DO NOT MERGE - Fix StatusBar.updateIsKeyguard() when suspending to RAM.

That method was throwing a NPE on automotive because it's called before start()

Test: check logcat while running 'adb shell dumpsys car_service suspend'
Fixes: 146144370
Change-Id: Id863acac44f75b06c8cd1a0f0bcd6f23f8ab6fd9
(cherry picked from commit 20e362a92b8376b590d5df615265050dd6838c91)
This commit is contained in:
Felipe Leme
2019-12-12 12:17:53 -08:00
parent 248a73969f
commit fea5c4af0e

View File

@@ -3055,10 +3055,21 @@ public class StatusBar extends SystemUI implements DemoMode,
return mState == StatusBarState.FULLSCREEN_USER_SWITCHER;
}
private boolean isAutomotive() {
return mContext != null
&& mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUTOMOTIVE);
}
private boolean updateIsKeyguard() {
boolean wakeAndUnlocking = mBiometricUnlockController.getMode()
== BiometricUnlockController.MODE_WAKE_AND_UNLOCK;
if (mScreenLifecycle == null && isAutomotive()) {
// TODO(b/146144370): workaround to avoid NPE when device goes into STR (Suspend to RAM)
Log.w(TAG, "updateIsKeyguard(): mScreenLifeCycle not set yet");
mScreenLifecycle = Dependency.get(ScreenLifecycle.class);
}
// For dozing, keyguard needs to be shown whenever the device is non-interactive. Otherwise
// there's no surface we can show to the user. Note that the device goes fully interactive
// late in the transition, so we also allow the device to start dozing once the screen has