Loading api/test-current.txt +4 −1 Original line number Diff line number Diff line Loading @@ -133,16 +133,19 @@ package android.app { method @RequiresPermission("android.permission.MANAGE_APPOPS") public void addHistoricalOps(@NonNull android.app.AppOpsManager.HistoricalOps); method @RequiresPermission("android.permission.MANAGE_APPOPS") public void clearHistory(); method @RequiresPermission("android.permission.GET_APP_OPS_STATS") public void getHistoricalOps(@NonNull android.app.AppOpsManager.HistoricalOpsRequest, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.app.AppOpsManager.HistoricalOps>); method @RequiresPermission("android.permission.GET_APP_OPS_STATS") public void getHistoricalOpsFromDiskRaw(@NonNull android.app.AppOpsManager.HistoricalOpsRequest, @Nullable java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.app.AppOpsManager.HistoricalOps>); method @RequiresPermission("android.permission.MANAGE_APPOPS") public void getHistoricalOpsFromDiskRaw(@NonNull android.app.AppOpsManager.HistoricalOpsRequest, @Nullable java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.app.AppOpsManager.HistoricalOps>); method public static int getNumOps(); method public static String[] getOpStrs(); method public boolean isOperationActive(int, int, String); method @RequiresPermission("android.permission.MANAGE_APPOPS") public void offsetHistory(long); method public static int opToDefaultMode(@NonNull String); method public static String opToPermission(int); method public static int permissionToOpCode(String); method @RequiresPermission("android.permission.MANAGE_APPOPS") public void reloadNonHistoricalState(); method @RequiresPermission("android.permission.MANAGE_APPOPS") public void resetHistoryParameters(); method @RequiresPermission("android.permission.MANAGE_APPOPS") public void setHistoryParameters(int, long, int); method @RequiresPermission("android.permission.MANAGE_APP_OPS_MODES") public void setMode(int, int, String, int); method @RequiresPermission("android.permission.MANAGE_APP_OPS_MODES") public void setMode(String, int, String, int); method @RequiresPermission("android.permission.MANAGE_APP_OPS_MODES") public void setUidMode(String, int, int); method public void startWatchingActive(@NonNull int[], @NonNull android.app.AppOpsManager.OnOpActiveChangedListener); method public void stopWatchingActive(@NonNull android.app.AppOpsManager.OnOpActiveChangedListener); Loading core/java/android/app/AppOpsManager.java +18 −1 Original line number Diff line number Diff line Loading @@ -2153,6 +2153,7 @@ public class AppOpsManager { * * @hide */ @TestApi @SystemApi public static int opToDefaultMode(@NonNull String appOp) { return opToDefaultMode(strOpToOp(appOp)); Loading Loading @@ -4465,7 +4466,7 @@ public class AppOpsManager { * @hide */ @TestApi @RequiresPermission(android.Manifest.permission.GET_APP_OPS_STATS) @RequiresPermission(Manifest.permission.MANAGE_APPOPS) public void getHistoricalOpsFromDiskRaw(@NonNull HistoricalOpsRequest request, @Nullable Executor executor, @NonNull Consumer<HistoricalOps> callback) { Preconditions.checkNotNull(executor, "executor cannot be null"); Loading @@ -4487,6 +4488,21 @@ public class AppOpsManager { } } /** * Reloads the non historical state to allow testing the read/write path. * * @hide */ @TestApi @RequiresPermission(Manifest.permission.MANAGE_APPOPS) public void reloadNonHistoricalState() { try { mService.reloadNonHistoricalState(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Sets given app op in the specified mode for app ops in the UID. * This applies to all apps currently in the UID or installed in Loading Loading @@ -4570,6 +4586,7 @@ public class AppOpsManager { * be changed. * @hide */ @TestApi @SystemApi @RequiresPermission(android.Manifest.permission.MANAGE_APP_OPS_MODES) public void setMode(String op, int uid, String packageName, @Mode int mode) { Loading core/java/android/view/GestureDetector.java +5 −68 Original line number Diff line number Diff line Loading @@ -16,20 +16,11 @@ package android.view; import static android.util.StatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__DEEP_PRESS; import static android.util.StatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__DOUBLE_TAP; import static android.util.StatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS; import static android.util.StatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__SCROLL; import static android.util.StatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__SINGLE_TAP; import static android.util.StatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__UNKNOWN_CLASSIFICATION; import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.os.Build; import android.os.Handler; import android.os.Message; import android.os.SystemClock; import android.util.StatsLog; /** * Detects various gestures and events using the supplied {@link MotionEvent}s. Loading Loading @@ -260,12 +251,8 @@ public class GestureDetector { private boolean mAlwaysInTapRegion; private boolean mAlwaysInBiggerTapRegion; private boolean mIgnoreNextUpEvent; // Whether a classification has been recorded by statsd for the current event stream. Reset on // ACTION_DOWN. private boolean mHasRecordedClassification; private MotionEvent mCurrentDownEvent; private MotionEvent mCurrentMotionEvent; private MotionEvent mPreviousUpEvent; /** Loading Loading @@ -310,7 +297,6 @@ public class GestureDetector { break; case LONG_PRESS: recordGestureClassification(msg.arg1); dispatchLongPress(); break; Loading @@ -318,8 +304,6 @@ public class GestureDetector { // If the user's finger is still down, do not count it as a tap if (mDoubleTapListener != null) { if (!mStillDown) { recordGestureClassification( TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__SINGLE_TAP); mDoubleTapListener.onSingleTapConfirmed(mCurrentDownEvent); } else { mDeferConfirmSingleTap = true; Loading Loading @@ -517,11 +501,6 @@ public class GestureDetector { final int action = ev.getAction(); if (mCurrentMotionEvent != null) { mCurrentMotionEvent.recycle(); } mCurrentMotionEvent = MotionEvent.obtain(ev); if (mVelocityTracker == null) { mVelocityTracker = VelocityTracker.obtain(); } Loading Loading @@ -590,8 +569,6 @@ public class GestureDetector { && isConsideredDoubleTap(mCurrentDownEvent, mPreviousUpEvent, ev)) { // This is a second tap mIsDoubleTapping = true; recordGestureClassification( TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__DOUBLE_TAP); // Give a callback with the first tap of the double-tap handled |= mDoubleTapListener.onDoubleTap(mCurrentDownEvent); // Give a callback with down event of the double-tap Loading @@ -613,16 +590,10 @@ public class GestureDetector { mStillDown = true; mInLongPress = false; mDeferConfirmSingleTap = false; mHasRecordedClassification = false; if (mIsLongpressEnabled) { mHandler.removeMessages(LONG_PRESS); mHandler.sendMessageAtTime( mHandler.obtainMessage( LONG_PRESS, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS, 0 /* arg2 */), mCurrentDownEvent.getDownTime() mHandler.sendEmptyMessageAtTime(LONG_PRESS, mCurrentDownEvent.getDownTime() + ViewConfiguration.getLongPressTimeout()); } mHandler.sendEmptyMessageAtTime(SHOW_PRESS, Loading @@ -642,8 +613,6 @@ public class GestureDetector { final float scrollY = mLastFocusY - focusY; if (mIsDoubleTapping) { // Give the move events of the double-tap recordGestureClassification( TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__DOUBLE_TAP); handled |= mDoubleTapListener.onDoubleTapEvent(ev); } else if (mAlwaysInTapRegion) { final int deltaX = (int) (focusX - mDownFocusX); Loading @@ -666,12 +635,8 @@ public class GestureDetector { // reschedule long press with a modified timeout. mHandler.removeMessages(LONG_PRESS); final long longPressTimeout = ViewConfiguration.getLongPressTimeout(); mHandler.sendMessageAtTime( mHandler.obtainMessage( LONG_PRESS, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS, 0 /* arg2 */), ev.getDownTime() + (long) (longPressTimeout * multiplier)); mHandler.sendEmptyMessageAtTime(LONG_PRESS, ev.getDownTime() + (long) (longPressTimeout * multiplier)); } // Inhibit default scroll. If a gesture is ambiguous, we prevent scroll // until the gesture is resolved. Loading @@ -681,8 +646,6 @@ public class GestureDetector { } if (distance > slopSquare) { recordGestureClassification( TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__SCROLL); handled = mListener.onScroll(mCurrentDownEvent, ev, scrollX, scrollY); mLastFocusX = focusX; mLastFocusY = focusY; Loading @@ -696,7 +659,6 @@ public class GestureDetector { mAlwaysInBiggerTapRegion = false; } } else if ((Math.abs(scrollX) >= 1) || (Math.abs(scrollY) >= 1)) { recordGestureClassification(TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__SCROLL); handled = mListener.onScroll(mCurrentDownEvent, ev, scrollX, scrollY); mLastFocusX = focusX; mLastFocusY = focusY; Loading @@ -705,11 +667,7 @@ public class GestureDetector { motionClassification == MotionEvent.CLASSIFICATION_DEEP_PRESS; if (deepPress && hasPendingLongPress) { mHandler.removeMessages(LONG_PRESS); mHandler.sendMessage( mHandler.obtainMessage( LONG_PRESS, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__DEEP_PRESS, 0 /* arg2 */)); mHandler.sendEmptyMessage(LONG_PRESS); } break; Loading @@ -718,15 +676,11 @@ public class GestureDetector { MotionEvent currentUpEvent = MotionEvent.obtain(ev); if (mIsDoubleTapping) { // Finally, give the up event of the double-tap recordGestureClassification( TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__DOUBLE_TAP); handled |= mDoubleTapListener.onDoubleTapEvent(ev); } else if (mInLongPress) { mHandler.removeMessages(TAP); mInLongPress = false; } else if (mAlwaysInTapRegion && !mIgnoreNextUpEvent) { recordGestureClassification( TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__SINGLE_TAP); handled = mListener.onSingleTapUp(ev); if (mDeferConfirmSingleTap && mDoubleTapListener != null) { mDoubleTapListener.onSingleTapConfirmed(ev); Loading Loading @@ -867,21 +821,4 @@ public class GestureDetector { mInLongPress = true; mListener.onLongPress(mCurrentDownEvent); } private void recordGestureClassification(int classification) { if (mHasRecordedClassification || classification == TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__UNKNOWN_CLASSIFICATION) { // Only record the first classification for an event stream. return; } StatsLog.write( StatsLog.TOUCH_GESTURE_CLASSIFIED, getClass().getName(), classification, (int) (SystemClock.uptimeMillis() - mCurrentMotionEvent.getDownTime()), (float) Math.hypot(mCurrentMotionEvent.getRawX() - mCurrentDownEvent.getRawX(), mCurrentMotionEvent.getRawY() - mCurrentDownEvent.getRawY())); mHasRecordedClassification = true; } } core/java/android/view/View.java +7 −55 Original line number Diff line number Diff line Loading @@ -17,10 +17,6 @@ package android.view; import static android.content.res.Resources.ID_NULL; import static android.util.StatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__DEEP_PRESS; import static android.util.StatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS; import static android.util.StatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__SINGLE_TAP; import static android.util.StatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__UNKNOWN_CLASSIFICATION; import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL; import static android.view.accessibility.AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED; Loading Loading @@ -100,7 +96,6 @@ import android.util.Property; import android.util.SparseArray; import android.util.SparseIntArray; import android.util.StateSet; import android.util.StatsLog; import android.util.SuperNotCalledException; import android.util.TypedValue; import android.view.AccessibilityIterators.CharacterTextSegmentIterator; Loading Loading @@ -14547,12 +14542,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, if (clickable) { setPressed(true, x, y); } checkForLongClick( ViewConfiguration.getLongPressTimeout(), x, y, // This is not a touch gesture -- do not classify it as one. TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__UNKNOWN_CLASSIFICATION); checkForLongClick(ViewConfiguration.getLongPressTimeout(), x, y); return true; } } Loading Loading @@ -15293,11 +15283,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, mHasPerformedLongPress = false; if (!clickable) { checkForLongClick( ViewConfiguration.getLongPressTimeout(), x, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); checkForLongClick(ViewConfiguration.getLongPressTimeout(), x, y); break; } Loading @@ -15321,11 +15307,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } else { // Not inside a scrolling container, so show the feedback right away setPressed(true, x, y); checkForLongClick( ViewConfiguration.getLongPressTimeout(), x, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); checkForLongClick(ViewConfiguration.getLongPressTimeout(), x, y); } break; Loading Loading @@ -15362,11 +15344,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * ambiguousMultiplier); // Subtract the time already spent delay -= event.getEventTime() - event.getDownTime(); checkForLongClick( delay, x, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); checkForLongClick(delay, x, y); } touchSlop *= ambiguousMultiplier; } Loading @@ -15388,11 +15366,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, if (deepPress && hasPendingLongPressCallback()) { // process the long click action immediately removeLongPressCallback(); checkForLongClick( 0 /* send immediately */, x, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__DEEP_PRESS); checkForLongClick(0 /* send immediately */, x, y); } break; Loading Loading @@ -26057,7 +26031,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } } private void checkForLongClick(long delay, float x, float y, int classification) { private void checkForLongClick(long delay, float x, float y) { if ((mViewFlags & LONG_CLICKABLE) == LONG_CLICKABLE || (mViewFlags & TOOLTIP) == TOOLTIP) { mHasPerformedLongPress = false; Loading @@ -26067,7 +26041,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, mPendingCheckForLongPress.setAnchor(x, y); mPendingCheckForLongPress.rememberWindowAttachCount(); mPendingCheckForLongPress.rememberPressedState(); mPendingCheckForLongPress.setClassification(classification); postDelayed(mPendingCheckForLongPress, delay); } } Loading Loading @@ -27625,17 +27598,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback, private float mX; private float mY; private boolean mOriginalPressedState; /** * The classification of the long click being checked: one of the * StatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__* constants. */ private int mClassification; @Override public void run() { if ((mOriginalPressedState == isPressed()) && (mParent != null) && mOriginalWindowAttachCount == mWindowAttachCount) { recordGestureClassification(mClassification); if (performLongClick(mX, mY)) { mHasPerformedLongPress = true; } Loading @@ -27654,10 +27621,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, public void rememberPressedState() { mOriginalPressedState = isPressed(); } public void setClassification(int classification) { mClassification = classification; } } private final class CheckForTap implements Runnable { Loading @@ -27670,28 +27633,17 @@ public class View implements Drawable.Callback, KeyEvent.Callback, setPressed(true, x, y); final long delay = ViewConfiguration.getLongPressTimeout() - ViewConfiguration.getTapTimeout(); checkForLongClick(delay, x, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); checkForLongClick(delay, x, y); } } private final class PerformClick implements Runnable { @Override public void run() { recordGestureClassification(TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__SINGLE_TAP); performClickInternal(); } } /** Records a classification for the current event stream. */ private void recordGestureClassification(int classification) { if (classification == TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__UNKNOWN_CLASSIFICATION) { return; } // To avoid negatively impacting View performance, the latency and displacement metrics // are omitted. StatsLog.write(StatsLog.TOUCH_GESTURE_CLASSIFIED, getClass().getName(), classification); } /** * This method returns a ViewPropertyAnimator object, which can be used to animate * specific properties on this View. core/java/com/android/internal/app/IAppOpsService.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -79,4 +79,6 @@ interface IAppOpsService { void stopWatchingNoted(IAppOpsNotedCallback callback); int checkOperationRaw(int code, int uid, String packageName); void reloadNonHistoricalState(); } Loading
api/test-current.txt +4 −1 Original line number Diff line number Diff line Loading @@ -133,16 +133,19 @@ package android.app { method @RequiresPermission("android.permission.MANAGE_APPOPS") public void addHistoricalOps(@NonNull android.app.AppOpsManager.HistoricalOps); method @RequiresPermission("android.permission.MANAGE_APPOPS") public void clearHistory(); method @RequiresPermission("android.permission.GET_APP_OPS_STATS") public void getHistoricalOps(@NonNull android.app.AppOpsManager.HistoricalOpsRequest, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.app.AppOpsManager.HistoricalOps>); method @RequiresPermission("android.permission.GET_APP_OPS_STATS") public void getHistoricalOpsFromDiskRaw(@NonNull android.app.AppOpsManager.HistoricalOpsRequest, @Nullable java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.app.AppOpsManager.HistoricalOps>); method @RequiresPermission("android.permission.MANAGE_APPOPS") public void getHistoricalOpsFromDiskRaw(@NonNull android.app.AppOpsManager.HistoricalOpsRequest, @Nullable java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.app.AppOpsManager.HistoricalOps>); method public static int getNumOps(); method public static String[] getOpStrs(); method public boolean isOperationActive(int, int, String); method @RequiresPermission("android.permission.MANAGE_APPOPS") public void offsetHistory(long); method public static int opToDefaultMode(@NonNull String); method public static String opToPermission(int); method public static int permissionToOpCode(String); method @RequiresPermission("android.permission.MANAGE_APPOPS") public void reloadNonHistoricalState(); method @RequiresPermission("android.permission.MANAGE_APPOPS") public void resetHistoryParameters(); method @RequiresPermission("android.permission.MANAGE_APPOPS") public void setHistoryParameters(int, long, int); method @RequiresPermission("android.permission.MANAGE_APP_OPS_MODES") public void setMode(int, int, String, int); method @RequiresPermission("android.permission.MANAGE_APP_OPS_MODES") public void setMode(String, int, String, int); method @RequiresPermission("android.permission.MANAGE_APP_OPS_MODES") public void setUidMode(String, int, int); method public void startWatchingActive(@NonNull int[], @NonNull android.app.AppOpsManager.OnOpActiveChangedListener); method public void stopWatchingActive(@NonNull android.app.AppOpsManager.OnOpActiveChangedListener); Loading
core/java/android/app/AppOpsManager.java +18 −1 Original line number Diff line number Diff line Loading @@ -2153,6 +2153,7 @@ public class AppOpsManager { * * @hide */ @TestApi @SystemApi public static int opToDefaultMode(@NonNull String appOp) { return opToDefaultMode(strOpToOp(appOp)); Loading Loading @@ -4465,7 +4466,7 @@ public class AppOpsManager { * @hide */ @TestApi @RequiresPermission(android.Manifest.permission.GET_APP_OPS_STATS) @RequiresPermission(Manifest.permission.MANAGE_APPOPS) public void getHistoricalOpsFromDiskRaw(@NonNull HistoricalOpsRequest request, @Nullable Executor executor, @NonNull Consumer<HistoricalOps> callback) { Preconditions.checkNotNull(executor, "executor cannot be null"); Loading @@ -4487,6 +4488,21 @@ public class AppOpsManager { } } /** * Reloads the non historical state to allow testing the read/write path. * * @hide */ @TestApi @RequiresPermission(Manifest.permission.MANAGE_APPOPS) public void reloadNonHistoricalState() { try { mService.reloadNonHistoricalState(); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Sets given app op in the specified mode for app ops in the UID. * This applies to all apps currently in the UID or installed in Loading Loading @@ -4570,6 +4586,7 @@ public class AppOpsManager { * be changed. * @hide */ @TestApi @SystemApi @RequiresPermission(android.Manifest.permission.MANAGE_APP_OPS_MODES) public void setMode(String op, int uid, String packageName, @Mode int mode) { Loading
core/java/android/view/GestureDetector.java +5 −68 Original line number Diff line number Diff line Loading @@ -16,20 +16,11 @@ package android.view; import static android.util.StatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__DEEP_PRESS; import static android.util.StatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__DOUBLE_TAP; import static android.util.StatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS; import static android.util.StatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__SCROLL; import static android.util.StatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__SINGLE_TAP; import static android.util.StatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__UNKNOWN_CLASSIFICATION; import android.annotation.UnsupportedAppUsage; import android.content.Context; import android.os.Build; import android.os.Handler; import android.os.Message; import android.os.SystemClock; import android.util.StatsLog; /** * Detects various gestures and events using the supplied {@link MotionEvent}s. Loading Loading @@ -260,12 +251,8 @@ public class GestureDetector { private boolean mAlwaysInTapRegion; private boolean mAlwaysInBiggerTapRegion; private boolean mIgnoreNextUpEvent; // Whether a classification has been recorded by statsd for the current event stream. Reset on // ACTION_DOWN. private boolean mHasRecordedClassification; private MotionEvent mCurrentDownEvent; private MotionEvent mCurrentMotionEvent; private MotionEvent mPreviousUpEvent; /** Loading Loading @@ -310,7 +297,6 @@ public class GestureDetector { break; case LONG_PRESS: recordGestureClassification(msg.arg1); dispatchLongPress(); break; Loading @@ -318,8 +304,6 @@ public class GestureDetector { // If the user's finger is still down, do not count it as a tap if (mDoubleTapListener != null) { if (!mStillDown) { recordGestureClassification( TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__SINGLE_TAP); mDoubleTapListener.onSingleTapConfirmed(mCurrentDownEvent); } else { mDeferConfirmSingleTap = true; Loading Loading @@ -517,11 +501,6 @@ public class GestureDetector { final int action = ev.getAction(); if (mCurrentMotionEvent != null) { mCurrentMotionEvent.recycle(); } mCurrentMotionEvent = MotionEvent.obtain(ev); if (mVelocityTracker == null) { mVelocityTracker = VelocityTracker.obtain(); } Loading Loading @@ -590,8 +569,6 @@ public class GestureDetector { && isConsideredDoubleTap(mCurrentDownEvent, mPreviousUpEvent, ev)) { // This is a second tap mIsDoubleTapping = true; recordGestureClassification( TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__DOUBLE_TAP); // Give a callback with the first tap of the double-tap handled |= mDoubleTapListener.onDoubleTap(mCurrentDownEvent); // Give a callback with down event of the double-tap Loading @@ -613,16 +590,10 @@ public class GestureDetector { mStillDown = true; mInLongPress = false; mDeferConfirmSingleTap = false; mHasRecordedClassification = false; if (mIsLongpressEnabled) { mHandler.removeMessages(LONG_PRESS); mHandler.sendMessageAtTime( mHandler.obtainMessage( LONG_PRESS, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS, 0 /* arg2 */), mCurrentDownEvent.getDownTime() mHandler.sendEmptyMessageAtTime(LONG_PRESS, mCurrentDownEvent.getDownTime() + ViewConfiguration.getLongPressTimeout()); } mHandler.sendEmptyMessageAtTime(SHOW_PRESS, Loading @@ -642,8 +613,6 @@ public class GestureDetector { final float scrollY = mLastFocusY - focusY; if (mIsDoubleTapping) { // Give the move events of the double-tap recordGestureClassification( TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__DOUBLE_TAP); handled |= mDoubleTapListener.onDoubleTapEvent(ev); } else if (mAlwaysInTapRegion) { final int deltaX = (int) (focusX - mDownFocusX); Loading @@ -666,12 +635,8 @@ public class GestureDetector { // reschedule long press with a modified timeout. mHandler.removeMessages(LONG_PRESS); final long longPressTimeout = ViewConfiguration.getLongPressTimeout(); mHandler.sendMessageAtTime( mHandler.obtainMessage( LONG_PRESS, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS, 0 /* arg2 */), ev.getDownTime() + (long) (longPressTimeout * multiplier)); mHandler.sendEmptyMessageAtTime(LONG_PRESS, ev.getDownTime() + (long) (longPressTimeout * multiplier)); } // Inhibit default scroll. If a gesture is ambiguous, we prevent scroll // until the gesture is resolved. Loading @@ -681,8 +646,6 @@ public class GestureDetector { } if (distance > slopSquare) { recordGestureClassification( TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__SCROLL); handled = mListener.onScroll(mCurrentDownEvent, ev, scrollX, scrollY); mLastFocusX = focusX; mLastFocusY = focusY; Loading @@ -696,7 +659,6 @@ public class GestureDetector { mAlwaysInBiggerTapRegion = false; } } else if ((Math.abs(scrollX) >= 1) || (Math.abs(scrollY) >= 1)) { recordGestureClassification(TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__SCROLL); handled = mListener.onScroll(mCurrentDownEvent, ev, scrollX, scrollY); mLastFocusX = focusX; mLastFocusY = focusY; Loading @@ -705,11 +667,7 @@ public class GestureDetector { motionClassification == MotionEvent.CLASSIFICATION_DEEP_PRESS; if (deepPress && hasPendingLongPress) { mHandler.removeMessages(LONG_PRESS); mHandler.sendMessage( mHandler.obtainMessage( LONG_PRESS, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__DEEP_PRESS, 0 /* arg2 */)); mHandler.sendEmptyMessage(LONG_PRESS); } break; Loading @@ -718,15 +676,11 @@ public class GestureDetector { MotionEvent currentUpEvent = MotionEvent.obtain(ev); if (mIsDoubleTapping) { // Finally, give the up event of the double-tap recordGestureClassification( TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__DOUBLE_TAP); handled |= mDoubleTapListener.onDoubleTapEvent(ev); } else if (mInLongPress) { mHandler.removeMessages(TAP); mInLongPress = false; } else if (mAlwaysInTapRegion && !mIgnoreNextUpEvent) { recordGestureClassification( TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__SINGLE_TAP); handled = mListener.onSingleTapUp(ev); if (mDeferConfirmSingleTap && mDoubleTapListener != null) { mDoubleTapListener.onSingleTapConfirmed(ev); Loading Loading @@ -867,21 +821,4 @@ public class GestureDetector { mInLongPress = true; mListener.onLongPress(mCurrentDownEvent); } private void recordGestureClassification(int classification) { if (mHasRecordedClassification || classification == TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__UNKNOWN_CLASSIFICATION) { // Only record the first classification for an event stream. return; } StatsLog.write( StatsLog.TOUCH_GESTURE_CLASSIFIED, getClass().getName(), classification, (int) (SystemClock.uptimeMillis() - mCurrentMotionEvent.getDownTime()), (float) Math.hypot(mCurrentMotionEvent.getRawX() - mCurrentDownEvent.getRawX(), mCurrentMotionEvent.getRawY() - mCurrentDownEvent.getRawY())); mHasRecordedClassification = true; } }
core/java/android/view/View.java +7 −55 Original line number Diff line number Diff line Loading @@ -17,10 +17,6 @@ package android.view; import static android.content.res.Resources.ID_NULL; import static android.util.StatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__DEEP_PRESS; import static android.util.StatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS; import static android.util.StatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__SINGLE_TAP; import static android.util.StatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__UNKNOWN_CLASSIFICATION; import static android.view.ViewRootImpl.NEW_INSETS_MODE_FULL; import static android.view.accessibility.AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED; Loading Loading @@ -100,7 +96,6 @@ import android.util.Property; import android.util.SparseArray; import android.util.SparseIntArray; import android.util.StateSet; import android.util.StatsLog; import android.util.SuperNotCalledException; import android.util.TypedValue; import android.view.AccessibilityIterators.CharacterTextSegmentIterator; Loading Loading @@ -14547,12 +14542,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, if (clickable) { setPressed(true, x, y); } checkForLongClick( ViewConfiguration.getLongPressTimeout(), x, y, // This is not a touch gesture -- do not classify it as one. TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__UNKNOWN_CLASSIFICATION); checkForLongClick(ViewConfiguration.getLongPressTimeout(), x, y); return true; } } Loading Loading @@ -15293,11 +15283,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, mHasPerformedLongPress = false; if (!clickable) { checkForLongClick( ViewConfiguration.getLongPressTimeout(), x, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); checkForLongClick(ViewConfiguration.getLongPressTimeout(), x, y); break; } Loading @@ -15321,11 +15307,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } else { // Not inside a scrolling container, so show the feedback right away setPressed(true, x, y); checkForLongClick( ViewConfiguration.getLongPressTimeout(), x, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); checkForLongClick(ViewConfiguration.getLongPressTimeout(), x, y); } break; Loading Loading @@ -15362,11 +15344,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * ambiguousMultiplier); // Subtract the time already spent delay -= event.getEventTime() - event.getDownTime(); checkForLongClick( delay, x, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); checkForLongClick(delay, x, y); } touchSlop *= ambiguousMultiplier; } Loading @@ -15388,11 +15366,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, if (deepPress && hasPendingLongPressCallback()) { // process the long click action immediately removeLongPressCallback(); checkForLongClick( 0 /* send immediately */, x, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__DEEP_PRESS); checkForLongClick(0 /* send immediately */, x, y); } break; Loading Loading @@ -26057,7 +26031,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } } private void checkForLongClick(long delay, float x, float y, int classification) { private void checkForLongClick(long delay, float x, float y) { if ((mViewFlags & LONG_CLICKABLE) == LONG_CLICKABLE || (mViewFlags & TOOLTIP) == TOOLTIP) { mHasPerformedLongPress = false; Loading @@ -26067,7 +26041,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, mPendingCheckForLongPress.setAnchor(x, y); mPendingCheckForLongPress.rememberWindowAttachCount(); mPendingCheckForLongPress.rememberPressedState(); mPendingCheckForLongPress.setClassification(classification); postDelayed(mPendingCheckForLongPress, delay); } } Loading Loading @@ -27625,17 +27598,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback, private float mX; private float mY; private boolean mOriginalPressedState; /** * The classification of the long click being checked: one of the * StatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__* constants. */ private int mClassification; @Override public void run() { if ((mOriginalPressedState == isPressed()) && (mParent != null) && mOriginalWindowAttachCount == mWindowAttachCount) { recordGestureClassification(mClassification); if (performLongClick(mX, mY)) { mHasPerformedLongPress = true; } Loading @@ -27654,10 +27621,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, public void rememberPressedState() { mOriginalPressedState = isPressed(); } public void setClassification(int classification) { mClassification = classification; } } private final class CheckForTap implements Runnable { Loading @@ -27670,28 +27633,17 @@ public class View implements Drawable.Callback, KeyEvent.Callback, setPressed(true, x, y); final long delay = ViewConfiguration.getLongPressTimeout() - ViewConfiguration.getTapTimeout(); checkForLongClick(delay, x, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); checkForLongClick(delay, x, y); } } private final class PerformClick implements Runnable { @Override public void run() { recordGestureClassification(TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__SINGLE_TAP); performClickInternal(); } } /** Records a classification for the current event stream. */ private void recordGestureClassification(int classification) { if (classification == TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__UNKNOWN_CLASSIFICATION) { return; } // To avoid negatively impacting View performance, the latency and displacement metrics // are omitted. StatsLog.write(StatsLog.TOUCH_GESTURE_CLASSIFIED, getClass().getName(), classification); } /** * This method returns a ViewPropertyAnimator object, which can be used to animate * specific properties on this View.
core/java/com/android/internal/app/IAppOpsService.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -79,4 +79,6 @@ interface IAppOpsService { void stopWatchingNoted(IAppOpsNotedCallback callback); int checkOperationRaw(int code, int uid, String packageName); void reloadNonHistoricalState(); }