From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Dmitry Muhomor Date: Mon, 8 Aug 2022 19:03:37 +0300 Subject: [PATCH] add an option to show the details of an application error to the user Adds a "Show details" item to crash and ANR (app not responding) dialogs that takes the user to a SystemUI activity which shows the error details and allows to copy them to the clipboard or to export them via the standard sharing UI. --- .../android/app/ApplicationErrorReport.java | 14 +- core/res/res/layout/app_anr_dialog.xml | 4 +- core/res/res/layout/app_error_dialog.xml | 4 +- core/res/res/values/strings.xml | 3 + core/res/res/values/symbols.xml | 3 + packages/SystemUI/AndroidManifest.xml | 13 ++ packages/SystemUI/res/values/strings.xml | 5 + .../android/systemui/ErrorReportActivity.kt | 159 ++++++++++++++++++ .../java/com/android/server/am/AppErrors.java | 1 + 9 files changed, 200 insertions(+), 6 deletions(-) create mode 100644 packages/SystemUI/src/com/android/systemui/ErrorReportActivity.kt diff --git a/core/java/android/app/ApplicationErrorReport.java b/core/java/android/app/ApplicationErrorReport.java index a0b3dc0452ac..d6b9a837c46b 100644 --- a/core/java/android/app/ApplicationErrorReport.java +++ b/core/java/android/app/ApplicationErrorReport.java @@ -98,6 +98,9 @@ public class ApplicationErrorReport implements Parcelable { */ public String packageName; + /** @hide */ + public long packageVersion; + /** * Package name of the application which installed the application this * report pertains to. @@ -162,13 +165,18 @@ public class ApplicationErrorReport implements Parcelable { String packageName, int appFlags) { // check if error reporting is enabled in secure settings int enabled = Settings.Global.getInt(context.getContentResolver(), - Settings.Global.SEND_ACTION_APP_ERROR, 0); + Settings.Global.SEND_ACTION_APP_ERROR, 1); if (enabled == 0) { return null; } PackageManager pm = context.getPackageManager(); + ComponentName systemUiReceiver = getErrorReportReceiver(pm, packageName, "com.android.systemui"); + if (systemUiReceiver != null) { + return systemUiReceiver; + } + // look for receiver in the installer package String candidate = null; ComponentName result = null; @@ -233,6 +241,7 @@ public class ApplicationErrorReport implements Parcelable { public void writeToParcel(Parcel dest, int flags) { dest.writeInt(type); dest.writeString(packageName); + dest.writeLong(packageVersion); dest.writeString(installerPackageName); dest.writeString(processName); dest.writeLong(time); @@ -260,6 +269,7 @@ public class ApplicationErrorReport implements Parcelable { public void readFromParcel(Parcel in) { type = in.readInt(); packageName = in.readString(); + packageVersion = in.readLong(); installerPackageName = in.readString(); processName = in.readString(); time = in.readLong(); @@ -686,7 +696,7 @@ public class ApplicationErrorReport implements Parcelable { */ public void dump(Printer pw, String prefix) { pw.println(prefix + "type: " + type); - pw.println(prefix + "packageName: " + packageName); + pw.println(prefix + "packageName: " + packageName + ":" + packageVersion); pw.println(prefix + "installerPackageName: " + installerPackageName); pw.println(prefix + "processName: " + processName); pw.println(prefix + "time: " + time); diff --git a/core/res/res/layout/app_anr_dialog.xml b/core/res/res/layout/app_anr_dialog.xml index 5ad0f4c0f6cc..ad3a2d2991de 100644 --- a/core/res/res/layout/app_anr_dialog.xml +++ b/core/res/res/layout/app_anr_dialog.xml @@ -41,8 +41,8 @@ android:id="@+id/aerr_report" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="@string/aerr_report" - android:drawableStart="@drawable/ic_feedback" + android:text="@string/aerr_show_details" + android:drawableStart="@drawable/ic_info_outline_24" style="@style/aerr_list_item" /> diff --git a/core/res/res/layout/app_error_dialog.xml b/core/res/res/layout/app_error_dialog.xml index c3b149a1e295..a47b82018377 100644 --- a/core/res/res/layout/app_error_dialog.xml +++ b/core/res/res/layout/app_error_dialog.xml @@ -52,8 +52,8 @@ android:id="@+id/aerr_report" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="@string/aerr_report" - android:drawableStart="@drawable/ic_feedback" + android:text="@string/aerr_show_details" + android:drawableStart="@drawable/ic_info_outline_24" style="@style/aerr_list_item" />