Merge "Fix SysUI-Assistant metrics logging" into qt-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
1d6d10dc6f
@@ -142,6 +142,10 @@ public final class AssistHandleBehaviorController implements AssistHandleCallbac
|
||||
mHandler.post(() -> maybeShowHandles(/* ignoreThreshold = */ true));
|
||||
}
|
||||
|
||||
boolean areHandlesShowing() {
|
||||
return mHandlesShowing;
|
||||
}
|
||||
|
||||
void onAssistantGesturePerformed() {
|
||||
mBehaviorMap.get(mCurrentBehavior).onAssistantGesturePerformed();
|
||||
}
|
||||
|
||||
@@ -104,6 +104,11 @@ public class AssistManager implements ConfigurationChangedReceiver {
|
||||
public static final int INVOCATION_TYPE_QUICK_SEARCH_BAR = 4;
|
||||
public static final int INVOCATION_HOME_BUTTON_LONG_PRESS = 5;
|
||||
|
||||
public static final int DISMISS_REASON_INVOCATION_CANCELLED = 1;
|
||||
public static final int DISMISS_REASON_TAP = 2;
|
||||
public static final int DISMISS_REASON_BACK = 3;
|
||||
public static final int DISMISS_REASON_TIMEOUT = 4;
|
||||
|
||||
private static final long TIMEOUT_SERVICE = 2500;
|
||||
private static final long TIMEOUT_ACTIVITY = 1000;
|
||||
|
||||
@@ -251,13 +256,14 @@ public class AssistManager implements ConfigurationChangedReceiver {
|
||||
if (invocationType == INVOCATION_TYPE_GESTURE) {
|
||||
mHandleController.onAssistantGesturePerformed();
|
||||
}
|
||||
args.putInt(INVOCATION_PHONE_STATE_KEY, mPhoneStateMonitor.getPhoneState());
|
||||
int phoneState = mPhoneStateMonitor.getPhoneState();
|
||||
args.putInt(INVOCATION_PHONE_STATE_KEY, phoneState);
|
||||
args.putLong(INVOCATION_TIME_MS_KEY, SystemClock.uptimeMillis());
|
||||
// Logs assistant start with invocation type.
|
||||
MetricsLogger.action(
|
||||
new LogMaker(MetricsEvent.ASSISTANT)
|
||||
.setType(MetricsEvent.TYPE_OPEN).setSubtype(
|
||||
invocationType));
|
||||
.setType(MetricsEvent.TYPE_OPEN)
|
||||
.setSubtype(toLoggingSubType(invocationType, phoneState)));
|
||||
startAssistInternal(args, assistComponent, isService);
|
||||
}
|
||||
|
||||
@@ -437,4 +443,19 @@ public class AssistManager implements ConfigurationChangedReceiver {
|
||||
public void onLockscreenShown() {
|
||||
mAssistUtils.onLockscreenShown();
|
||||
}
|
||||
|
||||
/** Returns the logging flags for the given Assistant invocation type. */
|
||||
public int toLoggingSubType(int invocationType) {
|
||||
return toLoggingSubType(invocationType, mPhoneStateMonitor.getPhoneState());
|
||||
}
|
||||
|
||||
private int toLoggingSubType(int invocationType, int phoneState) {
|
||||
// Note that this logic will break if the number of Assistant invocation types exceeds 7.
|
||||
// There are currently 5 invocation types, but we will be migrating to the new logging
|
||||
// framework in the next update.
|
||||
int subType = mHandleController.areHandlesShowing() ? 0 : 1;
|
||||
subType |= invocationType << 1;
|
||||
subType |= phoneState << 4;
|
||||
return subType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.android.systemui.assist.ui;
|
||||
|
||||
import static com.android.systemui.assist.AssistManager.DISMISS_REASON_INVOCATION_CANCELLED;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
import android.animation.ValueAnimator;
|
||||
@@ -91,6 +93,8 @@ public class DefaultUiController implements AssistManager.UiController {
|
||||
|
||||
@Override // AssistManager.UiController
|
||||
public void onInvocationProgress(int type, float progress) {
|
||||
boolean invocationWasInProgress = mInvocationInProgress;
|
||||
|
||||
if (progress == 1) {
|
||||
animateInvocationCompletion(type, 0);
|
||||
} else if (progress == 0) {
|
||||
@@ -105,16 +109,7 @@ public class DefaultUiController implements AssistManager.UiController {
|
||||
}
|
||||
mLastInvocationProgress = progress;
|
||||
|
||||
// Logs assistant invocation start.
|
||||
if (!mInvocationInProgress && progress > 0.f) {
|
||||
MetricsLogger.action(new LogMaker(MetricsEvent.ASSISTANT)
|
||||
.setType(MetricsEvent.TYPE_ACTION));
|
||||
}
|
||||
// Logs assistant invocation cancelled.
|
||||
if (mInvocationInProgress && progress == 0f) {
|
||||
MetricsLogger.action(new LogMaker(MetricsEvent.ASSISTANT)
|
||||
.setType(MetricsEvent.TYPE_DISMISS).setSubtype(0));
|
||||
}
|
||||
logInvocationProgressMetrics(type, progress, invocationWasInProgress);
|
||||
}
|
||||
|
||||
@Override // AssistManager.UiController
|
||||
@@ -142,6 +137,22 @@ public class DefaultUiController implements AssistManager.UiController {
|
||||
mInvocationLightsView.setColors(color1, color2, color3, color4);
|
||||
}
|
||||
|
||||
protected static void logInvocationProgressMetrics(
|
||||
int type, float progress, boolean invocationWasInProgress) {
|
||||
// Logs assistant invocation start.
|
||||
if (!invocationWasInProgress && progress > 0.f) {
|
||||
MetricsLogger.action(new LogMaker(MetricsEvent.ASSISTANT)
|
||||
.setType(MetricsEvent.TYPE_ACTION)
|
||||
.setSubtype(Dependency.get(AssistManager.class).toLoggingSubType(type)));
|
||||
}
|
||||
// Logs assistant invocation cancelled.
|
||||
if (invocationWasInProgress && progress == 0f) {
|
||||
MetricsLogger.action(new LogMaker(MetricsEvent.ASSISTANT)
|
||||
.setType(MetricsEvent.TYPE_DISMISS)
|
||||
.setSubtype(DISMISS_REASON_INVOCATION_CANCELLED));
|
||||
}
|
||||
}
|
||||
|
||||
private void updateAssistHandleVisibility() {
|
||||
ScreenDecorations decorations = SysUiServiceProvider.getComponent(mRoot.getContext(),
|
||||
ScreenDecorations.class);
|
||||
|
||||
Reference in New Issue
Block a user