summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/app/Activity.java34
-rw-r--r--core/java/android/util/BoostFramework.java148
-rw-r--r--core/java/android/widget/OverScroller.java37
-rw-r--r--core/java/android/widget/Scroller.java31
4 files changed, 250 insertions, 0 deletions
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 2cb3f39..627c854 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -111,6 +111,7 @@ import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import android.util.BoostFramework;
/**
* An activity is a single, focused thing that the user can do. Almost all
@@ -672,6 +673,10 @@ public class Activity extends ContextThemeWrapper
Window.Callback, KeyEvent.Callback,
OnCreateContextMenuListener, ComponentCallbacks2,
Window.OnWindowDismissedCallback {
+ private static BoostFramework mPerf = null;
+ private static int mDragBoostPossible = -1;
+ private static int mPerfLockDuration = -1;
+ private static int mAsParamVal[];
private static final String TAG = "Activity";
private static final boolean DEBUG_LIFECYCLE = false;
@@ -2759,6 +2764,35 @@ public class Activity extends ContextThemeWrapper
* @return boolean Return true if this event was consumed.
*/
public boolean dispatchTouchEvent(MotionEvent ev) {
+ if(mDragBoostPossible == -1) {
+ mDragBoostPossible = 0;
+ String currentActivity = getPackageName();
+ String[] activityList = getResources().getStringArray(
+ com.android.internal.R.array.boost_activityList);
+ if(activityList != null){
+ for (String match : activityList) {
+ if (currentActivity.indexOf(match) != -1){
+ mDragBoostPossible = 1;
+ break;
+ }
+ }
+ }
+ }
+ if (mDragBoostPossible == 1) {
+ if (mPerf == null){
+ mPerf = new BoostFramework();
+ }
+ if(mPerfLockDuration == -1){
+ mPerfLockDuration = getResources().getInteger(
+ com.android.internal.R.integer.ascrollboost_timeout);
+ mAsParamVal = getResources().getIntArray(
+ com.android.internal.R.array.ascrollboost_param_value);
+ }
+ mPerf.perfLockAcquireTouch(ev,
+ getResources().getDisplayMetrics(),
+ mPerfLockDuration, mAsParamVal);
+ }
+
if (ev.getAction() == MotionEvent.ACTION_DOWN) {
onUserInteraction();
}
diff --git a/core/java/android/util/BoostFramework.java b/core/java/android/util/BoostFramework.java
new file mode 100644
index 0000000..badbda5
--- /dev/null
+++ b/core/java/android/util/BoostFramework.java
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2015, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package android.util;
+
+import android.util.Log;
+import dalvik.system.PathClassLoader;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.lang.System;
+import android.view.MotionEvent;
+import android.util.DisplayMetrics;
+
+/** @hide */
+public class BoostFramework {
+
+ private static final String TAG = "BoostFramework";
+ private static final String PERFORMANCE_JAR = "/system/framework/QPerformance.jar";
+ private static final String PERFORMANCE_CLASS = "com.qualcomm.qti.Performance";
+
+/** @hide */
+ private static boolean mIsLoaded = false;
+ private static Method mAcquireFunc = null;
+ private static Method mReleaseFunc = null;
+ private static Method mAcquireTouchFunc = null;
+ private static Constructor<Class> mConstructor = null;
+
+/** @hide */
+ private Object mPerf = null;
+
+/** @hide */
+ public BoostFramework() {
+
+ if (mIsLoaded == false) {
+ try {
+ Class perfClass;
+ PathClassLoader perfClassLoader;
+
+ perfClassLoader = new PathClassLoader(PERFORMANCE_JAR,
+ ClassLoader.getSystemClassLoader());
+ perfClass = perfClassLoader.loadClass(PERFORMANCE_CLASS);
+ mConstructor = perfClass.getConstructor();
+
+ Class[] argClasses = new Class[] {int.class, int[].class};
+ mAcquireFunc = perfClass.getDeclaredMethod("perfLockAcquire", argClasses);
+ Log.v(TAG,"mAcquireFunc method = " + mAcquireFunc);
+
+ argClasses = new Class[] {};
+ mReleaseFunc = perfClass.getDeclaredMethod("perfLockRelease", argClasses);
+ Log.v(TAG,"mReleaseFunc method = " + mReleaseFunc);
+
+ argClasses = new Class[] {MotionEvent.class, DisplayMetrics.class, int.class, int[].class};
+ mAcquireTouchFunc = perfClass.getDeclaredMethod("perfLockAcquireTouch", argClasses);
+ Log.v(TAG,"mAcquireTouchFunc method = " + mAcquireTouchFunc);
+
+ mIsLoaded = true;
+ }
+ catch(Exception e) {
+ Log.e(TAG,"BoostFramework() : Exception_1 = " + e);
+ }
+ }
+
+ try {
+ if (mConstructor != null) {
+ mPerf = mConstructor.newInstance();
+ }
+ }
+ catch(Exception e) {
+ Log.e(TAG,"BoostFramework() : Exception_2 = " + e);
+ }
+
+ Log.v(TAG,"BoostFramework() : mPerf = " + mPerf);
+ }
+
+/** @hide */
+/* private static void loadNative() {
+ if(!isLoaded){
+ //System.loadLibrary("perf_jni");
+ System.loadLibrary("qti_performance");
+ isLoaded=true;
+ }
+ return;
+ }
+*/
+
+/** @hide */
+ public int perfLockAcquire(int duration, int... list) {
+ int ret = -1;
+ try {
+ Object retVal = mAcquireFunc.invoke(mPerf, duration, list);
+ ret = (int)retVal;
+ } catch(Exception e) {
+ Log.e(TAG,"Exception " + e);
+ }
+ return ret;
+ }
+
+/** @hide */
+ public int perfLockRelease() {
+ int ret = -1;
+ try {
+ Object retVal = mReleaseFunc.invoke(mPerf);
+ ret = (int)retVal;
+ } catch(Exception e) {
+ Log.e(TAG,"Exception " + e);
+ }
+ return ret;
+ }
+/** @hide */
+ public int perfLockAcquireTouch(MotionEvent ev, DisplayMetrics metrics,
+ int duration, int... list) {
+ int ret = -1;
+ try {
+ Object retVal = mAcquireTouchFunc.invoke(mPerf, ev, metrics, duration, list);
+ ret = (int)retVal;
+ } catch(Exception e) {
+ Log.e(TAG,"Exception " + e);
+ }
+ return ret;
+ }
+
+};
diff --git a/core/java/android/widget/OverScroller.java b/core/java/android/widget/OverScroller.java
index 50569d7..4cb1514 100644
--- a/core/java/android/widget/OverScroller.java
+++ b/core/java/android/widget/OverScroller.java
@@ -22,6 +22,7 @@ import android.util.Log;
import android.view.ViewConfiguration;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
+import android.util.BoostFramework;
/**
* This class encapsulates scrolling with the ability to overshoot the bounds
@@ -599,6 +600,17 @@ public class OverScroller {
private static final int CUBIC = 1;
private static final int BALLISTIC = 2;
+ /*
+ * Perf boost related variables
+ * Enabled/Disabled using config_enableCpuBoostForOverScrollerFling
+ * true value turns it on, by default will be turned off
+ */
+ private BoostFramework mPerf = null;
+ private boolean mIsPerfLockAcquired = false;
+ private boolean mIsPerfBoostEnabled = false;
+ private int fBoostTimeOut = 0;
+ private int fBoostParamVal[];
+
static {
float x_min = 0.0f;
float y_min = 0.0f;
@@ -643,6 +655,15 @@ public class OverScroller {
* 39.37f // inch/meter
* ppi
* 0.84f; // look and feel tuning
+
+ mIsPerfBoostEnabled = context.getResources().getBoolean(
+ com.android.internal.R.bool.config_enableCpuBoostForOverScrollerFling);
+ if (mIsPerfBoostEnabled) {
+ fBoostTimeOut = context.getResources().getInteger(
+ com.android.internal.R.integer.flingboost_timeout_param);
+ fBoostParamVal = context.getResources().getIntArray(
+ com.android.internal.R.array.flingboost_param_value);
+ }
}
void updateScroll(float q) {
@@ -690,6 +711,11 @@ public class OverScroller {
}
void finish() {
+ if (mIsPerfLockAcquired && mPerf != null) {
+ mPerf.perfLockRelease();
+ mIsPerfLockAcquired = false;
+ }
+
mCurrentPosition = mFinal;
// Not reset since WebView relies on this value for fast fling.
// TODO: restore when WebView uses the fast fling implemented in this class.
@@ -760,6 +786,17 @@ public class OverScroller {
if (velocity != 0) {
mDuration = mSplineDuration = getSplineFlingDuration(velocity);
totalDistance = getSplineFlingDistance(velocity);
+ if (mPerf == null && mIsPerfBoostEnabled) {
+ mPerf = new BoostFramework();
+ }
+
+ if (mPerf != null) {
+ mIsPerfLockAcquired = true;
+ if (0 == fBoostTimeOut) {
+ fBoostTimeOut = mDuration;
+ }
+ mPerf.perfLockAcquire(fBoostTimeOut, fBoostParamVal);
+ }
}
mSplineDistance = (int) (totalDistance * Math.signum(velocity));
diff --git a/core/java/android/widget/Scroller.java b/core/java/android/widget/Scroller.java
index 357c9c3..96e6b9d 100644
--- a/core/java/android/widget/Scroller.java
+++ b/core/java/android/widget/Scroller.java
@@ -22,6 +22,7 @@ import android.os.Build;
import android.view.ViewConfiguration;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
+import android.util.BoostFramework;
/**
@@ -108,6 +109,16 @@ public class Scroller {
private float mDeceleration;
private final float mPpi;
+ /*
+ * Perf boost related variables
+ * Enabled/Disabled using config_enableCpuBoostForScroller
+ * true value turns it on, by default will be turned off
+ */
+ private BoostFramework mPerf = null;
+ boolean bIsPerfBoostEnabled = false;
+ private int sBoostTimeOut = 0;
+ private int sBoostParamVal[];
+
// A context-specific coefficient adjusted to physical values.
private float mPhysicalCoeff;
@@ -167,6 +178,7 @@ public class Scroller {
* not to support progressive "flywheel" behavior in flinging.
*/
public Scroller(Context context, Interpolator interpolator, boolean flywheel) {
+ boolean bIsPerfBoostEnabled = false;
mFinished = true;
if (interpolator == null) {
mInterpolator = new ViscousFluidInterpolator();
@@ -178,6 +190,18 @@ public class Scroller {
mFlywheel = flywheel;
mPhysicalCoeff = computeDeceleration(0.84f); // look and feel tuning
+ bIsPerfBoostEnabled = context.getResources().getBoolean(
+ com.android.internal.R.bool.config_enableCpuBoostForScroller);
+ if (bIsPerfBoostEnabled) {
+ sBoostTimeOut = context.getResources().getInteger(
+ com.android.internal.R.integer.scrollboost_timeout_param);
+ sBoostParamVal = context.getResources().getIntArray(
+ com.android.internal.R.array.scrollboost_param_value);
+ }
+ if (mPerf == null && bIsPerfBoostEnabled) {
+ mPerf = new BoostFramework();
+ }
+
}
/**
@@ -395,6 +419,13 @@ public class Scroller {
mDeltaX = dx;
mDeltaY = dy;
mDurationReciprocal = 1.0f / (float) mDuration;
+
+ if ((mPerf != null) && (duration != 0)) {
+ if (0 == sBoostTimeOut) {
+ sBoostTimeOut = mDuration;
+ }
+ mPerf.perfLockAcquire(sBoostTimeOut, sBoostParamVal);
+ }
}
/**