[Replicant] [PATCH] Wifi: Enable hotspot functionality with external Wifi dongle

belgin belginstirbu at hotmail.com
Fri Mar 26 10:09:12 UTC 2021


The Android wifi state machine checks if the propietary
firmware can be loaded, and uses that. Otherwise,
this patch makes it so it tries to enable the hostapd
daemon anyway, which, if you have a supported wifi
dongle connected, will enable the hotspot.
If no firmware and no wifi dongle is found, the wifi state machine
will cause the Android UI to say "Turning hotspost on..."
forever until the user turns it off, but obviously,
hotspot won't work.

Signed-off-by: belgin <belginstirbu at hotmail.com>
---
 .../com/android/server/wifi/WifiStateMachine.java     | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index 6d9c0d0..00b73a7 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -6128,15 +6128,18 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno
                 case CMD_START_AP:
                     if (mWifiNative.loadDriver() == false) {
                         loge("Failed to load driver for softap");
+                        loge("trying to load external wifi dongle");
+		    }
+                    mP2pSupported = false;
+                    mWifiMonitor.killSupplicant(mP2pSupported);
+
+                    if (enableSoftAp() == true) {
+                        setWifiApState(WIFI_AP_STATE_ENABLING, 0);
+                        transitionTo(mSoftApStartingState);
                     } else {
-                        if (enableSoftAp() == true) {
-                            setWifiApState(WIFI_AP_STATE_ENABLING, 0);
-                            transitionTo(mSoftApStartingState);
-                        } else {
-                            setWifiApState(WIFI_AP_STATE_FAILED,
-                                    WifiManager.SAP_START_FAILURE_GENERAL);
-                            transitionTo(mInitialState);
-                        }
+                        setWifiApState(WIFI_AP_STATE_FAILED,
+                                WifiManager.SAP_START_FAILURE_GENERAL);
+                        transitionTo(mInitialState);
                     }
                     break;
                 default:
-- 
2.11.0



More information about the Replicant mailing list