• 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 #include "locator_background_proxy.h"
17 
18 #include <thread>
19 
20 #include "common_event_manager.h"
21 #include "common_event_support.h"
22 #include "iservice_registry.h"
23 #include "os_account_manager.h"
24 #include "system_ability_definition.h"
25 
26 #include "common_utils.h"
27 #include "constant_definition.h"
28 #include "location_config_manager.h"
29 #include "location_log.h"
30 #include "locator_ability.h"
31 #include "request_manager.h"
32 #include "permission_manager.h"
33 #include "location_data_rdb_manager.h"
34 
35 #include "accesstoken_kit.h"
36 #include "tokenid_kit.h"
37 
38 #ifdef BGTASKMGR_SUPPORT
39 #include "background_mode.h"
40 #include "background_task_mgr_helper.h"
41 #endif
42 
43 #ifdef FMSKIT_NATIVE_SUPPORT
44 #include "form_mgr.h"
45 #endif
46 
47 namespace OHOS {
48 namespace Location {
49 const int BACKGROUNDAPP_STATUS = 4;
50 const int FOREGROUPAPP_STATUS = 2;
51 std::mutex LocatorBackgroundProxy::requestListMutex_;
52 std::mutex LocatorBackgroundProxy::locatorMutex_;
53 std::mutex LocatorBackgroundProxy::foregroundAppMutex_;
GetInstance()54 LocatorBackgroundProxy* LocatorBackgroundProxy::GetInstance()
55 {
56     static LocatorBackgroundProxy data;
57     return &data;
58 }
59 
LocatorBackgroundProxy()60 LocatorBackgroundProxy::LocatorBackgroundProxy()
61 {
62     InitArgsFromProp();
63     if (!featureSwitch_) {
64         return;
65     }
66     requestsMap_ = std::make_shared<std::map<int32_t, std::shared_ptr<std::list<std::shared_ptr<Request>>>>>();
67     requestsList_ = std::make_shared<std::list<std::shared_ptr<Request>>>();
68     CommonUtils::GetCurrentUserId(curUserId_);
69     requestsMap_->insert(make_pair(curUserId_, requestsList_));
70 
71     auto requestConfig = std::make_unique<RequestConfig>();
72     requestConfig->SetPriority(PRIORITY_LOW_POWER);
73     requestConfig->SetTimeInterval(timeInterval_);
74     callback_ = sptr<mLocatorCallback>(new (std::nothrow) LocatorBackgroundProxy::mLocatorCallback());
75     if (callback_ == nullptr) {
76         return;
77     }
78     request_ = std::make_shared<Request>();
79     if (request_ == nullptr) {
80         return;
81     }
82     request_->SetUid(SYSTEM_UID);
83     request_->SetPid(getpid());
84     request_->SetPackageName(PROC_NAME);
85     request_->SetRequestConfig(*requestConfig);
86     request_->SetLocatorCallBack(callback_);
87     SubscribeSaStatusChangeListerner();
88     isUserSwitchSubscribed_ = LocatorBackgroundProxy::UserSwitchSubscriber::Subscribe();
89     proxySwtich_ = (LocationConfigManager::GetInstance()->GetLocationSwitchState() == ENABLED);
90     RegisterAppStateObserver();
91 }
92 
~LocatorBackgroundProxy()93 LocatorBackgroundProxy::~LocatorBackgroundProxy()
94 {
95     UnregisterAppStateObserver();
96 }
97 
98 // modify the parameters, in order to make the test easier
InitArgsFromProp()99 void LocatorBackgroundProxy::InitArgsFromProp()
100 {
101     featureSwitch_ = 1;
102     timeInterval_ = DEFAULT_TIME_INTERVAL;
103 }
104 
SubscribeSaStatusChangeListerner()105 void LocatorBackgroundProxy::SubscribeSaStatusChangeListerner()
106 {
107     OHOS::EventFwk::MatchingSkills matchingSkills;
108     matchingSkills.AddEvent(OHOS::EventFwk::CommonEventSupport::COMMON_EVENT_USER_SWITCHED);
109     OHOS::EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills);
110     if (subscriber_ == nullptr) {
111         subscriber_ = std::make_shared<UserSwitchSubscriber>(subscriberInfo);
112     }
113     auto samgrProxy = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
114     statusChangeListener_ = new (std::nothrow) SystemAbilityStatusChangeListener(subscriber_);
115     if (samgrProxy == nullptr || statusChangeListener_ == nullptr) {
116         LBSLOGE(LOCATOR_BACKGROUND_PROXY,
117             "SubscribeSaStatusChangeListerner samgrProxy or statusChangeListener_ is nullptr");
118         return;
119     }
120     int32_t ret = samgrProxy->SubscribeSystemAbility(COMMON_EVENT_SERVICE_ID, statusChangeListener_);
121     LBSLOGI(LOCATOR_BACKGROUND_PROXY,
122         "SubscribeSaStatusChangeListerner SubscribeSystemAbility COMMON_EVENT_SERVICE_ID result:%{public}d", ret);
123 }
124 
StartLocatorThread()125 void LocatorBackgroundProxy::StartLocatorThread()
126 {
127     auto requestManager = RequestManager::GetInstance();
128     auto locatorAbility = LocatorAbility::GetInstance();
129     std::this_thread::sleep_for(std::chrono::seconds(timeInterval_));
130     std::unique_lock<std::mutex> lock(locatorMutex_, std::defer_lock);
131     lock.lock();
132     isWating_ = false;
133     if (isLocating_ || !proxySwtich_ || requestsList_->empty()) {
134         LBSLOGD(LOCATOR_BACKGROUND_PROXY, "cancel locating");
135         lock.unlock();
136         return;
137     }
138     isLocating_ = true;
139     lock.unlock();
140     LBSLOGI(LOCATOR_BACKGROUND_PROXY, "real start locating");
141     requestManager->HandleStartLocating(request_);
142     locatorAbility->ReportLocationStatus(callback_, SESSION_START);
143 }
144 
StopLocatorThread()145 void LocatorBackgroundProxy::StopLocatorThread()
146 {
147     auto locatorAbility = LocatorAbility::GetInstance();
148     std::unique_lock<std::mutex> lock(locatorMutex_, std::defer_lock);
149     lock.lock();
150     if (!isLocating_) {
151         lock.unlock();
152         return;
153     }
154     isLocating_ = false;
155     lock.unlock();
156     locatorAbility->StopLocating(callback_);
157     LBSLOGI(LOCATOR_BACKGROUND_PROXY, "end locating");
158 }
159 
StopLocator()160 void LocatorBackgroundProxy::StopLocator()
161 {
162 }
163 
StartLocator()164 void LocatorBackgroundProxy::StartLocator()
165 {
166 }
167 
UpdateListOnRequestChange(const std::shared_ptr<Request> & request)168 void LocatorBackgroundProxy::UpdateListOnRequestChange(const std::shared_ptr<Request>& request)
169 {
170 }
171 
172 // called when the app freezes or wakes up
173 // When the app enters frozen state, start proxy
174 // when the app wakes up, stop proxy
OnSuspend(const std::shared_ptr<Request> & request,bool active)175 void LocatorBackgroundProxy::OnSuspend(const std::shared_ptr<Request>& request, bool active)
176 {
177 }
178 
179 // called when SA switch on or switch off
180 // when switch on, start proxy
181 // when switch off, stop proxy
OnSaStateChange(bool enable)182 void LocatorBackgroundProxy::OnSaStateChange(bool enable)
183 {
184 }
185 
186 // called when deleteRequest called from locator ability (e.g. app stop locating)
OnDeleteRequestRecord(const std::shared_ptr<Request> & request)187 void LocatorBackgroundProxy::OnDeleteRequestRecord(const std::shared_ptr<Request>& request)
188 {
189 }
190 
CheckPermission(const std::shared_ptr<Request> & request) const191 bool LocatorBackgroundProxy::CheckPermission(const std::shared_ptr<Request>& request) const
192 {
193     uint32_t tokenId = request->GetTokenId();
194     uint32_t firstTokenId = request->GetFirstTokenId();
195     return ((PermissionManager::CheckLocationPermission(tokenId, firstTokenId) ||
196             PermissionManager::CheckApproximatelyPermission(tokenId, firstTokenId)) &&
197             PermissionManager::CheckBackgroundPermission(tokenId, firstTokenId));
198 }
199 
UpdateListOnSuspend(const std::shared_ptr<Request> & request,bool active)200 void LocatorBackgroundProxy::UpdateListOnSuspend(const std::shared_ptr<Request>& request, bool active)
201 {
202 }
203 
UpdateListOnUserSwitch(int32_t userId)204 void LocatorBackgroundProxy::UpdateListOnUserSwitch(int32_t userId)
205 {
206     std::unique_lock lock(requestListMutex_);
207     auto iter = requestsMap_->find(userId);
208     if (iter == requestsMap_->end()) {
209         auto mRequestsList = std::make_shared<std::list<std::shared_ptr<Request>>>();
210         requestsMap_->insert(make_pair(userId, mRequestsList));
211         LBSLOGD(LOCATOR_BACKGROUND_PROXY, "add requsetlist on user:%{public}d", userId);
212     }
213     // if change to another user, proxy requestList should change
214     requestsList_ = (*requestsMap_)[userId];
215     curUserId_ = userId;
216 }
217 
218 
GetRequestsInProxy() const219 const std::list<std::shared_ptr<Request>>& LocatorBackgroundProxy::GetRequestsInProxy() const
220 {
221     return *requestsList_;
222 }
223 
224 // called in LocatorCallbackProxy::OnLocationReport
225 // check if callback is from proxy
IsCallbackInProxy(const sptr<ILocatorCallback> & callback) const226 bool LocatorBackgroundProxy::IsCallbackInProxy(const sptr<ILocatorCallback>& callback) const
227 {
228     if (!featureSwitch_) {
229         return false;
230     }
231     std::unique_lock lock(requestListMutex_);
232     for (auto request : *requestsList_) {
233         if (request->GetLocatorCallBack() == callback) {
234             return true;
235         }
236     }
237     return false;
238 }
239 
getCurrentUserId()240 int32_t LocatorBackgroundProxy::getCurrentUserId()
241 {
242     return curUserId_;
243 }
244 
GetUserId(int32_t uid) const245 int32_t LocatorBackgroundProxy::GetUserId(int32_t uid) const
246 {
247     int userId = 0;
248     AccountSA::OsAccountManager::GetOsAccountLocalIdFromUid(uid, userId);
249     return userId;
250 }
251 
OnUserSwitch(int32_t userId)252 void LocatorBackgroundProxy::OnUserSwitch(int32_t userId)
253 {
254     UpdateListOnUserSwitch(userId);
255     auto locatorAbility = LocatorAbility::GetInstance();
256     if (locatorAbility != nullptr) {
257         locatorAbility->ApplyRequests(0);
258     }
259 }
260 
OnUserRemove(int32_t userId)261 void LocatorBackgroundProxy::OnUserRemove(int32_t userId)
262 {
263     // if user is removed, remove the requestList from the user in requestsMap
264     std::unique_lock lock(requestListMutex_);
265     auto iter = requestsMap_->find(userId);
266     if (iter != requestsMap_->end()) {
267         requestsMap_->erase(iter);
268         LBSLOGD(LOCATOR_BACKGROUND_PROXY, "erase requsetlist on user:%{public}d", userId);
269     }
270 }
271 
272 // limit the number of requests per app
CheckMaxRequestNum(pid_t uid,const std::string & packageName) const273 bool LocatorBackgroundProxy::CheckMaxRequestNum(pid_t uid, const std::string& packageName) const
274 {
275     int32_t num = 0;
276     auto iter = requestsMap_->find(GetUserId(uid));
277     if (iter == requestsMap_->end()) {
278         return false;
279     }
280     for (auto request : *(iter->second)) {
281         if (request->GetUid() == uid && packageName.compare(request->GetPackageName()) == 0) {
282             if (++num >= REQUESTS_NUM_MAX) {
283                 return false;
284             }
285         }
286     }
287     return true;
288 }
289 
OnLocationReport(const std::unique_ptr<Location> & location)290 void LocatorBackgroundProxy::mLocatorCallback::OnLocationReport(const std::unique_ptr<Location>& location)
291 {
292     LBSLOGD(LOCATOR_BACKGROUND_PROXY, "locator background OnLocationReport");
293 }
294 
OnLocatingStatusChange(const int status)295 void LocatorBackgroundProxy::mLocatorCallback::OnLocatingStatusChange(const int status)
296 {
297 }
298 
OnErrorReport(const int errorCode)299 void LocatorBackgroundProxy::mLocatorCallback::OnErrorReport(const int errorCode)
300 {
301 }
302 
UserSwitchSubscriber(const OHOS::EventFwk::CommonEventSubscribeInfo & info)303 LocatorBackgroundProxy::UserSwitchSubscriber::UserSwitchSubscriber(
304     const OHOS::EventFwk::CommonEventSubscribeInfo &info)
305     : CommonEventSubscriber(info)
306 {
307     LBSLOGD(LOCATOR_BACKGROUND_PROXY, "create UserSwitchEventSubscriber");
308 }
309 
OnReceiveEvent(const OHOS::EventFwk::CommonEventData & event)310 void LocatorBackgroundProxy::UserSwitchSubscriber::OnReceiveEvent(const OHOS::EventFwk::CommonEventData& event)
311 {
312     int32_t userId = event.GetCode();
313     const auto action = event.GetWant().GetAction();
314     auto locatorProxy = LocatorBackgroundProxy::GetInstance();
315     LBSLOGD(LOCATOR_BACKGROUND_PROXY, "action = %{public}s, userId = %{public}d", action.c_str(), userId);
316     if (action == OHOS::EventFwk::CommonEventSupport::COMMON_EVENT_USER_SWITCHED) {
317         locatorProxy->OnUserSwitch(userId);
318     } else if (action == OHOS::EventFwk::CommonEventSupport::COMMON_EVENT_USER_REMOVED) {
319         locatorProxy->OnUserRemove(userId);
320     }
321 }
322 
Subscribe()323 bool LocatorBackgroundProxy::UserSwitchSubscriber::Subscribe()
324 {
325     LBSLOGD(LOCATOR_BACKGROUND_PROXY, "subscribe common event");
326     OHOS::EventFwk::MatchingSkills matchingSkills;
327     matchingSkills.AddEvent(OHOS::EventFwk::CommonEventSupport::COMMON_EVENT_USER_SWITCHED);
328     OHOS::EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills);
329     std::shared_ptr<UserSwitchSubscriber> subscriber = std::make_shared<UserSwitchSubscriber>(subscriberInfo);
330     bool result = OHOS::EventFwk::CommonEventManager::SubscribeCommonEvent(subscriber);
331     if (result) {
332     } else {
333         LBSLOGE(LOCATOR_BACKGROUND_PROXY, "Subscribe service event error.");
334     }
335     return result;
336 }
337 
SystemAbilityStatusChangeListener(std::shared_ptr<UserSwitchSubscriber> & subscriber)338 LocatorBackgroundProxy::SystemAbilityStatusChangeListener::SystemAbilityStatusChangeListener(
339     std::shared_ptr<UserSwitchSubscriber> &subscriber) : subscriber_(subscriber)
340 {}
341 
OnAddSystemAbility(int32_t systemAbilityId,const std::string & deviceId)342 void LocatorBackgroundProxy::SystemAbilityStatusChangeListener::OnAddSystemAbility(
343     int32_t systemAbilityId, const std::string& deviceId)
344 {
345     if (systemAbilityId != COMMON_EVENT_SERVICE_ID) {
346         LBSLOGE(LOCATOR_BACKGROUND_PROXY, "systemAbilityId is not COMMON_EVENT_SERVICE_ID");
347         return;
348     }
349     if (subscriber_ == nullptr) {
350         LBSLOGE(LOCATOR_BACKGROUND_PROXY, "OnAddSystemAbility subscribeer is nullptr");
351         return;
352     }
353     bool result = OHOS::EventFwk::CommonEventManager::SubscribeCommonEvent(subscriber_);
354     LBSLOGI(LOCATOR_BACKGROUND_PROXY, "SubscribeCommonEvent subscriber_ result = %{public}d", result);
355 }
356 
OnRemoveSystemAbility(int32_t systemAbilityId,const std::string & deviceId)357 void LocatorBackgroundProxy::SystemAbilityStatusChangeListener::OnRemoveSystemAbility(
358     int32_t systemAbilityId, const std::string& deviceId)
359 {
360     if (systemAbilityId != COMMON_EVENT_SERVICE_ID) {
361         LBSLOGE(LOCATOR_BACKGROUND_PROXY, "systemAbilityId is not COMMON_EVENT_SERVICE_ID");
362         return;
363     }
364     if (subscriber_ == nullptr) {
365         LBSLOGE(LOCATOR_BACKGROUND_PROXY, "OnRemoveSystemAbility subscribeer is nullptr");
366         return;
367     }
368     bool result = OHOS::EventFwk::CommonEventManager::UnSubscribeCommonEvent(subscriber_);
369     LBSLOGE(LOCATOR_BACKGROUND_PROXY, "UnSubscribeCommonEvent subscriber_ result = %{public}d", result);
370 }
371 
IsAppBackground(std::string bundleName)372 bool LocatorBackgroundProxy::IsAppBackground(std::string bundleName)
373 {
374     sptr<ISystemAbilityManager> samgrClient = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
375     if (samgrClient == nullptr) {
376         LBSLOGE(LOCATOR_BACKGROUND_PROXY, "Get system ability manager failed.");
377         return false;
378     }
379     sptr<AppExecFwk::IAppMgr> iAppManager =
380         iface_cast<AppExecFwk::IAppMgr>(samgrClient->GetSystemAbility(APP_MGR_SERVICE_ID));
381     if (iAppManager == nullptr) {
382         LBSLOGE(LOCATOR_BACKGROUND_PROXY, "Failed to get ability manager service.");
383         return false;
384     }
385     std::vector<AppExecFwk::AppStateData> foregroundAppList;
386     iAppManager->GetForegroundApplications(foregroundAppList);
387     auto it = std::find_if(foregroundAppList.begin(), foregroundAppList.end(), [bundleName] (auto foregroundApp) {
388         return bundleName.compare(foregroundApp.bundleName) == 0;
389     });
390     if (it != foregroundAppList.end()) {
391         LBSLOGD(LOCATOR_BACKGROUND_PROXY, "app : %{public}s is foreground.", bundleName.c_str());
392         return false;
393     }
394     return true;
395 }
396 
IsAppBackground(int uid,std::string bundleName)397 bool LocatorBackgroundProxy::IsAppBackground(int uid, std::string bundleName)
398 {
399     std::unique_lock lock(foregroundAppMutex_);
400     auto iter = foregroundAppMap_.find(uid);
401     if (iter == foregroundAppMap_.end()) {
402         return IsAppBackground(bundleName);
403     }
404     return false;
405 }
406 
UpdateBackgroundAppStatues(int32_t uid,int32_t status)407 void LocatorBackgroundProxy::UpdateBackgroundAppStatues(int32_t uid, int32_t status)
408 {
409     std::unique_lock lock(foregroundAppMutex_);
410     if (status == FOREGROUPAPP_STATUS) {
411         foregroundAppMap_[uid] = status;
412     } else {
413         auto iter = foregroundAppMap_.find(uid);
414         if (iter != foregroundAppMap_.end()) {
415             foregroundAppMap_.erase(iter);
416         }
417     }
418     LBSLOGD(REQUEST_MANAGER, "UpdateBackgroundApp uid = %{public}d, state = %{public}d", uid, status);
419 }
420 
RegisterAppStateObserver()421 bool LocatorBackgroundProxy::RegisterAppStateObserver()
422 {
423     if (appStateObserver_ != nullptr) {
424         LBSLOGI(REQUEST_MANAGER, "app state observer exist.");
425         return true;
426     }
427     appStateObserver_ = sptr<AppStateChangeCallback>(new (std::nothrow) AppStateChangeCallback());
428     sptr<ISystemAbilityManager> samgrClient = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
429     if (samgrClient == nullptr) {
430         LBSLOGE(REQUEST_MANAGER, "Get system ability manager failed.");
431         appStateObserver_ = nullptr;
432         return false;
433     }
434     iAppMgr_ = iface_cast<AppExecFwk::IAppMgr>(samgrClient->GetSystemAbility(APP_MGR_SERVICE_ID));
435     if (iAppMgr_ == nullptr) {
436         LBSLOGE(REQUEST_MANAGER, "Failed to get ability manager service.");
437         appStateObserver_ = nullptr;
438         return false;
439     }
440     int32_t result = iAppMgr_->RegisterApplicationStateObserver(appStateObserver_);
441     if (result != 0) {
442         LBSLOGE(REQUEST_MANAGER, "Failed to Register app state observer.");
443         iAppMgr_ = nullptr;
444         appStateObserver_ = nullptr;
445         return false;
446     }
447     return true;
448 }
449 
UnregisterAppStateObserver()450 bool LocatorBackgroundProxy::UnregisterAppStateObserver()
451 {
452     if (iAppMgr_ != nullptr && appStateObserver_ != nullptr) {
453         iAppMgr_->UnregisterApplicationStateObserver(appStateObserver_);
454     }
455     iAppMgr_ = nullptr;
456     appStateObserver_ = nullptr;
457     return true;
458 }
459 
IsAppInLocationContinuousTasks(pid_t uid,pid_t pid)460 bool LocatorBackgroundProxy::IsAppInLocationContinuousTasks(pid_t uid, pid_t pid)
461 {
462 #ifdef BGTASKMGR_SUPPORT
463     std::vector<std::shared_ptr<BackgroundTaskMgr::ContinuousTaskCallbackInfo>> continuousTasks;
464     ErrCode result = BackgroundTaskMgr::BackgroundTaskMgrHelper::GetContinuousTaskApps(continuousTasks);
465     if (result != ERR_OK) {
466         return false;
467     }
468     for (auto iter = continuousTasks.begin(); iter != continuousTasks.end(); iter++) {
469         auto continuousTask = *iter;
470         if (continuousTask == nullptr) {
471             continue;
472         }
473         if (continuousTask->GetCreatorUid() != uid || continuousTask->GetCreatorPid() != pid) {
474             continue;
475         }
476         auto typeIds = continuousTask->GetTypeIds();
477         for (auto typeId : typeIds) {
478             if (typeId == BackgroundTaskMgr::BackgroundMode::Type::LOCATION) {
479                 return true;
480             }
481         }
482     }
483 #endif
484     return false;
485 }
486 
IsAppHasFormVisible(uint32_t tokenId,uint64_t tokenIdEx)487 bool LocatorBackgroundProxy::IsAppHasFormVisible(uint32_t tokenId, uint64_t tokenIdEx)
488 {
489     bool ret = false;
490     auto tokenType = Security::AccessToken::AccessTokenKit::GetTokenTypeFlag(tokenId);
491     if (tokenType != Security::AccessToken::ATokenTypeEnum::TOKEN_HAP) {
492         return ret;
493     }
494 #ifdef FMSKIT_NATIVE_SUPPORT
495     ret = OHOS::AppExecFwk::FormMgr::GetInstance().HasFormVisible(tokenId);
496 #endif
497     return ret;
498 }
499 
AppStateChangeCallback()500 AppStateChangeCallback::AppStateChangeCallback()
501 {
502 }
503 
~AppStateChangeCallback()504 AppStateChangeCallback::~AppStateChangeCallback()
505 {
506 }
507 
OnForegroundApplicationChanged(const AppExecFwk::AppStateData & appStateData)508 void AppStateChangeCallback::OnForegroundApplicationChanged(const AppExecFwk::AppStateData& appStateData)
509 {
510     auto requestManager = RequestManager::GetInstance();
511     int32_t pid = appStateData.pid;
512     int32_t uid = appStateData.uid;
513     int32_t state = appStateData.state;
514     LBSLOGD(REQUEST_MANAGER,
515         "The state of App changed, uid = %{public}d, pid = %{public}d, state = %{public}d", uid, pid, state);
516     requestManager->HandlePowerSuspendChanged(pid, uid, state);
517     auto instance = LocatorBackgroundProxy::GetInstance();
518     instance->UpdateBackgroundAppStatues(uid, state);
519 }
520 } // namespace OHOS
521 } // namespace Location
522