use of android.net.wifi.p2p.WifiP2pGroup in project android_packages_apps_Settings by omnirom.
the class WifiP2pSettingsTest method persistentController_withOneGroup_shouldBeAvailable.
@Test
public void persistentController_withOneGroup_shouldBeAvailable() {
final String fakeGroupName = new String("fakeGroupName");
doReturn(fakeGroupName).when(mWifiP2pGroup).getNetworkName();
final List<WifiP2pGroup> groupList = new ArrayList<>();
groupList.add(mWifiP2pGroup);
final WifiP2pGroupList wifiP2pGroupList = mock(WifiP2pGroupList.class);
doReturn(groupList).when(wifiP2pGroupList).getGroupList();
final Bundle bundle = new Bundle();
bundle.putString(WifiP2pSettings.SAVE_SELECTED_GROUP, fakeGroupName);
mFragment.onActivityCreated(bundle);
mFragment.onPersistentGroupInfoAvailable(wifiP2pGroupList);
assertThat(mFragment.mPersistentCategoryController.isAvailable()).isTrue();
}
use of android.net.wifi.p2p.WifiP2pGroup in project android_packages_apps_Settings by DirtyUnicorns.
the class WifiP2pSettings method onPersistentGroupInfoAvailable.
@Override
public void onPersistentGroupInfoAvailable(WifiP2pGroupList groups) {
mPersistentCategoryController.removeAllChildren();
for (WifiP2pGroup group : groups.getGroupList()) {
if (DBG)
Log.d(TAG, " group " + group);
WifiP2pPersistentGroup wppg = new WifiP2pPersistentGroup(getPrefContext(), group);
mPersistentCategoryController.addChild(wppg);
if (wppg.getGroupName().equals(mSelectedGroupName)) {
if (DBG)
Log.d(TAG, "Selecting group " + wppg.getGroupName());
mSelectedGroup = wppg;
mSelectedGroupName = null;
}
}
if (mSelectedGroupName != null) {
// Looks like there's a dialog pending getting user confirmation to delete the
// selected group. When user hits OK on that dialog, we won't do anything; but we
// shouldn't be in this situation in first place, because these groups are persistent
// groups and they shouldn't just get deleted!
Log.w(TAG, " Selected group " + mSelectedGroupName + " disappered on next query ");
}
}
use of android.net.wifi.p2p.WifiP2pGroup in project android_packages_apps_Settings by crdroidandroid.
the class WifiP2pSettings method onPersistentGroupInfoAvailable.
@Override
public void onPersistentGroupInfoAvailable(WifiP2pGroupList groups) {
mPersistentCategoryController.removeAllChildren();
for (WifiP2pGroup group : groups.getGroupList()) {
if (DBG)
Log.d(TAG, " group " + group);
WifiP2pPersistentGroup wppg = new WifiP2pPersistentGroup(getPrefContext(), group);
mPersistentCategoryController.addChild(wppg);
if (wppg.getGroupName().equals(mSelectedGroupName)) {
if (DBG)
Log.d(TAG, "Selecting group " + wppg.getGroupName());
mSelectedGroup = wppg;
mSelectedGroupName = null;
}
}
if (mSelectedGroupName != null) {
// Looks like there's a dialog pending getting user confirmation to delete the
// selected group. When user hits OK on that dialog, we won't do anything; but we
// shouldn't be in this situation in first place, because these groups are persistent
// groups and they shouldn't just get deleted!
Log.w(TAG, " Selected group " + mSelectedGroupName + " disappered on next query ");
}
}
use of android.net.wifi.p2p.WifiP2pGroup in project physical-web by google.
the class WifiDirectConnect method connect.
public void connect(UrlDevice urlDevice, String title) {
String progressTitle = mContext.getString(R.string.page_loading_title) + " " + title;
mProgress = new ProgressDialog(mContext);
mProgress.setCancelable(true);
mProgress.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
Log.i(TAG, "Dialog box canceled");
mDevice = null;
mManager.cancelConnect(mChannel, new ActionListener() {
@Override
public void onSuccess() {
Log.d(TAG, "cancel connect call success");
}
@Override
public void onFailure(int reason) {
Log.d(TAG, "cancel connect call fail " + reason);
}
});
}
});
mProgress.setTitle(progressTitle);
mProgress.setMessage(mContext.getString(R.string.page_loading_message));
mProgress.show();
mDevice = urlDevice;
WifiP2pConfig config = new WifiP2pConfig();
config.deviceAddress = Utils.getWifiAddress(mDevice);
config.groupOwnerIntent = 0;
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION);
mContext.registerReceiver(mReceiver, intentFilter);
mManager.requestGroupInfo(mChannel, new WifiP2pManager.GroupInfoListener() {
public void onGroupInfoAvailable(final WifiP2pGroup group) {
if (group != null) {
Log.d(TAG, "group not null");
if (group.getOwner().deviceAddress.equals(Utils.getWifiAddress(mDevice))) {
Log.i(TAG, "Already connected");
mManager.requestConnectionInfo(mChannel, new WifiP2pManager.ConnectionInfoListener() {
public void onConnectionInfoAvailable(final WifiP2pInfo info) {
if (mDevice != null && info.groupOwnerAddress != null) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("http:/" + info.groupOwnerAddress + ":" + Integer.toString(Utils.getWifiPort(mDevice))));
mContext.startActivity(intent);
}
}
});
} else {
mManager.removeGroup(mChannel, new ActionListener() {
@Override
public void onSuccess() {
Log.d(TAG, "remove call success");
connectHelper(true, config);
}
@Override
public void onFailure(int reason) {
Log.d(TAG, "remove call fail " + reason);
}
});
}
} else {
Log.d(TAG, "group null");
connectHelper(true, config);
}
}
});
}
use of android.net.wifi.p2p.WifiP2pGroup in project platform_packages_apps_Settings by BlissRoms.
the class WifiP2pSettings method onPersistentGroupInfoAvailable.
@Override
public void onPersistentGroupInfoAvailable(WifiP2pGroupList groups) {
mPersistentCategoryController.removeAllChildren();
for (WifiP2pGroup group : groups.getGroupList()) {
if (DBG)
Log.d(TAG, " group " + group);
WifiP2pPersistentGroup wppg = new WifiP2pPersistentGroup(getPrefContext(), group);
mPersistentCategoryController.addChild(wppg);
if (wppg.getGroupName().equals(mSelectedGroupName)) {
if (DBG)
Log.d(TAG, "Selecting group " + wppg.getGroupName());
mSelectedGroup = wppg;
mSelectedGroupName = null;
}
}
if (mSelectedGroupName != null) {
// Looks like there's a dialog pending getting user confirmation to delete the
// selected group. When user hits OK on that dialog, we won't do anything; but we
// shouldn't be in this situation in first place, because these groups are persistent
// groups and they shouldn't just get deleted!
Log.w(TAG, " Selected group " + mSelectedGroupName + " disappered on next query ");
}
}
Aggregations