Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,9 @@ class MainActivity : ComponentActivity() {
override fun onDestroy() {
super.onDestroy()
overlayManager?.hide()
HandDetector.stopScanning()
CardClassifier.destroy()
HandDetector.destroy()
// CardClassifier is a process-scoped singleton (PyTorch). Destroying it while a scan coroutine
// is mid-inference can crash native code (destroyed mutex). Let the OS clean up on process exit.
scope.cancel()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,7 @@ Or if waiting is better: {"action":"wait","reasoning":"<15 words max>"}"""
val msg = "Low confidence: $card? ($pct% < ${(threshold * 100).toInt()}%)"
overlay?.updateStatus(msg)
Log.w(TAG, "CMD: $msg")
isBusy = false
return
}

Expand All @@ -878,13 +879,15 @@ Or if waiting is better: {"action":"wait","reasoning":"<15 words max>"}"""
val msg = "Not in hand: $card (hand: $handCards)"
overlay?.updateStatus(msg)
Log.w(TAG, "CMD: $msg")
isBusy = false
return
}

if (slotIndex < 0 || slotIndex >= Coordinates.CARD_SLOTS.size) {
val msg = "ERROR: Invalid slot index $slotIndex for $card"
overlay?.updateStatus(msg)
Log.e(TAG, "CMD: $msg")
isBusy = false
return
}

Expand All @@ -901,13 +904,15 @@ Or if waiting is better: {"action":"wait","reasoning":"<15 words max>"}"""
val msg = "ERROR: No zone for $card"
overlay?.updateStatus(msg)
Log.e(TAG, "CMD: $msg")
isBusy = false
return
}
val zoneCoords = Coordinates.ZONE_MAP[zone]
if (zoneCoords == null) {
val msg = "ERROR: Unknown zone '$zone'"
overlay?.updateStatus(msg)
Log.e(TAG, "CMD: $msg")
isBusy = false
return
}
zoneX = zoneCoords.first
Expand All @@ -920,6 +925,7 @@ Or if waiting is better: {"action":"wait","reasoning":"<15 words max>"}"""
val msg = "ERROR: Accessibility service not connected"
overlay?.updateStatus(msg)
Log.e(TAG, "CMD: $msg")
isBusy = false
return
}

Expand Down