Fix crash with WakeLock

This commit is contained in:
Benoit Marty 2020-09-04 18:43:59 +02:00
parent 8045d61e1f
commit 8ead371603

View file

@ -62,7 +62,9 @@ class CallProximityManager @Inject constructor(
*/ */
fun stop() { fun stop() {
sensorManager.unregisterListener(this) sensorManager.unregisterListener(this)
wakeLock?.release() wakeLock
?.takeIf { it.isHeld }
?.release()
} }
override fun onAccuracyChanged(sensor: Sensor?, accuracy: Int) { override fun onAccuracyChanged(sensor: Sensor?, accuracy: Int) {
@ -91,6 +93,8 @@ class CallProximityManager @Inject constructor(
} }
private fun onProximityFar() { private fun onProximityFar() {
wakeLock?.release() wakeLock
?.takeIf { it.isHeld }
?.release()
} }
} }