summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2017-10-04 07:27:23 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2017-10-04 07:27:23 +0000
commit7db8888d6dcf9971ca83b6c1984d528cdc9a50e3 (patch)
tree534172de6369318b441002f388419bb0017ff51c
parentc6cfddcea894b34b54b07baa8caee1a608d6ecaa (diff)
parent988256f6c383c2c6b24d295c2f2e7ce77ec9955f (diff)
downloadandroid_frameworks_opt_net_wifi-7db8888d6dcf9971ca83b6c1984d528cdc9a50e3.tar.gz
android_frameworks_opt_net_wifi-7db8888d6dcf9971ca83b6c1984d528cdc9a50e3.tar.bz2
android_frameworks_opt_net_wifi-7db8888d6dcf9971ca83b6c1984d528cdc9a50e3.zip
Snap for 4376088 from 988256f6c383c2c6b24d295c2f2e7ce77ec9955f to oc-mr1-release
Change-Id: I69ffda90e6be4e715c156c6b9767f7b95e69ddad
-rw-r--r--service/java/com/android/server/wifi/WifiConfigManager.java11
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java45
2 files changed, 53 insertions, 3 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java
index 06b53be85..02f8302f9 100644
--- a/service/java/com/android/server/wifi/WifiConfigManager.java
+++ b/service/java/com/android/server/wifi/WifiConfigManager.java
@@ -2572,10 +2572,12 @@ public class WifiConfigManager {
* @param userId The identifier of the user that stopped.
*/
public void handleUserStop(int userId) {
+ if (mVerboseLoggingEnabled) {
+ Log.v(TAG, "Handling user stop for " + userId);
+ }
if (userId == mCurrentUserId && mUserManager.isUserUnlockingOrUnlocked(mCurrentUserId)) {
saveToStore(true);
- clearInternalData();
- mCurrentUserId = UserHandle.USER_SYSTEM;
+ clearInternalUserData(mCurrentUserId);
}
}
@@ -2587,6 +2589,7 @@ public class WifiConfigManager {
* - List of deleted ephemeral networks.
*/
private void clearInternalData() {
+ localLog("clearInternalData: Clearing all internal data");
mConfiguredNetworks.clear();
mDeletedEphemeralSSIDs.clear();
mScanDetailCaches.clear();
@@ -2605,12 +2608,16 @@ public class WifiConfigManager {
* removed from memory.
*/
private Set<Integer> clearInternalUserData(int userId) {
+ localLog("clearInternalUserData: Clearing user internal data for " + userId);
Set<Integer> removedNetworkIds = new HashSet<>();
// Remove any private networks of the old user before switching the userId.
for (WifiConfiguration config : getInternalConfiguredNetworks()) {
if (!config.shared && WifiConfigurationUtil.doesUidBelongToAnyProfile(
config.creatorUid, mUserManager.getProfiles(userId))) {
removedNetworkIds.add(config.networkId);
+ localLog("clearInternalUserData: removed config."
+ + " netId=" + config.networkId
+ + " configKey=" + config.configKey());
mConfiguredNetworks.remove(config.networkId);
}
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
index 7ce53629b..0fa660081 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
@@ -2406,7 +2406,7 @@ public class WifiConfigManagerTest {
}
/**
- * Verifies that the foreground user stop using {@link WifiConfigManager#handleUserStop(int)}
+ * Verifies that the user stop handling using {@link WifiConfigManager#handleUserStop(int)}
* and ensures that the store is written only when the foreground user is stopped.
*/
@Test
@@ -2429,6 +2429,49 @@ public class WifiConfigManagerTest {
}
/**
+ * Verifies that the user stop handling using {@link WifiConfigManager#handleUserStop(int)}
+ * and ensures that the shared data is not lost when the foreground user is stopped.
+ */
+ @Test
+ public void testHandleUserStopDoesNotClearSharedData() throws Exception {
+ int user1 = TEST_DEFAULT_USER;
+
+ //
+ // Setup the database for the user before initiating stop.
+ //
+ int appId = 674;
+ // Create 2 networks. 1 for user1, and 1 shared.
+ final WifiConfiguration user1Network = WifiConfigurationTestUtil.createPskNetwork();
+ user1Network.shared = false;
+ user1Network.creatorUid = UserHandle.getUid(user1, appId);
+ final WifiConfiguration sharedNetwork = WifiConfigurationTestUtil.createPskNetwork();
+
+ // Set up the store data that is loaded initially.
+ List<WifiConfiguration> sharedNetworks = new ArrayList<WifiConfiguration>() {
+ {
+ add(sharedNetwork);
+ }
+ };
+ List<WifiConfiguration> user1Networks = new ArrayList<WifiConfiguration>() {
+ {
+ add(user1Network);
+ }
+ };
+ setupStoreDataForRead(sharedNetworks, user1Networks, new HashSet<String>());
+ assertTrue(mWifiConfigManager.loadFromStore());
+ verify(mWifiConfigStore).read();
+
+ // Ensure that we have 2 networks in the database before the stop.
+ assertEquals(2, mWifiConfigManager.getConfiguredNetworks().size());
+
+ mWifiConfigManager.handleUserStop(user1);
+
+ // Ensure that we only have 1 shared network in the database after the stop.
+ assertEquals(1, mWifiConfigManager.getConfiguredNetworks().size());
+ assertEquals(sharedNetwork.SSID, mWifiConfigManager.getConfiguredNetworks().get(0).SSID);
+ }
+
+ /**
* Verifies the foreground user unlock via {@link WifiConfigManager#handleUserUnlock(int)}
* results in a store read after bootup.
*/