diff --git a/apex/jobscheduler/framework/java/android/app/job/JobParameters.java b/apex/jobscheduler/framework/java/android/app/job/JobParameters.java index 48b62a607a5e6..6abef1b42161b 100644 --- a/apex/jobscheduler/framework/java/android/app/job/JobParameters.java +++ b/apex/jobscheduler/framework/java/android/app/job/JobParameters.java @@ -45,25 +45,25 @@ public class JobParameters implements Parcelable { /** @hide */ public static final int INTERNAL_STOP_REASON_CANCELED = - JobProtoEnums.STOP_REASON_CANCELLED; // 0. + JobProtoEnums.INTERNAL_STOP_REASON_CANCELLED; // 0. /** @hide */ public static final int INTERNAL_STOP_REASON_CONSTRAINTS_NOT_SATISFIED = - JobProtoEnums.STOP_REASON_CONSTRAINTS_NOT_SATISFIED; // 1. + JobProtoEnums.INTERNAL_STOP_REASON_CONSTRAINTS_NOT_SATISFIED; // 1. /** @hide */ public static final int INTERNAL_STOP_REASON_PREEMPT = - JobProtoEnums.STOP_REASON_PREEMPT; // 2. + JobProtoEnums.INTERNAL_STOP_REASON_PREEMPT; // 2. /** * The job ran for at least its minimum execution limit. * @hide */ public static final int INTERNAL_STOP_REASON_TIMEOUT = - JobProtoEnums.STOP_REASON_TIMEOUT; // 3. + JobProtoEnums.INTERNAL_STOP_REASON_TIMEOUT; // 3. /** @hide */ public static final int INTERNAL_STOP_REASON_DEVICE_IDLE = - JobProtoEnums.STOP_REASON_DEVICE_IDLE; // 4. + JobProtoEnums.INTERNAL_STOP_REASON_DEVICE_IDLE; // 4. /** @hide */ public static final int INTERNAL_STOP_REASON_DEVICE_THERMAL = - JobProtoEnums.STOP_REASON_DEVICE_THERMAL; // 5. + JobProtoEnums.INTERNAL_STOP_REASON_DEVICE_THERMAL; // 5. /** * The job is in the {@link android.app.usage.UsageStatsManager#STANDBY_BUCKET_RESTRICTED} * bucket. @@ -71,26 +71,30 @@ public class JobParameters implements Parcelable { * @hide */ public static final int INTERNAL_STOP_REASON_RESTRICTED_BUCKET = - JobProtoEnums.STOP_REASON_RESTRICTED_BUCKET; // 6. + JobProtoEnums.INTERNAL_STOP_REASON_RESTRICTED_BUCKET; // 6. /** * The app was uninstalled. * @hide */ - public static final int INTERNAL_STOP_REASON_UNINSTALL = 7; + public static final int INTERNAL_STOP_REASON_UNINSTALL = + JobProtoEnums.INTERNAL_STOP_REASON_UNINSTALL; // 7. /** * The app's data was cleared. * @hide */ - public static final int INTERNAL_STOP_REASON_DATA_CLEARED = 8; + public static final int INTERNAL_STOP_REASON_DATA_CLEARED = + JobProtoEnums.INTERNAL_STOP_REASON_DATA_CLEARED; // 8. /** * @hide */ - public static final int INTERNAL_STOP_REASON_RTC_UPDATED = 9; + public static final int INTERNAL_STOP_REASON_RTC_UPDATED = + JobProtoEnums.INTERNAL_STOP_REASON_RTC_UPDATED; // 9. /** * The app called jobFinished() on its own. * @hide */ - public static final int INTERNAL_STOP_REASON_SUCCESSFUL_FINISH = 10; + public static final int INTERNAL_STOP_REASON_SUCCESSFUL_FINISH = + JobProtoEnums.INTERNAL_STOP_REASON_SUCCESSFUL_FINISH; // 10. /** * All the stop reason codes. This should be regarded as an immutable array at runtime. @@ -109,6 +113,10 @@ public class JobParameters implements Parcelable { INTERNAL_STOP_REASON_DEVICE_IDLE, INTERNAL_STOP_REASON_DEVICE_THERMAL, INTERNAL_STOP_REASON_RESTRICTED_BUCKET, + INTERNAL_STOP_REASON_UNINSTALL, + INTERNAL_STOP_REASON_DATA_CLEARED, + INTERNAL_STOP_REASON_RTC_UPDATED, + INTERNAL_STOP_REASON_SUCCESSFUL_FINISH, }; /** 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 313cd208f7fba..452be3008a32d 100644 --- a/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java +++ b/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java @@ -1088,7 +1088,7 @@ public class JobSchedulerService extends com.android.server.SystemService FrameworkStatsLog.write_non_chained(FrameworkStatsLog.SCHEDULED_JOB_STATE_CHANGED, uId, null, jobStatus.getBatteryName(), FrameworkStatsLog.SCHEDULED_JOB_STATE_CHANGED__STATE__SCHEDULED, - JobProtoEnums.STOP_REASON_UNKNOWN, jobStatus.getStandbyBucket(), + JobProtoEnums.INTERNAL_STOP_REASON_UNKNOWN, jobStatus.getStandbyBucket(), jobStatus.getJobId(), jobStatus.hasChargingConstraint(), jobStatus.hasBatteryNotLowConstraint(), @@ -1099,7 +1099,8 @@ public class JobSchedulerService extends com.android.server.SystemService jobStatus.hasConnectivityConstraint(), jobStatus.hasContentTriggerConstraint(), jobStatus.isRequestedExpeditedJob(), - /* isRunningAsExpeditedJob */ false); + /* isRunningAsExpeditedJob */ false, + JobProtoEnums.STOP_REASON_UNDEFINED); // 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 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 6ab2be32f5c34..3fa1c12ce762f 100644 --- a/apex/jobscheduler/service/java/com/android/server/job/JobServiceContext.java +++ b/apex/jobscheduler/service/java/com/android/server/job/JobServiceContext.java @@ -314,7 +314,8 @@ public final class JobServiceContext implements ServiceConnection { FrameworkStatsLog.write_non_chained(FrameworkStatsLog.SCHEDULED_JOB_STATE_CHANGED, job.getSourceUid(), null, job.getBatteryName(), FrameworkStatsLog.SCHEDULED_JOB_STATE_CHANGED__STATE__STARTED, - JobProtoEnums.STOP_REASON_UNKNOWN, job.getStandbyBucket(), job.getJobId(), + JobProtoEnums.INTERNAL_STOP_REASON_UNKNOWN, + job.getStandbyBucket(), job.getJobId(), job.hasChargingConstraint(), job.hasBatteryNotLowConstraint(), job.hasStorageNotLowConstraint(), @@ -324,7 +325,8 @@ public final class JobServiceContext implements ServiceConnection { job.hasConnectivityConstraint(), job.hasContentTriggerConstraint(), job.isRequestedExpeditedJob(), - job.shouldTreatAsExpeditedJob()); + job.shouldTreatAsExpeditedJob(), + JobProtoEnums.STOP_REASON_UNDEFINED); try { mBatteryStats.noteJobStart(job.getBatteryName(), job.getSourceUid()); } catch (RemoteException e) { @@ -923,7 +925,8 @@ public final class JobServiceContext implements ServiceConnection { completedJob.hasConnectivityConstraint(), completedJob.hasContentTriggerConstraint(), completedJob.isRequestedExpeditedJob(), - completedJob.startedAsExpeditedJob); + completedJob.startedAsExpeditedJob, + mParams.getStopReason()); try { mBatteryStats.noteJobFinish(mRunningJob.getBatteryName(), mRunningJob.getSourceUid(), internalStopReason); diff --git a/core/proto/android/os/batterystats.proto b/core/proto/android/os/batterystats.proto index 7d68a0df23d50..4c84944a73821 100644 --- a/core/proto/android/os/batterystats.proto +++ b/core/proto/android/os/batterystats.proto @@ -642,7 +642,7 @@ message UidProto { message ReasonCount { option (android.msg_privacy).dest = DEST_AUTOMATIC; - optional android.app.job.StopReasonEnum name = 1; + optional android.app.job.InternalStopReasonEnum name = 1; optional int32 count = 2; } repeated ReasonCount reason_count = 2; diff --git a/core/proto/android/server/jobscheduler.proto b/core/proto/android/server/jobscheduler.proto index 36d48e22e247f..c4ff49cfbfaf5 100644 --- a/core/proto/android/server/jobscheduler.proto +++ b/core/proto/android/server/jobscheduler.proto @@ -51,7 +51,7 @@ message JobSchedulerServiceDumpProto { message JobRestriction { option (.android.msg_privacy).dest = DEST_AUTOMATIC; - optional .android.app.job.StopReasonEnum reason = 1; + optional .android.app.job.InternalStopReasonEnum reason = 1; optional bool is_restricting = 2; } @@ -856,7 +856,7 @@ message DataSetProto { message StopReasonCount { option (.android.msg_privacy).dest = DEST_AUTOMATIC; - optional .android.app.job.StopReasonEnum reason = 1; + optional .android.app.job.InternalStopReasonEnum reason = 1; optional int32 count = 2; } repeated StopReasonCount stop_reasons = 9; @@ -907,7 +907,7 @@ message JobPackageHistoryProto { optional int32 job_id = 4; optional string tag = 5; // Only valid for STOP_JOB or STOP_PERIODIC_JOB Events. - optional .android.app.job.StopReasonEnum stop_reason = 6; + optional .android.app.job.InternalStopReasonEnum stop_reason = 6; } repeated HistoryEvent history_event = 1; }