首页 > 解决方案 > 在哪里可以找到 JobScheduler 调试文档

问题描述

我从调试中得到以下数据:

 JOB #u0a231/5: a2826a0 com.abc.workmanagertest/androidx.work.impl.background.systemjob.SystemJobService
    u0a231 tag=*job*/com.abc.workmanagertest/androidx.work.impl.background.systemjob.SystemJobService
    Source: uid=u0a231 user=0 pkg=com.abc.workmanagertest
    JobInfo:
      Service: com.abc.workmanagertest/androidx.work.impl.background.systemjob.SystemJobService
      Flags: 2
      Requires: charging=false batteryNotLow=false deviceIdle=false
      Trigger content URIs:
        1 content://media/internal/video/media
        1 content://media/external/video/media
        1 content://media/internal/images/media
        1 content://media/external/images/media
      Trigger update delay: +1m0s0ms
      Trigger max delay: +10m0s0ms
      Extras: mParcelledData.dataSize=180
      Network type: NetworkRequest [ NONE id=0, [ Capabilities: NOT_METERED&INTERNET&NOT_RESTRICTED&TRUSTED&VALIDATED Uid: 10231 AdministratorUids: [] RequestorUid: -1 RequestorPackageName: null] ]
      Backoff: policy=1 initial=+30s0ms
    Required constraints: CONNECTIVITY CONTENT_TRIGGER [0x14000000]
    Dynamic constraints:
    Satisfied constraints: CONNECTIVITY CONTENT_TRIGGER DEVICE_NOT_DOZING BACKGROUND_NOT_RESTRICTED [0x16400000]
    Unsatisfied constraints: WITHIN_QUOTA [0x1000000]
    Tracking: CONNECTIVITY CONTENT QUOTA
    Implicit constraints:
      readyNotDozing: true
      readyNotRestrictedInBg: true
      readyDynamicSatisfied: false
    Network: 103
    Standby bucket: RARE
      Deferred since: -1h4m36s59ms
    Enqueue time: -1h4m36s59ms
    Run time: earliest=none, latest=none, original latest=none
    Restricted due to: none.
    Ready: false (job=false user=true !restricted=true !pending=true !active=true !backingup=true comp=true) 

如您所见,未执行作业的问题是:未满足的约束:WITHIN_QUOTA

没有任何文档解释这意味着什么吗?

我看到了以下帖子,但这只是一个观点:

独特的周期性工作在一段时间后停止执行

标签: androidandroid-workmanagerandroid-jobscheduler

解决方案


您可以像setRequiresCharging一样为 Job 指定约束。如果不满足约束,可以使用onStopJob停止作业。例如,转储中的作业需要CONNECTIVITY CONTENT_TRIGGER约束。

Unsatisfied constraints: WITHIN_QUOTA shows WITHIN_QUOTA implicit constraints unsatisfied for this job - can't run your job without quota. WITHIN_QUOTA is implicit constraints (added without explicit constraints setting, see this code).

PTAL QuotaController documentation for more detail regards standby bucket quota.


推荐阅读