diff options
author | Vinit Deshpande <vinitd@google.com> | 2015-08-05 22:41:14 -0700 |
---|---|---|
committer | Vinit Deshpande <vinitd@google.com> | 2015-08-05 23:26:32 -0700 |
commit | da515a82e79abdf603b290c9fed4d4198ca75519 (patch) | |
tree | abd701ab4c69c9edae55c47ebac7d6c546efd393 /service/jni | |
parent | 67eb298371b04d03c0140ccde890f2ecf7bf30c0 (diff) | |
download | android_frameworks_opt_net_wifi-da515a82e79abdf603b290c9fed4d4198ca75519.tar.gz android_frameworks_opt_net_wifi-da515a82e79abdf603b290c9fed4d4198ca75519.tar.bz2 android_frameworks_opt_net_wifi-da515a82e79abdf603b290c9fed4d4198ca75519.zip |
Fix RSSI monitoring code to the no-leaking standards
Change-Id: I4a0cb1eefb74a9775c10397a8abad15e594385f3
Diffstat (limited to 'service/jni')
-rw-r--r-- | service/jni/com_android_server_wifi_WifiNative.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/service/jni/com_android_server_wifi_WifiNative.cpp b/service/jni/com_android_server_wifi_WifiNative.cpp index aa5308d65..1cce0b687 100644 --- a/service/jni/com_android_server_wifi_WifiNative.cpp +++ b/service/jni/com_android_server_wifi_WifiNative.cpp @@ -2067,14 +2067,18 @@ static jboolean android_net_wifi_setSsidWhitelist( static jint android_net_wifi_start_sending_offloaded_packet(JNIEnv *env, jclass cls, jint iface, jint idx, jbyteArray srcMac, jbyteArray dstMac, jbyteArray pkt, jint period) { - wifi_interface_handle handle = getIfaceHandle(env, cls, iface); + JNIHelper helper(env); + wifi_interface_handle handle = getIfaceHandle(helper, cls, iface); ALOGD("Start packet offload [%d] = %p", idx, handle); wifi_error ret; wifi_request_id id = idx; - byte * pkt_data = (byte *)env->GetByteArrayElements(pkt, NULL); + + ScopedBytesRO pktBytes(env, pkt), srcMacBytes(env, srcMac), dstMacBytes(env, dstMac); + + byte * pkt_data = (byte*) pktBytes.get(); unsigned short pkt_len = env->GetArrayLength(pkt); - byte* src_mac_addr = (byte *)env->GetByteArrayElements(srcMac, NULL); - byte* dst_mac_addr = (byte *)env->GetByteArrayElements(dstMac, NULL); + byte* src_mac_addr = (byte*) srcMacBytes.get(); + byte* dst_mac_addr = (byte*) dstMacBytes.get(); int i; char macAddr[32]; sprintf(macAddr, "%0x:%0x:%0x:%0x:%0x:%0x", src_mac_addr[0], src_mac_addr[1], @@ -2098,7 +2102,8 @@ static jint android_net_wifi_start_sending_offloaded_packet(JNIEnv *env, jclass static jint android_net_wifi_stop_sending_offloaded_packet(JNIEnv *env, jclass cls, jint iface, jint idx) { int ret; - wifi_interface_handle handle = getIfaceHandle(env, cls, iface); + JNIHelper helper(env); + wifi_interface_handle handle = getIfaceHandle(helper, cls, iface); ALOGD("Stop packet offload [%d] = %p", idx, handle); ret = hal_fn.wifi_stop_sending_offloaded_packet(idx, handle); ALOGD("ret= %d\n", ret); @@ -2111,16 +2116,16 @@ static void onRssiThresholdbreached(wifi_request_id id, u8 *cur_bssid, s8 cur_rs ALOGD("BSSID %02x:%02x:%02x:%02x:%02x:%02x\n", cur_bssid[0], cur_bssid[1], cur_bssid[2], cur_bssid[3], cur_bssid[4], cur_bssid[5]); - JNIEnv *env = NULL; - mVM->AttachCurrentThread(&env, NULL); + JNIHelper helper(mVM); //ALOGD("onRssiThresholdbreached called, vm = %p, obj = %p, env = %p", mVM, mCls, env); - reportEvent(env, mCls, "onRssiThresholdBreached", "(IB)V", id, cur_rssi); + helper.reportEvent(mCls, "onRssiThresholdBreached", "(IB)V", id, cur_rssi); } static jint android_net_wifi_start_rssi_monitoring_native(JNIEnv *env, jclass cls, jint iface, jint idx, jbyte maxRssi, jbyte minRssi) { - wifi_interface_handle handle = getIfaceHandle(env, cls, iface); + JNIHelper helper(env); + wifi_interface_handle handle = getIfaceHandle(helper, cls, iface); ALOGD("Start Rssi monitoring = %p", handle); ALOGD("MinRssi %d MaxRssi %d", minRssi, maxRssi); wifi_error ret; @@ -2133,7 +2138,8 @@ static jint android_net_wifi_start_rssi_monitoring_native(JNIEnv *env, jclass cl static jint android_net_wifi_stop_rssi_monitoring_native(JNIEnv *env, jclass cls, jint iface, jint idx) { - wifi_interface_handle handle = getIfaceHandle(env, cls, iface); + JNIHelper helper(env); + wifi_interface_handle handle = getIfaceHandle(helper, cls, iface); ALOGD("Stop Rssi monitoring = %p", handle); wifi_error ret; wifi_request_id id = idx; |