Merge "Pass isLikelyToStartNewTask to onGestureStarted()" into ub-launcher3-rvc-dev
diff --git a/ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java b/ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java
index 0b7d4bf..e649ce1 100644
--- a/ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java
+++ b/ext_tests/src/com/android/launcher3/testing/DebugTestInformationHandler.java
@@ -23,6 +23,7 @@
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Color;
+import android.os.Binder;
import android.os.Bundle;
import android.os.Debug;
import android.system.Os;
@@ -171,11 +172,16 @@
}
case TestProtocol.REQUEST_CLEAR_DATA: {
- LauncherSettings.Settings.call(mContext.getContentResolver(),
- LauncherSettings.Settings.METHOD_CREATE_EMPTY_DB);
- MAIN_EXECUTOR.submit(() ->
- LauncherAppState.getInstance(mContext).getModel().forceReload());
- return response;
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ LauncherSettings.Settings.call(mContext.getContentResolver(),
+ LauncherSettings.Settings.METHOD_CREATE_EMPTY_DB);
+ MAIN_EXECUTOR.submit(() ->
+ LauncherAppState.getInstance(mContext).getModel().forceReload());
+ return response;
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
}
default:
diff --git a/quickstep/recents_ui_overrides/res/layout/predicted_hotseat_edu.xml b/quickstep/recents_ui_overrides/res/layout/predicted_hotseat_edu.xml
index 36c9b00..1dab482 100644
--- a/quickstep/recents_ui_overrides/res/layout/predicted_hotseat_edu.xml
+++ b/quickstep/recents_ui_overrides/res/layout/predicted_hotseat_edu.xml
@@ -90,6 +90,7 @@
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:text="@string/hotseat_edu_dismiss"
+ android:layout_gravity="start|center_vertical"
android:textColor="@android:color/white"/>
</FrameLayout>
<FrameLayout
@@ -102,7 +103,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
- android:gravity="end"
+ android:layout_gravity="end|center_vertical"
android:text="@string/hotseat_edu_accept"
android:textColor="@android:color/white"/>
</FrameLayout>
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatEduController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatEduController.java
index a1218ae..4f95254 100644
--- a/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatEduController.java
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatEduController.java
@@ -47,7 +47,6 @@
*/
public class HotseatEduController {
- public static final String KEY_HOTSEAT_EDU_SEEN = "hotseat_edu_seen";
public static final String HOTSEAT_EDU_ACTION =
"com.android.launcher3.action.SHOW_HYBRID_HOTSEAT_EDU";
public static final String SETTINGS_ACTION =
@@ -229,7 +228,6 @@
void finishOnboarding() {
mOnOnboardingComplete.run();
- mLauncher.getSharedPrefs().edit().putBoolean(KEY_HOTSEAT_EDU_SEEN, true).apply();
}
void showDimissTip() {
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java
index 7334d80..1dbb9e2 100644
--- a/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java
@@ -155,14 +155,6 @@
}
/**
- * Returns whether or not user has seen hybrid hotseat education
- */
- public boolean isEduSeen() {
- return mLauncher.getSharedPrefs().getBoolean(HotseatEduController.KEY_HOTSEAT_EDU_SEEN,
- false);
- }
-
- /**
* Shows appropriate hotseat education based on prediction enabled and migration states.
*/
public void showEdu() {
@@ -172,7 +164,7 @@
Snackbar.show(mLauncher, R.string.hotsaet_tip_prediction_disabled,
R.string.hotseat_prediction_settings, null,
() -> mLauncher.startActivity(getSettingsIntent()));
- } else if (isEduSeen() || getPredictedIcons().size() >= (mHotSeatItemsCount + 1) / 2) {
+ } else if (getPredictedIcons().size() >= (mHotSeatItemsCount + 1) / 2) {
showDiscoveryTip();
} else {
HotseatEduController eduController = new HotseatEduController(mLauncher,
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/TaskOverlayFactory.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/TaskOverlayFactory.java
index 01936e4..e9614d1 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/TaskOverlayFactory.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/TaskOverlayFactory.java
@@ -148,7 +148,7 @@
boolean rotated) {
final boolean isAllowedByPolicy = thumbnail.isRealSnapshot;
- mActionsView.updateDisabledFlags(DISABLED_ROTATED, rotated);
+ getActionsView().updateDisabledFlags(DISABLED_ROTATED, rotated);
getActionsView().setCallbacks(new OverlayUICallbacks() {
@Override
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskMenuView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskMenuView.java
index 512bbac..ef66b7a 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskMenuView.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskMenuView.java
@@ -235,7 +235,8 @@
Rect insets = mActivity.getDragLayer().getInsets();
BaseDragLayer.LayoutParams params = (BaseDragLayer.LayoutParams) getLayoutParams();
params.width = orientationHandler.getTaskMenuWidth(taskView.getThumbnail());
- params.gravity = Gravity.START;
+ // Gravity set to Left instead of Start as sTempRect.left measures Left distance not Start
+ params.gravity = Gravity.LEFT;
setLayoutParams(params);
setScaleX(taskView.getScaleX());
setScaleY(taskView.getScaleY());
diff --git a/quickstep/robolectric_tests/src/com/android/quickstep/OrientationTouchTransformerTest.java b/quickstep/robolectric_tests/src/com/android/quickstep/OrientationTouchTransformerTest.java
index 53f37c1..22d205a 100644
--- a/quickstep/robolectric_tests/src/com/android/quickstep/OrientationTouchTransformerTest.java
+++ b/quickstep/robolectric_tests/src/com/android/quickstep/OrientationTouchTransformerTest.java
@@ -59,6 +59,7 @@
mResources = mock(Resources.class);
when(mResources.getBoolean(anyInt())).thenReturn(true);
when(mResources.getDimension(anyInt())).thenReturn(10.0f);
+ when(mResources.getDimensionPixelSize(anyInt())).thenReturn(10);
DisplayMetrics mockDisplayMetrics = new DisplayMetrics();
mockDisplayMetrics.density = DENSITY_DISPLAY_METRICS;
when(mResources.getDisplayMetrics()).thenReturn(mockDisplayMetrics);
@@ -67,53 +68,114 @@
}
@Test
- public void disabledMultipeRegions_shouldOverrideFirstRegion() {
- mTouchTransformer.createOrAddTouchRegion(mInfo);
- DefaultDisplay.Info info2 = createDisplayInfo(Surface.ROTATION_90);
- mTouchTransformer.createOrAddTouchRegion(info2);
+ public void disabledMultipleRegions_shouldOverrideFirstRegion() {
+ float portraitRegionY = generateTouchRegionHeight(Surface.ROTATION_0) + 1;
+ float landscapeRegionY = generateTouchRegionHeight(Surface.ROTATION_90) + 1;
- float y = generateTouchRegionHeight(Surface.ROTATION_0) + 1;
- MotionEvent inOldRegion = generateMotionEvent(MotionEvent.ACTION_DOWN, 100, y);
- mTouchTransformer.transform(inOldRegion);
- assertFalse(mTouchTransformer.touchInValidSwipeRegions(inOldRegion.getX(), inOldRegion.getY()));
+ mTouchTransformer.createOrAddTouchRegion(mInfo);
+ tapAndAssertTrue(100, portraitRegionY,
+ event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY()));
+ tapAndAssertFalse(100, landscapeRegionY,
+ event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY()));
+ tapAndAssertTrue(0, portraitRegionY,
+ event -> mTouchTransformer.touchInAssistantRegion(event));
+ tapAndAssertFalse(0, landscapeRegionY,
+ event -> mTouchTransformer.touchInAssistantRegion(event));
// Override region
+ mTouchTransformer.createOrAddTouchRegion(createDisplayInfo(Surface.ROTATION_90));
+ tapAndAssertFalse(100, portraitRegionY,
+ event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY()));
+ tapAndAssertTrue(100, landscapeRegionY,
+ event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY()));
+ tapAndAssertFalse(0, portraitRegionY,
+ event -> mTouchTransformer.touchInAssistantRegion(event));
+ tapAndAssertTrue(0, landscapeRegionY,
+ event -> mTouchTransformer.touchInAssistantRegion(event));
+
+ // Override region again
mTouchTransformer.createOrAddTouchRegion(mInfo);
- inOldRegion = generateMotionEvent(MotionEvent.ACTION_DOWN, 100, y);
- mTouchTransformer.transform(inOldRegion);
- assertTrue(mTouchTransformer.touchInValidSwipeRegions(inOldRegion.getX(), inOldRegion.getY()));
+ tapAndAssertTrue(100, portraitRegionY,
+ event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY()));
+ tapAndAssertFalse(100, landscapeRegionY,
+ event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY()));
+ tapAndAssertTrue(0, portraitRegionY,
+ event -> mTouchTransformer.touchInAssistantRegion(event));
+ tapAndAssertFalse(0, landscapeRegionY,
+ event -> mTouchTransformer.touchInAssistantRegion(event));
}
@Test
- public void allowMultipeRegions_shouldOverrideFirstRegion() {
- DefaultDisplay.Info info2 = createDisplayInfo(Surface.ROTATION_90);
- mTouchTransformer.createOrAddTouchRegion(info2);
+ public void enableMultipleRegions_shouldOverrideFirstRegion() {
+ float portraitRegionY = generateTouchRegionHeight(Surface.ROTATION_0) + 1;
+ float landscapeRegionY = generateTouchRegionHeight(Surface.ROTATION_90) + 1;
+
+ mTouchTransformer.createOrAddTouchRegion(createDisplayInfo(Surface.ROTATION_90));
+ tapAndAssertFalse(100, portraitRegionY,
+ event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY()));
+ tapAndAssertTrue(100, landscapeRegionY,
+ event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY()));
+ tapAndAssertFalse(0, portraitRegionY,
+ event -> mTouchTransformer.touchInAssistantRegion(event));
+ tapAndAssertTrue(0, landscapeRegionY,
+ event -> mTouchTransformer.touchInAssistantRegion(event));
// We have to add 0 rotation second so that gets set as the current rotation, otherwise
// matrix transform will fail (tests only work in Portrait at the moment)
mTouchTransformer.enableMultipleRegions(true, mInfo);
mTouchTransformer.createOrAddTouchRegion(mInfo);
- float y = generateTouchRegionHeight(Surface.ROTATION_0) + 1;
- MotionEvent inNewRegion = generateMotionEvent(MotionEvent.ACTION_DOWN, 100, y);
- mTouchTransformer.transform(inNewRegion);
- assertTrue(mTouchTransformer.touchInValidSwipeRegions(inNewRegion.getX(), inNewRegion.getY()));
+ tapAndAssertTrue(100, portraitRegionY,
+ event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY()));
+ tapAndAssertFalse(100, landscapeRegionY,
+ event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY()));
+ tapAndAssertTrue(0, portraitRegionY,
+ event -> mTouchTransformer.touchInAssistantRegion(event));
+ tapAndAssertFalse(0, landscapeRegionY,
+ event -> mTouchTransformer.touchInAssistantRegion(event));
+ }
+
+ @Test
+ public void enableMultipleRegions_assistantTriggersInMostRecent() {
+ float portraitRegionY = generateTouchRegionHeight(Surface.ROTATION_0) + 1;
+ float landscapeRegionY = generateTouchRegionHeight(Surface.ROTATION_90) + 1;
+
+ mTouchTransformer.enableMultipleRegions(true, mInfo);
+ mTouchTransformer.createOrAddTouchRegion(createDisplayInfo(Surface.ROTATION_90));
+ mTouchTransformer.createOrAddTouchRegion(mInfo);
+ tapAndAssertTrue(0, portraitRegionY,
+ event -> mTouchTransformer.touchInAssistantRegion(event));
+ tapAndAssertFalse(0, landscapeRegionY,
+ event -> mTouchTransformer.touchInAssistantRegion(event));
+ }
+
+ @Test
+ public void enableMultipleRegions_assistantTriggersInCurrentOrientationAfterDisable() {
+ float portraitRegionY = generateTouchRegionHeight(Surface.ROTATION_0) + 1;
+ float landscapeRegionY = generateTouchRegionHeight(Surface.ROTATION_90) + 1;
+
+ mTouchTransformer.enableMultipleRegions(true, mInfo);
+ mTouchTransformer.createOrAddTouchRegion(mInfo);
+ mTouchTransformer.createOrAddTouchRegion(createDisplayInfo(Surface.ROTATION_90));
+ mTouchTransformer.enableMultipleRegions(false, mInfo);
+ tapAndAssertTrue(0, portraitRegionY,
+ event -> mTouchTransformer.touchInAssistantRegion(event));
+ tapAndAssertFalse(0, landscapeRegionY,
+ event -> mTouchTransformer.touchInAssistantRegion(event));
}
@Test
public void applyTransform_taskNotFrozen_notInRegion() {
mTouchTransformer.createOrAddTouchRegion(mInfo);
- MotionEvent outOfRegion = generateMotionEvent(MotionEvent.ACTION_DOWN, 100, 100);
- mTouchTransformer.transform(outOfRegion);
- assertFalse(mTouchTransformer.touchInValidSwipeRegions(outOfRegion.getX(), outOfRegion.getY()));
+ tapAndAssertFalse(100, 100,
+ event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY()));
}
@Test
public void applyTransform_taskFrozen_noRotate_outOfRegion() {
mTouchTransformer.createOrAddTouchRegion(mInfo);
mTouchTransformer.enableMultipleRegions(true, mInfo);
- MotionEvent outOfRegion = generateMotionEvent(MotionEvent.ACTION_DOWN, 100, 100);
- mTouchTransformer.transform(outOfRegion);
- assertFalse(mTouchTransformer.touchInValidSwipeRegions(outOfRegion.getX(), outOfRegion.getY()));
+ tapAndAssertFalse(100, 100,
+ event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY()));
}
@Test
@@ -121,27 +183,24 @@
mTouchTransformer.createOrAddTouchRegion(mInfo);
mTouchTransformer.enableMultipleRegions(true, mInfo);
float y = generateTouchRegionHeight(Surface.ROTATION_0) + 1;
- MotionEvent inRegion = generateMotionEvent(MotionEvent.ACTION_DOWN, 100, y);
- mTouchTransformer.transform(inRegion);
- assertTrue(mTouchTransformer.touchInValidSwipeRegions(inRegion.getX(), inRegion.getY()));
+ tapAndAssertTrue(100, y,
+ event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY()));
}
@Test
public void applyTransform_taskNotFrozen_noRotate_inDefaultRegion() {
mTouchTransformer.createOrAddTouchRegion(mInfo);
float y = generateTouchRegionHeight(Surface.ROTATION_0) + 1;
- MotionEvent inRegion = generateMotionEvent(MotionEvent.ACTION_DOWN, 100, y);
- mTouchTransformer.transform(inRegion);
- assertTrue(mTouchTransformer.touchInValidSwipeRegions(inRegion.getX(), inRegion.getY()));
+ tapAndAssertTrue(100, y,
+ event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY()));
}
@Test
public void applyTransform_taskNotFrozen_90Rotate_inRegion() {
mTouchTransformer.createOrAddTouchRegion(createDisplayInfo(Surface.ROTATION_90));
float y = generateTouchRegionHeight(Surface.ROTATION_90) + 1;
- MotionEvent inRegion = generateMotionEvent(MotionEvent.ACTION_DOWN, 100, y);
- mTouchTransformer.transform(inRegion);
- assertTrue(mTouchTransformer.touchInValidSwipeRegions(inRegion.getX(), inRegion.getY()));
+ tapAndAssertTrue(100, y,
+ event -> mTouchTransformer.touchInValidSwipeRegions(event.getX(), event.getY()));
}
@Test
@@ -160,15 +219,15 @@
MotionEvent inRegion2 = generateMotionEvent(MotionEvent.ACTION_DOWN, 10, 10);
mTouchTransformer.transform(inRegion1_down);
mTouchTransformer.transform(inRegion2);
- assertTrue(mTouchTransformer.touchInValidSwipeRegions(inRegion1_down.getX(), inRegion1_down.getY()));
+ assertTrue(mTouchTransformer.touchInValidSwipeRegions(
+ inRegion1_down.getX(), inRegion1_down.getY()));
// We only process one gesture region until we see a MotionEvent.ACTION_UP
assertFalse(mTouchTransformer.touchInValidSwipeRegions(inRegion2.getX(), inRegion2.getY()));
mTouchTransformer.transform(inRegion1_up);
// Set the new region with this MotionEvent.ACTION_DOWN
- inRegion2 = generateMotionEvent(MotionEvent.ACTION_DOWN, 10, 370);
- mTouchTransformer.transform(inRegion2);
+ inRegion2 = generateAndTransformMotionEvent(MotionEvent.ACTION_DOWN, 10, 370);
assertTrue(mTouchTransformer.touchInValidSwipeRegions(inRegion2.getX(), inRegion2.getY()));
}
@@ -191,4 +250,26 @@
private MotionEvent generateMotionEvent(int motionAction, float x, float y) {
return MotionEvent.obtain(0, 0, motionAction, x, y, 0);
}
+
+ private MotionEvent generateAndTransformMotionEvent(int motionAction, float x, float y) {
+ MotionEvent motionEvent = generateMotionEvent(motionAction, x, y);
+ mTouchTransformer.transform(motionEvent);
+ return motionEvent;
+ }
+
+ private void tapAndAssertTrue(float x, float y, MotionEventAssertion assertion) {
+ MotionEvent motionEvent = generateAndTransformMotionEvent(MotionEvent.ACTION_DOWN, x, y);
+ assertTrue(assertion.getCondition(motionEvent));
+ generateAndTransformMotionEvent(MotionEvent.ACTION_UP, x, y);
+ }
+
+ private void tapAndAssertFalse(float x, float y, MotionEventAssertion assertion) {
+ MotionEvent motionEvent = generateAndTransformMotionEvent(MotionEvent.ACTION_DOWN, x, y);
+ assertFalse(assertion.getCondition(motionEvent));
+ generateAndTransformMotionEvent(MotionEvent.ACTION_UP, x, y);
+ }
+
+ private interface MotionEventAssertion {
+ boolean getCondition(MotionEvent motionEvent);
+ }
}
diff --git a/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java b/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java
index 3375c53..1081548 100644
--- a/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java
+++ b/quickstep/src/com/android/quickstep/OrientationTouchTransformer.java
@@ -68,13 +68,13 @@
private Resources mResources;
private OrientationRectF mLastRectTouched;
/**
- * The rotation of the last touched nav bar. Derived from {@link #mLastRectTouched}, but has a
- * longer lifetime than the rect. Note this is different than {@link #mQuickStepStartingRotation}
- * as it always updates its value on every touch whereas mQuickstepStartingRotation only
- * updates when device rotation matches touch rotation. Maybe this will be only one necessary
- * after TODO(b/154580671) is in. TBD.
+ * The rotation of the last touched nav bar, whether that be through the last region the user
+ * touched down on or valid rotation user turned their device to.
+ * Note this is different than
+ * {@link #mQuickStepStartingRotation} as it always updates its value on every touch whereas
+ * mQuickstepStartingRotation only updates when device rotation matches touch rotation.
*/
- private int mLastRectRotation;
+ private int mActiveTouchRotation;
private SysUINavigationMode.Mode mMode;
private QuickStepContractInfo mContractInfo;
@@ -159,13 +159,27 @@
if (mEnableMultipleRegions) {
mQuickStepStartingRotation = info.rotation;
} else {
- mLastRectRotation = 0;
+ mActiveTouchRotation = 0;
mQuickStepStartingRotation = QUICKSTEP_ROTATION_UNINITIALIZED;
}
resetSwipeRegions(info);
}
/**
+ * Call when removing multiple regions to swipe from, but still in active quickswitch mode (task
+ * list is still frozen).
+ * Ex. This would be called when user has quickswitched to the same app rotation that
+ * they started quickswitching in, indicating that extra nav regions can be ignored. Calling
+ * this will update the value of {@link #mActiveTouchRotation}
+ *
+ * @param displayInfo The display whos rotation will be used as the current active rotation
+ */
+ void setSingleActiveRegion(DefaultDisplay.Info displayInfo) {
+ mActiveTouchRotation = displayInfo.rotation;
+ resetSwipeRegions(displayInfo);
+ }
+
+ /**
* Only saves the swipe region represented by {@param region}, clears the
* rest from {@link #mSwipeTouchRegions}
* To be called whenever we want to stop tracking more than one swipe region.
@@ -178,15 +192,21 @@
mCurrentDisplayRotation = region.rotation;
OrientationRectF regionToKeep = mSwipeTouchRegions.get(mCurrentDisplayRotation);
+ if (regionToKeep == null) {
+ regionToKeep = createRegionForDisplay(region);
+ }
mSwipeTouchRegions.clear();
- mSwipeTouchRegions.put(mCurrentDisplayRotation,
- regionToKeep != null ? regionToKeep : createRegionForDisplay(region));
+ mSwipeTouchRegions.put(mCurrentDisplayRotation, regionToKeep);
+ updateAssistantRegions(regionToKeep);
}
private void resetSwipeRegions() {
OrientationRectF regionToKeep = mSwipeTouchRegions.get(mCurrentDisplayRotation);
mSwipeTouchRegions.clear();
- mSwipeTouchRegions.put(mCurrentDisplayRotation, regionToKeep);
+ if (regionToKeep != null) {
+ mSwipeTouchRegions.put(mCurrentDisplayRotation, regionToKeep);
+ updateAssistantRegions(regionToKeep);
+ }
}
private OrientationRectF createRegionForDisplay(DefaultDisplay.Info display) {
@@ -201,20 +221,7 @@
if (mMode == SysUINavigationMode.Mode.NO_BUTTON) {
int touchHeight = getNavbarSize(ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE);
orientationRectF.top = orientationRectF.bottom - touchHeight;
-
- final int assistantWidth = mResources
- .getDimensionPixelSize(R.dimen.gestures_assistant_width);
- final float assistantHeight = Math.max(touchHeight,
- mContractInfo.getWindowCornerRadius());
- mAssistantLeftRegion.bottom = mAssistantRightRegion.bottom = orientationRectF.bottom;
- mAssistantLeftRegion.top = mAssistantRightRegion.top =
- orientationRectF.bottom - assistantHeight;
-
- mAssistantLeftRegion.left = 0;
- mAssistantLeftRegion.right = assistantWidth;
-
- mAssistantRightRegion.right = orientationRectF.right;
- mAssistantRightRegion.left = orientationRectF.right - assistantWidth;
+ updateAssistantRegions(orientationRectF);
} else {
mAssistantLeftRegion.setEmpty();
mAssistantRightRegion.setEmpty();
@@ -236,6 +243,21 @@
return orientationRectF;
}
+ private void updateAssistantRegions(OrientationRectF orientationRectF) {
+ int navbarHeight = getNavbarSize(ResourceUtils.NAVBAR_BOTTOM_GESTURE_SIZE);
+ int assistantWidth = mResources.getDimensionPixelSize(R.dimen.gestures_assistant_width);
+ float assistantHeight = Math.max(navbarHeight, mContractInfo.getWindowCornerRadius());
+ mAssistantLeftRegion.bottom = mAssistantRightRegion.bottom = orientationRectF.bottom;
+ mAssistantLeftRegion.top = mAssistantRightRegion.top =
+ orientationRectF.bottom - assistantHeight;
+
+ mAssistantLeftRegion.left = 0;
+ mAssistantLeftRegion.right = assistantWidth;
+
+ mAssistantRightRegion.right = orientationRectF.right;
+ mAssistantRightRegion.left = orientationRectF.right - assistantWidth;
+ }
+
boolean touchInAssistantRegion(MotionEvent ev) {
return mAssistantLeftRegion.contains(ev.getX(), ev.getY())
|| mAssistantRightRegion.contains(ev.getX(), ev.getY());
@@ -258,7 +280,7 @@
}
int getCurrentActiveRotation() {
- return mLastRectRotation;
+ return mActiveTouchRotation;
}
int getQuickStepStartingRotation() {
@@ -303,8 +325,9 @@
Log.d(TestProtocol.NO_SWIPE_TO_HOME, "setting mLastRectTouched");
}
mLastRectTouched = rect;
- mLastRectRotation = rect.mRotation;
- if (mEnableMultipleRegions && mCurrentDisplayRotation == mLastRectRotation) {
+ mActiveTouchRotation = rect.mRotation;
+ if (mEnableMultipleRegions
+ && mCurrentDisplayRotation == mActiveTouchRotation) {
// TODO(b/154580671) might make this block unnecessary
// Start a touch session for the default nav region for the display
mQuickStepStartingRotation = mLastRectTouched.mRotation;
diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
index 79b38f2..0a70bd6 100644
--- a/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
+++ b/quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java
@@ -151,7 +151,7 @@
* sysui to adjust the navbar.
*/
private OrientationEventListener mOrientationListener;
- private int mPreviousRotation = ROTATION_0;
+ private int mSensorRotation = ROTATION_0;
/**
* This is the configuration of the foreground app or the app that will be in the foreground
* once a quickstep gesture finishes.
@@ -246,18 +246,18 @@
@Override
public void onOrientationChanged(int degrees) {
int newRotation = RecentsOrientedState.getRotationForUserDegreesRotated(degrees,
- mPreviousRotation);
- if (newRotation == mPreviousRotation) {
+ mSensorRotation);
+ if (newRotation == mSensorRotation) {
return;
}
- mPreviousRotation = newRotation;
+ mSensorRotation = newRotation;
mPrioritizeDeviceRotation = true;
if (newRotation == mCurrentAppRotation) {
// When user rotates device to the orientation of the foreground app after
// quickstepping
- toggleSecondaryNavBarsForRotation(false);
+ toggleSecondaryNavBarsForRotation();
}
}
};
@@ -339,14 +339,16 @@
mCurrentAppRotation = mDisplayRotation;
/* Update nav bars on the following:
- * a) if we're not expecting quickswitch, this is coming from an activity rotation
- * b) we launch an app in the orientation that user is already in
- * c) We're not in overview, since overview will always be portrait (w/o home rotation)
+ * a) if this is coming from an activity rotation OR
+ * aa) we launch an app in the orientation that user is already in
+ * b) We're not in overview, since overview will always be portrait (w/o home rotation)
+ * c) We're actively in quickswitch mode
*/
if ((mPrioritizeDeviceRotation
- || mCurrentAppRotation == mPreviousRotation) // switch to an app of orientation user is in
- && !mInOverview) {
- toggleSecondaryNavBarsForRotation(false);
+ || mCurrentAppRotation == mSensorRotation) // switch to an app of orientation user is in
+ && !mInOverview
+ && mTaskListFrozen) {
+ toggleSecondaryNavBarsForRotation();
}
}
@@ -461,7 +463,9 @@
* @return whether SystemUI is in a state where we can start a system gesture.
*/
public boolean canStartSystemGesture() {
- return (mSystemUiStateFlags & SYSUI_STATE_NAV_BAR_HIDDEN) == 0
+ boolean canStartWithNavHidden = (mSystemUiStateFlags & SYSUI_STATE_NAV_BAR_HIDDEN) == 0
+ || mTaskListFrozen;
+ return canStartWithNavHidden
&& (mSystemUiStateFlags & SYSUI_STATE_NOTIFICATION_PANEL_EXPANDED) == 0
&& (mSystemUiStateFlags & SYSUI_STATE_QUICK_SETTINGS_EXPANDED) == 0
&& ((mSystemUiStateFlags & SYSUI_STATE_HOME_DISABLED) == 0
@@ -634,29 +638,26 @@
}
private void enableMultipleRegions(boolean enable) {
- toggleSecondaryNavBarsForRotation(enable);
- if (enable && !TestProtocol.sDisableSensorRotation) {
+ mOrientationTouchTransformer.enableMultipleRegions(enable, mDefaultDisplay.getInfo());
+ notifySysuiOfCurrentRotation(mOrientationTouchTransformer.getQuickStepStartingRotation());
+ if (enable && !mInOverview && !TestProtocol.sDisableSensorRotation) {
+ // Clear any previous state from sensor manager
+ mSensorRotation = mCurrentAppRotation;
mOrientationListener.enable();
} else {
mOrientationListener.disable();
}
}
- private void notifySysuiForRotation(int rotation) {
- UI_HELPER_EXECUTOR.execute(() ->
- SystemUiProxy.INSTANCE.get(mContext).onQuickSwitchToNewTask(rotation));
- }
-
public void onStartGesture() {
if (mTaskListFrozen) {
// Prioritize whatever nav bar user touches once in quickstep
// This case is specifically when user changes what nav bar they are using mid
// quickswitch session before tasks list is unfrozen
- notifySysuiForRotation(mOrientationTouchTransformer.getCurrentActiveRotation());
+ notifySysuiOfCurrentRotation(mOrientationTouchTransformer.getCurrentActiveRotation());
}
}
-
void onEndTargetCalculated(GestureState.GestureEndTarget endTarget,
BaseActivityInterface activityInterface) {
if (endTarget == GestureState.GestureEndTarget.RECENTS) {
@@ -673,7 +674,8 @@
// First gesture to start quickswitch
enableMultipleRegions(true);
} else {
- notifySysuiForRotation(mOrientationTouchTransformer.getCurrentActiveRotation());
+ notifySysuiOfCurrentRotation(
+ mOrientationTouchTransformer.getCurrentActiveRotation());
}
// A new gesture is starting, reset the current device rotation
@@ -685,7 +687,7 @@
// touched nav bar but didn't go anywhere and not quickswitching, do nothing
return;
}
- notifySysuiForRotation(mOrientationTouchTransformer.getCurrentActiveRotation());
+ notifySysuiOfCurrentRotation(mOrientationTouchTransformer.getCurrentActiveRotation());
}
}
@@ -697,13 +699,10 @@
/**
* Disables/Enables multiple nav bars on {@link OrientationTouchTransformer} and then
* notifies system UI of the primary rotation the user is interacting with
- *
- * @param enable if {@code true}, this will report to sysUI the navbar of the region the gesture
- * started in (during ACTION_DOWN), otherwise will report {@param displayRotation}
*/
- private void toggleSecondaryNavBarsForRotation(boolean enable) {
- mOrientationTouchTransformer.enableMultipleRegions(enable, mDefaultDisplay.getInfo());
- notifySysuiOfCurrentRotation(mOrientationTouchTransformer.getQuickStepStartingRotation());
+ private void toggleSecondaryNavBarsForRotation() {
+ mOrientationTouchTransformer.setSingleActiveRegion(mDefaultDisplay.getInfo());
+ notifySysuiOfCurrentRotation(mOrientationTouchTransformer.getCurrentActiveRotation());
}
public int getCurrentActiveRotation() {
diff --git a/src/com/android/launcher3/util/DefaultDisplay.java b/src/com/android/launcher3/util/DefaultDisplay.java
index 150fb5b..35788a5 100644
--- a/src/com/android/launcher3/util/DefaultDisplay.java
+++ b/src/com/android/launcher3/util/DefaultDisplay.java
@@ -49,20 +49,25 @@
public static final int CHANGE_ALL = CHANGE_SIZE | CHANGE_ROTATION | CHANGE_FRAME_DELAY;
- private final Context mContext;
+ private final Context mDisplayContext;
private final int mId;
private final ArrayList<DisplayInfoChangeListener> mListeners = new ArrayList<>();
private final Handler mChangeHandler;
private Info mInfo;
private DefaultDisplay(Context context) {
- mContext = context;
- mInfo = new Info(context);
+ DisplayManager dm = context.getSystemService(DisplayManager.class);
+ // Use application context to create display context so that it can have its own Resources.
+ mDisplayContext = context.getApplicationContext().createDisplayContext(
+ dm.getDisplay(DEFAULT_DISPLAY));
+ // Note that the Display object must be obtained from DisplayManager which is associated to
+ // the display context, so the Display is isolated from Activity and Application to provide
+ // the actual state of device that excludes the additional adjustment and override.
+ mInfo = new Info(mDisplayContext);
mId = mInfo.id;
mChangeHandler = new Handler(this::onChange);
- context.getSystemService(DisplayManager.class)
- .registerDisplayListener(this, UI_HELPER_EXECUTOR.getHandler());
+ dm.registerDisplayListener(this, UI_HELPER_EXECUTOR.getHandler());
}
@Override
@@ -78,7 +83,7 @@
}
Info oldInfo = mInfo;
- Info info = new Info(mContext);
+ Info info = new Info(mDisplayContext);
int change = 0;
if (info.hasDifferentSize(oldInfo)) {
@@ -162,8 +167,7 @@
display.getRealSize(realSize);
display.getCurrentSizeRange(smallestSize, largestSize);
- Context defaultDisplayContext = context.createDisplayContext(display);
- metrics = defaultDisplayContext.getResources().getDisplayMetrics();
+ metrics = context.getResources().getDisplayMetrics();
}
private boolean hasDifferentSize(Info info) {