Tag name should use a unique prefix followed by a colon (found tag). For instance
myapp:mywakelocktag. This will help with debugging less... (Ctrl+F1)Wake Lock tags must follow the naming conventions defined in the
PowerManagerdocumentation. Issue id: InvalidWakeLockTag
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
float distance = sensorEvent.values[0];
if (!isVideo && !isSpeaker) {
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
if (distance < 4) {
if (wlOn != null && wlOn.isHeld()) {
wlOn.release();
}
if (pm != null) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
if (wlOff == null)
wlOff = pm.newWakeLock(PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK, "tag");
if (!wlOff.isHeld()) wlOff.acquire();
}
}
} else {
if (wlOff != null && wlOff.isHeld()) {
wlOff.release();
}
if (pm != null) {
if (wlOn == null)
wlOn = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "tag");
if (!wlOn.isHeld()) wlOn.acquire();
}
}
}
}
