1 /*
2 * Copyright (c) 2022 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 "container_manager_proxy.h"
17
18 #include "errors.h"
19 #include "string_ex.h"
20
21 namespace OHOS {
22 namespace AAFwk {
WriteInterfaceToken(MessageParcel & data)23 bool ContainerManagerProxy::WriteInterfaceToken(MessageParcel &data)
24 {
25 if (!data.WriteInterfaceToken(ContainerManagerProxy::GetDescriptor())) {
26 HILOG_ERROR("write interface token failed.");
27 return false;
28 }
29 return true;
30 }
31
NotifyBootComplete(int32_t state)32 int ContainerManagerProxy::NotifyBootComplete(int32_t state)
33 {
34 MessageParcel data;
35 MessageParcel reply;
36 MessageOption option;
37
38 if (!WriteInterfaceToken(data)) {
39 return -1;
40 }
41
42 if (!data.WriteInt32(state)) {
43 HILOG_ERROR("state write failed.");
44 return -1;
45 }
46
47 sptr<IRemoteObject> remoteObject = Remote();
48 if (remoteObject == nullptr) {
49 HILOG_ERROR("ContainerManagerProxy::NotifyBootComplete, Remote() is nullptr");
50 return -1;
51 }
52 int error = remoteObject->SendRequest(IContainerManager::NOTIFY_BOOT_COMPLETE, data, reply, option);
53 if (error != NO_ERROR) {
54 HILOG_ERROR("Send request error: %{public}d", error);
55 return error;
56 }
57 return reply.ReadInt32();
58 }
59 } // namespace AAFwk
60 } // namespace OHOS