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 TIME_MANAGER_H 17#define TIME_MANAGER_H 18#ifdef FEATURE_GNSS_SUPPORT 19#ifdef TIME_SERVICE_ENABLE 20 21#include <string> 22 23namespace OHOS { 24namespace Location { 25const int64_t EXPIRT_TIME = 14 * 24 * 60 * 60 * 1000L; // 14 day, two week 26 27class TimeManager { 28public: 29 TimeManager() = default; 30 explicit TimeManager(int64_t expireTime) : expireTime_(expireTime) {} 31 ~TimeManager() = default; 32 int64_t GetCurrentTime(); 33 void SetCurrentTime(int64_t msTime, int64_t msTimeSynsBoot); 34 int64_t GetTimestamp(); 35 36private: 37 int64_t timestamp_ = 0; 38 int64_t timeSinceBoot_ = 0; 39 int64_t expireTime_ = EXPIRT_TIME; 40}; 41} // namespace Location 42} // namespace OHOS 43 44#endif // TIME_SERVICE_ENABLE 45#endif // FEATURE_GNSS_SUPPORT 46#endif // TIME_MANAGER_H 47