Skip to content

#2060 fix: fix toggle hotspot action crashing on Android 11#2114

Closed
sds100 wants to merge 2 commits intodevelopfrom
claude/issue-2060-hotspot-android-11
Closed

#2060 fix: fix toggle hotspot action crashing on Android 11#2114
sds100 wants to merge 2 commits intodevelopfrom
claude/issue-2060-hotspot-android-11

Conversation

@sds100
Copy link
Copy Markdown
Collaborator

@sds100 sds100 commented Apr 12, 2026

Closes #2060

Summary

The hotspot toggle/enable/disable actions crashed the accessibility service on Android 11 because:

  1. SystemBridgeConnectionManager.run() only caught RemoteException, so UnsupportedOperationException thrown by the SystemBridge (when TetheringConnector is unavailable on some Android 11 devices) propagated uncaught and crashed the service.
  2. There was no non-root path for hotspot control on Android 11.

Changes

File Change
SystemBridgeConnectionManager.kt run() now also catches RuntimeException so unexpected exceptions from the SystemBridge never crash the accessibility service
AndroidNetworkAdapter.kt On Android 11 (API 30): isHotspotEnabled() uses the public (deprecated) WifiManager.isWifiApEnabled(); enableHotspot() / disableHotspot() use the hidden ConnectivityManager.startTethering() / stopTethering() APIs via reflection when WRITE_SETTINGS is granted, falling back to the SystemBridge when it is not
ActionUtils.kt WRITE_SETTINGS is now declared as a required permission for hotspot actions on Android 11 only (on Android 12+ the SystemBridge is still preferred)

Test plan

  • On Android 11 device without Shizuku/root: grant Modify system settings permission to KeyMapper, then confirm that toggle/enable/disable hotspot actions work without crashing
  • On Android 11 device without Shizuku/root and without WRITE_SETTINGS: confirm a permission error is shown (not a crash)
  • On Android 12+ device with SystemBridge: confirm hotspot actions still work as before

https://claude.ai/code/session_01AdijnJnpbsCqPDTYobwnLa

claude added 2 commits April 12, 2026 22:25
Three-part fix:

1. Catch RuntimeException in SystemBridgeConnectionManager.run() to
   prevent the accessibility service from crashing if the SystemBridge
   throws an unexpected exception (e.g. UnsupportedOperationException
   when the TetheringConnector is unavailable on some Android 11 devices).

2. On Android 11 (API 30) use the public (deprecated) WifiManager
   isWifiApEnabled() to check hotspot state without requiring root.

3. On Android 11 with WRITE_SETTINGS permission, use the hidden
   ConnectivityManager.startTethering() / stopTethering() APIs via
   reflection to enable/disable the hotspot without Shizuku or root.
   WRITE_SETTINGS is now declared as a required permission for hotspot
   actions on Android 11 only.

https://claude.ai/code/session_01AdijnJnpbsCqPDTYobwnLa
Replace direct call to deprecated WifiManager.isWifiApEnabled() with a
reflection-based lookup in isHotspotEnabled(). The deprecated method may
not be present in newer Android SDK compilation stubs (compileSdk 36),
causing a build failure. Reflection bypasses the compile-time check while
still working correctly at runtime on Android 11 devices.

Fall back to the SystemBridge path if reflection fails.

https://claude.ai/code/session_01AdijnJnpbsCqPDTYobwnLa
@sds100
Copy link
Copy Markdown
Collaborator Author

sds100 commented Apr 13, 2026

this did not fix the problem. needs much more investigation

@sds100 sds100 closed this Apr 13, 2026
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.

Toggle hotspot action crashes on Android 11

2 participants