Merge "Additional logging to debug lost Wifi APs" into klp-dev
This commit is contained in:
@ -37,6 +37,7 @@ import android.os.HandlerThread;
|
|||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.security.KeyStore;
|
import android.security.KeyStore;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.LocalLog;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
@ -108,7 +109,7 @@ class WifiConfigStore {
|
|||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private static final String TAG = "WifiConfigStore";
|
private static final String TAG = "WifiConfigStore";
|
||||||
private static final boolean DBG = false;
|
private static final boolean DBG = true;
|
||||||
|
|
||||||
/* configured networks with network id as the key */
|
/* configured networks with network id as the key */
|
||||||
private HashMap<Integer, WifiConfiguration> mConfiguredNetworks =
|
private HashMap<Integer, WifiConfiguration> mConfiguredNetworks =
|
||||||
@ -145,12 +146,19 @@ class WifiConfigStore {
|
|||||||
private static final String EXCLUSION_LIST_KEY = "exclusionList";
|
private static final String EXCLUSION_LIST_KEY = "exclusionList";
|
||||||
private static final String EOS = "eos";
|
private static final String EOS = "eos";
|
||||||
|
|
||||||
|
private final LocalLog mLocalLog;
|
||||||
|
|
||||||
private WifiNative mWifiNative;
|
private WifiNative mWifiNative;
|
||||||
private final KeyStore mKeyStore = KeyStore.getInstance();
|
private final KeyStore mKeyStore = KeyStore.getInstance();
|
||||||
|
|
||||||
WifiConfigStore(Context c, WifiNative wn) {
|
WifiConfigStore(Context c, WifiNative wn) {
|
||||||
mContext = c;
|
mContext = c;
|
||||||
mWifiNative = wn;
|
mWifiNative = wn;
|
||||||
|
|
||||||
|
if (DBG) {
|
||||||
|
mLocalLog = new LocalLog(1024); // takes about 64 K
|
||||||
|
mWifiNative.setLocalLog(mLocalLog);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -212,6 +220,7 @@ class WifiConfigStore {
|
|||||||
* @return false if the network id is invalid
|
* @return false if the network id is invalid
|
||||||
*/
|
*/
|
||||||
boolean selectNetwork(int netId) {
|
boolean selectNetwork(int netId) {
|
||||||
|
localLog("selectNetwork", netId);
|
||||||
if (netId == INVALID_NETWORK_ID) return false;
|
if (netId == INVALID_NETWORK_ID) return false;
|
||||||
|
|
||||||
// Reset the priority of each network at start or if it goes too high.
|
// Reset the priority of each network at start or if it goes too high.
|
||||||
@ -248,6 +257,7 @@ class WifiConfigStore {
|
|||||||
* @return network update result
|
* @return network update result
|
||||||
*/
|
*/
|
||||||
NetworkUpdateResult saveNetwork(WifiConfiguration config) {
|
NetworkUpdateResult saveNetwork(WifiConfiguration config) {
|
||||||
|
localLog("saveNetwork", config.networkId);
|
||||||
// A new network cannot have null SSID
|
// A new network cannot have null SSID
|
||||||
if (config == null || (config.networkId == INVALID_NETWORK_ID &&
|
if (config == null || (config.networkId == INVALID_NETWORK_ID &&
|
||||||
config.SSID == null)) {
|
config.SSID == null)) {
|
||||||
@ -296,6 +306,7 @@ class WifiConfigStore {
|
|||||||
* @return {@code true} if it succeeds, {@code false} otherwise
|
* @return {@code true} if it succeeds, {@code false} otherwise
|
||||||
*/
|
*/
|
||||||
boolean forgetNetwork(int netId) {
|
boolean forgetNetwork(int netId) {
|
||||||
|
localLog("forgetNetwork", netId);
|
||||||
if (mWifiNative.removeNetwork(netId)) {
|
if (mWifiNative.removeNetwork(netId)) {
|
||||||
mWifiNative.saveConfig();
|
mWifiNative.saveConfig();
|
||||||
removeConfigAndSendBroadcastIfNeeded(netId);
|
removeConfigAndSendBroadcastIfNeeded(netId);
|
||||||
@ -316,6 +327,7 @@ class WifiConfigStore {
|
|||||||
* @return network Id
|
* @return network Id
|
||||||
*/
|
*/
|
||||||
int addOrUpdateNetwork(WifiConfiguration config) {
|
int addOrUpdateNetwork(WifiConfiguration config) {
|
||||||
|
localLog("addOrUpdateNetwork", config.networkId);
|
||||||
NetworkUpdateResult result = addOrUpdateNetworkNative(config);
|
NetworkUpdateResult result = addOrUpdateNetworkNative(config);
|
||||||
if (result.getNetworkId() != WifiConfiguration.INVALID_NETWORK_ID) {
|
if (result.getNetworkId() != WifiConfiguration.INVALID_NETWORK_ID) {
|
||||||
sendConfiguredNetworksChangedBroadcast(mConfiguredNetworks.get(result.getNetworkId()),
|
sendConfiguredNetworksChangedBroadcast(mConfiguredNetworks.get(result.getNetworkId()),
|
||||||
@ -335,6 +347,7 @@ class WifiConfigStore {
|
|||||||
* @return {@code true} if it succeeds, {@code false} otherwise
|
* @return {@code true} if it succeeds, {@code false} otherwise
|
||||||
*/
|
*/
|
||||||
boolean removeNetwork(int netId) {
|
boolean removeNetwork(int netId) {
|
||||||
|
localLog("removeNetwork", netId);
|
||||||
boolean ret = mWifiNative.removeNetwork(netId);
|
boolean ret = mWifiNative.removeNetwork(netId);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
removeConfigAndSendBroadcastIfNeeded(netId);
|
removeConfigAndSendBroadcastIfNeeded(netId);
|
||||||
@ -369,8 +382,10 @@ class WifiConfigStore {
|
|||||||
boolean enableNetwork(int netId, boolean disableOthers) {
|
boolean enableNetwork(int netId, boolean disableOthers) {
|
||||||
boolean ret = enableNetworkWithoutBroadcast(netId, disableOthers);
|
boolean ret = enableNetworkWithoutBroadcast(netId, disableOthers);
|
||||||
if (disableOthers) {
|
if (disableOthers) {
|
||||||
|
localLog("enableNetwork(disableOthers=true) ", netId);
|
||||||
sendConfiguredNetworksChangedBroadcast();
|
sendConfiguredNetworksChangedBroadcast();
|
||||||
} else {
|
} else {
|
||||||
|
localLog("enableNetwork(disableOthers=false) ", netId);
|
||||||
WifiConfiguration enabledNetwork = null;
|
WifiConfiguration enabledNetwork = null;
|
||||||
synchronized(mConfiguredNetworks) {
|
synchronized(mConfiguredNetworks) {
|
||||||
enabledNetwork = mConfiguredNetworks.get(netId);
|
enabledNetwork = mConfiguredNetworks.get(netId);
|
||||||
@ -397,6 +412,7 @@ class WifiConfigStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void disableAllNetworks() {
|
void disableAllNetworks() {
|
||||||
|
localLog("disableAllNetworks");
|
||||||
boolean networkDisabled = false;
|
boolean networkDisabled = false;
|
||||||
for(WifiConfiguration config : mConfiguredNetworks.values()) {
|
for(WifiConfiguration config : mConfiguredNetworks.values()) {
|
||||||
if(config != null && config.status != Status.DISABLED) {
|
if(config != null && config.status != Status.DISABLED) {
|
||||||
@ -429,6 +445,7 @@ class WifiConfigStore {
|
|||||||
* @return {@code true} if it succeeds, {@code false} otherwise
|
* @return {@code true} if it succeeds, {@code false} otherwise
|
||||||
*/
|
*/
|
||||||
boolean disableNetwork(int netId, int reason) {
|
boolean disableNetwork(int netId, int reason) {
|
||||||
|
localLog("disableNetwork", netId);
|
||||||
boolean ret = mWifiNative.disableNetwork(netId);
|
boolean ret = mWifiNative.disableNetwork(netId);
|
||||||
WifiConfiguration network = null;
|
WifiConfiguration network = null;
|
||||||
WifiConfiguration config = mConfiguredNetworks.get(netId);
|
WifiConfiguration config = mConfiguredNetworks.get(netId);
|
||||||
@ -639,10 +656,13 @@ class WifiConfigStore {
|
|||||||
config.proxySettings = ProxySettings.NONE;
|
config.proxySettings = ProxySettings.NONE;
|
||||||
mConfiguredNetworks.put(config.networkId, config);
|
mConfiguredNetworks.put(config.networkId, config);
|
||||||
mNetworkIds.put(configKey(config), config.networkId);
|
mNetworkIds.put(configKey(config), config.networkId);
|
||||||
|
localLog("loaded configured network", config.networkId);
|
||||||
}
|
}
|
||||||
|
|
||||||
readIpAndProxyConfigurations();
|
readIpAndProxyConfigurations();
|
||||||
sendConfiguredNetworksChangedBroadcast();
|
sendConfiguredNetworksChangedBroadcast();
|
||||||
|
|
||||||
|
localLog("loadConfiguredNetworks loaded " + mNetworkIds.size() + " networks");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mark all networks except specified netId as disabled */
|
/* Mark all networks except specified netId as disabled */
|
||||||
@ -972,6 +992,9 @@ class WifiConfigStore {
|
|||||||
* network configuration. Otherwise, the networkId should
|
* network configuration. Otherwise, the networkId should
|
||||||
* refer to an existing configuration.
|
* refer to an existing configuration.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
localLog("addOrUpdateNetworkNative " + config.getPrintableSsid());
|
||||||
|
|
||||||
int netId = config.networkId;
|
int netId = config.networkId;
|
||||||
boolean newNetwork = false;
|
boolean newNetwork = false;
|
||||||
// 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
|
||||||
@ -1577,6 +1600,12 @@ class WifiConfigStore {
|
|||||||
pw.println(conf);
|
pw.println(conf);
|
||||||
}
|
}
|
||||||
pw.println();
|
pw.println();
|
||||||
|
|
||||||
|
if (mLocalLog != null) {
|
||||||
|
pw.println("WifiConfigStore - Log Begin ----");
|
||||||
|
mLocalLog.dump(fd, pw, args);
|
||||||
|
pw.println("WifiConfigStore - Log End ----");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getConfigFile() {
|
public String getConfigFile() {
|
||||||
@ -1590,4 +1619,28 @@ class WifiConfigStore {
|
|||||||
private void log(String s) {
|
private void log(String s) {
|
||||||
Log.d(TAG, s);
|
Log.d(TAG, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void localLog(String s) {
|
||||||
|
if (mLocalLog != null) {
|
||||||
|
mLocalLog.log(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void localLog(String s, int netId) {
|
||||||
|
if (mLocalLog == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WifiConfiguration config;
|
||||||
|
synchronized(mConfiguredNetworks) {
|
||||||
|
config = mConfiguredNetworks.get(netId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config != null) {
|
||||||
|
mLocalLog.log(s + " " + config.getPrintableSsid());
|
||||||
|
} else {
|
||||||
|
mLocalLog.log(s + " " + netId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -435,6 +435,7 @@ public class WifiMonitor {
|
|||||||
} else {
|
} else {
|
||||||
mIfaceMap.remove(iface);
|
mIfaceMap.remove(iface);
|
||||||
m.mWifiStateMachine.sendMessage(SUP_DISCONNECTION_EVENT);
|
m.mWifiStateMachine.sendMessage(SUP_DISCONNECTION_EVENT);
|
||||||
|
Log.e(TAG, "startMonitoring(" + iface + ") failed!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ import android.net.wifi.p2p.WifiP2pConfig;
|
|||||||
import android.net.wifi.p2p.WifiP2pGroup;
|
import android.net.wifi.p2p.WifiP2pGroup;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.net.wifi.p2p.nsd.WifiP2pServiceInfo;
|
import android.net.wifi.p2p.nsd.WifiP2pServiceInfo;
|
||||||
|
import android.util.LocalLog;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -91,6 +92,18 @@ public class WifiNative {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private LocalLog mLocalLog;
|
||||||
|
|
||||||
|
public void setLocalLog(LocalLog l) {
|
||||||
|
mLocalLog = l;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void localLog(String s) {
|
||||||
|
if (mLocalLog != null)
|
||||||
|
mLocalLog.log(mInterfaceName + ": " + s);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean connectToSupplicant() {
|
public boolean connectToSupplicant() {
|
||||||
return connectToSupplicantNative();
|
return connectToSupplicantNative();
|
||||||
}
|
}
|
||||||
@ -144,15 +157,18 @@ public class WifiNative {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String listNetworks() {
|
public String listNetworks() {
|
||||||
|
localLog("LIST_NETWORKS");
|
||||||
return doStringCommand("LIST_NETWORKS");
|
return doStringCommand("LIST_NETWORKS");
|
||||||
}
|
}
|
||||||
|
|
||||||
public int addNetwork() {
|
public int addNetwork() {
|
||||||
|
localLog("ADD_NETWORK");
|
||||||
return doIntCommand("ADD_NETWORK");
|
return doIntCommand("ADD_NETWORK");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setNetworkVariable(int netId, String name, String value) {
|
public boolean setNetworkVariable(int netId, String name, String value) {
|
||||||
if (TextUtils.isEmpty(name) || TextUtils.isEmpty(value)) return false;
|
if (TextUtils.isEmpty(name) || TextUtils.isEmpty(value)) return false;
|
||||||
|
localLog("SET_NETWORK " + netId + " " + name + "=" + value);
|
||||||
return doBooleanCommand("SET_NETWORK " + netId + " " + name + " " + value);
|
return doBooleanCommand("SET_NETWORK " + netId + " " + name + " " + value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,22 +178,27 @@ public class WifiNative {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeNetwork(int netId) {
|
public boolean removeNetwork(int netId) {
|
||||||
|
localLog("REMOVE_NETWORK " + netId);
|
||||||
return doBooleanCommand("REMOVE_NETWORK " + netId);
|
return doBooleanCommand("REMOVE_NETWORK " + netId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean enableNetwork(int netId, boolean disableOthers) {
|
public boolean enableNetwork(int netId, boolean disableOthers) {
|
||||||
if (disableOthers) {
|
if (disableOthers) {
|
||||||
|
localLog("SELECT_NETWORK " + netId);
|
||||||
return doBooleanCommand("SELECT_NETWORK " + netId);
|
return doBooleanCommand("SELECT_NETWORK " + netId);
|
||||||
} else {
|
} else {
|
||||||
|
localLog("ENABLE_NETWORK " + netId);
|
||||||
return doBooleanCommand("ENABLE_NETWORK " + netId);
|
return doBooleanCommand("ENABLE_NETWORK " + netId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean disableNetwork(int netId) {
|
public boolean disableNetwork(int netId) {
|
||||||
|
localLog("DISABLE_NETWORK " + netId);
|
||||||
return doBooleanCommand("DISABLE_NETWORK " + netId);
|
return doBooleanCommand("DISABLE_NETWORK " + netId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean reconnect() {
|
public boolean reconnect() {
|
||||||
|
localLog("RECONNECT");
|
||||||
return doBooleanCommand("RECONNECT");
|
return doBooleanCommand("RECONNECT");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,6 +397,7 @@ public class WifiNative {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean saveConfig() {
|
public boolean saveConfig() {
|
||||||
|
localLog("SAVE_CONFIG");
|
||||||
return doBooleanCommand("SAVE_CONFIG");
|
return doBooleanCommand("SAVE_CONFIG");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2790,7 +2790,10 @@ public class WifiStateMachine extends StateMachine {
|
|||||||
} else {
|
} else {
|
||||||
/* Driver stop may have disabled networks, enable right after start */
|
/* Driver stop may have disabled networks, enable right after start */
|
||||||
mWifiConfigStore.enableAllNetworks();
|
mWifiConfigStore.enableAllNetworks();
|
||||||
|
|
||||||
|
if (DBG) log("Attempting to reconnect to wifi network ..");
|
||||||
mWifiNative.reconnect();
|
mWifiNative.reconnect();
|
||||||
|
|
||||||
// Status pulls in the current supplicant state and network connection state
|
// Status pulls in the current supplicant state and network connection state
|
||||||
// events over the monitor connection. This helps framework sync up with
|
// events over the monitor connection. This helps framework sync up with
|
||||||
// current supplicant state
|
// current supplicant state
|
||||||
|
Reference in New Issue
Block a user