Skip to content

feat(banking): add Banking mode (Pause Mika) switch - #804

Open
Razor573 wants to merge 12 commits into
wangzan101:mainfrom
Razor573:pr/banking-mode
Open

Razor573 wants to merge 12 commits into
wangzan101:mainfrom
Razor573:pr/banking-mode

Conversation

@Razor573

Copy link
Copy Markdown
Contributor

Summary

Adds Banking mode ("Pause Mika") under Settings → Banking mode, allowing users to temporarily pause Mika so strict banking apps that block accessibility services or wireless debugging can open, and then resume Mika afterward without uninstalling, re-pairing, or losing data.

What it does

  • Core shell pause/resume (BuiltinShellStatus.Paused): BuiltinShellEngine.pause() stops the running phone helper and suppresses the watchdog, AccessibilityRepair, PairingScreen auto-pairing, and pairing notifications—while preserving the saved wireless-debugging pairing key and port cache (unpair()/forget() is never called).
  • BankingMode controller (BankingMode.kt): Persists the paused flag across restarts (re-applied on MikaApp.onCreate()), stops any running task first, disables the accessibility service via disableSelf() on Android 13+, and turns off wireless debugging when WRITE_SECURE_SETTINGS is held (falling back to clear manual instructions otherwise).
  • Resume flow (BankingScreen.kt): Clears paused, re-enables wireless debugging when permitted, reconnects the helper using the saved pairing, and lists any remaining manual steps (such as toggling Accessibility back on in system settings, which Android forbids an app from doing itself).
  • Settings & home banner integration: Adds a Banking mode row under Capabilities in SettingsScreen and shows a non-error paused status banner that routes to Settings.

Adaptations for upstream main

  • Branched cleanly from upstream main (9c7aabd8) with all fork-specific code removed (no Mika 2 branding, no app/build.gradle.kts version/package changes, no docs/play-internal-testing.md).
  • Integrated BuiltinShellStatus.Paused alongside upstream's Shizuku transport checks in BuiltinShellEngine and PhoneSetupCopy, and Fix.OpenPhoneOps in MainActivity.
  • Replaced bank-specific copy in strings_banking.xml and docs/banking-mode.md with generic banking-app wording.
  • Placed the 4 engine pause/resume tests in a standalone BuiltinShellEngineBankingTest.kt to avoid touching BuiltinShellEngineTest.kt.

How to test

  1. Run unit tests and translation checks:
    python3 tools/i18n/translations.py check
    ./gradlew :core:test :app:testDebugUnitTest
  2. On a device, open Settings → Banking mode and tap Pause Mika: verify running tasks stop, the phone helper transitions to Paused, accessibility turns off (Android 13+), wireless debugging turns off (if WRITE_SECURE_SETTINGS is granted), and the home banner shows Mika paused.
  3. Tap Resume Mika: verify the helper reconnects with the saved pairing without asking for a new pairing code, and any remaining manual steps (Accessibility settings) are listed with direct action buttons.

Copilot AI balanced review requested due to automatic review settings November 22, 2026 14:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T14:35:25.158273Z 82ae2cd PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 82ae2cd87f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +397 to +399
if (_paused) {
_status.value = BuiltinShellStatus.Paused
return@withLock

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Stop helper handoffs that finish after Pause

If the user pauses while a wireless-debugging launch has passed this guard but has not handed its Binder to hub.shell, pause() can cancel the retry and call stopHelper() before a helper exists. The detached helper can then attach afterward, and the paused collector only updates the status and returns, leaving the helper alive while Banking mode reports Paused. Serialize pause with an in-flight launch or stop any helper that attaches after pause.

Useful? React with 👍 / 👎.

Comment on lines +108 to +109
allowed() && s.stuck && unlocked && h != BuiltinShellStatus.Paused &&
(direct() || h == BuiltinShellStatus.Running) && consent().wants(RecoveryCapability.Accessibility)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Gate accessibility repair on the pause flag

If Shizuku becomes unavailable while Banking mode is paused, BuiltinShellEngine.shizukuChanged() can replace the Paused status with idleStatus(), so this check allows recovery to proceed even though the persisted pause flag is still true. When WRITE_SECURE_SETTINGS and accessibility recovery consent are enabled, AccessibilityRepair can then write Mika back into the enabled-services list while the user is trying to keep it off. Check the pause state directly or preserve Paused through status changes.

Useful? React with 👍 / 👎.

var a11yOff = before.accessibility == AccessibilityState.Off
var a11yNeedsManual = false
if (!a11yOff) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use disableSelf() across the supported API range

On supported Android versions 29–32, this branch never calls disableSelf() and always requires the user to turn off accessibility manually, even when Mika's service is running. AccessibilityService.disableSelf() has been available since API 24, so these devices leave accessibility enabled after Pause instead of completing the one-tap flow. Use the method on the APIs where it is available.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants