diff options
author | 2024-08-04 19:48:17 +0000 | |
---|---|---|
committer | 2024-08-04 20:42:04 +0000 | |
commit | 699111cd90ebe58824157aa93925b725abbec8de (patch) | |
tree | 8a0f367544394176dff3807586a99b1abaa1ea82 /apex | |
parent | cd0e636d7ffcb26700ea2f3d6a3eed75fc3a2f47 (diff) |
Create the workchain by default when acquiring the wakelock.
The APIs to create and use workchains have been available for
a while. So, it should be safe to create a workchain by default.
Since the System acquires the wakelock on behalf of the apps
when scheduling jobs, the worksource should include the System uid
to correctly indicate the wakelock acquirer and will allow us to
differentiate between system-held and app-held wakelocks.
Bug: 352676818
Test: atest services/tests/mockingservicestests/src/com/android/server/job/JobSchedulerServiceTest.java
Test: statsd_testdrive 10
Flag: com.android.server.job.create_work_chain_by_default
Change-Id: Ib135729df1a1bcaace2d01ce1a94ec16094b264a
Diffstat (limited to 'apex')
-rw-r--r-- | apex/jobscheduler/service/aconfig/job.aconfig | 10 | ||||
-rw-r--r-- | apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java | 5 |
2 files changed, 13 insertions, 2 deletions
diff --git a/apex/jobscheduler/service/aconfig/job.aconfig b/apex/jobscheduler/service/aconfig/job.aconfig index e489c1ad891a..e8568651eeaa 100644 --- a/apex/jobscheduler/service/aconfig/job.aconfig +++ b/apex/jobscheduler/service/aconfig/job.aconfig @@ -48,3 +48,13 @@ flag { purpose: PURPOSE_BUGFIX } } + +flag { + name: "create_work_chain_by_default" + namespace: "backstage_power" + description: "Create a workchain by default when acquiring a wakelock" + bug: "352676818" + metadata { + purpose: PURPOSE_BUGFIX + } +} 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 ff73a4922977..5f2b01a7304a 100644 --- a/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java +++ b/apex/jobscheduler/service/java/com/android/server/job/JobSchedulerService.java @@ -1617,10 +1617,11 @@ public class JobSchedulerService extends com.android.server.SystemService @NonNull public WorkSource deriveWorkSource(int sourceUid, @Nullable String sourcePackageName) { - if (WorkSource.isChainedBatteryAttributionEnabled(getContext())) { + if (Flags.createWorkChainByDefault() + || WorkSource.isChainedBatteryAttributionEnabled(getContext())) { WorkSource ws = new WorkSource(); ws.createWorkChain() - .addNode(sourceUid, sourcePackageName) + .addNode(sourceUid, null) .addNode(Process.SYSTEM_UID, "JobScheduler"); return ws; } else { |