WEB开发网
开发学院手机开发Android 开发 Gears Android WIFI/基站定位源代码分析 阅读

Gears Android WIFI/基站定位源代码分析

 2010-03-18 16:11:00 来源:WEB开发网   
核心提示:data_mutex_.Unlock();if (cached_position) {assert(cached_position->IsGoodFix());// Record the position and update its timestamp.position_mutex_.Lock();positi

data_mutex_.Unlock();

if (cached_position) {

assert(cached_position->IsGoodFix());

// Record the position and update its timestamp.

position_mutex_.Lock();

position_ = *cached_position;

position_.timestamp = timestamp_;

position_mutex_.Unlock();

// Let listeners know that we now have a position available.

UpdateListeners();

return true;

}

如果找不到,再做实际的请求

return request_->MakeRequest(access_token,

radio_data_,

wifi_data_,

request_address_,

address_language_,

kBadLatLng, // We don't have a position to pass

kBadLatLng, // to the server.

timestamp_);

7.客户端协议包装

前面的request_是NetworkLocationRequest实例,先看MakeRequest的实现:

先对参数进行打包:

if (!FormRequestBody(host_name_, access_token, radio_data, wifi_data,

request_address, address_language, latitude, longitude,

is_reverse_geocode_, &post_body_)) {

return false;

}

通知负责收发的线程

thread_event_.Signal();

8.负责收发的线程

void NetworkLocationRequest::Run() {

while (true) {

thread_event_.Wait();

if (is_shutting_down_) {

break;

}

MakeRequestImpl();

}

}

void NetworkLocationRequest::MakeRequestImpl() {

WebCacheDB::PayloadInfo payload;

把打包好的数据通过HTTP请求,发送给服务器

scoped_refptr payload_data;

bool result = HttpPost(url_.c_str(),

false, // Not capturing, so follow redirects

NULL, // reason_header_value

HttpConstants::kMimeApplicationJson, // Content-Type

NULL, // mod_since_date

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

Tags:Gears Android WIFI

编辑录入:coldstar [复制链接] [打 印]
赞助商链接