Gears Android WIFI/基站定位源代码分析
2010-03-18 16:11:00 来源:WEB开发网NULL, // required_cookie
true, // disable_browser_cookies
post_body_.get(),
&payload,
&payload_data,
NULL, // was_redirected
NULL, // full_redirect_url
NULL); // error_message
MutexLock lock(&is_processing_response_mutex_);
// is_aborted_ may be true even if HttpPost succeeded.
if (is_aborted_) {
LOG(("NetworkLocationRequest::Run() : HttpPost request was cancelled. "));
return;
}
if (listener_) {
Position position;
std::string response_body;
if (result) {
// If HttpPost succeeded, payload_data is guaranteed to be non-NULL.
assert(payload_data.get());
if (!payload_data->Length() ||
!BlobToString(payload_data.get(), &response_body)) {
LOG(("NetworkLocationRequest::Run() : Failed to get response body. "));
}
}
解析出位置信息
std::string16 access_token;
GetLocationFromResponse(result, payload.status_code, response_body,
timestamp_, url_, is_reverse_geocode_,
&position, &access_token);
通知位置信息的监听者。
bool server_error =
!result || (payload.status_code >= 500 && payload.status_code < 600);
listener_->LocationResponseAvailable(position, server_error, access_token);
}
}
有人会问,请求是发哪个服务器的?当然是google了,缺省的URL是:
static const char16 *kDefaultLocationProviderUrl =
STRING16(L"https://www.google.com/loc/json");
回过头来,我们再总结一下:
1.WIFI和基站定位过程如下:
2.NetworkLocationProvider和NetworkLocationRequest各有一个线程来异步处理请求。
3.这里的NetworkLocationProvider与android中的NetworkLocationProvider并不是同一个东西,这里是给gears用的,要在android的google
更多精彩
赞助商链接