1 /*
2  * Copyright (c) 2021-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 "user_callback_stub.h"
17 
18 #include "hilog_tag_wrapper.h"
19 
20 namespace OHOS {
21 namespace AAFwk {
UserCallbackStub()22 UserCallbackStub::UserCallbackStub() {}
23 
OnStopUserDoneInner(MessageParcel & data,MessageParcel & reply)24 int UserCallbackStub::OnStopUserDoneInner(MessageParcel &data, MessageParcel &reply)
25 {
26     auto accountId = data.ReadInt32();
27     auto errCode = data.ReadInt32();
28     OnStopUserDone(accountId, errCode);
29     return NO_ERROR;
30 }
31 
OnStartUserDoneInner(MessageParcel & data,MessageParcel & reply)32 int UserCallbackStub::OnStartUserDoneInner(MessageParcel &data, MessageParcel &reply)
33 {
34     auto accountId = data.ReadInt32();
35     auto errCode = data.ReadInt32();
36     OnStartUserDone(accountId, errCode);
37     return NO_ERROR;
38 }
39 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)40 int UserCallbackStub::OnRemoteRequest(
41     uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
42 {
43     std::u16string descriptor = UserCallbackStub::GetDescriptor();
44     std::u16string remoteDescriptor = data.ReadInterfaceToken();
45     if (descriptor != remoteDescriptor) {
46         TAG_LOGI(AAFwkTag::ABILITYMGR, "Local descriptor is not equal to remote");
47         return ERR_INVALID_STATE;
48     }
49 
50     if (code < UserCallbackCmd::CMD_MAX && code >= 0) {
51         switch (code) {
52             case UserCallbackCmd::ON_STOP_USER_DONE:
53                 return OnStopUserDoneInner(data, reply);
54                 break;
55             case UserCallbackCmd::ON_START_USER_DONE:
56                 return OnStartUserDoneInner(data, reply);
57                 break;
58         }
59     }
60 
61     return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
62 }
63 }  // namespace AAFwk
64 }  // namespace OHOS
65