summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNate Jiang <qiangjiang@google.com>2020-05-05 18:46:10 -0700
committerNate Jiang <qiangjiang@google.com>2020-05-11 17:57:06 -0700
commitb57702bddb5bd75407fbe5a5d06a82846bba3799 (patch)
tree5c5bc4341dfe989f9c0a62b50e0c983eb951c12d
parentb6ef9646566c02792d6c0e765d28669453c4d7b3 (diff)
Enable Verbose logging in WifiAware
Make WifiAware verbase logging change with settings. Bug: 155708406 Test: atest com.android.server.wifi Change-Id: If96fd2b3f8e371d6267975e6bd4cac7106a5f953
-rw-r--r--service/java/com/android/server/wifi/aware/WifiAwareClientState.java13
-rw-r--r--service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java53
-rw-r--r--service/java/com/android/server/wifi/aware/WifiAwareDiscoverySessionState.java12
-rw-r--r--service/java/com/android/server/wifi/aware/WifiAwareMetrics.java2
-rw-r--r--service/java/com/android/server/wifi/aware/WifiAwareNativeApi.java10
-rw-r--r--service/java/com/android/server/wifi/aware/WifiAwareNativeCallback.java19
-rw-r--r--service/java/com/android/server/wifi/aware/WifiAwareNativeManager.java12
-rw-r--r--service/java/com/android/server/wifi/aware/WifiAwareServiceImpl.java36
-rw-r--r--service/java/com/android/server/wifi/aware/WifiAwareStateManager.java54
9 files changed, 116 insertions, 95 deletions
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareClientState.java b/service/java/com/android/server/wifi/aware/WifiAwareClientState.java
index f4135743d..b71546639 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareClientState.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareClientState.java
@@ -44,7 +44,7 @@ import java.util.Arrays;
public class WifiAwareClientState {
private static final String TAG = "WifiAwareClientState";
private static final boolean VDBG = false; // STOPSHIP if true
- /* package */ boolean mDbg = false;
+ private boolean mDbg = false;
/* package */ static final int CLUSTER_CHANGE_EVENT_STARTED = 0;
/* package */ static final int CLUSTER_CHANGE_EVENT_JOINED = 1;
@@ -89,6 +89,13 @@ public class WifiAwareClientState {
}
/**
+ * Enable verbose logging.
+ */
+ public void enableVerboseLogging(boolean verbose) {
+ mDbg = verbose | VDBG;
+ }
+
+ /**
* Destroy the current client - corresponds to a disconnect() request from
* the client. Destroys all discovery sessions belonging to this client.
*/
@@ -216,7 +223,7 @@ public class WifiAwareClientState {
* client.
*/
public void onInterfaceAddressChange(byte[] mac) {
- if (VDBG) {
+ if (mDbg) {
Log.v(TAG,
"onInterfaceAddressChange: mClientId=" + mClientId + ", mNotifyIdentityChange="
+ mNotifyIdentityChange + ", mac=" + String.valueOf(
@@ -249,7 +256,7 @@ public class WifiAwareClientState {
* @param currentDiscoveryInterfaceMac The MAC address of the discovery interface.
*/
public void onClusterChange(int flag, byte[] mac, byte[] currentDiscoveryInterfaceMac) {
- if (VDBG) {
+ if (mDbg) {
Log.v(TAG,
"onClusterChange: mClientId=" + mClientId + ", mNotifyIdentityChange="
+ mNotifyIdentityChange + ", mac=" + String.valueOf(
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java b/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java
index 18ff047a2..49ce8ad6f 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java
@@ -87,7 +87,7 @@ import java.util.TreeSet;
public class WifiAwareDataPathStateManager {
private static final String TAG = "WifiAwareDataPathStMgr";
private static final boolean VDBG = false; // STOPSHIP if true
- /* package */ boolean mDbg = false;
+ private boolean mDbg = false;
private static final String AWARE_INTERFACE_PREFIX = "aware_data";
private static final String NETWORK_TAG = "WIFI_AWARE_FACTORY";
@@ -166,6 +166,13 @@ public class WifiAwareDataPathStateManager {
mNetworkFactory.register();
}
+ /**
+ * Enable verbose logging.
+ */
+ public void enableVerboseLogging(boolean verbose) {
+ mDbg = verbose | VDBG;
+ }
+
private Map.Entry<WifiAwareNetworkSpecifier, AwareNetworkRequestInformation>
getNetworkRequestByNdpId(int ndpId) {
for (Map.Entry<WifiAwareNetworkSpecifier, AwareNetworkRequestInformation> entry :
@@ -200,7 +207,7 @@ public class WifiAwareDataPathStateManager {
* capabilities of the firmware.
*/
public void createAllInterfaces() {
- if (VDBG) Log.v(TAG, "createAllInterfaces");
+ if (mDbg) Log.v(TAG, "createAllInterfaces");
if (mMgr.getCapabilities() == null) {
Log.e(TAG, "createAllInterfaces: capabilities aren't initialized yet!");
@@ -226,7 +233,7 @@ public class WifiAwareDataPathStateManager {
* Delete all Aware data-path interfaces which are currently up.
*/
public void deleteAllInterfaces() {
- if (VDBG) Log.v(TAG, "deleteAllInterfaces");
+ if (mDbg) Log.v(TAG, "deleteAllInterfaces");
onAwareDownCleanupDataPaths();
if (mMgr.getCapabilities() == null) {
@@ -245,7 +252,7 @@ public class WifiAwareDataPathStateManager {
* Called when firmware indicates the an interface was created.
*/
public void onInterfaceCreated(String interfaceName) {
- if (VDBG) Log.v(TAG, "onInterfaceCreated: interfaceName=" + interfaceName);
+ if (mDbg) Log.v(TAG, "onInterfaceCreated: interfaceName=" + interfaceName);
if (mInterfaces.contains(interfaceName)) {
Log.w(TAG, "onInterfaceCreated: already contains interface -- " + interfaceName);
@@ -258,7 +265,7 @@ public class WifiAwareDataPathStateManager {
* Called when firmware indicates the an interface was deleted.
*/
public void onInterfaceDeleted(String interfaceName) {
- if (VDBG) Log.v(TAG, "onInterfaceDeleted: interfaceName=" + interfaceName);
+ if (mDbg) Log.v(TAG, "onInterfaceDeleted: interfaceName=" + interfaceName);
if (!mInterfaces.contains(interfaceName)) {
Log.w(TAG, "onInterfaceDeleted: interface not on list -- " + interfaceName);
@@ -275,7 +282,7 @@ public class WifiAwareDataPathStateManager {
* @param ndpId The ID assigned to the data-path.
*/
public void onDataPathInitiateSuccess(WifiAwareNetworkSpecifier networkSpecifier, int ndpId) {
- if (VDBG) {
+ if (mDbg) {
Log.v(TAG,
"onDataPathInitiateSuccess: networkSpecifier=" + networkSpecifier + ", ndpId="
+ ndpId);
@@ -309,7 +316,7 @@ public class WifiAwareDataPathStateManager {
* @param reason Failure reason.
*/
public void onDataPathInitiateFail(WifiAwareNetworkSpecifier networkSpecifier, int reason) {
- if (VDBG) {
+ if (mDbg) {
Log.v(TAG,
"onDataPathInitiateFail: networkSpecifier=" + networkSpecifier + ", reason="
+ reason);
@@ -346,7 +353,7 @@ public class WifiAwareDataPathStateManager {
*/
public WifiAwareNetworkSpecifier onDataPathRequest(int pubSubId, byte[] mac, int ndpId,
byte[] message) {
- if (VDBG) {
+ if (mDbg) {
Log.v(TAG,
"onDataPathRequest: pubSubId=" + pubSubId + ", mac=" + String.valueOf(
HexEncoding.encode(mac)) + ", ndpId=" + ndpId);
@@ -456,7 +463,7 @@ public class WifiAwareDataPathStateManager {
* @param success Whether or not the 'RespondToDataPathRequest' operation was a success.
*/
public void onRespondToDataPathRequest(int ndpId, boolean success, int reasonOnFailure) {
- if (VDBG) {
+ if (mDbg) {
Log.v(TAG, "onRespondToDataPathRequest: ndpId=" + ndpId + ", success=" + success);
}
@@ -525,7 +532,7 @@ public class WifiAwareDataPathStateManager {
*/
public WifiAwareNetworkSpecifier onDataPathConfirm(int ndpId, byte[] mac, boolean accept,
int reason, byte[] message, List<NanDataPathChannelInfo> channelInfo) {
- if (VDBG) {
+ if (mDbg) {
Log.v(TAG, "onDataPathConfirm: ndpId=" + ndpId + ", mac=" + String.valueOf(
HexEncoding.encode(mac)) + ", accept=" + accept + ", reason=" + reason
+ ", message.length=" + ((message == null) ? 0 : message.length)
@@ -685,7 +692,7 @@ public class WifiAwareDataPathStateManager {
declareUnfullfillableAndEndDp(nnri, ndpId);
return;
}
- if (mDbg) {
+ if (VDBG) {
Log.d(TAG, "Failed address validation");
}
mHandler.postDelayed(() -> {
@@ -707,7 +714,7 @@ public class WifiAwareDataPathStateManager {
* @param ndpId The ID of the terminated data-path.
*/
public void onDataPathEnd(int ndpId) {
- if (VDBG) Log.v(TAG, "onDataPathEnd: ndpId=" + ndpId);
+ if (mDbg) Log.v(TAG, "onDataPathEnd: ndpId=" + ndpId);
Map.Entry<WifiAwareNetworkSpecifier, AwareNetworkRequestInformation> nnriE =
getNetworkRequestByNdpId(ndpId);
@@ -734,7 +741,7 @@ public class WifiAwareDataPathStateManager {
*/
public void onDataPathSchedUpdate(byte[] peerMac, List<Integer> ndpIds,
List<NanDataPathChannelInfo> channelInfo) {
- if (VDBG) {
+ if (mDbg) {
Log.v(TAG, "onDataPathSchedUpdate: peerMac=" + MacAddress.fromBytes(peerMac).toString()
+ ", ndpIds=" + ndpIds + ", channelInfo=" + channelInfo);
}
@@ -761,7 +768,7 @@ public class WifiAwareDataPathStateManager {
* Called whenever Aware comes down. Clean up all pending and up network requests and agents.
*/
public void onAwareDownCleanupDataPaths() {
- if (VDBG) Log.v(TAG, "onAwareDownCleanupDataPaths");
+ if (mDbg) Log.v(TAG, "onAwareDownCleanupDataPaths");
Iterator<Map.Entry<WifiAwareNetworkSpecifier, AwareNetworkRequestInformation>> it =
mNetworkRequestsCache.entrySet().iterator();
@@ -782,7 +789,7 @@ public class WifiAwareDataPathStateManager {
AwareNetworkRequestInformation nnri = mNetworkRequestsCache.remove(networkSpecifier);
if (nnri == null) {
- if (mDbg) {
+ if (VDBG) {
Log.v(TAG,
"handleDataPathTimeout: network request not found for networkSpecifier="
+ networkSpecifier);
@@ -899,7 +906,7 @@ public class WifiAwareDataPathStateManager {
@Override
protected void needNetworkFor(NetworkRequest networkRequest, int score) {
- if (VDBG) {
+ if (mDbg) {
Log.v(TAG, "WifiAwareNetworkFactory.needNetworkFor: networkRequest="
+ networkRequest + ", score=" + score);
}
@@ -951,7 +958,7 @@ public class WifiAwareDataPathStateManager {
@Override
protected void releaseNetworkFor(NetworkRequest networkRequest) {
- if (VDBG) {
+ if (mDbg) {
Log.v(TAG, "WifiAwareNetworkFactory.releaseNetworkFor: networkRequest="
+ networkRequest);
}
@@ -986,7 +993,7 @@ public class WifiAwareDataPathStateManager {
*/
nnri.removeSupportForRequest(networkRequest);
if (nnri.equivalentRequests.isEmpty()) {
- if (VDBG) {
+ if (mDbg) {
Log.v(TAG, "releaseNetworkFor: there are no further requests, networkRequest="
+ networkRequest);
}
@@ -1033,7 +1040,7 @@ public class WifiAwareDataPathStateManager {
@Override
public void onNetworkUnwanted() {
- if (VDBG) {
+ if (mDbg) {
Log.v(TAG, "WifiAwareNetworkAgent.unwanted: request=" + mAwareNetworkRequestInfo);
}
@@ -1045,7 +1052,7 @@ public class WifiAwareDataPathStateManager {
}
void reconfigureAgentAsDisconnected() {
- if (VDBG) {
+ if (mDbg) {
Log.v(TAG, "WifiAwareNetworkAgent.reconfigureAgentAsDisconnected: request="
+ mAwareNetworkRequestInfo);
}
@@ -1059,7 +1066,7 @@ public class WifiAwareDataPathStateManager {
if (!TextUtils.isEmpty(nnri.interfaceName)) {
boolean interfaceUsedByAnotherNdp = isInterfaceUpAndUsedByAnotherNdp(nnri);
if (interfaceUsedByAnotherNdp) {
- if (VDBG) {
+ if (mDbg) {
Log.v(TAG, "tearDownInterfaceIfPossible: interfaceName=" + nnri.interfaceName
+ ", still in use - not turning down");
}
@@ -1108,7 +1115,7 @@ public class WifiAwareDataPathStateManager {
SortedSet<String> potential = new TreeSet<>(mInterfaces);
Set<String> used = new HashSet<>();
- if (VDBG) {
+ if (mDbg) {
Log.v(TAG, "selectInterfaceForRequest: req=" + req + ", mNetworkRequestsCache="
+ mNetworkRequestsCache);
}
@@ -1539,7 +1546,7 @@ public class WifiAwareDataPathStateManager {
testDatagramSocket = new DatagramSocket(0, address);
} catch (SocketException e) {
if (mDbg) {
- Log.d(TAG, "Can't create socket on address " + address + " -- " + e);
+ Log.v(TAG, "Can't create socket on address " + address + " -- " + e);
}
return false;
} finally {
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareDiscoverySessionState.java b/service/java/com/android/server/wifi/aware/WifiAwareDiscoverySessionState.java
index f58b3d78e..9af954557 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareDiscoverySessionState.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareDiscoverySessionState.java
@@ -37,8 +37,7 @@ import java.util.Arrays;
*/
public class WifiAwareDiscoverySessionState {
private static final String TAG = "WifiAwareDiscSessState";
- private static final boolean VDBG = false; // STOPSHIP if true
- /* package */ boolean mDbg = false;
+ private boolean mDbg = false;
private static int sNextPeerIdToBeAllocated = 100; // used to create a unique peer ID
@@ -81,6 +80,13 @@ public class WifiAwareDiscoverySessionState {
mCreationTime = creationTime;
}
+ /**
+ * Enable verbose logging.
+ */
+ public void enableVerboseLogging(boolean verbose) {
+ mDbg = verbose;
+ }
+
public int getSessionId() {
return mSessionId;
}
@@ -301,7 +307,7 @@ public class WifiAwareDiscoverySessionState {
PeerInfo newPeerInfo = new PeerInfo(requestorInstanceId, peerMac);
mPeerInfoByRequestorInstanceId.put(newPeerId, newPeerInfo);
- if (VDBG) {
+ if (mDbg) {
Log.v(TAG, "New peer info: peerId=" + newPeerId + ", peerInfo=" + newPeerInfo);
}
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareMetrics.java b/service/java/com/android/server/wifi/aware/WifiAwareMetrics.java
index 67b0cd887..e9043f820 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareMetrics.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareMetrics.java
@@ -41,8 +41,6 @@ import java.util.Set;
*/
public class WifiAwareMetrics {
private static final String TAG = "WifiAwareMetrics";
- private static final boolean VDBG = false;
- /* package */ boolean mDbg = false;
// Histogram: 8 buckets (i=0, ..., 7) of 9 slots in range 10^i -> 10^(i+1)
// Buckets:
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareNativeApi.java b/service/java/com/android/server/wifi/aware/WifiAwareNativeApi.java
index 3d769a5dd..4e6f08613 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareNativeApi.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareNativeApi.java
@@ -61,7 +61,7 @@ import java.util.Map;
public class WifiAwareNativeApi implements WifiAwareShellCommand.DelegatedShellCommand {
private static final String TAG = "WifiAwareNativeApi";
private static final boolean VDBG = false; // STOPSHIP if true
- /* package */ boolean mDbg = false;
+ private boolean mDbg = false;
@VisibleForTesting
static final String SERVICE_NAME_FOR_OOB_DATA_PATH = "Wi-Fi Aware Data Path";
@@ -77,6 +77,14 @@ public class WifiAwareNativeApi implements WifiAwareShellCommand.DelegatedShellC
}
}
+ /**
+ * Enable verbose logging.
+ */
+ public void enableVerboseLogging(boolean verbose) {
+ mDbg = verbose | VDBG;
+ }
+
+
private void recordTransactionId(int transactionId) {
if (!VDBG) return;
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareNativeCallback.java b/service/java/com/android/server/wifi/aware/WifiAwareNativeCallback.java
index 5e76897a2..c9616db37 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareNativeCallback.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareNativeCallback.java
@@ -28,6 +28,7 @@ import android.hardware.wifi.V1_0.WifiNanStatus;
import android.hardware.wifi.V1_2.IWifiNanIfaceEventCallback;
import android.hardware.wifi.V1_2.NanDataPathChannelInfo;
import android.hardware.wifi.V1_2.NanDataPathScheduleUpdateInd;
+import android.net.MacAddress;
import android.net.wifi.util.HexEncoding;
import android.os.BasicShellCommandHandler;
import android.util.Log;
@@ -49,8 +50,7 @@ import java.util.Arrays;
public class WifiAwareNativeCallback extends IWifiNanIfaceEventCallback.Stub implements
WifiAwareShellCommand.DelegatedShellCommand {
private static final String TAG = "WifiAwareNativeCallback";
- private static final boolean VDBG = false;
- /* package */ boolean mDbg = false;
+ private boolean mDbg = false;
/* package */ boolean mIsHal12OrLater = false;
@@ -60,6 +60,14 @@ public class WifiAwareNativeCallback extends IWifiNanIfaceEventCallback.Stub imp
mWifiAwareStateManager = wifiAwareStateManager;
}
+ /**
+ * Enable verbose logging.
+ */
+ public void enableVerboseLogging(boolean verbose) {
+ mDbg = verbose;
+ }
+
+
/*
* Counts of callbacks from HAL. Retrievable through shell command.
*/
@@ -94,11 +102,9 @@ public class WifiAwareNativeCallback extends IWifiNanIfaceEventCallback.Stub imp
final PrintWriter pwo = parentShell.getOutPrintWriter();
String subCmd = parentShell.getNextArgRequired();
- if (VDBG) Log.v(TAG, "onCommand: subCmd='" + subCmd + "'");
switch (subCmd) {
case "get_cb_count": {
String option = parentShell.getNextOption();
- if (VDBG) Log.v(TAG, "option='" + option + "'");
boolean reset = false;
if (option != null) {
if ("--reset".equals(option)) {
@@ -126,7 +132,6 @@ public class WifiAwareNativeCallback extends IWifiNanIfaceEventCallback.Stub imp
}
case "get_channel_info": {
String option = parentShell.getNextOption();
- if (VDBG) Log.v(TAG, "option='" + option + "'");
if (option != null) {
pwe.println("Unknown option to 'get_channel_info'");
return -1;
@@ -536,7 +541,9 @@ public class WifiAwareNativeCallback extends IWifiNanIfaceEventCallback.Stub imp
@Override
public void eventDataPathScheduleUpdate(NanDataPathScheduleUpdateInd event) {
if (mDbg) {
- Log.v(TAG, "eventDataPathScheduleUpdate");
+ Log.v(TAG, "eventDataPathScheduleUpdate: peerMac="
+ + MacAddress.fromBytes(event.peerDiscoveryAddress).toString()
+ + ", ndpIds=" + event.ndpInstanceIds + ", channelInfo=" + event.channelInfo);
}
if (!mIsHal12OrLater) {
Log.wtf(TAG, "eventDataPathScheduleUpdate should not be called by a <1.2 HAL!");
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareNativeManager.java b/service/java/com/android/server/wifi/aware/WifiAwareNativeManager.java
index e3361bfc0..ec6c0ade5 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareNativeManager.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareNativeManager.java
@@ -36,8 +36,7 @@ import java.io.PrintWriter;
*/
public class WifiAwareNativeManager {
private static final String TAG = "WifiAwareNativeManager";
- private static final boolean VDBG = false;
- /* package */ boolean mDbg = false;
+ private boolean mDbg = false;
// to be used for synchronizing access to any of the WifiAwareNative objects
private final Object mLock = new Object();
@@ -62,6 +61,13 @@ public class WifiAwareNativeManager {
}
/**
+ * Enable verbose logging.
+ */
+ public void enableVerboseLogging(boolean verbose) {
+ mDbg = verbose;
+ }
+
+ /**
* (HIDL) Cast the input to a 1.2 NAN interface (possibly resulting in a null).
*
* Separate function so can be mocked in unit tests.
@@ -82,7 +88,7 @@ public class WifiAwareNativeManager {
new HalDeviceManager.ManagerStatusListener() {
@Override
public void onStatusChanged() {
- if (VDBG) Log.v(TAG, "onStatusChanged");
+ if (mDbg) Log.v(TAG, "onStatusChanged");
// only care about isStarted (Wi-Fi started) not isReady - since if not
// ready then Wi-Fi will also be down.
if (mHalDeviceManager.isStarted()) {
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareServiceImpl.java b/service/java/com/android/server/wifi/aware/WifiAwareServiceImpl.java
index bbb01468d..3e33cc1aa 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareServiceImpl.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareServiceImpl.java
@@ -44,7 +44,6 @@ import android.util.SparseArray;
import android.util.SparseIntArray;
import com.android.server.wifi.Clock;
-import com.android.server.wifi.WifiInjector;
import com.android.server.wifi.WifiSettingsConfigStore;
import com.android.server.wifi.util.NetdWrapper;
import com.android.server.wifi.util.WifiPermissionsUtil;
@@ -62,8 +61,7 @@ import java.util.List;
*/
public class WifiAwareServiceImpl extends IWifiAwareManager.Stub {
private static final String TAG = "WifiAwareService";
- private static final boolean VDBG = false; // STOPSHIP if true
- /* package */ boolean mDbg = false;
+ private boolean mDbg = false;
private Context mContext;
private AppOpsManager mAppOps;
@@ -124,25 +122,17 @@ public class WifiAwareServiceImpl extends IWifiAwareManager.Stub {
});
}
- private void enableVerboseLogging(boolean verbose, WifiAwareStateManager awareStateManager,
+ private void enableVerboseLogging(boolean dbg, WifiAwareStateManager awareStateManager,
WifiAwareNativeManager wifiAwareNativeManager, WifiAwareNativeApi wifiAwareNativeApi,
WifiAwareNativeCallback wifiAwareNativeCallback) {
- boolean dbg;
-
- dbg = verbose;
- if (VDBG) {
- dbg = true; // just override
- }
-
mDbg = dbg;
- awareStateManager.mDbg = dbg;
+ awareStateManager.enableVerboseLogging(dbg);
if (awareStateManager.mDataPathMgr != null) { // needed for unit tests
- awareStateManager.mDataPathMgr.mDbg = dbg;
- WifiInjector.getInstance().getWifiMetrics().getWifiAwareMetrics().mDbg = dbg;
+ awareStateManager.mDataPathMgr.enableVerboseLogging(dbg);
}
- wifiAwareNativeCallback.mDbg = dbg;
- wifiAwareNativeManager.mDbg = dbg;
- wifiAwareNativeApi.mDbg = dbg;
+ wifiAwareNativeCallback.enableVerboseLogging(dbg);
+ wifiAwareNativeManager.enableVerboseLogging(dbg);
+ wifiAwareNativeApi.enableVerboseLogging(dbg);
}
/**
@@ -278,7 +268,7 @@ public class WifiAwareServiceImpl extends IWifiAwareManager.Stub {
int uid = getMockableCallingUid();
enforceClientValidity(uid, clientId);
- if (VDBG) {
+ if (mDbg) {
Log.v(TAG, "terminateSession: sessionId=" + sessionId + ", uid=" + uid + ", clientId="
+ clientId);
}
@@ -307,7 +297,7 @@ public class WifiAwareServiceImpl extends IWifiAwareManager.Stub {
mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI_RTT));
enforceClientValidity(uid, clientId);
- if (VDBG) {
+ if (mDbg) {
Log.v(TAG, "publish: uid=" + uid + ", clientId=" + clientId + ", publishConfig="
+ publishConfig + ", callback=" + callback);
}
@@ -328,7 +318,7 @@ public class WifiAwareServiceImpl extends IWifiAwareManager.Stub {
int uid = getMockableCallingUid();
enforceClientValidity(uid, clientId);
- if (VDBG) {
+ if (mDbg) {
Log.v(TAG, "updatePublish: uid=" + uid + ", clientId=" + clientId + ", sessionId="
+ sessionId + ", config=" + publishConfig);
}
@@ -357,7 +347,7 @@ public class WifiAwareServiceImpl extends IWifiAwareManager.Stub {
mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI_RTT));
enforceClientValidity(uid, clientId);
- if (VDBG) {
+ if (mDbg) {
Log.v(TAG, "subscribe: uid=" + uid + ", clientId=" + clientId + ", config="
+ subscribeConfig + ", callback=" + callback);
}
@@ -378,7 +368,7 @@ public class WifiAwareServiceImpl extends IWifiAwareManager.Stub {
int uid = getMockableCallingUid();
enforceClientValidity(uid, clientId);
- if (VDBG) {
+ if (mDbg) {
Log.v(TAG, "updateSubscribe: uid=" + uid + ", clientId=" + clientId + ", sessionId="
+ sessionId + ", config=" + subscribeConfig);
}
@@ -408,7 +398,7 @@ public class WifiAwareServiceImpl extends IWifiAwareManager.Stub {
int uid = getMockableCallingUid();
enforceClientValidity(uid, clientId);
- if (VDBG) {
+ if (mDbg) {
Log.v(TAG,
"sendMessage: sessionId=" + sessionId + ", uid=" + uid + ", clientId="
+ clientId + ", peerId=" + peerId + ", messageId=" + messageId
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java b/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java
index f7a6032d2..73e2d043a 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareStateManager.java
@@ -77,9 +77,8 @@ import java.util.Map;
*/
public class WifiAwareStateManager implements WifiAwareShellCommand.DelegatedShellCommand {
private static final String TAG = "WifiAwareStateManager";
- private static final boolean VDBG = false; // STOPSHIP if true
- private static final boolean VVDBG = false; // STOPSHIP if true - for detailed state machine
- /* package */ boolean mDbg = false;
+ private static final boolean VDBG = false; // STOPSHIP if true - for detailed state machine
+ private boolean mDbg = false;
@VisibleForTesting
public static final String HAL_COMMAND_TIMEOUT_TAG = TAG + " HAL Command Timeout";
@@ -236,6 +235,14 @@ public class WifiAwareStateManager implements WifiAwareShellCommand.DelegatedShe
}
/**
+ * Enable verbose logging.
+ */
+ public void enableVerboseLogging(boolean verbose) {
+ mDbg = verbose | VDBG;
+ }
+
+
+ /**
* Inject references to other manager objects. Needed to resolve
* circular dependencies and to allow mocking.
*/
@@ -264,18 +271,15 @@ public class WifiAwareStateManager implements WifiAwareShellCommand.DelegatedShe
final PrintWriter pw_out = parentShell.getOutPrintWriter();
String subCmd = parentShell.getNextArgRequired();
- if (VDBG) Log.v(TAG, "onCommand: subCmd='" + subCmd + "'");
switch (subCmd) {
case "set": {
String name = parentShell.getNextArgRequired();
- if (VDBG) Log.v(TAG, "onCommand: name='" + name + "'");
if (!mSettableParameters.containsKey(name)) {
pw_err.println("Unknown parameter name -- '" + name + "'");
return -1;
}
String valueStr = parentShell.getNextArgRequired();
- if (VDBG) Log.v(TAG, "onCommand: valueStr='" + valueStr + "'");
int value;
try {
value = Integer.valueOf(valueStr);
@@ -288,7 +292,6 @@ public class WifiAwareStateManager implements WifiAwareShellCommand.DelegatedShe
}
case "get": {
String name = parentShell.getNextArgRequired();
- if (VDBG) Log.v(TAG, "onCommand: name='" + name + "'");
if (!mSettableParameters.containsKey(name)) {
pw_err.println("Unknown parameter name -- '" + name + "'");
return -1;
@@ -327,7 +330,6 @@ public class WifiAwareStateManager implements WifiAwareShellCommand.DelegatedShe
}
case "allow_ndp_any": {
String flag = parentShell.getNextArgRequired();
- if (VDBG) Log.v(TAG, "onCommand: flag='" + flag + "'");
if (mDataPathMgr == null) {
pw_err.println("Null Aware data-path manager - can't configure");
return -1;
@@ -389,7 +391,7 @@ public class WifiAwareStateManager implements WifiAwareShellCommand.DelegatedShe
mAwareMetrics = awareMetrics;
mWifiPermissionsUtil = wifiPermissionsUtil;
mSm = new WifiAwareStateMachine(TAG, looper);
- mSm.setDbg(VVDBG);
+ mSm.setDbg(VDBG);
mSm.start();
mDataPathMgr = new WifiAwareDataPathStateManager(this, clock);
@@ -408,7 +410,7 @@ public class WifiAwareStateManager implements WifiAwareShellCommand.DelegatedShe
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
- if (VDBG) Log.v(TAG, "BroadcastReceiver: action=" + action);
+ if (mDbg) Log.v(TAG, "BroadcastReceiver: action=" + action);
if (action.equals(Intent.ACTION_SCREEN_ON)
|| action.equals(Intent.ACTION_SCREEN_OFF)) {
reconfigure();
@@ -523,7 +525,7 @@ public class WifiAwareStateManager implements WifiAwareShellCommand.DelegatedShe
}
try {
- if (VDBG) Log.v(TAG, "requestMacAddresses: peerIdToMacMap=" + peerIdToMacMap);
+ if (mDbg) Log.v(TAG, "requestMacAddresses: peerIdToMacMap=" + peerIdToMacMap);
callback.macAddress(peerIdToMacMap);
} catch (RemoteException e) {
Log.e(TAG, "requestMacAddress (sync): exception on callback -- " + e);
@@ -1469,7 +1471,7 @@ public class WifiAwareStateManager implements WifiAwareShellCommand.DelegatedShe
int retryCount = sentMessage.getData()
.getInt(MESSAGE_BUNDLE_KEY_RETRY_COUNT);
if (retryCount > 0 && reason == NanStatusType.NO_OTA_ACK) {
- if (VDBG) {
+ if (mDbg) {
Log.v(TAG,
"NOTIFICATION_TYPE_ON_MESSAGE_SEND_FAIL: transactionId="
+ transactionId + ", reason=" + reason
@@ -1951,14 +1953,11 @@ public class WifiAwareStateManager implements WifiAwareShellCommand.DelegatedShe
* Only have to handle those COMMANDs which wait for a response.
*/
switch (msg.arg1) {
- case COMMAND_TYPE_CONNECT: {
+ case COMMAND_TYPE_CONNECT:
+ case COMMAND_TYPE_DISCONNECT:
onConfigFailedLocal(mCurrentCommand, NanStatusType.INTERNAL_FAILURE);
break;
- }
- case COMMAND_TYPE_DISCONNECT: {
- onConfigFailedLocal(mCurrentCommand, NanStatusType.INTERNAL_FAILURE);
- break;
- }
+
case COMMAND_TYPE_RECONFIGURE:
/*
* Reconfigure timed-out. There is nothing to do but log the issue - which
@@ -1970,19 +1969,12 @@ public class WifiAwareStateManager implements WifiAwareShellCommand.DelegatedShe
Log.wtf(TAG, "processTimeout: TERMINATE_SESSION - shouldn't be waiting!");
break;
}
- case COMMAND_TYPE_PUBLISH: {
- onSessionConfigFailLocal(mCurrentCommand, true, NanStatusType.INTERNAL_FAILURE);
- break;
- }
+ case COMMAND_TYPE_PUBLISH:
case COMMAND_TYPE_UPDATE_PUBLISH: {
onSessionConfigFailLocal(mCurrentCommand, true, NanStatusType.INTERNAL_FAILURE);
break;
}
- case COMMAND_TYPE_SUBSCRIBE: {
- onSessionConfigFailLocal(mCurrentCommand, false,
- NanStatusType.INTERNAL_FAILURE);
- break;
- }
+ case COMMAND_TYPE_SUBSCRIBE:
case COMMAND_TYPE_UPDATE_SUBSCRIBE: {
onSessionConfigFailLocal(mCurrentCommand, false,
NanStatusType.INTERNAL_FAILURE);
@@ -2240,7 +2232,7 @@ public class WifiAwareStateManager implements WifiAwareShellCommand.DelegatedShe
WifiAwareClientState client = new WifiAwareClientState(mContext, clientId, uid, pid,
callingPackage, callingFeatureId, callback, configRequest, notifyIdentityChange,
SystemClock.elapsedRealtime(), mWifiPermissionsUtil);
- client.mDbg = mDbg;
+ client.enableVerboseLogging(mDbg);
client.onInterfaceAddressChange(mCurrentDiscoveryInterfaceMac);
mClients.append(clientId, client);
mAwareMetrics.recordAttachSession(uid, notifyIdentityChange, mClients);
@@ -2604,7 +2596,7 @@ public class WifiAwareStateManager implements WifiAwareShellCommand.DelegatedShe
WifiAwareClientState client = new WifiAwareClientState(mContext, clientId, uid, pid,
callingPackage, callingFeatureId, callback, configRequest, notifyIdentityChange,
SystemClock.elapsedRealtime(), mWifiPermissionsUtil);
- client.mDbg = mDbg;
+ client.enableVerboseLogging(mDbg);
mClients.put(clientId, client);
mAwareMetrics.recordAttachSession(uid, notifyIdentityChange, mClients);
try {
@@ -2737,7 +2729,7 @@ public class WifiAwareStateManager implements WifiAwareShellCommand.DelegatedShe
WifiAwareDiscoverySessionState session = new WifiAwareDiscoverySessionState(
mWifiAwareNativeApi, sessionId, pubSubId, callback, isPublish, isRangingEnabled,
SystemClock.elapsedRealtime());
- session.mDbg = mDbg;
+ session.enableVerboseLogging(mDbg);
client.addSession(session);
if (isRangingEnabled) {
@@ -3140,7 +3132,7 @@ public class WifiAwareStateManager implements WifiAwareShellCommand.DelegatedShe
* If the configurations are "incompatible" (rules in comment below) return a null.
*/
private ConfigRequest mergeConfigRequests(ConfigRequest configRequest) {
- if (VDBG) {
+ if (mDbg) {
Log.v(TAG, "mergeConfigRequests(): mClients=[" + mClients + "], configRequest="
+ configRequest);
}