I'm little bit confused why my Transitions API
solution works usually for first day or two and after that stop receiving any updates. I dug deeper into it and found a lead that talks about how we need to have SIGNIFICAT_MOTION
sensor active in order to wake up sensors that eventually wake up Transitions API
solution as a whole.
What I did was I implemented listener that helps me understand when SIGNIFICANT_MOTION
sensor is enabled and when not:
try {
boolean request = sensorManager.requestTriggerSensor(triggerEventListener, sensor);
Timber.e("Transitions API is working. If returns false - device is STILL");
} catch (IllegalArgumentException exception) {
sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
sensor = sensorManager.getDefaultSensor(Sensor.TYPE_SIGNIFICANT_MOTION);
Timber.e("SensorManager - " + sensorManager + ", sensor - " + sensor); //TODO: Later delete
}
Now as you can see, whenever this code throws exception I try to re-initialize sensors to make sure exception is not thrown later in the app. Logs show that sensor is null
.
When sensor turns to null after day or two (for first day it works well and device returns sensor value correctly), there's no way to fix the issue anymore except rebooting the device.
Question: Why does sensorManager.getDefaultSensor(Sensor.TYPE_SIGNIFICANT_MOTION);
return value (sensor) for first day, but after 48ish hours returns null and stops working? (I believe that messes up my Transitions API solution and is root cause of why it is not working).
Additional information.
Phone: Google Pixel 3A OS: Android 12
I think this ticker might be related? https://issuetracker.google.com/issues/259298110
from Android defaultSensor TYPE_SIGNIFICANT_MOTION returns null after 24 hours
No comments:
Post a Comment