• 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 
17 #include "timer_call_back_proxy.h"
18 
19 namespace OHOS {
20 namespace MiscServices {
TimerCallbackProxy(const sptr<IRemoteObject> & object)21 TimerCallbackProxy::TimerCallbackProxy(const sptr<IRemoteObject> &object) : IRemoteProxy<ITimerCallback>(object)
22 {
23 }
24 
25 
~TimerCallbackProxy()26 TimerCallbackProxy::~TimerCallbackProxy()
27 {
28     TIME_HILOGD(TIME_MODULE_CLIENT, "TimerCallbackProxy instance destoryed");
29 }
30 
NotifyTimer(const uint64_t timerId)31 void TimerCallbackProxy::NotifyTimer(const uint64_t timerId)
32 {
33     TIME_HILOGD(TIME_MODULE_CLIENT, "start id: %{public}" PRId64 "", timerId);
34     sptr<IRemoteObject> remote = Remote();
35     if (remote == nullptr) {
36         return;
37     }
38 
39     MessageParcel data;
40     MessageParcel reply;
41     MessageOption option;
42 
43     if (!data.WriteInterfaceToken(GetDescriptor())) {
44         TIME_HILOGE(TIME_MODULE_CLIENT, "write descriptor failed!");
45         return;
46     }
47 
48     if (!data.WriteUint64(timerId)) {
49         TIME_HILOGE(TIME_MODULE_CLIENT, "write timerId failed!");
50         return;
51     }
52     int ret = remote->SendRequest(static_cast<int>(ITimerCallback::Message::NOTIFY_TIMER), data, reply, option);
53     if (ret != ERR_OK) {
54         TIME_HILOGE(TIME_MODULE_CLIENT, "SendRequest is failed, error code: %{public}d", ret);
55     }
56     TIME_HILOGI(TIME_MODULE_CLIENT, "end.");
57 }
58 } // namespace MiscServices
59 } // namespace OHOS
60