1 /*
2 * Copyright (C) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #ifdef FEATURE_GEOCODE_SUPPORT
17 #include "geo_convert_service.h"
18 #include <file_ex.h>
19 #include <thread>
20 #include "ability_connect_callback_stub.h"
21 #include "ability_manager_client.h"
22 #include "geo_address.h"
23 #include "geo_convert_request.h"
24 #include "common_utils.h"
25 #include "location_config_manager.h"
26 #include "location_dumper.h"
27 #include "location_sa_load_manager.h"
28 #include "system_ability_definition.h"
29 #ifdef LOCATION_HICOLLIE_ENABLE
30 #include "xcollie/xcollie.h"
31 #include "xcollie/xcollie_define.h"
32 #endif
33
34 namespace OHOS {
35 namespace Location {
36 const bool REGISTER_RESULT = SystemAbility::MakeAndRegisterAbility(
37 GeoConvertService::GetInstance());
38 const uint32_t EVENT_SEND_GEOREQUEST = 0x0100;
39 const char* UNLOAD_GEOCONVERT_TASK = "geoconvert_sa_unload";
40 const int GEOCONVERT_CONNECT_TIME_OUT = 2;
41 const uint32_t EVENT_INTERVAL_UNITE = 1000;
42 const int UNLOAD_GEOCONVERT_DELAY_TIME = 10 * EVENT_INTERVAL_UNITE;
43 const int TIMEOUT_WATCHDOG = 60; // s
44
GetInstance()45 GeoConvertService* GeoConvertService::GetInstance()
46 {
47 static GeoConvertService data;
48 return &data;
49 }
50
GeoConvertService()51 GeoConvertService::GeoConvertService() : SystemAbility(LOCATION_GEO_CONVERT_SA_ID, true)
52 {
53 #ifndef TDD_CASES_ENABLED
54 geoConvertHandler_ =
55 std::make_shared<GeoConvertHandler>(AppExecFwk::EventRunner::Create(true, AppExecFwk::ThreadMode::FFRT));
56 #endif
57 LBSLOGI(GEO_CONVERT, "GeoConvertService constructed.");
58 }
59
~GeoConvertService()60 GeoConvertService::~GeoConvertService()
61 {
62 #ifndef TDD_CASES_ENABLED
63 if (geoConvertHandler_ != nullptr) {
64 geoConvertHandler_->RemoveTask(UNLOAD_GEOCONVERT_TASK);
65 }
66 #endif
67 conn_ = nullptr;
68 }
69
OnStart()70 void GeoConvertService::OnStart()
71 {
72 if (state_ == ServiceRunningState::STATE_RUNNING) {
73 LBSLOGI(GEO_CONVERT, "GeoConvertService has already started.");
74 return;
75 }
76 if (!Init()) {
77 LBSLOGE(GEO_CONVERT, "failed to init GeoConvertService");
78 OnStop();
79 return;
80 }
81 state_ = ServiceRunningState::STATE_RUNNING;
82 LBSLOGI(GEO_CONVERT, "GeoConvertService::OnStart start service success.");
83 }
84
OnStop()85 void GeoConvertService::OnStop()
86 {
87 state_ = ServiceRunningState::STATE_NOT_START;
88 registerToService_ = false;
89 if (conn_ != nullptr) {
90 AAFwk::AbilityManagerClient::GetInstance()->DisconnectAbility(conn_);
91 LBSLOGD(GEO_CONVERT, "GeoConvertService::OnStop and disconnect");
92 UnRegisterGeoServiceDeathRecipient();
93 SetServiceConnectState(ServiceConnectState::STATE_DISCONNECT);
94 conn_ = nullptr;
95 }
96 LBSLOGI(GEO_CONVERT, "GeoConvertService::OnStop service stopped.");
97 }
98
Init()99 bool GeoConvertService::Init()
100 {
101 if (!registerToService_) {
102 bool ret = Publish(AsObject());
103 if (!ret) {
104 LBSLOGE(GEO_CONVERT, "GeoConvertService::Init Publish failed!");
105 return false;
106 }
107 registerToService_ = true;
108 }
109 return true;
110 }
111
112 class AbilityConnection : public AAFwk::AbilityConnectionStub {
113 public:
OnAbilityConnectDone(const AppExecFwk::ElementName & element,const sptr<IRemoteObject> & remoteObject,int resultCode)114 void OnAbilityConnectDone(
115 const AppExecFwk::ElementName& element, const sptr<IRemoteObject>& remoteObject, int resultCode) override
116 {
117 std::string uri = element.GetURI();
118 LBSLOGD(GEO_CONVERT, "Connected uri is %{public}s, result is %{public}d.", uri.c_str(), resultCode);
119 if (resultCode != ERR_OK) {
120 return;
121 }
122 GeoConvertService::GetInstance()->NotifyConnected(remoteObject);
123 }
124
OnAbilityDisconnectDone(const AppExecFwk::ElementName & element,int)125 void OnAbilityDisconnectDone(const AppExecFwk::ElementName& element, int) override
126 {
127 std::string uri = element.GetURI();
128 LBSLOGD(GEO_CONVERT, "Disconnected uri is %{public}s.", uri.c_str());
129 GeoConvertService::GetInstance()->NotifyDisConnected();
130 }
131 };
132
ConnectService()133 bool GeoConvertService::ConnectService()
134 {
135 LBSLOGD(GEO_CONVERT, "start ConnectService");
136 AAFwk::Want connectionWant;
137 std::string serviceName;
138 bool result = LocationConfigManager::GetInstance()->GetGeocodeServiceName(serviceName);
139 if (!result || serviceName.empty()) {
140 LBSLOGE(GEO_CONVERT, "get service name failed!");
141 return false;
142 }
143 std::string abilityName;
144 bool res = LocationConfigManager::GetInstance()->GetGeocodeAbilityName(abilityName);
145 if (!res || abilityName.empty()) {
146 LBSLOGE(GEO_CONVERT, "get service name failed!");
147 return false;
148 }
149 connectionWant.SetElementName(serviceName, abilityName);
150 conn_ = sptr<AAFwk::IAbilityConnection>(new (std::nothrow) AbilityConnection());
151 if (conn_ == nullptr) {
152 LBSLOGE(GEO_CONVERT, "get connection failed!");
153 return false;
154 }
155 SetServiceConnectState(ServiceConnectState::STATE_CONNECTTING);
156 int32_t ret = AAFwk::AbilityManagerClient::GetInstance()->ConnectAbility(connectionWant, conn_, -1);
157 if (ret != ERR_OK) {
158 LBSLOGE(GEO_CONVERT, "Connect cloud service failed!");
159 return false;
160 }
161 std::unique_lock<std::mutex> uniqueLock(mutex_);
162 auto waitStatus =
163 connectCondition_.wait_for(uniqueLock,
164 std::chrono::seconds(GEOCONVERT_CONNECT_TIME_OUT), [this]() { return serviceProxy_ != nullptr; });
165 if (!waitStatus) {
166 LBSLOGE(GEO_CONVERT, "Connect cloudService timeout!");
167 SetServiceConnectState(ServiceConnectState::STATE_DISCONNECT);
168 return false;
169 }
170 SetServiceConnectState(ServiceConnectState::STATE_CONNECTTED);
171 RegisterGeoServiceDeathRecipient();
172 return true;
173 }
174
NotifyConnected(const sptr<IRemoteObject> & remoteObject)175 void GeoConvertService::NotifyConnected(const sptr<IRemoteObject>& remoteObject)
176 {
177 std::unique_lock<std::mutex> uniqueLock(mutex_);
178 serviceProxy_ = remoteObject;
179 connectCondition_.notify_all();
180 }
181
NotifyDisConnected()182 void GeoConvertService::NotifyDisConnected()
183 {
184 std::unique_lock<std::mutex> uniqueLock(mutex_);
185 serviceProxy_ = nullptr;
186 connectCondition_.notify_all();
187 }
188
IsGeoConvertAvailable(MessageParcel & reply)189 int GeoConvertService::IsGeoConvertAvailable(MessageParcel &reply)
190 {
191 std::string serviceName;
192 bool result = LocationConfigManager::GetInstance()->GetGeocodeServiceName(serviceName);
193 if (!result || serviceName.empty()) {
194 LBSLOGE(GEO_CONVERT, "get service name failed!");
195 reply.WriteInt32(ERRCODE_SUCCESS);
196 reply.WriteBool(false);
197 return ERRCODE_SUCCESS;
198 }
199 reply.WriteInt32(ERRCODE_SUCCESS);
200 if (!CommonUtils::CheckAppInstalled(serviceName)) { // app is not installed
201 reply.WriteBool(false);
202 } else {
203 reply.WriteBool(true);
204 }
205 return ERRCODE_SUCCESS;
206 }
207
CheckGeoConvertAvailable()208 bool GeoConvertService::CheckGeoConvertAvailable()
209 {
210 if (!IsConnect() && !IsConnecting()) {
211 std::string serviceName;
212 bool result = LocationConfigManager::GetInstance()->GetGeocodeServiceName(serviceName);
213 if (!result || serviceName.empty()) {
214 LBSLOGE(GEO_CONVERT, "get service name failed!");
215 return false;
216 }
217 if (!CommonUtils::CheckAppInstalled(serviceName)) { // app is not installed
218 LBSLOGE(GEO_CONVERT, "service is not available.");
219 return false;
220 }
221 std::string abilityName;
222 bool res = LocationConfigManager::GetInstance()->GetGeocodeAbilityName(abilityName);
223 if (!res || abilityName.empty()) {
224 LBSLOGE(GEO_CONVERT, "get ability name failed!");
225 return false;
226 }
227 }
228 return true;
229 }
230
GetAddressByCoordinate(MessageParcel & data,MessageParcel & reply)231 int GeoConvertService::GetAddressByCoordinate(MessageParcel &data, MessageParcel &reply)
232 {
233 if (mockEnabled_) {
234 ReportAddressMock(data, reply);
235 return ERRCODE_SUCCESS;
236 }
237 if (!CheckGeoConvertAvailable()) {
238 reply.WriteInt32(ERRCODE_REVERSE_GEOCODING_FAIL);
239 return ERRCODE_REVERSE_GEOCODING_FAIL;
240 }
241 GeoCodeType requestType = GeoCodeType::REQUEST_REVERSE_GEOCODE;
242 auto geoConvertRequest = GeoConvertRequest::Unmarshalling(data, requestType);
243 AppExecFwk::InnerEvent::Pointer event = AppExecFwk::InnerEvent::
244 Get(EVENT_SEND_GEOREQUEST, geoConvertRequest);
245 if (geoConvertHandler_ != nullptr) {
246 geoConvertHandler_->SendEvent(event);
247 }
248 return ERRCODE_SUCCESS;
249 }
250
ReportAddressMock(MessageParcel & data,MessageParcel & reply)251 void GeoConvertService::ReportAddressMock(MessageParcel &data, MessageParcel &reply)
252 {
253 int arraySize = 0;
254 std::vector<std::shared_ptr<GeoAddress>> array;
255 ReverseGeocodeRequest request;
256 request.locale = Str16ToStr8(data.ReadString16());
257 request.latitude = data.ReadDouble();
258 request.longitude = data.ReadDouble();
259 request.maxItems = data.ReadInt32();
260 std::unique_lock<std::mutex> lock(mockInfoMutex_, std::defer_lock);
261 lock.lock();
262 for (size_t i = 0; i < mockInfo_.size(); i++) {
263 std::shared_ptr<GeocodingMockInfo> info = mockInfo_[i];
264 if (!CommonUtils::DoubleEqual(request.latitude, info->GetLocation()->latitude) ||
265 !CommonUtils::DoubleEqual(request.longitude, info->GetLocation()->longitude)) {
266 continue;
267 }
268 arraySize++;
269 array.push_back(info->GetGeoAddressInfo());
270 }
271 lock.unlock();
272 reply.WriteInt32(ERRCODE_SUCCESS);
273 if (arraySize > 0) {
274 reply.WriteInt32(arraySize);
275 for (size_t i = 0; i < array.size(); i++) {
276 array[i]->Marshalling(reply);
277 }
278 } else {
279 reply.WriteInt32(0);
280 }
281 }
282
GetAddressByLocationName(MessageParcel & data,MessageParcel & reply)283 int GeoConvertService::GetAddressByLocationName(MessageParcel &data, MessageParcel &reply)
284 {
285 if (!CheckGeoConvertAvailable()) {
286 reply.WriteInt32(ERRCODE_GEOCODING_FAIL);
287 return ERRCODE_GEOCODING_FAIL;
288 }
289 GeoCodeType requestType = GeoCodeType::REQUEST_GEOCODE;
290 auto geoConvertRequest = GeoConvertRequest::Unmarshalling(data, requestType);
291 AppExecFwk::InnerEvent::Pointer event = AppExecFwk::InnerEvent::
292 Get(EVENT_SEND_GEOREQUEST, geoConvertRequest);
293 if (geoConvertHandler_ != nullptr) {
294 geoConvertHandler_->SendEvent(event);
295 }
296 return ERRCODE_SUCCESS;
297 }
298
GetService()299 bool GeoConvertService::GetService()
300 {
301 if (!IsConnect() && !IsConnecting()) {
302 std::string serviceName;
303 bool result = LocationConfigManager::GetInstance()->GetGeocodeServiceName(serviceName);
304 if (!result || serviceName.empty()) {
305 LBSLOGE(GEO_CONVERT, "get service name failed!");
306 return false;
307 }
308 if (!CommonUtils::CheckAppInstalled(serviceName)) { // app is not installed
309 LBSLOGE(GEO_CONVERT, "service is not available.");
310 return false;
311 } else if (!ConnectService()) {
312 return false;
313 }
314 }
315 return true;
316 }
317
IsConnect()318 bool GeoConvertService::IsConnect()
319 {
320 std::unique_lock<std::mutex> uniqueLock(mutex_);
321 return serviceProxy_ != nullptr &&
322 GetServiceConnectState() == ServiceConnectState::STATE_CONNECTTED;
323 }
324
EnableReverseGeocodingMock()325 bool GeoConvertService::EnableReverseGeocodingMock()
326 {
327 LBSLOGD(GEO_CONVERT, "EnableReverseGeocodingMock");
328 mockEnabled_ = true;
329 return true;
330 }
331
DisableReverseGeocodingMock()332 bool GeoConvertService::DisableReverseGeocodingMock()
333 {
334 LBSLOGD(GEO_CONVERT, "DisableReverseGeocodingMock");
335 mockEnabled_ = false;
336 return true;
337 }
338
SetReverseGeocodingMockInfo(std::vector<std::shared_ptr<GeocodingMockInfo>> & mockInfo)339 LocationErrCode GeoConvertService::SetReverseGeocodingMockInfo(
340 std::vector<std::shared_ptr<GeocodingMockInfo>>& mockInfo)
341 {
342 LBSLOGD(GEO_CONVERT, "SetReverseGeocodingMockInfo");
343 std::unique_lock<std::mutex> lock(mockInfoMutex_, std::defer_lock);
344 lock.lock();
345 mockInfo_.assign(mockInfo.begin(), mockInfo.end());
346 lock.unlock();
347 return ERRCODE_SUCCESS;
348 }
349
CancelIdleState()350 bool GeoConvertService::CancelIdleState()
351 {
352 SystemAbilityState state = GetAbilityState();
353 if (state != SystemAbilityState::IDLE) {
354 return true;
355 }
356 bool ret = CancelIdle();
357 if (!ret) {
358 LBSLOGE(GEO_CONVERT, "%{public}s cancel idle failed!", __func__);
359 return false;
360 }
361 return true;
362 }
363
UnloadGeoConvertSystemAbility()364 void GeoConvertService::UnloadGeoConvertSystemAbility()
365 {
366 if (geoConvertHandler_ == nullptr) {
367 LBSLOGE(GEO_CONVERT, "%{public}s geoConvertHandler_ is nullptr", __func__);
368 return;
369 }
370 geoConvertHandler_->RemoveTask(UNLOAD_GEOCONVERT_TASK);
371 auto task = [this]() {
372 if (CheckIfGeoConvertConnecting()) {
373 return;
374 }
375 SaLoadWithStatistic::UnInitLocationSa(LOCATION_GEO_CONVERT_SA_ID);
376 GeoConvertService::GetInstance()->DisconnectAbilityConnect();
377 };
378 geoConvertHandler_->PostTask(task, UNLOAD_GEOCONVERT_TASK, UNLOAD_GEOCONVERT_DELAY_TIME);
379 }
380
DisconnectAbilityConnect()381 void GeoConvertService::DisconnectAbilityConnect()
382 {
383 if (conn_ != nullptr) {
384 UnRegisterGeoServiceDeathRecipient();
385 AAFwk::AbilityManagerClient::GetInstance()->DisconnectAbility(conn_);
386 SetServiceConnectState(ServiceConnectState::STATE_DISCONNECT);
387 conn_ = nullptr;
388 LBSLOGI(GEO_CONVERT, "UnloadGeoConvert OnStop and disconnect");
389 }
390 }
391
CheckIfGeoConvertConnecting()392 bool GeoConvertService::CheckIfGeoConvertConnecting()
393 {
394 return mockEnabled_;
395 }
396
SaDumpInfo(std::string & result)397 void GeoConvertService::SaDumpInfo(std::string& result)
398 {
399 result += "GeoConvert enable status: false";
400 result += "\n";
401 }
402
Dump(int32_t fd,const std::vector<std::u16string> & args)403 int32_t GeoConvertService::Dump(int32_t fd, const std::vector<std::u16string>& args)
404 {
405 std::vector<std::string> vecArgs;
406 std::transform(args.begin(), args.end(), std::back_inserter(vecArgs), [](const std::u16string &arg) {
407 return Str16ToStr8(arg);
408 });
409
410 LocationDumper dumper;
411 std::string result;
412 dumper.GeocodeDump(SaDumpInfo, vecArgs, result);
413 if (!SaveStringToFd(fd, result)) {
414 LBSLOGE(GEO_CONVERT, "Geocode save string to fd failed!");
415 return ERR_OK;
416 }
417 return ERR_OK;
418 }
419
ResetServiceProxy()420 bool GeoConvertService::ResetServiceProxy()
421 {
422 std::unique_lock<std::mutex> uniqueLock(mutex_);
423 serviceProxy_ = nullptr;
424 return true;
425 }
426
RegisterGeoServiceDeathRecipient()427 void GeoConvertService::RegisterGeoServiceDeathRecipient()
428 {
429 if (serviceProxy_ == nullptr) {
430 LBSLOGE(GEO_CONVERT, "%{public}s: geoServiceProxy_ is nullptr", __func__);
431 return;
432 }
433 if (geoServiceRecipient_ != nullptr) {
434 serviceProxy_->AddDeathRecipient(geoServiceRecipient_);
435 }
436 }
437
UnRegisterGeoServiceDeathRecipient()438 void GeoConvertService::UnRegisterGeoServiceDeathRecipient()
439 {
440 std::unique_lock<std::mutex> uniqueLock(mutex_);
441 if (serviceProxy_ == nullptr) {
442 LBSLOGE(GEO_CONVERT, "%{public}s: geoServiceProxy_ is nullptr", __func__);
443 return;
444 }
445 if (geoServiceRecipient_ != nullptr) {
446 serviceProxy_->RemoveDeathRecipient(geoServiceRecipient_);
447 geoServiceRecipient_ = nullptr;
448 }
449 }
450
SendGeocodeRequest(int code,MessageParcel & dataParcel,MessageParcel & replyParcel,MessageOption & option)451 bool GeoConvertService::SendGeocodeRequest(int code, MessageParcel& dataParcel, MessageParcel& replyParcel,
452 MessageOption& option)
453 {
454 if (!GetService()) {
455 LBSLOGE(GEO_CONVERT, "GetService error!");
456 return false;
457 }
458 std::unique_lock<std::mutex> uniqueLock(mutex_);
459 if (serviceProxy_ == nullptr) {
460 LBSLOGE(GEO_CONVERT, "serviceProxy is nullptr!");
461 return false;
462 }
463 MessageParcel data;
464 data.WriteInterfaceToken(serviceProxy_->GetInterfaceDescriptor());
465 data.Append(dataParcel);
466 int error = serviceProxy_->SendRequest(code, data, replyParcel, option);
467 if (error != ERR_OK) {
468 LBSLOGE(GEO_CONVERT, "SendRequest to cloud service failed. error = %{public}d", error);
469 return false;
470 }
471 return true;
472 }
473
GetServiceConnectState()474 ServiceConnectState GeoConvertService::GetServiceConnectState()
475 {
476 std::unique_lock<std::mutex> uniqueLock(connectStateMutex_);
477 return connectState_;
478 }
479
SetServiceConnectState(ServiceConnectState connectState)480 void GeoConvertService::SetServiceConnectState(ServiceConnectState connectState)
481 {
482 std::unique_lock<std::mutex> uniqueLock(connectStateMutex_);
483 connectState_ = connectState;
484 }
485
IsConnecting()486 bool GeoConvertService::IsConnecting()
487 {
488 std::unique_lock<std::mutex> uniqueLock(connectStateMutex_);
489 return connectState_ == ServiceConnectState::STATE_CONNECTTING;
490 }
491
GeoServiceDeathRecipient()492 GeoServiceDeathRecipient::GeoServiceDeathRecipient()
493 {
494 }
495
~GeoServiceDeathRecipient()496 GeoServiceDeathRecipient::~GeoServiceDeathRecipient()
497 {
498 }
499
OnRemoteDied(const wptr<IRemoteObject> & remote)500 void GeoServiceDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote)
501 {
502 auto geoConvertService = GeoConvertService::GetInstance();
503 if (geoConvertService != nullptr) {
504 LBSLOGI(GEO_CONVERT, "geo OnRemoteDied");
505 geoConvertService->ResetServiceProxy();
506 geoConvertService->SetServiceConnectState(ServiceConnectState::STATE_DISCONNECT);
507 }
508 }
509
GeoConvertHandler(const std::shared_ptr<AppExecFwk::EventRunner> & runner)510 GeoConvertHandler::GeoConvertHandler(const std::shared_ptr<AppExecFwk::EventRunner>& runner) : EventHandler(runner)
511 {
512 InitGeoConvertHandlerEventMap();
513 }
514
~GeoConvertHandler()515 GeoConvertHandler::~GeoConvertHandler() {}
516
InitGeoConvertHandlerEventMap()517 void GeoConvertHandler::InitGeoConvertHandlerEventMap()
518 {
519 if (geoConvertHandlerEventMap_.size() != 0) {
520 return;
521 }
522 geoConvertHandlerEventMap_[EVENT_SEND_GEOREQUEST] =
523 [this](const AppExecFwk::InnerEvent::Pointer& event) { SendGeocodeRequest(event); };
524 }
525
ProcessEvent(const AppExecFwk::InnerEvent::Pointer & event)526 void GeoConvertHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer& event)
527 {
528 uint32_t eventId = event->GetInnerEventId();
529 LBSLOGD(GEO_CONVERT, "ProcessEvent event:%{public}d", eventId);
530 auto handleFunc = geoConvertHandlerEventMap_.find(eventId);
531 if (handleFunc != geoConvertHandlerEventMap_.end() && handleFunc->second != nullptr) {
532 auto memberFunc = handleFunc->second;
533 #ifdef LOCATION_HICOLLIE_ENABLE
534 int tid = gettid();
535 std::string moduleName = "GeoConvertHandler";
536 XCollieCallback callbackFunc = [moduleName, eventId, tid](void *) {
537 LBSLOGE(GEO_CONVERT,
538 "TimeoutCallback tid:%{public}d moduleName:%{public}s excute eventId:%{public}u timeout.",
539 tid, moduleName.c_str(), eventId);
540 };
541 std::string dfxInfo = moduleName + "_" + std::to_string(eventId) + "_" + std::to_string(tid);
542 int timerId = HiviewDFX::XCollie::GetInstance().SetTimer(dfxInfo, TIMEOUT_WATCHDOG, callbackFunc, nullptr,
543 HiviewDFX::XCOLLIE_FLAG_LOG|HiviewDFX::XCOLLIE_FLAG_RECOVERY);
544 memberFunc(event);
545 HiviewDFX::XCollie::GetInstance().CancelTimer(timerId);
546 #else
547 memberFunc(event);
548 #endif
549 } else {
550 LBSLOGE(GEO_CONVERT, "ProcessEvent event:%{public}d, unsupport service.", eventId);
551 }
552 }
553
SendGeocodeRequest(const AppExecFwk::InnerEvent::Pointer & event)554 void GeoConvertHandler::SendGeocodeRequest(const AppExecFwk::InnerEvent::Pointer& event)
555 {
556 std::unique_ptr<GeoConvertRequest> geoConvertRequest = event->GetUniqueObject<GeoConvertRequest>();
557 if (geoConvertRequest == nullptr) {
558 return;
559 }
560 auto geoConvertService = GeoConvertService::GetInstance();
561 MessageParcel dataParcel;
562 MessageParcel replyParcel;
563 MessageOption option;
564 geoConvertRequest->Marshalling(dataParcel);
565 bool ret = geoConvertService->SendGeocodeRequest(static_cast<int>(geoConvertRequest->GetRequestType()),
566 dataParcel, replyParcel, option);
567 if (!ret) {
568 LBSLOGE(GEO_CONVERT, "SendGeocodeRequest failed errcode");
569 }
570 }
571
572 } // namespace Location
573 } // namespace OHOS
574 #endif
575