Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.qualcomm.qti;
- import android.util.DisplayMetrics;
- import android.view.MotionEvent;
- import android.view.VelocityTracker;
- public class Performance {
- public static final int ALL_CPUS_PC_DIS = 257;
- public static final int ALL_CPUS_PWR_CLPS_DIS = 256;
- public static final int CPU0_FREQ_NONTURBO_MAX = 522;
- public static final int CPU0_FREQ_TURBO_MAX = 766;
- public static final int CPU0_MAX_FREQ_NONTURBO_MAX = 5386;
- public static final int CPU1_FREQ_NONTURBO_MAX = 778;
- public static final int CPU1_FREQ_TURBO_MAX = 1022;
- public static final int CPU1_MAX_FREQ_NONTURBO_MAX = 5642;
- public static final int CPU2_FREQ_NONTURBO_MAX = 1034;
- public static final int CPU2_FREQ_TURBO_MAX = 1278;
- public static final int CPU2_MAX_FREQ_NONTURBO_MAX = 5898;
- public static final int CPU3_FREQ_NONTURBO_MAX = 1290;
- public static final int CPU3_FREQ_TURBO_MAX = 1534;
- public static final int CPU3_MAX_FREQ_NONTURBO_MAX = 6154;
- public static final int CPUS_ON_2 = 1794;
- public static final int CPUS_ON_3 = 1795;
- public static final int CPUS_ON_LIMIT_1 = 2302;
- public static final int CPUS_ON_LIMIT_2 = 2301;
- public static final int CPUS_ON_LIMIT_3 = 2300;
- public static final int CPUS_ON_MAX = 2047;
- public static final int REQUEST_FAILED = -1;
- public static final int REQUEST_SUCCEEDED = 0;
- public static final int SCHED_MIGRATE_COST = 16129;
- public static final int SCHED_PREFER_IDLE = 15873;
- private static final String TAG = "Perf";
- private static boolean isFlingEnabled = false;
- private static TouchInfo mTouchInfo = null;
- private static VelocityTracker mVelocityTracker = null;
- private int handle = REQUEST_SUCCEEDED;
- private int mDivFact = 6;
- private int mHDragPix = 12;
- private int mMaxVelocity = 24000;
- private int mMinVelocity = 150;
- private int mWDragPix = 12;
- class TouchInfo {
- private int mCurX = Performance.REQUEST_SUCCEEDED;
- private int mCurY = Performance.REQUEST_SUCCEEDED;
- private int mMinDragH = Performance.REQUEST_SUCCEEDED;
- private int mMinDragW = Performance.REQUEST_SUCCEEDED;
- private int mStartX = Performance.REQUEST_SUCCEEDED;
- private int mStartY = Performance.REQUEST_SUCCEEDED;
- TouchInfo() {
- }
- private void reset() {
- this.mCurY = Performance.REQUEST_SUCCEEDED;
- this.mCurX = Performance.REQUEST_SUCCEEDED;
- this.mStartY = Performance.REQUEST_SUCCEEDED;
- this.mStartX = Performance.REQUEST_SUCCEEDED;
- this.mMinDragW = Performance.REQUEST_SUCCEEDED;
- this.mMinDragH = Performance.REQUEST_SUCCEEDED;
- Performance.isFlingEnabled = false;
- }
- private void setXY(int dx, int dy) {
- this.mCurX = dx;
- this.mCurY = dy;
- }
- private void setDragWH(int dw, int dh) {
- this.mMinDragW = dw;
- this.mMinDragH = dh;
- }
- private void setStartXY(int dx, int dy) {
- this.mCurX = dx;
- this.mStartX = dx;
- this.mCurY = dy;
- this.mStartY = dy;
- }
- }
- private native int native_cpu_setoptions(int i, int i2);
- private native void native_deinit();
- private native int native_perf_io_prefetch_start(int i, String str);
- private native int native_perf_io_prefetch_stop();
- private native int native_perf_lock_acq(int i, int i2, int[] iArr);
- private native int native_perf_lock_rel(int i);
- static {
- try {
- System.loadLibrary("qti_performance");
- } catch (UnsatisfiedLinkError e) {
- }
- }
- public int perfLockAcquire(int duration, int... list) {
- this.handle = native_perf_lock_acq(this.handle, duration, list);
- if (this.handle == 0) {
- return REQUEST_FAILED;
- }
- return REQUEST_SUCCEEDED;
- }
- public int perfLockAcquireTouch(MotionEvent ev, DisplayMetrics metrics, int duration, int... list) {
- int actionMasked = ev.getActionMasked();
- int pointerIndex = ev.getActionIndex();
- int pointerId = ev.getPointerId(pointerIndex);
- int y = (int) ev.getY(pointerIndex);
- int dx = (int) ((((float) ((int) ev.getX(pointerIndex))) * 1.0f) / metrics.density);
- int dy = (int) ((((float) y) * 1.0f) / metrics.density);
- boolean isBoostRequired = false;
- int xdiff;
- int ydiff;
- switch (actionMasked) {
- case REQUEST_SUCCEEDED /*0*/:
- if (mVelocityTracker == null) {
- mVelocityTracker = VelocityTracker.obtain();
- } else {
- mVelocityTracker.clear();
- }
- if (mVelocityTracker != null) {
- mVelocityTracker.addMovement(ev);
- }
- if (mTouchInfo == null) {
- mTouchInfo = new TouchInfo();
- }
- if (mTouchInfo != null) {
- mTouchInfo.reset();
- mTouchInfo.setStartXY(dx, dy);
- float f = (float) this.mWDragPix;
- int i = (int) ((r0 * 1.0f) / metrics.density);
- float f2 = (float) this.mHDragPix;
- mTouchInfo.setDragWH(r0, (int) ((r0 * 1.0f) / metrics.density));
- break;
- }
- break;
- case 1:
- if (mVelocityTracker != null) {
- mVelocityTracker.addMovement(ev);
- mVelocityTracker.computeCurrentVelocity(1000, (float) this.mMaxVelocity);
- int initialVelocity = Math.abs((int) mVelocityTracker.getYVelocity(pointerId));
- if (initialVelocity > this.mMinVelocity) {
- duration = (int) (((float) duration) * ((((float) initialVelocity) * 1.0f) / (((float) this.mMinVelocity) * 1.0f)));
- isBoostRequired = true;
- break;
- }
- }
- if (mTouchInfo != null) {
- xdiff = Math.abs(dx - mTouchInfo.mCurX);
- ydiff = Math.abs(dy - mTouchInfo.mCurY);
- if (xdiff > mTouchInfo.mMinDragW || ydiff > mTouchInfo.mMinDragH) {
- isBoostRequired = true;
- break;
- }
- }
- break;
- case 2:
- if (mVelocityTracker != null) {
- mVelocityTracker.addMovement(ev);
- }
- if (mTouchInfo != null) {
- xdiff = Math.abs(dx - mTouchInfo.mCurX);
- ydiff = Math.abs(dy - mTouchInfo.mCurY);
- mTouchInfo.setXY(dx, dy);
- if (xdiff > mTouchInfo.mMinDragW || ydiff > mTouchInfo.mMinDragH) {
- isBoostRequired = true;
- break;
- }
- }
- break;
- case 3:
- if (mTouchInfo != null) {
- mTouchInfo.reset();
- break;
- }
- break;
- }
- if (!isBoostRequired) {
- return REQUEST_FAILED;
- }
- this.handle = native_perf_lock_acq(this.handle, duration, list);
- if (this.handle != 0) {
- return REQUEST_SUCCEEDED;
- }
- return REQUEST_FAILED;
- }
- public int perfLockRelease() {
- return native_perf_lock_rel(this.handle);
- }
- public int perfIOPrefetchStart(int PId, String Pkg_name) {
- return native_perf_io_prefetch_start(PId, Pkg_name);
- }
- public int perfIOPrefetchStop() {
- return native_perf_io_prefetch_stop();
- }
- protected void finalize() {
- native_deinit();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment