summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Makoto Onuki <omakoto@google.com> 2019-01-24 16:19:06 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-01-24 16:19:06 +0000
commit3ef89abe3dec15f2f8633d3e438dd01e020754d3 (patch)
tree791ff40c3d2ed1edb9ecbc0bd7450aa322473154
parent46165b5d61e6c9bb2a606822bdeecfc28a59c06e (diff)
parentf731c4209fa5415e7d6cfa4164fb5dba82ad704a (diff)
Merge "Add proto dumpsys for JobConcurrencyManager"
-rw-r--r--core/proto/android/server/jobscheduler.proto82
-rw-r--r--services/core/java/com/android/server/job/JobConcurrencyManager.java126
-rw-r--r--services/core/java/com/android/server/job/JobSchedulerService.java170
-rw-r--r--services/tests/servicestests/src/com/android/server/job/MaxJobCountsTest.java13
4 files changed, 270 insertions, 121 deletions
diff --git a/core/proto/android/server/jobscheduler.proto b/core/proto/android/server/jobscheduler.proto
index e68f9dbbc9b7..188769d930d1 100644
--- a/core/proto/android/server/jobscheduler.proto
+++ b/core/proto/android/server/jobscheduler.proto
@@ -31,6 +31,7 @@ import "frameworks/base/core/proto/android/os/persistablebundle.proto";
import "frameworks/base/core/proto/android/server/forceappstandbytracker.proto";
import "frameworks/base/libs/incident/proto/android/privacy.proto";
+// Next tag: 21
message JobSchedulerServiceDumpProto {
option (.android.msg_privacy).dest = DEST_AUTOMATIC;
@@ -139,9 +140,13 @@ message JobSchedulerServiceDumpProto {
// The current limit on the number of concurrent JobServiceContext entries
// we want to keep actively running a job.
optional int32 max_active_jobs = 13;
+
+ // Dump from JobConcurrencyManager.
+ optional JobConcurrencyManagerProto concurrency_manager = 20;
}
// A com.android.server.job.JobSchedulerService.Constants object.
+// Next tag: 29
message ConstantsProto {
option (.android.msg_privacy).dest = DEST_AUTOMATIC;
@@ -273,7 +278,39 @@ message ConstantsProto {
}
optional QuotaController quota_controller = 24;
- // Next tag: 26
+ // Max number of jobs, when screen is ON.
+ optional MaxJobCountsPerMemoryTrimLevelProto max_job_counts_screen_on = 26;
+
+ // Max number of jobs, when screen is OFF.
+ optional MaxJobCountsPerMemoryTrimLevelProto max_job_counts_screen_off = 27;
+
+ // In this time after screen turns on, we increase job concurrency.
+ optional int32 screen_off_job_concurrency_increase_delay_ms = 28;
+}
+
+// Next tag: 4
+message MaxJobCountsProto {
+ option (.android.msg_privacy).dest = DEST_AUTOMATIC;
+
+ // Total number of jobs to run simultaneously.
+ optional int32 total_jobs = 1;
+
+ // Max number of BG (== owned by non-TOP apps) jobs to run simultaneously.
+ optional int32 max_bg = 2;
+
+ // We try to run at least this many BG (== owned by non-TOP apps) jobs, when there are any
+ // pending, rather than always running the TOTAL number of FG jobs.
+ optional int32 min_bg = 3;
+}
+
+// Next tag: 5
+message MaxJobCountsPerMemoryTrimLevelProto {
+ option (.android.msg_privacy).dest = DEST_AUTOMATIC;
+
+ optional MaxJobCountsProto normal = 1;
+ optional MaxJobCountsProto moderate = 2;
+ optional MaxJobCountsProto low = 3;
+ optional MaxJobCountsProto critical = 4;
}
message StateControllerProto {
@@ -807,3 +844,46 @@ message JobStatusDumpProto {
// Next tag: 28
}
+
+// Dump from com.android.server.job.JobConcurrencyManager.
+// Next tag: 7
+message JobConcurrencyManagerProto {
+ option (.android.msg_privacy).dest = DEST_AUTOMATIC;
+
+ // Whether the device is interactive (== screen on) now or not.
+ optional bool current_interactive = 1;
+ // Similar to current_interactive, screen on or not, but it takes into account the off timeout.
+ optional bool effective_interactive = 2;
+ // How many milliseconds have passed since the last screen on. (i.e. 1000 == 1 sec ago)
+ optional int64 time_since_last_screen_on_ms = 3;
+ // How many milliseconds have passed since the last screen off. (i.e. 1000 == 1 sec ago)
+ optional int64 time_since_last_screen_off_ms = 4;
+ // Current max number of jobs.
+ optional JobCountTrackerProto job_count_tracker = 5;
+ // Current memory trim level.
+ optional int32 memory_trim_level = 6;
+}
+
+// Dump from com.android.server.job.JobConcurrencyManager.JobCountTracker.
+// Next tag: 8
+message JobCountTrackerProto {
+ option (.android.msg_privacy).dest = DEST_AUTOMATIC;
+
+ // Number of total jos that can run simultaneously.
+ optional int32 config_num_max_total_jobs = 1;
+ // Number of background jos that can run simultaneously.
+ optional int32 config_num_max_bg_jobs = 2;
+ // Out of total jobs, this many background jobs should be guaranteed to be executed, even if
+ // there are the config_num_max_total_jobs count of foreground jobs pending.
+ optional int32 config_num_min_bg_jobs = 3;
+
+ // Number of running foreground jobs.
+ optional int32 num_running_fg_jobs = 4;
+ // Number of running background jobs.
+ optional int32 num_running_bg_jobs = 5;
+
+ // Number of pending foreground jobs.
+ optional int32 num_pending_fg_jobs = 6;
+ // Number of pending background jobs.
+ optional int32 num_pending_bg_jobs = 7;
+}
diff --git a/services/core/java/com/android/server/job/JobConcurrencyManager.java b/services/core/java/com/android/server/job/JobConcurrencyManager.java
index 4d9b5f5d01c6..bec1947df228 100644
--- a/services/core/java/com/android/server/job/JobConcurrencyManager.java
+++ b/services/core/java/com/android/server/job/JobConcurrencyManager.java
@@ -36,6 +36,7 @@ import com.android.internal.os.BackgroundThread;
import com.android.internal.util.IndentingPrintWriter;
import com.android.internal.util.StatLogger;
import com.android.server.job.JobSchedulerService.Constants;
+import com.android.server.job.JobSchedulerService.MaxJobCountsPerMemoryTrimLevel;
import com.android.server.job.controllers.JobStatus;
import com.android.server.job.controllers.StateController;
@@ -148,14 +149,14 @@ class JobConcurrencyManager {
Slog.d(TAG, "Interactive: " + interactive);
}
- final long now = JobSchedulerService.sElapsedRealtimeClock.millis();
+ final long nowRealtime = JobSchedulerService.sElapsedRealtimeClock.millis();
if (interactive) {
- mLastScreenOnRealtime = now;
+ mLastScreenOnRealtime = nowRealtime;
mEffectiveInteractiveState = true;
mHandler.removeCallbacks(mRampUpForScreenOff);
} else {
- mLastScreenOffRealtime = now;
+ mLastScreenOffRealtime = nowRealtime;
// Set mEffectiveInteractiveState to false after the delay, when we may increase
// the concurrency.
@@ -232,38 +233,24 @@ class JobConcurrencyManager {
private void updateMaxCountsLocked() {
refreshSystemStateLocked();
- if (mEffectiveInteractiveState) {
- // Screen on
- switch (mLastMemoryTrimLevel) {
- case ProcessStats.ADJ_MEM_FACTOR_MODERATE:
- mMaxJobCounts = mConstants.MAX_JOB_COUNTS_ON_MODERATE;
- break;
- case ProcessStats.ADJ_MEM_FACTOR_LOW:
- mMaxJobCounts = mConstants.MAX_JOB_COUNTS_ON_LOW;
- break;
- case ProcessStats.ADJ_MEM_FACTOR_CRITICAL:
- mMaxJobCounts = mConstants.MAX_JOB_COUNTS_ON_CRITICAL;
- break;
- default:
- mMaxJobCounts = mConstants.MAX_JOB_COUNTS_ON_NORMAL;
- break;
- }
- } else {
- // Screen off
- switch (mLastMemoryTrimLevel) {
- case ProcessStats.ADJ_MEM_FACTOR_MODERATE:
- mMaxJobCounts = mConstants.MAX_JOB_COUNTS_OFF_MODERATE;
- break;
- case ProcessStats.ADJ_MEM_FACTOR_LOW:
- mMaxJobCounts = mConstants.MAX_JOB_COUNTS_OFF_LOW;
- break;
- case ProcessStats.ADJ_MEM_FACTOR_CRITICAL:
- mMaxJobCounts = mConstants.MAX_JOB_COUNTS_OFF_CRITICAL;
- break;
- default:
- mMaxJobCounts = mConstants.MAX_JOB_COUNTS_OFF_NORMAL;
- break;
- }
+ final MaxJobCountsPerMemoryTrimLevel jobCounts = mEffectiveInteractiveState
+ ? mConstants.MAX_JOB_COUNTS_SCREEN_ON
+ : mConstants.MAX_JOB_COUNTS_SCREEN_OFF;
+
+
+ switch (mLastMemoryTrimLevel) {
+ case ProcessStats.ADJ_MEM_FACTOR_MODERATE:
+ mMaxJobCounts = jobCounts.moderate;
+ break;
+ case ProcessStats.ADJ_MEM_FACTOR_LOW:
+ mMaxJobCounts = jobCounts.low;
+ break;
+ case ProcessStats.ADJ_MEM_FACTOR_CRITICAL:
+ mMaxJobCounts = jobCounts.critical;
+ break;
+ default:
+ mMaxJobCounts = jobCounts.normal;
+ break;
}
}
@@ -303,7 +290,7 @@ class JobConcurrencyManager {
// Initialize the work variables and also count running jobs.
mJobCountTracker.reset(
- mMaxJobCounts.getTotalMax(),
+ mMaxJobCounts.getMaxTotal(),
mMaxJobCounts.getMaxBg(),
mMaxJobCounts.getMinBg());
@@ -482,10 +469,7 @@ class JobConcurrencyManager {
}
- public void dumpLocked(IndentingPrintWriter pw) {
- final long now = System.currentTimeMillis();
- final long nowRealtime = JobSchedulerService.sElapsedRealtimeClock.millis();
-
+ public void dumpLocked(IndentingPrintWriter pw, long now, long nowRealtime) {
pw.println("Concurrency:");
pw.increaseIndent();
@@ -522,19 +506,36 @@ class JobConcurrencyManager {
}
}
- public void dumpProtoLocked(ProtoOutputStream proto) {
- // TODO Implement it.
+ public void dumpProtoLocked(ProtoOutputStream proto, long tag, long now, long nowRealtime) {
+ final long token = proto.start(tag);
+
+ proto.write(JobConcurrencyManagerProto.CURRENT_INTERACTIVE,
+ mCurrentInteractiveState);
+ proto.write(JobConcurrencyManagerProto.EFFECTIVE_INTERACTIVE,
+ mEffectiveInteractiveState);
+
+ proto.write(JobConcurrencyManagerProto.TIME_SINCE_LAST_SCREEN_ON_MS,
+ nowRealtime - mLastScreenOnRealtime);
+ proto.write(JobConcurrencyManagerProto.TIME_SINCE_LAST_SCREEN_OFF_MS,
+ nowRealtime - mLastScreenOffRealtime);
+
+ mJobCountTracker.dumpProto(proto, JobConcurrencyManagerProto.JOB_COUNT_TRACKER);
+
+ proto.write(JobConcurrencyManagerProto.MEMORY_TRIM_LEVEL,
+ mLastMemoryTrimLevel);
+
+ proto.end(token);
}
/**
- * This class decides, taking into account {@link #mMaxJobCounts} and how many jos are running /
+ * This class decides, taking into account {@link #mMaxJobCounts} and how mny jos are running /
* pending, how many more job can start.
*
* Extracted for testing and logging.
*/
@VisibleForTesting
static class JobCountTracker {
- private int mConfigNumTotalMaxJobs;
+ private int mConfigNumMaxTotalJobs;
private int mConfigNumMaxBgJobs;
private int mConfigNumMinBgJobs;
@@ -552,7 +553,7 @@ class JobConcurrencyManager {
private int mNumActualMaxBgJobs;
void reset(int numTotalMaxJobs, int numMaxBgJobs, int numMinBgJobs) {
- mConfigNumTotalMaxJobs = numTotalMaxJobs;
+ mConfigNumMaxTotalJobs = numTotalMaxJobs;
mConfigNumMaxBgJobs = numMaxBgJobs;
mConfigNumMinBgJobs = numMinBgJobs;
@@ -607,12 +608,12 @@ class JobConcurrencyManager {
// However, if there are FG jobs already running, we have to adjust it.
mNumReservedForBg = Math.min(reservedForBg,
- mConfigNumTotalMaxJobs - mNumRunningFgJobs);
+ mConfigNumMaxTotalJobs - mNumRunningFgJobs);
// Max FG is [total - [number needed for BG jobs]]
// [number needed for BG jobs] is the bigger one of [running BG] or [reserved BG]
final int maxFg =
- mConfigNumTotalMaxJobs - Math.max(mNumRunningBgJobs, mNumReservedForBg);
+ mConfigNumMaxTotalJobs - Math.max(mNumRunningBgJobs, mNumReservedForBg);
// The above maxFg is the theoretical max. If there are less FG jobs, the actual
// max FG will be lower accordingly.
@@ -623,7 +624,7 @@ class JobConcurrencyManager {
// Max BG is [total - actual max FG], but cap at [config max BG].
final int maxBg = Math.min(
mConfigNumMaxBgJobs,
- mConfigNumTotalMaxJobs - mNumActualMaxFgJobs);
+ mConfigNumMaxTotalJobs - mNumActualMaxFgJobs);
// If there are less BG jobs than maxBg, then reduce the actual max BG accordingly.
// This isn't needed for the logic to work, but this will give consistent output
@@ -669,12 +670,13 @@ class JobConcurrencyManager {
final int totalBg = mNumRunningBgJobs + mNumStartingBgJobs;
return String.format(
"Config={tot=%d bg min/max=%d/%d}"
- + " Running: %d / %d (%d)"
+ + " Running[FG/BG (total)]: %d / %d (%d)"
+ " Pending: %d / %d (%d)"
+ " Actual max: %d%s / %d%s (%d%s)"
+ + " Res BG: %d"
+ " Starting: %d / %d (%d)"
+ " Total: %d%s / %d%s (%d%s)",
- mConfigNumTotalMaxJobs,
+ mConfigNumMaxTotalJobs,
mConfigNumMinBgJobs,
mConfigNumMaxBgJobs,
@@ -684,19 +686,37 @@ class JobConcurrencyManager {
mNumPendingFgJobs, mNumPendingBgJobs,
mNumPendingFgJobs + mNumPendingBgJobs,
- mNumActualMaxFgJobs, (totalFg <= mConfigNumTotalMaxJobs) ? "" : "*",
+ mNumActualMaxFgJobs, (totalFg <= mConfigNumMaxTotalJobs) ? "" : "*",
mNumActualMaxBgJobs, (totalBg <= mConfigNumMaxBgJobs) ? "" : "*",
mNumActualMaxFgJobs + mNumActualMaxBgJobs,
- (mNumActualMaxFgJobs + mNumActualMaxBgJobs <= mConfigNumTotalMaxJobs)
+ (mNumActualMaxFgJobs + mNumActualMaxBgJobs <= mConfigNumMaxTotalJobs)
? "" : "*",
+ mNumReservedForBg,
+
mNumStartingFgJobs, mNumStartingBgJobs, mNumStartingFgJobs + mNumStartingBgJobs,
totalFg, (totalFg <= mNumActualMaxFgJobs) ? "" : "*",
totalBg, (totalBg <= mNumActualMaxBgJobs) ? "" : "*",
- totalFg + totalBg, (totalFg + totalBg <= mConfigNumTotalMaxJobs) ? "" : "*"
+ totalFg + totalBg, (totalFg + totalBg <= mConfigNumMaxTotalJobs) ? "" : "*"
);
}
+
+ public void dumpProto(ProtoOutputStream proto, long fieldId) {
+ final long token = proto.start(fieldId);
+
+ proto.write(JobCountTrackerProto.CONFIG_NUM_MAX_TOTAL_JOBS, mConfigNumMaxTotalJobs);
+ proto.write(JobCountTrackerProto.CONFIG_NUM_MAX_BG_JOBS, mConfigNumMaxBgJobs);
+ proto.write(JobCountTrackerProto.CONFIG_NUM_MIN_BG_JOBS, mConfigNumMinBgJobs);
+
+ proto.write(JobCountTrackerProto.NUM_RUNNING_FG_JOBS, mNumRunningFgJobs);
+ proto.write(JobCountTrackerProto.NUM_RUNNING_BG_JOBS, mNumRunningBgJobs);
+
+ proto.write(JobCountTrackerProto.NUM_PENDING_FG_JOBS, mNumPendingFgJobs);
+ proto.write(JobCountTrackerProto.NUM_PENDING_BG_JOBS, mNumPendingBgJobs);
+
+ proto.end(token);
+ }
}
}
diff --git a/services/core/java/com/android/server/job/JobSchedulerService.java b/services/core/java/com/android/server/job/JobSchedulerService.java
index bd12075fdad3..7625aafd0907 100644
--- a/services/core/java/com/android/server/job/JobSchedulerService.java
+++ b/services/core/java/com/android/server/job/JobSchedulerService.java
@@ -366,14 +366,20 @@ public class JobSchedulerService extends com.android.server.SystemService
}
}
- public int getTotalMax() {
+ /** Total number of jobs to run simultaneously. */
+ public int getMaxTotal() {
return mTotal.getValue();
}
+ /** Max number of BG (== owned by non-TOP apps) jobs to run simultaneously. */
public int getMaxBg() {
return mMaxBg.getValue();
}
+ /**
+ * We try to run at least this many BG (== owned by non-TOP apps) jobs, when there are any
+ * pending, rather than always running the TOTAL number of FG jobs.
+ */
public int getMinBg() {
return mMinBg.getValue();
}
@@ -384,10 +390,39 @@ public class JobSchedulerService extends com.android.server.SystemService
mMinBg.dump(pw, prefix);
}
- public void dumpProto(ProtoOutputStream proto, long tagTotal, long tagBg) {
- mTotal.dumpProto(proto, tagTotal);
- mMaxBg.dumpProto(proto, tagBg);
- mMinBg.dumpProto(proto, tagBg);
+ public void dumpProto(ProtoOutputStream proto, long fieldId) {
+ final long token = proto.start(fieldId);
+ mTotal.dumpProto(proto, MaxJobCountsProto.TOTAL_JOBS);
+ mMaxBg.dumpProto(proto, MaxJobCountsProto.MAX_BG);
+ mMinBg.dumpProto(proto, MaxJobCountsProto.MIN_BG);
+ proto.end(token);
+ }
+ }
+
+ /** {@link MaxJobCounts} for each memory trim level. */
+ static class MaxJobCountsPerMemoryTrimLevel {
+ public final MaxJobCounts normal;
+ public final MaxJobCounts moderate;
+ public final MaxJobCounts low;
+ public final MaxJobCounts critical;
+
+ MaxJobCountsPerMemoryTrimLevel(
+ MaxJobCounts normal,
+ MaxJobCounts moderate, MaxJobCounts low,
+ MaxJobCounts critical) {
+ this.normal = normal;
+ this.moderate = moderate;
+ this.low = low;
+ this.critical = critical;
+ }
+
+ public void dumpProto(ProtoOutputStream proto, long fieldId) {
+ final long token = proto.start(fieldId);
+ normal.dumpProto(proto, MaxJobCountsPerMemoryTrimLevelProto.NORMAL);
+ moderate.dumpProto(proto, MaxJobCountsPerMemoryTrimLevelProto.MODERATE);
+ low.dumpProto(proto, MaxJobCountsPerMemoryTrimLevelProto.LOW);
+ critical.dumpProto(proto, MaxJobCountsPerMemoryTrimLevelProto.CRITICAL);
+ proto.end(token);
}
}
@@ -546,45 +581,44 @@ public class JobSchedulerService extends com.android.server.SystemService
float MODERATE_USE_FACTOR = DEFAULT_MODERATE_USE_FACTOR;
// Max job counts for screen on / off, for each memory trim level.
- final MaxJobCounts MAX_JOB_COUNTS_ON_NORMAL = new MaxJobCounts(
- 8, "max_job_total_on_normal",
- 6, "max_job_max_bg_on_normal",
- 2, "max_job_min_bg_on_normal");
-
- final MaxJobCounts MAX_JOB_COUNTS_ON_MODERATE = new MaxJobCounts(
- 8, "max_job_total_on_moderate",
- 4, "max_job_max_bg_on_moderate",
- 2, "max_job_min_bg_on_moderate");
-
- final MaxJobCounts MAX_JOB_COUNTS_ON_LOW = new MaxJobCounts(
- 5, "max_job_total_on_low",
- 1, "max_job_max_bg_on_low",
- 1, "max_job_min_bg_on_low");
-
- final MaxJobCounts MAX_JOB_COUNTS_ON_CRITICAL = new MaxJobCounts(
- 5, "max_job_total_on_critical",
- 1, "max_job_max_bg_on_critical",
- 1, "max_job_min_bg_on_critical");
-
- final MaxJobCounts MAX_JOB_COUNTS_OFF_NORMAL = new MaxJobCounts(
- 10, "max_job_total_off_normal",
- 6, "max_job_max_bg_off_normal",
- 2, "max_job_min_bg_off_normal");
-
- final MaxJobCounts MAX_JOB_COUNTS_OFF_MODERATE = new MaxJobCounts(
- 10, "max_job_total_off_moderate",
- 4, "max_job_max_bg_off_moderate",
- 2, "max_job_min_bg_off_moderate");
-
- final MaxJobCounts MAX_JOB_COUNTS_OFF_LOW = new MaxJobCounts(
- 5, "max_job_total_off_low",
- 1, "max_job_max_bg_off_low",
- 1, "max_job_min_bg_off_low");
-
- final MaxJobCounts MAX_JOB_COUNTS_OFF_CRITICAL = new MaxJobCounts(
- 5, "max_job_total_off_critical",
- 1, "max_job_max_bg_off_critical",
- 1, "max_job_min_bg_off_critical");
+ final MaxJobCountsPerMemoryTrimLevel MAX_JOB_COUNTS_SCREEN_ON =
+ new MaxJobCountsPerMemoryTrimLevel(
+ new MaxJobCounts(
+ 8, "max_job_total_on_normal",
+ 6, "max_job_max_bg_on_normal",
+ 2, "max_job_min_bg_on_normal"),
+ new MaxJobCounts(
+ 8, "max_job_total_on_moderate",
+ 4, "max_job_max_bg_on_moderate",
+ 2, "max_job_min_bg_on_moderate"),
+ new MaxJobCounts(
+ 5, "max_job_total_on_low",
+ 1, "max_job_max_bg_on_low",
+ 1, "max_job_min_bg_on_low"),
+ new MaxJobCounts(
+ 5, "max_job_total_on_critical",
+ 1, "max_job_max_bg_on_critical",
+ 1, "max_job_min_bg_on_critical"));
+
+ final MaxJobCountsPerMemoryTrimLevel MAX_JOB_COUNTS_SCREEN_OFF =
+ new MaxJobCountsPerMemoryTrimLevel(
+ new MaxJobCounts(
+ 10, "max_job_total_off_normal",
+ 6, "max_job_max_bg_off_normal",
+ 2, "max_job_min_bg_off_normal"),
+ new MaxJobCounts(
+ 10, "max_job_total_off_moderate",
+ 4, "max_job_max_bg_off_moderate",
+ 2, "max_job_min_bg_off_moderate"),
+ new MaxJobCounts(
+ 5, "max_job_total_off_low",
+ 1, "max_job_max_bg_off_low",
+ 1, "max_job_min_bg_off_low"),
+ new MaxJobCounts(
+ 5, "max_job_total_off_critical",
+ 1, "max_job_max_bg_off_critical",
+ 1, "max_job_min_bg_off_critical"));
+
/** Wait for this long after screen off before increasing the job concurrency. */
final KeyValueListParser.IntValue SCREEN_OFF_JOB_CONCURRENCY_INCREASE_DELAY_MS =
@@ -766,15 +800,15 @@ public class JobSchedulerService extends com.android.server.SystemService
MODERATE_USE_FACTOR = mParser.getFloat(KEY_MODERATE_USE_FACTOR,
DEFAULT_MODERATE_USE_FACTOR);
- MAX_JOB_COUNTS_ON_NORMAL.parse(mParser);
- MAX_JOB_COUNTS_ON_MODERATE.parse(mParser);
- MAX_JOB_COUNTS_ON_LOW.parse(mParser);
- MAX_JOB_COUNTS_ON_CRITICAL.parse(mParser);
+ MAX_JOB_COUNTS_SCREEN_ON.normal.parse(mParser);
+ MAX_JOB_COUNTS_SCREEN_ON.moderate.parse(mParser);
+ MAX_JOB_COUNTS_SCREEN_ON.low.parse(mParser);
+ MAX_JOB_COUNTS_SCREEN_ON.critical.parse(mParser);
- MAX_JOB_COUNTS_OFF_NORMAL.parse(mParser);
- MAX_JOB_COUNTS_OFF_MODERATE.parse(mParser);
- MAX_JOB_COUNTS_OFF_LOW.parse(mParser);
- MAX_JOB_COUNTS_OFF_CRITICAL.parse(mParser);
+ MAX_JOB_COUNTS_SCREEN_OFF.normal.parse(mParser);
+ MAX_JOB_COUNTS_SCREEN_OFF.moderate.parse(mParser);
+ MAX_JOB_COUNTS_SCREEN_OFF.low.parse(mParser);
+ MAX_JOB_COUNTS_SCREEN_OFF.critical.parse(mParser);
MAX_STANDARD_RESCHEDULE_COUNT = mParser.getInt(KEY_MAX_STANDARD_RESCHEDULE_COUNT,
DEFAULT_MAX_STANDARD_RESCHEDULE_COUNT);
@@ -851,15 +885,17 @@ public class JobSchedulerService extends com.android.server.SystemService
pw.printPair(KEY_HEAVY_USE_FACTOR, HEAVY_USE_FACTOR).println();
pw.printPair(KEY_MODERATE_USE_FACTOR, MODERATE_USE_FACTOR).println();
- MAX_JOB_COUNTS_ON_NORMAL.dump(pw, "");
- MAX_JOB_COUNTS_ON_MODERATE.dump(pw, "");
- MAX_JOB_COUNTS_ON_LOW.dump(pw, "");
- MAX_JOB_COUNTS_ON_CRITICAL.dump(pw, "");
+ MAX_JOB_COUNTS_SCREEN_ON.normal.dump(pw, "");
+ MAX_JOB_COUNTS_SCREEN_ON.moderate.dump(pw, "");
+ MAX_JOB_COUNTS_SCREEN_ON.low.dump(pw, "");
+ MAX_JOB_COUNTS_SCREEN_ON.critical.dump(pw, "");
+
+ MAX_JOB_COUNTS_SCREEN_OFF.normal.dump(pw, "");
+ MAX_JOB_COUNTS_SCREEN_OFF.moderate.dump(pw, "");
+ MAX_JOB_COUNTS_SCREEN_OFF.low.dump(pw, "");
+ MAX_JOB_COUNTS_SCREEN_OFF.critical.dump(pw, "");
- MAX_JOB_COUNTS_OFF_NORMAL.dump(pw, "");
- MAX_JOB_COUNTS_OFF_MODERATE.dump(pw, "");
- MAX_JOB_COUNTS_OFF_LOW.dump(pw, "");
- MAX_JOB_COUNTS_OFF_CRITICAL.dump(pw, "");
+ SCREEN_OFF_JOB_CONCURRENCY_INCREASE_DELAY_MS.dump(pw, "");
pw.printPair(KEY_MAX_STANDARD_RESCHEDULE_COUNT, MAX_STANDARD_RESCHEDULE_COUNT).println();
pw.printPair(KEY_MAX_WORK_RESCHEDULE_COUNT, MAX_WORK_RESCHEDULE_COUNT).println();
@@ -917,7 +953,11 @@ public class JobSchedulerService extends com.android.server.SystemService
proto.write(ConstantsProto.HEAVY_USE_FACTOR, HEAVY_USE_FACTOR);
proto.write(ConstantsProto.MODERATE_USE_FACTOR, MODERATE_USE_FACTOR);
- // TODO Dump max job counts.
+ MAX_JOB_COUNTS_SCREEN_ON.dumpProto(proto, ConstantsProto.MAX_JOB_COUNTS_SCREEN_ON);
+ MAX_JOB_COUNTS_SCREEN_OFF.dumpProto(proto, ConstantsProto.MAX_JOB_COUNTS_SCREEN_OFF);
+
+ SCREEN_OFF_JOB_CONCURRENCY_INCREASE_DELAY_MS.dumpProto(proto,
+ ConstantsProto.SCREEN_OFF_JOB_CONCURRENCY_INCREASE_DELAY_MS);
proto.write(ConstantsProto.MAX_STANDARD_RESCHEDULE_COUNT, MAX_STANDARD_RESCHEDULE_COUNT);
proto.write(ConstantsProto.MAX_WORK_RESCHEDULE_COUNT, MAX_WORK_RESCHEDULE_COUNT);
@@ -3371,8 +3411,10 @@ public class JobSchedulerService extends com.android.server.SystemService
void dumpInternal(final IndentingPrintWriter pw, int filterUid) {
final int filterUidFinal = UserHandle.getAppId(filterUid);
+ final long now = sSystemClock.millis();
final long nowElapsed = sElapsedRealtimeClock.millis();
final long nowUptime = sUptimeMillisClock.millis();
+
final Predicate<JobStatus> predicate = (js) -> {
return filterUidFinal == -1 || UserHandle.getAppId(js.getUid()) == filterUidFinal
|| UserHandle.getAppId(js.getSourceUid()) == filterUidFinal;
@@ -3548,7 +3590,7 @@ public class JobSchedulerService extends com.android.server.SystemService
}
pw.println();
- mConcurrencyManager.dumpLocked(pw);
+ mConcurrencyManager.dumpLocked(pw, now, nowElapsed);
pw.println();
pw.print("PersistStats: ");
@@ -3560,6 +3602,7 @@ public class JobSchedulerService extends com.android.server.SystemService
void dumpInternalProto(final FileDescriptor fd, int filterUid) {
ProtoOutputStream proto = new ProtoOutputStream(fd);
final int filterUidFinal = UserHandle.getAppId(filterUid);
+ final long now = sSystemClock.millis();
final long nowElapsed = sElapsedRealtimeClock.millis();
final long nowUptime = sUptimeMillisClock.millis();
final Predicate<JobStatus> predicate = (js) -> {
@@ -3703,7 +3746,8 @@ public class JobSchedulerService extends com.android.server.SystemService
proto.write(JobSchedulerServiceDumpProto.IS_READY_TO_ROCK, mReadyToRock);
proto.write(JobSchedulerServiceDumpProto.REPORTED_ACTIVE, mReportedActive);
}
- mConcurrencyManager.dumpProtoLocked(proto);
+ mConcurrencyManager.dumpProtoLocked(proto,
+ JobSchedulerServiceDumpProto.CONCURRENCY_MANAGER, now, nowElapsed);
}
proto.flush();
diff --git a/services/tests/servicestests/src/com/android/server/job/MaxJobCountsTest.java b/services/tests/servicestests/src/com/android/server/job/MaxJobCountsTest.java
index 01199a36ff5b..0219f2201675 100644
--- a/services/tests/servicestests/src/com/android/server/job/MaxJobCountsTest.java
+++ b/services/tests/servicestests/src/com/android/server/job/MaxJobCountsTest.java
@@ -17,15 +17,15 @@ package com.android.server.job;
import android.util.KeyValueListParser;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
import com.android.server.job.JobSchedulerService.MaxJobCounts;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
-import androidx.test.filters.SmallTest;
-import androidx.test.runner.AndroidJUnit4;
-
@RunWith(AndroidJUnit4.class)
@SmallTest
public class MaxJobCountsTest {
@@ -43,13 +43,14 @@ public class MaxJobCountsTest {
counts.parse(parser);
- Assert.assertEquals(expectedTotal, counts.getTotalMax());
+ Assert.assertEquals(expectedTotal, counts.getMaxTotal());
Assert.assertEquals(expectedMaxBg, counts.getMaxBg());
Assert.assertEquals(expectedMinBg, counts.getMinBg());
}
@Test
public void test() {
+ // Tests with various combinations.
check("", /*default*/ 5, 1, 0, /*expected*/ 5, 1, 0);
check("", /*default*/ 5, 0, 0, /*expected*/ 5, 1, 0);
check("", /*default*/ 0, 0, 0, /*expected*/ 1, 1, 0);
@@ -58,7 +59,11 @@ public class MaxJobCountsTest {
check("", /*default*/ 6, 5, 6, /*expected*/ 6, 5, 5);
check("", /*default*/ 4, 5, 6, /*expected*/ 4, 4, 3);
check("", /*default*/ 5, 1, 1, /*expected*/ 5, 1, 1);
+ check("", /*default*/ 15, 15, 15, /*expected*/ 15, 15, 14);
+ check("", /*default*/ 16, 16, 16, /*expected*/ 16, 16, 15);
+ check("", /*default*/ 20, 20, 20, /*expected*/ 16, 16, 15);
+ // Test for overriding with a setting string.
check("total=5,maxbg=4,minbg=3", /*default*/ 9, 9, 9, /*expected*/ 5, 4, 3);
check("total=5", /*default*/ 9, 9, 9, /*expected*/ 5, 5, 4);
check("maxbg=4", /*default*/ 9, 9, 9, /*expected*/ 9, 4, 4);