Merge "Merge changes from topic "keyguard-occlude-race-transitions" into udc-dev am: a3bd224e93" into udc-dev-plus-aosp

This commit is contained in:
Automerger Merge Worker
2023-06-29 19:52:58 +00:00
committed by Android (Google) Code Review
10 changed files with 112 additions and 33 deletions

View File

@@ -139,6 +139,7 @@ import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.flags.Flags; import com.android.systemui.flags.Flags;
import com.android.systemui.flags.SystemPropertiesHelper; import com.android.systemui.flags.SystemPropertiesHelper;
import com.android.systemui.keyguard.dagger.KeyguardModule; import com.android.systemui.keyguard.dagger.KeyguardModule;
import com.android.systemui.keyguard.shared.model.TransitionStep;
import com.android.systemui.keyguard.ui.viewmodel.DreamingToLockscreenTransitionViewModel; import com.android.systemui.keyguard.ui.viewmodel.DreamingToLockscreenTransitionViewModel;
import com.android.systemui.log.SessionTracker; import com.android.systemui.log.SessionTracker;
import com.android.systemui.navigationbar.NavigationModeController; import com.android.systemui.navigationbar.NavigationModeController;
@@ -538,6 +539,8 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
private CentralSurfaces mCentralSurfaces; private CentralSurfaces mCentralSurfaces;
private IRemoteAnimationFinishedCallback mUnoccludeFromDreamFinishedCallback;
private final DeviceConfig.OnPropertiesChangedListener mOnPropertiesChangedListener = private final DeviceConfig.OnPropertiesChangedListener mOnPropertiesChangedListener =
new DeviceConfig.OnPropertiesChangedListener() { new DeviceConfig.OnPropertiesChangedListener() {
@Override @Override
@@ -1164,6 +1167,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
getRemoteSurfaceAlphaApplier().accept(0.0f); getRemoteSurfaceAlphaApplier().accept(0.0f);
mDreamingToLockscreenTransitionViewModel.get() mDreamingToLockscreenTransitionViewModel.get()
.startTransition(); .startTransition();
mUnoccludeFromDreamFinishedCallback = finishedCallback;
return; return;
} }
@@ -1243,6 +1247,19 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
}; };
} }
private Consumer<TransitionStep> getFinishedCallbackConsumer() {
return (TransitionStep step) -> {
if (mUnoccludeFromDreamFinishedCallback == null) return;
try {
mUnoccludeFromDreamFinishedCallback.onAnimationFinished();
mUnoccludeFromDreamFinishedCallback = null;
} catch (RemoteException e) {
Log.e(TAG, "Wasn't able to callback", e);
}
mInteractionJankMonitor.end(CUJ_LOCKSCREEN_OCCLUSION);
};
}
private DeviceConfigProxy mDeviceConfig; private DeviceConfigProxy mDeviceConfig;
private DozeParameters mDozeParameters; private DozeParameters mDozeParameters;
@@ -1502,6 +1519,9 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
collectFlow(viewRootImpl.getView(), collectFlow(viewRootImpl.getView(),
mDreamingToLockscreenTransitionViewModel.get().getDreamOverlayAlpha(), mDreamingToLockscreenTransitionViewModel.get().getDreamOverlayAlpha(),
getRemoteSurfaceAlphaApplier(), mMainDispatcher); getRemoteSurfaceAlphaApplier(), mMainDispatcher);
collectFlow(viewRootImpl.getView(),
mDreamingToLockscreenTransitionViewModel.get().getTransitionEnded(),
getFinishedCallbackConsumer(), mMainDispatcher);
} }
} }
// Most services aren't available until the system reaches the ready state, so we // Most services aren't available until the system reaches the ready state, so we

View File

@@ -49,11 +49,15 @@ constructor(
) { ) {
/** (any)->GONE transition information */ /** (any)->GONE transition information */
val anyStateToGoneTransition: Flow<TransitionStep> = val anyStateToGoneTransition: Flow<TransitionStep> =
repository.transitions.filter { step -> step.to == KeyguardState.GONE } repository.transitions.filter { step -> step.to == GONE }
/** (any)->AOD transition information */ /** (any)->AOD transition information */
val anyStateToAodTransition: Flow<TransitionStep> = val anyStateToAodTransition: Flow<TransitionStep> =
repository.transitions.filter { step -> step.to == KeyguardState.AOD } repository.transitions.filter { step -> step.to == AOD }
/** DREAMING->(any) transition information. */
val fromDreamingTransition: Flow<TransitionStep> =
repository.transitions.filter { step -> step.from == DREAMING }
/** AOD->LOCKSCREEN transition information. */ /** AOD->LOCKSCREEN transition information. */
val aodToLockscreenTransition: Flow<TransitionStep> = repository.transition(AOD, LOCKSCREEN) val aodToLockscreenTransition: Flow<TransitionStep> = repository.transition(AOD, LOCKSCREEN)

View File

@@ -48,7 +48,7 @@ constructor(
) )
val transitionEnded = val transitionEnded =
keyguardTransitionInteractor.dreamingToLockscreenTransition.filter { step -> keyguardTransitionInteractor.fromDreamingTransition.filter { step ->
step.transitionState == TransitionState.FINISHED || step.transitionState == TransitionState.FINISHED ||
step.transitionState == TransitionState.CANCELED step.transitionState == TransitionState.CANCELED
} }

View File

@@ -186,6 +186,8 @@ public class KeyguardViewMediatorTest extends SysuiTestCase {
when(mStatusBarKeyguardViewManager.getViewRootImpl()).thenReturn(testViewRoot); when(mStatusBarKeyguardViewManager.getViewRootImpl()).thenReturn(testViewRoot);
when(mDreamingToLockscreenTransitionViewModel.getDreamOverlayAlpha()) when(mDreamingToLockscreenTransitionViewModel.getDreamOverlayAlpha())
.thenReturn(mock(Flow.class)); .thenReturn(mock(Flow.class));
when(mDreamingToLockscreenTransitionViewModel.getTransitionEnded())
.thenReturn(mock(Flow.class));
mNotificationShadeWindowController = new NotificationShadeWindowControllerImpl(mContext, mNotificationShadeWindowController = new NotificationShadeWindowControllerImpl(mContext,
mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController, mWindowManager, mActivityManager, mDozeParameters, mStatusBarStateController,
mConfigurationController, mViewMediator, mKeyguardBypassController, mConfigurationController, mViewMediator, mKeyguardBypassController,

View File

@@ -22,8 +22,16 @@ import com.android.systemui.RoboPilotTest
import com.android.systemui.SysuiTestCase import com.android.systemui.SysuiTestCase
import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository import com.android.systemui.keyguard.data.repository.FakeKeyguardTransitionRepository
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor
import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.shared.model.KeyguardState.AOD
import com.android.systemui.keyguard.shared.model.KeyguardState.DOZING
import com.android.systemui.keyguard.shared.model.KeyguardState.DREAMING
import com.android.systemui.keyguard.shared.model.KeyguardState.GONE
import com.android.systemui.keyguard.shared.model.KeyguardState.LOCKSCREEN
import com.android.systemui.keyguard.shared.model.TransitionState import com.android.systemui.keyguard.shared.model.TransitionState
import com.android.systemui.keyguard.shared.model.TransitionState.CANCELED
import com.android.systemui.keyguard.shared.model.TransitionState.FINISHED
import com.android.systemui.keyguard.shared.model.TransitionState.RUNNING
import com.android.systemui.keyguard.shared.model.TransitionState.STARTED
import com.android.systemui.keyguard.shared.model.TransitionStep import com.android.systemui.keyguard.shared.model.TransitionStep
import com.android.systemui.util.mockito.mock import com.android.systemui.util.mockito.mock
import com.google.common.collect.Range import com.google.common.collect.Range
@@ -60,7 +68,7 @@ class DreamingToLockscreenTransitionViewModelTest : SysuiTestCase() {
val job = val job =
underTest.dreamOverlayTranslationY(pixels).onEach { values.add(it) }.launchIn(this) underTest.dreamOverlayTranslationY(pixels).onEach { values.add(it) }.launchIn(this)
repository.sendTransitionStep(step(0f, TransitionState.STARTED)) repository.sendTransitionStep(step(0f, STARTED))
repository.sendTransitionStep(step(0f)) repository.sendTransitionStep(step(0f))
repository.sendTransitionStep(step(0.3f)) repository.sendTransitionStep(step(0.3f))
repository.sendTransitionStep(step(0.5f)) repository.sendTransitionStep(step(0.5f))
@@ -82,7 +90,7 @@ class DreamingToLockscreenTransitionViewModelTest : SysuiTestCase() {
val job = underTest.dreamOverlayAlpha.onEach { values.add(it) }.launchIn(this) val job = underTest.dreamOverlayAlpha.onEach { values.add(it) }.launchIn(this)
// Should start running here... // Should start running here...
repository.sendTransitionStep(step(0f, TransitionState.STARTED)) repository.sendTransitionStep(step(0f, STARTED))
repository.sendTransitionStep(step(0f)) repository.sendTransitionStep(step(0f))
repository.sendTransitionStep(step(0.1f)) repository.sendTransitionStep(step(0.1f))
repository.sendTransitionStep(step(0.5f)) repository.sendTransitionStep(step(0.5f))
@@ -104,7 +112,7 @@ class DreamingToLockscreenTransitionViewModelTest : SysuiTestCase() {
val job = underTest.lockscreenAlpha.onEach { values.add(it) }.launchIn(this) val job = underTest.lockscreenAlpha.onEach { values.add(it) }.launchIn(this)
repository.sendTransitionStep(step(0f, TransitionState.STARTED)) repository.sendTransitionStep(step(0f, STARTED))
repository.sendTransitionStep(step(0f)) repository.sendTransitionStep(step(0f))
repository.sendTransitionStep(step(0.1f)) repository.sendTransitionStep(step(0.1f))
repository.sendTransitionStep(step(0.2f)) repository.sendTransitionStep(step(0.2f))
@@ -126,7 +134,7 @@ class DreamingToLockscreenTransitionViewModelTest : SysuiTestCase() {
val job = val job =
underTest.lockscreenTranslationY(pixels).onEach { values.add(it) }.launchIn(this) underTest.lockscreenTranslationY(pixels).onEach { values.add(it) }.launchIn(this)
repository.sendTransitionStep(step(0f, TransitionState.STARTED)) repository.sendTransitionStep(step(0f, STARTED))
repository.sendTransitionStep(step(0f)) repository.sendTransitionStep(step(0f))
repository.sendTransitionStep(step(0.3f)) repository.sendTransitionStep(step(0.3f))
repository.sendTransitionStep(step(0.5f)) repository.sendTransitionStep(step(0.5f))
@@ -138,13 +146,44 @@ class DreamingToLockscreenTransitionViewModelTest : SysuiTestCase() {
job.cancel() job.cancel()
} }
private fun step( @Test
value: Float, fun transitionEnded() =
state: TransitionState = TransitionState.RUNNING runTest(UnconfinedTestDispatcher()) {
): TransitionStep { val values = mutableListOf<TransitionStep>()
val job = underTest.transitionEnded.onEach { values.add(it) }.launchIn(this)
repository.sendTransitionStep(TransitionStep(DOZING, DREAMING, 0.0f, STARTED))
repository.sendTransitionStep(TransitionStep(DOZING, DREAMING, 1.0f, FINISHED))
repository.sendTransitionStep(TransitionStep(DREAMING, LOCKSCREEN, 0.0f, STARTED))
repository.sendTransitionStep(TransitionStep(DREAMING, LOCKSCREEN, 0.1f, RUNNING))
repository.sendTransitionStep(TransitionStep(DREAMING, LOCKSCREEN, 1.0f, FINISHED))
repository.sendTransitionStep(TransitionStep(LOCKSCREEN, DREAMING, 0.0f, STARTED))
repository.sendTransitionStep(TransitionStep(LOCKSCREEN, DREAMING, 0.5f, RUNNING))
repository.sendTransitionStep(TransitionStep(LOCKSCREEN, DREAMING, 1.0f, FINISHED))
repository.sendTransitionStep(TransitionStep(DREAMING, GONE, 0.0f, STARTED))
repository.sendTransitionStep(TransitionStep(DREAMING, GONE, 0.5f, RUNNING))
repository.sendTransitionStep(TransitionStep(DREAMING, GONE, 1.0f, CANCELED))
repository.sendTransitionStep(TransitionStep(DREAMING, AOD, 0.0f, STARTED))
repository.sendTransitionStep(TransitionStep(DREAMING, AOD, 1.0f, FINISHED))
assertThat(values.size).isEqualTo(3)
values.forEach {
assertThat(it.transitionState == FINISHED || it.transitionState == CANCELED)
.isTrue()
}
job.cancel()
}
private fun step(value: Float, state: TransitionState = RUNNING): TransitionStep {
return TransitionStep( return TransitionStep(
from = KeyguardState.DREAMING, from = DREAMING,
to = KeyguardState.LOCKSCREEN, to = LOCKSCREEN,
value = value, value = value,
transitionState = state, transitionState = state,
ownerName = "DreamingToLockscreenTransitionViewModelTest" ownerName = "DreamingToLockscreenTransitionViewModelTest"

View File

@@ -3570,19 +3570,17 @@ public class PhoneWindowManager implements WindowManagerPolicy {
} }
@Override @Override
public void onKeyguardOccludedChangedLw(boolean occluded, boolean waitAppTransition) { public void onKeyguardOccludedChangedLw(boolean occluded) {
if (mKeyguardDelegate != null && waitAppTransition) { if (mKeyguardDelegate != null) {
mPendingKeyguardOccluded = occluded; mPendingKeyguardOccluded = occluded;
mKeyguardOccludedChanged = true; mKeyguardOccludedChanged = true;
} else {
setKeyguardOccludedLw(occluded);
} }
} }
@Override @Override
public int applyKeyguardOcclusionChange() { public int applyKeyguardOcclusionChange() {
if (DEBUG_KEYGUARD) Slog.d(TAG, "transition/occluded commit occluded=" if (DEBUG_KEYGUARD) Slog.d(TAG, "transition/occluded commit occluded="
+ mPendingKeyguardOccluded); + mPendingKeyguardOccluded + " changed=" + mKeyguardOccludedChanged);
// TODO(b/276433230): Explicitly save before/after for occlude state in each // TODO(b/276433230): Explicitly save before/after for occlude state in each
// Transition so we don't need to update SysUI every time. // Transition so we don't need to update SysUI every time.

View File

@@ -169,7 +169,7 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
* *
* @param occluded Whether Keyguard is currently occluded or not. * @param occluded Whether Keyguard is currently occluded or not.
*/ */
void onKeyguardOccludedChangedLw(boolean occluded, boolean waitAppTransition); void onKeyguardOccludedChangedLw(boolean occluded);
/** /**
* Commit any queued changes to keyguard occlude status that had been deferred during the * Commit any queued changes to keyguard occlude status that had been deferred during the

View File

@@ -419,13 +419,17 @@ class KeyguardController {
return; return;
} }
final boolean waitAppTransition = isKeyguardLocked(displayId); final TransitionController tc = mRootWindowContainer.mTransitionController;
mWindowManager.mPolicy.onKeyguardOccludedChangedLw(isDisplayOccluded(DEFAULT_DISPLAY),
waitAppTransition); final boolean occluded = isDisplayOccluded(displayId);
if (waitAppTransition) { final boolean performTransition = isKeyguardLocked(displayId);
mService.deferWindowLayout(); final boolean executeTransition = performTransition && !tc.isCollecting();
try {
if (isDisplayOccluded(DEFAULT_DISPLAY)) { mWindowManager.mPolicy.onKeyguardOccludedChangedLw(occluded);
mService.deferWindowLayout();
try {
if (isKeyguardLocked(displayId)) {
if (occluded) {
mRootWindowContainer.getDefaultDisplay().requestTransitionAndLegacyPrepare( mRootWindowContainer.getDefaultDisplay().requestTransitionAndLegacyPrepare(
TRANSIT_KEYGUARD_OCCLUDE, TRANSIT_KEYGUARD_OCCLUDE,
TRANSIT_FLAG_KEYGUARD_OCCLUDING, TRANSIT_FLAG_KEYGUARD_OCCLUDING,
@@ -435,11 +439,19 @@ class KeyguardController {
TRANSIT_KEYGUARD_UNOCCLUDE, TRANSIT_KEYGUARD_UNOCCLUDE,
TRANSIT_FLAG_KEYGUARD_UNOCCLUDING); TRANSIT_FLAG_KEYGUARD_UNOCCLUDING);
} }
updateKeyguardSleepToken(DEFAULT_DISPLAY); } else {
mWindowManager.executeAppTransition(); if (tc.inTransition()) {
} finally { tc.mStateValidators.add(mWindowManager.mPolicy::applyKeyguardOcclusionChange);
mService.continueWindowLayout(); } else {
mWindowManager.mPolicy.applyKeyguardOcclusionChange();
}
} }
updateKeyguardSleepToken(displayId);
if (performTransition && executeTransition) {
mWindowManager.executeAppTransition();
}
} finally {
mService.continueWindowLayout();
} }
} }
@@ -486,6 +498,9 @@ class KeyguardController {
} }
} }
/**
* @return true if Keyguard is occluded or the device is dreaming.
*/
boolean isDisplayOccluded(int displayId) { boolean isDisplayOccluded(int displayId) {
return getDisplayState(displayId).mOccluded; return getDisplayState(displayId).mOccluded;
} }

View File

@@ -27,6 +27,7 @@ import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.INVALID_DISPLAY; import static android.view.Display.INVALID_DISPLAY;
import static android.view.WindowManager.INPUT_CONSUMER_RECENTS_ANIMATION; import static android.view.WindowManager.INPUT_CONSUMER_RECENTS_ANIMATION;
import static android.view.WindowManager.KEYGUARD_VISIBILITY_TRANSIT_FLAGS;
import static android.view.WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS; import static android.view.WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS;
import static android.view.WindowManager.LayoutParams.ROTATION_ANIMATION_UNSPECIFIED; import static android.view.WindowManager.LayoutParams.ROTATION_ANIMATION_UNSPECIFIED;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
@@ -2659,7 +2660,7 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
} }
private void validateKeyguardOcclusion() { private void validateKeyguardOcclusion() {
if ((mFlags & TRANSIT_FLAG_KEYGUARD_LOCKED) != 0) { if ((mFlags & KEYGUARD_VISIBILITY_TRANSIT_FLAGS) != 0) {
mController.mStateValidators.add( mController.mStateValidators.add(
mController.mAtm.mWindowManager.mPolicy::applyKeyguardOcclusionChange); mController.mAtm.mWindowManager.mPolicy::applyKeyguardOcclusionChange);
} }

View File

@@ -233,7 +233,7 @@ class TestWindowManagerPolicy implements WindowManagerPolicy {
} }
@Override @Override
public void onKeyguardOccludedChangedLw(boolean occluded, boolean waitAppTransition) { public void onKeyguardOccludedChangedLw(boolean occluded) {
} }
public void setSafeMode(boolean safeMode) { public void setSafeMode(boolean safeMode) {