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

Commit a2bbe84e authored by Harshit Mahajan's avatar Harshit Mahajan
Browse files

Expose important thresholds for mitigation impacts

1. LEAST_PACKAGE_HEALTH_OBSERVER_IMPACT: no mitigation
2. MEDIUM_USER_IMPACT_THRESHOLD: user starts noticing mitigations
3. HIGH_USER_IMPACT_THRESHOLD: Severe user impact mitigations

Bug: 377635591
Test: NA
Flag: android.crashrecovery.flags.enable_crashrecovery
Change-Id: I6756ac919ba07ae1c080131b57f5cd2e84d3611d
parent 55fc3d50
Loading
Loading
Loading
Loading
+35 −7
Original line number Original line Diff line number Diff line
@@ -726,6 +726,25 @@ public class PackageWatchdog {
        return mPackagesExemptFromImpactLevelThreshold;
        return mPackagesExemptFromImpactLevelThreshold;
    }
    }


    /**
     * The minimum value that can be returned by any observer.
     * It represents that no mitigations were available.
     */
    public static final int LEAST_PACKAGE_HEALTH_OBSERVER_IMPACT =
            PackageHealthObserverImpact.USER_IMPACT_LEVEL_0;

    /**
     * The mitigation impact beyond which the user will start noticing the mitigations.
     */
    public static final int MEDIUM_USER_IMPACT_THRESHOLD =
            PackageHealthObserverImpact.USER_IMPACT_LEVEL_20;

    /**
     * The mitigation impact beyond which the user impact is severely high.
     */
    public static final int HIGH_USER_IMPACT_THRESHOLD =
            PackageHealthObserverImpact.USER_IMPACT_LEVEL_71;

    /**
    /**
     * Possible severity values of the user impact of a
     * Possible severity values of the user impact of a
     * {@link PackageHealthObserver#onExecuteHealthCheckMitigation}.
     * {@link PackageHealthObserver#onExecuteHealthCheckMitigation}.
@@ -769,6 +788,11 @@ public class PackageWatchdog {
        /**
        /**
         * Called when health check fails for the {@code versionedPackage}.
         * Called when health check fails for the {@code versionedPackage}.
         *
         *
         * Note: if the returned user impact is higher than
         * {@link #DEFAULT_HIGH_USER_IMPACT_THRESHOLD}, then
         * {@link #onExecuteHealthCheckMitigation} would be called only in severe device conditions
         * like boot-loop or network failure.
         *
         * @param versionedPackage the package that is failing. This may be null if a native
         * @param versionedPackage the package that is failing. This may be null if a native
         *                          service is crashing.
         *                          service is crashing.
         * @param failureReason   the type of failure that is occurring.
         * @param failureReason   the type of failure that is occurring.
@@ -776,8 +800,8 @@ public class PackageWatchdog {
         *                        (including this time).
         *                        (including this time).
         *
         *
         *
         *
         * @return any one of {@link PackageHealthObserverImpact} to express the impact
         * @return any value greater than {@link #LEAST_PACKAGE_HEALTH_OBSERVER_IMPACT} to express
         * to the user on {@link #onExecuteHealthCheckMitigation}
         * the impact of mitigation on the user in {@link #onExecuteHealthCheckMitigation}
         */
         */
        @PackageHealthObserverImpact int onHealthCheckFailed(
        @PackageHealthObserverImpact int onHealthCheckFailed(
                @Nullable VersionedPackage versionedPackage,
                @Nullable VersionedPackage versionedPackage,
@@ -786,9 +810,8 @@ public class PackageWatchdog {


        /**
        /**
         * This would be called after {@link #onHealthCheckFailed}.
         * This would be called after {@link #onHealthCheckFailed}.
         * This is called only if current observer returned least
         * This is called only if current observer returned least impact mitigation for failed
         * {@link PackageHealthObserverImpact} mitigation for failed health
         * health check.
         * check.
         *
         *
         * @param versionedPackage the package that is failing. This may be null if a native
         * @param versionedPackage the package that is failing. This may be null if a native
         *                          service is crashing.
         *                          service is crashing.
@@ -807,6 +830,9 @@ public class PackageWatchdog {
         *
         *
         * @param mitigationCount the number of times mitigation has been attempted for this
         * @param mitigationCount the number of times mitigation has been attempted for this
         *                        boot loop (including this time).
         *                        boot loop (including this time).
         *
         * @return any value greater than {@link #LEAST_PACKAGE_HEALTH_OBSERVER_IMPACT} to express
         * the impact of mitigation on the user in {@link #onExecuteBootLoopMitigation}
         */
         */
        default @PackageHealthObserverImpact int onBootLoop(int mitigationCount) {
        default @PackageHealthObserverImpact int onBootLoop(int mitigationCount) {
            return PackageHealthObserverImpact.USER_IMPACT_LEVEL_0;
            return PackageHealthObserverImpact.USER_IMPACT_LEVEL_0;
@@ -814,11 +840,13 @@ public class PackageWatchdog {


        /**
        /**
         * This would be called after {@link #onBootLoop}.
         * This would be called after {@link #onBootLoop}.
         * This is called only if current observer returned least
         * This is called only if current observer returned least impact mitigation for fixing
         * {@link PackageHealthObserverImpact} mitigation for fixing boot loop
         * boot loop.
         *
         *
         * @param mitigationCount the number of times mitigation has been attempted for this
         * @param mitigationCount the number of times mitigation has been attempted for this
         *                        boot loop (including this time).
         *                        boot loop (including this time).
         *
         * @return {@code true} if action was executed successfully, {@code false} otherwise
         */
         */
        default boolean onExecuteBootLoopMitigation(int mitigationCount) {
        default boolean onExecuteBootLoopMitigation(int mitigationCount) {
            return false;
            return false;