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