summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2017-08-01 17:08:40 -0700
committerRoshan Pius <rpius@google.com>2017-08-02 10:49:03 -0700
commita49af7fd6bf5d51ef7c34fbf2d71ee10c0f7d1dd (patch)
treeac89cfdf107cc507e032f1e016c61fb1ebda7df2 /tests
parentb1d6ef28f4a40b4b7384859b52b176d55f7d4bae (diff)
WifiStateMachine: Always return a copy of WifiInfo
WifiStateMachine#syncRequestConnectionInfo() should always return a copy of WifiInfo to prevent external services directly accessing a local variable in WifiStateMachine. Binder calls within the same process doesn't parcel objects, hence this is needed to prevent other threads in system_server directly using a local object within the wifi service. Bug: 64207440 Test: Unit test that checks for object returned from WifiStateMachine#getWifiInfo() vs WifiStateMachine#syncRequestConnectionInfo(). Change-Id: I3d709a09d3d10a1d133fd79eeee430830eb008b2
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java16
1 files changed, 14 insertions, 2 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
index 631ec3f4c..7d9f6e655 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
@@ -1791,20 +1791,30 @@ public class WifiStateMachineTest {
}
/**
- * Test that the process uid has full wifiInfo access
+ * Test that the process uid has full wifiInfo access.
+ * Also tests that {@link WifiStateMachine#syncRequestConnectionInfo()} always
+ * returns a copy of WifiInfo.
*/
@Test
public void testConnectedIdsAreVisibleFromOwnUid() throws Exception {
assertEquals(Process.myUid(), Binder.getCallingUid());
WifiInfo wifiInfo = mWsm.getWifiInfo();
+ wifiInfo.setBSSID(sBSSID);
+ wifiInfo.setSSID(WifiSsid.createFromAsciiEncoded(sSSID));
+
connect();
WifiInfo connectionInfo = mWsm.syncRequestConnectionInfo();
- assertEquals(wifiInfo, connectionInfo);
+
+ assertNotEquals(wifiInfo, connectionInfo);
+ assertEquals(wifiInfo.getSSID(), connectionInfo.getSSID());
+ assertEquals(wifiInfo.getBSSID(), connectionInfo.getBSSID());
}
/**
* 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
+ * returns a copy of WifiInfo.
*/
@Test
public void testConnectedIdsAreHiddenFromRandomApp() throws Exception {
@@ -1836,6 +1846,8 @@ 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
+ * returns a copy of WifiInfo.
*/
@Test
public void testConnectedIdsAreHiddenOnSecurityException() throws Exception {