Loading src/com/android/settings/BugreportPreference.java +16 −40 Original line number Diff line number Diff line Loading @@ -21,30 +21,20 @@ import android.app.settings.SettingsEnums; import android.content.Context; import android.content.DialogInterface; import android.os.RemoteException; import android.os.BugreportParams; import android.os.SystemProperties; import android.util.AttributeSet; import android.util.FeatureFlagUtils; import android.util.Log; import android.view.View; import android.widget.CheckedTextView; import android.widget.TextView; import android.content.Intent; import androidx.appcompat.app.AlertDialog.Builder; import com.android.settings.core.FeatureFlags; import com.android.settings.overlay.FeatureFactory; import com.android.settingslib.CustomDialogPreferenceCompat; public class BugreportPreference extends CustomDialogPreferenceCompat { private static final String TAG = "BugreportPreference"; private static final String INTENT_BUGREPORT_REQUESTED = "com.android.internal.intent.action.BUGREPORT_REQUESTED"; private static final String EXTRA_ORIGINAL_INTENT = "android.intent.extra.ORIGINAL_INTENT"; private static final String EXTRA_BUGREPORT_TYPE = "android.intent.extra.BUGREPORT_TYPE"; private static final String SHELL_APP_PACKAGE = "com.android.shell"; private CheckedTextView mInteractiveTitle; private TextView mInteractiveSummary; Loading @@ -56,12 +46,15 @@ public class BugreportPreference extends CustomDialogPreferenceCompat { } @Override protected void onPrepareDialogBuilder(Builder builder, DialogInterface.OnClickListener listener) { protected void onPrepareDialogBuilder(Builder builder, DialogInterface.OnClickListener listener) { super.onPrepareDialogBuilder(builder, listener); final View dialogView = View.inflate(getContext(), R.layout.bugreport_options_dialog, null); mInteractiveTitle = (CheckedTextView) dialogView.findViewById(R.id.bugreport_option_interactive_title); mInteractiveSummary = (TextView) dialogView.findViewById(R.id.bugreport_option_interactive_summary); mInteractiveTitle = (CheckedTextView) dialogView .findViewById(R.id.bugreport_option_interactive_title); mInteractiveSummary = (TextView) dialogView .findViewById(R.id.bugreport_option_interactive_summary); mFullTitle = (CheckedTextView) dialogView.findViewById(R.id.bugreport_option_full_title); mFullSummary = (TextView) dialogView.findViewById(R.id.bugreport_option_full_summary); final View.OnClickListener l = new View.OnClickListener() { Loading Loading @@ -96,38 +89,21 @@ public class BugreportPreference extends CustomDialogPreferenceCompat { Log.v(TAG, "Taking full bugreport right away"); FeatureFactory.getFactory(context).getMetricsFeatureProvider().action(context, SettingsEnums.ACTION_BUGREPORT_FROM_SETTINGS_FULL); takeBugreport(ActivityManager.BUGREPORT_OPTION_FULL); try { ActivityManager.getService().requestFullBugReport(); } catch (RemoteException e) { Log.e(TAG, "error taking bugreport (bugreportType=Full)", e); } } else { Log.v(TAG, "Taking interactive bugreport right away"); FeatureFactory.getFactory(context).getMetricsFeatureProvider().action(context, SettingsEnums.ACTION_BUGREPORT_FROM_SETTINGS_INTERACTIVE); takeBugreport(ActivityManager.BUGREPORT_OPTION_INTERACTIVE); } } } private void takeBugreport(int bugreportType) { try { final Context context = getContext(); // USE_BUGREPORT_API is a system property flag used to switch back to the old workflow // using dumpstate. By using the default value as true, new workflow using Bugreport // API is triggered. To switch to the old workflow directly using dumpstate run the // following commands on the terminal: // * adb root // * adb shell setprop settings_use_bugreport_api false if (FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.USE_BUGREPORT_API)) { Intent triggerShellBugreport = new Intent(); triggerShellBugreport.setAction(INTENT_BUGREPORT_REQUESTED); triggerShellBugreport.setPackage(SHELL_APP_PACKAGE); triggerShellBugreport.putExtra(EXTRA_BUGREPORT_TYPE, bugreportType); // Send broadcast to shell to trigger bugreport using Bugreport API context.sendBroadcast(triggerShellBugreport); } else { ActivityManager.getService().requestBugReport(bugreportType); } ActivityManager.getService().requestInteractiveBugReport(); } catch (RemoteException e) { Log.e(TAG, "error taking bugreport (bugreportType=" + bugreportType + ")", e); Log.e(TAG, "error taking bugreport (bugreportType=Interactive)", e); } } } } } Loading
src/com/android/settings/BugreportPreference.java +16 −40 Original line number Diff line number Diff line Loading @@ -21,30 +21,20 @@ import android.app.settings.SettingsEnums; import android.content.Context; import android.content.DialogInterface; import android.os.RemoteException; import android.os.BugreportParams; import android.os.SystemProperties; import android.util.AttributeSet; import android.util.FeatureFlagUtils; import android.util.Log; import android.view.View; import android.widget.CheckedTextView; import android.widget.TextView; import android.content.Intent; import androidx.appcompat.app.AlertDialog.Builder; import com.android.settings.core.FeatureFlags; import com.android.settings.overlay.FeatureFactory; import com.android.settingslib.CustomDialogPreferenceCompat; public class BugreportPreference extends CustomDialogPreferenceCompat { private static final String TAG = "BugreportPreference"; private static final String INTENT_BUGREPORT_REQUESTED = "com.android.internal.intent.action.BUGREPORT_REQUESTED"; private static final String EXTRA_ORIGINAL_INTENT = "android.intent.extra.ORIGINAL_INTENT"; private static final String EXTRA_BUGREPORT_TYPE = "android.intent.extra.BUGREPORT_TYPE"; private static final String SHELL_APP_PACKAGE = "com.android.shell"; private CheckedTextView mInteractiveTitle; private TextView mInteractiveSummary; Loading @@ -56,12 +46,15 @@ public class BugreportPreference extends CustomDialogPreferenceCompat { } @Override protected void onPrepareDialogBuilder(Builder builder, DialogInterface.OnClickListener listener) { protected void onPrepareDialogBuilder(Builder builder, DialogInterface.OnClickListener listener) { super.onPrepareDialogBuilder(builder, listener); final View dialogView = View.inflate(getContext(), R.layout.bugreport_options_dialog, null); mInteractiveTitle = (CheckedTextView) dialogView.findViewById(R.id.bugreport_option_interactive_title); mInteractiveSummary = (TextView) dialogView.findViewById(R.id.bugreport_option_interactive_summary); mInteractiveTitle = (CheckedTextView) dialogView .findViewById(R.id.bugreport_option_interactive_title); mInteractiveSummary = (TextView) dialogView .findViewById(R.id.bugreport_option_interactive_summary); mFullTitle = (CheckedTextView) dialogView.findViewById(R.id.bugreport_option_full_title); mFullSummary = (TextView) dialogView.findViewById(R.id.bugreport_option_full_summary); final View.OnClickListener l = new View.OnClickListener() { Loading Loading @@ -96,38 +89,21 @@ public class BugreportPreference extends CustomDialogPreferenceCompat { Log.v(TAG, "Taking full bugreport right away"); FeatureFactory.getFactory(context).getMetricsFeatureProvider().action(context, SettingsEnums.ACTION_BUGREPORT_FROM_SETTINGS_FULL); takeBugreport(ActivityManager.BUGREPORT_OPTION_FULL); try { ActivityManager.getService().requestFullBugReport(); } catch (RemoteException e) { Log.e(TAG, "error taking bugreport (bugreportType=Full)", e); } } else { Log.v(TAG, "Taking interactive bugreport right away"); FeatureFactory.getFactory(context).getMetricsFeatureProvider().action(context, SettingsEnums.ACTION_BUGREPORT_FROM_SETTINGS_INTERACTIVE); takeBugreport(ActivityManager.BUGREPORT_OPTION_INTERACTIVE); } } } private void takeBugreport(int bugreportType) { try { final Context context = getContext(); // USE_BUGREPORT_API is a system property flag used to switch back to the old workflow // using dumpstate. By using the default value as true, new workflow using Bugreport // API is triggered. To switch to the old workflow directly using dumpstate run the // following commands on the terminal: // * adb root // * adb shell setprop settings_use_bugreport_api false if (FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.USE_BUGREPORT_API)) { Intent triggerShellBugreport = new Intent(); triggerShellBugreport.setAction(INTENT_BUGREPORT_REQUESTED); triggerShellBugreport.setPackage(SHELL_APP_PACKAGE); triggerShellBugreport.putExtra(EXTRA_BUGREPORT_TYPE, bugreportType); // Send broadcast to shell to trigger bugreport using Bugreport API context.sendBroadcast(triggerShellBugreport); } else { ActivityManager.getService().requestBugReport(bugreportType); } ActivityManager.getService().requestInteractiveBugReport(); } catch (RemoteException e) { Log.e(TAG, "error taking bugreport (bugreportType=" + bugreportType + ")", e); Log.e(TAG, "error taking bugreport (bugreportType=Interactive)", e); } } } } }