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_STUB_H
17 #define SERVICES_INCLUDE_TIME_SERVICE_STUB_H
18 
19 #include <map>
20 
21 #include "ipc_skeleton.h"
22 #include "iremote_stub.h"
23 #include "itimer_call_back.h"
24 #include "time_service_interface.h"
25 #include "time_permission.h"
26 #include "time_service_ipc_interface_code.h"
27 
28 namespace OHOS {
29 namespace MiscServices {
30 class TimeServiceStub : public IRemoteStub<ITimeService> {
31 public:
32     TimeServiceStub();
33     ~TimeServiceStub();
34     int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
35 
36 private:
37     using TimeServiceFunc = std::function<int32_t(MessageParcel &data, MessageParcel &reply)>;
38     int32_t OnSetTime(MessageParcel &data, MessageParcel &reply);
39     int32_t OnSetTimeZone(MessageParcel &data, MessageParcel &reply);
40     int32_t OnGetTimeZone(MessageParcel &data, MessageParcel &reply);
41     int32_t OnGetThreadTimeMs(MessageParcel &data, MessageParcel &reply);
42     int32_t OnGetThreadTimeNs(MessageParcel &data, MessageParcel &reply);
43 
44     int32_t OnCreateTimer(MessageParcel &data, MessageParcel &reply);
45     int32_t OnStartTimer(MessageParcel &data, MessageParcel &reply);
46     int32_t OnStopTimer(MessageParcel &data, MessageParcel &reply);
47     int32_t OnDestroyTimer(MessageParcel &data, MessageParcel &reply);
48     int32_t OnNetworkTimeStatusOff(MessageParcel &data, MessageParcel &reply);
49     int32_t OnNetworkTimeStatusOn(MessageParcel &data, MessageParcel &reply);
50     int32_t OnTimerProxy(MessageParcel &data, MessageParcel &reply);
51     int32_t OnPidTimerProxy(MessageParcel &data, MessageParcel &reply);
52     int32_t OnAdjustTimer(MessageParcel &data, MessageParcel &reply);
53     int32_t OnSetTimerExemption(MessageParcel &data, MessageParcel &reply);
54     int32_t OnAllProxyReset(MessageParcel &data, MessageParcel &reply);
55     int32_t OnGetNtpTimeMs(MessageParcel &data, MessageParcel &reply);
56     int32_t OnGetRealTimeMs(MessageParcel &data, MessageParcel &reply);
57     std::map<TimeServiceIpcInterfaceCode, TimeServiceFunc> memberFuncMap_;
58 };
59 } // namespace MiscServices
60 } // namespace OHOS
61 
62 #endif // SERVICES_INCLUDE_TIME_SERVICE_STUB_H