diff options
author | Beverly <beverlyt@google.com> | 2021-05-20 15:14:32 -0400 |
---|---|---|
committer | Beverly <beverlyt@google.com> | 2021-05-20 16:41:09 -0400 |
commit | 27e2efeeeb88fc25ea6f68f42dd945ae053a4fd6 (patch) | |
tree | b67d713c1776024f811a94ef8f2aae351010f7f6 /packages/SystemUI/src/com/android/keyguard/AnimatableClockController.java | |
parent | 85cf59de2ffab839eff2705f654a9d9fdc8665c9 (diff) |
Forward fix/revert of clock detached state on keyguard visibility
This reverts most of ag/14554008. The keyguard visibility state isn't
updated immediatly when dozing begins, so we need to make sure we're
still registered for the StatusBarStateControllerListener for dozing
state so that the clock is in the correct state when entering AOD.
Test: manual, enter AOD from the home screen on timeout
Fixes: 188592929
Change-Id: Idf19bc86b11e3423ffdf1ed6e12ef52ea68d8881
Diffstat (limited to 'packages/SystemUI/src/com/android/keyguard/AnimatableClockController.java')
-rw-r--r-- | packages/SystemUI/src/com/android/keyguard/AnimatableClockController.java | 50 |
1 files changed, 18 insertions, 32 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/AnimatableClockController.java b/packages/SystemUI/src/com/android/keyguard/AnimatableClockController.java index 332de6c6cb40..7cb4846cf7e7 100644 --- a/packages/SystemUI/src/com/android/keyguard/AnimatableClockController.java +++ b/packages/SystemUI/src/com/android/keyguard/AnimatableClockController.java @@ -54,8 +54,8 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie private boolean mIsDozing; private boolean mIsCharging; private float mDozeAmount; + boolean mKeyguardShowing; private Locale mLocale; - private boolean mAttached; // if keyguard isn't showing, mAttached = false private final NumberFormat mBurmeseNf = NumberFormat.getInstance(Locale.forLanguageTag("my")); private final String mBurmeseNumerals; @@ -85,11 +85,15 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie R.dimen.keyguard_clock_line_spacing_scale); } + private void reset() { + mView.animateDoze(mIsDozing, false); + } + private final BatteryController.BatteryStateChangeCallback mBatteryCallback = new BatteryController.BatteryStateChangeCallback() { @Override public void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) { - if (!mIsCharging && charging) { + if (mKeyguardShowing && !mIsCharging && charging) { mView.animateCharge(mIsDozing); } mIsCharging = charging; @@ -103,21 +107,6 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie } }; - private final KeyguardUpdateMonitorCallback mKeyguardPersistentCallback = - new KeyguardUpdateMonitorCallback() { - @Override - public void onKeyguardVisibilityChanged(boolean showing) { - // call attached/detached methods on visibility changes. benefits include: - // - no animations when keyguard/clock view aren't visible - // - resets state when keyguard is visible again (ie: font weight) - if (showing) { - onViewAttached(); - } else { - onViewDetached(); - } - } - }; - private final KeyguardUpdateMonitorCallback mKeyguardUpdateMonitorCallback = new KeyguardUpdateMonitorCallback() { @Override @@ -128,44 +117,41 @@ public class AnimatableClockController extends ViewController<AnimatableClockVie mView.animateDisappear(); } } + + @Override + public void onKeyguardVisibilityChanged(boolean showing) { + mKeyguardShowing = showing; + if (!mKeyguardShowing) { + // reset state (ie: after animateDisappear) + reset(); + } + } }; @Override protected void onViewAttached() { - if (mAttached) { - return; - } - mAttached = true; updateLocale(); mBroadcastDispatcher.registerReceiver(mLocaleBroadcastReceiver, new IntentFilter(Intent.ACTION_LOCALE_CHANGED)); mStatusBarStateController.addCallback(mStatusBarStateListener); + mIsDozing = mStatusBarStateController.isDozing(); mDozeAmount = mStatusBarStateController.getDozeAmount(); mBatteryController.addCallback(mBatteryCallback); mKeyguardUpdateMonitor.registerCallback(mKeyguardUpdateMonitorCallback); - - mKeyguardUpdateMonitor.removeCallback(mKeyguardPersistentCallback); - mKeyguardUpdateMonitor.registerCallback(mKeyguardPersistentCallback); + mKeyguardShowing = true; refreshTime(); initColors(); + mView.animateDoze(mIsDozing, false); } @Override protected void onViewDetached() { - if (!mAttached) { - return; - } - - mAttached = false; mBroadcastDispatcher.unregisterReceiver(mLocaleBroadcastReceiver); mStatusBarStateController.removeCallback(mStatusBarStateListener); mKeyguardUpdateMonitor.removeCallback(mKeyguardUpdateMonitorCallback); mBatteryController.removeCallback(mBatteryCallback); - if (!mView.isAttachedToWindow()) { - mKeyguardUpdateMonitor.removeCallback(mKeyguardPersistentCallback); - } } /** Animate the clock appearance */ |