diff options
author | Rebecca Silberstein <silberst@google.com> | 2017-03-20 22:28:54 -0700 |
---|---|---|
committer | Rebecca Silberstein <silberst@google.com> | 2017-04-11 17:58:24 +0000 |
commit | 36f52ffb5fd16c89f022dead27d8df9e51874160 (patch) | |
tree | ac454eb5e81df09b33d9dbeb255e47097dc89814 /service | |
parent | ed71d5209d66544a46a7dc543a0ee94e1be39eab (diff) |
WifiServiceImpl: check device encryption at boot
When a device is booting, it may need to be decrypted. This extra step
will restart system services, including wifi. If this restart happens
while we are creating interfaces or loading firmware, we can get odd
exceptions end up crashing. To avoid this, we add a check to see if the
device needs to be decrypted. If it does, we do not start wifi.
Added unittests to cover both decrypted and encrypted boot. Also with
and without wifi enabled.
Bug: 35416881
Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh
Test: frameworks/base/wifi/tests/runtests.sh
Test: wifi integration tests
Change-Id: I8d471c7d0345611f90782dd3bc1b2261957eee73
Merged-In: I8d471c7d0345611f90782dd3bc1b2261957eee73
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/FrameworkFacade.java | 10 | ||||
-rw-r--r-- | service/java/com/android/server/wifi/WifiServiceImpl.java | 17 |
2 files changed, 23 insertions, 4 deletions
diff --git a/service/java/com/android/server/wifi/FrameworkFacade.java b/service/java/com/android/server/wifi/FrameworkFacade.java index 42f0161e9..2c3e5f7e0 100644 --- a/service/java/com/android/server/wifi/FrameworkFacade.java +++ b/service/java/com/android/server/wifi/FrameworkFacade.java @@ -29,6 +29,7 @@ import android.os.Handler; import android.os.IBinder; import android.os.RemoteException; import android.os.ServiceManager; +import android.os.storage.StorageManager; import android.provider.Settings; import android.telephony.CarrierConfigManager; @@ -151,4 +152,13 @@ public class FrameworkFacade { public WifiAsyncChannel makeWifiAsyncChannel(String tag) { return new WifiAsyncChannel(tag); } + + /** + * Check if the device will be restarting after decrypting during boot by calling {@link + * StorageManager.inCryptKeeperBounce}. + * @return true if the device will restart, false otherwise + */ + public boolean inStorageManagerCryptKeeperBounce() { + return StorageManager.inCryptKeeperBounce(); + } } diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index c137be8e0..a327fa7b1 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -361,14 +361,23 @@ public class WifiServiceImpl extends IWifiManager.Stub { public void setWifiHandlerLogForTest(WifiLog log) { mClientHandler.setWifiLog(log); } + /** - * Check if Wi-Fi needs to be enabled and start - * if needed + * Check if we are ready to start wifi. + * + * First check if we will be restarting system services to decrypt the device. If the device is + * not encrypted, check if Wi-Fi needs to be enabled and start if needed * - * This function is used only at boot time + * This function is used only at boot time. */ public void checkAndStartWifi() { - /* Check if wi-fi needs to be enabled */ + // First check if we will end up restarting WifiService + if (mFrameworkFacade.inStorageManagerCryptKeeperBounce()) { + Log.d(TAG, "Device still encrypted. Need to restart SystemServer. Do not start wifi."); + return; + } + + // Check if wi-fi needs to be enabled boolean wifiEnabled = mSettingsStore.isWifiToggleEnabled(); Slog.i(TAG, "WifiService starting up with Wi-Fi " + (wifiEnabled ? "enabled" : "disabled")); |