mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2024-12-14 10:24:32 -05:00
07951955d3
Signed-off-by: Tavi <tavi@divested.dev>
195 lines
8.5 KiB
Diff
195 lines
8.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Dmitry Muhomor <muhomor.dmitry@gmail.com>
|
|
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 | 29 +++++++++++++++++--
|
|
core/res/res/layout/app_anr_dialog.xml | 4 +--
|
|
core/res/res/layout/app_error_dialog.xml | 4 +--
|
|
core/res/res/values/strings.xml | 2 ++
|
|
core/res/res/values/symbols.xml | 3 ++
|
|
.../java/com/android/server/am/AppErrors.java | 1 +
|
|
6 files changed, 37 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/core/java/android/app/ApplicationErrorReport.java b/core/java/android/app/ApplicationErrorReport.java
|
|
index 9cea5e8ef4cf..a8f51104d0fa 100644
|
|
--- a/core/java/android/app/ApplicationErrorReport.java
|
|
+++ b/core/java/android/app/ApplicationErrorReport.java
|
|
@@ -25,6 +25,8 @@ import android.content.pm.ResolveInfo;
|
|
import android.os.Binder;
|
|
import android.os.Parcel;
|
|
import android.os.Parcelable;
|
|
+import android.os.Process;
|
|
+import android.os.SystemClock;
|
|
import android.os.SystemProperties;
|
|
import android.provider.Settings;
|
|
import android.util.Printer;
|
|
@@ -98,6 +100,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 +167,19 @@ 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 logViewerApp = getErrorReportReceiver(pm, packageName,
|
|
+ android.ext.LogViewerApp.getPackageName());
|
|
+ if (logViewerApp != null) {
|
|
+ return logViewerApp;
|
|
+ }
|
|
+
|
|
// look for receiver in the installer package
|
|
String candidate = null;
|
|
ComponentName result = null;
|
|
@@ -233,6 +244,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 +272,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();
|
|
@@ -345,6 +358,11 @@ public class ApplicationErrorReport implements Parcelable {
|
|
*/
|
|
public String crashTag;
|
|
|
|
+ /** @hide */
|
|
+ public long processUptimeMs;
|
|
+ /** @hide */
|
|
+ public long processStartupLatencyMs;
|
|
+
|
|
/**
|
|
* Create an uninitialized instance of CrashInfo.
|
|
*/
|
|
@@ -398,6 +416,9 @@ public class ApplicationErrorReport implements Parcelable {
|
|
}
|
|
|
|
exceptionMessage = sanitizeString(exceptionMessage);
|
|
+
|
|
+ processUptimeMs = SystemClock.elapsedRealtime() - Process.getStartElapsedRealtime();
|
|
+ processStartupLatencyMs = Process.getStartElapsedRealtime() - Process.getStartRequestedElapsedRealtime();
|
|
}
|
|
|
|
/** {@hide} */
|
|
@@ -439,6 +460,8 @@ public class ApplicationErrorReport implements Parcelable {
|
|
throwLineNumber = in.readInt();
|
|
stackTrace = in.readString();
|
|
crashTag = in.readString();
|
|
+ processUptimeMs = in.readLong();
|
|
+ processStartupLatencyMs = in.readLong();
|
|
}
|
|
|
|
/**
|
|
@@ -455,6 +478,8 @@ public class ApplicationErrorReport implements Parcelable {
|
|
dest.writeInt(throwLineNumber);
|
|
dest.writeString(stackTrace);
|
|
dest.writeString(crashTag);
|
|
+ dest.writeLong(processUptimeMs);
|
|
+ dest.writeLong(processStartupLatencyMs);
|
|
int total = dest.dataPosition()-start;
|
|
if (Binder.CHECK_PARCEL_SIZE && total > 20*1024) {
|
|
Slog.d("Error", "ERR: exHandler=" + exceptionHandlerClassName);
|
|
@@ -704,7 +729,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" />
|
|
|
|
</LinearLayout>
|
|
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" />
|
|
|
|
<Button
|
|
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
|
|
index fe69b195ea4c..bca56dba6b76 100644
|
|
--- a/core/res/res/values/strings.xml
|
|
+++ b/core/res/res/values/strings.xml
|
|
@@ -6380,4 +6380,6 @@ ul.</string>
|
|
<!-- Communal profile label on a screen. This can be used as a tab label for this profile in tabbed views and can be used to represent the profile in sharing surfaces, etc. [CHAR LIMIT=20] -->
|
|
<string name="profile_label_communal">Communal</string>
|
|
|
|
+ <!-- Button that opens the screen with details of an application error -->
|
|
+ <string name="aerr_show_details">Show details</string>
|
|
</resources>
|
|
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
|
|
index fd6158d02b8f..6c3c6c1f4e46 100644
|
|
--- a/core/res/res/values/symbols.xml
|
|
+++ b/core/res/res/values/symbols.xml
|
|
@@ -5129,6 +5129,9 @@
|
|
<java-symbol type="id" name="language_picker_item" />
|
|
<java-symbol type="id" name="language_picker_header" />
|
|
|
|
+ <!-- Button that opens the screen with details of an application error -->
|
|
+ <java-symbol type="string" name="aerr_show_details" />
|
|
+
|
|
<java-symbol type="dimen" name="status_bar_height_default" />
|
|
|
|
<java-symbol type="string" name="default_card_name"/>
|
|
diff --git a/services/core/java/com/android/server/am/AppErrors.java b/services/core/java/com/android/server/am/AppErrors.java
|
|
index 061bcd740f6b..937b0eacff66 100644
|
|
--- a/services/core/java/com/android/server/am/AppErrors.java
|
|
+++ b/services/core/java/com/android/server/am/AppErrors.java
|
|
@@ -838,6 +838,7 @@ class AppErrors {
|
|
|
|
ApplicationErrorReport report = new ApplicationErrorReport();
|
|
report.packageName = r.info.packageName;
|
|
+ report.packageVersion = r.info.longVersionCode;
|
|
report.installerPackageName = errState.getErrorReportReceiver().getPackageName();
|
|
report.processName = r.processName;
|
|
report.time = timeMillis;
|