Merge "Consolidate occlusion events into KeyguardStateController" into tm-dev

This commit is contained in:
Matt Pietal
2022-03-28 18:26:57 +00:00
committed by Android (Google) Code Review
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 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) {
updateBubblesVisibility();
mStatusBarWindowState = state;
@@ -655,7 +665,6 @@ public class CentralSurfaces extends CoreStartable implements
private int mLastLoggedStateFingerprint;
private boolean mTopHidesStatusBar;
private boolean mStatusBarWindowHidden;
private boolean mIsOccluded;
private boolean mIsLaunchingActivityOverLockscreen;
private final UserSwitcherController mUserSwitcherController;
@@ -1002,7 +1011,6 @@ public class CentralSurfaces extends CoreStartable implements
mCommandQueue.setIcon(result.mIcons.keyAt(i), result.mIcons.valueAt(i));
}
if (DEBUG) {
Log.d(TAG, String.format(
"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() {
@Override
public void onUnlockedChanged() {
updateKeyguardState();
logStateToEventlog();
}
});
@@ -1599,6 +1606,7 @@ public class CentralSurfaces extends CoreStartable implements
mBiometricUnlockController,
mStackScroller,
mKeyguardBypassController);
mKeyguardStateController.addCallback(mKeyguardStateControllerCallback);
mKeyguardIndicationController
.setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager);
mBiometricUnlockController.setKeyguardViewController(mStatusBarKeyguardViewManager);
@@ -1853,13 +1861,7 @@ public class CentralSurfaces extends CoreStartable implements
* @return whether the keyguard is currently occluded
*/
public boolean isOccluded() {
return mIsOccluded;
}
public void setOccluded(boolean occluded) {
mIsOccluded = occluded;
mStatusBarHideIconsForBouncerManager.setIsOccludedAndTriggerUpdate(occluded);
mScrimController.setKeyguardOccluded(occluded);
return mKeyguardStateController.isOccluded();
}
/** A launch animation was cancelled. */
@@ -3383,11 +3385,6 @@ public class CentralSurfaces extends CoreStartable implements
return mLightRevealScrim;
}
private void updateKeyguardState() {
mKeyguardStateController.notifyKeyguardState(mStatusBarKeyguardViewManager.isShowing(),
mStatusBarKeyguardViewManager.isOccluded());
}
public void onTrackingStarted() {
mShadeController.runPostCollapseRunnables();
}
@@ -4396,7 +4393,6 @@ public class CentralSurfaces extends CoreStartable implements
checkBarModes();
updateScrimController();
mPresenter.updateMediaMetaData(false, mState != StatusBarState.KEYGUARD);
updateKeyguardState();
Trace.endSection();
}

View File

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

View File

@@ -861,11 +861,17 @@ public class CentralSurfacesTest extends SysuiTestCase {
@Test
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));
reset(mScrimController);
mCentralSurfaces.setOccluded(false);
when(mKeyguardStateController.isOccluded()).thenReturn(false);
callbackCaptor.getValue().onKeyguardShowingChanged();
verify(mScrimController).setKeyguardOccluded(eq(false));
}

View File

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