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

Commit 4561dda7 authored by Harshit Mahajan's avatar Harshit Mahajan
Browse files

Refactoring RescueParty for CrashRecovery

1. Move away from hidden Build APIs
2. Remove ExceptionUtils dependency

Bug: b/289203818
Test: m

Change-Id: I3025cac57978a1e9b3b789c315737cdcb88fa98e
parent 4dc30852
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ import android.provider.Settings;
import android.sysprop.CrashRecoveryProperties;
import android.text.TextUtils;
import android.util.ArraySet;
import android.util.ExceptionUtils;
import android.util.Log;
import android.util.Slog;

@@ -136,7 +135,7 @@ public class RescueParty {
        }

        // We're disabled on all engineering devices
        if (Build.IS_ENG) {
        if (Build.TYPE.equals("eng")) {
            Slog.v(TAG, "Disabled because of eng build");
            return true;
        }
@@ -144,7 +143,7 @@ public class RescueParty {
        // We're disabled on userdebug devices connected over USB, since that's
        // a decent signal that someone is actively trying to debug the device,
        // or that it's in a lab environment.
        if (Build.IS_USERDEBUG && isUsbActive()) {
        if (Build.TYPE.equals("userdebug") && isUsbActive()) {
            Slog.v(TAG, "Disabled because of active USB connection");
            return true;
        }
@@ -478,9 +477,18 @@ public class RescueParty {
        }
    }

    private static String getCompleteMessage(Throwable t) {
        final StringBuilder builder = new StringBuilder();
        builder.append(t.getMessage());
        while ((t = t.getCause()) != null) {
            builder.append(": ").append(t.getMessage());
        }
        return builder.toString();
    }

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