Loading data/etc/services.core.protolog.json +6 −0 Original line number Original line Diff line number Diff line Loading @@ -1051,6 +1051,12 @@ "group": "WM_DEBUG_ORIENTATION", "group": "WM_DEBUG_ORIENTATION", "at": "com\/android\/server\/wm\/WindowContainer.java" "at": "com\/android\/server\/wm\/WindowContainer.java" }, }, "-1104347731": { "message": "Setting requested orientation %s for %s", "level": "VERBOSE", "group": "WM_DEBUG_ORIENTATION", "at": "com\/android\/server\/wm\/ActivityRecord.java" }, "-1103716954": { "-1103716954": { "message": "Not removing %s due to exit animation", "message": "Not removing %s due to exit animation", "level": "VERBOSE", "level": "VERBOSE", Loading services/core/java/com/android/server/wm/ActivityRecord.java +54 −11 Original line number Original line Diff line number Diff line Loading @@ -7733,27 +7733,38 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A /** /** * Returns the requested {@link Configuration.Orientation} for the current activity. * Returns the requested {@link Configuration.Orientation} for the current activity. */ @Configuration.Orientation @Override int getRequestedConfigurationOrientation(boolean forDisplay) { return getRequestedConfigurationOrientation(forDisplay, getOverrideOrientation()); } /** * Returns the requested {@link Configuration.Orientation} for the requested * {@link ActivityInfo.ScreenOrientation}. * * * <p>When The current orientation is set to {@link SCREEN_ORIENTATION_BEHIND} it returns the * <p>When the current screen orientation is set to {@link SCREEN_ORIENTATION_BEHIND} it returns * requested orientation for the activity below which is the first activity with an explicit * the requested orientation for the activity below which is the first activity with an explicit * (different from {@link SCREEN_ORIENTATION_UNSET}) orientation which is not {@link * (different from {@link SCREEN_ORIENTATION_UNSET}) orientation which is not {@link * SCREEN_ORIENTATION_BEHIND}. * SCREEN_ORIENTATION_BEHIND}. */ */ @Configuration.Orientation @Configuration.Orientation @Override int getRequestedConfigurationOrientation(boolean forDisplay, int getRequestedConfigurationOrientation(boolean forDisplay) { @ActivityInfo.ScreenOrientation int requestedOrientation) { if (mLetterboxUiController.hasInheritedOrientation()) { if (mLetterboxUiController.hasInheritedOrientation()) { final RootDisplayArea root = getRootDisplayArea(); final RootDisplayArea root = getRootDisplayArea(); if (forDisplay && root != null && root.isOrientationDifferentFromDisplay()) { if (forDisplay && root != null && root.isOrientationDifferentFromDisplay()) { return ActivityInfo.reverseOrientation( return reverseConfigurationOrientation( mLetterboxUiController.getInheritedOrientation()); mLetterboxUiController.getInheritedOrientation()); } else { } else { return mLetterboxUiController.getInheritedOrientation(); return mLetterboxUiController.getInheritedOrientation(); } } } } if (task != null && getOverrideOrientation() == SCREEN_ORIENTATION_BEHIND) { if (task != null && requestedOrientation == SCREEN_ORIENTATION_BEHIND) { // We use Task here because we want to be consistent with what happens in // We use Task here because we want to be consistent with what happens in // multi-window mode where other tasks orientations are ignored. // multi-window mode where other tasks orientations are ignored. android.util.Log.d("orientation", "We are here"); final ActivityRecord belowCandidate = task.getActivity( final ActivityRecord belowCandidate = task.getActivity( a -> a.canDefineOrientationForActivitiesAbove() /* callback */, a -> a.canDefineOrientationForActivitiesAbove() /* callback */, this /* boundary */, false /* includeBoundary */, this /* boundary */, false /* includeBoundary */, Loading @@ -7762,7 +7773,23 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return belowCandidate.getRequestedConfigurationOrientation(forDisplay); return belowCandidate.getRequestedConfigurationOrientation(forDisplay); } } } } return super.getRequestedConfigurationOrientation(forDisplay); return super.getRequestedConfigurationOrientation(forDisplay, requestedOrientation); } /** * Returns the reversed configuration orientation. * @hide */ @Configuration.Orientation public static int reverseConfigurationOrientation(@Configuration.Orientation int orientation) { switch (orientation) { case ORIENTATION_LANDSCAPE: return ORIENTATION_PORTRAIT; case ORIENTATION_PORTRAIT: return ORIENTATION_LANDSCAPE; default: return orientation; } } } /** /** Loading Loading @@ -7808,6 +7835,19 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A if (mLetterboxUiController.shouldIgnoreRequestedOrientation(requestedOrientation)) { if (mLetterboxUiController.shouldIgnoreRequestedOrientation(requestedOrientation)) { return; return; } } // This is necessary in order to avoid going into size compat mode when the orientation // change request comes from the app if (mWmService.mLetterboxConfiguration .isSizeCompatModeDisabledAfterOrientationChangeFromApp() && getRequestedConfigurationOrientation(false, requestedOrientation) != getRequestedConfigurationOrientation(false /*forDisplay */)) { // Do not change the requested configuration now, because this will be done when setting // the orientation below with the new mCompatDisplayInsets clearSizeCompatModeAttributes(); } ProtoLog.v(WM_DEBUG_ORIENTATION, "Setting requested orientation %s for %s", ActivityInfo.screenOrientationToString(requestedOrientation), this); setOrientation(requestedOrientation, this); setOrientation(requestedOrientation, this); // Push the new configuration to the requested app in case where it's not pushed, e.g. when // Push the new configuration to the requested app in case where it's not pushed, e.g. when Loading Loading @@ -8027,17 +8067,20 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A mDisplayContent, this, mLetterboxBoundsForFixedOrientationAndAspectRatio); mDisplayContent, this, mLetterboxBoundsForFixedOrientationAndAspectRatio); } } @VisibleForTesting private void clearSizeCompatModeAttributes() { void clearSizeCompatMode() { final float lastSizeCompatScale = mSizeCompatScale; mInSizeCompatModeForBounds = false; mInSizeCompatModeForBounds = false; mSizeCompatScale = 1f; mSizeCompatScale = 1f; mSizeCompatBounds = null; mSizeCompatBounds = null; mCompatDisplayInsets = null; mCompatDisplayInsets = null; } @VisibleForTesting void clearSizeCompatMode() { final float lastSizeCompatScale = mSizeCompatScale; clearSizeCompatModeAttributes(); if (mSizeCompatScale != lastSizeCompatScale) { if (mSizeCompatScale != lastSizeCompatScale) { forAllWindows(WindowState::updateGlobalScale, false /* traverseTopToBottom */); forAllWindows(WindowState::updateGlobalScale, false /* traverseTopToBottom */); } } // Clear config override in #updateCompatDisplayInsets(). // Clear config override in #updateCompatDisplayInsets(). final int activityType = getActivityType(); final int activityType = getActivityType(); final Configuration overrideConfig = getRequestedOverrideConfiguration(); final Configuration overrideConfig = getRequestedOverrideConfiguration(); Loading services/core/java/com/android/server/wm/LetterboxConfiguration.java +15 −0 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.server.wm; import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_ATM; 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.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_ALLOW_IGNORE_ORIENTATION_REQUEST; import static com.android.server.wm.LetterboxConfigurationDeviceConfig.KEY_DISABLE_SIZE_COMPAT_MODE_AFTER_ORIENTATION_CHANGE_FROM_APP; import static com.android.server.wm.LetterboxConfigurationDeviceConfig.KEY_ENABLE_CAMERA_COMPAT_TREATMENT; import static com.android.server.wm.LetterboxConfigurationDeviceConfig.KEY_ENABLE_CAMERA_COMPAT_TREATMENT; import static com.android.server.wm.LetterboxConfigurationDeviceConfig.KEY_ENABLE_COMPAT_FAKE_FOCUS; import static com.android.server.wm.LetterboxConfigurationDeviceConfig.KEY_ENABLE_COMPAT_FAKE_FOCUS; import static com.android.server.wm.LetterboxConfigurationDeviceConfig.KEY_ENABLE_DISPLAY_ROTATION_IMMERSIVE_APP_COMPAT_POLICY; import static com.android.server.wm.LetterboxConfigurationDeviceConfig.KEY_ENABLE_DISPLAY_ROTATION_IMMERSIVE_APP_COMPAT_POLICY; Loading Loading @@ -314,6 +315,10 @@ final class LetterboxConfiguration { mDeviceConfig.updateFlagActiveStatus( mDeviceConfig.updateFlagActiveStatus( /* isActive */ mTranslucentLetterboxingEnabled, /* isActive */ mTranslucentLetterboxingEnabled, /* key */ KEY_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY); /* key */ KEY_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY); mDeviceConfig.updateFlagActiveStatus( /* isActive */ true, /* key */ KEY_DISABLE_SIZE_COMPAT_MODE_AFTER_ORIENTATION_CHANGE_FROM_APP); mLetterboxConfigurationPersister = letterboxConfigurationPersister; mLetterboxConfigurationPersister = letterboxConfigurationPersister; mLetterboxConfigurationPersister.start(); mLetterboxConfigurationPersister.start(); } } Loading @@ -326,6 +331,16 @@ final class LetterboxConfiguration { return mDeviceConfig.getFlag(KEY_ALLOW_IGNORE_ORIENTATION_REQUEST); return mDeviceConfig.getFlag(KEY_ALLOW_IGNORE_ORIENTATION_REQUEST); } } /** * Whether size compat mode is disabled after an orientation change request comes from the app. * This value is controlled via {@link android.provider.DeviceConfig}. */ // TODO(b/270356567) Clean up this flag boolean isSizeCompatModeDisabledAfterOrientationChangeFromApp() { return mDeviceConfig.getFlag( KEY_DISABLE_SIZE_COMPAT_MODE_AFTER_ORIENTATION_CHANGE_FROM_APP); } /** /** * Overrides the aspect ratio of letterbox for fixed orientation. If given value is <= {@link * 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 * #MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO}, both it and a value of {@link Loading services/core/java/com/android/server/wm/LetterboxConfigurationDeviceConfig.java +18 −2 Original line number Original line Diff line number Diff line Loading @@ -20,7 +20,6 @@ import android.annotation.NonNull; import android.provider.DeviceConfig; import android.provider.DeviceConfig; import android.util.ArraySet; import android.util.ArraySet; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting; import java.util.Map; import java.util.Map; Loading Loading @@ -53,6 +52,11 @@ final class LetterboxConfigurationDeviceConfig private static final boolean DEFAULT_VALUE_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY = true; private static final boolean DEFAULT_VALUE_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY = true; static final String KEY_DISABLE_SIZE_COMPAT_MODE_AFTER_ORIENTATION_CHANGE_FROM_APP = "disable_size_compat_mode_after_orientation_change_from_app"; private static final boolean DEFAULT_VALUE_DISABLE_SIZE_COMPAT_MODE_AFTER_ORIENTATION_CHANGE_FROM_APP = true; @VisibleForTesting @VisibleForTesting static final Map<String, Boolean> sKeyToDefaultValueMap = Map.of( static final Map<String, Boolean> sKeyToDefaultValueMap = Map.of( KEY_ENABLE_CAMERA_COMPAT_TREATMENT, KEY_ENABLE_CAMERA_COMPAT_TREATMENT, Loading @@ -64,7 +68,9 @@ final class LetterboxConfigurationDeviceConfig KEY_ENABLE_COMPAT_FAKE_FOCUS, KEY_ENABLE_COMPAT_FAKE_FOCUS, DEFAULT_VALUE_ENABLE_COMPAT_FAKE_FOCUS, DEFAULT_VALUE_ENABLE_COMPAT_FAKE_FOCUS, KEY_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY, KEY_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY, DEFAULT_VALUE_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY DEFAULT_VALUE_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY, KEY_DISABLE_SIZE_COMPAT_MODE_AFTER_ORIENTATION_CHANGE_FROM_APP, DEFAULT_VALUE_DISABLE_SIZE_COMPAT_MODE_AFTER_ORIENTATION_CHANGE_FROM_APP ); ); // Whether camera compatibility treatment is enabled. // Whether camera compatibility treatment is enabled. Loading Loading @@ -93,6 +99,10 @@ final class LetterboxConfigurationDeviceConfig private boolean mIsTranslucentLetterboxingAllowed = private boolean mIsTranslucentLetterboxingAllowed = DEFAULT_VALUE_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY; DEFAULT_VALUE_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY; // Whether size compat mode is disabled after an orientation change request comes from the app private boolean mIsSizeCompatModeDisabledAfterOrientationChangeFromApp = DEFAULT_VALUE_DISABLE_SIZE_COMPAT_MODE_AFTER_ORIENTATION_CHANGE_FROM_APP; // Set of active device configs that need to be updated in // Set of active device configs that need to be updated in // DeviceConfig.OnPropertiesChangedListener#onPropertiesChanged. // DeviceConfig.OnPropertiesChangedListener#onPropertiesChanged. private final ArraySet<String> mActiveDeviceConfigsSet = new ArraySet<>(); private final ArraySet<String> mActiveDeviceConfigsSet = new ArraySet<>(); Loading Loading @@ -142,6 +152,8 @@ final class LetterboxConfigurationDeviceConfig return mIsCompatFakeFocusAllowed; return mIsCompatFakeFocusAllowed; case KEY_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY: case KEY_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY: return mIsTranslucentLetterboxingAllowed; return mIsTranslucentLetterboxingAllowed; case KEY_DISABLE_SIZE_COMPAT_MODE_AFTER_ORIENTATION_CHANGE_FROM_APP: return mIsSizeCompatModeDisabledAfterOrientationChangeFromApp; default: default: throw new AssertionError("Unexpected flag name: " + key); throw new AssertionError("Unexpected flag name: " + key); } } Loading Loading @@ -169,6 +181,10 @@ final class LetterboxConfigurationDeviceConfig case KEY_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY: case KEY_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY: mIsTranslucentLetterboxingAllowed = getDeviceConfig(key, defaultValue); mIsTranslucentLetterboxingAllowed = getDeviceConfig(key, defaultValue); break; break; case KEY_DISABLE_SIZE_COMPAT_MODE_AFTER_ORIENTATION_CHANGE_FROM_APP: mIsSizeCompatModeDisabledAfterOrientationChangeFromApp = getDeviceConfig(key, defaultValue); break; default: default: throw new AssertionError("Unexpected flag name: " + key); throw new AssertionError("Unexpected flag name: " + key); } } Loading services/core/java/com/android/server/wm/WindowContainer.java +21 −2 Original line number Original line Diff line number Diff line Loading @@ -1456,7 +1456,26 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< */ */ @Configuration.Orientation @Configuration.Orientation int getRequestedConfigurationOrientation(boolean forDisplay) { int getRequestedConfigurationOrientation(boolean forDisplay) { int requestedOrientation = getOverrideOrientation(); return getRequestedConfigurationOrientation(forDisplay, getOverrideOrientation()); } /** * Gets the configuration orientation by the requested screen orientation * * @param forDisplay whether it is the requested config orientation for display. * If {@code true}, we may reverse the requested orientation if the root is * different from the display, so that when the display rotates to the * reversed orientation, the requested app will be in the requested * orientation. * @param requestedOrientation the screen orientation({@link ScreenOrientation}) that is * requested * @return orientation in ({@link Configuration#ORIENTATION_LANDSCAPE}, * {@link Configuration#ORIENTATION_PORTRAIT}, * {@link Configuration#ORIENTATION_UNDEFINED}). */ @Configuration.Orientation int getRequestedConfigurationOrientation(boolean forDisplay, @ScreenOrientation int requestedOrientation) { final RootDisplayArea root = getRootDisplayArea(); final RootDisplayArea root = getRootDisplayArea(); if (forDisplay && root != null && root.isOrientationDifferentFromDisplay()) { if (forDisplay && root != null && root.isOrientationDifferentFromDisplay()) { // Reverse the requested orientation if the orientation of its root is different from // Reverse the requested orientation if the orientation of its root is different from Loading @@ -1466,7 +1485,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< // (portrait). // (portrait). // When an app below the DAG is requesting landscape, it should actually request the // When an app below the DAG is requesting landscape, it should actually request the // display to be portrait, so that the DAG and the app will be in landscape. // display to be portrait, so that the DAG and the app will be in landscape. requestedOrientation = reverseOrientation(getOverrideOrientation()); requestedOrientation = reverseOrientation(requestedOrientation); } } if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_NOSENSOR) { if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_NOSENSOR) { Loading Loading
data/etc/services.core.protolog.json +6 −0 Original line number Original line Diff line number Diff line Loading @@ -1051,6 +1051,12 @@ "group": "WM_DEBUG_ORIENTATION", "group": "WM_DEBUG_ORIENTATION", "at": "com\/android\/server\/wm\/WindowContainer.java" "at": "com\/android\/server\/wm\/WindowContainer.java" }, }, "-1104347731": { "message": "Setting requested orientation %s for %s", "level": "VERBOSE", "group": "WM_DEBUG_ORIENTATION", "at": "com\/android\/server\/wm\/ActivityRecord.java" }, "-1103716954": { "-1103716954": { "message": "Not removing %s due to exit animation", "message": "Not removing %s due to exit animation", "level": "VERBOSE", "level": "VERBOSE", Loading
services/core/java/com/android/server/wm/ActivityRecord.java +54 −11 Original line number Original line Diff line number Diff line Loading @@ -7733,27 +7733,38 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A /** /** * Returns the requested {@link Configuration.Orientation} for the current activity. * Returns the requested {@link Configuration.Orientation} for the current activity. */ @Configuration.Orientation @Override int getRequestedConfigurationOrientation(boolean forDisplay) { return getRequestedConfigurationOrientation(forDisplay, getOverrideOrientation()); } /** * Returns the requested {@link Configuration.Orientation} for the requested * {@link ActivityInfo.ScreenOrientation}. * * * <p>When The current orientation is set to {@link SCREEN_ORIENTATION_BEHIND} it returns the * <p>When the current screen orientation is set to {@link SCREEN_ORIENTATION_BEHIND} it returns * requested orientation for the activity below which is the first activity with an explicit * the requested orientation for the activity below which is the first activity with an explicit * (different from {@link SCREEN_ORIENTATION_UNSET}) orientation which is not {@link * (different from {@link SCREEN_ORIENTATION_UNSET}) orientation which is not {@link * SCREEN_ORIENTATION_BEHIND}. * SCREEN_ORIENTATION_BEHIND}. */ */ @Configuration.Orientation @Configuration.Orientation @Override int getRequestedConfigurationOrientation(boolean forDisplay, int getRequestedConfigurationOrientation(boolean forDisplay) { @ActivityInfo.ScreenOrientation int requestedOrientation) { if (mLetterboxUiController.hasInheritedOrientation()) { if (mLetterboxUiController.hasInheritedOrientation()) { final RootDisplayArea root = getRootDisplayArea(); final RootDisplayArea root = getRootDisplayArea(); if (forDisplay && root != null && root.isOrientationDifferentFromDisplay()) { if (forDisplay && root != null && root.isOrientationDifferentFromDisplay()) { return ActivityInfo.reverseOrientation( return reverseConfigurationOrientation( mLetterboxUiController.getInheritedOrientation()); mLetterboxUiController.getInheritedOrientation()); } else { } else { return mLetterboxUiController.getInheritedOrientation(); return mLetterboxUiController.getInheritedOrientation(); } } } } if (task != null && getOverrideOrientation() == SCREEN_ORIENTATION_BEHIND) { if (task != null && requestedOrientation == SCREEN_ORIENTATION_BEHIND) { // We use Task here because we want to be consistent with what happens in // We use Task here because we want to be consistent with what happens in // multi-window mode where other tasks orientations are ignored. // multi-window mode where other tasks orientations are ignored. android.util.Log.d("orientation", "We are here"); final ActivityRecord belowCandidate = task.getActivity( final ActivityRecord belowCandidate = task.getActivity( a -> a.canDefineOrientationForActivitiesAbove() /* callback */, a -> a.canDefineOrientationForActivitiesAbove() /* callback */, this /* boundary */, false /* includeBoundary */, this /* boundary */, false /* includeBoundary */, Loading @@ -7762,7 +7773,23 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return belowCandidate.getRequestedConfigurationOrientation(forDisplay); return belowCandidate.getRequestedConfigurationOrientation(forDisplay); } } } } return super.getRequestedConfigurationOrientation(forDisplay); return super.getRequestedConfigurationOrientation(forDisplay, requestedOrientation); } /** * Returns the reversed configuration orientation. * @hide */ @Configuration.Orientation public static int reverseConfigurationOrientation(@Configuration.Orientation int orientation) { switch (orientation) { case ORIENTATION_LANDSCAPE: return ORIENTATION_PORTRAIT; case ORIENTATION_PORTRAIT: return ORIENTATION_LANDSCAPE; default: return orientation; } } } /** /** Loading Loading @@ -7808,6 +7835,19 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A if (mLetterboxUiController.shouldIgnoreRequestedOrientation(requestedOrientation)) { if (mLetterboxUiController.shouldIgnoreRequestedOrientation(requestedOrientation)) { return; return; } } // This is necessary in order to avoid going into size compat mode when the orientation // change request comes from the app if (mWmService.mLetterboxConfiguration .isSizeCompatModeDisabledAfterOrientationChangeFromApp() && getRequestedConfigurationOrientation(false, requestedOrientation) != getRequestedConfigurationOrientation(false /*forDisplay */)) { // Do not change the requested configuration now, because this will be done when setting // the orientation below with the new mCompatDisplayInsets clearSizeCompatModeAttributes(); } ProtoLog.v(WM_DEBUG_ORIENTATION, "Setting requested orientation %s for %s", ActivityInfo.screenOrientationToString(requestedOrientation), this); setOrientation(requestedOrientation, this); setOrientation(requestedOrientation, this); // Push the new configuration to the requested app in case where it's not pushed, e.g. when // Push the new configuration to the requested app in case where it's not pushed, e.g. when Loading Loading @@ -8027,17 +8067,20 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A mDisplayContent, this, mLetterboxBoundsForFixedOrientationAndAspectRatio); mDisplayContent, this, mLetterboxBoundsForFixedOrientationAndAspectRatio); } } @VisibleForTesting private void clearSizeCompatModeAttributes() { void clearSizeCompatMode() { final float lastSizeCompatScale = mSizeCompatScale; mInSizeCompatModeForBounds = false; mInSizeCompatModeForBounds = false; mSizeCompatScale = 1f; mSizeCompatScale = 1f; mSizeCompatBounds = null; mSizeCompatBounds = null; mCompatDisplayInsets = null; mCompatDisplayInsets = null; } @VisibleForTesting void clearSizeCompatMode() { final float lastSizeCompatScale = mSizeCompatScale; clearSizeCompatModeAttributes(); if (mSizeCompatScale != lastSizeCompatScale) { if (mSizeCompatScale != lastSizeCompatScale) { forAllWindows(WindowState::updateGlobalScale, false /* traverseTopToBottom */); forAllWindows(WindowState::updateGlobalScale, false /* traverseTopToBottom */); } } // Clear config override in #updateCompatDisplayInsets(). // Clear config override in #updateCompatDisplayInsets(). final int activityType = getActivityType(); final int activityType = getActivityType(); final Configuration overrideConfig = getRequestedOverrideConfiguration(); final Configuration overrideConfig = getRequestedOverrideConfiguration(); Loading
services/core/java/com/android/server/wm/LetterboxConfiguration.java +15 −0 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.server.wm; import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_ATM; 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.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_ALLOW_IGNORE_ORIENTATION_REQUEST; import static com.android.server.wm.LetterboxConfigurationDeviceConfig.KEY_DISABLE_SIZE_COMPAT_MODE_AFTER_ORIENTATION_CHANGE_FROM_APP; import static com.android.server.wm.LetterboxConfigurationDeviceConfig.KEY_ENABLE_CAMERA_COMPAT_TREATMENT; import static com.android.server.wm.LetterboxConfigurationDeviceConfig.KEY_ENABLE_CAMERA_COMPAT_TREATMENT; import static com.android.server.wm.LetterboxConfigurationDeviceConfig.KEY_ENABLE_COMPAT_FAKE_FOCUS; import static com.android.server.wm.LetterboxConfigurationDeviceConfig.KEY_ENABLE_COMPAT_FAKE_FOCUS; import static com.android.server.wm.LetterboxConfigurationDeviceConfig.KEY_ENABLE_DISPLAY_ROTATION_IMMERSIVE_APP_COMPAT_POLICY; import static com.android.server.wm.LetterboxConfigurationDeviceConfig.KEY_ENABLE_DISPLAY_ROTATION_IMMERSIVE_APP_COMPAT_POLICY; Loading Loading @@ -314,6 +315,10 @@ final class LetterboxConfiguration { mDeviceConfig.updateFlagActiveStatus( mDeviceConfig.updateFlagActiveStatus( /* isActive */ mTranslucentLetterboxingEnabled, /* isActive */ mTranslucentLetterboxingEnabled, /* key */ KEY_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY); /* key */ KEY_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY); mDeviceConfig.updateFlagActiveStatus( /* isActive */ true, /* key */ KEY_DISABLE_SIZE_COMPAT_MODE_AFTER_ORIENTATION_CHANGE_FROM_APP); mLetterboxConfigurationPersister = letterboxConfigurationPersister; mLetterboxConfigurationPersister = letterboxConfigurationPersister; mLetterboxConfigurationPersister.start(); mLetterboxConfigurationPersister.start(); } } Loading @@ -326,6 +331,16 @@ final class LetterboxConfiguration { return mDeviceConfig.getFlag(KEY_ALLOW_IGNORE_ORIENTATION_REQUEST); return mDeviceConfig.getFlag(KEY_ALLOW_IGNORE_ORIENTATION_REQUEST); } } /** * Whether size compat mode is disabled after an orientation change request comes from the app. * This value is controlled via {@link android.provider.DeviceConfig}. */ // TODO(b/270356567) Clean up this flag boolean isSizeCompatModeDisabledAfterOrientationChangeFromApp() { return mDeviceConfig.getFlag( KEY_DISABLE_SIZE_COMPAT_MODE_AFTER_ORIENTATION_CHANGE_FROM_APP); } /** /** * Overrides the aspect ratio of letterbox for fixed orientation. If given value is <= {@link * 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 * #MIN_FIXED_ORIENTATION_LETTERBOX_ASPECT_RATIO}, both it and a value of {@link Loading
services/core/java/com/android/server/wm/LetterboxConfigurationDeviceConfig.java +18 −2 Original line number Original line Diff line number Diff line Loading @@ -20,7 +20,6 @@ import android.annotation.NonNull; import android.provider.DeviceConfig; import android.provider.DeviceConfig; import android.util.ArraySet; import android.util.ArraySet; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.annotations.VisibleForTesting; import java.util.Map; import java.util.Map; Loading Loading @@ -53,6 +52,11 @@ final class LetterboxConfigurationDeviceConfig private static final boolean DEFAULT_VALUE_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY = true; private static final boolean DEFAULT_VALUE_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY = true; static final String KEY_DISABLE_SIZE_COMPAT_MODE_AFTER_ORIENTATION_CHANGE_FROM_APP = "disable_size_compat_mode_after_orientation_change_from_app"; private static final boolean DEFAULT_VALUE_DISABLE_SIZE_COMPAT_MODE_AFTER_ORIENTATION_CHANGE_FROM_APP = true; @VisibleForTesting @VisibleForTesting static final Map<String, Boolean> sKeyToDefaultValueMap = Map.of( static final Map<String, Boolean> sKeyToDefaultValueMap = Map.of( KEY_ENABLE_CAMERA_COMPAT_TREATMENT, KEY_ENABLE_CAMERA_COMPAT_TREATMENT, Loading @@ -64,7 +68,9 @@ final class LetterboxConfigurationDeviceConfig KEY_ENABLE_COMPAT_FAKE_FOCUS, KEY_ENABLE_COMPAT_FAKE_FOCUS, DEFAULT_VALUE_ENABLE_COMPAT_FAKE_FOCUS, DEFAULT_VALUE_ENABLE_COMPAT_FAKE_FOCUS, KEY_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY, KEY_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY, DEFAULT_VALUE_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY DEFAULT_VALUE_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY, KEY_DISABLE_SIZE_COMPAT_MODE_AFTER_ORIENTATION_CHANGE_FROM_APP, DEFAULT_VALUE_DISABLE_SIZE_COMPAT_MODE_AFTER_ORIENTATION_CHANGE_FROM_APP ); ); // Whether camera compatibility treatment is enabled. // Whether camera compatibility treatment is enabled. Loading Loading @@ -93,6 +99,10 @@ final class LetterboxConfigurationDeviceConfig private boolean mIsTranslucentLetterboxingAllowed = private boolean mIsTranslucentLetterboxingAllowed = DEFAULT_VALUE_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY; DEFAULT_VALUE_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY; // Whether size compat mode is disabled after an orientation change request comes from the app private boolean mIsSizeCompatModeDisabledAfterOrientationChangeFromApp = DEFAULT_VALUE_DISABLE_SIZE_COMPAT_MODE_AFTER_ORIENTATION_CHANGE_FROM_APP; // Set of active device configs that need to be updated in // Set of active device configs that need to be updated in // DeviceConfig.OnPropertiesChangedListener#onPropertiesChanged. // DeviceConfig.OnPropertiesChangedListener#onPropertiesChanged. private final ArraySet<String> mActiveDeviceConfigsSet = new ArraySet<>(); private final ArraySet<String> mActiveDeviceConfigsSet = new ArraySet<>(); Loading Loading @@ -142,6 +152,8 @@ final class LetterboxConfigurationDeviceConfig return mIsCompatFakeFocusAllowed; return mIsCompatFakeFocusAllowed; case KEY_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY: case KEY_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY: return mIsTranslucentLetterboxingAllowed; return mIsTranslucentLetterboxingAllowed; case KEY_DISABLE_SIZE_COMPAT_MODE_AFTER_ORIENTATION_CHANGE_FROM_APP: return mIsSizeCompatModeDisabledAfterOrientationChangeFromApp; default: default: throw new AssertionError("Unexpected flag name: " + key); throw new AssertionError("Unexpected flag name: " + key); } } Loading Loading @@ -169,6 +181,10 @@ final class LetterboxConfigurationDeviceConfig case KEY_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY: case KEY_ENABLE_LETTERBOX_TRANSLUCENT_ACTIVITY: mIsTranslucentLetterboxingAllowed = getDeviceConfig(key, defaultValue); mIsTranslucentLetterboxingAllowed = getDeviceConfig(key, defaultValue); break; break; case KEY_DISABLE_SIZE_COMPAT_MODE_AFTER_ORIENTATION_CHANGE_FROM_APP: mIsSizeCompatModeDisabledAfterOrientationChangeFromApp = getDeviceConfig(key, defaultValue); break; default: default: throw new AssertionError("Unexpected flag name: " + key); throw new AssertionError("Unexpected flag name: " + key); } } Loading
services/core/java/com/android/server/wm/WindowContainer.java +21 −2 Original line number Original line Diff line number Diff line Loading @@ -1456,7 +1456,26 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< */ */ @Configuration.Orientation @Configuration.Orientation int getRequestedConfigurationOrientation(boolean forDisplay) { int getRequestedConfigurationOrientation(boolean forDisplay) { int requestedOrientation = getOverrideOrientation(); return getRequestedConfigurationOrientation(forDisplay, getOverrideOrientation()); } /** * Gets the configuration orientation by the requested screen orientation * * @param forDisplay whether it is the requested config orientation for display. * If {@code true}, we may reverse the requested orientation if the root is * different from the display, so that when the display rotates to the * reversed orientation, the requested app will be in the requested * orientation. * @param requestedOrientation the screen orientation({@link ScreenOrientation}) that is * requested * @return orientation in ({@link Configuration#ORIENTATION_LANDSCAPE}, * {@link Configuration#ORIENTATION_PORTRAIT}, * {@link Configuration#ORIENTATION_UNDEFINED}). */ @Configuration.Orientation int getRequestedConfigurationOrientation(boolean forDisplay, @ScreenOrientation int requestedOrientation) { final RootDisplayArea root = getRootDisplayArea(); final RootDisplayArea root = getRootDisplayArea(); if (forDisplay && root != null && root.isOrientationDifferentFromDisplay()) { if (forDisplay && root != null && root.isOrientationDifferentFromDisplay()) { // Reverse the requested orientation if the orientation of its root is different from // Reverse the requested orientation if the orientation of its root is different from Loading @@ -1466,7 +1485,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< // (portrait). // (portrait). // When an app below the DAG is requesting landscape, it should actually request the // When an app below the DAG is requesting landscape, it should actually request the // display to be portrait, so that the DAG and the app will be in landscape. // display to be portrait, so that the DAG and the app will be in landscape. requestedOrientation = reverseOrientation(getOverrideOrientation()); requestedOrientation = reverseOrientation(requestedOrientation); } } if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_NOSENSOR) { if (requestedOrientation == ActivityInfo.SCREEN_ORIENTATION_NOSENSOR) { Loading