Loading core/java/android/view/IWindowManager.aidl +21 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,22 @@ import android.view.SurfaceControl; */ interface IWindowManager { /** * 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}. */ const int FIXED_TO_USER_ROTATION_DEFAULT = 0; /** * Don't fix display rotation to {@link DisplayRotation#mUserRotation} only. Always allow * other factors to play a role in deciding display rotation. */ const int FIXED_TO_USER_ROTATION_DISABLED = 1; /** * Only use {@link DisplayRotation#mUserRotation} as the display rotation. */ const int FIXED_TO_USER_ROTATION_ENABLED = 2; /** * ===== NOTICE ===== * The first three methods must remain the first three methods. Scripts Loading Loading @@ -272,6 +288,11 @@ interface IWindowManager */ boolean isDisplayRotationFrozen(int displayId); /** * Sets if display rotation is fixed to user specified value for given displayId. */ void setFixedToUserRotation(int displayId, int fixedToUserRotation); /** * Screenshot the current wallpaper layer, including the whole screen. */ Loading services/core/java/com/android/server/wm/DisplayRotation.java +6 −27 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ import android.provider.Settings; import android.util.Slog; import android.util.SparseArray; import android.view.IDisplayWindowRotationCallback; import android.view.IWindowManager; import android.view.Surface; import android.view.WindowContainerTransaction; Loading Loading @@ -183,33 +184,12 @@ public class DisplayRotation { */ 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. */ @FixedToUserRotation private int mFixedToUserRotation = FIXED_TO_USER_ROTATION_DEFAULT; private int mFixedToUserRotation = IWindowManager.FIXED_TO_USER_ROTATION_DEFAULT; private int mDemoHdmiRotation; private int mDemoRotation; Loading Loading @@ -723,8 +703,7 @@ public class DisplayRotation { } } void restoreSettings(int userRotationMode, int userRotation, @FixedToUserRotation int fixedToUserRotation) { void restoreSettings(int userRotationMode, int userRotation, int fixedToUserRotation) { mFixedToUserRotation = fixedToUserRotation; // We will retrieve user rotation and user rotation mode from settings for default display. Loading @@ -746,7 +725,7 @@ public class DisplayRotation { mUserRotation = userRotation; } void setFixedToUserRotation(@FixedToUserRotation int fixedToUserRotation) { void setFixedToUserRotation(int fixedToUserRotation) { if (mFixedToUserRotation == fixedToUserRotation) { return; } Loading Loading @@ -808,9 +787,9 @@ public class DisplayRotation { boolean isFixedToUserRotation() { switch (mFixedToUserRotation) { case FIXED_TO_USER_ROTATION_DISABLED: case IWindowManager.FIXED_TO_USER_ROTATION_DISABLED: return false; case FIXED_TO_USER_ROTATION_ENABLED: case IWindowManager.FIXED_TO_USER_ROTATION_ENABLED: return true; default: return mDefaultFixedToUserRotation; Loading services/core/java/com/android/server/wm/DisplayWindowSettings.java +5 −7 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ 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 @@ -38,6 +37,7 @@ import android.util.Xml; import android.view.Display; import android.view.DisplayAddress; import android.view.DisplayInfo; import android.view.IWindowManager; import android.view.Surface; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -111,8 +111,7 @@ class DisplayWindowSettings { private boolean mShouldShowWithInsecureKeyguard = false; private boolean mShouldShowSystemDecors = false; private boolean mShouldShowIme = false; private @DisplayRotation.FixedToUserRotation int mFixedToUserRotation = FIXED_TO_USER_ROTATION_DEFAULT; private int mFixedToUserRotation = IWindowManager.FIXED_TO_USER_ROTATION_DEFAULT; private Entry(String name) { mName = name; Loading Loading @@ -145,7 +144,7 @@ class DisplayWindowSettings { && !mShouldShowWithInsecureKeyguard && !mShouldShowSystemDecors && !mShouldShowIme && mFixedToUserRotation == FIXED_TO_USER_ROTATION_DEFAULT; && mFixedToUserRotation == IWindowManager.FIXED_TO_USER_ROTATION_DEFAULT; } } Loading Loading @@ -242,8 +241,7 @@ class DisplayWindowSettings { writeSettingsIfNeeded(entry, displayInfo); } void setFixedToUserRotation(DisplayContent displayContent, @DisplayRotation.FixedToUserRotation int fixedToUserRotation) { void setFixedToUserRotation(DisplayContent displayContent, int fixedToUserRotation) { final DisplayInfo displayInfo = displayContent.getDisplayInfo(); final Entry entry = getOrCreateEntry(displayInfo); entry.mFixedToUserRotation = fixedToUserRotation; Loading Loading @@ -610,7 +608,7 @@ class DisplayWindowSettings { if (entry.mShouldShowIme) { out.attribute(null, "shouldShowIme", Boolean.toString(entry.mShouldShowIme)); } if (entry.mFixedToUserRotation != FIXED_TO_USER_ROTATION_DEFAULT) { if (entry.mFixedToUserRotation != IWindowManager.FIXED_TO_USER_ROTATION_DEFAULT) { out.attribute(null, "fixedToUserRotation", Integer.toString(entry.mFixedToUserRotation)); } Loading services/core/java/com/android/server/wm/WindowManagerService.java +6 −2 Original line number Diff line number Diff line Loading @@ -3545,8 +3545,12 @@ public class WindowManagerService extends IWindowManager.Stub } } void setRotateForApp(int displayId, @DisplayRotation.FixedToUserRotation int fixedToUserRotation) { @Override public void setFixedToUserRotation(int displayId, int fixedToUserRotation) { if (!checkCallingPermission(android.Manifest.permission.SET_ORIENTATION, "freezeRotation()")) { throw new SecurityException("Requires SET_ORIENTATION permission"); } synchronized (mGlobalLock) { final DisplayContent display = mRoot.getDisplayContent(displayId); if (display == null) { Loading services/core/java/com/android/server/wm/WindowManagerShellCommand.java +6 −6 Original line number Diff line number Diff line Loading @@ -321,7 +321,7 @@ public class WindowManagerShellCommand extends ShellCommand { } } private int runSetFixToUserRotation(PrintWriter pw) { private int runSetFixToUserRotation(PrintWriter pw) throws RemoteException { int displayId = Display.DEFAULT_DISPLAY; String arg = getNextArgRequired(); if ("-d".equals(arg)) { Loading @@ -329,16 +329,16 @@ public class WindowManagerShellCommand extends ShellCommand { arg = getNextArgRequired(); } final @DisplayRotation.FixedToUserRotation int fixedToUserRotation; final int fixedToUserRotation; switch (arg) { case "enabled": fixedToUserRotation = DisplayRotation.FIXED_TO_USER_ROTATION_ENABLED; fixedToUserRotation = IWindowManager.FIXED_TO_USER_ROTATION_ENABLED; break; case "disabled": fixedToUserRotation = DisplayRotation.FIXED_TO_USER_ROTATION_DISABLED; fixedToUserRotation = IWindowManager.FIXED_TO_USER_ROTATION_DISABLED; break; case "default": fixedToUserRotation = DisplayRotation.FIXED_TO_USER_ROTATION_DISABLED; fixedToUserRotation = IWindowManager.FIXED_TO_USER_ROTATION_DEFAULT; break; default: getErrPrintWriter().println("Error: expecting enabled, disabled or default, but we " Loading @@ -346,7 +346,7 @@ public class WindowManagerShellCommand extends ShellCommand { return -1; } mInternal.setRotateForApp(displayId, fixedToUserRotation); mInterface.setFixedToUserRotation(displayId, fixedToUserRotation); return 0; } Loading Loading
core/java/android/view/IWindowManager.aidl +21 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,22 @@ import android.view.SurfaceControl; */ interface IWindowManager { /** * 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}. */ const int FIXED_TO_USER_ROTATION_DEFAULT = 0; /** * Don't fix display rotation to {@link DisplayRotation#mUserRotation} only. Always allow * other factors to play a role in deciding display rotation. */ const int FIXED_TO_USER_ROTATION_DISABLED = 1; /** * Only use {@link DisplayRotation#mUserRotation} as the display rotation. */ const int FIXED_TO_USER_ROTATION_ENABLED = 2; /** * ===== NOTICE ===== * The first three methods must remain the first three methods. Scripts Loading Loading @@ -272,6 +288,11 @@ interface IWindowManager */ boolean isDisplayRotationFrozen(int displayId); /** * Sets if display rotation is fixed to user specified value for given displayId. */ void setFixedToUserRotation(int displayId, int fixedToUserRotation); /** * Screenshot the current wallpaper layer, including the whole screen. */ Loading
services/core/java/com/android/server/wm/DisplayRotation.java +6 −27 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ import android.provider.Settings; import android.util.Slog; import android.util.SparseArray; import android.view.IDisplayWindowRotationCallback; import android.view.IWindowManager; import android.view.Surface; import android.view.WindowContainerTransaction; Loading Loading @@ -183,33 +184,12 @@ public class DisplayRotation { */ 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. */ @FixedToUserRotation private int mFixedToUserRotation = FIXED_TO_USER_ROTATION_DEFAULT; private int mFixedToUserRotation = IWindowManager.FIXED_TO_USER_ROTATION_DEFAULT; private int mDemoHdmiRotation; private int mDemoRotation; Loading Loading @@ -723,8 +703,7 @@ public class DisplayRotation { } } void restoreSettings(int userRotationMode, int userRotation, @FixedToUserRotation int fixedToUserRotation) { void restoreSettings(int userRotationMode, int userRotation, int fixedToUserRotation) { mFixedToUserRotation = fixedToUserRotation; // We will retrieve user rotation and user rotation mode from settings for default display. Loading @@ -746,7 +725,7 @@ public class DisplayRotation { mUserRotation = userRotation; } void setFixedToUserRotation(@FixedToUserRotation int fixedToUserRotation) { void setFixedToUserRotation(int fixedToUserRotation) { if (mFixedToUserRotation == fixedToUserRotation) { return; } Loading Loading @@ -808,9 +787,9 @@ public class DisplayRotation { boolean isFixedToUserRotation() { switch (mFixedToUserRotation) { case FIXED_TO_USER_ROTATION_DISABLED: case IWindowManager.FIXED_TO_USER_ROTATION_DISABLED: return false; case FIXED_TO_USER_ROTATION_ENABLED: case IWindowManager.FIXED_TO_USER_ROTATION_ENABLED: return true; default: return mDefaultFixedToUserRotation; Loading
services/core/java/com/android/server/wm/DisplayWindowSettings.java +5 −7 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ 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 @@ -38,6 +37,7 @@ import android.util.Xml; import android.view.Display; import android.view.DisplayAddress; import android.view.DisplayInfo; import android.view.IWindowManager; import android.view.Surface; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -111,8 +111,7 @@ class DisplayWindowSettings { private boolean mShouldShowWithInsecureKeyguard = false; private boolean mShouldShowSystemDecors = false; private boolean mShouldShowIme = false; private @DisplayRotation.FixedToUserRotation int mFixedToUserRotation = FIXED_TO_USER_ROTATION_DEFAULT; private int mFixedToUserRotation = IWindowManager.FIXED_TO_USER_ROTATION_DEFAULT; private Entry(String name) { mName = name; Loading Loading @@ -145,7 +144,7 @@ class DisplayWindowSettings { && !mShouldShowWithInsecureKeyguard && !mShouldShowSystemDecors && !mShouldShowIme && mFixedToUserRotation == FIXED_TO_USER_ROTATION_DEFAULT; && mFixedToUserRotation == IWindowManager.FIXED_TO_USER_ROTATION_DEFAULT; } } Loading Loading @@ -242,8 +241,7 @@ class DisplayWindowSettings { writeSettingsIfNeeded(entry, displayInfo); } void setFixedToUserRotation(DisplayContent displayContent, @DisplayRotation.FixedToUserRotation int fixedToUserRotation) { void setFixedToUserRotation(DisplayContent displayContent, int fixedToUserRotation) { final DisplayInfo displayInfo = displayContent.getDisplayInfo(); final Entry entry = getOrCreateEntry(displayInfo); entry.mFixedToUserRotation = fixedToUserRotation; Loading Loading @@ -610,7 +608,7 @@ class DisplayWindowSettings { if (entry.mShouldShowIme) { out.attribute(null, "shouldShowIme", Boolean.toString(entry.mShouldShowIme)); } if (entry.mFixedToUserRotation != FIXED_TO_USER_ROTATION_DEFAULT) { if (entry.mFixedToUserRotation != IWindowManager.FIXED_TO_USER_ROTATION_DEFAULT) { out.attribute(null, "fixedToUserRotation", Integer.toString(entry.mFixedToUserRotation)); } Loading
services/core/java/com/android/server/wm/WindowManagerService.java +6 −2 Original line number Diff line number Diff line Loading @@ -3545,8 +3545,12 @@ public class WindowManagerService extends IWindowManager.Stub } } void setRotateForApp(int displayId, @DisplayRotation.FixedToUserRotation int fixedToUserRotation) { @Override public void setFixedToUserRotation(int displayId, int fixedToUserRotation) { if (!checkCallingPermission(android.Manifest.permission.SET_ORIENTATION, "freezeRotation()")) { throw new SecurityException("Requires SET_ORIENTATION permission"); } synchronized (mGlobalLock) { final DisplayContent display = mRoot.getDisplayContent(displayId); if (display == null) { Loading
services/core/java/com/android/server/wm/WindowManagerShellCommand.java +6 −6 Original line number Diff line number Diff line Loading @@ -321,7 +321,7 @@ public class WindowManagerShellCommand extends ShellCommand { } } private int runSetFixToUserRotation(PrintWriter pw) { private int runSetFixToUserRotation(PrintWriter pw) throws RemoteException { int displayId = Display.DEFAULT_DISPLAY; String arg = getNextArgRequired(); if ("-d".equals(arg)) { Loading @@ -329,16 +329,16 @@ public class WindowManagerShellCommand extends ShellCommand { arg = getNextArgRequired(); } final @DisplayRotation.FixedToUserRotation int fixedToUserRotation; final int fixedToUserRotation; switch (arg) { case "enabled": fixedToUserRotation = DisplayRotation.FIXED_TO_USER_ROTATION_ENABLED; fixedToUserRotation = IWindowManager.FIXED_TO_USER_ROTATION_ENABLED; break; case "disabled": fixedToUserRotation = DisplayRotation.FIXED_TO_USER_ROTATION_DISABLED; fixedToUserRotation = IWindowManager.FIXED_TO_USER_ROTATION_DISABLED; break; case "default": fixedToUserRotation = DisplayRotation.FIXED_TO_USER_ROTATION_DISABLED; fixedToUserRotation = IWindowManager.FIXED_TO_USER_ROTATION_DEFAULT; break; default: getErrPrintWriter().println("Error: expecting enabled, disabled or default, but we " Loading @@ -346,7 +346,7 @@ public class WindowManagerShellCommand extends ShellCommand { return -1; } mInternal.setRotateForApp(displayId, fixedToUserRotation); mInterface.setFixedToUserRotation(displayId, fixedToUserRotation); return 0; } Loading