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

Commit 00506e38 authored by Irfan Sheriff's avatar Irfan Sheriff Committed by Android (Google) Code Review
Browse files

Merge "Fix configuration change handling"

parents 848024f7 be9ee6a4
Loading
Loading
Loading
Loading
+61 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2010 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.net.wifi;

import static android.net.wifi.WifiConfiguration.INVALID_NETWORK_ID;

class NetworkUpdateResult {
    int netId;
    boolean ipChanged;
    boolean proxyChanged;

    public NetworkUpdateResult(int id) {
        netId = id;
        ipChanged = false;
        proxyChanged = false;
    }

    public NetworkUpdateResult(boolean ip, boolean proxy) {
        netId = INVALID_NETWORK_ID;
        ipChanged = ip;
        proxyChanged = proxy;
    }

    public void setNetworkId(int id) {
        netId = id;
    }

    public int getNetworkId() {
        return netId;
    }

    public void setIpChanged(boolean ip) {
        ipChanged = ip;
    }

    public boolean hasIpChanged() {
        return ipChanged;
    }

    public void setProxyChanged(boolean proxy) {
        proxyChanged = proxy;
    }

    public boolean hasProxyChanged() {
        return proxyChanged;
    }
}
+32 −26
Original line number Original line Diff line number Diff line
@@ -16,7 +16,6 @@


package android.net.wifi;
package android.net.wifi;


import android.app.ActivityManagerNative;
import android.content.Context;
import android.content.Context;
import android.content.Intent;
import android.content.Intent;
import android.net.DhcpInfo;
import android.net.DhcpInfo;
@@ -28,6 +27,7 @@ import android.net.wifi.WifiConfiguration.IpAssignment;
import android.net.wifi.WifiConfiguration.KeyMgmt;
import android.net.wifi.WifiConfiguration.KeyMgmt;
import android.net.wifi.WifiConfiguration.ProxySettings;
import android.net.wifi.WifiConfiguration.ProxySettings;
import android.net.wifi.WifiConfiguration.Status;
import android.net.wifi.WifiConfiguration.Status;
import android.net.wifi.NetworkUpdateResult;
import static android.net.wifi.WifiConfiguration.INVALID_NETWORK_ID;
import static android.net.wifi.WifiConfiguration.INVALID_NETWORK_ID;
import android.os.Environment;
import android.os.Environment;
import android.text.TextUtils;
import android.text.TextUtils;
@@ -42,7 +42,6 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.BitSet;
@@ -178,7 +177,7 @@ class WifiConfigStore {
        }
        }


        WifiNative.saveConfigCommand();
        WifiNative.saveConfigCommand();
        sendConfigChangeBroadcast();
        sendConfiguredNetworksChangedBroadcast();
    }
    }


    /**
    /**
@@ -194,7 +193,8 @@ class WifiConfigStore {
     */
     */
    static void selectNetwork(WifiConfiguration config) {
    static void selectNetwork(WifiConfiguration config) {
        if (config != null) {
        if (config != null) {
            int netId = addOrUpdateNetworkNative(config);
            NetworkUpdateResult result = addOrUpdateNetworkNative(config);
            int netId = result.getNetworkId();
            if (netId != INVALID_NETWORK_ID) {
            if (netId != INVALID_NETWORK_ID) {
                selectNetwork(netId);
                selectNetwork(netId);
            } else {
            } else {
@@ -248,9 +248,10 @@ class WifiConfigStore {
     *
     *
     * @param config WifiConfiguration to be saved
     * @param config WifiConfiguration to be saved
     */
     */
    static void saveNetwork(WifiConfiguration config) {
    static NetworkUpdateResult saveNetwork(WifiConfiguration config) {
        boolean newNetwork = (config.networkId == INVALID_NETWORK_ID);
        boolean newNetwork = (config.networkId == INVALID_NETWORK_ID);
        int netId = addOrUpdateNetworkNative(config);
        NetworkUpdateResult result = addOrUpdateNetworkNative(config);
        int netId = result.getNetworkId();
        /* enable a new network */
        /* enable a new network */
        if (newNetwork && netId != INVALID_NETWORK_ID) {
        if (newNetwork && netId != INVALID_NETWORK_ID) {
            WifiNative.enableNetworkCommand(netId, false);
            WifiNative.enableNetworkCommand(netId, false);
@@ -259,7 +260,8 @@ class WifiConfigStore {
            }
            }
        }
        }
        WifiNative.saveConfigCommand();
        WifiNative.saveConfigCommand();
        sendConfigChangeBroadcast();
        sendConfiguredNetworksChangedBroadcast();
        return result;
    }
    }


    /**
    /**
@@ -274,7 +276,7 @@ class WifiConfigStore {
                sConfiguredNetworks.remove(netId);
                sConfiguredNetworks.remove(netId);
            }
            }
            writeIpAndProxyConfigurations();
            writeIpAndProxyConfigurations();
            sendConfigChangeBroadcast();
            sendConfiguredNetworksChangedBroadcast();
        } else {
        } else {
            Log.e(TAG, "Failed to remove network " + netId);
            Log.e(TAG, "Failed to remove network " + netId);
        }
        }
@@ -289,9 +291,9 @@ class WifiConfigStore {
     * @param config wifi configuration to add/update
     * @param config wifi configuration to add/update
     */
     */
    static int addOrUpdateNetwork(WifiConfiguration config) {
    static int addOrUpdateNetwork(WifiConfiguration config) {
        int ret = addOrUpdateNetworkNative(config);
        NetworkUpdateResult result = addOrUpdateNetworkNative(config);
        sendConfigChangeBroadcast();
        sendConfiguredNetworksChangedBroadcast();
        return ret;
        return result.getNetworkId();
    }
    }


    /**
    /**
@@ -307,7 +309,7 @@ class WifiConfigStore {
        synchronized (sConfiguredNetworks) {
        synchronized (sConfiguredNetworks) {
            if (ret) sConfiguredNetworks.remove(netId);
            if (ret) sConfiguredNetworks.remove(netId);
        }
        }
        sendConfigChangeBroadcast();
        sendConfiguredNetworksChangedBroadcast();
        return ret;
        return ret;
    }
    }


@@ -321,7 +323,7 @@ class WifiConfigStore {
     */
     */
    static boolean enableNetwork(int netId, boolean disableOthers) {
    static boolean enableNetwork(int netId, boolean disableOthers) {
        boolean ret = enableNetworkWithoutBroadcast(netId, disableOthers);
        boolean ret = enableNetworkWithoutBroadcast(netId, disableOthers);
        sendConfigChangeBroadcast();
        sendConfiguredNetworksChangedBroadcast();
        return ret;
        return ret;
    }
    }


@@ -349,7 +351,7 @@ class WifiConfigStore {
            WifiConfiguration config = sConfiguredNetworks.get(netId);
            WifiConfiguration config = sConfiguredNetworks.get(netId);
            if (config != null) config.status = Status.DISABLED;
            if (config != null) config.status = Status.DISABLED;
        }
        }
        sendConfigChangeBroadcast();
        sendConfiguredNetworksChangedBroadcast();
        return ret;
        return ret;
    }
    }


@@ -475,9 +477,9 @@ class WifiConfigStore {
        return false;
        return false;
    }
    }


    private static void sendConfigChangeBroadcast() {
    private static void sendConfiguredNetworksChangedBroadcast() {
        if (!ActivityManagerNative.isSystemReady()) return;
        Intent intent = new Intent(WifiManager.CONFIGURED_NETWORKS_CHANGED_ACTION);
        Intent intent = new Intent(WifiManager.SUPPLICANT_CONFIG_CHANGED_ACTION);
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
        sContext.sendBroadcast(intent);
        sContext.sendBroadcast(intent);
    }
    }


@@ -522,7 +524,7 @@ class WifiConfigStore {
            }
            }
        }
        }
        readIpAndProxyConfigurations();
        readIpAndProxyConfigurations();
        sendConfigChangeBroadcast();
        sendConfiguredNetworksChangedBroadcast();
    }
    }


    /* Mark all networks except specified netId as disabled */
    /* Mark all networks except specified netId as disabled */
@@ -748,7 +750,7 @@ class WifiConfigStore {
        }
        }
    }
    }


    private static int addOrUpdateNetworkNative(WifiConfiguration config) {
    private static NetworkUpdateResult addOrUpdateNetworkNative(WifiConfiguration config) {
        /*
        /*
         * If the supplied networkId is INVALID_NETWORK_ID, we create a new empty
         * If the supplied networkId is INVALID_NETWORK_ID, we create a new empty
         * network configuration. Otherwise, the networkId should
         * network configuration. Otherwise, the networkId should
@@ -756,14 +758,14 @@ class WifiConfigStore {
         */
         */
        int netId = config.networkId;
        int netId = config.networkId;
        boolean updateFailed = true;
        boolean updateFailed = true;
        boolean newNetwork = (netId == INVALID_NETWORK_ID);
        // networkId of INVALID_NETWORK_ID means we want to create a new network
        // networkId of INVALID_NETWORK_ID means we want to create a new network
        boolean newNetwork = (netId == INVALID_NETWORK_ID);


        if (newNetwork) {
        if (newNetwork) {
            netId = WifiNative.addNetworkCommand();
            netId = WifiNative.addNetworkCommand();
            if (netId < 0) {
            if (netId < 0) {
                Log.e(TAG, "Failed to add a network!");
                Log.e(TAG, "Failed to add a network!");
                return INVALID_NETWORK_ID;
                return new NetworkUpdateResult(INVALID_NETWORK_ID);
          }
          }
        }
        }


@@ -937,7 +939,7 @@ class WifiConfigStore {
                        "Failed to set a network variable, removed network: "
                        "Failed to set a network variable, removed network: "
                        + netId);
                        + netId);
            }
            }
            return INVALID_NETWORK_ID;
            return new NetworkUpdateResult(INVALID_NETWORK_ID);
        }
        }


        /* An update of the network variables requires reading them
        /* An update of the network variables requires reading them
@@ -959,12 +961,15 @@ class WifiConfigStore {
            }
            }
        }
        }
        readNetworkVariables(sConfig);
        readNetworkVariables(sConfig);
        writeIpAndProxyConfigurationsOnChange(sConfig, config);

        return netId;
        NetworkUpdateResult result = writeIpAndProxyConfigurationsOnChange(sConfig, config);
        result.setNetworkId(netId);
        return result;
    }
    }


    /* Compare current and new configuration and write to file on change */
    /* Compare current and new configuration and write to file on change */
    private static void writeIpAndProxyConfigurationsOnChange(WifiConfiguration currentConfig,
    private static NetworkUpdateResult writeIpAndProxyConfigurationsOnChange(
            WifiConfiguration currentConfig,
            WifiConfiguration newConfig) {
            WifiConfiguration newConfig) {
        boolean ipChanged = false;
        boolean ipChanged = false;
        boolean proxyChanged = false;
        boolean proxyChanged = false;
@@ -1056,8 +1061,9 @@ class WifiConfigStore {
        if (ipChanged || proxyChanged) {
        if (ipChanged || proxyChanged) {
            currentConfig.linkProperties = linkProperties;
            currentConfig.linkProperties = linkProperties;
            writeIpAndProxyConfigurations();
            writeIpAndProxyConfigurations();
            sendConfigChangeBroadcast();
            sendConfiguredNetworksChangedBroadcast();
        }
        }
        return new NetworkUpdateResult(ipChanged, proxyChanged);
    }
    }


    private static void addIpSettingsFromConfig(LinkProperties linkProperties,
    private static void addIpSettingsFromConfig(LinkProperties linkProperties,
+6 −8
Original line number Original line Diff line number Diff line
@@ -131,7 +131,6 @@ public class WifiManager {
     *
     *
     * @hide
     * @hide
     */
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String WIFI_AP_STATE_CHANGED_ACTION =
    public static final String WIFI_AP_STATE_CHANGED_ACTION =
        "android.net.wifi.WIFI_AP_STATE_CHANGED";
        "android.net.wifi.WIFI_AP_STATE_CHANGED";


@@ -276,13 +275,12 @@ public class WifiManager {
     */
     */
    public static final String EXTRA_SUPPLICANT_ERROR = "supplicantError";
    public static final String EXTRA_SUPPLICANT_ERROR = "supplicantError";
    /**
    /**
     * Broadcast intent action indicating that the supplicant configuration changed.
     * Broadcast intent action indicating that the configured networks changed.
     * This can be as a result of adding/updating/deleting a network
     * This can be as a result of adding/updating/deleting a network
     * @hide
     * @hide
     */
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String CONFIGURED_NETWORKS_CHANGED_ACTION =
    public static final String SUPPLICANT_CONFIG_CHANGED_ACTION =
        "android.net.wifi.CONFIGURED_NETWORKS_CHANGE";
        "android.net.wifi.supplicant.CONFIG_CHANGE";
    /**
    /**
     * An access point scan has completed, and results are available from the supplicant.
     * An access point scan has completed, and results are available from the supplicant.
     * Call {@link #getScanResults()} to obtain the results.
     * Call {@link #getScanResults()} to obtain the results.
@@ -301,12 +299,12 @@ public class WifiManager {
    public static final String EXTRA_NEW_RSSI = "newRssi";
    public static final String EXTRA_NEW_RSSI = "newRssi";


    /**
    /**
     * Broadcast intent action indicating that the IP configuration
     * Broadcast intent action indicating that the link configuration
     * changed on wifi.
     * changed on wifi.
     * @hide
     * @hide
     */
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String LINK_CONFIGURATION_CHANGED_ACTION =
    public static final String CONFIG_CHANGED_ACTION = "android.net.wifi.CONFIG_CHANGED";
        "android.net.wifi.LINK_CONFIGURATION_CHANGED";


    /**
    /**
     * The lookup key for a {@link android.net.LinkProperties} object associated with the
     * The lookup key for a {@link android.net.LinkProperties} object associated with the
+42 −30
Original line number Original line Diff line number Diff line
@@ -37,7 +37,6 @@ import static android.net.wifi.WifiManager.WIFI_AP_STATE_ENABLED;
import static android.net.wifi.WifiManager.WIFI_AP_STATE_ENABLING;
import static android.net.wifi.WifiManager.WIFI_AP_STATE_ENABLING;
import static android.net.wifi.WifiManager.WIFI_AP_STATE_FAILED;
import static android.net.wifi.WifiManager.WIFI_AP_STATE_FAILED;


import android.app.ActivityManagerNative;
import android.app.AlarmManager;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.app.PendingIntent;
import android.net.LinkAddress;
import android.net.LinkAddress;
@@ -47,6 +46,7 @@ import android.net.NetworkUtils;
import android.net.ConnectivityManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo.DetailedState;
import android.net.NetworkInfo.DetailedState;
import android.net.LinkProperties;
import android.net.LinkProperties;
import android.net.wifi.NetworkUpdateResult;
import android.os.Binder;
import android.os.Binder;
import android.os.Message;
import android.os.Message;
import android.os.IBinder;
import android.os.IBinder;
@@ -193,9 +193,6 @@ public class WifiStateMachine extends HierarchicalStateMachine {
    static final int CMD_IP_CONFIG_SUCCESS                = 15;
    static final int CMD_IP_CONFIG_SUCCESS                = 15;
    /* Indicates DHCP failed */
    /* Indicates DHCP failed */
    static final int CMD_IP_CONFIG_FAILURE                = 16;
    static final int CMD_IP_CONFIG_FAILURE                = 16;
    /* Re-configure interface */
    static final int CMD_RECONFIGURE_IP                   = 17;



    /* Start the soft access point */
    /* Start the soft access point */
    static final int CMD_START_AP                         = 21;
    static final int CMD_START_AP                         = 21;
@@ -1336,15 +1333,14 @@ public class WifiStateMachine extends HierarchicalStateMachine {
    };
    };


    private void sendScanResultsAvailableBroadcast() {
    private void sendScanResultsAvailableBroadcast() {
        if (!ActivityManagerNative.isSystemReady()) return;
        Intent intent = new Intent(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);

        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
        mContext.sendBroadcast(new Intent(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
        mContext.sendBroadcast(intent);
    }
    }


    private void sendRssiChangeBroadcast(final int newRssi) {
    private void sendRssiChangeBroadcast(final int newRssi) {
        if (!ActivityManagerNative.isSystemReady()) return;

        Intent intent = new Intent(WifiManager.RSSI_CHANGED_ACTION);
        Intent intent = new Intent(WifiManager.RSSI_CHANGED_ACTION);
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
        intent.putExtra(WifiManager.EXTRA_NEW_RSSI, newRssi);
        intent.putExtra(WifiManager.EXTRA_NEW_RSSI, newRssi);
        mContext.sendBroadcast(intent);
        mContext.sendBroadcast(intent);
    }
    }
@@ -1360,18 +1356,16 @@ public class WifiStateMachine extends HierarchicalStateMachine {
        mContext.sendStickyBroadcast(intent);
        mContext.sendStickyBroadcast(intent);
    }
    }


    /* TODO: Unused for now, will be used when ip change on connected network is handled */
    private void sendLinkConfigurationChangedBroadcast() {
    private void sendConfigChangeBroadcast() {
        Intent intent = new Intent(WifiManager.LINK_CONFIGURATION_CHANGED_ACTION);
        if (!ActivityManagerNative.isSystemReady()) return;
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
        Intent intent = new Intent(WifiManager.CONFIG_CHANGED_ACTION);
        intent.putExtra(WifiManager.EXTRA_LINK_PROPERTIES, mLinkProperties);
        intent.putExtra(WifiManager.EXTRA_LINK_PROPERTIES, mLinkProperties);
        mContext.sendBroadcast(intent);
        mContext.sendBroadcast(intent);
    }
    }


    private void sendSupplicantConnectionChangedBroadcast(boolean connected) {
    private void sendSupplicantConnectionChangedBroadcast(boolean connected) {
        if (!ActivityManagerNative.isSystemReady()) return;

        Intent intent = new Intent(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION);
        Intent intent = new Intent(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION);
        intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
        intent.putExtra(WifiManager.EXTRA_SUPPLICANT_CONNECTED, connected);
        intent.putExtra(WifiManager.EXTRA_SUPPLICANT_CONNECTED, connected);
        mContext.sendBroadcast(intent);
        mContext.sendBroadcast(intent);
    }
    }
@@ -1380,7 +1374,7 @@ public class WifiStateMachine extends HierarchicalStateMachine {
     * Record the detailed state of a network.
     * Record the detailed state of a network.
     * @param state the new @{code DetailedState}
     * @param state the new @{code DetailedState}
     */
     */
    private void setDetailedState(NetworkInfo.DetailedState state) {
    private void setNetworkDetailedState(NetworkInfo.DetailedState state) {
        Log.d(TAG, "setDetailed state, old ="
        Log.d(TAG, "setDetailed state, old ="
                + mNetworkInfo.getDetailedState() + " and new state=" + state);
                + mNetworkInfo.getDetailedState() + " and new state=" + state);
        if (state != mNetworkInfo.getDetailedState()) {
        if (state != mNetworkInfo.getDetailedState()) {
@@ -1388,6 +1382,10 @@ public class WifiStateMachine extends HierarchicalStateMachine {
        }
        }
    }
    }


    private DetailedState getNetworkDetailedState() {
        return mNetworkInfo.getDetailedState();
    }

    /**
    /**
     * Resets the Wi-Fi Connections by clearing any state, resetting any sockets
     * Resets the Wi-Fi Connections by clearing any state, resetting any sockets
     * using the interface, stopping DHCP & disabling interface
     * using the interface, stopping DHCP & disabling interface
@@ -1408,7 +1406,7 @@ public class WifiStateMachine extends HierarchicalStateMachine {
        NetworkUtils.disableInterface(mInterfaceName);
        NetworkUtils.disableInterface(mInterfaceName);


        /* send event to CM & network change broadcast */
        /* send event to CM & network change broadcast */
        setDetailedState(DetailedState.DISCONNECTED);
        setNetworkDetailedState(DetailedState.DISCONNECTED);
        sendNetworkStateChangeBroadcast(mLastBssid);
        sendNetworkStateChangeBroadcast(mLastBssid);


        /* Reset data structures */
        /* Reset data structures */
@@ -1576,7 +1574,6 @@ public class WifiStateMachine extends HierarchicalStateMachine {
                case CMD_DISCONNECT:
                case CMD_DISCONNECT:
                case CMD_RECONNECT:
                case CMD_RECONNECT:
                case CMD_REASSOCIATE:
                case CMD_REASSOCIATE:
                case CMD_RECONFIGURE_IP:
                case SUP_CONNECTION_EVENT:
                case SUP_CONNECTION_EVENT:
                case SUP_DISCONNECTION_EVENT:
                case SUP_DISCONNECTION_EVENT:
                case DRIVER_START_EVENT:
                case DRIVER_START_EVENT:
@@ -2415,7 +2412,7 @@ public class WifiStateMachine extends HierarchicalStateMachine {
                    mWifiInfo.setNetworkId(stateChangeResult.networkId);
                    mWifiInfo.setNetworkId(stateChangeResult.networkId);
                    mLastNetworkId = stateChangeResult.networkId;
                    mLastNetworkId = stateChangeResult.networkId;
                    /* send event to CM & network change broadcast */
                    /* send event to CM & network change broadcast */
                    setDetailedState(DetailedState.OBTAINING_IPADDR);
                    setNetworkDetailedState(DetailedState.OBTAINING_IPADDR);
                    sendNetworkStateChangeBroadcast(mLastBssid);
                    sendNetworkStateChangeBroadcast(mLastBssid);
                    transitionTo(mConnectingState);
                    transitionTo(mConnectingState);
                    break;
                    break;
@@ -2526,8 +2523,12 @@ public class WifiStateMachine extends HierarchicalStateMachine {
                      mWifiInfo.setIpAddress(mDhcpInfo.ipAddress);
                      mWifiInfo.setIpAddress(mDhcpInfo.ipAddress);
                  }
                  }
                  configureLinkProperties();
                  configureLinkProperties();
                  setDetailedState(DetailedState.CONNECTED);
                  if (getNetworkDetailedState() == DetailedState.CONNECTED) {
                      sendLinkConfigurationChangedBroadcast();
                  } else {
                      setNetworkDetailedState(DetailedState.CONNECTED);
                      sendNetworkStateChangeBroadcast(mLastBssid);
                      sendNetworkStateChangeBroadcast(mLastBssid);
                  }
                  //TODO: The framework is not detecting a DHCP renewal and a possible
                  //TODO: The framework is not detecting a DHCP renewal and a possible
                  //IP change. we should detect this and send out a config change broadcast
                  //IP change. we should detect this and send out a config change broadcast
                  transitionTo(mConnectedState);
                  transitionTo(mConnectedState);
@@ -2565,6 +2566,9 @@ public class WifiStateMachine extends HierarchicalStateMachine {
                      break;
                      break;
                  }
                  }
                  return NOT_HANDLED;
                  return NOT_HANDLED;
              case CMD_SAVE_NETWORK:
                  deferMessage(message);
                  break;
                  /* Ignore */
                  /* Ignore */
              case NETWORK_CONNECTION_EVENT:
              case NETWORK_CONNECTION_EVENT:
                  break;
                  break;
@@ -2582,9 +2586,6 @@ public class WifiStateMachine extends HierarchicalStateMachine {
              case CMD_START_SCAN:
              case CMD_START_SCAN:
                  deferMessage(message);
                  deferMessage(message);
                  break;
                  break;
              case CMD_RECONFIGURE_IP:
                  deferMessage(message);
                  break;
                  /* Defer any power mode changes since we must keep active power mode at DHCP */
                  /* Defer any power mode changes since we must keep active power mode at DHCP */
              case CMD_SET_HIGH_PERF_MODE:
              case CMD_SET_HIGH_PERF_MODE:
                  deferMessage(message);
                  deferMessage(message);
@@ -2632,11 +2633,6 @@ public class WifiStateMachine extends HierarchicalStateMachine {
                    WifiNative.disconnectCommand();
                    WifiNative.disconnectCommand();
                    transitionTo(mDisconnectingState);
                    transitionTo(mDisconnectingState);
                    break;
                    break;
                case CMD_RECONFIGURE_IP:
                    Log.d(TAG,"Reconfiguring IP on connection");
                    NetworkUtils.resetConnections(mInterfaceName);
                    transitionTo(mConnectingState);
                    break;
                case CMD_STOP_DRIVER:
                case CMD_STOP_DRIVER:
                    sendMessage(CMD_DISCONNECT);
                    sendMessage(CMD_DISCONNECT);
                    deferMessage(message);
                    deferMessage(message);
@@ -2663,6 +2659,22 @@ public class WifiStateMachine extends HierarchicalStateMachine {
                        break;
                        break;
                    }
                    }
                    return NOT_HANDLED;
                    return NOT_HANDLED;
                case CMD_SAVE_NETWORK:
                    WifiConfiguration config = (WifiConfiguration) message.obj;
                    NetworkUpdateResult result = WifiConfigStore.saveNetwork(config);
                    if (mWifiInfo.getNetworkId() == result.getNetworkId()) {
                        if (result.hasIpChanged()) {
                            Log.d(TAG,"Reconfiguring IP on connection");
                            NetworkUtils.resetConnections(mInterfaceName);
                            transitionTo(mConnectingState);
                        }
                        if (result.hasProxyChanged()) {
                            Log.d(TAG,"Reconfiguring proxy on connection");
                            configureLinkProperties();
                            sendLinkConfigurationChangedBroadcast();
                        }
                    }
                    break;
                    /* Ignore */
                    /* Ignore */
                case NETWORK_CONNECTION_EVENT:
                case NETWORK_CONNECTION_EVENT:
                    break;
                    break;
@@ -2767,7 +2779,7 @@ public class WifiStateMachine extends HierarchicalStateMachine {
                case SUPPLICANT_STATE_CHANGE_EVENT:
                case SUPPLICANT_STATE_CHANGE_EVENT:
                    StateChangeResult stateChangeResult = (StateChangeResult) message.obj;
                    StateChangeResult stateChangeResult = (StateChangeResult) message.obj;
                    SupplicantState state = (SupplicantState) stateChangeResult.state;
                    SupplicantState state = (SupplicantState) stateChangeResult.state;
                    setDetailedState(WifiInfo.getDetailedStateOf(state));
                    setNetworkDetailedState(WifiInfo.getDetailedStateOf(state));
                    /* DriverStartedState does the rest of the handling */
                    /* DriverStartedState does the rest of the handling */
                    return NOT_HANDLED;
                    return NOT_HANDLED;
                default:
                default:
+2 −2
Original line number Original line Diff line number Diff line
@@ -86,7 +86,7 @@ public class WifiStateTracker implements NetworkStateTracker {
        mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
        mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
        IntentFilter filter = new IntentFilter();
        IntentFilter filter = new IntentFilter();
        filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
        filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
        filter.addAction(WifiManager.CONFIG_CHANGED_ACTION);
        filter.addAction(WifiManager.LINK_CONFIGURATION_CHANGED_ACTION);


        mWifiStateReceiver = new WifiStateReceiver();
        mWifiStateReceiver = new WifiStateReceiver();
        mContext.registerReceiver(mWifiStateReceiver, filter);
        mContext.registerReceiver(mWifiStateReceiver, filter);
@@ -254,7 +254,7 @@ public class WifiStateTracker implements NetworkStateTracker {
                }
                }
                Message msg = mCsHandler.obtainMessage(EVENT_STATE_CHANGED, mNetworkInfo);
                Message msg = mCsHandler.obtainMessage(EVENT_STATE_CHANGED, mNetworkInfo);
                msg.sendToTarget();
                msg.sendToTarget();
            } else if (intent.getAction().equals(WifiManager.CONFIG_CHANGED_ACTION)) {
            } else if (intent.getAction().equals(WifiManager.LINK_CONFIGURATION_CHANGED_ACTION)) {
                mLinkProperties = (LinkProperties) intent.getParcelableExtra(
                mLinkProperties = (LinkProperties) intent.getParcelableExtra(
                        WifiManager.EXTRA_LINK_PROPERTIES);
                        WifiManager.EXTRA_LINK_PROPERTIES);
                Message msg = mCsHandler.obtainMessage(EVENT_CONFIGURATION_CHANGED, mNetworkInfo);
                Message msg = mCsHandler.obtainMessage(EVENT_CONFIGURATION_CHANGED, mNetworkInfo);