1 /* 2 * Copyright (C) 2021 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 SERVICES_INCLUDE_TIME_SERVICE_PROXY_H 17 #define SERVICES_INCLUDE_TIME_SERVICE_PROXY_H 18 19 #include "iremote_proxy.h" 20 #include "time_service_interface.h" 21 #include <unordered_set> 22 23 namespace OHOS { 24 namespace MiscServices { 25 class TimeServiceProxy : public IRemoteProxy<ITimeService> { 26 public: 27 explicit TimeServiceProxy(const sptr<IRemoteObject> &object); 28 ~TimeServiceProxy() = default; 29 DISALLOW_COPY_AND_MOVE(TimeServiceProxy); 30 31 int32_t SetTime(int64_t time, APIVersion apiVersion = APIVersion::API_VERSION_7) override; 32 int32_t SetTimeZone(const std::string &timeZoneId, APIVersion apiVersion = APIVersion::API_VERSION_7) override; 33 int32_t GetTimeZone(std::string &timeZoneId) override; 34 int32_t GetThreadTimeMs(int64_t ×) override; 35 int32_t GetThreadTimeNs(int64_t ×) override; 36 int32_t CreateTimer(const std::shared_ptr<ITimerInfo> &timerOptions, sptr<IRemoteObject> &timerCallback, 37 uint64_t &timerId) override; 38 int32_t StartTimer(uint64_t timerId, uint64_t triggerTime) override; 39 int32_t StopTimer(uint64_t timerId) override; 40 int32_t DestroyTimer(uint64_t timerId, bool isAsync) override; 41 bool ProxyTimer(int32_t uid, bool isProxy, bool needRetrigger) override; 42 bool ProxyTimer(int32_t uid, std::set<int> pidList, bool isProxy, bool needRetrigger) override; 43 int32_t AdjustTimer(bool isAdjust, uint32_t interval) override; 44 int32_t SetTimerExemption(const std::unordered_set<std::string> &nameArr, bool isExemption) override; 45 bool ResetAllProxy() override; 46 int32_t GetNtpTimeMs(int64_t &time) override; 47 int32_t GetRealTimeMs(int64_t &time) override; 48 49 private: 50 static inline BrokerDelegator<TimeServiceProxy> delegator_; 51 }; 52 } // namespace MiscServices 53 } // namespace OHOS 54 #endif // SERVICES_INCLUDE_TIME_SERVICE_PROXY_H