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

Commit 70964774 authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Log if orientation is ignored by universal resizable" into main

parents 99e033fd 3fad2a3b
Loading
Loading
Loading
Loading
+24 −4
Original line number Diff line number Diff line
@@ -1623,6 +1623,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                newParent.setResumedActivity(this, "onParentChanged");
            }
            mAppCompatController.getTransparentPolicy().start();
            if (mState == INITIALIZING && isRestrictedFixedOrientation(info.screenOrientation)) {
                Slog.i(TAG, "Ignoring manifest-declared fixed orientation "
                        + ActivityInfo.screenOrientationToString(info.screenOrientation)
                        + " of " + this + " since target sdk 36");
            }
        }

        if (rootTask != null && rootTask.topRunningActivity() == this) {
@@ -3191,6 +3196,17 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        return getWindowConfiguration().canReceiveKeys() && !mWaitForEnteringPinnedMode;
    }

    /**
     * Returns {@code true} if the orientation will be ignored for {@link #isUniversalResizeable()}.
     */
    private boolean isRestrictedFixedOrientation(
            @ActivityInfo.ScreenOrientation int orientation) {
        // Exclude "locked" because it is not explicit portrait or landscape.
        return orientation != ActivityInfo.SCREEN_ORIENTATION_LOCKED
                && ActivityInfo.isFixedOrientation(orientation)
                && isUniversalResizeable();
    }

    /**
     * Returns {@code true} if the fixed orientation, aspect ratio, resizability of this activity
     * will be ignored.
@@ -8123,7 +8139,13 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        ProtoLog.v(WM_DEBUG_ORIENTATION,
                "Setting requested orientation %s for %s",
                ActivityInfo.screenOrientationToString(requestedOrientation), this);
        setOrientation(requestedOrientation, this);
        final int resolvedOrientation = setOrientation(requestedOrientation, this);
        if (resolvedOrientation != requestedOrientation
                && isRestrictedFixedOrientation(requestedOrientation)) {
            Slog.i(TAG, "Ignoring requested fixed orientation "
                    + ActivityInfo.screenOrientationToString(requestedOrientation)
                    + " of " + this + " since target sdk 36");
        }

        // Push the new configuration to the requested app in case where it's not pushed, e.g. when
        // the request is handled at task level with letterbox.
@@ -8214,9 +8236,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    @ActivityInfo.ScreenOrientation
    protected int getOverrideOrientation() {
        int candidateOrientation = super.getOverrideOrientation();
        if (candidateOrientation != ActivityInfo.SCREEN_ORIENTATION_LOCKED
                && ActivityInfo.isFixedOrientation(candidateOrientation)
                && isUniversalResizeable()) {
        if (isRestrictedFixedOrientation(candidateOrientation)) {
            candidateOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
        }
        return mAppCompatController.getOrientationPolicy()
+0 −2
Original line number Diff line number Diff line
@@ -101,8 +101,6 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> {

    DisplayArea(WindowManagerService wms, Type type, String name, int featureId) {
        super(wms);
        // TODO(display-area): move this up to ConfigurationContainer
        setOverrideOrientation(SCREEN_ORIENTATION_UNSET);
        mType = type;
        mName = name;
        mFeatureId = featureId;
+22 −16
Original line number Diff line number Diff line
@@ -1676,17 +1676,23 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
     * @param orientation the specified orientation. Needs to be one of {@link ScreenOrientation}.
     * @param requestingContainer the container which orientation request has changed. Mostly used
     *                            to ensure it gets correct configuration.
     * @return the resolved override orientation of this window container.
     */
    void setOrientation(@ScreenOrientation int orientation,
    @ScreenOrientation
    int setOrientation(@ScreenOrientation int orientation,
            @Nullable WindowContainer requestingContainer) {
        if (getOverrideOrientation() == orientation) {
            return;
            return orientation;
        }

        setOverrideOrientation(orientation);
        final WindowContainer parent = getParent();
        if (parent != null) {
            if (getConfiguration().orientation != getRequestedConfigurationOrientation()
        if (parent == null) {
            return orientation;
        }
        // The derived class can return a result that is different from the given orientation.
        final int resolvedOrientation = getOverrideOrientation();
        if (getConfiguration().orientation != getRequestedConfigurationOrientation(
                false /* forDisplay */, resolvedOrientation)
                // Update configuration directly only if the change won't be dispatched from
                // ancestor. This prevents from computing intermediate configuration when the
                // parent also needs to be updated from the ancestor. E.g. the app requests
@@ -1699,7 +1705,7 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
            onConfigurationChanged(parent.getConfiguration());
        }
        onDescendantOrientationChanged(requestingContainer);
        }
        return resolvedOrientation;
    }

    @ScreenOrientation