Merge "Add firmware reload support for P2P"
This commit is contained in:
committed by
Android (Google) Code Review
commit
5f6ddecdee
@@ -172,6 +172,12 @@ interface INetworkManagementService
|
||||
*/
|
||||
void detachPppd(String tty);
|
||||
|
||||
/**
|
||||
* Load firmware for operation in the given mode. Currently the three
|
||||
* modes supported are "AP", "STA" and "P2P".
|
||||
*/
|
||||
void wifiFirmwareReload(String wlanIface, String mode);
|
||||
|
||||
/**
|
||||
* Start Wifi Access Point
|
||||
*/
|
||||
|
||||
@@ -854,7 +854,7 @@ class NetworkManagementService extends INetworkManagementService.Stub {
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
android.Manifest.permission.CHANGE_WIFI_STATE, "NetworkManagementService");
|
||||
try {
|
||||
mConnector.doCommand(String.format("softap fwreload " + wlanIface + " AP"));
|
||||
wifiFirmwareReload(wlanIface, "AP");
|
||||
mConnector.doCommand(String.format("softap start " + wlanIface));
|
||||
if (wifiConfig == null) {
|
||||
mConnector.doCommand(String.format("softap set " + wlanIface + " " + softapIface));
|
||||
@@ -901,6 +901,20 @@ class NetworkManagementService extends INetworkManagementService.Stub {
|
||||
}
|
||||
}
|
||||
|
||||
/* @param mode can be "AP", "STA" or "P2P" */
|
||||
public void wifiFirmwareReload(String wlanIface, String mode) throws IllegalStateException {
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
android.Manifest.permission.CHANGE_NETWORK_STATE, "NetworkManagementService");
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
android.Manifest.permission.CHANGE_WIFI_STATE, "NetworkManagementService");
|
||||
|
||||
try {
|
||||
mConnector.doCommand(String.format("softap fwreload " + wlanIface + " " + mode));
|
||||
} catch (NativeDaemonConnectorException e) {
|
||||
throw new IllegalStateException("Error communicating to native daemon ", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void stopAccessPoint(String wlanIface) throws IllegalStateException {
|
||||
mContext.enforceCallingOrSelfPermission(
|
||||
android.Manifest.permission.CHANGE_NETWORK_STATE, "NetworkManagementService");
|
||||
@@ -909,7 +923,7 @@ class NetworkManagementService extends INetworkManagementService.Stub {
|
||||
try {
|
||||
mConnector.doCommand("softap stopap");
|
||||
mConnector.doCommand("softap stop " + wlanIface);
|
||||
mConnector.doCommand(String.format("softap fwreload " + wlanIface + " STA"));
|
||||
wifiFirmwareReload(wlanIface, "STA");
|
||||
} catch (NativeDaemonConnectorException e) {
|
||||
throw new IllegalStateException("Error communicating to native daemon to stop soft AP",
|
||||
e);
|
||||
|
||||
@@ -315,6 +315,7 @@ class ServerThread extends Thread {
|
||||
ServiceManager.addService(Context.CONNECTIVITY_SERVICE, connectivity);
|
||||
networkStats.bindConnectivityManager(connectivity);
|
||||
networkPolicy.bindConnectivityManager(connectivity);
|
||||
wifiP2p.connectivityServiceReady();
|
||||
} catch (Throwable e) {
|
||||
Slog.e(TAG, "Failure starting Connectivity Service", e);
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ public class WifiStateMachine extends StateMachine {
|
||||
private static final String SOFTAP_IFACE = "wl0.1";
|
||||
|
||||
private WifiMonitor mWifiMonitor;
|
||||
private INetworkManagementService nwService;
|
||||
private INetworkManagementService mNwService;
|
||||
private ConnectivityManager mCm;
|
||||
|
||||
/* Scan results handling */
|
||||
@@ -500,7 +500,7 @@ public class WifiStateMachine extends StateMachine {
|
||||
mBatteryStats = IBatteryStats.Stub.asInterface(ServiceManager.getService("batteryinfo"));
|
||||
|
||||
IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE);
|
||||
nwService = INetworkManagementService.Stub.asInterface(b);
|
||||
mNwService = INetworkManagementService.Stub.asInterface(b);
|
||||
|
||||
mWifiMonitor = new WifiMonitor(this);
|
||||
mDhcpInfoInternal = new DhcpInfoInternal();
|
||||
@@ -1090,14 +1090,14 @@ public class WifiStateMachine extends StateMachine {
|
||||
|
||||
InterfaceConfiguration ifcg = null;
|
||||
try {
|
||||
ifcg = nwService.getInterfaceConfig(intf);
|
||||
ifcg = mNwService.getInterfaceConfig(intf);
|
||||
if (ifcg != null) {
|
||||
/* IP/netmask: 192.168.43.1/255.255.255.0 */
|
||||
ifcg.addr = new LinkAddress(NetworkUtils.numericToInetAddress(
|
||||
"192.168.43.1"), 24);
|
||||
ifcg.interfaceFlags = "[up]";
|
||||
|
||||
nwService.setInterfaceConfig(intf, ifcg);
|
||||
mNwService.setInterfaceConfig(intf, ifcg);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Error configuring interface " + intf + ", :" + e);
|
||||
@@ -1124,11 +1124,11 @@ public class WifiStateMachine extends StateMachine {
|
||||
ip settings */
|
||||
InterfaceConfiguration ifcg = null;
|
||||
try {
|
||||
ifcg = nwService.getInterfaceConfig(mInterfaceName);
|
||||
ifcg = mNwService.getInterfaceConfig(mInterfaceName);
|
||||
if (ifcg != null) {
|
||||
ifcg.addr = new LinkAddress(NetworkUtils.numericToInetAddress(
|
||||
"0.0.0.0"), 0);
|
||||
nwService.setInterfaceConfig(mInterfaceName, ifcg);
|
||||
mNwService.setInterfaceConfig(mInterfaceName, ifcg);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Error resetting interface " + mInterfaceName + ", :" + e);
|
||||
@@ -1534,7 +1534,7 @@ public class WifiStateMachine extends StateMachine {
|
||||
}
|
||||
|
||||
try {
|
||||
nwService.clearInterfaceAddresses(mInterfaceName);
|
||||
mNwService.clearInterfaceAddresses(mInterfaceName);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Failed to clear IP addresses on disconnect" + e);
|
||||
}
|
||||
@@ -1669,12 +1669,12 @@ public class WifiStateMachine extends StateMachine {
|
||||
WifiApConfigStore.setApConfiguration(config);
|
||||
}
|
||||
try {
|
||||
nwService.startAccessPoint(config, mInterfaceName, SOFTAP_IFACE);
|
||||
mNwService.startAccessPoint(config, mInterfaceName, SOFTAP_IFACE);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Exception in softap start " + e);
|
||||
try {
|
||||
nwService.stopAccessPoint(mInterfaceName);
|
||||
nwService.startAccessPoint(config, mInterfaceName, SOFTAP_IFACE);
|
||||
mNwService.stopAccessPoint(mInterfaceName);
|
||||
mNwService.startAccessPoint(config, mInterfaceName, SOFTAP_IFACE);
|
||||
} catch (Exception e1) {
|
||||
Log.e(TAG, "Exception in softap re-start " + e1);
|
||||
return false;
|
||||
@@ -2698,7 +2698,7 @@ public class WifiStateMachine extends StateMachine {
|
||||
ifcg.addr = dhcpInfoInternal.makeLinkAddress();
|
||||
ifcg.interfaceFlags = "[up]";
|
||||
try {
|
||||
nwService.setInterfaceConfig(mInterfaceName, ifcg);
|
||||
mNwService.setInterfaceConfig(mInterfaceName, ifcg);
|
||||
Log.v(TAG, "Static IP configuration succeeded");
|
||||
sendMessage(CMD_STATIC_IP_SUCCESS, dhcpInfoInternal);
|
||||
} catch (RemoteException re) {
|
||||
@@ -3158,7 +3158,7 @@ public class WifiStateMachine extends StateMachine {
|
||||
setWifiApState(WIFI_AP_STATE_DISABLING);
|
||||
stopTethering();
|
||||
try {
|
||||
nwService.stopAccessPoint(mInterfaceName);
|
||||
mNwService.stopAccessPoint(mInterfaceName);
|
||||
} catch(Exception e) {
|
||||
Log.e(TAG, "Exception in stopAccessPoint()");
|
||||
}
|
||||
|
||||
@@ -34,10 +34,13 @@ import android.net.wifi.WpsConfiguration.Setup;
|
||||
import android.net.wifi.p2p.WifiP2pDevice.Status;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import android.os.INetworkManagementService;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.os.Message;
|
||||
import android.os.Messenger;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.SystemProperties;
|
||||
import android.util.Slog;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -69,6 +72,9 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
|
||||
private static final boolean DBG = true;
|
||||
|
||||
private Context mContext;
|
||||
private String mInterface;
|
||||
|
||||
INetworkManagementService mNwService;
|
||||
|
||||
// Tracked to notify the user about wifi client/hotspot being shut down
|
||||
// during p2p bring up
|
||||
@@ -94,6 +100,7 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
|
||||
public WifiP2pService(Context context) {
|
||||
mContext = context;
|
||||
|
||||
mInterface = SystemProperties.get("wifi.interface", "wlan0");
|
||||
mP2pSupported = mContext.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_wifi_p2p_support);
|
||||
|
||||
@@ -108,6 +115,11 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
|
||||
|
||||
}
|
||||
|
||||
public void connectivityServiceReady() {
|
||||
IBinder b = ServiceManager.getService(Context.NETWORKMANAGEMENT_SERVICE);
|
||||
mNwService = INetworkManagementService.Stub.asInterface(b);
|
||||
}
|
||||
|
||||
private class WifiStateReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
@@ -324,8 +336,6 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
|
||||
@Override
|
||||
public void enter() {
|
||||
if (DBG) Slog.d(TAG, getName());
|
||||
// TODO: fix later
|
||||
WifiNative.unloadDriver();
|
||||
transitionTo(mP2pDisabledState);
|
||||
}
|
||||
|
||||
@@ -334,7 +344,6 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
|
||||
if (DBG) Slog.d(TAG, getName() + message.toString());
|
||||
switch (message.what) {
|
||||
case WifiMonitor.SUP_DISCONNECTION_EVENT:
|
||||
WifiNative.unloadDriver();
|
||||
transitionTo(mP2pDisabledState);
|
||||
break;
|
||||
default:
|
||||
@@ -411,9 +420,13 @@ public class WifiP2pService extends IWifiP2pManager.Stub {
|
||||
if (DBG) Slog.d(TAG, getName() + message.toString());
|
||||
switch (message.what) {
|
||||
case WifiStateMachine.P2P_ENABLE_PROCEED:
|
||||
// TODO: fix this for p2p
|
||||
if (WifiNative.loadDriver() &&
|
||||
WifiNative.startSupplicant()) {
|
||||
try {
|
||||
mNwService.wifiFirmwareReload(mInterface, "P2P");
|
||||
} catch (Exception e) {
|
||||
Slog.e(TAG, "Failed to reload p2p firmware " + e);
|
||||
// continue
|
||||
}
|
||||
if (WifiNative.startSupplicant()) {
|
||||
Slog.d(TAG, "Wi-fi Direct start successful");
|
||||
mWifiMonitor.startMonitoring();
|
||||
transitionTo(mP2pEnablingState);
|
||||
|
||||
Reference in New Issue
Block a user