Guest User

Untitled

a guest
Aug 19th, 2017
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.70 KB | None | 0 0
  1. package com.qualcomm.qti;
  2.  
  3. import android.util.DisplayMetrics;
  4. import android.view.MotionEvent;
  5. import android.view.VelocityTracker;
  6.  
  7. public class Performance {
  8. public static final int ALL_CPUS_PC_DIS = 257;
  9. public static final int ALL_CPUS_PWR_CLPS_DIS = 256;
  10. public static final int CPU0_FREQ_NONTURBO_MAX = 522;
  11. public static final int CPU0_FREQ_TURBO_MAX = 766;
  12. public static final int CPU0_MAX_FREQ_NONTURBO_MAX = 5386;
  13. public static final int CPU1_FREQ_NONTURBO_MAX = 778;
  14. public static final int CPU1_FREQ_TURBO_MAX = 1022;
  15. public static final int CPU1_MAX_FREQ_NONTURBO_MAX = 5642;
  16. public static final int CPU2_FREQ_NONTURBO_MAX = 1034;
  17. public static final int CPU2_FREQ_TURBO_MAX = 1278;
  18. public static final int CPU2_MAX_FREQ_NONTURBO_MAX = 5898;
  19. public static final int CPU3_FREQ_NONTURBO_MAX = 1290;
  20. public static final int CPU3_FREQ_TURBO_MAX = 1534;
  21. public static final int CPU3_MAX_FREQ_NONTURBO_MAX = 6154;
  22. public static final int CPUS_ON_2 = 1794;
  23. public static final int CPUS_ON_3 = 1795;
  24. public static final int CPUS_ON_LIMIT_1 = 2302;
  25. public static final int CPUS_ON_LIMIT_2 = 2301;
  26. public static final int CPUS_ON_LIMIT_3 = 2300;
  27. public static final int CPUS_ON_MAX = 2047;
  28. public static final int REQUEST_FAILED = -1;
  29. public static final int REQUEST_SUCCEEDED = 0;
  30. public static final int SCHED_MIGRATE_COST = 16129;
  31. public static final int SCHED_PREFER_IDLE = 15873;
  32. private static final String TAG = "Perf";
  33. private static boolean isFlingEnabled = false;
  34. private static TouchInfo mTouchInfo = null;
  35. private static VelocityTracker mVelocityTracker = null;
  36. private int handle = REQUEST_SUCCEEDED;
  37. private int mDivFact = 6;
  38. private int mHDragPix = 12;
  39. private int mMaxVelocity = 24000;
  40. private int mMinVelocity = 150;
  41. private int mWDragPix = 12;
  42.  
  43. class TouchInfo {
  44. private int mCurX = Performance.REQUEST_SUCCEEDED;
  45. private int mCurY = Performance.REQUEST_SUCCEEDED;
  46. private int mMinDragH = Performance.REQUEST_SUCCEEDED;
  47. private int mMinDragW = Performance.REQUEST_SUCCEEDED;
  48. private int mStartX = Performance.REQUEST_SUCCEEDED;
  49. private int mStartY = Performance.REQUEST_SUCCEEDED;
  50.  
  51. TouchInfo() {
  52. }
  53.  
  54. private void reset() {
  55. this.mCurY = Performance.REQUEST_SUCCEEDED;
  56. this.mCurX = Performance.REQUEST_SUCCEEDED;
  57. this.mStartY = Performance.REQUEST_SUCCEEDED;
  58. this.mStartX = Performance.REQUEST_SUCCEEDED;
  59. this.mMinDragW = Performance.REQUEST_SUCCEEDED;
  60. this.mMinDragH = Performance.REQUEST_SUCCEEDED;
  61. Performance.isFlingEnabled = false;
  62. }
  63.  
  64. private void setXY(int dx, int dy) {
  65. this.mCurX = dx;
  66. this.mCurY = dy;
  67. }
  68.  
  69. private void setDragWH(int dw, int dh) {
  70. this.mMinDragW = dw;
  71. this.mMinDragH = dh;
  72. }
  73.  
  74. private void setStartXY(int dx, int dy) {
  75. this.mCurX = dx;
  76. this.mStartX = dx;
  77. this.mCurY = dy;
  78. this.mStartY = dy;
  79. }
  80. }
  81.  
  82. private native int native_cpu_setoptions(int i, int i2);
  83.  
  84. private native void native_deinit();
  85.  
  86. private native int native_perf_io_prefetch_start(int i, String str);
  87.  
  88. private native int native_perf_io_prefetch_stop();
  89.  
  90. private native int native_perf_lock_acq(int i, int i2, int[] iArr);
  91.  
  92. private native int native_perf_lock_rel(int i);
  93.  
  94. static {
  95. try {
  96. System.loadLibrary("qti_performance");
  97. } catch (UnsatisfiedLinkError e) {
  98. }
  99. }
  100.  
  101. public int perfLockAcquire(int duration, int... list) {
  102. this.handle = native_perf_lock_acq(this.handle, duration, list);
  103. if (this.handle == 0) {
  104. return REQUEST_FAILED;
  105. }
  106. return REQUEST_SUCCEEDED;
  107. }
  108.  
  109. public int perfLockAcquireTouch(MotionEvent ev, DisplayMetrics metrics, int duration, int... list) {
  110. int actionMasked = ev.getActionMasked();
  111. int pointerIndex = ev.getActionIndex();
  112. int pointerId = ev.getPointerId(pointerIndex);
  113. int y = (int) ev.getY(pointerIndex);
  114. int dx = (int) ((((float) ((int) ev.getX(pointerIndex))) * 1.0f) / metrics.density);
  115. int dy = (int) ((((float) y) * 1.0f) / metrics.density);
  116. boolean isBoostRequired = false;
  117. int xdiff;
  118. int ydiff;
  119. switch (actionMasked) {
  120. case REQUEST_SUCCEEDED /*0*/:
  121. if (mVelocityTracker == null) {
  122. mVelocityTracker = VelocityTracker.obtain();
  123. } else {
  124. mVelocityTracker.clear();
  125. }
  126. if (mVelocityTracker != null) {
  127. mVelocityTracker.addMovement(ev);
  128. }
  129. if (mTouchInfo == null) {
  130. mTouchInfo = new TouchInfo();
  131. }
  132. if (mTouchInfo != null) {
  133. mTouchInfo.reset();
  134. mTouchInfo.setStartXY(dx, dy);
  135. float f = (float) this.mWDragPix;
  136. int i = (int) ((r0 * 1.0f) / metrics.density);
  137. float f2 = (float) this.mHDragPix;
  138. mTouchInfo.setDragWH(r0, (int) ((r0 * 1.0f) / metrics.density));
  139. break;
  140. }
  141. break;
  142. case 1:
  143. if (mVelocityTracker != null) {
  144. mVelocityTracker.addMovement(ev);
  145. mVelocityTracker.computeCurrentVelocity(1000, (float) this.mMaxVelocity);
  146. int initialVelocity = Math.abs((int) mVelocityTracker.getYVelocity(pointerId));
  147. if (initialVelocity > this.mMinVelocity) {
  148. duration = (int) (((float) duration) * ((((float) initialVelocity) * 1.0f) / (((float) this.mMinVelocity) * 1.0f)));
  149. isBoostRequired = true;
  150. break;
  151. }
  152. }
  153. if (mTouchInfo != null) {
  154. xdiff = Math.abs(dx - mTouchInfo.mCurX);
  155. ydiff = Math.abs(dy - mTouchInfo.mCurY);
  156. if (xdiff > mTouchInfo.mMinDragW || ydiff > mTouchInfo.mMinDragH) {
  157. isBoostRequired = true;
  158. break;
  159. }
  160. }
  161. break;
  162. case 2:
  163. if (mVelocityTracker != null) {
  164. mVelocityTracker.addMovement(ev);
  165. }
  166. if (mTouchInfo != null) {
  167. xdiff = Math.abs(dx - mTouchInfo.mCurX);
  168. ydiff = Math.abs(dy - mTouchInfo.mCurY);
  169. mTouchInfo.setXY(dx, dy);
  170. if (xdiff > mTouchInfo.mMinDragW || ydiff > mTouchInfo.mMinDragH) {
  171. isBoostRequired = true;
  172. break;
  173. }
  174. }
  175. break;
  176. case 3:
  177. if (mTouchInfo != null) {
  178. mTouchInfo.reset();
  179. break;
  180. }
  181. break;
  182. }
  183. if (!isBoostRequired) {
  184. return REQUEST_FAILED;
  185. }
  186. this.handle = native_perf_lock_acq(this.handle, duration, list);
  187. if (this.handle != 0) {
  188. return REQUEST_SUCCEEDED;
  189. }
  190. return REQUEST_FAILED;
  191. }
  192.  
  193. public int perfLockRelease() {
  194. return native_perf_lock_rel(this.handle);
  195. }
  196.  
  197. public int perfIOPrefetchStart(int PId, String Pkg_name) {
  198. return native_perf_io_prefetch_start(PId, Pkg_name);
  199. }
  200.  
  201. public int perfIOPrefetchStop() {
  202. return native_perf_io_prefetch_stop();
  203. }
  204.  
  205. protected void finalize() {
  206. native_deinit();
  207. }
  208. }
Advertisement
Add Comment
Please, Sign In to add comment