Maria Sophia wrote:
> Q: What's an easy yet accurate way to determine the most recent package? > A: ?
Woo hoo. I found a great way to find the last program run. adb shell dumpsys usagestats | grep "ACTIVITY_RESUMED" | grep -vE "dreams\.basic|launcher|systemui|launcher3|wallpaper" | tail -1 | grep -oE "package=[^ ]+" => package=org.schabi.newpipe Note: where grep => C:\Program Files\coreutils\bin\grep.exe where tail => C:\Program Files\coreutils\bin\tail.exe Changing that only a teeny tiny bit, nets us the last Activity run! adb shell dumpsys usagestats | grep "ACTIVITY_RESUMED" | grep -vE "dreams\.basic|launcher|systemui|launcher3|wallpaper" | tail -1 | grep -oE "class=[^ ]+" => class=org.schabi.newpipe.MainActivity Note that I had to filter out sleep screens & launcher stuff as this gets the last activity run, but since it's a sleep screen, we need to filter out common stuff we're not interested in. adb shell dumpsys usagestats | grep "ACTIVITY_RESUMED" | tail -1 time="2026-11-07 10:00:07" type=ACTIVITY_RESUMED package=com.android.dreams.basic class=android.service.dreams.DreamActivity instanceId=113775963 taskRootPackage=com.android.dreams.basic taskRootClass=android.service.dreams.DreamActivity flags=0x0 Diving down into the previous five activities, we find NewPipe was run. adb shell dumpsys usagestats | grep "ACTIVITY_RESUMED" | tail -5 time="2026-11-07 10:00:07" type=ACTIVITY_RESUMED package=com.android.dreams.basic class=android.service.dreams.DreamActivity instanceId=113775963 taskRootPackage=com.android.dreams.basic taskRootClass=android.service.dreams.DreamActivity flags=0x0 time="2026-11-07 10:00:07" type=ACTIVITY_RESUMED package=com.android.dreams.basic class=android.service.dreams.DreamActivity instanceId=113775963 taskRootPackage=com.android.dreams.basic taskRootClass=android.service.dreams.DreamActivity flags=0x0 time="2026-11-07 10:13:03" type=ACTIVITY_RESUMED package=com.teslacoilsw.launcher class=com.teslacoilsw.launcher.NovaLauncher instanceId=22358917 taskRootPackage=com.teslacoilsw.launcher taskRootClass=com.teslacoilsw.launcher.NovaLauncher flags=0x0 time="2026-11-07 10:13:04" type=ACTIVITY_RESUMED package=com.teslacoilsw.launcher class=com.teslacoilsw.launcher.NovaLauncher instanceId=22358917 taskRootPackage=com.teslacoilsw.launcher taskRootClass=com.teslacoilsw.launcher.NovaLauncher flags=0x0 time="2026-11-07 10:13:09" type=ACTIVITY_RESUMED package=org.schabi.newpipe class=org.schabi.newpipe.MainActivity instanceId=1104153 taskRootPackage=org.schabi.newpipe taskRootClass=org.schabi.newpipe.MainActivity flags=0x0