diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/wifitests/Android.mk | 8 | ||||
-rw-r--r-- | tests/wifitests/jni/wifi_aware_hal_mock.cpp (renamed from tests/wifitests/jni/wifi_nan_hal_mock.cpp) | 106 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java | 10 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/aware/TlvBufferUtilsTest.java (renamed from tests/wifitests/src/com/android/server/wifi/nan/TlvBufferUtilsTest.java) | 8 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java (renamed from tests/wifitests/src/com/android/server/wifi/nan/WifiNanDataPathStateManagerTest.java) | 191 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/aware/WifiAwareHalMock.java (renamed from tests/wifitests/src/com/android/server/wifi/nan/WifiNanHalMock.java) | 20 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/aware/WifiAwareHalTest.java (renamed from tests/wifitests/src/com/android/server/wifi/nan/WifiNanHalTest.java) | 421 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/aware/WifiAwareManagerTest.java (renamed from tests/wifitests/src/com/android/server/wifi/nan/WifiNanManagerTest.java) | 356 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/aware/WifiAwareRttStateManagerTest.java (renamed from tests/wifitests/src/com/android/server/wifi/nan/WifiNanRttStateManagerTest.java) | 12 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/aware/WifiAwareServiceImplTest.java (renamed from tests/wifitests/src/com/android/server/wifi/nan/WifiNanServiceImplTest.java) | 120 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/aware/WifiAwareStateManagerTest.java (renamed from tests/wifitests/src/com/android/server/wifi/nan/WifiNanStateManagerTest.java) | 480 |
11 files changed, 874 insertions, 858 deletions
diff --git a/tests/wifitests/Android.mk b/tests/wifitests/Android.mk index e0ca76b9c..08677bb8b 100644 --- a/tests/wifitests/Android.mk +++ b/tests/wifitests/Android.mk @@ -34,9 +34,9 @@ LOCAL_C_INCLUDES += \ LOCAL_SRC_FILES := \ jni/wifi_hal_mock.cpp -ifeq ($(BOARD_HAS_NAN), true) +ifeq ($(BOARD_HAS_AWARE), true) LOCAL_SRC_FILES += \ - jni/wifi_nan_hal_mock.cpp + jni/wifi_aware_hal_mock.cpp endif LOCAL_MODULE := libwifi-hal-mock @@ -62,9 +62,9 @@ LOCAL_MODULE_TAGS := tests LOCAL_SRC_FILES := $(call all-subdir-java-files) -ifneq ($(BOARD_HAS_NAN), true) +ifneq ($(BOARD_HAS_AWARE), true) LOCAL_SRC_FILES := $(filter-out $(call all-java-files-under, \ - src/com/android/server/wifi/nan),$(LOCAL_SRC_FILES)) + src/com/android/server/wifi/aware),$(LOCAL_SRC_FILES)) endif # Provide jack a list of classes to exclude form code coverage diff --git a/tests/wifitests/jni/wifi_nan_hal_mock.cpp b/tests/wifitests/jni/wifi_aware_hal_mock.cpp index 01da519e5..ae5a259ef 100644 --- a/tests/wifitests/jni/wifi_nan_hal_mock.cpp +++ b/tests/wifitests/jni/wifi_aware_hal_mock.cpp @@ -36,14 +36,14 @@ namespace android { -extern jobject mock_mObj; /* saved NanHalMock object */ +extern jobject mock_mObj; /* saved AwareHalMock object */ extern JavaVM* mock_mVM; /* saved JVM pointer */ /* Variable and function declared and defined in: - * com_android_servier_wifi_nan_WifiNanNative.cpp + * com_android_server_wifi_aware_WifiAwareNative.cpp */ extern wifi_hal_fn hal_fn; -extern "C" jint Java_com_android_server_wifi_nan_WifiNanNative_registerNanNatives( +extern "C" jint Java_com_android_server_wifi_aware_WifiAwareNative_registerAwareNatives( JNIEnv* env, jclass clazz); static NanCallbackHandler mCallbackHandlers; @@ -374,7 +374,7 @@ wifi_error wifi_nan_data_interface_create_mock(transaction_id id, JNIObject<jstring> json_write_string = helper.newStringUTF(str.c_str()); - helper.callMethod(mock_mObj, "createNanNetworkInterfaceMockNative", + helper.callMethod(mock_mObj, "createAwareNetworkInterfaceMockNative", "(SLjava/lang/String;)V", (short)id, json_write_string.get()); @@ -393,7 +393,7 @@ wifi_error wifi_nan_data_interface_delete_mock(transaction_id id, JNIObject<jstring> json_write_string = helper.newStringUTF(str.c_str()); - helper.callMethod(mock_mObj, "deleteNanNetworkInterfaceMockNative", + helper.callMethod(mock_mObj, "deleteAwareNetworkInterfaceMockNative", "(SLjava/lang/String;)V", (short)id, json_write_string.get()); @@ -477,14 +477,14 @@ wifi_error wifi_nan_data_end_mock(transaction_id id, // Callbacks -extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callNotifyResponse( +extern "C" void Java_com_android_server_wifi_aware_WifiAwareHalMock_callNotifyResponse( JNIEnv* env, jclass clazz, jshort transaction_id, jstring json_args_jstring) { ScopedUtfChars chars(env, json_args_jstring); HalMockJsonReader jsonR(chars.c_str()); bool error = false; - ALOGD("Java_com_android_server_wifi_nan_WifiNanHalMock_callNotifyResponse: '%s'", + ALOGD("Java_com_android_server_wifi_aware_WifiAwareHalMock_callNotifyResponse: '%s'", chars.c_str()); NanResponseMsg msg; @@ -499,38 +499,38 @@ extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callNotifyRespon "body.subscribe_response.subscribe_id", &error); } else if (msg.response_type == NAN_GET_CAPABILITIES) { msg.body.nan_capabilities.max_concurrent_nan_clusters = jsonR.get_int( - "body.nan_capabilities.max_concurrent_nan_clusters", &error); + "body.aware_capabilities.max_concurrent_aware_clusters", &error); msg.body.nan_capabilities.max_publishes = jsonR.get_int( - "body.nan_capabilities.max_publishes", &error); + "body.aware_capabilities.max_publishes", &error); msg.body.nan_capabilities.max_subscribes = jsonR.get_int( - "body.nan_capabilities.max_subscribes", &error); + "body.aware_capabilities.max_subscribes", &error); msg.body.nan_capabilities.max_service_name_len = jsonR.get_int( - "body.nan_capabilities.max_service_name_len", &error); + "body.aware_capabilities.max_service_name_len", &error); msg.body.nan_capabilities.max_match_filter_len = jsonR.get_int( - "body.nan_capabilities.max_match_filter_len", &error); + "body.aware_capabilities.max_match_filter_len", &error); msg.body.nan_capabilities.max_total_match_filter_len = jsonR.get_int( - "body.nan_capabilities.max_total_match_filter_len", &error); + "body.aware_capabilities.max_total_match_filter_len", &error); msg.body.nan_capabilities.max_service_specific_info_len = jsonR.get_int( - "body.nan_capabilities.max_service_specific_info_len", &error); + "body.aware_capabilities.max_service_specific_info_len", &error); msg.body.nan_capabilities.max_vsa_data_len = jsonR.get_int( - "body.nan_capabilities.max_vsa_data_len", &error); + "body.aware_capabilities.max_vsa_data_len", &error); msg.body.nan_capabilities.max_mesh_data_len = jsonR.get_int( - "body.nan_capabilities.max_mesh_data_len", &error); + "body.aware_capabilities.max_mesh_data_len", &error); msg.body.nan_capabilities.max_ndi_interfaces = jsonR.get_int( - "body.nan_capabilities.max_ndi_interfaces", &error); + "body.aware_capabilities.max_ndi_interfaces", &error); msg.body.nan_capabilities.max_ndp_sessions = jsonR.get_int( - "body.nan_capabilities.max_ndp_sessions", &error); + "body.aware_capabilities.max_ndp_sessions", &error); msg.body.nan_capabilities.max_app_info_len = jsonR.get_int( - "body.nan_capabilities.max_app_info_len", &error); + "body.aware_capabilities.max_app_info_len", &error); msg.body.nan_capabilities.max_queued_transmit_followup_msgs = jsonR.get_int( - "body.nan_capabilities.max_queued_transmit_followup_msgs", &error); + "body.aware_capabilities.max_queued_transmit_followup_msgs", &error); } else if (msg.response_type == NAN_DP_INITIATOR_RESPONSE) { msg.body.data_request_response.ndp_instance_id = jsonR.get_int( "body.data_request_response.ndp_instance_id", &error); } if (error) { - ALOGE("Java_com_android_server_wifi_nan_WifiNanHalMock_callNotifyResponse: " + ALOGE("Java_com_android_server_wifi_aware_WifiAwareHalMock_callNotifyResponse: " "error parsing args"); return; } @@ -538,14 +538,14 @@ extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callNotifyRespon mCallbackHandlers.NotifyResponse(transaction_id, &msg); } -extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callPublishTerminated( +extern "C" void Java_com_android_server_wifi_aware_WifiAwareHalMock_callPublishTerminated( JNIEnv* env, jclass clazz, jstring json_args_jstring) { ScopedUtfChars chars(env, json_args_jstring); HalMockJsonReader jsonR(chars.c_str()); bool error = false; ALOGD( - "Java_com_android_server_wifi_nan_WifiNanHalMock_callPublishTerminated: '%s'", + "Java_com_android_server_wifi_aware_WifiAwareHalMock_callPublishTerminated: '%s'", chars.c_str()); NanPublishTerminatedInd msg; @@ -553,7 +553,7 @@ extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callPublishTermi msg.reason = (NanStatusType) jsonR.get_int("reason", &error); if (error) { - ALOGE("Java_com_android_server_wifi_nan_WifiNanHalMock_callPublishTerminated: " + ALOGE("Java_com_android_server_wifi_aware_WifiAwareHalMock_callPublishTerminated: " "error parsing args"); return; } @@ -561,14 +561,14 @@ extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callPublishTermi mCallbackHandlers.EventPublishTerminated(&msg); } -extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callSubscribeTerminated( +extern "C" void Java_com_android_server_wifi_aware_WifiAwareHalMock_callSubscribeTerminated( JNIEnv* env, jclass clazz, jstring json_args_jstring) { ScopedUtfChars chars(env, json_args_jstring); HalMockJsonReader jsonR(chars.c_str()); bool error = false; ALOGD( - "Java_com_android_server_wifi_nan_WifiNanHalMock_callSubscribeTerminated: '%s'", + "Java_com_android_server_wifi_aware_WifiAwareHalMock_callSubscribeTerminated: '%s'", chars.c_str()); NanSubscribeTerminatedInd msg; @@ -576,7 +576,7 @@ extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callSubscribeTer msg.reason = (NanStatusType) jsonR.get_int("reason", &error); if (error) { - ALOGE("Java_com_android_server_wifi_nan_WifiNanHalMock_callSubscribeTerminated:" + ALOGE("Java_com_android_server_wifi_aware_WifiAwareHalMock_callSubscribeTerminated:" " error parsing args"); return; } @@ -584,13 +584,13 @@ extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callSubscribeTer mCallbackHandlers.EventSubscribeTerminated(&msg); } -extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callFollowup( +extern "C" void Java_com_android_server_wifi_aware_WifiAwareHalMock_callFollowup( JNIEnv* env, jclass clazz, jstring json_args_jstring) { ScopedUtfChars chars(env, json_args_jstring); HalMockJsonReader jsonR(chars.c_str()); bool error = false; - ALOGD("Java_com_android_server_wifi_nan_WifiNanHalMock_callFollowup: '%s'", + ALOGD("Java_com_android_server_wifi_aware_WifiAwareHalMock_callFollowup: '%s'", chars.c_str()); NanFollowupInd msg; @@ -605,7 +605,7 @@ extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callFollowup( NAN_MAX_SERVICE_SPECIFIC_INFO_LEN); if (error) { - ALOGE("Java_com_android_server_wifi_nan_WifiNanHalMock_callFollowup: " + ALOGE("Java_com_android_server_wifi_aware_WifiAwareHalMock_callFollowup: " "error parsing args"); return; } @@ -613,13 +613,13 @@ extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callFollowup( mCallbackHandlers.EventFollowup(&msg); } -extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callMatch( +extern "C" void Java_com_android_server_wifi_aware_WifiAwareHalMock_callMatch( JNIEnv* env, jclass clazz, jstring json_args_jstring) { ScopedUtfChars chars(env, json_args_jstring); HalMockJsonReader jsonR(chars.c_str()); bool error = false; - ALOGD("Java_com_android_server_wifi_nan_WifiNanHalMock_callMatch: '%s'", + ALOGD("Java_com_android_server_wifi_aware_WifiAwareHalMock_callMatch: '%s'", chars.c_str()); NanMatchInd msg; @@ -637,7 +637,7 @@ extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callMatch( /* a few more fields here - but not used (yet/never?) */ if (error) { - ALOGE("Java_com_android_server_wifi_nan_WifiNanHalMock_callMatch: " + ALOGE("Java_com_android_server_wifi_aware_WifiAwareHalMock_callMatch: " "error parsing args"); return; } @@ -645,13 +645,13 @@ extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callMatch( mCallbackHandlers.EventMatch(&msg); } -extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callDiscEngEvent( +extern "C" void Java_com_android_server_wifi_aware_WifiAwareHalMock_callDiscEngEvent( JNIEnv* env, jclass clazz, jstring json_args_jstring) { ScopedUtfChars chars(env, json_args_jstring); HalMockJsonReader jsonR(chars.c_str()); bool error = false; - ALOGD("Java_com_android_server_wifi_nan_WifiNanHalMock_callDiscEngEvent: '%s'", + ALOGD("Java_com_android_server_wifi_aware_WifiAwareHalMock_callDiscEngEvent: '%s'", chars.c_str()); NanDiscEngEventInd msg; @@ -665,7 +665,7 @@ extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callDiscEngEvent } if (error) { - ALOGE("Java_com_android_server_wifi_nan_WifiNanHalMock_callDiscEngEvent: " + ALOGE("Java_com_android_server_wifi_aware_WifiAwareHalMock_callDiscEngEvent: " "error parsing args"); return; } @@ -673,20 +673,20 @@ extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callDiscEngEvent mCallbackHandlers.EventDiscEngEvent(&msg); } -extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callDisabled( +extern "C" void Java_com_android_server_wifi_aware_WifiAwareHalMock_callDisabled( JNIEnv* env, jclass clazz, jstring json_args_jstring) { ScopedUtfChars chars(env, json_args_jstring); HalMockJsonReader jsonR(chars.c_str()); bool error = false; - ALOGD("Java_com_android_server_wifi_nan_WifiNanHalMock_callDisabled: '%s'", + ALOGD("Java_com_android_server_wifi_aware_WifiAwareHalMock_callDisabled: '%s'", chars.c_str()); NanDisabledInd msg; msg.reason = (NanStatusType) jsonR.get_int("reason", &error); if (error) { - ALOGE("Java_com_android_server_wifi_nan_WifiNanHalMock_callDisabled: " + ALOGE("Java_com_android_server_wifi_aware_WifiAwareHalMock_callDisabled: " "error parsing args"); return; } @@ -694,13 +694,13 @@ extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callDisabled( mCallbackHandlers.EventDisabled(&msg); } -extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callTransmitFollowup( +extern "C" void Java_com_android_server_wifi_aware_WifiAwareHalMock_callTransmitFollowup( JNIEnv* env, jclass clazz, jstring json_args_jstring) { ScopedUtfChars chars(env, json_args_jstring); HalMockJsonReader jsonR(chars.c_str()); bool error = false; - ALOGD("Java_com_android_server_wifi_nan_WifiNanHalMock_callTransmitFollowup: '%s'", + ALOGD("Java_com_android_server_wifi_aware_WifiAwareHalMock_callTransmitFollowup: '%s'", chars.c_str()); NanTransmitFollowupInd msg; @@ -708,7 +708,7 @@ extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callTransmitFoll msg.reason = (NanStatusType) jsonR.get_int("reason", &error); if (error) { - ALOGE("Java_com_android_server_wifi_nan_WifiNanHalMock_callTransmitFollowup: " + ALOGE("Java_com_android_server_wifi_aware_WifiAwareHalMock_callTransmitFollowup: " "error parsing args"); return; } @@ -716,13 +716,13 @@ extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callTransmitFoll mCallbackHandlers.EventTransmitFollowup(&msg); } -extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callDataPathRequest( +extern "C" void Java_com_android_server_wifi_aware_WifiAwareHalMock_callDataPathRequest( JNIEnv* env, jclass clazz, jstring json_args_jstring) { ScopedUtfChars chars(env, json_args_jstring); HalMockJsonReader jsonR(chars.c_str()); bool error = false; - ALOGD("Java_com_android_server_wifi_nan_WifiNanHalMock_callDataPathRequest: '%s'", + ALOGD("Java_com_android_server_wifi_aware_WifiAwareHalMock_callDataPathRequest: '%s'", chars.c_str()); NanDataPathRequestInd msg; @@ -741,7 +741,7 @@ extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callDataPathRequ if (error) { ALOGE( - "Java_com_android_server_wifi_nan_WifiNanHalMock_callDataPathRequest: " + "Java_com_android_server_wifi_aware_WifiAwareHalMock_callDataPathRequest: " "error parsing args"); return; } @@ -749,13 +749,13 @@ extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callDataPathRequ mCallbackHandlers.EventDataRequest(&msg); } -extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callDataPathConfirm( +extern "C" void Java_com_android_server_wifi_aware_WifiAwareHalMock_callDataPathConfirm( JNIEnv* env, jclass clazz, jstring json_args_jstring) { ScopedUtfChars chars(env, json_args_jstring); HalMockJsonReader jsonR(chars.c_str()); bool error = false; - ALOGD("Java_com_android_server_wifi_nan_WifiNanHalMock_callDataPathConfirm: '%s'", + ALOGD("Java_com_android_server_wifi_aware_WifiAwareHalMock_callDataPathConfirm: '%s'", chars.c_str()); NanDataPathConfirmInd msg; @@ -771,7 +771,7 @@ extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callDataPathConf if (error) { ALOGE( - "Java_com_android_server_wifi_nan_WifiNanHalMock_callDataPathConfirm: " + "Java_com_android_server_wifi_aware_WifiAwareHalMock_callDataPathConfirm: " "error parsing args"); return; } @@ -779,13 +779,13 @@ extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callDataPathConf mCallbackHandlers.EventDataConfirm(&msg); } -extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callDataPathEnd( +extern "C" void Java_com_android_server_wifi_aware_WifiAwareHalMock_callDataPathEnd( JNIEnv* env, jclass clazz, jstring json_args_jstring) { ScopedUtfChars chars(env, json_args_jstring); HalMockJsonReader jsonR(chars.c_str()); bool error = false; - ALOGD("Java_com_android_server_wifi_nan_WifiNanHalMock_callDataPathEnd: '%s'", + ALOGD("Java_com_android_server_wifi_aware_WifiAwareHalMock_callDataPathEnd: '%s'", chars.c_str()); int num_ndp_instances = jsonR.get_int("num_ndp_instances", &error); @@ -799,7 +799,7 @@ extern "C" void Java_com_android_server_wifi_nan_WifiNanHalMock_callDataPathEnd( if (error) { ALOGE( - "Java_com_android_server_wifi_nan_WifiNanHalMock_callDataPathEnd: " + "Java_com_android_server_wifi_aware_WifiAwareHalMock_callDataPathEnd: " "error parsing args"); return; } @@ -846,9 +846,9 @@ int init_wifi_nan_hal_func_table_mock(wifi_hal_fn *fn) { return 0; } -extern "C" jint Java_com_android_server_wifi_nan_WifiNanHalMock_initNanHalMock( +extern "C" jint Java_com_android_server_wifi_aware_WifiAwareHalMock_initAwareHalMock( JNIEnv* env, jclass clazz) { - Java_com_android_server_wifi_nan_WifiNanNative_registerNanNatives(env, clazz); + Java_com_android_server_wifi_aware_WifiAwareNative_registerAwareNatives(env, clazz); return init_wifi_nan_hal_func_table_mock(&hal_fn); } diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java index 9de360812..36f8b7c41 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java @@ -915,17 +915,17 @@ public class WifiStateMachineTest { /** Verifies that syncGetSupportedFeatures() masks out capabilities based on system flags. */ @Test public void syncGetSupportedFeatures() { - final int featureNan = WifiManager.WIFI_FEATURE_NAN; + final int featureAware = WifiManager.WIFI_FEATURE_AWARE; final int featureInfra = WifiManager.WIFI_FEATURE_INFRA; final int featureD2dRtt = WifiManager.WIFI_FEATURE_D2D_RTT; final int featureD2apRtt = WifiManager.WIFI_FEATURE_D2AP_RTT; assertEquals(0, testGetSupportedFeaturesCase(0, false)); assertEquals(0, testGetSupportedFeaturesCase(0, true)); - assertEquals(featureNan | featureInfra, - testGetSupportedFeaturesCase(featureNan | featureInfra, false)); - assertEquals(featureNan | featureInfra, - testGetSupportedFeaturesCase(featureNan | featureInfra, true)); + assertEquals(featureAware | featureInfra, + testGetSupportedFeaturesCase(featureAware | featureInfra, false)); + assertEquals(featureAware | featureInfra, + testGetSupportedFeaturesCase(featureAware | featureInfra, true)); assertEquals(featureInfra | featureD2dRtt, testGetSupportedFeaturesCase(featureInfra | featureD2dRtt, false)); assertEquals(featureInfra, diff --git a/tests/wifitests/src/com/android/server/wifi/nan/TlvBufferUtilsTest.java b/tests/wifitests/src/com/android/server/wifi/aware/TlvBufferUtilsTest.java index 3a9529b76..cc6896f2f 100644 --- a/tests/wifitests/src/com/android/server/wifi/nan/TlvBufferUtilsTest.java +++ b/tests/wifitests/src/com/android/server/wifi/aware/TlvBufferUtilsTest.java @@ -14,12 +14,12 @@ * limitations under the License. */ -package com.android.server.wifi.nan; +package com.android.server.wifi.aware; import static org.hamcrest.core.IsEqual.equalTo; -import android.net.wifi.nan.LvBufferUtils; -import android.net.wifi.nan.TlvBufferUtils; +import android.net.wifi.aware.LvBufferUtils; +import android.net.wifi.aware.TlvBufferUtils; import android.test.suitebuilder.annotation.SmallTest; import org.junit.Rule; @@ -27,7 +27,7 @@ import org.junit.Test; import org.junit.rules.ErrorCollector; /** - * Unit test harness for WifiNanManager class. + * Unit test harness for TlvBufferUtils class. */ @SmallTest public class TlvBufferUtilsTest { diff --git a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanDataPathStateManagerTest.java b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java index 50f7a11c7..5ebe57cc0 100644 --- a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanDataPathStateManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.server.wifi.nan; +package com.android.server.wifi.aware; import static org.hamcrest.core.IsEqual.equalTo; import static org.junit.Assert.assertTrue; @@ -40,18 +40,18 @@ import android.net.NetworkInfo; import android.net.NetworkMisc; import android.net.NetworkRequest; import android.net.wifi.RttManager; -import android.net.wifi.nan.ConfigRequest; -import android.net.wifi.nan.IWifiNanDiscoverySessionCallback; -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.WifiNanManager; -import android.net.wifi.nan.WifiNanPublishDiscoverySession; -import android.net.wifi.nan.WifiNanSession; -import android.net.wifi.nan.WifiNanSubscribeDiscoverySession; +import android.net.wifi.aware.ConfigRequest; +import android.net.wifi.aware.IWifiAwareDiscoverySessionCallback; +import android.net.wifi.aware.IWifiAwareEventCallback; +import android.net.wifi.aware.IWifiAwareManager; +import android.net.wifi.aware.PublishConfig; +import android.net.wifi.aware.SubscribeConfig; +import android.net.wifi.aware.WifiAwareAttachCallback; +import android.net.wifi.aware.WifiAwareDiscoverySessionCallback; +import android.net.wifi.aware.WifiAwareManager; +import android.net.wifi.aware.WifiAwarePublishDiscoverySession; +import android.net.wifi.aware.WifiAwareSession; +import android.net.wifi.aware.WifiAwareSubscribeDiscoverySession; import android.os.Handler; import android.os.IBinder; import android.os.INetworkManagementService; @@ -79,26 +79,26 @@ import java.lang.reflect.Field; import java.util.Arrays; /** - * Unit test harness for WifiNanDataPathStateManager class. + * Unit test harness for WifiAwareDataPathStateManager class. */ @SmallTest -public class WifiNanDataPathStateManagerTest { - private static final String sNanInterfacePrefix = "nan"; +public class WifiAwareDataPathStateManagerTest { + private static final String sAwareInterfacePrefix = "aware"; private TestLooper mMockLooper; private Handler mMockLooperHandler; - private WifiNanStateManager mDut; - @Mock private WifiNanNative mMockNative; + private WifiAwareStateManager mDut; + @Mock private WifiAwareNative mMockNative; @Mock private Context mMockContext; - @Mock private IWifiNanManager mMockNanService; - @Mock private WifiNanPublishDiscoverySession mMockPublishSession; - @Mock private WifiNanSubscribeDiscoverySession mMockSubscribeSession; + @Mock private IWifiAwareManager mMockAwareService; + @Mock private WifiAwarePublishDiscoverySession mMockPublishSession; + @Mock private WifiAwareSubscribeDiscoverySession mMockSubscribeSession; @Mock private RttManager.RttListener mMockRttListener; @Mock private ConnectivityManager mMockCm; @Mock private INetworkManagementService mMockNwMgt; - @Mock private WifiNanDataPathStateManager.NetworkInterfaceWrapper mMockNetworkInterface; - @Mock private IWifiNanEventCallback mMockCallback; - @Mock IWifiNanDiscoverySessionCallback mMockSessionCallback; + @Mock private WifiAwareDataPathStateManager.NetworkInterfaceWrapper mMockNetworkInterface; + @Mock private IWifiAwareEventCallback mMockCallback; + @Mock IWifiAwareDiscoverySessionCallback mMockSessionCallback; TestAlarmManager mAlarmManager; @Rule @@ -120,7 +120,7 @@ public class WifiNanDataPathStateManagerTest { mMockLooper = new TestLooper(); mMockLooperHandler = new Handler(mMockLooper.getLooper()); - mDut = installNewNanStateManager(); + mDut = installNewAwareStateManager(); mDut.start(mMockContext, mMockLooper.getLooper()); mDut.startLate(); @@ -135,8 +135,8 @@ public class WifiNanDataPathStateManagerTest { any(byte[].class), anyInt())).thenReturn(true); when(mMockNative.stopPublish(anyShort(), anyInt())).thenReturn(true); when(mMockNative.stopSubscribe(anyShort(), anyInt())).thenReturn(true); - when(mMockNative.createNanNetworkInterface(anyShort(), anyString())).thenReturn(true); - when(mMockNative.deleteNanNetworkInterface(anyShort(), anyString())).thenReturn(true); + when(mMockNative.createAwareNetworkInterface(anyShort(), anyString())).thenReturn(true); + when(mMockNative.deleteAwareNetworkInterface(anyShort(), anyString())).thenReturn(true); when(mMockNative.initiateDataPath(anyShort(), anyInt(), anyInt(), anyInt(), any(byte[].class), anyString(), any(byte[].class))).thenReturn(true); when(mMockNative.respondToDataPathRequest(anyShort(), anyBoolean(), anyInt(), anyString(), @@ -144,11 +144,11 @@ public class WifiNanDataPathStateManagerTest { when(mMockNative.endDataPath(anyShort(), anyInt())).thenReturn(true); when(mMockNetworkInterface.configureAgentProperties( - any(WifiNanDataPathStateManager.NanNetworkRequestInformation.class), anyString(), - anyInt(), any(NetworkInfo.class), any(NetworkCapabilities.class), + any(WifiAwareDataPathStateManager.AwareNetworkRequestInformation.class), + anyString(), anyInt(), any(NetworkInfo.class), any(NetworkCapabilities.class), any(LinkProperties.class))).thenReturn(true); - installMockWifiNanNative(mMockNative); + installMockWifiAwareNative(mMockNative); installDataPathStateManagerMocks(); } @@ -160,7 +160,7 @@ public class WifiNanDataPathStateManagerTest { final int numNdis = 3; final int failCreateInterfaceIndex = 1; - WifiNanNative.Capabilities capabilities = new WifiNanNative.Capabilities(); + WifiAwareNative.Capabilities capabilities = new WifiAwareNative.Capabilities(); capabilities.maxNdiInterfaces = numNdis; ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); @@ -178,9 +178,9 @@ public class WifiNanDataPathStateManagerTest { mDut.createAllDataPathInterfaces(); mMockLooper.dispatchAll(); for (int i = 0; i < numNdis; ++i) { - inOrder.verify(mMockNative).createNanNetworkInterface(transactionId.capture(), + inOrder.verify(mMockNative).createAwareNetworkInterface(transactionId.capture(), interfaceName.capture()); - collector.checkThat("interface created -- " + i, sNanInterfacePrefix + i, + collector.checkThat("interface created -- " + i, sAwareInterfacePrefix + i, equalTo(interfaceName.getValue())); mDut.onCreateDataPathInterfaceResponse(transactionId.getValue(), true, 0); mMockLooper.dispatchAll(); @@ -193,10 +193,10 @@ public class WifiNanDataPathStateManagerTest { mDut.deleteAllDataPathInterfaces(); mMockLooper.dispatchAll(); for (int i = 0; i < numNdis; ++i) { - inOrder.verify(mMockNative).deleteNanNetworkInterface(transactionId.capture(), + inOrder.verify(mMockNative).deleteAwareNetworkInterface(transactionId.capture(), interfaceName.capture()); int interfaceIndex = Integer.valueOf( - interfaceName.getValue().substring(sNanInterfacePrefix.length())); + interfaceName.getValue().substring(sAwareInterfacePrefix.length())); done[interfaceIndex] = true; if (interfaceIndex == failCreateInterfaceIndex) { mDut.onDeleteDataPathInterfaceResponse(transactionId.getValue(), false, 0); @@ -214,16 +214,16 @@ public class WifiNanDataPathStateManagerTest { mMockLooper.dispatchAll(); for (int i = 0; i < numNdis; ++i) { if (i == failCreateInterfaceIndex) { - inOrder.verify(mMockNative).deleteNanNetworkInterface(transactionId.capture(), + inOrder.verify(mMockNative).deleteAwareNetworkInterface(transactionId.capture(), interfaceName.capture()); - collector.checkThat("interface delete pre-create -- " + i, sNanInterfacePrefix + i, - equalTo(interfaceName.getValue())); + collector.checkThat("interface delete pre-create -- " + i, + sAwareInterfacePrefix + i, equalTo(interfaceName.getValue())); mDut.onDeleteDataPathInterfaceResponse(transactionId.getValue(), true, 0); mMockLooper.dispatchAll(); } - inOrder.verify(mMockNative).createNanNetworkInterface(transactionId.capture(), + inOrder.verify(mMockNative).createAwareNetworkInterface(transactionId.capture(), interfaceName.capture()); - collector.checkThat("interface created -- " + i, sNanInterfacePrefix + i, + collector.checkThat("interface created -- " + i, sAwareInterfacePrefix + i, equalTo(interfaceName.getValue())); mDut.onCreateDataPathInterfaceResponse(transactionId.getValue(), true, 0); mMockLooper.dispatchAll(); @@ -401,7 +401,7 @@ public class WifiNanDataPathStateManagerTest { boolean provideToken, boolean getConfirmation) throws Exception { final int clientId = 123; final int pubSubId = 11234; - final WifiNanManager.OpaquePeerHandle peerHandle = new WifiNanManager.OpaquePeerHandle( + final WifiAwareManager.OpaquePeerHandle peerHandle = new WifiAwareManager.OpaquePeerHandle( 1341234); final int ndpId = 2; final String token = "some token"; @@ -420,11 +420,13 @@ public class WifiNanDataPathStateManagerTest { // (1) request network NetworkRequest nr; if (useDirect) { - nr = getDirectNetworkRequest(clientId, WifiNanManager.WIFI_NAN_DATA_PATH_ROLE_INITIATOR, + nr = getDirectNetworkRequest(clientId, + WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_INITIATOR, provideMac ? peerDiscoveryMac : null, provideToken ? token : null); } else { nr = getSessionNetworkRequest(clientId, res.first, provideMac ? peerHandle : null, - WifiNanManager.WIFI_NAN_DATA_PATH_ROLE_INITIATOR, provideToken ? token : null); + WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_INITIATOR, + provideToken ? token : null); } Message reqNetworkMsg = Message.obtain(); @@ -435,8 +437,8 @@ public class WifiNanDataPathStateManagerTest { mMockLooper.dispatchAll(); inOrder.verify(mMockNative).initiateDataPath(transactionId.capture(), eq(useDirect ? 0 : peerHandle.peerId), - eq(WifiNanNative.CHANNEL_REQUEST_TYPE_REQUESTED), eq(2437), eq(peerDiscoveryMac), - eq("nan0"), eq(token.getBytes())); + eq(WifiAwareNative.CHANNEL_REQUEST_TYPE_REQUESTED), eq(2437), eq(peerDiscoveryMac), + eq("aware0"), eq(token.getBytes())); mDut.onInitiateDataPathResponseSuccess(transactionId.getValue(), ndpId); mMockLooper.dispatchAll(); @@ -450,8 +452,8 @@ public class WifiNanDataPathStateManagerTest { any(NetworkCapabilities.class), anyInt(), any(NetworkMisc.class)); } else { - assertTrue( - mAlarmManager.dispatch(WifiNanStateManager.HAL_DATA_PATH_CONFIRM_TIMEOUT_TAG)); + assertTrue(mAlarmManager.dispatch( + WifiAwareStateManager.HAL_DATA_PATH_CONFIRM_TIMEOUT_TAG)); mMockLooper.dispatchAll(); inOrder.verify(mMockNative).endDataPath(transactionId.capture(), eq(ndpId)); mDut.onEndDataPathResponse(transactionId.getValue(), true, 0); @@ -482,7 +484,7 @@ public class WifiNanDataPathStateManagerTest { boolean provideToken, boolean getConfirmation) throws Exception { final int clientId = 123; final int pubSubId = 11234; - final WifiNanManager.OpaquePeerHandle peerHandle = new WifiNanManager.OpaquePeerHandle( + final WifiAwareManager.OpaquePeerHandle peerHandle = new WifiAwareManager.OpaquePeerHandle( 1341234); final int ndpId = 2; final String token = "some token"; @@ -501,11 +503,13 @@ public class WifiNanDataPathStateManagerTest { // (1) request network NetworkRequest nr; if (useDirect) { - nr = getDirectNetworkRequest(clientId, WifiNanManager.WIFI_NAN_DATA_PATH_ROLE_RESPONDER, + nr = getDirectNetworkRequest(clientId, + WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_RESPONDER, provideMac ? peerDiscoveryMac : null, provideToken ? token : null); } else { nr = getSessionNetworkRequest(clientId, res.first, provideMac ? peerHandle : null, - WifiNanManager.WIFI_NAN_DATA_PATH_ROLE_RESPONDER, provideToken ? token : null); + WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_RESPONDER, + provideToken ? token : null); } Message reqNetworkMsg = Message.obtain(); @@ -519,7 +523,7 @@ public class WifiNanDataPathStateManagerTest { mDut.onDataPathRequestNotification(pubSubId, peerDiscoveryMac, ndpId, token.getBytes()); mMockLooper.dispatchAll(); inOrder.verify(mMockNative).respondToDataPathRequest(transactionId.capture(), eq(true), - eq(ndpId), eq("nan0"), eq(new byte[0])); + eq(ndpId), eq("aware0"), eq(new byte[0])); mDut.onRespondToDataPathSetupRequestResponse(transactionId.getValue(), true, 0); mMockLooper.dispatchAll(); @@ -533,8 +537,8 @@ public class WifiNanDataPathStateManagerTest { any(NetworkCapabilities.class), anyInt(), any(NetworkMisc.class)); } else { - assertTrue( - mAlarmManager.dispatch(WifiNanStateManager.HAL_DATA_PATH_CONFIRM_TIMEOUT_TAG)); + assertTrue(mAlarmManager.dispatch( + WifiAwareStateManager.HAL_DATA_PATH_CONFIRM_TIMEOUT_TAG)); mMockLooper.dispatchAll(); inOrder.verify(mMockNative).endDataPath(transactionId.capture(), eq(ndpId)); mDut.onEndDataPathResponse(transactionId.getValue(), true, 0); @@ -562,66 +566,67 @@ public class WifiNanDataPathStateManagerTest { } - private static WifiNanStateManager installNewNanStateManager() + private static WifiAwareStateManager installNewAwareStateManager() throws Exception { - Constructor<WifiNanStateManager> ctr = WifiNanStateManager.class.getDeclaredConstructor(); + Constructor<WifiAwareStateManager> ctr = + WifiAwareStateManager.class.getDeclaredConstructor(); ctr.setAccessible(true); - WifiNanStateManager nanStateManager = ctr.newInstance(); + WifiAwareStateManager awareStateManager = ctr.newInstance(); - Field field = WifiNanStateManager.class.getDeclaredField("sNanStateManagerSingleton"); + Field field = WifiAwareStateManager.class.getDeclaredField("sAwareStateManagerSingleton"); field.setAccessible(true); - field.set(null, nanStateManager); + field.set(null, awareStateManager); - return WifiNanStateManager.getInstance(); + return WifiAwareStateManager.getInstance(); } - private static void installMockWifiNanNative(WifiNanNative obj) throws Exception { - Field field = WifiNanNative.class.getDeclaredField("sWifiNanNativeSingleton"); + private static void installMockWifiAwareNative(WifiAwareNative obj) throws Exception { + Field field = WifiAwareNative.class.getDeclaredField("sWifiAwareNativeSingleton"); field.setAccessible(true); field.set(null, obj); } private void installDataPathStateManagerMocks() throws Exception { - Field field = WifiNanStateManager.class.getDeclaredField("mDataPathMgr"); + Field field = WifiAwareStateManager.class.getDeclaredField("mDataPathMgr"); field.setAccessible(true); Object mDataPathMgr = field.get(mDut); - field = WifiNanDataPathStateManager.class.getDeclaredField("mNwService"); + field = WifiAwareDataPathStateManager.class.getDeclaredField("mNwService"); field.setAccessible(true); field.set(mDataPathMgr, mMockNwMgt); - field = WifiNanDataPathStateManager.class.getDeclaredField("mNiWrapper"); + field = WifiAwareDataPathStateManager.class.getDeclaredField("mNiWrapper"); field.setAccessible(true); field.set(mDataPathMgr, mMockNetworkInterface); } private NetworkRequest getSessionNetworkRequest(int clientId, int sessionId, Object peerHandle, int role, String token) throws Exception { - final WifiNanManager mgr = new WifiNanManager(mMockContext, mMockNanService); + final WifiAwareManager mgr = new WifiAwareManager(mMockContext, mMockAwareService); final ConfigRequest configRequest = new ConfigRequest.Builder().build(); final PublishConfig publishConfig = new PublishConfig.Builder().build(); - ArgumentCaptor<WifiNanSession> sessionCaptor = ArgumentCaptor.forClass( - WifiNanSession.class); - ArgumentCaptor<IWifiNanEventCallback> clientProxyCallback = ArgumentCaptor - .forClass(IWifiNanEventCallback.class); - ArgumentCaptor<IWifiNanDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor - .forClass(IWifiNanDiscoverySessionCallback.class); - ArgumentCaptor<WifiNanPublishDiscoverySession> publishSession = ArgumentCaptor - .forClass(WifiNanPublishDiscoverySession.class); + ArgumentCaptor<WifiAwareSession> sessionCaptor = ArgumentCaptor.forClass( + WifiAwareSession.class); + ArgumentCaptor<IWifiAwareEventCallback> clientProxyCallback = ArgumentCaptor + .forClass(IWifiAwareEventCallback.class); + ArgumentCaptor<IWifiAwareDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor + .forClass(IWifiAwareDiscoverySessionCallback.class); + ArgumentCaptor<WifiAwarePublishDiscoverySession> publishSession = ArgumentCaptor + .forClass(WifiAwarePublishDiscoverySession.class); - WifiNanAttachCallback mockCallback = mock(WifiNanAttachCallback.class); - WifiNanDiscoverySessionCallback mockSessionCallback = mock( - WifiNanDiscoverySessionCallback.class); + WifiAwareAttachCallback mockCallback = mock(WifiAwareAttachCallback.class); + WifiAwareDiscoverySessionCallback mockSessionCallback = mock( + WifiAwareDiscoverySessionCallback.class); mgr.attach(mMockLooperHandler, configRequest, mockCallback, null); - verify(mMockNanService).connect(any(IBinder.class), anyString(), + verify(mMockAwareService).connect(any(IBinder.class), anyString(), clientProxyCallback.capture(), eq(configRequest), eq(false)); clientProxyCallback.getValue().onConnectSuccess(clientId); mMockLooper.dispatchAll(); verify(mockCallback).onAttached(sessionCaptor.capture()); sessionCaptor.getValue().publish(mMockLooperHandler, publishConfig, mockSessionCallback); - verify(mMockNanService).publish(eq(clientId), eq(publishConfig), + verify(mMockAwareService).publish(eq(clientId), eq(publishConfig), sessionProxyCallback.capture()); sessionProxyCallback.getValue().onSessionStarted(sessionId); mMockLooper.dispatchAll(); @@ -632,7 +637,7 @@ public class WifiNanDataPathStateManagerTest { NetworkCapabilities nc = new NetworkCapabilities(); nc.clearAll(); - nc.addTransportType(NetworkCapabilities.TRANSPORT_WIFI_NAN); + nc.addTransportType(NetworkCapabilities.TRANSPORT_WIFI_AWARE); nc.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN).addCapability( NetworkCapabilities.NET_CAPABILITY_NOT_METERED); nc.setNetworkSpecifier(ns); @@ -646,17 +651,17 @@ public class WifiNanDataPathStateManagerTest { private NetworkRequest getDirectNetworkRequest(int clientId, int role, byte[] peer, String token) throws Exception { final ConfigRequest configRequest = new ConfigRequest.Builder().build(); - final WifiNanManager mgr = new WifiNanManager(mMockContext, mMockNanService); + final WifiAwareManager mgr = new WifiAwareManager(mMockContext, mMockAwareService); - ArgumentCaptor<WifiNanSession> sessionCaptor = ArgumentCaptor.forClass( - WifiNanSession.class); - ArgumentCaptor<IWifiNanEventCallback> clientProxyCallback = ArgumentCaptor - .forClass(IWifiNanEventCallback.class); + ArgumentCaptor<WifiAwareSession> sessionCaptor = ArgumentCaptor.forClass( + WifiAwareSession.class); + ArgumentCaptor<IWifiAwareEventCallback> clientProxyCallback = ArgumentCaptor + .forClass(IWifiAwareEventCallback.class); - WifiNanAttachCallback mockCallback = mock(WifiNanAttachCallback.class); + WifiAwareAttachCallback mockCallback = mock(WifiAwareAttachCallback.class); mgr.attach(mMockLooperHandler, configRequest, mockCallback, null); - verify(mMockNanService).connect(any(IBinder.class), anyString(), + verify(mMockAwareService).connect(any(IBinder.class), anyString(), clientProxyCallback.capture(), eq(configRequest), eq(false)); clientProxyCallback.getValue().onConnectSuccess(clientId); mMockLooper.dispatchAll(); @@ -666,7 +671,7 @@ public class WifiNanDataPathStateManagerTest { (token == null) ? null : token.getBytes()); NetworkCapabilities nc = new NetworkCapabilities(); nc.clearAll(); - nc.addTransportType(NetworkCapabilities.TRANSPORT_WIFI_NAN); + nc.addTransportType(NetworkCapabilities.TRANSPORT_WIFI_AWARE); nc.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN).addCapability( NetworkCapabilities.NET_CAPABILITY_NOT_METERED); nc.setNetworkSpecifier(ns); @@ -678,7 +683,7 @@ public class WifiNanDataPathStateManagerTest { } private Pair<Integer, Messenger> initDataPathEndPoint(int clientId, int pubSubId, - WifiNanManager.OpaquePeerHandle peerHandle, byte[] peerDiscoveryMac, InOrder inOrder) + WifiAwareManager.OpaquePeerHandle peerHandle, byte[] peerDiscoveryMac, InOrder inOrder) throws Exception { final int uid = 1000; final int pid = 2000; @@ -687,7 +692,7 @@ public class WifiNanDataPathStateManagerTest { final ConfigRequest configRequest = new ConfigRequest.Builder().build(); final PublishConfig publishConfig = new PublishConfig.Builder().build(); - WifiNanNative.Capabilities capabilities = new WifiNanNative.Capabilities(); + WifiAwareNative.Capabilities capabilities = new WifiAwareNative.Capabilities(); capabilities.maxNdiInterfaces = 1; ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); @@ -698,7 +703,7 @@ public class WifiNanDataPathStateManagerTest { // (0) start/registrations inOrder.verify(mMockCm).registerNetworkFactory(messengerCaptor.capture(), strCaptor.capture()); - collector.checkThat("factory name", "WIFI_NAN_FACTORY", equalTo(strCaptor.getValue())); + collector.checkThat("factory name", "WIFI_AWARE_FACTORY", equalTo(strCaptor.getValue())); // (1) get capabilities mDut.queryCapabilities(); @@ -710,10 +715,10 @@ public class WifiNanDataPathStateManagerTest { // (2) enable usage (creates interfaces) mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); - inOrder.verify(mMockNative).createNanNetworkInterface(transactionId.capture(), + inOrder.verify(mMockNative).deInitAware(); + inOrder.verify(mMockNative).createAwareNetworkInterface(transactionId.capture(), strCaptor.capture()); - collector.checkThat("interface created -- 0", sNanInterfacePrefix + 0, + collector.checkThat("interface created -- 0", sAwareInterfacePrefix + 0, equalTo(strCaptor.getValue())); mDut.onCreateDataPathInterfaceResponse(transactionId.getValue(), true, 0); mMockLooper.dispatchAll(); diff --git a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanHalMock.java b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareHalMock.java index 694187e0d..4d97d8ce1 100644 --- a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanHalMock.java +++ b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareHalMock.java @@ -14,12 +14,12 @@ * limitations under the License. */ -package com.android.server.wifi.nan; +package com.android.server.wifi.aware; import java.lang.reflect.Field; /** - * Mock class for NAN HAL. Provides access to HAL API and to callbacks. To + * Mock class for Aware HAL. Provides access to HAL API and to callbacks. To * extend: * <ul> * <li>HAL API: create a {@code public void} method which takes any fixed @@ -30,7 +30,7 @@ import java.lang.reflect.Field; * similar to the HAL API arguments. * </ul> */ -public class WifiNanHalMock { +public class WifiAwareHalMock { public void getCapabilitiesHalMockNative(short transactionId) { throw new IllegalStateException("Please mock this class!"); } @@ -67,11 +67,11 @@ public class WifiNanHalMock { throw new IllegalStateException("Please mock this class!"); } - public void createNanNetworkInterfaceMockNative(short transactionId, String jsonArgs) { + public void createAwareNetworkInterfaceMockNative(short transactionId, String jsonArgs) { throw new IllegalStateException("Please mock this class!"); } - public void deleteNanNetworkInterfaceMockNative(short transactionId, String jsonArgs) { + public void deleteAwareNetworkInterfaceMockNative(short transactionId, String jsonArgs) { throw new IllegalStateException("Please mock this class!"); } @@ -115,15 +115,15 @@ public class WifiNanHalMock { public static native void callDataPathEnd(String jsonArgs); /** - * initialize NAN mock + * initialize Aware mock */ - private static native int initNanHalMock(); + private static native int initAwareHalMock(); - public static void initNanHalMockLibrary(WifiNanNative instance) throws Exception { - Field field = WifiNanNative.class.getDeclaredField("mNativeHandlersIsInitialized"); + public static void initAwareHalMockLibrary(WifiAwareNative instance) throws Exception { + Field field = WifiAwareNative.class.getDeclaredField("mNativeHandlersIsInitialized"); field.setAccessible(true); field.setBoolean(instance, true); - initNanHalMock(); + initAwareHalMock(); } } diff --git a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanHalTest.java b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareHalTest.java index 99b8596e5..100b37295 100644 --- a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanHalTest.java +++ b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareHalTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.server.wifi.nan; +package com.android.server.wifi.aware; import static org.hamcrest.core.IsEqual.equalTo; import static org.mockito.Matchers.eq; @@ -22,11 +22,11 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; -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.WifiNanDiscoverySessionCallback; +import android.net.wifi.aware.ConfigRequest; +import android.net.wifi.aware.PublishConfig; +import android.net.wifi.aware.SubscribeConfig; +import android.net.wifi.aware.TlvBufferUtils; +import android.net.wifi.aware.WifiAwareDiscoverySessionCallback; import android.os.Bundle; import android.test.suitebuilder.annotation.SmallTest; @@ -47,16 +47,16 @@ import org.mockito.MockitoAnnotations; import java.lang.reflect.Field; /** - * Unit test harness for WifiNanNative + JNI code interfacing to the HAL. + * Unit test harness for WifiAwareNative + JNI code interfacing to the HAL. */ @SmallTest -public class WifiNanHalTest { - private WifiNanNative mDut = WifiNanNative.getInstance(); +public class WifiAwareHalTest { + private WifiAwareNative mDut = WifiAwareNative.getInstance(); private ArgumentCaptor<String> mArgs = ArgumentCaptor.forClass(String.class); @Mock - private WifiNanHalMock mNanHalMock; - @Mock private WifiNanStateManager mNanStateManager; + private WifiAwareHalMock mAwareHalMock; + @Mock private WifiAwareStateManager mAwareStateManager; @Rule public ErrorCollector collector = new ErrorCollector(); @@ -65,13 +65,13 @@ public class WifiNanHalTest { public void setup() throws Exception { MockitoAnnotations.initMocks(this); - resetWifiNanNative(); + resetWifiAwareNative(); HalMockUtils.initHalMockLibrary(); - WifiNanHalMock.initNanHalMockLibrary(mDut); - WifiNanNative.initNanHandlersNative(WifiNative.class, WifiNative.sWlan0Index); - HalMockUtils.setHalMockObject(mNanHalMock); - installMockNanStateManager(mNanStateManager); + WifiAwareHalMock.initAwareHalMockLibrary(mDut); + WifiAwareNative.initAwareHandlersNative(WifiNative.class, WifiNative.sWlan0Index); + HalMockUtils.setHalMockObject(mAwareHalMock); + installMockAwareStateManager(mAwareStateManager); } @Test @@ -110,7 +110,7 @@ public class WifiNanHalTest { mDut.disable(transactionId); - verify(mNanHalMock).disableHalMockNative(transactionId); + verify(mAwareHalMock).disableHalMockNative(transactionId); } @Test @@ -156,7 +156,7 @@ public class WifiNanHalTest { mDut.stopPublish(transactionId, publishId); - verify(mNanHalMock).publishCancelHalMockNative(eq(transactionId), mArgs.capture()); + verify(mAwareHalMock).publishCancelHalMockNative(eq(transactionId), mArgs.capture()); Bundle argsData = HalMockUtils.convertJsonToBundle(mArgs.getValue()); @@ -210,7 +210,7 @@ public class WifiNanHalTest { mDut.stopSubscribe(transactionId, subscribeId); - verify(mNanHalMock).subscribeCancelHalMockNative(eq(transactionId), mArgs.capture()); + verify(mAwareHalMock).subscribeCancelHalMockNative(eq(transactionId), mArgs.capture()); Bundle argsData = HalMockUtils.convertJsonToBundle(mArgs.getValue()); @@ -228,7 +228,7 @@ public class WifiNanHalTest { mDut.sendMessage(transactionId, pubSubId, reqInstanceId, peer, msg.getBytes(), messageId); - verify(mNanHalMock).transmitFollowupHalMockNative(eq(transactionId), mArgs.capture()); + verify(mAwareHalMock).transmitFollowupHalMockNative(eq(transactionId), mArgs.capture()); Bundle argsData = HalMockUtils.convertJsonToBundle(mArgs.getValue()); @@ -259,7 +259,7 @@ public class WifiNanHalTest { mDut.sendMessage(transactionId, pubSubId, reqInstanceId, peer, msg.getBytes(), messageId); - verify(mNanHalMock).transmitFollowupHalMockNative(eq(transactionId), mArgs.capture()); + verify(mAwareHalMock).transmitFollowupHalMockNative(eq(transactionId), mArgs.capture()); Bundle argsData = HalMockUtils.convertJsonToBundle(mArgs.getValue()); @@ -288,7 +288,7 @@ public class WifiNanHalTest { mDut.sendMessage(transactionId, pubSubId, reqInstanceId, peer, msg, messageId); - verify(mNanHalMock).transmitFollowupHalMockNative(eq(transactionId), mArgs.capture()); + verify(mAwareHalMock).transmitFollowupHalMockNative(eq(transactionId), mArgs.capture()); Bundle argsData = HalMockUtils.convertJsonToBundle(mArgs.getValue()); @@ -308,7 +308,7 @@ public class WifiNanHalTest { @Test public void testRespondWithCapabilities() throws JSONException { final short transactionId = 23; - final int max_concurrent_nan_clusters = 1; + final int max_concurrent_aware_clusters = 1; final int max_publishes = 2; final int max_subscribes = 3; final int max_service_name_len = 4; @@ -322,39 +322,40 @@ public class WifiNanHalTest { final int max_app_info_len = 12; final int max_queued_transmit_followup_msgs = 7; - ArgumentCaptor<WifiNanNative.Capabilities> capabilitiesCapture = ArgumentCaptor - .forClass(WifiNanNative.Capabilities.class); + ArgumentCaptor<WifiAwareNative.Capabilities> capabilitiesCapture = ArgumentCaptor + .forClass(WifiAwareNative.Capabilities.class); Bundle args = new Bundle(); - args.putInt("status", WifiNanNative.NAN_STATUS_SUCCESS); + args.putInt("status", WifiAwareNative.AWARE_STATUS_SUCCESS); args.putInt("value", 0); - args.putInt("response_type", WifiNanNative.NAN_RESPONSE_GET_CAPABILITIES); - - args.putInt("body.nan_capabilities.max_concurrent_nan_clusters", - max_concurrent_nan_clusters); - args.putInt("body.nan_capabilities.max_publishes", max_publishes); - args.putInt("body.nan_capabilities.max_subscribes", max_subscribes); - args.putInt("body.nan_capabilities.max_service_name_len", max_service_name_len); - args.putInt("body.nan_capabilities.max_match_filter_len", max_match_filter_len); - args.putInt("body.nan_capabilities.max_total_match_filter_len", max_total_match_filter_len); - args.putInt("body.nan_capabilities.max_service_specific_info_len", + args.putInt("response_type", WifiAwareNative.AWARE_RESPONSE_GET_CAPABILITIES); + + args.putInt("body.aware_capabilities.max_concurrent_aware_clusters", + max_concurrent_aware_clusters); + args.putInt("body.aware_capabilities.max_publishes", max_publishes); + args.putInt("body.aware_capabilities.max_subscribes", max_subscribes); + args.putInt("body.aware_capabilities.max_service_name_len", max_service_name_len); + args.putInt("body.aware_capabilities.max_match_filter_len", max_match_filter_len); + args.putInt("body.aware_capabilities.max_total_match_filter_len", + max_total_match_filter_len); + args.putInt("body.aware_capabilities.max_service_specific_info_len", max_service_specific_info_len); - args.putInt("body.nan_capabilities.max_vsa_data_len", max_vsa_data_len); - args.putInt("body.nan_capabilities.max_mesh_data_len", max_mesh_data_len); - args.putInt("body.nan_capabilities.max_ndi_interfaces", max_ndi_interfaces); - args.putInt("body.nan_capabilities.max_ndp_sessions", max_ndp_sessions); - args.putInt("body.nan_capabilities.max_app_info_len", max_app_info_len); - args.putInt("body.nan_capabilities.max_queued_transmit_followup_msgs", + args.putInt("body.aware_capabilities.max_vsa_data_len", max_vsa_data_len); + args.putInt("body.aware_capabilities.max_mesh_data_len", max_mesh_data_len); + args.putInt("body.aware_capabilities.max_ndi_interfaces", max_ndi_interfaces); + args.putInt("body.aware_capabilities.max_ndp_sessions", max_ndp_sessions); + args.putInt("body.aware_capabilities.max_app_info_len", max_app_info_len); + args.putInt("body.aware_capabilities.max_queued_transmit_followup_msgs", max_queued_transmit_followup_msgs); - WifiNanHalMock.callNotifyResponse(transactionId, + WifiAwareHalMock.callNotifyResponse(transactionId, HalMockUtils.convertBundleToJson(args).toString()); - verify(mNanStateManager).onCapabilitiesUpdateResponse(eq(transactionId), + verify(mAwareStateManager).onCapabilitiesUpdateResponse(eq(transactionId), capabilitiesCapture.capture()); - WifiNanNative.Capabilities capabilities = capabilitiesCapture.getValue(); - collector.checkThat("max_concurrent_nan_clusters", capabilities.maxConcurrentNanClusters, - equalTo(max_concurrent_nan_clusters)); + WifiAwareNative.Capabilities capabilities = capabilitiesCapture.getValue(); + collector.checkThat("max_concurrent_aware_clusters", + capabilities.maxConcurrentAwareClusters, equalTo(max_concurrent_aware_clusters)); collector.checkThat("max_publishes", capabilities.maxPublishes, equalTo(max_publishes)); collector.checkThat("max_subscribes", capabilities.maxSubscribes, equalTo(max_subscribes)); collector.checkThat("max_service_name_len", capabilities.maxServiceNameLen, @@ -377,7 +378,7 @@ public class WifiNanHalTest { equalTo(max_app_info_len)); collector.checkThat("max_queued_transmit_followup_msgs", capabilities.maxQueuedTransmitMessages, equalTo(max_queued_transmit_followup_msgs)); - verifyNoMoreInteractions(mNanStateManager); + verifyNoMoreInteractions(mAwareStateManager); } @Test @@ -385,15 +386,15 @@ public class WifiNanHalTest { final short transactionId = 23; Bundle args = new Bundle(); - args.putInt("status", WifiNanNative.NAN_STATUS_SUCCESS); + args.putInt("status", WifiAwareNative.AWARE_STATUS_SUCCESS); args.putInt("value", 0); - args.putInt("response_type", WifiNanNative.NAN_RESPONSE_ENABLED); + args.putInt("response_type", WifiAwareNative.AWARE_RESPONSE_ENABLED); - WifiNanHalMock.callNotifyResponse(transactionId, + WifiAwareHalMock.callNotifyResponse(transactionId, HalMockUtils.convertBundleToJson(args).toString()); - verify(mNanStateManager).onConfigSuccessResponse(transactionId); - verifyNoMoreInteractions(mNanStateManager); + verify(mAwareStateManager).onConfigSuccessResponse(transactionId); + verifyNoMoreInteractions(mAwareStateManager); } @Test @@ -401,16 +402,16 @@ public class WifiNanHalTest { final short transactionId = 23; Bundle args = new Bundle(); - args.putInt("status", WifiNanNative.NAN_STATUS_INVALID_BAND_CONFIG_FLAGS); + args.putInt("status", WifiAwareNative.AWARE_STATUS_INVALID_BAND_CONFIG_FLAGS); args.putInt("value", 0); - args.putInt("response_type", WifiNanNative.NAN_RESPONSE_ENABLED); + args.putInt("response_type", WifiAwareNative.AWARE_RESPONSE_ENABLED); - WifiNanHalMock.callNotifyResponse(transactionId, + WifiAwareHalMock.callNotifyResponse(transactionId, HalMockUtils.convertBundleToJson(args).toString()); - verify(mNanStateManager).onConfigFailedResponse(transactionId, - WifiNanNative.NAN_STATUS_INVALID_BAND_CONFIG_FLAGS); - verifyNoMoreInteractions(mNanStateManager); + verify(mAwareStateManager).onConfigFailedResponse(transactionId, + WifiAwareNative.AWARE_STATUS_INVALID_BAND_CONFIG_FLAGS); + verifyNoMoreInteractions(mAwareStateManager); } @Test @@ -419,16 +420,16 @@ public class WifiNanHalTest { final int publishId = 127; Bundle args = new Bundle(); - args.putInt("status", WifiNanNative.NAN_STATUS_SUCCESS); + args.putInt("status", WifiAwareNative.AWARE_STATUS_SUCCESS); args.putInt("value", 0); - args.putInt("response_type", WifiNanNative.NAN_RESPONSE_PUBLISH); + args.putInt("response_type", WifiAwareNative.AWARE_RESPONSE_PUBLISH); args.putInt("body.publish_response.publish_id", publishId); - WifiNanHalMock.callNotifyResponse(transactionId, + WifiAwareHalMock.callNotifyResponse(transactionId, HalMockUtils.convertBundleToJson(args).toString()); - verify(mNanStateManager).onSessionConfigSuccessResponse(transactionId, true, publishId); - verifyNoMoreInteractions(mNanStateManager); + verify(mAwareStateManager).onSessionConfigSuccessResponse(transactionId, true, publishId); + verifyNoMoreInteractions(mAwareStateManager); } @Test @@ -437,17 +438,17 @@ public class WifiNanHalTest { final int publishId = 127; Bundle args = new Bundle(); - args.putInt("status", WifiNanNative.NAN_STATUS_NO_SPACE_AVAILABLE); + args.putInt("status", WifiAwareNative.AWARE_STATUS_NO_SPACE_AVAILABLE); args.putInt("value", 57); - args.putInt("response_type", WifiNanNative.NAN_RESPONSE_PUBLISH); + args.putInt("response_type", WifiAwareNative.AWARE_RESPONSE_PUBLISH); args.putInt("body.publish_response.publish_id", publishId); - WifiNanHalMock.callNotifyResponse(transactionId, + WifiAwareHalMock.callNotifyResponse(transactionId, HalMockUtils.convertBundleToJson(args).toString()); - verify(mNanStateManager).onSessionConfigFailResponse(transactionId, true, - WifiNanNative.NAN_STATUS_NO_SPACE_AVAILABLE); - verifyNoMoreInteractions(mNanStateManager); + verify(mAwareStateManager).onSessionConfigFailResponse(transactionId, true, + WifiAwareNative.AWARE_STATUS_NO_SPACE_AVAILABLE); + verifyNoMoreInteractions(mAwareStateManager); } @Test @@ -455,14 +456,14 @@ public class WifiNanHalTest { final short transactionId = 23; Bundle args = new Bundle(); - args.putInt("status", WifiNanNative.NAN_STATUS_SUCCESS); + args.putInt("status", WifiAwareNative.AWARE_STATUS_SUCCESS); args.putInt("value", 0); - args.putInt("response_type", WifiNanNative.NAN_RESPONSE_PUBLISH_CANCEL); + args.putInt("response_type", WifiAwareNative.AWARE_RESPONSE_PUBLISH_CANCEL); - WifiNanHalMock.callNotifyResponse(transactionId, + WifiAwareHalMock.callNotifyResponse(transactionId, HalMockUtils.convertBundleToJson(args).toString()); - verifyNoMoreInteractions(mNanStateManager); + verifyNoMoreInteractions(mAwareStateManager); } @Test @@ -471,16 +472,17 @@ public class WifiNanHalTest { final int subscribeId = 198; Bundle args = new Bundle(); - args.putInt("status", WifiNanNative.NAN_STATUS_SUCCESS); + args.putInt("status", WifiAwareNative.AWARE_STATUS_SUCCESS); args.putInt("value", 0); - args.putInt("response_type", WifiNanNative.NAN_RESPONSE_SUBSCRIBE); + args.putInt("response_type", WifiAwareNative.AWARE_RESPONSE_SUBSCRIBE); args.putInt("body.subscribe_response.subscribe_id", subscribeId); - WifiNanHalMock.callNotifyResponse(transactionId, + WifiAwareHalMock.callNotifyResponse(transactionId, HalMockUtils.convertBundleToJson(args).toString()); - verify(mNanStateManager).onSessionConfigSuccessResponse(transactionId, false, subscribeId); - verifyNoMoreInteractions(mNanStateManager); + verify(mAwareStateManager).onSessionConfigSuccessResponse(transactionId, false, + subscribeId); + verifyNoMoreInteractions(mAwareStateManager); } @Test @@ -489,17 +491,17 @@ public class WifiNanHalTest { final int subscribeId = 198; Bundle args = new Bundle(); - args.putInt("status", WifiNanNative.NAN_STATUS_DE_FAILURE); + args.putInt("status", WifiAwareNative.AWARE_STATUS_DE_FAILURE); args.putInt("value", 0); - args.putInt("response_type", WifiNanNative.NAN_RESPONSE_SUBSCRIBE); + args.putInt("response_type", WifiAwareNative.AWARE_RESPONSE_SUBSCRIBE); args.putInt("body.subscribe_response.subscribe_id", subscribeId); - WifiNanHalMock.callNotifyResponse(transactionId, + WifiAwareHalMock.callNotifyResponse(transactionId, HalMockUtils.convertBundleToJson(args).toString()); - verify(mNanStateManager).onSessionConfigFailResponse(transactionId, false, - WifiNanNative.NAN_STATUS_DE_FAILURE); - verifyNoMoreInteractions(mNanStateManager); + verify(mAwareStateManager).onSessionConfigFailResponse(transactionId, false, + WifiAwareNative.AWARE_STATUS_DE_FAILURE); + verifyNoMoreInteractions(mAwareStateManager); } @Test @@ -507,14 +509,14 @@ public class WifiNanHalTest { final short transactionId = 23; Bundle args = new Bundle(); - args.putInt("status", WifiNanNative.NAN_STATUS_DE_FAILURE); + args.putInt("status", WifiAwareNative.AWARE_STATUS_DE_FAILURE); args.putInt("value", 0); - args.putInt("response_type", WifiNanNative.NAN_RESPONSE_SUBSCRIBE_CANCEL); + args.putInt("response_type", WifiAwareNative.AWARE_RESPONSE_SUBSCRIBE_CANCEL); - WifiNanHalMock.callNotifyResponse(transactionId, + WifiAwareHalMock.callNotifyResponse(transactionId, HalMockUtils.convertBundleToJson(args).toString()); - verifyNoMoreInteractions(mNanStateManager); + verifyNoMoreInteractions(mAwareStateManager); } @Test @@ -522,15 +524,15 @@ public class WifiNanHalTest { final short transactionId = 23; Bundle args = new Bundle(); - args.putInt("status", WifiNanNative.NAN_STATUS_SUCCESS); + args.putInt("status", WifiAwareNative.AWARE_STATUS_SUCCESS); args.putInt("value", 0); - args.putInt("response_type", WifiNanNative.NAN_RESPONSE_TRANSMIT_FOLLOWUP); + args.putInt("response_type", WifiAwareNative.AWARE_RESPONSE_TRANSMIT_FOLLOWUP); - WifiNanHalMock.callNotifyResponse(transactionId, + WifiAwareHalMock.callNotifyResponse(transactionId, HalMockUtils.convertBundleToJson(args).toString()); - verify(mNanStateManager).onMessageSendQueuedSuccessResponse(transactionId); - verifyNoMoreInteractions(mNanStateManager); + verify(mAwareStateManager).onMessageSendQueuedSuccessResponse(transactionId); + verifyNoMoreInteractions(mAwareStateManager); } @Test @@ -538,50 +540,50 @@ public class WifiNanHalTest { final short transactionId = 45; Bundle args = new Bundle(); - args.putInt("status", WifiNanNative.NAN_STATUS_TIMEOUT); + args.putInt("status", WifiAwareNative.AWARE_STATUS_TIMEOUT); args.putInt("value", 0); - args.putInt("response_type", WifiNanNative.NAN_RESPONSE_TRANSMIT_FOLLOWUP); + args.putInt("response_type", WifiAwareNative.AWARE_RESPONSE_TRANSMIT_FOLLOWUP); - WifiNanHalMock.callNotifyResponse(transactionId, + WifiAwareHalMock.callNotifyResponse(transactionId, HalMockUtils.convertBundleToJson(args).toString()); - verify(mNanStateManager).onMessageSendQueuedFailResponse(transactionId, - WifiNanNative.NAN_STATUS_TIMEOUT); - verifyNoMoreInteractions(mNanStateManager); + verify(mAwareStateManager).onMessageSendQueuedFailResponse(transactionId, + WifiAwareNative.AWARE_STATUS_TIMEOUT); + verifyNoMoreInteractions(mAwareStateManager); } @Test public void testNotifyResponseCreateDataPath() throws JSONException { final short transactionId = 48; - final int reason = WifiNanNative.NAN_STATUS_TIMEOUT; + final int reason = WifiAwareNative.AWARE_STATUS_TIMEOUT; Bundle args = new Bundle(); args.putInt("status", reason); args.putInt("value", 0); - args.putInt("response_type", WifiNanNative.NAN_RESPONSE_DP_INTERFACE_CREATE); + args.putInt("response_type", WifiAwareNative.AWARE_RESPONSE_DP_INTERFACE_CREATE); - WifiNanHalMock.callNotifyResponse(transactionId, + WifiAwareHalMock.callNotifyResponse(transactionId, HalMockUtils.convertBundleToJson(args).toString()); - verify(mNanStateManager).onCreateDataPathInterfaceResponse(transactionId, false, reason); - verifyNoMoreInteractions(mNanStateManager); + verify(mAwareStateManager).onCreateDataPathInterfaceResponse(transactionId, false, reason); + verifyNoMoreInteractions(mAwareStateManager); } @Test public void testNotifyResponseDeleteDataPath() throws JSONException { final short transactionId = 49; - final int reason = WifiNanNative.NAN_STATUS_DE_FAILURE; + final int reason = WifiAwareNative.AWARE_STATUS_DE_FAILURE; Bundle args = new Bundle(); args.putInt("status", reason); args.putInt("value", 0); - args.putInt("response_type", WifiNanNative.NAN_RESPONSE_DP_INTERFACE_DELETE); + args.putInt("response_type", WifiAwareNative.AWARE_RESPONSE_DP_INTERFACE_DELETE); - WifiNanHalMock.callNotifyResponse(transactionId, + WifiAwareHalMock.callNotifyResponse(transactionId, HalMockUtils.convertBundleToJson(args).toString()); - verify(mNanStateManager).onDeleteDataPathInterfaceResponse(transactionId, false, reason); - verifyNoMoreInteractions(mNanStateManager); + verify(mAwareStateManager).onDeleteDataPathInterfaceResponse(transactionId, false, reason); + verifyNoMoreInteractions(mAwareStateManager); } @Test @@ -590,69 +592,69 @@ public class WifiNanHalTest { final int ndpId = 1234; Bundle args = new Bundle(); - args.putInt("status", WifiNanNative.NAN_STATUS_SUCCESS); + args.putInt("status", WifiAwareNative.AWARE_STATUS_SUCCESS); args.putInt("value", 0); - args.putInt("response_type", WifiNanNative.NAN_RESPONSE_DP_INITIATOR_RESPONSE); + args.putInt("response_type", WifiAwareNative.AWARE_RESPONSE_DP_INITIATOR_RESPONSE); args.putInt("body.data_request_response.ndp_instance_id", ndpId); - WifiNanHalMock.callNotifyResponse(transactionId, + WifiAwareHalMock.callNotifyResponse(transactionId, HalMockUtils.convertBundleToJson(args).toString()); - verify(mNanStateManager).onInitiateDataPathResponseSuccess(transactionId, ndpId); - verifyNoMoreInteractions(mNanStateManager); + verify(mAwareStateManager).onInitiateDataPathResponseSuccess(transactionId, ndpId); + verifyNoMoreInteractions(mAwareStateManager); } @Test public void testNotifyResponseInitiateDataPathFail() throws JSONException { final short transactionId = 49; - final int reason = WifiNanNative.NAN_STATUS_NDP_DATA_INITIATOR_REQUEST_FAILED; + final int reason = WifiAwareNative.AWARE_STATUS_NDP_DATA_INITIATOR_REQUEST_FAILED; Bundle args = new Bundle(); args.putInt("status", reason); args.putInt("value", 0); - args.putInt("response_type", WifiNanNative.NAN_RESPONSE_DP_INITIATOR_RESPONSE); + args.putInt("response_type", WifiAwareNative.AWARE_RESPONSE_DP_INITIATOR_RESPONSE); args.putInt("body.data_request_response.ndp_instance_id", 5555); // NOP - WifiNanHalMock.callNotifyResponse(transactionId, + WifiAwareHalMock.callNotifyResponse(transactionId, HalMockUtils.convertBundleToJson(args).toString()); - verify(mNanStateManager).onInitiateDataPathResponseFail(transactionId, reason); - verifyNoMoreInteractions(mNanStateManager); + verify(mAwareStateManager).onInitiateDataPathResponseFail(transactionId, reason); + verifyNoMoreInteractions(mAwareStateManager); } @Test public void testNotifyResponseRespondToDataPathSetupRequest() throws JSONException { final short transactionId = 50; - final int reason = WifiNanNative.NAN_STATUS_DISABLE_IN_PROGRESS; + final int reason = WifiAwareNative.AWARE_STATUS_DISABLE_IN_PROGRESS; Bundle args = new Bundle(); args.putInt("status", reason); args.putInt("value", 0); - args.putInt("response_type", WifiNanNative.NAN_RESPONSE_DP_RESPONDER_RESPONSE); + args.putInt("response_type", WifiAwareNative.AWARE_RESPONSE_DP_RESPONDER_RESPONSE); - WifiNanHalMock.callNotifyResponse(transactionId, + WifiAwareHalMock.callNotifyResponse(transactionId, HalMockUtils.convertBundleToJson(args).toString()); - verify(mNanStateManager).onRespondToDataPathSetupRequestResponse(transactionId, false, + verify(mAwareStateManager).onRespondToDataPathSetupRequestResponse(transactionId, false, reason); - verifyNoMoreInteractions(mNanStateManager); + verifyNoMoreInteractions(mAwareStateManager); } @Test public void testNotifyResponseEndDataPath() throws JSONException { final short transactionId = 50; - final int reason = WifiNanNative.NAN_STATUS_NDP_END_FAILED; + final int reason = WifiAwareNative.AWARE_STATUS_NDP_END_FAILED; Bundle args = new Bundle(); args.putInt("status", reason); args.putInt("value", 0); - args.putInt("response_type", WifiNanNative.NAN_RESPONSE_DP_END); + args.putInt("response_type", WifiAwareNative.AWARE_RESPONSE_DP_END); - WifiNanHalMock.callNotifyResponse(transactionId, + WifiAwareHalMock.callNotifyResponse(transactionId, HalMockUtils.convertBundleToJson(args).toString()); - verify(mNanStateManager).onEndDataPathResponse(transactionId, false, reason); - verifyNoMoreInteractions(mNanStateManager); + verify(mAwareStateManager).onEndDataPathResponse(transactionId, false, reason); + verifyNoMoreInteractions(mAwareStateManager); } @Test @@ -661,14 +663,14 @@ public class WifiNanHalTest { final short transactionId = 46; Bundle args = new Bundle(); - args.putInt("status", WifiNanNative.NAN_STATUS_SUCCESS); + args.putInt("status", WifiAwareNative.AWARE_STATUS_SUCCESS); args.putInt("value", 0); args.putInt("response_type", invalidTransactionId); - WifiNanHalMock.callNotifyResponse(transactionId, + WifiAwareHalMock.callNotifyResponse(transactionId, HalMockUtils.convertBundleToJson(args).toString()); - verifyNoMoreInteractions(mNanStateManager); + verifyNoMoreInteractions(mAwareStateManager); } @Test @@ -677,13 +679,13 @@ public class WifiNanHalTest { Bundle args = new Bundle(); args.putInt("publish_id", publishId); - args.putInt("reason", WifiNanNative.NAN_TERMINATED_REASON_COUNT_REACHED); + args.putInt("reason", WifiAwareNative.AWARE_TERMINATED_REASON_COUNT_REACHED); - WifiNanHalMock.callPublishTerminated(HalMockUtils.convertBundleToJson(args).toString()); + WifiAwareHalMock.callPublishTerminated(HalMockUtils.convertBundleToJson(args).toString()); - verify(mNanStateManager).onSessionTerminatedNotification(publishId, - WifiNanDiscoverySessionCallback.TERMINATE_REASON_DONE, true); - verifyNoMoreInteractions(mNanStateManager); + verify(mAwareStateManager).onSessionTerminatedNotification(publishId, + WifiAwareDiscoverySessionCallback.TERMINATE_REASON_DONE, true); + verifyNoMoreInteractions(mAwareStateManager); } @Test @@ -692,13 +694,13 @@ public class WifiNanHalTest { Bundle args = new Bundle(); args.putInt("subscribe_id", subscribeId); - args.putInt("reason", WifiNanNative.NAN_TERMINATED_REASON_FAILURE); + args.putInt("reason", WifiAwareNative.AWARE_TERMINATED_REASON_FAILURE); - WifiNanHalMock.callSubscribeTerminated(HalMockUtils.convertBundleToJson(args).toString()); + WifiAwareHalMock.callSubscribeTerminated(HalMockUtils.convertBundleToJson(args).toString()); - verify(mNanStateManager).onSessionTerminatedNotification(subscribeId, - WifiNanDiscoverySessionCallback.TERMINATE_REASON_FAIL, false); - verifyNoMoreInteractions(mNanStateManager); + verify(mAwareStateManager).onSessionTerminatedNotification(subscribeId, + WifiAwareDiscoverySessionCallback.TERMINATE_REASON_FAIL, false); + verifyNoMoreInteractions(mAwareStateManager); } @Test @@ -716,11 +718,11 @@ public class WifiNanHalTest { args.putInt("service_specific_info_len", message.length()); args.putByteArray("service_specific_info", message.getBytes()); - WifiNanHalMock.callFollowup(HalMockUtils.convertBundleToJson(args).toString()); + WifiAwareHalMock.callFollowup(HalMockUtils.convertBundleToJson(args).toString()); - verify(mNanStateManager).onMessageReceivedNotification(pubSubId, reqInstanceId, peer, + verify(mAwareStateManager).onMessageReceivedNotification(pubSubId, reqInstanceId, peer, message.getBytes()); - verifyNoMoreInteractions(mNanStateManager); + verifyNoMoreInteractions(mAwareStateManager); } @Test @@ -740,11 +742,11 @@ public class WifiNanHalTest { args.putInt("sdf_match_filter_len", filter.length()); args.putByteArray("sdf_match_filter", filter.getBytes()); - WifiNanHalMock.callMatch(HalMockUtils.convertBundleToJson(args).toString()); + WifiAwareHalMock.callMatch(HalMockUtils.convertBundleToJson(args).toString()); - verify(mNanStateManager).onMatchNotification(pubSubId, reqInstanceId, peer, ssi.getBytes(), - filter.getBytes()); - verifyNoMoreInteractions(mNanStateManager); + verify(mAwareStateManager).onMatchNotification(pubSubId, reqInstanceId, peer, + ssi.getBytes(), filter.getBytes()); + verifyNoMoreInteractions(mAwareStateManager); } @Test @@ -752,13 +754,13 @@ public class WifiNanHalTest { final byte[] mac = HexEncoding.decode("060504030201".toCharArray(), false); Bundle args = new Bundle(); - args.putInt("event_type", WifiNanNative.NAN_EVENT_ID_DISC_MAC_ADDR); + args.putInt("event_type", WifiAwareNative.AWARE_EVENT_ID_DISC_MAC_ADDR); args.putByteArray("data", mac); - WifiNanHalMock.callDiscEngEvent(HalMockUtils.convertBundleToJson(args).toString()); + WifiAwareHalMock.callDiscEngEvent(HalMockUtils.convertBundleToJson(args).toString()); - verify(mNanStateManager).onInterfaceAddressChangeNotification(mac); - verifyNoMoreInteractions(mNanStateManager); + verify(mAwareStateManager).onInterfaceAddressChangeNotification(mac); + verifyNoMoreInteractions(mAwareStateManager); } @Test @@ -766,14 +768,14 @@ public class WifiNanHalTest { final byte[] mac = HexEncoding.decode("060504030201".toCharArray(), false); Bundle args = new Bundle(); - args.putInt("event_type", WifiNanNative.NAN_EVENT_ID_JOINED_CLUSTER); + args.putInt("event_type", WifiAwareNative.AWARE_EVENT_ID_JOINED_CLUSTER); args.putByteArray("data", mac); - WifiNanHalMock.callDiscEngEvent(HalMockUtils.convertBundleToJson(args).toString()); + WifiAwareHalMock.callDiscEngEvent(HalMockUtils.convertBundleToJson(args).toString()); - verify(mNanStateManager) - .onClusterChangeNotification(WifiNanClientState.CLUSTER_CHANGE_EVENT_JOINED, mac); - verifyNoMoreInteractions(mNanStateManager); + verify(mAwareStateManager) + .onClusterChangeNotification(WifiAwareClientState.CLUSTER_CHANGE_EVENT_JOINED, mac); + verifyNoMoreInteractions(mAwareStateManager); } @Test @@ -781,25 +783,25 @@ public class WifiNanHalTest { final byte[] mac = HexEncoding.decode("0A0B0C0B0A00".toCharArray(), false); Bundle args = new Bundle(); - args.putInt("event_type", WifiNanNative.NAN_EVENT_ID_STARTED_CLUSTER); + args.putInt("event_type", WifiAwareNative.AWARE_EVENT_ID_STARTED_CLUSTER); args.putByteArray("data", mac); - WifiNanHalMock.callDiscEngEvent(HalMockUtils.convertBundleToJson(args).toString()); + WifiAwareHalMock.callDiscEngEvent(HalMockUtils.convertBundleToJson(args).toString()); - verify(mNanStateManager) - .onClusterChangeNotification(WifiNanClientState.CLUSTER_CHANGE_EVENT_STARTED, mac); - verifyNoMoreInteractions(mNanStateManager); + verify(mAwareStateManager).onClusterChangeNotification( + WifiAwareClientState.CLUSTER_CHANGE_EVENT_STARTED, mac); + verifyNoMoreInteractions(mAwareStateManager); } @Test public void testDisabled() throws JSONException { Bundle args = new Bundle(); - args.putInt("reason", WifiNanNative.NAN_STATUS_DE_FAILURE); + args.putInt("reason", WifiAwareNative.AWARE_STATUS_DE_FAILURE); - WifiNanHalMock.callDisabled(HalMockUtils.convertBundleToJson(args).toString()); + WifiAwareHalMock.callDisabled(HalMockUtils.convertBundleToJson(args).toString()); - verify(mNanStateManager).onNanDownNotification(WifiNanNative.NAN_STATUS_DE_FAILURE); - verifyNoMoreInteractions(mNanStateManager); + verify(mAwareStateManager).onAwareDownNotification(WifiAwareNative.AWARE_STATUS_DE_FAILURE); + verifyNoMoreInteractions(mAwareStateManager); } @Test @@ -808,12 +810,12 @@ public class WifiNanHalTest { Bundle args = new Bundle(); args.putInt("id", transactionId); - args.putInt("reason", WifiNanNative.NAN_STATUS_SUCCESS); + args.putInt("reason", WifiAwareNative.AWARE_STATUS_SUCCESS); - WifiNanHalMock.callTransmitFollowup(HalMockUtils.convertBundleToJson(args).toString()); + WifiAwareHalMock.callTransmitFollowup(HalMockUtils.convertBundleToJson(args).toString()); - verify(mNanStateManager).onMessageSendSuccessNotification(transactionId); - verifyNoMoreInteractions(mNanStateManager); + verify(mAwareStateManager).onMessageSendSuccessNotification(transactionId); + verifyNoMoreInteractions(mAwareStateManager); } @Test @@ -822,23 +824,24 @@ public class WifiNanHalTest { Bundle args = new Bundle(); args.putInt("id", transactionId); - args.putInt("reason", WifiNanNative.NAN_STATUS_TX_FAIL); + args.putInt("reason", WifiAwareNative.AWARE_STATUS_TX_FAIL); - WifiNanHalMock.callTransmitFollowup(HalMockUtils.convertBundleToJson(args).toString()); + WifiAwareHalMock.callTransmitFollowup(HalMockUtils.convertBundleToJson(args).toString()); - verify(mNanStateManager).onMessageSendFailNotification(transactionId, - WifiNanNative.NAN_STATUS_TX_FAIL); - verifyNoMoreInteractions(mNanStateManager); + verify(mAwareStateManager).onMessageSendFailNotification(transactionId, + WifiAwareNative.AWARE_STATUS_TX_FAIL); + verifyNoMoreInteractions(mAwareStateManager); } @Test - public void testCreateNanNetworkInterface() throws JSONException { + public void testCreateAwareNetworkInterface() throws JSONException { final short transactionId = 10; - final String interfaceName = "nan0"; + final String interfaceName = "aware0"; - mDut.createNanNetworkInterface(transactionId, interfaceName); + mDut.createAwareNetworkInterface(transactionId, interfaceName); - verify(mNanHalMock).createNanNetworkInterfaceMockNative(eq(transactionId), mArgs.capture()); + verify(mAwareHalMock).createAwareNetworkInterfaceMockNative(eq(transactionId), + mArgs.capture()); Bundle argsData = HalMockUtils.convertJsonToBundle(mArgs.getValue()); @@ -847,13 +850,14 @@ public class WifiNanHalTest { } @Test - public void testDeleteNanNetworkInterface() throws JSONException { + public void testDeleteAwareNetworkInterface() throws JSONException { final short transactionId = 10; - final String interfaceName = "nan0"; + final String interfaceName = "aware0"; - mDut.deleteNanNetworkInterface(transactionId, interfaceName); + mDut.deleteAwareNetworkInterface(transactionId, interfaceName); - verify(mNanHalMock).deleteNanNetworkInterfaceMockNative(eq(transactionId), mArgs.capture()); + verify(mAwareHalMock).deleteAwareNetworkInterfaceMockNative(eq(transactionId), + mArgs.capture()); Bundle argsData = HalMockUtils.convertJsonToBundle(mArgs.getValue()); @@ -868,13 +872,13 @@ public class WifiNanHalTest { final int channelRequestType = 0; final int channel = 2437; final byte[] peer = HexEncoding.decode("0A0B0C0D0E0F".toCharArray(), false); - final String interfaceName = "nan1"; + final String interfaceName = "aware1"; final String msg = "let me talk!"; mDut.initiateDataPath(transactionId, pubSubId, channelRequestType, channel, peer, interfaceName, msg.getBytes()); - verify(mNanHalMock).initiateDataPathMockNative(eq(transactionId), mArgs.capture()); + verify(mAwareHalMock).initiateDataPathMockNative(eq(transactionId), mArgs.capture()); Bundle argsData = HalMockUtils.convertJsonToBundle(mArgs.getValue()); @@ -901,13 +905,14 @@ public class WifiNanHalTest { final short transactionId = 123; final boolean accept = true; final int ndpId = 523; - final String interfaceName = "nan1"; + final String interfaceName = "aware1"; final String msg = "fine - you can talk ..."; mDut.respondToDataPathRequest(transactionId, accept, ndpId, interfaceName, msg .getBytes()); - verify(mNanHalMock).respondToDataPathRequestMockNative(eq(transactionId), mArgs.capture()); + verify(mAwareHalMock).respondToDataPathRequestMockNative(eq(transactionId), + mArgs.capture()); Bundle argsData = HalMockUtils.convertJsonToBundle(mArgs.getValue()); @@ -931,7 +936,7 @@ public class WifiNanHalTest { mDut.endDataPath(transactionId, ndpId); - verify(mNanHalMock).endDataPathMockNative(eq(transactionId), mArgs.capture()); + verify(mAwareHalMock).endDataPathMockNative(eq(transactionId), mArgs.capture()); Bundle argsData = HalMockUtils.convertJsonToBundle(mArgs.getValue()); @@ -955,11 +960,11 @@ public class WifiNanHalTest { args.putInt("app_info.ndp_app_info_len", msg.length()); args.putByteArray("app_info.ndp_app_info", msg.getBytes()); - WifiNanHalMock.callDataPathRequest(HalMockUtils.convertBundleToJson(args).toString()); + WifiAwareHalMock.callDataPathRequest(HalMockUtils.convertBundleToJson(args).toString()); - verify(mNanStateManager).onDataPathRequestNotification(pubSubId, peer, ndpId, + verify(mAwareStateManager).onDataPathRequestNotification(pubSubId, peer, ndpId, msg.getBytes()); - verifyNoMoreInteractions(mNanStateManager); + verifyNoMoreInteractions(mAwareStateManager); } @Test @@ -978,11 +983,11 @@ public class WifiNanHalTest { args.putInt("rsp_code", accept ? 0 : 1); args.putInt("reason_code", reason); - WifiNanHalMock.callDataPathConfirm(HalMockUtils.convertBundleToJson(args).toString()); + WifiAwareHalMock.callDataPathConfirm(HalMockUtils.convertBundleToJson(args).toString()); - verify(mNanStateManager).onDataPathConfirmNotification(ndpId, peer, accept, reason, + verify(mAwareStateManager).onDataPathConfirmNotification(ndpId, peer, accept, reason, msg.getBytes()); - verifyNoMoreInteractions(mNanStateManager); + verifyNoMoreInteractions(mAwareStateManager); } @Test @@ -1012,7 +1017,7 @@ public class WifiNanHalTest { mDut.enableAndConfigure(transactionId, configRequest, true); - verify(mNanHalMock).enableHalMockNative(eq(transactionId), mArgs.capture()); + verify(mAwareHalMock).enableHalMockNative(eq(transactionId), mArgs.capture()); Bundle argsData = HalMockUtils.convertJsonToBundle(mArgs.getValue()); @@ -1065,7 +1070,7 @@ public class WifiNanHalTest { mDut.enableAndConfigure(transactionId, configRequest, false); - verify(mNanHalMock).configHalMockNative(eq(transactionId), mArgs.capture()); + verify(mAwareHalMock).configHalMockNative(eq(transactionId), mArgs.capture()); Bundle argsData = HalMockUtils.convertJsonToBundle(mArgs.getValue()); @@ -1117,7 +1122,7 @@ public class WifiNanHalTest { mDut.publish(transactionId, publishId, publishConfig); - verify(mNanHalMock).publishHalMockNative(eq(transactionId), mArgs.capture()); + verify(mAwareHalMock).publishHalMockNative(eq(transactionId), mArgs.capture()); Bundle argsData = HalMockUtils.convertJsonToBundle(mArgs.getValue()); @@ -1164,7 +1169,7 @@ public class WifiNanHalTest { mDut.subscribe(transactionId, subscribeId, subscribeConfig); - verify(mNanHalMock).subscribeHalMockNative(eq(transactionId), mArgs.capture()); + verify(mAwareHalMock).subscribeHalMockNative(eq(transactionId), mArgs.capture()); Bundle argsData = HalMockUtils.convertJsonToBundle(mArgs.getValue()); @@ -1216,11 +1221,11 @@ public class WifiNanHalTest { args.putInt("num_ndp_instances", numInstances); args.putInt("ndp_instance_id", ndpIdBase); - WifiNanHalMock.callDataPathEnd(HalMockUtils.convertBundleToJson(args).toString()); + WifiAwareHalMock.callDataPathEnd(HalMockUtils.convertBundleToJson(args).toString()); - verify(mNanStateManager, times(numInstances)).onDataPathEndNotification( + verify(mAwareStateManager, times(numInstances)).onDataPathEndNotification( ndpIdsCaptor.capture()); - verifyNoMoreInteractions(mNanStateManager); + verifyNoMoreInteractions(mAwareStateManager); for (int i = 0; i < numInstances; ++i) { collector.checkThat("ndp id #" + i, ndpIdsCaptor.getAllValues().get(i), @@ -1228,15 +1233,15 @@ public class WifiNanHalTest { } } - private static void installMockNanStateManager(WifiNanStateManager nanStateManager) + private static void installMockAwareStateManager(WifiAwareStateManager awareStateManager) throws Exception { - Field field = WifiNanStateManager.class.getDeclaredField("sNanStateManagerSingleton"); + Field field = WifiAwareStateManager.class.getDeclaredField("sAwareStateManagerSingleton"); field.setAccessible(true); - field.set(null, nanStateManager); + field.set(null, awareStateManager); } - private static void resetWifiNanNative() throws Exception { - Field field = WifiNanNative.class.getDeclaredField("sWifiNanNativeSingleton"); + private static void resetWifiAwareNative() throws Exception { + Field field = WifiAwareNative.class.getDeclaredField("sWifiAwareNativeSingleton"); field.setAccessible(true); field.set(null, null); } diff --git a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanManagerTest.java b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareManagerTest.java index 7e451af2f..5239e329f 100644 --- a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareManagerTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.server.wifi.nan; +package com.android.server.wifi.aware; import static org.hamcrest.core.IsEqual.equalTo; import static org.junit.Assert.assertEquals; @@ -30,18 +30,18 @@ import static org.mockito.Mockito.when; import android.content.Context; import android.net.wifi.RttManager; -import android.net.wifi.nan.ConfigRequest; -import android.net.wifi.nan.IWifiNanDiscoverySessionCallback; -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.WifiNanManager; -import android.net.wifi.nan.WifiNanPublishDiscoverySession; -import android.net.wifi.nan.WifiNanSession; -import android.net.wifi.nan.WifiNanSubscribeDiscoverySession; +import android.net.wifi.aware.ConfigRequest; +import android.net.wifi.aware.IWifiAwareDiscoverySessionCallback; +import android.net.wifi.aware.IWifiAwareEventCallback; +import android.net.wifi.aware.IWifiAwareManager; +import android.net.wifi.aware.PublishConfig; +import android.net.wifi.aware.SubscribeConfig; +import android.net.wifi.aware.WifiAwareAttachCallback; +import android.net.wifi.aware.WifiAwareDiscoverySessionCallback; +import android.net.wifi.aware.WifiAwareManager; +import android.net.wifi.aware.WifiAwarePublishDiscoverySession; +import android.net.wifi.aware.WifiAwareSession; +import android.net.wifi.aware.WifiAwareSubscribeDiscoverySession; import android.os.Handler; import android.os.IBinder; import android.os.Parcel; @@ -62,11 +62,11 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; /** - * Unit test harness for WifiNanManager class. + * Unit test harness for WifiAwareManager class. */ @SmallTest -public class WifiNanManagerTest { - private WifiNanManager mDut; +public class WifiAwareManagerTest { + private WifiAwareManager mDut; private TestLooper mMockLooper; private Handler mMockLooperHandler; @@ -77,19 +77,19 @@ public class WifiNanManagerTest { public Context mockContext; @Mock - public WifiNanAttachCallback mockCallback; + public WifiAwareAttachCallback mockCallback; @Mock - public WifiNanDiscoverySessionCallback mockSessionCallback; + public WifiAwareDiscoverySessionCallback mockSessionCallback; @Mock - public IWifiNanManager mockNanService; + public IWifiAwareManager mockAwareService; @Mock - public WifiNanPublishDiscoverySession mockPublishSession; + public WifiAwarePublishDiscoverySession mockPublishSession; @Mock - public WifiNanSubscribeDiscoverySession mockSubscribeSession; + public WifiAwareSubscribeDiscoverySession mockSubscribeSession; @Mock public RttManager.RttListener mockRttListener; @@ -98,7 +98,7 @@ public class WifiNanManagerTest { public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - mDut = new WifiNanManager(mockContext, mockNanService); + mDut = new WifiAwareManager(mockContext, mockAwareService); mMockLooper = new TestLooper(); mMockLooperHandler = new Handler(mMockLooper.getLooper()); } @@ -114,7 +114,7 @@ public class WifiNanManagerTest { public void testEnableUsage() throws Exception { mDut.enableUsage(); - verify(mockNanService).enableUsage(); + verify(mockAwareService).enableUsage(); } /** @@ -124,7 +124,7 @@ public class WifiNanManagerTest { public void testDisableUsage() throws Exception { mDut.disableUsage(); - verify(mockNanService).disableUsage(); + verify(mockAwareService).disableUsage(); } /** @@ -134,7 +134,7 @@ public class WifiNanManagerTest { public void testIsUsageEnable() throws Exception { mDut.isAvailable(); - verify(mockNanService).isUsageEnabled(); + verify(mockAwareService).isUsageEnabled(); } /** @@ -144,11 +144,11 @@ public class WifiNanManagerTest { public void testGetCharacteristics() throws Exception { mDut.getCharacteristics(); - verify(mockNanService).getCharacteristics(); + verify(mockAwareService).getCharacteristics(); } /* - * WifiNanEventCallbackProxy Tests + * WifiAwareEventCallbackProxy Tests */ /** @@ -159,31 +159,31 @@ public class WifiNanManagerTest { public void testConnectFlow() throws Exception { final int clientId = 4565; - InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mockNanService); - ArgumentCaptor<IWifiNanEventCallback> clientProxyCallback = ArgumentCaptor - .forClass(IWifiNanEventCallback.class); - ArgumentCaptor<WifiNanSession> sessionCaptor = ArgumentCaptor.forClass( - WifiNanSession.class); + InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mockAwareService); + ArgumentCaptor<IWifiAwareEventCallback> clientProxyCallback = ArgumentCaptor + .forClass(IWifiAwareEventCallback.class); + ArgumentCaptor<WifiAwareSession> sessionCaptor = ArgumentCaptor.forClass( + WifiAwareSession.class); ArgumentCaptor<IBinder> binder = ArgumentCaptor.forClass(IBinder.class); // (1) connect + success mDut.attach(mMockLooperHandler, mockCallback); - inOrder.verify(mockNanService).connect(binder.capture(), anyString(), + inOrder.verify(mockAwareService).connect(binder.capture(), anyString(), clientProxyCallback.capture(), (ConfigRequest) isNull(), eq(false)); clientProxyCallback.getValue().onConnectSuccess(clientId); mMockLooper.dispatchAll(); inOrder.verify(mockCallback).onAttached(sessionCaptor.capture()); - WifiNanSession session = sessionCaptor.getValue(); + WifiAwareSession session = sessionCaptor.getValue(); // (2) publish - should succeed PublishConfig publishConfig = new PublishConfig.Builder().build(); session.publish(mMockLooperHandler, publishConfig, mockSessionCallback); - inOrder.verify(mockNanService).publish(eq(clientId), eq(publishConfig), - any(IWifiNanDiscoverySessionCallback.class)); + inOrder.verify(mockAwareService).publish(eq(clientId), eq(publishConfig), + any(IWifiAwareDiscoverySessionCallback.class)); // (3) disconnect session.destroy(); - inOrder.verify(mockNanService).disconnect(eq(clientId), eq(binder.getValue())); + inOrder.verify(mockAwareService).disconnect(eq(clientId), eq(binder.getValue())); // (4) try publishing again - fails silently session.publish(mMockLooperHandler, new PublishConfig.Builder().build(), @@ -191,10 +191,10 @@ public class WifiNanManagerTest { // (5) connect mDut.attach(mMockLooperHandler, mockCallback); - inOrder.verify(mockNanService).connect(binder.capture(), anyString(), - any(IWifiNanEventCallback.class), (ConfigRequest) isNull(), eq(false)); + inOrder.verify(mockAwareService).connect(binder.capture(), anyString(), + any(IWifiAwareEventCallback.class), (ConfigRequest) isNull(), eq(false)); - verifyNoMoreInteractions(mockCallback, mockSessionCallback, mockNanService); + verifyNoMoreInteractions(mockCallback, mockSessionCallback, mockAwareService); } /** @@ -203,17 +203,17 @@ public class WifiNanManagerTest { @Test public void testConnectFailure() throws Exception { final int clientId = 4565; - final int reason = WifiNanNative.NAN_STATUS_ERROR; + final int reason = WifiAwareNative.AWARE_STATUS_ERROR; - InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mockNanService); - ArgumentCaptor<WifiNanSession> sessionCaptor = ArgumentCaptor.forClass( - WifiNanSession.class); - ArgumentCaptor<IWifiNanEventCallback> clientProxyCallback = ArgumentCaptor - .forClass(IWifiNanEventCallback.class); + InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mockAwareService); + ArgumentCaptor<WifiAwareSession> sessionCaptor = ArgumentCaptor.forClass( + WifiAwareSession.class); + ArgumentCaptor<IWifiAwareEventCallback> clientProxyCallback = ArgumentCaptor + .forClass(IWifiAwareEventCallback.class); // (1) connect + failure mDut.attach(mMockLooperHandler, mockCallback); - inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(), + inOrder.verify(mockAwareService).connect(any(IBinder.class), anyString(), clientProxyCallback.capture(), (ConfigRequest) isNull(), eq(false)); clientProxyCallback.getValue().onConnectFail(reason); mMockLooper.dispatchAll(); @@ -221,20 +221,20 @@ public class WifiNanManagerTest { // (2) connect + success mDut.attach(mMockLooperHandler, mockCallback); - inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(), + inOrder.verify(mockAwareService).connect(any(IBinder.class), anyString(), clientProxyCallback.capture(), (ConfigRequest) isNull(), eq(false)); clientProxyCallback.getValue().onConnectSuccess(clientId); mMockLooper.dispatchAll(); inOrder.verify(mockCallback).onAttached(sessionCaptor.capture()); - WifiNanSession session = sessionCaptor.getValue(); + WifiAwareSession session = sessionCaptor.getValue(); // (4) subscribe: should succeed SubscribeConfig subscribeConfig = new SubscribeConfig.Builder().build(); session.subscribe(mMockLooperHandler, subscribeConfig, mockSessionCallback); - inOrder.verify(mockNanService).subscribe(eq(clientId), eq(subscribeConfig), - any(IWifiNanDiscoverySessionCallback.class)); + inOrder.verify(mockAwareService).subscribe(eq(clientId), eq(subscribeConfig), + any(IWifiAwareDiscoverySessionCallback.class)); - verifyNoMoreInteractions(mockCallback, mockSessionCallback, mockNanService); + verifyNoMoreInteractions(mockCallback, mockSessionCallback, mockAwareService); } /** @@ -245,31 +245,31 @@ public class WifiNanManagerTest { public void testInvalidConnectSequence() throws Exception { final int clientId = 4565; - InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mockNanService); - ArgumentCaptor<IWifiNanEventCallback> clientProxyCallback = ArgumentCaptor - .forClass(IWifiNanEventCallback.class); + InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mockAwareService); + ArgumentCaptor<IWifiAwareEventCallback> clientProxyCallback = ArgumentCaptor + .forClass(IWifiAwareEventCallback.class); // (1) connect + success mDut.attach(mMockLooperHandler, mockCallback); - inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(), + inOrder.verify(mockAwareService).connect(any(IBinder.class), anyString(), clientProxyCallback.capture(), (ConfigRequest) isNull(), eq(false)); clientProxyCallback.getValue().onConnectSuccess(clientId); mMockLooper.dispatchAll(); - inOrder.verify(mockCallback).onAttached(any(WifiNanSession.class)); + inOrder.verify(mockCallback).onAttached(any(WifiAwareSession.class)); // (2) connect + success mDut.attach(mMockLooperHandler, mockCallback); - inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(), + inOrder.verify(mockAwareService).connect(any(IBinder.class), anyString(), clientProxyCallback.capture(), (ConfigRequest) isNull(), eq(false)); clientProxyCallback.getValue().onConnectSuccess(clientId + 1); mMockLooper.dispatchAll(); - inOrder.verify(mockCallback).onAttached(any(WifiNanSession.class)); + inOrder.verify(mockCallback).onAttached(any(WifiAwareSession.class)); - verifyNoMoreInteractions(mockCallback, mockSessionCallback, mockNanService); + verifyNoMoreInteractions(mockCallback, mockSessionCallback, mockAwareService); } /* - * WifiNanDiscoverySessionCallbackProxy Tests + * WifiAwareDiscoverySessionCallbackProxy Tests */ /** @@ -284,36 +284,37 @@ public class WifiNanManagerTest { final int sessionId = 123; final ConfigRequest configRequest = new ConfigRequest.Builder().build(); final PublishConfig publishConfig = new PublishConfig.Builder().build(); - final WifiNanManager.OpaquePeerHandle peerHandle = new WifiNanManager.OpaquePeerHandle(873); + final WifiAwareManager.OpaquePeerHandle peerHandle = new WifiAwareManager.OpaquePeerHandle( + 873); final String string1 = "hey from here..."; final String string2 = "some other arbitrary string..."; final int messageId = 2123; - final int reason = WifiNanNative.NAN_STATUS_ERROR; + final int reason = WifiAwareNative.AWARE_STATUS_ERROR; - InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mockNanService, + InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mockAwareService, mockPublishSession); - ArgumentCaptor<WifiNanSession> sessionCaptor = ArgumentCaptor.forClass( - WifiNanSession.class); - ArgumentCaptor<IWifiNanEventCallback> clientProxyCallback = ArgumentCaptor - .forClass(IWifiNanEventCallback.class); - ArgumentCaptor<IWifiNanDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor - .forClass(IWifiNanDiscoverySessionCallback.class); - ArgumentCaptor<WifiNanPublishDiscoverySession> publishSession = ArgumentCaptor - .forClass(WifiNanPublishDiscoverySession.class); + ArgumentCaptor<WifiAwareSession> sessionCaptor = ArgumentCaptor.forClass( + WifiAwareSession.class); + ArgumentCaptor<IWifiAwareEventCallback> clientProxyCallback = ArgumentCaptor + .forClass(IWifiAwareEventCallback.class); + ArgumentCaptor<IWifiAwareDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor + .forClass(IWifiAwareDiscoverySessionCallback.class); + ArgumentCaptor<WifiAwarePublishDiscoverySession> publishSession = ArgumentCaptor + .forClass(WifiAwarePublishDiscoverySession.class); ArgumentCaptor<Object> peerIdCaptor = ArgumentCaptor.forClass(Object.class); // (0) connect + success mDut.attach(mMockLooperHandler, configRequest, mockCallback, null); - inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(), + inOrder.verify(mockAwareService).connect(any(IBinder.class), anyString(), clientProxyCallback.capture(), eq(configRequest), eq(false)); clientProxyCallback.getValue().onConnectSuccess(clientId); mMockLooper.dispatchAll(); inOrder.verify(mockCallback).onAttached(sessionCaptor.capture()); - WifiNanSession session = sessionCaptor.getValue(); + WifiAwareSession session = sessionCaptor.getValue(); // (1) publish session.publish(mMockLooperHandler, publishConfig, mockSessionCallback); - inOrder.verify(mockNanService).publish(eq(clientId), eq(publishConfig), + inOrder.verify(mockAwareService).publish(eq(clientId), eq(publishConfig), sessionProxyCallback.capture()); // (2) publish session created @@ -330,15 +331,15 @@ public class WifiNanManagerTest { sessionProxyCallback.getValue().onMessageSendSuccess(messageId); mMockLooper.dispatchAll(); - inOrder.verify(mockNanService).sendMessage(eq(clientId), eq(sessionId), + inOrder.verify(mockAwareService).sendMessage(eq(clientId), eq(sessionId), eq(peerHandle.peerId), eq(string1.getBytes()), eq(messageId), eq(0)); inOrder.verify(mockSessionCallback).onServiceDiscovered(peerIdCaptor.capture(), eq(string1.getBytes()), eq(string2.getBytes())); - assertEquals(((WifiNanManager.OpaquePeerHandle) peerIdCaptor.getValue()).peerId, + assertEquals(((WifiAwareManager.OpaquePeerHandle) peerIdCaptor.getValue()).peerId, peerHandle.peerId); inOrder.verify(mockSessionCallback).onMessageReceived(peerIdCaptor.capture(), eq(string1.getBytes())); - assertEquals(((WifiNanManager.OpaquePeerHandle) peerIdCaptor.getValue()).peerId, + assertEquals(((WifiAwareManager.OpaquePeerHandle) peerIdCaptor.getValue()).peerId, peerHandle.peerId); inOrder.verify(mockSessionCallback).onMessageSendFailed(eq(messageId)); inOrder.verify(mockSessionCallback).onMessageSent(eq(messageId)); @@ -347,20 +348,20 @@ public class WifiNanManagerTest { publishSession.getValue().updatePublish(publishConfig); sessionProxyCallback.getValue().onSessionConfigFail(reason); mMockLooper.dispatchAll(); - inOrder.verify(mockNanService).updatePublish(eq(clientId), eq(sessionId), + inOrder.verify(mockAwareService).updatePublish(eq(clientId), eq(sessionId), eq(publishConfig)); inOrder.verify(mockSessionCallback).onSessionConfigFailed(); // (5) terminate publishSession.getValue().destroy(); mMockLooper.dispatchAll(); - inOrder.verify(mockNanService).terminateSession(clientId, sessionId); + inOrder.verify(mockAwareService).terminateSession(clientId, sessionId); // (6) try an update (nothing) publishSession.getValue().updatePublish(publishConfig); mMockLooper.dispatchAll(); - verifyNoMoreInteractions(mockCallback, mockSessionCallback, mockNanService, + verifyNoMoreInteractions(mockCallback, mockSessionCallback, mockAwareService, mockPublishSession); } @@ -374,31 +375,31 @@ public class WifiNanManagerTest { final int sessionId = 123; final ConfigRequest configRequest = new ConfigRequest.Builder().build(); final PublishConfig publishConfig = new PublishConfig.Builder().build(); - final int reason = WifiNanDiscoverySessionCallback.TERMINATE_REASON_DONE; + final int reason = WifiAwareDiscoverySessionCallback.TERMINATE_REASON_DONE; - InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mockNanService, + InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mockAwareService, mockPublishSession); - ArgumentCaptor<WifiNanSession> sessionCaptor = ArgumentCaptor.forClass( - WifiNanSession.class); - ArgumentCaptor<IWifiNanEventCallback> clientProxyCallback = ArgumentCaptor - .forClass(IWifiNanEventCallback.class); - ArgumentCaptor<IWifiNanDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor - .forClass(IWifiNanDiscoverySessionCallback.class); - ArgumentCaptor<WifiNanPublishDiscoverySession> publishSession = ArgumentCaptor - .forClass(WifiNanPublishDiscoverySession.class); + ArgumentCaptor<WifiAwareSession> sessionCaptor = ArgumentCaptor.forClass( + WifiAwareSession.class); + ArgumentCaptor<IWifiAwareEventCallback> clientProxyCallback = ArgumentCaptor + .forClass(IWifiAwareEventCallback.class); + ArgumentCaptor<IWifiAwareDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor + .forClass(IWifiAwareDiscoverySessionCallback.class); + ArgumentCaptor<WifiAwarePublishDiscoverySession> publishSession = ArgumentCaptor + .forClass(WifiAwarePublishDiscoverySession.class); // (1) connect successfully mDut.attach(mMockLooperHandler, configRequest, mockCallback, null); - inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(), + inOrder.verify(mockAwareService).connect(any(IBinder.class), anyString(), clientProxyCallback.capture(), eq(configRequest), eq(false)); clientProxyCallback.getValue().onConnectSuccess(clientId); mMockLooper.dispatchAll(); inOrder.verify(mockCallback).onAttached(sessionCaptor.capture()); - WifiNanSession session = sessionCaptor.getValue(); + WifiAwareSession session = sessionCaptor.getValue(); // (2) publish: successfully - then terminated session.publish(mMockLooperHandler, publishConfig, mockSessionCallback); - inOrder.verify(mockNanService).publish(eq(clientId), eq(publishConfig), + inOrder.verify(mockAwareService).publish(eq(clientId), eq(publishConfig), sessionProxyCallback.capture()); sessionProxyCallback.getValue().onSessionStarted(sessionId); sessionProxyCallback.getValue().onSessionTerminated(reason); @@ -409,7 +410,7 @@ public class WifiNanManagerTest { // (3) failure when trying to update: NOP publishSession.getValue().updatePublish(publishConfig); - verifyNoMoreInteractions(mockCallback, mockSessionCallback, mockNanService, + verifyNoMoreInteractions(mockCallback, mockSessionCallback, mockAwareService, mockPublishSession); } @@ -425,36 +426,37 @@ public class WifiNanManagerTest { final int sessionId = 123; final ConfigRequest configRequest = new ConfigRequest.Builder().build(); final SubscribeConfig subscribeConfig = new SubscribeConfig.Builder().build(); - final WifiNanManager.OpaquePeerHandle peerHandle = new WifiNanManager.OpaquePeerHandle(873); + final WifiAwareManager.OpaquePeerHandle peerHandle = new WifiAwareManager.OpaquePeerHandle( + 873); final String string1 = "hey from here..."; final String string2 = "some other arbitrary string..."; final int messageId = 2123; - final int reason = WifiNanNative.NAN_STATUS_ERROR; + final int reason = WifiAwareNative.AWARE_STATUS_ERROR; - InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mockNanService, + InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mockAwareService, mockSubscribeSession); - ArgumentCaptor<WifiNanSession> sessionCaptor = ArgumentCaptor.forClass( - WifiNanSession.class); - ArgumentCaptor<IWifiNanEventCallback> clientProxyCallback = ArgumentCaptor - .forClass(IWifiNanEventCallback.class); - ArgumentCaptor<IWifiNanDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor - .forClass(IWifiNanDiscoverySessionCallback.class); - ArgumentCaptor<WifiNanSubscribeDiscoverySession> subscribeSession = ArgumentCaptor - .forClass(WifiNanSubscribeDiscoverySession.class); + ArgumentCaptor<WifiAwareSession> sessionCaptor = ArgumentCaptor.forClass( + WifiAwareSession.class); + ArgumentCaptor<IWifiAwareEventCallback> clientProxyCallback = ArgumentCaptor + .forClass(IWifiAwareEventCallback.class); + ArgumentCaptor<IWifiAwareDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor + .forClass(IWifiAwareDiscoverySessionCallback.class); + ArgumentCaptor<WifiAwareSubscribeDiscoverySession> subscribeSession = ArgumentCaptor + .forClass(WifiAwareSubscribeDiscoverySession.class); ArgumentCaptor<Object> peerIdCaptor = ArgumentCaptor.forClass(Object.class); // (0) connect + success mDut.attach(mMockLooperHandler, configRequest, mockCallback, null); - inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(), + inOrder.verify(mockAwareService).connect(any(IBinder.class), anyString(), clientProxyCallback.capture(), eq(configRequest), eq(false)); clientProxyCallback.getValue().onConnectSuccess(clientId); mMockLooper.dispatchAll(); inOrder.verify(mockCallback).onAttached(sessionCaptor.capture()); - WifiNanSession session = sessionCaptor.getValue(); + WifiAwareSession session = sessionCaptor.getValue(); // (1) subscribe session.subscribe(mMockLooperHandler, subscribeConfig, mockSessionCallback); - inOrder.verify(mockNanService).subscribe(eq(clientId), eq(subscribeConfig), + inOrder.verify(mockAwareService).subscribe(eq(clientId), eq(subscribeConfig), sessionProxyCallback.capture()); // (2) subscribe session created @@ -471,15 +473,15 @@ public class WifiNanManagerTest { sessionProxyCallback.getValue().onMessageSendSuccess(messageId); mMockLooper.dispatchAll(); - inOrder.verify(mockNanService).sendMessage(eq(clientId), eq(sessionId), + inOrder.verify(mockAwareService).sendMessage(eq(clientId), eq(sessionId), eq(peerHandle.peerId), eq(string1.getBytes()), eq(messageId), eq(0)); inOrder.verify(mockSessionCallback).onServiceDiscovered(peerIdCaptor.capture(), eq(string1.getBytes()), eq(string2.getBytes())); - assertEquals(((WifiNanManager.OpaquePeerHandle) peerIdCaptor.getValue()).peerId, + assertEquals(((WifiAwareManager.OpaquePeerHandle) peerIdCaptor.getValue()).peerId, peerHandle.peerId); inOrder.verify(mockSessionCallback).onMessageReceived(peerIdCaptor.capture(), eq(string1.getBytes())); - assertEquals(((WifiNanManager.OpaquePeerHandle) peerIdCaptor.getValue()).peerId, + assertEquals(((WifiAwareManager.OpaquePeerHandle) peerIdCaptor.getValue()).peerId, peerHandle.peerId); inOrder.verify(mockSessionCallback).onMessageSendFailed(eq(messageId)); inOrder.verify(mockSessionCallback).onMessageSent(eq(messageId)); @@ -488,20 +490,20 @@ public class WifiNanManagerTest { subscribeSession.getValue().updateSubscribe(subscribeConfig); sessionProxyCallback.getValue().onSessionConfigFail(reason); mMockLooper.dispatchAll(); - inOrder.verify(mockNanService).updateSubscribe(eq(clientId), eq(sessionId), + inOrder.verify(mockAwareService).updateSubscribe(eq(clientId), eq(sessionId), eq(subscribeConfig)); inOrder.verify(mockSessionCallback).onSessionConfigFailed(); // (5) terminate subscribeSession.getValue().destroy(); mMockLooper.dispatchAll(); - inOrder.verify(mockNanService).terminateSession(clientId, sessionId); + inOrder.verify(mockAwareService).terminateSession(clientId, sessionId); // (6) try an update (nothing) subscribeSession.getValue().updateSubscribe(subscribeConfig); mMockLooper.dispatchAll(); - verifyNoMoreInteractions(mockCallback, mockSessionCallback, mockNanService, + verifyNoMoreInteractions(mockCallback, mockSessionCallback, mockAwareService, mockSubscribeSession); } @@ -515,31 +517,31 @@ public class WifiNanManagerTest { final int sessionId = 123; final ConfigRequest configRequest = new ConfigRequest.Builder().build(); final SubscribeConfig subscribeConfig = new SubscribeConfig.Builder().build(); - final int reason = WifiNanDiscoverySessionCallback.TERMINATE_REASON_DONE; + final int reason = WifiAwareDiscoverySessionCallback.TERMINATE_REASON_DONE; - InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mockNanService, + InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mockAwareService, mockSubscribeSession); - ArgumentCaptor<WifiNanSession> sessionCaptor = ArgumentCaptor.forClass( - WifiNanSession.class); - ArgumentCaptor<IWifiNanEventCallback> clientProxyCallback = ArgumentCaptor - .forClass(IWifiNanEventCallback.class); - ArgumentCaptor<IWifiNanDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor - .forClass(IWifiNanDiscoverySessionCallback.class); - ArgumentCaptor<WifiNanSubscribeDiscoverySession> subscribeSession = ArgumentCaptor - .forClass(WifiNanSubscribeDiscoverySession.class); + ArgumentCaptor<WifiAwareSession> sessionCaptor = ArgumentCaptor.forClass( + WifiAwareSession.class); + ArgumentCaptor<IWifiAwareEventCallback> clientProxyCallback = ArgumentCaptor + .forClass(IWifiAwareEventCallback.class); + ArgumentCaptor<IWifiAwareDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor + .forClass(IWifiAwareDiscoverySessionCallback.class); + ArgumentCaptor<WifiAwareSubscribeDiscoverySession> subscribeSession = ArgumentCaptor + .forClass(WifiAwareSubscribeDiscoverySession.class); // (1) connect successfully mDut.attach(mMockLooperHandler, configRequest, mockCallback, null); - inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(), + inOrder.verify(mockAwareService).connect(any(IBinder.class), anyString(), clientProxyCallback.capture(), eq(configRequest), eq(false)); clientProxyCallback.getValue().onConnectSuccess(clientId); mMockLooper.dispatchAll(); inOrder.verify(mockCallback).onAttached(sessionCaptor.capture()); - WifiNanSession session = sessionCaptor.getValue(); + WifiAwareSession session = sessionCaptor.getValue(); // (2) subscribe: successfully - then terminated session.subscribe(mMockLooperHandler, subscribeConfig, mockSessionCallback); - inOrder.verify(mockNanService).subscribe(eq(clientId), eq(subscribeConfig), + inOrder.verify(mockAwareService).subscribe(eq(clientId), eq(subscribeConfig), sessionProxyCallback.capture()); sessionProxyCallback.getValue().onSessionStarted(sessionId); sessionProxyCallback.getValue().onSessionTerminated(reason); @@ -550,7 +552,7 @@ public class WifiNanManagerTest { // (3) failure when trying to update: NOP subscribeSession.getValue().updateSubscribe(subscribeConfig); - verifyNoMoreInteractions(mockCallback, mockSessionCallback, mockNanService, + verifyNoMoreInteractions(mockCallback, mockSessionCallback, mockAwareService, mockSubscribeSession); } @@ -880,19 +882,19 @@ public class WifiNanManagerTest { final RttManager.RttResult rttResults = new RttManager.RttResult(); rttResults.distance = 10; - when(mockNanService.startRanging(anyInt(), anyInt(), + when(mockAwareService.startRanging(anyInt(), anyInt(), any(RttManager.ParcelableRttParams.class))).thenReturn(rangingId); - InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mockNanService, + InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mockAwareService, mockPublishSession, mockRttListener); - ArgumentCaptor<WifiNanSession> sessionCaptor = ArgumentCaptor.forClass( - WifiNanSession.class); - ArgumentCaptor<IWifiNanEventCallback> clientProxyCallback = ArgumentCaptor - .forClass(IWifiNanEventCallback.class); - ArgumentCaptor<IWifiNanDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor - .forClass(IWifiNanDiscoverySessionCallback.class); - ArgumentCaptor<WifiNanPublishDiscoverySession> publishSession = ArgumentCaptor - .forClass(WifiNanPublishDiscoverySession.class); + ArgumentCaptor<WifiAwareSession> sessionCaptor = ArgumentCaptor.forClass( + WifiAwareSession.class); + ArgumentCaptor<IWifiAwareEventCallback> clientProxyCallback = ArgumentCaptor + .forClass(IWifiAwareEventCallback.class); + ArgumentCaptor<IWifiAwareDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor + .forClass(IWifiAwareDiscoverySessionCallback.class); + ArgumentCaptor<WifiAwarePublishDiscoverySession> publishSession = ArgumentCaptor + .forClass(WifiAwarePublishDiscoverySession.class); ArgumentCaptor<RttManager.ParcelableRttParams> rttParamCaptor = ArgumentCaptor .forClass(RttManager.ParcelableRttParams.class); ArgumentCaptor<RttManager.RttResult[]> rttResultsCaptor = ArgumentCaptor @@ -900,16 +902,16 @@ public class WifiNanManagerTest { // (1) connect successfully mDut.attach(mMockLooperHandler, configRequest, mockCallback, null); - inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(), + inOrder.verify(mockAwareService).connect(any(IBinder.class), anyString(), clientProxyCallback.capture(), eq(configRequest), eq(false)); clientProxyCallback.getValue().onConnectSuccess(clientId); mMockLooper.dispatchAll(); inOrder.verify(mockCallback).onAttached(sessionCaptor.capture()); - WifiNanSession session = sessionCaptor.getValue(); + WifiAwareSession session = sessionCaptor.getValue(); // (2) publish successfully session.publish(mMockLooperHandler, publishConfig, mockSessionCallback); - inOrder.verify(mockNanService).publish(eq(clientId), eq(publishConfig), + inOrder.verify(mockAwareService).publish(eq(clientId), eq(publishConfig), sessionProxyCallback.capture()); sessionProxyCallback.getValue().onSessionStarted(sessionId); mMockLooper.dispatchAll(); @@ -918,7 +920,7 @@ public class WifiNanManagerTest { // (3) start ranging publishSession.getValue().startRanging(new RttManager.RttParams[]{rttParams}, mockRttListener); - inOrder.verify(mockNanService).startRanging(eq(clientId), eq(sessionId), + inOrder.verify(mockAwareService).startRanging(eq(clientId), eq(sessionId), rttParamCaptor.capture()); collector.checkThat("RttParams.deviceType", rttParams.deviceType, equalTo(rttParamCaptor.getValue().mParams[0].deviceType)); @@ -937,7 +939,7 @@ public class WifiNanManagerTest { clientProxyCallback.getValue().onRangingAborted(rangingId); mMockLooper.dispatchAll(); - verifyNoMoreInteractions(mockCallback, mockSessionCallback, mockNanService, + verifyNoMoreInteractions(mockCallback, mockSessionCallback, mockAwareService, mockPublishSession, mockRttListener); } @@ -952,39 +954,39 @@ public class WifiNanManagerTest { public void testNetworkSpecifierWithClient() throws Exception { final int clientId = 4565; final int sessionId = 123; - final WifiNanManager.OpaquePeerHandle peerHandle = new WifiNanManager.OpaquePeerHandle( + final WifiAwareManager.OpaquePeerHandle peerHandle = new WifiAwareManager.OpaquePeerHandle( 123412); - final int role = WifiNanManager.WIFI_NAN_DATA_PATH_ROLE_INITIATOR; + final int role = WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_INITIATOR; final String token = "Some arbitrary token string - can really be anything"; final ConfigRequest configRequest = new ConfigRequest.Builder().build(); final PublishConfig publishConfig = new PublishConfig.Builder().build(); String tokenB64 = Base64.encodeToString(token.getBytes(), Base64.DEFAULT); - ArgumentCaptor<WifiNanSession> sessionCaptor = ArgumentCaptor.forClass( - WifiNanSession.class); - ArgumentCaptor<IWifiNanEventCallback> clientProxyCallback = ArgumentCaptor - .forClass(IWifiNanEventCallback.class); - ArgumentCaptor<IWifiNanDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor - .forClass(IWifiNanDiscoverySessionCallback.class); - ArgumentCaptor<WifiNanPublishDiscoverySession> publishSession = ArgumentCaptor - .forClass(WifiNanPublishDiscoverySession.class); + ArgumentCaptor<WifiAwareSession> sessionCaptor = ArgumentCaptor.forClass( + WifiAwareSession.class); + ArgumentCaptor<IWifiAwareEventCallback> clientProxyCallback = ArgumentCaptor + .forClass(IWifiAwareEventCallback.class); + ArgumentCaptor<IWifiAwareDiscoverySessionCallback> sessionProxyCallback = ArgumentCaptor + .forClass(IWifiAwareDiscoverySessionCallback.class); + ArgumentCaptor<WifiAwarePublishDiscoverySession> publishSession = ArgumentCaptor + .forClass(WifiAwarePublishDiscoverySession.class); - InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mockNanService, + InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mockAwareService, mockPublishSession, mockRttListener); // (1) connect successfully mDut.attach(mMockLooperHandler, configRequest, mockCallback, null); - inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(), + inOrder.verify(mockAwareService).connect(any(IBinder.class), anyString(), clientProxyCallback.capture(), eq(configRequest), eq(false)); clientProxyCallback.getValue().onConnectSuccess(clientId); mMockLooper.dispatchAll(); inOrder.verify(mockCallback).onAttached(sessionCaptor.capture()); - WifiNanSession session = sessionCaptor.getValue(); + WifiAwareSession session = sessionCaptor.getValue(); // (2) publish successfully session.publish(mMockLooperHandler, publishConfig, mockSessionCallback); - inOrder.verify(mockNanService).publish(eq(clientId), eq(publishConfig), + inOrder.verify(mockAwareService).publish(eq(clientId), eq(publishConfig), sessionProxyCallback.capture()); sessionProxyCallback.getValue().onSessionStarted(sessionId); mMockLooper.dispatchAll(); @@ -997,17 +999,17 @@ public class WifiNanManagerTest { // validate format JSONObject jsonObject = new JSONObject(networkSpecifier); collector.checkThat("role", role, - equalTo(jsonObject.getInt(WifiNanManager.NETWORK_SPECIFIER_KEY_ROLE))); + equalTo(jsonObject.getInt(WifiAwareManager.NETWORK_SPECIFIER_KEY_ROLE))); collector.checkThat("client_id", clientId, - equalTo(jsonObject.getInt(WifiNanManager.NETWORK_SPECIFIER_KEY_CLIENT_ID))); + equalTo(jsonObject.getInt(WifiAwareManager.NETWORK_SPECIFIER_KEY_CLIENT_ID))); collector.checkThat("session_id", sessionId, - equalTo(jsonObject.getInt(WifiNanManager.NETWORK_SPECIFIER_KEY_SESSION_ID))); + equalTo(jsonObject.getInt(WifiAwareManager.NETWORK_SPECIFIER_KEY_SESSION_ID))); collector.checkThat("peer_id", peerHandle.peerId, - equalTo(jsonObject.getInt(WifiNanManager.NETWORK_SPECIFIER_KEY_PEER_ID))); + equalTo(jsonObject.getInt(WifiAwareManager.NETWORK_SPECIFIER_KEY_PEER_ID))); collector.checkThat("token", tokenB64, - equalTo(jsonObject.getString(WifiNanManager.NETWORK_SPECIFIER_KEY_TOKEN))); + equalTo(jsonObject.getString(WifiAwareManager.NETWORK_SPECIFIER_KEY_TOKEN))); - verifyNoMoreInteractions(mockCallback, mockSessionCallback, mockNanService, + verifyNoMoreInteractions(mockCallback, mockSessionCallback, mockAwareService, mockPublishSession, mockRttListener); } @@ -1020,27 +1022,27 @@ public class WifiNanManagerTest { final int clientId = 134; final ConfigRequest configRequest = new ConfigRequest.Builder().build(); final byte[] someMac = HexEncoding.decode("000102030405".toCharArray(), false); - final int role = WifiNanManager.WIFI_NAN_DATA_PATH_ROLE_INITIATOR; + final int role = WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_INITIATOR; final String token = "Some arbitrary token string - can really be anything"; String tokenB64 = Base64.encodeToString(token.getBytes(), Base64.DEFAULT); - ArgumentCaptor<WifiNanSession> sessionCaptor = ArgumentCaptor.forClass( - WifiNanSession.class); - ArgumentCaptor<IWifiNanEventCallback> clientProxyCallback = ArgumentCaptor - .forClass(IWifiNanEventCallback.class); + ArgumentCaptor<WifiAwareSession> sessionCaptor = ArgumentCaptor.forClass( + WifiAwareSession.class); + ArgumentCaptor<IWifiAwareEventCallback> clientProxyCallback = ArgumentCaptor + .forClass(IWifiAwareEventCallback.class); - InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mockNanService, + InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mockAwareService, mockPublishSession, mockRttListener); // (1) connect successfully mDut.attach(mMockLooperHandler, configRequest, mockCallback, null); - inOrder.verify(mockNanService).connect(any(IBinder.class), anyString(), + inOrder.verify(mockAwareService).connect(any(IBinder.class), anyString(), clientProxyCallback.capture(), eq(configRequest), eq(false)); clientProxyCallback.getValue().onConnectSuccess(clientId); mMockLooper.dispatchAll(); inOrder.verify(mockCallback).onAttached(sessionCaptor.capture()); - WifiNanSession session = sessionCaptor.getValue(); + WifiAwareSession session = sessionCaptor.getValue(); /* (2) request a direct network specifier*/ String networkSpecifier = session.createNetworkSpecifier(role, someMac, token.getBytes()); @@ -1048,16 +1050,16 @@ public class WifiNanManagerTest { /* validate format*/ JSONObject jsonObject = new JSONObject(networkSpecifier); collector.checkThat("role", role, - equalTo(jsonObject.getInt(WifiNanManager.NETWORK_SPECIFIER_KEY_ROLE))); + equalTo(jsonObject.getInt(WifiAwareManager.NETWORK_SPECIFIER_KEY_ROLE))); collector.checkThat("client_id", clientId, - equalTo(jsonObject.getInt(WifiNanManager.NETWORK_SPECIFIER_KEY_CLIENT_ID))); + equalTo(jsonObject.getInt(WifiAwareManager.NETWORK_SPECIFIER_KEY_CLIENT_ID))); collector.checkThat("peer_mac", someMac, equalTo(HexEncoding.decode( - jsonObject.getString(WifiNanManager.NETWORK_SPECIFIER_KEY_PEER_MAC).toCharArray(), + jsonObject.getString(WifiAwareManager.NETWORK_SPECIFIER_KEY_PEER_MAC).toCharArray(), false))); collector.checkThat("token", tokenB64, - equalTo(jsonObject.getString(WifiNanManager.NETWORK_SPECIFIER_KEY_TOKEN))); + equalTo(jsonObject.getString(WifiAwareManager.NETWORK_SPECIFIER_KEY_TOKEN))); - verifyNoMoreInteractions(mockCallback, mockSessionCallback, mockNanService, + verifyNoMoreInteractions(mockCallback, mockSessionCallback, mockAwareService, mockPublishSession, mockRttListener); } } diff --git a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanRttStateManagerTest.java b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareRttStateManagerTest.java index 35a600add..a4b75c296 100644 --- a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanRttStateManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareRttStateManagerTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.server.wifi.nan; +package com.android.server.wifi.aware; import static org.hamcrest.core.IsEqual.equalTo; import static org.hamcrest.core.IsNull.nullValue; @@ -44,11 +44,11 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; /** - * Unit test harness for WifiNanManager class. + * Unit test harness for WifiAwareManager class. */ @SmallTest -public class WifiNanRttStateManagerTest { - private WifiNanRttStateManager mDut; +public class WifiAwareRttStateManagerTest { + private WifiAwareRttStateManager mDut; private TestLooper mTestLooper; @Mock @@ -70,7 +70,7 @@ public class WifiNanRttStateManagerTest { public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - mDut = new WifiNanRttStateManager(); + mDut = new WifiAwareRttStateManager(); mTestLooper = new TestLooper(); BidirectionalAsyncChannelServer server = new BidirectionalAsyncChannelServer( mMockContext, mTestLooper.getLooper(), mMockHandler); @@ -87,7 +87,7 @@ public class WifiNanRttStateManagerTest { @Test public void testStartRanging() throws Exception { final int rangingId = 1234; - WifiNanClientState mockClient = mock(WifiNanClientState.class); + WifiAwareClientState mockClient = mock(WifiAwareClientState.class); RttManager.RttParams[] params = new RttManager.RttParams[1]; params[0] = new RttManager.RttParams(); RttManager.ParcelableRttResults results = diff --git a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareServiceImplTest.java index 86d388b25..d54c111f0 100644 --- a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanServiceImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareServiceImplTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.server.wifi.nan; +package com.android.server.wifi.aware; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; @@ -31,12 +31,12 @@ import static org.mockito.Mockito.when; import android.content.Context; import android.content.pm.PackageManager; import android.net.wifi.RttManager; -import android.net.wifi.nan.ConfigRequest; -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.WifiNanCharacteristics; +import android.net.wifi.aware.ConfigRequest; +import android.net.wifi.aware.IWifiAwareDiscoverySessionCallback; +import android.net.wifi.aware.IWifiAwareEventCallback; +import android.net.wifi.aware.PublishConfig; +import android.net.wifi.aware.SubscribeConfig; +import android.net.wifi.aware.WifiAwareCharacteristics; import android.os.IBinder; import android.os.Looper; import android.test.suitebuilder.annotation.SmallTest; @@ -53,13 +53,13 @@ import org.mockito.MockitoAnnotations; import java.lang.reflect.Field; /** - * Unit test harness for WifiNanStateManager. + * Unit test harness for WifiAwareStateManager. */ @SmallTest -public class WifiNanServiceImplTest { +public class WifiAwareServiceImplTest { private static final int MAX_LENGTH = 255; - private WifiNanServiceImplSpy mDut; + private WifiAwareServiceImplSpy mDut; private int mDefaultUid = 1500; @Mock @@ -67,22 +67,22 @@ public class WifiNanServiceImplTest { @Mock private PackageManager mPackageManagerMock; @Mock - private WifiNanStateManager mNanStateManagerMock; + private WifiAwareStateManager mAwareStateManagerMock; @Mock private IBinder mBinderMock; @Mock - private IWifiNanEventCallback mCallbackMock; + private IWifiAwareEventCallback mCallbackMock; @Mock - private IWifiNanDiscoverySessionCallback mSessionCallbackMock; + private IWifiAwareDiscoverySessionCallback mSessionCallbackMock; /** * Using instead of spy to avoid native crash failures - possibly due to * spy's copying of state. */ - private class WifiNanServiceImplSpy extends WifiNanServiceImpl { + private class WifiAwareServiceImplSpy extends WifiAwareServiceImpl { public int fakeUid; - WifiNanServiceImplSpy(Context context) { + WifiAwareServiceImplSpy(Context context) { super(context); } @@ -105,13 +105,13 @@ public class WifiNanServiceImplTest { when(mContextMock.getApplicationContext()).thenReturn(mContextMock); when(mContextMock.getPackageManager()).thenReturn(mPackageManagerMock); - when(mPackageManagerMock.hasSystemFeature(PackageManager.FEATURE_WIFI_NAN)) + when(mPackageManagerMock.hasSystemFeature(PackageManager.FEATURE_WIFI_AWARE)) .thenReturn(true); - when(mNanStateManagerMock.getCharacteristics()).thenReturn(getCharacteristics()); + when(mAwareStateManagerMock.getCharacteristics()).thenReturn(getCharacteristics()); - installMockNanStateManager(); + installMockAwareStateManager(); - mDut = new WifiNanServiceImplSpy(mContextMock); + mDut = new WifiAwareServiceImplSpy(mContextMock); mDut.fakeUid = mDefaultUid; } @@ -122,7 +122,7 @@ public class WifiNanServiceImplTest { public void testStart() { mDut.start(); - verify(mNanStateManagerMock).start(eq(mContextMock), any(Looper.class)); + verify(mAwareStateManagerMock).start(eq(mContextMock), any(Looper.class)); } /** @@ -132,7 +132,7 @@ public class WifiNanServiceImplTest { public void testEnableUsage() { mDut.enableUsage(); - verify(mNanStateManagerMock).enableUsage(); + verify(mAwareStateManagerMock).enableUsage(); } /** @@ -144,7 +144,7 @@ public class WifiNanServiceImplTest { doConnect(); mDut.disableUsage(); - verify(mNanStateManagerMock).disableUsage(); + verify(mAwareStateManagerMock).disableUsage(); } /** @@ -154,7 +154,7 @@ public class WifiNanServiceImplTest { public void testIsUsageEnabled() { mDut.isUsageEnabled(); - verify(mNanStateManagerMock).isUsageEnabled(); + verify(mAwareStateManagerMock).isUsageEnabled(); } @@ -177,7 +177,7 @@ public class WifiNanServiceImplTest { mDut.connect(mBinderMock, callingPackage, mCallbackMock, configRequest, false); - verify(mNanStateManagerMock).connect(anyInt(), anyInt(), anyInt(), + verify(mAwareStateManagerMock).connect(anyInt(), anyInt(), anyInt(), eq(callingPackage), eq(mCallbackMock), eq(configRequest), eq(false)); } @@ -192,7 +192,7 @@ public class WifiNanServiceImplTest { mDut.disconnect(clientId, mBinderMock); - verify(mNanStateManagerMock).disconnect(clientId); + verify(mAwareStateManagerMock).disconnect(clientId); validateInternalStateCleanedUp(clientId); } @@ -215,7 +215,7 @@ public class WifiNanServiceImplTest { mDut.disconnect(clientId, mBinderMock); - verify(mNanStateManagerMock).disconnect(clientId); + verify(mAwareStateManagerMock).disconnect(clientId); validateInternalStateCleanedUp(clientId); mDut.disconnect(clientId, mBinderMock); @@ -250,7 +250,7 @@ public class WifiNanServiceImplTest { .build(); mDut.publish(clientId, publishConfig, mSessionCallbackMock); - verify(mNanStateManagerMock).publish(clientId, publishConfig, mSessionCallbackMock); + verify(mAwareStateManagerMock).publish(clientId, publishConfig, mSessionCallbackMock); assertTrue("SecurityException for invalid access from wrong UID thrown", failsAsExpected); } @@ -266,7 +266,7 @@ public class WifiNanServiceImplTest { verify(mBinderMock).linkToDeath(deathRecipient.capture(), eq(0)); deathRecipient.getValue().binderDied(); - verify(mNanStateManagerMock).disconnect(clientId); + verify(mAwareStateManagerMock).disconnect(clientId); validateInternalStateCleanedUp(clientId); } @@ -277,13 +277,13 @@ public class WifiNanServiceImplTest { public void testClientIdIncrementing() { int loopCount = 100; - InOrder inOrder = inOrder(mNanStateManagerMock); + InOrder inOrder = inOrder(mAwareStateManagerMock); ArgumentCaptor<Integer> clientIdCaptor = ArgumentCaptor.forClass(Integer.class); int prevId = 0; for (int i = 0; i < loopCount; ++i) { mDut.connect(mBinderMock, "", mCallbackMock, null, false); - inOrder.verify(mNanStateManagerMock).connect(clientIdCaptor.capture(), anyInt(), + inOrder.verify(mAwareStateManagerMock).connect(clientIdCaptor.capture(), anyInt(), anyInt(), anyString(), eq(mCallbackMock), any(ConfigRequest.class), eq(false)); int id = clientIdCaptor.getValue(); if (i != 0) { @@ -303,7 +303,7 @@ public class WifiNanServiceImplTest { mDut.terminateSession(clientId, sessionId); - verify(mNanStateManagerMock).terminateSession(clientId, sessionId); + verify(mAwareStateManagerMock).terminateSession(clientId, sessionId); } /** @@ -314,12 +314,12 @@ public class WifiNanServiceImplTest { PublishConfig publishConfig = new PublishConfig.Builder().setServiceName("something.valid") .build(); int clientId = doConnect(); - IWifiNanDiscoverySessionCallback mockCallback = mock( - IWifiNanDiscoverySessionCallback.class); + IWifiAwareDiscoverySessionCallback mockCallback = mock( + IWifiAwareDiscoverySessionCallback.class); mDut.publish(clientId, publishConfig, mockCallback); - verify(mNanStateManagerMock).publish(clientId, publishConfig, mockCallback); + verify(mAwareStateManagerMock).publish(clientId, publishConfig, mockCallback); } /** @@ -373,7 +373,7 @@ public class WifiNanServiceImplTest { mDut.updatePublish(clientId, sessionId, publishConfig); - verify(mNanStateManagerMock).updatePublish(clientId, sessionId, publishConfig); + verify(mAwareStateManagerMock).updatePublish(clientId, sessionId, publishConfig); } /** @@ -388,7 +388,7 @@ public class WifiNanServiceImplTest { mDut.updatePublish(clientId, sessionId, publishConfig); - verify(mNanStateManagerMock).updatePublish(clientId, sessionId, publishConfig); + verify(mAwareStateManagerMock).updatePublish(clientId, sessionId, publishConfig); } /** @@ -399,12 +399,12 @@ public class WifiNanServiceImplTest { SubscribeConfig subscribeConfig = new SubscribeConfig.Builder() .setServiceName("something.valid").build(); int clientId = doConnect(); - IWifiNanDiscoverySessionCallback mockCallback = mock( - IWifiNanDiscoverySessionCallback.class); + IWifiAwareDiscoverySessionCallback mockCallback = mock( + IWifiAwareDiscoverySessionCallback.class); mDut.subscribe(clientId, subscribeConfig, mockCallback); - verify(mNanStateManagerMock).subscribe(clientId, subscribeConfig, mockCallback); + verify(mAwareStateManagerMock).subscribe(clientId, subscribeConfig, mockCallback); } /** @@ -459,7 +459,7 @@ public class WifiNanServiceImplTest { mDut.updateSubscribe(clientId, sessionId, subscribeConfig); - verify(mNanStateManagerMock).updateSubscribe(clientId, sessionId, subscribeConfig); + verify(mAwareStateManagerMock).updateSubscribe(clientId, sessionId, subscribeConfig); } /** @@ -474,7 +474,7 @@ public class WifiNanServiceImplTest { mDut.updateSubscribe(clientId, sessionId, subscribeConfig); - verify(mNanStateManagerMock).updateSubscribe(clientId, sessionId, subscribeConfig); + verify(mAwareStateManagerMock).updateSubscribe(clientId, sessionId, subscribeConfig); } /** @@ -490,7 +490,7 @@ public class WifiNanServiceImplTest { mDut.sendMessage(clientId, sessionId, peerId, message, messageId, 0); - verify(mNanStateManagerMock).sendMessage(clientId, sessionId, peerId, message, messageId, + verify(mAwareStateManagerMock).sendMessage(clientId, sessionId, peerId, message, messageId, 0); } @@ -507,7 +507,7 @@ public class WifiNanServiceImplTest { mDut.sendMessage(clientId, sessionId, peerId, message, messageId, 0); - verify(mNanStateManagerMock).sendMessage(clientId, sessionId, peerId, message, messageId, + verify(mAwareStateManagerMock).sendMessage(clientId, sessionId, peerId, message, messageId, 0); } @@ -526,7 +526,7 @@ public class WifiNanServiceImplTest { int rangingId = mDut.startRanging(clientId, sessionId, params); - verify(mNanStateManagerMock).startRanging(eq(clientId), eq(sessionId), + verify(mAwareStateManagerMock).startRanging(eq(clientId), eq(sessionId), paramsCaptor.capture(), eq(rangingId)); assertArrayEquals(paramsCaptor.getValue(), params.mParams); @@ -570,7 +570,7 @@ public class WifiNanServiceImplTest { } /* - * Tests of internal state of WifiNanServiceImpl: very limited (not usually + * Tests of internal state of WifiAwareServiceImpl: very limited (not usually * a good idea). However, these test that the internal state is cleaned-up * appropriately. Alternatively would cause issues with memory leaks or * information leak between sessions. @@ -593,12 +593,12 @@ public class WifiNanServiceImplTest { PublishConfig publishConfig = new PublishConfig.Builder().setServiceName(serviceName) .setServiceSpecificInfo(ssi).setMatchFilter(matchFilter).build(); int clientId = doConnect(); - IWifiNanDiscoverySessionCallback mockCallback = mock( - IWifiNanDiscoverySessionCallback.class); + IWifiAwareDiscoverySessionCallback mockCallback = mock( + IWifiAwareDiscoverySessionCallback.class); mDut.publish(clientId, publishConfig, mockCallback); - verify(mNanStateManagerMock).publish(clientId, publishConfig, mockCallback); + verify(mAwareStateManagerMock).publish(clientId, publishConfig, mockCallback); } private void doBadSubscribeConfiguration(String serviceName, byte[] ssi, byte[] matchFilter) @@ -606,12 +606,12 @@ public class WifiNanServiceImplTest { SubscribeConfig subscribeConfig = new SubscribeConfig.Builder().setServiceName(serviceName) .setServiceSpecificInfo(ssi).setMatchFilter(matchFilter).build(); int clientId = doConnect(); - IWifiNanDiscoverySessionCallback mockCallback = mock( - IWifiNanDiscoverySessionCallback.class); + IWifiAwareDiscoverySessionCallback mockCallback = mock( + IWifiAwareDiscoverySessionCallback.class); mDut.subscribe(clientId, subscribeConfig, mockCallback); - verify(mNanStateManagerMock).subscribe(clientId, subscribeConfig, mockCallback); + verify(mAwareStateManagerMock).subscribe(clientId, subscribeConfig, mockCallback); } private int doConnect() { @@ -620,23 +620,23 @@ public class WifiNanServiceImplTest { mDut.connect(mBinderMock, callingPackage, mCallbackMock, null, false); ArgumentCaptor<Integer> clientId = ArgumentCaptor.forClass(Integer.class); - verify(mNanStateManagerMock).connect(clientId.capture(), anyInt(), anyInt(), + verify(mAwareStateManagerMock).connect(clientId.capture(), anyInt(), anyInt(), eq(callingPackage), eq(mCallbackMock), eq(new ConfigRequest.Builder().build()), eq(false)); return clientId.getValue(); } - private void installMockNanStateManager() + private void installMockAwareStateManager() throws Exception { - Field field = WifiNanStateManager.class.getDeclaredField("sNanStateManagerSingleton"); + Field field = WifiAwareStateManager.class.getDeclaredField("sAwareStateManagerSingleton"); field.setAccessible(true); - field.set(null, mNanStateManagerMock); + field.set(null, mAwareStateManagerMock); } - private static WifiNanCharacteristics getCharacteristics() { - WifiNanNative.Capabilities cap = new WifiNanNative.Capabilities(); - cap.maxConcurrentNanClusters = 1; + private static WifiAwareCharacteristics getCharacteristics() { + WifiAwareNative.Capabilities cap = new WifiAwareNative.Capabilities(); + cap.maxConcurrentAwareClusters = 1; cap.maxPublishes = 2; cap.maxSubscribes = 2; cap.maxServiceNameLen = MAX_LENGTH; @@ -653,7 +653,7 @@ public class WifiNanServiceImplTest { } private int getInternalStateUid(int clientId) throws Exception { - Field field = WifiNanServiceImpl.class.getDeclaredField("mUidByClientId"); + Field field = WifiAwareServiceImpl.class.getDeclaredField("mUidByClientId"); field.setAccessible(true); @SuppressWarnings("unchecked") SparseIntArray uidByClientId = (SparseIntArray) field.get(mDut); @@ -662,7 +662,7 @@ public class WifiNanServiceImplTest { } private IBinder.DeathRecipient getInternalStateDeathRecipient(int clientId) throws Exception { - Field field = WifiNanServiceImpl.class.getDeclaredField("mDeathRecipientsByClientId"); + Field field = WifiAwareServiceImpl.class.getDeclaredField("mDeathRecipientsByClientId"); field.setAccessible(true); @SuppressWarnings("unchecked") SparseArray<IBinder.DeathRecipient> deathRecipientsByClientId = diff --git a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanStateManagerTest.java b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareStateManagerTest.java index b9fc83b18..42492039f 100644 --- a/tests/wifitests/src/com/android/server/wifi/nan/WifiNanStateManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareStateManagerTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.server.wifi.nan; +package com.android.server.wifi.aware; import static org.hamcrest.core.IsEqual.equalTo; import static org.hamcrest.core.IsNull.notNullValue; @@ -43,13 +43,13 @@ import android.content.Intent; import android.content.pm.PackageManager; import android.net.ConnectivityManager; import android.net.wifi.RttManager; -import android.net.wifi.nan.ConfigRequest; -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.WifiNanDiscoverySessionCallback; -import android.net.wifi.nan.WifiNanManager; +import android.net.wifi.aware.ConfigRequest; +import android.net.wifi.aware.IWifiAwareDiscoverySessionCallback; +import android.net.wifi.aware.IWifiAwareEventCallback; +import android.net.wifi.aware.PublishConfig; +import android.net.wifi.aware.SubscribeConfig; +import android.net.wifi.aware.WifiAwareDiscoverySessionCallback; +import android.net.wifi.aware.WifiAwareManager; import android.os.Message; import android.os.UserHandle; import android.os.test.TestLooper; @@ -76,19 +76,19 @@ import java.util.Map; import java.util.Random; /** - * Unit test harness for WifiNanStateManager. + * Unit test harness for WifiAwareStateManager. */ @SmallTest -public class WifiNanStateManagerTest { +public class WifiAwareStateManagerTest { private TestLooper mMockLooper; private Random mRandomNg = new Random(15687); - private WifiNanStateManager mDut; - @Mock private WifiNanNative mMockNative; + private WifiAwareStateManager mDut; + @Mock private WifiAwareNative mMockNative; @Mock private Context mMockContext; @Mock private AppOpsManager mMockAppOpsManager; - @Mock private WifiNanRttStateManager mMockNanRttStateManager; + @Mock private WifiAwareRttStateManager mMockAwareRttStateManager; TestAlarmManager mAlarmManager; - @Mock private WifiNanDataPathStateManager mMockNanDataPathStatemanager; + @Mock private WifiAwareDataPathStateManager mMockAwareDataPathStatemanager; @Rule public ErrorCollector collector = new ErrorCollector(); @@ -120,9 +120,9 @@ public class WifiNanStateManagerTest { mMockLooper = new TestLooper(); - mDut = installNewNanStateManager(); + mDut = installNewAwareStateManager(); mDut.start(mMockContext, mMockLooper.getLooper()); - installMocksInStateManager(mDut, mMockNanRttStateManager, mMockNanDataPathStatemanager); + installMocksInStateManager(mDut, mMockAwareRttStateManager, mMockAwareDataPathStatemanager); when(mMockNative.enableAndConfigure(anyShort(), any(ConfigRequest.class), anyBoolean())) .thenReturn(true); @@ -136,39 +136,39 @@ public class WifiNanStateManagerTest { when(mMockNative.stopSubscribe(anyShort(), anyInt())).thenReturn(true); when(mMockNative.getCapabilities(anyShort())).thenReturn(true); - installMockWifiNanNative(mMockNative); + installMockWifiAwareNative(mMockNative); } /** - * Validate that NAN data-path interfaces are brought up and down correctly. + * Validate that Aware data-path interfaces are brought up and down correctly. */ @Test - public void testNanDataPathInterfaceUpDown() throws Exception { + public void testAwareDataPathInterfaceUpDown() throws Exception { ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); - InOrder inOrder = inOrder(mMockContext, mMockNative, mMockNanDataPathStatemanager); + InOrder inOrder = inOrder(mMockContext, mMockNative, mMockAwareDataPathStatemanager); // (1) enable usage mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); - validateCorrectNanStatusChangeBroadcast(inOrder, true); + inOrder.verify(mMockNative).deInitAware(); + validateCorrectAwareStatusChangeBroadcast(inOrder, true); inOrder.verify(mMockNative).getCapabilities(transactionId.capture()); mDut.onCapabilitiesUpdateResponse(transactionId.getValue(), getCapabilities()); mMockLooper.dispatchAll(); - inOrder.verify(mMockNanDataPathStatemanager).createAllInterfaces(); + inOrder.verify(mMockAwareDataPathStatemanager).createAllInterfaces(); collector.checkThat("usage enabled", mDut.isUsageEnabled(), equalTo(true)); // (2) disable usage mDut.disableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNanDataPathStatemanager).onNanDownCleanupDataPaths(); + inOrder.verify(mMockAwareDataPathStatemanager).onAwareDownCleanupDataPaths(); inOrder.verify(mMockNative).disable((short) 0); - inOrder.verify(mMockNative).deInitNan(); - validateCorrectNanStatusChangeBroadcast(inOrder, false); - inOrder.verify(mMockNanDataPathStatemanager).deleteAllInterfaces(); + inOrder.verify(mMockNative).deInitAware(); + validateCorrectAwareStatusChangeBroadcast(inOrder, false); + inOrder.verify(mMockAwareDataPathStatemanager).deleteAllInterfaces(); collector.checkThat("usage disabled", mDut.isUsageEnabled(), equalTo(false)); - verifyNoMoreInteractions(mMockNative, mMockNanDataPathStatemanager); + verifyNoMoreInteractions(mMockNative, mMockAwareDataPathStatemanager); } /** @@ -182,7 +182,7 @@ public class WifiNanStateManagerTest { final String callingPackage = "com.google.somePackage"; final ConfigRequest configRequest = new ConfigRequest.Builder().build(); - IWifiNanEventCallback mockCallback = mock(IWifiNanEventCallback.class); + IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class); InOrder inOrder = inOrder(mMockContext, mMockNative, mockCallback); ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); @@ -190,8 +190,8 @@ public class WifiNanStateManagerTest { // (1) check initial state mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); - validateCorrectNanStatusChangeBroadcast(inOrder, true); + inOrder.verify(mMockNative).deInitAware(); + validateCorrectAwareStatusChangeBroadcast(inOrder, true); inOrder.verify(mMockNative).getCapabilities(transactionId.capture()); mDut.onCapabilitiesUpdateResponse(transactionId.getValue(), getCapabilities()); mMockLooper.dispatchAll(); @@ -202,8 +202,8 @@ public class WifiNanStateManagerTest { mMockLooper.dispatchAll(); collector.checkThat("usage disabled", mDut.isUsageEnabled(), equalTo(false)); inOrder.verify(mMockNative).disable((short) 0); - inOrder.verify(mMockNative).deInitNan(); - validateCorrectNanStatusChangeBroadcast(inOrder, false); + inOrder.verify(mMockNative).deInitAware(); + validateCorrectAwareStatusChangeBroadcast(inOrder, false); // (3) try connecting and validate that get nothing (app should be aware of non-availability // through state change broadcast and/or query API) @@ -226,15 +226,15 @@ public class WifiNanStateManagerTest { final String callingPackage = "com.google.somePackage"; final ConfigRequest configRequest = new ConfigRequest.Builder().build(); - IWifiNanEventCallback mockCallback = mock(IWifiNanEventCallback.class); + IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class); ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); InOrder inOrder = inOrder(mMockContext, mMockNative, mockCallback); // (1) check initial state mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); - validateCorrectNanStatusChangeBroadcast(inOrder, true); + inOrder.verify(mMockNative).deInitAware(); + validateCorrectAwareStatusChangeBroadcast(inOrder, true); inOrder.verify(mMockNative).getCapabilities(transactionId.capture()); mDut.onCapabilitiesUpdateResponse(transactionId.getValue(), getCapabilities()); mMockLooper.dispatchAll(); @@ -255,11 +255,11 @@ public class WifiNanStateManagerTest { mMockLooper.dispatchAll(); collector.checkThat("usage disabled", mDut.isUsageEnabled(), equalTo(false)); inOrder.verify(mMockNative).disable((short) 0); - inOrder.verify(mMockNative).deInitNan(); - validateCorrectNanStatusChangeBroadcast(inOrder, false); + inOrder.verify(mMockNative).deInitAware(); + validateCorrectAwareStatusChangeBroadcast(inOrder, false); validateInternalClientInfoCleanedUp(clientId); - // (4) try connecting again and validate that just get an onNanDown + // (4) try connecting again and validate that just get an onAwareDown mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false); mMockLooper.dispatchAll(); @@ -272,8 +272,8 @@ public class WifiNanStateManagerTest { mDut.enableUsage(); mMockLooper.dispatchAll(); collector.checkThat("usage enabled", mDut.isUsageEnabled(), equalTo(true)); - inOrder.verify(mMockNative).deInitNan(); - validateCorrectNanStatusChangeBroadcast(inOrder, true); + inOrder.verify(mMockNative).deInitAware(); + validateCorrectAwareStatusChangeBroadcast(inOrder, true); // (7) connect (should be successful) mDut.connect(clientId, uid, pid, callingPackage, mockCallback, configRequest, false); @@ -292,7 +292,7 @@ public class WifiNanStateManagerTest { * that IdentityChanged not delivered if configuration disables delivery. */ @Test - public void testNanEventsDelivery() throws Exception { + public void testAwareEventsDelivery() throws Exception { final int clientId1 = 1005; final int clientId2 = 1007; final int clusterLow = 5; @@ -301,7 +301,7 @@ public class WifiNanStateManagerTest { final int uid = 1000; final int pid = 2000; final String callingPackage = "com.google.somePackage"; - final int reason = WifiNanNative.NAN_STATUS_ERROR; + final int reason = WifiAwareNative.AWARE_STATUS_ERROR; final byte[] someMac = HexEncoding.decode("000102030405".toCharArray(), false); final byte[] someMac2 = HexEncoding.decode("060708090A0B".toCharArray(), false); @@ -309,14 +309,14 @@ public class WifiNanStateManagerTest { .setClusterHigh(clusterHigh).setMasterPreference(masterPref) .build(); - IWifiNanEventCallback mockCallback1 = mock(IWifiNanEventCallback.class); - IWifiNanEventCallback mockCallback2 = mock(IWifiNanEventCallback.class); + IWifiAwareEventCallback mockCallback1 = mock(IWifiAwareEventCallback.class); + IWifiAwareEventCallback mockCallback2 = mock(IWifiAwareEventCallback.class); ArgumentCaptor<Short> transactionIdCapture = ArgumentCaptor.forClass(Short.class); InOrder inOrder = inOrder(mockCallback1, mockCallback2, mMockNative); mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); + inOrder.verify(mMockNative).deInitAware(); inOrder.verify(mMockNative).getCapabilities(transactionIdCapture.capture()); mDut.onCapabilitiesUpdateResponse(transactionIdCapture.getValue(), getCapabilities()); mMockLooper.dispatchAll(); @@ -333,8 +333,9 @@ public class WifiNanStateManagerTest { inOrder.verify(mockCallback1).onConnectSuccess(clientId1); inOrder.verify(mockCallback2).onConnectSuccess(clientId2); - // (2) deliver NAN events - without LOCATIONING permission - mDut.onClusterChangeNotification(WifiNanClientState.CLUSTER_CHANGE_EVENT_STARTED, someMac); + // (2) deliver Aware events - without LOCATIONING permission + mDut.onClusterChangeNotification(WifiAwareClientState.CLUSTER_CHANGE_EVENT_STARTED, + someMac); mDut.onInterfaceAddressChangeNotification(someMac); mMockLooper.dispatchAll(); @@ -361,8 +362,8 @@ public class WifiNanStateManagerTest { inOrder.verify(mockCallback2).onIdentityChanged(someMac); - // (6) NAN down (no feedback) - mDut.onNanDownNotification(reason); + // (6) Aware down (no feedback) + mDut.onAwareDownNotification(reason); mMockLooper.dispatchAll(); validateInternalClientInfoCleanedUp(clientId1); @@ -386,15 +387,15 @@ public class WifiNanStateManagerTest { final ConfigRequest configRequest = new ConfigRequest.Builder().build(); final PublishConfig publishConfig = new PublishConfig.Builder().build(); - IWifiNanEventCallback mockCallback = mock(IWifiNanEventCallback.class); - IWifiNanDiscoverySessionCallback mockSessionCallback = mock( - IWifiNanDiscoverySessionCallback.class); + IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class); + IWifiAwareDiscoverySessionCallback mockSessionCallback = mock( + IWifiAwareDiscoverySessionCallback.class); ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); InOrder inOrder = inOrder(mMockNative, mockCallback, mockSessionCallback); mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); + inOrder.verify(mMockNative).deInitAware(); inOrder.verify(mMockNative).getCapabilities(transactionId.capture()); mDut.onCapabilitiesUpdateResponse(transactionId.getValue(), getCapabilities()); mMockLooper.dispatchAll(); @@ -412,9 +413,9 @@ public class WifiNanStateManagerTest { mDut.publish(clientId, publishConfig, mockSessionCallback); mMockLooper.dispatchAll(); inOrder.verify(mMockNative).publish(anyShort(), eq(0), eq(publishConfig)); - assertTrue(mAlarmManager.dispatch(WifiNanStateManager.HAL_COMMAND_TIMEOUT_TAG)); + assertTrue(mAlarmManager.dispatch(WifiAwareStateManager.HAL_COMMAND_TIMEOUT_TAG)); mMockLooper.dispatchAll(); - inOrder.verify(mockSessionCallback).onSessionConfigFail(WifiNanNative.NAN_STATUS_ERROR); + inOrder.verify(mockSessionCallback).onSessionConfigFail(WifiAwareNative.AWARE_STATUS_ERROR); validateInternalNoSessions(clientId); // (3) publish + success @@ -438,20 +439,20 @@ public class WifiNanStateManagerTest { final int uid = 1000; final int pid = 2000; final String callingPackage = "com.google.somePackage"; - final int reasonFail = WifiNanNative.NAN_STATUS_ERROR; + final int reasonFail = WifiAwareNative.AWARE_STATUS_ERROR; ConfigRequest configRequest = new ConfigRequest.Builder().build(); PublishConfig publishConfig = new PublishConfig.Builder().build(); - IWifiNanEventCallback mockCallback = mock(IWifiNanEventCallback.class); - IWifiNanDiscoverySessionCallback mockSessionCallback = mock( - IWifiNanDiscoverySessionCallback.class); + IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class); + IWifiAwareDiscoverySessionCallback mockSessionCallback = mock( + IWifiAwareDiscoverySessionCallback.class); ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mMockNative); mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); + inOrder.verify(mMockNative).deInitAware(); inOrder.verify(mMockNative).getCapabilities(transactionId.capture()); mDut.onCapabilitiesUpdateResponse(transactionId.getValue(), getCapabilities()); mMockLooper.dispatchAll(); @@ -491,22 +492,22 @@ public class WifiNanStateManagerTest { final int uid = 1000; final int pid = 2000; final String callingPackage = "com.google.somePackage"; - final int reasonTerminate = WifiNanDiscoverySessionCallback.TERMINATE_REASON_DONE; + final int reasonTerminate = WifiAwareDiscoverySessionCallback.TERMINATE_REASON_DONE; final int publishId = 15; ConfigRequest configRequest = new ConfigRequest.Builder().build(); PublishConfig publishConfig = new PublishConfig.Builder().build(); - IWifiNanEventCallback mockCallback = mock(IWifiNanEventCallback.class); - IWifiNanDiscoverySessionCallback mockSessionCallback = mock( - IWifiNanDiscoverySessionCallback.class); + IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class); + IWifiAwareDiscoverySessionCallback mockSessionCallback = mock( + IWifiAwareDiscoverySessionCallback.class); ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); ArgumentCaptor<Integer> sessionId = ArgumentCaptor.forClass(Integer.class); InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mMockNative); mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); + inOrder.verify(mMockNative).deInitAware(); inOrder.verify(mMockNative).getCapabilities(transactionId.capture()); mDut.onCapabilitiesUpdateResponse(transactionId.getValue(), getCapabilities()); mMockLooper.dispatchAll(); @@ -566,21 +567,21 @@ public class WifiNanStateManagerTest { final int pid = 2000; final String callingPackage = "com.google.somePackage"; final int publishId = 15; - final int reasonFail = WifiNanNative.NAN_STATUS_ERROR; + final int reasonFail = WifiAwareNative.AWARE_STATUS_ERROR; ConfigRequest configRequest = new ConfigRequest.Builder().build(); PublishConfig publishConfig = new PublishConfig.Builder().build(); - IWifiNanEventCallback mockCallback = mock(IWifiNanEventCallback.class); - IWifiNanDiscoverySessionCallback mockSessionCallback = mock( - IWifiNanDiscoverySessionCallback.class); + IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class); + IWifiAwareDiscoverySessionCallback mockSessionCallback = mock( + IWifiAwareDiscoverySessionCallback.class); ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); ArgumentCaptor<Integer> sessionId = ArgumentCaptor.forClass(Integer.class); InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mMockNative); mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); + inOrder.verify(mMockNative).deInitAware(); inOrder.verify(mMockNative).getCapabilities(transactionId.capture()); mDut.onCapabilitiesUpdateResponse(transactionId.getValue(), getCapabilities()); mMockLooper.dispatchAll(); @@ -646,15 +647,15 @@ public class WifiNanStateManagerTest { ConfigRequest configRequest = new ConfigRequest.Builder().build(); PublishConfig publishConfig = new PublishConfig.Builder().build(); - IWifiNanEventCallback mockCallback = mock(IWifiNanEventCallback.class); - IWifiNanDiscoverySessionCallback mockSessionCallback = mock( - IWifiNanDiscoverySessionCallback.class); + IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class); + IWifiAwareDiscoverySessionCallback mockSessionCallback = mock( + IWifiAwareDiscoverySessionCallback.class); ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mMockNative); mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); + inOrder.verify(mMockNative).deInitAware(); inOrder.verify(mMockNative).getCapabilities(transactionId.capture()); mDut.onCapabilitiesUpdateResponse(transactionId.getValue(), getCapabilities()); mMockLooper.dispatchAll(); @@ -700,20 +701,20 @@ public class WifiNanStateManagerTest { final int uid = 1000; final int pid = 2000; final String callingPackage = "com.google.somePackage"; - final int reasonFail = WifiNanNative.NAN_STATUS_ERROR; + final int reasonFail = WifiAwareNative.AWARE_STATUS_ERROR; ConfigRequest configRequest = new ConfigRequest.Builder().build(); SubscribeConfig subscribeConfig = new SubscribeConfig.Builder().build(); - IWifiNanEventCallback mockCallback = mock(IWifiNanEventCallback.class); - IWifiNanDiscoverySessionCallback mockSessionCallback = mock( - IWifiNanDiscoverySessionCallback.class); + IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class); + IWifiAwareDiscoverySessionCallback mockSessionCallback = mock( + IWifiAwareDiscoverySessionCallback.class); ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mMockNative); mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); + inOrder.verify(mMockNative).deInitAware(); inOrder.verify(mMockNative).getCapabilities(transactionId.capture()); mDut.onCapabilitiesUpdateResponse(transactionId.getValue(), getCapabilities()); mMockLooper.dispatchAll(); @@ -753,22 +754,22 @@ public class WifiNanStateManagerTest { final int uid = 1000; final int pid = 2000; final String callingPackage = "com.google.somePackage"; - final int reasonTerminate = WifiNanDiscoverySessionCallback.TERMINATE_REASON_DONE; + final int reasonTerminate = WifiAwareDiscoverySessionCallback.TERMINATE_REASON_DONE; final int subscribeId = 15; ConfigRequest configRequest = new ConfigRequest.Builder().build(); SubscribeConfig subscribeConfig = new SubscribeConfig.Builder().build(); - IWifiNanEventCallback mockCallback = mock(IWifiNanEventCallback.class); - IWifiNanDiscoverySessionCallback mockSessionCallback = mock( - IWifiNanDiscoverySessionCallback.class); + IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class); + IWifiAwareDiscoverySessionCallback mockSessionCallback = mock( + IWifiAwareDiscoverySessionCallback.class); ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); ArgumentCaptor<Integer> sessionId = ArgumentCaptor.forClass(Integer.class); InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mMockNative); mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); + inOrder.verify(mMockNative).deInitAware(); inOrder.verify(mMockNative).getCapabilities(transactionId.capture()); mDut.onCapabilitiesUpdateResponse(transactionId.getValue(), getCapabilities()); mMockLooper.dispatchAll(); @@ -827,21 +828,21 @@ public class WifiNanStateManagerTest { final int pid = 2000; final String callingPackage = "com.google.somePackage"; final int subscribeId = 15; - final int reasonFail = WifiNanNative.NAN_STATUS_ERROR; + final int reasonFail = WifiAwareNative.AWARE_STATUS_ERROR; ConfigRequest configRequest = new ConfigRequest.Builder().build(); SubscribeConfig subscribeConfig = new SubscribeConfig.Builder().build(); - IWifiNanEventCallback mockCallback = mock(IWifiNanEventCallback.class); - IWifiNanDiscoverySessionCallback mockSessionCallback = mock( - IWifiNanDiscoverySessionCallback.class); + IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class); + IWifiAwareDiscoverySessionCallback mockSessionCallback = mock( + IWifiAwareDiscoverySessionCallback.class); ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); ArgumentCaptor<Integer> sessionId = ArgumentCaptor.forClass(Integer.class); InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mMockNative); mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); + inOrder.verify(mMockNative).deInitAware(); inOrder.verify(mMockNative).getCapabilities(transactionId.capture()); mDut.onCapabilitiesUpdateResponse(transactionId.getValue(), getCapabilities()); mMockLooper.dispatchAll(); @@ -907,15 +908,15 @@ public class WifiNanStateManagerTest { ConfigRequest configRequest = new ConfigRequest.Builder().build(); SubscribeConfig subscribeConfig = new SubscribeConfig.Builder().build(); - IWifiNanEventCallback mockCallback = mock(IWifiNanEventCallback.class); - IWifiNanDiscoverySessionCallback mockSessionCallback = mock( - IWifiNanDiscoverySessionCallback.class); + IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class); + IWifiAwareDiscoverySessionCallback mockSessionCallback = mock( + IWifiAwareDiscoverySessionCallback.class); ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mMockNative); mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); + inOrder.verify(mMockNative).deInitAware(); inOrder.verify(mMockNative).getCapabilities(transactionId.capture()); mDut.onCapabilitiesUpdateResponse(transactionId.getValue(), getCapabilities()); mMockLooper.dispatchAll(); @@ -964,7 +965,7 @@ public class WifiNanStateManagerTest { final String serviceName = "some-service-name"; final String ssi = "some much longer and more arbitrary data"; final int subscribeCount = 7; - final int reasonFail = WifiNanNative.NAN_STATUS_ERROR; + final int reasonFail = WifiAwareNative.AWARE_STATUS_ERROR; final int subscribeId = 15; final int requestorId = 22; final byte[] peerMac = HexEncoding.decode("060708090A0B".toCharArray(), false); @@ -980,16 +981,16 @@ public class WifiNanStateManagerTest { .setSubscribeType(SubscribeConfig.SUBSCRIBE_TYPE_PASSIVE) .setSubscribeCount(subscribeCount).build(); - IWifiNanEventCallback mockCallback = mock(IWifiNanEventCallback.class); - IWifiNanDiscoverySessionCallback mockSessionCallback = mock( - IWifiNanDiscoverySessionCallback.class); + IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class); + IWifiAwareDiscoverySessionCallback mockSessionCallback = mock( + IWifiAwareDiscoverySessionCallback.class); ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); ArgumentCaptor<Integer> sessionId = ArgumentCaptor.forClass(Integer.class); InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mMockNative); mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); + inOrder.verify(mMockNative).deInitAware(); inOrder.verify(mMockNative).getCapabilities(transactionId.capture()); mDut.onCapabilitiesUpdateResponse(transactionId.getValue(), getCapabilities()); mMockLooper.dispatchAll(); @@ -1079,7 +1080,7 @@ public class WifiNanStateManagerTest { final String msgToPeer2 = "hey there 0506..."; final int msgToPeerId1 = 546; final int msgToPeerId2 = 9654; - final int reason = WifiNanNative.NAN_STATUS_ERROR; + final int reason = WifiAwareNative.AWARE_STATUS_ERROR; ConfigRequest configRequest = new ConfigRequest.Builder().setClusterLow(clusterLow) .setClusterHigh(clusterHigh).setMasterPreference(masterPref).build(); @@ -1089,14 +1090,14 @@ public class WifiNanStateManagerTest { ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); ArgumentCaptor<Integer> sessionId = ArgumentCaptor.forClass(Integer.class); - IWifiNanEventCallback mockCallback = mock(IWifiNanEventCallback.class); - IWifiNanDiscoverySessionCallback mockSessionCallback = mock( - IWifiNanDiscoverySessionCallback.class); + IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class); + IWifiAwareDiscoverySessionCallback mockSessionCallback = mock( + IWifiAwareDiscoverySessionCallback.class); InOrder inOrder = inOrder(mMockNative, mockCallback, mockSessionCallback); mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); + inOrder.verify(mMockNative).deInitAware(); inOrder.verify(mMockNative).getCapabilities(transactionId.capture()); mDut.onCapabilitiesUpdateResponse(transactionId.getValue(), getCapabilities()); mMockLooper.dispatchAll(); @@ -1184,14 +1185,14 @@ public class WifiNanStateManagerTest { ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); ArgumentCaptor<Integer> sessionId = ArgumentCaptor.forClass(Integer.class); - IWifiNanEventCallback mockCallback = mock(IWifiNanEventCallback.class); - IWifiNanDiscoverySessionCallback mockSessionCallback = mock( - IWifiNanDiscoverySessionCallback.class); + IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class); + IWifiAwareDiscoverySessionCallback mockSessionCallback = mock( + IWifiAwareDiscoverySessionCallback.class); InOrder inOrder = inOrder(mMockNative, mockCallback, mockSessionCallback); mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); + inOrder.verify(mMockNative).deInitAware(); inOrder.verify(mMockNative).getCapabilities(transactionId.capture()); mDut.onCapabilitiesUpdateResponse(transactionId.getValue(), getCapabilities()); mMockLooper.dispatchAll(); @@ -1266,16 +1267,16 @@ public class WifiNanStateManagerTest { ConfigRequest configRequest = new ConfigRequest.Builder().build(); SubscribeConfig subscribeConfig = new SubscribeConfig.Builder().build(); - IWifiNanEventCallback mockCallback = mock(IWifiNanEventCallback.class); - IWifiNanDiscoverySessionCallback mockSessionCallback = mock( - IWifiNanDiscoverySessionCallback.class); + IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class); + IWifiAwareDiscoverySessionCallback mockSessionCallback = mock( + IWifiAwareDiscoverySessionCallback.class); ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); ArgumentCaptor<Integer> sessionId = ArgumentCaptor.forClass(Integer.class); InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mMockNative); mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); + inOrder.verify(mMockNative).deInitAware(); inOrder.verify(mMockNative).getCapabilities(transactionId.capture()); mDut.onCapabilitiesUpdateResponse(transactionId.getValue(), getCapabilities()); mMockLooper.dispatchAll(); @@ -1306,7 +1307,7 @@ public class WifiNanStateManagerTest { messageId, 0); mMockLooper.dispatchAll(); inOrder.verify(mockSessionCallback).onMessageSendFail(messageId, - WifiNanNative.NAN_STATUS_ERROR); + WifiAwareNative.AWARE_STATUS_ERROR); validateInternalSendMessageQueuesCleanedUp(messageId); verifyNoMoreInteractions(mockCallback, mockSessionCallback, mMockNative); @@ -1333,16 +1334,16 @@ public class WifiNanStateManagerTest { ConfigRequest configRequest = new ConfigRequest.Builder().build(); SubscribeConfig subscribeConfig = new SubscribeConfig.Builder().build(); - IWifiNanEventCallback mockCallback = mock(IWifiNanEventCallback.class); - IWifiNanDiscoverySessionCallback mockSessionCallback = mock( - IWifiNanDiscoverySessionCallback.class); + IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class); + IWifiAwareDiscoverySessionCallback mockSessionCallback = mock( + IWifiAwareDiscoverySessionCallback.class); ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); ArgumentCaptor<Integer> sessionId = ArgumentCaptor.forClass(Integer.class); InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mMockNative); mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); + inOrder.verify(mMockNative).deInitAware(); inOrder.verify(mMockNative).getCapabilities(transactionId.capture()); mDut.onCapabilitiesUpdateResponse(transactionId.getValue(), getCapabilities()); mMockLooper.dispatchAll(); @@ -1388,10 +1389,10 @@ public class WifiNanStateManagerTest { mMockLooper.dispatchAll(); // (4) message send timeout - assertTrue(mAlarmManager.dispatch(WifiNanStateManager.HAL_SEND_MESSAGE_TIMEOUT_TAG)); + assertTrue(mAlarmManager.dispatch(WifiAwareStateManager.HAL_SEND_MESSAGE_TIMEOUT_TAG)); mMockLooper.dispatchAll(); inOrder.verify(mockSessionCallback).onMessageSendFail(messageId, - WifiNanNative.NAN_STATUS_ERROR); + WifiAwareNative.AWARE_STATUS_ERROR); validateInternalSendMessageQueuesCleanedUp(messageId); // (5) firmware response (unlikely - but good to check) @@ -1427,16 +1428,16 @@ public class WifiNanStateManagerTest { ConfigRequest configRequest = new ConfigRequest.Builder().build(); SubscribeConfig subscribeConfig = new SubscribeConfig.Builder().build(); - IWifiNanEventCallback mockCallback = mock(IWifiNanEventCallback.class); - IWifiNanDiscoverySessionCallback mockSessionCallback = mock( - IWifiNanDiscoverySessionCallback.class); + IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class); + IWifiAwareDiscoverySessionCallback mockSessionCallback = mock( + IWifiAwareDiscoverySessionCallback.class); ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); ArgumentCaptor<Integer> sessionId = ArgumentCaptor.forClass(Integer.class); InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mMockNative); mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); + inOrder.verify(mMockNative).deInitAware(); inOrder.verify(mMockNative).getCapabilities(transactionId.capture()); mDut.onCapabilitiesUpdateResponse(transactionId.getValue(), getCapabilities()); mMockLooper.dispatchAll(); @@ -1474,7 +1475,7 @@ public class WifiNanStateManagerTest { // (4) loop and fail until reach retryCount for (int i = 0; i < retryCount; ++i) { mDut.onMessageSendFailNotification(transactionId.getValue(), - WifiNanNative.NAN_STATUS_TX_FAIL); + WifiAwareNative.AWARE_STATUS_TX_FAIL); mMockLooper.dispatchAll(); inOrder.verify(mMockNative).sendMessage(transactionId.capture(), eq(subscribeId), eq(requestorId), eq(peerMac), eq(ssi.getBytes()), eq(messageId)); @@ -1514,16 +1515,16 @@ public class WifiNanStateManagerTest { ConfigRequest configRequest = new ConfigRequest.Builder().build(); SubscribeConfig subscribeConfig = new SubscribeConfig.Builder().build(); - IWifiNanEventCallback mockCallback = mock(IWifiNanEventCallback.class); - IWifiNanDiscoverySessionCallback mockSessionCallback = mock( - IWifiNanDiscoverySessionCallback.class); + IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class); + IWifiAwareDiscoverySessionCallback mockSessionCallback = mock( + IWifiAwareDiscoverySessionCallback.class); ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); ArgumentCaptor<Integer> sessionId = ArgumentCaptor.forClass(Integer.class); InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mMockNative); mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); + inOrder.verify(mMockNative).deInitAware(); inOrder.verify(mMockNative).getCapabilities(transactionId.capture()); mDut.onCapabilitiesUpdateResponse(transactionId.getValue(), getCapabilities()); mMockLooper.dispatchAll(); @@ -1561,7 +1562,7 @@ public class WifiNanStateManagerTest { // (4) loop and fail until reach retryCount+1 for (int i = 0; i < retryCount + 1; ++i) { mDut.onMessageSendFailNotification(transactionId.getValue(), - WifiNanNative.NAN_STATUS_TX_FAIL); + WifiAwareNative.AWARE_STATUS_TX_FAIL); mMockLooper.dispatchAll(); if (i != retryCount) { @@ -1573,7 +1574,7 @@ public class WifiNanStateManagerTest { } inOrder.verify(mockSessionCallback).onMessageSendFail(messageId, - WifiNanNative.NAN_STATUS_TX_FAIL); + WifiAwareNative.AWARE_STATUS_TX_FAIL); validateInternalSendMessageQueuesCleanedUp(messageId); verifyNoMoreInteractions(mockCallback, mockSessionCallback, mMockNative); @@ -1604,9 +1605,9 @@ public class WifiNanStateManagerTest { .setSubscribeType(SubscribeConfig.SUBSCRIBE_TYPE_PASSIVE) .setSubscribeCount(subscribeCount).build(); - IWifiNanEventCallback mockCallback = mock(IWifiNanEventCallback.class); - IWifiNanDiscoverySessionCallback mockSessionCallback = mock( - IWifiNanDiscoverySessionCallback.class); + IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class); + IWifiAwareDiscoverySessionCallback mockSessionCallback = mock( + IWifiAwareDiscoverySessionCallback.class); ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); ArgumentCaptor<Integer> sessionId = ArgumentCaptor.forClass(Integer.class); ArgumentCaptor<byte[]> byteArrayCaptor = ArgumentCaptor.forClass(byte[].class); @@ -1614,7 +1615,7 @@ public class WifiNanStateManagerTest { mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); + inOrder.verify(mMockNative).deInitAware(); inOrder.verify(mMockNative).getCapabilities(transactionId.capture()); mDut.onCapabilitiesUpdateResponse(transactionId.getValue(), getCapabilities()); mMockLooper.dispatchAll(); @@ -1695,35 +1696,35 @@ public class WifiNanStateManagerTest { @Test public void testSendMessageQueueAllQueueFail() throws Exception { - WifiNanNative.Capabilities cap = getCapabilities(); + WifiAwareNative.Capabilities cap = getCapabilities(); testSendMessageQueue(SendMessageAnswer.OP_QUEUE_FAIL, cap, cap.maxQueuedTransmitMessages + 5); } @Test public void testSendMessageQueueAllTxSuccess() throws Exception { - WifiNanNative.Capabilities cap = getCapabilities(); + WifiAwareNative.Capabilities cap = getCapabilities(); testSendMessageQueue(SendMessageAnswer.OP_QUEUE_OK_SEND_OK, cap, cap.maxQueuedTransmitMessages + 5); } @Test public void testSendMessageQueueAllTxFailRetxOk() throws Exception { - WifiNanNative.Capabilities cap = getCapabilities(); + WifiAwareNative.Capabilities cap = getCapabilities(); testSendMessageQueue(SendMessageAnswer.OP_QUEUE_OK_SEND_RETX_OK, cap, cap.maxQueuedTransmitMessages + 5); } @Test public void testSendMessageQueueAllTxFail() throws Exception { - WifiNanNative.Capabilities cap = getCapabilities(); + WifiAwareNative.Capabilities cap = getCapabilities(); testSendMessageQueue(SendMessageAnswer.OP_QUEUE_OK_SEND_RETX_FAIL, cap, cap.maxQueuedTransmitMessages + 5); } @Test public void testSendMessageQueueRandomize() throws Exception { - WifiNanNative.Capabilities cap = getCapabilities(); + WifiAwareNative.Capabilities cap = getCapabilities(); testSendMessageQueue(SendMessageAnswer.OP_QUEUE_RANDOMIZE, cap, cap.maxQueuedTransmitMessages * 10); } @@ -1733,8 +1734,8 @@ public class WifiNanStateManagerTest { * capability information) they are queued. Support all possible test success/failure codes. * @param behavior: SendMessageAnswer.OP_*. */ - private void testSendMessageQueue(int behavior, WifiNanNative.Capabilities cap, int numMessages) - throws Exception { + private void testSendMessageQueue(int behavior, WifiAwareNative.Capabilities cap, + int numMessages) throws Exception { final int clientId = 1005; final int uid = 1000; final int pid = 2000; @@ -1747,14 +1748,14 @@ public class WifiNanStateManagerTest { final String peerMatchFilter = "filter binary array represented as string"; final int messageId = 6948; final int retryCount = 3; - final int reason = WifiNanNative.NAN_STATUS_ERROR; + final int reason = WifiAwareNative.AWARE_STATUS_ERROR; ConfigRequest configRequest = new ConfigRequest.Builder().build(); SubscribeConfig subscribeConfig = new SubscribeConfig.Builder().build(); - IWifiNanEventCallback mockCallback = mock(IWifiNanEventCallback.class); - IWifiNanDiscoverySessionCallback mockSessionCallback = mock( - IWifiNanDiscoverySessionCallback.class); + IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class); + IWifiAwareDiscoverySessionCallback mockSessionCallback = mock( + IWifiAwareDiscoverySessionCallback.class); ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); ArgumentCaptor<Integer> sessionId = ArgumentCaptor.forClass(Integer.class); ArgumentCaptor<Integer> msgId = ArgumentCaptor.forClass(Integer.class); @@ -1762,7 +1763,7 @@ public class WifiNanStateManagerTest { // (0) initial conditions mDut.enableUsage(); mMockLooper.dispatchAll(); - verify(mMockNative).deInitNan(); + verify(mMockNative).deInitAware(); verify(mMockNative).getCapabilities(transactionId.capture()); mDut.onCapabilitiesUpdateResponse(transactionId.getValue(), cap); mMockLooper.dispatchAll(); @@ -1806,7 +1807,7 @@ public class WifiNanStateManagerTest { + answerObj.ops[SendMessageAnswer.OP_QUEUE_OK_SEND_RETX_OK]; int numOnSendFail = answerObj.ops[SendMessageAnswer.OP_QUEUE_OK_SEND_RETX_FAIL]; - Log.v("WifiNanStateManagerTest", + Log.v("WifiAwareStateMgrTest", "testSendMessageQueue: ops=" + Arrays.toString(answerObj.ops) + ", numSends=" + numSends + ", numOnSendSuccess=" + numOnSendSuccess + ", numOnSendFail=" + numOnSendFail); @@ -1843,7 +1844,7 @@ public class WifiNanStateManagerTest { public boolean answer(short transactionId, int pubSubId, int requestorInstanceId, byte[] dest, byte[] message, int messageId) throws Exception { - Log.v("WifiNanStateManagerTest", + Log.v("WifiAwareStateMgrTest", "SendMessageAnswer.answer: mBehavior=" + mBehavior + ", transactionId=" + transactionId + ", messageId=" + messageId + ", mPacketBehavior[messageId]" + mPacketBehavior.get(messageId, -1)); @@ -1863,7 +1864,7 @@ public class WifiNanStateManagerTest { if (behavior == OP_QUEUE_FAIL) { ops[OP_QUEUE_FAIL]++; mDut.onMessageSendQueuedFailResponse(transactionId, - WifiNanNative.NAN_STATUS_ERROR); + WifiAwareNative.AWARE_STATUS_ERROR); } else if (behavior == OP_QUEUE_OK_SEND_OK) { ops[OP_QUEUE_OK_SEND_OK]++; mDut.onMessageSendQueuedSuccessResponse(transactionId); @@ -1872,7 +1873,7 @@ public class WifiNanStateManagerTest { mDut.onMessageSendQueuedSuccessResponse(transactionId); if (!packetRetx) { mDut.onMessageSendFailNotification(transactionId, - WifiNanNative.NAN_STATUS_TX_FAIL); + WifiAwareNative.AWARE_STATUS_TX_FAIL); } else { ops[OP_QUEUE_OK_SEND_RETX_OK]++; mDut.onMessageSendSuccessNotification(transactionId); @@ -1883,7 +1884,7 @@ public class WifiNanStateManagerTest { ops[OP_QUEUE_OK_SEND_RETX_FAIL]++; } mDut.onMessageSendFailNotification(transactionId, - WifiNanNative.NAN_STATUS_NO_OTA_ACK); + WifiAwareNative.AWARE_STATUS_NO_OTA_ACK); } return true; } @@ -1914,23 +1915,23 @@ public class WifiNanStateManagerTest { ConfigRequest configRequest = new ConfigRequest.Builder().build(); SubscribeConfig subscribeConfig = new SubscribeConfig.Builder().build(); - IWifiNanEventCallback mockCallback = mock(IWifiNanEventCallback.class); - IWifiNanDiscoverySessionCallback mockSessionCallback = mock( - IWifiNanDiscoverySessionCallback.class); + IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class); + IWifiAwareDiscoverySessionCallback mockSessionCallback = mock( + IWifiAwareDiscoverySessionCallback.class); ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); ArgumentCaptor<Integer> sessionId = ArgumentCaptor.forClass(Integer.class); - ArgumentCaptor<WifiNanClientState> clientCaptor = - ArgumentCaptor.forClass(WifiNanClientState.class); + ArgumentCaptor<WifiAwareClientState> clientCaptor = + ArgumentCaptor.forClass(WifiAwareClientState.class); ArgumentCaptor<RttManager.RttParams[]> rttParamsCaptor = ArgumentCaptor.forClass(RttManager.RttParams[].class); InOrder inOrder = inOrder(mockCallback, mockSessionCallback, mMockNative, - mMockNanRttStateManager); + mMockAwareRttStateManager); mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); + inOrder.verify(mMockNative).deInitAware(); inOrder.verify(mMockNative).getCapabilities(transactionId.capture()); mDut.onCapabilitiesUpdateResponse(transactionId.getValue(), getCapabilities()); mMockLooper.dispatchAll(); @@ -1959,14 +1960,14 @@ public class WifiNanStateManagerTest { // (3) start ranging: pass along a valid peer ID and an invalid one mDut.startRanging(clientId, sessionId.getValue(), params, rangingId); mMockLooper.dispatchAll(); - inOrder.verify(mMockNanRttStateManager).startRanging(eq(rangingId), clientCaptor.capture(), - rttParamsCaptor.capture()); + inOrder.verify(mMockAwareRttStateManager).startRanging(eq(rangingId), + clientCaptor.capture(), rttParamsCaptor.capture()); collector.checkThat("RttParams[0].bssid", "06:07:08:09:0A:0B", equalTo(rttParamsCaptor.getValue()[0].bssid)); collector.checkThat("RttParams[1].bssid", "", equalTo(rttParamsCaptor.getValue()[1].bssid)); verifyNoMoreInteractions(mockCallback, mockSessionCallback, mMockNative, - mMockNanRttStateManager); + mMockAwareRttStateManager); } /** @@ -2000,15 +2001,15 @@ public class WifiNanStateManagerTest { .setClusterLow(clusterLow2).setClusterHigh(clusterHigh2) .setMasterPreference(masterPref2).build(); - IWifiNanEventCallback mockCallback1 = mock(IWifiNanEventCallback.class); - IWifiNanEventCallback mockCallback2 = mock(IWifiNanEventCallback.class); - IWifiNanEventCallback mockCallback3 = mock(IWifiNanEventCallback.class); + IWifiAwareEventCallback mockCallback1 = mock(IWifiAwareEventCallback.class); + IWifiAwareEventCallback mockCallback2 = mock(IWifiAwareEventCallback.class); + IWifiAwareEventCallback mockCallback3 = mock(IWifiAwareEventCallback.class); InOrder inOrder = inOrder(mMockNative, mockCallback1, mockCallback2, mockCallback3); mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); + inOrder.verify(mMockNative).deInitAware(); inOrder.verify(mMockNative).getCapabilities(transactionId.capture()); mDut.onCapabilitiesUpdateResponse(transactionId.getValue(), getCapabilities()); mMockLooper.dispatchAll(); @@ -2027,7 +2028,7 @@ public class WifiNanStateManagerTest { mDut.connect(clientId2, uid, pid, callingPackage, mockCallback2, configRequest2, false); mMockLooper.dispatchAll(); inOrder.verify(mockCallback2) - .onConnectFail(WifiNanNative.NAN_STATUS_ERROR); + .onConnectFail(WifiAwareNative.AWARE_STATUS_ERROR); validateInternalClientInfoCleanedUp(clientId2); // (5) disconnect config1: disable @@ -2054,7 +2055,7 @@ public class WifiNanStateManagerTest { final String serviceName = "some-service-name"; final String ssi = "some much longer and more arbitrary data"; final int publishCount = 7; - final int reason = WifiNanDiscoverySessionCallback.TERMINATE_REASON_DONE; + final int reason = WifiAwareDiscoverySessionCallback.TERMINATE_REASON_DONE; final int publishId = 22; ConfigRequest configRequest = new ConfigRequest.Builder().setClusterLow(clusterLow) @@ -2065,14 +2066,14 @@ public class WifiNanStateManagerTest { PublishConfig.PUBLISH_TYPE_UNSOLICITED).setPublishCount(publishCount).build(); ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); - IWifiNanEventCallback mockCallback = mock(IWifiNanEventCallback.class); - IWifiNanDiscoverySessionCallback mockSessionCallback = mock( - IWifiNanDiscoverySessionCallback.class); + IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class); + IWifiAwareDiscoverySessionCallback mockSessionCallback = mock( + IWifiAwareDiscoverySessionCallback.class); InOrder inOrder = inOrder(mMockNative, mockCallback, mockSessionCallback); mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); + inOrder.verify(mMockNative).deInitAware(); inOrder.verify(mMockNative).getCapabilities(transactionId.capture()); mDut.onCapabilitiesUpdateResponse(transactionId.getValue(), getCapabilities()); mMockLooper.dispatchAll(); @@ -2141,14 +2142,14 @@ public class WifiNanStateManagerTest { PublishConfig.PUBLISH_TYPE_UNSOLICITED).setPublishCount(publishCount).build(); ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); - IWifiNanEventCallback mockCallback = mock(IWifiNanEventCallback.class); - IWifiNanDiscoverySessionCallback mockPublishSessionCallback = mock( - IWifiNanDiscoverySessionCallback.class); + IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class); + IWifiAwareDiscoverySessionCallback mockPublishSessionCallback = mock( + IWifiAwareDiscoverySessionCallback.class); InOrder inOrder = inOrder(mMockNative, mockCallback, mockPublishSessionCallback); mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); + inOrder.verify(mMockNative).deInitAware(); inOrder.verify(mMockNative).getCapabilities(transactionId.capture()); mDut.onCapabilitiesUpdateResponse(transactionId.getValue(), getCapabilities()); mMockLooper.dispatchAll(); @@ -2185,14 +2186,14 @@ public class WifiNanStateManagerTest { ConfigRequest configRequest = new ConfigRequest.Builder().build(); ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); - IWifiNanEventCallback mockCallback = mock(IWifiNanEventCallback.class); - IWifiNanDiscoverySessionCallback mockSessionCallback = mock( - IWifiNanDiscoverySessionCallback.class); + IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class); + IWifiAwareDiscoverySessionCallback mockSessionCallback = mock( + IWifiAwareDiscoverySessionCallback.class); InOrder inOrder = inOrder(mMockNative, mockCallback, mockSessionCallback); mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); + inOrder.verify(mMockNative).deInitAware(); inOrder.verify(mMockNative).getCapabilities(transactionId.capture()); mDut.onCapabilitiesUpdateResponse(transactionId.getValue(), getCapabilities()); mMockLooper.dispatchAll(); @@ -2222,12 +2223,12 @@ public class WifiNanStateManagerTest { ConfigRequest configRequest = new ConfigRequest.Builder().build(); ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); - IWifiNanEventCallback mockCallback = mock(IWifiNanEventCallback.class); + IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class); InOrder inOrder = inOrder(mMockNative, mockCallback); mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); + inOrder.verify(mMockNative).deInitAware(); inOrder.verify(mMockNative).getCapabilities(transactionId.capture()); mDut.onCapabilitiesUpdateResponse(transactionId.getValue(), getCapabilities()); mMockLooper.dispatchAll(); @@ -2277,14 +2278,14 @@ public class WifiNanStateManagerTest { ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); ArgumentCaptor<Integer> sessionId = ArgumentCaptor.forClass(Integer.class); - IWifiNanEventCallback mockCallback = mock(IWifiNanEventCallback.class); - IWifiNanDiscoverySessionCallback mockSessionCallback = mock( - IWifiNanDiscoverySessionCallback.class); + IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class); + IWifiAwareDiscoverySessionCallback mockSessionCallback = mock( + IWifiAwareDiscoverySessionCallback.class); InOrder inOrder = inOrder(mMockNative, mockCallback, mockSessionCallback); mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); + inOrder.verify(mMockNative).deInitAware(); inOrder.verify(mMockNative).getCapabilities(transactionId.capture()); mDut.onCapabilitiesUpdateResponse(transactionId.getValue(), getCapabilities()); mMockLooper.dispatchAll(); @@ -2310,7 +2311,7 @@ public class WifiNanStateManagerTest { mDut.updateSubscribe(clientId, sessionId.getValue(), subscribeConfig); mMockLooper.dispatchAll(); inOrder.verify(mockSessionCallback) - .onSessionConfigFail(WifiNanNative.NAN_STATUS_ERROR); + .onSessionConfigFail(WifiAwareNative.AWARE_STATUS_ERROR); verifyNoMoreInteractions(mMockNative, mockCallback, mockSessionCallback); } @@ -2333,14 +2334,14 @@ public class WifiNanStateManagerTest { ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); ArgumentCaptor<Integer> sessionId = ArgumentCaptor.forClass(Integer.class); - IWifiNanEventCallback mockCallback = mock(IWifiNanEventCallback.class); - IWifiNanDiscoverySessionCallback mockSessionCallback = mock( - IWifiNanDiscoverySessionCallback.class); + IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class); + IWifiAwareDiscoverySessionCallback mockSessionCallback = mock( + IWifiAwareDiscoverySessionCallback.class); InOrder inOrder = inOrder(mMockNative, mockCallback, mockSessionCallback); mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); + inOrder.verify(mMockNative).deInitAware(); inOrder.verify(mMockNative).getCapabilities(transactionId.capture()); mDut.onCapabilitiesUpdateResponse(transactionId.getValue(), getCapabilities()); mMockLooper.dispatchAll(); @@ -2366,7 +2367,7 @@ public class WifiNanStateManagerTest { mDut.updatePublish(clientId, sessionId.getValue(), publishConfig); mMockLooper.dispatchAll(); inOrder.verify(mockSessionCallback) - .onSessionConfigFail(WifiNanNative.NAN_STATUS_ERROR); + .onSessionConfigFail(WifiAwareNative.AWARE_STATUS_ERROR); verifyNoMoreInteractions(mMockNative, mockCallback, mockSessionCallback); } @@ -2387,14 +2388,14 @@ public class WifiNanStateManagerTest { ArgumentCaptor<Short> transactionId = ArgumentCaptor.forClass(Short.class); ArgumentCaptor<Integer> sessionId = ArgumentCaptor.forClass(Integer.class); - IWifiNanEventCallback mockCallback = mock(IWifiNanEventCallback.class); - IWifiNanDiscoverySessionCallback mockSessionCallback = mock( - IWifiNanDiscoverySessionCallback.class); + IWifiAwareEventCallback mockCallback = mock(IWifiAwareEventCallback.class); + IWifiAwareDiscoverySessionCallback mockSessionCallback = mock( + IWifiAwareDiscoverySessionCallback.class); InOrder inOrder = inOrder(mMockNative, mockCallback, mockSessionCallback); mDut.enableUsage(); mMockLooper.dispatchAll(); - inOrder.verify(mMockNative).deInitNan(); + inOrder.verify(mMockNative).deInitAware(); inOrder.verify(mMockNative).getCapabilities(transactionId.capture()); mDut.onCapabilitiesUpdateResponse(transactionId.getValue(), getCapabilities()); mMockLooper.dispatchAll(); @@ -2428,7 +2429,7 @@ public class WifiNanStateManagerTest { } /* - * Tests of internal state of WifiNanStateManager: very limited (not usually + * Tests of internal state of WifiAwareStateManager: very limited (not usually * a good idea). However, these test that the internal state is cleaned-up * appropriately. Alternatively would cause issues with memory leaks or * information leak between sessions. @@ -2442,7 +2443,7 @@ public class WifiNanStateManagerTest { * @param clientId The ID of the client which should be deleted. */ private void validateInternalClientInfoCleanedUp(int clientId) throws Exception { - WifiNanClientState client = getInternalClientState(mDut, clientId); + WifiAwareClientState client = getInternalClientState(mDut, clientId); collector.checkThat("Client record not cleared up for clientId=" + clientId, client, nullValue()); } @@ -2457,9 +2458,9 @@ public class WifiNanStateManagerTest { */ private void validateInternalSessionInfoCleanedUp(int clientId, int sessionId) throws Exception { - WifiNanClientState client = getInternalClientState(mDut, clientId); + WifiAwareClientState client = getInternalClientState(mDut, clientId); collector.checkThat("Client record exists clientId=" + clientId, client, notNullValue()); - WifiNanDiscoverySessionState session = getInternalSessionState(client, sessionId); + WifiAwareDiscoverySessionState session = getInternalSessionState(client, sessionId); collector.checkThat("Client record not cleaned-up for sessionId=" + sessionId, session, nullValue()); } @@ -2472,102 +2473,105 @@ public class WifiNanStateManagerTest { * @param clientId The ID of the client which we want to check. */ private void validateInternalNoSessions(int clientId) throws Exception { - WifiNanClientState client = getInternalClientState(mDut, clientId); + WifiAwareClientState client = getInternalClientState(mDut, clientId); collector.checkThat("Client record exists clientId=" + clientId, client, notNullValue()); - Field field = WifiNanClientState.class.getDeclaredField("mSessions"); + Field field = WifiAwareClientState.class.getDeclaredField("mSessions"); field.setAccessible(true); @SuppressWarnings("unchecked") - SparseArray<WifiNanDiscoverySessionState> sessions = - (SparseArray<WifiNanDiscoverySessionState>) field.get(client); + SparseArray<WifiAwareDiscoverySessionState> sessions = + (SparseArray<WifiAwareDiscoverySessionState>) field.get(client); collector.checkThat("No sessions exist for clientId=" + clientId, sessions.size(), equalTo(0)); } /** - * Validates that the broadcast sent on NAN status change is correct. + * Validates that the broadcast sent on Aware status change is correct. * * @param expectedEnabled The expected change status - i.e. are we expected - * to announce that NAN is enabled (true) or disabled (false). + * to announce that Aware is enabled (true) or disabled (false). */ - private void validateCorrectNanStatusChangeBroadcast(InOrder inOrder, boolean expectedEnabled) { + private void validateCorrectAwareStatusChangeBroadcast(InOrder inOrder, + boolean expectedEnabled) { ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class); inOrder.verify(mMockContext).sendBroadcastAsUser(intent.capture(), eq(UserHandle.ALL)); collector.checkThat("intent action", intent.getValue().getAction(), - equalTo(WifiNanManager.ACTION_WIFI_NAN_STATE_CHANGED)); + equalTo(WifiAwareManager.ACTION_WIFI_AWARE_STATE_CHANGED)); } /* * Utilities */ - private static WifiNanStateManager installNewNanStateManager() + private static WifiAwareStateManager installNewAwareStateManager() throws Exception { - Constructor<WifiNanStateManager> ctr = WifiNanStateManager.class.getDeclaredConstructor(); + Constructor<WifiAwareStateManager> ctr = + WifiAwareStateManager.class.getDeclaredConstructor(); ctr.setAccessible(true); - WifiNanStateManager nanStateManager = ctr.newInstance(); + WifiAwareStateManager awareStateManager = ctr.newInstance(); - Field field = WifiNanStateManager.class.getDeclaredField("sNanStateManagerSingleton"); + Field field = WifiAwareStateManager.class.getDeclaredField("sAwareStateManagerSingleton"); field.setAccessible(true); - field.set(null, nanStateManager); + field.set(null, awareStateManager); - return WifiNanStateManager.getInstance(); + return WifiAwareStateManager.getInstance(); } - private static void installMocksInStateManager(WifiNanStateManager nanStateManager, - WifiNanRttStateManager mockRtt, WifiNanDataPathStateManager mockDpMgr) + private static void installMocksInStateManager(WifiAwareStateManager awareStateManager, + WifiAwareRttStateManager mockRtt, WifiAwareDataPathStateManager mockDpMgr) throws Exception { - Field field = WifiNanStateManager.class.getDeclaredField("mRtt"); + Field field = WifiAwareStateManager.class.getDeclaredField("mRtt"); field.setAccessible(true); - field.set(nanStateManager, mockRtt); + field.set(awareStateManager, mockRtt); - field = WifiNanStateManager.class.getDeclaredField("mDataPathMgr"); + field = WifiAwareStateManager.class.getDeclaredField("mDataPathMgr"); field.setAccessible(true); - field.set(nanStateManager, mockDpMgr); + field.set(awareStateManager, mockDpMgr); } - private static void installMockWifiNanNative(WifiNanNative obj) throws Exception { - Field field = WifiNanNative.class.getDeclaredField("sWifiNanNativeSingleton"); + private static void installMockWifiAwareNative(WifiAwareNative obj) throws Exception { + Field field = WifiAwareNative.class.getDeclaredField("sWifiAwareNativeSingleton"); field.setAccessible(true); field.set(null, obj); } - private static WifiNanClientState getInternalClientState(WifiNanStateManager dut, int clientId) - throws Exception { - Field field = WifiNanStateManager.class.getDeclaredField("mClients"); + private static WifiAwareClientState getInternalClientState(WifiAwareStateManager dut, + int clientId) throws Exception { + Field field = WifiAwareStateManager.class.getDeclaredField("mClients"); field.setAccessible(true); @SuppressWarnings("unchecked") - SparseArray<WifiNanClientState> clients = (SparseArray<WifiNanClientState>) field.get(dut); + SparseArray<WifiAwareClientState> clients = (SparseArray<WifiAwareClientState>) field.get( + dut); return clients.get(clientId); } - private static WifiNanDiscoverySessionState getInternalSessionState(WifiNanClientState client, - int sessionId) throws Exception { - Field field = WifiNanClientState.class.getDeclaredField("mSessions"); + private static WifiAwareDiscoverySessionState getInternalSessionState( + WifiAwareClientState client, int sessionId) throws Exception { + Field field = WifiAwareClientState.class.getDeclaredField("mSessions"); field.setAccessible(true); @SuppressWarnings("unchecked") - SparseArray<WifiNanDiscoverySessionState> sessions = - (SparseArray<WifiNanDiscoverySessionState>) field.get(client); + SparseArray<WifiAwareDiscoverySessionState> sessions = + (SparseArray<WifiAwareDiscoverySessionState>) field.get(client); return sessions.get(sessionId); } private void validateInternalSendMessageQueuesCleanedUp(int messageId) throws Exception { - Field field = WifiNanStateManager.class.getDeclaredField("mSm"); + Field field = WifiAwareStateManager.class.getDeclaredField("mSm"); field.setAccessible(true); - WifiNanStateManager.WifiNanStateMachine sm = - (WifiNanStateManager.WifiNanStateMachine) field.get(mDut); + WifiAwareStateManager.WifiAwareStateMachine sm = + (WifiAwareStateManager.WifiAwareStateMachine) field.get(mDut); - field = WifiNanStateManager.WifiNanStateMachine.class.getDeclaredField( + field = WifiAwareStateManager.WifiAwareStateMachine.class.getDeclaredField( "mHostQueuedSendMessages"); field.setAccessible(true); SparseArray<Message> hostQueuedSendMessages = (SparseArray<Message>) field.get(sm); - field = WifiNanStateManager.WifiNanStateMachine.class.getDeclaredField( + field = WifiAwareStateManager.WifiAwareStateMachine.class.getDeclaredField( "mFwQueuedSendMessages"); field.setAccessible(true); Map<Short, Message> fwQueuedSendMessages = (Map<Short, Message>) field.get(sm); @@ -2590,9 +2594,9 @@ public class WifiNanStateManagerTest { } } - private static WifiNanNative.Capabilities getCapabilities() { - WifiNanNative.Capabilities cap = new WifiNanNative.Capabilities(); - cap.maxConcurrentNanClusters = 1; + private static WifiAwareNative.Capabilities getCapabilities() { + WifiAwareNative.Capabilities cap = new WifiAwareNative.Capabilities(); + cap.maxConcurrentAwareClusters = 1; cap.maxPublishes = 2; cap.maxSubscribes = 2; cap.maxServiceNameLen = 255; |