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

Commit af29e814 authored by Gavin Corkery's avatar Gavin Corkery
Browse files

Add package information to RescueParty uiderrors

Since RescueParty no longer uses a global rescue level, instead
log rescue level successes/failures with package names. These
logs are surfaced in /data/system/uiderrors.txt

Test: adb shell setprop debug.crash_sysui 1; adb shell stop;
      adb shell start; adb shell cat data/system/uiderrors.txt
Bug: 187289291
Change-Id: I088aeea5ac8c5c610b251b53ba79f153ec491c68
parent a1f1ba17
Loading
Loading
Loading
Loading
+15 −8
Original line number Diff line number Diff line
@@ -361,10 +361,13 @@ public class RescueParty {
        try {
            executeRescueLevelInternal(context, level, failedPackage);
            EventLogTags.writeRescueSuccess(level);
            logCriticalInfo(Log.DEBUG,
                    "Finished rescue level " + levelToString(level));
            String successMsg = "Finished rescue level " + levelToString(level);
            if (!TextUtils.isEmpty(failedPackage)) {
                successMsg += " for package " + failedPackage;
            }
            logCriticalInfo(Log.DEBUG, successMsg);
        } catch (Throwable t) {
            logRescueException(level, t);
            logRescueException(level, failedPackage, t);
        }
    }

@@ -427,7 +430,7 @@ public class RescueParty {
                            pm.reboot(TAG);
                        }
                    } catch (Throwable t) {
                        logRescueException(level, t);
                        logRescueException(level, failedPackage, t);
                    }
                };
                thread = new Thread(runnable);
@@ -441,7 +444,7 @@ public class RescueParty {
                        try {
                            RecoverySystem.rebootPromptAndWipeUserData(context, TAG);
                        } catch (Throwable t) {
                            logRescueException(level, t);
                            logRescueException(level, failedPackage, t);
                        }
                    }
                };
@@ -455,11 +458,15 @@ public class RescueParty {
        }
    }

    private static void logRescueException(int level, Throwable t) {
    private static void logRescueException(int level, @Nullable String failedPackageName,
            Throwable t) {
        final String msg = ExceptionUtils.getCompleteMessage(t);
        EventLogTags.writeRescueFailure(level, msg);
        logCriticalInfo(Log.ERROR,
                "Failed rescue level " + levelToString(level) + ": " + msg);
        String failureMsg = "Failed rescue level " + levelToString(level);
        if (!TextUtils.isEmpty(failedPackageName)) {
            failureMsg += " for package " + failedPackageName;
        }
        logCriticalInfo(Log.ERROR, failureMsg + ": " + msg);
    }

    private static int mapRescueLevelToUserImpact(int rescueLevel) {