Loading core/res/res/values/config.xml +0 −5 Original line number Diff line number Diff line Loading @@ -2673,11 +2673,6 @@ </string-array> <!-- Flag indicating that this device does not rotate and will always remain in its default orientation. Activities that desire to run in a non-compatible orientation will be run from an emulated display within the physical display. --> <bool name="config_forceDefaultOrientation">false</bool> <!-- Default Gravity setting for the system Toast view. Equivalent to: Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM --> <integer name="config_toastDefaultGravity">0x00000051</integer> Loading core/res/res/values/symbols.xml +0 −1 Original line number Diff line number Diff line Loading @@ -347,7 +347,6 @@ <java-symbol type="bool" name="config_requireRadioPowerOffOnSimRefreshReset" /> <java-symbol type="bool" name="config_speed_up_audio_on_mt_calls" /> <java-symbol type="bool" name="config_useFixedVolume" /> <java-symbol type="bool" name="config_forceDefaultOrientation" /> <java-symbol type="bool" name="config_wifi_batched_scan_supported" /> <java-symbol type="bool" name="config_wifi_softap_acs_supported" /> <java-symbol type="string" name="config_wifi_softap_acs_supported_channel_list" /> Loading services/core/java/com/android/server/wm/DisplayRotation.java +53 −24 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ORIENTATION; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; import android.annotation.IntDef; import android.annotation.UserIdInt; import android.app.ActivityManager; import android.content.ContentResolver; Loading Loading @@ -49,6 +50,8 @@ import com.android.server.policy.WindowOrientationListener; import com.android.server.statusbar.StatusBarManagerInternal; import java.io.PrintWriter; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * Defines the mapping between orientation and rotation of a display. Loading Loading @@ -95,12 +98,37 @@ public class DisplayRotation { private int mUserRotationMode = WindowManagerPolicy.USER_ROTATION_FREE; private int mUserRotation = Surface.ROTATION_0; /** * Flag that indicates this is a display that may run better when fixed to user rotation. */ private boolean mDefaultFixedToUserRotation; /** * No overridden behavior is provided in terms of fixing rotation to user rotation. Use other * flags to derive the default behavior, such as {@link WindowManagerService#mIsPc} and * {@link WindowManagerService#mForceDesktopModeOnExternalDisplays}. */ static final int FIXED_TO_USER_ROTATION_DEFAULT = 0; /** * Don't fix display rotation to {@link #mUserRotation} only. Always allow other factors to play * a role in deciding display rotation. */ static final int FIXED_TO_USER_ROTATION_DISABLED = 1; /** * Only use {@link #mUserRotation} as the display rotation. */ static final int FIXED_TO_USER_ROTATION_ENABLED = 2; @IntDef({ FIXED_TO_USER_ROTATION_DEFAULT, FIXED_TO_USER_ROTATION_DISABLED, FIXED_TO_USER_ROTATION_ENABLED }) @Retention(RetentionPolicy.SOURCE) @interface FixedToUserRotation {} /** * A flag to indicate if the display rotation should be fixed to user specified rotation * regardless of all other states (including app requrested orientation). {@code true} the * display rotation should be fixed to user specified rotation, {@code false} otherwise. */ private boolean mFixedToUserRotation; private int mFixedToUserRotation = FIXED_TO_USER_ROTATION_DEFAULT; private int mDemoHdmiRotation; private int mDemoRotation; Loading Loading @@ -220,19 +248,14 @@ public class DisplayRotation { PackageManager.FEATURE_LEANBACK); final boolean isCloseToSquare = isNonDecorDisplayCloseToSquare(Surface.ROTATION_0, width, height); final boolean forceDefaultOrientationInRes = res.getBoolean(com.android.internal.R.bool.config_forceDefaultOrientation); final boolean forceDefaultOrienation = ((longSizeDp >= 960 && shortSizeDp >= 720) || isCar || isTv || isCloseToSquare) && forceDefaultOrientationInRes final boolean forceDesktopMode = mService.mForceDesktopModeOnExternalDisplays && !isDefaultDisplay; mDefaultFixedToUserRotation = (isCar || isTv || mService.mIsPc || forceDesktopMode || isCloseToSquare) // For debug purposes the next line turns this feature off with: // $ adb shell setprop config.override_forced_orient true // $ adb shell wm size reset && !"true".equals(SystemProperties.get("config.override_forced_orient")); // Configuration says we force to use the default orientation. We can fall back to fix // rotation to only user rotation. As long as OEM doesn't change user rotation then the // rotation of this display is effectively stuck at 0 deg. setFixedToUserRotation(forceDefaultOrienation); } private boolean isNonDecorDisplayCloseToSquare(int rotation, int width, int height) { Loading Loading @@ -263,7 +286,7 @@ public class DisplayRotation { } void restoreSettings(int userRotationMode, int userRotation, boolean fixedToUserRotation) { @FixedToUserRotation int fixedToUserRotation) { mFixedToUserRotation = fixedToUserRotation; // We will retrieve user rotation and user rotation mode from settings for default display. Loading @@ -285,14 +308,13 @@ public class DisplayRotation { mUserRotation = userRotation; } void setFixedToUserRotation(boolean fixedToUserRotation) { void setFixedToUserRotation(@FixedToUserRotation int fixedToUserRotation) { if (mFixedToUserRotation == fixedToUserRotation) { return; } mFixedToUserRotation = fixedToUserRotation; mDisplayWindowSettings.setFixedToUserRotation(mDisplayContent, fixedToUserRotation); mDisplayWindowSettings.setFixedToUserRotation(mDisplayContent, fixedToUserRotation); mService.updateRotation(true /* alwaysSendConfiguration */, false /* forceRelayout */); } Loading Loading @@ -346,7 +368,14 @@ public class DisplayRotation { } boolean isFixedToUserRotation() { return mFixedToUserRotation; switch (mFixedToUserRotation) { case FIXED_TO_USER_ROTATION_DISABLED: return false; case FIXED_TO_USER_ROTATION_ENABLED: return true; default: return mDefaultFixedToUserRotation; } } /** Loading @@ -355,7 +384,7 @@ public class DisplayRotation { * false} is when {@link #isFixedToUserRotation()} is {@code true}. */ boolean respectAppRequestedOrientation() { return !mFixedToUserRotation; return !isFixedToUserRotation(); } public int getLandscapeRotation() { Loading Loading @@ -461,7 +490,7 @@ public class DisplayRotation { * screen is switched off. */ private boolean needSensorRunning() { if (mFixedToUserRotation) { if (isFixedToUserRotation()) { // We are sure we only respect user rotation settings, so we are sure we will not // support sensor rotation. return false; Loading Loading @@ -527,7 +556,7 @@ public class DisplayRotation { ); } if (mFixedToUserRotation) { if (isFixedToUserRotation()) { return mUserRotation; } Loading Loading @@ -739,7 +768,7 @@ public class DisplayRotation { // demo, hdmi, vr, etc mode. // Determine if the rotation is currently forced. if (mFixedToUserRotation) { if (isFixedToUserRotation()) { return false; // Rotation is forced to user settings. } Loading Loading @@ -899,7 +928,7 @@ public class DisplayRotation { pw.print(" mDemoHdmiRotationLock=" + mDemoHdmiRotationLock); pw.println(" mUndockedHdmiRotation=" + Surface.rotationToString(mUndockedHdmiRotation)); pw.println(prefix + " mLidOpenRotation=" + Surface.rotationToString(mLidOpenRotation)); pw.println(prefix + " mFixedToUserRotation=" + mFixedToUserRotation); pw.println(prefix + " mFixedToUserRotation=" + isFixedToUserRotation()); } private class OrientationListener extends WindowOrientationListener { Loading services/core/java/com/android/server/wm/DisplayWindowSettings.java +9 −7 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import static android.view.WindowManager.REMOVE_CONTENT_MODE_UNDEFINED; import static com.android.server.wm.DisplayContent.FORCE_SCALING_MODE_AUTO; import static com.android.server.wm.DisplayContent.FORCE_SCALING_MODE_DISABLED; import static com.android.server.wm.DisplayRotation.FIXED_TO_USER_ROTATION_DEFAULT; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; Loading Loading @@ -80,7 +81,8 @@ class DisplayWindowSettings { private boolean mShouldShowWithInsecureKeyguard = false; private boolean mShouldShowSystemDecors = false; private boolean mShouldShowIme = false; private boolean mFixedToUserRotation; private @DisplayRotation.FixedToUserRotation int mFixedToUserRotation = FIXED_TO_USER_ROTATION_DEFAULT; private Entry(String name) { mName = name; Loading @@ -99,7 +101,7 @@ class DisplayWindowSettings { && !mShouldShowWithInsecureKeyguard && !mShouldShowSystemDecors && !mShouldShowIme && !mFixedToUserRotation; && mFixedToUserRotation == FIXED_TO_USER_ROTATION_DEFAULT; } } Loading Loading @@ -188,7 +190,8 @@ class DisplayWindowSettings { writeSettingsIfNeeded(entry, displayInfo); } void setFixedToUserRotation(DisplayContent displayContent, boolean fixedToUserRotation) { void setFixedToUserRotation(DisplayContent displayContent, @DisplayRotation.FixedToUserRotation int fixedToUserRotation) { final DisplayInfo displayInfo = displayContent.getDisplayInfo(); final Entry entry = getOrCreateEntry(displayInfo); entry.mFixedToUserRotation = fixedToUserRotation; Loading Loading @@ -464,8 +467,7 @@ class DisplayWindowSettings { "shouldShowWithInsecureKeyguard"); entry.mShouldShowSystemDecors = getBooleanAttribute(parser, "shouldShowSystemDecors"); entry.mShouldShowIme = getBooleanAttribute(parser, "shouldShowIme"); entry.mFixedToUserRotation = getBooleanAttribute(parser, "fixedToUserRotation"); entry.mFixedToUserRotation = getIntAttribute(parser, "fixedToUserRotation"); mEntries.put(name, entry); } XmlUtils.skipCurrentTag(parser); Loading Loading @@ -549,9 +551,9 @@ class DisplayWindowSettings { if (entry.mShouldShowIme) { out.attribute(null, "shouldShowIme", Boolean.toString(entry.mShouldShowIme)); } if (entry.mFixedToUserRotation) { if (entry.mFixedToUserRotation != FIXED_TO_USER_ROTATION_DEFAULT) { out.attribute(null, "fixedToUserRotation", Boolean.toString(entry.mFixedToUserRotation)); Integer.toString(entry.mFixedToUserRotation)); } out.endTag(null, "display"); } Loading services/core/java/com/android/server/wm/WindowManagerService.java +3 −2 Original line number Diff line number Diff line Loading @@ -3520,14 +3520,15 @@ public class WindowManagerService extends IWindowManager.Stub } } void setRotateForApp(int displayId, boolean enabled) { void setRotateForApp(int displayId, @DisplayRotation.FixedToUserRotation int fixedToUserRotation) { synchronized (mGlobalLock) { final DisplayContent display = mRoot.getDisplayContent(displayId); if (display == null) { Slog.w(TAG, "Trying to set rotate for app for a missing display."); return; } display.getDisplayRotation().setFixedToUserRotation(enabled); display.getDisplayRotation().setFixedToUserRotation(fixedToUserRotation); } } Loading Loading
core/res/res/values/config.xml +0 −5 Original line number Diff line number Diff line Loading @@ -2673,11 +2673,6 @@ </string-array> <!-- Flag indicating that this device does not rotate and will always remain in its default orientation. Activities that desire to run in a non-compatible orientation will be run from an emulated display within the physical display. --> <bool name="config_forceDefaultOrientation">false</bool> <!-- Default Gravity setting for the system Toast view. Equivalent to: Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM --> <integer name="config_toastDefaultGravity">0x00000051</integer> Loading
core/res/res/values/symbols.xml +0 −1 Original line number Diff line number Diff line Loading @@ -347,7 +347,6 @@ <java-symbol type="bool" name="config_requireRadioPowerOffOnSimRefreshReset" /> <java-symbol type="bool" name="config_speed_up_audio_on_mt_calls" /> <java-symbol type="bool" name="config_useFixedVolume" /> <java-symbol type="bool" name="config_forceDefaultOrientation" /> <java-symbol type="bool" name="config_wifi_batched_scan_supported" /> <java-symbol type="bool" name="config_wifi_softap_acs_supported" /> <java-symbol type="string" name="config_wifi_softap_acs_supported_channel_list" /> Loading
services/core/java/com/android/server/wm/DisplayRotation.java +53 −24 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ORIENTATION; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; import android.annotation.IntDef; import android.annotation.UserIdInt; import android.app.ActivityManager; import android.content.ContentResolver; Loading Loading @@ -49,6 +50,8 @@ import com.android.server.policy.WindowOrientationListener; import com.android.server.statusbar.StatusBarManagerInternal; import java.io.PrintWriter; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * Defines the mapping between orientation and rotation of a display. Loading Loading @@ -95,12 +98,37 @@ public class DisplayRotation { private int mUserRotationMode = WindowManagerPolicy.USER_ROTATION_FREE; private int mUserRotation = Surface.ROTATION_0; /** * Flag that indicates this is a display that may run better when fixed to user rotation. */ private boolean mDefaultFixedToUserRotation; /** * No overridden behavior is provided in terms of fixing rotation to user rotation. Use other * flags to derive the default behavior, such as {@link WindowManagerService#mIsPc} and * {@link WindowManagerService#mForceDesktopModeOnExternalDisplays}. */ static final int FIXED_TO_USER_ROTATION_DEFAULT = 0; /** * Don't fix display rotation to {@link #mUserRotation} only. Always allow other factors to play * a role in deciding display rotation. */ static final int FIXED_TO_USER_ROTATION_DISABLED = 1; /** * Only use {@link #mUserRotation} as the display rotation. */ static final int FIXED_TO_USER_ROTATION_ENABLED = 2; @IntDef({ FIXED_TO_USER_ROTATION_DEFAULT, FIXED_TO_USER_ROTATION_DISABLED, FIXED_TO_USER_ROTATION_ENABLED }) @Retention(RetentionPolicy.SOURCE) @interface FixedToUserRotation {} /** * A flag to indicate if the display rotation should be fixed to user specified rotation * regardless of all other states (including app requrested orientation). {@code true} the * display rotation should be fixed to user specified rotation, {@code false} otherwise. */ private boolean mFixedToUserRotation; private int mFixedToUserRotation = FIXED_TO_USER_ROTATION_DEFAULT; private int mDemoHdmiRotation; private int mDemoRotation; Loading Loading @@ -220,19 +248,14 @@ public class DisplayRotation { PackageManager.FEATURE_LEANBACK); final boolean isCloseToSquare = isNonDecorDisplayCloseToSquare(Surface.ROTATION_0, width, height); final boolean forceDefaultOrientationInRes = res.getBoolean(com.android.internal.R.bool.config_forceDefaultOrientation); final boolean forceDefaultOrienation = ((longSizeDp >= 960 && shortSizeDp >= 720) || isCar || isTv || isCloseToSquare) && forceDefaultOrientationInRes final boolean forceDesktopMode = mService.mForceDesktopModeOnExternalDisplays && !isDefaultDisplay; mDefaultFixedToUserRotation = (isCar || isTv || mService.mIsPc || forceDesktopMode || isCloseToSquare) // For debug purposes the next line turns this feature off with: // $ adb shell setprop config.override_forced_orient true // $ adb shell wm size reset && !"true".equals(SystemProperties.get("config.override_forced_orient")); // Configuration says we force to use the default orientation. We can fall back to fix // rotation to only user rotation. As long as OEM doesn't change user rotation then the // rotation of this display is effectively stuck at 0 deg. setFixedToUserRotation(forceDefaultOrienation); } private boolean isNonDecorDisplayCloseToSquare(int rotation, int width, int height) { Loading Loading @@ -263,7 +286,7 @@ public class DisplayRotation { } void restoreSettings(int userRotationMode, int userRotation, boolean fixedToUserRotation) { @FixedToUserRotation int fixedToUserRotation) { mFixedToUserRotation = fixedToUserRotation; // We will retrieve user rotation and user rotation mode from settings for default display. Loading @@ -285,14 +308,13 @@ public class DisplayRotation { mUserRotation = userRotation; } void setFixedToUserRotation(boolean fixedToUserRotation) { void setFixedToUserRotation(@FixedToUserRotation int fixedToUserRotation) { if (mFixedToUserRotation == fixedToUserRotation) { return; } mFixedToUserRotation = fixedToUserRotation; mDisplayWindowSettings.setFixedToUserRotation(mDisplayContent, fixedToUserRotation); mDisplayWindowSettings.setFixedToUserRotation(mDisplayContent, fixedToUserRotation); mService.updateRotation(true /* alwaysSendConfiguration */, false /* forceRelayout */); } Loading Loading @@ -346,7 +368,14 @@ public class DisplayRotation { } boolean isFixedToUserRotation() { return mFixedToUserRotation; switch (mFixedToUserRotation) { case FIXED_TO_USER_ROTATION_DISABLED: return false; case FIXED_TO_USER_ROTATION_ENABLED: return true; default: return mDefaultFixedToUserRotation; } } /** Loading @@ -355,7 +384,7 @@ public class DisplayRotation { * false} is when {@link #isFixedToUserRotation()} is {@code true}. */ boolean respectAppRequestedOrientation() { return !mFixedToUserRotation; return !isFixedToUserRotation(); } public int getLandscapeRotation() { Loading Loading @@ -461,7 +490,7 @@ public class DisplayRotation { * screen is switched off. */ private boolean needSensorRunning() { if (mFixedToUserRotation) { if (isFixedToUserRotation()) { // We are sure we only respect user rotation settings, so we are sure we will not // support sensor rotation. return false; Loading Loading @@ -527,7 +556,7 @@ public class DisplayRotation { ); } if (mFixedToUserRotation) { if (isFixedToUserRotation()) { return mUserRotation; } Loading Loading @@ -739,7 +768,7 @@ public class DisplayRotation { // demo, hdmi, vr, etc mode. // Determine if the rotation is currently forced. if (mFixedToUserRotation) { if (isFixedToUserRotation()) { return false; // Rotation is forced to user settings. } Loading Loading @@ -899,7 +928,7 @@ public class DisplayRotation { pw.print(" mDemoHdmiRotationLock=" + mDemoHdmiRotationLock); pw.println(" mUndockedHdmiRotation=" + Surface.rotationToString(mUndockedHdmiRotation)); pw.println(prefix + " mLidOpenRotation=" + Surface.rotationToString(mLidOpenRotation)); pw.println(prefix + " mFixedToUserRotation=" + mFixedToUserRotation); pw.println(prefix + " mFixedToUserRotation=" + isFixedToUserRotation()); } private class OrientationListener extends WindowOrientationListener { Loading
services/core/java/com/android/server/wm/DisplayWindowSettings.java +9 −7 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import static android.view.WindowManager.REMOVE_CONTENT_MODE_UNDEFINED; import static com.android.server.wm.DisplayContent.FORCE_SCALING_MODE_AUTO; import static com.android.server.wm.DisplayContent.FORCE_SCALING_MODE_DISABLED; import static com.android.server.wm.DisplayRotation.FIXED_TO_USER_ROTATION_DEFAULT; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; Loading Loading @@ -80,7 +81,8 @@ class DisplayWindowSettings { private boolean mShouldShowWithInsecureKeyguard = false; private boolean mShouldShowSystemDecors = false; private boolean mShouldShowIme = false; private boolean mFixedToUserRotation; private @DisplayRotation.FixedToUserRotation int mFixedToUserRotation = FIXED_TO_USER_ROTATION_DEFAULT; private Entry(String name) { mName = name; Loading @@ -99,7 +101,7 @@ class DisplayWindowSettings { && !mShouldShowWithInsecureKeyguard && !mShouldShowSystemDecors && !mShouldShowIme && !mFixedToUserRotation; && mFixedToUserRotation == FIXED_TO_USER_ROTATION_DEFAULT; } } Loading Loading @@ -188,7 +190,8 @@ class DisplayWindowSettings { writeSettingsIfNeeded(entry, displayInfo); } void setFixedToUserRotation(DisplayContent displayContent, boolean fixedToUserRotation) { void setFixedToUserRotation(DisplayContent displayContent, @DisplayRotation.FixedToUserRotation int fixedToUserRotation) { final DisplayInfo displayInfo = displayContent.getDisplayInfo(); final Entry entry = getOrCreateEntry(displayInfo); entry.mFixedToUserRotation = fixedToUserRotation; Loading Loading @@ -464,8 +467,7 @@ class DisplayWindowSettings { "shouldShowWithInsecureKeyguard"); entry.mShouldShowSystemDecors = getBooleanAttribute(parser, "shouldShowSystemDecors"); entry.mShouldShowIme = getBooleanAttribute(parser, "shouldShowIme"); entry.mFixedToUserRotation = getBooleanAttribute(parser, "fixedToUserRotation"); entry.mFixedToUserRotation = getIntAttribute(parser, "fixedToUserRotation"); mEntries.put(name, entry); } XmlUtils.skipCurrentTag(parser); Loading Loading @@ -549,9 +551,9 @@ class DisplayWindowSettings { if (entry.mShouldShowIme) { out.attribute(null, "shouldShowIme", Boolean.toString(entry.mShouldShowIme)); } if (entry.mFixedToUserRotation) { if (entry.mFixedToUserRotation != FIXED_TO_USER_ROTATION_DEFAULT) { out.attribute(null, "fixedToUserRotation", Boolean.toString(entry.mFixedToUserRotation)); Integer.toString(entry.mFixedToUserRotation)); } out.endTag(null, "display"); } Loading
services/core/java/com/android/server/wm/WindowManagerService.java +3 −2 Original line number Diff line number Diff line Loading @@ -3520,14 +3520,15 @@ public class WindowManagerService extends IWindowManager.Stub } } void setRotateForApp(int displayId, boolean enabled) { void setRotateForApp(int displayId, @DisplayRotation.FixedToUserRotation int fixedToUserRotation) { synchronized (mGlobalLock) { final DisplayContent display = mRoot.getDisplayContent(displayId); if (display == null) { Slog.w(TAG, "Trying to set rotate for app for a missing display."); return; } display.getDisplayRotation().setFixedToUserRotation(enabled); display.getDisplayRotation().setFixedToUserRotation(fixedToUserRotation); } } Loading