Merge "Check if keyguard is showing instead of occluded for compat UI." into tm-dev
This commit is contained in:
@@ -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.
|
||||
*
|
||||
* <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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
@@ -116,6 +117,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;
|
||||
@@ -129,7 +131,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
|
||||
@@ -143,6 +145,7 @@ public final class WMShell extends CoreStartable
|
||||
Optional<DragAndDrop> dragAndDropOptional,
|
||||
CommandQueue commandQueue,
|
||||
ConfigurationController configurationController,
|
||||
KeyguardStateController keyguardStateController,
|
||||
KeyguardUpdateMonitor keyguardUpdateMonitor,
|
||||
NavigationModeController navigationModeController,
|
||||
ScreenLifecycle screenLifecycle,
|
||||
@@ -154,6 +157,7 @@ public final class WMShell extends CoreStartable
|
||||
super(context);
|
||||
mCommandQueue = commandQueue;
|
||||
mConfigurationController = configurationController;
|
||||
mKeyguardStateController = keyguardStateController;
|
||||
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
|
||||
mNavigationModeController = navigationModeController;
|
||||
mScreenLifecycle = screenLifecycle;
|
||||
@@ -362,13 +366,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) {
|
||||
|
||||
@@ -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;
|
||||
@@ -66,6 +67,7 @@ public class WMShellTest extends SysuiTestCase {
|
||||
|
||||
@Mock CommandQueue mCommandQueue;
|
||||
@Mock ConfigurationController mConfigurationController;
|
||||
@Mock KeyguardStateController mKeyguardStateController;
|
||||
@Mock KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||
@Mock NavigationModeController mNavigationModeController;
|
||||
@Mock ScreenLifecycle mScreenLifecycle;
|
||||
@@ -90,9 +92,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
|
||||
@@ -132,6 +134,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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user