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

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

Clean up deferDisplayUpdates flag

The flag was enabled since previous release.

PhysicalDisplaySwitchTransitionLauncher is only used by
ImmediateDisplayUpdater which was replaced by DeferredDisplayUpdater.
So the related classes can be removed.

Bug: 259220649
Flag: EXEMPT remove dead code for launched flag
Test: DisplayContentDeferredUpdateTests
Change-Id: I57478ca252f32b714f7d4a2e3d2587043432192e
parent a5c1ec25
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -64,14 +64,6 @@ flag {
  is_fixed_read_only: true
}

flag {
    name: "defer_display_updates"
    namespace: "windowing_frontend"
    description: "Feature flag for deferring DisplayManager updates to WindowManager if Shell transition is running"
    bug: "259220649"
    is_fixed_read_only: true
}

flag {
  name: "close_to_square_config_includes_status_bar"
  namespace: "windowing_frontend"
+15 −11
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ import java.util.Objects;
 * display change transition. In this case, we will queue all display updates until the current
 * transition's collection finishes and then apply them afterwards.
 */
public class DeferredDisplayUpdater implements DisplayUpdater {
class DeferredDisplayUpdater {

    /**
     * List of fields that could be deferred before applying to DisplayContent.
@@ -110,7 +110,7 @@ public class DeferredDisplayUpdater implements DisplayUpdater {
        continueScreenUnblocking();
    };

    public DeferredDisplayUpdater(@NonNull DisplayContent displayContent) {
    DeferredDisplayUpdater(@NonNull DisplayContent displayContent) {
        mDisplayContent = displayContent;
        mNonOverrideDisplayInfo.copyFrom(mDisplayContent.getDisplayInfo());
    }
@@ -122,8 +122,7 @@ public class DeferredDisplayUpdater implements DisplayUpdater {
     *
     * @param finishCallback is called when all pending display updates are finished
     */
    @Override
    public void updateDisplayInfo(@NonNull Runnable finishCallback) {
    void updateDisplayInfo(@NonNull Runnable finishCallback) {
        // Get the latest display parameters from the DisplayManager
        final DisplayInfo displayInfo = getCurrentDisplayInfo();

@@ -310,9 +309,11 @@ public class DeferredDisplayUpdater implements DisplayUpdater {
        return !Objects.equals(first.uniqueId, second.uniqueId);
    }

    @Override
    public void onDisplayContentDisplayPropertiesPostChanged(int previousRotation, int newRotation,
            DisplayAreaInfo newDisplayAreaInfo) {
    /**
     * Called after physical display has changed and after DisplayContent applied new display
     * properties.
     */
    void onDisplayContentDisplayPropertiesPostChanged() {
        // Unblock immediately in case there is no transition. This is unlikely to happen.
        if (mScreenUnblocker != null && !mDisplayContent.mTransitionController.inTransition()) {
            mScreenUnblocker.sendToTarget();
@@ -320,13 +321,16 @@ public class DeferredDisplayUpdater implements DisplayUpdater {
        }
    }

    @Override
    public void onDisplaySwitching(boolean switching) {
    /**
     * Called with {@code true} when physical display is going to switch. And {@code false} when
     * the display is turned on or the device goes to sleep.
     */
    void onDisplaySwitching(boolean switching) {
        mShouldWaitForTransitionWhenScreenOn = switching;
    }

    @Override
    public boolean waitForTransition(@NonNull Message screenUnblocker) {
    /** Returns {@code true} if the transition will control when to turn on the screen. */
    boolean waitForTransition(@NonNull Message screenUnblocker) {
        if (!Flags.waitForTransitionOnDisplaySwitch()) return false;
        if (!mShouldWaitForTransitionWhenScreenOn) {
            return false;
+3 −15
Original line number Diff line number Diff line
@@ -159,7 +159,6 @@ import static com.android.server.wm.utils.DisplayInfoOverrides.WM_OVERRIDE_FIELD
import static com.android.server.wm.utils.DisplayInfoOverrides.copyDisplayInfoFields;
import static com.android.server.wm.utils.RegionUtils.forEachRectReverse;
import static com.android.server.wm.utils.RegionUtils.rectListToRegion;
import static com.android.window.flags.Flags.deferDisplayUpdates;
import static com.android.window.flags.Flags.explicitRefreshRateHints;

import android.annotation.IntDef;
@@ -478,7 +477,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
    AppCompatCameraPolicy mAppCompatCameraPolicy;

    DisplayFrames mDisplayFrames;
    final DisplayUpdater mDisplayUpdater;
    final DeferredDisplayUpdater mDisplayUpdater;

    private boolean mInTouchMode;

@@ -624,7 +623,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
    @VisibleForTesting
    final DeviceStateController mDeviceStateController;
    final Consumer<DeviceStateController.DeviceState> mDeviceStateConsumer;
    final PhysicalDisplaySwitchTransitionLauncher mDisplaySwitchTransitionLauncher;
    final RemoteDisplayChangeController mRemoteDisplayChangeController;

    /** Windows added since {@link #mCurrentFocus} was set to null. Used for ANR blaming. */
@@ -1141,11 +1139,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        mWallpaperController.resetLargestDisplay(display);
        display.getDisplayInfo(mDisplayInfo);
        display.getMetrics(mDisplayMetrics);
        if (deferDisplayUpdates()) {
        mDisplayUpdater = new DeferredDisplayUpdater(this);
        } else {
            mDisplayUpdater = new ImmediateDisplayUpdater(this);
        }
        mSystemGestureExclusionLimit = mWmService.mConstants.mSystemGestureExclusionLimitDp
                * mDisplayMetrics.densityDpi / DENSITY_DEFAULT;
        isDefaultDisplay = mDisplayId == DEFAULT_DISPLAY;
@@ -1169,8 +1163,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        mAppTransitionController = new AppTransitionController(mWmService, this);
        mTransitionController.registerLegacyListener(mFixedRotationTransitionListener);
        mUnknownAppVisibilityController = new UnknownAppVisibilityController(mWmService, this);
        mDisplaySwitchTransitionLauncher = new PhysicalDisplaySwitchTransitionLauncher(this,
                mTransitionController);
        mRemoteDisplayChangeController = new RemoteDisplayChangeController(this);

        final InputChannel inputChannel = mWmService.mInputManager.monitorInput(
@@ -1191,7 +1183,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp

        mDeviceStateConsumer =
                (@NonNull DeviceStateController.DeviceState newFoldState) -> {
                    mDisplaySwitchTransitionLauncher.foldStateChanged(newFoldState);
                    mDisplayRotation.foldStateChanged(newFoldState);
                };
        mDeviceStateController.registerDeviceStateCallback(mDeviceStateConsumer,
@@ -3094,8 +3085,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
                // metrics are updated as rotation settings might depend on them
                mWmService.mDisplayWindowSettings.applySettingsToDisplayLocked(this,
                        /* includeRotationSettings */ false);
                mDisplayUpdater.onDisplayContentDisplayPropertiesPreChanged(mDisplayId,
                        mInitialDisplayWidth, mInitialDisplayHeight, newWidth, newHeight);
                mDisplayRotation.physicalDisplayChanged();
                mDisplayPolicy.physicalDisplayChanged();
            }
@@ -3130,8 +3119,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp

            if (physicalDisplayChanged) {
                mDisplayPolicy.physicalDisplayUpdated();
                mDisplayUpdater.onDisplayContentDisplayPropertiesPostChanged(currentRotation,
                        getRotation(), getDisplayAreaInfo());
                mDisplayUpdater.onDisplayContentDisplayPropertiesPostChanged();
            }
        }
    }
+0 −65
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.wm;

import android.annotation.NonNull;
import android.os.Message;
import android.view.Surface;
import android.window.DisplayAreaInfo;

/**
 * Interface for a helper class that manages updates of DisplayInfo coming from DisplayManager
 */
interface DisplayUpdater {
    /**
     * Reads the latest display parameters from the display manager and returns them in a callback.
     * If there are pending display updates, it will wait for them to finish first and only then it
     * will call the callback with the latest display parameters.
     *
     * @param callback is called when all pending display updates are finished
     */
    void updateDisplayInfo(@NonNull Runnable callback);

    /**
     * Called when physical display has changed and before DisplayContent has applied new display
     * properties
     */
    default void onDisplayContentDisplayPropertiesPreChanged(int displayId, int initialDisplayWidth,
            int initialDisplayHeight, int newWidth, int newHeight) {
    }

    /**
     * Called after physical display has changed and after DisplayContent applied new display
     * properties
     */
    default void onDisplayContentDisplayPropertiesPostChanged(
            @Surface.Rotation int previousRotation, @Surface.Rotation int newRotation,
            @NonNull DisplayAreaInfo newDisplayAreaInfo) {
    }

    /**
     * Called with {@code true} when physical display is going to switch. And {@code false} when
     * the display is turned on or the device goes to sleep.
     */
    default void onDisplaySwitching(boolean switching) {
    }

    /** Returns {@code true} if the transition will control when to turn on the screen. */
    default boolean waitForTransition(@NonNull Message screenUnBlocker) {
        return false;
    }
}
+0 −58
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.wm;

import android.annotation.NonNull;
import android.view.DisplayInfo;
import android.window.DisplayAreaInfo;

/**
 * DisplayUpdater that immediately applies new DisplayInfo properties
 */
public class ImmediateDisplayUpdater implements DisplayUpdater {

    private final DisplayContent mDisplayContent;
    private final DisplayInfo mDisplayInfo = new DisplayInfo();

    public ImmediateDisplayUpdater(@NonNull DisplayContent displayContent) {
        mDisplayContent = displayContent;
        mDisplayInfo.copyFrom(mDisplayContent.getDisplayInfo());
    }

    @Override
    public void updateDisplayInfo(Runnable callback) {
        mDisplayContent.mWmService.mDisplayManagerInternal.getNonOverrideDisplayInfo(
                mDisplayContent.mDisplayId, mDisplayInfo);
        mDisplayContent.onDisplayInfoUpdated(mDisplayInfo);
        callback.run();
    }

    @Override
    public void onDisplayContentDisplayPropertiesPreChanged(int displayId, int initialDisplayWidth,
            int initialDisplayHeight, int newWidth, int newHeight) {
        mDisplayContent.mDisplaySwitchTransitionLauncher.requestDisplaySwitchTransitionIfNeeded(
                displayId, initialDisplayWidth, initialDisplayHeight, newWidth, newHeight);
    }

    @Override
    public void onDisplayContentDisplayPropertiesPostChanged(int previousRotation, int newRotation,
            DisplayAreaInfo newDisplayAreaInfo) {
        mDisplayContent.mDisplaySwitchTransitionLauncher.onDisplayUpdated(previousRotation,
                newRotation,
                newDisplayAreaInfo);
    }
}
Loading