diff options
author | Tony Mak <tonymak@google.com> | 2017-08-03 12:20:42 +0100 |
---|---|---|
committer | Tony Mak <tonymak@google.com> | 2017-08-03 13:52:02 +0100 |
commit | d79fe7b2896c389d9304919763066a49913219db (patch) | |
tree | c90d618e3fcaf8a2b96a3d0852e70de86d11c001 /tests | |
parent | 184f668983529067537f6265f53700ad6120ecab (diff) |
Fix various issues of getConnectionInfo
1. We should pass through the "op package name" instead of
resolving the UID to package name.
2. ActivityManager.getCurrentUser() requires INTERACT_ACROSS_USER
permission, clearing calling identity before calling it..
Bug: 64245163
Test: Verify QR provisioning is now possible
Test: runtest -x frameworks/opt/net/wifi/tests/
Test: runtest -x runtest -x cts/tests/tests/net/src/android/net/wifi/cts/WifiInfoTest.java
Change-Id: Id4dd9e7b38120e7b5867b71472a5aa24c288a47e
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java index 7d9f6e655..3547b763d 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java @@ -140,6 +140,7 @@ public class WifiStateMachineTest { private static final int WPS_SUPPLICANT_NETWORK_ID = 5; private static final int WPS_FRAMEWORK_NETWORK_ID = 10; private static final String DEFAULT_TEST_SSID = "\"GoogleGuest\""; + private static final String OP_PACKAGE_NAME = "com.xxx"; private long mBinderToken; @@ -228,6 +229,8 @@ public class WifiStateMachineTest { when(context.getSystemService(Context.CONNECTIVITY_SERVICE)).thenReturn( mock(ConnectivityManager.class)); + when(context.getOpPackageName()).thenReturn(OP_PACKAGE_NAME); + return context; } @@ -1792,7 +1795,7 @@ public class WifiStateMachineTest { /** * Test that the process uid has full wifiInfo access. - * Also tests that {@link WifiStateMachine#syncRequestConnectionInfo()} always + * Also tests that {@link WifiStateMachine#syncRequestConnectionInfo(String)} always * returns a copy of WifiInfo. */ @Test @@ -1803,7 +1806,7 @@ public class WifiStateMachineTest { wifiInfo.setSSID(WifiSsid.createFromAsciiEncoded(sSSID)); connect(); - WifiInfo connectionInfo = mWsm.syncRequestConnectionInfo(); + WifiInfo connectionInfo = mWsm.syncRequestConnectionInfo(mContext.getOpPackageName()); assertNotEquals(wifiInfo, connectionInfo); assertEquals(wifiInfo.getSSID(), connectionInfo.getSSID()); @@ -1813,7 +1816,7 @@ public class WifiStateMachineTest { /** * Test that connected SSID and BSSID are not exposed to an app that does not have the * appropriate permissions. - * Also tests that {@link WifiStateMachine#syncRequestConnectionInfo()} always + * Also tests that {@link WifiStateMachine#syncRequestConnectionInfo(String)} always * returns a copy of WifiInfo. */ @Test @@ -1833,7 +1836,7 @@ public class WifiStateMachineTest { when(mWifiPermissionsUtil.canAccessScanResults(anyString(), eq(fakeUid), anyInt())) .thenReturn(false); - WifiInfo connectionInfo = mWsm.syncRequestConnectionInfo(); + WifiInfo connectionInfo = mWsm.syncRequestConnectionInfo(mContext.getOpPackageName()); assertNotEquals(wifiInfo, connectionInfo); assertEquals(WifiSsid.NONE, connectionInfo.getSSID()); @@ -1846,7 +1849,7 @@ public class WifiStateMachineTest { /** * Test that connected SSID and BSSID are not exposed to an app that does not have the * appropriate permissions, when canAccessScanResults raises a SecurityException. - * Also tests that {@link WifiStateMachine#syncRequestConnectionInfo()} always + * Also tests that {@link WifiStateMachine#syncRequestConnectionInfo(String)} always * returns a copy of WifiInfo. */ @Test @@ -1866,7 +1869,7 @@ public class WifiStateMachineTest { when(mWifiPermissionsUtil.canAccessScanResults(anyString(), eq(fakeUid), anyInt())) .thenThrow(new SecurityException()); - WifiInfo connectionInfo = mWsm.syncRequestConnectionInfo(); + WifiInfo connectionInfo = mWsm.syncRequestConnectionInfo(mContext.getOpPackageName()); assertNotEquals(wifiInfo, connectionInfo); assertEquals(WifiSsid.NONE, connectionInfo.getSSID()); @@ -1896,7 +1899,7 @@ public class WifiStateMachineTest { when(mWifiPermissionsUtil.canAccessScanResults(anyString(), eq(fakeUid), anyInt())) .thenReturn(true); - WifiInfo connectionInfo = mWsm.syncRequestConnectionInfo(); + WifiInfo connectionInfo = mWsm.syncRequestConnectionInfo(mContext.getOpPackageName()); assertNotEquals(wifiInfo, connectionInfo); assertEquals(wifiInfo.getSSID(), connectionInfo.getSSID()); |