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_GNSS_SUPPORT
17 #include "gnss_ability_skeleton.h"
18 
19 #include "ipc_skeleton.h"
20 
21 #include "common_utils.h"
22 #include "constant_definition.h"
23 #include "gnss_ability.h"
24 #include "locationhub_ipc_interface_code.h"
25 #include "permission_manager.h"
26 #include "want_agent_helper.h"
27 
28 namespace OHOS {
29 namespace Location {
InitGnssMsgHandleMap()30 void GnssAbilityStub::InitGnssMsgHandleMap()
31 {
32     if (GnssMsgHandleMap_.size() != 0) {
33         return;
34     }
35     GnssMsgHandleMap_[static_cast<uint32_t>(GnssInterfaceCode::SEND_LOCATION_REQUEST)] =
36         [this](MessageParcel &data, MessageParcel &reply, AppIdentity &identity) {
37         return SendLocationRequestInner(data, reply, identity);
38         };
39     GnssMsgHandleMap_[static_cast<uint32_t>(GnssInterfaceCode::SET_ENABLE)] =
40         [this](MessageParcel &data, MessageParcel &reply, AppIdentity &identity) {
41         return SetEnableInner(data, reply, identity);
42         };
43     GnssMsgHandleMap_[static_cast<uint32_t>(GnssInterfaceCode::REFRESH_REQUESTS)] =
44         [this](MessageParcel &data, MessageParcel &reply, AppIdentity &identity) {
45         return RefreshRequirementsInner(data, reply, identity);
46     };
47     GnssMsgHandleMap_[static_cast<uint32_t>(GnssInterfaceCode::REG_GNSS_STATUS)] =
48         [this](MessageParcel &data, MessageParcel &reply, AppIdentity &identity) {
49         return RegisterGnssStatusCallbackInner(data, reply, identity);
50         };
51     GnssMsgHandleMap_[static_cast<uint32_t>(GnssInterfaceCode::UNREG_GNSS_STATUS)] =
52         [this](MessageParcel &data, MessageParcel &reply, AppIdentity &identity) {
53         return UnregisterGnssStatusCallbackInner(data, reply, identity);
54         };
55     GnssMsgHandleMap_[static_cast<uint32_t>(GnssInterfaceCode::REG_NMEA)] =
56         [this](MessageParcel &data, MessageParcel &reply, AppIdentity &identity) {
57         return RegisterNmeaMessageCallbackInner(data, reply, identity);
58         };
59     GnssMsgHandleMap_[static_cast<uint32_t>(GnssInterfaceCode::UNREG_NMEA)] =
60         [this](MessageParcel &data, MessageParcel &reply, AppIdentity &identity) {
61         return UnregisterNmeaMessageCallbackInner(data, reply, identity);
62         };
63     GnssMsgHandleMap_[static_cast<uint32_t>(GnssInterfaceCode::REG_CACHED)] =
64         [this](MessageParcel &data, MessageParcel &reply, AppIdentity &identity) {
65         return RegisterCachedCallbackInner(data, reply, identity);
66         };
67     GnssMsgHandleMap_[static_cast<uint32_t>(GnssInterfaceCode::UNREG_CACHED)] =
68         [this](MessageParcel &data, MessageParcel &reply, AppIdentity &identity) {
69         return UnregisterCachedCallbackInner(data, reply, identity);
70         };
71     GnssMsgHandleMap_[static_cast<uint32_t>(GnssInterfaceCode::GET_CACHED_SIZE)] =
72         [this](MessageParcel &data, MessageParcel &reply, AppIdentity &identity) {
73         return GetCachedGnssLocationsSizeInner(data, reply, identity);
74         };
75     GnssMsgHandleMap_[static_cast<uint32_t>(GnssInterfaceCode::FLUSH_CACHED)] =
76         [this](MessageParcel &data, MessageParcel &reply, AppIdentity &identity) {
77         return FlushCachedGnssLocationsInner(data, reply, identity);
78         };
79 }
80 
InitGnssEnhanceMsgHandleMap()81 void GnssAbilityStub::InitGnssEnhanceMsgHandleMap()
82 {
83     GnssMsgHandleMap_[static_cast<uint32_t>(GnssInterfaceCode::SEND_COMMANDS)] =
84         [this](MessageParcel &data, MessageParcel &reply, AppIdentity &identity) {
85         return SendCommandInner(data, reply, identity);
86         };
87     GnssMsgHandleMap_[static_cast<uint32_t>(GnssInterfaceCode::SET_MOCKED_LOCATIONS)] =
88         [this](MessageParcel &data, MessageParcel &reply, AppIdentity &identity) {
89         return SetMockLocationsInner(data, reply, identity);
90         };
91     GnssMsgHandleMap_[static_cast<uint32_t>(GnssInterfaceCode::ENABLE_LOCATION_MOCK)] =
92         [this](MessageParcel &data, MessageParcel &reply, AppIdentity &identity) {
93         return EnableMockInner(data, reply, identity);
94         };
95     GnssMsgHandleMap_[static_cast<uint32_t>(GnssInterfaceCode::DISABLE_LOCATION_MOCK)] =
96         [this](MessageParcel &data, MessageParcel &reply, AppIdentity &identity) {
97         return DisableMockInner(data, reply, identity);
98         };
99     GnssMsgHandleMap_[static_cast<uint32_t>(GnssInterfaceCode::ADD_FENCE_INFO)] =
100         [this](MessageParcel &data, MessageParcel &reply, AppIdentity &identity) {
101         return AddFenceInner(data, reply, identity);
102         };
103     GnssMsgHandleMap_[static_cast<uint32_t>(GnssInterfaceCode::REMOVE_FENCE_INFO)] =
104         [this](MessageParcel &data, MessageParcel &reply, AppIdentity &identity) {
105         return RemoveFenceInner(data, reply, identity);
106         };
107     GnssMsgHandleMap_[static_cast<uint32_t>(GnssInterfaceCode::ADD_GNSS_GEOFENCE)] =
108         [this](MessageParcel &data, MessageParcel &reply, AppIdentity &identity) {
109         return AddGnssGeofenceInner(data, reply, identity);
110         };
111     GnssMsgHandleMap_[static_cast<uint32_t>(GnssInterfaceCode::REMOVE_GNSS_GEOFENCE)] =
112         [this](MessageParcel &data, MessageParcel &reply, AppIdentity &identity) {
113         return RemoveGnssGeofenceInner(data, reply, identity);
114         };
115     GnssMsgHandleMap_[static_cast<uint32_t>(GnssInterfaceCode::GET_GEOFENCE_SUPPORT_COORDINATE_SYSTEM_TYPE)] =
116         [this](MessageParcel &data, MessageParcel &reply, AppIdentity &identity) {
117         return QuerySupportCoordinateSystemTypeInner(data, reply, identity);
118         };
119     GnssMsgHandleMap_[static_cast<uint32_t>(GnssInterfaceCode::SEND_NETWORK_LOCATION)] =
120         [this](MessageParcel &data, MessageParcel &reply, AppIdentity &identity) {
121         return SendNetworkLocationInner(data, reply, identity);
122         };
123 }
124 
GnssAbilityStub()125 GnssAbilityStub::GnssAbilityStub()
126 {
127     InitGnssMsgHandleMap();
128     InitGnssEnhanceMsgHandleMap();
129 }
130 
SendLocationRequestInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)131 int GnssAbilityStub::SendLocationRequestInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
132 {
133     if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
134         return ERRCODE_PERMISSION_DENIED;
135     }
136     SendMessage(static_cast<uint32_t>(GnssInterfaceCode::SEND_LOCATION_REQUEST), data, reply);
137     isMessageRequest_ = true;
138     return ERRCODE_SUCCESS;
139 }
140 
SetMockLocationsInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)141 int GnssAbilityStub::SetMockLocationsInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
142 {
143     if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
144         return ERRCODE_PERMISSION_DENIED;
145     }
146     SendMessage(static_cast<uint32_t>(GnssInterfaceCode::SET_MOCKED_LOCATIONS), data, reply);
147     isMessageRequest_ = true;
148     return ERRCODE_SUCCESS;
149 }
150 
SetEnableInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)151 int GnssAbilityStub::SetEnableInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
152 {
153     if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
154         return ERRCODE_PERMISSION_DENIED;
155     }
156     SendMessage(static_cast<uint32_t>(GnssInterfaceCode::SET_ENABLE), data, reply);
157     isMessageRequest_ = true;
158     return ERRCODE_SUCCESS;
159 }
160 
RefreshRequirementsInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)161 int GnssAbilityStub::RefreshRequirementsInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
162 {
163     if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
164         return ERRCODE_PERMISSION_DENIED;
165     }
166     reply.WriteInt32(RefrashRequirements());
167     return ERRCODE_SUCCESS;
168 }
169 
RegisterGnssStatusCallbackInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)170 int GnssAbilityStub::RegisterGnssStatusCallbackInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
171 {
172     if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
173         return ERRCODE_PERMISSION_DENIED;
174     }
175     AppIdentity appIdentity;
176     appIdentity.ReadFromParcel(data);
177     sptr<IRemoteObject> client = data.ReadObject<IRemoteObject>();
178     reply.WriteInt32(RegisterGnssStatusCallback(client, appIdentity));
179     return ERRCODE_SUCCESS;
180 }
181 
UnregisterGnssStatusCallbackInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)182 int GnssAbilityStub::UnregisterGnssStatusCallbackInner(
183     MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
184 {
185     if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
186         return ERRCODE_PERMISSION_DENIED;
187     }
188     sptr<IRemoteObject> client = data.ReadObject<IRemoteObject>();
189     reply.WriteInt32(UnregisterGnssStatusCallback(client));
190     return ERRCODE_SUCCESS;
191 }
192 
RegisterNmeaMessageCallbackInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)193 int GnssAbilityStub::RegisterNmeaMessageCallbackInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
194 {
195     if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
196         return ERRCODE_PERMISSION_DENIED;
197     }
198     AppIdentity appIdentity;
199     appIdentity.ReadFromParcel(data);
200     sptr<IRemoteObject> client = data.ReadObject<IRemoteObject>();
201     reply.WriteInt32(RegisterNmeaMessageCallback(client, appIdentity));
202     return ERRCODE_SUCCESS;
203 }
204 
UnregisterNmeaMessageCallbackInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)205 int GnssAbilityStub::UnregisterNmeaMessageCallbackInner(MessageParcel &data, MessageParcel &reply,
206     AppIdentity &identity)
207 {
208     if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
209         return ERRCODE_PERMISSION_DENIED;
210     }
211     sptr<IRemoteObject> client = data.ReadObject<IRemoteObject>();
212     reply.WriteInt32(UnregisterNmeaMessageCallback(client));
213     return ERRCODE_SUCCESS;
214 }
215 
RegisterCachedCallbackInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)216 int GnssAbilityStub::RegisterCachedCallbackInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
217 {
218     if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
219         return ERRCODE_PERMISSION_DENIED;
220     }
221     std::unique_ptr<CachedGnssLocationsRequest> requestConfig = std::make_unique<CachedGnssLocationsRequest>();
222     requestConfig->reportingPeriodSec = data.ReadInt32();
223     requestConfig->wakeUpCacheQueueFull = data.ReadBool();
224     sptr<IRemoteObject> callback = data.ReadObject<IRemoteObject>();
225     reply.WriteInt32(RegisterCachedCallback(requestConfig, callback));
226     return ERRCODE_SUCCESS;
227 }
228 
UnregisterCachedCallbackInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)229 int GnssAbilityStub::UnregisterCachedCallbackInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
230 {
231     if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
232         return ERRCODE_PERMISSION_DENIED;
233     }
234     sptr<IRemoteObject> callback = data.ReadObject<IRemoteObject>();
235     reply.WriteInt32(UnregisterCachedCallback(callback));
236     return ERRCODE_SUCCESS;
237 }
238 
GetCachedGnssLocationsSizeInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)239 int GnssAbilityStub::GetCachedGnssLocationsSizeInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
240 {
241     if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
242         return ERRCODE_PERMISSION_DENIED;
243     }
244     int size = -1;
245     reply.WriteInt32(GetCachedGnssLocationsSize(size));
246     reply.WriteInt32(size);
247     return ERRCODE_SUCCESS;
248 }
249 
FlushCachedGnssLocationsInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)250 int GnssAbilityStub::FlushCachedGnssLocationsInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
251 {
252     if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
253         return ERRCODE_PERMISSION_DENIED;
254     }
255     reply.WriteInt32(FlushCachedGnssLocations());
256     return ERRCODE_SUCCESS;
257 }
258 
SendCommandInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)259 int GnssAbilityStub::SendCommandInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
260 {
261     if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
262         return ERRCODE_PERMISSION_DENIED;
263     }
264     SendMessage(static_cast<uint32_t>(GnssInterfaceCode::SEND_COMMANDS), data, reply);
265     isMessageRequest_ = true;
266     return ERRCODE_SUCCESS;
267 }
268 
EnableMockInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)269 int GnssAbilityStub::EnableMockInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
270 {
271     if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
272         return ERRCODE_PERMISSION_DENIED;
273     }
274     reply.WriteInt32(EnableMock());
275     return ERRCODE_SUCCESS;
276 }
277 
DisableMockInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)278 int GnssAbilityStub::DisableMockInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
279 {
280     if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
281         return ERRCODE_PERMISSION_DENIED;
282     }
283     reply.WriteInt32(DisableMock());
284     return ERRCODE_SUCCESS;
285 }
286 
AddFenceInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)287 int GnssAbilityStub::AddFenceInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
288 {
289     if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
290         return ERRCODE_PERMISSION_DENIED;
291     }
292     SendMessage(static_cast<uint32_t>(GnssAbilityInterfaceCode::ADD_FENCE), data, reply);
293     isMessageRequest_ = true;
294     return ERRCODE_SUCCESS;
295 }
296 
RemoveFenceInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)297 int GnssAbilityStub::RemoveFenceInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
298 {
299     if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
300         return ERRCODE_PERMISSION_DENIED;
301     }
302     SendMessage(static_cast<uint32_t>(GnssAbilityInterfaceCode::REMOVE_FENCE), data, reply);
303     isMessageRequest_ = true;
304     return ERRCODE_SUCCESS;
305 }
306 
AddGnssGeofenceInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)307 int GnssAbilityStub::AddGnssGeofenceInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
308 {
309     if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
310         return ERRCODE_PERMISSION_DENIED;
311     }
312     SendMessage(static_cast<uint32_t>(GnssAbilityInterfaceCode::ADD_GEOFENCE), data, reply);
313     isMessageRequest_ = true;
314     return ERRCODE_SUCCESS;
315 }
316 
RemoveGnssGeofenceInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)317 int GnssAbilityStub::RemoveGnssGeofenceInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
318 {
319     if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
320         return ERRCODE_PERMISSION_DENIED;
321     }
322     SendMessage(static_cast<uint32_t>(GnssAbilityInterfaceCode::REMOVE_GEOFENCE), data, reply);
323     isMessageRequest_ = true;
324     return ERRCODE_SUCCESS;
325 }
326 
QuerySupportCoordinateSystemTypeInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)327 int GnssAbilityStub::QuerySupportCoordinateSystemTypeInner(
328     MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
329 {
330     if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
331         return ERRCODE_PERMISSION_DENIED;
332     }
333     std::vector<CoordinateSystemType> coordinateSystemTypes;
334     auto errCode = QuerySupportCoordinateSystemType(coordinateSystemTypes);
335     reply.WriteInt32(errCode);
336     if (errCode != ERRCODE_SUCCESS) {
337         return errCode;
338     }
339     int size = static_cast<int>(coordinateSystemTypes.size()) > COORDINATE_SYSTEM_TYPE_SIZE ?
340         COORDINATE_SYSTEM_TYPE_SIZE : static_cast<int>(coordinateSystemTypes.size());
341     reply.WriteInt32(size);
342     for (int i = 0; i < size; i++) {
343         reply.WriteInt32(static_cast<int>(coordinateSystemTypes[i]));
344     }
345     return ERRCODE_SUCCESS;
346 }
347 
SendNetworkLocationInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)348 int GnssAbilityStub::SendNetworkLocationInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
349 {
350     LBSLOGI(GNSS, "SendNetworkLocationInner");
351     if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
352         return ERRCODE_PERMISSION_DENIED;
353     }
354     SendMessage(static_cast<uint32_t>(GnssInterfaceCode::SEND_NETWORK_LOCATION), data, reply);
355     isMessageRequest_ = true;
356     return ERRCODE_SUCCESS;
357 }
358 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)359 int GnssAbilityStub::OnRemoteRequest(uint32_t code,
360     MessageParcel &data, MessageParcel &reply, MessageOption &option)
361 {
362     pid_t callingPid = IPCSkeleton::GetCallingPid();
363     pid_t callingUid = IPCSkeleton::GetCallingUid();
364     AppIdentity identity;
365     identity.SetPid(callingPid);
366     identity.SetUid(callingUid);
367     std::string currentTime = std::to_string(CommonUtils::GetCurrentTimeStamp());
368     LBSLOGI(GNSS, "%{public}s cmd = %{public}u, flags= %{public}d, identity = %{public}s, timestamp = %{public}s",
369         __func__, code, option.GetFlags(), identity.ToString().c_str(), currentTime.c_str());
370 
371     if (data.ReadInterfaceToken() != GetDescriptor()) {
372         LBSLOGE(GNSS, "invalid token.");
373         return ERRCODE_SERVICE_UNAVAILABLE;
374     }
375     CancelIdleState();
376     int ret = ERRCODE_SUCCESS;
377     isMessageRequest_ = false;
378     auto handleFunc = GnssMsgHandleMap_.find(code);
379     if (handleFunc != GnssMsgHandleMap_.end() && handleFunc->second != nullptr) {
380         auto memberFunc = handleFunc->second;
381         ret = memberFunc(data, reply, identity);
382     } else {
383         LBSLOGE(GNSS, "OnReceived cmd = %{public}u, unsupport service.", code);
384         ret = IPCObjectStub::OnRemoteRequest(code, data, reply, option);
385     }
386     if (!isMessageRequest_) {
387         UnloadGnssSystemAbility();
388     }
389     return ret;
390 }
391 
GnssStatusCallbackDeathRecipient()392 GnssStatusCallbackDeathRecipient::GnssStatusCallbackDeathRecipient()
393 {
394 }
395 
~GnssStatusCallbackDeathRecipient()396 GnssStatusCallbackDeathRecipient::~GnssStatusCallbackDeathRecipient()
397 {
398 }
399 
OnRemoteDied(const wptr<IRemoteObject> & remote)400 void GnssStatusCallbackDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote)
401 {
402     auto gnssAbility = GnssAbility::GetInstance();
403     if (gnssAbility != nullptr) {
404         gnssAbility->UnregisterGnssStatusCallback(remote.promote());
405         gnssAbility->UnloadGnssSystemAbility();
406         LBSLOGI(LOCATOR, "gnss status callback OnRemoteDied");
407     }
408 }
409 
NmeaCallbackDeathRecipient()410 NmeaCallbackDeathRecipient::NmeaCallbackDeathRecipient()
411 {
412 }
413 
~NmeaCallbackDeathRecipient()414 NmeaCallbackDeathRecipient::~NmeaCallbackDeathRecipient()
415 {
416 }
417 
OnRemoteDied(const wptr<IRemoteObject> & remote)418 void NmeaCallbackDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote)
419 {
420     auto gnssAbility = GnssAbility::GetInstance();
421     if (gnssAbility != nullptr) {
422         gnssAbility->UnregisterNmeaMessageCallback(remote.promote());
423         gnssAbility->UnloadGnssSystemAbility();
424         LBSLOGI(LOCATOR, "nmea callback OnRemoteDied");
425     }
426 }
427 
CachedLocationCallbackDeathRecipient()428 CachedLocationCallbackDeathRecipient::CachedLocationCallbackDeathRecipient()
429 {
430 }
431 
~CachedLocationCallbackDeathRecipient()432 CachedLocationCallbackDeathRecipient::~CachedLocationCallbackDeathRecipient()
433 {
434 }
435 
OnRemoteDied(const wptr<IRemoteObject> & remote)436 void CachedLocationCallbackDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote)
437 {
438     auto gnssAbility = GnssAbility::GetInstance();
439     if (gnssAbility != nullptr) {
440         gnssAbility->UnregisterCachedCallback(remote.promote());
441         gnssAbility->UnloadGnssSystemAbility();
442         LBSLOGI(LOCATOR, "cached location callback OnRemoteDied");
443     }
444 }
445 
GnssGeofenceCallbackDeathRecipient()446 GnssGeofenceCallbackDeathRecipient::GnssGeofenceCallbackDeathRecipient()
447 {
448 }
449 
~GnssGeofenceCallbackDeathRecipient()450 GnssGeofenceCallbackDeathRecipient::~GnssGeofenceCallbackDeathRecipient()
451 {
452 }
453 
OnRemoteDied(const wptr<IRemoteObject> & remote)454 void GnssGeofenceCallbackDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote)
455 {
456     auto gnssAbility = GnssAbility::GetInstance();
457     if (gnssAbility != nullptr) {
458         gnssAbility->RemoveGnssGeofenceRequestByCallback(remote.promote());
459         gnssAbility->UnloadGnssSystemAbility();
460         LBSLOGI(LOCATOR, "gnss geofence location callback OnRemoteDied");
461     }
462 }
463 } // namespace Location
464 } // namespace OHOS
465 #endif
466