1 /*
2  * Copyright (c) 2023-2024 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 "prepare_terminate_callback_stub.h"
17 #include "hilog_tag_wrapper.h"
18 
19 namespace OHOS {
20 namespace AAFwk {
21 
PrepareTerminateCallbackStub()22 PrepareTerminateCallbackStub::PrepareTerminateCallbackStub() {}
23 
~PrepareTerminateCallbackStub()24 PrepareTerminateCallbackStub::~PrepareTerminateCallbackStub()
25 {
26     TAG_LOGI(AAFwkTag::ABILITYMGR, "call");
27 }
28 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)29 int32_t PrepareTerminateCallbackStub::OnRemoteRequest(
30     uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
31 {
32     if (data.ReadInterfaceToken() != IPrepareTerminateCallback::GetDescriptor()) {
33         TAG_LOGE(AAFwkTag::ABILITYMGR, "InterfaceToken not equal IPrepareTerminateCallback's descriptor.");
34         return ERR_INVALID_STATE;
35     }
36 
37     if (code == ON_DO_PREPARE_TERMINATE) {
38         return DoPrepareTerminateInner(data, reply);
39     }
40 
41     TAG_LOGW(AAFwkTag::ABILITYMGR, "default case, needs to be checked.");
42     return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
43 }
44 
DoPrepareTerminateInner(MessageParcel & data,MessageParcel & reply)45 int32_t PrepareTerminateCallbackStub::DoPrepareTerminateInner(MessageParcel &data, MessageParcel &reply)
46 {
47     TAG_LOGD(AAFwkTag::ABILITYMGR, "call");
48     DoPrepareTerminate();
49     return ERR_OK;
50 }
51 }
52 }
53