• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 "stop_user_callback_proxy.h"
17 
18 #include "hilog_wrapper.h"
19 #include "ipc_types.h"
20 #include "message_parcel.h"
21 
22 namespace OHOS {
23 namespace AAFwk {
OnStopUserDone(int userId,int errcode)24 void StopUserCallbackProxy::OnStopUserDone(int userId, int errcode)
25 {
26     SendRequestCommon(userId, errcode, IStopUserCallback::StopUserCallbackCmd::ON_STOP_USER_DONE);
27 }
28 
SendRequestCommon(int userId,int errcode,IStopUserCallback::StopUserCallbackCmd cmd)29 void StopUserCallbackProxy::SendRequestCommon(int userId, int errcode, IStopUserCallback::StopUserCallbackCmd cmd)
30 {
31     MessageParcel data;
32     MessageParcel reply;
33     MessageOption option(MessageOption::TF_ASYNC);
34 
35     HILOG_INFO("StopUserCallbackProxy, sendrequest, cmd:%{public}d, userId:%{public}d, errcode:%{public}d",
36         cmd, userId, errcode);
37     if (!data.WriteInterfaceToken(IStopUserCallback::GetDescriptor())) {
38         HILOG_ERROR("Write interface token failed.");
39         return;
40     }
41 
42     if (!data.WriteInt32(userId)) {
43         HILOG_ERROR("Write userId error.");
44         return;
45     }
46 
47     if (!data.WriteInt32(errcode)) {
48         HILOG_ERROR("Write errcode error.");
49         return;
50     }
51 
52     sptr<IRemoteObject> remote = Remote();
53     if (remote == nullptr) {
54         HILOG_ERROR("remote object is nullptr.");
55         return;
56     }
57 
58     int error = remote->SendRequest(cmd, data, reply, option);
59     if (error != NO_ERROR) {
60         HILOG_ERROR("OnStopUserDone fail, error: %{public}d", error);
61         return;
62     }
63 }
64 }  // namespace AAFwk
65 }  // namespace OHOS
66