1 /*
2 * Copyright (c) 2023 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_wrapper.h"
18 #include "message_parcel.h"
19
20 namespace OHOS {
21 namespace AAFwk {
SessionHandlerStub()22 SessionHandlerStub::SessionHandlerStub()
23 {
24 vecMemberFunc_.resize(ISessionHandler::CODE_MAX);
25 vecMemberFunc_[ON_SESSION_MOVED_TO_FRONT] = &SessionHandlerStub::OnSessionMovedToFrontInner;
26 }
27
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)28 int32_t SessionHandlerStub::OnRemoteRequest(
29 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
30 {
31 std::u16string descriptor = SessionHandlerStub::GetDescriptor();
32 std::u16string remoteDescriptor = data.ReadInterfaceToken();
33 if (descriptor != remoteDescriptor) {
34 HILOG_ERROR("local descriptor is not equal to remote.");
35 return ERR_INVALID_STATE;
36 }
37
38 if (code < ISessionHandler::CODE_MAX) {
39 auto memberFunc = vecMemberFunc_[code];
40 return (this->*memberFunc)(data, reply);
41 }
42 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
43 }
44
OnSessionMovedToFrontInner(MessageParcel & data,MessageParcel & reply)45 int32_t SessionHandlerStub::OnSessionMovedToFrontInner(MessageParcel &data, MessageParcel &reply)
46 {
47 int32_t sessionId = data.ReadInt32();
48 OnSessionMovedToFront(sessionId);
49 return NO_ERROR;
50 }
51
OnSessionMovedToFront(int32_t sessionId)52 void SessionHandlerStub::OnSessionMovedToFront(int32_t sessionId)
53 {
54 HILOG_INFO("call, sessionId:%{public}d", sessionId);
55 }
56 }
57 }