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

Commit 108ffe3b authored by Liana Kazanova's avatar Liana Kazanova Committed by Gerrit Code Review
Browse files

Merge "Revert "Add throtling to crashloop mitigations"" into main

parents edba2395 ec7f7207
Loading
Loading
Loading
Loading
+0 −23
Original line number Original line Diff line number Diff line
@@ -138,11 +138,6 @@ public class PackageWatchdog {


    static final long DEFAULT_BOOT_LOOP_TRIGGER_WINDOW_MS = TimeUnit.MINUTES.toMillis(10);
    static final long DEFAULT_BOOT_LOOP_TRIGGER_WINDOW_MS = TimeUnit.MINUTES.toMillis(10);


    // Time needed to apply mitigation
    private static final String MITIGATION_WINDOW_MS =
            "persist.device_config.configuration.mitigation_window_ms";
    private static final long DEFAULT_MITIGATION_WINDOW_MS = TimeUnit.SECONDS.toMillis(5);

    // Threshold level at which or above user might experience significant disruption.
    // Threshold level at which or above user might experience significant disruption.
    private static final String MAJOR_USER_IMPACT_LEVEL_THRESHOLD =
    private static final String MAJOR_USER_IMPACT_LEVEL_THRESHOLD =
            "persist.device_config.configuration.major_user_impact_level_threshold";
            "persist.device_config.configuration.major_user_impact_level_threshold";
@@ -215,9 +210,6 @@ public class PackageWatchdog {
    @GuardedBy("mLock")
    @GuardedBy("mLock")
    private boolean mSyncRequired = false;
    private boolean mSyncRequired = false;


    @GuardedBy("mLock")
    private long mLastMitigation = -1000000;

    @FunctionalInterface
    @FunctionalInterface
    @VisibleForTesting
    @VisibleForTesting
    interface SystemClock {
    interface SystemClock {
@@ -408,14 +400,6 @@ public class PackageWatchdog {
            Slog.w(TAG, "Could not resolve a list of failing packages");
            Slog.w(TAG, "Could not resolve a list of failing packages");
            return;
            return;
        }
        }
        synchronized (mLock) {
            final long now = mSystemClock.uptimeMillis();
            if (now >= mLastMitigation
                    && (now - mLastMitigation) < getMitigationWindowMs()) {
                Slog.i(TAG, "Skipping onPackageFailure mitigation");
                return;
            }
        }
        mLongTaskHandler.post(() -> {
        mLongTaskHandler.post(() -> {
            synchronized (mLock) {
            synchronized (mLock) {
                if (mAllObservers.isEmpty()) {
                if (mAllObservers.isEmpty()) {
@@ -516,17 +500,10 @@ public class PackageWatchdog {
                              int currentObserverImpact,
                              int currentObserverImpact,
                              int mitigationCount) {
                              int mitigationCount) {
        if (currentObserverImpact < getUserImpactLevelLimit()) {
        if (currentObserverImpact < getUserImpactLevelLimit()) {
            synchronized (mLock) {
                mLastMitigation = mSystemClock.uptimeMillis();
            }
            currentObserverToNotify.execute(versionedPackage, failureReason, mitigationCount);
            currentObserverToNotify.execute(versionedPackage, failureReason, mitigationCount);
        }
        }
    }
    }


    private long getMitigationWindowMs() {
        return SystemProperties.getLong(MITIGATION_WINDOW_MS, DEFAULT_MITIGATION_WINDOW_MS);
    }



    /**
    /**
     * Called when the system server boots. If the system server is detected to be in a boot loop,
     * Called when the system server boots. If the system server is detected to be in a boot loop,