fix: getCurrentPackage returns actual foreground app instead of own overlay
rootInActiveWindow was returning PicoClaw's own overlay window, causing current_activity to always report PicoClaw as the foreground app. Now iterates service.windows to find the first TYPE_APPLICATION window that isn't our own package. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d970fdd0b9
commit
c839b0d658
1 changed files with 7 additions and 1 deletions
|
|
@ -55,7 +55,13 @@ class DeviceController {
|
|||
}
|
||||
|
||||
fun getCurrentPackage(): String? {
|
||||
return service?.rootInActiveWindow?.packageName?.toString()
|
||||
val svc = service ?: return null
|
||||
val ownPackage = svc.packageName
|
||||
// Skip our own overlay window and find the actual foreground app
|
||||
return svc.windows
|
||||
.filter { it.type == android.view.accessibility.AccessibilityWindowInfo.TYPE_APPLICATION }
|
||||
.firstOrNull { it.root?.packageName?.toString() != ownPackage }
|
||||
?.root?.packageName?.toString()
|
||||
}
|
||||
|
||||
suspend fun inputText(text: String): Boolean {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue