android: fix head gestures not working

This commit is contained in:
Kavish Devar
2025-05-21 21:52:41 +05:30
parent 5472e09293
commit 96e63cf35e

View File

@@ -87,13 +87,13 @@ fun startDetection(doNotStop: Boolean = false, onGestureDetected: (Boolean) -> U
isRunning = true
gestureDetectedCallback = onGestureDetected
Log.d(TAG, "started: ${airPodsService.startHeadTracking()}")
clearData()
prevHorizontal = 0.0
prevVertical = 0.0
airPodsService.aacpManager.sendStartHeadTracking()
detectionJob = CoroutineScope(Dispatchers.Default).launch {
while (isRunning) {
delay(50)
@@ -117,7 +117,7 @@ fun startDetection(doNotStop: Boolean = false, onGestureDetected: (Boolean) -> U
Log.d(TAG, "Stopping gesture detection")
isRunning = false
if (!doNotStop) airPodsService.aacpManager.sendStopHeadTracking()
if (!doNotStop) airPodsService.stopHeadTracking()
detectionJob?.cancel()
detectionJob = null