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_INTERFACE_H 17 #define SERVICES_INCLUDE_TIME_SERVICE_INTERFACE_H 18 19 #include "iremote_broker.h" 20 #include "want_agent_helper.h" 21 22 namespace OHOS { 23 namespace MiscServices { 24 class ITimeService : public IRemoteBroker { 25 public: 26 // remote method code 27 enum { 28 SET_TIME = 0, 29 SET_TIME_ZONE = 1, 30 GET_TIME_ZONE = 2, 31 GET_WALL_TIME_MILLI = 3, 32 GET_WALL_TIME_NANO = 4, 33 GET_BOOT_TIME_MILLI = 5, 34 GET_BOOT_TIME_NANO = 6, 35 GET_MONO_TIME_MILLI = 7, 36 GET_MONO_TIME_NANO = 8, 37 GET_THREAD_TIME_MILLI = 9, 38 GET_THREAD_TIME_NANO = 10, 39 CREATE_TIMER = 11, 40 START_TIMER = 12, 41 STOP_TIMER = 13, 42 DESTORY_TIMER = 14, 43 NETWORK_TIME_ON = 15, 44 NETWORK_TIME_OFF = 16 45 }; 46 /** 47 * SetTime 48 * 49 * @param time int64_t set milliseconds 50 * @return int32_t ERR_OK on success, other on failure. 51 */ 52 virtual int32_t SetTime(const int64_t time) = 0; 53 54 /** 55 * SetTimeZone 56 * 57 * @param timezoneId std::string &timezoneId string 58 * @return int32_t ERR_OK on success, other on failure. 59 */ 60 virtual int32_t SetTimeZone(const std::string timezoneId) = 0; 61 62 /** 63 * GetTimeZone 64 * 65 * @param timezoneId std::string &timezoneId string 66 * @return int32_t ERR_OK on success, other on failure. 67 */ 68 virtual int32_t GetTimeZone(std::string &timezoneId) = 0; 69 70 /** 71 * GetWallTimeMs 72 * 73 * @param times result of times ,unit: millisecond 74 * @return int32_t ERR_OK on success, other on failure. 75 */ 76 virtual int32_t GetWallTimeMs(int64_t ×) = 0; 77 78 /** 79 * GetWallTimeNs 80 * 81 * @param times result of times ,unit: Nanosecond 82 * @return int32_t ERR_OK on success, other on failure. 83 */ 84 virtual int32_t GetWallTimeNs(int64_t ×) = 0; 85 86 /** 87 * GetBootTimeMs 88 * 89 * @param times result of times ,unit: millisecond 90 * @return int32_t ERR_OK on success, other on failure. 91 */ 92 virtual int32_t GetBootTimeMs(int64_t ×) = 0; 93 94 /** 95 * GetBootTimeNs 96 * 97 * @param times result of times ,unit: millisecond 98 * @return int32_t ERR_OK on success, other on failure. 99 */ 100 virtual int32_t GetBootTimeNs(int64_t ×) = 0; 101 102 /** 103 * GetMonotonicTimeMs 104 * 105 * @param times result of times ,unit: millisecond 106 * @return int32_t ERR_OK on success, other on failure. 107 */ 108 virtual int32_t GetMonotonicTimeMs(int64_t ×) = 0; 109 110 /** 111 * GetMonotonicTimeNs 112 * 113 * @param times result of times ,unit: Nanosecond 114 * @return int32_t ERR_OK on success, other on failure. 115 */ 116 virtual int32_t GetMonotonicTimeNs(int64_t ×) = 0; 117 118 /** 119 * GetThreadTimeMs 120 * 121 * @param times result of times ,unit: millisecond 122 * @return int32_t ERR_OK on success, other on failure. 123 */ 124 virtual int32_t GetThreadTimeMs(int64_t ×) = 0; 125 126 /** 127 * GetThreadTimeNs 128 * 129 * @param times result of times ,unit: Nanosecond 130 * @return int32_t ERR_OK on success, other on failure. 131 */ 132 virtual int32_t GetThreadTimeNs(int64_t ×) = 0; 133 134 /** 135 * CreateTimer 136 * 137 * @param type timer type 138 * @param repeat is repeat or not 139 * @param timerCallback remoteobject 140 * @return uint64_t > 0 on success, == 0 failure. 141 */ 142 virtual uint64_t CreateTimer(int32_t type, bool repeat, uint64_t interval, sptr<IRemoteObject> &timerCallback) = 0; 143 144 /** 145 * StartTimer 146 * 147 * @param timerId indicate timerId 148 * @param treggerTime trigger times 149 * @return bool true on success, false on failure. 150 */ 151 virtual bool StartTimer(uint64_t timerId, uint64_t treggerTime) = 0; 152 153 /** 154 * StopTimer 155 * 156 * @param timerId indicate timerId 157 * @return bool true on success, false on failure. 158 */ 159 virtual bool StopTimer(uint64_t timerId) = 0; 160 161 /** 162 * DestroyTimer 163 * 164 * @param timerId indicate timerId 165 * @return bool true on success, false on failure. 166 */ 167 virtual bool DestroyTimer(uint64_t timerId) = 0; 168 169 /** 170 * NetworkTimeStatusOff 171 * @return void. 172 */ 173 virtual void NetworkTimeStatusOff() = 0; 174 175 /** 176 * NetworkTimeStatusOn 177 * @return void. 178 */ 179 virtual void NetworkTimeStatusOn() = 0; 180 181 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.miscservices.time.ITimeService"); 182 }; 183 } // namespace MiscServices 184 } // namespace OHOS 185 #endif // SERVICES_INCLUDE_TIME_SERVICE_INTERFACE_H