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

Commit c319a30b authored by Harshit Mahajan's avatar Harshit Mahajan Committed by Android (Google) Code Review
Browse files

Merge "Remove observer specific logic in PackageWatchdog" into main

parents 42001174 f604fc6a
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -1304,7 +1304,7 @@ public class PackageWatchdog {

    /** Dump status of every observer in mAllObservers. */
    public void dump(@NonNull PrintWriter pw) {
        if (Flags.synchronousRebootInRescueParty() && RescueParty.isRecoveryTriggeredReboot()) {
        if (Flags.synchronousRebootInRescueParty() && isRecoveryTriggeredReboot()) {
            dumpInternal(pw);
        } else {
            synchronized (sLock) {
@@ -1313,6 +1313,24 @@ public class PackageWatchdog {
        }
    }

    /**
     * Check if we're currently attempting to reboot during mitigation. This method must return
     * true if triggered reboot early during a boot loop, since the device will not be fully booted
     * at this time.
     * @hide
     */
    public static boolean isRecoveryTriggeredReboot() {
        return isFactoryResetPropertySet() || isRebootPropertySet();
    }

    private static boolean isFactoryResetPropertySet() {
        return CrashRecoveryProperties.attemptingFactoryReset().orElse(false);
    }

    private static boolean isRebootPropertySet() {
        return CrashRecoveryProperties.attemptingReboot().orElse(false);
    }

    private void dumpInternal(@NonNull PrintWriter pw) {
        IndentingPrintWriter ipw = new IndentingPrintWriter(pw, "  ");
        ipw.println("Package Watchdog status");