Proto changes and binary for adding more logs to the Back am: 4f9ab82c08 am: 4f8c046291 am: 31aaad4a7e

Change-Id: I269bd38abc47e1dc707102c21ed7be88a1ef599e
This commit is contained in:
Maryam Karimzadehgan
2020-03-26 17:43:40 +00:00
committed by Automerger Merge Worker
2 changed files with 111 additions and 53 deletions

View File

@@ -2753,21 +2753,32 @@ message PhoneStateChanged {
message BackGesture { message BackGesture {
enum BackType { enum BackType {
DEFAULT_BACK_TYPE = 0; DEFAULT_BACK_TYPE = 0;
COMPLETED = 1; COMPLETED = 1;
COMPLETED_REJECTED = 2; // successful because coming from rejected area COMPLETED_REJECTED = 2; // successful because coming from rejected area
INCOMPLETE_EXCLUDED = 3; // would have been successful but in the exclusion area INCOMPLETE_EXCLUDED = 3; // would have been successful but in the exclusion area
INCOMPLETE = 4; INCOMPLETE = 4; // Unsuccessful, for reasons other than below.
INCOMPLETE_FAR_FROM_EDGE = 5; // Unsuccessful, far from the edge.
INCOMPLETE_MULTI_TOUCH = 6; // Unsuccessful, multi touch.
INCOMPLETE_LONG_PRESS = 7; // Unsuccessful, long press.
INCOMPLETE_VERTICAL_MOVE = 8; // Unsuccessful, move vertically.
} }
optional BackType type = 1; optional BackType type = 1;
optional int32 y_coordinate = 2; // y coordinate for ACTION_DOWN event optional int32 y_coordinate = 2 [deprecated = true]; // y coordinate for ACTION_DOWN event
optional int32 start_x = 4; // X coordinate for ACTION_DOWN event.
optional int32 start_y = 5; // Y coordinate for ACTION_DOWN event.
optional int32 end_x = 6; // X coordinate for ACTION_MOVE event.
optional int32 end_y = 7; // Y coordinate for ACTION_MOVE event.
optional int32 left_boundary = 8; // left edge width + left inset
optional int32 right_boundary = 9; // screen width - (right edge width + right inset)
enum WindowHorizontalLocation { enum WindowHorizontalLocation {
DEFAULT_LOCATION = 0; DEFAULT_LOCATION = 0;
LEFT = 1; LEFT = 1;
RIGHT = 2; RIGHT = 2;
} }
optional WindowHorizontalLocation x_location = 3; optional WindowHorizontalLocation x_location = 3 [deprecated = true];
} }
message ExclusionRectStateChanged { message ExclusionRectStateChanged {

View File

@@ -110,10 +110,14 @@ public class EdgeBackGestureHandler implements DisplayListener,
private final float mTouchSlop; private final float mTouchSlop;
// Duration after which we consider the event as longpress. // Duration after which we consider the event as longpress.
private final int mLongPressTimeout; private final int mLongPressTimeout;
// The back gesture type
private int mBackType;
private final PointF mDownPoint = new PointF(); private final PointF mDownPoint = new PointF();
private final PointF mEndPoint = new PointF();
private boolean mThresholdCrossed = false; private boolean mThresholdCrossed = false;
private boolean mAllowGesture = false; private boolean mAllowGesture = false;
private boolean mLogGesture = false;
private boolean mInRejectedExclusion = false; private boolean mInRejectedExclusion = false;
private boolean mIsOnLeftEdge; private boolean mIsOnLeftEdge;
@@ -141,24 +145,16 @@ public class EdgeBackGestureHandler implements DisplayListener,
mOverviewProxyService.notifyBackAction(true, (int) mDownPoint.x, mOverviewProxyService.notifyBackAction(true, (int) mDownPoint.x,
(int) mDownPoint.y, false /* isButton */, !mIsOnLeftEdge); (int) mDownPoint.y, false /* isButton */, !mIsOnLeftEdge);
int backtype = (mInRejectedExclusion logGesture(mInRejectedExclusion
? SysUiStatsLog.BACK_GESTURE__TYPE__COMPLETED_REJECTED : ? SysUiStatsLog.BACK_GESTURE__TYPE__COMPLETED_REJECTED
SysUiStatsLog.BACK_GESTURE__TYPE__COMPLETED); : SysUiStatsLog.BACK_GESTURE__TYPE__COMPLETED);
SysUiStatsLog.write(SysUiStatsLog.BACK_GESTURE_REPORTED_REPORTED, backtype,
(int) mDownPoint.y, mIsOnLeftEdge
? SysUiStatsLog.BACK_GESTURE__X_LOCATION__LEFT :
SysUiStatsLog.BACK_GESTURE__X_LOCATION__RIGHT);
} }
@Override @Override
public void cancelBack() { public void cancelBack() {
logGesture(SysUiStatsLog.BACK_GESTURE__TYPE__INCOMPLETE);
mOverviewProxyService.notifyBackAction(false, (int) mDownPoint.x, mOverviewProxyService.notifyBackAction(false, (int) mDownPoint.x,
(int) mDownPoint.y, false /* isButton */, !mIsOnLeftEdge); (int) mDownPoint.y, false /* isButton */, !mIsOnLeftEdge);
int backtype = SysUiStatsLog.BACK_GESTURE__TYPE__INCOMPLETE;
SysUiStatsLog.write(SysUiStatsLog.BACK_GESTURE_REPORTED_REPORTED, backtype,
(int) mDownPoint.y, mIsOnLeftEdge
? SysUiStatsLog.BACK_GESTURE__X_LOCATION__LEFT :
SysUiStatsLog.BACK_GESTURE__X_LOCATION__RIGHT);
} }
}; };
@@ -331,39 +327,55 @@ public class EdgeBackGestureHandler implements DisplayListener,
} }
private boolean isWithinTouchRegion(int x, int y) { private boolean isWithinTouchRegion(int x, int y) {
// Disallow if too far from the edge
if (x > mEdgeWidthLeft + mLeftInset
&& x < (mDisplaySize.x - mEdgeWidthRight - mRightInset)) {
return false;
}
// Disallow if we are in the bottom gesture area // Disallow if we are in the bottom gesture area
if (y >= (mDisplaySize.y - mBottomGestureHeight)) { if (y >= (mDisplaySize.y - mBottomGestureHeight)) {
return false; return false;
} }
// Always allow if the user is in a transient sticky immersive state // If the point is way too far (twice the margin), it is
if (mIsNavBarShownTransiently) { // not interesting to us for logging purposes, nor we
return true; // should process it. Simply return false and keep
// mLogGesture = false.
if (x > 2 * (mEdgeWidthLeft + mLeftInset)
&& x < (mDisplaySize.x - 2 * (mEdgeWidthRight + mRightInset))) {
return false;
} }
boolean isInExcludedRegion = mExcludeRegion.contains(x, y); // Denotes whether we should proceed with the gesture.
if (isInExcludedRegion) { // Even if it is false, we may want to log it assuming
mOverviewProxyService.notifyBackAction(false /* completed */, -1, -1, // it is not invalid due to exclusion.
false /* isButton */, !mIsOnLeftEdge); boolean withinRange = x <= mEdgeWidthLeft + mLeftInset
SysUiStatsLog.write(SysUiStatsLog.BACK_GESTURE_REPORTED_REPORTED, || x >= (mDisplaySize.x - mEdgeWidthRight - mRightInset);
SysUiStatsLog.BACK_GESTURE__TYPE__INCOMPLETE_EXCLUDED, y,
mIsOnLeftEdge ? SysUiStatsLog.BACK_GESTURE__X_LOCATION__LEFT : // Always allow if the user is in a transient sticky immersive state
SysUiStatsLog.BACK_GESTURE__X_LOCATION__RIGHT); if (mIsNavBarShownTransiently) {
} else { mLogGesture = true;
mInRejectedExclusion = mUnrestrictedExcludeRegion.contains(x, y); return withinRange;
} }
return !isInExcludedRegion;
if (mExcludeRegion.contains(x, y)) {
if (withinRange) {
// Log as exclusion only if it is in acceptable range in the first place.
mOverviewProxyService.notifyBackAction(
false /* completed */, -1, -1, false /* isButton */, !mIsOnLeftEdge);
// We don't have the end point for logging purposes.
mEndPoint.x = -1;
mEndPoint.y = -1;
mLogGesture = true;
logGesture(SysUiStatsLog.BACK_GESTURE__TYPE__INCOMPLETE_EXCLUDED);
}
return false;
}
mInRejectedExclusion = mUnrestrictedExcludeRegion.contains(x, y);
mLogGesture = true;
return withinRange;
} }
private void cancelGesture(MotionEvent ev) { private void cancelGesture(MotionEvent ev) {
// Send action cancel to reset all the touch events // Send action cancel to reset all the touch events
mAllowGesture = false; mAllowGesture = false;
mLogGesture = false;
mInRejectedExclusion = false; mInRejectedExclusion = false;
MotionEvent cancelEv = MotionEvent.obtain(ev); MotionEvent cancelEv = MotionEvent.obtain(ev);
cancelEv.setAction(MotionEvent.ACTION_CANCEL); cancelEv.setAction(MotionEvent.ACTION_CANCEL);
@@ -371,51 +383,86 @@ public class EdgeBackGestureHandler implements DisplayListener,
cancelEv.recycle(); cancelEv.recycle();
} }
private void logGesture(int backType) {
if (!mLogGesture) {
return;
}
mLogGesture = false;
SysUiStatsLog.write(SysUiStatsLog.BACK_GESTURE_REPORTED_REPORTED, backType,
(int) mDownPoint.y, mIsOnLeftEdge
? SysUiStatsLog.BACK_GESTURE__X_LOCATION__LEFT
: SysUiStatsLog.BACK_GESTURE__X_LOCATION__RIGHT,
(int) mDownPoint.x, (int) mDownPoint.y,
(int) mEndPoint.x, (int) mEndPoint.y,
mEdgeWidthLeft + mLeftInset,
mDisplaySize.x - (mEdgeWidthRight + mRightInset));
}
private void onMotionEvent(MotionEvent ev) { private void onMotionEvent(MotionEvent ev) {
int action = ev.getActionMasked(); int action = ev.getActionMasked();
if (action == MotionEvent.ACTION_DOWN) { if (action == MotionEvent.ACTION_DOWN) {
// Verify if this is in within the touch region and we aren't in immersive mode, and // Verify if this is in within the touch region and we aren't in immersive mode, and
// either the bouncer is showing or the notification panel is hidden // either the bouncer is showing or the notification panel is hidden
mIsOnLeftEdge = ev.getX() <= mEdgeWidthLeft + mLeftInset; mIsOnLeftEdge = ev.getX() <= mEdgeWidthLeft + mLeftInset;
mLogGesture = false;
mInRejectedExclusion = false; mInRejectedExclusion = false;
mAllowGesture = !QuickStepContract.isBackGestureDisabled(mSysUiFlags) mAllowGesture = !QuickStepContract.isBackGestureDisabled(mSysUiFlags)
&& isWithinTouchRegion((int) ev.getX(), (int) ev.getY()); && isWithinTouchRegion((int) ev.getX(), (int) ev.getY());
if (mAllowGesture) { if (mAllowGesture) {
mEdgeBackPlugin.setIsLeftPanel(mIsOnLeftEdge); mEdgeBackPlugin.setIsLeftPanel(mIsOnLeftEdge);
mEdgeBackPlugin.onMotionEvent(ev); mEdgeBackPlugin.onMotionEvent(ev);
}
if (mLogGesture) {
mDownPoint.set(ev.getX(), ev.getY()); mDownPoint.set(ev.getX(), ev.getY());
mEndPoint.set(-1, -1);
mThresholdCrossed = false; mThresholdCrossed = false;
} }
} else if (mAllowGesture || mLogGesture) {
} else if (mAllowGesture) {
if (!mThresholdCrossed) { if (!mThresholdCrossed) {
mEndPoint.x = (int) ev.getX();
mEndPoint.y = (int) ev.getY();
if (action == MotionEvent.ACTION_POINTER_DOWN) { if (action == MotionEvent.ACTION_POINTER_DOWN) {
// We do not support multi touch for back gesture if (mAllowGesture) {
cancelGesture(ev); logGesture(SysUiStatsLog.BACK_GESTURE__TYPE__INCOMPLETE_MULTI_TOUCH);
// We do not support multi touch for back gesture
cancelGesture(ev);
}
mLogGesture = false;
return; return;
} else if (action == MotionEvent.ACTION_MOVE) { } else if (action == MotionEvent.ACTION_MOVE) {
if ((ev.getEventTime() - ev.getDownTime()) > mLongPressTimeout) { if ((ev.getEventTime() - ev.getDownTime()) > mLongPressTimeout) {
cancelGesture(ev); if (mAllowGesture) {
logGesture(SysUiStatsLog.BACK_GESTURE__TYPE__INCOMPLETE_LONG_PRESS);
cancelGesture(ev);
}
mLogGesture = false;
return; return;
} }
float dx = Math.abs(ev.getX() - mDownPoint.x); float dx = Math.abs(ev.getX() - mDownPoint.x);
float dy = Math.abs(ev.getY() - mDownPoint.y); float dy = Math.abs(ev.getY() - mDownPoint.y);
if (dy > dx && dy > mTouchSlop) { if (dy > dx && dy > mTouchSlop) {
cancelGesture(ev); if (mAllowGesture) {
logGesture(SysUiStatsLog.BACK_GESTURE__TYPE__INCOMPLETE_VERTICAL_MOVE);
cancelGesture(ev);
}
mLogGesture = false;
return; return;
} else if (dx > dy && dx > mTouchSlop) { } else if (dx > dy && dx > mTouchSlop) {
mThresholdCrossed = true; if (mAllowGesture) {
// Capture inputs mThresholdCrossed = true;
mInputMonitor.pilferPointers(); // Capture inputs
mInputMonitor.pilferPointers();
} else {
logGesture(SysUiStatsLog.BACK_GESTURE__TYPE__INCOMPLETE_FAR_FROM_EDGE);
}
} }
} }
} }
// forward touch if (mAllowGesture) {
mEdgeBackPlugin.onMotionEvent(ev); // forward touch
mEdgeBackPlugin.onMotionEvent(ev);
}
} }
Dependency.get(ProtoTracer.class).update(); Dependency.get(ProtoTracer.class).update();