Merge "Exception for Kids Mode from ignoreOrientationRequest." into tm-dev am: 42f304140f
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17760471 Change-Id: I0b90e7f47374db983bc9da9a5f53e9453c0fd5a2 Ignore-AOSP-First: this is an automerge Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -69,4 +69,14 @@ interface ITaskOrganizerController {
|
|||||||
|
|
||||||
/** Updates a state of camera compat control for stretched issues in the viewfinder. */
|
/** Updates a state of camera compat control for stretched issues in the viewfinder. */
|
||||||
void updateCameraCompatControlState(in WindowContainerToken task, int state);
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.
|
* Gets the executor to run callbacks on.
|
||||||
* @hide
|
* @hide
|
||||||
|
|||||||
@@ -225,6 +225,10 @@ public class KidsModeTaskOrganizer extends ShellTaskOrganizer {
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void enable() {
|
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);
|
final DisplayLayout displayLayout = mDisplayController.getDisplayLayout(DEFAULT_DISPLAY);
|
||||||
if (displayLayout != null) {
|
if (displayLayout != null) {
|
||||||
mDisplayWidth = displayLayout.width();
|
mDisplayWidth = displayLayout.width();
|
||||||
@@ -245,6 +249,7 @@ public class KidsModeTaskOrganizer extends ShellTaskOrganizer {
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void disable() {
|
void disable() {
|
||||||
|
setIsIgnoreOrientationRequestDisabled(false);
|
||||||
mDisplayInsetsController.removeInsetsChangedListener(DEFAULT_DISPLAY,
|
mDisplayInsetsController.removeInsetsChangedListener(DEFAULT_DISPLAY,
|
||||||
mOnInsetsChangedListener);
|
mOnInsetsChangedListener);
|
||||||
mDisplayController.removeDisplayWindowListener(mOnDisplaysChangedListener);
|
mDisplayController.removeDisplayWindowListener(mOnDisplaysChangedListener);
|
||||||
|
|||||||
@@ -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
|
* 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
|
* can never specify orientation, but shows the fixed-orientation apps below it in the
|
||||||
* letterbox; otherwise, it rotates based on the fixed-orientation request.
|
* 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) {
|
DisplayArea(WindowManagerService wms, Type type, String name) {
|
||||||
this(wms, type, name, FEATURE_UNDEFINED);
|
this(wms, type, name, FEATURE_UNDEFINED);
|
||||||
@@ -140,7 +143,7 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> {
|
|||||||
@Override
|
@Override
|
||||||
int getOrientation(int candidate) {
|
int getOrientation(int candidate) {
|
||||||
mLastOrientationSource = null;
|
mLastOrientationSource = null;
|
||||||
if (mIgnoreOrientationRequest) {
|
if (getIgnoreOrientationRequest()) {
|
||||||
return SCREEN_ORIENTATION_UNSET;
|
return SCREEN_ORIENTATION_UNSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,14 +152,15 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean handlesOrientationChangeFromDescendant() {
|
boolean handlesOrientationChangeFromDescendant() {
|
||||||
return !mIgnoreOrientationRequest && super.handlesOrientationChangeFromDescendant();
|
return !getIgnoreOrientationRequest()
|
||||||
|
&& super.handlesOrientationChangeFromDescendant();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean onDescendantOrientationChanged(WindowContainer requestingContainer) {
|
boolean onDescendantOrientationChanged(WindowContainer requestingContainer) {
|
||||||
// If this is set to ignore the orientation request, we don't propagate descendant
|
// If this is set to ignore the orientation request, we don't propagate descendant
|
||||||
// orientation request.
|
// orientation request.
|
||||||
return !mIgnoreOrientationRequest
|
return !getIgnoreOrientationRequest()
|
||||||
&& super.onDescendantOrientationChanged(requestingContainer);
|
&& super.onDescendantOrientationChanged(requestingContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,10 +171,10 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> {
|
|||||||
* @return Whether the display orientation changed after calling this method.
|
* @return Whether the display orientation changed after calling this method.
|
||||||
*/
|
*/
|
||||||
boolean setIgnoreOrientationRequest(boolean ignoreOrientationRequest) {
|
boolean setIgnoreOrientationRequest(boolean ignoreOrientationRequest) {
|
||||||
if (mIgnoreOrientationRequest == ignoreOrientationRequest) {
|
if (mSetIgnoreOrientationRequest == ignoreOrientationRequest) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
mIgnoreOrientationRequest = ignoreOrientationRequest;
|
mSetIgnoreOrientationRequest = ignoreOrientationRequest;
|
||||||
|
|
||||||
// Check whether we should notify Display to update orientation.
|
// Check whether we should notify Display to update orientation.
|
||||||
if (mDisplayContent == null) {
|
if (mDisplayContent == null) {
|
||||||
@@ -204,7 +208,11 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean getIgnoreOrientationRequest() {
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -289,8 +297,8 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> {
|
|||||||
@Override
|
@Override
|
||||||
void dump(PrintWriter pw, String prefix, boolean dumpAll) {
|
void dump(PrintWriter pw, String prefix, boolean dumpAll) {
|
||||||
super.dump(pw, prefix, dumpAll);
|
super.dump(pw, prefix, dumpAll);
|
||||||
if (mIgnoreOrientationRequest) {
|
if (mSetIgnoreOrientationRequest) {
|
||||||
pw.println(prefix + "mIgnoreOrientationRequest=true");
|
pw.println(prefix + "mSetIgnoreOrientationRequest=true");
|
||||||
}
|
}
|
||||||
if (hasRequestedOverrideConfiguration()) {
|
if (hasRequestedOverrideConfiguration()) {
|
||||||
pw.println(prefix + "overrideConfig=" + getRequestedOverrideConfiguration());
|
pw.println(prefix + "overrideConfig=" + getRequestedOverrideConfiguration());
|
||||||
@@ -600,7 +608,7 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> {
|
|||||||
@Override
|
@Override
|
||||||
int getOrientation(int candidate) {
|
int getOrientation(int candidate) {
|
||||||
mLastOrientationSource = null;
|
mLastOrientationSource = null;
|
||||||
if (mIgnoreOrientationRequest) {
|
if (getIgnoreOrientationRequest()) {
|
||||||
return SCREEN_ORIENTATION_UNSET;
|
return SCREEN_ORIENTATION_UNSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1489,7 +1489,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean handlesOrientationChangeFromDescendant() {
|
boolean handlesOrientationChangeFromDescendant() {
|
||||||
return !mIgnoreOrientationRequest && !getDisplayRotation().isFixedToUserRotation();
|
return !getIgnoreOrientationRequest()
|
||||||
|
&& !getDisplayRotation().isFixedToUserRotation();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -4892,7 +4893,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
int getOrientation(int candidate) {
|
int getOrientation(int candidate) {
|
||||||
if (mIgnoreOrientationRequest) {
|
if (getIgnoreOrientationRequest()) {
|
||||||
return SCREEN_ORIENTATION_UNSET;
|
return SCREEN_ORIENTATION_UNSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6131,13 +6132,28 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
boolean setIgnoreOrientationRequest(boolean ignoreOrientationRequest) {
|
boolean setIgnoreOrientationRequest(boolean ignoreOrientationRequest) {
|
||||||
if (mIgnoreOrientationRequest == ignoreOrientationRequest) return false;
|
if (mSetIgnoreOrientationRequest == ignoreOrientationRequest) return false;
|
||||||
final boolean rotationChanged = super.setIgnoreOrientationRequest(ignoreOrientationRequest);
|
final boolean rotationChanged = super.setIgnoreOrientationRequest(ignoreOrientationRequest);
|
||||||
mWmService.mDisplayWindowSettings.setIgnoreOrientationRequest(
|
mWmService.mDisplayWindowSettings.setIgnoreOrientationRequest(
|
||||||
this, mIgnoreOrientationRequest);
|
this, mSetIgnoreOrientationRequest);
|
||||||
return rotationChanged;
|
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
|
* Locates the appropriate target window for scroll capture. The search progresses top to
|
||||||
* bottom.
|
* bottom.
|
||||||
|
|||||||
@@ -1683,7 +1683,7 @@ public class DisplayRotation {
|
|||||||
mSensorRotation = (listener == null || !listener.mEnabled)
|
mSensorRotation = (listener == null || !listener.mEnabled)
|
||||||
? -2 /* disabled */ : dr.mLastSensorRotation;
|
? -2 /* disabled */ : dr.mLastSensorRotation;
|
||||||
final DisplayContent dc = dr.mDisplayContent;
|
final DisplayContent dc = dr.mDisplayContent;
|
||||||
mIgnoreOrientationRequest = dc.mIgnoreOrientationRequest;
|
mIgnoreOrientationRequest = dc.getIgnoreOrientationRequest();
|
||||||
final TaskDisplayArea requestingTda = dc.getOrientationRequestingTaskDisplayArea();
|
final TaskDisplayArea requestingTda = dc.getOrientationRequestingTaskDisplayArea();
|
||||||
mNonDefaultRequestingTaskDisplayArea = requestingTda == null
|
mNonDefaultRequestingTaskDisplayArea = requestingTda == null
|
||||||
? "none" : requestingTda != dc.getDefaultTaskDisplayArea()
|
? "none" : requestingTda != dc.getDefaultTaskDisplayArea()
|
||||||
|
|||||||
@@ -640,7 +640,7 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
|
|||||||
@Override
|
@Override
|
||||||
int getOrientation(int candidate) {
|
int getOrientation(int candidate) {
|
||||||
mLastOrientationSource = null;
|
mLastOrientationSource = null;
|
||||||
if (mIgnoreOrientationRequest) {
|
if (getIgnoreOrientationRequest()) {
|
||||||
return SCREEN_ORIENTATION_UNSET;
|
return SCREEN_ORIENTATION_UNSET;
|
||||||
}
|
}
|
||||||
if (!canSpecifyOrientation()) {
|
if (!canSpecifyOrientation()) {
|
||||||
@@ -1917,7 +1917,7 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
|
|||||||
// Only allow to specify orientation if this TDA is not set to ignore orientation request,
|
// Only allow to specify orientation if this TDA is not set to ignore orientation request,
|
||||||
// and it is the last focused one on this logical display that can request orientation
|
// and it is the last focused one on this logical display that can request orientation
|
||||||
// request.
|
// request.
|
||||||
return !mIgnoreOrientationRequest
|
return !getIgnoreOrientationRequest()
|
||||||
&& mDisplayContent.getOrientationRequestingTaskDisplayArea() == this;
|
&& mDisplayContent.getOrientationRequestingTaskDisplayArea() == this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1000,6 +1000,19 @@ class TaskOrganizerController extends ITaskOrganizerController.Stub {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setIsIgnoreOrientationRequestDisabled(boolean isDisabled) {
|
||||||
|
enforceTaskPermission("setIsIgnoreOrientationRequestDisabled()");
|
||||||
|
final long origId = Binder.clearCallingIdentity();
|
||||||
|
try {
|
||||||
|
synchronized (mGlobalLock) {
|
||||||
|
mService.mWindowManager.setIsIgnoreOrientationRequestDisabled(isDisabled);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
Binder.restoreCallingIdentity(origId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean handleInterceptBackPressedOnTaskRoot(Task task) {
|
public boolean handleInterceptBackPressedOnTaskRoot(Task task) {
|
||||||
if (task == null || !task.isOrganized()
|
if (task == null || !task.isOrganized()
|
||||||
|| !mInterceptBackPressedOnRootTasks.contains(task.mTaskId)) {
|
|| !mInterceptBackPressedOnRootTasks.contains(task.mTaskId)) {
|
||||||
|
|||||||
@@ -989,6 +989,8 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
|
|
||||||
final LetterboxConfiguration mLetterboxConfiguration;
|
final LetterboxConfiguration mLetterboxConfiguration;
|
||||||
|
|
||||||
|
private boolean mIsIgnoreOrientationRequestDisabled;
|
||||||
|
|
||||||
final InputManagerService mInputManager;
|
final InputManagerService mInputManager;
|
||||||
final DisplayManagerInternal mDisplayManagerInternal;
|
final DisplayManagerInternal mDisplayManagerInternal;
|
||||||
final DisplayManager mDisplayManager;
|
final DisplayManager mDisplayManager;
|
||||||
@@ -4088,6 +4090,36 @@ public class WindowManagerService extends IWindowManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controls whether ignore orientation request logic in {@link DisplayArea} is disabled
|
||||||
|
* at runtime.
|
||||||
|
*
|
||||||
|
* <p>Note: this assumes that {@link #mGlobalLock} is held by the caller.
|
||||||
|
*
|
||||||
|
* @param isDisabled when {@code true}, the system always ignores the value of {@link
|
||||||
|
* DisplayArea#getIgnoreOrientationRequest} and app requested orientation is
|
||||||
|
* respected.
|
||||||
|
*/
|
||||||
|
void setIsIgnoreOrientationRequestDisabled(boolean isDisabled) {
|
||||||
|
if (isDisabled == mIsIgnoreOrientationRequestDisabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mIsIgnoreOrientationRequestDisabled = isDisabled;
|
||||||
|
for (int i = mRoot.getChildCount() - 1; i >= 0; i--) {
|
||||||
|
mRoot.getChildAt(i).onIsIgnoreOrientationRequestDisabledChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the system ignores the value of {@link DisplayArea#getIgnoreOrientationRequest} and
|
||||||
|
* app requested orientation is respected.
|
||||||
|
*
|
||||||
|
* <p>Note: this assumes that {@link #mGlobalLock} is held by the caller.
|
||||||
|
*/
|
||||||
|
boolean isIgnoreOrientationRequestDisabled() {
|
||||||
|
return mIsIgnoreOrientationRequestDisabled;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void freezeRotation(int rotation) {
|
public void freezeRotation(int rotation) {
|
||||||
freezeDisplayRotation(Display.DEFAULT_DISPLAY, rotation);
|
freezeDisplayRotation(Display.DEFAULT_DISPLAY, rotation);
|
||||||
|
|||||||
@@ -2174,7 +2174,7 @@ public class DisplayContentTests extends WindowTestsBase {
|
|||||||
assertEquals(windowingMode, windowConfig.getWindowingMode());
|
assertEquals(windowingMode, windowConfig.getWindowingMode());
|
||||||
|
|
||||||
// test misc display overrides
|
// test misc display overrides
|
||||||
assertEquals(ignoreOrientationRequests, testDisplayContent.mIgnoreOrientationRequest);
|
assertEquals(ignoreOrientationRequests, testDisplayContent.mSetIgnoreOrientationRequest);
|
||||||
assertEquals(fixedOrientationLetterboxRatio,
|
assertEquals(fixedOrientationLetterboxRatio,
|
||||||
mWm.mLetterboxConfiguration.getFixedOrientationLetterboxAspectRatio(),
|
mWm.mLetterboxConfiguration.getFixedOrientationLetterboxAspectRatio(),
|
||||||
0 /* delta */);
|
0 /* delta */);
|
||||||
@@ -2215,7 +2215,7 @@ public class DisplayContentTests extends WindowTestsBase {
|
|||||||
assertEquals(windowingMode, windowConfig.getWindowingMode());
|
assertEquals(windowingMode, windowConfig.getWindowingMode());
|
||||||
|
|
||||||
// test misc display overrides
|
// test misc display overrides
|
||||||
assertEquals(ignoreOrientationRequests, testDisplayContent.mIgnoreOrientationRequest);
|
assertEquals(ignoreOrientationRequests, testDisplayContent.mSetIgnoreOrientationRequest);
|
||||||
assertEquals(fixedOrientationLetterboxRatio,
|
assertEquals(fixedOrientationLetterboxRatio,
|
||||||
mWm.mLetterboxConfiguration.getFixedOrientationLetterboxAspectRatio(),
|
mWm.mLetterboxConfiguration.getFixedOrientationLetterboxAspectRatio(),
|
||||||
0 /* delta */);
|
0 /* delta */);
|
||||||
|
|||||||
Reference in New Issue
Block a user