Skip to content

feat: add Android Auto connected/disconnected automation triggers - #1363

Merged
sameerasw merged 2 commits into
sameerasw:developfrom
jawzf:feature/android-auto-modes
Oct 15, 2026
Merged

sameerasw merged 2 commits into
sameerasw:developfrom
jawzf:feature/android-auto-modes

Conversation

@jawzf

@jawzf jawzf commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Joe · project thread

Description

Adds Android Auto Connected and Android Auto Disconnected triggers to DIY automations, in the Connectivity & Network category with a car icon.

AndroidAutoModule reuses the existing CarConnectionMonitor and only fires when the projection state actually changes. CarConnection re-emits its current value, so repeated emits are ignored.

Paired with the Set Mode action (now in #1365), this gives Pixels a Samsung-style Driving mode: Android Auto Connected → turn the Driving Mode on, Android Auto Disconnected → turn it off.

Testing: tested on an Android 17 emulator. Both triggers appear in the trigger picker and can be saved. I haven't fired them in a real car, because the emulator has no Android Auto.

The Set Mode action that was part of this PR has moved to #1365.

Type of change

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

UI changes

1_android_auto_triggers

Android Auto Connected / Disconnected in the trigger picker

Checklist

Before submitting, please make sure:

  • The base branch is set to develop (not main).
  • The app builds cleanly locally with ./gradlew assembleDebug.
  • Unit tests pass with ./gradlew testDebugUnitTest.
  • You tested the changes on a device or emulator (including Shizuku or Root if applicable).
  • New preferences use SettingsRepository for keys and getter/setter methods.
  • New user-facing settings are registered in FeatureRegistry.kt for search indexing.
  • New UI follows the design system in ui/core/ (RoundedCardContainer, IconToggleItem, etc.).
  • Strings are added to res/values/strings.xml and drawables use rounded variants (R.drawable.rounded_*).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Qsx9zsmJCSpqGMWqYtXdsS

@jawzf
jawzf requested a review from sameerasw as a code owner October 13, 2026 15:26
@jawzf
jawzf force-pushed the feature/android-auto-modes branch from c727d57 to 2044b47 Compare October 13, 2026 15:46
@jawzf jawzf changed the title feat: Android Auto triggers and a Set Mode action for system Modes feat: add Android Auto connected/disconnected automation triggers Oct 13, 2026
@sameerasw

Copy link
Copy Markdown
Owner

@jawzf some older PRs caused conflcits, can you resolve?

@sameerasw
sameerasw marked this pull request as draft October 15, 2026 11:53
@sameerasw sameerasw added the enhancement New feature or request label Oct 15, 2026
@jawzf
jawzf force-pushed the feature/android-auto-modes branch from 2044b47 to b3acd1f Compare October 15, 2026 15:43
@jawzf

jawzf commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

Rebased on the latest develop and resolved the conflicts with the location triggers.


Generated by Claude Code

@jawzf
jawzf marked this pull request as ready for review October 15, 2026 15:46
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qsx9zsmJCSpqGMWqYtXdsS
@sameerasw
sameerasw force-pushed the feature/android-auto-modes branch from b3acd1f to 5b805bf Compare October 15, 2026 16:48

@sameerasw sameerasw left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contributions <3

@sameerasw
sameerasw merged commit 0dfb0a3 into sameerasw:develop Oct 15, 2026
2 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Essentials Progress Oct 15, 2026
sameerasw added a commit that referenced this pull request Oct 15, 2026
…1365)

<!-- claude-projects-attribution: {"github_login":"jawzf"} -->
_Requested by **Joe** · [project
thread](https://claude.ai/code/project/chan_01FyKGsodrf7JS5wLrjvnZmV?thread=cmsg_01FyKGsodrf7JS5wLrjvnZmV5gqq2zaavhZ6yd58kd52ru)_

## Description
Adds a **Set Mode** action under Sound & Media (Android 15+, needs
Shizuku). It picks any Mode from Settings > Modes and turns it on or
off.

- Runs through Shizuku as shell. Shell holds `MANAGE_NOTIFICATIONS`, so
it can switch Modes that Essentials doesn't own: the built-in ones,
Modes the user created, and rules owned by other apps.
- On Android 17, when `refactor_modes_code` is on, Modes live in the new
`contextual_mode` service (`IContextualModeManager`), and the old
`INotificationManager.getAutomaticZenRules` throws
`IllegalStateException: can't be used when refactor_modes_code is on`.
The action uses `contextual_mode` first and falls back to
`INotificationManager`. It reads both the older `Map` result and the
newer `ParceledListSlice<AutomaticZenRule.AzrWithId>` result.
- If the saved Mode's id no longer exists, it falls back to the Mode's
name, so the action keeps working when a Mode is deleted and recreated.
- When it can't run, it shows a toast: Shizuku isn't running, permission
is missing, the Mode no longer exists, or the system call fails.
- It can be set up from every action picker: DIY automations, Status
Glance, Duo and the island gesture picker.

Example: combined with the Android Auto triggers in #1363, Android Auto
Connected → Set Mode: Driving on gives a Samsung-style Driving mode.

**Testing:** tested on an Android 17 emulator with Shizuku. The picker
listed Bedtime, Driving, Transit and a custom "Test Drive" Mode. Turning
Test Drive on set `zen_mode` to 1, and Settings showed it on. Turning it
off set `zen_mode` back to 0, and Settings showed it off. When a Mode
was deleted after it had been chosen, the action showed "Mode \"Temp
Mode\" no longer exists". I haven't checked setting it up from the
Status Glance, Duo and gesture pickers, because those screens need the
accessibility service. Not yet tested on a physical Pixel.

## Type of change
- [ ] Bug fix
- [x] New feature
- [ ] UI / visual update
- [ ] Performance improvement
- [ ] Refactoring / cleanup
- [ ] Translations
- [ ] Build / CI tooling

## UI changes
<!-- 2_set_mode_picker.png -->
<img width="1344" height="2992" alt="2_set_mode_picker"
src="https://github.com/user-attachments/assets/99cace6f-e9c8-4c0f-b5d7-94fd7eabdce7"
/>

Set Mode settings: choose a Mode and Turn on / Turn off

<!-- 3_mode_turned_on.png -->
<img width="1344" height="2992" alt="3_mode_turned_on"
src="https://github.com/user-attachments/assets/05c61975-7209-4b7b-bc54-2628920d7b4b"
/>

Settings > Modes after the action turned Test Drive on

<!-- 4_mode_turned_off.png -->
<img width="1344" height="2992" alt="4_mode_turned_off"
src="https://github.com/user-attachments/assets/aba6f175-e012-4ca1-8a66-b350fc3ee123"
/>

Settings > Modes after the action turned Test Drive off

## Checklist
Before submitting, please make sure:
- [x] The base branch is set to `develop` (not `main`).
- [x] The app builds cleanly locally with `./gradlew assembleDebug`.
- [x] Unit tests pass with `./gradlew testDebugUnitTest`.
- [x] You tested the changes on a device or emulator (including Shizuku
or Root if applicable).
- [ ] New preferences use `SettingsRepository` for keys and
getter/setter methods.
- [ ] New user-facing settings are registered in `FeatureRegistry.kt`
for search indexing.
- [ ] New UI follows the design system in `ui/core/`
(`RoundedCardContainer`, `IconToggleItem`, etc.).
- [x] Strings are added to `res/values/strings.xml` and drawables use
rounded variants (`R.drawable.rounded_*`).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01Qsx9zsmJCSpqGMWqYtXdsS
@jawzf
jawzf deleted the feature/android-auto-modes branch October 15, 2026 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants