64 lines
4.3 KiB
Markdown
64 lines
4.3 KiB
Markdown
# Ethernet Tethering: focused setup and diagnosis
|
||
|
||
This patch focuses on the Ethernet Tethering path only. It does not pretend to bypass Android system permissions or hardware support.
|
||
|
||
## What was changed
|
||
|
||
- Kept the Android `TetheringManager` request path for Android 11–15 (API 30–35) when the app has the required access.
|
||
- Updated the permission message to explain the one-time setup without auto-opening Settings.
|
||
- Removed `TETHER_PRIVILEGED` from the ordinary APK manifest because declaring a signature/privileged permission does not grant it. A manufacturer/system-app build would need its own authorized manifest and signing configuration.
|
||
- Fixed the state classification so a missing permission is a permission failure, not a claim that the device hardware is unsupported.
|
||
- The Start flow no longer refuses to submit a system request only because no Ethernet interface is currently visible; some builds expose or bring up the downstream interface after tethering starts. The OS callback is still authoritative.
|
||
- Added Windows and shell scripts to grant the `WRITE_SETTINGS` app-op on an owner's authorized development device.
|
||
|
||
## One-time setup on a Windows development PC
|
||
|
||
1. Install the APK whose application ID is `com.ecohub.locksolved`.
|
||
2. Connect the phone to the PC with USB and authorize USB debugging on the phone.
|
||
3. Open this project folder in Explorer and run `tools\grant_write_settings.bat`, or run the same commands in Android Studio Terminal:
|
||
|
||
```bat
|
||
adb devices
|
||
adb shell appops set com.ecohub.locksolved WRITE_SETTINGS allow
|
||
adb shell appops get com.ecohub.locksolved WRITE_SETTINGS
|
||
```
|
||
|
||
The final command should show `WRITE_SETTINGS: allow`. This is a development setup for your own device; `WRITE_SETTINGS` gives the app a broader special permission to modify system settings, so only grant it to a source build you trust. It does not grant `TETHER_PRIVILEGED`. The app itself will not open Settings.
|
||
|
||
If you prefer the Android UI instead, `WRITE_SETTINGS` can only be granted by the system's special-access screen; a normal app cannot grant it to itself.
|
||
|
||
## Verify the physical Ethernet link
|
||
|
||
Your screenshot showed `Ethernet Interface: Disconnected`. This means the app did not observe a live Ethernet link. A software API cannot create a physical link. Connect a compatible USB-C/OTG Ethernet adapter and Ethernet cable to the actual downstream device, and make sure the adapter's link/activity LEDs come on. Then refresh the app. A down/no-carrier interface means a client connection cannot yet be verified, even if a tethering request is accepted.
|
||
|
||
## Try Start Sharing and inspect the real result
|
||
|
||
After the permission setup, close and reopen the app and tap **Start Sharing** once. The controller will submit the Ethernet request for API 30–35 and report the actual platform callback error if Android rejects it.
|
||
|
||
For logs, use Android Studio **View → Tool Windows → Logcat** and filter for `SystemTetheringManager`, `TetheringCapabilityChecker`, `MainViewModel`, and `AndroidRuntime`. Keep the exact error code/message.
|
||
|
||
Common callback results from AOSP include:
|
||
|
||
- `1` unknown interface
|
||
- `2` tethering service unavailable
|
||
- `3` unsupported tethering type/device implementation
|
||
- `4` tethering interface unavailable
|
||
- `11` provisioning failed
|
||
- `12` DHCP server failed
|
||
- `13` entitlement/provisioning check failed
|
||
- `14` no permission to change tethering
|
||
- `15` no permission to access tethering
|
||
|
||
## Android 16 / universal-device limitations
|
||
|
||
The ordinary public Android 16 API documents Wi-Fi tethering requests, not a supported Ethernet request for normal APKs. Devices may also lack an OEM-configured Ethernet downstream interface. This patch does not use undocumented API calls, reflection, root commands, or Settings automation to bypass those restrictions. Android 16 or a device that returns “unsupported” may require manufacturer-authorized system integration.
|
||
|
||
## Important distinction
|
||
|
||
- `WRITE_SETTINGS` access: allows the request path to be attempted on supported Android 11–15 systems.
|
||
- Ethernet interface present + carrier/link up: physical downstream path is available.
|
||
- `TetheringManager` success callback: Android accepted/started the tethering request.
|
||
- Client connected / internet reachable: separate facts that need their own verification.
|
||
|
||
Do not treat any one of these as proof of all the others.
|