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

Commit 91338fb3 authored by Dilip Gudlur's avatar Dilip Gudlur Committed by Linux Build Service Account
Browse files

frameworks: Add custom boost for scroll/fling

Change adds custom scroll/fling boost for specific
applications, gets enabled only when system property
(persist.debugboost.enabled) is defined

Change-Id: I75141636bbe1a58b9f5cc948d7e16e588c4e6b98
parent 7d2b34ac
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -3074,7 +3074,14 @@ public class Activity extends ContextThemeWrapper
                }
            }
        }
        if (mDragBoostPossible == 1) {

       Context context = getApplicationContext();
       if (mPerf == null){
           mPerf = new BoostFramework();
       }
       boolean override = mPerf.boostOverride(context, ev, getResources().getDisplayMetrics());

       if (mDragBoostPossible == 1 && override != true) {
            if (mPerf == null){
                mPerf = new BoostFramework();
            }
+68 −0
Original line number Diff line number Diff line
@@ -36,6 +36,8 @@ import java.lang.reflect.Method;
import java.lang.System;
import android.view.MotionEvent;
import android.util.DisplayMetrics;
import android.os.SystemProperties;
import android.content.Context;

/** @hide */
public class BoostFramework {
@@ -52,6 +54,11 @@ public class BoostFramework {
    private static Method mIOPStart = null;
    private static Method mIOPStop  = null;
    private static Constructor<Class> mConstructor = null;
    private static int mLockDuration = -1;
    private static int mParamVal[];
    private static String mBoostActivityList[];
    private static long mStartTime;
    private static final int mDebugBoost = getDebugBoostProperty();

/** @hide */
    private Object mPerf = null;
@@ -142,6 +149,67 @@ public class BoostFramework {
        }
        return ret;
    }

/** @hide Reads system property
     * @return 1 if property is set
     */
    public static int getDebugBoostProperty() {
       return SystemProperties.getInt("persist.debugboost.enable", 0);
    }

/** @hide Acquires debug boost perflock
     * @param ev Touch Screen event
     */
    public void enableDebugBoost(Context context, MotionEvent ev, DisplayMetrics metrics) {

       final int NANO_TO_MILLI = 1000000;
       long elapsedMillis;
       boolean mDebugBoostPossible = false;

       /* extract the XML params */
       if (mLockDuration == -1 || mParamVal == null || mBoostActivityList == null) {
          mLockDuration = context.getResources().getInteger(
             com.android.internal.R.integer.debugBoost_timeout);
          mParamVal = context.getResources().getIntArray(
             com.android.internal.R.array.debugBoost_param_value);
          mBoostActivityList = context.getResources().getStringArray(
             com.android.internal.R.array.debugBoost_activityList);
       }

       String currentActivity = context.getPackageName();

       /* search for the current activity in list */
       for (String match : mBoostActivityList) {
          if (currentActivity.indexOf(match) != -1) {
             /* break if found */
             mDebugBoostPossible = true;
             break;
          }
       }

       elapsedMillis = (System.nanoTime() - mStartTime)/NANO_TO_MILLI;

       /* elapsed should be atleast greater than lock duration */
       if (mDebugBoostPossible == true && elapsedMillis > mLockDuration) {
          perfLockAcquireTouch(ev, metrics, mLockDuration, mParamVal);
          mStartTime = System.nanoTime();
          Log.i(TAG, "dBoost: activity = " + currentActivity + " " + "elapsed = " + elapsedMillis);
       }
    }

/** @hide sets debug boost if property is set
    */
    public boolean boostOverride(Context context, MotionEvent ev, DisplayMetrics metrics) {
       /* Enable debug boost if property is set and
        * current actiivity is present in list
        */
       if (mDebugBoost == 1) {
          enableDebugBoost(context, ev, metrics);
          return true;
       }
       return false;
    }

/** @hide */
    public int perfLockAcquireTouch(MotionEvent ev, DisplayMetrics metrics,
                                   int duration, int... list) {
+6 −0
Original line number Diff line number Diff line
@@ -2515,6 +2515,12 @@
    <integer name="ascrollboost_timeout">0</integer>
    <integer-array name="ascrollboost_param_value"/>

    <!-- SSDOU scroll boost optimization -->
    <bool name="config_debugBoost">false</bool>
    <string-array  translatable="false" name="debugBoost_activityList"></string-array>
    <integer name="debugBoost_timeout">0</integer>
    <integer-array name="debugBoost_param_value"/>

    <!-- cpu boost for PanelView fling -->
    <bool name="config_enableCpuBoostForPanelViewFling">false</bool>
    <integer-array name="panelview_flingboost_param_value" />
+6 −0
Original line number Diff line number Diff line
@@ -2651,6 +2651,12 @@
  <java-symbol type="integer" name="ascrollboost_timeout" />
  <java-symbol type="array" name="ascrollboost_param_value" />

  <!-- SSDOU scroll boost optimization -->
  <java-symbol type="bool" name="config_debugBoost" />
  <java-symbol type="array" name="debugBoost_activityList" />
  <java-symbol type="integer" name="debugBoost_timeout" />
  <java-symbol type="array" name="debugBoost_param_value" />

  <!-- cpu boost for PanelView fling -->
  <java-symbol type="bool" name="config_enableCpuBoostForPanelViewFling" />
  <java-symbol type="array" name="panelview_flingboost_param_value" />