From 65e89d2063f6ee50d00a2579b809deb0a98b5d8b Mon Sep 17 00:00:00 2001 From: Etan Cohen Date: Thu, 18 Aug 2016 15:38:39 -0700 Subject: [NAN] Simplify publish/subscribe configuration - merge match filters Merge Tx/Rx match filters into single Match filter configuration. Only a single filter can be used at a time (either Tx or Rx). Bug: 30948496 Change-Id: I863b642ca1f1d4790fcedcea07eaa91b7ff8ea17 --- .../com_android_server_wifi_nan_WifiNanNative.cpp | 72 ++++++++++++---------- 1 file changed, 38 insertions(+), 34 deletions(-) (limited to 'service') diff --git a/service/jni/com_android_server_wifi_nan_WifiNanNative.cpp b/service/jni/com_android_server_wifi_nan_WifiNanNative.cpp index ff9c4469d..379794de2 100644 --- a/service/jni/com_android_server_wifi_nan_WifiNanNative.cpp +++ b/service/jni/com_android_server_wifi_nan_WifiNanNative.cpp @@ -398,6 +398,7 @@ static jint android_net_wifi_nan_publish(JNIEnv *env, jclass cls, /* configurable settings */ msg.publish_id = publish_id; + msg.publish_type = (NanPublishType)helper.getIntField(publish_config, "mPublishType"); size_t array_length; helper.getByteArrayField(publish_config, "mServiceName", msg.service_name, @@ -417,25 +418,26 @@ static jint android_net_wifi_nan_publish(JNIEnv *env, jclass cls, return 0; } - helper.getByteArrayField(publish_config, "mTxFilter", - msg.tx_match_filter, &array_length, - NAN_MAX_MATCH_FILTER_LEN); - msg.tx_match_filter_len = array_length; - if (array_length > NAN_MAX_MATCH_FILTER_LEN) { - ALOGE("Length of tx filter info field larger than max allowed"); - return 0; - } - - helper.getByteArrayField(publish_config, "mRxFilter", - msg.rx_match_filter, &array_length, - NAN_MAX_MATCH_FILTER_LEN); - msg.rx_match_filter_len = array_length; - if (array_length > NAN_MAX_MATCH_FILTER_LEN) { - ALOGE("Length of rx filter info field larger than max allowed"); - return 0; + if (msg.publish_type == NAN_PUBLISH_TYPE_UNSOLICITED) { + helper.getByteArrayField(publish_config, "mMatchFilter", + msg.tx_match_filter, &array_length, + NAN_MAX_MATCH_FILTER_LEN); + msg.tx_match_filter_len = array_length; + if (array_length > NAN_MAX_MATCH_FILTER_LEN) { + ALOGE("Length of match filter info field larger than max allowed"); + return 0; + } + } else { + helper.getByteArrayField(publish_config, "mMatchFilter", + msg.rx_match_filter, &array_length, + NAN_MAX_MATCH_FILTER_LEN); + msg.rx_match_filter_len = array_length; + if (array_length > NAN_MAX_MATCH_FILTER_LEN) { + ALOGE("Length of match filter info field larger than max allowed"); + return 0; + } } - msg.publish_type = (NanPublishType)helper.getIntField(publish_config, "mPublishType"); msg.publish_count = helper.getIntField(publish_config, "mPublishCount"); msg.ttl = helper.getIntField(publish_config, "mTtlSec"); @@ -477,6 +479,7 @@ static jint android_net_wifi_nan_subscribe(JNIEnv *env, jclass cls, /* configurable settings */ msg.subscribe_id = subscribe_id; + msg.subscribe_type = (NanSubscribeType)helper.getIntField(subscribe_config, "mSubscribeType"); size_t array_length; helper.getByteArrayField(subscribe_config, "mServiceName", msg.service_name, @@ -496,25 +499,26 @@ static jint android_net_wifi_nan_subscribe(JNIEnv *env, jclass cls, return 0; } - helper.getByteArrayField(subscribe_config, "mTxFilter", - msg.tx_match_filter, &array_length, - NAN_MAX_MATCH_FILTER_LEN); - msg.tx_match_filter_len = array_length; - if (array_length > NAN_MAX_MATCH_FILTER_LEN) { - ALOGE("Length of tx filter field larger than max allowed"); - return 0; - } - - helper.getByteArrayField(subscribe_config, "mRxFilter", - msg.rx_match_filter, &array_length, - NAN_MAX_MATCH_FILTER_LEN); - msg.rx_match_filter_len = array_length; - if (array_length > NAN_MAX_MATCH_FILTER_LEN) { - ALOGE("Length of rx filter field larger than max allowed"); - return 0; + if (msg.subscribe_type == NAN_SUBSCRIBE_TYPE_ACTIVE) { + helper.getByteArrayField(subscribe_config, "mMatchFilter", + msg.tx_match_filter, &array_length, + NAN_MAX_MATCH_FILTER_LEN); + msg.tx_match_filter_len = array_length; + if (array_length > NAN_MAX_MATCH_FILTER_LEN) { + ALOGE("Length of match filter field larger than max allowed"); + return 0; + } + } else { + helper.getByteArrayField(subscribe_config, "mMatchFilter", + msg.rx_match_filter, &array_length, + NAN_MAX_MATCH_FILTER_LEN); + msg.rx_match_filter_len = array_length; + if (array_length > NAN_MAX_MATCH_FILTER_LEN) { + ALOGE("Length of match filter field larger than max allowed"); + return 0; + } } - msg.subscribe_type = (NanSubscribeType)helper.getIntField(subscribe_config, "mSubscribeType"); msg.subscribe_count = helper.getIntField(subscribe_config, "mSubscribeCount"); msg.ttl = helper.getIntField(subscribe_config, "mTtlSec"); msg.subscribe_match_indicator = (NanMatchAlg) helper.getIntField( -- cgit v1.2.3