diff options
author | Vinit Deshapnde <vinitd@google.com> | 2013-08-28 13:13:40 -0700 |
---|---|---|
committer | Vinit Deshapnde <vinitd@google.com> | 2013-08-28 13:13:40 -0700 |
commit | 48c47471061d7d5da15fa2b45ac7c8102bdf847e (patch) | |
tree | 718693b7c065cbcc413cdbf39c48a89360119831 /wifi/java/android | |
parent | 1f809c7761a52102621b22fe8ec8c9f91ec1fe54 (diff) | |
download | frameworks_base-48c47471061d7d5da15fa2b45ac7c8102bdf847e.zip frameworks_base-48c47471061d7d5da15fa2b45ac7c8102bdf847e.tar.gz frameworks_base-48c47471061d7d5da15fa2b45ac7c8102bdf847e.tar.bz2 |
More elaborate logs to debug missing APs
Bug: 10375978
Change-Id: Ic9bb8f3a7a0684143e4e77f8da0d2c833293c94a
Diffstat (limited to 'wifi/java/android')
-rw-r--r-- | wifi/java/android/net/wifi/WifiConfigStore.java | 57 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiNative.java | 53 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiStateMachine.java | 2 |
3 files changed, 91 insertions, 21 deletions
diff --git a/wifi/java/android/net/wifi/WifiConfigStore.java b/wifi/java/android/net/wifi/WifiConfigStore.java index 3f6fb6e..4baab1f 100644 --- a/wifi/java/android/net/wifi/WifiConfigStore.java +++ b/wifi/java/android/net/wifi/WifiConfigStore.java @@ -31,6 +31,7 @@ import android.net.wifi.WifiConfiguration.Status; import android.net.wifi.NetworkUpdateResult; import static android.net.wifi.WifiConfiguration.INVALID_NETWORK_ID; import android.os.Environment; +import android.os.FileObserver; import android.os.Message; import android.os.Handler; import android.os.HandlerThread; @@ -42,12 +43,16 @@ import android.util.Log; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; +import java.io.BufferedReader; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.EOFException; +import java.io.File; import java.io.FileDescriptor; import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.FileOutputStream; +import java.io.FileReader; import java.io.IOException; import java.io.PrintWriter; import java.net.InetAddress; @@ -111,6 +116,8 @@ class WifiConfigStore { private static final String TAG = "WifiConfigStore"; private static final boolean DBG = true; + private static final String SUPPLICANT_CONFIG_FILE = "/data/misc/wifi/wpa_supplicant.conf"; + /* configured networks with network id as the key */ private HashMap<Integer, WifiConfiguration> mConfiguredNetworks = new HashMap<Integer, WifiConfiguration>(); @@ -147,6 +154,7 @@ class WifiConfigStore { private static final String EOS = "eos"; private final LocalLog mLocalLog; + WpaConfigFileObserver mFileObserver; private WifiNative mWifiNative; private final KeyStore mKeyStore = KeyStore.getInstance(); @@ -156,11 +164,28 @@ class WifiConfigStore { mWifiNative = wn; if (DBG) { - mLocalLog = new LocalLog(1024); // takes about 64 K - mWifiNative.setLocalLog(mLocalLog); + mLocalLog = mWifiNative.getLocalLog(); + mFileObserver = new WpaConfigFileObserver(); + mFileObserver.startWatching(); + } + } + + class WpaConfigFileObserver extends FileObserver { + + public WpaConfigFileObserver() { + super(SUPPLICANT_CONFIG_FILE, CLOSE_WRITE); + } + + @Override + public void onEvent(int event, String path) { + if (event == CLOSE_WRITE) { + File file = new File(SUPPLICANT_CONFIG_FILE); + localLog("wpa_supplicant.conf changed; new size = " + file.length()); + } } } + /** * Fetch the list of configured networks * and enable all stored networks in supplicant. @@ -332,7 +357,7 @@ class WifiConfigStore { if (result.getNetworkId() != WifiConfiguration.INVALID_NETWORK_ID) { sendConfiguredNetworksChangedBroadcast(mConfiguredNetworks.get(result.getNetworkId()), result.isNewNetwork ? WifiManager.CHANGE_REASON_ADDED : - WifiManager.CHANGE_REASON_CONFIG_CHANGE); + WifiManager.CHANGE_REASON_CONFIG_CHANGE); } return result.getNetworkId(); } @@ -636,6 +661,7 @@ class WifiConfigStore { try { config.networkId = Integer.parseInt(result[0]); } catch(NumberFormatException e) { + loge("Failed to read network-id '" + result[0] + "'"); continue; } if (result.length > 3) { @@ -663,6 +689,31 @@ class WifiConfigStore { sendConfiguredNetworksChangedBroadcast(); localLog("loadConfiguredNetworks loaded " + mNetworkIds.size() + " networks"); + + if (mNetworkIds.size() == 0) { + // no networks? Lets log if the wpa_supplicant.conf file contents + BufferedReader reader = null; + try { + reader = new BufferedReader(new FileReader(SUPPLICANT_CONFIG_FILE)); + localLog("--- Begin wpa_supplicant.conf Contents ---"); + for (String line = reader.readLine(); line != null; line = reader.readLine()) { + localLog(line); + } + localLog("--- End wpa_supplicant.conf Contents ---"); + } catch (FileNotFoundException e) { + localLog("Could not open " + SUPPLICANT_CONFIG_FILE + ", " + e); + } catch (IOException e) { + localLog("Could not read " + SUPPLICANT_CONFIG_FILE + ", " + e); + } finally { + try { + if (reader != null) { + reader.close(); + } + } catch (IOException e) { + // Just ignore the fact that we couldn't close + } + } + } } /* Mark all networks except specified netId as disabled */ diff --git a/wifi/java/android/net/wifi/WifiNative.java b/wifi/java/android/net/wifi/WifiNative.java index ea259be..53c00d8 100644 --- a/wifi/java/android/net/wifi/WifiNative.java +++ b/wifi/java/android/net/wifi/WifiNative.java @@ -93,10 +93,17 @@ public class WifiNative { } - private LocalLog mLocalLog; + private static final LocalLog mLocalLog = new LocalLog(1024); + private int mCmdId; - public void setLocalLog(LocalLog l) { - mLocalLog = l; + public LocalLog getLocalLog() { + return mLocalLog; + } + + private int getNewCmdId() { + synchronized (mLocalLog) { + return mCmdId++; + } } private void localLog(String s) { @@ -105,10 +112,12 @@ public class WifiNative { } public boolean connectToSupplicant() { + localLog(mInterfacePrefix + "connectToSupplicant"); return connectToSupplicantNative(); } public void closeSupplicantConnection() { + localLog(mInterfacePrefix + "closeSupplicantConnection"); closeSupplicantConnectionNative(); } @@ -118,16 +127,33 @@ public class WifiNative { private boolean doBooleanCommand(String command) { if (DBG) Log.d(mTAG, "doBoolean: " + command); - return doBooleanCommandNative(mInterfacePrefix + command); + int cmdId = getNewCmdId(); + localLog(cmdId + "->" + mInterfacePrefix + command); + boolean result = doBooleanCommandNative(mInterfacePrefix + command); + localLog(cmdId + "<-" + result); + return result; } private int doIntCommand(String command) { if (DBG) Log.d(mTAG, "doInt: " + command); - return doIntCommandNative(mInterfacePrefix + command); + int cmdId = getNewCmdId(); + localLog(cmdId + "->" + mInterfacePrefix + command); + int result = doIntCommandNative(mInterfacePrefix + command); + localLog(cmdId + "<-" + result); + return result; } private String doStringCommand(String command) { if (DBG) Log.d(mTAG, "doString: " + command); + int cmdId = getNewCmdId(); + localLog(cmdId + "->" + mInterfacePrefix + command); + String result = doStringCommandNative(mInterfacePrefix + command); + localLog(cmdId + "<-" + result); + return result; + } + + private String doStringCommandWithoutLogging(String command) { + if (DBG) Log.d(mTAG, "doString: " + command); return doStringCommandNative(mInterfacePrefix + command); } @@ -157,48 +183,42 @@ public class WifiNative { } public String listNetworks() { - localLog("LIST_NETWORKS"); return doStringCommand("LIST_NETWORKS"); } public int addNetwork() { - localLog("ADD_NETWORK"); return doIntCommand("ADD_NETWORK"); } public boolean setNetworkVariable(int netId, String name, String value) { if (TextUtils.isEmpty(name) || TextUtils.isEmpty(value)) return false; - localLog("SET_NETWORK " + netId + " " + name + "=" + value); return doBooleanCommand("SET_NETWORK " + netId + " " + name + " " + value); } public String getNetworkVariable(int netId, String name) { if (TextUtils.isEmpty(name)) return null; - return doStringCommand("GET_NETWORK " + netId + " " + name); + + // GET_NETWORK will likely flood the logs ... + return doStringCommandWithoutLogging("GET_NETWORK " + netId + " " + name); } public boolean removeNetwork(int netId) { - localLog("REMOVE_NETWORK " + netId); return doBooleanCommand("REMOVE_NETWORK " + netId); } public boolean enableNetwork(int netId, boolean disableOthers) { if (disableOthers) { - localLog("SELECT_NETWORK " + netId); return doBooleanCommand("SELECT_NETWORK " + netId); } else { - localLog("ENABLE_NETWORK " + netId); return doBooleanCommand("ENABLE_NETWORK " + netId); } } public boolean disableNetwork(int netId) { - localLog("DISABLE_NETWORK " + netId); return doBooleanCommand("DISABLE_NETWORK " + netId); } public boolean reconnect() { - localLog("RECONNECT"); return doBooleanCommand("RECONNECT"); } @@ -242,7 +262,7 @@ public class WifiNative { * MASK=<N> see wpa_supplicant/src/common/wpa_ctrl.h for details */ public String scanResults(int sid) { - return doStringCommand("BSS RANGE=" + sid + "- MASK=0x21987"); + return doStringCommandWithoutLogging("BSS RANGE=" + sid + "- MASK=0x21987"); } /** @@ -401,7 +421,6 @@ public class WifiNative { } public boolean saveConfig() { - localLog("SAVE_CONFIG"); return doBooleanCommand("SAVE_CONFIG"); } @@ -456,7 +475,7 @@ public class WifiNative { * FREQUENCY=0 */ public String signalPoll() { - return doStringCommand("SIGNAL_POLL"); + return doStringCommandWithoutLogging("SIGNAL_POLL"); } /** Example outout: diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index 85fbdd8..d4e98c5 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -723,7 +723,7 @@ public class WifiStateMachine extends StateMachine { setInitialState(mInitialState); - setLogRecSize(300); + setLogRecSize(2000); setLogOnlyTransitions(false); if (DBG) setDbg(true); |