summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/java/com/android/server/wifi/nan/WifiNanClientState.java31
-rw-r--r--service/java/com/android/server/wifi/nan/WifiNanNative.java8
-rw-r--r--service/java/com/android/server/wifi/nan/WifiNanServiceImpl.java19
-rw-r--r--service/java/com/android/server/wifi/nan/WifiNanStateManager.java41
-rw-r--r--tests/wifitests/src/com/android/server/wifi/nan/WifiNanDataPathStateManagerTest.java16
-rw-r--r--tests/wifitests/src/com/android/server/wifi/nan/WifiNanHalTest.java6
-rw-r--r--tests/wifitests/src/com/android/server/wifi/nan/WifiNanManagerTest.java56
-rw-r--r--tests/wifitests/src/com/android/server/wifi/nan/WifiNanServiceImplTest.java13
-rw-r--r--tests/wifitests/src/com/android/server/wifi/nan/WifiNanStateManagerTest.java140
9 files changed, 141 insertions, 189 deletions
diff --git a/service/java/com/android/server/wifi/nan/WifiNanClientState.java b/service/java/com/android/server/wifi/nan/WifiNanClientState.java
index 6492893f3..03a2cd2e7 100644
--- a/service/java/com/android/server/wifi/nan/WifiNanClientState.java
+++ b/service/java/com/android/server/wifi/nan/WifiNanClientState.java
@@ -59,6 +59,7 @@ public class WifiNanClientState {
private final int mUid;
private final int mPid;
private final String mCallingPackage;
+ private final boolean mNotifyIdentityChange;
private AppOpsManager mAppOps;
@@ -66,7 +67,8 @@ public class WifiNanClientState {
private byte[] mLastDiscoveryInterfaceMac = ALL_ZERO_MAC;
public WifiNanClientState(Context context, int clientId, int uid, int pid,
- String callingPackage, IWifiNanEventCallback callback, ConfigRequest configRequest) {
+ String callingPackage, IWifiNanEventCallback callback, ConfigRequest configRequest,
+ boolean notifyIdentityChange) {
mContext = context;
mClientId = clientId;
mUid = uid;
@@ -74,6 +76,7 @@ public class WifiNanClientState {
mCallingPackage = callingPackage;
mCallback = callback;
mConfigRequest = configRequest;
+ mNotifyIdentityChange = notifyIdentityChange;
mAppOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
}
@@ -190,15 +193,12 @@ public class WifiNanClientState {
public void onInterfaceAddressChange(byte[] mac) {
if (VDBG) {
Log.v(TAG,
- "onInterfaceAddressChange: mClientId=" + mClientId
- + ", mEnableIdentityChangeCallback="
- + mConfigRequest.mEnableIdentityChangeCallback + ", mac="
- + String.valueOf(HexEncoding.encode(mac))
- + ", mLastDiscoveryInterfaceMac=" + String.valueOf(
- HexEncoding.encode(mLastDiscoveryInterfaceMac)));
+ "onInterfaceAddressChange: mClientId=" + mClientId + ", mNotifyIdentityChange="
+ + mNotifyIdentityChange + ", mac=" + String.valueOf(
+ HexEncoding.encode(mac)) + ", mLastDiscoveryInterfaceMac="
+ + String.valueOf(HexEncoding.encode(mLastDiscoveryInterfaceMac)));
}
- if (mConfigRequest.mEnableIdentityChangeCallback && !Arrays.equals(mac,
- mLastDiscoveryInterfaceMac)) {
+ if (mNotifyIdentityChange && !Arrays.equals(mac, mLastDiscoveryInterfaceMac)) {
try {
boolean hasPermission = hasLocationingPermission();
if (VDBG) Log.v(TAG, "hasPermission=" + hasPermission);
@@ -224,16 +224,15 @@ public class WifiNanClientState {
public void onClusterChange(int flag, byte[] mac, byte[] currentDiscoveryInterfaceMac) {
if (VDBG) {
Log.v(TAG,
- "onClusterChange: mClientId=" + mClientId + ", mEnableIdentityChangeCallback="
- + mConfigRequest.mEnableIdentityChangeCallback + ", mac="
- + String.valueOf(HexEncoding.encode(mac))
- + ", currentDiscoveryInterfaceMac=" + String.valueOf(
- HexEncoding.encode(currentDiscoveryInterfaceMac))
+ "onClusterChange: mClientId=" + mClientId + ", mNotifyIdentityChange="
+ + mNotifyIdentityChange + ", mac=" + String.valueOf(
+ HexEncoding.encode(mac)) + ", currentDiscoveryInterfaceMac="
+ + String.valueOf(HexEncoding.encode(currentDiscoveryInterfaceMac))
+ ", mLastDiscoveryInterfaceMac=" + String.valueOf(
HexEncoding.encode(mLastDiscoveryInterfaceMac)));
}
- if (mConfigRequest.mEnableIdentityChangeCallback && !Arrays.equals(
- currentDiscoveryInterfaceMac, mLastDiscoveryInterfaceMac)) {
+ if (mNotifyIdentityChange && !Arrays.equals(currentDiscoveryInterfaceMac,
+ mLastDiscoveryInterfaceMac)) {
try {
boolean hasPermission = hasLocationingPermission();
if (VDBG) Log.v(TAG, "hasPermission=" + hasPermission);
diff --git a/service/java/com/android/server/wifi/nan/WifiNanNative.java b/service/java/com/android/server/wifi/nan/WifiNanNative.java
index 7b22a593c..0a712a6d4 100644
--- a/service/java/com/android/server/wifi/nan/WifiNanNative.java
+++ b/service/java/com/android/server/wifi/nan/WifiNanNative.java
@@ -19,8 +19,8 @@ package com.android.server.wifi.nan;
import android.net.wifi.nan.ConfigRequest;
import android.net.wifi.nan.PublishConfig;
import android.net.wifi.nan.SubscribeConfig;
+import android.net.wifi.nan.WifiNanAttachCallback;
import android.net.wifi.nan.WifiNanDiscoverySessionCallback;
-import android.net.wifi.nan.WifiNanEventCallback;
import android.util.Log;
import com.android.server.wifi.WifiNative;
@@ -713,7 +713,7 @@ public class WifiNanNative {
/*
* TODO: b/27914592 all of these codes will be cleaned-up/reduced.
*/
- return WifiNanEventCallback.REASON_OTHER;
+ return WifiNanAttachCallback.REASON_OTHER;
case NAN_STATUS_INVALID_RSSI_CLOSE_VALUE:
case NAN_STATUS_INVALID_RSSI_MIDDLE_VALUE:
case NAN_STATUS_INVALID_HOP_COUNT_LIMIT:
@@ -740,10 +740,10 @@ public class WifiNanNative {
case NAN_STATUS_INVALID_ONGOING_SCAN_PERIOD:
case NAN_STATUS_INVALID_DW_INTERVAL_VALUE:
case NAN_STATUS_INVALID_DB_INTERVAL_VALUE:
- return WifiNanEventCallback.REASON_INVALID_ARGS;
+ return WifiNanAttachCallback.REASON_INVALID_ARGS;
}
- return WifiNanEventCallback.REASON_OTHER;
+ return WifiNanAttachCallback.REASON_OTHER;
}
private static int translateHalStatusToNanSessionCallbackTerminate(int halStatus) {
diff --git a/service/java/com/android/server/wifi/nan/WifiNanServiceImpl.java b/service/java/com/android/server/wifi/nan/WifiNanServiceImpl.java
index e21e41c8e..b7f319b52 100644
--- a/service/java/com/android/server/wifi/nan/WifiNanServiceImpl.java
+++ b/service/java/com/android/server/wifi/nan/WifiNanServiceImpl.java
@@ -25,8 +25,8 @@ import android.net.wifi.nan.IWifiNanEventCallback;
import android.net.wifi.nan.IWifiNanManager;
import android.net.wifi.nan.PublishConfig;
import android.net.wifi.nan.SubscribeConfig;
+import android.net.wifi.nan.WifiNanAttachCallback;
import android.net.wifi.nan.WifiNanDiscoveryBaseSession;
-import android.net.wifi.nan.WifiNanEventCallback;
import android.os.Binder;
import android.os.HandlerThread;
import android.os.IBinder;
@@ -131,7 +131,7 @@ public class WifiNanServiceImpl extends IWifiNanManager.Stub {
@Override
public void connect(final IBinder binder, String callingPackage, IWifiNanEventCallback callback,
- ConfigRequest configRequest) {
+ ConfigRequest configRequest, boolean notifyOnIdentityChanged) {
enforceAccessPermission();
enforceChangePermission();
if (callback == null) {
@@ -141,10 +141,12 @@ public class WifiNanServiceImpl extends IWifiNanManager.Stub {
throw new IllegalArgumentException("Binder must not be null");
}
+ if (notifyOnIdentityChanged) {
+ enforceLocationPermission();
+ }
+
if (configRequest != null) {
- if (configRequest.isNonDefaultOnTheAir()) {
- enforceConnectivityInternalPermission();
- }
+ enforceConnectivityInternalPermission();
} else {
configRequest = new ConfigRequest.Builder().build();
}
@@ -160,7 +162,7 @@ public class WifiNanServiceImpl extends IWifiNanManager.Stub {
if (VDBG) {
Log.v(TAG, "connect: uid=" + uid + ", clientId=" + clientId + ", configRequest"
- + configRequest);
+ + configRequest + ", notifyOnIdentityChanged=" + notifyOnIdentityChanged);
}
IBinder.DeathRecipient dr = new IBinder.DeathRecipient() {
@@ -183,7 +185,7 @@ public class WifiNanServiceImpl extends IWifiNanManager.Stub {
} catch (RemoteException e) {
Log.e(TAG, "Error on linkToDeath - " + e);
try {
- callback.onConnectFail(WifiNanEventCallback.REASON_OTHER);
+ callback.onConnectFail(WifiNanAttachCallback.REASON_OTHER);
} catch (RemoteException e1) {
Log.e(TAG, "Error on onConnectFail()");
}
@@ -195,7 +197,8 @@ public class WifiNanServiceImpl extends IWifiNanManager.Stub {
mUidByClientId.put(clientId, uid);
}
- mStateManager.connect(clientId, uid, pid, callingPackage, callback, configRequest);
+ mStateManager.connect(clientId, uid, pid, callingPackage, callback, configRequest,
+ notifyOnIdentityChanged);
}
@Override
diff --git a/service/java/com/android/server/wifi/nan/WifiNanStateManager.java b/service/java/com/android/server/wifi/nan/WifiNanStateManager.java
index 950adab43..8c1388f80 100644
--- a/service/java/com/android/server/wifi/nan/WifiNanStateManager.java
+++ b/service/java/com/android/server/wifi/nan/WifiNanStateManager.java
@@ -24,8 +24,8 @@ import android.net.wifi.nan.IWifiNanDiscoverySessionCallback;
import android.net.wifi.nan.IWifiNanEventCallback;
import android.net.wifi.nan.PublishConfig;
import android.net.wifi.nan.SubscribeConfig;
+import android.net.wifi.nan.WifiNanAttachCallback;
import android.net.wifi.nan.WifiNanDiscoverySessionCallback;
-import android.net.wifi.nan.WifiNanEventCallback;
import android.net.wifi.nan.WifiNanManager;
import android.os.Bundle;
import android.os.Looper;
@@ -169,6 +169,7 @@ public class WifiNanStateManager {
private static final String MESSAGE_BUNDLE_KEY_CALLING_PACKAGE = "calling_package";
private static final String MESSAGE_BUNDLE_KEY_SENT_MESSAGE = "send_message";
private static final String MESSAGE_BUNDLE_KEY_MESSAGE_ARRIVAL_SEQ = "message_arrival_seq";
+ private static final String MESSAGE_BUNDLE_KEY_NOTIFY_IDENTITY_CHANGE = "notify_identity_chg";
/*
* Asynchronous access with no lock
@@ -250,7 +251,8 @@ public class WifiNanStateManager {
* Place a request for a new client connection on the state machine queue.
*/
public void connect(int clientId, int uid, int pid, String callingPackage,
- IWifiNanEventCallback callback, ConfigRequest configRequest) {
+ IWifiNanEventCallback callback, ConfigRequest configRequest,
+ boolean notifyOnIdentityChanged) {
Message msg = mSm.obtainMessage(MESSAGE_TYPE_COMMAND);
msg.arg1 = COMMAND_TYPE_CONNECT;
msg.arg2 = clientId;
@@ -259,6 +261,8 @@ public class WifiNanStateManager {
msg.getData().putInt(MESSAGE_BUNDLE_KEY_UID, uid);
msg.getData().putInt(MESSAGE_BUNDLE_KEY_PID, pid);
msg.getData().putString(MESSAGE_BUNDLE_KEY_CALLING_PACKAGE, callingPackage);
+ msg.getData().putBoolean(MESSAGE_BUNDLE_KEY_NOTIFY_IDENTITY_CHANGE,
+ notifyOnIdentityChanged);
mSm.sendMessage(msg);
}
@@ -1186,9 +1190,11 @@ public class WifiNanStateManager {
int pid = msg.getData().getInt(MESSAGE_BUNDLE_KEY_PID);
String callingPackage = msg.getData().getString(
MESSAGE_BUNDLE_KEY_CALLING_PACKAGE);
+ boolean notifyIdentityChange = msg.getData().getBoolean(
+ MESSAGE_BUNDLE_KEY_NOTIFY_IDENTITY_CHANGE);
waitForResponse = connectLocal(mCurrentTransactionId, clientId, uid, pid,
- callingPackage, callback, configRequest);
+ callingPackage, callback, configRequest, notifyIdentityChange);
break;
}
case COMMAND_TYPE_DISCONNECT: {
@@ -1531,7 +1537,7 @@ public class WifiNanStateManager {
*/
switch (msg.arg1) {
case COMMAND_TYPE_CONNECT: {
- onConfigFailedLocal(mCurrentCommand, WifiNanEventCallback.REASON_OTHER);
+ onConfigFailedLocal(mCurrentCommand, WifiNanAttachCallback.REASON_OTHER);
break;
}
case COMMAND_TYPE_DISCONNECT: {
@@ -1539,7 +1545,7 @@ public class WifiNanStateManager {
* Will only get here on DISCONNECT if was downgrading. The
* callback will do a NOP - but should still call it.
*/
- onConfigFailedLocal(mCurrentCommand, WifiNanEventCallback.REASON_OTHER);
+ onConfigFailedLocal(mCurrentCommand, WifiNanAttachCallback.REASON_OTHER);
break;
}
case COMMAND_TYPE_TERMINATE_SESSION: {
@@ -1742,11 +1748,13 @@ public class WifiNanStateManager {
*/
private boolean connectLocal(short transactionId, int clientId, int uid, int pid,
- String callingPackage, IWifiNanEventCallback callback, ConfigRequest configRequest) {
+ String callingPackage, IWifiNanEventCallback callback, ConfigRequest configRequest,
+ boolean notifyIdentityChange) {
if (VDBG) {
Log.v(TAG, "connectLocal(): transactionId=" + transactionId + ", clientId=" + clientId
+ ", uid=" + uid + ", pid=" + pid + ", callingPackage=" + callingPackage
- + ", callback=" + callback + ", configRequest=" + configRequest);
+ + ", callback=" + callback + ", configRequest=" + configRequest
+ + ", notifyIdentityChange=" + notifyIdentityChange);
}
if (!mUsageEnabled) {
@@ -1759,10 +1767,10 @@ public class WifiNanStateManager {
}
if (mCurrentNanConfiguration != null
- && !mCurrentNanConfiguration.equalsOnTheAir(configRequest)) {
+ && !mCurrentNanConfiguration.equals(configRequest)) {
try {
callback.onConnectFail(
- WifiNanEventCallback.REASON_ALREADY_CONNECTED_INCOMPAT_CONFIG);
+ WifiNanAttachCallback.REASON_ALREADY_CONNECTED_INCOMPAT_CONFIG);
} catch (RemoteException e) {
Log.w(TAG, "connectLocal onConnectFail(): RemoteException (FYI): " + e);
}
@@ -1777,7 +1785,7 @@ public class WifiNanStateManager {
Log.w(TAG, "connectLocal onConnectSuccess(): RemoteException (FYI): " + e);
}
WifiNanClientState client = new WifiNanClientState(mContext, clientId, uid, pid,
- callingPackage, callback, configRequest);
+ callingPackage, callback, configRequest, notifyIdentityChange);
client.onInterfaceAddressChange(mCurrentDiscoveryInterfaceMac);
mClients.append(clientId, client);
return false;
@@ -2063,10 +2071,12 @@ public class WifiNanStateManager {
.getParcelable(MESSAGE_BUNDLE_KEY_CONFIG);
int uid = data.getInt(MESSAGE_BUNDLE_KEY_UID);
int pid = data.getInt(MESSAGE_BUNDLE_KEY_PID);
+ boolean notifyIdentityChange = data.getBoolean(
+ MESSAGE_BUNDLE_KEY_NOTIFY_IDENTITY_CHANGE);
String callingPackage = data.getString(MESSAGE_BUNDLE_KEY_CALLING_PACKAGE);
WifiNanClientState client = new WifiNanClientState(mContext, clientId, uid, pid,
- callingPackage, callback, configRequest);
+ callingPackage, callback, configRequest, notifyIdentityChange);
mClients.put(clientId, client);
try {
callback.onConnectSuccess(clientId);
@@ -2506,14 +2516,12 @@ public class WifiNanStateManager {
boolean clusterIdValid = false;
int clusterLow = 0;
int clusterHigh = ConfigRequest.CLUSTER_ID_MAX;
- boolean identityChange = false;
if (configRequest != null) {
support5gBand = configRequest.mSupport5gBand;
masterPreference = configRequest.mMasterPreference;
clusterIdValid = true;
clusterLow = configRequest.mClusterLow;
clusterHigh = configRequest.mClusterHigh;
- identityChange = configRequest.mEnableIdentityChangeCallback;
}
for (int i = 0; i < mClients.size(); ++i) {
ConfigRequest cr = mClients.valueAt(i).getConfigRequest();
@@ -2534,15 +2542,10 @@ public class WifiNanStateManager {
}
clusterIdValid = true;
}
-
- if (cr.mEnableIdentityChangeCallback) {
- identityChange = true;
- }
}
return new ConfigRequest.Builder().setSupport5gBand(support5gBand)
.setMasterPreference(masterPreference).setClusterLow(clusterLow)
- .setClusterHigh(clusterHigh).setEnableIdentityChangeCallback(identityChange)
- .build();
+ .setClusterHigh(clusterHigh).build();
}
private static String messageToString(Message msg) {
diff --git a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanDataPathStateManagerTest.java b/tests/wifitests/src/com/android/server/wifi/nan/WifiNanDataPathStateManagerTest.java
index 8b96ef1ed..32b66dc0f 100644
--- a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanDataPathStateManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/nan/WifiNanDataPathStateManagerTest.java
@@ -46,8 +46,8 @@ import android.net.wifi.nan.IWifiNanEventCallback;
import android.net.wifi.nan.IWifiNanManager;
import android.net.wifi.nan.PublishConfig;
import android.net.wifi.nan.SubscribeConfig;
+import android.net.wifi.nan.WifiNanAttachCallback;
import android.net.wifi.nan.WifiNanDiscoverySessionCallback;
-import android.net.wifi.nan.WifiNanEventCallback;
import android.net.wifi.nan.WifiNanManager;
import android.net.wifi.nan.WifiNanPublishDiscoverySession;
import android.net.wifi.nan.WifiNanSession;
@@ -607,13 +607,13 @@ public class WifiNanDataPathStateManagerTest {
ArgumentCaptor<WifiNanPublishDiscoverySession> publishSession = ArgumentCaptor
.forClass(WifiNanPublishDiscoverySession.class);
- WifiNanEventCallback mockCallback = mock(WifiNanEventCallback.class);
+ WifiNanAttachCallback mockCallback = mock(WifiNanAttachCallback.class);
WifiNanDiscoverySessionCallback mockSessionCallback = mock(
WifiNanDiscoverySessionCallback.class);
- mgr.attach(mMockLooperHandler, configRequest, mockCallback);
+ mgr.attach(mMockLooperHandler, configRequest, mockCallback, null);
verify(mMockNanService).connect(any(IBinder.class), anyString(),
- clientProxyCallback.capture(), eq(configRequest));
+ clientProxyCallback.capture(), eq(configRequest), eq(false));
clientProxyCallback.getValue().onConnectSuccess(clientId);
mMockLooper.dispatchAll();
verify(mockCallback).onAttached(sessionCaptor.capture());
@@ -650,11 +650,11 @@ public class WifiNanDataPathStateManagerTest {
ArgumentCaptor<IWifiNanEventCallback> clientProxyCallback = ArgumentCaptor
.forClass(IWifiNanEventCallback.class);
- WifiNanEventCallback mockCallback = mock(WifiNanEventCallback.class);
+ WifiNanAttachCallback mockCallback = mock(WifiNanAttachCallback.class);
- mgr.attach(mMockLooperHandler, configRequest, mockCallback);
+ mgr.attach(mMockLooperHandler, configRequest, mockCallback, null);
verify(mMockNanService).connect(any(IBinder.class), anyString(),
- clientProxyCallback.capture(), eq(configRequest));
+ clientProxyCallback.capture(), eq(configRequest), eq(false));
clientProxyCallback.getValue().onConnectSuccess(clientId);
mMockLooper.dispatchAll();
verify(mockCallback).onAttached(sessionCaptor.capture());
@@ -715,7 +715,7 @@ public class WifiNanDataPathStateManagerTest {
mMockLooper.dispatchAll();
// (3) create client & session & rx message
- mDut.connect(clientId, uid, pid, callingPackage, mMockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mMockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
eq(configRequest), eq(true));
diff --git a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanHalTest.java b/tests/wifitests/src/com/android/server/wifi/nan/WifiNanHalTest.java
index 2a607691e..d073d4dae 100644
--- a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanHalTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/nan/WifiNanHalTest.java
@@ -26,8 +26,8 @@ import android.net.wifi.nan.ConfigRequest;
import android.net.wifi.nan.PublishConfig;
import android.net.wifi.nan.SubscribeConfig;
import android.net.wifi.nan.TlvBufferUtils;
+import android.net.wifi.nan.WifiNanAttachCallback;
import android.net.wifi.nan.WifiNanDiscoverySessionCallback;
-import android.net.wifi.nan.WifiNanEventCallback;
import android.os.Bundle;
import android.test.suitebuilder.annotation.SmallTest;
@@ -379,7 +379,7 @@ public class WifiNanHalTest {
HalMockUtils.convertBundleToJson(args).toString());
verify(mNanStateManager).onConfigFailedResponse(transactionId,
- WifiNanEventCallback.REASON_INVALID_ARGS);
+ WifiNanAttachCallback.REASON_INVALID_ARGS);
verifyNoMoreInteractions(mNanStateManager);
}
@@ -768,7 +768,7 @@ public class WifiNanHalTest {
WifiNanHalMock.callDisabled(HalMockUtils.convertBundleToJson(args).toString());
- verify(mNanStateManager).onNanDownNotification(WifiNanEventCallback.REASON_OTHER);
+ verify(mNanStateManager).onNanDownNotification(WifiNanAttachCallback.REASON_OTHER);
verifyNoMoreInteractions(mNanStateManager);
}
diff --git a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanManagerTest.java b/tests/wifitests/src/com/android/server/wifi/nan/WifiNanManagerTest.java
index 4a633760f..4bebfb7f1 100644
--- a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/nan/WifiNanManagerTest.java
@@ -36,8 +36,8 @@ import android.net.wifi.nan.IWifiNanEventCallback;
import android.net.wifi.nan.IWifiNanManager;
import android.net.wifi.nan.PublishConfig;
import android.net.wifi.nan.SubscribeConfig;
+import android.net.wifi.nan.WifiNanAttachCallback;
import android.net.wifi.nan.WifiNanDiscoverySessionCallback;
-import android.net.wifi.nan.WifiNanEventCallback;
import android.net.wifi.nan.WifiNanManager;
import android.net.wifi.nan.WifiNanPublishDiscoverySession;
import android.net.wifi.nan.WifiNanSession;
@@ -77,7 +77,7 @@ public class WifiNanManagerTest {
public Context mockContext;
@Mock
- public WifiNanEventCallback mockCallback;
+ public WifiNanAttachCallback mockCallback;
@Mock
public WifiNanDiscoverySessionCallback mockSessionCallback;
@@ -159,7 +159,7 @@ public class WifiNanManagerTest {
// (1) connect + success
mDut.attach(mMockLooperHandler, mockCallback);
inOrder.verify(mockNanService).connect(binder.capture(), anyString(),
- clientProxyCallback.capture(), (ConfigRequest) isNull());
+ clientProxyCallback.capture(), (ConfigRequest) isNull(), eq(false));
clientProxyCallback.getValue().onConnectSuccess(clientId);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onAttached(sessionCaptor.capture());
@@ -181,7 +181,7 @@ public class WifiNanManagerTest {
// (5) connect
mDut.attach(mMockLooperHandler, mockCallback);
inOrder.verify(mockNanService).connect(binder.capture(), anyString(),
- any(IWifiNanEventCallback.class), (ConfigRequest) isNull());
+ any(IWifiNanEventCallback.class), (ConfigRequest) isNull(), eq(false));
verifyNoMoreInteractions(mockCallback, mockSessionCallback, mockNanService);
}
@@ -192,7 +192,7 @@ public class WifiNanManagerTest {
@Test
public void testConnectFailure() throws Exception {
final int clientId = 4565;
- final int reason = WifiNanEventCallback.REASON_OTHER;
+ final int reason = WifiNanAttachCallback.REASON_OTHER;
InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mockNanService);
ArgumentCaptor<WifiNanSession> sessionCaptor = ArgumentCaptor.forClass(
@@ -203,7 +203,7 @@ public class WifiNanManagerTest {
// (1) connect + failure
mDut.attach(mMockLooperHandler, mockCallback);
inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(),
- clientProxyCallback.capture(), (ConfigRequest) isNull());
+ clientProxyCallback.capture(), (ConfigRequest) isNull(), eq(false));
clientProxyCallback.getValue().onConnectFail(reason);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onAttachFailed(reason);
@@ -211,7 +211,7 @@ public class WifiNanManagerTest {
// (2) connect + success
mDut.attach(mMockLooperHandler, mockCallback);
inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(),
- clientProxyCallback.capture(), (ConfigRequest) isNull());
+ clientProxyCallback.capture(), (ConfigRequest) isNull(), eq(false));
clientProxyCallback.getValue().onConnectSuccess(clientId);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onAttached(sessionCaptor.capture());
@@ -241,7 +241,7 @@ public class WifiNanManagerTest {
// (1) connect + success
mDut.attach(mMockLooperHandler, mockCallback);
inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(),
- clientProxyCallback.capture(), (ConfigRequest) isNull());
+ clientProxyCallback.capture(), (ConfigRequest) isNull(), eq(false));
clientProxyCallback.getValue().onConnectSuccess(clientId);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onAttached(any(WifiNanSession.class));
@@ -249,7 +249,7 @@ public class WifiNanManagerTest {
// (2) connect + success
mDut.attach(mMockLooperHandler, mockCallback);
inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(),
- clientProxyCallback.capture(), (ConfigRequest) isNull());
+ clientProxyCallback.capture(), (ConfigRequest) isNull(), eq(false));
clientProxyCallback.getValue().onConnectSuccess(clientId + 1);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onAttached(any(WifiNanSession.class));
@@ -291,9 +291,9 @@ public class WifiNanManagerTest {
.forClass(WifiNanPublishDiscoverySession.class);
// (0) connect + success
- mDut.attach(mMockLooperHandler, configRequest, mockCallback);
+ mDut.attach(mMockLooperHandler, configRequest, mockCallback, null);
inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(),
- clientProxyCallback.capture(), eq(configRequest));
+ clientProxyCallback.capture(), eq(configRequest), eq(false));
clientProxyCallback.getValue().onConnectSuccess(clientId);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onAttached(sessionCaptor.capture());
@@ -370,9 +370,9 @@ public class WifiNanManagerTest {
.forClass(WifiNanPublishDiscoverySession.class);
// (1) connect successfully
- mDut.attach(mMockLooperHandler, configRequest, mockCallback);
+ mDut.attach(mMockLooperHandler, configRequest, mockCallback, null);
inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(),
- clientProxyCallback.capture(), eq(configRequest));
+ clientProxyCallback.capture(), eq(configRequest), eq(false));
clientProxyCallback.getValue().onConnectSuccess(clientId);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onAttached(sessionCaptor.capture());
@@ -425,9 +425,9 @@ public class WifiNanManagerTest {
.forClass(WifiNanSubscribeDiscoverySession.class);
// (0) connect + success
- mDut.attach(mMockLooperHandler, configRequest, mockCallback);
+ mDut.attach(mMockLooperHandler, configRequest, mockCallback, null);
inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(),
- clientProxyCallback.capture(), eq(configRequest));
+ clientProxyCallback.capture(), eq(configRequest), eq(false));
clientProxyCallback.getValue().onConnectSuccess(clientId);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onAttached(sessionCaptor.capture());
@@ -504,9 +504,9 @@ public class WifiNanManagerTest {
.forClass(WifiNanSubscribeDiscoverySession.class);
// (1) connect successfully
- mDut.attach(mMockLooperHandler, configRequest, mockCallback);
+ mDut.attach(mMockLooperHandler, configRequest, mockCallback, null);
inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(),
- clientProxyCallback.capture(), eq(configRequest));
+ clientProxyCallback.capture(), eq(configRequest), eq(false));
clientProxyCallback.getValue().onConnectSuccess(clientId);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onAttached(sessionCaptor.capture());
@@ -544,8 +544,6 @@ public class WifiNanManagerTest {
collector.checkThat("mMasterPreference", 0,
equalTo(configRequest.mMasterPreference));
collector.checkThat("mSupport5gBand", false, equalTo(configRequest.mSupport5gBand));
- collector.checkThat("mEnableIdentityChangeCallback", false,
- equalTo(configRequest.mEnableIdentityChangeCallback));
}
@Test
@@ -554,20 +552,17 @@ public class WifiNanManagerTest {
final int clusterLow = 5;
final int masterPreference = 55;
final boolean supportBand5g = true;
- final boolean enableIdentityChangeCallback = true;
ConfigRequest configRequest = new ConfigRequest.Builder().setClusterHigh(clusterHigh)
.setClusterLow(clusterLow).setMasterPreference(masterPreference)
.setSupport5gBand(supportBand5g)
- .setEnableIdentityChangeCallback(enableIdentityChangeCallback).build();
+ .build();
collector.checkThat("mClusterHigh", clusterHigh, equalTo(configRequest.mClusterHigh));
collector.checkThat("mClusterLow", clusterLow, equalTo(configRequest.mClusterLow));
collector.checkThat("mMasterPreference", masterPreference,
equalTo(configRequest.mMasterPreference));
collector.checkThat("mSupport5gBand", supportBand5g, equalTo(configRequest.mSupport5gBand));
- collector.checkThat("mEnableIdentityChangeCallback", enableIdentityChangeCallback,
- equalTo(configRequest.mEnableIdentityChangeCallback));
}
@Test(expected = IllegalArgumentException.class)
@@ -622,12 +617,11 @@ public class WifiNanManagerTest {
final int clusterLow = 25;
final int masterPreference = 177;
final boolean supportBand5g = true;
- final boolean enableIdentityChangeCallback = true;
ConfigRequest configRequest = new ConfigRequest.Builder().setClusterHigh(clusterHigh)
.setClusterLow(clusterLow).setMasterPreference(masterPreference)
.setSupport5gBand(supportBand5g)
- .setEnableIdentityChangeCallback(enableIdentityChangeCallback).build();
+ .build();
Parcel parcelW = Parcel.obtain();
configRequest.writeToParcel(parcelW, 0);
@@ -880,9 +874,9 @@ public class WifiNanManagerTest {
.forClass(RttManager.RttResult[].class);
// (1) connect successfully
- mDut.attach(mMockLooperHandler, configRequest, mockCallback);
+ mDut.attach(mMockLooperHandler, configRequest, mockCallback, null);
inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(),
- clientProxyCallback.capture(), eq(configRequest));
+ clientProxyCallback.capture(), eq(configRequest), eq(false));
clientProxyCallback.getValue().onConnectSuccess(clientId);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onAttached(sessionCaptor.capture());
@@ -954,9 +948,9 @@ public class WifiNanManagerTest {
mockPublishSession, mockRttListener);
// (1) connect successfully
- mDut.attach(mMockLooperHandler, configRequest, mockCallback);
+ mDut.attach(mMockLooperHandler, configRequest, mockCallback, null);
inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(),
- clientProxyCallback.capture(), eq(configRequest));
+ clientProxyCallback.capture(), eq(configRequest), eq(false));
clientProxyCallback.getValue().onConnectSuccess(clientId);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onAttached(sessionCaptor.capture());
@@ -1014,9 +1008,9 @@ public class WifiNanManagerTest {
mockPublishSession, mockRttListener);
// (1) connect successfully
- mDut.attach(mMockLooperHandler, configRequest, mockCallback);
+ mDut.attach(mMockLooperHandler, configRequest, mockCallback, null);
inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(),
- clientProxyCallback.capture(), eq(configRequest));
+ clientProxyCallback.capture(), eq(configRequest), eq(false));
clientProxyCallback.getValue().onConnectSuccess(clientId);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback).onAttached(sessionCaptor.capture());
diff --git a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/nan/WifiNanServiceImplTest.java
index f7077afd7..13912e9b6 100644
--- a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanServiceImplTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/nan/WifiNanServiceImplTest.java
@@ -171,10 +171,10 @@ public class WifiNanServiceImplTest {
String callingPackage = "com.google.somePackage";
mDut.connect(mBinderMock, callingPackage, mCallbackMock,
- configRequest);
+ configRequest, false);
verify(mNanStateManagerMock).connect(anyInt(), anyInt(), anyInt(),
- eq(callingPackage), eq(mCallbackMock), eq(configRequest));
+ eq(callingPackage), eq(mCallbackMock), eq(configRequest), eq(false));
}
/**
@@ -278,9 +278,9 @@ public class WifiNanServiceImplTest {
int prevId = 0;
for (int i = 0; i < loopCount; ++i) {
- mDut.connect(mBinderMock, "", mCallbackMock, null);
+ mDut.connect(mBinderMock, "", mCallbackMock, null, false);
inOrder.verify(mNanStateManagerMock).connect(clientIdCaptor.capture(), anyInt(),
- anyInt(), anyString(), eq(mCallbackMock), any(ConfigRequest.class));
+ anyInt(), anyString(), eq(mCallbackMock), any(ConfigRequest.class), eq(false));
int id = clientIdCaptor.getValue();
if (i != 0) {
assertTrue("Client ID incrementing", id > prevId);
@@ -495,11 +495,12 @@ public class WifiNanServiceImplTest {
private int doConnect() {
String callingPackage = "com.google.somePackage";
- mDut.connect(mBinderMock, callingPackage, mCallbackMock, null);
+ mDut.connect(mBinderMock, callingPackage, mCallbackMock, null, false);
ArgumentCaptor<Integer> clientId = ArgumentCaptor.forClass(Integer.class);
verify(mNanStateManagerMock).connect(clientId.capture(), anyInt(), anyInt(),
- eq(callingPackage), eq(mCallbackMock), eq(new ConfigRequest.Builder().build()));
+ eq(callingPackage), eq(mCallbackMock), eq(new ConfigRequest.Builder().build()),
+ eq(false));
return clientId.getValue();
}
diff --git a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanStateManagerTest.java b/tests/wifitests/src/com/android/server/wifi/nan/WifiNanStateManagerTest.java
index cb78f7232..94a969b3d 100644
--- a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanStateManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/nan/WifiNanStateManagerTest.java
@@ -47,8 +47,8 @@ import android.net.wifi.nan.IWifiNanDiscoverySessionCallback;
import android.net.wifi.nan.IWifiNanEventCallback;
import android.net.wifi.nan.PublishConfig;
import android.net.wifi.nan.SubscribeConfig;
+import android.net.wifi.nan.WifiNanAttachCallback;
import android.net.wifi.nan.WifiNanDiscoverySessionCallback;
-import android.net.wifi.nan.WifiNanEventCallback;
import android.net.wifi.nan.WifiNanManager;
import android.os.Message;
import android.os.UserHandle;
@@ -207,7 +207,7 @@ public class WifiNanStateManagerTest {
// (3) try connecting and validate that get nothing (app should be aware of non-availability
// through state change broadcast and/or query API)
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
verifyNoMoreInteractions(mMockNative, mockCallback);
@@ -242,7 +242,7 @@ public class WifiNanStateManagerTest {
collector.checkThat("usage enabled", mDut.isUsageEnabled(), equalTo(true));
// (2) connect (successfully)
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -260,7 +260,7 @@ public class WifiNanStateManagerTest {
validateInternalClientInfoCleanedUp(clientId);
// (4) try connecting again and validate that just get an onNanDown
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
// (5) disable usage again and validate that not much happens
@@ -276,7 +276,7 @@ public class WifiNanStateManagerTest {
validateCorrectNanStatusChangeBroadcast(inOrder, true);
// (7) connect (should be successful)
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -301,17 +301,13 @@ public class WifiNanStateManagerTest {
final int uid = 1000;
final int pid = 2000;
final String callingPackage = "com.google.somePackage";
- final int reason = WifiNanEventCallback.REASON_OTHER;
+ final int reason = WifiNanAttachCallback.REASON_OTHER;
final byte[] someMac = HexEncoding.decode("000102030405".toCharArray(), false);
final byte[] someMac2 = HexEncoding.decode("060708090A0B".toCharArray(), false);
- ConfigRequest configRequest1 = new ConfigRequest.Builder().setClusterLow(clusterLow)
- .setClusterHigh(clusterHigh).setMasterPreference(masterPref)
- .setEnableIdentityChangeCallback(false).build();
-
- ConfigRequest configRequest2 = new ConfigRequest.Builder().setClusterLow(clusterLow)
+ ConfigRequest configRequest = new ConfigRequest.Builder().setClusterLow(clusterLow)
.setClusterHigh(clusterHigh).setMasterPreference(masterPref)
- .setEnableIdentityChangeCallback(true).build();
+ .build();
IWifiNanEventCallback mockCallback1 = mock(IWifiNanEventCallback.class);
IWifiNanEventCallback mockCallback2 = mock(IWifiNanEventCallback.class);
@@ -326,44 +322,36 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect 1st and 2nd clients
- mDut.connect(clientId1, uid, pid, callingPackage, mockCallback1, configRequest1);
- mDut.connect(clientId2, uid, pid, callingPackage, mockCallback2, configRequest2);
+ mDut.connect(clientId1, uid, pid, callingPackage, mockCallback1, configRequest, false);
+ mDut.connect(clientId2, uid, pid, callingPackage, mockCallback2, configRequest, true);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionIdCapture.capture(),
- eq(configRequest1), eq(true));
+ eq(configRequest), eq(true));
short transactionId = transactionIdCapture.getValue();
mDut.onConfigSuccessResponse(transactionId);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback1).onConnectSuccess(clientId1);
-
- // (2) finish connection of 2nd client
- inOrder.verify(mMockNative).enableAndConfigure(transactionIdCapture.capture(),
- eq(configRequest2), eq(false));
- transactionId = transactionIdCapture.getValue();
- mDut.onConfigSuccessResponse(transactionId);
- mMockLooper.dispatchAll();
-
inOrder.verify(mockCallback2).onConnectSuccess(clientId2);
- // (3) deliver NAN events - without LOCATIONING permission
+ // (2) deliver NAN events - without LOCATIONING permission
mDut.onClusterChangeNotification(WifiNanClientState.CLUSTER_CHANGE_EVENT_STARTED, someMac);
mDut.onInterfaceAddressChangeNotification(someMac);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback2).onIdentityChanged(ALL_ZERO_MAC);
- // (4) deliver new identity - still without LOCATIONING permission (should get an event)
+ // (3) deliver new identity - still without LOCATIONING permission (should get an event)
mDut.onInterfaceAddressChangeNotification(someMac2);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback2).onIdentityChanged(ALL_ZERO_MAC);
- // (5) deliver same identity - still without LOCATIONING permission (should
+ // (4) deliver same identity - still without LOCATIONING permission (should
// not get an event)
mDut.onInterfaceAddressChangeNotification(someMac2);
mMockLooper.dispatchAll();
- // (6) deliver new identity - with LOCATIONING permission
+ // (5) deliver new identity - with LOCATIONING permission
when(mMockContext.checkPermission(eq(Manifest.permission.ACCESS_COARSE_LOCATION),
anyInt(), anyInt())).thenReturn(PackageManager.PERMISSION_GRANTED);
when(mMockAppOpsManager.noteOp(eq(AppOpsManager.OP_COARSE_LOCATION), anyInt(),
@@ -373,7 +361,7 @@ public class WifiNanStateManagerTest {
inOrder.verify(mockCallback2).onIdentityChanged(someMac);
- // (7) NAN down (no feedback)
+ // (6) NAN down (no feedback)
mDut.onNanDownNotification(reason);
mMockLooper.dispatchAll();
@@ -412,7 +400,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect (successfully)
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -470,7 +458,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
eq(configRequest), eq(true));
@@ -525,7 +513,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
eq(configRequest), eq(true));
@@ -599,7 +587,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -673,7 +661,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -732,7 +720,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -787,7 +775,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -860,7 +848,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -934,7 +922,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -1008,7 +996,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
eq(configRequest), eq(true));
@@ -1115,7 +1103,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -1210,7 +1198,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -1294,7 +1282,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -1361,7 +1349,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -1455,7 +1443,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -1542,7 +1530,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -1633,7 +1621,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (0) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
eq(configRequest), eq(true));
@@ -1749,7 +1737,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -1917,7 +1905,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -1970,23 +1958,17 @@ public class WifiNanStateManagerTest {
final int clusterLow2 = 7;
final int clusterHigh2 = 155;
final int masterPref2 = 0;
- final int clientId3 = 55;
ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class);
ArgumentCaptor<ConfigRequest> crCapture = ArgumentCaptor.forClass(ConfigRequest.class);
ConfigRequest configRequest1 = new ConfigRequest.Builder().setClusterLow(clusterLow1)
- .setClusterHigh(clusterHigh1).setMasterPreference(masterPref1)
- .setEnableIdentityChangeCallback(false).build();
+ .setClusterHigh(clusterHigh1).setMasterPreference(masterPref1).build();
ConfigRequest configRequest2 = new ConfigRequest.Builder().setSupport5gBand(support5g2)
.setClusterLow(clusterLow2).setClusterHigh(clusterHigh2)
.setMasterPreference(masterPref2).build();
- ConfigRequest configRequest3 = new ConfigRequest.Builder().setClusterLow(clusterLow1)
- .setClusterHigh(clusterHigh1).setMasterPreference(masterPref1)
- .setEnableIdentityChangeCallback(true).build();
-
IWifiNanEventCallback mockCallback1 = mock(IWifiNanEventCallback.class);
IWifiNanEventCallback mockCallback2 = mock(IWifiNanEventCallback.class);
IWifiNanEventCallback mockCallback3 = mock(IWifiNanEventCallback.class);
@@ -2001,7 +1983,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) config1 (valid)
- mDut.connect(clientId1, uid, pid, callingPackage, mockCallback1, configRequest1);
+ mDut.connect(clientId1, uid, pid, callingPackage, mockCallback1, configRequest1, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
crCapture.capture(), eq(true));
@@ -2011,42 +1993,12 @@ public class WifiNanStateManagerTest {
inOrder.verify(mockCallback1).onConnectSuccess(clientId1);
// (2) config2 (incompatible with config1)
- mDut.connect(clientId2, uid, pid, callingPackage, mockCallback2, configRequest2);
+ mDut.connect(clientId2, uid, pid, callingPackage, mockCallback2, configRequest2, false);
mMockLooper.dispatchAll();
inOrder.verify(mockCallback2)
- .onConnectFail(WifiNanEventCallback.REASON_ALREADY_CONNECTED_INCOMPAT_CONFIG);
+ .onConnectFail(WifiNanAttachCallback.REASON_ALREADY_CONNECTED_INCOMPAT_CONFIG);
validateInternalClientInfoCleanedUp(clientId2);
- // (3) config3 (compatible with config1 but requires upgrade - i.e. no
- // OTA changes)
- mDut.connect(clientId3, uid, pid, callingPackage, mockCallback3, configRequest3);
- mMockLooper.dispatchAll();
- inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
- crCapture.capture(), eq(false));
- collector.checkThat("merge: stage 3: support 5g", crCapture.getValue().mSupport5gBand,
- equalTo(false));
- collector.checkThat("merge: stage 3: master pref", crCapture.getValue().mMasterPreference,
- equalTo(masterPref1));
- collector.checkThat("merge: stage 3: cluster low", crCapture.getValue().mClusterLow,
- equalTo(clusterLow1));
- collector.checkThat("merge: stage 3: cluster high", crCapture.getValue().mClusterHigh,
- equalTo(clusterHigh1));
- collector.checkThat("merge: stage 3: enable identity change callback",
- crCapture.getValue().mEnableIdentityChangeCallback, equalTo(true));
- mDut.onConfigSuccessResponse(transactionId.getValue());
- mMockLooper.dispatchAll();
- inOrder.verify(mockCallback3).onConnectSuccess(clientId3);
-
- // (4) disconnect config3: want a downgrade
- mDut.disconnect(clientId3);
- mMockLooper.dispatchAll();
- validateInternalClientInfoCleanedUp(clientId3);
- inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
- crCapture.capture(), eq(false));
- collector.checkThat("merge: stage 4", crCapture.getValue(), equalTo(configRequest1));
- mDut.onConfigSuccessResponse(transactionId.getValue());
- mMockLooper.dispatchAll();
-
// (5) disconnect config1: disable
mDut.disconnect(clientId1);
mMockLooper.dispatchAll();
@@ -2095,7 +2047,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -2171,7 +2123,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -2215,7 +2167,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect (no response)
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -2250,7 +2202,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect and succeed
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -2307,7 +2259,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(), eq(configRequest),
eq(true));
@@ -2363,7 +2315,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
eq(configRequest), eq(true));
@@ -2417,7 +2369,7 @@ public class WifiNanStateManagerTest {
mMockLooper.dispatchAll();
// (1) connect
- mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest);
+ mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false);
mMockLooper.dispatchAll();
inOrder.verify(mMockNative).enableAndConfigure(transactionId.capture(),
eq(configRequest), eq(true));