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_NETWORK_SUPPORT
17 #include "network_ability.h"
18 #include <file_ex.h>
19 #include <thread>
20 #include "ability_connect_callback_stub.h"
21 #include "ability_manager_client.h"
22 #include "ipc_skeleton.h"
23 #include "iservice_registry.h"
24 #include "system_ability_definition.h"
25 #include "want_agent_helper.h"
26
27 #include "common_utils.h"
28 #include "location_config_manager.h"
29 #include "location_dumper.h"
30 #include "location_log.h"
31 #include "location_sa_load_manager.h"
32 #include "network_callback_host.h"
33 #include "locationhub_ipc_interface_code.h"
34 #include "location_log_event_ids.h"
35 #include "common_hisysevent.h"
36 #include "location_data_rdb_manager.h"
37
38 namespace OHOS {
39 namespace Location {
40 const uint32_t EVENT_REPORT_MOCK_LOCATION = 0x0100;
41 const uint32_t EVENT_RESTART_ALL_LOCATION_REQUEST = 0x0200;
42 const uint32_t EVENT_STOP_ALL_LOCATION_REQUEST = 0x0300;
43 const uint32_t EVENT_INTERVAL_UNITE = 1000;
44 constexpr uint32_t WAIT_MS = 100;
45 const int MAX_RETRY_COUNT = 5;
46 const std::string UNLOAD_NETWORK_TASK = "network_sa_unload";
47 const uint32_t RETRY_INTERVAL_OF_UNLOAD_SA = 4 * 60 * EVENT_INTERVAL_UNITE;
48 const bool REGISTER_RESULT = NetworkAbility::MakeAndRegisterAbility(
49 NetworkAbility::GetInstance());
50
NetworkAbility()51 NetworkAbility::NetworkAbility() : SystemAbility(LOCATION_NETWORK_LOCATING_SA_ID, true)
52 {
53 SetAbility(NETWORK_ABILITY);
54 networkHandler_ =
55 std::make_shared<NetworkHandler>(AppExecFwk::EventRunner::Create(true, AppExecFwk::ThreadMode::FFRT));
56 LBSLOGI(NETWORK, "ability constructed.");
57 }
58
~NetworkAbility()59 NetworkAbility::~NetworkAbility()
60 {
61 conn_ = nullptr;
62 }
63
OnStart()64 void NetworkAbility::OnStart()
65 {
66 if (state_ == ServiceRunningState::STATE_RUNNING) {
67 LBSLOGI(NETWORK, "ability has already started.");
68 return;
69 }
70 if (!Init()) {
71 LBSLOGE(NETWORK, "failed to init ability");
72 OnStop();
73 return;
74 }
75 state_ = ServiceRunningState::STATE_RUNNING;
76 LBSLOGI(NETWORK, "OnStart start ability success.");
77 }
78
OnStop()79 void NetworkAbility::OnStop()
80 {
81 state_ = ServiceRunningState::STATE_NOT_START;
82 registerToAbility_ = false;
83 LBSLOGI(NETWORK, "OnStop ability stopped.");
84 }
85
GetInstance()86 NetworkAbility* NetworkAbility::GetInstance()
87 {
88 static NetworkAbility data;
89 return &data;
90 }
91
Init()92 bool NetworkAbility::Init()
93 {
94 if (!registerToAbility_) {
95 if (!Publish(AsObject())) {
96 LBSLOGE(NETWORK, "Init Publish failed!");
97 return false;
98 }
99 registerToAbility_ = true;
100 }
101 return true;
102 }
103
104 class AbilityConnection : public AAFwk::AbilityConnectionStub {
105 public:
OnAbilityConnectDone(const AppExecFwk::ElementName & element,const sptr<IRemoteObject> & remoteObject,int resultCode)106 void OnAbilityConnectDone(
107 const AppExecFwk::ElementName& element, const sptr<IRemoteObject>& remoteObject, int resultCode) override
108 {
109 std::string uri = element.GetURI();
110 LBSLOGD(NETWORK, "Connected uri is %{public}s, result is %{public}d.", uri.c_str(), resultCode);
111 if (resultCode != ERR_OK) {
112 return;
113 }
114 NetworkAbility::GetInstance()->NotifyConnected(remoteObject);
115 }
116
OnAbilityDisconnectDone(const AppExecFwk::ElementName & element,int)117 void OnAbilityDisconnectDone(const AppExecFwk::ElementName& element, int) override
118 {
119 std::string uri = element.GetURI();
120 LBSLOGD(NETWORK, "Disconnected uri is %{public}s.", uri.c_str());
121 NetworkAbility::GetInstance()->NotifyDisConnected();
122 }
123 };
124
ConnectNlpService()125 bool NetworkAbility::ConnectNlpService()
126 {
127 LBSLOGD(NETWORK, "start ConnectNlpService");
128 if (!IsConnect()) {
129 AAFwk::Want connectionWant;
130 std::string serviceName;
131 bool result = LocationConfigManager::GetInstance()->GetNlpServiceName(serviceName);
132 if (!result || serviceName.empty()) {
133 LBSLOGE(NETWORK, "get service name failed!");
134 return false;
135 }
136 std::string abilityName;
137 bool res = LocationConfigManager::GetInstance()->GetNlpAbilityName(abilityName);
138 if (!res || abilityName.empty()) {
139 LBSLOGE(NETWORK, "get service name failed!");
140 return false;
141 }
142 connectionWant.SetElementName(serviceName, abilityName);
143 conn_ = sptr<AAFwk::IAbilityConnection>(new (std::nothrow) AbilityConnection());
144 if (conn_ == nullptr) {
145 LBSLOGE(NETWORK, "get connection failed!");
146 return false;
147 }
148 int32_t ret = AAFwk::AbilityManagerClient::GetInstance()->ConnectAbility(connectionWant, conn_, -1);
149 if (ret != ERR_OK) {
150 LBSLOGE(NETWORK, "Connect cloud service failed, ret = %{public}d", ret);
151 return false;
152 }
153 std::unique_lock<ffrt::mutex> uniqueLock(mutex_);
154 auto waitStatus = connectCondition_.wait_for(
155 uniqueLock, std::chrono::seconds(CONNECT_TIME_OUT), [this]() { return nlpServiceProxy_ != nullptr; });
156 if (!waitStatus) {
157 WriteLocationInnerEvent(NLP_SERVICE_TIMEOUT, {});
158 LBSLOGE(NETWORK, "Connect cloudService timeout!");
159 return false;
160 }
161 }
162 RegisterNLPServiceDeathRecipient();
163 return true;
164 }
165
ReConnectNlpService()166 bool NetworkAbility::ReConnectNlpService()
167 {
168 int retryCount = 0;
169 if (IsConnect()) {
170 LBSLOGI(NETWORK, "Connect success!");
171 return true;
172 }
173 while (retryCount < MAX_RETRY_COUNT) {
174 retryCount++;
175 bool ret = ConnectNlpService();
176 if (ret) {
177 LBSLOGI(NETWORK, "Connect success!");
178 return true;
179 }
180 std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_MS));
181 }
182 return false;
183 }
184
ResetServiceProxy()185 bool NetworkAbility::ResetServiceProxy()
186 {
187 std::unique_lock<ffrt::mutex> uniqueLock(mutex_);
188 nlpServiceProxy_ = nullptr;
189 return true;
190 }
191
NotifyConnected(const sptr<IRemoteObject> & remoteObject)192 void NetworkAbility::NotifyConnected(const sptr<IRemoteObject>& remoteObject)
193 {
194 std::unique_lock<ffrt::mutex> uniqueLock(mutex_);
195 nlpServiceProxy_ = remoteObject;
196 connectCondition_.notify_all();
197 }
198
NotifyDisConnected()199 void NetworkAbility::NotifyDisConnected()
200 {
201 std::unique_lock<ffrt::mutex> uniqueLock(mutex_);
202 nlpServiceProxy_ = nullptr;
203 connectCondition_.notify_all();
204 }
205
SendLocationRequest(WorkRecord & workrecord)206 LocationErrCode NetworkAbility::SendLocationRequest(WorkRecord &workrecord)
207 {
208 LocationRequest(workrecord);
209 return ERRCODE_SUCCESS;
210 }
211
SetEnable(bool state)212 LocationErrCode NetworkAbility::SetEnable(bool state)
213 {
214 LBSLOGD(NETWORK, "SetEnable: %{public}d", state);
215 if (networkHandler_ == nullptr) {
216 LBSLOGE(NETWORK, "%{public}s networkHandler is nullptr", __func__);
217 return ERRCODE_SERVICE_UNAVAILABLE;
218 }
219 auto event = state ? AppExecFwk::InnerEvent::Get(EVENT_RESTART_ALL_LOCATION_REQUEST, 0) :
220 AppExecFwk::InnerEvent::Get(EVENT_STOP_ALL_LOCATION_REQUEST, 0);
221 networkHandler_->SendHighPriorityEvent(event);
222 return ERRCODE_SUCCESS;
223 }
224
CancelIdleState()225 bool NetworkAbility::CancelIdleState()
226 {
227 bool ret = CancelIdle();
228 if (!ret) {
229 LBSLOGE(NETWORK, "%{public}s cancel idle failed!", __func__);
230 return false;
231 }
232 return true;
233 }
234
UnloadNetworkSystemAbility()235 void NetworkAbility::UnloadNetworkSystemAbility()
236 {
237 if (networkHandler_ == nullptr) {
238 LBSLOGE(NETWORK, "%{public}s networkHandler is nullptr", __func__);
239 return;
240 }
241 networkHandler_->RemoveTask(UNLOAD_NETWORK_TASK);
242 if (CheckIfNetworkConnecting()) {
243 return;
244 }
245 auto task = [this]() {
246 LocationSaLoadManager::UnInitLocationSa(LOCATION_NETWORK_LOCATING_SA_ID);
247 };
248 if (networkHandler_ != nullptr) {
249 networkHandler_->PostTask(task, UNLOAD_NETWORK_TASK, RETRY_INTERVAL_OF_UNLOAD_SA);
250 }
251 }
252
CheckIfNetworkConnecting()253 bool NetworkAbility::CheckIfNetworkConnecting()
254 {
255 return IsMockEnabled() || !GetLocationMock().empty() || GetRequestNum() != 0;
256 }
257
RequestRecord(WorkRecord & workRecord,bool isAdded)258 void NetworkAbility::RequestRecord(WorkRecord &workRecord, bool isAdded)
259 {
260 if (!IsConnect()) {
261 std::string serviceName;
262 bool result = LocationConfigManager::GetInstance()->GetNlpServiceName(serviceName);
263 if (!result || serviceName.empty()) {
264 LBSLOGE(NETWORK, "get service name failed!");
265 return;
266 }
267 if (!CommonUtils::CheckAppInstalled(serviceName)) { // app is not installed
268 LBSLOGE(NETWORK, "nlp service is not available.");
269 return;
270 } else if (!ReConnectNlpService()) {
271 LBSLOGE(NETWORK, "nlp service is not ready.");
272 return;
273 }
274 }
275 std::unique_lock<ffrt::mutex> uniqueLock(mutex_);
276 if (isAdded) {
277 RequestNetworkLocation(workRecord);
278 } else {
279 RemoveNetworkLocation(workRecord);
280 if (GetRequestNum() == 0 && conn_ != nullptr) {
281 LBSLOGI(NETWORK, "RequestRecord disconnect");
282 AAFwk::AbilityManagerClient::GetInstance()->DisconnectAbility(conn_);
283 }
284 }
285 }
286
RequestNetworkLocation(WorkRecord & workRecord)287 bool NetworkAbility::RequestNetworkLocation(WorkRecord &workRecord)
288 {
289 if (nlpServiceProxy_ == nullptr) {
290 LBSLOGE(NETWORK, "nlpProxy is nullptr.");
291 return false;
292 }
293 if (LocationDataRdbManager::QuerySwitchState() != ENABLED) {
294 LBSLOGE(NETWORK, "QuerySwitchState is DISABLED");
295 return false;
296 }
297 LBSLOGI(NETWORK, "start network location, uuid: %{public}s", workRecord.GetUuid(0).c_str());
298 sptr<NetworkCallbackHost> callback = new (std::nothrow) NetworkCallbackHost();
299 if (callback == nullptr) {
300 LBSLOGE(NETWORK, "can not get valid callback.");
301 return false;
302 }
303 MessageParcel data;
304 MessageParcel reply;
305 MessageOption option;
306 data.WriteString16(Str8ToStr16(workRecord.GetUuid(0)));
307 data.WriteInt64(workRecord.GetTimeInterval(0) * MILLI_PER_SEC);
308 data.WriteInt32(workRecord.GetNlpRequestType(0));
309 data.WriteRemoteObject(callback->AsObject());
310 if (workRecord.GetName(0).size() == 0) {
311 data.WriteString16(Str8ToStr16(std::to_string(workRecord.GetUid(0)))); // uid
312 } else {
313 data.WriteString16(Str8ToStr16(workRecord.GetName(0))); // bundleName
314 }
315 int error = nlpServiceProxy_->SendRequest(REQUEST_NETWORK_LOCATION, data, reply, option);
316 if (error != ERR_OK) {
317 LBSLOGE(NETWORK, "SendRequest to cloud service failed. error = %{public}d", error);
318 return false;
319 }
320 return true;
321 }
322
RemoveNetworkLocation(WorkRecord & workRecord)323 bool NetworkAbility::RemoveNetworkLocation(WorkRecord &workRecord)
324 {
325 if (nlpServiceProxy_ == nullptr) {
326 LBSLOGE(NETWORK, "nlpProxy is nullptr.");
327 return false;
328 }
329 LBSLOGI(NETWORK, "stop network location, uuid: %{public}s", workRecord.GetUuid(0).c_str());
330 MessageParcel data;
331 MessageParcel reply;
332 MessageOption option;
333 data.WriteString16(Str8ToStr16(workRecord.GetUuid(0)));
334 data.WriteString16(Str8ToStr16(workRecord.GetName(0))); // bundleName
335 int error = nlpServiceProxy_->SendRequest(REMOVE_NETWORK_LOCATION, data, reply, option);
336 if (error != ERR_OK) {
337 LBSLOGE(NETWORK, "SendRequest to cloud service failed.");
338 return false;
339 }
340 return true;
341 }
342
EnableMock()343 LocationErrCode NetworkAbility::EnableMock()
344 {
345 if (!EnableLocationMock()) {
346 return ERRCODE_NOT_SUPPORTED;
347 }
348 return ERRCODE_SUCCESS;
349 }
350
DisableMock()351 LocationErrCode NetworkAbility::DisableMock()
352 {
353 if (!DisableLocationMock()) {
354 return ERRCODE_NOT_SUPPORTED;
355 }
356 return ERRCODE_SUCCESS;
357 }
358
IsMockEnabled()359 bool NetworkAbility::IsMockEnabled()
360 {
361 return IsLocationMocked();
362 }
363
SetMocked(const int timeInterval,const std::vector<std::shared_ptr<Location>> & location)364 LocationErrCode NetworkAbility::SetMocked(const int timeInterval,
365 const std::vector<std::shared_ptr<Location>> &location)
366 {
367 if (!SetMockedLocations(timeInterval, location)) {
368 return ERRCODE_NOT_SUPPORTED;
369 }
370 return ERRCODE_SUCCESS;
371 }
372
ProcessReportLocationMock()373 void NetworkAbility::ProcessReportLocationMock()
374 {
375 std::vector<std::shared_ptr<Location>> mockLocationArray = GetLocationMock();
376 if (mockLocationIndex_ < mockLocationArray.size()) {
377 ReportMockedLocation(mockLocationArray[mockLocationIndex_++]);
378 if (networkHandler_ != nullptr) {
379 networkHandler_->SendHighPriorityEvent(EVENT_REPORT_MOCK_LOCATION,
380 0, GetTimeIntervalMock() * EVENT_INTERVAL_UNITE);
381 }
382 } else {
383 ClearLocationMock();
384 mockLocationIndex_ = 0;
385 }
386 }
387
SendReportMockLocationEvent()388 void NetworkAbility::SendReportMockLocationEvent()
389 {
390 if (networkHandler_ == nullptr) {
391 return;
392 }
393 networkHandler_->SendHighPriorityEvent(EVENT_REPORT_MOCK_LOCATION, 0, 0);
394 }
395
ReportMockedLocation(const std::shared_ptr<Location> location)396 int32_t NetworkAbility::ReportMockedLocation(const std::shared_ptr<Location> location)
397 {
398 if ((IsLocationMocked() && !location->GetIsFromMock()) ||
399 (!IsLocationMocked() && location->GetIsFromMock())) {
400 LBSLOGE(NETWORK, "location mock is enabled, do not report network location!");
401 return ERR_OK;
402 }
403 location->SetTimeSinceBoot(CommonUtils::GetSinceBootTime());
404 location->SetTimeStamp(CommonUtils::GetCurrentTimeStamp() * MICRO_PER_MILLI);
405 location->SetLocationSourceType(LocationSourceType::NETWORK_TYPE);
406 ReportLocationInfo(NETWORK_ABILITY, location);
407 #ifdef FEATURE_PASSIVE_SUPPORT
408 ReportLocationInfo(PASSIVE_ABILITY, location);
409 #endif
410 return ERR_OK;
411 }
412
SaDumpInfo(std::string & result)413 void NetworkAbility::SaDumpInfo(std::string& result)
414 {
415 result += "Network Location enable status: false";
416 result += "\n";
417 }
418
Dump(int32_t fd,const std::vector<std::u16string> & args)419 int32_t NetworkAbility::Dump(int32_t fd, const std::vector<std::u16string>& args)
420 {
421 std::vector<std::string> vecArgs;
422 std::transform(args.begin(), args.end(), std::back_inserter(vecArgs), [](const std::u16string &arg) {
423 return Str16ToStr8(arg);
424 });
425
426 LocationDumper dumper;
427 std::string result;
428 dumper.NetWorkDump(SaDumpInfo, vecArgs, result);
429 if (!SaveStringToFd(fd, result)) {
430 LBSLOGE(NETWORK, "Network save string to fd failed!");
431 return ERR_OK;
432 }
433 return ERR_OK;
434 }
435
SendMessage(uint32_t code,MessageParcel & data,MessageParcel & reply)436 void NetworkAbility::SendMessage(uint32_t code, MessageParcel &data, MessageParcel &reply)
437 {
438 if (networkHandler_ == nullptr) {
439 reply.WriteInt32(ERRCODE_SERVICE_UNAVAILABLE);
440 return;
441 }
442 switch (code) {
443 case static_cast<uint32_t>(NetworkInterfaceCode::SEND_LOCATION_REQUEST): {
444 std::unique_ptr<WorkRecord> workrecord = WorkRecord::Unmarshalling(data);
445 AppExecFwk::InnerEvent::Pointer event = AppExecFwk::InnerEvent::Get(code, workrecord);
446 if (networkHandler_->SendEvent(event)) {
447 reply.WriteInt32(ERRCODE_SUCCESS);
448 } else {
449 reply.WriteInt32(ERRCODE_SERVICE_UNAVAILABLE);
450 }
451 break;
452 }
453 case static_cast<uint32_t>(NetworkInterfaceCode::SET_MOCKED_LOCATIONS): {
454 if (!IsMockEnabled()) {
455 reply.WriteInt32(ERRCODE_NOT_SUPPORTED);
456 break;
457 }
458 int timeInterval = data.ReadInt32();
459 int locationSize = data.ReadInt32();
460 timeInterval = timeInterval < 0 ? 1 : timeInterval;
461 locationSize = locationSize > INPUT_ARRAY_LEN_MAX ? INPUT_ARRAY_LEN_MAX :
462 locationSize;
463 std::shared_ptr<std::vector<std::shared_ptr<Location>>> vcLoc =
464 std::make_shared<std::vector<std::shared_ptr<Location>>>();
465 for (int i = 0; i < locationSize; i++) {
466 vcLoc->push_back(Location::UnmarshallingShared(data));
467 }
468 AppExecFwk::InnerEvent::Pointer event =
469 AppExecFwk::InnerEvent::Get(code, vcLoc, timeInterval);
470 if (networkHandler_->SendEvent(event)) {
471 reply.WriteInt32(ERRCODE_SUCCESS);
472 } else {
473 reply.WriteInt32(ERRCODE_SERVICE_UNAVAILABLE);
474 }
475 break;
476 }
477 default:
478 break;
479 }
480 }
481
RegisterNLPServiceDeathRecipient()482 void NetworkAbility::RegisterNLPServiceDeathRecipient()
483 {
484 std::unique_lock<ffrt::mutex> uniqueLock(mutex_);
485 if (nlpServiceProxy_ == nullptr) {
486 LBSLOGE(NETWORK, "%{public}s: nlpServiceProxy_ is nullptr", __func__);
487 return;
488 }
489 sptr<IRemoteObject::DeathRecipient> death(new (std::nothrow) NLPServiceDeathRecipient());
490 nlpServiceProxy_->AddDeathRecipient(death);
491 }
492
IsConnect()493 bool NetworkAbility::IsConnect()
494 {
495 std::unique_lock<ffrt::mutex> uniqueLock(mutex_);
496 return nlpServiceProxy_ != nullptr;
497 }
498
ReportLocationError(int32_t errCode,std::string errMsg,std::string uuid)499 void NetworkAbility::ReportLocationError(int32_t errCode, std::string errMsg, std::string uuid)
500 {
501 MessageParcel data;
502 MessageParcel reply;
503 MessageOption option;
504 data.WriteInterfaceToken(u"location.ILocator");
505 data.WriteInt32(LOCATING_FAILED_INTERNET_ACCESS_FAILURE);
506 data.WriteString(errMsg);
507 data.WriteString(uuid);
508 sptr<IRemoteObject> objectLocator =
509 CommonUtils::GetRemoteObject(LOCATION_LOCATOR_SA_ID, CommonUtils::InitDeviceId());
510 if (objectLocator == nullptr) {
511 LBSLOGE(NETWORK, "%{public}s get locator sa failed", __func__);
512 return;
513 }
514 objectLocator->SendRequest(static_cast<int>(LocatorInterfaceCode::REPORT_LOCATION_ERROR), data, reply, option);
515 }
516
NetworkHandler(const std::shared_ptr<AppExecFwk::EventRunner> & runner)517 NetworkHandler::NetworkHandler(const std::shared_ptr<AppExecFwk::EventRunner>& runner) : EventHandler(runner) {}
518
~NetworkHandler()519 NetworkHandler::~NetworkHandler() {}
520
ProcessEvent(const AppExecFwk::InnerEvent::Pointer & event)521 void NetworkHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer& event)
522 {
523 auto networkAbility = NetworkAbility::GetInstance();
524 if (networkAbility == nullptr) {
525 LBSLOGE(NETWORK, "ProcessEvent: NetworkAbility is nullptr");
526 return;
527 }
528 uint32_t eventId = event->GetInnerEventId();
529 LBSLOGD(NETWORK, "ProcessEvent event:%{public}d", eventId);
530 switch (eventId) {
531 case EVENT_REPORT_MOCK_LOCATION: {
532 networkAbility->ProcessReportLocationMock();
533 break;
534 }
535 case EVENT_RESTART_ALL_LOCATION_REQUEST: {
536 networkAbility->RestartAllLocationRequests();
537 break;
538 }
539 case EVENT_STOP_ALL_LOCATION_REQUEST: {
540 networkAbility->StopAllLocationRequests();
541 break;
542 }
543 case static_cast<uint32_t>(NetworkInterfaceCode::SEND_LOCATION_REQUEST): {
544 std::unique_ptr<WorkRecord> workrecord = event->GetUniqueObject<WorkRecord>();
545 if (workrecord != nullptr) {
546 networkAbility->LocationRequest(*workrecord);
547 }
548 break;
549 }
550 case static_cast<uint32_t>(NetworkInterfaceCode::SET_MOCKED_LOCATIONS): {
551 int timeInterval = event->GetParam();
552 auto vcLoc = event->GetSharedObject<std::vector<std::shared_ptr<Location>>>();
553 if (vcLoc != nullptr) {
554 std::vector<std::shared_ptr<Location>> mockLocations;
555 for (auto it = vcLoc->begin(); it != vcLoc->end(); ++it) {
556 mockLocations.push_back(*it);
557 }
558 networkAbility->SetMocked(timeInterval, mockLocations);
559 }
560 break;
561 }
562 default:
563 break;
564 }
565 networkAbility->UnloadNetworkSystemAbility();
566 }
567
NLPServiceDeathRecipient()568 NLPServiceDeathRecipient::NLPServiceDeathRecipient()
569 {
570 }
571
~NLPServiceDeathRecipient()572 NLPServiceDeathRecipient::~NLPServiceDeathRecipient()
573 {
574 }
575
OnRemoteDied(const wptr<IRemoteObject> & remote)576 void NLPServiceDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote)
577 {
578 auto networkAbility = NetworkAbility::GetInstance();
579 if (networkAbility != nullptr) {
580 LBSLOGI(NETWORK, "nlp ResetServiceProxy");
581 networkAbility->ResetServiceProxy();
582 }
583 }
584 } // namespace Location
585 } // namespace OHOS
586 #endif // FEATURE_NETWORK_SUPPORT
587