void getLinkStats(void) { wifi_stats_result_handler handler; memset(&handler, 0, sizeof(handler)); handler.on_link_stats_results = &onLinkStatsResults; int result = wifi_get_link_stats(0, wlan0Handle, handler); if (result < 0) { printMsg("failed to get link statistics - %d\n", result); } else { printLinkStats(link_stat, trx_stat); } }
static jobject android_net_wifi_getLinkLayerStats (JNIEnv *env, jclass cls, jint iface) { wifi_stats_result_handler handler; memset(&handler, 0, sizeof(handler)); handler.on_link_stats_results = &onLinkStatsResults; wifi_interface_handle handle = getIfaceHandle(env, cls, iface); int result = wifi_get_link_stats(0, handle, handler); if (result < 0) { ALOGE("android_net_wifi_getLinkLayerStats: failed to get link statistics\n"); return NULL; } jobject wifiLinkLayerStats = createObject(env, "android/net/wifi/WifiLinkLayerStats"); if (wifiLinkLayerStats == NULL) { ALOGE("Error in allocating wifiLinkLayerStats"); return NULL; } setIntField(env, wifiLinkLayerStats, "beacon_rx", link_stat.beacon_rx); setIntField(env, wifiLinkLayerStats, "rssi_mgmt", link_stat.rssi_mgmt); setLongField(env, wifiLinkLayerStats, "rxmpdu_be", link_stat.ac[WIFI_AC_BE].rx_mpdu); setLongField(env, wifiLinkLayerStats, "rxmpdu_bk", link_stat.ac[WIFI_AC_BK].rx_mpdu); setLongField(env, wifiLinkLayerStats, "rxmpdu_vi", link_stat.ac[WIFI_AC_VI].rx_mpdu); setLongField(env, wifiLinkLayerStats, "rxmpdu_vo", link_stat.ac[WIFI_AC_VO].rx_mpdu); setLongField(env, wifiLinkLayerStats, "txmpdu_be", link_stat.ac[WIFI_AC_BE].tx_mpdu); setLongField(env, wifiLinkLayerStats, "txmpdu_bk", link_stat.ac[WIFI_AC_BK].tx_mpdu); setLongField(env, wifiLinkLayerStats, "txmpdu_vi", link_stat.ac[WIFI_AC_VI].tx_mpdu); setLongField(env, wifiLinkLayerStats, "txmpdu_vo", link_stat.ac[WIFI_AC_VO].tx_mpdu); setLongField(env, wifiLinkLayerStats, "lostmpdu_be", link_stat.ac[WIFI_AC_BE].mpdu_lost); setLongField(env, wifiLinkLayerStats, "lostmpdu_bk", link_stat.ac[WIFI_AC_BK].mpdu_lost); setLongField(env, wifiLinkLayerStats, "lostmpdu_vi", link_stat.ac[WIFI_AC_VI].mpdu_lost); setLongField(env, wifiLinkLayerStats, "lostmpdu_vo", link_stat.ac[WIFI_AC_VO].mpdu_lost); setLongField(env, wifiLinkLayerStats, "retries_be", link_stat.ac[WIFI_AC_BE].retries); setLongField(env, wifiLinkLayerStats, "retries_bk", link_stat.ac[WIFI_AC_BK].retries); setLongField(env, wifiLinkLayerStats, "retries_vi", link_stat.ac[WIFI_AC_VI].retries); setLongField(env, wifiLinkLayerStats, "retries_vo", link_stat.ac[WIFI_AC_VO].retries); setIntField(env, wifiLinkLayerStats, "on_time", radio_stat.on_time); setIntField(env, wifiLinkLayerStats, "tx_time", radio_stat.tx_time); setIntField(env, wifiLinkLayerStats, "rx_time", radio_stat.rx_time); setIntField(env, wifiLinkLayerStats, "on_time_scan", radio_stat.on_time_scan); return wifiLinkLayerStats; }