Merge "Disable additional logging in WifiConfigStore/WifiNative" into klp-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
96ece97073
@@ -115,6 +115,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 = true;
|
private static final boolean DBG = true;
|
||||||
|
private static final boolean VDBG = false;
|
||||||
|
|
||||||
private static final String SUPPLICANT_CONFIG_FILE = "/data/misc/wifi/wpa_supplicant.conf";
|
private static final String SUPPLICANT_CONFIG_FILE = "/data/misc/wifi/wpa_supplicant.conf";
|
||||||
|
|
||||||
@@ -154,7 +155,7 @@ class WifiConfigStore {
|
|||||||
private static final String EOS = "eos";
|
private static final String EOS = "eos";
|
||||||
|
|
||||||
private final LocalLog mLocalLog;
|
private final LocalLog mLocalLog;
|
||||||
WpaConfigFileObserver mFileObserver;
|
private final WpaConfigFileObserver mFileObserver;
|
||||||
|
|
||||||
private WifiNative mWifiNative;
|
private WifiNative mWifiNative;
|
||||||
private final KeyStore mKeyStore = KeyStore.getInstance();
|
private final KeyStore mKeyStore = KeyStore.getInstance();
|
||||||
@@ -163,10 +164,13 @@ class WifiConfigStore {
|
|||||||
mContext = c;
|
mContext = c;
|
||||||
mWifiNative = wn;
|
mWifiNative = wn;
|
||||||
|
|
||||||
if (DBG) {
|
if (VDBG) {
|
||||||
mLocalLog = mWifiNative.getLocalLog();
|
mLocalLog = mWifiNative.getLocalLog();
|
||||||
mFileObserver = new WpaConfigFileObserver();
|
mFileObserver = new WpaConfigFileObserver();
|
||||||
mFileObserver.startWatching();
|
mFileObserver.startWatching();
|
||||||
|
} else {
|
||||||
|
mLocalLog = null;
|
||||||
|
mFileObserver = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,7 +184,7 @@ class WifiConfigStore {
|
|||||||
public void onEvent(int event, String path) {
|
public void onEvent(int event, String path) {
|
||||||
if (event == CLOSE_WRITE) {
|
if (event == CLOSE_WRITE) {
|
||||||
File file = new File(SUPPLICANT_CONFIG_FILE);
|
File file = new File(SUPPLICANT_CONFIG_FILE);
|
||||||
localLog("wpa_supplicant.conf changed; new size = " + file.length());
|
if (VDBG) localLog("wpa_supplicant.conf changed; new size = " + file.length());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -245,7 +249,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 (VDBG) 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.
|
||||||
@@ -282,7 +286,7 @@ class WifiConfigStore {
|
|||||||
* @return network update result
|
* @return network update result
|
||||||
*/
|
*/
|
||||||
NetworkUpdateResult saveNetwork(WifiConfiguration config) {
|
NetworkUpdateResult saveNetwork(WifiConfiguration config) {
|
||||||
localLog("saveNetwork", config.networkId);
|
if (VDBG) 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)) {
|
||||||
@@ -331,7 +335,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 (VDBG) localLog("forgetNetwork", netId);
|
||||||
if (mWifiNative.removeNetwork(netId)) {
|
if (mWifiNative.removeNetwork(netId)) {
|
||||||
mWifiNative.saveConfig();
|
mWifiNative.saveConfig();
|
||||||
removeConfigAndSendBroadcastIfNeeded(netId);
|
removeConfigAndSendBroadcastIfNeeded(netId);
|
||||||
@@ -352,7 +356,7 @@ class WifiConfigStore {
|
|||||||
* @return network Id
|
* @return network Id
|
||||||
*/
|
*/
|
||||||
int addOrUpdateNetwork(WifiConfiguration config) {
|
int addOrUpdateNetwork(WifiConfiguration config) {
|
||||||
localLog("addOrUpdateNetwork", config.networkId);
|
if (VDBG) 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()),
|
||||||
@@ -372,7 +376,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);
|
if (VDBG) localLog("removeNetwork", netId);
|
||||||
boolean ret = mWifiNative.removeNetwork(netId);
|
boolean ret = mWifiNative.removeNetwork(netId);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
removeConfigAndSendBroadcastIfNeeded(netId);
|
removeConfigAndSendBroadcastIfNeeded(netId);
|
||||||
@@ -407,10 +411,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);
|
if (VDBG) localLog("enableNetwork(disableOthers=true) ", netId);
|
||||||
sendConfiguredNetworksChangedBroadcast();
|
sendConfiguredNetworksChangedBroadcast();
|
||||||
} else {
|
} else {
|
||||||
localLog("enableNetwork(disableOthers=false) ", netId);
|
if (VDBG) localLog("enableNetwork(disableOthers=false) ", netId);
|
||||||
WifiConfiguration enabledNetwork = null;
|
WifiConfiguration enabledNetwork = null;
|
||||||
synchronized(mConfiguredNetworks) {
|
synchronized(mConfiguredNetworks) {
|
||||||
enabledNetwork = mConfiguredNetworks.get(netId);
|
enabledNetwork = mConfiguredNetworks.get(netId);
|
||||||
@@ -437,7 +441,7 @@ class WifiConfigStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void disableAllNetworks() {
|
void disableAllNetworks() {
|
||||||
localLog("disableAllNetworks");
|
if (VDBG) 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) {
|
||||||
@@ -470,7 +474,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);
|
if (VDBG) 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);
|
||||||
@@ -683,33 +687,33 @@ class WifiConfigStore {
|
|||||||
|
|
||||||
if (mNetworkIds.containsKey(configKey(config))) {
|
if (mNetworkIds.containsKey(configKey(config))) {
|
||||||
// That SSID is already known, just ignore this duplicate entry
|
// That SSID is already known, just ignore this duplicate entry
|
||||||
localLog("discarded duplicate network", config.networkId);
|
if (VDBG) localLog("discarded duplicate network", config.networkId);
|
||||||
} else {
|
} else {
|
||||||
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);
|
if (VDBG) localLog("loaded configured network", config.networkId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
readIpAndProxyConfigurations();
|
readIpAndProxyConfigurations();
|
||||||
sendConfiguredNetworksChangedBroadcast();
|
sendConfiguredNetworksChangedBroadcast();
|
||||||
|
|
||||||
localLog("loadConfiguredNetworks loaded " + mNetworkIds.size() + " networks");
|
if (VDBG) localLog("loadConfiguredNetworks loaded " + mNetworkIds.size() + " networks");
|
||||||
|
|
||||||
if (mNetworkIds.size() == 0) {
|
if (mNetworkIds.size() == 0) {
|
||||||
// no networks? Lets log if the wpa_supplicant.conf file contents
|
// no networks? Lets log if the wpa_supplicant.conf file contents
|
||||||
BufferedReader reader = null;
|
BufferedReader reader = null;
|
||||||
try {
|
try {
|
||||||
reader = new BufferedReader(new FileReader(SUPPLICANT_CONFIG_FILE));
|
reader = new BufferedReader(new FileReader(SUPPLICANT_CONFIG_FILE));
|
||||||
localLog("--- Begin wpa_supplicant.conf Contents ---");
|
if (VDBG) localLog("--- Begin wpa_supplicant.conf Contents ---");
|
||||||
for (String line = reader.readLine(); line != null; line = reader.readLine()) {
|
for (String line = reader.readLine(); line != null; line = reader.readLine()) {
|
||||||
localLog(line);
|
if (VDBG) localLog(line);
|
||||||
}
|
}
|
||||||
localLog("--- End wpa_supplicant.conf Contents ---");
|
if (VDBG) localLog("--- End wpa_supplicant.conf Contents ---");
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
localLog("Could not open " + SUPPLICANT_CONFIG_FILE + ", " + e);
|
if (VDBG) localLog("Could not open " + SUPPLICANT_CONFIG_FILE + ", " + e);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
localLog("Could not read " + SUPPLICANT_CONFIG_FILE + ", " + e);
|
if (VDBG) localLog("Could not read " + SUPPLICANT_CONFIG_FILE + ", " + e);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
if (reader != null) {
|
if (reader != null) {
|
||||||
@@ -1050,7 +1054,7 @@ class WifiConfigStore {
|
|||||||
* refer to an existing configuration.
|
* refer to an existing configuration.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
localLog("addOrUpdateNetworkNative " + config.getPrintableSsid());
|
if (VDBG) localLog("addOrUpdateNetworkNative " + config.getPrintableSsid());
|
||||||
|
|
||||||
int netId = config.networkId;
|
int netId = config.networkId;
|
||||||
boolean newNetwork = false;
|
boolean newNetwork = false;
|
||||||
|
|||||||
@@ -117,12 +117,12 @@ public class WifiNative {
|
|||||||
|
|
||||||
public boolean connectToSupplicant() {
|
public boolean connectToSupplicant() {
|
||||||
// No synchronization necessary .. it is implemented in WifiMonitor
|
// No synchronization necessary .. it is implemented in WifiMonitor
|
||||||
localLog(mInterfacePrefix + "connectToSupplicant");
|
if (VDBG) localLog(mInterfacePrefix + "connectToSupplicant");
|
||||||
return connectToSupplicantNative();
|
return connectToSupplicantNative();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void closeSupplicantConnection() {
|
public void closeSupplicantConnection() {
|
||||||
localLog(mInterfacePrefix + "closeSupplicantConnection");
|
if (VDBG) localLog(mInterfacePrefix + "closeSupplicantConnection");
|
||||||
closeSupplicantConnectionNative();
|
closeSupplicantConnectionNative();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,9 +135,9 @@ public class WifiNative {
|
|||||||
if (DBG) Log.d(mTAG, "doBoolean: " + command);
|
if (DBG) Log.d(mTAG, "doBoolean: " + command);
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
int cmdId = getNewCmdIdLocked();
|
int cmdId = getNewCmdIdLocked();
|
||||||
localLog(cmdId + "->" + mInterfacePrefix + command);
|
if (VDBG) localLog(cmdId + "->" + mInterfacePrefix + command);
|
||||||
boolean result = doBooleanCommandNative(mInterfacePrefix + command);
|
boolean result = doBooleanCommandNative(mInterfacePrefix + command);
|
||||||
localLog(cmdId + "<-" + result);
|
if (VDBG) localLog(cmdId + "<-" + result);
|
||||||
if (DBG) Log.d(mTAG, " returned " + result);
|
if (DBG) Log.d(mTAG, " returned " + result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -147,9 +147,9 @@ public class WifiNative {
|
|||||||
if (DBG) Log.d(mTAG, "doInt: " + command);
|
if (DBG) Log.d(mTAG, "doInt: " + command);
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
int cmdId = getNewCmdIdLocked();
|
int cmdId = getNewCmdIdLocked();
|
||||||
localLog(cmdId + "->" + mInterfacePrefix + command);
|
if (VDBG) localLog(cmdId + "->" + mInterfacePrefix + command);
|
||||||
int result = doIntCommandNative(mInterfacePrefix + command);
|
int result = doIntCommandNative(mInterfacePrefix + command);
|
||||||
localLog(cmdId + "<-" + result);
|
if (VDBG) localLog(cmdId + "<-" + result);
|
||||||
if (DBG) Log.d(mTAG, " returned " + result);
|
if (DBG) Log.d(mTAG, " returned " + result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -159,9 +159,9 @@ public class WifiNative {
|
|||||||
if (DBG) Log.d(mTAG, "doString: " + command);
|
if (DBG) Log.d(mTAG, "doString: " + command);
|
||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
int cmdId = getNewCmdIdLocked();
|
int cmdId = getNewCmdIdLocked();
|
||||||
localLog(cmdId + "->" + mInterfacePrefix + command);
|
if (VDBG) localLog(cmdId + "->" + mInterfacePrefix + command);
|
||||||
String result = doStringCommandNative(mInterfacePrefix + command);
|
String result = doStringCommandNative(mInterfacePrefix + command);
|
||||||
localLog(cmdId + "<-" + result);
|
if (VDBG) localLog(cmdId + "<-" + result);
|
||||||
if (DBG) Log.d(mTAG, " returned " + result);
|
if (DBG) Log.d(mTAG, " returned " + result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user