Loading core/java/android/window/ITaskOrganizerController.aidl +10 −0 Original line number Diff line number Diff line Loading @@ -69,4 +69,14 @@ interface ITaskOrganizerController { /** Updates a state of camera compat control for stretched issues in the viewfinder. */ void updateCameraCompatControlState(in WindowContainerToken task, int state); /** * Controls whether ignore orientation request logic in {@link * com.android.server.wm.DisplayArea} is disabled at runtime. * * @param isDisabled when {@code true}, the system always ignores the value of {@link * com.android.server.wm.DisplayArea#getIgnoreOrientationRequest} and app * requested orientation is respected. */ void setIsIgnoreOrientationRequestDisabled(boolean isDisabled); } core/java/android/window/TaskOrganizer.java +18 −0 Original line number Diff line number Diff line Loading @@ -252,6 +252,24 @@ public class TaskOrganizer extends WindowOrganizer { } } /** * Controls whether ignore orientation request logic in {@link * com.android.server.wm.DisplayArea} is disabled at runtime. * * @param isDisabled when {@code true}, the system always ignores the value of {@link * com.android.server.wm.DisplayArea#getIgnoreOrientationRequest} and app * requested orientation is respected. * @hide */ @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS) public void setIsIgnoreOrientationRequestDisabled(boolean isDisabled) { try { mTaskOrganizerController.setIsIgnoreOrientationRequestDisabled(isDisabled); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Gets the executor to run callbacks on. * @hide Loading libs/WindowManager/Shell/src/com/android/wm/shell/kidsmode/KidsModeTaskOrganizer.java +5 −0 Original line number Diff line number Diff line Loading @@ -225,6 +225,10 @@ public class KidsModeTaskOrganizer extends ShellTaskOrganizer { @VisibleForTesting void enable() { // Needed since many Kids apps aren't optimised to support both orientations and it will be // hard for kids to understand the app compat mode. // TODO(229961548): Remove ignoreOrientationRequest exception for Kids Mode once possible. setIsIgnoreOrientationRequestDisabled(true); final DisplayLayout displayLayout = mDisplayController.getDisplayLayout(DEFAULT_DISPLAY); if (displayLayout != null) { mDisplayWidth = displayLayout.width(); Loading @@ -245,6 +249,7 @@ public class KidsModeTaskOrganizer extends ShellTaskOrganizer { @VisibleForTesting void disable() { setIsIgnoreOrientationRequestDisabled(false); mDisplayInsetsController.removeInsetsChangedListener(DEFAULT_DISPLAY, mOnInsetsChangedListener); mDisplayController.removeDisplayWindowListener(mOnDisplaysChangedListener); Loading services/core/java/com/android/server/wm/DisplayArea.java +18 −10 Original line number Diff line number Diff line Loading @@ -78,8 +78,11 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> { * Whether this {@link DisplayArea} should ignore fixed-orientation request. If {@code true}, it * can never specify orientation, but shows the fixed-orientation apps below it in the * letterbox; otherwise, it rotates based on the fixed-orientation request. * * <p>Note: use {@link #getIgnoreOrientationRequest} to access outside of {@link * #setIgnoreOrientationRequest} since the value can be overridden at runtime on a device level. */ protected boolean mIgnoreOrientationRequest; protected boolean mSetIgnoreOrientationRequest; DisplayArea(WindowManagerService wms, Type type, String name) { this(wms, type, name, FEATURE_UNDEFINED); Loading Loading @@ -140,7 +143,7 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> { @Override int getOrientation(int candidate) { mLastOrientationSource = null; if (mIgnoreOrientationRequest) { if (getIgnoreOrientationRequest()) { return SCREEN_ORIENTATION_UNSET; } Loading @@ -149,14 +152,15 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> { @Override boolean handlesOrientationChangeFromDescendant() { return !mIgnoreOrientationRequest && super.handlesOrientationChangeFromDescendant(); return !getIgnoreOrientationRequest() && super.handlesOrientationChangeFromDescendant(); } @Override boolean onDescendantOrientationChanged(WindowContainer requestingContainer) { // If this is set to ignore the orientation request, we don't propagate descendant // orientation request. return !mIgnoreOrientationRequest return !getIgnoreOrientationRequest() && super.onDescendantOrientationChanged(requestingContainer); } Loading @@ -167,10 +171,10 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> { * @return Whether the display orientation changed after calling this method. */ boolean setIgnoreOrientationRequest(boolean ignoreOrientationRequest) { if (mIgnoreOrientationRequest == ignoreOrientationRequest) { if (mSetIgnoreOrientationRequest == ignoreOrientationRequest) { return false; } mIgnoreOrientationRequest = ignoreOrientationRequest; mSetIgnoreOrientationRequest = ignoreOrientationRequest; // Check whether we should notify Display to update orientation. if (mDisplayContent == null) { Loading Loading @@ -204,7 +208,11 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> { } boolean getIgnoreOrientationRequest() { return mIgnoreOrientationRequest; // Adding an exception for when ignoreOrientationRequest is overridden at runtime for all // DisplayArea-s. For example, this is needed for the Kids Mode since many Kids apps aren't // optimised to support both orientations and it will be hard for kids to understand the // app compat mode. return mSetIgnoreOrientationRequest && !mWmService.isIgnoreOrientationRequestDisabled(); } /** Loading Loading @@ -289,8 +297,8 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> { @Override void dump(PrintWriter pw, String prefix, boolean dumpAll) { super.dump(pw, prefix, dumpAll); if (mIgnoreOrientationRequest) { pw.println(prefix + "mIgnoreOrientationRequest=true"); if (mSetIgnoreOrientationRequest) { pw.println(prefix + "mSetIgnoreOrientationRequest=true"); } if (hasRequestedOverrideConfiguration()) { pw.println(prefix + "overrideConfig=" + getRequestedOverrideConfiguration()); Loading Loading @@ -600,7 +608,7 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> { @Override int getOrientation(int candidate) { mLastOrientationSource = null; if (mIgnoreOrientationRequest) { if (getIgnoreOrientationRequest()) { return SCREEN_ORIENTATION_UNSET; } Loading services/core/java/com/android/server/wm/DisplayContent.java +20 −4 Original line number Diff line number Diff line Loading @@ -1489,7 +1489,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp @Override boolean handlesOrientationChangeFromDescendant() { return !mIgnoreOrientationRequest && !getDisplayRotation().isFixedToUserRotation(); return !getIgnoreOrientationRequest() && !getDisplayRotation().isFixedToUserRotation(); } /** Loading Loading @@ -4892,7 +4893,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp @Override int getOrientation(int candidate) { if (mIgnoreOrientationRequest) { if (getIgnoreOrientationRequest()) { return SCREEN_ORIENTATION_UNSET; } Loading Loading @@ -6131,13 +6132,28 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp @Override boolean setIgnoreOrientationRequest(boolean ignoreOrientationRequest) { if (mIgnoreOrientationRequest == ignoreOrientationRequest) return false; if (mSetIgnoreOrientationRequest == ignoreOrientationRequest) return false; final boolean rotationChanged = super.setIgnoreOrientationRequest(ignoreOrientationRequest); mWmService.mDisplayWindowSettings.setIgnoreOrientationRequest( this, mIgnoreOrientationRequest); this, mSetIgnoreOrientationRequest); return rotationChanged; } /** * Updates orientation if necessary after ignore orientation request override logic in {@link * WindowManagerService#isIgnoreOrientationRequestDisabled} changes at runtime. */ void onIsIgnoreOrientationRequestDisabledChanged() { if (mFocusedApp != null) { // We record the last focused TDA that respects orientation request, check if this // change may affect it. onLastFocusedTaskDisplayAreaChanged(mFocusedApp.getDisplayArea()); } if (mSetIgnoreOrientationRequest) { updateOrientation(); } } /** * Locates the appropriate target window for scroll capture. The search progresses top to * bottom. Loading Loading
core/java/android/window/ITaskOrganizerController.aidl +10 −0 Original line number Diff line number Diff line Loading @@ -69,4 +69,14 @@ interface ITaskOrganizerController { /** Updates a state of camera compat control for stretched issues in the viewfinder. */ void updateCameraCompatControlState(in WindowContainerToken task, int state); /** * Controls whether ignore orientation request logic in {@link * com.android.server.wm.DisplayArea} is disabled at runtime. * * @param isDisabled when {@code true}, the system always ignores the value of {@link * com.android.server.wm.DisplayArea#getIgnoreOrientationRequest} and app * requested orientation is respected. */ void setIsIgnoreOrientationRequestDisabled(boolean isDisabled); }
core/java/android/window/TaskOrganizer.java +18 −0 Original line number Diff line number Diff line Loading @@ -252,6 +252,24 @@ public class TaskOrganizer extends WindowOrganizer { } } /** * Controls whether ignore orientation request logic in {@link * com.android.server.wm.DisplayArea} is disabled at runtime. * * @param isDisabled when {@code true}, the system always ignores the value of {@link * com.android.server.wm.DisplayArea#getIgnoreOrientationRequest} and app * requested orientation is respected. * @hide */ @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS) public void setIsIgnoreOrientationRequestDisabled(boolean isDisabled) { try { mTaskOrganizerController.setIsIgnoreOrientationRequestDisabled(isDisabled); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Gets the executor to run callbacks on. * @hide Loading
libs/WindowManager/Shell/src/com/android/wm/shell/kidsmode/KidsModeTaskOrganizer.java +5 −0 Original line number Diff line number Diff line Loading @@ -225,6 +225,10 @@ public class KidsModeTaskOrganizer extends ShellTaskOrganizer { @VisibleForTesting void enable() { // Needed since many Kids apps aren't optimised to support both orientations and it will be // hard for kids to understand the app compat mode. // TODO(229961548): Remove ignoreOrientationRequest exception for Kids Mode once possible. setIsIgnoreOrientationRequestDisabled(true); final DisplayLayout displayLayout = mDisplayController.getDisplayLayout(DEFAULT_DISPLAY); if (displayLayout != null) { mDisplayWidth = displayLayout.width(); Loading @@ -245,6 +249,7 @@ public class KidsModeTaskOrganizer extends ShellTaskOrganizer { @VisibleForTesting void disable() { setIsIgnoreOrientationRequestDisabled(false); mDisplayInsetsController.removeInsetsChangedListener(DEFAULT_DISPLAY, mOnInsetsChangedListener); mDisplayController.removeDisplayWindowListener(mOnDisplaysChangedListener); Loading
services/core/java/com/android/server/wm/DisplayArea.java +18 −10 Original line number Diff line number Diff line Loading @@ -78,8 +78,11 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> { * Whether this {@link DisplayArea} should ignore fixed-orientation request. If {@code true}, it * can never specify orientation, but shows the fixed-orientation apps below it in the * letterbox; otherwise, it rotates based on the fixed-orientation request. * * <p>Note: use {@link #getIgnoreOrientationRequest} to access outside of {@link * #setIgnoreOrientationRequest} since the value can be overridden at runtime on a device level. */ protected boolean mIgnoreOrientationRequest; protected boolean mSetIgnoreOrientationRequest; DisplayArea(WindowManagerService wms, Type type, String name) { this(wms, type, name, FEATURE_UNDEFINED); Loading Loading @@ -140,7 +143,7 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> { @Override int getOrientation(int candidate) { mLastOrientationSource = null; if (mIgnoreOrientationRequest) { if (getIgnoreOrientationRequest()) { return SCREEN_ORIENTATION_UNSET; } Loading @@ -149,14 +152,15 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> { @Override boolean handlesOrientationChangeFromDescendant() { return !mIgnoreOrientationRequest && super.handlesOrientationChangeFromDescendant(); return !getIgnoreOrientationRequest() && super.handlesOrientationChangeFromDescendant(); } @Override boolean onDescendantOrientationChanged(WindowContainer requestingContainer) { // If this is set to ignore the orientation request, we don't propagate descendant // orientation request. return !mIgnoreOrientationRequest return !getIgnoreOrientationRequest() && super.onDescendantOrientationChanged(requestingContainer); } Loading @@ -167,10 +171,10 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> { * @return Whether the display orientation changed after calling this method. */ boolean setIgnoreOrientationRequest(boolean ignoreOrientationRequest) { if (mIgnoreOrientationRequest == ignoreOrientationRequest) { if (mSetIgnoreOrientationRequest == ignoreOrientationRequest) { return false; } mIgnoreOrientationRequest = ignoreOrientationRequest; mSetIgnoreOrientationRequest = ignoreOrientationRequest; // Check whether we should notify Display to update orientation. if (mDisplayContent == null) { Loading Loading @@ -204,7 +208,11 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> { } boolean getIgnoreOrientationRequest() { return mIgnoreOrientationRequest; // Adding an exception for when ignoreOrientationRequest is overridden at runtime for all // DisplayArea-s. For example, this is needed for the Kids Mode since many Kids apps aren't // optimised to support both orientations and it will be hard for kids to understand the // app compat mode. return mSetIgnoreOrientationRequest && !mWmService.isIgnoreOrientationRequestDisabled(); } /** Loading Loading @@ -289,8 +297,8 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> { @Override void dump(PrintWriter pw, String prefix, boolean dumpAll) { super.dump(pw, prefix, dumpAll); if (mIgnoreOrientationRequest) { pw.println(prefix + "mIgnoreOrientationRequest=true"); if (mSetIgnoreOrientationRequest) { pw.println(prefix + "mSetIgnoreOrientationRequest=true"); } if (hasRequestedOverrideConfiguration()) { pw.println(prefix + "overrideConfig=" + getRequestedOverrideConfiguration()); Loading Loading @@ -600,7 +608,7 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> { @Override int getOrientation(int candidate) { mLastOrientationSource = null; if (mIgnoreOrientationRequest) { if (getIgnoreOrientationRequest()) { return SCREEN_ORIENTATION_UNSET; } Loading
services/core/java/com/android/server/wm/DisplayContent.java +20 −4 Original line number Diff line number Diff line Loading @@ -1489,7 +1489,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp @Override boolean handlesOrientationChangeFromDescendant() { return !mIgnoreOrientationRequest && !getDisplayRotation().isFixedToUserRotation(); return !getIgnoreOrientationRequest() && !getDisplayRotation().isFixedToUserRotation(); } /** Loading Loading @@ -4892,7 +4893,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp @Override int getOrientation(int candidate) { if (mIgnoreOrientationRequest) { if (getIgnoreOrientationRequest()) { return SCREEN_ORIENTATION_UNSET; } Loading Loading @@ -6131,13 +6132,28 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp @Override boolean setIgnoreOrientationRequest(boolean ignoreOrientationRequest) { if (mIgnoreOrientationRequest == ignoreOrientationRequest) return false; if (mSetIgnoreOrientationRequest == ignoreOrientationRequest) return false; final boolean rotationChanged = super.setIgnoreOrientationRequest(ignoreOrientationRequest); mWmService.mDisplayWindowSettings.setIgnoreOrientationRequest( this, mIgnoreOrientationRequest); this, mSetIgnoreOrientationRequest); return rotationChanged; } /** * Updates orientation if necessary after ignore orientation request override logic in {@link * WindowManagerService#isIgnoreOrientationRequestDisabled} changes at runtime. */ void onIsIgnoreOrientationRequestDisabledChanged() { if (mFocusedApp != null) { // We record the last focused TDA that respects orientation request, check if this // change may affect it. onLastFocusedTaskDisplayAreaChanged(mFocusedApp.getDisplayArea()); } if (mSetIgnoreOrientationRequest) { updateOrientation(); } } /** * Locates the appropriate target window for scroll capture. The search progresses top to * bottom. Loading