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

Commit 0213ace0 authored by Christopher Tate's avatar Christopher Tate
Browse files

Reintroduce per-app scheduled job limits

There was a period of interim deployments during which sync-manager jobs
were not properly attributed to the package whose sync operations were
being driven.  This situation is now corrected when it is encountered.

Bug 27335118

Change-Id: Iafc40c80093499447b2e62a4888e3ece0371bfcb
parent 187b9b9e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ public final class JobSchedulerService extends com.android.server.SystemService
    /** The maximum number of concurrent jobs we run at one time. */
    private static final int MAX_JOB_CONTEXTS_COUNT = 8;
    /** Enforce a per-app limit on scheduled jobs? */
    private static final boolean ENFORCE_MAX_JOBS = false;
    private static final boolean ENFORCE_MAX_JOBS = true;
    /** The maximum number of jobs that we allow an unprivileged app to schedule */
    private static final int MAX_JOBS_PER_APP = 100;

+13 −1
Original line number Diff line number Diff line
@@ -543,7 +543,7 @@ public class JobStore {
                return null;
            }

            final String sourcePackageName = parser.getAttributeValue(null, "sourcePackageName");
            String sourcePackageName = parser.getAttributeValue(null, "sourcePackageName");

            final String sourceTag = parser.getAttributeValue(null, "sourceTag");

@@ -660,6 +660,18 @@ public class JobStore {
            jobBuilder.setExtras(extras);
            parser.nextTag(); // Consume </extras>

            // Migrate sync jobs forward from earlier, incomplete representation
            if ("android".equals(sourcePackageName)
                    && extras != null
                    && extras.getBoolean("SyncManagerJob", false)) {
                sourcePackageName = extras.getString("owningPackage", sourcePackageName);
                if (DEBUG) {
                    Slog.i(TAG, "Fixing up sync job source package name from 'android' to '"
                            + sourcePackageName + "'");
                }
            }

            // And now we're done
            JobStatus js = new JobStatus(
                    jobBuilder.build(), uid, sourcePackageName, sourceUserId, sourceTag,
                    elapsedRuntimes.first, elapsedRuntimes.second);