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