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