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

Commit 1cb371e5 authored by Harshit Mahajan's avatar Harshit Mahajan
Browse files

Fix tests to use updated API

Rename the hidden APIs in PackageHealthObserver to match module APIs.
Remove flags which require DEPRECATE_FLAGS_AND_SETTINGS_RESETS disabled.

Bug: 289203818
Test: verified by running tests locally.
Flag: EXEMPT Test change
Change-Id: I8afb5dd7f82c010cbb685029b55155bff32c6305
parent 375e1c29
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();

+11 −428

File changed.

Preview size limit exceeded, changes collapsed.

+44 −41

File changed.

Preview size limit exceeded, changes collapsed.

Loading