Android Wake lock remains after Doze mode?

倖福魔咒の 提交于 2019-12-08 07:19:00

问题


Iam trying to simulate the Doze mode while my app is running in the background.

What happens is that the thread will continue to run, even though the device has entered Doze mode. The docs specifies that wake locks are ignored, so why cpu is still on?

Tested On: Emulator with Api 27

             JobScheduler jobScheduler = (JobScheduler)getApplicationContext()
                    .getSystemService(JOB_SCHEDULER_SERVICE);

            ComponentName componentName = new ComponentName(this, MyJob.class);

            JobInfo jobInfo = new JobInfo.Builder(1, componentName)
                    .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY)
                    .build();

          jobScheduler.schedule(jobInfo);

Service

  public class MyJob extends JobService {

    static public int var=0;

    @Override
    public boolean onStartJob(final JobParameters jobParameters) {


        new Thread(new Runnable() {
            @Override
            public void run() {   
                while(true) {
                    Log.d("Counter",var+++"");
                }
            }
        }).start();
        return true;
    }

Shell:

adb shell dumpsys deviceidle force-idle

来源:https://stackoverflow.com/questions/53594490/android-wake-lock-remains-after-doze-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!