Android Wake lock remains after Doze mode?
Asked Answered
V

0

1

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
Vinegary answered 3/12, 2018 at 13:6 Comment(4)
Suffice it to say, this shouldn't be happening. Some possibilities: 1.) Your Job occurred during a scheduled maintenance window (which would actually be the design behavior) 2.) Maybe you have to disconnect emulator power, and turn the screen off 3.) Emulator image doesn't support doze or maybe 4.) Emulator is simply buggy @NickAnanna
@Ananna I tried it also on a couple real devices and same thing happened. I ran also the adb command battery unplug and nothing change. Thread still running. The job/thread was executing before the doze mode kicks in. You could tried it to see for yourself. Its a simple example.Vinegary
Can't get it to work either.Ananna
@Ananna So what is wrong here? Iam very curious..Vinegary

© 2022 - 2024 — McMap. All rights reserved.