Loading AconfigFlags.bp +4 −0 Original line number Diff line number Diff line Loading @@ -1560,6 +1560,10 @@ java_aconfig_library { name: "android.crashrecovery.flags-aconfig-java", aconfig_declarations: "android.crashrecovery.flags-aconfig", defaults: ["framework-minus-apex-aconfig-java-defaults"], apex_available: [ "//apex_available:platform", "com.android.crashrecovery", ], } java_aconfig_library { Loading core/java/Android.bp +7 −0 Original line number Diff line number Diff line Loading @@ -344,6 +344,13 @@ filegroup { ], } filegroup { name: "service-crashrecovery-shared-srcs", srcs: [ "android/util/IndentingPrintWriter.java", ], } filegroup { name: "incremental_aidl", srcs: [ Loading packages/CrashRecovery/services/module/java/com/android/server/PackageWatchdog.java +30 −14 Original line number Diff line number Diff line Loading @@ -24,9 +24,12 @@ import static com.android.server.crashrecovery.CrashRecoveryUtils.dumpCrashRecov import static java.lang.annotation.RetentionPolicy.SOURCE; import android.annotation.FlaggedApi; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SuppressLint; import android.annotation.SystemApi; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; Loading Loading @@ -94,6 +97,8 @@ import java.util.concurrent.TimeUnit; * be notified. * @hide */ @FlaggedApi(Flags.FLAG_ENABLE_CRASHRECOVERY) @SystemApi(client = SystemApi.Client.SYSTEM_SERVER) public class PackageWatchdog { private static final String TAG = "PackageWatchdog"; Loading Loading @@ -351,7 +356,7 @@ public class PackageWatchdog { * * <p>If monitoring a package supporting explicit health check, at the end of the monitoring * duration if {@link #onHealthCheckPassed} was never called, * {@link PackageHealthObserver#execute} will be called as if the package failed. * {@link PackageHealthObserver#onExecuteHealthCheckMitigation} will be called as if the package failed. * * <p>If {@code observer} is already monitoring a package in {@code packageNames}, * the monitoring window of that package will be reset to {@code durationMs} and the health Loading Loading @@ -514,8 +519,8 @@ public class PackageWatchdog { maybeExecute(currentObserverToNotify, versionedPackage, failureReason, currentObserverImpact, mitigationCount); } else { currentObserverToNotify.execute(versionedPackage, failureReason, mitigationCount); currentObserverToNotify.onExecuteHealthCheckMitigation( versionedPackage, failureReason, mitigationCount); } } } Loading Loading @@ -550,7 +555,8 @@ public class PackageWatchdog { maybeExecute(currentObserverToNotify, failingPackage, failureReason, currentObserverImpact, /*mitigationCount=*/ 1); } else { currentObserverToNotify.execute(failingPackage, failureReason, 1); currentObserverToNotify.onExecuteHealthCheckMitigation(failingPackage, failureReason, 1); } } } Loading @@ -564,7 +570,8 @@ public class PackageWatchdog { synchronized (mLock) { mLastMitigation = mSystemClock.uptimeMillis(); } currentObserverToNotify.execute(versionedPackage, failureReason, mitigationCount); currentObserverToNotify.onExecuteHealthCheckMitigation(versionedPackage, failureReason, mitigationCount); } } Loading Loading @@ -626,12 +633,12 @@ public class PackageWatchdog { currentObserverInternal.setBootMitigationCount( currentObserverMitigationCount); saveAllObserversBootMitigationCountToMetadata(METADATA_FILE); currentObserverToNotify.executeBootLoopMitigation( currentObserverToNotify.onExecuteBootLoopMitigation( currentObserverMitigationCount); } else { mBootThreshold.setMitigationCount(mitigationCount); mBootThreshold.saveMitigationCountToMetadata(); currentObserverToNotify.executeBootLoopMitigation(mitigationCount); currentObserverToNotify.onExecuteBootLoopMitigation(mitigationCount); } } } Loading Loading @@ -717,7 +724,9 @@ public class PackageWatchdog { return mPackagesExemptFromImpactLevelThreshold; } /** Possible severity values of the user impact of a {@link PackageHealthObserver#execute}. /** * Possible severity values of the user impact of a * {@link PackageHealthObserver#onExecuteHealthCheckMitigation}. * @hide */ @Retention(SOURCE) Loading Loading @@ -753,6 +762,7 @@ public class PackageWatchdog { } /** Register instances of this interface to receive notifications on package failure. */ @SuppressLint({"CallbackName"}) public interface PackageHealthObserver { /** * Called when health check fails for the {@code versionedPackage}. Loading @@ -765,7 +775,7 @@ public class PackageWatchdog { * * * @return any one of {@link PackageHealthObserverImpact} to express the impact * to the user on {@link #execute} * to the user on {@link #onExecuteHealthCheckMitigation} */ @PackageHealthObserverImpact int onHealthCheckFailed( @Nullable VersionedPackage versionedPackage, Loading @@ -773,7 +783,10 @@ public class PackageWatchdog { int mitigationCount); /** * Executes mitigation for {@link #onHealthCheckFailed}. * This would be called after {@link #onHealthCheckFailed}. * This is called only if current observer returned least * {@link PackageHealthObserverImpact} mitigation for failed health * check. * * @param versionedPackage the package that is failing. This may be null if a native * service is crashing. Loading @@ -782,7 +795,7 @@ public class PackageWatchdog { * (including this time). * @return {@code true} if action was executed successfully, {@code false} otherwise */ boolean execute(@Nullable VersionedPackage versionedPackage, boolean onExecuteHealthCheckMitigation(@Nullable VersionedPackage versionedPackage, @FailureReasons int failureReason, int mitigationCount); Loading @@ -798,11 +811,14 @@ public class PackageWatchdog { } /** * Executes mitigation for {@link #onBootLoop} * This would be called after {@link #onBootLoop}. * This is called only if current observer returned least * {@link PackageHealthObserverImpact} mitigation for fixing boot loop * * @param mitigationCount the number of times mitigation has been attempted for this * boot loop (including this time). */ default boolean executeBootLoopMitigation(int mitigationCount) { default boolean onExecuteBootLoopMitigation(int mitigationCount) { return false; } Loading Loading @@ -1083,7 +1099,7 @@ public class PackageWatchdog { if (versionedPkg != null) { Slog.i(TAG, "Explicit health check failed for package " + versionedPkg); registeredObserver.execute(versionedPkg, registeredObserver.onExecuteHealthCheckMitigation(versionedPkg, PackageWatchdog.FAILURE_REASON_EXPLICIT_HEALTH_CHECK, 1); } } Loading packages/CrashRecovery/services/module/java/com/android/server/RescueParty.java +2 −2 Original line number Diff line number Diff line Loading @@ -728,7 +728,7 @@ public class RescueParty { } @Override public boolean execute(@Nullable VersionedPackage failedPackage, public boolean onExecuteHealthCheckMitigation(@Nullable VersionedPackage failedPackage, @FailureReasons int failureReason, int mitigationCount) { if (isDisabled()) { return false; Loading Loading @@ -796,7 +796,7 @@ public class RescueParty { } @Override public boolean executeBootLoopMitigation(int mitigationCount) { public boolean onExecuteBootLoopMitigation(int mitigationCount) { if (isDisabled()) { return false; } Loading packages/CrashRecovery/services/module/java/com/android/server/rollback/RollbackPackageHealthObserver.java +9 −3 Original line number Diff line number Diff line Loading @@ -19,8 +19,11 @@ package com.android.server.rollback; import static com.android.server.crashrecovery.CrashRecoveryUtils.logCrashRecoveryEvent; import android.annotation.AnyThread; import android.annotation.FlaggedApi; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SuppressLint; import android.annotation.SystemApi; import android.annotation.WorkerThread; import android.app.PendingIntent; import android.content.BroadcastReceiver; Loading Loading @@ -75,6 +78,9 @@ import java.util.function.Consumer; * * @hide */ @FlaggedApi(Flags.FLAG_ENABLE_CRASHRECOVERY) @SuppressLint({"CallbackName"}) @SystemApi(client = SystemApi.Client.SYSTEM_SERVER) public final class RollbackPackageHealthObserver implements PackageHealthObserver { private static final String TAG = "RollbackPackageHealthObserver"; private static final String NAME = "rollback-observer"; Loading Loading @@ -148,7 +154,7 @@ public final class RollbackPackageHealthObserver implements PackageHealthObserve // Note: For non-native crashes the rollback-all step has higher impact impact = PackageHealthObserverImpact.USER_IMPACT_LEVEL_30; } else if (getAvailableRollback(failedPackage) != null) { // Rollback is available, we may get a callback into #execute // Rollback is available, we may get a callback into #onExecuteHealthCheckMitigation impact = PackageHealthObserverImpact.USER_IMPACT_LEVEL_30; } else if (anyRollbackAvailable) { // If any rollbacks are available, we will commit them Loading @@ -165,7 +171,7 @@ public final class RollbackPackageHealthObserver implements PackageHealthObserve } @Override public boolean execute(@Nullable VersionedPackage failedPackage, public boolean onExecuteHealthCheckMitigation(@Nullable VersionedPackage failedPackage, @FailureReasons int rollbackReason, int mitigationCount) { Slog.i(TAG, "Executing remediation." + " failedPackage: " Loading Loading @@ -219,7 +225,7 @@ public final class RollbackPackageHealthObserver implements PackageHealthObserve } @Override public boolean executeBootLoopMitigation(int mitigationCount) { public boolean onExecuteBootLoopMitigation(int mitigationCount) { if (Flags.recoverabilityDetection()) { List<RollbackInfo> availableRollbacks = getAvailableRollbacks(); Loading Loading
AconfigFlags.bp +4 −0 Original line number Diff line number Diff line Loading @@ -1560,6 +1560,10 @@ java_aconfig_library { name: "android.crashrecovery.flags-aconfig-java", aconfig_declarations: "android.crashrecovery.flags-aconfig", defaults: ["framework-minus-apex-aconfig-java-defaults"], apex_available: [ "//apex_available:platform", "com.android.crashrecovery", ], } java_aconfig_library { Loading
core/java/Android.bp +7 −0 Original line number Diff line number Diff line Loading @@ -344,6 +344,13 @@ filegroup { ], } filegroup { name: "service-crashrecovery-shared-srcs", srcs: [ "android/util/IndentingPrintWriter.java", ], } filegroup { name: "incremental_aidl", srcs: [ Loading
packages/CrashRecovery/services/module/java/com/android/server/PackageWatchdog.java +30 −14 Original line number Diff line number Diff line Loading @@ -24,9 +24,12 @@ import static com.android.server.crashrecovery.CrashRecoveryUtils.dumpCrashRecov import static java.lang.annotation.RetentionPolicy.SOURCE; import android.annotation.FlaggedApi; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SuppressLint; import android.annotation.SystemApi; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; Loading Loading @@ -94,6 +97,8 @@ import java.util.concurrent.TimeUnit; * be notified. * @hide */ @FlaggedApi(Flags.FLAG_ENABLE_CRASHRECOVERY) @SystemApi(client = SystemApi.Client.SYSTEM_SERVER) public class PackageWatchdog { private static final String TAG = "PackageWatchdog"; Loading Loading @@ -351,7 +356,7 @@ public class PackageWatchdog { * * <p>If monitoring a package supporting explicit health check, at the end of the monitoring * duration if {@link #onHealthCheckPassed} was never called, * {@link PackageHealthObserver#execute} will be called as if the package failed. * {@link PackageHealthObserver#onExecuteHealthCheckMitigation} will be called as if the package failed. * * <p>If {@code observer} is already monitoring a package in {@code packageNames}, * the monitoring window of that package will be reset to {@code durationMs} and the health Loading Loading @@ -514,8 +519,8 @@ public class PackageWatchdog { maybeExecute(currentObserverToNotify, versionedPackage, failureReason, currentObserverImpact, mitigationCount); } else { currentObserverToNotify.execute(versionedPackage, failureReason, mitigationCount); currentObserverToNotify.onExecuteHealthCheckMitigation( versionedPackage, failureReason, mitigationCount); } } } Loading Loading @@ -550,7 +555,8 @@ public class PackageWatchdog { maybeExecute(currentObserverToNotify, failingPackage, failureReason, currentObserverImpact, /*mitigationCount=*/ 1); } else { currentObserverToNotify.execute(failingPackage, failureReason, 1); currentObserverToNotify.onExecuteHealthCheckMitigation(failingPackage, failureReason, 1); } } } Loading @@ -564,7 +570,8 @@ public class PackageWatchdog { synchronized (mLock) { mLastMitigation = mSystemClock.uptimeMillis(); } currentObserverToNotify.execute(versionedPackage, failureReason, mitigationCount); currentObserverToNotify.onExecuteHealthCheckMitigation(versionedPackage, failureReason, mitigationCount); } } Loading Loading @@ -626,12 +633,12 @@ public class PackageWatchdog { currentObserverInternal.setBootMitigationCount( currentObserverMitigationCount); saveAllObserversBootMitigationCountToMetadata(METADATA_FILE); currentObserverToNotify.executeBootLoopMitigation( currentObserverToNotify.onExecuteBootLoopMitigation( currentObserverMitigationCount); } else { mBootThreshold.setMitigationCount(mitigationCount); mBootThreshold.saveMitigationCountToMetadata(); currentObserverToNotify.executeBootLoopMitigation(mitigationCount); currentObserverToNotify.onExecuteBootLoopMitigation(mitigationCount); } } } Loading Loading @@ -717,7 +724,9 @@ public class PackageWatchdog { return mPackagesExemptFromImpactLevelThreshold; } /** Possible severity values of the user impact of a {@link PackageHealthObserver#execute}. /** * Possible severity values of the user impact of a * {@link PackageHealthObserver#onExecuteHealthCheckMitigation}. * @hide */ @Retention(SOURCE) Loading Loading @@ -753,6 +762,7 @@ public class PackageWatchdog { } /** Register instances of this interface to receive notifications on package failure. */ @SuppressLint({"CallbackName"}) public interface PackageHealthObserver { /** * Called when health check fails for the {@code versionedPackage}. Loading @@ -765,7 +775,7 @@ public class PackageWatchdog { * * * @return any one of {@link PackageHealthObserverImpact} to express the impact * to the user on {@link #execute} * to the user on {@link #onExecuteHealthCheckMitigation} */ @PackageHealthObserverImpact int onHealthCheckFailed( @Nullable VersionedPackage versionedPackage, Loading @@ -773,7 +783,10 @@ public class PackageWatchdog { int mitigationCount); /** * Executes mitigation for {@link #onHealthCheckFailed}. * This would be called after {@link #onHealthCheckFailed}. * This is called only if current observer returned least * {@link PackageHealthObserverImpact} mitigation for failed health * check. * * @param versionedPackage the package that is failing. This may be null if a native * service is crashing. Loading @@ -782,7 +795,7 @@ public class PackageWatchdog { * (including this time). * @return {@code true} if action was executed successfully, {@code false} otherwise */ boolean execute(@Nullable VersionedPackage versionedPackage, boolean onExecuteHealthCheckMitigation(@Nullable VersionedPackage versionedPackage, @FailureReasons int failureReason, int mitigationCount); Loading @@ -798,11 +811,14 @@ public class PackageWatchdog { } /** * Executes mitigation for {@link #onBootLoop} * This would be called after {@link #onBootLoop}. * This is called only if current observer returned least * {@link PackageHealthObserverImpact} mitigation for fixing boot loop * * @param mitigationCount the number of times mitigation has been attempted for this * boot loop (including this time). */ default boolean executeBootLoopMitigation(int mitigationCount) { default boolean onExecuteBootLoopMitigation(int mitigationCount) { return false; } Loading Loading @@ -1083,7 +1099,7 @@ public class PackageWatchdog { if (versionedPkg != null) { Slog.i(TAG, "Explicit health check failed for package " + versionedPkg); registeredObserver.execute(versionedPkg, registeredObserver.onExecuteHealthCheckMitigation(versionedPkg, PackageWatchdog.FAILURE_REASON_EXPLICIT_HEALTH_CHECK, 1); } } Loading
packages/CrashRecovery/services/module/java/com/android/server/RescueParty.java +2 −2 Original line number Diff line number Diff line Loading @@ -728,7 +728,7 @@ public class RescueParty { } @Override public boolean execute(@Nullable VersionedPackage failedPackage, public boolean onExecuteHealthCheckMitigation(@Nullable VersionedPackage failedPackage, @FailureReasons int failureReason, int mitigationCount) { if (isDisabled()) { return false; Loading Loading @@ -796,7 +796,7 @@ public class RescueParty { } @Override public boolean executeBootLoopMitigation(int mitigationCount) { public boolean onExecuteBootLoopMitigation(int mitigationCount) { if (isDisabled()) { return false; } Loading
packages/CrashRecovery/services/module/java/com/android/server/rollback/RollbackPackageHealthObserver.java +9 −3 Original line number Diff line number Diff line Loading @@ -19,8 +19,11 @@ package com.android.server.rollback; import static com.android.server.crashrecovery.CrashRecoveryUtils.logCrashRecoveryEvent; import android.annotation.AnyThread; import android.annotation.FlaggedApi; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SuppressLint; import android.annotation.SystemApi; import android.annotation.WorkerThread; import android.app.PendingIntent; import android.content.BroadcastReceiver; Loading Loading @@ -75,6 +78,9 @@ import java.util.function.Consumer; * * @hide */ @FlaggedApi(Flags.FLAG_ENABLE_CRASHRECOVERY) @SuppressLint({"CallbackName"}) @SystemApi(client = SystemApi.Client.SYSTEM_SERVER) public final class RollbackPackageHealthObserver implements PackageHealthObserver { private static final String TAG = "RollbackPackageHealthObserver"; private static final String NAME = "rollback-observer"; Loading Loading @@ -148,7 +154,7 @@ public final class RollbackPackageHealthObserver implements PackageHealthObserve // Note: For non-native crashes the rollback-all step has higher impact impact = PackageHealthObserverImpact.USER_IMPACT_LEVEL_30; } else if (getAvailableRollback(failedPackage) != null) { // Rollback is available, we may get a callback into #execute // Rollback is available, we may get a callback into #onExecuteHealthCheckMitigation impact = PackageHealthObserverImpact.USER_IMPACT_LEVEL_30; } else if (anyRollbackAvailable) { // If any rollbacks are available, we will commit them Loading @@ -165,7 +171,7 @@ public final class RollbackPackageHealthObserver implements PackageHealthObserve } @Override public boolean execute(@Nullable VersionedPackage failedPackage, public boolean onExecuteHealthCheckMitigation(@Nullable VersionedPackage failedPackage, @FailureReasons int rollbackReason, int mitigationCount) { Slog.i(TAG, "Executing remediation." + " failedPackage: " Loading Loading @@ -219,7 +225,7 @@ public final class RollbackPackageHealthObserver implements PackageHealthObserve } @Override public boolean executeBootLoopMitigation(int mitigationCount) { public boolean onExecuteBootLoopMitigation(int mitigationCount) { if (Flags.recoverabilityDetection()) { List<RollbackInfo> availableRollbacks = getAvailableRollbacks(); Loading