1 /*
2  * Copyright (c) 2022 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 #include "timer_notify_callback_stub.h"
17 
18 namespace OHOS {
19 namespace MiscServices {
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)20 int TimerNotifyCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
21     MessageOption &option)
22 {
23     TIME_HILOGD(TIME_MODULE_SERVICE, "cmd = %{public}d, flags = %{public}d", code, option.GetFlags());
24     std::u16string descripter = GetDescriptor();
25     std::u16string remoteDescripter = data.ReadInterfaceToken();
26     if (descripter != remoteDescripter) {
27         TIME_HILOGE(TIME_MODULE_SERVICE, "failed,descripter is not matched!");
28         return E_TIME_READ_PARCEL_ERROR;
29     }
30 
31     switch (code) {
32         case static_cast<int>(ITimerNotifyCallback::Message::FINISH): {
33             return OnFinishStub(data);
34         }
35         default:
36             return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
37     }
38     return ERR_OK;
39 }
40 
OnFinishStub(MessageParcel & data)41 int TimerNotifyCallbackStub::OnFinishStub(MessageParcel& data)
42 {
43     TIME_HILOGD(TIME_MODULE_SERVICE, "start.");
44     auto timerId = data.ReadUint64();
45     TIME_HILOGD(TIME_MODULE_SERVICE, "id: %{public}" PRId64 "", timerId);
46     Finish(timerId);
47     TIME_HILOGD(TIME_MODULE_SERVICE, "end.");
48     return ERR_OK;
49 }
50 } // namespace MiscServices
51 } // namespace OHOS