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

Commit 5e43dcfc authored by Felipe Leme's avatar Felipe Leme Committed by android-build-merger
Browse files

Merge "Initial implementation of logging metrics for bugreport." into nyc-dev

am: 4e34c4e5

* commit '4e34c4e5':
  Initial implementation of logging metrics for bugreport.
parents 02dce148 4e34c4e5
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -41,6 +41,8 @@ import java.util.zip.ZipOutputStream;
import libcore.io.Streams;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.MetricsProto.MetricsEvent;
import com.google.android.collect.Lists;

import android.accounts.Account;
@@ -506,6 +508,7 @@ public class BugreportProgressService extends Service {
     * Cancels a bugreport upon user's request.
     */
    private void cancel(int id) {
        MetricsLogger.action(this, MetricsEvent.ACTION_BUGREPORT_NOTIFICATION_ACTION_CANCEL);
        Log.v(TAG, "cancel: ID=" + id);
        final BugreportInfo info = getInfo(id);
        if (info != null && !info.finished) {
@@ -582,6 +585,7 @@ public class BugreportProgressService extends Service {
     * change its values.
     */
    private void launchBugreportInfoDialog(int id) {
        MetricsLogger.action(this, MetricsEvent.ACTION_BUGREPORT_NOTIFICATION_ACTION_DETAILS);
        // Copy values so it doesn't lock mProcesses while UI is being updated
        final String name, title, description;
        final BugreportInfo info = getInfo(id);
@@ -610,6 +614,7 @@ public class BugreportProgressService extends Service {
     * upon receiving a {@link #INTENT_BUGREPORT_STARTED}.
     */
    private void takeScreenshot(int id, boolean delayed) {
        MetricsLogger.action(this, MetricsEvent.ACTION_BUGREPORT_NOTIFICATION_ACTION_SCREENSHOT);
        if (getInfo(id) == null) {
            // Most likely am killed Shell before user tapped the notification. Since system might
            // be too busy anwyays, it's better to ignore the notification and switch back to the
@@ -859,6 +864,7 @@ public class BugreportProgressService extends Service {
     * intent, but issuing a warning dialog the first time.
     */
    private void shareBugreport(int id, BugreportInfo sharedInfo) {
        MetricsLogger.action(this, MetricsEvent.ACTION_BUGREPORT_NOTIFICATION_ACTION_SHARE);
        BugreportInfo info = getInfo(id);
        if (info == null) {
            // Service was terminated but notification persisted
@@ -1139,9 +1145,16 @@ public class BugreportProgressService extends Service {
        if (info == null) {
            return;
        }
        if (title != null && !title.equals(info.title)) {
            MetricsLogger.action(this, MetricsEvent.ACTION_BUGREPORT_DETAILS_TITLE_CHANGED);
        }
        info.title = title;
        if (description != null && !description.equals(info.description)) {
            MetricsLogger.action(this, MetricsEvent.ACTION_BUGREPORT_DETAILS_DESCRIPTION_CHANGED);
        }
        info.description = description;
        if (name != null && !name.equals(info.name)) {
            MetricsLogger.action(this, MetricsEvent.ACTION_BUGREPORT_DETAILS_NAME_CHANGED);
            info.name = name;
            updateProgress(info);
        }
@@ -1229,7 +1242,7 @@ public class BugreportProgressService extends Service {
        /**
         * Sets its internal state and displays the dialog.
         */
        private void initialize(Context context, BugreportInfo info) {
        private void initialize(final Context context, BugreportInfo info) {
            // First initializes singleton.
            if (mDialog == null) {
                @SuppressLint("InflateParams")
@@ -1263,6 +1276,8 @@ public class BugreportProgressService extends Service {
                                    @Override
                                    public void onClick(DialogInterface dialog, int id)
                                    {
                                        MetricsLogger.action(context,
                                                MetricsEvent.ACTION_BUGREPORT_DETAILS_CANCELED);
                                        if (!mTempName.equals(mSavedName)) {
                                            // Must restore dumpstate's name since it was changed
                                            // before user clicked OK.
@@ -1307,6 +1322,7 @@ public class BugreportProgressService extends Service {

                    @Override
                    public void onClick(View view) {
                        MetricsLogger.action(context, MetricsEvent.ACTION_BUGREPORT_DETAILS_SAVED);
                        sanitizeName();
                        final String name = mInfoName.getText().toString();
                        final String title = mInfoTitle.getText().toString();
+39 −0
Original line number Diff line number Diff line
@@ -369,5 +369,44 @@ message MetricsEvent {
    // Logged when the user saves a modification to notification importance. Negative numbers
    // indicate the user lowered the importance; positive means they increased it.
    ACTION_SAVE_IMPORTANCE = 291;

    // Interactive bug report initiated from power menu.
    ACTION_BUGREPORT_FROM_POWER_MENU_INTERACTIVE = 292;

    // Full bug report initiated from power menu.
    ACTION_BUGREPORT_FROM_POWER_MENU_FULL = 293;

    // Interactive bug report initiated from Settings.
    ACTION_BUGREPORT_FROM_SETTINGS_INTERACTIVE = 294;

    // Full bug report initiated from Settings.
    ACTION_BUGREPORT_FROM_SETTINGS_FULL = 295;

    // Bug report canceled using system notification.
    ACTION_BUGREPORT_NOTIFICATION_ACTION_CANCEL = 296;

    // Bug report details screen open using system notification.
    ACTION_BUGREPORT_NOTIFICATION_ACTION_DETAILS = 297;

    // Additional Bug report screen shot taken using system notification.
    ACTION_BUGREPORT_NOTIFICATION_ACTION_SCREENSHOT = 298;

    // Bug report shared by user using system notification.
    ACTION_BUGREPORT_NOTIFICATION_ACTION_SHARE = 299;

    // User changed bug report name using the details screen.
    ACTION_BUGREPORT_DETAILS_NAME_CHANGED = 300;

    // User changed bug report title using the details screen.
    ACTION_BUGREPORT_DETAILS_TITLE_CHANGED = 301;

    // User changed bug report description using the details screen.
    ACTION_BUGREPORT_DETAILS_DESCRIPTION_CHANGED = 302;

    // Changes made on bug report details screen were saved by user.
    ACTION_BUGREPORT_DETAILS_SAVED = 303;

    // Changes made on bug report details screen were canceled by user.
    ACTION_BUGREPORT_DETAILS_CANCELED = 304;
  }
}
+4 −0
Original line number Diff line number Diff line
@@ -388,6 +388,8 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
                public void run() {
                    try {
                        // Take an "interactive" bugreport.
                        MetricsLogger.visible(this,
                                MetricsEvent.ACTION_BUGREPORT_FROM_POWER_MENU_INTERACTIVE);
                        ActivityManagerNative.getDefault().requestBugReport(
                                ActivityManager.BUGREPORT_OPTION_INTERACTIVE);
                    } catch (RemoteException e) {
@@ -405,6 +407,8 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
            }
            try {
                // Take a "full" bugreport.
                MetricsLogger.visible(this,
                        MetricsEvent.ACTION_BUGREPORT_FROM_POWER_MENU_FULL);
                ActivityManagerNative.getDefault().requestBugReport(
                        ActivityManager.BUGREPORT_OPTION_FULL);
            } catch (RemoteException e) {