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

Commit a00be9b4 authored by Brian Carlstrom's avatar Brian Carlstrom
Browse files

Remember failed dexopt to avoid retry

Bug: 18643977
Change-Id: Ida8d9b9ce992d97fb75bccb8c3da0d9d73a480a9
parent 12b5e504
Loading
Loading
Loading
Loading
+14 −1
Original line number Original line Diff line number Diff line
@@ -39,6 +39,11 @@ public class BackgroundDexOptService extends JobService {
            "android",
            "android",
            BackgroundDexOptService.class.getName());
            BackgroundDexOptService.class.getName());


    /**
     * Set of failed packages remembered across job runs.
     */
    static final ArraySet<String> sFailedPackageNames = new ArraySet<String>();

    final AtomicBoolean mIdleTime = new AtomicBoolean(false);
    final AtomicBoolean mIdleTime = new AtomicBoolean(false);


    public static void schedule(Context context) {
    public static void schedule(Context context) {
@@ -75,7 +80,15 @@ public class BackgroundDexOptService extends JobService {
                        schedule(BackgroundDexOptService.this);
                        schedule(BackgroundDexOptService.this);
                        return;
                        return;
                    }
                    }
                    pm.performDexOpt(pkg, null /* instruction set */, true);
                    if (sFailedPackageNames.contains(pkg)) {
                        // skip previously failing package
                        continue;
                    }
                    if (!pm.performDexOpt(pkg, null /* instruction set */, true)) {
                        // there was a problem running dexopt,
                        // remember this so we do not keep retrying.
                        sFailedPackageNames.add(pkg);
                    }
                }
                }
                // ran to completion, so we abandon our timeslice and do not reschedule
                // ran to completion, so we abandon our timeslice and do not reschedule
                jobFinished(jobParams, false);
                jobFinished(jobParams, false);