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

Commit 98f03f98 authored by Wei Wang's avatar Wei Wang
Browse files

Trigger power hints for activity launch

BUG: 28220567
Change-Id: Id2a0397efd1dd02ee50d5626edaed9e60ea6de8a
parent ce8e88aa
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -57,14 +57,19 @@ public abstract class PowerManagerInternal {
    /**
     * Power hint:
     * Interaction: The user is interacting with the device. The corresponding data field must be
     * the expected duration of the fling, or 0 if unknown.
     * the expected duration of the interaction, or 0 if unknown.
     *
     * Sustained Performance Mode: Enable/Disables Sustained Performance Mode.
     * Sustained Performance Mode: The corresponding data field must be Enable/Disable
     * Sustained Performance Mode.
     *
     * Launch: This is specific for activity launching. The corresponding data field must be
     * the expected duration of the required boost, or 0 if unknown.
     *
     * These must be kept in sync with the values in hardware/libhardware/include/hardware/power.h
     */
    public static final int POWER_HINT_INTERACTION = 2;
    public static final int POWER_HINT_SUSTAINED_PERFORMANCE_MODE = 6;
    public static final int POWER_HINT_LAUNCH = 8;

    public static String wakefulnessToString(int wakefulness) {
        switch (wakefulness) {
+1 −0
Original line number Diff line number Diff line
@@ -4412,6 +4412,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
        // Work Challenge is present) let startActivityInPackage handle the intercepting.
        if (!mService.mUserController.shouldConfirmCredentials(task.userId)
                && task.getRootActivity() != null) {
            mService.mActivityStarter.sendPowerHintForLaunchIfNeeded(true /* forceSend */);
            mActivityMetricsLogger.notifyActivityLaunching();
            mService.moveTaskToFrontLocked(task.taskId, 0, bOptions);
            mActivityMetricsLogger.notifyActivityLaunched(ActivityManager.START_TASK_TO_FRONT,
+23 −0
Original line number Diff line number Diff line
@@ -102,6 +102,7 @@ import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.PowerManagerInternal;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.UserHandle;
@@ -172,6 +173,7 @@ class ActivityStarter {
    private boolean mNoAnimation;
    private boolean mKeepCurTransition;
    private boolean mAvoidMoveToFront;
    private boolean mPowerHintSent;

    private IVoiceInteractionSession mVoiceSession;
    private IVoiceInteractor mVoiceInteractor;
@@ -210,6 +212,8 @@ class ActivityStarter {
        mKeepCurTransition = false;
        mAvoidMoveToFront = false;

        mPowerHintSent = false;

        mVoiceSession = null;
        mVoiceInteractor = null;
    }
@@ -933,6 +937,20 @@ class ActivityStarter {
        return START_SUCCESS;
    }

    void sendPowerHintForLaunchIfNeeded(boolean forceSend) {
        // Trigger launch power hint if activity is not in the current task
        final ActivityStack focusStack = mSupervisor.getFocusedStack();
        final ActivityRecord curTop = (focusStack == null)
            ? null : focusStack.topRunningNonDelayedActivityLocked(mNotTop);
        if ((forceSend || (!mPowerHintSent && curTop != null &&
                curTop.task != null && mStartActivity != null &&
                curTop.task != mStartActivity.task )) &&
                mService.mLocalPowerManager != null) {
            mService.mLocalPowerManager.powerHint(PowerManagerInternal.POWER_HINT_LAUNCH, 0);
            mPowerHintSent = true;
        }
    }

    private int startActivityUnchecked(final ActivityRecord r, ActivityRecord sourceRecord,
            IVoiceInteractionSession voiceSession, IVoiceInteractor voiceInteractor,
            int startFlags, boolean doResume, ActivityOptions options, TaskRecord inTask) {
@@ -994,6 +1012,8 @@ class ActivityStarter {
                }
            }

            sendPowerHintForLaunchIfNeeded(false /* forceSend */);

            mReusedActivity = setTargetStackAndMoveToFrontIfNeeded(mReusedActivity);

            if ((mStartFlags & START_FLAG_ONLY_IF_NEEDED) != 0) {
@@ -1116,6 +1136,9 @@ class ActivityStarter {
        ActivityStack.logStartActivity(
                EventLogTags.AM_CREATE_ACTIVITY, mStartActivity, mStartActivity.task);
        mTargetStack.mLastPausedActivity = null;

        sendPowerHintForLaunchIfNeeded(false /* forceSend */);

        mTargetStack.startActivityLocked(mStartActivity, newTask, mKeepCurTransition, mOptions);
        if (mDoResume) {
            if (!mLaunchTaskBehind) {