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

Commit 1bd22c67 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Remove redundant parameter of onDescendantOrientationChanged

The freezeDisplayToken is only non-null when the requestingContainer
is ActivityRecord and mayFreezeScreenLocked is true. The token also
always belongs to the activity so they are the same thing.

The parameter should be left after window hierarchy merge. Now the
check of freeze is centralized to DisplayContent#updateOrientation.

Bug: 163976519
Test: WmTests
Change-Id: I918fcdaae227d0c9bf4738735d4ce27a18200f1e
parent 26ca287d
Loading
Loading
Loading
Loading
+5 −10
Original line number Diff line number Diff line
@@ -6372,14 +6372,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    }

    void setRequestedOrientation(int requestedOrientation) {
        setOrientation(requestedOrientation, mayFreezeScreenLocked());
        mAtmService.getTaskChangeNotificationController().notifyActivityRequestedOrientationChanged(
                task.mTaskId, requestedOrientation);
    }

    private void setOrientation(int requestedOrientation, boolean freezeScreenIfNeeded) {
        final IBinder binder = freezeScreenIfNeeded ? appToken.asBinder() : null;
        setOrientation(requestedOrientation, binder, this);
        setOrientation(requestedOrientation, this);

        // 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.
@@ -6387,6 +6380,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                mLastReportedConfiguration.getMergedConfiguration())) {
            ensureActivityConfiguration(0 /* globalChanges */, false /* preserveWindow */);
        }

        mAtmService.getTaskChangeNotificationController().notifyActivityRequestedOrientationChanged(
                task.mTaskId, requestedOrientation);
    }

    /*
@@ -6403,8 +6399,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            return;
        }

        final IBinder freezeToken = mayFreezeScreenLocked() ? appToken : null;
        if (onDescendantOrientationChanged(freezeToken, this)) {
        if (onDescendantOrientationChanged(this)) {
            // The app is just becoming visible, and the parent Task has updated with the
            // orientation request. Update the size compat mode.
            updateSizeCompatMode();
+2 −4
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ import static com.android.server.wm.WindowContainerChildProto.DISPLAY_AREA;
import android.annotation.Nullable;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.os.IBinder;
import android.util.proto.ProtoOutputStream;
import android.window.DisplayAreaInfo;
import android.window.IDisplayAreaOrganizer;
@@ -151,12 +150,11 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> {
    }

    @Override
    boolean onDescendantOrientationChanged(IBinder freezeDisplayToken,
            WindowContainer requestingContainer) {
    boolean onDescendantOrientationChanged(WindowContainer requestingContainer) {
        // If this is set to ignore the orientation request, we don't propagate descendant
        // orientation request.
        return !mIgnoreOrientationRequest
                && super.onDescendantOrientationChanged(freezeDisplayToken, requestingContainer);
                && super.onDescendantOrientationChanged(requestingContainer);
    }

    /**
+8 −9
Original line number Diff line number Diff line
@@ -1300,10 +1300,9 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
    }

    @Override
    boolean onDescendantOrientationChanged(IBinder freezeDisplayToken,
            WindowContainer requestingContainer) {
    boolean onDescendantOrientationChanged(WindowContainer requestingContainer) {
        final Configuration config = updateOrientation(
                getRequestedOverrideConfiguration(), freezeDisplayToken, false /* forceUpdate */);
                getRequestedOverrideConfiguration(), requestingContainer, false /* forceUpdate */);
        // If display rotation class tells us that it doesn't consider app requested orientation,
        // this display won't rotate just because of an app changes its requested orientation. Thus
        // it indicates that this display chooses not to handle this request.
@@ -1355,11 +1354,11 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
     * @param currentConfig The current requested override configuration (it is usually set from
     *                      the last {@link #sendNewConfiguration}) of the display. It is used to
     *                      check if the configuration container has the latest state.
     * @param freezeDisplayToken Freeze the app window token if the orientation is changed.
     * @param freezeDisplayWindow Freeze the app window if the orientation is changed.
     * @param forceUpdate See {@link DisplayRotation#updateRotationUnchecked(boolean)}
     */
    Configuration updateOrientation(Configuration currentConfig, IBinder freezeDisplayToken,
            boolean forceUpdate) {
    Configuration updateOrientation(Configuration currentConfig,
            WindowContainer freezeDisplayWindow, boolean forceUpdate) {
        if (!mDisplayReady) {
            return null;
        }
@@ -1368,9 +1367,9 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        if (updateOrientation(forceUpdate)) {
            // If we changed the orientation but mOrientationChangeComplete is already true,
            // we used seamless rotation, and we don't need to freeze the screen.
            if (freezeDisplayToken != null && !mWmService.mRoot.mOrientationChangeComplete) {
                final ActivityRecord activity = getActivityRecord(freezeDisplayToken);
                if (activity != null) {
            if (freezeDisplayWindow != null && !mWmService.mRoot.mOrientationChangeComplete) {
                final ActivityRecord activity = freezeDisplayWindow.asActivityRecord();
                if (activity != null && activity.mayFreezeScreenLocked()) {
                    activity.startFreezingScreen();
                }
            }
+1 −4
Original line number Diff line number Diff line
@@ -1804,10 +1804,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
        Configuration config = null;
        if (displayContent != null) {
            config = displayContent.updateOrientation(
                    getDisplayOverrideConfiguration(displayId),
                    starting != null && starting.mayFreezeScreenLocked()
                            ? starting.appToken : null,
                    true /* forceUpdate */);
                    getDisplayOverrideConfiguration(displayId), starting, true /* forceUpdate */);
        }
        // Visibilities may change so let the starting activity have a chance to report. Can't do it
        // when visibility is changed in each AppWindowToken because it may trigger wrong
+3 −4
Original line number Diff line number Diff line
@@ -2249,7 +2249,7 @@ class Task extends WindowContainer<WindowContainer> {
            // the rotation animation needs to capture snapshot earlier to avoid animating from
            // an intermediate state.
            if (oldOrientation != getOrientation()) {
                onDescendantOrientationChanged(null, this);
                onDescendantOrientationChanged(this);
            }
        } finally {
            if (pipChanging) {
@@ -3305,9 +3305,8 @@ class Task extends WindowContainer<WindowContainer> {
    }

    @Override
    public boolean onDescendantOrientationChanged(IBinder freezeDisplayToken,
            WindowContainer requestingContainer) {
        if (super.onDescendantOrientationChanged(freezeDisplayToken, requestingContainer)) {
    public boolean onDescendantOrientationChanged(WindowContainer requestingContainer) {
        if (super.onDescendantOrientationChanged(requestingContainer)) {
            return true;
        }

Loading