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

Unverified Commit aca2f3aa authored by Steve Kondik's avatar Steve Kondik Committed by Michael Bestas
Browse files

perf: Add boostage

 * Boost the CPU during app launches and button presses.

Change-Id: Ic417f1c11428ff5f7f11405c28dac79b2b2ba6e0
parent d158a808
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -46,6 +46,8 @@ import android.widget.ImageView;
import com.android.systemui.R;
import com.android.systemui.statusbar.phone.ButtonDispatcher;

import cyanogenmod.power.PerformanceManager;

import static android.view.accessibility.AccessibilityNodeInfo.ACTION_CLICK;
import static android.view.accessibility.AccessibilityNodeInfo.ACTION_LONG_CLICK;

@@ -61,6 +63,8 @@ public class KeyButtonView extends ImageView implements ButtonDispatcher.ButtonI
    private boolean mLongClicked;
    private OnClickListener mOnClickListener;

    private PerformanceManager mPerf;

    private final Runnable mCheckLongPress = new Runnable() {
        public void run() {
            if (isPressed()) {
@@ -104,6 +108,7 @@ public class KeyButtonView extends ImageView implements ButtonDispatcher.ButtonI
        mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
        mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
        setBackground(new KeyButtonRipple(context, this));
        mPerf = PerformanceManager.getInstance(context);
    }

    public void setCode(int code) {
@@ -186,6 +191,9 @@ public class KeyButtonView extends ImageView implements ButtonDispatcher.ButtonI
            return false;
        }

        // A lot of stuff is about to happen. Lets get ready.
        mPerf.cpuBoost(750000);

        switch (action) {
            case MotionEvent.ACTION_DOWN:
                mDownTime = SystemClock.uptimeMillis();
+21 −0
Original line number Diff line number Diff line
@@ -248,6 +248,8 @@ import java.util.concurrent.atomic.AtomicLong;
import dalvik.system.VMRuntime;
import cyanogenmod.power.PerformanceManagerInternal;
import libcore.io.IoUtils;
import libcore.util.EmptyArray;
@@ -1233,6 +1235,11 @@ public final class ActivityManagerService extends ActivityManagerNative
     */
    private IVoiceInteractionSession mRunningVoice;
    /**
     * For boosting the CPU during app launches
     */
    PerformanceManagerInternal mPerf;
    /**
     * For some direct access we need to power manager.
     */
@@ -3694,6 +3701,17 @@ public final class ActivityManagerService extends ActivityManagerNative
        }
    }
    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);
    }
    final ProcessRecord startProcessLocked(String processName,
            ApplicationInfo info, boolean knownToBeDead, int intentFlags,
            String hostingType, ComponentName hostingName, boolean allowWhileBooting,
@@ -3989,6 +4007,9 @@ public final class ActivityManagerService extends ActivityManagerNative
            checkTime(startTime, "startProcess: building log message");
            StringBuilder buf = mStringBuilder;
            buf.setLength(0);
            if (hostingType.equals("activity")) {
                launchBoost(startResult.pid, app.processName);
            }
            buf.append("Start proc ");
            buf.append(startResult.pid);
            buf.append(':');
+10 −0
Original line number Diff line number Diff line
@@ -2379,6 +2379,11 @@ final class ActivityStack {
                    mWindowManager.prepareAppTransition(prev.task == next.task
                            ? TRANSIT_ACTIVITY_CLOSE
                            : TRANSIT_TASK_CLOSE, false);
                    if (prev.task != next.task) {
                        if (mStackSupervisor.mService.mPerf != null) {
                            mStackSupervisor.mService.mPerf.cpuBoost(2000 * 1000);
                        }
                    }
                }
                mWindowManager.setAppVisibility(prev.appToken, false);
            } else {
@@ -2393,6 +2398,11 @@ final class ActivityStack {
                            : next.mLaunchTaskBehind
                                    ? TRANSIT_TASK_OPEN_BEHIND
                                    : TRANSIT_TASK_OPEN, false);
                    if (prev.task != next.task) {
                        if (mStackSupervisor.mService.mPerf != null) {
                            mStackSupervisor.mService.mPerf.cpuBoost(2000 * 1000);
                        }
                    }
                }
            }
        } else {
+15 −2
Original line number Diff line number Diff line
@@ -1879,6 +1879,12 @@ public final class ActivityStackSupervisor implements DisplayListener {

    void findTaskToMoveToFrontLocked(TaskRecord task, int flags, ActivityOptions options,
            String reason, boolean forceNonResizeable) {
        ActivityRecord top = task.stack.topRunningActivityLocked();
        /* App is launching from recent apps and it's a new process */
        if (top != null && top.state == ActivityState.DESTROYED) {
            mService.launchBoost(-1, top.packageName);
        }

        if ((flags & ActivityManager.MOVE_TASK_NO_USER_ACTION) == 0) {
            mUserLeaving = true;
        }
@@ -2715,11 +2721,18 @@ public final class ActivityStackSupervisor implements DisplayListener {
                // If the match we found was based on root affinity we keep on looking to see if
                // there is a better match in another stack. We eventually return the match based
                // on root affinity if we don't find a better match.
                if (mTmpFindTaskResult.r != null && !mTmpFindTaskResult.matchedByRootAffinity) {
                if (mTmpFindTaskResult.r != null) {
                    if (mTmpFindTaskResult.r.state == ActivityState.DESTROYED) {
                        mService.launchBoost(-1, r.packageName);
                    }
                    if (!mTmpFindTaskResult.matchedByRootAffinity) {
                        return mTmpFindTaskResult.r;
                    }
                }
            }
        }
        mService.launchBoost(-1, r.packageName);

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