diff options
author | Roshan Pius <rpius@google.com> | 2016-12-15 08:50:45 -0800 |
---|---|---|
committer | Roshan Pius <rpius@google.com> | 2016-12-15 09:32:04 -0800 |
commit | 1a2b2242a2f30e0ad6dfa1d43265a15059db2a8a (patch) | |
tree | 93a293992de4fb4d813768b26df326c784e8a444 /service | |
parent | 2c42f1c08ec37e0cb9d5ebbc66584dc294d4bf42 (diff) |
WifiConfigStore: Start with no user store
Since the user store file is not accessible at bootup, start
WifiConfigStore with no user store file instance. When the user
eventually logs in, WifiConfigManager will invoke
|switchUserStoreAndRead| to set the user store.
Note: WifiConfigStoreData already handles the user/shared store
data being null.
Bug: 33659400
Test: Added unit test, modified couple of existing ones.
Test: Device boots up fine auto-connects to one of the saved networks.
Change-Id: I8c3c48211ec3bd5be734568cd3cbc20fde1a1f48
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiConfigStore.java | 26 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiInjector.java | 3 |
2 files changed, 17 insertions, 12 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigStore.java b/service/java/com/android/server/wifi/WifiConfigStore.java index af469f10c..1eea9d5ca 100644 --- a/service/java/com/android/server/wifi/WifiConfigStore.java +++ b/service/java/com/android/server/wifi/WifiConfigStore.java @@ -113,11 +113,9 @@ public class WifiConfigStore { * @param clock clock instance to retrieve timestamps for alarms. * @param sharedStore StoreFile instance pointing to the shared store file. This should * be retrieved using {@link #createSharedFile()} method. - * @param userStore StoreFile instance pointing to the user specific store file. This should - * be retrieved using {@link #createUserFile(int)} method. */ public WifiConfigStore(Context context, Looper looper, Clock clock, - StoreFile sharedStore, StoreFile userStore) { + StoreFile sharedStore) { mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); mEventHandler = new Handler(looper); @@ -125,7 +123,9 @@ public class WifiConfigStore { // Initialize the store files. mSharedStore = sharedStore; - mUserStore = userStore; + // The user store is initialized to null, this will be set when the user unlocks and + // CE storage is accessible via |switchUserStoreAndRead|. + mUserStore = null; } /** @@ -181,7 +181,7 @@ public class WifiConfigStore { * @return true if any of the store file is present, false otherwise. */ public boolean areStoresPresent() { - return (mSharedStore.exists() || mUserStore.exists()); + return (mSharedStore.exists() || (mUserStore != null && mUserStore.exists())); } /** @@ -198,10 +198,11 @@ public class WifiConfigStore { // Serialize the provided data and send it to the respective stores. The actual write will // be performed later depending on the |forceSync| flag . byte[] sharedDataBytes = storeData.createSharedRawData(); - byte[] userDataBytes = storeData.createUserRawData(); - mSharedStore.storeRawDataToWrite(sharedDataBytes); - mUserStore.storeRawDataToWrite(userDataBytes); + if (mUserStore != null) { + byte[] userDataBytes = storeData.createUserRawData(); + mUserStore.storeRawDataToWrite(userDataBytes); + } // Every write provides a new snapshot to be persisted, so |forceSync| flag overrides any // pending buffer writes. @@ -243,7 +244,9 @@ public class WifiConfigStore { long writeStartTime = mClock.getElapsedSinceBootMillis(); mSharedStore.writeBufferedRawData(); - mUserStore.writeBufferedRawData(); + if (mUserStore != null) { + mUserStore.writeBufferedRawData(); + } long writeTime = mClock.getElapsedSinceBootMillis() - writeStartTime; Log.d(TAG, "Writing to stores completed in " + writeTime + " ms."); @@ -259,7 +262,10 @@ public class WifiConfigStore { public WifiConfigStoreData read() throws XmlPullParserException, IOException { long readStartTime = mClock.getElapsedSinceBootMillis(); byte[] sharedDataBytes = mSharedStore.readRawData(); - byte[] userDataBytes = mUserStore.readRawData(); + byte[] userDataBytes = null; + if (mUserStore != null) { + userDataBytes = mUserStore.readRawData(); + } long readTime = mClock.getElapsedSinceBootMillis() - readStartTime; Log.d(TAG, "Reading from stores completed in " + readTime + " ms."); diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java index 37d8aa024..00bbe4239 100644 --- a/service/java/com/android/server/wifi/WifiInjector.java +++ b/service/java/com/android/server/wifi/WifiInjector.java @@ -145,8 +145,7 @@ public class WifiInjector { mWifiKeyStore = new WifiKeyStore(mKeyStore); mWifiConfigStore = new WifiConfigStore( mContext, mWifiStateMachineHandlerThread.getLooper(), mClock, - WifiConfigStore.createSharedFile(), - WifiConfigStore.createUserFile(UserHandle.USER_SYSTEM)); + WifiConfigStore.createSharedFile()); // Legacy config store DelayedDiskWrite writer = new DelayedDiskWrite(); mWifiNetworkHistory = new WifiNetworkHistory(mContext, mWifiNative.getLocalLog(), writer); |