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
  • Suffice it to say, this shouldn't be happening. Some possibilities: 1.) Your `Job` occurred during a scheduled [maintenance window](https://developer.android.com/training/monitoring-device-state/doze-standby) (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 @Nick – greeble31 Dec 03 '18 at 14:18
  • @greeble31 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. –  Dec 03 '18 at 14:22
  • Can't get it to work either. – greeble31 Dec 03 '18 at 14:48
  • @greeble31 So what is wrong here? Iam very curious.. –  Dec 03 '18 at 14:54

0 Answers0