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

Commit 9d048147 authored by Steve Kondik's avatar Steve Kondik Committed by Steve Kondik
Browse files

perf: Send the process name and pid for launch boosts

Change-Id: I999a32ed1d8c779fa5118302a75abac88979a5b5
parent a3cdad2f
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -264,6 +264,9 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import cyanogenmod.power.PerformanceManagerInternal;
import java.util.Date;
import java.text.SimpleDateFormat;
@@ -1094,6 +1097,8 @@ public final class ActivityManagerService extends ActivityManagerNative
     */
    private IVoiceInteractionSession mRunningVoice;
    PerformanceManagerInternal mPerf;
    /**
     * For some direct access we need to power manager.
     */
@@ -3440,6 +3445,17 @@ public final class ActivityManagerService extends ActivityManagerNative
                null /* entryPoint */, null /* entryPointArgs */);
    }
    void launchBoost(int pid, String packageName) {
        if (mPerf == null) {
            mPerf = LocalServices.getService(PerformanceManagerInternal.class);
            if (mPerf == null) {
                Slog.e(TAG, "PerformanceManager not ready!");
                return;
            }
        }
        mPerf.launchBoost(pid, packageName);
    }
    private final void startProcessLocked(ProcessRecord app, String hostingType,
            String hostingNameStr, String abiOverride, String entryPoint, String[] entryPointArgs) {
        long startTime = SystemClock.elapsedRealtime();
@@ -3602,6 +3618,9 @@ public final class ActivityManagerService extends ActivityManagerNative
            checkTime(startTime, "startProcess: building log message");
            StringBuilder buf = mStringBuilder;
            buf.setLength(0);
            if (hostingType.equals("activity")) {
                mPerf.launchBoost(startResult.pid, app.processName);
            }
            buf.append("Start proc ");
            buf.append(startResult.pid);
            buf.append(':');
+7 −7
Original line number Diff line number Diff line
@@ -1701,8 +1701,8 @@ final class ActivityStack {
        if (DEBUG_SWITCH) Slog.v(TAG_SWITCH, "Resuming " + next);

        // Some activities may want to alter the system power management
        if (mStackSupervisor.mPerf != null) {
            mStackSupervisor.mPerf.activityResumed(next.intent);
        if (mStackSupervisor.mService.mPerf != null) {
            mStackSupervisor.mService.mPerf.activityResumed(next.intent);
        }

        // If we are currently pausing an activity, then don't do anything
@@ -1838,8 +1838,8 @@ final class ActivityStack {
                            ? AppTransition.TRANSIT_ACTIVITY_CLOSE
                            : AppTransition.TRANSIT_TASK_CLOSE, false);
                    if (prev.task != next.task) {
                        if (mStackSupervisor.mPerf != null) {
                            mStackSupervisor.mPerf.cpuBoost(2000 * 1000);
                        if (mStackSupervisor.mService.mPerf != null) {
                            mStackSupervisor.mService.mPerf.cpuBoost(2000 * 1000);
                        }
                    }
                }
@@ -1858,8 +1858,8 @@ final class ActivityStack {
                                    ? AppTransition.TRANSIT_TASK_OPEN_BEHIND
                                    : AppTransition.TRANSIT_TASK_OPEN, false);
                    if (prev.task != next.task) {
                        if (mStackSupervisor.mPerf != null) {
                            mStackSupervisor.mPerf.cpuBoost(2000 * 1000);
                        if (mStackSupervisor.mService.mPerf != null) {
                            mStackSupervisor.mService.mPerf.cpuBoost(2000 * 1000);
                        }
                    }
                }
+5 −20
Original line number Diff line number Diff line
@@ -118,8 +118,6 @@ import com.android.server.LocalServices;
import com.android.server.am.ActivityStack.ActivityState;
import com.android.server.wm.WindowManagerService;

import cyanogenmod.power.PerformanceManagerInternal;

import java.io.FileDescriptor;
import java.io.IOException;
import java.io.PrintWriter;
@@ -276,8 +274,6 @@ public final class ActivityStackSupervisor implements DisplayListener {

    PowerManager mPm;

    PerformanceManagerInternal mPerf;

    /**
     * Is the privacy guard currently enabled? Shared between ActivityStacks
     */
@@ -354,17 +350,6 @@ public final class ActivityStackSupervisor implements DisplayListener {
        mHandler = new ActivityStackSupervisorHandler(mService.mHandler.getLooper());
    }

    private void launchBoost() {
        if (mPerf == null) {
            mPerf = LocalServices.getService(PerformanceManagerInternal.class);
        }
        if (mPerf == null) {
            Slog.e(TAG, "PerformanceManager not ready!");
        } else {
            mPerf.launchBoost();
        }
    }
    
    /**
     * At the time when the constructor runs, the power manager has not yet been
     * initialized.  So we initialize our wakelocks afterwards.
@@ -1469,7 +1454,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
                            (container.mActivityDisplay == null ? Display.DEFAULT_DISPLAY :
                                    container.mActivityDisplay.mDisplayId)));
            /* Acquire perf lock during new app launch */
            launchBoost();
            mService.launchBoost(-1, aInfo.packageName);
        }

        ActivityRecord sourceRecord = null;
@@ -2822,7 +2807,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
        ActivityRecord top = task.stack.topRunningActivityLocked(null);
        /* App is launching from recent apps and it's a new process */
        if(top != null && top.state == ActivityState.DESTROYED) {
            launchBoost();
            mService.launchBoost(-1, top.packageName);
        }

        if ((flags & ActivityManager.MOVE_TASK_NO_USER_ACTION) == 0) {
@@ -3107,15 +3092,15 @@ public final class ActivityStackSupervisor implements DisplayListener {
                final ActivityRecord ar = stack.findTaskLocked(r);
                if (ar != null) {
                    if (ar.state == ActivityState.DESTROYED) {
                        launchBoost();
                        mService.launchBoost(-1, r.packageName);
                    }
                    return ar;
                }
            }
        }
        if (DEBUG_TASKS) Slog.d(TAG_TASKS, "No task found");
        launchBoost();
        mService.launchBoost(-1, r.packageName);

        if (DEBUG_TASKS) Slog.d(TAG_TASKS, "No task found");
        return null;
    }