From 0d394193796f10efeb28a052399a63bf4a96455f Mon Sep 17 00:00:00 2001 From: Alejandro Nijamkin Date: Thu, 23 May 2024 15:58:18 -0700 Subject: [flexiglass] Move "show lockscreen when folded" to the main thread. As of ag/27342795, changing the scene on STL throws an exception when called off the main thread. This CL fixes it for the KeyguardService.showDismissibleKeyguard case. Test: manually verified that the scene is changed to lockscreen when folding closed an unfolded, unlocked foldable Bug: 341445974 Flag: com.android.systemui.scene_container Change-Id: I2787ccc8fe94caeabdc709d74e5665f4f0400e19 --- .../src/com/android/systemui/keyguard/KeyguardService.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java index 9cdba5853959..956c0f51cda0 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java @@ -77,6 +77,7 @@ import com.android.internal.policy.IKeyguardStateCallback; import com.android.keyguard.mediator.ScreenOnCoordinator; import com.android.systemui.SystemUIApplication; import com.android.systemui.dagger.qualifiers.Application; +import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.flags.FeatureFlags; import com.android.systemui.keyguard.ui.binder.KeyguardSurfaceBehindParamsApplier; import com.android.systemui.keyguard.ui.binder.KeyguardSurfaceBehindViewBinder; @@ -101,6 +102,7 @@ import kotlinx.coroutines.CoroutineScope; import java.util.ArrayList; import java.util.Map; import java.util.WeakHashMap; +import java.util.concurrent.Executor; import javax.inject.Inject; @@ -116,6 +118,7 @@ public class KeyguardService extends Service { private final DisplayTracker mDisplayTracker; private final PowerInteractor mPowerInteractor; private final Lazy mSceneInteractorLazy; + private final Executor mMainExecutor; private static RemoteAnimationTarget[] wrap(TransitionInfo info, boolean wallpapers, SurfaceControl.Transaction t, ArrayMap leashMap, @@ -331,7 +334,8 @@ public class KeyguardService extends Service { FeatureFlags featureFlags, PowerInteractor powerInteractor, WindowManagerOcclusionManager windowManagerOcclusionManager, - Lazy sceneInteractorLazy) { + Lazy sceneInteractorLazy, + @Main Executor mainExecutor) { super(); mKeyguardViewMediator = keyguardViewMediator; mKeyguardLifecyclesDispatcher = keyguardLifecyclesDispatcher; @@ -341,6 +345,7 @@ public class KeyguardService extends Service { mFlags = featureFlags; mPowerInteractor = powerInteractor; mSceneInteractorLazy = sceneInteractorLazy; + mMainExecutor = mainExecutor; if (KeyguardWmStateRefactor.isEnabled()) { WindowManagerLockscreenVisibilityViewBinder.bind( @@ -619,8 +624,8 @@ public class KeyguardService extends Service { mKeyguardViewMediator.showDismissibleKeyguard(); if (SceneContainerFlag.isEnabled() && mFoldGracePeriodProvider.get().isEnabled()) { - mSceneInteractorLazy.get().changeScene( - Scenes.Lockscreen, "KeyguardService.showDismissibleKeyguard"); + mMainExecutor.execute(() -> mSceneInteractorLazy.get().changeScene( + Scenes.Lockscreen, "KeyguardService.showDismissibleKeyguard")); } } -- cgit v1.2.3-59-g8ed1b