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

Commit c7512057 authored by Irfan Sheriff's avatar Irfan Sheriff Committed by Android Git Automerger
Browse files

am 5f2f3dfe: Merge "Fix proxy and IP settings" into jb-mr2-dev

* commit '5f2f3dfe':
  Fix proxy and IP settings
parents 4e9ce36e 5f2f3dfe
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -634,6 +634,8 @@ class WifiConfigStore {
            if (config.priority > mLastPriority) {
                mLastPriority = config.priority;
            }
            config.ipAssignment = IpAssignment.DHCP;
            config.proxySettings = ProxySettings.NONE;
            mConfiguredNetworks.put(config.networkId, config);
            mNetworkIds.put(configKey(config), config.networkId);
        }
@@ -831,8 +833,9 @@ class WifiConfigStore {

            while (true) {
                int id = -1;
                IpAssignment ipAssignment = IpAssignment.UNASSIGNED;
                ProxySettings proxySettings = ProxySettings.UNASSIGNED;
                // Default is DHCP with no proxy
                IpAssignment ipAssignment = IpAssignment.DHCP;
                ProxySettings proxySettings = ProxySettings.NONE;
                LinkProperties linkProperties = new LinkProperties();
                String proxyHost = null;
                int proxyPort = -1;
@@ -902,7 +905,8 @@ class WifiConfigStore {
                                config.ipAssignment = ipAssignment;
                                break;
                            case UNASSIGNED:
                                //Ignore
                                loge("BUG: Found UNASSIGNED IP on file, use DHCP");
                                config.ipAssignment = IpAssignment.DHCP;
                                break;
                            default:
                                loge("Ignore invalid ip assignment while reading");
@@ -920,7 +924,8 @@ class WifiConfigStore {
                                config.proxySettings = proxySettings;
                                break;
                            case UNASSIGNED:
                                //Ignore
                                loge("BUG: Found UNASSIGNED proxy on file, use NONE");
                                config.proxySettings = ProxySettings.NONE;
                                break;
                            default:
                                loge("Ignore invalid proxy settings while reading");
@@ -1176,6 +1181,8 @@ class WifiConfigStore {
        WifiConfiguration currentConfig = mConfiguredNetworks.get(netId);
        if (currentConfig == null) {
            currentConfig = new WifiConfiguration();
            currentConfig.ipAssignment = IpAssignment.DHCP;
            currentConfig.proxySettings = ProxySettings.NONE;
            currentConfig.networkId = netId;
        }

+23 −18
Original line number Diff line number Diff line
@@ -1648,15 +1648,7 @@ public class WifiStateMachine extends StateMachine {
    private void handleNetworkDisconnect() {
        if (DBG) log("Stopping DHCP and clearing IP");

        /*
         * stop DHCP
         */
        if (mDhcpStateMachine != null) {
            /* In case we were in middle of DHCP operation
               restore back powermode */
            handlePostDhcpSetup();
            mDhcpStateMachine.sendMessage(DhcpStateMachine.CMD_STOP_DHCP);
        }
        stopDhcp();

        try {
            mNwService.clearInterfaceAddresses(mInterfaceName);
@@ -1734,6 +1726,24 @@ public class WifiStateMachine extends StateMachine {
    }


    void startDhcp() {
        if (mDhcpStateMachine == null) {
            mDhcpStateMachine = DhcpStateMachine.makeDhcpStateMachine(
                    mContext, WifiStateMachine.this, mInterfaceName);

        }
        mDhcpStateMachine.registerForPreDhcpNotification();
        mDhcpStateMachine.sendMessage(DhcpStateMachine.CMD_START_DHCP);
    }

    void stopDhcp() {
        if (mDhcpStateMachine != null) {
            /* In case we were in middle of DHCP operation restore back powermode */
            handlePostDhcpSetup();
            mDhcpStateMachine.sendMessage(DhcpStateMachine.CMD_STOP_DHCP);
        }
    }

    void handlePostDhcpSetup() {
        /* Restore power save and suspend optimizations */
        setSuspendOptimizationsNative(SUSPEND_DUE_TO_DHCP, true);
@@ -1751,7 +1761,7 @@ public class WifiStateMachine extends StateMachine {
            mDhcpResults = dhcpResults;
        }
        LinkProperties linkProperties = dhcpResults.linkProperties;
        mWifiConfigStore.setLinkProperties(mLastNetworkId, linkProperties);
        mWifiConfigStore.setLinkProperties(mLastNetworkId, new LinkProperties(linkProperties));
        InetAddress addr = null;
        Iterator<InetAddress> addrs = linkProperties.getAddresses().iterator();
        if (addrs.hasNext()) {
@@ -2996,15 +3006,10 @@ public class WifiStateMachine extends StateMachine {
        @Override
        public void enter() {
            if (!mWifiConfigStore.isUsingStaticIp(mLastNetworkId)) {
                //start DHCP
                if (mDhcpStateMachine == null) {
                    mDhcpStateMachine = DhcpStateMachine.makeDhcpStateMachine(
                            mContext, WifiStateMachine.this, mInterfaceName);

                }
                mDhcpStateMachine.registerForPreDhcpNotification();
                mDhcpStateMachine.sendMessage(DhcpStateMachine.CMD_START_DHCP);
                startDhcp();
            } else {
                // stop any running dhcp before assigning static IP
                stopDhcp();
                DhcpResults dhcpResults = new DhcpResults(
                        mWifiConfigStore.getLinkProperties(mLastNetworkId));
                dhcpResults.linkProperties.setInterfaceName(mInterfaceName);