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