pyamsoft / tetherfi

TetherFi - Internet sharing without Root
Apache License 2.0
416 stars 34 forks source link

Tetherfi Hotspot failed to start - Broadcast Error #231

Closed ItsIgnacioPortal closed 4 months ago

ItsIgnacioPortal commented 1 year ago

App version: 20231015-1 Android: 12 Device: Moto e6 plus

When I try to start the Tetherfi hotspot, I get this error:

Screenshot_20231022-022648_TetherFi.png

I already tried reseting to the default settings and rebooting my device, but the problem persists. I've also collected the debugging log of when this error happens:

[D] Creating service 
[D] Starting runner! 
[D] Starting Proxy! 
[D] Start WiDi Network 
[D] Started foreground notification: NotifyId(id=42069): ServerNotificationData(status=NotRunning, clientCount=0, blockCount=0) 
[D] #################################### 
[D] Acquire CPU wakelock: com.pyamsoft.tetherfi:PROXY_WAKE_LOCK 
[D] #################################### 
[D] Register Wifi Receiver 
[D] #################################### 
[D] Acquire WiFi wakelock: com.pyamsoft.tetherfi:PROXY_WIFI_LOCK 
[D] #################################### 
[D] Starting Wi-Fi Direct Network... 
[D] START NEW NETWORK 
[D] WiDi Status Changed: Starting 
[D] Creating WifiP2PManager Channel 
[D] Updated foreground notification: NotifyId(id=42069): ServerNotificationData(status=Starting, clientCount=0, blockCount=0) 
[W] No Group owner address in connection intent 
[W] Group is ERROR, cannot re-use 
[D] Creating new wifi p2p group 
[E] Unable to create Wifi Direct Group
java.lang.RuntimeException: Broadcast Error: Error
    at com.pyamsoft.tetherfi.server.widi.WifiDirectNetwork$createGroup$3$listener$1.onFailure(SourceFile:23)
    at android.net.wifi.p2p.WifiP2pManager$Channel$P2pHandler.handleMessage(WifiP2pManager.java:960)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7870)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
 Broadcast Error: Error
[W] Group failed creation, stop network 
[D] Stop existing WiFi Group 
[W] Failed to stop network: Busy 
[D] Close Group failed but continue teardown anyway 
[D] Close WiFiP2PManager channel 
[D] Reset last info refresh times 
[W] Stopping network after Group failed to create 
[D] WiDi Status Changed: WiFiDirectError(reason=Error, throwable=java.lang.RuntimeException: Broadcast Error: Error) 
[D] WifiP2PManager Channel died! Do nothing :D 
[D] Shutdown event received! 
[D] Shutdown event received! 
[D] Stopping Wi-Fi Direct Network... 
[D] Updated foreground notification: NotifyId(id=42069): ServerNotificationData(status=WiFiDirectError(reason=Error, throwable=java.lang.RuntimeException: Broadcast Error: Error), clientCount=0, blockCount=0) 
[D] Stop Foreground Service! 
[W] Cannot get group info without Wifi channel 
[D] WiFi Direct Group Info: Empty 
[D] Destroying service 
[D] STOP NETWORK 
[D] Shutting down wifi network 
[D] Reset last info refresh times 
[D] Network was stopped 
[D] #################################### 
[D] Release CPU wakelock: com.pyamsoft.tetherfi:PROXY_WAKE_LOCK 
[D] #################################### 
[D] #################################### 
[D] Release WIFI wakelock: com.pyamsoft.tetherfi:PROXY_WIFI_LOCK 
[D] #################################### 
[D] Stop foreground notification 
[D] Unregister Wifi Receiver 
[D] Stopping runner! 

Could you help me @pyamsoft ?

pyamsoft commented 1 year ago

Thanks for the logs, very helpful!

Unfortunately it seems like the wifi p2p manager is rejecting your attempt.

https://developer.android.com/reference/android/net/wifi/p2p/WifiP2pManager#ERROR

Error code "Error" could unfortunately be just about anything.

Is your device able to use WiFi Direct for other functions?

This may be the API wake up call to move to starting a Local Hotspot API instead in the codebase. I will read up about how that API works and may be able to provide Local Hotspot as an alternative connection Broadcast

pyamsoft commented 11 months ago

Do the recent changes in version 38 resolve your problem? Does rebooting the device hosting the hotspot change anything?

ItsIgnacioPortal commented 11 months ago

Do the recent changes in version 38 resolve your problem? Does rebooting the device hosting the hotspot change anything?

Hey! I've tested v38 now but the problem persists. Rebooting the host device does not seem to have any effect.

I'll try to manually test WiFi Direct functions next week

pyamsoft commented 10 months ago

Unfortunate to hear. If Wifi direct is sending an internal error like your situation here, then either something else is using it (but normally that would report as BUSY instead of ERROR) or your device may just be incompatible :(

In your system settings, under Wifi, do you have a Wifi Direct option? Maybe in the overflow menu?

ItsIgnacioPortal commented 7 months ago

Hey, sorry for the late answer, it's been some very busy months. Screenshot_20240331-174053_Settings

I do have that button in my Android settings. I've tested Wi-Fi direct, and I can connect to another Wi-Fi direct android phone, and also connect to a regular WiFi network at the same time. So, Wifi-Direct does work. What else could be the cause of the issue?

pyamsoft commented 7 months ago

Hi, thanks for getting back. I know life can be busy, it happens :)

Well unfortunately, I am not sure where else to go from here.

From the code side, all I am able to do as a Dev is say "hey WiFi direct, turn on"

And WiFi direct can either say "yes, error, or busy"

In your case its just saying "error" but nothing exists to convey to TetherFi why its erroring or what you can do to make it not error.

I'd look through other apps you have running just in case something else is expecting to use WiFi direct. Common things I've seen are things like Android Auto and some printer software or IoT devices like assistants or cameras.

Sometimes things just magically start working after you turn WiFi on and off 50 jillion times. It really is random, unfortunately.

Sorry to say, I don't know what else I can do here :(

ItsIgnacioPortal commented 7 months ago

I ran logcat while I tried to start the TetherFi hotspot, and I found this:

04-07 21:34:47.264  1684  2843 E SupplicantP2pIfaceHal: Can't call groupAdd_1_2: ISupplicantP2pIface is null
04-07 21:34:47.270  9086  9086 E (WifiDirectNetwork.kt:366): Unable to create Wifi Direct Group
04-07 21:34:47.270  9086  9086 E (WifiDirectNetwork.kt:366): java.lang.RuntimeException: Broadcast Error: Error

I went down the rabbit hole and I can only conclude that this issue is caused by LineageOS. I'm on LineageOS 19.1, Android 12. Is there an alternative to WifiP2pManager? Earlier you mentioned:

This may be the API wake up call to move to starting a Local Hotspot API instead in the codebase. I will read up about how that API works and may be able to provide Local Hotspot as an alternative connection Broadcast

pyamsoft commented 7 months ago

Hey nice job!

I really don't know where to go from here, you would probably have to report to lineage, since I have no control over the virt iface level of WiFi direct.

I've investigated Wifip2p local hotspot APIs since our very initial discussion, but the local hotspot is not a full replacement for WiFi p2p, so it wouldn't be an easy switch - I'm not even fully sure if it would be viable.

I would take this over to lineage and see what they say. Thanks for all your very cool work!