Skip to content

feat: add Device care DIY action - #1476

Open
jawzf wants to merge 1 commit into
sameerasw:developfrom
jawzf:feat/011-device-care-action
Open

jawzf wants to merge 1 commit into
sameerasw:developfrom
jawzf:feat/011-device-care-action

Conversation

@jawzf

@jawzf jawzf commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds a Device care action to DIY automations, under System actions next to Send notification. It cleans up the device in one step and needs Shizuku or root.

Before: there was no way to clear app caches or close background apps without picking a list of apps (App Freezing).

After: add Device care to any automation (for example, Screen on or Charging), with two switches in its settings:

  • Clear app caches: deletes every app's cache files (pm trim-caches). Apps rebuild them as needed.
  • Close background apps: closes the background processes of idle user-installed apps (am kill). It skips Essentials, the default launcher, the current keyboard, Shizuku, and apps FreezeManager.isAppActive sees as in use (foreground, playing media, ongoing notification). am kill never touches foreground apps or foreground services, and unlike force-stop it leaves the app's alarms, jobs and notifications alone. System apps aren't touched.

When it finishes, a toast shows the space freed, e.g. "Device care: 23 MB freed". Save is disabled with both switches off. With only one switch on, the action row shows "Device care · Clear app caches" or "Device care · Close background apps".

How: Action.DeviceCare is a configurable action like SendNotification, saved through the existing ActionGsonAdapter. DeviceCare.run runs both steps through ShellUtils off the main thread, sending all the kills as one shell command. The action declares SHIZUKU/ROOT, so the editor shows the existing permission sheet when access is missing, and executeAll reports it at run time.

Type of change

  • Bug fix
  • New feature
  • UI / visual update
  • Performance improvement
  • Refactoring / cleanup
  • Translations
  • Build / CI tooling

UI changes

1_settings_sheet

The Device care settings sheet.

2_toast

The toast after a run.

Checklist

  • The base branch is set to develop (not main).
  • The app builds cleanly locally with ./gradlew assembleDebug (and assembleRelease).
  • Unit tests pass with ./gradlew testDebugUnitTest (2 new tests in ActionListJsonTest: round trip, and a bare {"type":"DeviceCare"} loads with both options on).
  • Tested on the Android 17 emulator with Shizuku: listed under System; permission sheet without Shizuku; Save disabled with both off; row titles for each combination; saved options reopen; a run deleted a 40 MB cache file, then closed an idle app while keeping Essentials, Shizuku, the launcher and the keyboard; the action survives a force-stop.
  • Tested on a Pixel 11 Pro (Android 17) with Shizuku: the first run freed about 9 GB of caches in about 35 s and closed 60 of 78 running user apps; apps with foreground services and the launcher kept running. With Spotify playing, a second run left it playing and showed the toast.
  • Reuses EssentialsBottomSheet, RoundedCardContainer, IconToggleItem, the existing permission sheet and FreezeManager.isAppActive.
  • New strings are in strings.xml (English only); icons are rounded_* drawables.
  • No new settings, so nothing to register in FeatureRegistry.kt.
  • No new dependencies or permissions in the manifest. Release APK +8 KB.

🤖 Generated with Claude Code

New System action that clears all apps' caches (pm trim-caches) and
closes idle user apps' background processes (am kill) through Shizuku
or root. It skips Essentials, the launcher, the keyboard, Shizuku and
apps FreezeManager sees as active, then shows a toast with the space
freed. Both steps can be switched off in the action's settings sheet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jawzf
jawzf force-pushed the feat/011-device-care-action branch from ec88e79 to e1e0ce8 Compare October 25, 2026 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant