Merge "Fix SysUI-Assistant metrics logging" into qt-dev
am: 1d6d10dc6f
Change-Id: I3eacdcdc6a489823944578d9cb90d1970b45dbda
This commit is contained in:
@@ -142,6 +142,10 @@ public final class AssistHandleBehaviorController implements AssistHandleCallbac
|
|||||||
mHandler.post(() -> maybeShowHandles(/* ignoreThreshold = */ true));
|
mHandler.post(() -> maybeShowHandles(/* ignoreThreshold = */ true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean areHandlesShowing() {
|
||||||
|
return mHandlesShowing;
|
||||||
|
}
|
||||||
|
|
||||||
void onAssistantGesturePerformed() {
|
void onAssistantGesturePerformed() {
|
||||||
mBehaviorMap.get(mCurrentBehavior).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_TYPE_QUICK_SEARCH_BAR = 4;
|
||||||
public static final int INVOCATION_HOME_BUTTON_LONG_PRESS = 5;
|
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_SERVICE = 2500;
|
||||||
private static final long TIMEOUT_ACTIVITY = 1000;
|
private static final long TIMEOUT_ACTIVITY = 1000;
|
||||||
|
|
||||||
@@ -251,13 +256,14 @@ public class AssistManager implements ConfigurationChangedReceiver {
|
|||||||
if (invocationType == INVOCATION_TYPE_GESTURE) {
|
if (invocationType == INVOCATION_TYPE_GESTURE) {
|
||||||
mHandleController.onAssistantGesturePerformed();
|
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());
|
args.putLong(INVOCATION_TIME_MS_KEY, SystemClock.uptimeMillis());
|
||||||
// Logs assistant start with invocation type.
|
// Logs assistant start with invocation type.
|
||||||
MetricsLogger.action(
|
MetricsLogger.action(
|
||||||
new LogMaker(MetricsEvent.ASSISTANT)
|
new LogMaker(MetricsEvent.ASSISTANT)
|
||||||
.setType(MetricsEvent.TYPE_OPEN).setSubtype(
|
.setType(MetricsEvent.TYPE_OPEN)
|
||||||
invocationType));
|
.setSubtype(toLoggingSubType(invocationType, phoneState)));
|
||||||
startAssistInternal(args, assistComponent, isService);
|
startAssistInternal(args, assistComponent, isService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -437,4 +443,19 @@ public class AssistManager implements ConfigurationChangedReceiver {
|
|||||||
public void onLockscreenShown() {
|
public void onLockscreenShown() {
|
||||||
mAssistUtils.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;
|
package com.android.systemui.assist.ui;
|
||||||
|
|
||||||
|
import static com.android.systemui.assist.AssistManager.DISMISS_REASON_INVOCATION_CANCELLED;
|
||||||
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
import android.animation.AnimatorListenerAdapter;
|
import android.animation.AnimatorListenerAdapter;
|
||||||
import android.animation.ValueAnimator;
|
import android.animation.ValueAnimator;
|
||||||
@@ -91,6 +93,8 @@ public class DefaultUiController implements AssistManager.UiController {
|
|||||||
|
|
||||||
@Override // AssistManager.UiController
|
@Override // AssistManager.UiController
|
||||||
public void onInvocationProgress(int type, float progress) {
|
public void onInvocationProgress(int type, float progress) {
|
||||||
|
boolean invocationWasInProgress = mInvocationInProgress;
|
||||||
|
|
||||||
if (progress == 1) {
|
if (progress == 1) {
|
||||||
animateInvocationCompletion(type, 0);
|
animateInvocationCompletion(type, 0);
|
||||||
} else if (progress == 0) {
|
} else if (progress == 0) {
|
||||||
@@ -105,16 +109,7 @@ public class DefaultUiController implements AssistManager.UiController {
|
|||||||
}
|
}
|
||||||
mLastInvocationProgress = progress;
|
mLastInvocationProgress = progress;
|
||||||
|
|
||||||
// Logs assistant invocation start.
|
logInvocationProgressMetrics(type, progress, invocationWasInProgress);
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // AssistManager.UiController
|
@Override // AssistManager.UiController
|
||||||
@@ -142,6 +137,22 @@ public class DefaultUiController implements AssistManager.UiController {
|
|||||||
mInvocationLightsView.setColors(color1, color2, color3, color4);
|
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() {
|
private void updateAssistHandleVisibility() {
|
||||||
ScreenDecorations decorations = SysUiServiceProvider.getComponent(mRoot.getContext(),
|
ScreenDecorations decorations = SysUiServiceProvider.getComponent(mRoot.getContext(),
|
||||||
ScreenDecorations.class);
|
ScreenDecorations.class);
|
||||||
|
|||||||
Reference in New Issue
Block a user