summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorRebecca Silberstein <silberst@google.com>2017-05-25 03:19:27 -0700
committerRebecca Silberstein <silberst@google.com>2017-06-05 15:02:52 -0700
commit2f47b2755faffaa1a011ddeb8527bd9c99bb6106 (patch)
treef3ba28d4a1f47df6d2eb9bc593d79a2b39e3f64d /service
parentce59c9965c0b9de1baeb1a55903ca21b96232711 (diff)
WifiStateMachine: add iface name to ap updates
When softap mode changes state, add the interface name to the ap state change broadcast. This will be used by ConnectivityService to properly track interface updates and changes. Bug: 62076211 Test: frameworks/base/wifi/tests/runtests.sh Test: frameworks/opt/net/wifi/tests/wifitests/runtests.sh Test: softap integration tests locally Test: manually toggled and confirmed in logs Test: wifi integration tests Change-Id: I655dbdbf522c582973bb3fa8a2c42dadceb85a8d
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java11
-rw-r--r--service/java/com/android/server/wifi/WifiStateMachine.java21
2 files changed, 28 insertions, 4 deletions
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index ec05f7cec..1b3334d5f 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -18,6 +18,7 @@ package com.android.server.wifi;
import static android.net.wifi.WifiManager.EXTRA_PREVIOUS_WIFI_AP_STATE;
import static android.net.wifi.WifiManager.EXTRA_WIFI_AP_FAILURE_REASON;
+import static android.net.wifi.WifiManager.EXTRA_WIFI_AP_INTERFACE_NAME;
import static android.net.wifi.WifiManager.EXTRA_WIFI_AP_STATE;
import static android.net.wifi.WifiManager.LocalOnlyHotspotCallback.ERROR_GENERIC;
import static android.net.wifi.WifiManager.LocalOnlyHotspotCallback.ERROR_NO_CHANNEL;
@@ -491,7 +492,9 @@ public class WifiServiceImpl extends IWifiManager.Stub {
WIFI_AP_STATE_DISABLED);
final int errorCode = intent.getIntExtra(EXTRA_WIFI_AP_FAILURE_REASON,
HOTSPOT_NO_ERROR);
- handleWifiApStateChange(currentState, prevState, errorCode);
+ final String ifaceName =
+ intent.getStringExtra(EXTRA_WIFI_AP_INTERFACE_NAME);
+ handleWifiApStateChange(currentState, prevState, errorCode, ifaceName);
}
},
new IntentFilter(WifiManager.WIFI_AP_STATE_CHANGED_ACTION));
@@ -993,10 +996,12 @@ public class WifiServiceImpl extends IWifiManager.Stub {
/**
* Private method to handle SoftAp state changes
*/
- private void handleWifiApStateChange(int currentState, int previousState, int errorCode) {
+ private void handleWifiApStateChange(
+ int currentState, int previousState, int errorCode, String ifaceName) {
// The AP state update from WifiStateMachine for softap
Slog.d(TAG, "handleWifiApStateChange: currentState=" + currentState
- + " previousState=" + previousState + " errorCode= " + errorCode);
+ + " previousState=" + previousState + " errorCode= " + errorCode
+ + " ifaceName=" + ifaceName);
// check if we have a failure - since it is possible (worst case scenario where
// WifiController and WifiStateMachine are out of sync wrt modes) to get two FAILED
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index 7f57316a6..5ac8a3520 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -2807,6 +2807,10 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
}
private void setWifiApState(int wifiApState, int reason) {
+ setWifiApState(wifiApState, reason, null);
+ }
+
+ private void setWifiApState(int wifiApState, int reason, String ifaceName) {
final int previousWifiApState = mWifiApState.get();
try {
@@ -2833,6 +2837,12 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
intent.putExtra(WifiManager.EXTRA_WIFI_AP_FAILURE_REASON, reason);
}
+ if (ifaceName == null) {
+ loge("Updating wifiApState with a null iface name");
+ } else {
+ intent.putExtra(WifiManager.EXTRA_WIFI_AP_INTERFACE_NAME, ifaceName);
+ }
+
mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
}
@@ -6667,6 +6677,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
class SoftApState extends State {
private SoftApManager mSoftApManager;
+ private String mIfaceName;
private class SoftApListener implements SoftApManager.Listener {
@Override
@@ -6677,7 +6688,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
sendMessage(CMD_START_AP_FAILURE);
}
- setWifiApState(state, reason);
+ setWifiApState(state, reason, mIfaceName);
}
}
@@ -6700,6 +6711,13 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
return;
}
+ try {
+ mIfaceName = apInterface.getInterfaceName();
+ } catch (RemoteException e) {
+ // Failed to get the interface name. The name will not be available for
+ // the enabled broadcast, but since we had an error getting the name, we most likely
+ // won't be able to fully start softap mode.
+ }
WifiConfiguration config = (WifiConfiguration) message.obj;
checkAndSetConnectivityInstance();
@@ -6714,6 +6732,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
@Override
public void exit() {
mSoftApManager = null;
+ mIfaceName = null;
}
@Override