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 #ifndef REPORT_MANAGER_H 17 #define REPORT_MANAGER_H 18 19 #include <singleton.h> 20 #include <string> 21 #include <time.h> 22 23 #include "i_locator_callback.h" 24 #include "location.h" 25 #include "request.h" 26 27 namespace OHOS { 28 namespace Location { 29 class ReportManager : public DelayedSingleton<ReportManager> { 30 public: 31 ReportManager(); 32 ~ReportManager(); 33 bool ReportRemoteCallback(sptr<ILocatorCallback>& locatorCallback, int type, int result); 34 bool OnReportLocation(const std::unique_ptr<Location>& location, std::string abilityName); 35 bool ResultCheck(const std::unique_ptr<Location>& location, const std::shared_ptr<Request>& request); 36 void SetLastLocation(const std::unique_ptr<Location>& location); 37 std::unique_ptr<Location> GetLastLocation(); 38 std::unique_ptr<Location> GetPermittedLocation(pid_t uid, uint32_t tokenId, uint32_t firstTokenId, 39 const std::unique_ptr<Location>& location); 40 void UpdateRandom(); 41 private: 42 struct timespec lastUpdateTime_; 43 double offsetRandom_; 44 Location lastLocation_; 45 std::unique_ptr<Location> ApproximatelyLocation(const std::unique_ptr<Location>& location); 46 bool ProcessRequestForReport(std::shared_ptr<Request>& request, 47 std::unique_ptr<std::list<std::shared_ptr<Request>>>& deadRequests, const std::unique_ptr<Location>& location); 48 }; 49 } // namespace OHOS 50 } // namespace Location 51 #endif // REPORT_MANAGER_H 52