#2060 fix: fix toggle hotspot action crashing on Android 11#2114
Closed
#2060 fix: fix toggle hotspot action crashing on Android 11#2114
Conversation
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
Collaborator
Author
|
this did not fix the problem. needs much more investigation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2060
Summary
The hotspot toggle/enable/disable actions crashed the accessibility service on Android 11 because:
SystemBridgeConnectionManager.run()only caughtRemoteException, soUnsupportedOperationExceptionthrown by the SystemBridge (whenTetheringConnectoris unavailable on some Android 11 devices) propagated uncaught and crashed the service.Changes
SystemBridgeConnectionManager.ktrun()now also catchesRuntimeExceptionso unexpected exceptions from the SystemBridge never crash the accessibility serviceAndroidNetworkAdapter.ktisHotspotEnabled()uses the public (deprecated)WifiManager.isWifiApEnabled();enableHotspot()/disableHotspot()use the hiddenConnectivityManager.startTethering()/stopTethering()APIs via reflection whenWRITE_SETTINGSis granted, falling back to the SystemBridge when it is notActionUtils.ktWRITE_SETTINGSis now declared as a required permission for hotspot actions on Android 11 only (on Android 12+ the SystemBridge is still preferred)Test plan
WRITE_SETTINGS: confirm a permission error is shown (not a crash)https://claude.ai/code/session_01AdijnJnpbsCqPDTYobwnLa