diff options
author | Irfan Sheriff <isheriff@google.com> | 2011-10-04 11:01:50 -0700 |
---|---|---|
committer | Irfan Sheriff <isheriff@google.com> | 2011-10-04 12:01:31 -0700 |
commit | 7f8a12c75cf2b376fce58fc22b5ecb1b64acf110 (patch) | |
tree | 36d5b96e2d9dafecc39c10759999ddc517fae937 | |
parent | b9e7e132eacb4d1e1719135a366b767018fa1373 (diff) | |
download | frameworks_base-7f8a12c75cf2b376fce58fc22b5ecb1b64acf110.zip frameworks_base-7f8a12c75cf2b376fce58fc22b5ecb1b64acf110.tar.gz frameworks_base-7f8a12c75cf2b376fce58fc22b5ecb1b64acf110.tar.bz2 |
Reduce/Fix system logging
Bug: 5410239
Change-Id: I2f91dfde0b701e8905a1235696591b3154693c7c
-rw-r--r-- | core/java/android/net/DhcpStateMachine.java | 8 | ||||
-rw-r--r-- | core/java/android/net/DnsPinger.java | 36 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiConfigStore.java | 95 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiStateMachine.java | 255 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiWatchdogStateMachine.java | 106 |
5 files changed, 263 insertions, 237 deletions
diff --git a/core/java/android/net/DhcpStateMachine.java b/core/java/android/net/DhcpStateMachine.java index 79c9395..fc6a44a 100644 --- a/core/java/android/net/DhcpStateMachine.java +++ b/core/java/android/net/DhcpStateMachine.java @@ -336,17 +336,17 @@ public class DhcpStateMachine extends StateMachine { DhcpInfoInternal dhcpInfoInternal = new DhcpInfoInternal(); if (dhcpAction == DhcpAction.START) { - Log.d(TAG, "DHCP request on " + mInterfaceName); + if (DBG) Log.d(TAG, "DHCP request on " + mInterfaceName); success = NetworkUtils.runDhcp(mInterfaceName, dhcpInfoInternal); mDhcpInfo = dhcpInfoInternal; } else if (dhcpAction == DhcpAction.RENEW) { - Log.d(TAG, "DHCP renewal on " + mInterfaceName); + if (DBG) Log.d(TAG, "DHCP renewal on " + mInterfaceName); success = NetworkUtils.runDhcpRenew(mInterfaceName, dhcpInfoInternal); dhcpInfoInternal.updateFromDhcpRequest(mDhcpInfo); } if (success) { - Log.d(TAG, "DHCP succeeded on " + mInterfaceName); + if (DBG) Log.d(TAG, "DHCP succeeded on " + mInterfaceName); long leaseDuration = dhcpInfoInternal.leaseDuration; //int to long conversion //Sanity check for renewal @@ -366,7 +366,7 @@ public class DhcpStateMachine extends StateMachine { mController.obtainMessage(CMD_POST_DHCP_ACTION, DHCP_SUCCESS, 0, dhcpInfoInternal) .sendToTarget(); } else { - Log.d(TAG, "DHCP failed on " + mInterfaceName + ": " + + Log.e(TAG, "DHCP failed on " + mInterfaceName + ": " + NetworkUtils.getDhcpError()); NetworkUtils.stopDhcp(mInterfaceName); mController.obtainMessage(CMD_POST_DHCP_ACTION, DHCP_FAILURE, 0) diff --git a/core/java/android/net/DnsPinger.java b/core/java/android/net/DnsPinger.java index 3291e6b..11acabe 100644 --- a/core/java/android/net/DnsPinger.java +++ b/core/java/android/net/DnsPinger.java @@ -22,7 +22,7 @@ import android.os.Looper; import android.os.Message; import android.os.SystemClock; import android.provider.Settings; -import android.util.Slog; +import android.util.Log; import com.android.internal.util.Protocol; @@ -51,7 +51,7 @@ import java.util.concurrent.atomic.AtomicInteger; * @hide */ public final class DnsPinger extends Handler { - private static final boolean V = true; + private static final boolean DBG = false; private static final int RECEIVE_POLL_INTERVAL_MS = 200; private static final int DNS_PORT = 53; @@ -154,7 +154,7 @@ public final class DnsPinger extends Handler { newActivePing.socket.setNetworkInterface(NetworkInterface.getByName( getCurrentLinkProperties().getInterfaceName())); } catch (Exception e) { - Slog.w(TAG,"sendDnsPing::Error binding to socket", e); + loge("sendDnsPing::Error binding to socket " + e); } newActivePing.packetId = (short) sRandom.nextInt(); @@ -165,8 +165,8 @@ public final class DnsPinger extends Handler { // Send the DNS query DatagramPacket packet = new DatagramPacket(buf, buf.length, dnsAddress, DNS_PORT); - if (V) { - Slog.v(TAG, "Sending a ping " + newActivePing.internalId + + if (DBG) { + log("Sending a ping " + newActivePing.internalId + " to " + dnsAddress.getHostAddress() + " with packetId " + newActivePing.packetId + "."); } @@ -196,15 +196,15 @@ public final class DnsPinger extends Handler { curPing.result = (int) (SystemClock.elapsedRealtime() - curPing.start); } else { - if (V) { - Slog.v(TAG, "response ID didn't match, ignoring packet"); + if (DBG) { + log("response ID didn't match, ignoring packet"); } } } catch (SocketTimeoutException e) { // A timeout here doesn't mean anything - squelsh this exception } catch (Exception e) { - if (V) { - Slog.v(TAG, "DnsPinger.pingDns got socket exception: ", e); + if (DBG) { + log("DnsPinger.pingDns got socket exception: " + e); } curPing.result = SOCKET_EXCEPTION; } @@ -244,13 +244,13 @@ public final class DnsPinger extends Handler { public List<InetAddress> getDnsList() { LinkProperties curLinkProps = getCurrentLinkProperties(); if (curLinkProps == null) { - Slog.e(TAG, "getCurLinkProperties:: LP for type" + mConnectionType + " is null!"); + loge("getCurLinkProperties:: LP for type" + mConnectionType + " is null!"); return mDefaultDns; } Collection<InetAddress> dnses = curLinkProps.getDnses(); if (dnses == null || dnses.size() == 0) { - Slog.v(TAG, "getDns::LinkProps has null dns - returning default"); + loge("getDns::LinkProps has null dns - returning default"); return mDefaultDns; } @@ -277,8 +277,8 @@ public final class DnsPinger extends Handler { } private void sendResponse(int internalId, int externalId, int responseVal) { - if(V) { - Slog.d(TAG, "Responding to packet " + internalId + + if(DBG) { + log("Responding to packet " + internalId + " externalId " + externalId + " and val " + responseVal); } @@ -304,7 +304,7 @@ public final class DnsPinger extends Handler { try { return NetworkUtils.numericToInetAddress(dns); } catch (IllegalArgumentException e) { - Slog.w(TAG, "getDefaultDns::malformed default dns address"); + loge("getDefaultDns::malformed default dns address"); return null; } } @@ -323,4 +323,12 @@ public final class DnsPinger extends Handler { 0, 1, // QTYPE, set to 1 = A (host address) 0, 1 // QCLASS, set to 1 = IN (internet) }; + + private void log(String s) { + Log.d(TAG, s); + } + + private void loge(String s) { + Log.e(TAG, s); + } } diff --git a/wifi/java/android/net/wifi/WifiConfigStore.java b/wifi/java/android/net/wifi/WifiConfigStore.java index 18d6eaa..568a485 100644 --- a/wifi/java/android/net/wifi/WifiConfigStore.java +++ b/wifi/java/android/net/wifi/WifiConfigStore.java @@ -100,6 +100,7 @@ class WifiConfigStore { private static Context sContext; private static final String TAG = "WifiConfigStore"; + private static final boolean DBG = false; /* configured networks with network id as the key */ private static HashMap<Integer, WifiConfiguration> sConfiguredNetworks = @@ -140,7 +141,7 @@ class WifiConfigStore { * and enable all stored networks in supplicant. */ static void initialize(Context context) { - Log.d(TAG, "Loading config and enabling all networks"); + if (DBG) log("Loading config and enabling all networks"); sContext = context; loadConfiguredNetworks(); enableAllNetworks(); @@ -173,7 +174,7 @@ class WifiConfigStore { networkEnabledStateChanged = true; config.status = Status.ENABLED; } else { - Log.e(TAG, "Enable network failed on " + config.networkId); + loge("Enable network failed on " + config.networkId); } } } @@ -204,7 +205,7 @@ class WifiConfigStore { if (netId != INVALID_NETWORK_ID) { selectNetwork(netId); } else { - Log.e(TAG, "Failed to update network " + config); + loge("Failed to update network " + config); } return netId; } @@ -290,7 +291,7 @@ class WifiConfigStore { writeIpAndProxyConfigurations(); sendConfiguredNetworksChangedBroadcast(); } else { - Log.e(TAG, "Failed to remove network " + netId); + loge("Failed to remove network " + netId); } } @@ -404,7 +405,7 @@ class WifiConfigStore { markAllNetworksDisabled(); result.status = WpsResult.Status.SUCCESS; } else { - Log.e(TAG, "Failed to start WPS pin method configuration"); + loge("Failed to start WPS pin method configuration"); result.status = WpsResult.Status.FAILURE; } return result; @@ -423,7 +424,7 @@ class WifiConfigStore { markAllNetworksDisabled(); result.status = WpsResult.Status.SUCCESS; } else { - Log.e(TAG, "Failed to start WPS pin method configuration"); + loge("Failed to start WPS pin method configuration"); result.status = WpsResult.Status.FAILURE; } return result; @@ -439,7 +440,7 @@ class WifiConfigStore { markAllNetworksDisabled(); result.status = WpsResult.Status.SUCCESS; } else { - Log.e(TAG, "Failed to start WPS push button configuration"); + loge("Failed to start WPS push button configuration"); result.status = WpsResult.Status.FAILURE; } return result; @@ -680,7 +681,7 @@ class WifiConfigStore { /* Ignore */ break; default: - Log.e(TAG, "Ignore invalid ip assignment while writing"); + loge("Ignore invalid ip assignment while writing"); break; } @@ -707,7 +708,7 @@ class WifiConfigStore { /* Ignore */ break; default: - Log.e(TAG, "Ignore invalid proxy settings while writing"); + loge("Ignore invalid proxy settings while writing"); break; } if (writeToFile) { @@ -715,14 +716,14 @@ class WifiConfigStore { out.writeInt(configKey(config)); } } catch (NullPointerException e) { - Log.e(TAG, "Failure in writing " + config.linkProperties + e); + loge("Failure in writing " + config.linkProperties + e); } out.writeUTF(EOS); } } } catch (IOException e) { - Log.e(TAG, "Error writing data file"); + loge("Error writing data file"); } finally { if (out != null) { try { @@ -741,7 +742,7 @@ class WifiConfigStore { int version = in.readInt(); if (version != 2 && version != 1) { - Log.e(TAG, "Bad version on IP configuration file, ignore read"); + loge("Bad version on IP configuration file, ignore read"); return; } @@ -797,10 +798,10 @@ class WifiConfigStore { } else if (key.equals(EOS)) { break; } else { - Log.e(TAG, "Ignore unknown key " + key + "while reading"); + loge("Ignore unknown key " + key + "while reading"); } } catch (IllegalArgumentException e) { - Log.e(TAG, "Ignore invalid address while reading" + e); + loge("Ignore invalid address while reading" + e); } } while (true); @@ -810,7 +811,7 @@ class WifiConfigStore { sNetworkIds.get(id)); if (config == null) { - Log.e(TAG, "configuration found for missing network, ignored"); + loge("configuration found for missing network, ignored"); } else { config.linkProperties = linkProperties; switch (ipAssignment) { @@ -822,7 +823,7 @@ class WifiConfigStore { //Ignore break; default: - Log.e(TAG, "Ignore invalid ip assignment while reading"); + loge("Ignore invalid ip assignment while reading"); break; } @@ -840,18 +841,18 @@ class WifiConfigStore { //Ignore break; default: - Log.e(TAG, "Ignore invalid proxy settings while reading"); + loge("Ignore invalid proxy settings while reading"); break; } } } } else { - Log.e(TAG, "Missing id while parsing configuration"); + loge("Missing id while parsing configuration"); } } } catch (EOFException ignore) { } catch (IOException e) { - Log.e(TAG, "Error parsing configuration" + e); + loge("Error parsing configuration" + e); } finally { if (in != null) { try { @@ -878,7 +879,7 @@ class WifiConfigStore { newNetwork = true; netId = WifiNative.addNetworkCommand(); if (netId < 0) { - Log.e(TAG, "Failed to add a network!"); + loge("Failed to add a network!"); return new NetworkUpdateResult(INVALID_NETWORK_ID); } } @@ -893,7 +894,7 @@ class WifiConfigStore { netId, WifiConfiguration.ssidVarName, config.SSID)) { - Log.d(TAG, "failed to set SSID: "+config.SSID); + loge("failed to set SSID: "+config.SSID); break setVariables; } @@ -902,7 +903,7 @@ class WifiConfigStore { netId, WifiConfiguration.bssidVarName, config.BSSID)) { - Log.d(TAG, "failed to set BSSID: "+config.BSSID); + loge("failed to set BSSID: "+config.BSSID); break setVariables; } @@ -913,7 +914,7 @@ class WifiConfigStore { netId, WifiConfiguration.KeyMgmt.varName, allowedKeyManagementString)) { - Log.d(TAG, "failed to set key_mgmt: "+ + loge("failed to set key_mgmt: "+ allowedKeyManagementString); break setVariables; } @@ -925,7 +926,7 @@ class WifiConfigStore { netId, WifiConfiguration.Protocol.varName, allowedProtocolsString)) { - Log.d(TAG, "failed to set proto: "+ + loge("failed to set proto: "+ allowedProtocolsString); break setVariables; } @@ -937,7 +938,7 @@ class WifiConfigStore { netId, WifiConfiguration.AuthAlgorithm.varName, allowedAuthAlgorithmsString)) { - Log.d(TAG, "failed to set auth_alg: "+ + loge("failed to set auth_alg: "+ allowedAuthAlgorithmsString); break setVariables; } @@ -950,7 +951,7 @@ class WifiConfigStore { netId, WifiConfiguration.PairwiseCipher.varName, allowedPairwiseCiphersString)) { - Log.d(TAG, "failed to set pairwise: "+ + loge("failed to set pairwise: "+ allowedPairwiseCiphersString); break setVariables; } @@ -962,7 +963,7 @@ class WifiConfigStore { netId, WifiConfiguration.GroupCipher.varName, allowedGroupCiphersString)) { - Log.d(TAG, "failed to set group: "+ + loge("failed to set group: "+ allowedGroupCiphersString); break setVariables; } @@ -974,7 +975,7 @@ class WifiConfigStore { netId, WifiConfiguration.pskVarName, config.preSharedKey)) { - Log.d(TAG, "failed to set psk"); + loge("failed to set psk"); break setVariables; } @@ -988,9 +989,7 @@ class WifiConfigStore { netId, WifiConfiguration.wepKeyVarNames[i], config.wepKeys[i])) { - Log.d(TAG, - "failed to set wep_key"+i+": " + - config.wepKeys[i]); + loge("failed to set wep_key" + i + ": " + config.wepKeys[i]); break setVariables; } hasSetKey = true; @@ -1003,9 +1002,7 @@ class WifiConfigStore { netId, WifiConfiguration.wepTxKeyIdxVarName, Integer.toString(config.wepTxKeyIndex))) { - Log.d(TAG, - "failed to set wep_tx_keyidx: "+ - config.wepTxKeyIndex); + loge("failed to set wep_tx_keyidx: " + config.wepTxKeyIndex); break setVariables; } } @@ -1014,7 +1011,7 @@ class WifiConfigStore { netId, WifiConfiguration.priorityVarName, Integer.toString(config.priority))) { - Log.d(TAG, config.SSID + ": failed to set priority: " + loge(config.SSID + ": failed to set priority: " +config.priority); break setVariables; } @@ -1023,7 +1020,7 @@ class WifiConfigStore { netId, WifiConfiguration.hiddenSSIDVarName, Integer.toString(config.hiddenSSID ? 1 : 0))) { - Log.d(TAG, config.SSID + ": failed to set hiddenSSID: "+ + loge(config.SSID + ": failed to set hiddenSSID: "+ config.hiddenSSID); break setVariables; } @@ -1040,7 +1037,7 @@ class WifiConfigStore { netId, varName, value)) { - Log.d(TAG, config.SSID + ": failed to set " + varName + + loge(config.SSID + ": failed to set " + varName + ": " + value); break setVariables; } @@ -1052,9 +1049,7 @@ class WifiConfigStore { if (updateFailed) { if (newNetwork) { WifiNative.removeNetworkCommand(netId); - Log.d(TAG, - "Failed to set a network variable, removed network: " - + netId); + loge("Failed to set a network variable, removed network: " + netId); } return new NetworkUpdateResult(INVALID_NETWORK_ID); } @@ -1130,7 +1125,7 @@ class WifiConfigStore { /* Ignore */ break; default: - Log.e(TAG, "Ignore invalid ip assignment during write"); + loge("Ignore invalid ip assignment during write"); break; } @@ -1154,7 +1149,7 @@ class WifiConfigStore { /* Ignore */ break; default: - Log.e(TAG, "Ignore invalid proxy configuration during write"); + loge("Ignore invalid proxy configuration during write"); break; } @@ -1163,7 +1158,7 @@ class WifiConfigStore { } else { currentConfig.ipAssignment = newConfig.ipAssignment; addIpSettingsFromConfig(linkProperties, newConfig); - Log.d(TAG, "IP config changed SSID = " + currentConfig.SSID + " linkProperties: " + + log("IP config changed SSID = " + currentConfig.SSID + " linkProperties: " + linkProperties.toString()); } @@ -1173,9 +1168,9 @@ class WifiConfigStore { } else { currentConfig.proxySettings = newConfig.proxySettings; linkProperties.setHttpProxy(newConfig.linkProperties.getHttpProxy()); - Log.d(TAG, "proxy changed SSID = " + currentConfig.SSID); + log("proxy changed SSID = " + currentConfig.SSID); if (linkProperties.getHttpProxy() != null) { - Log.d(TAG, " proxyProperties: " + linkProperties.getHttpProxy().toString()); + log(" proxyProperties: " + linkProperties.getHttpProxy().toString()); } } @@ -1394,7 +1389,7 @@ class WifiConfigStore { // if we ever get here, we should probably add the // value to WifiConfiguration to reflect that it's // supported by the WPA supplicant - Log.w(TAG, "Failed to look-up a string: " + string); + loge("Failed to look-up a string: " + string); return -1; } @@ -1431,4 +1426,12 @@ class WifiConfigStore { public static String getConfigFile() { return ipConfigFile; } + + private static void loge(String s) { + Log.e(TAG, s); + } + + private static void log(String s) { + Log.d(TAG, s); + } } diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java index d1522fb..5ca7aff 100644 --- a/wifi/java/android/net/wifi/WifiStateMachine.java +++ b/wifi/java/android/net/wifi/WifiStateMachine.java @@ -75,7 +75,6 @@ import android.provider.Settings; import android.util.EventLog; import android.util.Log; import android.util.LruCache; -import android.util.Slog; import com.android.internal.app.IBatteryStats; import com.android.internal.util.AsyncChannel; @@ -1104,12 +1103,12 @@ public class WifiStateMachine extends StateMachine { mNwService.setInterfaceConfig(intf, ifcg); } } catch (Exception e) { - Log.e(TAG, "Error configuring interface " + intf + ", :" + e); + loge("Error configuring interface " + intf + ", :" + e); return false; } if(mCm.tether(intf) != ConnectivityManager.TETHER_ERROR_NO_ERROR) { - Log.e(TAG, "Error tethering on " + intf); + loge("Error tethering on " + intf); return false; } return true; @@ -1135,11 +1134,11 @@ public class WifiStateMachine extends StateMachine { mNwService.setInterfaceConfig(mInterfaceName, ifcg); } } catch (Exception e) { - Log.e(TAG, "Error resetting interface " + mInterfaceName + ", :" + e); + loge("Error resetting interface " + mInterfaceName + ", :" + e); } if (mCm.untether(mInterfaceName) != ConnectivityManager.TETHER_ERROR_NO_ERROR) { - Log.e(TAG, "Untether initiate failed!"); + loge("Untether initiate failed!"); } } @@ -1175,12 +1174,12 @@ public class WifiStateMachine extends StateMachine { mBatteryStats.noteWifiOff(); } } catch (RemoteException e) { - Log.e(TAG, "Failed to note battery stats in wifi"); + loge("Failed to note battery stats in wifi"); } mWifiState.set(wifiState); - if (DBG) Log.d(TAG, "setWifiState: " + syncGetWifiStateByName()); + if (DBG) log("setWifiState: " + syncGetWifiStateByName()); final Intent intent = new Intent(WifiManager.WIFI_STATE_CHANGED_ACTION); intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); @@ -1199,13 +1198,13 @@ public class WifiStateMachine extends StateMachine { mBatteryStats.noteWifiOff(); } } catch (RemoteException e) { - Log.d(TAG, "Failed to note battery stats in wifi"); + loge("Failed to note battery stats in wifi"); } // Update state mWifiApState.set(wifiApState); - if (DBG) Log.d(TAG, "setWifiApState: " + syncGetWifiApStateByName()); + if (DBG) log("setWifiApState: " + syncGetWifiApStateByName()); final Intent intent = new Intent(WifiManager.WIFI_AP_STATE_CHANGED_ACTION); intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); @@ -1291,7 +1290,7 @@ public class WifiStateMachine extends StateMachine { } } } else { - Log.w(TAG, "Misformatted scan result text with " + + loge("Misformatted scan result text with " + result.length + " fields: " + line); } } @@ -1419,15 +1418,15 @@ public class WifiStateMachine extends StateMachine { private void setHighPerfModeEnabledNative(boolean enable) { if(!WifiNative.setSuspendOptimizationsCommand(!enable)) { - Log.e(TAG, "set suspend optimizations failed!"); + loge("set suspend optimizations failed!"); } if (enable) { if (!WifiNative.setPowerModeCommand(POWER_MODE_ACTIVE)) { - Log.e(TAG, "set power mode active failed!"); + loge("set power mode active failed!"); } } else { if (!WifiNative.setPowerModeCommand(POWER_MODE_AUTO)) { - Log.e(TAG, "set power mode auto failed!"); + loge("set power mode auto failed!"); } } } @@ -1442,7 +1441,10 @@ public class WifiStateMachine extends StateMachine { mLinkProperties.setHttpProxy(WifiConfigStore.getProxyProperties(mLastNetworkId)); } mLinkProperties.setInterfaceName(mInterfaceName); - Log.d(TAG, "netId=" + mLastNetworkId + " Link configured: " + mLinkProperties.toString()); + if (DBG) { + log("netId=" + mLastNetworkId + " Link configured: " + + mLinkProperties.toString()); + } } private int getMaxDhcpRetries() { @@ -1503,8 +1505,11 @@ public class WifiStateMachine extends StateMachine { * @param state the new @{code DetailedState} */ private void setNetworkDetailedState(NetworkInfo.DetailedState state) { - Log.d(TAG, "setDetailed state, old =" - + mNetworkInfo.getDetailedState() + " and new state=" + state); + if (DBG) { + log("setDetailed state, old =" + + mNetworkInfo.getDetailedState() + " and new state=" + state); + } + if (state != mNetworkInfo.getDetailedState()) { mNetworkInfo.setDetailedState(state, null, null); } @@ -1547,7 +1552,7 @@ public class WifiStateMachine extends StateMachine { * using the interface, stopping DHCP & disabling interface */ private void handleNetworkDisconnect() { - Log.d(TAG, "Stopping DHCP and clearing IP"); + if (DBG) log("Stopping DHCP and clearing IP"); /* * stop DHCP @@ -1562,7 +1567,7 @@ public class WifiStateMachine extends StateMachine { mNwService.clearInterfaceAddresses(mInterfaceName); mNwService.disableIpv6(mInterfaceName); } catch (Exception e) { - Log.e(TAG, "Failed to clear addresses or disable ipv6" + e); + loge("Failed to clear addresses or disable ipv6" + e); } /* Reset data structures */ @@ -1647,8 +1652,10 @@ public class WifiStateMachine extends StateMachine { linkProperties.setHttpProxy(WifiConfigStore.getProxyProperties(mLastNetworkId)); linkProperties.setInterfaceName(mInterfaceName); if (!linkProperties.equals(mLinkProperties)) { - Log.d(TAG, "Link configuration changed for netId: " + mLastNetworkId - + " old: " + mLinkProperties + "new: " + linkProperties); + if (DBG) { + log("Link configuration changed for netId: " + mLastNetworkId + + " old: " + mLinkProperties + "new: " + linkProperties); + } mLinkProperties = linkProperties; sendLinkConfigurationChangedBroadcast(); } @@ -1660,7 +1667,7 @@ public class WifiStateMachine extends StateMachine { } private void handleFailedIpConfiguration() { - Log.e(TAG, "IP configuration failed"); + loge("IP configuration failed"); mWifiInfo.setInetAddress(null); /** @@ -1668,7 +1675,7 @@ public class WifiStateMachine extends StateMachine { * to a given network, disable the network */ if (++mReconnectCount > getMaxDhcpRetries()) { - Log.e(TAG, "Failed " + + loge("Failed " + mReconnectCount + " times, Disabling " + mLastNetworkId); WifiConfigStore.disableNetwork(mLastNetworkId, WifiConfiguration.DISABLED_DHCP_FAILURE); @@ -1697,12 +1704,12 @@ public class WifiStateMachine extends StateMachine { try { mNwService.startAccessPoint(config, mInterfaceName, SOFTAP_IFACE); } catch (Exception e) { - Log.e(TAG, "Exception in softap start " + e); + loge("Exception in softap start " + e); try { mNwService.stopAccessPoint(mInterfaceName); mNwService.startAccessPoint(config, mInterfaceName, SOFTAP_IFACE); } catch (Exception e1) { - Log.e(TAG, "Exception in softap re-start " + e1); + loge("Exception in softap re-start " + e1); return false; } } @@ -1716,17 +1723,17 @@ public class WifiStateMachine extends StateMachine { class DefaultState extends State { @Override public boolean processMessage(Message message) { - if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); + if (DBG) log(getName() + message.toString() + "\n"); switch (message.what) { case AsyncChannel.CMD_CHANNEL_HALF_CONNECTED: if (message.arg1 == AsyncChannel.STATUS_SUCCESSFUL) { mWifiP2pChannel.sendMessage(AsyncChannel.CMD_CHANNEL_FULL_CONNECTION); } else { - Log.e(TAG, "WifiP2pService connection failure, error=" + message.arg1); + loge("WifiP2pService connection failure, error=" + message.arg1); } break; case AsyncChannel.CMD_CHANNEL_DISCONNECTED: - Log.e(TAG, "WifiP2pService channel lost, message.arg1 =" + message.arg1); + loge("WifiP2pService channel lost, message.arg1 =" + message.arg1); //TODO: Re-establish connection to state machine after a delay //mWifiP2pChannel.connect(mContext, getHandler(), mWifiP2pManager.getMessenger()); break; @@ -1812,7 +1819,7 @@ public class WifiStateMachine extends StateMachine { deferMessage(message); break; default: - Log.e(TAG, "Error! unhandled message" + message); + loge("Error! unhandled message" + message); break; } return HANDLED; @@ -1823,7 +1830,7 @@ public class WifiStateMachine extends StateMachine { @Override //TODO: could move logging into a common class public void enter() { - if (DBG) Log.d(TAG, getName() + "\n"); + if (DBG) log(getName() + "\n"); // [31-8] Reserved for future use // [7 - 0] HSM state change // 50021 wifi_state_changed (custom|1|5) @@ -1853,9 +1860,9 @@ public class WifiStateMachine extends StateMachine { try { mNwService.disableIpv6(mInterfaceName); } catch (RemoteException re) { - Log.e(TAG, "Failed to disable IPv6: " + re); + loge("Failed to disable IPv6: " + re); } catch (IllegalStateException e) { - Log.e(TAG, "Failed to disable IPv6: " + e); + loge("Failed to disable IPv6: " + e); } } } @@ -1863,7 +1870,7 @@ public class WifiStateMachine extends StateMachine { class DriverLoadingState extends State { @Override public void enter() { - if (DBG) Log.d(TAG, getName() + "\n"); + if (DBG) log(getName() + "\n"); EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName()); final Message message = new Message(); @@ -1885,10 +1892,10 @@ public class WifiStateMachine extends StateMachine { } if(WifiNative.loadDriver()) { - Log.d(TAG, "Driver load successful"); + if (DBG) log("Driver load successful"); sendMessage(CMD_LOAD_DRIVER_SUCCESS); } else { - Log.e(TAG, "Failed to load driver!"); + loge("Failed to load driver!"); switch(message.arg1) { case WIFI_STATE_ENABLING: setWifiState(WIFI_STATE_UNKNOWN); @@ -1906,7 +1913,7 @@ public class WifiStateMachine extends StateMachine { @Override public boolean processMessage(Message message) { - if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); + if (DBG) log(getName() + message.toString() + "\n"); switch (message.what) { case CMD_LOAD_DRIVER_SUCCESS: transitionTo(mDriverLoadedState); @@ -1942,12 +1949,12 @@ public class WifiStateMachine extends StateMachine { class DriverLoadedState extends State { @Override public void enter() { - if (DBG) Log.d(TAG, getName() + "\n"); + if (DBG) log(getName() + "\n"); EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName()); } @Override public boolean processMessage(Message message) { - if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); + if (DBG) log(getName() + message.toString() + "\n"); switch(message.what) { case CMD_UNLOAD_DRIVER: transitionTo(mDriverUnloadingState); @@ -1956,7 +1963,7 @@ public class WifiStateMachine extends StateMachine { try { mNwService.wifiFirmwareReload(mInterfaceName, "STA"); } catch (Exception e) { - Log.e(TAG, "Failed to reload STA firmware " + e); + loge("Failed to reload STA firmware " + e); // continue } try { @@ -1967,17 +1974,17 @@ public class WifiStateMachine extends StateMachine { //Set privacy extensions mNwService.setInterfaceIpv6PrivacyExtensions(mInterfaceName, true); } catch (RemoteException re) { - if (DBG) Log.w(TAG, "Unable to change interface settings: " + re); + loge("Unable to change interface settings: " + re); } catch (IllegalStateException ie) { - if (DBG) Log.w(TAG, "Unable to change interface settings: " + ie); + loge("Unable to change interface settings: " + ie); } if(WifiNative.startSupplicant()) { - Log.d(TAG, "Supplicant start successful"); + if (DBG) log("Supplicant start successful"); mWifiMonitor.startMonitoring(); transitionTo(mSupplicantStartingState); } else { - Log.e(TAG, "Failed to start supplicant!"); + loge("Failed to start supplicant!"); sendMessage(obtainMessage(CMD_UNLOAD_DRIVER, WIFI_STATE_UNKNOWN, 0)); } break; @@ -1995,17 +2002,17 @@ public class WifiStateMachine extends StateMachine { class DriverUnloadingState extends State { @Override public void enter() { - if (DBG) Log.d(TAG, getName() + "\n"); + if (DBG) log(getName() + "\n"); EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName()); final Message message = new Message(); message.copyFrom(getCurrentMessage()); new Thread(new Runnable() { public void run() { - if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); + if (DBG) log(getName() + message.toString() + "\n"); mWakeLock.acquire(); if(WifiNative.unloadDriver()) { - Log.d(TAG, "Driver unload successful"); + if (DBG) log("Driver unload successful"); sendMessage(CMD_UNLOAD_DRIVER_SUCCESS); switch(message.arg1) { @@ -2019,7 +2026,7 @@ public class WifiStateMachine extends StateMachine { break; } } else { - Log.e(TAG, "Failed to unload driver!"); + loge("Failed to unload driver!"); sendMessage(CMD_UNLOAD_DRIVER_FAILURE); switch(message.arg1) { @@ -2040,7 +2047,7 @@ public class WifiStateMachine extends StateMachine { @Override public boolean processMessage(Message message) { - if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); + if (DBG) log(getName() + message.toString() + "\n"); switch (message.what) { case CMD_UNLOAD_DRIVER_SUCCESS: transitionTo(mDriverUnloadedState); @@ -2076,12 +2083,12 @@ public class WifiStateMachine extends StateMachine { class DriverUnloadedState extends State { @Override public void enter() { - if (DBG) Log.d(TAG, getName() + "\n"); + if (DBG) log(getName() + "\n"); EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName()); } @Override public boolean processMessage(Message message) { - if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); + if (DBG) log(getName() + message.toString() + "\n"); switch (message.what) { case CMD_LOAD_DRIVER: mWifiP2pChannel.sendMessage(WIFI_ENABLE_PENDING); @@ -2101,12 +2108,12 @@ public class WifiStateMachine extends StateMachine { class DriverFailedState extends State { @Override public void enter() { - Log.e(TAG, getName() + "\n"); + loge(getName() + "\n"); EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName()); } @Override public boolean processMessage(Message message) { - if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); + if (DBG) log(getName() + message.toString() + "\n"); return NOT_HANDLED; } } @@ -2115,15 +2122,15 @@ public class WifiStateMachine extends StateMachine { class SupplicantStartingState extends State { @Override public void enter() { - if (DBG) Log.d(TAG, getName() + "\n"); + if (DBG) log(getName() + "\n"); EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName()); } @Override public boolean processMessage(Message message) { - if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); + if (DBG) log(getName() + message.toString() + "\n"); switch(message.what) { case WifiMonitor.SUP_CONNECTION_EVENT: - Log.d(TAG, "Supplicant connection established"); + if (DBG) log("Supplicant connection established"); setWifiState(WIFI_STATE_ENABLED); mSupplicantRestartCount = 0; /* Reset the supplicant state to indicate the supplicant @@ -2144,12 +2151,12 @@ public class WifiStateMachine extends StateMachine { break; case WifiMonitor.SUP_DISCONNECTION_EVENT: if (++mSupplicantRestartCount <= SUPPLICANT_RESTART_TRIES) { - Log.e(TAG, "Failed to setup control channel, restart supplicant"); + loge("Failed to setup control channel, restart supplicant"); WifiNative.killSupplicant(); transitionTo(mDriverLoadedState); sendMessageDelayed(CMD_START_SUPPLICANT, SUPPLICANT_RESTART_INTERVAL_MSECS); } else { - Log.e(TAG, "Failed " + mSupplicantRestartCount + + loge("Failed " + mSupplicantRestartCount + " times to start supplicant, unload driver"); mSupplicantRestartCount = 0; transitionTo(mDriverLoadedState); @@ -2184,7 +2191,7 @@ public class WifiStateMachine extends StateMachine { class SupplicantStartedState extends State { @Override public void enter() { - if (DBG) Log.d(TAG, getName() + "\n"); + if (DBG) log(getName() + "\n"); EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName()); /* Initialize for connect mode operation at start */ mIsScanMode = false; @@ -2198,7 +2205,7 @@ public class WifiStateMachine extends StateMachine { } @Override public boolean processMessage(Message message) { - if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); + if (DBG) log(getName() + message.toString() + "\n"); WifiConfiguration config; boolean eventLoggingEnabled = true; switch(message.what) { @@ -2206,7 +2213,7 @@ public class WifiStateMachine extends StateMachine { transitionTo(mSupplicantStoppingState); break; case WifiMonitor.SUP_DISCONNECTION_EVENT: /* Supplicant connection lost */ - Log.e(TAG, "Connection lost, restart supplicant"); + loge("Connection lost, restart supplicant"); WifiNative.killSupplicant(); WifiNative.closeSupplicantConnection(); mNetworkInfo.setIsAvailable(false); @@ -2270,7 +2277,7 @@ public class WifiStateMachine extends StateMachine { break; /* Cannot start soft AP while in client mode */ case CMD_START_AP: - Log.d(TAG, "Failed to start soft AP with a running supplicant"); + loge("Failed to start soft AP with a running supplicant"); setWifiApState(WIFI_AP_STATE_FAILED); break; case CMD_SET_SCAN_MODE: @@ -2301,11 +2308,11 @@ public class WifiStateMachine extends StateMachine { class SupplicantStoppingState extends State { @Override public void enter() { - if (DBG) Log.d(TAG, getName() + "\n"); + if (DBG) log(getName() + "\n"); EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName()); - Log.d(TAG, "stopping supplicant"); + if (DBG) log("stopping supplicant"); if (!WifiNative.stopSupplicant()) { - Log.e(TAG, "Failed to stop supplicant"); + loge("Failed to stop supplicant"); } /* Send ourselves a delayed message to indicate failure after a wait time */ @@ -2321,13 +2328,13 @@ public class WifiStateMachine extends StateMachine { } @Override public boolean processMessage(Message message) { - if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); + if (DBG) log(getName() + message.toString() + "\n"); switch(message.what) { case WifiMonitor.SUP_CONNECTION_EVENT: - Log.e(TAG, "Supplicant connection received while stopping"); + loge("Supplicant connection received while stopping"); break; case WifiMonitor.SUP_DISCONNECTION_EVENT: - Log.d(TAG, "Supplicant connection lost"); + if (DBG) log("Supplicant connection lost"); /* Socket connection can be lost when we do a graceful shutdown * or when the driver is hung. Ensure supplicant is stopped here. */ @@ -2337,7 +2344,7 @@ public class WifiStateMachine extends StateMachine { break; case CMD_STOP_SUPPLICANT_FAILED: if (message.arg1 == mSupplicantStopFailureToken) { - Log.e(TAG, "Timed out on a supplicant stop, kill and proceed"); + loge("Timed out on a supplicant stop, kill and proceed"); WifiNative.killSupplicant(); WifiNative.closeSupplicantConnection(); transitionTo(mDriverLoadedState); @@ -2371,12 +2378,12 @@ public class WifiStateMachine extends StateMachine { class DriverStartingState extends State { @Override public void enter() { - if (DBG) Log.d(TAG, getName() + "\n"); + if (DBG) log(getName() + "\n"); EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName()); } @Override public boolean processMessage(Message message) { - if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); + if (DBG) log(getName() + message.toString() + "\n"); switch(message.what) { case WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT: SupplicantState state = handleSupplicantStateChange(message); @@ -2418,7 +2425,7 @@ public class WifiStateMachine extends StateMachine { class DriverStartedState extends State { @Override public void enter() { - if (DBG) Log.d(TAG, getName() + "\n"); + if (DBG) log(getName() + "\n"); EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName()); mIsRunning = true; @@ -2459,7 +2466,7 @@ public class WifiStateMachine extends StateMachine { } @Override public boolean processMessage(Message message) { - if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); + if (DBG) log(getName() + message.toString() + "\n"); boolean eventLoggingEnabled = true; switch(message.what) { case CMD_SET_SCAN_TYPE: @@ -2479,20 +2486,20 @@ public class WifiStateMachine extends StateMachine { break; case CMD_SET_COUNTRY_CODE: String country = (String) message.obj; - Log.d(TAG, "set country code " + country); + if (DBG) log("set country code " + country); if (!WifiNative.setCountryCodeCommand(country.toUpperCase())) { - Log.e(TAG, "Failed to set country code " + country); + loge("Failed to set country code " + country); } break; case CMD_SET_FREQUENCY_BAND: int band = message.arg1; - Log.d(TAG, "set frequency band " + band); + if (DBG) log("set frequency band " + band); if (WifiNative.setBandCommand(band)) { mFrequencyBand.set(band); //Fetch the latest scan results when frequency band is set startScan(true); } else { - Log.e(TAG, "Failed to set frequency band " + band); + loge("Failed to set frequency band " + band); } break; case CMD_BLUETOOTH_ADAPTER_STATE_CHANGE: @@ -2512,7 +2519,7 @@ public class WifiStateMachine extends StateMachine { } else if (message.arg1 == MULTICAST_V4) { WifiNative.startFilteringMulticastV4Packets(); } else { - Log.e(TAG, "Illegal arugments to CMD_START_PACKET_FILTERING"); + loge("Illegal arugments to CMD_START_PACKET_FILTERING"); } break; case CMD_STOP_PACKET_FILTERING: @@ -2521,7 +2528,7 @@ public class WifiStateMachine extends StateMachine { } else if (message.arg1 == MULTICAST_V4) { WifiNative.stopFilteringMulticastV4Packets(); } else { - Log.e(TAG, "Illegal arugments to CMD_STOP_PACKET_FILTERING"); + loge("Illegal arugments to CMD_STOP_PACKET_FILTERING"); } break; default: @@ -2534,7 +2541,7 @@ public class WifiStateMachine extends StateMachine { } @Override public void exit() { - if (DBG) Log.d(TAG, getName() + "\n"); + if (DBG) log(getName() + "\n"); mIsRunning = false; updateBatteryWorkSource(null); mScanResults = null; @@ -2544,12 +2551,12 @@ public class WifiStateMachine extends StateMachine { class DriverStoppingState extends State { @Override public void enter() { - if (DBG) Log.d(TAG, getName() + "\n"); + if (DBG) log(getName() + "\n"); EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName()); } @Override public boolean processMessage(Message message) { - if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); + if (DBG) log(getName() + message.toString() + "\n"); switch(message.what) { case WifiMonitor.SUPPLICANT_STATE_CHANGE_EVENT: SupplicantState state = handleSupplicantStateChange(message); @@ -2583,12 +2590,12 @@ public class WifiStateMachine extends StateMachine { class DriverStoppedState extends State { @Override public void enter() { - if (DBG) Log.d(TAG, getName() + "\n"); + if (DBG) log(getName() + "\n"); EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName()); } @Override public boolean processMessage(Message message) { - if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); + if (DBG) log(getName() + message.toString() + "\n"); switch (message.what) { case CMD_START_DRIVER: mWakeLock.acquire(); @@ -2607,12 +2614,12 @@ public class WifiStateMachine extends StateMachine { class ScanModeState extends State { @Override public void enter() { - if (DBG) Log.d(TAG, getName() + "\n"); + if (DBG) log(getName() + "\n"); EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName()); } @Override public boolean processMessage(Message message) { - if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); + if (DBG) log(getName() + message.toString() + "\n"); switch(message.what) { case CMD_SET_SCAN_MODE: if (message.arg1 == SCAN_ONLY_MODE) { @@ -2644,12 +2651,12 @@ public class WifiStateMachine extends StateMachine { class ConnectModeState extends State { @Override public void enter() { - if (DBG) Log.d(TAG, getName() + "\n"); + if (DBG) log(getName() + "\n"); EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName()); } @Override public boolean processMessage(Message message) { - if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); + if (DBG) log(getName() + message.toString() + "\n"); StateChangeResult stateChangeResult; switch(message.what) { case WifiMonitor.AUTHENTICATION_FAILURE_EVENT: @@ -2696,7 +2703,7 @@ public class WifiStateMachine extends StateMachine { mLastExplicitNetworkId = netId; mLastNetworkChoiceTime = SystemClock.elapsedRealtime(); mNextWifiActionExplicit = true; - Slog.d(TAG, "Setting wifi connect explicit for netid " + netId); + if (DBG) log("Setting wifi connect explicit for netid " + netId); /* Expect a disconnection from the old connection */ transitionTo(mDisconnectingState); break; @@ -2710,7 +2717,7 @@ public class WifiStateMachine extends StateMachine { /* Handle scan results */ return NOT_HANDLED; case WifiMonitor.NETWORK_CONNECTION_EVENT: - Log.d(TAG,"Network connection established"); + if (DBG) log("Network connection established"); mLastNetworkId = message.arg1; mLastBssid = (String) message.obj; @@ -2731,7 +2738,7 @@ public class WifiStateMachine extends StateMachine { transitionTo(mConnectingState); break; case WifiMonitor.NETWORK_DISCONNECTION_EVENT: - Log.d(TAG,"Network connection lost"); + if (DBG) log("Network connection lost"); handleNetworkDisconnect(); transitionTo(mDisconnectedState); break; @@ -2747,15 +2754,15 @@ public class WifiStateMachine extends StateMachine { @Override public void enter() { - if (DBG) Log.d(TAG, getName() + "\n"); + if (DBG) log(getName() + "\n"); EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName()); try { mNwService.enableIpv6(mInterfaceName); } catch (RemoteException re) { - Log.e(TAG, "Failed to enable IPv6: " + re); + loge("Failed to enable IPv6: " + re); } catch (IllegalStateException e) { - Log.e(TAG, "Failed to enable IPv6: " + e); + loge("Failed to enable IPv6: " + e); } if (!WifiConfigStore.isUsingStaticIp(mLastNetworkId)) { @@ -2772,20 +2779,20 @@ public class WifiStateMachine extends StateMachine { ifcg.interfaceFlags = "[up]"; try { mNwService.setInterfaceConfig(mInterfaceName, ifcg); - Log.v(TAG, "Static IP configuration succeeded"); + if (DBG) log("Static IP configuration succeeded"); sendMessage(CMD_STATIC_IP_SUCCESS, dhcpInfoInternal); } catch (RemoteException re) { - Log.v(TAG, "Static IP configuration failed: " + re); + loge("Static IP configuration failed: " + re); sendMessage(CMD_STATIC_IP_FAILURE); } catch (IllegalStateException e) { - Log.v(TAG, "Static IP configuration failed: " + e); + loge("Static IP configuration failed: " + e); sendMessage(CMD_STATIC_IP_FAILURE); } } } @Override public boolean processMessage(Message message) { - if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); + if (DBG) log(getName() + message.toString() + "\n"); switch(message.what) { case DhcpStateMachine.CMD_PRE_DHCP_ACTION: @@ -2856,7 +2863,7 @@ public class WifiStateMachine extends StateMachine { class ConnectedState extends State { @Override public void enter() { - if (DBG) Log.d(TAG, getName() + "\n"); + if (DBG) log(getName() + "\n"); EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName()); mRssiPollToken++; if (mEnableRssiPolling) { @@ -2865,7 +2872,7 @@ public class WifiStateMachine extends StateMachine { } @Override public boolean processMessage(Message message) { - if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); + if (DBG) log(getName() + message.toString() + "\n"); boolean eventLoggingEnabled = true; switch (message.what) { case DhcpStateMachine.CMD_PRE_DHCP_ACTION: @@ -2921,11 +2928,11 @@ public class WifiStateMachine extends StateMachine { NetworkUpdateResult result = WifiConfigStore.saveNetwork(config); if (mWifiInfo.getNetworkId() == result.getNetworkId()) { if (result.hasIpChanged()) { - Log.d(TAG,"Reconfiguring IP on connection"); + log("Reconfiguring IP on connection"); transitionTo(mConnectingState); } if (result.hasProxyChanged()) { - Log.d(TAG,"Reconfiguring proxy on connection"); + log("Reconfiguring proxy on connection"); configureLinkProperties(); sendLinkConfigurationChangedBroadcast(); } @@ -2977,12 +2984,12 @@ public class WifiStateMachine extends StateMachine { class DisconnectingState extends State { @Override public void enter() { - if (DBG) Log.d(TAG, getName() + "\n"); + if (DBG) log(getName() + "\n"); EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName()); } @Override public boolean processMessage(Message message) { - if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); + if (DBG) log(getName() + message.toString() + "\n"); switch (message.what) { case CMD_STOP_DRIVER: /* Stop driver only after disconnect handled */ deferMessage(message); @@ -3029,7 +3036,7 @@ public class WifiStateMachine extends StateMachine { @Override public void enter() { - if (DBG) Log.d(TAG, getName() + "\n"); + if (DBG) log(getName() + "\n"); EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName()); mFrameworkScanIntervalMs = Settings.Secure.getLong(mContext.getContentResolver(), @@ -3056,7 +3063,7 @@ public class WifiStateMachine extends StateMachine { } @Override public boolean processMessage(Message message) { - if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); + if (DBG) log(getName() + message.toString() + "\n"); switch (message.what) { case CMD_SET_SCAN_MODE: if (message.arg1 == SCAN_ONLY_MODE) { @@ -3119,12 +3126,12 @@ public class WifiStateMachine extends StateMachine { class WaitForWpsCompletionState extends State { @Override public void enter() { - if (DBG) Log.d(TAG, getName() + "\n"); + if (DBG) log(getName() + "\n"); EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName()); } @Override public boolean processMessage(Message message) { - if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); + if (DBG) log(getName() + message.toString() + "\n"); switch (message.what) { /* Defer all commands that can cause connections to a different network * or put the state machine out of connect mode @@ -3139,7 +3146,7 @@ public class WifiStateMachine extends StateMachine { deferMessage(message); break; case WifiMonitor.NETWORK_DISCONNECTION_EVENT: - Log.d(TAG,"Network connection lost"); + if (DBG) log("Network connection lost"); handleNetworkDisconnect(); break; case WPS_COMPLETED_EVENT: @@ -3158,7 +3165,7 @@ public class WifiStateMachine extends StateMachine { class SoftApStartingState extends State { @Override public void enter() { - if (DBG) Log.d(TAG, getName() + "\n"); + if (DBG) log(getName() + "\n"); EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName()); final Message message = Message.obtain(getCurrentMessage()); @@ -3168,10 +3175,10 @@ public class WifiStateMachine extends StateMachine { new Thread(new Runnable() { public void run() { if (startSoftApWithConfig(config)) { - Log.d(TAG, "Soft AP start successful"); + if (DBG) log("Soft AP start successful"); sendMessage(CMD_START_AP_SUCCESS); } else { - Log.d(TAG, "Soft AP start failed"); + loge("Soft AP start failed"); sendMessage(CMD_START_AP_FAILURE); } } @@ -3179,7 +3186,7 @@ public class WifiStateMachine extends StateMachine { } @Override public boolean processMessage(Message message) { - if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); + if (DBG) log(getName() + message.toString() + "\n"); switch(message.what) { case CMD_LOAD_DRIVER: case CMD_UNLOAD_DRIVER: @@ -3219,21 +3226,21 @@ public class WifiStateMachine extends StateMachine { class SoftApStartedState extends State { @Override public void enter() { - if (DBG) Log.d(TAG, getName() + "\n"); + if (DBG) log(getName() + "\n"); EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName()); } @Override public boolean processMessage(Message message) { - if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); + if (DBG) log(getName() + message.toString() + "\n"); switch(message.what) { case CMD_STOP_AP: - Log.d(TAG,"Stopping Soft AP"); + if (DBG) log("Stopping Soft AP"); setWifiApState(WIFI_AP_STATE_DISABLING); stopTethering(); try { mNwService.stopAccessPoint(mInterfaceName); } catch(Exception e) { - Log.e(TAG, "Exception in stopAccessPoint()"); + loge("Exception in stopAccessPoint()"); } transitionTo(mDriverLoadedState); break; @@ -3242,7 +3249,7 @@ public class WifiStateMachine extends StateMachine { break; /* Fail client mode operation when soft AP is enabled */ case CMD_START_SUPPLICANT: - Log.e(TAG,"Cannot start supplicant with a running soft AP"); + loge("Cannot start supplicant with a running soft AP"); setWifiState(WIFI_STATE_UNKNOWN); break; case CMD_TETHER_INTERFACE: @@ -3268,7 +3275,7 @@ public class WifiStateMachine extends StateMachine { private int mSavedArg; @Override public void enter() { - if (DBG) Log.d(TAG, getName() + "\n"); + if (DBG) log(getName() + "\n"); EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName()); //Preserve the argument arg1 that has information used in DriverLoadingState @@ -3276,7 +3283,7 @@ public class WifiStateMachine extends StateMachine { } @Override public boolean processMessage(Message message) { - if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); + if (DBG) log(getName() + message.toString() + "\n"); switch(message.what) { case WifiP2pService.WIFI_ENABLE_PROCEED: //restore argument from original message (CMD_LOAD_DRIVER) @@ -3311,12 +3318,12 @@ public class WifiStateMachine extends StateMachine { class TetheredState extends State { @Override public void enter() { - if (DBG) Log.d(TAG, getName() + "\n"); + if (DBG) log(getName() + "\n"); EventLog.writeEvent(EVENTLOG_WIFI_STATE_CHANGED, getName()); } @Override public boolean processMessage(Message message) { - if (DBG) Log.d(TAG, getName() + message.toString() + "\n"); + if (DBG) log(getName() + message.toString() + "\n"); switch(message.what) { case CMD_TETHER_INTERFACE: // Ignore any duplicate interface available notifications @@ -3327,4 +3334,12 @@ public class WifiStateMachine extends StateMachine { } } } + + private void log(String s) { + Log.d(TAG, s); + } + + private void loge(String s) { + Log.e(TAG, s); + } } diff --git a/wifi/java/android/net/wifi/WifiWatchdogStateMachine.java b/wifi/java/android/net/wifi/WifiWatchdogStateMachine.java index af8c486..5d5b9ef 100644 --- a/wifi/java/android/net/wifi/WifiWatchdogStateMachine.java +++ b/wifi/java/android/net/wifi/WifiWatchdogStateMachine.java @@ -35,7 +35,6 @@ import android.os.SystemClock; import android.os.SystemProperties; import android.provider.Settings; import android.provider.Settings.Secure; -import android.util.Slog; import android.util.Log; import com.android.internal.util.Protocol; @@ -67,10 +66,8 @@ import java.util.List; */ public class WifiWatchdogStateMachine extends StateMachine { - - private static final boolean VDBG = false; - private static final boolean DBG = true; - private static final String WWSM_TAG = "WifiWatchdogStateMachine"; + private static final boolean DBG = false; + private static final String TAG = "WifiWatchdogStateMachine"; private static final String WATCHDOG_NOTIFICATION_ID = "Android.System.WifiWatchdog"; private static final int WIFI_SIGNAL_LEVELS = 4; @@ -192,7 +189,7 @@ public class WifiWatchdogStateMachine extends StateMachine { * (all other states) */ private WifiWatchdogStateMachine(Context context) { - super(WWSM_TAG); + super(TAG); mContext = context; mContentResolver = context.getContentResolver(); mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); @@ -351,7 +348,7 @@ public class WifiWatchdogStateMachine extends StateMachine { return urlConnection.getResponseCode() != 204; } catch (IOException e) { if (DBG) { - Slog.d(WWSM_TAG, "Walled garden check - probably not a portal: exception ", e); + log("Walled garden check - probably not a portal: exception " + e); } return false; } finally { @@ -443,7 +440,7 @@ public class WifiWatchdogStateMachine extends StateMachine { if (results == null) { if (DBG) { - Slog.d(WWSM_TAG, "updateBssids: Got null scan results!"); + log("updateBssids: Got null scan results!"); } return; } @@ -451,7 +448,7 @@ public class WifiWatchdogStateMachine extends StateMachine { for (ScanResult result : results) { if (result == null || result.SSID == null) { if (DBG) { - Slog.d(WWSM_TAG, "Received invalid scan result: " + result); + log("Received invalid scan result: " + result); } continue; } @@ -461,8 +458,8 @@ public class WifiWatchdogStateMachine extends StateMachine { } private void resetWatchdogState() { - if (VDBG) { - Slog.v(WWSM_TAG, "Resetting watchdog state..."); + if (DBG) { + log("Resetting watchdog state..."); } mConnectionInfo = null; mDisableAPNextFailure = false; @@ -522,13 +519,13 @@ public class WifiWatchdogStateMachine extends StateMachine { switch (msg.what) { case EVENT_WATCHDOG_SETTINGS_CHANGE: updateSettings(); - if (VDBG) { - Slog.d(WWSM_TAG, "Updating wifi-watchdog secure settings"); + if (DBG) { + log("Updating wifi-watchdog secure settings"); } return HANDLED; } - if (VDBG) { - Slog.v(WWSM_TAG, "Caught message " + msg.what + " in state " + + if (DBG) { + log("Caught message " + msg.what + " in state " + getCurrentState().getName()); } return HANDLED; @@ -553,7 +550,7 @@ public class WifiWatchdogStateMachine extends StateMachine { public void enter() { resetWatchdogState(); mContext.registerReceiver(mBroadcastReceiver, mIntentFilter); - Slog.i(WWSM_TAG, "WifiWatchdogService enabled"); + if (DBG) log("WifiWatchdogService enabled"); } @Override @@ -574,12 +571,12 @@ public class WifiWatchdogStateMachine extends StateMachine { WifiInfo wifiInfo = (WifiInfo) stateChangeIntent.getParcelableExtra(WifiManager.EXTRA_WIFI_INFO); if (wifiInfo == null) { - Slog.e(WWSM_TAG, "Connected --> WifiInfo object null!"); + loge("Connected --> WifiInfo object null!"); return HANDLED; } if (wifiInfo.getSSID() == null || wifiInfo.getBSSID() == null) { - Slog.e(WWSM_TAG, "Received wifiInfo object with null elts: " + loge("Received wifiInfo object with null elts: " + wifiInfoToStr(wifiInfo)); return HANDLED; } @@ -598,7 +595,7 @@ public class WifiWatchdogStateMachine extends StateMachine { return HANDLED; case EVENT_WIFI_RADIO_STATE_CHANGE: if ((Integer) msg.obj == WifiManager.WIFI_STATE_DISABLING) { - Slog.i(WWSM_TAG, "WifiStateDisabling -- Resetting WatchdogState"); + if (DBG) log("WifiStateDisabling -- Resetting WatchdogState"); resetWatchdogState(); mNetEventCounter++; transitionTo(mNotConnectedState); @@ -613,8 +610,8 @@ public class WifiWatchdogStateMachine extends StateMachine { * @param wifiInfo Info object with non-null ssid and bssid */ private void initConnection(WifiInfo wifiInfo) { - if (VDBG) { - Slog.v(WWSM_TAG, "Connected:: old " + wifiInfoToStr(mConnectionInfo) + + if (DBG) { + log("Connected:: old " + wifiInfoToStr(mConnectionInfo) + " ==> new " + wifiInfoToStr(wifiInfo)); } @@ -628,7 +625,7 @@ public class WifiWatchdogStateMachine extends StateMachine { @Override public void exit() { mContext.unregisterReceiver(mBroadcastReceiver); - Slog.i(WWSM_TAG, "WifiWatchdogService disabled"); + if (DBG) log("WifiWatchdogService disabled"); } } @@ -671,7 +668,7 @@ public class WifiWatchdogStateMachine extends StateMachine { if (DBG) { dnsCheckLogStr = String.format("Pinging %s on ssid [%s]: ", mDnsList, mConnectionInfo.getSSID()); - Slog.d(WWSM_TAG, dnsCheckLogStr); + log(dnsCheckLogStr); } idDnsMap.clear(); @@ -694,7 +691,7 @@ public class WifiWatchdogStateMachine extends StateMachine { Integer dnsServerId = idDnsMap.get(pingID); if (dnsServerId == null) { - Slog.w(WWSM_TAG, "Received a Dns response with unknown ID!"); + loge("Received a Dns response with unknown ID!"); return HANDLED; } @@ -722,7 +719,7 @@ public class WifiWatchdogStateMachine extends StateMachine { if (dnsCheckSuccesses[dnsServerId] >= mMinDnsResponses) { // DNS CHECKS OK, NOW WALLED GARDEN if (DBG) { - Slog.d(WWSM_TAG, makeLogString() + " SUCCESS"); + log(makeLogString() + " SUCCESS"); } if (!shouldCheckWalledGarden()) { @@ -732,13 +729,10 @@ public class WifiWatchdogStateMachine extends StateMachine { mLastWalledGardenCheckTime = SystemClock.elapsedRealtime(); if (isWalledGardenConnection()) { - if (DBG) - Slog.d(WWSM_TAG, - "Walled garden test complete - walled garden detected"); + if (DBG) log("Walled garden test complete - walled garden detected"); transitionTo(mWalledGardenState); } else { - if (DBG) - Slog.d(WWSM_TAG, "Walled garden test complete - online"); + if (DBG) log("Walled garden test complete - online"); transitionTo(mOnlineWatchState); } return HANDLED; @@ -746,7 +740,7 @@ public class WifiWatchdogStateMachine extends StateMachine { if (idDnsMap.isEmpty()) { if (DBG) { - Slog.d(WWSM_TAG, makeLogString() + " FAILURE"); + log(makeLogString() + " FAILURE"); } transitionTo(mDnsCheckFailureState); return HANDLED; @@ -769,15 +763,15 @@ public class WifiWatchdogStateMachine extends StateMachine { private boolean shouldCheckWalledGarden() { if (!mWalledGardenTestEnabled) { - if (VDBG) - Slog.v(WWSM_TAG, "Skipping walled garden check - disabled"); + if (DBG) + log("Skipping walled garden check - disabled"); return false; } long waitTime = waitTime(mWalledGardenIntervalMs, mLastWalledGardenCheckTime); if (waitTime > 0) { if (DBG) { - Slog.d(WWSM_TAG, "Skipping walled garden check - wait " + + log("Skipping walled garden check - wait " + waitTime + " ms."); } return false; @@ -825,28 +819,28 @@ public class WifiWatchdogStateMachine extends StateMachine { case EVENT_RSSI_CHANGE: if (msg.arg1 != mNetEventCounter) { if (DBG) { - Slog.d(WWSM_TAG, "Rssi change message out of sync, ignoring"); + log("Rssi change message out of sync, ignoring"); } return HANDLED; } int newRssi = msg.arg2; signalUnstable = !rssiStrengthAboveCutoff(newRssi); - if (VDBG) { - Slog.v(WWSM_TAG, "OnlineWatchState:: new rssi " + newRssi + " --> level " + + if (DBG) { + log("OnlineWatchState:: new rssi " + newRssi + " --> level " + WifiManager.calculateSignalLevel(newRssi, WIFI_SIGNAL_LEVELS)); } if (signalUnstable && !unstableSignalChecks) { - if (VDBG) { - Slog.v(WWSM_TAG, "Sending triggered check msg"); + if (DBG) { + log("Sending triggered check msg"); } triggerSingleDnsCheck(); } return HANDLED; case MESSAGE_SINGLE_DNS_CHECK: if (msg.arg1 != checkGuard) { - if (VDBG) { - Slog.v(WWSM_TAG, "Single check msg out of sync, ignoring."); + if (DBG) { + log("Single check msg out of sync, ignoring."); } return HANDLED; } @@ -865,8 +859,8 @@ public class WifiWatchdogStateMachine extends StateMachine { pingInfoMap.remove(msg.arg1); int responseTime = msg.arg2; if (responseTime >= 0) { - if (VDBG) { - Slog.v(WWSM_TAG, "Single DNS ping OK. Response time: " + if (DBG) { + log("Single DNS ping OK. Response time: " + responseTime + " from DNS " + curDnsServer); } pingInfoMap.clear(); @@ -877,7 +871,7 @@ public class WifiWatchdogStateMachine extends StateMachine { } else { if (pingInfoMap.isEmpty()) { if (DBG) { - Slog.d(WWSM_TAG, "Single dns ping failure. All dns servers failed, " + log("Single dns ping failure. All dns servers failed, " + "starting full checks."); } transitionTo(mDnsCheckingState); @@ -924,8 +918,8 @@ public class WifiWatchdogStateMachine extends StateMachine { } if (msg.arg1 != mNetEventCounter) { - if (VDBG) { - Slog.v(WWSM_TAG, "Msg out of sync, ignoring..."); + if (DBG) { + log("Msg out of sync, ignoring..."); } return HANDLED; } @@ -933,7 +927,7 @@ public class WifiWatchdogStateMachine extends StateMachine { if (mDisableAPNextFailure || mNumCheckFailures >= mBssids.size() || mNumCheckFailures >= mMaxSsidBlacklists) { if (sWifiOnly) { - Slog.w(WWSM_TAG, "Would disable bad network, but device has no mobile data!" + + log("Would disable bad network, but device has no mobile data!" + " Going idle..."); // This state should be called idle -- will be changing flow. transitionTo(mNotConnectedState); @@ -941,7 +935,7 @@ public class WifiWatchdogStateMachine extends StateMachine { } // TODO : Unban networks if they had low signal ? - Slog.i(WWSM_TAG, "Disabling current SSID " + wifiInfoToStr(mConnectionInfo) + log("Disabling current SSID " + wifiInfoToStr(mConnectionInfo) + ". " + "numCheckFailures " + mNumCheckFailures + ", numAPs " + mBssids.size()); int networkId = mConnectionInfo.getNetworkId(); @@ -955,7 +949,7 @@ public class WifiWatchdogStateMachine extends StateMachine { } transitionTo(mNotConnectedState); } else { - Slog.i(WWSM_TAG, "Blacklisting current BSSID. " + wifiInfoToStr(mConnectionInfo) + log("Blacklisting current BSSID. " + wifiInfoToStr(mConnectionInfo) + "numCheckFailures " + mNumCheckFailures + ", numAPs " + mBssids.size()); mWifiManager.addToBlacklist(mConnectionInfo.getBSSID()); @@ -979,8 +973,8 @@ public class WifiWatchdogStateMachine extends StateMachine { } if (msg.arg1 != mNetEventCounter) { - if (VDBG) { - Slog.v(WWSM_TAG, "WalledGardenState::Msg out of sync, ignoring..."); + if (DBG) { + log("WalledGardenState::Msg out of sync, ignoring..."); } return HANDLED; } @@ -1005,8 +999,8 @@ public class WifiWatchdogStateMachine extends StateMachine { } if (msg.arg1 != mNetEventCounter) { - if (VDBG) { - Slog.v(WWSM_TAG, "BlacklistedApState::Msg out of sync, ignoring..."); + if (DBG) { + log("BlacklistedApState::Msg out of sync, ignoring..."); } return HANDLED; } @@ -1067,5 +1061,11 @@ public class WifiWatchdogStateMachine extends StateMachine { return Settings.Secure.putInt(cr, name, value ? 1 : 0); } + private void log(String s) { + Log.d(TAG, s); + } + private void loge(String s) { + Log.e(TAG, s); + } } |