Skip to content

FullCharge: Switch charge modes from the gesture notification - #50

Merged
d4rken merged 1 commit into
mainfrom
feat/gesture-notification-actions
Aug 11, 2026
Merged

FullCharge: Switch charge modes from the gesture notification#50
d4rken merged 1 commit into
mainfrom
feat/gesture-notification-actions

Conversation

@d4rken

@d4rken d4rken commented Aug 11, 2026

Copy link
Copy Markdown
Member

What changed

  • While the reconnect gesture is enabled, its ongoing notification now offers two buttons to switch the charge mode directly: one sets the protective default (e.g. "Limit to 80%"), one sets "Always 100%".
  • The buttons show in the notification's steady states only — the 10-second reconnect countdown stays a bare, time-critical instruction.
  • If charging control isn't available when a button is tapped (e.g. Shizuku isn't running and no durable permission was granted), a notification now explains that the charge mode wasn't changed instead of failing silently.

Technical Context

  • Both actions route through the existing serialized ACTION_SET_PERSISTENT_POLICY service command the widget's ∞80%/∞100% buttons already use (cancels a running session without restoring, force-writes so same-value writes still re-trigger the HAL, updates all surfaces). No new write path, no allowlist or capability-gate change.
  • SessionNotifications.gesture() takes the protect policy as a required parameter fed from the adapter's declared defaultProtectivePolicy, so the action follows the capability surface instead of hardcoding the Pixel limit. Label handles FixedLimit/Adaptive with a generic fallback, mirroring the widget's protectButtonLabel.
  • The two PendingIntents share an intent action and differ only in an extra, which doesn't factor into PendingIntent equality — hence distinct request codes (8/9).
  • Actions are gated on an explicit IDLE || ARMED allowlist rather than != WAITING_FOR_RECONNECT, because TRIGGER also reaches the builder and must not offer a competing persistent write.
  • The unwritable-control feedback lives in the refusal branch of the shared command: widget/tile pre-check writability and open the app instead, but a notification action fires a PendingIntent and cannot pre-check; the branch also covers a surface racing a lost write capability.
  • Robolectric tests cover action count per gesture state (including TRIGGER), labels per policy, policy-to-extra wiring, foreground-service PendingIntent semantics/distinctness, and send() dispatch into the started-service record.

…ication

The reconnect-gesture notification was display-only. It now carries two
actions on its standing states: the adapter's declared protective default
(named after defaultProtectivePolicy, so Adaptive-default adapters aren't
mislabelled as a percentage limit) and "Always 100%".

Both route through the existing serialized ACTION_SET_PERSISTENT_POLICY
command, the same path the widget uses, so they inherit its writability
guard, recovery-target persistence before the risky write, session
cancel-without-restore, forced re-write and surface updates. No new write
path and no change to the writable-setting allowlist.

Actions are attached on IDLE and ARMED only — an explicit allowlist rather
than "not the countdown", because TRIGGER also reaches the builder and a
tick that is starting a full charge must not offer a competing persistent
write. The two PendingIntents differ only in an extra, which does not
factor into PendingIntent equality, so they use distinct request codes.

setPersistentPolicy's refusal branch now posts the recovery notification:
the widget and tile pre-check writability and open the app instead of
dispatching, but a notification action cannot, so its tap would otherwise
be a silent no-op.
@d4rken d4rken added the ROM: Pixel Google Pixel label Aug 11, 2026
@github-actions github-actions Bot added the enhancement New feature or request label Aug 11, 2026
@d4rken
d4rken merged commit d83688f into main Aug 11, 2026
12 checks passed
@d4rken
d4rken deleted the feat/gesture-notification-actions branch August 11, 2026 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request ROM: Pixel Google Pixel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant