Clean up changing AP configuration
Bug: 2527293 Change-Id: I35e82e24e27349e2966f88189ebca4246ad1a354
This commit is contained in:
@@ -167,11 +167,15 @@ interface INetworkManagementService
|
||||
/**
|
||||
* Start Wifi Access Point
|
||||
*/
|
||||
void startAccessPoint(in WifiConfiguration wifiConfig, String intf);
|
||||
void startAccessPoint(in WifiConfiguration wifiConfig, String wlanIface, String softapIface);
|
||||
|
||||
/**
|
||||
* Stop Wifi Access Point
|
||||
*/
|
||||
void stopAccessPoint();
|
||||
|
||||
/**
|
||||
* Set Access Point config
|
||||
*/
|
||||
void setAccessPoint(in WifiConfiguration wifiConfig, String wlanIface, String softapIface);
|
||||
}
|
||||
|
||||
@@ -460,17 +460,17 @@ class NetworkManagementService extends INetworkManagementService.Stub {
|
||||
throw new IllegalStateException("Got an empty response");
|
||||
}
|
||||
|
||||
public void startAccessPoint(WifiConfiguration wifiConfig, String intf)
|
||||
public void startAccessPoint(WifiConfiguration wifiConfig, String wlanIface, String softapIface)
|
||||
throws IllegalStateException {
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
android.Manifest.permission.CHANGE_NETWORK_STATE, "NetworkManagementService");
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
android.Manifest.permission.CHANGE_WIFI_STATE, "NetworkManagementService");
|
||||
mConnector.doCommand(String.format("softap stop " + intf));
|
||||
mConnector.doCommand(String.format("softap fwreload " + intf + " AP"));
|
||||
mConnector.doCommand(String.format("softap start " + intf));
|
||||
android.Manifest.permission.CHANGE_WIFI_STATE, "NetworkManagementService");
|
||||
mConnector.doCommand(String.format("softap stop " + wlanIface));
|
||||
mConnector.doCommand(String.format("softap fwreload " + wlanIface + " AP"));
|
||||
mConnector.doCommand(String.format("softap start " + wlanIface));
|
||||
if (wifiConfig == null) {
|
||||
mConnector.doCommand(String.format("softap set " + intf + " wl0.1"));
|
||||
mConnector.doCommand(String.format("softap set " + wlanIface + " " + softapIface));
|
||||
} else {
|
||||
/**
|
||||
* softap set arg1 arg2 arg3 [arg4 arg5 arg6 arg7 arg8]
|
||||
@@ -482,10 +482,9 @@ class NetworkManagementService extends INetworkManagementService.Stub {
|
||||
* argv6 - Channel
|
||||
* argv7 - Preamble
|
||||
* argv8 - Max SCB
|
||||
*
|
||||
* TODO: get a configurable softap interface from driver
|
||||
*/
|
||||
String str = String.format("softap set " + intf + " wl0.1 %s %s %s", wifiConfig.SSID,
|
||||
String str = String.format("softap set " + wlanIface + " " + softapIface + " %s %s %s",
|
||||
wifiConfig.SSID,
|
||||
wifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ?
|
||||
"wpa2-psk" : "open",
|
||||
wifiConfig.preSharedKey);
|
||||
@@ -498,8 +497,25 @@ class NetworkManagementService extends INetworkManagementService.Stub {
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
android.Manifest.permission.CHANGE_NETWORK_STATE, "NetworkManagementService");
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
android.Manifest.permission.CHANGE_WIFI_STATE, "NetworkManagementService");
|
||||
android.Manifest.permission.CHANGE_WIFI_STATE, "NetworkManagementService");
|
||||
mConnector.doCommand("softap stopap");
|
||||
}
|
||||
|
||||
public void setAccessPoint(WifiConfiguration wifiConfig, String wlanIface, String softapIface)
|
||||
throws IllegalStateException {
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
android.Manifest.permission.CHANGE_NETWORK_STATE, "NetworkManagementService");
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
android.Manifest.permission.CHANGE_WIFI_STATE, "NetworkManagementService");
|
||||
if (wifiConfig == null) {
|
||||
mConnector.doCommand(String.format("softap set " + wlanIface + " " + softapIface));
|
||||
} else {
|
||||
String str = String.format("softap set " + wlanIface + " " + softapIface +
|
||||
" %s %s %s", wifiConfig.SSID,
|
||||
wifiConfig.allowedKeyManagement.get(KeyMgmt.WPA_PSK) ?
|
||||
"wpa2-psk" : "open",
|
||||
wifiConfig.preSharedKey);
|
||||
mConnector.doCommand(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +96,8 @@ public class WifiService extends IWifiManager.Stub {
|
||||
private static final boolean DBG = false;
|
||||
private static final Pattern scanResultPattern = Pattern.compile("\t+");
|
||||
private final WifiStateTracker mWifiStateTracker;
|
||||
/* TODO: fetch a configurable interface */
|
||||
private static final String SOFTAP_IFACE = "wl0.1";
|
||||
|
||||
private Context mContext;
|
||||
private int mWifiApState;
|
||||
@@ -582,9 +584,10 @@ public class WifiService extends IWifiManager.Stub {
|
||||
}
|
||||
|
||||
/**
|
||||
* see {@link android.net.wifi.WifiManager#startAccessPoint(WifiConfiguration)}
|
||||
* see {@link android.net.wifi.WifiManager#setWifiApEnabled(WifiConfiguration, boolean)}
|
||||
* @param wifiConfig SSID, security and channel details as
|
||||
* part of WifiConfiguration
|
||||
* @param enabled, true to enable and false to disable
|
||||
* @return {@code true} if the start operation was
|
||||
* started or is already in the queue.
|
||||
*/
|
||||
@@ -656,11 +659,16 @@ public class WifiService extends IWifiManager.Stub {
|
||||
if(enable && (wifiConfig != null)) {
|
||||
try {
|
||||
persistApConfiguration(wifiConfig);
|
||||
nwService.stopAccessPoint();
|
||||
nwService.startAccessPoint(wifiConfig, mWifiStateTracker.getInterfaceName());
|
||||
nwService.setAccessPoint(wifiConfig, mWifiStateTracker.getInterfaceName(),
|
||||
SOFTAP_IFACE);
|
||||
return true;
|
||||
} catch(Exception e) {
|
||||
Slog.e(TAG, "Exception in nwService during AP restart");
|
||||
try {
|
||||
nwService.stopAccessPoint();
|
||||
} catch (Exception ee) {
|
||||
Slog.e(TAG, "Could not stop AP, :" + ee);
|
||||
}
|
||||
setWifiApEnabledState(WIFI_AP_STATE_FAILED, uid, DriverAction.DRIVER_UNLOAD);
|
||||
return false;
|
||||
}
|
||||
@@ -696,7 +704,8 @@ public class WifiService extends IWifiManager.Stub {
|
||||
}
|
||||
|
||||
try {
|
||||
nwService.startAccessPoint(wifiConfig, mWifiStateTracker.getInterfaceName());
|
||||
nwService.startAccessPoint(wifiConfig, mWifiStateTracker.getInterfaceName(),
|
||||
SOFTAP_IFACE);
|
||||
} catch(Exception e) {
|
||||
Slog.e(TAG, "Exception in startAccessPoint()");
|
||||
setWifiApEnabledState(WIFI_AP_STATE_FAILED, uid, DriverAction.DRIVER_UNLOAD);
|
||||
|
||||
Reference in New Issue
Block a user