diff options
author | Belgin Stirbu <belginstirbu@hotmail.com> | 2019-10-12 17:09:10 +0000 |
---|---|---|
committer | Joonas Kylmälä <joonas.kylmala@iki.fi> | 2019-10-14 11:22:20 -0400 |
commit | 94f9a24b15cffdb1920ff2cef3edc30ed3373ddd (patch) | |
tree | 954c3cdc68e6f1b39e3ebce805177bc55e36a78e /service | |
parent | 2e1ff498017ee2e2a403fce604efe8947ed85411 (diff) | |
download | frameworks_opt_net_wifi-replicant-6.0-0004-rc4.tar.gz frameworks_opt_net_wifi-replicant-6.0-0004-rc4.tar.bz2 frameworks_opt_net_wifi-replicant-6.0-0004-rc4.zip |
Add native Android support for external WiFi donglesreplicant-6.0-0004-rc4replicant-6.0-0004-rc3replicant-6.0-0004-rc2replicant-6.0-0004-rc1
With this patch, if the nonfree firmware is found, the internal WiFi
is used, otherwise the WiFi state machine tries to use the external
WiFi adapter.
Because the WiFiStateMachine tries to do things with the
Bluetooth Coexistence mode, which the ath9k driver
doesn't seem to have (at least not by default),
wpa_supplicant registers enough consecutive errors
to think the driver hanged, so it stops the
connection. To work around this, I have commented
the calls to enable/disable Bluetooth Coexistence
mode in the WiFi state machine java file. A proper fix
for this would be to enable Bluetooth Coexistence
mode in the ath9k driver.
Regarding removing the multicast packet filtering
code, the same wpa_supplicant issue as above was occuring,
causing wpa_supplicant to disconnect after a few errors.
I am unsure if this affects the firewall in any way.
Signed-off-by: Belgin Stirbu <belginstirbu@hotmail.com>
Acked-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/WifiStateMachine.java | 103 |
1 files changed, 67 insertions, 36 deletions
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index 38d0ac8..6d9c0d0 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -198,7 +198,8 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno private ConnectivityManager mCm; private DummyWifiLogger mWifiLogger; private WifiApConfigStore mWifiApConfigStore; - private final boolean mP2pSupported; + private boolean mP2pSupported; + private boolean mDongleConnected; private boolean mIbssSupported; private final AtomicBoolean mP2pConnected = new AtomicBoolean(false); private boolean mTemporarilyDisconnectWifi = false; @@ -1155,6 +1156,8 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno mP2pSupported = mContext.getPackageManager().hasSystemFeature( PackageManager.FEATURE_WIFI_DIRECT); + mDongleConnected = false; + mWifiNative = new WifiNative(mInterfaceName); mWifiConfigStore = new WifiConfigStore(context,this, mWifiNative); mWifiAutoJoinController = new WifiAutoJoinController(context, this, @@ -5274,16 +5277,19 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno void handlePreDhcpSetup() { mDhcpActive = true; - // Disable the coexistence mode - mWifiNative.setBluetoothCoexistenceMode( - mWifiNative.BLUETOOTH_COEXISTENCE_MODE_DISABLED); - // Disable power save and suspend optimizations during DHCP - // Note: The order here is important for now. Brcm driver changes - // power settings when we control suspend mode optimizations. - // TODO: Remove this comment when the driver is fixed. - setSuspendOptimizationsNative(SUSPEND_DUE_TO_DHCP, false); - mWifiNative.setPowerSave(false); + if (mDongleConnected == false) { + // Disable the coexistence mode + mWifiNative.setBluetoothCoexistenceMode( + mWifiNative.BLUETOOTH_COEXISTENCE_MODE_DISABLED); + + // Disable power save and suspend optimizations during DHCP + // Note: The order here is important for now. Brcm driver changes + // power settings when we control suspend mode optimizations. + // TODO: Remove this comment when the driver is fixed. + setSuspendOptimizationsNative(SUSPEND_DUE_TO_DHCP, false); + mWifiNative.setPowerSave(false); + } // Update link layer stats getWifiLinkLayerStats(false); @@ -5337,15 +5343,17 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno } void handlePostDhcpSetup() { - /* Restore power save and suspend optimizations */ - setSuspendOptimizationsNative(SUSPEND_DUE_TO_DHCP, true); - mWifiNative.setPowerSave(true); + if (mDongleConnected == false) { + /* Restore power save and suspend optimizations */ + setSuspendOptimizationsNative(SUSPEND_DUE_TO_DHCP, true); + mWifiNative.setPowerSave(true); - mWifiP2pChannel.sendMessage(WifiP2pServiceImpl.BLOCK_DISCOVERY, WifiP2pServiceImpl.DISABLED); + mWifiP2pChannel.sendMessage(WifiP2pServiceImpl.BLOCK_DISCOVERY, WifiP2pServiceImpl.DISABLED); - // Set the coexistence mode back to its default value - mWifiNative.setBluetoothCoexistenceMode( - mWifiNative.BLUETOOTH_COEXISTENCE_MODE_SENSE); + // Set the coexistence mode back to its default value + mWifiNative.setBluetoothCoexistenceMode( + mWifiNative.BLUETOOTH_COEXISTENCE_MODE_SENSE); + } mDhcpActive = false; } @@ -6047,8 +6055,12 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno * Avoids issues with drivers that do not handle interface down * on a running supplicant properly. */ + mDongleConnected = false; mWifiMonitor.killSupplicant(mP2pSupported); + mP2pSupported = mContext.getPackageManager().hasSystemFeature( + PackageManager.FEATURE_WIFI_DIRECT); + if (mWifiNative.loadDriver()) { try { mNwService.wifiFirmwareReload(mInterfaceName, "STA"); @@ -6096,7 +6108,21 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno } } else { loge("Failed to load driver"); - setWifiState(WifiManager.WIFI_STATE_FAILED); + + loge("trying to load external wifi dongle"); + mP2pSupported = false; + mWifiMonitor.killSupplicant(mP2pSupported); + + if (mWifiNative.startSupplicant(mP2pSupported)) { + setWifiState(WIFI_STATE_ENABLING); + if (DBG) log("Supplicant start successful"); + mWifiMonitor.startMonitoring(); + mDongleConnected = true; + transitionTo(mSupplicantStartingState); + } else { + loge("Failed to start supplicant!"); + setWifiState(WifiManager.WIFI_STATE_FAILED); + } } break; case CMD_START_AP: @@ -6527,23 +6553,26 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno mInDelayedStop = false; mDelayedStopCounter++; updateBatteryWorkSource(null); - /** - * Enable bluetooth coexistence scan mode when bluetooth connection is active. - * When this mode is on, some of the low-level scan parameters used by the - * driver are changed to reduce interference with bluetooth - */ - mWifiNative.setBluetoothCoexistenceScanMode(mBluetoothConnectionActive); - /* initialize network state */ - setNetworkDetailedState(DetailedState.DISCONNECTED); - /* Remove any filtering on Multicast v6 at start */ - mWifiNative.stopFilteringMulticastV6Packets(); + if (mDongleConnected == false) { + /** + * Enable bluetooth coexistence scan mode when bluetooth connection is active. + * When this mode is on, some of the low-level scan parameters used by the + * driver are changed to reduce interference with bluetooth + */ + mWifiNative.setBluetoothCoexistenceScanMode(mBluetoothConnectionActive); + /* initialize network state */ + setNetworkDetailedState(DetailedState.DISCONNECTED); - /* Reset Multicast v4 filtering state */ - if (mFilteringMulticastV4Packets.get()) { - mWifiNative.startFilteringMulticastV4Packets(); - } else { - mWifiNative.stopFilteringMulticastV4Packets(); + /* Remove any filtering on Multicast v6 at start */ + mWifiNative.stopFilteringMulticastV6Packets(); + + /* Reset Multicast v4 filtering state */ + if (mFilteringMulticastV4Packets.get()) { + mWifiNative.startFilteringMulticastV4Packets(); + } else { + mWifiNative.stopFilteringMulticastV4Packets(); + } } mDhcpActive = false; @@ -6647,9 +6676,11 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno } break; case CMD_BLUETOOTH_ADAPTER_STATE_CHANGE: - mBluetoothConnectionActive = (message.arg1 != - BluetoothAdapter.STATE_DISCONNECTED); - mWifiNative.setBluetoothCoexistenceScanMode(mBluetoothConnectionActive); + if (mDongleConnected == false) { + mBluetoothConnectionActive = (message.arg1 != + BluetoothAdapter.STATE_DISCONNECTED); + mWifiNative.setBluetoothCoexistenceScanMode(mBluetoothConnectionActive); + } break; case CMD_STOP_DRIVER: int mode = message.arg1; |