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

Commit 1c93bfcc authored by Kunal Malhotra's avatar Kunal Malhotra Committed by Android (Google) Code Review
Browse files

Merge "Updating JobScheduler WW logging to include calculated bytes...

Merge "Updating JobScheduler WW logging to include calculated bytes transferred during Job execution" into main
parents 55fb6c8c 61476574
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -1820,7 +1820,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
@@ -2257,7 +2261,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;

@@ -472,6 +481,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
@@ -517,7 +534,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)) {
@@ -1586,7 +1607,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());