Merge "Add a DeviceConfig flag for ignoreOrientationRequest." into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
b4bd797457
@@ -18,6 +18,7 @@ package com.android.server.wm;
|
||||
|
||||
import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_ATM;
|
||||
import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_WITH_CLASS_NAME;
|
||||
import static com.android.server.wm.LetterboxConfigurationDeviceConfig.KEY_ALLOW_IGNORE_ORIENTATION_REQUEST;
|
||||
import static com.android.server.wm.LetterboxConfigurationDeviceConfig.KEY_ENABLE_DISPLAY_ROTATION_IMMERSIVE_APP_COMPAT_POLICY;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
@@ -311,11 +312,22 @@ final class LetterboxConfiguration {
|
||||
mDeviceConfig.updateFlagActiveStatus(
|
||||
/* isActive */ mIsDisplayRotationImmersiveAppCompatPolicyEnabled,
|
||||
/* key */ KEY_ENABLE_DISPLAY_ROTATION_IMMERSIVE_APP_COMPAT_POLICY);
|
||||
mDeviceConfig.updateFlagActiveStatus(
|
||||
/* isActive */ true,
|
||||
/* key */ KEY_ALLOW_IGNORE_ORIENTATION_REQUEST);
|
||||
|
||||
mLetterboxConfigurationPersister = letterboxConfigurationPersister;
|
||||
mLetterboxConfigurationPersister.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether enabling ignoreOrientationRequest is allowed on the device. This value is controlled
|
||||
* via {@link android.provider.DeviceConfig}.
|
||||
*/
|
||||
boolean isIgnoreOrientationRequestAllowed() {
|
||||
return mDeviceConfig.getFlag(KEY_ALLOW_IGNORE_ORIENTATION_REQUEST);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the aspect ratio of letterbox for fixed orientation. If given value is <= {@link
|
||||
* #MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO}, both it and a value of {@link
|
||||
|
||||
@@ -38,10 +38,16 @@ final class LetterboxConfigurationDeviceConfig
|
||||
private static final boolean DEFAULT_VALUE_ENABLE_DISPLAY_ROTATION_IMMERSIVE_APP_COMPAT_POLICY =
|
||||
true;
|
||||
|
||||
static final String KEY_ALLOW_IGNORE_ORIENTATION_REQUEST =
|
||||
"allow_ignore_orientation_request";
|
||||
private static final boolean DEFAULT_VALUE_ALLOW_IGNORE_ORIENTATION_REQUEST = true;
|
||||
|
||||
@VisibleForTesting
|
||||
static final Map<String, Boolean> sKeyToDefaultValueMap = Map.of(
|
||||
KEY_ENABLE_DISPLAY_ROTATION_IMMERSIVE_APP_COMPAT_POLICY,
|
||||
DEFAULT_VALUE_ENABLE_DISPLAY_ROTATION_IMMERSIVE_APP_COMPAT_POLICY
|
||||
DEFAULT_VALUE_ENABLE_DISPLAY_ROTATION_IMMERSIVE_APP_COMPAT_POLICY,
|
||||
KEY_ALLOW_IGNORE_ORIENTATION_REQUEST,
|
||||
DEFAULT_VALUE_ALLOW_IGNORE_ORIENTATION_REQUEST
|
||||
);
|
||||
|
||||
// Whether enabling rotation compat policy for immersive apps that prevents auto rotation
|
||||
@@ -52,6 +58,10 @@ final class LetterboxConfigurationDeviceConfig
|
||||
private boolean mIsDisplayRotationImmersiveAppCompatPolicyEnabled =
|
||||
DEFAULT_VALUE_ENABLE_DISPLAY_ROTATION_IMMERSIVE_APP_COMPAT_POLICY;
|
||||
|
||||
// Whether enabling ignoreOrientationRequest is allowed on the device.
|
||||
private boolean mIsAllowIgnoreOrientationRequest =
|
||||
DEFAULT_VALUE_ALLOW_IGNORE_ORIENTATION_REQUEST;
|
||||
|
||||
// Set of active device configs that need to be updated in
|
||||
// DeviceConfig.OnPropertiesChangedListener#onPropertiesChanged.
|
||||
private final ArraySet<String> mActiveDeviceConfigsSet = new ArraySet<>();
|
||||
@@ -93,6 +103,8 @@ final class LetterboxConfigurationDeviceConfig
|
||||
switch (key) {
|
||||
case KEY_ENABLE_DISPLAY_ROTATION_IMMERSIVE_APP_COMPAT_POLICY:
|
||||
return mIsDisplayRotationImmersiveAppCompatPolicyEnabled;
|
||||
case KEY_ALLOW_IGNORE_ORIENTATION_REQUEST:
|
||||
return mIsAllowIgnoreOrientationRequest;
|
||||
default:
|
||||
throw new AssertionError("Unexpected flag name: " + key);
|
||||
}
|
||||
@@ -108,6 +120,10 @@ final class LetterboxConfigurationDeviceConfig
|
||||
mIsDisplayRotationImmersiveAppCompatPolicyEnabled =
|
||||
getDeviceConfig(key, defaultValue);
|
||||
break;
|
||||
case KEY_ALLOW_IGNORE_ORIENTATION_REQUEST:
|
||||
mIsAllowIgnoreOrientationRequest =
|
||||
getDeviceConfig(key, defaultValue);
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError("Unexpected flag name: " + key);
|
||||
}
|
||||
|
||||
@@ -4170,7 +4170,8 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
* <p>Note: this assumes that {@link #mGlobalLock} is held by the caller.
|
||||
*/
|
||||
boolean isIgnoreOrientationRequestDisabled() {
|
||||
return mIsIgnoreOrientationRequestDisabled;
|
||||
return mIsIgnoreOrientationRequestDisabled
|
||||
|| !mLetterboxConfiguration.isIgnoreOrientationRequestAllowed();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2312,6 +2312,29 @@ public class SizeCompatTests extends WindowTestsBase {
|
||||
assertActivityMaxBoundsSandboxed();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDisplayIgnoreOrientationRequest_disabledViaDeviceConfig_orientationRespected() {
|
||||
// Set up a display in landscape
|
||||
setUpDisplaySizeWithApp(2800, 1400);
|
||||
|
||||
final ActivityRecord activity = buildActivityRecord(/* supportsSizeChanges= */ false,
|
||||
RESIZE_MODE_UNRESIZEABLE, SCREEN_ORIENTATION_PORTRAIT);
|
||||
activity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
|
||||
|
||||
spyOn(activity.mWmService.mLetterboxConfiguration);
|
||||
doReturn(true).when(activity.mWmService.mLetterboxConfiguration)
|
||||
.isIgnoreOrientationRequestAllowed();
|
||||
|
||||
// Display should not be rotated.
|
||||
assertEquals(SCREEN_ORIENTATION_UNSPECIFIED, activity.mDisplayContent.getOrientation());
|
||||
|
||||
doReturn(false).when(activity.mWmService.mLetterboxConfiguration)
|
||||
.isIgnoreOrientationRequestAllowed();
|
||||
|
||||
// Display should be rotated.
|
||||
assertEquals(SCREEN_ORIENTATION_PORTRAIT, activity.mDisplayContent.getOrientation());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSandboxDisplayApis_unresizableAppNotSandboxed() {
|
||||
// Set up a display in landscape with an unresizable app.
|
||||
|
||||
Reference in New Issue
Block a user