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

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

Merge changes from topic "fixTests" into main

* changes:
  Fix tests to use updated API
  Add crashrecovery libraries to tests
parents b183120c 1cb371e5
Loading
Loading
Loading
Loading
+15 −12
Original line number Diff line number Diff line
@@ -383,7 +383,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
@@ -546,8 +546,8 @@ public class PackageWatchdog {
                                maybeExecute(currentObserverToNotify, versionedPackage,
                                        failureReason, currentObserverImpact, mitigationCount);
                            } else {
                                currentObserverToNotify.execute(versionedPackage,
                                        failureReason, mitigationCount);
                                currentObserverToNotify.onExecuteHealthCheckMitigation(
                                        versionedPackage, failureReason, mitigationCount);
                            }
                        }
                    }
@@ -582,7 +582,8 @@ public class PackageWatchdog {
                maybeExecute(currentObserverToNotify, failingPackage, failureReason,
                        currentObserverImpact, /*mitigationCount=*/ 1);
            } else {
                currentObserverToNotify.execute(failingPackage,  failureReason, 1);
                currentObserverToNotify.onExecuteHealthCheckMitigation(failingPackage,
                        failureReason, 1);
            }
        }
    }
@@ -596,7 +597,8 @@ public class PackageWatchdog {
            synchronized (mLock) {
                mLastMitigation = mSystemClock.uptimeMillis();
            }
            currentObserverToNotify.execute(versionedPackage, failureReason, mitigationCount);
            currentObserverToNotify.onExecuteHealthCheckMitigation(versionedPackage, failureReason,
                    mitigationCount);
        }
    }

@@ -658,12 +660,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);
                    }
                }
            }
@@ -749,7 +751,8 @@ 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)
@@ -797,7 +800,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,
@@ -814,7 +817,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);


@@ -834,7 +837,7 @@ public class PackageWatchdog {
         * @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;
        }

@@ -1115,7 +1118,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);
                        }
                    }
+2 −2
Original line number Diff line number Diff line
@@ -859,7 +859,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;
@@ -927,7 +927,7 @@ public class RescueParty {
        }

        @Override
        public boolean executeBootLoopMitigation(int mitigationCount) {
        public boolean onExecuteBootLoopMitigation(int mitigationCount) {
            if (isDisabled()) {
                return false;
            }
+3 −3
Original line number Diff line number Diff line
@@ -158,7 +158,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
@@ -175,7 +175,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: "
@@ -229,7 +229,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();

+4 −1
Original line number Diff line number Diff line
@@ -77,7 +77,10 @@ android_test {
        "flag-junit",
        "am_flags_lib",
        "device_policy_aconfig_flags_lib",
    ],
    ] + select(soong_config_variable("ANDROID", "release_crashrecovery_module"), {
        "true": ["service-crashrecovery.impl"],
        default: [],
    }),

    libs: [
        "android.test.mock.stubs.system",
+11 −428

File changed.

Preview size limit exceeded, changes collapsed.

Loading