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

Commit 61476574 authored by Kunal's avatar Kunal
Browse files

Updating JobScheduler WW logging to include calculated bytes transferred

during Job execution

Test: manual testing on device done by building
Bug: 255393346
Change-Id: If876aed542e8edf282ac36ff53979919bf41ce90
parent 619f3200
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -1808,7 +1808,11 @@ public class JobSchedulerService extends com.android.server.SystemService
                    jobStatus.getEstimatedNetworkUploadBytes(),
                    jobStatus.getWorkCount(),
                    ActivityManager.processStateAmToProto(mUidProcStates.get(jobStatus.getUid())),
                    jobStatus.getNamespaceHash());
                    jobStatus.getNamespaceHash(),
                    /* system_measured_source_download_bytes */0,
                    /* system_measured_source_upload_bytes */ 0,
                    /* system_measured_calling_download_bytes */0,
                    /* system_measured_calling_upload_bytes */ 0);

            // 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
@@ -2245,7 +2249,11 @@ public class JobSchedulerService extends com.android.server.SystemService
                    cancelled.getEstimatedNetworkUploadBytes(),
                    cancelled.getWorkCount(),
                    ActivityManager.processStateAmToProto(mUidProcStates.get(cancelled.getUid())),
                    cancelled.getNamespaceHash());
                    cancelled.getNamespaceHash(),
                    /* system_measured_source_download_bytes */ 0,
                    /* system_measured_source_upload_bytes */ 0,
                    /* system_measured_calling_download_bytes */0,
                    /* system_measured_calling_upload_bytes */ 0);
        }
        // If this is a replacement, bring in the new version of the job
        if (incomingJob != null) {
+31 −2
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import android.content.Intent;
import android.content.PermissionChecker;
import android.content.ServiceConnection;
import android.net.Network;
import android.net.TrafficStats;
import android.net.Uri;
import android.os.Binder;
import android.os.Build;
@@ -241,6 +242,14 @@ public final class JobServiceContext implements ServiceConnection {
    private int mDeathMarkInternalStopReason;
    private String mDeathMarkDebugReason;

    private long mInitialDownloadedBytesFromSource;

    private long mInitialUploadedBytesFromSource;

    private long mInitialDownloadedBytesFromCalling;

    private long mInitialUploadedBytesFromCalling;

    // Debugging: reason this job was last stopped.
    public String mStoppedReason;

@@ -471,6 +480,14 @@ public final class JobServiceContext implements ServiceConnection {
            }
            mJobPackageTracker.noteActive(job);
            final int sourceUid = job.getSourceUid();

            // Measure UID baseline traffic for deltas
            mInitialDownloadedBytesFromSource = TrafficStats.getUidRxBytes(sourceUid);
            mInitialUploadedBytesFromSource = TrafficStats.getUidTxBytes(sourceUid);

            mInitialDownloadedBytesFromCalling = TrafficStats.getUidRxBytes(job.getUid());
            mInitialUploadedBytesFromCalling = TrafficStats.getUidTxBytes(job.getUid());

            FrameworkStatsLog.write(FrameworkStatsLog.SCHEDULED_JOB_STATE_CHANGED,
                    job.isProxyJob() ? new int[]{sourceUid, job.getUid()} : new int[]{sourceUid},
                    // Given that the source tag is set by the calling app, it should be connected
@@ -516,7 +533,11 @@ public final class JobServiceContext implements ServiceConnection {
                    job.getEstimatedNetworkUploadBytes(),
                    job.getWorkCount(),
                    ActivityManager.processStateAmToProto(mService.getUidProcState(job.getUid())),
                    job.getNamespaceHash());
                    job.getNamespaceHash(),
                    /* system_measured_source_download_bytes */ 0,
                    /* system_measured_source_upload_bytes */ 0,
                    /* system_measured_calling_download_bytes */ 0,
                    /* system_measured_calling_upload_bytes */ 0);
            sEnqueuedJwiAtJobStart.logSampleWithUid(job.getUid(), job.getWorkCount());
            final String sourcePackage = job.getSourcePackageName();
            if (Trace.isTagEnabled(Trace.TRACE_TAG_SYSTEM_SERVER)) {
@@ -1585,7 +1606,15 @@ public final class JobServiceContext implements ServiceConnection {
                completedJob.getWorkCount(),
                ActivityManager
                        .processStateAmToProto(mService.getUidProcState(completedJob.getUid())),
                completedJob.getNamespaceHash());
                completedJob.getNamespaceHash(),
                TrafficStats.getUidRxBytes(completedJob.getSourceUid())
                        - mInitialDownloadedBytesFromSource,
                TrafficStats.getUidTxBytes(completedJob.getSourceUid())
                        - mInitialUploadedBytesFromSource,
                TrafficStats.getUidRxBytes(completedJob.getUid())
                        - mInitialDownloadedBytesFromCalling,
                TrafficStats.getUidTxBytes(completedJob.getUid())
                        - mInitialUploadedBytesFromCalling);
        if (Trace.isTagEnabled(Trace.TRACE_TAG_SYSTEM_SERVER)) {
            Trace.asyncTraceForTrackEnd(Trace.TRACE_TAG_SYSTEM_SERVER, "JobScheduler",
                    getId());