Merge "Fix One-handed mode truncated screen when device rotates in multiple user mode" into sc-v2-dev
This commit is contained in:
@@ -43,6 +43,7 @@ import android.util.Slog;
|
|||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.view.accessibility.AccessibilityManager;
|
import android.view.accessibility.AccessibilityManager;
|
||||||
|
import android.window.WindowContainerTransaction;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@@ -64,7 +65,8 @@ import java.io.PrintWriter;
|
|||||||
/**
|
/**
|
||||||
* Manages and manipulates the one handed states, transitions, and gesture for phones.
|
* Manages and manipulates the one handed states, transitions, and gesture for phones.
|
||||||
*/
|
*/
|
||||||
public class OneHandedController implements RemoteCallable<OneHandedController> {
|
public class OneHandedController implements RemoteCallable<OneHandedController>,
|
||||||
|
DisplayChangeController.OnDisplayChangingListener {
|
||||||
private static final String TAG = "OneHandedController";
|
private static final String TAG = "OneHandedController";
|
||||||
|
|
||||||
private static final String ONE_HANDED_MODE_OFFSET_PERCENTAGE =
|
private static final String ONE_HANDED_MODE_OFFSET_PERCENTAGE =
|
||||||
@@ -106,19 +108,6 @@ public class OneHandedController implements RemoteCallable<OneHandedController>
|
|||||||
private OneHandedBackgroundPanelOrganizer mBackgroundPanelOrganizer;
|
private OneHandedBackgroundPanelOrganizer mBackgroundPanelOrganizer;
|
||||||
private OneHandedUiEventLogger mOneHandedUiEventLogger;
|
private OneHandedUiEventLogger mOneHandedUiEventLogger;
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle rotation based on OnDisplayChangingListener callback
|
|
||||||
*/
|
|
||||||
private final DisplayChangeController.OnDisplayChangingListener mRotationController =
|
|
||||||
(display, fromRotation, toRotation, wct) -> {
|
|
||||||
if (!isInitialized()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mDisplayAreaOrganizer.onRotateDisplay(mContext, toRotation, wct);
|
|
||||||
mOneHandedUiEventLogger.writeEvent(
|
|
||||||
OneHandedUiEventLogger.EVENT_ONE_HANDED_TRIGGER_ROTATION_OUT);
|
|
||||||
};
|
|
||||||
|
|
||||||
private final DisplayController.OnDisplaysChangedListener mDisplaysChangedListener =
|
private final DisplayController.OnDisplaysChangedListener mDisplaysChangedListener =
|
||||||
new DisplayController.OnDisplaysChangedListener() {
|
new DisplayController.OnDisplaysChangedListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -296,7 +285,7 @@ public class OneHandedController implements RemoteCallable<OneHandedController>
|
|||||||
getObserver(this::onSwipeToNotificationEnabledChanged);
|
getObserver(this::onSwipeToNotificationEnabledChanged);
|
||||||
mShortcutEnabledObserver = getObserver(this::onShortcutEnabledChanged);
|
mShortcutEnabledObserver = getObserver(this::onShortcutEnabledChanged);
|
||||||
|
|
||||||
mDisplayController.addDisplayChangingController(mRotationController);
|
mDisplayController.addDisplayChangingController(this);
|
||||||
setupCallback();
|
setupCallback();
|
||||||
registerSettingObservers(mUserId);
|
registerSettingObservers(mUserId);
|
||||||
setupTimeoutListener();
|
setupTimeoutListener();
|
||||||
@@ -744,6 +733,27 @@ public class OneHandedController implements RemoteCallable<OneHandedController>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles rotation based on OnDisplayChangingListener callback
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onRotateDisplay(int displayId, int fromRotation, int toRotation,
|
||||||
|
WindowContainerTransaction wct) {
|
||||||
|
if (!isInitialized()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mOneHandedSettingsUtil.getSettingsOneHandedModeEnabled(mContext.getContentResolver(),
|
||||||
|
mUserId) || mOneHandedSettingsUtil.getSettingsSwipeToNotificationEnabled(
|
||||||
|
mContext.getContentResolver(), mUserId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mDisplayAreaOrganizer.onRotateDisplay(mContext, toRotation, wct);
|
||||||
|
mOneHandedUiEventLogger.writeEvent(
|
||||||
|
OneHandedUiEventLogger.EVENT_ONE_HANDED_TRIGGER_ROTATION_OUT);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The interface for calls from outside the Shell, within the host process.
|
* The interface for calls from outside the Shell, within the host process.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
package com.android.wm.shell.onehanded;
|
package com.android.wm.shell.onehanded;
|
||||||
|
|
||||||
import static android.os.UserHandle.myUserId;
|
|
||||||
|
|
||||||
import static com.android.wm.shell.onehanded.OneHandedAnimationController.TRANSITION_DIRECTION_EXIT;
|
import static com.android.wm.shell.onehanded.OneHandedAnimationController.TRANSITION_DIRECTION_EXIT;
|
||||||
import static com.android.wm.shell.onehanded.OneHandedAnimationController.TRANSITION_DIRECTION_TRIGGER;
|
import static com.android.wm.shell.onehanded.OneHandedAnimationController.TRANSITION_DIRECTION_TRIGGER;
|
||||||
|
|
||||||
@@ -186,20 +184,8 @@ public class OneHandedDisplayAreaOrganizer extends DisplayAreaOrganizer {
|
|||||||
if (mDisplayLayout.rotation() == toRotation) {
|
if (mDisplayLayout.rotation() == toRotation) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mOneHandedSettingsUtil.getSettingsOneHandedModeEnabled(context.getContentResolver(),
|
|
||||||
myUserId())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mDisplayLayout.rotateTo(context.getResources(), toRotation);
|
mDisplayLayout.rotateTo(context.getResources(), toRotation);
|
||||||
updateDisplayBounds();
|
updateDisplayBounds();
|
||||||
|
|
||||||
if (mOneHandedSettingsUtil.getSettingsSwipeToNotificationEnabled(
|
|
||||||
context.getContentResolver(), myUserId())) {
|
|
||||||
// If current settings is swipe notification, skip finishOffset.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
finishOffset(0, TRANSITION_DIRECTION_EXIT);
|
finishOffset(0, TRANSITION_DIRECTION_EXIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ import android.util.ArrayMap;
|
|||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
import android.view.SurfaceControl;
|
import android.view.SurfaceControl;
|
||||||
|
import android.window.WindowContainerTransaction;
|
||||||
|
|
||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
|
|
||||||
@@ -331,6 +332,58 @@ public class OneHandedControllerTest extends OneHandedTestCase {
|
|||||||
verify(mMockDisplayAreaOrganizer, never()).scheduleOffset(anyInt(), anyInt());
|
verify(mMockDisplayAreaOrganizer, never()).scheduleOffset(anyInt(), anyInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOneHandedEnabledRotation90ShouldHandleRotate() {
|
||||||
|
when(mMockSettingsUitl.getSettingsOneHandedModeEnabled(any(), anyInt())).thenReturn(true);
|
||||||
|
when(mMockSettingsUitl.getSettingsSwipeToNotificationEnabled(any(), anyInt())).thenReturn(
|
||||||
|
false);
|
||||||
|
final WindowContainerTransaction handlerWCT = new WindowContainerTransaction();
|
||||||
|
mSpiedOneHandedController.onRotateDisplay(mDisplay.getDisplayId(), Surface.ROTATION_0,
|
||||||
|
Surface.ROTATION_90, handlerWCT);
|
||||||
|
|
||||||
|
verify(mMockDisplayAreaOrganizer, atLeastOnce()).onRotateDisplay(eq(mContext),
|
||||||
|
eq(Surface.ROTATION_90), any(WindowContainerTransaction.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOneHandedDisabledRotation90ShouldNotHandleRotate() {
|
||||||
|
when(mMockSettingsUitl.getSettingsOneHandedModeEnabled(any(), anyInt())).thenReturn(false);
|
||||||
|
when(mMockSettingsUitl.getSettingsSwipeToNotificationEnabled(any(), anyInt())).thenReturn(
|
||||||
|
false);
|
||||||
|
final WindowContainerTransaction handlerWCT = new WindowContainerTransaction();
|
||||||
|
mSpiedOneHandedController.onRotateDisplay(mDisplay.getDisplayId(), Surface.ROTATION_0,
|
||||||
|
Surface.ROTATION_90, handlerWCT);
|
||||||
|
|
||||||
|
verify(mMockDisplayAreaOrganizer, never()).onRotateDisplay(eq(mContext),
|
||||||
|
eq(Surface.ROTATION_90), any(WindowContainerTransaction.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSwipeToNotificationEnabledRotation90ShouldNotHandleRotate() {
|
||||||
|
when(mMockSettingsUitl.getSettingsOneHandedModeEnabled(any(), anyInt())).thenReturn(true);
|
||||||
|
when(mMockSettingsUitl.getSettingsSwipeToNotificationEnabled(any(), anyInt())).thenReturn(
|
||||||
|
true);
|
||||||
|
final WindowContainerTransaction handlerWCT = new WindowContainerTransaction();
|
||||||
|
mSpiedOneHandedController.onRotateDisplay(mDisplay.getDisplayId(), Surface.ROTATION_0,
|
||||||
|
Surface.ROTATION_90, handlerWCT);
|
||||||
|
|
||||||
|
verify(mMockDisplayAreaOrganizer, never()).onRotateDisplay(eq(mContext),
|
||||||
|
eq(Surface.ROTATION_90), any(WindowContainerTransaction.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSwipeToNotificationDisabledRotation90ShouldHandleRotate() {
|
||||||
|
when(mMockSettingsUitl.getSettingsOneHandedModeEnabled(any(), anyInt())).thenReturn(true);
|
||||||
|
when(mMockSettingsUitl.getSettingsSwipeToNotificationEnabled(any(), anyInt())).thenReturn(
|
||||||
|
false);
|
||||||
|
final WindowContainerTransaction handlerWCT = new WindowContainerTransaction();
|
||||||
|
mSpiedOneHandedController.onRotateDisplay(mDisplay.getDisplayId(), Surface.ROTATION_0,
|
||||||
|
Surface.ROTATION_90, handlerWCT);
|
||||||
|
|
||||||
|
verify(mMockDisplayAreaOrganizer, atLeastOnce()).onRotateDisplay(eq(mContext),
|
||||||
|
eq(Surface.ROTATION_90), any(WindowContainerTransaction.class));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStateActive_shortcutRequestActivate_skipActions() {
|
public void testStateActive_shortcutRequestActivate_skipActions() {
|
||||||
when(mSpiedTransitionState.getState()).thenReturn(STATE_ACTIVE);
|
when(mSpiedTransitionState.getState()).thenReturn(STATE_ACTIVE);
|
||||||
|
|||||||
Reference in New Issue
Block a user