/* * Copyright (C) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef REQUEST_MANAGER_H #define REQUEST_MANAGER_H #include #include #include #include #include "iremote_object.h" #include "i_locator_callback.h" #include "request.h" #include "work_record.h" namespace OHOS { namespace Location { class RequestManager : public DelayedSingleton { public: RequestManager(); ~RequestManager(); bool InitSystemListeners(); void HandleStartLocating(std::shared_ptr request); void HandleStopLocating(sptr callback); void HandlePowerSuspendChanged(int32_t pid, int32_t uid, int32_t flag); void UpdateRequestRecord(std::shared_ptr request, bool shouldInsert); void HandleRequest(); void UpdateUsingPermission(std::shared_ptr request); void HandlePermissionChanged(uint32_t tokenId); private: bool RestorRequest(std::shared_ptr request); void UpdateRequestRecord(std::shared_ptr request, std::string abilityName, bool shouldInsert); void DeleteRequestRecord(std::shared_ptr>> requests); void HandleRequest(std::string abilityName); void ProxySendLocationRequest(std::string abilityName, WorkRecord& workRecord); sptr GetRemoteObject(std::string abilityName); bool IsUidInProcessing(int32_t uid); void UpdateUsingLocationPermission(std::shared_ptr request); void UpdateUsingApproximatelyPermission(std::shared_ptr request); void UpdateUsingBackgroundPermission(std::shared_ptr request); bool ActiveLocatingStrategies(const std::shared_ptr& request); bool AddRequestToWorkRecord(std::shared_ptr& request, std::shared_ptr& workRecord); std::list runningUids_; static std::mutex requestMutex_; }; } // namespace Location } // namespace OHOS #endif // REQUEST_MANAGER_H