From 038bf65686bdb07eb73c068aa74f62134a48c96f Mon Sep 17 00:00:00 2001 From: Felipe Leme Date: Thu, 25 Feb 2016 11:37:56 -0800 Subject: [PATCH] Makes call to MetricsLogger right away when taking bugreports. Previously the call was made on takeBugreport(), which caused a NPE on interative report calls because the context was null since it was handled by a handler. BUG: 27354167 Change-Id: I19e91cb4b43a7aa0bfcdab440c4cd4225110fdfb --- .../android/settings/BugreportPreference.java | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/com/android/settings/BugreportPreference.java b/src/com/android/settings/BugreportPreference.java index 68ee5622eee..35896603af1 100644 --- a/src/com/android/settings/BugreportPreference.java +++ b/src/com/android/settings/BugreportPreference.java @@ -87,9 +87,13 @@ public class BugreportPreference extends CustomDialogPreference { if (mFullTitle.isChecked()) { Log.v(TAG, "Taking full bugreport right away"); + MetricsLogger.action(getDialog().getContext(), + MetricsEvent.ACTION_BUGREPORT_FROM_SETTINGS_FULL); takeBugreport(ActivityManager.BUGREPORT_OPTION_FULL); } else { Log.v(TAG, "Taking interactive bugreport in " + BUGREPORT_DELAY_SECONDS + "s"); + MetricsLogger.action(getDialog().getContext(), + MetricsEvent.ACTION_BUGREPORT_FROM_SETTINGS_INTERACTIVE); // Add a little delay before executing, to give the user a chance to close // the Settings activity before it takes a screenshot. final Context context = getContext(); @@ -110,18 +114,6 @@ public class BugreportPreference extends CustomDialogPreference { private void takeBugreport(int bugreportType) { try { - switch (bugreportType) { - case ActivityManager.BUGREPORT_OPTION_FULL: - MetricsLogger.action(getDialog().getContext(), - MetricsEvent.ACTION_BUGREPORT_FROM_SETTINGS_FULL); - break; - case ActivityManager.BUGREPORT_OPTION_INTERACTIVE: - MetricsLogger.action(getDialog().getContext(), - MetricsEvent.ACTION_BUGREPORT_FROM_SETTINGS_INTERACTIVE); - break; - default: - Log.w(TAG, "Unknown bugreportType: " + bugreportType); - } ActivityManagerNative.getDefault().requestBugReport(bugreportType); } catch (RemoteException e) { Log.e(TAG, "error taking bugreport (bugreportType=" + bugreportType + ")", e);