1 /*
2 * Copyright (c) 2021 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 "stop_user_callback_stub.h"
17
18 #include "hilog_wrapper.h"
19 #include "ipc_types.h"
20 #include "message_parcel.h"
21
22 namespace OHOS {
23 namespace AAFwk {
StopUserCallbackStub()24 StopUserCallbackStub::StopUserCallbackStub()
25 {
26 vecMemberFunc_.resize(StopUserCallbackCmd::CMD_MAX);
27 vecMemberFunc_[StopUserCallbackCmd::ON_STOP_USER_DONE] = &StopUserCallbackStub::OnStopUserDoneInner;
28 }
29
OnStopUserDoneInner(MessageParcel & data,MessageParcel & reply)30 int StopUserCallbackStub::OnStopUserDoneInner(MessageParcel &data, MessageParcel &reply)
31 {
32 auto accountId = data.ReadInt32();
33 auto errCode = data.ReadInt32();
34 OnStopUserDone(accountId, errCode);
35 return NO_ERROR;
36 }
37
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)38 int StopUserCallbackStub::OnRemoteRequest(
39 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
40 {
41 std::u16string descriptor = StopUserCallbackStub::GetDescriptor();
42 std::u16string remoteDescriptor = data.ReadInterfaceToken();
43 if (descriptor != remoteDescriptor) {
44 HILOG_INFO("Local descriptor is not equal to remote");
45 return ERR_INVALID_STATE;
46 }
47
48 if (code < StopUserCallbackCmd::CMD_MAX && code >= 0) {
49 auto memberFunc = vecMemberFunc_[code];
50 return (this->*memberFunc)(data, reply);
51 }
52
53 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
54 }
55 } // namespace AAFwk
56 } // namespace OHOS
57