Merge "Don't lock rotation to natural rotation when entering overview" into rvc-dev

This commit is contained in:
TreeHugger Robot
2020-06-15 07:05:25 +00:00
committed by Android (Google) Code Review
4 changed files with 37 additions and 0 deletions

View File

@@ -118,6 +118,7 @@ public class OverviewProxyRecentsImpl implements RecentsImplementation {
try {
if (mOverviewProxyService.getProxy() != null) {
mOverviewProxyService.getProxy().onOverviewToggle();
mOverviewProxyService.notifyToggleRecentApps();
}
} catch (RemoteException e) {
Log.e(TAG, "Cannot send toggle recents through proxy service.", e);

View File

@@ -871,6 +871,12 @@ public class OverviewProxyService extends CurrentUserTracker implements
}
}
void notifyToggleRecentApps() {
for (int i = mConnectionCallbacks.size() - 1; i >= 0; --i) {
mConnectionCallbacks.get(i).onToggleRecentApps();
}
}
private void updateEnabledState() {
mIsEnabled = mContext.getPackageManager().resolveServiceAsUser(mQuickStepIntent,
MATCH_SYSTEM_ONLY,
@@ -901,6 +907,8 @@ public class OverviewProxyService extends CurrentUserTracker implements
default void onQuickSwitchToNewTask(@Surface.Rotation int rotation) {}
default void onOverviewShown(boolean fromHome) {}
default void onQuickScrubStarted() {}
/** Notify the recents app (overview) is started by 3-button navigation. */
default void onToggleRecentApps() {}
/** Notify changes in the nav bar button alpha */
default void onNavBarButtonAlphaChanged(float alpha, boolean animate) {}
default void onSystemUiStateChanged(int sysuiStateFlags) {}

View File

@@ -323,6 +323,20 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
buttonDispatcher.setAlpha(forceVisible ? 1f : alpha, animate);
}
}
@Override
public void onOverviewShown(boolean fromHome) {
// If the overview has fixed orientation that may change display to natural rotation,
// we don't want the user rotation to be reset. So after user returns to application,
// it can keep in the original rotation.
mNavigationBarView.getRotationButtonController().setSkipOverrideUserLockPrefsOnce();
}
@Override
public void onToggleRecentApps() {
// The same case as onOverviewShown but only for 3-button navigation.
mNavigationBarView.getRotationButtonController().setSkipOverrideUserLockPrefsOnce();
}
};
private NavigationBarTransitions.DarkIntensityListener mOrientationHandleIntensityListener =

View File

@@ -74,6 +74,7 @@ public class RotationButtonController {
private Consumer<Integer> mRotWatcherListener;
private boolean mListenersRegistered = false;
private boolean mIsNavigationBarShowing;
private boolean mSkipOverrideUserLockPrefsOnce;
private final Runnable mRemoveRotationProposal =
() -> setRotateSuggestionButtonState(false /* visible */);
@@ -349,7 +350,20 @@ public class RotationButtonController {
mUiEventLogger.log(RotationButtonEvent.ROTATION_SUGGESTION_SHOWN);
}
/**
* Makes {@link #shouldOverrideUserLockPrefs} always return {@code false} once. It is used to
* avoid losing original user rotation when display rotation is changed by entering the fixed
* orientation overview.
*/
void setSkipOverrideUserLockPrefsOnce() {
mSkipOverrideUserLockPrefsOnce = true;
}
private boolean shouldOverrideUserLockPrefs(final int rotation) {
if (mSkipOverrideUserLockPrefsOnce) {
mSkipOverrideUserLockPrefsOnce = false;
return false;
}
// Only override user prefs when returning to the natural rotation (normally portrait).
// Don't let apps that force landscape or 180 alter user lock.
return rotation == NATURAL_ROTATION;