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

Commit ad549bde authored by Jiakai Zhang's avatar Jiakai Zhang
Browse files

Reschedule the legacy bg dexopt job when it's cancelled.

We reschedule the new bg dexopt job when it's cancelled, so we should do
the same for the legacy bg dexopt job too to close the gap.

This change is essential to make the metrics comparison between two
implementations meaningful.

Bug: 263249979
Test: atest FrameworksMockingServicesTests:BackgroundDexOptServiceUnitTest
Change-Id: I33dfb84f3f3138df670ddfb5af72f017892d592b
parent 07fc894c
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -405,11 +405,15 @@ public final class BackgroundDexOptService {
                                    new TimingsTraceAndSlog(TAG, Trace.TRACE_TAG_PACKAGE_MANAGER);
                            tr.traceBegin("jobExecution");
                            boolean completed = false;
                            boolean fatalError = false;
                            try {
                                completed = runIdleOptimization(
                                        pm, pkgs, params.getJobId() == JOB_POST_BOOT_UPDATE);
                            } catch (LegacyDexoptDisabledException e) {
                                Slog.wtf(TAG, e);
                            } catch (RuntimeException e) {
                                fatalError = true;
                                throw e;
                            } finally { // Those cleanup should be done always.
                                tr.traceEnd();
                                Slog.i(TAG,
@@ -422,12 +426,10 @@ public final class BackgroundDexOptService {
                                    if (completed) {
                                        markPostBootUpdateCompleted(params);
                                    }
                                    // Reschedule when cancelled
                                    job.jobFinished(params, !completed);
                                } else {
                                    // Periodic job
                                    job.jobFinished(params, false /* reschedule */);
                                }
                                // Reschedule when cancelled. No need to reschedule when failed with
                                // fatal error because it's likely to fail again.
                                job.jobFinished(params, !completed && !fatalError);
                                markDexOptCompleted();
                            }
                        }));
+2 −2
Original line number Diff line number Diff line
@@ -413,8 +413,8 @@ public final class BackgroundDexOptServiceUnitTest {
        mDexOptThread.join(TEST_WAIT_TIMEOUT_MS);
        mCancelThread.join(TEST_WAIT_TIMEOUT_MS);

        // Always reschedule for periodic job
        verify(mJobServiceForIdle).jobFinished(mJobParametersForIdle, false);
        // The job should be rescheduled.
        verify(mJobServiceForIdle).jobFinished(mJobParametersForIdle, true /* wantsReschedule */);
        verifyLastControlDexOptBlockingCall(false);
    }