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 "session_handler_stub.h"
17 #include "hilog_tag_wrapper.h"
18 #include "message_parcel.h"
19 
20 namespace OHOS {
21 namespace AAFwk {
SessionHandlerStub()22 SessionHandlerStub::SessionHandlerStub() {}
23 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)24 int32_t SessionHandlerStub::OnRemoteRequest(
25     uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
26 {
27     std::u16string descriptor = SessionHandlerStub::GetDescriptor();
28     std::u16string remoteDescriptor = data.ReadInterfaceToken();
29     if (descriptor != remoteDescriptor) {
30         TAG_LOGE(AAFwkTag::DEFAULT, "descriptor not equal remote");
31         return ERR_INVALID_STATE;
32     }
33 
34     if (code < ISessionHandler::CODE_MAX) {
35         if (code == ON_SESSION_MOVED_TO_FRONT) {
36             return OnSessionMovedToFrontInner(data, reply);
37         }
38     }
39     return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
40 }
41 
OnSessionMovedToFrontInner(MessageParcel & data,MessageParcel & reply)42 int32_t SessionHandlerStub::OnSessionMovedToFrontInner(MessageParcel &data, MessageParcel &reply)
43 {
44     int32_t sessionId = data.ReadInt32();
45     OnSessionMovedToFront(sessionId);
46     return NO_ERROR;
47 }
48 
OnSessionMovedToFront(int32_t sessionId)49 void SessionHandlerStub::OnSessionMovedToFront(int32_t sessionId)
50 {
51     TAG_LOGI(AAFwkTag::DEFAULT, "sessionId:%{public}d", sessionId);
52 }
53 }
54 }