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;
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);
}
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;
+ }
}
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;
@Override // AssistManager.UiController
public void onInvocationProgress(int type, float progress) {
+ boolean invocationWasInProgress = mInvocationInProgress;
+
if (progress == 1) {
animateInvocationCompletion(type, 0);
} else if (progress == 0) {
}
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
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);