• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
OnLogoutUserDoneInner(MessageParcel & data,MessageParcel & reply)40 int UserCallbackStub::OnLogoutUserDoneInner(MessageParcel &data, MessageParcel &reply)
41 {
42     auto accountId = data.ReadInt32();
43     auto errCode = data.ReadInt32();
44     OnLogoutUserDone(accountId, errCode);
45     return NO_ERROR;
46 }
47 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)48 int UserCallbackStub::OnRemoteRequest(
49     uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
50 {
51     std::u16string descriptor = UserCallbackStub::GetDescriptor();
52     std::u16string remoteDescriptor = data.ReadInterfaceToken();
53     if (descriptor != remoteDescriptor) {
54         TAG_LOGI(AAFwkTag::ABILITYMGR, "local descriptor invalid");
55         return ERR_INVALID_STATE;
56     }
57 
58     if (code < UserCallbackCmd::CMD_MAX && code >= 0) {
59         switch (code) {
60             case UserCallbackCmd::ON_STOP_USER_DONE:
61                 return OnStopUserDoneInner(data, reply);
62                 break;
63             case UserCallbackCmd::ON_START_USER_DONE:
64                 return OnStartUserDoneInner(data, reply);
65                 break;
66             case UserCallbackCmd::ON_LOGOUT_USER_DONE:
67                 return OnLogoutUserDoneInner(data, reply);
68                 break;
69         }
70     }
71 
72     return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
73 }
74 }  // namespace AAFwk
75 }  // namespace OHOS
76