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

Commit 38b5af54 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Set launch power mode for display change transition

It may reduce 10% latency if the visible activity takes longer time
to redraw for the display configuration change, e.g. relaunch.

Bug: 206487939
Test: setprop persist.debug.shell_transit 1; reboot
      Rotate device and check the log of ACTION_ROTATE_SCREEN.
Change-Id: I393ff88f26ddfc94cb9d2fb1aa95e88cb20a9ee1
parent 8fccb13a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -667,14 +667,14 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
    @Retention(RetentionPolicy.SOURCE)
    @IntDef({
            POWER_MODE_REASON_START_ACTIVITY,
            POWER_MODE_REASON_FREEZE_DISPLAY,
            POWER_MODE_REASON_CHANGE_DISPLAY,
            POWER_MODE_REASON_UNKNOWN_VISIBILITY,
            POWER_MODE_REASON_ALL,
    })
    @interface PowerModeReason {}

    static final int POWER_MODE_REASON_START_ACTIVITY = 1 << 0;
    static final int POWER_MODE_REASON_FREEZE_DISPLAY = 1 << 1;
    static final int POWER_MODE_REASON_CHANGE_DISPLAY = 1 << 1;
    /** @see UnknownAppVisibilityController */
    static final int POWER_MODE_REASON_UNKNOWN_VISIBILITY = 1 << 2;
    /** This can only be used by {@link #endLaunchPowerMode(int)}.*/
+2 −0
Original line number Diff line number Diff line
@@ -100,6 +100,7 @@ import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_C
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT;
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
import static com.android.server.wm.ActivityRecord.State.RESUMED;
import static com.android.server.wm.ActivityTaskManagerService.POWER_MODE_REASON_CHANGE_DISPLAY;
import static com.android.server.wm.DisplayContentProto.APP_TRANSITION;
import static com.android.server.wm.DisplayContentProto.CLOSING_APPS;
import static com.android.server.wm.DisplayContentProto.CURRENT_FOCUS;
@@ -3229,6 +3230,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        }
        final Transition t = controller.requestTransitionIfNeeded(TRANSIT_CHANGE, this);
        if (t != null) {
            mAtmService.startLaunchPowerMode(POWER_MODE_REASON_CHANGE_DISPLAY);
            if (getRotation() != getWindowConfiguration().getRotation()) {
                mWmService.mLatencyTracker.onActionStart(ACTION_ROTATE_SCREEN);
                controller.mTransitionMetricsReporter.associate(t,
+4 −0
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@ import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY;
import static android.view.WindowManager.TRANSIT_NONE;
import static android.view.WindowManager.TRANSIT_OPEN;

import static com.android.server.wm.ActivityTaskManagerService.POWER_MODE_REASON_CHANGE_DISPLAY;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityManager;
@@ -359,6 +361,8 @@ class TransitionController {
    void finishTransition(@NonNull IBinder token) {
        // It is usually a no-op but make sure that the metric consumer is removed.
        mTransitionMetricsReporter.reportAnimationStart(token, 0 /* startTime */);
        // It is a no-op if the transition did not change the display.
        mAtm.endLaunchPowerMode(POWER_MODE_REASON_CHANGE_DISPLAY);
        final Transition record = Transition.fromBinder(token);
        if (record == null || !mPlayingTransitions.contains(record)) {
            Slog.e(TAG, "Trying to finish a non-playing transition " + token);
+3 −3
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@ import static com.android.internal.util.LatencyTracker.ACTION_ROTATE_SCREEN;
import static com.android.server.LockGuard.INDEX_WINDOW;
import static com.android.server.LockGuard.installLock;
import static com.android.server.policy.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER;
import static com.android.server.wm.ActivityTaskManagerService.POWER_MODE_REASON_FREEZE_DISPLAY;
import static com.android.server.wm.ActivityTaskManagerService.POWER_MODE_REASON_CHANGE_DISPLAY;
import static com.android.server.wm.DisplayContent.IME_TARGET_CONTROL;
import static com.android.server.wm.DisplayContent.IME_TARGET_INPUT;
import static com.android.server.wm.DisplayContent.IME_TARGET_LAYERING;
@@ -5849,7 +5849,7 @@ public class WindowManagerService extends IWindowManager.Stub
        mScreenFrozenLock.acquire();
        // Apply launch power mode to reduce screen frozen time because orientation change may
        // relaunch activity and redraw windows. This may also help speed up user switching.
        mAtmService.startLaunchPowerMode(POWER_MODE_REASON_FREEZE_DISPLAY);
        mAtmService.startLaunchPowerMode(POWER_MODE_REASON_CHANGE_DISPLAY);

        mDisplayFrozen = true;
        mDisplayFreezeTime = SystemClock.elapsedRealtime();
@@ -5993,7 +5993,7 @@ public class WindowManagerService extends IWindowManager.Stub
        if (configChanged) {
            displayContent.sendNewConfiguration();
        }
        mAtmService.endLaunchPowerMode(POWER_MODE_REASON_FREEZE_DISPLAY);
        mAtmService.endLaunchPowerMode(POWER_MODE_REASON_CHANGE_DISPLAY);
        mLatencyTracker.onActionEnd(ACTION_ROTATE_SCREEN);
    }