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 sptr<IRemoteObject> client = data.ReadObject<IRemoteObject>();
176 reply.WriteInt32(RegisterGnssStatusCallback(client, identity.GetUid()));
177 return ERRCODE_SUCCESS;
178 }
179
UnregisterGnssStatusCallbackInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)180 int GnssAbilityStub::UnregisterGnssStatusCallbackInner(
181 MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
182 {
183 if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
184 return ERRCODE_PERMISSION_DENIED;
185 }
186 sptr<IRemoteObject> client = data.ReadObject<IRemoteObject>();
187 reply.WriteInt32(UnregisterGnssStatusCallback(client));
188 return ERRCODE_SUCCESS;
189 }
190
RegisterNmeaMessageCallbackInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)191 int GnssAbilityStub::RegisterNmeaMessageCallbackInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
192 {
193 if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
194 return ERRCODE_PERMISSION_DENIED;
195 }
196 sptr<IRemoteObject> client = data.ReadObject<IRemoteObject>();
197 reply.WriteInt32(RegisterNmeaMessageCallback(client, identity.GetUid()));
198 return ERRCODE_SUCCESS;
199 }
200
UnregisterNmeaMessageCallbackInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)201 int GnssAbilityStub::UnregisterNmeaMessageCallbackInner(MessageParcel &data, MessageParcel &reply,
202 AppIdentity &identity)
203 {
204 if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
205 return ERRCODE_PERMISSION_DENIED;
206 }
207 sptr<IRemoteObject> client = data.ReadObject<IRemoteObject>();
208 reply.WriteInt32(UnregisterNmeaMessageCallback(client));
209 return ERRCODE_SUCCESS;
210 }
211
RegisterCachedCallbackInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)212 int GnssAbilityStub::RegisterCachedCallbackInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
213 {
214 if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
215 return ERRCODE_PERMISSION_DENIED;
216 }
217 std::unique_ptr<CachedGnssLocationsRequest> requestConfig = std::make_unique<CachedGnssLocationsRequest>();
218 requestConfig->reportingPeriodSec = data.ReadInt32();
219 requestConfig->wakeUpCacheQueueFull = data.ReadBool();
220 sptr<IRemoteObject> callback = data.ReadObject<IRemoteObject>();
221 reply.WriteInt32(RegisterCachedCallback(requestConfig, callback));
222 return ERRCODE_SUCCESS;
223 }
224
UnregisterCachedCallbackInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)225 int GnssAbilityStub::UnregisterCachedCallbackInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
226 {
227 if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
228 return ERRCODE_PERMISSION_DENIED;
229 }
230 sptr<IRemoteObject> callback = data.ReadObject<IRemoteObject>();
231 reply.WriteInt32(UnregisterCachedCallback(callback));
232 return ERRCODE_SUCCESS;
233 }
234
GetCachedGnssLocationsSizeInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)235 int GnssAbilityStub::GetCachedGnssLocationsSizeInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
236 {
237 if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
238 return ERRCODE_PERMISSION_DENIED;
239 }
240 int size = -1;
241 reply.WriteInt32(GetCachedGnssLocationsSize(size));
242 reply.WriteInt32(size);
243 return ERRCODE_SUCCESS;
244 }
245
FlushCachedGnssLocationsInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)246 int GnssAbilityStub::FlushCachedGnssLocationsInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
247 {
248 if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
249 return ERRCODE_PERMISSION_DENIED;
250 }
251 reply.WriteInt32(FlushCachedGnssLocations());
252 return ERRCODE_SUCCESS;
253 }
254
SendCommandInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)255 int GnssAbilityStub::SendCommandInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
256 {
257 if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
258 return ERRCODE_PERMISSION_DENIED;
259 }
260 SendMessage(static_cast<uint32_t>(GnssInterfaceCode::SEND_COMMANDS), data, reply);
261 isMessageRequest_ = true;
262 return ERRCODE_SUCCESS;
263 }
264
EnableMockInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)265 int GnssAbilityStub::EnableMockInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
266 {
267 if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
268 return ERRCODE_PERMISSION_DENIED;
269 }
270 reply.WriteInt32(EnableMock());
271 return ERRCODE_SUCCESS;
272 }
273
DisableMockInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)274 int GnssAbilityStub::DisableMockInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
275 {
276 if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
277 return ERRCODE_PERMISSION_DENIED;
278 }
279 reply.WriteInt32(DisableMock());
280 return ERRCODE_SUCCESS;
281 }
282
AddFenceInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)283 int GnssAbilityStub::AddFenceInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
284 {
285 if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
286 return ERRCODE_PERMISSION_DENIED;
287 }
288 SendMessage(static_cast<uint32_t>(GnssAbilityInterfaceCode::ADD_FENCE), data, reply);
289 isMessageRequest_ = true;
290 return ERRCODE_SUCCESS;
291 }
292
RemoveFenceInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)293 int GnssAbilityStub::RemoveFenceInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
294 {
295 if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
296 return ERRCODE_PERMISSION_DENIED;
297 }
298 SendMessage(static_cast<uint32_t>(GnssAbilityInterfaceCode::REMOVE_FENCE), data, reply);
299 isMessageRequest_ = true;
300 return ERRCODE_SUCCESS;
301 }
302
AddGnssGeofenceInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)303 int GnssAbilityStub::AddGnssGeofenceInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
304 {
305 if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
306 return ERRCODE_PERMISSION_DENIED;
307 }
308 SendMessage(static_cast<uint32_t>(GnssAbilityInterfaceCode::ADD_GEOFENCE), data, reply);
309 isMessageRequest_ = true;
310 return ERRCODE_SUCCESS;
311 }
312
RemoveGnssGeofenceInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)313 int GnssAbilityStub::RemoveGnssGeofenceInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
314 {
315 if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
316 return ERRCODE_PERMISSION_DENIED;
317 }
318 SendMessage(static_cast<uint32_t>(GnssAbilityInterfaceCode::REMOVE_GEOFENCE), data, reply);
319 isMessageRequest_ = true;
320 return ERRCODE_SUCCESS;
321 }
322
QuerySupportCoordinateSystemTypeInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)323 int GnssAbilityStub::QuerySupportCoordinateSystemTypeInner(
324 MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
325 {
326 if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
327 return ERRCODE_PERMISSION_DENIED;
328 }
329 std::vector<CoordinateSystemType> coordinateSystemTypes;
330 auto errCode = QuerySupportCoordinateSystemType(coordinateSystemTypes);
331 reply.WriteInt32(errCode);
332 if (errCode != ERRCODE_SUCCESS) {
333 return errCode;
334 }
335 int size = static_cast<int>(coordinateSystemTypes.size()) > COORDINATE_SYSTEM_TYPE_SIZE ?
336 COORDINATE_SYSTEM_TYPE_SIZE : static_cast<int>(coordinateSystemTypes.size());
337 reply.WriteInt32(size);
338 for (int i = 0; i < size; i++) {
339 reply.WriteInt32(static_cast<int>(coordinateSystemTypes[i]));
340 }
341 return ERRCODE_SUCCESS;
342 }
343
SendNetworkLocationInner(MessageParcel & data,MessageParcel & reply,AppIdentity & identity)344 int GnssAbilityStub::SendNetworkLocationInner(MessageParcel &data, MessageParcel &reply, AppIdentity &identity)
345 {
346 LBSLOGI(GNSS, "SendNetworkLocationInner");
347 if (!PermissionManager::CheckCallingPermission(identity.GetUid(), identity.GetPid(), reply)) {
348 return ERRCODE_PERMISSION_DENIED;
349 }
350 SendMessage(static_cast<uint32_t>(GnssInterfaceCode::SEND_NETWORK_LOCATION), data, reply);
351 isMessageRequest_ = true;
352 return ERRCODE_SUCCESS;
353 }
354
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)355 int GnssAbilityStub::OnRemoteRequest(uint32_t code,
356 MessageParcel &data, MessageParcel &reply, MessageOption &option)
357 {
358 pid_t callingPid = IPCSkeleton::GetCallingPid();
359 pid_t callingUid = IPCSkeleton::GetCallingUid();
360 AppIdentity identity;
361 identity.SetPid(callingPid);
362 identity.SetUid(callingUid);
363 std::string currentTime = std::to_string(CommonUtils::GetCurrentTimeStamp());
364 LBSLOGI(GNSS, "%{public}s cmd = %{public}u, flags= %{public}d, identity = %{public}s, timestamp = %{public}s",
365 __func__, code, option.GetFlags(), identity.ToString().c_str(), currentTime.c_str());
366
367 if (data.ReadInterfaceToken() != GetDescriptor()) {
368 LBSLOGE(GNSS, "invalid token.");
369 return ERRCODE_SERVICE_UNAVAILABLE;
370 }
371 CancelIdleState();
372 int ret = ERRCODE_SUCCESS;
373 isMessageRequest_ = false;
374 auto handleFunc = GnssMsgHandleMap_.find(code);
375 if (handleFunc != GnssMsgHandleMap_.end() && handleFunc->second != nullptr) {
376 auto memberFunc = handleFunc->second;
377 ret = memberFunc(data, reply, identity);
378 } else {
379 LBSLOGE(GNSS, "OnReceived cmd = %{public}u, unsupport service.", code);
380 ret = IPCObjectStub::OnRemoteRequest(code, data, reply, option);
381 }
382 if (!isMessageRequest_) {
383 UnloadGnssSystemAbility();
384 }
385 return ret;
386 }
387
GnssStatusCallbackDeathRecipient()388 GnssStatusCallbackDeathRecipient::GnssStatusCallbackDeathRecipient()
389 {
390 }
391
~GnssStatusCallbackDeathRecipient()392 GnssStatusCallbackDeathRecipient::~GnssStatusCallbackDeathRecipient()
393 {
394 }
395
OnRemoteDied(const wptr<IRemoteObject> & remote)396 void GnssStatusCallbackDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote)
397 {
398 auto gnssAbility = GnssAbility::GetInstance();
399 if (gnssAbility != nullptr) {
400 gnssAbility->UnregisterGnssStatusCallback(remote.promote());
401 gnssAbility->UnloadGnssSystemAbility();
402 LBSLOGI(LOCATOR, "gnss status callback OnRemoteDied");
403 }
404 }
405
NmeaCallbackDeathRecipient()406 NmeaCallbackDeathRecipient::NmeaCallbackDeathRecipient()
407 {
408 }
409
~NmeaCallbackDeathRecipient()410 NmeaCallbackDeathRecipient::~NmeaCallbackDeathRecipient()
411 {
412 }
413
OnRemoteDied(const wptr<IRemoteObject> & remote)414 void NmeaCallbackDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote)
415 {
416 auto gnssAbility = GnssAbility::GetInstance();
417 if (gnssAbility != nullptr) {
418 gnssAbility->UnregisterNmeaMessageCallback(remote.promote());
419 gnssAbility->UnloadGnssSystemAbility();
420 LBSLOGI(LOCATOR, "nmea callback OnRemoteDied");
421 }
422 }
423
CachedLocationCallbackDeathRecipient()424 CachedLocationCallbackDeathRecipient::CachedLocationCallbackDeathRecipient()
425 {
426 }
427
~CachedLocationCallbackDeathRecipient()428 CachedLocationCallbackDeathRecipient::~CachedLocationCallbackDeathRecipient()
429 {
430 }
431
OnRemoteDied(const wptr<IRemoteObject> & remote)432 void CachedLocationCallbackDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote)
433 {
434 auto gnssAbility = GnssAbility::GetInstance();
435 if (gnssAbility != nullptr) {
436 gnssAbility->UnregisterCachedCallback(remote.promote());
437 gnssAbility->UnloadGnssSystemAbility();
438 LBSLOGI(LOCATOR, "cached location callback OnRemoteDied");
439 }
440 }
441
GnssGeofenceCallbackDeathRecipient()442 GnssGeofenceCallbackDeathRecipient::GnssGeofenceCallbackDeathRecipient()
443 {
444 }
445
~GnssGeofenceCallbackDeathRecipient()446 GnssGeofenceCallbackDeathRecipient::~GnssGeofenceCallbackDeathRecipient()
447 {
448 }
449
OnRemoteDied(const wptr<IRemoteObject> & remote)450 void GnssGeofenceCallbackDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote)
451 {
452 auto gnssAbility = GnssAbility::GetInstance();
453 if (gnssAbility != nullptr) {
454 gnssAbility->RemoveGnssGeofenceRequestByCallback(remote.promote());
455 gnssAbility->UnloadGnssSystemAbility();
456 LBSLOGI(LOCATOR, "gnss geofence location callback OnRemoteDied");
457 }
458 }
459 } // namespace Location
460 } // namespace OHOS
461 #endif
462