summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJimmy Chen <jimmycmchen@google.com>2020-06-16 16:20:16 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-06-16 16:20:16 +0000
commitf8af7fe1c4144329221566da6b13ee6ab555c10c (patch)
treeaac28bb802b4424e869e7acce5893b9e61be61ae
parente3706635b367d49b72c29317879a4e017de97ca1 (diff)
parent6be9a8a97fe8d6451ff277220034f6615a1dbc81 (diff)
Merge "p2p: trigger tethering flow before entering GroupStartedState" into rvc-dev
-rw-r--r--service/Android.bp1
-rw-r--r--service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java162
-rw-r--r--tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java78
3 files changed, 218 insertions, 23 deletions
diff --git a/service/Android.bp b/service/Android.bp
index 5becbe21d..71cf728de 100644
--- a/service/Android.bp
+++ b/service/Android.bp
@@ -63,6 +63,7 @@ java_library {
// compile time
"framework-wifi-pre-jarjar",
"framework-statsd.stubs.module_lib",
+ "framework-tethering.stubs.module_lib",
"unsupportedappusage",
],
diff --git a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
index b65ac643a..56cdba83d 100644
--- a/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
+++ b/service/java/com/android/server/wifi/p2p/WifiP2pServiceImpl.java
@@ -28,6 +28,7 @@ import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
@@ -38,6 +39,7 @@ import android.net.InetAddresses;
import android.net.LinkProperties;
import android.net.NetworkInfo;
import android.net.NetworkStack;
+import android.net.TetheringManager;
import android.net.ip.IIpClient;
import android.net.ip.IpClientCallbacks;
import android.net.ip.IpClientUtil;
@@ -101,10 +103,14 @@ import com.android.wifi.resources.R;
import java.io.FileDescriptor;
import java.io.PrintWriter;
+import java.net.Inet4Address;
import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -221,6 +227,8 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
private static final int IPC_PROVISIONING_SUCCESS = BASE + 33;
private static final int IPC_PROVISIONING_FAILURE = BASE + 34;
+ private static final int GROUP_OWNER_TETHER_READY = BASE + 35;
+
public static final int ENABLED = 1;
public static final int DISABLED = 0;
@@ -264,10 +272,6 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
// clients(application) channel list
private Map<IBinder, Messenger> mClientChannelList = new HashMap<IBinder, Messenger>();
- // Is chosen as a unique address to avoid conflict with
- // the ranges defined in Tethering.java
- private static final String SERVER_ADDRESS = "192.168.49.1";
-
// The empty device address set by wpa_supplicant.
private static final String EMPTY_DEVICE_ADDRESS = "00:00:00:00:00:00";
@@ -855,6 +859,22 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
}
}
}, new IntentFilter(LocationManager.MODE_CHANGED_ACTION));
+ // Register for tethering state
+ mContext.registerReceiver(new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (mGroup == null) return;
+ if (!mGroup.isGroupOwner()) return;
+ if (TextUtils.isEmpty(mGroup.getInterface())) return;
+
+ final ArrayList<String> interfaces = intent.getStringArrayListExtra(
+ TetheringManager.EXTRA_ACTIVE_LOCAL_ONLY);
+
+ if (interfaces.contains(mGroup.getInterface())) {
+ sendMessage(GROUP_OWNER_TETHER_READY);
+ }
+ }
+ }, new IntentFilter(TetheringManager.ACTION_TETHER_STATE_CHANGED));
// Register for interface availability from HalDeviceManager
mWifiNative.registerInterfaceAvailableListener((boolean isAvailable) -> {
mIsHalInterfaceAvailable = isAvailable;
@@ -1122,6 +1142,7 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
case IPC_DHCP_RESULTS:
case IPC_PROVISIONING_SUCCESS:
case IPC_PROVISIONING_FAILURE:
+ case GROUP_OWNER_TETHER_READY:
case WifiP2pMonitor.P2P_PROV_DISC_FAILURE_EVENT:
case SET_MIRACAST_MODE:
case WifiP2pManager.START_LISTEN:
@@ -2407,27 +2428,46 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
// {@link com.android.server.connectivity.Tethering} listens to
// {@link WifiP2pManager#WIFI_P2P_CONNECTION_CHANGED_ACTION}
// events and takes over the DHCP server management automatically.
- } else {
- mWifiNative.setP2pGroupIdle(mGroup.getInterface(), GROUP_IDLE_TIME_S);
- startIpClient(mGroup.getInterface(), getHandler());
- WifiP2pDevice groupOwner = mGroup.getOwner();
- WifiP2pDevice peer = mPeers.get(groupOwner.deviceAddress);
- if (peer != null) {
- // update group owner details with peer details found at discovery
- groupOwner.updateSupplicantDetails(peer);
- mPeers.updateStatus(groupOwner.deviceAddress,
- WifiP2pDevice.CONNECTED);
- sendPeersChangedBroadcast();
+ // Because tethering service introduces random IP range, P2P could not
+ // hard-coded group owner IP and needs to wait for tethering completion.
+ // As a result, P2P sends a unicast intent to tether service to trigger
+ // the whole flow before entering GroupCreatedState.
+ setWifiP2pInfoOnGroupFormation(null);
+ String tetheringServicePackage = findTetheringServicePackage();
+ if (!TextUtils.isEmpty(tetheringServicePackage)) {
+ sendP2pTetherRequestBroadcast(tetheringServicePackage);
} else {
- // A supplicant bug can lead to reporting an invalid
- // group owner address (all zeroes) at times. Avoid a
- // crash, but continue group creation since it is not
- // essential.
- logw("Unknown group owner " + groupOwner);
+ loge("No valid tethering service, remove " + mGroup);
+ mWifiNative.p2pGroupRemove(mGroup.getInterface());
}
+ break;
+ }
+
+ mWifiNative.setP2pGroupIdle(mGroup.getInterface(), GROUP_IDLE_TIME_S);
+ startIpClient(mGroup.getInterface(), getHandler());
+ WifiP2pDevice groupOwner = mGroup.getOwner();
+ WifiP2pDevice peer = mPeers.get(groupOwner.deviceAddress);
+ if (peer != null) {
+ // update group owner details with peer details found at discovery
+ groupOwner.updateSupplicantDetails(peer);
+ mPeers.updateStatus(groupOwner.deviceAddress,
+ WifiP2pDevice.CONNECTED);
+ sendPeersChangedBroadcast();
+ } else {
+ // A supplicant bug can lead to reporting an invalid
+ // group owner address (all zeroes) at times. Avoid a
+ // crash, but continue group creation since it is not
+ // essential.
+ logw("Unknown group owner " + groupOwner);
}
transitionTo(mGroupCreatedState);
break;
+ case GROUP_OWNER_TETHER_READY:
+ if (mGroup != null && mGroup.isGroupOwner()) {
+ Log.d(TAG, "tether " + mGroup.getInterface() + " ready");
+ transitionTo(mGroupCreatedState);
+ }
+ break;
case WifiP2pMonitor.P2P_GO_NEGOTIATION_FAILURE_EVENT:
P2pStatus status = (P2pStatus) message.obj;
if (status == P2pStatus.NO_COMMON_CHANNEL) {
@@ -2491,6 +2531,15 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
transitionTo(mInactiveState);
}
break;
+ case WifiP2pMonitor.AP_STA_CONNECTED_EVENT:
+ case WifiP2pMonitor.AP_STA_DISCONNECTED_EVENT:
+ // Group owner needs to wait for tethering completion before
+ // moving to GroupCreatedState. If native layer reports STA event
+ // earlier, defer it.
+ if (mGroup != null && mGroup.isGroupOwner()) {
+ deferMessage(message);
+ break;
+ }
default:
return NOT_HANDLED;
}
@@ -2606,7 +2655,14 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
// DHCP server has already been started if I am a group owner
if (mGroup.isGroupOwner()) {
- setWifiP2pInfoOnGroupFormation(SERVER_ADDRESS);
+ Inet4Address addr = getInterfaceAddress(mGroup.getInterface());
+ if (addr != null) {
+ setWifiP2pInfoOnGroupFormation(addr.getHostAddress());
+ Log.d(TAG, "Group owner address: " + addr.getHostAddress()
+ + " at " + mGroup.getInterface());
+ } else {
+ mWifiNative.p2pGroupRemove(mGroup.getInterface());
+ }
}
// In case of a negotiation group, connection changed is sent
@@ -3065,6 +3121,49 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
}
}
+ private boolean isPackageExisted(String pkgName) {
+ PackageManager pm = mContext.getPackageManager();
+ try {
+ PackageInfo info = pm.getPackageInfo(pkgName, PackageManager.GET_META_DATA);
+ } catch (PackageManager.NameNotFoundException e) {
+ return false;
+ }
+ return true;
+ }
+
+ private String findTetheringServicePackage() {
+ ArrayList<String> possiblePackageNames = new ArrayList<>();
+ // AOSP
+ possiblePackageNames.add("com.android.networkstack.tethering");
+ // mainline release
+ possiblePackageNames.add("com.google.android.networkstack.tethering");
+ // Android Go
+ possiblePackageNames.add("com.android.networkstack.tethering.inprocess");
+
+ for (String pkgName: possiblePackageNames) {
+ if (isPackageExisted(pkgName)) {
+ Log.d(TAG, "Tethering service package: " + pkgName);
+ return pkgName;
+ }
+ }
+ Log.w(TAG, "Cannot find tethering service package!");
+ return null;
+ }
+
+ private void sendP2pTetherRequestBroadcast(String tetheringServicePackage) {
+ if (mVerboseLoggingEnabled) logd("sending p2p tether request broadcast");
+
+ Intent intent = new Intent(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION);
+ intent.setPackage(tetheringServicePackage);
+ intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
+ | Intent.FLAG_RECEIVER_REPLACE_PENDING);
+ intent.putExtra(WifiP2pManager.EXTRA_WIFI_P2P_INFO, new WifiP2pInfo(mWifiP2pInfo));
+ intent.putExtra(WifiP2pManager.EXTRA_NETWORK_INFO, makeNetworkInfo());
+ intent.putExtra(WifiP2pManager.EXTRA_WIFI_P2P_GROUP, eraseOwnDeviceAddress(mGroup));
+
+ sendBroadcastMultiplePermissions(intent);
+ }
+
private void sendP2pPersistentGroupsChangedBroadcast() {
if (mVerboseLoggingEnabled) logd("sending p2p persistent groups changed broadcast");
Intent intent = new Intent(WifiP2pManager.ACTION_WIFI_P2P_PERSISTENT_GROUPS_CHANGED);
@@ -3589,6 +3688,27 @@ public class WifiP2pServiceImpl extends IWifiP2pManager.Stub {
return true;
}
+ private Inet4Address getInterfaceAddress(String interfaceName) {
+ NetworkInterface iface;
+ try {
+ iface = NetworkInterface.getByName(interfaceName);
+ } catch (SocketException ex) {
+ Log.w(TAG, "Could not obtain address of network interface "
+ + interfaceName, ex);
+ return null;
+ }
+ Enumeration<InetAddress> addrs = iface.getInetAddresses();
+ while (addrs.hasMoreElements()) {
+ InetAddress addr = addrs.nextElement();
+ if (addr instanceof Inet4Address) {
+ return (Inet4Address) addr;
+ }
+ }
+ Log.w(TAG, "Could not obtain address of network interface "
+ + interfaceName + " because it had no IPv4 addresses.");
+ return null;
+ }
+
private void setWifiP2pInfoOnGroupFormation(String serverAddress) {
InetAddress serverInetAddress = serverAddress == null
? null
diff --git a/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java
index 4aa2a2e42..cae812d58 100644
--- a/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/p2p/WifiP2pServiceImplTest.java
@@ -16,6 +16,7 @@
package com.android.server.wifi.p2p;
+import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession;
import static com.android.server.wifi.WifiSettingsConfigStore.WIFI_P2P_DEVICE_NAME;
import static com.android.server.wifi.WifiSettingsConfigStore.WIFI_P2P_PENDING_FACTORY_RESET;
import static com.android.server.wifi.WifiSettingsConfigStore.WIFI_VERBOSE_LOGGING_ENABLED;
@@ -35,6 +36,7 @@ import static org.mockito.Mockito.atLeastOnce;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.spy;
@@ -53,6 +55,7 @@ import android.content.res.Resources;
import android.location.LocationManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
+import android.net.TetheringManager;
import android.net.wifi.WifiManager;
import android.net.wifi.WpsInfo;
import android.net.wifi.p2p.WifiP2pConfig;
@@ -89,14 +92,22 @@ import com.android.server.wifi.util.WifiPermissionsUtil;
import com.android.server.wifi.util.WifiPermissionsWrapper;
import com.android.wifi.resources.R;
+import libcore.net.InetAddressUtils;
+
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import org.mockito.MockitoSession;
import org.mockito.Spy;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
/**
@@ -106,6 +117,7 @@ import java.util.List;
public class WifiP2pServiceImplTest extends WifiBaseTest {
private static final String TAG = "WifiP2pServiceImplTest";
private static final String IFACE_NAME_P2P = "mockP2p0";
+ private static final String P2P_GO_IP = "192.168.49.1";
private static final long STATE_CHANGE_WAITING_TIME = 1000;
private static final String thisDeviceMac = "11:22:33:44:55:66";
private static final String thisDeviceName = "thisDeviceName";
@@ -121,6 +133,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
private BroadcastReceiver mLocationModeReceiver;
private BroadcastReceiver mWifiStateChangedReceiver;
+ private BroadcastReceiver mTetherStateReceiver;
private Handler mClientHandler;
private Messenger mP2pStateMachineMessenger;
private Messenger mClientMessenger;
@@ -135,6 +148,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
private WifiP2pGroupList mGroups = new WifiP2pGroupList(null, null);
private WifiP2pDevice mTestThisDevice;
private ArgumentCaptor<Message> mMessageCaptor = ArgumentCaptor.forClass(Message.class);
+ private MockitoSession mStaticMockSession = null;
@Mock Context mContext;
@Mock FrameworkFacade mFrameworkFacade;
@@ -142,6 +156,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
@Mock NetdWrapper mNetdWrapper;
@Mock PackageManager mPackageManager;
@Mock Resources mResources;
+ @Mock NetworkInterface mP2pNetworkInterface;
@Mock WifiInjector mWifiInjector;
@Mock WifiManager mMockWifiManager;
@Mock WifiPermissionsUtil mWifiPermissionsUtil;
@@ -178,6 +193,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
mTestWifiP2pNewPersistentGoGroup.setNetworkName("DIRECT-xy-NEW");
mTestWifiP2pNewPersistentGoGroup.setOwner(new WifiP2pDevice(thisDeviceMac));
mTestWifiP2pNewPersistentGoGroup.setIsGroupOwner(true);
+ mTestWifiP2pNewPersistentGoGroup.setInterface(IFACE_NAME_P2P);
mGroups.clear();
WifiP2pGroup group1 = new WifiP2pGroup();
@@ -236,6 +252,26 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
}
/**
+ * Simulate tethering flow is completed
+ */
+ private void simulateTetherReady() {
+ ArrayList<String> availableList = new ArrayList<>();
+ ArrayList<String> localOnlyList = new ArrayList<>();
+ localOnlyList.add(IFACE_NAME_P2P);
+ ArrayList<String> tetherList = new ArrayList<>();
+ ArrayList<String> erroredList = new ArrayList<>();
+
+ Intent intent = new Intent(TetheringManager.ACTION_TETHER_STATE_CHANGED);
+ intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
+ intent.putStringArrayListExtra(TetheringManager.EXTRA_AVAILABLE_TETHER, availableList);
+ intent.putStringArrayListExtra(TetheringManager.EXTRA_ACTIVE_LOCAL_ONLY, localOnlyList);
+ intent.putStringArrayListExtra(TetheringManager.EXTRA_ACTIVE_TETHER, tetherList);
+ intent.putStringArrayListExtra(TetheringManager.EXTRA_ERRORED_TETHER, erroredList);
+ mTetherStateReceiver.onReceive(mContext, intent);
+ mLooper.dispatchAll();
+ }
+
+ /**
* Mock send WifiP2pManager.UPDATE_CHANNEL_INFO
*
* @param pkgName package name used for p2p channel init
@@ -699,7 +735,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
*
* @param supported defines the p2p is supported or not in this instance.
*/
- private void setUpWifiP2pServiceImpl(boolean supported) {
+ private void setUpWifiP2pServiceImpl(boolean supported) throws Exception {
reset(mContext, mFrameworkFacade, mHandlerThread, mPackageManager, mResources,
mWifiInjector, mWifiNative);
@@ -757,10 +793,15 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
mWifiP2pServiceImpl = new WifiP2pServiceImpl(mContext, mWifiInjector);
if (supported) {
- verify(mContext, times(2)).registerReceiver(mBcastRxCaptor.capture(),
+ // register these event:
+ // * WifiManager.WIFI_STATE_CHANGED_ACTION
+ // * LocationManager.MODE_CHANGED_ACTION
+ // * TetheringManager.ACTION_TETHER_STATE_CHANGED
+ verify(mContext, times(3)).registerReceiver(mBcastRxCaptor.capture(),
any(IntentFilter.class));
mWifiStateChangedReceiver = mBcastRxCaptor.getAllValues().get(0);
mLocationModeReceiver = mBcastRxCaptor.getAllValues().get(1);
+ mTetherStateReceiver = mBcastRxCaptor.getAllValues().get(2);
verify(mWifiNative).registerInterfaceAvailableListener(
mAvailListenerCaptor.capture(), any(Handler.class));
mAvailListenerCaptor.getValue().onAvailabilityChanged(true);
@@ -775,6 +816,17 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
+
+ mStaticMockSession = mockitoSession()
+ .mockStatic(NetworkInterface.class)
+ .startMocking();
+ lenient().when(NetworkInterface.getByName(eq(IFACE_NAME_P2P)))
+ .thenReturn(mP2pNetworkInterface);
+ ArrayList<InetAddress> p2pInetAddresses = new ArrayList<>();
+ p2pInetAddresses.add(InetAddressUtils.parseNumericAddress(P2P_GO_IP));
+ when(mP2pNetworkInterface.getInetAddresses())
+ .thenReturn(Collections.enumeration(p2pInetAddresses));
+
setUpWifiP2pServiceImpl(true);
mClient1 = new Binder();
mClient2 = new Binder();
@@ -782,6 +834,11 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
when(mContext.createContextAsUser(any(), anyInt())).thenReturn(mContext);
}
+ @After
+ public void cleanUp() throws Exception {
+ mStaticMockSession.finishMocking();
+ }
+
/**
* Mock enter Disabled state.
*/
@@ -1467,6 +1524,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
public void testRequestGroupInfoFailureWhenNoChannelUpdated() throws Exception {
forceP2pEnabled(mClient1);
sendGroupStartedMsg(mTestWifiP2pGroup);
+ simulateTetherReady();
sendRequestGroupInfoMsg(mClientMessenger);
verify(mClientHandler).sendMessage(mMessageCaptor.capture());
assertEquals(WifiP2pManager.RESPONSE_GROUP_INFO, mMessageCaptor.getValue().what);
@@ -1481,6 +1539,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
public void testRequestGroupInfoFailureWhenChannelUpdateWrongPkgName() throws Exception {
forceP2pEnabled(mClient1);
sendGroupStartedMsg(mTestWifiP2pGroup);
+ simulateTetherReady();
doThrow(new SecurityException("P2p unit test"))
.when(mWifiPermissionsUtil).checkPackage(anyInt(), anyString());
sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
@@ -1498,6 +1557,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
public void testRequestGroupInfoFailureWhenPermissionDenied() throws Exception {
forceP2pEnabled(mClient1);
sendGroupStartedMsg(mTestWifiP2pGroup);
+ simulateTetherReady();
doNothing().when(mWifiPermissionsUtil).checkPackage(anyInt(), anyString());
when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
anyBoolean())).thenReturn(false);
@@ -1519,6 +1579,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
mTestWifiP2pGroup.setOwner(mTestThisDevice);
forceP2pEnabled(mClient1);
sendGroupStartedMsg(mTestWifiP2pGroup);
+ simulateTetherReady();
when(mWifiPermissionsUtil.checkLocalMacAddressPermission(anyInt())).thenReturn(false);
when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
anyBoolean())).thenReturn(true);
@@ -1543,6 +1604,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
mTestWifiP2pGroup.setOwner(mTestThisDevice);
forceP2pEnabled(mClient1);
sendGroupStartedMsg(mTestWifiP2pGroup);
+ simulateTetherReady();
when(mWifiPermissionsUtil.checkLocalMacAddressPermission(anyInt())).thenReturn(true);
when(mWifiPermissionsUtil.checkCanAccessWifiDirect(anyString(), anyString(), anyInt(),
anyBoolean())).thenReturn(true);
@@ -1803,6 +1865,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
assertEquals(3, groupsCaptor.getValue().getGroupList().size());
sendGroupStartedMsg(mTestWifiP2pNewPersistentGoGroup);
+ simulateTetherReady();
verify(mWifiP2pMetrics, times(2)).updatePersistentGroup(groupsCaptor.capture());
// the captured object is the same object, just get the latest one is ok.
@@ -1839,6 +1902,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
sendChannelInfoUpdateMsg("testPkg1", "testFeature", mClient1, mClientMessenger);
sendGroupStartedMsg(mTestWifiP2pNewPersistentGoGroup);
+ simulateTetherReady();
ArgumentCaptor<WifiP2pGroup> groupCaptor =
ArgumentCaptor.forClass(WifiP2pGroup.class);
@@ -2041,7 +2105,9 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
group.setNetworkName("DIRECT-xy-NEW");
group.setOwner(new WifiP2pDevice("thisDeviceMac"));
group.setIsGroupOwner(true);
+ group.setInterface(IFACE_NAME_P2P);
sendGroupStartedMsg(group);
+ simulateTetherReady();
verify(mWifiP2pMetrics).endConnectionEvent(
eq(P2pConnectionEvent.CLF_NONE));
}
@@ -2353,6 +2419,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
group.setIsGroupOwner(true);
group.setInterface(IFACE_NAME_P2P);
sendGroupStartedMsg(group);
+ simulateTetherReady();
when(mWifiNative.p2pGroupRemove(eq(IFACE_NAME_P2P))).thenReturn(true);
sendSimpleMsg(mClientMessenger, WifiP2pManager.REMOVE_GROUP);
@@ -2376,6 +2443,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
group.setIsGroupOwner(true);
group.setInterface(IFACE_NAME_P2P);
sendGroupStartedMsg(group);
+ simulateTetherReady();
when(mWifiNative.p2pGroupRemove(eq(IFACE_NAME_P2P))).thenReturn(false);
sendSimpleMsg(mClientMessenger, WifiP2pManager.REMOVE_GROUP);
@@ -2529,6 +2597,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
group.setIsGroupOwner(true);
group.setInterface(IFACE_NAME_P2P);
sendGroupStartedMsg(group);
+ simulateTetherReady();
when(mWifiNative.startWpsPbc(anyString(), any())).thenReturn(true);
WpsInfo wps = new WpsInfo();
@@ -2562,6 +2631,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
group.setIsGroupOwner(true);
group.setInterface(IFACE_NAME_P2P);
sendGroupStartedMsg(group);
+ simulateTetherReady();
when(mWifiNative.startWpsPinKeypad(anyString(), anyString())).thenReturn(true);
WpsInfo wps = new WpsInfo();
@@ -2588,6 +2658,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
group.setIsGroupOwner(true);
group.setInterface(IFACE_NAME_P2P);
sendGroupStartedMsg(group);
+ simulateTetherReady();
WpsInfo wps = null;
sendStartWpsMsg(mClientMessenger, wps);
@@ -2611,6 +2682,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
group.setIsGroupOwner(true);
group.setInterface(IFACE_NAME_P2P);
sendGroupStartedMsg(group);
+ simulateTetherReady();
when(mWifiNative.startWpsPbc(anyString(), any())).thenReturn(false);
WpsInfo wps = new WpsInfo();
wps.setup = WpsInfo.PBC;
@@ -2636,6 +2708,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
group.setIsGroupOwner(true);
group.setInterface(IFACE_NAME_P2P);
sendGroupStartedMsg(group);
+ simulateTetherReady();
when(mWifiNative.startWpsPinDisplay(anyString(), any())).thenReturn("abcd");
WpsInfo wps = new WpsInfo();
@@ -2662,6 +2735,7 @@ public class WifiP2pServiceImplTest extends WifiBaseTest {
group.setIsGroupOwner(true);
group.setInterface(IFACE_NAME_P2P);
sendGroupStartedMsg(group);
+ simulateTetherReady();
when(mWifiNative.startWpsPinKeypad(anyString(), anyString())).thenReturn(false);
WpsInfo wps = new WpsInfo();