diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUI.java b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUI.java index 99dbfe01964cd..b87cf47dd93fb 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUI.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUI.java @@ -24,9 +24,12 @@ import com.android.wm.shell.common.annotations.ExternalThread; @ExternalThread public interface CompatUI { /** - * Called when the keyguard occluded state changes. Removes all compat UIs if the - * keyguard is now occluded. - * @param occluded indicates if the keyguard is now occluded. + * Called when the keyguard showing state changes. Removes all compat UIs if the + * keyguard is now showing. + * + *

Note that if the keyguard is occluded it will also be considered showing. + * + * @param showing indicates if the keyguard is now showing. */ - void onKeyguardOccludedChanged(boolean occluded); + void onKeyguardShowingChanged(boolean showing); } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java index ee4d5ed018bf9..b2bbafeb7bf5b 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java @@ -109,9 +109,9 @@ public class CompatUIController implements OnDisplaysChangedListener, // Only show each hint once automatically in the process life. private final CompatUIHintsState mCompatUIHintsState; - // Indicates if the keyguard is currently occluded, in which case compat UIs shouldn't + // Indicates if the keyguard is currently showing, in which case compat UIs shouldn't // be shown. - private boolean mKeyguardOccluded; + private boolean mKeyguardShowing; public CompatUIController(Context context, DisplayController displayController, @@ -218,14 +218,14 @@ public class CompatUIController implements OnDisplaysChangedListener, } @VisibleForTesting - void onKeyguardOccludedChanged(boolean occluded) { - mKeyguardOccluded = occluded; - // Hide the compat UIs when keyguard is occluded. + void onKeyguardShowingChanged(boolean showing) { + mKeyguardShowing = showing; + // Hide the compat UIs when keyguard is showing. forAllLayouts(layout -> layout.updateVisibility(showOnDisplay(layout.getDisplayId()))); } private boolean showOnDisplay(int displayId) { - return !mKeyguardOccluded && !isImeShowingOnDisplay(displayId); + return !mKeyguardShowing && !isImeShowingOnDisplay(displayId); } private boolean isImeShowingOnDisplay(int displayId) { @@ -372,9 +372,9 @@ public class CompatUIController implements OnDisplaysChangedListener, @ExternalThread private class CompatUIImpl implements CompatUI { @Override - public void onKeyguardOccludedChanged(boolean occluded) { + public void onKeyguardShowingChanged(boolean showing) { mMainExecutor.execute(() -> { - CompatUIController.this.onKeyguardOccludedChanged(occluded); + CompatUIController.this.onKeyguardShowingChanged(showing); }); } } diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java index 29e40be457d1c..a31b287375520 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/compatui/CompatUIControllerTest.java @@ -325,17 +325,17 @@ public class CompatUIControllerTest extends ShellTestCase { } @Test - public void testChangeLayoutsVisibilityOnKeyguardOccludedChanged() { + public void testChangeLayoutsVisibilityOnKeyguardShowingChanged() { mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID, /* hasSizeCompat= */ true, CAMERA_COMPAT_CONTROL_HIDDEN), mMockTaskListener); - // Verify that the restart button is hidden after keyguard becomes occluded. - mController.onKeyguardOccludedChanged(true); + // Verify that the restart button is hidden after keyguard becomes showing. + mController.onKeyguardShowingChanged(true); verify(mMockCompatLayout).updateVisibility(false); verify(mMockLetterboxEduLayout).updateVisibility(false); - // Verify button remains hidden while keyguard is occluded. + // Verify button remains hidden while keyguard is showing. TaskInfo taskInfo = createTaskInfo(DISPLAY_ID, TASK_ID, /* hasSizeCompat= */ true, CAMERA_COMPAT_CONTROL_HIDDEN); mController.onCompatInfoChanged(taskInfo, mMockTaskListener); @@ -345,20 +345,20 @@ public class CompatUIControllerTest extends ShellTestCase { verify(mMockLetterboxEduLayout).updateCompatInfo(taskInfo, mMockTaskListener, /* canShow= */ false); - // Verify button is shown after keyguard becomes not occluded. - mController.onKeyguardOccludedChanged(false); + // Verify button is shown after keyguard becomes not showing. + mController.onKeyguardShowingChanged(false); verify(mMockCompatLayout).updateVisibility(true); verify(mMockLetterboxEduLayout).updateVisibility(true); } @Test - public void testLayoutsRemainHiddenOnKeyguardOccludedFalseWhenImeIsShowing() { + public void testLayoutsRemainHiddenOnKeyguardShowingFalseWhenImeIsShowing() { mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID, /* hasSizeCompat= */ true, CAMERA_COMPAT_CONTROL_HIDDEN), mMockTaskListener); mController.onImeVisibilityChanged(DISPLAY_ID, /* isShowing= */ true); - mController.onKeyguardOccludedChanged(true); + mController.onKeyguardShowingChanged(true); verify(mMockCompatLayout, times(2)).updateVisibility(false); verify(mMockLetterboxEduLayout, times(2)).updateVisibility(false); @@ -366,8 +366,8 @@ public class CompatUIControllerTest extends ShellTestCase { clearInvocations(mMockCompatLayout); clearInvocations(mMockLetterboxEduLayout); - // Verify button remains hidden after keyguard becomes not occluded since IME is showing. - mController.onKeyguardOccludedChanged(false); + // Verify button remains hidden after keyguard becomes not showing since IME is showing. + mController.onKeyguardShowingChanged(false); verify(mMockCompatLayout).updateVisibility(false); verify(mMockLetterboxEduLayout).updateVisibility(false); @@ -380,12 +380,12 @@ public class CompatUIControllerTest extends ShellTestCase { } @Test - public void testLayoutsRemainHiddenOnImeHideWhenKeyguardIsOccluded() { + public void testLayoutsRemainHiddenOnImeHideWhenKeyguardIsShowing() { mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID, /* hasSizeCompat= */ true, CAMERA_COMPAT_CONTROL_HIDDEN), mMockTaskListener); mController.onImeVisibilityChanged(DISPLAY_ID, /* isShowing= */ true); - mController.onKeyguardOccludedChanged(true); + mController.onKeyguardShowingChanged(true); verify(mMockCompatLayout, times(2)).updateVisibility(false); verify(mMockLetterboxEduLayout, times(2)).updateVisibility(false); @@ -393,14 +393,14 @@ public class CompatUIControllerTest extends ShellTestCase { clearInvocations(mMockCompatLayout); clearInvocations(mMockLetterboxEduLayout); - // Verify button remains hidden after IME is hidden since keyguard is occluded. + // Verify button remains hidden after IME is hidden since keyguard is showing. mController.onImeVisibilityChanged(DISPLAY_ID, /* isShowing= */ false); verify(mMockCompatLayout).updateVisibility(false); verify(mMockLetterboxEduLayout).updateVisibility(false); - // Verify button is shown after keyguard becomes not occluded. - mController.onKeyguardOccludedChanged(false); + // Verify button is shown after keyguard becomes not showing. + mController.onKeyguardShowingChanged(false); verify(mMockCompatLayout).updateVisibility(true); verify(mMockLetterboxEduLayout).updateVisibility(true); diff --git a/packages/SystemUI/src/com/android/systemui/wmshell/WMShell.java b/packages/SystemUI/src/com/android/systemui/wmshell/WMShell.java index b2a79b01fb746..6f100abc3bf8c 100644 --- a/packages/SystemUI/src/com/android/systemui/wmshell/WMShell.java +++ b/packages/SystemUI/src/com/android/systemui/wmshell/WMShell.java @@ -51,6 +51,7 @@ import com.android.systemui.navigationbar.NavigationModeController; import com.android.systemui.shared.tracing.ProtoTraceable; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.policy.ConfigurationController; +import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.statusbar.policy.UserInfoController; import com.android.systemui.tracing.ProtoTracer; import com.android.systemui.tracing.nano.SystemUiTraceProto; @@ -118,6 +119,7 @@ public final class WMShell extends CoreStartable private final CommandQueue mCommandQueue; private final ConfigurationController mConfigurationController; + private final KeyguardStateController mKeyguardStateController; private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; private final NavigationModeController mNavigationModeController; private final ScreenLifecycle mScreenLifecycle; @@ -132,7 +134,7 @@ public final class WMShell extends CoreStartable private KeyguardUpdateMonitorCallback mSplitScreenKeyguardCallback; private KeyguardUpdateMonitorCallback mPipKeyguardCallback; private KeyguardUpdateMonitorCallback mOneHandedKeyguardCallback; - private KeyguardUpdateMonitorCallback mCompatUIKeyguardCallback; + private KeyguardStateController.Callback mCompatUIKeyguardCallback; private WakefulnessLifecycle.Observer mWakefulnessObserver; @Inject @@ -147,6 +149,7 @@ public final class WMShell extends CoreStartable Optional dragAndDropOptional, CommandQueue commandQueue, ConfigurationController configurationController, + KeyguardStateController keyguardStateController, KeyguardUpdateMonitor keyguardUpdateMonitor, NavigationModeController navigationModeController, ScreenLifecycle screenLifecycle, @@ -158,6 +161,7 @@ public final class WMShell extends CoreStartable super(context); mCommandQueue = commandQueue; mConfigurationController = configurationController; + mKeyguardStateController = keyguardStateController; mKeyguardUpdateMonitor = keyguardUpdateMonitor; mNavigationModeController = navigationModeController; mScreenLifecycle = screenLifecycle; @@ -383,13 +387,13 @@ public final class WMShell extends CoreStartable @VisibleForTesting void initCompatUi(CompatUI sizeCompatUI) { - mCompatUIKeyguardCallback = new KeyguardUpdateMonitorCallback() { + mCompatUIKeyguardCallback = new KeyguardStateController.Callback() { @Override - public void onKeyguardOccludedChanged(boolean occluded) { - sizeCompatUI.onKeyguardOccludedChanged(occluded); + public void onKeyguardShowingChanged() { + sizeCompatUI.onKeyguardShowingChanged(mKeyguardStateController.isShowing()); } }; - mKeyguardUpdateMonitor.registerCallback(mCompatUIKeyguardCallback); + mKeyguardStateController.addCallback(mCompatUIKeyguardCallback); } void initDragAndDrop(DragAndDrop dragAndDrop) { diff --git a/packages/SystemUI/tests/src/com/android/systemui/wmshell/WMShellTest.java b/packages/SystemUI/tests/src/com/android/systemui/wmshell/WMShellTest.java index 6593823183f8d..42899fdd5753b 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/wmshell/WMShellTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/wmshell/WMShellTest.java @@ -32,6 +32,7 @@ import com.android.systemui.model.SysUiState; import com.android.systemui.navigationbar.NavigationModeController; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.policy.ConfigurationController; +import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.statusbar.policy.UserInfoController; import com.android.systemui.tracing.ProtoTracer; import com.android.wm.shell.ShellCommandHandler; @@ -67,6 +68,7 @@ public class WMShellTest extends SysuiTestCase { @Mock CommandQueue mCommandQueue; @Mock ConfigurationController mConfigurationController; + @Mock KeyguardStateController mKeyguardStateController; @Mock KeyguardUpdateMonitor mKeyguardUpdateMonitor; @Mock NavigationModeController mNavigationModeController; @Mock ScreenLifecycle mScreenLifecycle; @@ -92,9 +94,9 @@ public class WMShellTest extends SysuiTestCase { Optional.of(mSplitScreen), Optional.of(mOneHanded), Optional.of(mHideDisplayCutout), Optional.of(mShellCommandHandler), Optional.of(mCompatUI), Optional.of(mDragAndDrop), - mCommandQueue, mConfigurationController, mKeyguardUpdateMonitor, - mNavigationModeController, mScreenLifecycle, mSysUiState, mProtoTracer, - mWakefulnessLifecycle, mUserInfoController, mSysUiMainExecutor); + mCommandQueue, mConfigurationController, mKeyguardStateController, + mKeyguardUpdateMonitor, mNavigationModeController, mScreenLifecycle, mSysUiState, + mProtoTracer, mWakefulnessLifecycle, mUserInfoController, mSysUiMainExecutor); } @Test @@ -141,6 +143,6 @@ public class WMShellTest extends SysuiTestCase { public void initCompatUI_registersCallbacks() { mWMShell.initCompatUi(mCompatUI); - verify(mKeyguardUpdateMonitor).registerCallback(any(KeyguardUpdateMonitorCallback.class)); + verify(mKeyguardStateController).addCallback(any(KeyguardStateController.Callback.class)); } }