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 "expired_callback_stub.h"
17
18 #include <errors.h>
19
20 #include "transient_task_log.h"
21
22 namespace OHOS {
23 namespace BackgroundTaskMgr {
ExpiredCallbackStub()24 ExpiredCallbackStub::ExpiredCallbackStub() {}
~ExpiredCallbackStub()25 ExpiredCallbackStub::~ExpiredCallbackStub() {}
26
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)27 ErrCode ExpiredCallbackStub::OnRemoteRequest(uint32_t code,
28 MessageParcel& data, MessageParcel& reply, MessageOption& option)
29 {
30 std::u16string descriptor = ExpiredCallbackStub::GetDescriptor();
31 std::u16string remoteDescriptor = data.ReadInterfaceToken();
32 if (descriptor != remoteDescriptor) {
33 BGTASK_LOGE("ExpiredCallbackStub local descriptor not match remote.");
34 return ERR_TRANSACTION_FAILED;
35 }
36 switch (code) {
37 case ON_EXPIRED:
38 return HandleOnExpired(data);
39 default:
40 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
41 }
42 }
43
HandleOnExpired(MessageParcel & data)44 int32_t ExpiredCallbackStub::HandleOnExpired(MessageParcel& data)
45 {
46 OnExpired();
47 return ERR_NONE;
48 }
49 } // namespace BackgroundTaskMgr
50 } // namespace OHOS