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

Commit 42b8594d authored by Zhao Wei Liew's avatar Zhao Wei Liew Committed by Steve Kondik
Browse files

core: Remove QCOM BoostFramework and ActivityTrigger

These rely on a bunch of proprietary libs that not
all devices support. CM has its own boosting solution
anyway, rendering these additions unnecessary.

One small, but important change has been omitted from the revert,
that is the addition of ro.sys.fw.bg_apps_limit in the file
services/core/java/com/android/server/am/ProcessList.java.

This reverts the following commits:
c35293c3 Framework for LaunchBoost v2 and Frequency aggr during launch.
91338fb3 frameworks: Add custom boost for scroll/fling
911884e1 Perf: Adding hooks for IO prefetcher into framework
f56206d6 BoostFramework to enhance performance during critical scenarios
d841ef62 add network related API into ActivityTrigger
2f1b2812 Set animation scale values for specific activity.
4ea9a4ec frameworks/base: activity pause/stop event triggers
015851c6 frameworks/base: Tap process start event to trigger perf lib.
e14378bf frameworks/base: Add support for low resolution rendering
4d9ec135 ActivityTrigger: New class to invoke when activity starts/resumes

Change-Id: Iafdc3866c39d4e0d51ca2d40931ea9a5baba7de5
parent 6b80bafe
Loading
Loading
Loading
Loading
+0 −41
Original line number Diff line number Diff line
@@ -127,7 +127,6 @@ 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
@@ -690,10 +689,6 @@ public class Activity extends ContextThemeWrapper
        OnCreateContextMenuListener, ComponentCallbacks2,
        Window.OnWindowDismissedCallback, WindowControllerCallback {
    private static final String TAG = "Activity";
    private static BoostFramework mPerf = null;
    private static int mDragBoostPossible = -1;
    private static int mPerfLockDuration = -1;
    private static int mAsParamVal[];
    private static final boolean DEBUG_LIFECYCLE = false;

    /** Standard activity result: operation canceled. */
@@ -3060,42 +3055,6 @@ 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;
                    }
                }
            }
        }

       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();
            }
            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();
        }
+0 −12
Original line number Diff line number Diff line
@@ -541,13 +541,6 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
     */
    public int privateFlags;

    /**
     * Boolean indicating whether the resolution of the SurfaceView associated
     * with this appplication can be overriden.
     * {@hide}
     */
    public int overrideRes = 0;

    /**
     * The required smallest screen width the application can run on.  If 0,
     * nothing has been specified.  Comes from
@@ -911,7 +904,6 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        theme = orig.theme;
        flags = orig.flags;
        privateFlags = orig.privateFlags;
        overrideRes = orig.overrideRes;
        requiresSmallestWidthDp = orig.requiresSmallestWidthDp;
        compatibleWidthLimitDp = orig.compatibleWidthLimitDp;
        largestWidthLimitDp = orig.largestWidthLimitDp;
@@ -969,7 +961,6 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        dest.writeInt(theme);
        dest.writeInt(flags);
        dest.writeInt(privateFlags);
        dest.writeInt(overrideRes);
        dest.writeInt(requiresSmallestWidthDp);
        dest.writeInt(compatibleWidthLimitDp);
        dest.writeInt(largestWidthLimitDp);
@@ -1027,7 +1018,6 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
        theme = source.readInt();
        flags = source.readInt();
        privateFlags = source.readInt();
        overrideRes = source.readInt();
        requiresSmallestWidthDp = source.readInt();
        compatibleWidthLimitDp = source.readInt();
        largestWidthLimitDp = source.readInt();
@@ -1234,7 +1224,6 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
    /** {@hide} */ public void setResourcePath(String resourcePath) { scanPublicSourceDir = resourcePath; }
    /** {@hide} */ public void setBaseResourcePath(String baseResourcePath) { publicSourceDir = baseResourcePath; }
    /** {@hide} */ public void setSplitResourcePaths(String[] splitResourcePaths) { splitPublicSourceDirs = splitResourcePaths; }
    /** {@hide} */ public void setOverrideRes(int overrideResolution) { overrideRes = overrideResolution; }

    /** {@hide} */ public String getCodePath() { return scanSourceDir; }
    /** {@hide} */ public String getBaseCodePath() { return sourceDir; }
@@ -1242,5 +1231,4 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
    /** {@hide} */ public String getResourcePath() { return scanPublicSourceDir; }
    /** {@hide} */ public String getBaseResourcePath() { return publicSourceDir; }
    /** {@hide} */ public String[] getSplitResourcePaths() { return splitSourceDirs; }
    /** {@hide} */ public int canOverrideRes() { return overrideRes; }
}
+0 −252
Original line number Diff line number Diff line
/*
 * 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;
import android.os.SystemProperties;
import android.content.Context;

/** @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 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;

/** @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);

                argClasses = new Class[] {int.class, String.class};
                mIOPStart =  perfClass.getDeclaredMethod("perfIOPrefetchStart", argClasses);
                Log.v(TAG,"mIOPStart method = " + mIOPStart);

                argClasses = new Class[] {};
                mIOPStop =  perfClass.getDeclaredMethod("perfIOPrefetchStop", argClasses);
                Log.v(TAG,"mIOPStop method = " + mIOPStop);

                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 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) {
        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;
    }

/** @hide */
    public int perfIOPrefetchStart(int pid, String pkg_name)
    {
        int ret = -1;
        try {
            Object retVal = mIOPStart.invoke(mPerf,pid,pkg_name);
            ret = (int)retVal;
        } catch(Exception e) {
            Log.e(TAG,"Exception " + e);
        }
        return ret;
    }

/** @hide */
    public int perfIOPrefetchStop()
    {
        int ret = -1;
         try {
             Object retVal = mIOPStop.invoke(mPerf);
             ret = (int)retVal;
         } catch(Exception e) {
             Log.e(TAG,"Exception " + e);
         }
         return ret;
    }

};
+0 −143
Original line number Diff line number Diff line
/* Copyright (c) 2015-2016 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.content.ComponentName;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.Matrix;
import android.os.SystemProperties;
import android.util.Log;
import android.view.MotionEvent;
import android.view.SurfaceView;
import android.view.View;

/** @hide */
public class ResolutionOverride {
    /** @hide */
    static private final boolean DEBUG = false;
    static private final String TAG = "ResolutionOverride";
    private static final String RES_OVERRIDE = "persist.debug.app_res_override";
    private boolean mIsEnabled = false;
    private int mOverrideXres = 0;
    private int mOverrideYres = 0;

    /** @hide */
    public ResolutionOverride(SurfaceView view) {
        boolean enable = (view.getContext().getApplicationInfo().canOverrideRes() == 1);
        String resStr = SystemProperties.get(RES_OVERRIDE, null);

        if (!enable || resStr == null || resStr.length() == 0 ||
                view.getResources() == null) {
            return;
        }

        int orientation = view.getResources().getConfiguration().orientation;

        if(orientation == Configuration.ORIENTATION_PORTRAIT ||
                orientation == Configuration.ORIENTATION_LANDSCAPE) {
            resStr = resStr.toLowerCase();
            final int pos = resStr.indexOf('x');
            if (pos > 0 && resStr.lastIndexOf('x') == pos) {
                try {
                    mOverrideXres = Integer.parseInt(resStr.substring(0, pos));
                    mOverrideYres = Integer.parseInt(resStr.substring(pos + 1));
                } catch (NumberFormatException ex) {
                    Log.e(TAG, "Error in extracting the overriding xres and yres");
                }
            }

            if(orientation == Configuration.ORIENTATION_LANDSCAPE) {
                int tmp = mOverrideXres;
                mOverrideXres = mOverrideYres;
                mOverrideYres = tmp;
            }

            if(mOverrideXres > 0 && mOverrideYres > 0) {
                mIsEnabled = true;
                if (DEBUG) Log.i(TAG, "Orientation: " + orientation +
                        " Overriding resolution to" + " xres: " + mOverrideXres
                        + " yres: " + mOverrideYres);
            }
        }
    }

    /** @hide */
    public void setFixedSize(SurfaceView view) {
        if(!mIsEnabled) {
            return;
        }

        view.getHolder().setFixedSize(mOverrideXres, mOverrideYres);
    }

    /** @hide */
    public void handleTouch(SurfaceView view, MotionEvent ev) {
        if(!mIsEnabled) {
            return;
        }

        Matrix matrix = new Matrix();
        //mOverride{Xres, Yres} are already swapped if orientation is landscape
        float xscale = (mOverrideXres * 1.0f) / view.getWidth();
        float yscale = (mOverrideYres * 1.0f) / view.getHeight();

        if (DEBUG) Log.i(TAG, "Before overriding the touch event x/y : " + ev);
        matrix.postScale(xscale, yscale);
        ev.transform(matrix);
        if (DEBUG) Log.i(TAG, "After overriding the touch event x/y : " + ev);
    }

    /** @hide */
    public void handleResize(final SurfaceView surfaceView) {
        if(!mIsEnabled) {
            return;
        }

        /* Change the visibility to GONE and back to VISIBLE and post it
         * on the main thread for the touch events to be effective on the
         * changed SurfaceView with the new dimensions
         */
        surfaceView.post(new Runnable() {
            @Override
            public void run() {
                surfaceView.setVisibility(View.GONE);
            }
        });

        surfaceView.postDelayed(new Runnable() {
            @Override
            public void run() {
                surfaceView.setVisibility(View.VISIBLE);
            }
        }, 100);
    }
};
+1 −18
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ import android.os.SystemClock;
import android.os.ParcelFileDescriptor;
import android.util.AttributeSet;
import android.util.Log;
import android.util.ResolutionOverride;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
@@ -190,7 +189,6 @@ public class SurfaceView extends View {
    private Translator mTranslator;
    private int mWindowInsetLeft;
    private int mWindowInsetTop;
    ResolutionOverride mResolutionOverride = null;

    private boolean mGlobalListenersAdded;

@@ -216,8 +214,6 @@ public class SurfaceView extends View {

    private void init() {
        setWillNotDraw(true);
        mResolutionOverride = new ResolutionOverride(this);
        mResolutionOverride.setFixedSize(this);
    }

    /**
@@ -310,16 +306,6 @@ public class SurfaceView extends View {
        setMeasuredDimension(width, height);
    }

    /**
     * Transforms the touch events to the new resolution coordinate system
     * if the resolution has changed
     */
    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        mResolutionOverride.handleTouch(this, ev);
        return super.dispatchTouchEvent(ev);
    }

    /** @hide */
    @Override
    protected boolean setFrame(int left, int top, int right, int bottom) {
@@ -823,13 +809,10 @@ public class SurfaceView extends View {
                Rect visibleInsets, Rect stableInsets, Rect outsets, boolean reportDraw,
                Configuration newConfig, Rect backDropRect, boolean forceLayout,
                boolean alwaysConsumeNavBar) {
            final SurfaceView surfaceView = mSurfaceView.get();
            SurfaceView surfaceView = mSurfaceView.get();
            if (surfaceView != null) {
                if (DEBUG) Log.v(TAG, surfaceView + " got resized: w=" + frame.width()
                        + " h=" + frame.height() + ", cur w=" + mCurWidth + " h=" + mCurHeight);

                surfaceView.mResolutionOverride.handleResize(surfaceView);

                surfaceView.mSurfaceLock.lock();
                try {
                    if (reportDraw) {
Loading