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

Commit 78a29672 authored by Steve Kondik's avatar Steve Kondik
Browse files

Add CPU boosting hooks

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

Change-Id: I72f2c2851b01fbceabddead03a4c3a7a0526ca61
parent dbd3649b
Loading
Loading
Loading
Loading
+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;
@@ -601,6 +602,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;
@@ -645,6 +648,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) {
@@ -762,6 +766,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;
@@ -108,6 +109,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;

@@ -184,6 +187,8 @@ public class Scroller {
        mFlywheel = flywheel;

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

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

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

        mPm.cpuBoost(duration * 1000);
    }

    /**