summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShashi Shekar Shankar <ssbang@codeaurora.org>2015-07-20 14:35:50 +0530
committerLinux Build Service Account <lnxbuild@localhost>2015-10-06 03:27:24 -0600
commit0c3a49a56f827e16d038542b0a81c0e257787995 (patch)
tree3a761517bbf210036cd19411679bedac14656d34
parenta0c043c88b0abaf53b9b08b5c85776f629a52002 (diff)
downloadframeworks_base-0c3a49a56f827e16d038542b0a81c0e257787995.zip
frameworks_base-0c3a49a56f827e16d038542b0a81c0e257787995.tar.gz
frameworks_base-0c3a49a56f827e16d038542b0a81c0e257787995.tar.bz2
BoostFramework to enchance performance during critical scenarios
Adding Boost APIs which can ensure the best possible resource availability during critical UX scenarios. These APIs can be either turned off or dynamically hooked to OEM specific performance optimizations Change-Id: Ib1be2400c2c3d2eab9a41667354667557e36605f
-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
-rwxr-xr-xcore/res/res/values/config.xml30
-rwxr-xr-xcore/res/res/values/symbols.xml30
-rw-r--r--services/core/java/com/android/server/am/ActivityStack.java22
-rw-r--r--services/core/java/com/android/server/am/ActivityStackSupervisor.java47
8 files changed, 378 insertions, 1 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);
+ }
}
/**
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 8c31809..db2bd10 100755
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -2276,4 +2276,34 @@
<string-array name="config_cell_retries_per_error_code">
</string-array>
+ <!-- Whether cpu boost is enabled for AppLaunch -->
+ <bool name="config_enableCpuBoostForAppLaunch">false</bool>
+ <integer name="disablepacking_timeout_param">0</integer>
+ <integer-array name="launchboost_packing_param_value"/>
+ <integer name="launchboost_timeout_param">0</integer>
+ <integer-array name="launchboost_param_value"/>
+
+ <!-- Whether cpu boost is enabled for animation. -->
+ <bool name="config_enablePerfBoostForAnimation">false</bool>
+ <integer name="animationboost_timeout_param">0</integer>
+ <integer-array name="animationboost_param_value"/>
+
+ <!-- Whether cpu boost is enabled for overscroller fling. -->
+ <bool name="config_enableCpuBoostForOverScrollerFling">false</bool>
+ <integer name="flingboost_timeout_param">0</integer>
+ <integer-array name="flingboost_param_value"/>
+
+ <!-- Whether cpu boost is enabled for horizontal scroll. -->
+ <bool name="config_enableCpuBoostForScroller">false</bool>
+ <integer name="scrollboost_timeout_param">0</integer>
+ <integer-array name="scrollboost_param_value"/>
+
+ <!-- Activities list for boost -->
+ <string-array translatable="false" name="boost_activityList">
+ </string-array>
+
+ <!-- Activity scroll boost params -->
+ <integer name="ascrollboost_timeout">0</integer>
+ <integer-array name="ascrollboost_param_value"/>
+
</resources>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index d00684f..da68b8e 100755
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2327,4 +2327,34 @@
<!-- config softap extention feature -->
<java-symbol type="bool" name="config_softap_extention" />
+
+ <!-- cpu boost for AppLaunch -->
+ <java-symbol type="bool" name="config_enableCpuBoostForAppLaunch" />
+ <java-symbol type="integer" name="disablepacking_timeout_param" />
+ <java-symbol type="array" name="launchboost_packing_param_value"/>
+ <java-symbol type="integer" name="launchboost_timeout_param" />
+ <java-symbol type="array" name="launchboost_param_value" />
+
+ <!-- cpu boost for Animationboost -->
+ <java-symbol type="bool" name="config_enablePerfBoostForAnimation" />
+ <java-symbol type="integer" name="animationboost_timeout_param" />
+ <java-symbol type="array" name="animationboost_param_value" />
+
+ <!-- cpu boost for overscroller fling -->
+ <java-symbol type="bool" name="config_enableCpuBoostForOverScrollerFling" />
+ <java-symbol type="integer" name="flingboost_timeout_param" />
+ <java-symbol type="array" name="flingboost_param_value" />
+
+ <!-- cpu boost for horizontal scroll -->
+ <java-symbol type="bool" name="config_enableCpuBoostForScroller" />
+ <java-symbol type="integer" name="scrollboost_timeout_param" />
+ <java-symbol type="array" name="scrollboost_param_value" />
+
+ <!-- Activities list for boost -->
+ <java-symbol type="array" name="boost_activityList" />
+
+ <!-- Activity scroll boost params -->
+ <java-symbol type="integer" name="ascrollboost_timeout" />
+ <java-symbol type="array" name="ascrollboost_param_value" />
+
</resources>
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 6e34876..ee301de 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -66,6 +66,7 @@ import android.service.voice.IVoiceInteractionSession;
import android.util.EventLog;
import android.util.Slog;
import android.view.Display;
+import android.util.BoostFramework;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -151,6 +152,10 @@ final class ActivityStack {
final WindowManagerService mWindowManager;
private final RecentTasks mRecentTasks;
+ public BoostFramework mPerf = null;
+ public boolean mIsAnimationBoostEnabled = false;
+ public int aBoostTimeOut = 0;
+ public int aBoostParamVal[];
/**
* The back history of all previous (and possibly still
* running) activities. It contains #TaskRecord objects.
@@ -362,6 +367,14 @@ final class ActivityStack {
mCurrentUser = mService.mCurrentUserId;
mRecentTasks = recentTasks;
mOverrideConfig = Configuration.EMPTY;
+ mIsAnimationBoostEnabled = mService.mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_enablePerfBoostForAnimation);
+ if (mIsAnimationBoostEnabled) {
+ aBoostTimeOut = mService.mContext.getResources().getInteger(
+ com.android.internal.R.integer.animationboost_timeout_param);
+ aBoostParamVal = mService.mContext.getResources().getIntArray(
+ com.android.internal.R.array.animationboost_param_value);
+ }
}
boolean okToShowLocked(ActivityRecord r) {
@@ -1803,6 +1816,9 @@ final class ActivityStack {
// that the previous one will be hidden soon. This way it can know
// to ignore it when computing the desired screen orientation.
boolean anim = true;
+ if (mIsAnimationBoostEnabled == true && mPerf == null) {
+ mPerf = new BoostFramework();
+ }
if (prev != null) {
if (prev.finishing) {
if (DEBUG_TRANSITION) Slog.v(TAG_TRANSITION,
@@ -1814,6 +1830,9 @@ final class ActivityStack {
mWindowManager.prepareAppTransition(prev.task == next.task
? AppTransition.TRANSIT_ACTIVITY_CLOSE
: AppTransition.TRANSIT_TASK_CLOSE, false);
+ if(prev.task != next.task && mPerf != null) {
+ mPerf.perfLockAcquire(aBoostTimeOut, aBoostParamVal);
+ }
}
mWindowManager.setAppWillBeHidden(prev.appToken);
mWindowManager.setAppVisibility(prev.appToken, false);
@@ -1829,6 +1848,9 @@ final class ActivityStack {
: next.mLaunchTaskBehind
? AppTransition.TRANSIT_TASK_OPEN_BEHIND
: AppTransition.TRANSIT_TASK_OPEN, false);
+ if(prev.task != next.task && mPerf != null) {
+ mPerf.perfLockAcquire(aBoostTimeOut, aBoostParamVal);
+ }
}
}
if (false) {
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index 6d91309..89b6f2e 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -101,6 +101,7 @@ import android.util.ArraySet;
import android.util.EventLog;
import android.util.Slog;
import android.util.SparseArray;
+import android.util.BoostFramework;
import android.util.SparseIntArray;
import android.view.Display;
@@ -118,7 +119,6 @@ import com.android.server.LocalServices;
import com.android.server.am.ActivityStack.ActivityState;
import com.android.server.wm.WindowManagerService;
-
import java.io.FileDescriptor;
import java.io.IOException;
import java.io.PrintWriter;
@@ -161,6 +161,12 @@ public final class ActivityStackSupervisor implements DisplayListener {
static final int RESUME_TOP_ACTIVITY_MSG = FIRST_SUPERVISOR_STACK_MSG + 2;
static final int SLEEP_TIMEOUT_MSG = FIRST_SUPERVISOR_STACK_MSG + 3;
static final int LAUNCH_TIMEOUT_MSG = FIRST_SUPERVISOR_STACK_MSG + 4;
+ public BoostFramework mPerf = null;
+ public boolean mIsPerfBoostEnabled = false;
+ public int lBoostTimeOut = 0;
+ public int lDisPackTimeOut = 0;
+ public int lBoostCpuParamVal[];
+ public int lBoostPackParamVal[];
static final int HANDLE_DISPLAY_ADDED = FIRST_SUPERVISOR_STACK_MSG + 5;
static final int HANDLE_DISPLAY_CHANGED = FIRST_SUPERVISOR_STACK_MSG + 6;
static final int HANDLE_DISPLAY_REMOVED = FIRST_SUPERVISOR_STACK_MSG + 7;
@@ -342,6 +348,19 @@ public final class ActivityStackSupervisor implements DisplayListener {
mService = service;
mRecentTasks = recentTasks;
mHandler = new ActivityStackSupervisorHandler(mService.mHandler.getLooper());
+ /* Is perf lock for cpu-boost enabled during App 1st launch */
+ mIsPerfBoostEnabled = mService.mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_enableCpuBoostForAppLaunch);
+ if(mIsPerfBoostEnabled) {
+ lBoostTimeOut = mService.mContext.getResources().getInteger(
+ com.android.internal.R.integer.launchboost_timeout_param);
+ lDisPackTimeOut = mService.mContext.getResources().getInteger(
+ com.android.internal.R.integer.disablepacking_timeout_param);
+ lBoostCpuParamVal = mService.mContext.getResources().getIntArray(
+ com.android.internal.R.array.launchboost_param_value);
+ lBoostPackParamVal = mService.mContext.getResources().getIntArray(
+ com.android.internal.R.array.launchboost_packing_param_value);
+ }
}
/**
@@ -2769,6 +2788,14 @@ public final class ActivityStackSupervisor implements DisplayListener {
}
void findTaskToMoveToFrontLocked(TaskRecord task, int flags, Bundle options, String reason) {
+
+ ActivityRecord top_activity;
+ top_activity = task.stack.topRunningActivityLocked(null);
+ /* App is launching from recent apps and it's a new process */
+ if(top_activity != null && top_activity.state == ActivityState.DESTROYED) {
+ acquireAppLaunchPerfLock();
+ }
+
if ((flags & ActivityManager.MOVE_TASK_NO_USER_ACTION) == 0) {
mUserLeaving = true;
}
@@ -3033,6 +3060,17 @@ public final class ActivityStackSupervisor implements DisplayListener {
resumeTopActivitiesLocked();
}
+ void acquireAppLaunchPerfLock() {
+ /* Acquire perf lock during new app launch */
+ if (mIsPerfBoostEnabled == true && mPerf == null) {
+ mPerf = new BoostFramework();
+ }
+ if (mPerf != null) {
+ mPerf.perfLockAcquire(lDisPackTimeOut, lBoostPackParamVal);
+ mPerf.perfLockAcquire(lBoostTimeOut, lBoostCpuParamVal);
+ }
+ }
+
ActivityRecord findTaskLocked(ActivityRecord r) {
if (DEBUG_TASKS) Slog.d(TAG_TASKS, "Looking for task of " + r);
for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) {
@@ -3050,10 +3088,17 @@ public final class ActivityStackSupervisor implements DisplayListener {
}
final ActivityRecord ar = stack.findTaskLocked(r);
if (ar != null) {
+ if(ar.state == ActivityState.DESTROYED ) {
+ /*It's a new app launch */
+ acquireAppLaunchPerfLock();
+ }
return ar;
}
}
}
+ /* Acquire perf lock during new app launch */
+ acquireAppLaunchPerfLock();
+
if (DEBUG_TASKS) Slog.d(TAG_TASKS, "No task found");
return null;
}