From 017fde0a6725b73bac6323f5d7c046200ce395f7 Mon Sep 17 00:00:00 2001 From: Kweku Adams Date: Mon, 27 Mar 2023 16:17:06 +0000 Subject: [PATCH] Log additional data to statsd. Log additional fields so we can better understand app usage of jobs. With these fields, we can identify how many jobs are periodic, the distribution of timing delays apps set, the estimated byte values they provide (and if they're reasonable based on the device capabilities), and how many JobWorkItems are queued. Bug: 138239687 Test: statsd_testdrive 8 Change-Id: I7631dea7abe56cc9dfb4a2db10d623419aea2b54 --- .../server/job/JobSchedulerService.java | 26 +++++++++++++------ .../android/server/job/JobServiceContext.java | 16 +++++++++--- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java b/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java index d94993d64995f..01fe00da4fe96 100644 --- a/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java +++ b/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java @@ -1499,16 +1499,21 @@ public class JobSchedulerService extends com.android.server.SystemService jobStatus.getNumPreviousAttempts(), jobStatus.getJob().getMaxExecutionDelayMillis(), /* isDeadlineConstraintSatisfied */ false, - /* isCharging */ false, - /* batteryNotLow */ false, - /* storageNotLow */false, + /* isChargingSatisfied */ false, + /* batteryNotLowSatisfied */ false, + /* storageNotLowSatisfied */false, /* timingDelayConstraintSatisfied */ false, - /* isDeviceIdle */ false, + /* isDeviceIdleSatisfied */ false, /* hasConnectivityConstraintSatisfied */ false, /* hasContentTriggerConstraintSatisfied */ false, - 0, + /* jobStartLatencyMs */ 0, jobStatus.getJob().isUserInitiated(), - /* isRunningAsUserInitiatedJob */ false); + /* isRunningAsUserInitiatedJob */ false, + jobStatus.getJob().isPeriodic(), + jobStatus.getJob().getMinLatencyMillis(), + jobStatus.getEstimatedNetworkDownloadBytes(), + jobStatus.getEstimatedNetworkUploadBytes(), + jobStatus.getWorkCount()); // If the job is immediately ready to run, then we can just immediately // put it in the pending list and try to schedule it. This is especially @@ -1929,9 +1934,14 @@ public class JobSchedulerService extends com.android.server.SystemService cancelled.isConstraintSatisfied(JobInfo.CONSTRAINT_FLAG_DEVICE_IDLE), cancelled.isConstraintSatisfied(JobStatus.CONSTRAINT_CONNECTIVITY), cancelled.isConstraintSatisfied(JobStatus.CONSTRAINT_CONTENT_TRIGGER), - 0, + /* jobStartLatencyMs */ 0, cancelled.getJob().isUserInitiated(), - /* isRunningAsUserInitiatedJob */ false); + /* isRunningAsUserInitiatedJob */ false, + cancelled.getJob().isPeriodic(), + cancelled.getJob().getMinLatencyMillis(), + cancelled.getEstimatedNetworkDownloadBytes(), + cancelled.getEstimatedNetworkUploadBytes(), + cancelled.getWorkCount()); } // If this is a replacement, bring in the new version of the job if (incomingJob != null) { diff --git a/apex/jobscheduler/service/java/com/android/server/job/JobServiceContext.java b/apex/jobscheduler/service/java/com/android/server/job/JobServiceContext.java index b080bf31fed40..217cf1d12b68d 100644 --- a/apex/jobscheduler/service/java/com/android/server/job/JobServiceContext.java +++ b/apex/jobscheduler/service/java/com/android/server/job/JobServiceContext.java @@ -464,7 +464,12 @@ public final class JobServiceContext implements ServiceConnection { job.isConstraintSatisfied(JobStatus.CONSTRAINT_CONTENT_TRIGGER), mExecutionStartTimeElapsed - job.enqueueTime, job.getJob().isUserInitiated(), - job.shouldTreatAsUserInitiatedJob()); + job.shouldTreatAsUserInitiatedJob(), + job.getJob().isPeriodic(), + job.getJob().getMinLatencyMillis(), + job.getEstimatedNetworkDownloadBytes(), + job.getEstimatedNetworkUploadBytes(), + job.getWorkCount()); final String sourcePackage = job.getSourcePackageName(); if (Trace.isTagEnabled(Trace.TRACE_TAG_SYSTEM_SERVER)) { final String componentPackage = job.getServiceComponent().getPackageName(); @@ -1388,9 +1393,14 @@ public final class JobServiceContext implements ServiceConnection { completedJob.isConstraintSatisfied(JobInfo.CONSTRAINT_FLAG_DEVICE_IDLE), completedJob.isConstraintSatisfied(JobStatus.CONSTRAINT_CONNECTIVITY), completedJob.isConstraintSatisfied(JobStatus.CONSTRAINT_CONTENT_TRIGGER), - 0, + mExecutionStartTimeElapsed - completedJob.enqueueTime, completedJob.getJob().isUserInitiated(), - completedJob.startedAsUserInitiatedJob); + completedJob.startedAsUserInitiatedJob, + completedJob.getJob().isPeriodic(), + completedJob.getJob().getMinLatencyMillis(), + completedJob.getEstimatedNetworkDownloadBytes(), + completedJob.getEstimatedNetworkUploadBytes(), + completedJob.getWorkCount()); if (Trace.isTagEnabled(Trace.TRACE_TAG_SYSTEM_SERVER)) { Trace.asyncTraceForTrackEnd(Trace.TRACE_TAG_SYSTEM_SERVER, "JobScheduler", getId());