1 /* 2 * Copyright (c) 2024 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 ELAPSED_REAL_TIME_CHECK_H 17 #define ELAPSED_REAL_TIME_CHECK_H 18 #ifdef FEATURE_GNSS_SUPPORT 19 #ifdef TIME_SERVICE_ENABLE 20 21 #include <cstdint> 22 23 namespace OHOS { 24 namespace Location { 25 class ElapsedRealTimeCheck { 26 public: 27 static ElapsedRealTimeCheck* GetInstance(); 28 void CheckRealTime(int64_t time); 29 bool CanTrustElapsedRealTime(); 30 31 private: 32 ElapsedRealTimeCheck(); 33 ~ElapsedRealTimeCheck(); 34 35 int64_t timeBegin_ = 0; 36 int64_t timeBeginElapsed_ = 0; 37 int64_t timeCheck_ = 0; 38 int64_t timeCheckElapsed_ = 0; 39 bool canTrustElapsedRealTime_ = true; // default is true, usually we trust this time. 40 }; 41 } // namespace Location 42 } // namespace OHOS 43 44 #endif // TIME_SERVICE_ENABLE 45 #endif // FEATURE_GNSS_SUPPORT 46 #endif // ELAPSED_REAL_TIME_CHECK_H 47