Merge "Consolidate occlusion events into KeyguardStateController" into tm-dev am: 68d2fdfde6

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17391821

Change-Id: I35c9467cadd2a37dea07df78e5c8d1dce259984d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Matt Pietal
2022-03-28 18:36:36 +00:00
committed by Automerger Merge Worker
4 changed files with 40 additions and 32 deletions

View File

@@ -359,6 +359,16 @@ public class CentralSurfaces extends CoreStartable implements
private float mTransitionToFullShadeProgress = 0f; private float mTransitionToFullShadeProgress = 0f;
private NotificationListContainer mNotifListContainer; private NotificationListContainer mNotifListContainer;
private final KeyguardStateController.Callback mKeyguardStateControllerCallback =
new KeyguardStateController.Callback() {
@Override
public void onKeyguardShowingChanged() {
boolean occluded = mKeyguardStateController.isOccluded();
mStatusBarHideIconsForBouncerManager.setIsOccludedAndTriggerUpdate(occluded);
mScrimController.setKeyguardOccluded(occluded);
}
};
void onStatusBarWindowStateChanged(@WindowVisibleState int state) { void onStatusBarWindowStateChanged(@WindowVisibleState int state) {
updateBubblesVisibility(); updateBubblesVisibility();
mStatusBarWindowState = state; mStatusBarWindowState = state;
@@ -655,7 +665,6 @@ public class CentralSurfaces extends CoreStartable implements
private int mLastLoggedStateFingerprint; private int mLastLoggedStateFingerprint;
private boolean mTopHidesStatusBar; private boolean mTopHidesStatusBar;
private boolean mStatusBarWindowHidden; private boolean mStatusBarWindowHidden;
private boolean mIsOccluded;
private boolean mIsLaunchingActivityOverLockscreen; private boolean mIsLaunchingActivityOverLockscreen;
private final UserSwitcherController mUserSwitcherController; private final UserSwitcherController mUserSwitcherController;
@@ -1002,7 +1011,6 @@ public class CentralSurfaces extends CoreStartable implements
mCommandQueue.setIcon(result.mIcons.keyAt(i), result.mIcons.valueAt(i)); mCommandQueue.setIcon(result.mIcons.keyAt(i), result.mIcons.valueAt(i));
} }
if (DEBUG) { if (DEBUG) {
Log.d(TAG, String.format( Log.d(TAG, String.format(
"init: icons=%d disabled=0x%08x lights=0x%08x imeButton=0x%08x", "init: icons=%d disabled=0x%08x lights=0x%08x imeButton=0x%08x",
@@ -1036,7 +1044,6 @@ public class CentralSurfaces extends CoreStartable implements
mKeyguardStateController.addCallback(new KeyguardStateController.Callback() { mKeyguardStateController.addCallback(new KeyguardStateController.Callback() {
@Override @Override
public void onUnlockedChanged() { public void onUnlockedChanged() {
updateKeyguardState();
logStateToEventlog(); logStateToEventlog();
} }
}); });
@@ -1599,6 +1606,7 @@ public class CentralSurfaces extends CoreStartable implements
mBiometricUnlockController, mBiometricUnlockController,
mStackScroller, mStackScroller,
mKeyguardBypassController); mKeyguardBypassController);
mKeyguardStateController.addCallback(mKeyguardStateControllerCallback);
mKeyguardIndicationController mKeyguardIndicationController
.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager); .setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager);
mBiometricUnlockController.setKeyguardViewController(mStatusBarKeyguardViewManager); mBiometricUnlockController.setKeyguardViewController(mStatusBarKeyguardViewManager);
@@ -1853,13 +1861,7 @@ public class CentralSurfaces extends CoreStartable implements
* @return whether the keyguard is currently occluded * @return whether the keyguard is currently occluded
*/ */
public boolean isOccluded() { public boolean isOccluded() {
return mIsOccluded; return mKeyguardStateController.isOccluded();
}
public void setOccluded(boolean occluded) {
mIsOccluded = occluded;
mStatusBarHideIconsForBouncerManager.setIsOccludedAndTriggerUpdate(occluded);
mScrimController.setKeyguardOccluded(occluded);
} }
/** A launch animation was cancelled. */ /** A launch animation was cancelled. */
@@ -3383,11 +3385,6 @@ public class CentralSurfaces extends CoreStartable implements
return mLightRevealScrim; return mLightRevealScrim;
} }
private void updateKeyguardState() {
mKeyguardStateController.notifyKeyguardState(mStatusBarKeyguardViewManager.isShowing(),
mStatusBarKeyguardViewManager.isOccluded());
}
public void onTrackingStarted() { public void onTrackingStarted() {
mShadeController.runPostCollapseRunnables(); mShadeController.runPostCollapseRunnables();
} }
@@ -4396,7 +4393,6 @@ public class CentralSurfaces extends CoreStartable implements
checkBarModes(); checkBarModes();
updateScrimController(); updateScrimController();
mPresenter.updateMediaMetaData(false, mState != StatusBarState.KEYGUARD); mPresenter.updateMediaMetaData(false, mState != StatusBarState.KEYGUARD);
updateKeyguardState();
Trace.endSection(); Trace.endSection();
} }

View File

@@ -670,12 +670,14 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
@Override @Override
public void setOccluded(boolean occluded, boolean animate) { public void setOccluded(boolean occluded, boolean animate) {
mCentralSurfaces.setOccluded(occluded); final boolean isOccluding = !mOccluded && occluded;
if (occluded && !mOccluded && mShowing) { final boolean isUnOccluding = mOccluded && !occluded;
setOccludedAndUpdateStates(occluded);
if (mShowing && isOccluding) {
SysUiStatsLog.write(SysUiStatsLog.KEYGUARD_STATE_CHANGED, SysUiStatsLog.write(SysUiStatsLog.KEYGUARD_STATE_CHANGED,
SysUiStatsLog.KEYGUARD_STATE_CHANGED__STATE__OCCLUDED); SysUiStatsLog.KEYGUARD_STATE_CHANGED__STATE__OCCLUDED);
if (mCentralSurfaces.isInLaunchTransition()) { if (mCentralSurfaces.isInLaunchTransition()) {
setOccludedAndUpdateStates(true);
final Runnable endRunnable = new Runnable() { final Runnable endRunnable = new Runnable() {
@Override @Override
public void run() { public void run() {
@@ -691,8 +693,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
} }
if (mCentralSurfaces.isLaunchingActivityOverLockscreen()) { if (mCentralSurfaces.isLaunchingActivityOverLockscreen()) {
setOccludedAndUpdateStates(true);
// When isLaunchingActivityOverLockscreen() is true, we know for sure that the post // When isLaunchingActivityOverLockscreen() is true, we know for sure that the post
// collapse runnables will be run. // collapse runnables will be run.
mShadeController.get().addPostCollapseAction(() -> { mShadeController.get().addPostCollapseAction(() -> {
@@ -701,16 +701,14 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
}); });
return; return;
} }
} else if (!occluded && mOccluded && mShowing) { } else if (mShowing && isUnOccluding) {
SysUiStatsLog.write(SysUiStatsLog.KEYGUARD_STATE_CHANGED, SysUiStatsLog.write(SysUiStatsLog.KEYGUARD_STATE_CHANGED,
SysUiStatsLog.KEYGUARD_STATE_CHANGED__STATE__SHOWN); SysUiStatsLog.KEYGUARD_STATE_CHANGED__STATE__SHOWN);
} }
boolean isOccluding = !mOccluded && occluded;
setOccludedAndUpdateStates(occluded);
if (mShowing) { if (mShowing) {
mMediaManager.updateMediaMetaData(false, animate && !occluded); mMediaManager.updateMediaMetaData(false, animate && !mOccluded);
} }
mNotificationShadeWindowController.setKeyguardOccluded(occluded); mNotificationShadeWindowController.setKeyguardOccluded(mOccluded);
// setDozing(false) will call reset once we stop dozing. // setDozing(false) will call reset once we stop dozing.
if (!mDozing) { if (!mDozing) {
@@ -718,7 +716,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
// by a FLAG_DISMISS_KEYGUARD_ACTIVITY. // by a FLAG_DISMISS_KEYGUARD_ACTIVITY.
reset(isOccluding /* hideBouncerWhenShowing*/); reset(isOccluding /* hideBouncerWhenShowing*/);
} }
if (animate && !occluded && mShowing && !mBouncer.isShowing()) { if (animate && !mOccluded && mShowing && !mBouncer.isShowing()) {
mCentralSurfaces.animateKeyguardUnoccluding(); mCentralSurfaces.animateKeyguardUnoccluding();
} }
} }
@@ -1052,6 +1050,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
if (occluded != mLastOccluded || mFirstUpdate) { if (occluded != mLastOccluded || mFirstUpdate) {
mKeyguardUpdateManager.onKeyguardOccludedChanged(occluded); mKeyguardUpdateManager.onKeyguardOccludedChanged(occluded);
mKeyguardStateController.notifyKeyguardState(showing, occluded);
} }
if ((showing && !occluded) != (mLastShowing && !mLastOccluded) || mFirstUpdate) { if ((showing && !occluded) != (mLastShowing && !mLastOccluded) || mFirstUpdate) {
mKeyguardUpdateManager.onKeyguardVisibilityChanged(showing && !occluded); mKeyguardUpdateManager.onKeyguardVisibilityChanged(showing && !occluded);

View File

@@ -861,11 +861,17 @@ public class CentralSurfacesTest extends SysuiTestCase {
@Test @Test
public void testSetOccluded_propagatesToScrimController() { public void testSetOccluded_propagatesToScrimController() {
mCentralSurfaces.setOccluded(true); ArgumentCaptor<KeyguardStateController.Callback> callbackCaptor =
ArgumentCaptor.forClass(KeyguardStateController.Callback.class);
verify(mKeyguardStateController).addCallback(callbackCaptor.capture());
when(mKeyguardStateController.isOccluded()).thenReturn(true);
callbackCaptor.getValue().onKeyguardShowingChanged();
verify(mScrimController).setKeyguardOccluded(eq(true)); verify(mScrimController).setKeyguardOccluded(eq(true));
reset(mScrimController); reset(mScrimController);
mCentralSurfaces.setOccluded(false); when(mKeyguardStateController.isOccluded()).thenReturn(false);
callbackCaptor.getValue().onKeyguardShowingChanged();
verify(mScrimController).setKeyguardOccluded(eq(false)); verify(mScrimController).setKeyguardOccluded(eq(false));
} }

View File

@@ -149,6 +149,7 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
mBiometricUnlockController, mBiometricUnlockController,
mNotificationContainer, mNotificationContainer,
mBypassController); mBypassController);
when(mKeyguardStateController.isOccluded()).thenReturn(false);
mStatusBarKeyguardViewManager.show(null); mStatusBarKeyguardViewManager.show(null);
} }
@@ -286,23 +287,27 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
@Test @Test
public void setOccluded_onKeyguardOccludedChangedCalledCorrectly() { public void setOccluded_onKeyguardOccludedChangedCalledCorrectly() {
mStatusBarKeyguardViewManager.setOccluded(false /* occluded */, false /* animated */); clearInvocations(mKeyguardStateController);
verify(mKeyguardUpdateMonitor).onKeyguardOccludedChanged(false);
clearInvocations(mKeyguardUpdateMonitor); clearInvocations(mKeyguardUpdateMonitor);
// Should be false to start, so no invocations
mStatusBarKeyguardViewManager.setOccluded(false /* occluded */, false /* animated */); mStatusBarKeyguardViewManager.setOccluded(false /* occluded */, false /* animated */);
verify(mKeyguardUpdateMonitor, never()).onKeyguardOccludedChanged(anyBoolean()); verify(mKeyguardUpdateMonitor, never()).onKeyguardOccludedChanged(anyBoolean());
verify(mKeyguardStateController, never()).notifyKeyguardState(anyBoolean(), anyBoolean());
clearInvocations(mKeyguardUpdateMonitor); clearInvocations(mKeyguardUpdateMonitor);
clearInvocations(mKeyguardStateController);
mStatusBarKeyguardViewManager.setOccluded(true /* occluded */, false /* animated */); mStatusBarKeyguardViewManager.setOccluded(true /* occluded */, false /* animated */);
verify(mKeyguardUpdateMonitor).onKeyguardOccludedChanged(true); verify(mKeyguardUpdateMonitor).onKeyguardOccludedChanged(true);
verify(mKeyguardStateController).notifyKeyguardState(true, true);
clearInvocations(mKeyguardUpdateMonitor); clearInvocations(mKeyguardUpdateMonitor);
clearInvocations(mKeyguardStateController);
mStatusBarKeyguardViewManager.setOccluded(true /* occluded */, false /* animated */); mStatusBarKeyguardViewManager.setOccluded(true /* occluded */, false /* animated */);
verify(mKeyguardUpdateMonitor, never()).onKeyguardOccludedChanged(anyBoolean()); verify(mKeyguardUpdateMonitor, never()).onKeyguardOccludedChanged(anyBoolean());
verify(mKeyguardStateController, never()).notifyKeyguardState(anyBoolean(), anyBoolean());
} }
@Test @Test
@@ -312,6 +317,7 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
mStatusBarKeyguardViewManager.setOccluded(true /* occluded */, false /* animated */); mStatusBarKeyguardViewManager.setOccluded(true /* occluded */, false /* animated */);
verify(mKeyguardUpdateMonitor).onKeyguardOccludedChanged(true); verify(mKeyguardUpdateMonitor).onKeyguardOccludedChanged(true);
verify(mKeyguardStateController).notifyKeyguardState(true, true);
} }
@Test @Test
@@ -321,6 +327,7 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
mStatusBarKeyguardViewManager.setOccluded(true /* occluded */, false /* animated */); mStatusBarKeyguardViewManager.setOccluded(true /* occluded */, false /* animated */);
verify(mKeyguardUpdateMonitor).onKeyguardOccludedChanged(true); verify(mKeyguardUpdateMonitor).onKeyguardOccludedChanged(true);
verify(mKeyguardStateController).notifyKeyguardState(true, true);
} }
@Test @Test