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

Commit 77fd2936 authored by Kweku Adams's avatar Kweku Adams
Browse files

Avoid incorrectly calling eventStopped.

Don't call noteOngoingEventStopped for jobs that the EconomyManager
wasn't told had started.

Bug: 240726265
Test: Android builds
Change-Id: Ia7d96fa85943b33f91f5a823fe2da21c054dc392
parent eca896f2
Loading
Loading
Loading
Loading
+16 −7
Original line number Diff line number Diff line
@@ -337,7 +337,6 @@ public class TareController extends StateController {
                removeJobFromBillList(jobStatus, billToJobMap.keyAt(i));
            }
        }
        addJobToBillList(jobStatus, getRunningBill(jobStatus));

        final int uid = jobStatus.getSourceUid();
        if (mService.getUidBias(uid) == JobInfo.BIAS_TOP_APP) {
@@ -347,6 +346,7 @@ public class TareController extends StateController {
            mTopStartedJobs.add(jobStatus);
            // Top jobs won't count towards quota so there's no need to involve the EconomyManager.
        } else {
            addJobToBillList(jobStatus, getRunningBill(jobStatus));
            mEconomyManagerInternal.noteOngoingEventStarted(userId, pkgName,
                    getRunningActionId(jobStatus), String.valueOf(jobStatus.getJobId()));
        }
@@ -357,9 +357,14 @@ public class TareController extends StateController {
    public void unprepareFromExecutionLocked(JobStatus jobStatus) {
        final int userId = jobStatus.getSourceUserId();
        final String pkgName = jobStatus.getSourcePackageName();
        // If this method is called, then jobStatus.madeActive was never updated, so don't use it
        // to determine if the EconomyManager was notified.
        if (!mTopStartedJobs.remove(jobStatus)) {
            // If the job was started while the app was top, then the EconomyManager wasn't notified
            // of the job start.
            mEconomyManagerInternal.noteOngoingEventStopped(userId, pkgName,
                    getRunningActionId(jobStatus), String.valueOf(jobStatus.getJobId()));
        mTopStartedJobs.remove(jobStatus);
        }

        final ArraySet<ActionBill> bills = getPossibleStartBills(jobStatus);
        ArrayMap<ActionBill, ArraySet<JobStatus>> billToJobMap =
@@ -382,9 +387,13 @@ public class TareController extends StateController {
            boolean forUpdate) {
        final int userId = jobStatus.getSourceUserId();
        final String pkgName = jobStatus.getSourcePackageName();
        if (!mTopStartedJobs.remove(jobStatus) && jobStatus.madeActive > 0) {
            // Only note the job stop if we previously told the EconomyManager that the job started.
            // If the job was started while the app was top, then the EconomyManager wasn't notified
            // of the job start.
            mEconomyManagerInternal.noteOngoingEventStopped(userId, pkgName,
                    getRunningActionId(jobStatus), String.valueOf(jobStatus.getJobId()));
        mTopStartedJobs.remove(jobStatus);
        }
        ArrayMap<ActionBill, ArraySet<JobStatus>> billToJobMap =
                mRegisteredBillsAndJobs.get(userId, pkgName);
        if (billToJobMap != null) {