Tony_89
Tony_89

Reputation: 817

Android does not exit doze mode when moving with device

So some background, i am developing a location tracking application. I have a service running that gets gps updates using the fused location provider. When the app is closed or the device is locked my service is moved to the foreground. It also uses a partial wakelock and is whitelisted.

I am under the impression that a device should exit doze mode if it moves. As stated in this answer here. However i am seeing inconsistent results on different devices. I have three test devices. A sony experia, a moto e4 plus and a nexus 5x. The application works great on the sony and the nexus. I leave it idle, doze mode kicks in and then when i move the device it exits doze mode and gps updates start again. Which is great because i do not need gps updates when the device is stationary, it would just waste battery life. Just for clarity the different android version for each device are:

Sony Xperia: 7.0
Moto E4 plus: 7.1.1
Nexus 5X: 8.0

The issue is with the moto, i leave the device to enter doze mode. However upon picking it up and moving with it, it does not exit doze mode. It only exits doze mode with some user interaction. After looking through other answers and androids documentation am i correct in assuming that moving the device should always results in it existing from doze mode. If that is the case is this more likely to be a hardware issue, or can the OEM change how doze mode should work?

Thank you for any help.

Upvotes: 0

Views: 685

Answers (2)

Nicolas Julémont
Nicolas Julémont

Reputation: 89

For having this feature working, the manufacturer should have been implemented the "Significant Motion sensor". You can check if this sensor is available by asking if this sensor exists: "android.sensor.significant_motion".

SensorManager mSensorManager = (SensorManager) mContext.getSystemService(Service.SENSOR_SERVICE);
boolean isSensorPresent = mSensorManager.getDefaultSensor(Sensor.TYPE_SIGNIFICANT_MOTION) != null;

Apart of this, there is also some manufacturers that bypass the Doze mode rules with their own power management system. It is the case for some of the phone manufactured by Huawei & Xiaomi for example. In those cases, it is possible to stop the manufacturer power manager system to suspend your application. But it has to be done manually by the user.

Upvotes: 1

Tony_89
Tony_89

Reputation: 817

So android needs to be able to detect motion in order to leave doze mode. The moto does not have a gyroscope. This stops it detecting the movement and exiting doze mode.

Upvotes: 4

Related Questions