summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2016-04-06 20:07:29 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-04-06 20:07:30 +0000
commitc1be2851f1c54e6e047ac62d71c9feb7e8df1561 (patch)
tree2b8a5e2da3ba58bfcd3326a5ff792ea1940eb19e /service
parent1b36c74e3e037576522479ebb42b261020ccf76f (diff)
parentff866c96ff5456bb0741aecbc26a4b097e798ece (diff)
Merge "WifiNative: Ignore tx level stats on unsupported devices" into nyc-dev
Diffstat (limited to 'service')
-rw-r--r--service/jni/com_android_server_wifi_WifiNative.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/service/jni/com_android_server_wifi_WifiNative.cpp b/service/jni/com_android_server_wifi_WifiNative.cpp
index 40bd15bc3..20c5b70e9 100644
--- a/service/jni/com_android_server_wifi_WifiNative.cpp
+++ b/service/jni/com_android_server_wifi_WifiNative.cpp
@@ -945,6 +945,19 @@ static jboolean android_net_wifi_untrackSignificantWifiChange(
wifi_iface_stat link_stat;
wifi_radio_stat radio_stat; // L release has support for only one radio
u32 *tx_time_per_level_arr = 0;
+// Let's cache the supported feature set to avoid unnecessary HAL invocations.
+feature_set cached_feature_set = 0;
+
+bool isTxLevelStatsPresent(wifi_radio_stat *radio_stats) {
+ if (IS_SUPPORTED_FEATURE(WIFI_FEATURE_TX_TRANSMIT_POWER, cached_feature_set)) {
+ if(radio_stats->tx_time_per_levels != 0 && radio_stats->num_tx_levels > 0) {
+ return true;
+ } else {
+ ALOGE("Ignoring invalid tx_level info in radio_stats");
+ }
+ }
+ return false;
+}
void onLinkStatsResults(wifi_request_id id, wifi_iface_stat *iface_stat,
int num_radios, wifi_radio_stat *radio_stats)
@@ -957,8 +970,7 @@ void onLinkStatsResults(wifi_request_id id, wifi_iface_stat *iface_stat,
if (num_radios > 0 && radio_stats != 0) {
memcpy(&radio_stat, radio_stats, sizeof(wifi_radio_stat));
- if ((radio_stats->num_tx_levels > 0)
- && (radio_stats->num_tx_levels <= RADIO_STAT_MAX_TX_LEVELS)) {
+ if (isTxLevelStatsPresent(radio_stats)) {
// This realloc should be a no-op after the first allocation because for a given
// device, the number of power levels should not change.
u32 arr_size = sizeof(u32) * radio_stats->num_tx_levels;
@@ -966,6 +978,7 @@ void onLinkStatsResults(wifi_request_id id, wifi_iface_stat *iface_stat,
memcpy(tx_time_per_level_arr, radio_stats->tx_time_per_levels, arr_size);
radio_stat.tx_time_per_levels = tx_time_per_level_arr;
} else {
+ radio_stat.num_tx_levels = 0;
radio_stat.tx_time_per_levels = 0;
}
} else {
@@ -993,7 +1006,16 @@ static jobject android_net_wifi_getLinkLayerStats (JNIEnv *env, jclass cls, jint
memset(&handler, 0, sizeof(handler));
handler.on_link_stats_results = &onLinkStatsResults;
wifi_interface_handle handle = getIfaceHandle(helper, cls, iface);
- int result = hal_fn.wifi_get_link_stats(0, handle, handler);
+ int result;
+ // Cache the features supported by the device to determine if tx level stats are present or not
+ if (cached_feature_set == 0) {
+ result = hal_fn.wifi_get_supported_feature_set(handle, &cached_feature_set);
+ if (result != WIFI_SUCCESS) {
+ cached_feature_set = 0;
+ }
+ }
+
+ result = hal_fn.wifi_get_link_stats(0, handle, handler);
if (result < 0) {
ALOGE("android_net_wifi_getLinkLayerStats: failed to get link statistics\n");
return NULL;