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

Commit f56d5452 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Remove unnecessary parameter of DC#updateOrientation

The parameter is always DC#getRequestedOverrideConfiguration,
so it can be simplified.

Also correct trace name of sync group which was not paired.

Bug: 163976519
Test: CtsActivityManagerDeviceTestCases

Change-Id: Ic1ebc379776f98eca9acc19499e96149f86dd26b
parent b3ae0fbf
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -59,7 +59,6 @@ import com.android.internal.protolog.common.ProtoLog;
 */
class BLASTSyncEngine {
    private static final String TAG = "BLASTSyncEngine";
    private static final String TRACE_NAME_SYNC_GROUP_READY = "SyncGroupReady";

    interface TransactionReadyListener {
        void onTransactionReady(int mSyncId, SurfaceControl.Transaction transaction);
@@ -75,6 +74,7 @@ class BLASTSyncEngine {
        boolean mReady = false;
        final ArraySet<WindowContainer> mRootMembers = new ArraySet<>();
        private SurfaceControl.Transaction mOrphanTransaction = null;
        private String mTraceName;

        private SyncGroup(TransactionReadyListener listener, int id, String name) {
            mSyncId = id;
@@ -86,8 +86,8 @@ class BLASTSyncEngine {
                }
            };
            if (Trace.isTagEnabled(TRACE_TAG_WINDOW_MANAGER)) {
                Trace.asyncTraceBegin(TRACE_TAG_WINDOW_MANAGER,
                        name + TRACE_NAME_SYNC_GROUP_READY, id);
                mTraceName = name + "SyncGroupReady";
                Trace.asyncTraceBegin(TRACE_TAG_WINDOW_MANAGER, mTraceName, id);
            }
        }

@@ -121,7 +121,9 @@ class BLASTSyncEngine {
        }

        private void finishNow() {
            Trace.asyncTraceEnd(TRACE_TAG_WINDOW_MANAGER, TRACE_NAME_SYNC_GROUP_READY, mSyncId);
            if (mTraceName != null) {
                Trace.asyncTraceEnd(TRACE_TAG_WINDOW_MANAGER, mTraceName, mSyncId);
            }
            ProtoLog.v(WM_DEBUG_SYNC_ENGINE, "SyncGroup %d: Finished!", mSyncId);
            SurfaceControl.Transaction merged = mWm.mTransactionFactory.get();
            if (mOrphanTransaction != null) {
+5 −9
Original line number Diff line number Diff line
@@ -1467,7 +1467,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
    @Override
    boolean onDescendantOrientationChanged(WindowContainer requestingContainer) {
        final Configuration config = updateOrientation(
                getRequestedOverrideConfiguration(), requestingContainer, false /* forceUpdate */);
                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.
@@ -1516,14 +1516,10 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
     * DisplayContent)} to tell the window manager it can unfreeze the screen. This will typically
     * be done by calling {@link #sendNewConfiguration}.
     *
     * @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 freezeDisplayWindow Freeze the app window if the orientation is changed.
     * @param forceUpdate See {@link DisplayRotation#updateRotationUnchecked(boolean)}
     */
    Configuration updateOrientation(Configuration currentConfig,
            WindowContainer freezeDisplayWindow, boolean forceUpdate) {
    Configuration updateOrientation(WindowContainer<?> freezeDisplayWindow, boolean forceUpdate) {
        if (!mDisplayReady) {
            return null;
        }
@@ -1540,15 +1536,15 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
            }
            config = new Configuration();
            computeScreenConfiguration(config);
        } else if (currentConfig != null
        } else if (!(mTransitionController.isCollecting(this)
                // If waiting for a remote rotation, don't prematurely update configuration.
                && !(mDisplayRotation.isWaitingForRemoteRotation()
                        || mTransitionController.isCollecting(this))) {
                || mDisplayRotation.isWaitingForRemoteRotation())) {
            // No obvious action we need to take, but if our current state mismatches the
            // activity manager's, update it, disregarding font scale, which should remain set
            // to the value of the previous configuration.
            // Here we're calling Configuration#unset() instead of setToDefaults() because we
            // need to keep override configs clear of non-empty values (e.g. fontSize).
            final Configuration currentConfig = getRequestedOverrideConfiguration();
            mTmpConfiguration.unset();
            mTmpConfiguration.updateFrom(currentConfig);
            computeScreenConfiguration(mTmpConfiguration);
+1 −20
Original line number Diff line number Diff line
@@ -1823,8 +1823,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
        final DisplayContent displayContent = getDisplayContent(displayId);
        Configuration config = null;
        if (displayContent != null) {
            config = displayContent.updateOrientation(
                    getDisplayOverrideConfiguration(displayId), starting, true /* forceUpdate */);
            config = displayContent.updateOrientation(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
@@ -2561,24 +2560,6 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
        mDisplayManagerInternal.setDisplayAccessUIDs(mDisplayAccessUIDs);
    }

    Configuration getDisplayOverrideConfiguration(int displayId) {
        final DisplayContent displayContent = getDisplayContentOrCreate(displayId);
        if (displayContent == null) {
            throw new IllegalArgumentException("No display found with id: " + displayId);
        }

        return displayContent.getRequestedOverrideConfiguration();
    }

    void setDisplayOverrideConfiguration(Configuration overrideConfiguration, int displayId) {
        final DisplayContent displayContent = getDisplayContentOrCreate(displayId);
        if (displayContent == null) {
            throw new IllegalArgumentException("No display found with id: " + displayId);
        }

        displayContent.onRequestedOverrideConfigurationChanged(overrideConfiguration);
    }

    void prepareForShutdown() {
        for (int i = 0; i < getChildCount(); i++) {
            createSleepToken("shutdown", getChildAt(i).mDisplayId);
+4 −6
Original line number Diff line number Diff line
@@ -2311,17 +2311,15 @@ public class ActivityRecordTests extends WindowTestsBase {

        // Set initial orientation and update.
        activity.setOrientation(SCREEN_ORIENTATION_LANDSCAPE);
        mDisplayContent.updateOrientation(
                mDisplayContent.getRequestedOverrideConfiguration(),
                null /* freezeThisOneIfNeeded */, false /* forceUpdate */);
        mDisplayContent.updateOrientation(null /* freezeThisOneIfNeeded */,
                false /* forceUpdate */);
        assertEquals(SCREEN_ORIENTATION_LANDSCAPE, mDisplayContent.getLastOrientation());
        appWindow.mResizeReported = false;

        // Update the orientation to perform 180 degree rotation and check that resize was reported.
        activity.setOrientation(SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
        mDisplayContent.updateOrientation(
                mDisplayContent.getRequestedOverrideConfiguration(),
                null /* freezeThisOneIfNeeded */, false /* forceUpdate */);
        mDisplayContent.updateOrientation(null /* freezeThisOneIfNeeded */,
                false /* forceUpdate */);
        // In this test, DC will not get config update. Set the waiting flag to false.
        mDisplayContent.mWaitingForConfig = false;
        mWm.mRoot.performSurfacePlacement();