Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7244c977 authored by Irfan Sheriff's avatar Irfan Sheriff
Browse files

Ensure interface down before wpa_supplicant start

Now that the driver is built into the kernel, a runtime crash
followed by a driver unload and reload does not reset the interface.

Ensure interface is down before bringing up supplicant

Bug: 5032635
Change-Id: Ib8f3d47617e587139a8a91a82146ee3a2f329700
parent 260e9105
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -63,6 +63,16 @@ interface INetworkManagementService
     */
    void clearInterfaceAddresses(String iface);

    /**
     * Set interface down
     */
    void setInterfaceDown(String iface);

    /**
     * Set interface up
     */
    void setInterfaceUp(String iface);

    /**
     * Retrieves the network routes currently configured on the specified
     * interface
+22 −0
Original line number Diff line number Diff line
@@ -446,6 +446,28 @@ class NetworkManagementService extends INetworkManagementService.Stub {
        }
    }

    public void setInterfaceDown(String iface) throws IllegalStateException {
        try {
            InterfaceConfiguration ifcg = getInterfaceConfig(iface);
            ifcg.interfaceFlags = ifcg.interfaceFlags.replace("up", "down");
            setInterfaceConfig(iface, ifcg);
        } catch (NativeDaemonConnectorException e) {
            throw new IllegalStateException(
                    "Unable to communicate with native daemon for interface down - " + e);
        }
    }

    public void setInterfaceUp(String iface) throws IllegalStateException {
        try {
            InterfaceConfiguration ifcg = getInterfaceConfig(iface);
            ifcg.interfaceFlags = ifcg.interfaceFlags.replace("down", "up");
            setInterfaceConfig(iface, ifcg);
        } catch (NativeDaemonConnectorException e) {
            throw new IllegalStateException(
                    "Unable to communicate with native daemon for interface up - " + e);
        }
    }

    /* TODO: This is right now a IPv4 only function. Works for wifi which loses its
       IPv6 addresses on interface down, but we need to do full clean up here */
    public void clearInterfaceAddresses(String iface) throws IllegalStateException {
+11 −0
Original line number Diff line number Diff line
@@ -1911,6 +1911,17 @@ public class WifiStateMachine extends StateMachine {
                    transitionTo(mDriverUnloadingState);
                    break;
                case CMD_START_SUPPLICANT:
                    //A runtime crash can leave the interface up and
                    //this affects connectivity when supplicant starts up.
                    //Ensure interface is down before a supplicant start.
                    try {
                        mNwService.setInterfaceDown(mInterfaceName);
                    } catch (RemoteException re) {
                        if (DBG) Log.w(TAG, "Unable to bring down wlan interface: " + re);
                    } catch (IllegalStateException ie) {
                        if (DBG) Log.w(TAG, "Unable to bring down wlan interface: " + ie);
                    }

                    if(WifiNative.startSupplicant()) {
                        Log.d(TAG, "Supplicant start successful");
                        mWifiMonitor.startMonitoring();