• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "itimer_info.h"
21 #include "want_agent_helper.h"
22 
23 namespace OHOS {
24 namespace MiscServices {
25 class ITimeService : public IRemoteBroker {
26 public:
27 
28     enum APIVersion : int8_t {
29         API_VERSION_7 = 0,
30         API_VERSION_9 = 1,
31     };
32     /**
33    * SetTime
34    *
35    * @param time int64_t set milliseconds
36    * @return int32_t ERR_OK on success, other on failure.
37    */
38     virtual int32_t SetTime(int64_t time, APIVersion apiVersion = APIVersion::API_VERSION_7) = 0;
39     /**
40      * SetTimeZone
41      *
42      * @param timezoneId std::string &timezoneId string
43      * @return int32_t ERR_OK on success, other on failure.
44      */
45     virtual int32_t SetTimeZone(const std::string &timezoneId, APIVersion apiVersion = APIVersion::API_VERSION_7) = 0;
46 
47     /**
48      * GetTimeZone
49      *
50      * @param timezoneId std::string &timezoneId string
51      * @return int32_t ERR_OK on success, other on failure.
52      */
53     virtual int32_t GetTimeZone(std::string &timezoneId) = 0;
54 
55     /**
56     * GetWallTimeMs
57     *
58     * @param times result of times ,unit: millisecond
59     * @return int32_t ERR_OK on success, other on failure.
60     */
61     virtual int32_t GetWallTimeMs(int64_t &times) = 0;
62 
63     /**
64     * GetWallTimeNs
65     *
66     * @param times result of times ,unit: Nanosecond
67     * @return int32_t ERR_OK on success, other on failure.
68     */
69     virtual int32_t GetWallTimeNs(int64_t &times) = 0;
70 
71     /**
72     * GetBootTimeMs
73     *
74     * @param times result of times ,unit: millisecond
75     * @return int32_t ERR_OK on success, other on failure.
76     */
77     virtual int32_t GetBootTimeMs(int64_t &times) = 0;
78 
79     /**
80     * GetBootTimeNs
81     *
82     * @param times result of times ,unit: millisecond
83     * @return int32_t ERR_OK on success, other on failure.
84     */
85     virtual int32_t GetBootTimeNs(int64_t &times) = 0;
86 
87     /**
88     * GetMonotonicTimeMs
89     *
90     * @param times result of times ,unit: millisecond
91     * @return int32_t ERR_OK on success, other on failure.
92     */
93     virtual int32_t GetMonotonicTimeMs(int64_t &times) = 0;
94 
95     /**
96     * GetMonotonicTimeNs
97     *
98     * @param times result of times ,unit: Nanosecond
99     * @return int32_t ERR_OK on success, other on failure.
100     */
101     virtual int32_t GetMonotonicTimeNs(int64_t &times) = 0;
102 
103     /**
104     * GetThreadTimeMs
105     *
106     * @param times result of times ,unit: millisecond
107     * @return int32_t ERR_OK on success, other on failure.
108     */
109     virtual int32_t GetThreadTimeMs(int64_t &times) = 0;
110 
111     /**
112     * GetThreadTimeNs
113     *
114     * @param times result of times ,unit: Nanosecond
115     * @return int32_t ERR_OK on success, other on failure.
116     */
117     virtual int32_t GetThreadTimeNs(int64_t &times) = 0;
118 
119     /**
120      * CreateTimer
121      *
122      * @param type    timer type
123      * @param repeat  is repeat or not
124      * @param timerCallback remoteobject
125      * @return uint64_t > 0 on success, == 0 failure.
126      */
127     virtual int32_t CreateTimer(const std::shared_ptr<ITimerInfo> &timerOptions, sptr<IRemoteObject> &timerCallback,
128         uint64_t &timerId) = 0;
129 
130     /**
131     * StartTimer
132     *
133     * @param timerId indicate timerId
134     * @param treggerTime  trigger times
135     * @return bool true on success, false on failure.
136     */
137     virtual int32_t StartTimer(uint64_t timerId, uint64_t triggerTime) = 0;
138 
139     /**
140     * StopTimer
141     *
142     * @param timerId indicate timerId
143     * @return bool true on success, false on failure.
144     */
145     virtual int32_t StopTimer(uint64_t timerId) = 0;
146 
147     /**
148     * DestroyTimer
149     *
150     * @param timerId indicate timerId
151     * @return bool true on success, false on failure.
152     */
153     virtual int32_t DestroyTimer(uint64_t timerId) = 0;
154 
155     /**
156      * ProxyTimer
157      * @param uid the uid
158      * @param isProxy true if proxy, false if not proxy
159      * @param needRetrigger true if need retrigger, false if not.
160      * @return bool true on success, false on failure.
161      */
162     virtual bool ProxyTimer(int32_t uid, bool isProxy, bool needRetrigger) = 0;
163 
164     /**
165      * ResetAllProxy
166      * @return bool true on success, false on failure.
167      */
168     virtual bool ResetAllProxy() = 0;
169 
170     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.miscservices.time.ITimeService");
171 };
172 } // namespace MiscServices
173 } // namespace OHOS
174 #endif // SERVICES_INCLUDE_TIME_SERVICE_INTERFACE_H