diff options
author | Roshan Pius <rpius@google.com> | 2017-08-01 17:08:40 -0700 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2017-08-02 17:08:33 +0000 |
commit | 806de232ff2a295ef27ff4450e4bdf5e989528bd (patch) | |
tree | 3ce55ac70d3e16c771e5b329d346d980701a03ef /tests | |
parent | 29702d5f6bf0b83837778377f765d393bdfcf5c1 (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
Merged-In: I3d709a09d3d10a1d133fd79eeee430830eb008b2
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java index 427d700b1..4dd0621bd 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java @@ -2141,4 +2141,20 @@ public class WifiStateMachineTest { currentConfig.networkId = lastSelectedNetworkId - 1; assertFalse(mWsm.shouldEvaluateWhetherToSendExplicitlySelected(currentConfig)); } + + /** + * Test that {@link WifiStateMachine#syncRequestConnectionInfo()} always returns a copy of + * WifiInfo. + */ + @Test + public void testSyncRequestConnectionInfoDoesNotReturnLocalReference() { + WifiInfo wifiInfo = mWsm.getWifiInfo(); + wifiInfo.setBSSID(sBSSID); + wifiInfo.setSSID(WifiSsid.createFromAsciiEncoded(sSSID)); + + WifiInfo syncWifiInfo = mWsm.syncRequestConnectionInfo(); + assertEquals(wifiInfo.getSSID(), syncWifiInfo.getSSID()); + assertEquals(wifiInfo.getBSSID(), syncWifiInfo.getBSSID()); + assertFalse(wifiInfo == syncWifiInfo); + } } |