### Get Current Wallpaper App Package Source: https://github.com/yassernull/shappky/blob/main/docs/how_shappky_works.md Extracts the package name of the current wallpaper component from dumpsys output. Used to protect the background app from being stopped. ```bash dumpsys wallpaper | grep "mWallpaperComponent=" | head -1 | sed 's/.*ComponentInfo{//' | cut -d'/' -f1 ``` -------------------------------- ### Modern process identification command with toybox (v2.0.0+) Source: https://github.com/yassernull/shappky/blob/main/docs/how_shappky_works.md Refactored in v2.0.0 to address compatibility and accuracy issues. Uses a bundled toybox binary to guarantee identical behavior across devices and ROMs, and includes extended parameters: user, %cpu, pid, and uid. ```bash toybox ps -A -o %cpu,pid,user,rss,name,uid ``` -------------------------------- ### Stage 4: Global Flush - am kill-all Source: https://github.com/yassernull/shappky/blob/main/docs/how_shappky_works.md Soft kill for all background apps to free memory without causing system damage. Used during bulk cleanup actions like 'Select All -> Kill'. ```bash am kill-all ``` -------------------------------- ### Check Foreground Status with dumpsys activity services Source: https://github.com/yassernull/shappky/blob/main/docs/how_shappky_works.md Use this command to dynamically verify if a specific service is in the foreground. The output contains 'isForeground=true' when the service is active. ```bash dumpsys activity services com.example | grep isForeground=true ``` -------------------------------- ### Detect App States - dumpsys activity activities Source: https://github.com/yassernull/shappky/blob/main/docs/how_shappky_works.md Executed to detect app states such as entering, exiting, or resuming. App packages are read from fields like ResumedActivity, mCurrentFocus, and related patterns. ```bash dumpsys activity activities ``` -------------------------------- ### Stage 2: Check PID with pidof Source: https://github.com/yassernull/shappky/blob/main/docs/how_shappky_works.md Verifies if the process is still running after a soft kill. If a PID is returned, Shappky proceeds to force-stop. ```bash pidof com.example ``` -------------------------------- ### List Active Widget Apps Source: https://github.com/yassernull/shappky/blob/main/docs/how_shappky_works.md Retrieves a sorted unique list of package names for active widgets from dumpsys appwidget output. Used to protect widget-providing apps. ```bash dumpsys appwidget | awk '/^Widgets:/{flag=1; next} flag && !/^[A-Z]/{print}' | grep "cmp:ComponentInfo" | sed 's/.*cmp:ComponentInfo{//' | cut -d'/' -f1 | sort -u ``` -------------------------------- ### Legacy process identification command (pre-v2.0.0) Source: https://github.com/yassernull/shappky/blob/main/docs/how_shappky_works.md Used before v2.0.0 to identify active applications by filtering processes with a dot in the name and excluding system services. It skipped valid process lines lacking a dot, such as child shell processes like '0 sh'. ```bash ps -A -o rss,name | grep '\.' | grep -v '[-@]' ``` -------------------------------- ### Stage 1: Soft Kill - am kill Source: https://github.com/yassernull/shappky/blob/main/docs/how_shappky_works.md Gracefully terminates background tasks without breaking widget state or interrupting active user interaction. Used when the app has active home widgets or is in the foreground. ```bash am kill com.example ``` -------------------------------- ### Fetch Recent Apps - dumpsys activity recents Source: https://github.com/yassernull/shappky/blob/main/docs/how_shappky_works.md Fetches apps present in the 'Recent Apps' screen. Used to skip recently used apps and to support the 'kill app when it auto-runs in background' rule. ```bash dumpsys activity recents ``` -------------------------------- ### Stage 2: Force Stop - am force-stop Source: https://github.com/yassernull/shappky/blob/main/docs/how_shappky_works.md Forcibly terminates the application regardless of its active state. Issued when a PID persists after a soft kill. ```bash am force-stop com.example ``` -------------------------------- ### Stage 3: Forced Signal Process Kill - pkill -9 Source: https://github.com/yassernull/shappky/blob/main/docs/how_shappky_works.md Sends a direct termination signal to orphaned background processes that persist after a force-stop. ```bash pkill -9 pid ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.