Log some data when the QS panel starts expanding

The main goal is to learn at what x-position users tend to swipe down to
pull the notification/qs shade. To do that, this CL logs the following
data:

- x-location (as 0-100 percent)
- y-location (same)
- device rotation

in PanelView#startOpening(). This should only be logged rarely enough
(once per qs pull) not to spam logs or have any performance impact.

It also currently doesn't collect any data when expanding qs from the
keyguard, but I'm assuming that that particular case is much less
common. Logging could be added later though.

Fixes: 74012876
Test: adb logcat -b events | grep sysui_multi_action; pull notification
shade when device is unlocked and see lines like this:

02-28 12:41:42.060 31783 31783 I sysui_multi_action: [757,1324,758,4,826,413,827,12769,1322,91,1323,0,1325,0]

Change-Id: I9154a808552656d3fe02b1a8f732a4fbba3b09e6
This commit is contained in:
Evan Laird
2018-02-28 15:31:29 -05:00
parent 90c27c332a
commit 404a85c467
4 changed files with 62 additions and 2 deletions

View File

@@ -52,6 +52,21 @@ public class LockscreenGestureLogger {
EventLogTags.writeSysuiLockscreenGesture(safeLookup(gesture), length, velocity);
}
/**
* Record the location of a swipe gesture, expressed as percentages of the whole screen
* @param category the action
* @param xPercent x-location / width * 100
* @param yPercent y-location / height * 100
*/
public void writeAtFractionalPosition(
int category, int xPercent, int yPercent, int rotation) {
mMetricsLogger.write(mLogMaker.setCategory(category)
.setType(MetricsEvent.TYPE_ACTION)
.addTaggedData(MetricsEvent.FIELD_GESTURE_X_PERCENT, xPercent)
.addTaggedData(MetricsEvent.FIELD_GESTURE_Y_PERCENT, yPercent)
.addTaggedData(MetricsEvent.FIELD_DEVICE_ROTATION, rotation));
}
private int safeLookup(int gesture) {
Integer value = mLegacyMap.get(gesture);
if (value == null) {

View File

@@ -342,7 +342,7 @@ public abstract class PanelView extends FrameLayout {
onTrackingStarted();
}
if (isFullyCollapsed() && !mHeadsUpManager.hasPinnedHeadsUp()) {
startOpening();
startOpening(event);
}
break;
@@ -417,7 +417,7 @@ public abstract class PanelView extends FrameLayout {
return !mGestureWaitForTouchSlop || mTracking;
}
private void startOpening() {;
private void startOpening(MotionEvent event) {
runPeekAnimation(INITIAL_OPENING_PEEK_DURATION, getOpeningHeight(),
false /* collapseWhenFinished */);
notifyBarPanelExpansionChanged();
@@ -425,6 +425,18 @@ public abstract class PanelView extends FrameLayout {
AsyncTask.execute(() ->
mVibrator.vibrate(VibrationEffect.get(VibrationEffect.EFFECT_TICK, false)));
}
//TODO: keyguard opens QS a different way; log that too?
// Log the position of the swipe that opened the panel
float width = mStatusBar.getDisplayWidth();
float height = mStatusBar.getDisplayHeight();
int rot = mStatusBar.getRotation();
mLockscreenGestureLogger.writeAtFractionalPosition(MetricsEvent.ACTION_PANEL_VIEW_EXPAND,
(int) (event.getX() / width * 100),
(int) (event.getY() / height * 100),
rot);
}
protected abstract float getOpeningHeight();

View File

@@ -2834,6 +2834,18 @@ public class StatusBar extends SystemUI implements DemoMode,
return mDisplayMetrics.density;
}
float getDisplayWidth() {
return mDisplayMetrics.widthPixels;
}
float getDisplayHeight() {
return mDisplayMetrics.heightPixels;
}
int getRotation() {
return mDisplay.getRotation();
}
public void startActivityDismissingKeyguard(final Intent intent, boolean onlyProvisioned,
boolean dismissShade) {
startActivityDismissingKeyguard(intent, onlyProvisioned, dismissShade,

View File

@@ -5348,6 +5348,27 @@ message MetricsEvent {
// OS: P
RECENT_LOCATION_REQUESTS_ALL = 1325;
// FIELD: The x-location of a swipe gesture, conveyed as percent of total width
// CATEGORY: GLOBAL_SYSTEM_UI
// OS: P
FIELD_GESTURE_X_PERCENT = 1326;
// FIELD: The y-location of a swipe gesture, conveyed as percent of total width
// CATEGORY: GLOBAL_SYSTEM_UI
// OS: P
FIELD_GESTURE_Y_PERCENT = 1327;
// ACTION: Expand the notification panel while unlocked
// CATEGORY: GLOBAL_SYSTEM_UI
// OS: P
ACTION_PANEL_VIEW_EXPAND = 1328;
// FIELD: Rotation of the device
// CATEGORY: GLOBAL_SYSTEM_UI
// OS: P
FIELD_DEVICE_ROTATION = 1329;
// ---- End P Constants, all P constants go above this line ----
// Add new aosp constants above this line.
// END OF AOSP CONSTANTS