summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Harshit Mahajan <harshitmahajan@google.com> 2024-11-16 00:00:41 +0000
committer Harshit Mahajan <harshitmahajan@google.com> 2024-11-16 00:05:56 +0000
commitf604fc6aa81bbb42fc9c4bf8842b3012e13a945f (patch)
tree146a1106f513243f69202605db6a8180cdd1cbbb
parent55fc3d50bef51fdb4850816ce30964ab71c81a94 (diff)
Remove observer specific logic in PackageWatchdog
PackageWatchdog should not directly call RescueParty APIs. Moving isRecoveryTriggeredReboot API to PackageWatchdog, as it can return true even if RollbackPackageHealthObserver triggers reboot. Bug: 289203818 Test: TH Flag: android.crashrecovery.flags.synchronous_reboot_in_rescue_party Change-Id: I26efd6731bad1419ccdbeba461b64c36b054425e
-rw-r--r--packages/CrashRecovery/services/module/java/com/android/server/PackageWatchdog.java20
1 files changed, 19 insertions, 1 deletions
diff --git a/packages/CrashRecovery/services/module/java/com/android/server/PackageWatchdog.java b/packages/CrashRecovery/services/module/java/com/android/server/PackageWatchdog.java
index fbf51fd7cca7..cda2c216fe20 100644
--- a/packages/CrashRecovery/services/module/java/com/android/server/PackageWatchdog.java
+++ b/packages/CrashRecovery/services/module/java/com/android/server/PackageWatchdog.java
@@ -1297,7 +1297,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 (mLock) {
@@ -1306,6 +1306,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");