Closed baltpeter closed 1 year ago
The function checks:
❯ adb shell dumpsys activity recents | grep 'Recent #0'
* Recent #0: Task{daae03c #324 type=standard A=10201:de.ivu.eticketinfo}
That does show an app ID.
The problem is with the regex:
That expects an additional U=
after the app ID, which this phone doesn't output.
The code was imported from my master's thesis, so we have no documentation on how it came to be (the linked StackOverflow answer doesn't help).
Anyway, let's assume that the app ID can be delimited at the end by either a space (when an additional parameter follows) or }
(as I observed).
Android 13 emulator:
❯ adb shell dumpsys activity recents | grep 'Recent #0'
* Recent #0: Task{851de4e #34 type=standard A=10159:com.wireguard.android}
Android 11 emulator:
❯ adb shell dumpsys activity recents | grep 'Recent #0'
* Recent #0: Task{a1cc7b9 #10 visible=true type=standard mode=fullscreen translucent=false A=10090:com.google.android.documentsui U=0 StackId=10 sz=1}
So, that's where that came from. My fix works for both.
I have an app open (and in the foreground) on Android. Nonetheless,
getForegroundAppId()
returnsundefined
.