Merge "Remove fixed-rotation-transform setting" into rvc-dev am: bda3156926

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11907893

Change-Id: Ief183fa62c144ae15cd7ee282e42d75255070b0e
This commit is contained in:
TreeHugger Robot
2020-06-22 13:51:39 +00:00
committed by Automerger Merge Worker
10 changed files with 12 additions and 109 deletions

View File

@@ -23,7 +23,6 @@ import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
import android.database.ContentObserver;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.PointF;
@@ -31,15 +30,11 @@ import android.graphics.Region;
import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayManager.DisplayListener;
import android.hardware.input.InputManager;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.provider.DeviceConfig;
import android.provider.Settings;
import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
@@ -92,8 +87,6 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa
private static final String TAG = "EdgeBackGestureHandler";
private static final int MAX_LONG_PRESS_TIMEOUT = SystemProperties.getInt(
"gestures.back_timeout", 250);
private static final String FIXED_ROTATION_TRANSFORM_SETTING_NAME = "fixed_rotation_transform";
private ISystemGestureExclusionListener mGestureExclusionListener =
new ISystemGestureExclusionListener.Stub() {
@@ -119,14 +112,6 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa
}
};
private final ContentObserver mFixedRotationObserver = new ContentObserver(
new Handler(Looper.getMainLooper())) {
@Override
public void onChange(boolean selfChange, Uri uri) {
updatedFixedRotation();
}
};
private TaskStackChangeListener mTaskStackListener = new TaskStackChangeListener() {
@Override
public void onTaskStackChanged() {
@@ -162,7 +147,6 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa
// We temporarily disable back gesture when user is quickswitching
// between apps of different orientations
private boolean mDisabledForQuickstep;
private boolean mFixedRotationFlagEnabled;
private final PointF mDownPoint = new PointF();
private final PointF mEndPoint = new PointF();
@@ -290,13 +274,7 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa
*/
public void onNavBarAttached() {
mIsAttached = true;
updatedFixedRotation();
if (mFixedRotationFlagEnabled) {
setRotationCallbacks(true);
}
mContext.getContentResolver().registerContentObserver(
Settings.Global.getUriFor(FIXED_ROTATION_TRANSFORM_SETTING_NAME),
false /* notifyForDescendants */, mFixedRotationObserver, UserHandle.USER_ALL);
mOverviewProxyService.addCallback(mQuickSwitchListener);
updateIsEnabled();
startTracking();
}
@@ -306,22 +284,11 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa
*/
public void onNavBarDetached() {
mIsAttached = false;
if (mFixedRotationFlagEnabled) {
setRotationCallbacks(false);
}
mContext.getContentResolver().unregisterContentObserver(mFixedRotationObserver);
mOverviewProxyService.removeCallback(mQuickSwitchListener);
updateIsEnabled();
stopTracking();
}
private void setRotationCallbacks(boolean enable) {
if (enable) {
mOverviewProxyService.addCallback(mQuickSwitchListener);
} else {
mOverviewProxyService.removeCallback(mQuickSwitchListener);
}
}
/**
* @see NavigationModeController.ModeChangedListener#onNavigationModeChanged
*/
@@ -641,17 +608,6 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa
InputManager.getInstance().injectInputEvent(ev, InputManager.INJECT_INPUT_EVENT_MODE_ASYNC);
}
private void updatedFixedRotation() {
boolean oldFlag = mFixedRotationFlagEnabled;
mFixedRotationFlagEnabled = Settings.Global.getInt(mContext.getContentResolver(),
FIXED_ROTATION_TRANSFORM_SETTING_NAME, 0) != 0;
if (oldFlag == mFixedRotationFlagEnabled) {
return;
}
setRotationCallbacks(mFixedRotationFlagEnabled);
}
public void setInsets(int leftInset, int rightInset) {
mLeftInset = leftInset;
mRightInset = rightInset;

View File

@@ -152,8 +152,6 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
private static final String EXTRA_DISABLE2_STATE = "disabled2_state";
private static final String EXTRA_APPEARANCE = "appearance";
private static final String EXTRA_TRANSIENT_STATE = "transient_state";
private static final String FIXED_ROTATION_TRANSFORM_SETTING_NAME = "fixed_rotation_transform";
/** Allow some time inbetween the long press for back and recents. */
private static final int LOCK_TO_APP_GESTURE_TOLERENCE = 200;
@@ -225,7 +223,6 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
private WindowManager.LayoutParams mOrientationParams;
private int mStartingQuickSwitchRotation;
private int mCurrentRotation;
private boolean mFixedRotationEnabled;
private ViewTreeObserver.OnGlobalLayoutListener mOrientationHandleGlobalLayoutListener;
private UiEventLogger mUiEventLogger;
@@ -370,14 +367,6 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
}
};
private final ContentObserver mFixedRotationObserver = new ContentObserver(
new Handler(Looper.getMainLooper())) {
@Override
public void onChange(boolean selfChange, Uri uri) {
updatedFixedRotation();
}
};
private final DeviceConfig.OnPropertiesChangedListener mOnPropertiesChangedListener =
new DeviceConfig.OnPropertiesChangedListener() {
@Override
@@ -439,10 +428,6 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
Settings.Secure.getUriFor(Settings.Secure.ASSISTANT),
false /* notifyForDescendants */, mAssistContentObserver, UserHandle.USER_ALL);
mContentResolver.registerContentObserver(
Settings.Global.getUriFor(FIXED_ROTATION_TRANSFORM_SETTING_NAME),
false /* notifyForDescendants */, mFixedRotationObserver, UserHandle.USER_ALL);
if (savedInstanceState != null) {
mDisabledFlags1 = savedInstanceState.getInt(EXTRA_DISABLE_STATE, 0);
mDisabledFlags2 = savedInstanceState.getInt(EXTRA_DISABLE2_STATE, 0);
@@ -468,7 +453,6 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
mNavigationModeController.removeListener(this);
mAccessibilityManagerWrapper.removeCallback(mAccessibilityListener);
mContentResolver.unregisterContentObserver(mAssistContentObserver);
mContentResolver.unregisterContentObserver(mFixedRotationObserver);
DeviceConfig.removeOnPropertiesChangedListener(mOnPropertiesChangedListener);
}
@@ -499,7 +483,6 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
}
mNavigationBarView.setNavigationIconHints(mNavigationIconHints);
mNavigationBarView.setWindowVisible(isNavBarWindowVisible());
updatedFixedRotation();
prepareNavigationBarView();
checkNavBarModes();
@@ -693,14 +676,6 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
return delta;
}
private void updatedFixedRotation() {
mFixedRotationEnabled = Settings.Global.getInt(mContentResolver,
FIXED_ROTATION_TRANSFORM_SETTING_NAME, 0) != 0;
if (!canShowSecondaryHandle()) {
resetSecondaryHandle();
}
}
@Override
public void dump(String prefix, FileDescriptor fd, PrintWriter pw, String[] args) {
if (mNavigationBarView != null) {
@@ -1409,7 +1384,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
}
private boolean canShowSecondaryHandle() {
return mFixedRotationEnabled && mNavBarMode == NAV_BAR_MODE_GESTURAL;
return mNavBarMode == NAV_BAR_MODE_GESTURAL;
}
private final Consumer<Integer> mRotationWatcher = rotation -> {

View File

@@ -1425,7 +1425,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
*/
@Surface.Rotation
int rotationForActivityInDifferentOrientation(@NonNull ActivityRecord r) {
if (!mWmService.mIsFixedRotationTransformEnabled) {
if (!WindowManagerService.ENABLE_FIXED_ROTATION_TRANSFORM) {
return ROTATION_UNDEFINED;
}
if (r.inMultiWindowMode()
@@ -1453,7 +1453,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
*/
boolean handleTopActivityLaunchingInDifferentOrientation(@NonNull ActivityRecord r,
boolean checkOpening) {
if (!mWmService.mIsFixedRotationTransformEnabled) {
if (!WindowManagerService.ENABLE_FIXED_ROTATION_TRANSFORM) {
return false;
}
if (r.isFinishingFixedRotationTransform()) {

View File

@@ -415,6 +415,13 @@ public class WindowManagerService extends IWindowManager.Stub
static boolean sEnableTripleBuffering = !SystemProperties.getBoolean(
DISABLE_TRIPLE_BUFFERING_PROPERTY, false);
/**
* Allows a fullscreen windowing mode activity to launch in its desired orientation directly
* when the display has different orientation.
*/
static final boolean ENABLE_FIXED_ROTATION_TRANSFORM =
SystemProperties.getBoolean("persist.wm.fixed_rotation_transform", true);
// Enums for animation scale update types.
@Retention(RetentionPolicy.SOURCE)
@IntDef({WINDOW_ANIMATION_SCALE, TRANSITION_ANIMATION_SCALE, ANIMATION_DURATION_SCALE})
@@ -431,10 +438,6 @@ public class WindowManagerService extends IWindowManager.Stub
/** System UI can create more window context... */
private static final int SYSTEM_UI_MULTIPLIER = 2;
// TODO(b/143053092): Remove the settings if it becomes stable.
private static final String FIXED_ROTATION_TRANSFORM_SETTING_NAME = "fixed_rotation_transform";
boolean mIsFixedRotationTransformEnabled;
final WindowManagerConstants mConstants;
final WindowTracing mWindowTracing;
@@ -765,8 +768,6 @@ public class WindowManagerService extends IWindowManager.Stub
DEVELOPMENT_ENABLE_SIZECOMPAT_FREEFORM);
private final Uri mRenderShadowsInCompositorUri = Settings.Global.getUriFor(
DEVELOPMENT_RENDER_SHADOWS_IN_COMPOSITOR);
private final Uri mFixedRotationTransformUri = Settings.Global.getUriFor(
FIXED_ROTATION_TRANSFORM_SETTING_NAME);
public SettingsObserver() {
super(new Handler());
@@ -791,8 +792,6 @@ public class WindowManagerService extends IWindowManager.Stub
UserHandle.USER_ALL);
resolver.registerContentObserver(mRenderShadowsInCompositorUri, false, this,
UserHandle.USER_ALL);
resolver.registerContentObserver(mFixedRotationTransformUri, false, this,
UserHandle.USER_ALL);
}
@Override
@@ -836,11 +835,6 @@ public class WindowManagerService extends IWindowManager.Stub
return;
}
if (mFixedRotationTransformUri.equals(uri)) {
updateFixedRotationTransform();
return;
}
@UpdateAnimationScaleMode
final int mode;
if (mWindowAnimationScaleUri.equals(uri)) {
@@ -860,7 +854,6 @@ public class WindowManagerService extends IWindowManager.Stub
void loadSettings() {
updateSystemUiSettings();
updatePointerLocation();
updateFixedRotationTransform();
}
void updateSystemUiSettings() {
@@ -932,17 +925,6 @@ public class WindowManagerService extends IWindowManager.Stub
mAtmService.mSizeCompatFreeform = sizeCompatFreeform;
}
void updateFixedRotationTransform() {
final int enabled = Settings.Global.getInt(mContext.getContentResolver(),
FIXED_ROTATION_TRANSFORM_SETTING_NAME, 2);
if (enabled == 2) {
// Make sure who read the settings won't use inconsistent default value.
Settings.Global.putInt(mContext.getContentResolver(),
FIXED_ROTATION_TRANSFORM_SETTING_NAME, 1);
}
mIsFixedRotationTransformEnabled = enabled != 0;
}
}
private void setShadowRenderer() {

View File

@@ -1423,7 +1423,6 @@ public class ActivityRecordTests extends ActivityTestsBase {
@Test
public void testActivityOnCancelFixedRotationTransform() {
mService.mWindowManager.mIsFixedRotationTransformEnabled = true;
final DisplayRotation displayRotation = mActivity.mDisplayContent.getDisplayRotation();
spyOn(displayRotation);
@@ -1480,7 +1479,6 @@ public class ActivityRecordTests extends ActivityTestsBase {
@Test
public void testIsSnapshotCompatible() {
mService.mWindowManager.mIsFixedRotationTransformEnabled = true;
final TaskSnapshot snapshot = new TaskSnapshotPersisterTestBase.TaskSnapshotBuilder()
.setRotation(mActivity.getWindowConfiguration().getRotation())
.build();
@@ -1494,7 +1492,6 @@ public class ActivityRecordTests extends ActivityTestsBase {
@Test
public void testFixedRotationSnapshotStartingWindow() {
mService.mWindowManager.mIsFixedRotationTransformEnabled = true;
// TaskSnapshotSurface requires a fullscreen opaque window.
final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.TYPE_APPLICATION_STARTING);

View File

@@ -455,7 +455,6 @@ public class AppWindowTokenTests extends WindowTestsBase {
@Test
public void testTransferStartingWindowSetFixedRotation() {
mWm.mIsFixedRotationTransformEnabled = true;
final ActivityRecord topActivity = createTestActivityRecordForGivenTask(mTask);
mTask.positionChildAt(topActivity, POSITION_TOP);
mActivity.addStartingWindow(mPackageName,

View File

@@ -1067,7 +1067,6 @@ public class DisplayContentTests extends WindowTestsBase {
@Test
public void testApplyTopFixedRotationTransform() {
mWm.mIsFixedRotationTransformEnabled = true;
final DisplayPolicy displayPolicy = mDisplayContent.getDisplayPolicy();
// Only non-movable (gesture) navigation bar will be animated by fixed rotation animation.
doReturn(false).when(displayPolicy).navigationBarCanMove();
@@ -1183,7 +1182,6 @@ public class DisplayContentTests extends WindowTestsBase {
@Test
public void testNoFixedRotationWithPip() {
mWm.mIsFixedRotationTransformEnabled = true;
// Make resume-top really update the activity state.
doReturn(false).when(mWm.mAtmService).isBooting();
doReturn(true).when(mWm.mAtmService).isBooted();

View File

@@ -321,7 +321,6 @@ public class RecentsAnimationControllerTest extends WindowTestsBase {
@Test
public void testRecentViewInFixedPortraitWhenTopAppInLandscape() {
mWm.mIsFixedRotationTransformEnabled = true;
mWm.setRecentsAnimationController(mController);
final ActivityRecord homeActivity = createHomeActivity();
@@ -390,7 +389,6 @@ public class RecentsAnimationControllerTest extends WindowTestsBase {
@Test
public void testWallpaperHasFixedRotationApplied() {
mWm.mIsFixedRotationTransformEnabled = true;
mWm.setRecentsAnimationController(mController);
// Create a portrait home activity, a wallpaper and a landscape activity displayed on top.

View File

@@ -511,7 +511,6 @@ public class SizeCompatTests extends ActivityTestsBase {
@Test
public void testLaunchWithFixedRotationTransform() {
mService.mWindowManager.mIsFixedRotationTransformEnabled = true;
final int dw = 1000;
final int dh = 2500;
final int notchHeight = 200;

View File

@@ -101,7 +101,6 @@ public class WallpaperControllerTests extends WindowTestsBase {
public void testWallpaperSizeWithFixedTransform() {
// No wallpaper
final DisplayContent dc = createNewDisplay();
dc.mWmService.mIsFixedRotationTransformEnabled = true;
// No wallpaper WSA Surface
WindowToken wallpaperWindowToken = new WallpaperWindowToken(mWm, mock(IBinder.class),