Loading quickstep/src/com/android/quickstep/OrientationTouchTransformer.java +25 −10 Original line number Original line Diff line number Diff line Loading @@ -68,13 +68,13 @@ class OrientationTouchTransformer { private Resources mResources; private Resources mResources; private OrientationRectF mLastRectTouched; private OrientationRectF mLastRectTouched; /** /** * The rotation of the last touched nav bar. Derived from {@link #mLastRectTouched}, but has a * The rotation of the last touched nav bar, whether that be through the last region the user * longer lifetime than the rect. Note this is different than {@link #mQuickStepStartingRotation} * touched down on or valid rotation user turned their device to. * as it always updates its value on every touch whereas mQuickstepStartingRotation only * Note this is different than * updates when device rotation matches touch rotation. Maybe this will be only one necessary * {@link #mQuickStepStartingRotation} as it always updates its value on every touch whereas * after TODO(b/154580671) is in. TBD. * mQuickstepStartingRotation only updates when device rotation matches touch rotation. */ */ private int mLastRectRotation; private int mActiveTouchRotation; private SysUINavigationMode.Mode mMode; private SysUINavigationMode.Mode mMode; private QuickStepContractInfo mContractInfo; private QuickStepContractInfo mContractInfo; Loading Loading @@ -159,12 +159,26 @@ class OrientationTouchTransformer { if (mEnableMultipleRegions) { if (mEnableMultipleRegions) { mQuickStepStartingRotation = info.rotation; mQuickStepStartingRotation = info.rotation; } else { } else { mLastRectRotation = 0; mActiveTouchRotation = 0; mQuickStepStartingRotation = QUICKSTEP_ROTATION_UNINITIALIZED; mQuickStepStartingRotation = QUICKSTEP_ROTATION_UNINITIALIZED; } } resetSwipeRegions(info); 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 * Only saves the swipe region represented by {@param region}, clears the * rest from {@link #mSwipeTouchRegions} * rest from {@link #mSwipeTouchRegions} Loading Loading @@ -258,7 +272,7 @@ class OrientationTouchTransformer { } } int getCurrentActiveRotation() { int getCurrentActiveRotation() { return mLastRectRotation; return mActiveTouchRotation; } } int getQuickStepStartingRotation() { int getQuickStepStartingRotation() { Loading Loading @@ -303,8 +317,9 @@ class OrientationTouchTransformer { Log.d(TestProtocol.NO_SWIPE_TO_HOME, "setting mLastRectTouched"); Log.d(TestProtocol.NO_SWIPE_TO_HOME, "setting mLastRectTouched"); } } mLastRectTouched = rect; mLastRectTouched = rect; mLastRectRotation = rect.mRotation; mActiveTouchRotation = rect.mRotation; if (mEnableMultipleRegions && mCurrentDisplayRotation == mLastRectRotation) { if (mEnableMultipleRegions && mCurrentDisplayRotation == mActiveTouchRotation) { // TODO(b/154580671) might make this block unnecessary // TODO(b/154580671) might make this block unnecessary // Start a touch session for the default nav region for the display // Start a touch session for the default nav region for the display mQuickStepStartingRotation = mLastRectTouched.mRotation; mQuickStepStartingRotation = mLastRectTouched.mRotation; Loading quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java +28 −29 Original line number Original line Diff line number Diff line Loading @@ -151,7 +151,7 @@ public class RecentsAnimationDeviceState implements * sysui to adjust the navbar. * sysui to adjust the navbar. */ */ private OrientationEventListener mOrientationListener; 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 * This is the configuration of the foreground app or the app that will be in the foreground * once a quickstep gesture finishes. * once a quickstep gesture finishes. Loading Loading @@ -246,18 +246,18 @@ public class RecentsAnimationDeviceState implements @Override @Override public void onOrientationChanged(int degrees) { public void onOrientationChanged(int degrees) { int newRotation = RecentsOrientedState.getRotationForUserDegreesRotated(degrees, int newRotation = RecentsOrientedState.getRotationForUserDegreesRotated(degrees, mPreviousRotation); mSensorRotation); if (newRotation == mPreviousRotation) { if (newRotation == mSensorRotation) { return; return; } } mPreviousRotation = newRotation; mSensorRotation = newRotation; mPrioritizeDeviceRotation = true; mPrioritizeDeviceRotation = true; if (newRotation == mCurrentAppRotation) { if (newRotation == mCurrentAppRotation) { // When user rotates device to the orientation of the foreground app after // When user rotates device to the orientation of the foreground app after // quickstepping // quickstepping toggleSecondaryNavBarsForRotation(false); toggleSecondaryNavBarsForRotation(); } } } } }; }; Loading Loading @@ -339,14 +339,16 @@ public class RecentsAnimationDeviceState implements mCurrentAppRotation = mDisplayRotation; mCurrentAppRotation = mDisplayRotation; /* Update nav bars on the following: /* Update nav bars on the following: * a) if we're not expecting quickswitch, this is coming from an activity rotation * a) if this is coming from an activity rotation OR * b) we launch an app in the orientation that user is already in * aa) 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) * 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 if ((mPrioritizeDeviceRotation || mCurrentAppRotation == mPreviousRotation) // switch to an app of orientation user is in || mCurrentAppRotation == mSensorRotation) // switch to an app of orientation user is in && !mInOverview) { && !mInOverview toggleSecondaryNavBarsForRotation(false); && mTaskListFrozen) { toggleSecondaryNavBarsForRotation(); } } } } Loading Loading @@ -461,7 +463,9 @@ public class RecentsAnimationDeviceState implements * @return whether SystemUI is in a state where we can start a system gesture. * @return whether SystemUI is in a state where we can start a system gesture. */ */ public boolean canStartSystemGesture() { 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_NOTIFICATION_PANEL_EXPANDED) == 0 && (mSystemUiStateFlags & SYSUI_STATE_QUICK_SETTINGS_EXPANDED) == 0 && (mSystemUiStateFlags & SYSUI_STATE_QUICK_SETTINGS_EXPANDED) == 0 && ((mSystemUiStateFlags & SYSUI_STATE_HOME_DISABLED) == 0 && ((mSystemUiStateFlags & SYSUI_STATE_HOME_DISABLED) == 0 Loading Loading @@ -634,29 +638,26 @@ public class RecentsAnimationDeviceState implements } } private void enableMultipleRegions(boolean enable) { private void enableMultipleRegions(boolean enable) { toggleSecondaryNavBarsForRotation(enable); mOrientationTouchTransformer.enableMultipleRegions(enable, mDefaultDisplay.getInfo()); if (enable && !TestProtocol.sDisableSensorRotation) { notifySysuiOfCurrentRotation(mOrientationTouchTransformer.getQuickStepStartingRotation()); if (enable && !mInOverview && !TestProtocol.sDisableSensorRotation) { // Clear any previous state from sensor manager mSensorRotation = mCurrentAppRotation; mOrientationListener.enable(); mOrientationListener.enable(); } else { } else { mOrientationListener.disable(); mOrientationListener.disable(); } } } } private void notifySysuiForRotation(int rotation) { UI_HELPER_EXECUTOR.execute(() -> SystemUiProxy.INSTANCE.get(mContext).onQuickSwitchToNewTask(rotation)); } public void onStartGesture() { public void onStartGesture() { if (mTaskListFrozen) { if (mTaskListFrozen) { // Prioritize whatever nav bar user touches once in quickstep // Prioritize whatever nav bar user touches once in quickstep // This case is specifically when user changes what nav bar they are using mid // This case is specifically when user changes what nav bar they are using mid // quickswitch session before tasks list is unfrozen // quickswitch session before tasks list is unfrozen notifySysuiForRotation(mOrientationTouchTransformer.getCurrentActiveRotation()); notifySysuiOfCurrentRotation(mOrientationTouchTransformer.getCurrentActiveRotation()); } } } } void onEndTargetCalculated(GestureState.GestureEndTarget endTarget, void onEndTargetCalculated(GestureState.GestureEndTarget endTarget, BaseActivityInterface activityInterface) { BaseActivityInterface activityInterface) { if (endTarget == GestureState.GestureEndTarget.RECENTS) { if (endTarget == GestureState.GestureEndTarget.RECENTS) { Loading @@ -673,7 +674,8 @@ public class RecentsAnimationDeviceState implements // First gesture to start quickswitch // First gesture to start quickswitch enableMultipleRegions(true); enableMultipleRegions(true); } else { } else { notifySysuiForRotation(mOrientationTouchTransformer.getCurrentActiveRotation()); notifySysuiOfCurrentRotation( mOrientationTouchTransformer.getCurrentActiveRotation()); } } // A new gesture is starting, reset the current device rotation // A new gesture is starting, reset the current device rotation Loading @@ -685,7 +687,7 @@ public class RecentsAnimationDeviceState implements // touched nav bar but didn't go anywhere and not quickswitching, do nothing // touched nav bar but didn't go anywhere and not quickswitching, do nothing return; return; } } notifySysuiForRotation(mOrientationTouchTransformer.getCurrentActiveRotation()); notifySysuiOfCurrentRotation(mOrientationTouchTransformer.getCurrentActiveRotation()); } } } } Loading @@ -697,13 +699,10 @@ public class RecentsAnimationDeviceState implements /** /** * Disables/Enables multiple nav bars on {@link OrientationTouchTransformer} and then * Disables/Enables multiple nav bars on {@link OrientationTouchTransformer} and then * notifies system UI of the primary rotation the user is interacting with * 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) { private void toggleSecondaryNavBarsForRotation() { mOrientationTouchTransformer.enableMultipleRegions(enable, mDefaultDisplay.getInfo()); mOrientationTouchTransformer.setSingleActiveRegion(mDefaultDisplay.getInfo()); notifySysuiOfCurrentRotation(mOrientationTouchTransformer.getQuickStepStartingRotation()); notifySysuiOfCurrentRotation(mOrientationTouchTransformer.getCurrentActiveRotation()); } } public int getCurrentActiveRotation() { public int getCurrentActiveRotation() { Loading Loading
quickstep/src/com/android/quickstep/OrientationTouchTransformer.java +25 −10 Original line number Original line Diff line number Diff line Loading @@ -68,13 +68,13 @@ class OrientationTouchTransformer { private Resources mResources; private Resources mResources; private OrientationRectF mLastRectTouched; private OrientationRectF mLastRectTouched; /** /** * The rotation of the last touched nav bar. Derived from {@link #mLastRectTouched}, but has a * The rotation of the last touched nav bar, whether that be through the last region the user * longer lifetime than the rect. Note this is different than {@link #mQuickStepStartingRotation} * touched down on or valid rotation user turned their device to. * as it always updates its value on every touch whereas mQuickstepStartingRotation only * Note this is different than * updates when device rotation matches touch rotation. Maybe this will be only one necessary * {@link #mQuickStepStartingRotation} as it always updates its value on every touch whereas * after TODO(b/154580671) is in. TBD. * mQuickstepStartingRotation only updates when device rotation matches touch rotation. */ */ private int mLastRectRotation; private int mActiveTouchRotation; private SysUINavigationMode.Mode mMode; private SysUINavigationMode.Mode mMode; private QuickStepContractInfo mContractInfo; private QuickStepContractInfo mContractInfo; Loading Loading @@ -159,12 +159,26 @@ class OrientationTouchTransformer { if (mEnableMultipleRegions) { if (mEnableMultipleRegions) { mQuickStepStartingRotation = info.rotation; mQuickStepStartingRotation = info.rotation; } else { } else { mLastRectRotation = 0; mActiveTouchRotation = 0; mQuickStepStartingRotation = QUICKSTEP_ROTATION_UNINITIALIZED; mQuickStepStartingRotation = QUICKSTEP_ROTATION_UNINITIALIZED; } } resetSwipeRegions(info); 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 * Only saves the swipe region represented by {@param region}, clears the * rest from {@link #mSwipeTouchRegions} * rest from {@link #mSwipeTouchRegions} Loading Loading @@ -258,7 +272,7 @@ class OrientationTouchTransformer { } } int getCurrentActiveRotation() { int getCurrentActiveRotation() { return mLastRectRotation; return mActiveTouchRotation; } } int getQuickStepStartingRotation() { int getQuickStepStartingRotation() { Loading Loading @@ -303,8 +317,9 @@ class OrientationTouchTransformer { Log.d(TestProtocol.NO_SWIPE_TO_HOME, "setting mLastRectTouched"); Log.d(TestProtocol.NO_SWIPE_TO_HOME, "setting mLastRectTouched"); } } mLastRectTouched = rect; mLastRectTouched = rect; mLastRectRotation = rect.mRotation; mActiveTouchRotation = rect.mRotation; if (mEnableMultipleRegions && mCurrentDisplayRotation == mLastRectRotation) { if (mEnableMultipleRegions && mCurrentDisplayRotation == mActiveTouchRotation) { // TODO(b/154580671) might make this block unnecessary // TODO(b/154580671) might make this block unnecessary // Start a touch session for the default nav region for the display // Start a touch session for the default nav region for the display mQuickStepStartingRotation = mLastRectTouched.mRotation; mQuickStepStartingRotation = mLastRectTouched.mRotation; Loading
quickstep/src/com/android/quickstep/RecentsAnimationDeviceState.java +28 −29 Original line number Original line Diff line number Diff line Loading @@ -151,7 +151,7 @@ public class RecentsAnimationDeviceState implements * sysui to adjust the navbar. * sysui to adjust the navbar. */ */ private OrientationEventListener mOrientationListener; 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 * This is the configuration of the foreground app or the app that will be in the foreground * once a quickstep gesture finishes. * once a quickstep gesture finishes. Loading Loading @@ -246,18 +246,18 @@ public class RecentsAnimationDeviceState implements @Override @Override public void onOrientationChanged(int degrees) { public void onOrientationChanged(int degrees) { int newRotation = RecentsOrientedState.getRotationForUserDegreesRotated(degrees, int newRotation = RecentsOrientedState.getRotationForUserDegreesRotated(degrees, mPreviousRotation); mSensorRotation); if (newRotation == mPreviousRotation) { if (newRotation == mSensorRotation) { return; return; } } mPreviousRotation = newRotation; mSensorRotation = newRotation; mPrioritizeDeviceRotation = true; mPrioritizeDeviceRotation = true; if (newRotation == mCurrentAppRotation) { if (newRotation == mCurrentAppRotation) { // When user rotates device to the orientation of the foreground app after // When user rotates device to the orientation of the foreground app after // quickstepping // quickstepping toggleSecondaryNavBarsForRotation(false); toggleSecondaryNavBarsForRotation(); } } } } }; }; Loading Loading @@ -339,14 +339,16 @@ public class RecentsAnimationDeviceState implements mCurrentAppRotation = mDisplayRotation; mCurrentAppRotation = mDisplayRotation; /* Update nav bars on the following: /* Update nav bars on the following: * a) if we're not expecting quickswitch, this is coming from an activity rotation * a) if this is coming from an activity rotation OR * b) we launch an app in the orientation that user is already in * aa) 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) * 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 if ((mPrioritizeDeviceRotation || mCurrentAppRotation == mPreviousRotation) // switch to an app of orientation user is in || mCurrentAppRotation == mSensorRotation) // switch to an app of orientation user is in && !mInOverview) { && !mInOverview toggleSecondaryNavBarsForRotation(false); && mTaskListFrozen) { toggleSecondaryNavBarsForRotation(); } } } } Loading Loading @@ -461,7 +463,9 @@ public class RecentsAnimationDeviceState implements * @return whether SystemUI is in a state where we can start a system gesture. * @return whether SystemUI is in a state where we can start a system gesture. */ */ public boolean canStartSystemGesture() { 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_NOTIFICATION_PANEL_EXPANDED) == 0 && (mSystemUiStateFlags & SYSUI_STATE_QUICK_SETTINGS_EXPANDED) == 0 && (mSystemUiStateFlags & SYSUI_STATE_QUICK_SETTINGS_EXPANDED) == 0 && ((mSystemUiStateFlags & SYSUI_STATE_HOME_DISABLED) == 0 && ((mSystemUiStateFlags & SYSUI_STATE_HOME_DISABLED) == 0 Loading Loading @@ -634,29 +638,26 @@ public class RecentsAnimationDeviceState implements } } private void enableMultipleRegions(boolean enable) { private void enableMultipleRegions(boolean enable) { toggleSecondaryNavBarsForRotation(enable); mOrientationTouchTransformer.enableMultipleRegions(enable, mDefaultDisplay.getInfo()); if (enable && !TestProtocol.sDisableSensorRotation) { notifySysuiOfCurrentRotation(mOrientationTouchTransformer.getQuickStepStartingRotation()); if (enable && !mInOverview && !TestProtocol.sDisableSensorRotation) { // Clear any previous state from sensor manager mSensorRotation = mCurrentAppRotation; mOrientationListener.enable(); mOrientationListener.enable(); } else { } else { mOrientationListener.disable(); mOrientationListener.disable(); } } } } private void notifySysuiForRotation(int rotation) { UI_HELPER_EXECUTOR.execute(() -> SystemUiProxy.INSTANCE.get(mContext).onQuickSwitchToNewTask(rotation)); } public void onStartGesture() { public void onStartGesture() { if (mTaskListFrozen) { if (mTaskListFrozen) { // Prioritize whatever nav bar user touches once in quickstep // Prioritize whatever nav bar user touches once in quickstep // This case is specifically when user changes what nav bar they are using mid // This case is specifically when user changes what nav bar they are using mid // quickswitch session before tasks list is unfrozen // quickswitch session before tasks list is unfrozen notifySysuiForRotation(mOrientationTouchTransformer.getCurrentActiveRotation()); notifySysuiOfCurrentRotation(mOrientationTouchTransformer.getCurrentActiveRotation()); } } } } void onEndTargetCalculated(GestureState.GestureEndTarget endTarget, void onEndTargetCalculated(GestureState.GestureEndTarget endTarget, BaseActivityInterface activityInterface) { BaseActivityInterface activityInterface) { if (endTarget == GestureState.GestureEndTarget.RECENTS) { if (endTarget == GestureState.GestureEndTarget.RECENTS) { Loading @@ -673,7 +674,8 @@ public class RecentsAnimationDeviceState implements // First gesture to start quickswitch // First gesture to start quickswitch enableMultipleRegions(true); enableMultipleRegions(true); } else { } else { notifySysuiForRotation(mOrientationTouchTransformer.getCurrentActiveRotation()); notifySysuiOfCurrentRotation( mOrientationTouchTransformer.getCurrentActiveRotation()); } } // A new gesture is starting, reset the current device rotation // A new gesture is starting, reset the current device rotation Loading @@ -685,7 +687,7 @@ public class RecentsAnimationDeviceState implements // touched nav bar but didn't go anywhere and not quickswitching, do nothing // touched nav bar but didn't go anywhere and not quickswitching, do nothing return; return; } } notifySysuiForRotation(mOrientationTouchTransformer.getCurrentActiveRotation()); notifySysuiOfCurrentRotation(mOrientationTouchTransformer.getCurrentActiveRotation()); } } } } Loading @@ -697,13 +699,10 @@ public class RecentsAnimationDeviceState implements /** /** * Disables/Enables multiple nav bars on {@link OrientationTouchTransformer} and then * Disables/Enables multiple nav bars on {@link OrientationTouchTransformer} and then * notifies system UI of the primary rotation the user is interacting with * 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) { private void toggleSecondaryNavBarsForRotation() { mOrientationTouchTransformer.enableMultipleRegions(enable, mDefaultDisplay.getInfo()); mOrientationTouchTransformer.setSingleActiveRegion(mDefaultDisplay.getInfo()); notifySysuiOfCurrentRotation(mOrientationTouchTransformer.getQuickStepStartingRotation()); notifySysuiOfCurrentRotation(mOrientationTouchTransformer.getCurrentActiveRotation()); } } public int getCurrentActiveRotation() { public int getCurrentActiveRotation() { Loading