Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 35604f02 authored by Miranda Kephart's avatar Miranda Kephart
Browse files

Add logging on invocation

Logs when an invocation is started, cancelled, or completed (along with
the invocation type). Also reduces spurious "cancellations" by ignoring
cancellations while we are completing an animation. (This occurs
because Launcher sends progress values back down to zero on TOUCH_UP,
sometimes even if there was a fling, and we don't want to log a
cancelled drag if it was actually completed as a fling.)

Bug: 141195388
Test: manual
Change-Id: I25c04f1c213515def0136c03b89daf331e43d522
parent eba21f1d
Loading
Loading
Loading
Loading
+21 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.systemui.assist.ui;

import static com.android.systemui.assist.AssistManager.DISMISS_REASON_INVOCATION_CANCELLED;
import static com.android.systemui.assist.AssistManager.INVOCATION_TYPE_GESTURE;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
@@ -24,6 +25,7 @@ import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.PixelFormat;
import android.metrics.LogMaker;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
@@ -40,6 +42,8 @@ import com.android.systemui.ScreenDecorations;
import com.android.systemui.SysUiServiceProvider;
import com.android.systemui.assist.AssistManager;

import java.util.Locale;

/**
 * Default UiController implementation. Shows white edge lights along the bottom of the phone,
 * expanding from the corners to meet in the center.
@@ -50,6 +54,9 @@ public class DefaultUiController implements AssistManager.UiController {

    private static final long ANIM_DURATION_MS = 200;

    private static final boolean VERBOSE = Build.TYPE.toLowerCase(Locale.ROOT).contains("debug")
            || Build.TYPE.toLowerCase(Locale.ROOT).equals("eng");

    protected final FrameLayout mRoot;
    protected InvocationLightsView mInvocationLightsView;

@@ -114,6 +121,7 @@ public class DefaultUiController implements AssistManager.UiController {
    @Override // AssistManager.UiController
    public void onGestureCompletion(float velocity) {
        animateInvocationCompletion(AssistManager.INVOCATION_TYPE_GESTURE, velocity);
        logInvocationProgressMetrics(INVOCATION_TYPE_GESTURE, 1, mInvocationInProgress);
    }

    @Override // AssistManager.UiController
@@ -127,16 +135,27 @@ public class DefaultUiController implements AssistManager.UiController {
        updateAssistHandleVisibility();
    }

    protected static void logInvocationProgressMetrics(
    protected void logInvocationProgressMetrics(
            int type, float progress, boolean invocationWasInProgress) {
        // Logs assistant invocation start.
        if (progress == 1f) {
            if (VERBOSE) {
                Log.v(TAG, "Invocation complete: type=" + type);
            }
        }
        if (!invocationWasInProgress && progress > 0.f) {
            if (VERBOSE) {
                Log.v(TAG, "Invocation started: type=" + type);
            }
            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) {
        if (!mInvocationAnimator.isRunning() && invocationWasInProgress && progress == 0f) {
            if (VERBOSE) {
                Log.v(TAG, "Invocation cancelled: type=" + type);
            }
            MetricsLogger.action(new LogMaker(MetricsEvent.ASSISTANT)
                    .setType(MetricsEvent.TYPE_DISMISS)
                    .setSubtype(DISMISS_REASON_INVOCATION_CANCELLED));