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

Commit 4ba189ba authored by Steve Kondik's avatar Steve Kondik
Browse files

power: Add CPU boosting interface

 * Boosts CPU using Power HAL for the given duration.
 * Duration is given in microseconds.
 * Power HAL must implement POWER_HINT_CPU_BOOST.

Change-Id: Ic79baf7e3d0f75483c2fe8a242b4c3d93368b68b

Add CPU boosting hooks

 * Send boost hint during scrolling
 * Still relevant on even high-end hardware

Change-Id: I72f2c2851b01fbceabddead03a4c3a7a0526ca61

perf: Send a boost hint when a key on the navbar is pressed

 * A lot of stuff happens, especially when invoking recents.
 * Get ahead of the storm by sending a boost hint before
   kicking off the animations.

Change-Id: I0cecd0c58f8bc8479ea44f63af796500d7b9d7d2

perf: Send boost hint during initial launch

Change-Id: I26afc909c35e514958894b0a07a650a20ce6e537
parent 2437f21f
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -60,4 +60,6 @@ interface IPowerManager
    void setAttentionLight(boolean on, int color);
    // update the uids being synchronized by network socket request manager
    void updateBlockedUids(int uid, boolean isBlocked);

    void cpuBoost(int duration);
}
+18 −0
Original line number Diff line number Diff line
@@ -812,6 +812,24 @@ public final class PowerManager {
        }
    }

    /**
     * Boost the CPU. Boosts the cpu for the given duration in microseconds.
     * Requires the {@link android.Manifest.permission#CPU_BOOST} permission.
     *
     * @param duration in microseconds to boost the CPU
     *
     * @hide
     */
    public void cpuBoost(int duration)
    {
        try {
            if (mService != null) {
                mService.cpuBoost(duration);
            }
        } catch (RemoteException e) {
        }
    }

    /**
     * Intent that is broadcast when the state of {@link #isPowerSaveMode()} changes.
     * This broadcast is only sent to registered receivers.
+5 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.widget;

import android.content.Context;
import android.hardware.SensorManager;
import android.os.PowerManager;
import android.util.FloatMath;
import android.util.Log;
import android.view.ViewConfiguration;
@@ -602,6 +603,8 @@ public class OverScroller {
        private static final int CUBIC = 1;
        private static final int BALLISTIC = 2;

        private final PowerManager mPm;

        static {
            float x_min = 0.0f;
            float y_min = 0.0f;
@@ -646,6 +649,7 @@ public class OverScroller {
                    * 39.37f // inch/meter
                    * ppi
                    * 0.84f; // look and feel tuning
            mPm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
        }

        void updateScroll(float q) {
@@ -763,6 +767,7 @@ public class OverScroller {
            if (velocity != 0) {
                mDuration = mSplineDuration = getSplineFlingDuration(velocity);
                totalDistance = getSplineFlingDistance(velocity);
                mPm.cpuBoost(mDuration * 1000);
            }

            mSplineDistance = (int) (totalDistance * Math.signum(velocity));
+7 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.widget;
import android.content.Context;
import android.hardware.SensorManager;
import android.os.Build;
import android.os.PowerManager;
import android.util.FloatMath;
import android.view.ViewConfiguration;
import android.view.animation.AnimationUtils;
@@ -109,6 +110,8 @@ public class Scroller {
    private float mDeceleration;
    private final float mPpi;

    private final PowerManager mPm;

    // A context-specific coefficient adjusted to physical values.
    private float mPhysicalCoeff;

@@ -179,6 +182,8 @@ public class Scroller {
        mFlywheel = flywheel;

        mPhysicalCoeff = computeDeceleration(0.84f); // look and feel tuning

        mPm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
    }

    /**
@@ -396,6 +401,8 @@ public class Scroller {
        mDeltaX = dx;
        mDeltaY = dy;
        mDurationReciprocal = 1.0f / (float) mDuration;

        mPm.cpuBoost(duration * 1000);
    }

    /**
+7 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import android.graphics.RectF;
import android.hardware.input.InputManager;
import android.media.AudioManager;
import android.os.Bundle;
import android.os.PowerManager;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.util.Log;
@@ -71,6 +72,8 @@ public class KeyButtonView extends ImageView {
    private AudioManager mAudioManager;
    private Animator mAnimateToQuiescent = new ObjectAnimator();

    private PowerManager mPm;

    private final Runnable mCheckLongPress = new Runnable() {
        public void run() {
            if (isPressed()) {
@@ -109,6 +112,7 @@ public class KeyButtonView extends ImageView {
        mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
        mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
        setBackground(new KeyButtonRipple(context, this));
        mPm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    }

    @Override
@@ -175,6 +179,9 @@ public class KeyButtonView extends ImageView {
        final int action = ev.getAction();
        int x, y;

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

        switch (action) {
            case MotionEvent.ACTION_DOWN:
                //Log.d("KeyButtonView", "press");
Loading