Merge "Check if keyguard is showing instead of occluded for compat UI." into tm-dev am: 687af63e66

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

Change-Id: I4ee8be64429eb2901a443058f1b8b1128851bcc5
This commit is contained in:
Tom Natan
2022-03-07 15:45:59 +00:00
committed by Automerger Merge Worker
5 changed files with 45 additions and 36 deletions

View File

@@ -24,9 +24,12 @@ import com.android.wm.shell.common.annotations.ExternalThread;
@ExternalThread @ExternalThread
public interface CompatUI { public interface CompatUI {
/** /**
* Called when the keyguard occluded state changes. Removes all compat UIs if the * Called when the keyguard showing state changes. Removes all compat UIs if the
* keyguard is now occluded. * keyguard is now showing.
* @param occluded indicates if the keyguard is now occluded. *
* <p>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);
} }

View File

@@ -109,9 +109,9 @@ public class CompatUIController implements OnDisplaysChangedListener,
// Only show each hint once automatically in the process life. // Only show each hint once automatically in the process life.
private final CompatUIHintsState mCompatUIHintsState; 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. // be shown.
private boolean mKeyguardOccluded; private boolean mKeyguardShowing;
public CompatUIController(Context context, public CompatUIController(Context context,
DisplayController displayController, DisplayController displayController,
@@ -218,14 +218,14 @@ public class CompatUIController implements OnDisplaysChangedListener,
} }
@VisibleForTesting @VisibleForTesting
void onKeyguardOccludedChanged(boolean occluded) { void onKeyguardShowingChanged(boolean showing) {
mKeyguardOccluded = occluded; mKeyguardShowing = showing;
// Hide the compat UIs when keyguard is occluded. // Hide the compat UIs when keyguard is showing.
forAllLayouts(layout -> layout.updateVisibility(showOnDisplay(layout.getDisplayId()))); forAllLayouts(layout -> layout.updateVisibility(showOnDisplay(layout.getDisplayId())));
} }
private boolean showOnDisplay(int displayId) { private boolean showOnDisplay(int displayId) {
return !mKeyguardOccluded && !isImeShowingOnDisplay(displayId); return !mKeyguardShowing && !isImeShowingOnDisplay(displayId);
} }
private boolean isImeShowingOnDisplay(int displayId) { private boolean isImeShowingOnDisplay(int displayId) {
@@ -372,9 +372,9 @@ public class CompatUIController implements OnDisplaysChangedListener,
@ExternalThread @ExternalThread
private class CompatUIImpl implements CompatUI { private class CompatUIImpl implements CompatUI {
@Override @Override
public void onKeyguardOccludedChanged(boolean occluded) { public void onKeyguardShowingChanged(boolean showing) {
mMainExecutor.execute(() -> { mMainExecutor.execute(() -> {
CompatUIController.this.onKeyguardOccludedChanged(occluded); CompatUIController.this.onKeyguardShowingChanged(showing);
}); });
} }
} }

View File

@@ -325,17 +325,17 @@ public class CompatUIControllerTest extends ShellTestCase {
} }
@Test @Test
public void testChangeLayoutsVisibilityOnKeyguardOccludedChanged() { public void testChangeLayoutsVisibilityOnKeyguardShowingChanged() {
mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID, mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID,
/* hasSizeCompat= */ true, CAMERA_COMPAT_CONTROL_HIDDEN), mMockTaskListener); /* hasSizeCompat= */ true, CAMERA_COMPAT_CONTROL_HIDDEN), mMockTaskListener);
// Verify that the restart button is hidden after keyguard becomes occluded. // Verify that the restart button is hidden after keyguard becomes showing.
mController.onKeyguardOccludedChanged(true); mController.onKeyguardShowingChanged(true);
verify(mMockCompatLayout).updateVisibility(false); verify(mMockCompatLayout).updateVisibility(false);
verify(mMockLetterboxEduLayout).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, TaskInfo taskInfo = createTaskInfo(DISPLAY_ID, TASK_ID, /* hasSizeCompat= */ true,
CAMERA_COMPAT_CONTROL_HIDDEN); CAMERA_COMPAT_CONTROL_HIDDEN);
mController.onCompatInfoChanged(taskInfo, mMockTaskListener); mController.onCompatInfoChanged(taskInfo, mMockTaskListener);
@@ -345,20 +345,20 @@ public class CompatUIControllerTest extends ShellTestCase {
verify(mMockLetterboxEduLayout).updateCompatInfo(taskInfo, mMockTaskListener, /* canShow= */ verify(mMockLetterboxEduLayout).updateCompatInfo(taskInfo, mMockTaskListener, /* canShow= */
false); false);
// Verify button is shown after keyguard becomes not occluded. // Verify button is shown after keyguard becomes not showing.
mController.onKeyguardOccludedChanged(false); mController.onKeyguardShowingChanged(false);
verify(mMockCompatLayout).updateVisibility(true); verify(mMockCompatLayout).updateVisibility(true);
verify(mMockLetterboxEduLayout).updateVisibility(true); verify(mMockLetterboxEduLayout).updateVisibility(true);
} }
@Test @Test
public void testLayoutsRemainHiddenOnKeyguardOccludedFalseWhenImeIsShowing() { public void testLayoutsRemainHiddenOnKeyguardShowingFalseWhenImeIsShowing() {
mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID, mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID,
/* hasSizeCompat= */ true, CAMERA_COMPAT_CONTROL_HIDDEN), mMockTaskListener); /* hasSizeCompat= */ true, CAMERA_COMPAT_CONTROL_HIDDEN), mMockTaskListener);
mController.onImeVisibilityChanged(DISPLAY_ID, /* isShowing= */ true); mController.onImeVisibilityChanged(DISPLAY_ID, /* isShowing= */ true);
mController.onKeyguardOccludedChanged(true); mController.onKeyguardShowingChanged(true);
verify(mMockCompatLayout, times(2)).updateVisibility(false); verify(mMockCompatLayout, times(2)).updateVisibility(false);
verify(mMockLetterboxEduLayout, times(2)).updateVisibility(false); verify(mMockLetterboxEduLayout, times(2)).updateVisibility(false);
@@ -366,8 +366,8 @@ public class CompatUIControllerTest extends ShellTestCase {
clearInvocations(mMockCompatLayout); clearInvocations(mMockCompatLayout);
clearInvocations(mMockLetterboxEduLayout); clearInvocations(mMockLetterboxEduLayout);
// Verify button remains hidden after keyguard becomes not occluded since IME is showing. // Verify button remains hidden after keyguard becomes not showing since IME is showing.
mController.onKeyguardOccludedChanged(false); mController.onKeyguardShowingChanged(false);
verify(mMockCompatLayout).updateVisibility(false); verify(mMockCompatLayout).updateVisibility(false);
verify(mMockLetterboxEduLayout).updateVisibility(false); verify(mMockLetterboxEduLayout).updateVisibility(false);
@@ -380,12 +380,12 @@ public class CompatUIControllerTest extends ShellTestCase {
} }
@Test @Test
public void testLayoutsRemainHiddenOnImeHideWhenKeyguardIsOccluded() { public void testLayoutsRemainHiddenOnImeHideWhenKeyguardIsShowing() {
mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID, mController.onCompatInfoChanged(createTaskInfo(DISPLAY_ID, TASK_ID,
/* hasSizeCompat= */ true, CAMERA_COMPAT_CONTROL_HIDDEN), mMockTaskListener); /* hasSizeCompat= */ true, CAMERA_COMPAT_CONTROL_HIDDEN), mMockTaskListener);
mController.onImeVisibilityChanged(DISPLAY_ID, /* isShowing= */ true); mController.onImeVisibilityChanged(DISPLAY_ID, /* isShowing= */ true);
mController.onKeyguardOccludedChanged(true); mController.onKeyguardShowingChanged(true);
verify(mMockCompatLayout, times(2)).updateVisibility(false); verify(mMockCompatLayout, times(2)).updateVisibility(false);
verify(mMockLetterboxEduLayout, times(2)).updateVisibility(false); verify(mMockLetterboxEduLayout, times(2)).updateVisibility(false);
@@ -393,14 +393,14 @@ public class CompatUIControllerTest extends ShellTestCase {
clearInvocations(mMockCompatLayout); clearInvocations(mMockCompatLayout);
clearInvocations(mMockLetterboxEduLayout); 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); mController.onImeVisibilityChanged(DISPLAY_ID, /* isShowing= */ false);
verify(mMockCompatLayout).updateVisibility(false); verify(mMockCompatLayout).updateVisibility(false);
verify(mMockLetterboxEduLayout).updateVisibility(false); verify(mMockLetterboxEduLayout).updateVisibility(false);
// Verify button is shown after keyguard becomes not occluded. // Verify button is shown after keyguard becomes not showing.
mController.onKeyguardOccludedChanged(false); mController.onKeyguardShowingChanged(false);
verify(mMockCompatLayout).updateVisibility(true); verify(mMockCompatLayout).updateVisibility(true);
verify(mMockLetterboxEduLayout).updateVisibility(true); verify(mMockLetterboxEduLayout).updateVisibility(true);

View File

@@ -51,6 +51,7 @@ import com.android.systemui.navigationbar.NavigationModeController;
import com.android.systemui.shared.tracing.ProtoTraceable; import com.android.systemui.shared.tracing.ProtoTraceable;
import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.policy.ConfigurationController; 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.statusbar.policy.UserInfoController;
import com.android.systemui.tracing.ProtoTracer; import com.android.systemui.tracing.ProtoTracer;
import com.android.systemui.tracing.nano.SystemUiTraceProto; import com.android.systemui.tracing.nano.SystemUiTraceProto;
@@ -116,6 +117,7 @@ public final class WMShell extends CoreStartable
private final CommandQueue mCommandQueue; private final CommandQueue mCommandQueue;
private final ConfigurationController mConfigurationController; private final ConfigurationController mConfigurationController;
private final KeyguardStateController mKeyguardStateController;
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
private final NavigationModeController mNavigationModeController; private final NavigationModeController mNavigationModeController;
private final ScreenLifecycle mScreenLifecycle; private final ScreenLifecycle mScreenLifecycle;
@@ -129,7 +131,7 @@ public final class WMShell extends CoreStartable
private KeyguardUpdateMonitorCallback mSplitScreenKeyguardCallback; private KeyguardUpdateMonitorCallback mSplitScreenKeyguardCallback;
private KeyguardUpdateMonitorCallback mPipKeyguardCallback; private KeyguardUpdateMonitorCallback mPipKeyguardCallback;
private KeyguardUpdateMonitorCallback mOneHandedKeyguardCallback; private KeyguardUpdateMonitorCallback mOneHandedKeyguardCallback;
private KeyguardUpdateMonitorCallback mCompatUIKeyguardCallback; private KeyguardStateController.Callback mCompatUIKeyguardCallback;
private WakefulnessLifecycle.Observer mWakefulnessObserver; private WakefulnessLifecycle.Observer mWakefulnessObserver;
@Inject @Inject
@@ -143,6 +145,7 @@ public final class WMShell extends CoreStartable
Optional<DragAndDrop> dragAndDropOptional, Optional<DragAndDrop> dragAndDropOptional,
CommandQueue commandQueue, CommandQueue commandQueue,
ConfigurationController configurationController, ConfigurationController configurationController,
KeyguardStateController keyguardStateController,
KeyguardUpdateMonitor keyguardUpdateMonitor, KeyguardUpdateMonitor keyguardUpdateMonitor,
NavigationModeController navigationModeController, NavigationModeController navigationModeController,
ScreenLifecycle screenLifecycle, ScreenLifecycle screenLifecycle,
@@ -154,6 +157,7 @@ public final class WMShell extends CoreStartable
super(context); super(context);
mCommandQueue = commandQueue; mCommandQueue = commandQueue;
mConfigurationController = configurationController; mConfigurationController = configurationController;
mKeyguardStateController = keyguardStateController;
mKeyguardUpdateMonitor = keyguardUpdateMonitor; mKeyguardUpdateMonitor = keyguardUpdateMonitor;
mNavigationModeController = navigationModeController; mNavigationModeController = navigationModeController;
mScreenLifecycle = screenLifecycle; mScreenLifecycle = screenLifecycle;
@@ -362,13 +366,13 @@ public final class WMShell extends CoreStartable
@VisibleForTesting @VisibleForTesting
void initCompatUi(CompatUI sizeCompatUI) { void initCompatUi(CompatUI sizeCompatUI) {
mCompatUIKeyguardCallback = new KeyguardUpdateMonitorCallback() { mCompatUIKeyguardCallback = new KeyguardStateController.Callback() {
@Override @Override
public void onKeyguardOccludedChanged(boolean occluded) { public void onKeyguardShowingChanged() {
sizeCompatUI.onKeyguardOccludedChanged(occluded); sizeCompatUI.onKeyguardShowingChanged(mKeyguardStateController.isShowing());
} }
}; };
mKeyguardUpdateMonitor.registerCallback(mCompatUIKeyguardCallback); mKeyguardStateController.addCallback(mCompatUIKeyguardCallback);
} }
void initDragAndDrop(DragAndDrop dragAndDrop) { void initDragAndDrop(DragAndDrop dragAndDrop) {

View File

@@ -32,6 +32,7 @@ import com.android.systemui.model.SysUiState;
import com.android.systemui.navigationbar.NavigationModeController; import com.android.systemui.navigationbar.NavigationModeController;
import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.policy.ConfigurationController; 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.statusbar.policy.UserInfoController;
import com.android.systemui.tracing.ProtoTracer; import com.android.systemui.tracing.ProtoTracer;
import com.android.wm.shell.ShellCommandHandler; import com.android.wm.shell.ShellCommandHandler;
@@ -66,6 +67,7 @@ public class WMShellTest extends SysuiTestCase {
@Mock CommandQueue mCommandQueue; @Mock CommandQueue mCommandQueue;
@Mock ConfigurationController mConfigurationController; @Mock ConfigurationController mConfigurationController;
@Mock KeyguardStateController mKeyguardStateController;
@Mock KeyguardUpdateMonitor mKeyguardUpdateMonitor; @Mock KeyguardUpdateMonitor mKeyguardUpdateMonitor;
@Mock NavigationModeController mNavigationModeController; @Mock NavigationModeController mNavigationModeController;
@Mock ScreenLifecycle mScreenLifecycle; @Mock ScreenLifecycle mScreenLifecycle;
@@ -90,9 +92,9 @@ public class WMShellTest extends SysuiTestCase {
Optional.of(mSplitScreen), Optional.of(mOneHanded), Optional.of(mHideDisplayCutout), Optional.of(mSplitScreen), Optional.of(mOneHanded), Optional.of(mHideDisplayCutout),
Optional.of(mShellCommandHandler), Optional.of(mCompatUI), Optional.of(mShellCommandHandler), Optional.of(mCompatUI),
Optional.of(mDragAndDrop), Optional.of(mDragAndDrop),
mCommandQueue, mConfigurationController, mKeyguardUpdateMonitor, mCommandQueue, mConfigurationController, mKeyguardStateController,
mNavigationModeController, mScreenLifecycle, mSysUiState, mProtoTracer, mKeyguardUpdateMonitor, mNavigationModeController, mScreenLifecycle, mSysUiState,
mWakefulnessLifecycle, mUserInfoController, mSysUiMainExecutor); mProtoTracer, mWakefulnessLifecycle, mUserInfoController, mSysUiMainExecutor);
} }
@Test @Test
@@ -132,6 +134,6 @@ public class WMShellTest extends SysuiTestCase {
public void initCompatUI_registersCallbacks() { public void initCompatUI_registersCallbacks() {
mWMShell.initCompatUi(mCompatUI); mWMShell.initCompatUi(mCompatUI);
verify(mKeyguardUpdateMonitor).registerCallback(any(KeyguardUpdateMonitorCallback.class)); verify(mKeyguardStateController).addCallback(any(KeyguardStateController.Callback.class));
} }
} }