Loading services/core/java/com/android/server/wm/AppCompatAspectRatioOverrides.java +19 −39 Original line number Diff line number Diff line Loading @@ -62,8 +62,8 @@ class AppCompatAspectRatioOverrides { private final ActivityRecord mActivityRecord; @NonNull private final AppCompatConfiguration mAppCompatConfiguration; @NonNull private final UserAspectRatioState mUserAspectRatioState; @PackageManager.UserMinAspectRatio final int mUserAspectRatioType; @NonNull private final OptPropFactory.OptProp mAllowMinAspectRatioOverrideOptProp; Loading @@ -86,7 +86,7 @@ class AppCompatAspectRatioOverrides { mActivityRecord = activityRecord; mAppCompatConfiguration = appCompatConfiguration; mAppCompatDeviceStateQuery = appCompatDeviceStateQuery; mUserAspectRatioState = new UserAspectRatioState(); mUserAspectRatioType = getUserMinAspectRatioOverrideType(); mAppCompatReachabilityOverrides = appCompatReachabilityOverrides; mAllowMinAspectRatioOverrideOptProp = optPropBuilder.create( PROPERTY_COMPAT_ALLOW_MIN_ASPECT_RATIO_OVERRIDE); Loading Loading @@ -122,41 +122,28 @@ class AppCompatAspectRatioOverrides { * current app. */ boolean shouldApplyUserMinAspectRatioOverride() { if (!shouldEnableUserAspectRatioSettings()) { return false; } mUserAspectRatioState.mUserAspectRatio = getUserMinAspectRatioOverrideCode(); return mUserAspectRatioState.mUserAspectRatio != USER_MIN_ASPECT_RATIO_UNSET && mUserAspectRatioState.mUserAspectRatio != USER_MIN_ASPECT_RATIO_APP_DEFAULT && mUserAspectRatioState.mUserAspectRatio != USER_MIN_ASPECT_RATIO_FULLSCREEN; return shouldEnableUserAspectRatioSettings() && mUserAspectRatioType != USER_MIN_ASPECT_RATIO_UNSET && mUserAspectRatioType != USER_MIN_ASPECT_RATIO_APP_DEFAULT && mUserAspectRatioType != USER_MIN_ASPECT_RATIO_FULLSCREEN; } boolean shouldApplyUserFullscreenOverride() { if (isUserFullscreenOverrideEnabled()) { mUserAspectRatioState.mUserAspectRatio = getUserMinAspectRatioOverrideCode(); return mUserAspectRatioState.mUserAspectRatio == USER_MIN_ASPECT_RATIO_FULLSCREEN; } return false; return isUserFullscreenOverrideEnabled() && mUserAspectRatioType == USER_MIN_ASPECT_RATIO_FULLSCREEN; } boolean isUserFullscreenOverrideEnabled() { if (mAllowUserAspectRatioOverrideOptProp.isFalse() || mAllowUserAspectRatioFullscreenOverrideOptProp.isFalse() || !mAppCompatConfiguration.isUserAppAspectRatioFullscreenEnabled()) { return false; } return true; return !mAllowUserAspectRatioOverrideOptProp.isFalse() && !mAllowUserAspectRatioFullscreenOverrideOptProp.isFalse() && mAppCompatConfiguration.isUserAppAspectRatioFullscreenEnabled(); } boolean isSystemOverrideToFullscreenEnabled() { return isChangeEnabled(mActivityRecord, OVERRIDE_ANY_ORIENTATION_TO_USER) && !mAllowOrientationOverrideOptProp.isFalse() && (mUserAspectRatioState.mUserAspectRatio == USER_MIN_ASPECT_RATIO_UNSET || mUserAspectRatioState.mUserAspectRatio == USER_MIN_ASPECT_RATIO_FULLSCREEN); && (mUserAspectRatioType == USER_MIN_ASPECT_RATIO_UNSET || mUserAspectRatioType == USER_MIN_ASPECT_RATIO_FULLSCREEN); } /** Loading @@ -173,12 +160,11 @@ class AppCompatAspectRatioOverrides { } boolean hasFullscreenOverride() { // `mUserAspectRatio` is always initialized first in `shouldApplyUserFullscreenOverride()`. return shouldApplyUserFullscreenOverride() || isSystemOverrideToFullscreenEnabled(); } float getUserMinAspectRatio() { switch (mUserAspectRatioState.mUserAspectRatio) { switch (mUserAspectRatioType) { case USER_MIN_ASPECT_RATIO_DISPLAY_SIZE: return getDisplaySizeMinAspectRatio(); case USER_MIN_ASPECT_RATIO_SPLIT_SCREEN: Loading @@ -191,7 +177,7 @@ class AppCompatAspectRatioOverrides { return 3 / 2f; default: throw new AssertionError("Unexpected user min aspect ratio override: " + mUserAspectRatioState.mUserAspectRatio); + mUserAspectRatioType); } } Loading Loading @@ -268,14 +254,15 @@ class AppCompatAspectRatioOverrides { return !mAllowUserAspectRatioOverrideOptProp.isFalse(); } int getUserMinAspectRatioOverrideCode() { // TODO(b/359217664): make this private. int getUserMinAspectRatioOverrideType() { try { return mActivityRecord.mAtmService.getPackageManager() .getUserMinAspectRatio(mActivityRecord.packageName, mActivityRecord.mUserId); } catch (RemoteException e) { Slog.w(TAG, "Exception thrown retrieving aspect ratio user override " + this, e); } return mUserAspectRatioState.mUserAspectRatio; return USER_MIN_ASPECT_RATIO_UNSET; } private float getDefaultMinAspectRatioForUnresizableApps() { Loading @@ -299,13 +286,6 @@ class AppCompatAspectRatioOverrides { return getDisplaySizeMinAspectRatio(); } private static class UserAspectRatioState { // TODO(b/315140179): Make mUserAspectRatio final // The min aspect ratio override set by user @PackageManager.UserMinAspectRatio private int mUserAspectRatio = USER_MIN_ASPECT_RATIO_UNSET; } private Resources getResources() { return mActivityRecord.mWmService.mContext.getResources(); } Loading services/core/java/com/android/server/wm/AppCompatOrientationPolicy.java +3 −21 Original line number Diff line number Diff line Loading @@ -56,11 +56,11 @@ class AppCompatOrientationPolicy { final DisplayContent displayContent = mActivityRecord.mDisplayContent; final boolean isIgnoreOrientationRequestEnabled = displayContent != null && displayContent.getIgnoreOrientationRequest(); final boolean shouldApplyUserFullscreenOverride = mAppCompatOverrides .getAppCompatAspectRatioOverrides().shouldApplyUserFullscreenOverride(); final boolean hasFullscreenOverride = mAppCompatOverrides .getAppCompatAspectRatioOverrides().hasFullscreenOverride(); final boolean shouldCameraCompatControlOrientation = AppCompatCameraPolicy.shouldCameraCompatControlOrientation(mActivityRecord); if (shouldApplyUserFullscreenOverride && isIgnoreOrientationRequestEnabled if (hasFullscreenOverride && isIgnoreOrientationRequestEnabled // Do not override orientation to fullscreen for camera activities. // Fixed-orientation activities are rarely tested in other orientations, and it // often results in sideways or stretched previews. As the camera compat treatment Loading Loading @@ -101,24 +101,6 @@ class AppCompatOrientationPolicy { return candidate; } // mUserAspectRatio is always initialized first in shouldApplyUserFullscreenOverride(), // which will always come first before this check as user override > device // manufacturer override. final boolean isSystemOverrideToFullscreenEnabled = mAppCompatOverrides .getAppCompatAspectRatioOverrides().isSystemOverrideToFullscreenEnabled(); if (isSystemOverrideToFullscreenEnabled && isIgnoreOrientationRequestEnabled // Do not override orientation to fullscreen for camera activities. // Fixed-orientation activities are rarely tested in other orientations, and it // often results in sideways or stretched previews. As the camera compat treatment // targets fixed-orientation activities, overriding the orientation disables the // treatment. && !shouldCameraCompatControlOrientation) { Slog.v(TAG, "Requested orientation " + screenOrientationToString(candidate) + " for " + mActivityRecord + " is overridden to " + screenOrientationToString(SCREEN_ORIENTATION_USER)); return SCREEN_ORIENTATION_USER; } final AppCompatOrientationOverrides.OrientationOverridesState capabilityState = mAppCompatOverrides.getAppCompatOrientationOverrides() .mOrientationOverridesState; Loading services/core/java/com/android/server/wm/DesktopAppCompatAspectRatioPolicy.java +1 −1 Original line number Diff line number Diff line Loading @@ -265,7 +265,7 @@ public class DesktopAppCompatAspectRatioPolicy { } final int userAspectRatioCode = mAppCompatOverrides.getAppCompatAspectRatioOverrides() .getUserMinAspectRatioOverrideCode(); .getUserMinAspectRatioOverrideType(); return userAspectRatioCode != USER_MIN_ASPECT_RATIO_UNSET && userAspectRatioCode != USER_MIN_ASPECT_RATIO_APP_DEFAULT Loading services/tests/wmtests/src/com/android/server/wm/AppCompatActivityRobot.java +8 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; import static com.android.server.wm.BackgroundActivityStartControllerTests.setViaReflection; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; Loading Loading @@ -227,7 +228,13 @@ class AppCompatActivityRobot { void setGetUserMinAspectRatioOverrideCode(@UserMinAspectRatio int overrideCode) { doReturn(overrideCode).when(mActivityStack.top().mAppCompatController .getAppCompatAspectRatioOverrides()).getUserMinAspectRatioOverrideCode(); .getAppCompatAspectRatioOverrides()).getUserMinAspectRatioOverrideType(); } void setUserAspectRatioType(@UserMinAspectRatio int aspectRatio) { final AppCompatAspectRatioOverrides aspectRatioOverrides = mActivityStack.top() .mAppCompatController.getAppCompatAspectRatioOverrides(); setViaReflection(aspectRatioOverrides, "mUserAspectRatioType", aspectRatio); } void setGetUserMinAspectRatioOverrideValue(float overrideValue) { Loading services/tests/wmtests/src/com/android/server/wm/AppCompatAspectRatioOverridesTest.java +10 −10 Original line number Diff line number Diff line Loading @@ -75,7 +75,7 @@ public class AppCompatAspectRatioOverridesTest extends WindowTestsBase { robot.activity().setIgnoreOrientationRequest(/* enabled */ true); robot.prop().disable(PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_FULLSCREEN_OVERRIDE); robot.activity().createActivityWithComponent(); robot.activity().setGetUserMinAspectRatioOverrideCode(USER_MIN_ASPECT_RATIO_FULLSCREEN); robot.activity().setUserAspectRatioType(USER_MIN_ASPECT_RATIO_FULLSCREEN); robot.checkShouldApplyUserFullscreenOverride(/* expected */ false); }); Loading @@ -88,7 +88,7 @@ public class AppCompatAspectRatioOverridesTest extends WindowTestsBase { robot.activity().setIgnoreOrientationRequest(/* enabled */ true); robot.prop().disable(PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE); robot.activity().createActivityWithComponent(); robot.activity().setGetUserMinAspectRatioOverrideCode(USER_MIN_ASPECT_RATIO_FULLSCREEN); robot.activity().setUserAspectRatioType(USER_MIN_ASPECT_RATIO_FULLSCREEN); robot.checkShouldApplyUserFullscreenOverride(/* expected */ false); }); } Loading @@ -100,7 +100,7 @@ public class AppCompatAspectRatioOverridesTest extends WindowTestsBase { robot.conf().enableUserAppAspectRatioFullscreen(/* enabled */ true); robot.activity().setIgnoreOrientationRequest(/* enabled */ true); robot.activity().createActivityWithComponent(); robot.activity().setGetUserMinAspectRatioOverrideCode(USER_MIN_ASPECT_RATIO_FULLSCREEN); robot.activity().setUserAspectRatioType(USER_MIN_ASPECT_RATIO_FULLSCREEN); robot.checkShouldApplyUserFullscreenOverride(/* expected */ true); }); Loading @@ -113,7 +113,7 @@ public class AppCompatAspectRatioOverridesTest extends WindowTestsBase { robot.activity().setIgnoreOrientationRequest(/* enabled */ true); robot.prop().disable(PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE); robot.activity().createActivityWithComponent(); robot.activity().setGetUserMinAspectRatioOverrideCode(USER_MIN_ASPECT_RATIO_3_2); robot.activity().setUserAspectRatioType(USER_MIN_ASPECT_RATIO_3_2); robot.checkShouldEnableUserAspectRatioSettings(/* expected */ false); }); Loading @@ -126,7 +126,7 @@ public class AppCompatAspectRatioOverridesTest extends WindowTestsBase { robot.activity().setIgnoreOrientationRequest(/* enabled */ true); robot.prop().enable(PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE); robot.activity().createActivityWithComponent(); robot.activity().setGetUserMinAspectRatioOverrideCode(USER_MIN_ASPECT_RATIO_3_2); robot.activity().setUserAspectRatioType(USER_MIN_ASPECT_RATIO_3_2); robot.checkShouldEnableUserAspectRatioSettings(/* expected */ true); }); Loading @@ -139,7 +139,7 @@ public class AppCompatAspectRatioOverridesTest extends WindowTestsBase { robot.activity().setIgnoreOrientationRequest(/* enabled */ true); robot.prop().enable(PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE); robot.activity().createActivityWithComponent(); robot.activity().setGetUserMinAspectRatioOverrideCode(USER_MIN_ASPECT_RATIO_3_2); robot.activity().setUserAspectRatioType(USER_MIN_ASPECT_RATIO_3_2); robot.checkShouldEnableUserAspectRatioSettings(/* expected */ false); }); Loading @@ -152,7 +152,7 @@ public class AppCompatAspectRatioOverridesTest extends WindowTestsBase { robot.activity().setIgnoreOrientationRequest(/* enabled */ true); robot.prop().disable(PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE); robot.activity().createActivityWithComponent(); robot.activity().setGetUserMinAspectRatioOverrideCode(USER_MIN_ASPECT_RATIO_3_2); robot.activity().setUserAspectRatioType(USER_MIN_ASPECT_RATIO_3_2); robot.checkShouldEnableUserAspectRatioSettings(/* expected */ false); }); Loading @@ -175,7 +175,7 @@ public class AppCompatAspectRatioOverridesTest extends WindowTestsBase { robot.conf().enableUserAppAspectRatioSettings(/* enabled */ true); robot.activity().setIgnoreOrientationRequest(/* enabled */ false); robot.activity().createActivityWithComponent(); robot.activity().setGetUserMinAspectRatioOverrideCode(USER_MIN_ASPECT_RATIO_3_2); robot.activity().setUserAspectRatioType(USER_MIN_ASPECT_RATIO_3_2); robot.checkShouldApplyUserMinAspectRatioOverride(/* expected */ false); }); Loading @@ -187,7 +187,7 @@ public class AppCompatAspectRatioOverridesTest extends WindowTestsBase { robot.conf().enableUserAppAspectRatioSettings(/* enabled */ true); robot.activity().setIgnoreOrientationRequest(/* enabled */ true); robot.activity().createActivityWithComponent(); robot.activity().setGetUserMinAspectRatioOverrideCode(USER_MIN_ASPECT_RATIO_3_2); robot.activity().setUserAspectRatioType(USER_MIN_ASPECT_RATIO_3_2); robot.checkShouldApplyUserMinAspectRatioOverride(/* expected */ true); }); Loading @@ -199,7 +199,7 @@ public class AppCompatAspectRatioOverridesTest extends WindowTestsBase { robot.conf().enableUserAppAspectRatioSettings(/* enabled */ false); robot.activity().setIgnoreOrientationRequest(/* enabled */ true); robot.activity().createActivityWithComponent(); robot.activity().setGetUserMinAspectRatioOverrideCode(USER_MIN_ASPECT_RATIO_3_2); robot.activity().setUserAspectRatioType(USER_MIN_ASPECT_RATIO_3_2); robot.checkShouldApplyUserMinAspectRatioOverride(/* expected */ false); }); Loading Loading
services/core/java/com/android/server/wm/AppCompatAspectRatioOverrides.java +19 −39 Original line number Diff line number Diff line Loading @@ -62,8 +62,8 @@ class AppCompatAspectRatioOverrides { private final ActivityRecord mActivityRecord; @NonNull private final AppCompatConfiguration mAppCompatConfiguration; @NonNull private final UserAspectRatioState mUserAspectRatioState; @PackageManager.UserMinAspectRatio final int mUserAspectRatioType; @NonNull private final OptPropFactory.OptProp mAllowMinAspectRatioOverrideOptProp; Loading @@ -86,7 +86,7 @@ class AppCompatAspectRatioOverrides { mActivityRecord = activityRecord; mAppCompatConfiguration = appCompatConfiguration; mAppCompatDeviceStateQuery = appCompatDeviceStateQuery; mUserAspectRatioState = new UserAspectRatioState(); mUserAspectRatioType = getUserMinAspectRatioOverrideType(); mAppCompatReachabilityOverrides = appCompatReachabilityOverrides; mAllowMinAspectRatioOverrideOptProp = optPropBuilder.create( PROPERTY_COMPAT_ALLOW_MIN_ASPECT_RATIO_OVERRIDE); Loading Loading @@ -122,41 +122,28 @@ class AppCompatAspectRatioOverrides { * current app. */ boolean shouldApplyUserMinAspectRatioOverride() { if (!shouldEnableUserAspectRatioSettings()) { return false; } mUserAspectRatioState.mUserAspectRatio = getUserMinAspectRatioOverrideCode(); return mUserAspectRatioState.mUserAspectRatio != USER_MIN_ASPECT_RATIO_UNSET && mUserAspectRatioState.mUserAspectRatio != USER_MIN_ASPECT_RATIO_APP_DEFAULT && mUserAspectRatioState.mUserAspectRatio != USER_MIN_ASPECT_RATIO_FULLSCREEN; return shouldEnableUserAspectRatioSettings() && mUserAspectRatioType != USER_MIN_ASPECT_RATIO_UNSET && mUserAspectRatioType != USER_MIN_ASPECT_RATIO_APP_DEFAULT && mUserAspectRatioType != USER_MIN_ASPECT_RATIO_FULLSCREEN; } boolean shouldApplyUserFullscreenOverride() { if (isUserFullscreenOverrideEnabled()) { mUserAspectRatioState.mUserAspectRatio = getUserMinAspectRatioOverrideCode(); return mUserAspectRatioState.mUserAspectRatio == USER_MIN_ASPECT_RATIO_FULLSCREEN; } return false; return isUserFullscreenOverrideEnabled() && mUserAspectRatioType == USER_MIN_ASPECT_RATIO_FULLSCREEN; } boolean isUserFullscreenOverrideEnabled() { if (mAllowUserAspectRatioOverrideOptProp.isFalse() || mAllowUserAspectRatioFullscreenOverrideOptProp.isFalse() || !mAppCompatConfiguration.isUserAppAspectRatioFullscreenEnabled()) { return false; } return true; return !mAllowUserAspectRatioOverrideOptProp.isFalse() && !mAllowUserAspectRatioFullscreenOverrideOptProp.isFalse() && mAppCompatConfiguration.isUserAppAspectRatioFullscreenEnabled(); } boolean isSystemOverrideToFullscreenEnabled() { return isChangeEnabled(mActivityRecord, OVERRIDE_ANY_ORIENTATION_TO_USER) && !mAllowOrientationOverrideOptProp.isFalse() && (mUserAspectRatioState.mUserAspectRatio == USER_MIN_ASPECT_RATIO_UNSET || mUserAspectRatioState.mUserAspectRatio == USER_MIN_ASPECT_RATIO_FULLSCREEN); && (mUserAspectRatioType == USER_MIN_ASPECT_RATIO_UNSET || mUserAspectRatioType == USER_MIN_ASPECT_RATIO_FULLSCREEN); } /** Loading @@ -173,12 +160,11 @@ class AppCompatAspectRatioOverrides { } boolean hasFullscreenOverride() { // `mUserAspectRatio` is always initialized first in `shouldApplyUserFullscreenOverride()`. return shouldApplyUserFullscreenOverride() || isSystemOverrideToFullscreenEnabled(); } float getUserMinAspectRatio() { switch (mUserAspectRatioState.mUserAspectRatio) { switch (mUserAspectRatioType) { case USER_MIN_ASPECT_RATIO_DISPLAY_SIZE: return getDisplaySizeMinAspectRatio(); case USER_MIN_ASPECT_RATIO_SPLIT_SCREEN: Loading @@ -191,7 +177,7 @@ class AppCompatAspectRatioOverrides { return 3 / 2f; default: throw new AssertionError("Unexpected user min aspect ratio override: " + mUserAspectRatioState.mUserAspectRatio); + mUserAspectRatioType); } } Loading Loading @@ -268,14 +254,15 @@ class AppCompatAspectRatioOverrides { return !mAllowUserAspectRatioOverrideOptProp.isFalse(); } int getUserMinAspectRatioOverrideCode() { // TODO(b/359217664): make this private. int getUserMinAspectRatioOverrideType() { try { return mActivityRecord.mAtmService.getPackageManager() .getUserMinAspectRatio(mActivityRecord.packageName, mActivityRecord.mUserId); } catch (RemoteException e) { Slog.w(TAG, "Exception thrown retrieving aspect ratio user override " + this, e); } return mUserAspectRatioState.mUserAspectRatio; return USER_MIN_ASPECT_RATIO_UNSET; } private float getDefaultMinAspectRatioForUnresizableApps() { Loading @@ -299,13 +286,6 @@ class AppCompatAspectRatioOverrides { return getDisplaySizeMinAspectRatio(); } private static class UserAspectRatioState { // TODO(b/315140179): Make mUserAspectRatio final // The min aspect ratio override set by user @PackageManager.UserMinAspectRatio private int mUserAspectRatio = USER_MIN_ASPECT_RATIO_UNSET; } private Resources getResources() { return mActivityRecord.mWmService.mContext.getResources(); } Loading
services/core/java/com/android/server/wm/AppCompatOrientationPolicy.java +3 −21 Original line number Diff line number Diff line Loading @@ -56,11 +56,11 @@ class AppCompatOrientationPolicy { final DisplayContent displayContent = mActivityRecord.mDisplayContent; final boolean isIgnoreOrientationRequestEnabled = displayContent != null && displayContent.getIgnoreOrientationRequest(); final boolean shouldApplyUserFullscreenOverride = mAppCompatOverrides .getAppCompatAspectRatioOverrides().shouldApplyUserFullscreenOverride(); final boolean hasFullscreenOverride = mAppCompatOverrides .getAppCompatAspectRatioOverrides().hasFullscreenOverride(); final boolean shouldCameraCompatControlOrientation = AppCompatCameraPolicy.shouldCameraCompatControlOrientation(mActivityRecord); if (shouldApplyUserFullscreenOverride && isIgnoreOrientationRequestEnabled if (hasFullscreenOverride && isIgnoreOrientationRequestEnabled // Do not override orientation to fullscreen for camera activities. // Fixed-orientation activities are rarely tested in other orientations, and it // often results in sideways or stretched previews. As the camera compat treatment Loading Loading @@ -101,24 +101,6 @@ class AppCompatOrientationPolicy { return candidate; } // mUserAspectRatio is always initialized first in shouldApplyUserFullscreenOverride(), // which will always come first before this check as user override > device // manufacturer override. final boolean isSystemOverrideToFullscreenEnabled = mAppCompatOverrides .getAppCompatAspectRatioOverrides().isSystemOverrideToFullscreenEnabled(); if (isSystemOverrideToFullscreenEnabled && isIgnoreOrientationRequestEnabled // Do not override orientation to fullscreen for camera activities. // Fixed-orientation activities are rarely tested in other orientations, and it // often results in sideways or stretched previews. As the camera compat treatment // targets fixed-orientation activities, overriding the orientation disables the // treatment. && !shouldCameraCompatControlOrientation) { Slog.v(TAG, "Requested orientation " + screenOrientationToString(candidate) + " for " + mActivityRecord + " is overridden to " + screenOrientationToString(SCREEN_ORIENTATION_USER)); return SCREEN_ORIENTATION_USER; } final AppCompatOrientationOverrides.OrientationOverridesState capabilityState = mAppCompatOverrides.getAppCompatOrientationOverrides() .mOrientationOverridesState; Loading
services/core/java/com/android/server/wm/DesktopAppCompatAspectRatioPolicy.java +1 −1 Original line number Diff line number Diff line Loading @@ -265,7 +265,7 @@ public class DesktopAppCompatAspectRatioPolicy { } final int userAspectRatioCode = mAppCompatOverrides.getAppCompatAspectRatioOverrides() .getUserMinAspectRatioOverrideCode(); .getUserMinAspectRatioOverrideType(); return userAspectRatioCode != USER_MIN_ASPECT_RATIO_UNSET && userAspectRatioCode != USER_MIN_ASPECT_RATIO_APP_DEFAULT Loading
services/tests/wmtests/src/com/android/server/wm/AppCompatActivityRobot.java +8 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; import static com.android.server.wm.BackgroundActivityStartControllerTests.setViaReflection; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; Loading Loading @@ -227,7 +228,13 @@ class AppCompatActivityRobot { void setGetUserMinAspectRatioOverrideCode(@UserMinAspectRatio int overrideCode) { doReturn(overrideCode).when(mActivityStack.top().mAppCompatController .getAppCompatAspectRatioOverrides()).getUserMinAspectRatioOverrideCode(); .getAppCompatAspectRatioOverrides()).getUserMinAspectRatioOverrideType(); } void setUserAspectRatioType(@UserMinAspectRatio int aspectRatio) { final AppCompatAspectRatioOverrides aspectRatioOverrides = mActivityStack.top() .mAppCompatController.getAppCompatAspectRatioOverrides(); setViaReflection(aspectRatioOverrides, "mUserAspectRatioType", aspectRatio); } void setGetUserMinAspectRatioOverrideValue(float overrideValue) { Loading
services/tests/wmtests/src/com/android/server/wm/AppCompatAspectRatioOverridesTest.java +10 −10 Original line number Diff line number Diff line Loading @@ -75,7 +75,7 @@ public class AppCompatAspectRatioOverridesTest extends WindowTestsBase { robot.activity().setIgnoreOrientationRequest(/* enabled */ true); robot.prop().disable(PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_FULLSCREEN_OVERRIDE); robot.activity().createActivityWithComponent(); robot.activity().setGetUserMinAspectRatioOverrideCode(USER_MIN_ASPECT_RATIO_FULLSCREEN); robot.activity().setUserAspectRatioType(USER_MIN_ASPECT_RATIO_FULLSCREEN); robot.checkShouldApplyUserFullscreenOverride(/* expected */ false); }); Loading @@ -88,7 +88,7 @@ public class AppCompatAspectRatioOverridesTest extends WindowTestsBase { robot.activity().setIgnoreOrientationRequest(/* enabled */ true); robot.prop().disable(PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE); robot.activity().createActivityWithComponent(); robot.activity().setGetUserMinAspectRatioOverrideCode(USER_MIN_ASPECT_RATIO_FULLSCREEN); robot.activity().setUserAspectRatioType(USER_MIN_ASPECT_RATIO_FULLSCREEN); robot.checkShouldApplyUserFullscreenOverride(/* expected */ false); }); } Loading @@ -100,7 +100,7 @@ public class AppCompatAspectRatioOverridesTest extends WindowTestsBase { robot.conf().enableUserAppAspectRatioFullscreen(/* enabled */ true); robot.activity().setIgnoreOrientationRequest(/* enabled */ true); robot.activity().createActivityWithComponent(); robot.activity().setGetUserMinAspectRatioOverrideCode(USER_MIN_ASPECT_RATIO_FULLSCREEN); robot.activity().setUserAspectRatioType(USER_MIN_ASPECT_RATIO_FULLSCREEN); robot.checkShouldApplyUserFullscreenOverride(/* expected */ true); }); Loading @@ -113,7 +113,7 @@ public class AppCompatAspectRatioOverridesTest extends WindowTestsBase { robot.activity().setIgnoreOrientationRequest(/* enabled */ true); robot.prop().disable(PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE); robot.activity().createActivityWithComponent(); robot.activity().setGetUserMinAspectRatioOverrideCode(USER_MIN_ASPECT_RATIO_3_2); robot.activity().setUserAspectRatioType(USER_MIN_ASPECT_RATIO_3_2); robot.checkShouldEnableUserAspectRatioSettings(/* expected */ false); }); Loading @@ -126,7 +126,7 @@ public class AppCompatAspectRatioOverridesTest extends WindowTestsBase { robot.activity().setIgnoreOrientationRequest(/* enabled */ true); robot.prop().enable(PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE); robot.activity().createActivityWithComponent(); robot.activity().setGetUserMinAspectRatioOverrideCode(USER_MIN_ASPECT_RATIO_3_2); robot.activity().setUserAspectRatioType(USER_MIN_ASPECT_RATIO_3_2); robot.checkShouldEnableUserAspectRatioSettings(/* expected */ true); }); Loading @@ -139,7 +139,7 @@ public class AppCompatAspectRatioOverridesTest extends WindowTestsBase { robot.activity().setIgnoreOrientationRequest(/* enabled */ true); robot.prop().enable(PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE); robot.activity().createActivityWithComponent(); robot.activity().setGetUserMinAspectRatioOverrideCode(USER_MIN_ASPECT_RATIO_3_2); robot.activity().setUserAspectRatioType(USER_MIN_ASPECT_RATIO_3_2); robot.checkShouldEnableUserAspectRatioSettings(/* expected */ false); }); Loading @@ -152,7 +152,7 @@ public class AppCompatAspectRatioOverridesTest extends WindowTestsBase { robot.activity().setIgnoreOrientationRequest(/* enabled */ true); robot.prop().disable(PROPERTY_COMPAT_ALLOW_USER_ASPECT_RATIO_OVERRIDE); robot.activity().createActivityWithComponent(); robot.activity().setGetUserMinAspectRatioOverrideCode(USER_MIN_ASPECT_RATIO_3_2); robot.activity().setUserAspectRatioType(USER_MIN_ASPECT_RATIO_3_2); robot.checkShouldEnableUserAspectRatioSettings(/* expected */ false); }); Loading @@ -175,7 +175,7 @@ public class AppCompatAspectRatioOverridesTest extends WindowTestsBase { robot.conf().enableUserAppAspectRatioSettings(/* enabled */ true); robot.activity().setIgnoreOrientationRequest(/* enabled */ false); robot.activity().createActivityWithComponent(); robot.activity().setGetUserMinAspectRatioOverrideCode(USER_MIN_ASPECT_RATIO_3_2); robot.activity().setUserAspectRatioType(USER_MIN_ASPECT_RATIO_3_2); robot.checkShouldApplyUserMinAspectRatioOverride(/* expected */ false); }); Loading @@ -187,7 +187,7 @@ public class AppCompatAspectRatioOverridesTest extends WindowTestsBase { robot.conf().enableUserAppAspectRatioSettings(/* enabled */ true); robot.activity().setIgnoreOrientationRequest(/* enabled */ true); robot.activity().createActivityWithComponent(); robot.activity().setGetUserMinAspectRatioOverrideCode(USER_MIN_ASPECT_RATIO_3_2); robot.activity().setUserAspectRatioType(USER_MIN_ASPECT_RATIO_3_2); robot.checkShouldApplyUserMinAspectRatioOverride(/* expected */ true); }); Loading @@ -199,7 +199,7 @@ public class AppCompatAspectRatioOverridesTest extends WindowTestsBase { robot.conf().enableUserAppAspectRatioSettings(/* enabled */ false); robot.activity().setIgnoreOrientationRequest(/* enabled */ true); robot.activity().createActivityWithComponent(); robot.activity().setGetUserMinAspectRatioOverrideCode(USER_MIN_ASPECT_RATIO_3_2); robot.activity().setUserAspectRatioType(USER_MIN_ASPECT_RATIO_3_2); robot.checkShouldApplyUserMinAspectRatioOverride(/* expected */ false); }); Loading