开发学院手机开发Android 开发 Android Wifi定位 阅读

Android Wifi定位

 2010-08-23 01:31:00 来源:WEB开发网   
核心提示:onUpdateAvailable(mWifiManager.getScanResults(), mNativeObject); 8 } 9 }Native函数onUpdateAvailable是在 wifi_data_provider_android.cc里实现的。1 JNINativeMethod AndroidW
onUpdateAvailable(mWifiManager.getScanResults(), mNativeObject); 8 } 9 }

Native函数onUpdateAvailable是在 wifi_data_provider_android.cc里实现的。

1 JNINativeMethod AndroidWifiDataProvider::native_methods_[] = { 2 {"onUpdateAvailable", 3 "(Ljava/util/List;J)V", 4 reinterpret_cast(AndroidWifiDataProvider::OnUpdateAvailable) 5 }, 6 }; 7 8 void AndroidWifiDataProvider::OnUpdateAvailable(JNIEnv* /* env */, 9 jclass /* cls */, 10 jobject wifi_data, 11 jlong self) { 12 assert(self); 13 AndroidWifiDataProvider *self_ptr = 14 reinterpret_cast(self); 15 WifiData new_wifi_data; 16 if (wifi_data) { 17 InitFromJava(wifi_data, &new_wifi_data); 18 } 19 // We notify regardless of whether new_wifi_data is empty 20 // or not. The arbitrator will decide what to do with an empty 21 // WifiData object. 22 self_ptr->NewWifiDataAvailable(&new_wifi_data); 23 } 24 25 void AndroidWifiDataProvider::NewWifiDataAvailable(WifiData* new_wifi_data) { 26 assert(supported_); 27 assert(new_wifi_data); 28 bool is_update_available = false; 29 data_mutex_.Lock(); 30 is_update_available = wifi_data_.DiffersSignificantly(*new_wifi_data); 31 wifi_data_ = *new_wifi_data; 32 // Avoid holding the mutex locked while notifying observers. 33 data_mutex_.Unlock(); 34 35 if (is_update_available) { 36 is_first_scan_complete_ = true; 37 NotifyListeners(); 38 } 39 40 #if USING_CCTESTS 41 // This is needed for running the WiFi test on the emulator. 42 // See wifi_data_provider_android.h for details. 43 if (!first_callback_made_ && wifi_data_.access_point_data.empty()) { 44 first_callback_made_ = true; 45 NotifyListeners(); 46 } 47 #endif 48 } 49 50 JNINativeMethod AndroidWifiDataProvider::native_methods_[] = {51 {"onUpdateAvailable",52 "(Ljava/util/List;J)V",53 reinterpret_cast(AndroidWifiDataProvider::OnUpdateAvailable)54 },55 };56 57 void AndroidWifiDataProvider::OnUpdateAvailable(JNIEnv* /* env */,58 jclass /* cls */,59 jobject wifi_data,60 jlong self) {61 assert(self);62

上一页  1 2 3 4 5 6 7  下一页

Tags:Android Wifi 定位

编辑录入:coldstar [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接