Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 42f30414 authored by Mariia Sandrikova's avatar Mariia Sandrikova Committed by Android (Google) Code Review
Browse files

Merge "Exception for Kids Mode from ignoreOrientationRequest." into tm-dev

parents d2b8731f 9182b74d
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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);
}
+18 −0
Original line number Diff line number Diff line
@@ -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
+5 −0
Original line number Diff line number Diff line
@@ -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();
@@ -245,6 +249,7 @@ public class KidsModeTaskOrganizer extends ShellTaskOrganizer {

    @VisibleForTesting
    void disable() {
        setIsIgnoreOrientationRequestDisabled(false);
        mDisplayInsetsController.removeInsetsChangedListener(DEFAULT_DISPLAY,
                mOnInsetsChangedListener);
        mDisplayController.removeDisplayWindowListener(mOnDisplaysChangedListener);
+18 −10
Original line number Diff line number Diff line
@@ -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);
@@ -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;
        }

@@ -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);
    }

@@ -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) {
@@ -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();
    }

    /**
@@ -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());
@@ -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;
            }

+20 −4
Original line number Diff line number Diff line
@@ -1489,7 +1489,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp

    @Override
    boolean handlesOrientationChangeFromDescendant() {
        return !mIgnoreOrientationRequest && !getDisplayRotation().isFixedToUserRotation();
        return !getIgnoreOrientationRequest()
                && !getDisplayRotation().isFixedToUserRotation();
    }

    /**
@@ -4892,7 +4893,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp

        @Override
        int getOrientation(int candidate) {
            if (mIgnoreOrientationRequest) {
            if (getIgnoreOrientationRequest()) {
                return SCREEN_ORIENTATION_UNSET;
            }

@@ -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