1eace7efcSopenharmony_ci/*
2eace7efcSopenharmony_ci * Copyright (c) 2023-2024 Huawei Device Co., Ltd.
3eace7efcSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4eace7efcSopenharmony_ci * you may not use this file except in compliance with the License.
5eace7efcSopenharmony_ci * You may obtain a copy of the License at
6eace7efcSopenharmony_ci *
7eace7efcSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8eace7efcSopenharmony_ci *
9eace7efcSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10eace7efcSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11eace7efcSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12eace7efcSopenharmony_ci * See the License for the specific language governing permissions and
13eace7efcSopenharmony_ci * limitations under the License.
14eace7efcSopenharmony_ci */
15eace7efcSopenharmony_ci
16eace7efcSopenharmony_ci#include "ability_manager_proxy.h"
17eace7efcSopenharmony_ci
18eace7efcSopenharmony_ci#include "ability_scheduler_stub.h"
19eace7efcSopenharmony_ci#include "ability_util.h"
20eace7efcSopenharmony_ci#include "freeze_util.h"
21eace7efcSopenharmony_ci#include "hitrace_meter.h"
22eace7efcSopenharmony_ci#include "status_bar_delegate_interface.h"
23eace7efcSopenharmony_ci
24eace7efcSopenharmony_cinamespace OHOS {
25eace7efcSopenharmony_cinamespace AAFwk {
26eace7efcSopenharmony_cinamespace {
27eace7efcSopenharmony_ci#define PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(messageParcel, type, value) \
28eace7efcSopenharmony_ci    do {                                                                  \
29eace7efcSopenharmony_ci        if (!(messageParcel).Write##type(value)) {                        \
30eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR,                                \
31eace7efcSopenharmony_ci            "failed write %{public}s", #value);                        \
32eace7efcSopenharmony_ci            return INNER_ERR;                                             \
33eace7efcSopenharmony_ci        }                                                                 \
34eace7efcSopenharmony_ci    } while (0)
35eace7efcSopenharmony_ci}
36eace7efcSopenharmony_ciusing AutoStartupInfo = AbilityRuntime::AutoStartupInfo;
37eace7efcSopenharmony_ciconstexpr int32_t CYCLE_LIMIT = 1000;
38eace7efcSopenharmony_ciconstexpr int32_t MAX_AUTO_STARTUP_COUNT = 100;
39eace7efcSopenharmony_ciconstexpr int32_t MAX_UPDATE_CONFIG_SIZE = 100;
40eace7efcSopenharmony_cibool AbilityManagerProxy::WriteInterfaceToken(MessageParcel &data)
41eace7efcSopenharmony_ci{
42eace7efcSopenharmony_ci    if (!data.WriteInterfaceToken(AbilityManagerProxy::GetDescriptor())) {
43eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
44eace7efcSopenharmony_ci        return false;
45eace7efcSopenharmony_ci    }
46eace7efcSopenharmony_ci    return true;
47eace7efcSopenharmony_ci}
48eace7efcSopenharmony_ci
49eace7efcSopenharmony_ciint AbilityManagerProxy::StartAbility(const Want &want, int32_t userId, int requestCode)
50eace7efcSopenharmony_ci{
51eace7efcSopenharmony_ci    int error;
52eace7efcSopenharmony_ci    MessageParcel data;
53eace7efcSopenharmony_ci    MessageParcel reply;
54eace7efcSopenharmony_ci    MessageOption option;
55eace7efcSopenharmony_ci
56eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
57eace7efcSopenharmony_ci        return INNER_ERR;
58eace7efcSopenharmony_ci    }
59eace7efcSopenharmony_ci    if (!data.WriteParcelable(&want)) {
60eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "want write fail");
61eace7efcSopenharmony_ci        return INNER_ERR;
62eace7efcSopenharmony_ci    }
63eace7efcSopenharmony_ci
64eace7efcSopenharmony_ci    if (!data.WriteInt32(userId)) {
65eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "userId write fail");
66eace7efcSopenharmony_ci        return INNER_ERR;
67eace7efcSopenharmony_ci    }
68eace7efcSopenharmony_ci
69eace7efcSopenharmony_ci    if (!data.WriteInt32(requestCode)) {
70eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "requestCode write fail");
71eace7efcSopenharmony_ci        return INNER_ERR;
72eace7efcSopenharmony_ci    }
73eace7efcSopenharmony_ci
74eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::START_ABILITY, data, reply, option);
75eace7efcSopenharmony_ci    if (error != NO_ERROR) {
76eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
77eace7efcSopenharmony_ci        return error;
78eace7efcSopenharmony_ci    }
79eace7efcSopenharmony_ci    return reply.ReadInt32();
80eace7efcSopenharmony_ci}
81eace7efcSopenharmony_ci
82eace7efcSopenharmony_ciAppExecFwk::ElementName AbilityManagerProxy::GetTopAbility(bool isNeedLocalDeviceId)
83eace7efcSopenharmony_ci{
84eace7efcSopenharmony_ci    HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
85eace7efcSopenharmony_ci    MessageParcel data;
86eace7efcSopenharmony_ci    MessageParcel reply;
87eace7efcSopenharmony_ci    MessageOption option;
88eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
89eace7efcSopenharmony_ci        return {};
90eace7efcSopenharmony_ci    }
91eace7efcSopenharmony_ci    if (!data.WriteBool(isNeedLocalDeviceId)) {
92eace7efcSopenharmony_ci        return {};
93eace7efcSopenharmony_ci    }
94eace7efcSopenharmony_ci
95eace7efcSopenharmony_ci    int error = SendRequest(AbilityManagerInterfaceCode::GET_TOP_ABILITY, data, reply, option);
96eace7efcSopenharmony_ci    if (error != NO_ERROR) {
97eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
98eace7efcSopenharmony_ci        return {};
99eace7efcSopenharmony_ci    }
100eace7efcSopenharmony_ci    std::unique_ptr<AppExecFwk::ElementName> name(reply.ReadParcelable<AppExecFwk::ElementName>());
101eace7efcSopenharmony_ci    if (!name) {
102eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "read info fail");
103eace7efcSopenharmony_ci        return {};
104eace7efcSopenharmony_ci    }
105eace7efcSopenharmony_ci    AppExecFwk::ElementName result = *name;
106eace7efcSopenharmony_ci    return result;
107eace7efcSopenharmony_ci}
108eace7efcSopenharmony_ci
109eace7efcSopenharmony_ciAppExecFwk::ElementName AbilityManagerProxy::GetElementNameByToken(sptr<IRemoteObject> token,
110eace7efcSopenharmony_ci    bool isNeedLocalDeviceId)
111eace7efcSopenharmony_ci{
112eace7efcSopenharmony_ci    MessageParcel data;
113eace7efcSopenharmony_ci    MessageParcel reply;
114eace7efcSopenharmony_ci    MessageOption option;
115eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
116eace7efcSopenharmony_ci        return {};
117eace7efcSopenharmony_ci    }
118eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(token)) {
119eace7efcSopenharmony_ci        return {};
120eace7efcSopenharmony_ci    }
121eace7efcSopenharmony_ci    if (!data.WriteBool(isNeedLocalDeviceId)) {
122eace7efcSopenharmony_ci        return {};
123eace7efcSopenharmony_ci    }
124eace7efcSopenharmony_ci    int error = SendRequest(AbilityManagerInterfaceCode::GET_ELEMENT_NAME_BY_TOKEN, data, reply, option);
125eace7efcSopenharmony_ci    if (error != NO_ERROR) {
126eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
127eace7efcSopenharmony_ci        return {};
128eace7efcSopenharmony_ci    }
129eace7efcSopenharmony_ci    std::unique_ptr<AppExecFwk::ElementName> name(reply.ReadParcelable<AppExecFwk::ElementName>());
130eace7efcSopenharmony_ci    if (!name) {
131eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "read info fail");
132eace7efcSopenharmony_ci        return {};
133eace7efcSopenharmony_ci    }
134eace7efcSopenharmony_ci    AppExecFwk::ElementName result = *name;
135eace7efcSopenharmony_ci    return result;
136eace7efcSopenharmony_ci}
137eace7efcSopenharmony_ci
138eace7efcSopenharmony_ciint AbilityManagerProxy::StartAbility(const Want &want, const AbilityStartSetting &abilityStartSetting,
139eace7efcSopenharmony_ci    const sptr<IRemoteObject> &callerToken, int32_t userId, int requestCode)
140eace7efcSopenharmony_ci{
141eace7efcSopenharmony_ci    int error;
142eace7efcSopenharmony_ci    MessageParcel data;
143eace7efcSopenharmony_ci    MessageParcel reply;
144eace7efcSopenharmony_ci    MessageOption option;
145eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
146eace7efcSopenharmony_ci        return INNER_ERR;
147eace7efcSopenharmony_ci    }
148eace7efcSopenharmony_ci    if (!data.WriteParcelable(&want)) {
149eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "want write fail");
150eace7efcSopenharmony_ci        return INNER_ERR;
151eace7efcSopenharmony_ci    }
152eace7efcSopenharmony_ci    if (!data.WriteParcelable(&abilityStartSetting)) {
153eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "abilityStartSetting write fail");
154eace7efcSopenharmony_ci        return INNER_ERR;
155eace7efcSopenharmony_ci    }
156eace7efcSopenharmony_ci    if (callerToken) {
157eace7efcSopenharmony_ci        if (!data.WriteBool(true) || !data.WriteRemoteObject(callerToken)) {
158eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag and callerToken write fail");
159eace7efcSopenharmony_ci            return INNER_ERR;
160eace7efcSopenharmony_ci        }
161eace7efcSopenharmony_ci    } else {
162eace7efcSopenharmony_ci        if (!data.WriteBool(false)) {
163eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag write fail");
164eace7efcSopenharmony_ci            return INNER_ERR;
165eace7efcSopenharmony_ci        }
166eace7efcSopenharmony_ci    }
167eace7efcSopenharmony_ci    if (!data.WriteInt32(userId)) {
168eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "userId write fail");
169eace7efcSopenharmony_ci        return INNER_ERR;
170eace7efcSopenharmony_ci    }
171eace7efcSopenharmony_ci    if (!data.WriteInt32(requestCode)) {
172eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "requestCode write fail");
173eace7efcSopenharmony_ci        return INNER_ERR;
174eace7efcSopenharmony_ci    }
175eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::START_ABILITY_FOR_SETTINGS, data, reply, option);
176eace7efcSopenharmony_ci    if (error != NO_ERROR) {
177eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "send request error: %{public}d", error);
178eace7efcSopenharmony_ci        return error;
179eace7efcSopenharmony_ci    }
180eace7efcSopenharmony_ci    return reply.ReadInt32();
181eace7efcSopenharmony_ci}
182eace7efcSopenharmony_ci
183eace7efcSopenharmony_ciint AbilityManagerProxy::StartAbility(
184eace7efcSopenharmony_ci    const Want &want, const sptr<IRemoteObject> &callerToken, int32_t userId, int requestCode)
185eace7efcSopenharmony_ci{
186eace7efcSopenharmony_ci    int error;
187eace7efcSopenharmony_ci    MessageParcel data;
188eace7efcSopenharmony_ci    MessageParcel reply;
189eace7efcSopenharmony_ci    MessageOption option;
190eace7efcSopenharmony_ci
191eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
192eace7efcSopenharmony_ci        return INNER_ERR;
193eace7efcSopenharmony_ci    }
194eace7efcSopenharmony_ci    if (!data.WriteParcelable(&want)) {
195eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "want write fail");
196eace7efcSopenharmony_ci        return INNER_ERR;
197eace7efcSopenharmony_ci    }
198eace7efcSopenharmony_ci    if (callerToken) {
199eace7efcSopenharmony_ci        if (!data.WriteBool(true) || !data.WriteRemoteObject(callerToken)) {
200eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "callerToken and flag write fail");
201eace7efcSopenharmony_ci            return INNER_ERR;
202eace7efcSopenharmony_ci        }
203eace7efcSopenharmony_ci    } else {
204eace7efcSopenharmony_ci        if (!data.WriteBool(false)) {
205eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag write fail");
206eace7efcSopenharmony_ci            return INNER_ERR;
207eace7efcSopenharmony_ci        }
208eace7efcSopenharmony_ci    }
209eace7efcSopenharmony_ci    if (!data.WriteInt32(userId)) {
210eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "userId write fail");
211eace7efcSopenharmony_ci        return INNER_ERR;
212eace7efcSopenharmony_ci    }
213eace7efcSopenharmony_ci    if (!data.WriteInt32(requestCode)) {
214eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "requestCode write fail");
215eace7efcSopenharmony_ci        return INNER_ERR;
216eace7efcSopenharmony_ci    }
217eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::START_ABILITY_ADD_CALLER, data, reply, option);
218eace7efcSopenharmony_ci    if (error != NO_ERROR) {
219eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
220eace7efcSopenharmony_ci        return error;
221eace7efcSopenharmony_ci    }
222eace7efcSopenharmony_ci    return reply.ReadInt32();
223eace7efcSopenharmony_ci}
224eace7efcSopenharmony_ci
225eace7efcSopenharmony_ciint AbilityManagerProxy::StartAbilityWithSpecifyTokenId(
226eace7efcSopenharmony_ci    const Want &want, const sptr<IRemoteObject> &callerToken, uint32_t specifyTokenId, int32_t userId, int requestCode)
227eace7efcSopenharmony_ci{
228eace7efcSopenharmony_ci    int error;
229eace7efcSopenharmony_ci    MessageParcel data;
230eace7efcSopenharmony_ci    MessageParcel reply;
231eace7efcSopenharmony_ci    MessageOption option;
232eace7efcSopenharmony_ci
233eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
234eace7efcSopenharmony_ci        return INNER_ERR;
235eace7efcSopenharmony_ci    }
236eace7efcSopenharmony_ci    if (!data.WriteParcelable(&want)) {
237eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "want write fail");
238eace7efcSopenharmony_ci        return INNER_ERR;
239eace7efcSopenharmony_ci    }
240eace7efcSopenharmony_ci    if (callerToken) {
241eace7efcSopenharmony_ci        if (!data.WriteBool(true) || !data.WriteRemoteObject(callerToken)) {
242eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "callerToken and flag write fail");
243eace7efcSopenharmony_ci            return INNER_ERR;
244eace7efcSopenharmony_ci        }
245eace7efcSopenharmony_ci    } else {
246eace7efcSopenharmony_ci        if (!data.WriteBool(false)) {
247eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag write fail");
248eace7efcSopenharmony_ci            return INNER_ERR;
249eace7efcSopenharmony_ci        }
250eace7efcSopenharmony_ci    }
251eace7efcSopenharmony_ci    if (!data.WriteInt32(specifyTokenId)) {
252eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "specifyTokenId write fail");
253eace7efcSopenharmony_ci        return INNER_ERR;
254eace7efcSopenharmony_ci    }
255eace7efcSopenharmony_ci    if (!data.WriteInt32(userId)) {
256eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "userId write fail");
257eace7efcSopenharmony_ci        return INNER_ERR;
258eace7efcSopenharmony_ci    }
259eace7efcSopenharmony_ci    if (!data.WriteInt32(requestCode)) {
260eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "requestCode write fail");
261eace7efcSopenharmony_ci        return INNER_ERR;
262eace7efcSopenharmony_ci    }
263eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::START_ABILITY_WITH_SPECIFY_TOKENID, data, reply, option);
264eace7efcSopenharmony_ci    if (error != NO_ERROR) {
265eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
266eace7efcSopenharmony_ci        return error;
267eace7efcSopenharmony_ci    }
268eace7efcSopenharmony_ci    return reply.ReadInt32();
269eace7efcSopenharmony_ci}
270eace7efcSopenharmony_ci
271eace7efcSopenharmony_ciint32_t AbilityManagerProxy::StartAbilityByInsightIntent(const Want &want, const sptr<IRemoteObject> &callerToken,
272eace7efcSopenharmony_ci    uint64_t intentId, int32_t userId)
273eace7efcSopenharmony_ci{
274eace7efcSopenharmony_ci    MessageParcel data;
275eace7efcSopenharmony_ci    if (callerToken == nullptr) {
276eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "invalid callertoken");
277eace7efcSopenharmony_ci        return INNER_ERR;
278eace7efcSopenharmony_ci    }
279eace7efcSopenharmony_ci
280eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
281eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "want write fail");
282eace7efcSopenharmony_ci        return INNER_ERR;
283eace7efcSopenharmony_ci    }
284eace7efcSopenharmony_ci
285eace7efcSopenharmony_ci    if (!data.WriteParcelable(&want)) {
286eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "want write fail");
287eace7efcSopenharmony_ci        return INNER_ERR;
288eace7efcSopenharmony_ci    }
289eace7efcSopenharmony_ci
290eace7efcSopenharmony_ci    if (!data.WriteBool(true) || !data.WriteRemoteObject(callerToken)) {
291eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "callerToken and flag write fail");
292eace7efcSopenharmony_ci        return INNER_ERR;
293eace7efcSopenharmony_ci    }
294eace7efcSopenharmony_ci
295eace7efcSopenharmony_ci    if (!data.WriteUint64(intentId)) {
296eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "intentId write fail");
297eace7efcSopenharmony_ci        return INNER_ERR;
298eace7efcSopenharmony_ci    }
299eace7efcSopenharmony_ci
300eace7efcSopenharmony_ci    if (!data.WriteInt32(userId)) {
301eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "userId write fail");
302eace7efcSopenharmony_ci        return INNER_ERR;
303eace7efcSopenharmony_ci    }
304eace7efcSopenharmony_ci
305eace7efcSopenharmony_ci    MessageParcel reply;
306eace7efcSopenharmony_ci    MessageOption option;
307eace7efcSopenharmony_ci    int32_t error = SendRequest(AbilityManagerInterfaceCode::START_ABILITY_BY_INSIGHT_INTENT, data, reply, option);
308eace7efcSopenharmony_ci    if (error != NO_ERROR) {
309eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "start err:%{public}d", error);
310eace7efcSopenharmony_ci        return error;
311eace7efcSopenharmony_ci    }
312eace7efcSopenharmony_ci    return reply.ReadInt32();
313eace7efcSopenharmony_ci}
314eace7efcSopenharmony_ci
315eace7efcSopenharmony_ciint AbilityManagerProxy::StartAbility(const Want &want, const StartOptions &startOptions,
316eace7efcSopenharmony_ci    const sptr<IRemoteObject> &callerToken, int32_t userId, int requestCode)
317eace7efcSopenharmony_ci{
318eace7efcSopenharmony_ci    int error;
319eace7efcSopenharmony_ci    MessageParcel data;
320eace7efcSopenharmony_ci    MessageParcel reply;
321eace7efcSopenharmony_ci    MessageOption option;
322eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
323eace7efcSopenharmony_ci        return INNER_ERR;
324eace7efcSopenharmony_ci    }
325eace7efcSopenharmony_ci    if (!data.WriteParcelable(&want)) {
326eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "want write fail");
327eace7efcSopenharmony_ci        return INNER_ERR;
328eace7efcSopenharmony_ci    }
329eace7efcSopenharmony_ci    if (!data.WriteParcelable(&startOptions)) {
330eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "writeParcelable fail");
331eace7efcSopenharmony_ci        return INNER_ERR;
332eace7efcSopenharmony_ci    }
333eace7efcSopenharmony_ci    if (callerToken) {
334eace7efcSopenharmony_ci        if (!data.WriteBool(true) || !data.WriteRemoteObject(callerToken)) {
335eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag and callerToken write fail");
336eace7efcSopenharmony_ci            return INNER_ERR;
337eace7efcSopenharmony_ci        }
338eace7efcSopenharmony_ci    } else {
339eace7efcSopenharmony_ci        if (!data.WriteBool(false)) {
340eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag write fail");
341eace7efcSopenharmony_ci            return INNER_ERR;
342eace7efcSopenharmony_ci        }
343eace7efcSopenharmony_ci    }
344eace7efcSopenharmony_ci    if (!data.WriteInt32(userId)) {
345eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "userId write fail");
346eace7efcSopenharmony_ci        return INNER_ERR;
347eace7efcSopenharmony_ci    }
348eace7efcSopenharmony_ci    if (!data.WriteInt32(requestCode)) {
349eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "requestCode write fail");
350eace7efcSopenharmony_ci        return INNER_ERR;
351eace7efcSopenharmony_ci    }
352eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::START_ABILITY_FOR_OPTIONS, data, reply, option);
353eace7efcSopenharmony_ci    if (error != NO_ERROR) {
354eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
355eace7efcSopenharmony_ci        return error;
356eace7efcSopenharmony_ci    }
357eace7efcSopenharmony_ci    return reply.ReadInt32();
358eace7efcSopenharmony_ci}
359eace7efcSopenharmony_ci
360eace7efcSopenharmony_ciint AbilityManagerProxy::StartAbilityAsCaller(const Want &want, const sptr<IRemoteObject> &callerToken,
361eace7efcSopenharmony_ci    sptr<IRemoteObject> asCallerSourceToken, int32_t userId, int requestCode)
362eace7efcSopenharmony_ci{
363eace7efcSopenharmony_ci    MessageParcel data;
364eace7efcSopenharmony_ci    MessageParcel reply;
365eace7efcSopenharmony_ci    MessageOption option;
366eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
367eace7efcSopenharmony_ci        return INNER_ERR;
368eace7efcSopenharmony_ci    }
369eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Parcelable, &want);
370eace7efcSopenharmony_ci    if (callerToken) {
371eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Bool, true);
372eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, RemoteObject, callerToken);
373eace7efcSopenharmony_ci    } else {
374eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Bool, false);
375eace7efcSopenharmony_ci    }
376eace7efcSopenharmony_ci    if (asCallerSourceToken) {
377eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Bool, true);
378eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, RemoteObject, asCallerSourceToken);
379eace7efcSopenharmony_ci    } else {
380eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Bool, false);
381eace7efcSopenharmony_ci    }
382eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Int32, userId);
383eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Int32, requestCode);
384eace7efcSopenharmony_ci    int error = SendRequest(AbilityManagerInterfaceCode::START_ABILITY_AS_CALLER_BY_TOKEN, data, reply, option);
385eace7efcSopenharmony_ci    if (error != NO_ERROR) {
386eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
387eace7efcSopenharmony_ci        return error;
388eace7efcSopenharmony_ci    }
389eace7efcSopenharmony_ci    return reply.ReadInt32();
390eace7efcSopenharmony_ci}
391eace7efcSopenharmony_ci
392eace7efcSopenharmony_ciint AbilityManagerProxy::StartAbilityAsCaller(const Want &want, const StartOptions &startOptions,
393eace7efcSopenharmony_ci    const sptr<IRemoteObject> &callerToken, sptr<IRemoteObject> asCallerSourceToken,
394eace7efcSopenharmony_ci    int32_t userId, int requestCode)
395eace7efcSopenharmony_ci{
396eace7efcSopenharmony_ci    int error;
397eace7efcSopenharmony_ci    MessageParcel data;
398eace7efcSopenharmony_ci    MessageParcel reply;
399eace7efcSopenharmony_ci    MessageOption option;
400eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
401eace7efcSopenharmony_ci        return INNER_ERR;
402eace7efcSopenharmony_ci    }
403eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Parcelable, &want);
404eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Parcelable, &startOptions);
405eace7efcSopenharmony_ci    if (callerToken) {
406eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Bool, true);
407eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, RemoteObject, callerToken);
408eace7efcSopenharmony_ci    } else {
409eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Bool, false);
410eace7efcSopenharmony_ci    }
411eace7efcSopenharmony_ci    if (asCallerSourceToken) {
412eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Bool, true);
413eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, RemoteObject, asCallerSourceToken);
414eace7efcSopenharmony_ci    } else {
415eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Bool, false);
416eace7efcSopenharmony_ci    }
417eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Int32, userId);
418eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Int32, requestCode);
419eace7efcSopenharmony_ci
420eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::START_ABILITY_AS_CALLER_FOR_OPTIONS, data, reply, option);
421eace7efcSopenharmony_ci    if (error != NO_ERROR) {
422eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
423eace7efcSopenharmony_ci        return error;
424eace7efcSopenharmony_ci    }
425eace7efcSopenharmony_ci    return reply.ReadInt32();
426eace7efcSopenharmony_ci}
427eace7efcSopenharmony_ci
428eace7efcSopenharmony_ciint AbilityManagerProxy::StartAbilityForResultAsCaller(
429eace7efcSopenharmony_ci    const Want &want, const sptr<IRemoteObject> &callerToken, int requestCode, int32_t userId)
430eace7efcSopenharmony_ci{
431eace7efcSopenharmony_ci    MessageParcel data;
432eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
433eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token failed");
434eace7efcSopenharmony_ci        return INNER_ERR;
435eace7efcSopenharmony_ci    }
436eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Parcelable, &want);
437eace7efcSopenharmony_ci    if (callerToken) {
438eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Bool, true);
439eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, RemoteObject, callerToken);
440eace7efcSopenharmony_ci    } else {
441eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Bool, false);
442eace7efcSopenharmony_ci    }
443eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Int32, requestCode);
444eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Int32, userId);
445eace7efcSopenharmony_ci    MessageParcel reply;
446eace7efcSopenharmony_ci    MessageOption option;
447eace7efcSopenharmony_ci    int error = SendRequest(AbilityManagerInterfaceCode::START_ABILITY_FOR_RESULT_AS_CALLER, data, reply, option);
448eace7efcSopenharmony_ci    if (error != NO_ERROR) {
449eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
450eace7efcSopenharmony_ci        return error;
451eace7efcSopenharmony_ci    }
452eace7efcSopenharmony_ci    return reply.ReadInt32();
453eace7efcSopenharmony_ci}
454eace7efcSopenharmony_ci
455eace7efcSopenharmony_ciint AbilityManagerProxy::StartAbilityForResultAsCaller(const Want &want, const StartOptions &startOptions,
456eace7efcSopenharmony_ci    const sptr<IRemoteObject> &callerToken, int requestCode, int32_t userId)
457eace7efcSopenharmony_ci{
458eace7efcSopenharmony_ci    MessageParcel data;
459eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
460eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token failed");
461eace7efcSopenharmony_ci        return INNER_ERR;
462eace7efcSopenharmony_ci    }
463eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Parcelable, &want);
464eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Parcelable, &startOptions);
465eace7efcSopenharmony_ci    if (callerToken) {
466eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Bool, true);
467eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, RemoteObject, callerToken);
468eace7efcSopenharmony_ci    } else {
469eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Bool, false);
470eace7efcSopenharmony_ci    }
471eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Int32, requestCode);
472eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Int32, userId);
473eace7efcSopenharmony_ci    MessageParcel reply;
474eace7efcSopenharmony_ci    MessageOption option;
475eace7efcSopenharmony_ci    int error =
476eace7efcSopenharmony_ci        SendRequest(AbilityManagerInterfaceCode::START_ABILITY_FOR_RESULT_AS_CALLER_FOR_OPTIONS, data, reply, option);
477eace7efcSopenharmony_ci    if (error != NO_ERROR) {
478eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
479eace7efcSopenharmony_ci        return error;
480eace7efcSopenharmony_ci    }
481eace7efcSopenharmony_ci    return reply.ReadInt32();
482eace7efcSopenharmony_ci}
483eace7efcSopenharmony_ci
484eace7efcSopenharmony_ciint AbilityManagerProxy::CheckUISessionParams(MessageParcel &data, const sptr<IRemoteObject> &callerToken,
485eace7efcSopenharmony_ci    const sptr<SessionInfo> &sessionInfo, int32_t userId, int requestCode)
486eace7efcSopenharmony_ci{
487eace7efcSopenharmony_ci    if (callerToken) {
488eace7efcSopenharmony_ci        if (!data.WriteBool(true) || !data.WriteRemoteObject(callerToken)) {
489eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "callerToken and flag write fail");
490eace7efcSopenharmony_ci            return INNER_ERR;
491eace7efcSopenharmony_ci        }
492eace7efcSopenharmony_ci    } else {
493eace7efcSopenharmony_ci        if (!data.WriteBool(false)) {
494eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag write fail");
495eace7efcSopenharmony_ci            return INNER_ERR;
496eace7efcSopenharmony_ci        }
497eace7efcSopenharmony_ci    }
498eace7efcSopenharmony_ci    if (sessionInfo) {
499eace7efcSopenharmony_ci        if (!data.WriteBool(true) || !data.WriteParcelable(sessionInfo)) {
500eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag and sessionInfo write fail");
501eace7efcSopenharmony_ci            return INNER_ERR;
502eace7efcSopenharmony_ci        }
503eace7efcSopenharmony_ci    } else {
504eace7efcSopenharmony_ci        if (!data.WriteBool(false)) {
505eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag write fail");
506eace7efcSopenharmony_ci            return INNER_ERR;
507eace7efcSopenharmony_ci        }
508eace7efcSopenharmony_ci    }
509eace7efcSopenharmony_ci    if (!data.WriteInt32(userId)) {
510eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "userId write fail");
511eace7efcSopenharmony_ci        return INNER_ERR;
512eace7efcSopenharmony_ci    }
513eace7efcSopenharmony_ci    if (!data.WriteInt32(requestCode)) {
514eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "requestCode write fail");
515eace7efcSopenharmony_ci        return INNER_ERR;
516eace7efcSopenharmony_ci    }
517eace7efcSopenharmony_ci    return ERR_OK;
518eace7efcSopenharmony_ci}
519eace7efcSopenharmony_ci
520eace7efcSopenharmony_ciint AbilityManagerProxy::StartAbilityByUIContentSession(const Want &want,
521eace7efcSopenharmony_ci    const sptr<IRemoteObject> &callerToken, const sptr<SessionInfo> &sessionInfo,
522eace7efcSopenharmony_ci    int32_t userId, int requestCode)
523eace7efcSopenharmony_ci{
524eace7efcSopenharmony_ci    int error;
525eace7efcSopenharmony_ci    MessageParcel data;
526eace7efcSopenharmony_ci    MessageParcel reply;
527eace7efcSopenharmony_ci    MessageOption option;
528eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
529eace7efcSopenharmony_ci        return INNER_ERR;
530eace7efcSopenharmony_ci    }
531eace7efcSopenharmony_ci    if (!data.WriteParcelable(&want)) {
532eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "want write fail");
533eace7efcSopenharmony_ci        return INNER_ERR;
534eace7efcSopenharmony_ci    }
535eace7efcSopenharmony_ci    if (CheckUISessionParams(data, callerToken, sessionInfo, userId, requestCode) == INNER_ERR) {
536eace7efcSopenharmony_ci        return INNER_ERR;
537eace7efcSopenharmony_ci    }
538eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::START_UI_SESSION_ABILITY_ADD_CALLER, data, reply, option);
539eace7efcSopenharmony_ci    if (error != NO_ERROR) {
540eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
541eace7efcSopenharmony_ci        return error;
542eace7efcSopenharmony_ci    }
543eace7efcSopenharmony_ci    return reply.ReadInt32();
544eace7efcSopenharmony_ci}
545eace7efcSopenharmony_ci
546eace7efcSopenharmony_ciint AbilityManagerProxy::StartAbilityByUIContentSession(const Want &want, const StartOptions &startOptions,
547eace7efcSopenharmony_ci    const sptr<IRemoteObject> &callerToken, const sptr<SessionInfo> &sessionInfo,
548eace7efcSopenharmony_ci    int32_t userId, int requestCode)
549eace7efcSopenharmony_ci{
550eace7efcSopenharmony_ci    int error;
551eace7efcSopenharmony_ci    MessageParcel data;
552eace7efcSopenharmony_ci    MessageParcel reply;
553eace7efcSopenharmony_ci    MessageOption option;
554eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
555eace7efcSopenharmony_ci        return INNER_ERR;
556eace7efcSopenharmony_ci    }
557eace7efcSopenharmony_ci    if (!data.WriteParcelable(&want)) {
558eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "want write fail");
559eace7efcSopenharmony_ci        return INNER_ERR;
560eace7efcSopenharmony_ci    }
561eace7efcSopenharmony_ci    if (!data.WriteParcelable(&startOptions)) {
562eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "writeParcelable fail");
563eace7efcSopenharmony_ci        return INNER_ERR;
564eace7efcSopenharmony_ci    }
565eace7efcSopenharmony_ci    if (CheckUISessionParams(data, callerToken, sessionInfo, userId, requestCode) == INNER_ERR) {
566eace7efcSopenharmony_ci        return INNER_ERR;
567eace7efcSopenharmony_ci    }
568eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::START_UI_SESSION_ABILITY_FOR_OPTIONS, data, reply, option);
569eace7efcSopenharmony_ci    if (error != NO_ERROR) {
570eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
571eace7efcSopenharmony_ci        return error;
572eace7efcSopenharmony_ci    }
573eace7efcSopenharmony_ci    return reply.ReadInt32();
574eace7efcSopenharmony_ci}
575eace7efcSopenharmony_ci
576eace7efcSopenharmony_ciint AbilityManagerProxy::StartAbilityOnlyUIAbility(const Want &want, const sptr<IRemoteObject> &callerToken,
577eace7efcSopenharmony_ci    uint32_t specifyTokenId)
578eace7efcSopenharmony_ci{
579eace7efcSopenharmony_ci    MessageParcel data;
580eace7efcSopenharmony_ci    if (callerToken == nullptr) {
581eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "invalid callertoken");
582eace7efcSopenharmony_ci        return INNER_ERR;
583eace7efcSopenharmony_ci    }
584eace7efcSopenharmony_ci
585eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
586eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "want write fail");
587eace7efcSopenharmony_ci        return INNER_ERR;
588eace7efcSopenharmony_ci    }
589eace7efcSopenharmony_ci
590eace7efcSopenharmony_ci    if (!data.WriteParcelable(&want)) {
591eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "want write fail");
592eace7efcSopenharmony_ci        return INNER_ERR;
593eace7efcSopenharmony_ci    }
594eace7efcSopenharmony_ci
595eace7efcSopenharmony_ci    if (!data.WriteBool(true) || !data.WriteRemoteObject(callerToken)) {
596eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "callerToken and flag write fail");
597eace7efcSopenharmony_ci        return INNER_ERR;
598eace7efcSopenharmony_ci    }
599eace7efcSopenharmony_ci
600eace7efcSopenharmony_ci    if (!data.WriteUint32(specifyTokenId)) {
601eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "specifyTokenId write fail");
602eace7efcSopenharmony_ci        return INNER_ERR;
603eace7efcSopenharmony_ci    }
604eace7efcSopenharmony_ci
605eace7efcSopenharmony_ci    MessageParcel reply;
606eace7efcSopenharmony_ci    MessageOption option;
607eace7efcSopenharmony_ci    int32_t error = SendRequest(AbilityManagerInterfaceCode::START_ABILITY_ONLY_UI_ABILITY, data, reply, option);
608eace7efcSopenharmony_ci    if (error != NO_ERROR) {
609eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "send err:%{public}d", error);
610eace7efcSopenharmony_ci        return error;
611eace7efcSopenharmony_ci    }
612eace7efcSopenharmony_ci    return reply.ReadInt32();
613eace7efcSopenharmony_ci}
614eace7efcSopenharmony_ci
615eace7efcSopenharmony_ciint32_t AbilityManagerProxy::StartExtensionAbility(const Want &want, const sptr<IRemoteObject> &callerToken,
616eace7efcSopenharmony_ci    int32_t userId, AppExecFwk::ExtensionAbilityType extensionType)
617eace7efcSopenharmony_ci{
618eace7efcSopenharmony_ci    HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
619eace7efcSopenharmony_ci    int error;
620eace7efcSopenharmony_ci    MessageParcel data;
621eace7efcSopenharmony_ci    MessageParcel reply;
622eace7efcSopenharmony_ci    MessageOption option;
623eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
624eace7efcSopenharmony_ci        return INNER_ERR;
625eace7efcSopenharmony_ci    }
626eace7efcSopenharmony_ci    if (!data.WriteParcelable(&want)) {
627eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "want write fail");
628eace7efcSopenharmony_ci        return INNER_ERR;
629eace7efcSopenharmony_ci    }
630eace7efcSopenharmony_ci    if (callerToken) {
631eace7efcSopenharmony_ci        if (!data.WriteBool(true) || !data.WriteRemoteObject(callerToken)) {
632eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag and callerToken write fail");
633eace7efcSopenharmony_ci            return INNER_ERR;
634eace7efcSopenharmony_ci        }
635eace7efcSopenharmony_ci    } else {
636eace7efcSopenharmony_ci        if (!data.WriteBool(false)) {
637eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag write fail");
638eace7efcSopenharmony_ci            return INNER_ERR;
639eace7efcSopenharmony_ci        }
640eace7efcSopenharmony_ci    }
641eace7efcSopenharmony_ci    if (!data.WriteInt32(userId)) {
642eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "userId write failed");
643eace7efcSopenharmony_ci        return INNER_ERR;
644eace7efcSopenharmony_ci    }
645eace7efcSopenharmony_ci    if (!data.WriteInt32(static_cast<int32_t>(extensionType))) {
646eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "extensionType write failed");
647eace7efcSopenharmony_ci        return INNER_ERR;
648eace7efcSopenharmony_ci    }
649eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::START_EXTENSION_ABILITY, data, reply, option);
650eace7efcSopenharmony_ci    if (error != NO_ERROR) {
651eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
652eace7efcSopenharmony_ci        return error;
653eace7efcSopenharmony_ci    }
654eace7efcSopenharmony_ci    return reply.ReadInt32();
655eace7efcSopenharmony_ci}
656eace7efcSopenharmony_ci
657eace7efcSopenharmony_ciint AbilityManagerProxy::RequestModalUIExtension(const Want &want)
658eace7efcSopenharmony_ci{
659eace7efcSopenharmony_ci    MessageParcel data;
660eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
661eace7efcSopenharmony_ci        return INNER_ERR;
662eace7efcSopenharmony_ci    }
663eace7efcSopenharmony_ci    if (!data.WriteParcelable(&want)) {
664eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "want write fail");
665eace7efcSopenharmony_ci        return INNER_ERR;
666eace7efcSopenharmony_ci    }
667eace7efcSopenharmony_ci
668eace7efcSopenharmony_ci    int error;
669eace7efcSopenharmony_ci    MessageParcel reply;
670eace7efcSopenharmony_ci    MessageOption option;
671eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::REQUESET_MODAL_UIEXTENSION, data, reply, option);
672eace7efcSopenharmony_ci    if (error != NO_ERROR) {
673eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
674eace7efcSopenharmony_ci        return error;
675eace7efcSopenharmony_ci    }
676eace7efcSopenharmony_ci    return reply.ReadInt32();
677eace7efcSopenharmony_ci}
678eace7efcSopenharmony_ci
679eace7efcSopenharmony_ciint AbilityManagerProxy::PreloadUIExtensionAbility(const Want &want, std::string &hostBundleName, int32_t userId)
680eace7efcSopenharmony_ci{
681eace7efcSopenharmony_ci    MessageParcel data;
682eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
683eace7efcSopenharmony_ci        return INNER_ERR;
684eace7efcSopenharmony_ci    }
685eace7efcSopenharmony_ci
686eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Parcelable, &want);
687eace7efcSopenharmony_ci
688eace7efcSopenharmony_ci    if (!data.WriteString16(Str8ToStr16(hostBundleName))) {
689eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "hostBundleName write fail");
690eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
691eace7efcSopenharmony_ci    }
692eace7efcSopenharmony_ci
693eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Int32, userId);
694eace7efcSopenharmony_ci    int error;
695eace7efcSopenharmony_ci    MessageParcel reply;
696eace7efcSopenharmony_ci    MessageOption option;
697eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::PRELOAD_UIEXTENSION_ABILITY, data, reply, option);
698eace7efcSopenharmony_ci    if (error != NO_ERROR) {
699eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
700eace7efcSopenharmony_ci        return error;
701eace7efcSopenharmony_ci    }
702eace7efcSopenharmony_ci    return reply.ReadInt32();
703eace7efcSopenharmony_ci}
704eace7efcSopenharmony_ci
705eace7efcSopenharmony_ciint AbilityManagerProxy::ChangeAbilityVisibility(sptr<IRemoteObject> token, bool isShow)
706eace7efcSopenharmony_ci{
707eace7efcSopenharmony_ci    MessageParcel data;
708eace7efcSopenharmony_ci    MessageParcel reply;
709eace7efcSopenharmony_ci    MessageOption option;
710eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
711eace7efcSopenharmony_ci        return ERR_NATIVE_IPC_PARCEL_FAILED;
712eace7efcSopenharmony_ci    }
713eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(token)) {
714eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
715eace7efcSopenharmony_ci        return ERR_NATIVE_IPC_PARCEL_FAILED;
716eace7efcSopenharmony_ci    }
717eace7efcSopenharmony_ci    if (!data.WriteBool(isShow)) {
718eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write isShow fail");
719eace7efcSopenharmony_ci        return ERR_NATIVE_IPC_PARCEL_FAILED;
720eace7efcSopenharmony_ci    }
721eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::CHANGE_ABILITY_VISIBILITY, data, reply, option);
722eace7efcSopenharmony_ci    if (error != NO_ERROR) {
723eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
724eace7efcSopenharmony_ci        return error;
725eace7efcSopenharmony_ci    }
726eace7efcSopenharmony_ci    return reply.ReadInt32();
727eace7efcSopenharmony_ci}
728eace7efcSopenharmony_ci
729eace7efcSopenharmony_ciint AbilityManagerProxy::ChangeUIAbilityVisibilityBySCB(sptr<SessionInfo> sessionInfo, bool isShow)
730eace7efcSopenharmony_ci{
731eace7efcSopenharmony_ci    MessageParcel data;
732eace7efcSopenharmony_ci    MessageParcel reply;
733eace7efcSopenharmony_ci    MessageOption option;
734eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
735eace7efcSopenharmony_ci        return ERR_NATIVE_IPC_PARCEL_FAILED;
736eace7efcSopenharmony_ci    }
737eace7efcSopenharmony_ci    if (!data.WriteParcelable(sessionInfo)) {
738eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write sessionInfo fail");
739eace7efcSopenharmony_ci        return ERR_NATIVE_IPC_PARCEL_FAILED;
740eace7efcSopenharmony_ci    }
741eace7efcSopenharmony_ci    if (!data.WriteBool(isShow)) {
742eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write isShow fail");
743eace7efcSopenharmony_ci        return ERR_NATIVE_IPC_PARCEL_FAILED;
744eace7efcSopenharmony_ci    }
745eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::CHANGE_UI_ABILITY_VISIBILITY_BY_SCB, data, reply, option);
746eace7efcSopenharmony_ci    if (error != NO_ERROR) {
747eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
748eace7efcSopenharmony_ci        return error;
749eace7efcSopenharmony_ci    }
750eace7efcSopenharmony_ci    return reply.ReadInt32();
751eace7efcSopenharmony_ci}
752eace7efcSopenharmony_ci
753eace7efcSopenharmony_ciint AbilityManagerProxy::StartUIExtensionAbility(const sptr<SessionInfo> &extensionSessionInfo, int32_t userId)
754eace7efcSopenharmony_ci{
755eace7efcSopenharmony_ci    int error;
756eace7efcSopenharmony_ci    MessageParcel data;
757eace7efcSopenharmony_ci    MessageParcel reply;
758eace7efcSopenharmony_ci    MessageOption option;
759eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
760eace7efcSopenharmony_ci        return INNER_ERR;
761eace7efcSopenharmony_ci    }
762eace7efcSopenharmony_ci
763eace7efcSopenharmony_ci    CHECK_POINTER_AND_RETURN_LOG(extensionSessionInfo, ERR_INVALID_VALUE,
764eace7efcSopenharmony_ci        "connect fail, null extensionSessionInfo");
765eace7efcSopenharmony_ci    if (extensionSessionInfo) {
766eace7efcSopenharmony_ci        if (!data.WriteBool(true) || !data.WriteParcelable(extensionSessionInfo)) {
767eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag and extensionSessionInfo write fail");
768eace7efcSopenharmony_ci            return INNER_ERR;
769eace7efcSopenharmony_ci        }
770eace7efcSopenharmony_ci    } else {
771eace7efcSopenharmony_ci        if (!data.WriteBool(false)) {
772eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag write fail");
773eace7efcSopenharmony_ci            return INNER_ERR;
774eace7efcSopenharmony_ci        }
775eace7efcSopenharmony_ci    }
776eace7efcSopenharmony_ci
777eace7efcSopenharmony_ci    if (!data.WriteInt32(userId)) {
778eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "userId write failed");
779eace7efcSopenharmony_ci        return INNER_ERR;
780eace7efcSopenharmony_ci    }
781eace7efcSopenharmony_ci
782eace7efcSopenharmony_ci    if (extensionSessionInfo->uiExtensionUsage == UIExtensionUsage::EMBEDDED) {
783eace7efcSopenharmony_ci        error = SendRequest(AbilityManagerInterfaceCode::START_UI_EXTENSION_ABILITY_EMBEDDED, data, reply, option);
784eace7efcSopenharmony_ci    } else if (extensionSessionInfo->uiExtensionUsage == UIExtensionUsage::MODAL) {
785eace7efcSopenharmony_ci        error = SendRequest(AbilityManagerInterfaceCode::START_UI_EXTENSION_ABILITY, data, reply, option);
786eace7efcSopenharmony_ci    } else {
787eace7efcSopenharmony_ci        error = SendRequest(AbilityManagerInterfaceCode::START_UI_EXTENSION_CONSTRAINED_EMBEDDED, data, reply, option);
788eace7efcSopenharmony_ci    }
789eace7efcSopenharmony_ci
790eace7efcSopenharmony_ci    if (error != NO_ERROR) {
791eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
792eace7efcSopenharmony_ci        return error;
793eace7efcSopenharmony_ci    }
794eace7efcSopenharmony_ci    return reply.ReadInt32();
795eace7efcSopenharmony_ci}
796eace7efcSopenharmony_ci
797eace7efcSopenharmony_ciint AbilityManagerProxy::StartUIAbilityBySCB(sptr<SessionInfo> sessionInfo, bool &isColdStart, uint32_t sceneFlag)
798eace7efcSopenharmony_ci{
799eace7efcSopenharmony_ci    MessageParcel data;
800eace7efcSopenharmony_ci    MessageParcel reply;
801eace7efcSopenharmony_ci    MessageOption option;
802eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
803eace7efcSopenharmony_ci        return INNER_ERR;
804eace7efcSopenharmony_ci    }
805eace7efcSopenharmony_ci    if (sessionInfo) {
806eace7efcSopenharmony_ci        if (!data.WriteBool(true) || !data.WriteParcelable(sessionInfo)) {
807eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag and sessionInfo write fail");
808eace7efcSopenharmony_ci            return INNER_ERR;
809eace7efcSopenharmony_ci        }
810eace7efcSopenharmony_ci    } else {
811eace7efcSopenharmony_ci        if (!data.WriteBool(false)) {
812eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag write fail");
813eace7efcSopenharmony_ci            return INNER_ERR;
814eace7efcSopenharmony_ci        }
815eace7efcSopenharmony_ci    }
816eace7efcSopenharmony_ci    if (!data.WriteUint32(sceneFlag)) {
817eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "sceneFlag write fail");
818eace7efcSopenharmony_ci        return INNER_ERR;
819eace7efcSopenharmony_ci    }
820eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::START_UI_ABILITY_BY_SCB, data, reply, option);
821eace7efcSopenharmony_ci    if (error != NO_ERROR) {
822eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
823eace7efcSopenharmony_ci        return error;
824eace7efcSopenharmony_ci    }
825eace7efcSopenharmony_ci    isColdStart = reply.ReadBool();
826eace7efcSopenharmony_ci    return reply.ReadInt32();
827eace7efcSopenharmony_ci}
828eace7efcSopenharmony_ci
829eace7efcSopenharmony_ciint AbilityManagerProxy::StopExtensionAbility(const Want &want, const sptr<IRemoteObject> &callerToken,
830eace7efcSopenharmony_ci    int32_t userId, AppExecFwk::ExtensionAbilityType extensionType)
831eace7efcSopenharmony_ci{
832eace7efcSopenharmony_ci    int error;
833eace7efcSopenharmony_ci    MessageParcel data;
834eace7efcSopenharmony_ci    MessageParcel reply;
835eace7efcSopenharmony_ci    MessageOption option;
836eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
837eace7efcSopenharmony_ci        return INNER_ERR;
838eace7efcSopenharmony_ci    }
839eace7efcSopenharmony_ci    if (!data.WriteParcelable(&want)) {
840eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "want write fail");
841eace7efcSopenharmony_ci        return INNER_ERR;
842eace7efcSopenharmony_ci    }
843eace7efcSopenharmony_ci    if (callerToken) {
844eace7efcSopenharmony_ci        if (!data.WriteBool(true) || !data.WriteRemoteObject(callerToken)) {
845eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag and callerToken write fail");
846eace7efcSopenharmony_ci            return INNER_ERR;
847eace7efcSopenharmony_ci        }
848eace7efcSopenharmony_ci    } else {
849eace7efcSopenharmony_ci        if (!data.WriteBool(false)) {
850eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag write fail");
851eace7efcSopenharmony_ci            return INNER_ERR;
852eace7efcSopenharmony_ci        }
853eace7efcSopenharmony_ci    }
854eace7efcSopenharmony_ci    if (!data.WriteInt32(userId)) {
855eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "userId write fail");
856eace7efcSopenharmony_ci        return INNER_ERR;
857eace7efcSopenharmony_ci    }
858eace7efcSopenharmony_ci    if (!data.WriteInt32(static_cast<int32_t>(extensionType))) {
859eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "writeInt32 fail");
860eace7efcSopenharmony_ci        return INNER_ERR;
861eace7efcSopenharmony_ci    }
862eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::STOP_EXTENSION_ABILITY, data, reply, option);
863eace7efcSopenharmony_ci    if (error != NO_ERROR) {
864eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
865eace7efcSopenharmony_ci        return error;
866eace7efcSopenharmony_ci    }
867eace7efcSopenharmony_ci    return reply.ReadInt32();
868eace7efcSopenharmony_ci}
869eace7efcSopenharmony_ci
870eace7efcSopenharmony_ciint AbilityManagerProxy::TerminateAbility(const sptr<IRemoteObject> &token, int resultCode, const Want *resultWant)
871eace7efcSopenharmony_ci{
872eace7efcSopenharmony_ci    return TerminateAbility(token, resultCode, resultWant, true);
873eace7efcSopenharmony_ci}
874eace7efcSopenharmony_ci
875eace7efcSopenharmony_ciint AbilityManagerProxy::TerminateAbility(const sptr<IRemoteObject> &token,
876eace7efcSopenharmony_ci    int resultCode, const Want *resultWant, bool flag)
877eace7efcSopenharmony_ci{
878eace7efcSopenharmony_ci    int error;
879eace7efcSopenharmony_ci    MessageParcel data;
880eace7efcSopenharmony_ci    MessageParcel reply;
881eace7efcSopenharmony_ci    MessageOption option;
882eace7efcSopenharmony_ci
883eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
884eace7efcSopenharmony_ci        return INNER_ERR;
885eace7efcSopenharmony_ci    }
886eace7efcSopenharmony_ci    if (token) {
887eace7efcSopenharmony_ci        if (!data.WriteBool(true) || !data.WriteRemoteObject(token)) {
888eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag and token write fail");
889eace7efcSopenharmony_ci            return INNER_ERR;
890eace7efcSopenharmony_ci        }
891eace7efcSopenharmony_ci    } else {
892eace7efcSopenharmony_ci        if (!data.WriteBool(false)) {
893eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag write fail");
894eace7efcSopenharmony_ci            return INNER_ERR;
895eace7efcSopenharmony_ci        }
896eace7efcSopenharmony_ci    }
897eace7efcSopenharmony_ci    if (!data.WriteInt32(resultCode) || !data.WriteParcelable(resultWant)) {
898eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "data write fail");
899eace7efcSopenharmony_ci        return INNER_ERR;
900eace7efcSopenharmony_ci    }
901eace7efcSopenharmony_ci    if (!data.WriteBool(flag)) {
902eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "data write flag fail");
903eace7efcSopenharmony_ci        return INNER_ERR;
904eace7efcSopenharmony_ci    }
905eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::TERMINATE_ABILITY, data, reply, option);
906eace7efcSopenharmony_ci    if (error != NO_ERROR) {
907eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
908eace7efcSopenharmony_ci        return error;
909eace7efcSopenharmony_ci    }
910eace7efcSopenharmony_ci    return reply.ReadInt32();
911eace7efcSopenharmony_ci}
912eace7efcSopenharmony_ci
913eace7efcSopenharmony_ciint AbilityManagerProxy::BackToCallerAbilityWithResult(const sptr<IRemoteObject> &token, int resultCode,
914eace7efcSopenharmony_ci    const Want *resultWant, int64_t callerRequestCode)
915eace7efcSopenharmony_ci{
916eace7efcSopenharmony_ci    int error;
917eace7efcSopenharmony_ci    MessageParcel data;
918eace7efcSopenharmony_ci    MessageParcel reply;
919eace7efcSopenharmony_ci    MessageOption option;
920eace7efcSopenharmony_ci
921eace7efcSopenharmony_ci    CHECK_POINTER_AND_RETURN_LOG(token, ERR_INVALID_VALUE, "null token");
922eace7efcSopenharmony_ci
923eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
924eace7efcSopenharmony_ci        return INNER_ERR;
925eace7efcSopenharmony_ci    }
926eace7efcSopenharmony_ci
927eace7efcSopenharmony_ci    if (token) {
928eace7efcSopenharmony_ci        if (!data.WriteBool(true) || !data.WriteRemoteObject(token)) {
929eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "token write fail");
930eace7efcSopenharmony_ci            return INNER_ERR;
931eace7efcSopenharmony_ci        }
932eace7efcSopenharmony_ci    } else {
933eace7efcSopenharmony_ci        if (!data.WriteBool(false)) {
934eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag write fail");
935eace7efcSopenharmony_ci            return INNER_ERR;
936eace7efcSopenharmony_ci        }
937eace7efcSopenharmony_ci    }
938eace7efcSopenharmony_ci    if (!data.WriteInt32(resultCode) || !data.WriteParcelable(resultWant)) {
939eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write resultCode fail");
940eace7efcSopenharmony_ci        return INNER_ERR;
941eace7efcSopenharmony_ci    }
942eace7efcSopenharmony_ci    if (!data.WriteInt64(callerRequestCode)) {
943eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write requestCode fail");
944eace7efcSopenharmony_ci        return INNER_ERR;
945eace7efcSopenharmony_ci    }
946eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::BACK_TO_CALLER_UIABILITY, data, reply, option);
947eace7efcSopenharmony_ci    if (error != NO_ERROR) {
948eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
949eace7efcSopenharmony_ci        return error;
950eace7efcSopenharmony_ci    }
951eace7efcSopenharmony_ci    return reply.ReadInt32();
952eace7efcSopenharmony_ci}
953eace7efcSopenharmony_ci
954eace7efcSopenharmony_ciint32_t AbilityManagerProxy::TerminateUIServiceExtensionAbility(const sptr<IRemoteObject> &token)
955eace7efcSopenharmony_ci{
956eace7efcSopenharmony_ci    int error;
957eace7efcSopenharmony_ci    MessageParcel data;
958eace7efcSopenharmony_ci    MessageParcel reply;
959eace7efcSopenharmony_ci    MessageOption option;
960eace7efcSopenharmony_ci
961eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
962eace7efcSopenharmony_ci        return INNER_ERR;
963eace7efcSopenharmony_ci    }
964eace7efcSopenharmony_ci    if (token) {
965eace7efcSopenharmony_ci        if (!data.WriteBool(true) || !data.WriteRemoteObject(token)) {
966eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag and token write fail");
967eace7efcSopenharmony_ci            return INNER_ERR;
968eace7efcSopenharmony_ci        }
969eace7efcSopenharmony_ci    } else {
970eace7efcSopenharmony_ci        if (!data.WriteBool(false)) {
971eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag write fail");
972eace7efcSopenharmony_ci            return INNER_ERR;
973eace7efcSopenharmony_ci        }
974eace7efcSopenharmony_ci    }
975eace7efcSopenharmony_ci
976eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::TERMINATE_UI_SERVICE_EXTENSION_ABILITY, data, reply, option);
977eace7efcSopenharmony_ci    if (error != NO_ERROR) {
978eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
979eace7efcSopenharmony_ci        return error;
980eace7efcSopenharmony_ci    }
981eace7efcSopenharmony_ci    return reply.ReadInt32();
982eace7efcSopenharmony_ci}
983eace7efcSopenharmony_ci
984eace7efcSopenharmony_ciint AbilityManagerProxy::TerminateUIExtensionAbility(const sptr<SessionInfo> &extensionSessionInfo, int resultCode,
985eace7efcSopenharmony_ci    const Want *resultWant)
986eace7efcSopenharmony_ci{
987eace7efcSopenharmony_ci    int error;
988eace7efcSopenharmony_ci    MessageParcel data;
989eace7efcSopenharmony_ci    MessageParcel reply;
990eace7efcSopenharmony_ci    MessageOption option;
991eace7efcSopenharmony_ci
992eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
993eace7efcSopenharmony_ci        return INNER_ERR;
994eace7efcSopenharmony_ci    }
995eace7efcSopenharmony_ci
996eace7efcSopenharmony_ci    CHECK_POINTER_AND_RETURN_LOG(extensionSessionInfo, ERR_INVALID_VALUE,
997eace7efcSopenharmony_ci        "connect fail, null extensionSessionInfo");
998eace7efcSopenharmony_ci    if (extensionSessionInfo) {
999eace7efcSopenharmony_ci        if (!data.WriteBool(true) || !data.WriteParcelable(extensionSessionInfo)) {
1000eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag and extensionSessionInfo write fail");
1001eace7efcSopenharmony_ci            return INNER_ERR;
1002eace7efcSopenharmony_ci        }
1003eace7efcSopenharmony_ci    } else {
1004eace7efcSopenharmony_ci        if (!data.WriteBool(false)) {
1005eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag write fail");
1006eace7efcSopenharmony_ci            return INNER_ERR;
1007eace7efcSopenharmony_ci        }
1008eace7efcSopenharmony_ci    }
1009eace7efcSopenharmony_ci
1010eace7efcSopenharmony_ci    if (!data.WriteInt32(resultCode) || !data.WriteParcelable(resultWant)) {
1011eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "data write fail");
1012eace7efcSopenharmony_ci        return INNER_ERR;
1013eace7efcSopenharmony_ci    }
1014eace7efcSopenharmony_ci
1015eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::TERMINATE_UI_EXTENSION_ABILITY, data, reply, option);
1016eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1017eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1018eace7efcSopenharmony_ci        return error;
1019eace7efcSopenharmony_ci    }
1020eace7efcSopenharmony_ci    return reply.ReadInt32();
1021eace7efcSopenharmony_ci}
1022eace7efcSopenharmony_ci
1023eace7efcSopenharmony_ciint AbilityManagerProxy::CloseUIAbilityBySCB(const sptr<SessionInfo> &sessionInfo)
1024eace7efcSopenharmony_ci{
1025eace7efcSopenharmony_ci    int error;
1026eace7efcSopenharmony_ci    MessageParcel data;
1027eace7efcSopenharmony_ci    MessageParcel reply;
1028eace7efcSopenharmony_ci    MessageOption option;
1029eace7efcSopenharmony_ci
1030eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1031eace7efcSopenharmony_ci        return INNER_ERR;
1032eace7efcSopenharmony_ci    }
1033eace7efcSopenharmony_ci
1034eace7efcSopenharmony_ci    if (sessionInfo) {
1035eace7efcSopenharmony_ci        if (!data.WriteBool(true) || !data.WriteParcelable(sessionInfo)) {
1036eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag and sessionInfo write fail");
1037eace7efcSopenharmony_ci            return INNER_ERR;
1038eace7efcSopenharmony_ci        }
1039eace7efcSopenharmony_ci    } else {
1040eace7efcSopenharmony_ci        if (!data.WriteBool(false)) {
1041eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag write fail");
1042eace7efcSopenharmony_ci            return INNER_ERR;
1043eace7efcSopenharmony_ci        }
1044eace7efcSopenharmony_ci    }
1045eace7efcSopenharmony_ci
1046eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::CLOSE_UI_ABILITY_BY_SCB, data, reply, option);
1047eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1048eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1049eace7efcSopenharmony_ci        return error;
1050eace7efcSopenharmony_ci    }
1051eace7efcSopenharmony_ci    return reply.ReadInt32();
1052eace7efcSopenharmony_ci}
1053eace7efcSopenharmony_ci
1054eace7efcSopenharmony_ciint AbilityManagerProxy::SendResultToAbility(int32_t requestCode, int32_t resultCode, Want& resultWant)
1055eace7efcSopenharmony_ci{
1056eace7efcSopenharmony_ci    int error;
1057eace7efcSopenharmony_ci    MessageParcel data;
1058eace7efcSopenharmony_ci    MessageParcel reply;
1059eace7efcSopenharmony_ci    MessageOption option;
1060eace7efcSopenharmony_ci
1061eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1062eace7efcSopenharmony_ci        return INNER_ERR;
1063eace7efcSopenharmony_ci    }
1064eace7efcSopenharmony_ci    if (!data.WriteInt32(requestCode)) {
1065eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "requestCode write fail");
1066eace7efcSopenharmony_ci        return INNER_ERR;
1067eace7efcSopenharmony_ci    }
1068eace7efcSopenharmony_ci    if (!data.WriteInt32(resultCode) || !data.WriteParcelable(&resultWant)) {
1069eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "data write fail");
1070eace7efcSopenharmony_ci        return INNER_ERR;
1071eace7efcSopenharmony_ci    }
1072eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::SEND_RESULT_TO_ABILITY, data, reply, option);
1073eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1074eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1075eace7efcSopenharmony_ci        return error;
1076eace7efcSopenharmony_ci    }
1077eace7efcSopenharmony_ci    return reply.ReadInt32();
1078eace7efcSopenharmony_ci}
1079eace7efcSopenharmony_ci
1080eace7efcSopenharmony_ciint AbilityManagerProxy::MoveAbilityToBackground(const sptr<IRemoteObject> &token)
1081eace7efcSopenharmony_ci{
1082eace7efcSopenharmony_ci    int error;
1083eace7efcSopenharmony_ci    MessageParcel data;
1084eace7efcSopenharmony_ci    MessageParcel reply;
1085eace7efcSopenharmony_ci    MessageOption option;
1086eace7efcSopenharmony_ci
1087eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1088eace7efcSopenharmony_ci        return INNER_ERR;
1089eace7efcSopenharmony_ci    }
1090eace7efcSopenharmony_ci    if (token) {
1091eace7efcSopenharmony_ci        if (!data.WriteBool(true) || !data.WriteRemoteObject(token)) {
1092eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag and token write fail");
1093eace7efcSopenharmony_ci            return INNER_ERR;
1094eace7efcSopenharmony_ci        }
1095eace7efcSopenharmony_ci    } else {
1096eace7efcSopenharmony_ci        if (!data.WriteBool(false)) {
1097eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag write fail");
1098eace7efcSopenharmony_ci            return INNER_ERR;
1099eace7efcSopenharmony_ci        }
1100eace7efcSopenharmony_ci    }
1101eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::MOVE_ABILITY_TO_BACKGROUND, data, reply, option);
1102eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1103eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1104eace7efcSopenharmony_ci        return error;
1105eace7efcSopenharmony_ci    }
1106eace7efcSopenharmony_ci    return reply.ReadInt32();
1107eace7efcSopenharmony_ci}
1108eace7efcSopenharmony_ci
1109eace7efcSopenharmony_ciint32_t AbilityManagerProxy::MoveUIAbilityToBackground(const sptr<IRemoteObject> token)
1110eace7efcSopenharmony_ci{
1111eace7efcSopenharmony_ci    CHECK_POINTER_AND_RETURN_LOG(token, ERR_INVALID_VALUE, "move fail, null token");
1112eace7efcSopenharmony_ci    MessageParcel data;
1113eace7efcSopenharmony_ci    MessageParcel reply;
1114eace7efcSopenharmony_ci    MessageOption option;
1115eace7efcSopenharmony_ci
1116eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1117eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write Token fail");
1118eace7efcSopenharmony_ci        return IPC_PROXY_ERR;
1119eace7efcSopenharmony_ci    }
1120eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, RemoteObject, token);
1121eace7efcSopenharmony_ci    int32_t error = SendRequest(AbilityManagerInterfaceCode::MOVE_UI_ABILITY_TO_BACKGROUND, data, reply, option);
1122eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1123eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1124eace7efcSopenharmony_ci        return error;
1125eace7efcSopenharmony_ci    }
1126eace7efcSopenharmony_ci    return reply.ReadInt32();
1127eace7efcSopenharmony_ci}
1128eace7efcSopenharmony_ci
1129eace7efcSopenharmony_ciint AbilityManagerProxy::CloseAbility(const sptr<IRemoteObject> &token, int resultCode, const Want *resultWant)
1130eace7efcSopenharmony_ci{
1131eace7efcSopenharmony_ci    return TerminateAbility(token, resultCode, resultWant, false);
1132eace7efcSopenharmony_ci}
1133eace7efcSopenharmony_ci
1134eace7efcSopenharmony_ciint AbilityManagerProxy::ConnectAbility(
1135eace7efcSopenharmony_ci    const Want &want, const sptr<IAbilityConnection> &connect, const sptr<IRemoteObject> &callerToken, int32_t userId)
1136eace7efcSopenharmony_ci{
1137eace7efcSopenharmony_ci    return ConnectAbilityCommon(want, connect, callerToken, AppExecFwk::ExtensionAbilityType::SERVICE, userId);
1138eace7efcSopenharmony_ci}
1139eace7efcSopenharmony_ci
1140eace7efcSopenharmony_ciint AbilityManagerProxy::ConnectAbilityCommon(
1141eace7efcSopenharmony_ci    const Want &want, const sptr<IAbilityConnection> &connect, const sptr<IRemoteObject> &callerToken,
1142eace7efcSopenharmony_ci    AppExecFwk::ExtensionAbilityType extensionType, int32_t userId, bool isQueryExtensionOnly)
1143eace7efcSopenharmony_ci{
1144eace7efcSopenharmony_ci    MessageParcel data;
1145eace7efcSopenharmony_ci    MessageParcel reply;
1146eace7efcSopenharmony_ci    MessageOption option;
1147eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1148eace7efcSopenharmony_ci        return INNER_ERR;
1149eace7efcSopenharmony_ci    }
1150eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Parcelable, &want);
1151eace7efcSopenharmony_ci    CHECK_POINTER_AND_RETURN_LOG(connect, ERR_INVALID_VALUE, "fail, null connect");
1152eace7efcSopenharmony_ci    if (connect->AsObject()) {
1153eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Bool, true);
1154eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, RemoteObject, connect->AsObject());
1155eace7efcSopenharmony_ci    } else {
1156eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Bool, false);
1157eace7efcSopenharmony_ci    }
1158eace7efcSopenharmony_ci    if (callerToken) {
1159eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Bool, true);
1160eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, RemoteObject, callerToken);
1161eace7efcSopenharmony_ci    } else {
1162eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Bool, false);
1163eace7efcSopenharmony_ci    }
1164eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Int32, userId);
1165eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Int32, static_cast<int32_t>(extensionType));
1166eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Bool, isQueryExtensionOnly);
1167eace7efcSopenharmony_ci    int error = SendRequest(AbilityManagerInterfaceCode::CONNECT_ABILITY_WITH_TYPE, data, reply, option);
1168eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1169eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s, request error:%{public}d", __func__, error);
1170eace7efcSopenharmony_ci        return error;
1171eace7efcSopenharmony_ci    }
1172eace7efcSopenharmony_ci    return reply.ReadInt32();
1173eace7efcSopenharmony_ci}
1174eace7efcSopenharmony_ci
1175eace7efcSopenharmony_ciint AbilityManagerProxy::ConnectUIExtensionAbility(const Want &want, const sptr<IAbilityConnection> &connect,
1176eace7efcSopenharmony_ci    const sptr<SessionInfo> &sessionInfo, int32_t userId, sptr<UIExtensionAbilityConnectInfo> connectInfo)
1177eace7efcSopenharmony_ci{
1178eace7efcSopenharmony_ci    MessageParcel data;
1179eace7efcSopenharmony_ci    MessageParcel reply;
1180eace7efcSopenharmony_ci    MessageOption option;
1181eace7efcSopenharmony_ci
1182eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1183eace7efcSopenharmony_ci        return INNER_ERR;
1184eace7efcSopenharmony_ci    }
1185eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Parcelable, &want);
1186eace7efcSopenharmony_ci    CHECK_POINTER_AND_RETURN_LOG(connect, ERR_INVALID_VALUE, "connect fail, null connect");
1187eace7efcSopenharmony_ci    if (connect->AsObject()) {
1188eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Bool, true);
1189eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, RemoteObject, connect->AsObject());
1190eace7efcSopenharmony_ci    } else {
1191eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Bool, false);
1192eace7efcSopenharmony_ci    }
1193eace7efcSopenharmony_ci    CHECK_POINTER_AND_RETURN_LOG(sessionInfo, ERR_INVALID_VALUE, "connect fail, null sessionInfo");
1194eace7efcSopenharmony_ci    if (sessionInfo) {
1195eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Bool, true);
1196eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Parcelable, sessionInfo);
1197eace7efcSopenharmony_ci    } else {
1198eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Bool, false);
1199eace7efcSopenharmony_ci    }
1200eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Int32, userId);
1201eace7efcSopenharmony_ci    if (connectInfo != nullptr) {
1202eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Bool, true);
1203eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Parcelable, connectInfo);
1204eace7efcSopenharmony_ci    } else {
1205eace7efcSopenharmony_ci        PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Bool, false);
1206eace7efcSopenharmony_ci    }
1207eace7efcSopenharmony_ci
1208eace7efcSopenharmony_ci    int error = SendRequest(AbilityManagerInterfaceCode::CONNECT_UI_EXTENSION_ABILITY, data, reply, option);
1209eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1210eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1211eace7efcSopenharmony_ci        return error;
1212eace7efcSopenharmony_ci    }
1213eace7efcSopenharmony_ci    if (connectInfo != nullptr) {
1214eace7efcSopenharmony_ci        sptr<UIExtensionAbilityConnectInfo> replyInfo = reply.ReadParcelable<UIExtensionAbilityConnectInfo>();
1215eace7efcSopenharmony_ci        if (replyInfo != nullptr) {
1216eace7efcSopenharmony_ci            connectInfo->uiExtensionAbilityId = replyInfo->uiExtensionAbilityId;
1217eace7efcSopenharmony_ci            TAG_LOGD(AAFwkTag::ABILITYMGR, "UIExtensionAbilityId is %{public}d.", connectInfo->uiExtensionAbilityId);
1218eace7efcSopenharmony_ci        }
1219eace7efcSopenharmony_ci    }
1220eace7efcSopenharmony_ci    return reply.ReadInt32();
1221eace7efcSopenharmony_ci}
1222eace7efcSopenharmony_ci
1223eace7efcSopenharmony_ciint AbilityManagerProxy::DisconnectAbility(sptr<IAbilityConnection> connect)
1224eace7efcSopenharmony_ci{
1225eace7efcSopenharmony_ci    int error;
1226eace7efcSopenharmony_ci    MessageParcel data;
1227eace7efcSopenharmony_ci    MessageParcel reply;
1228eace7efcSopenharmony_ci    MessageOption option;
1229eace7efcSopenharmony_ci    if (connect == nullptr) {
1230eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "fail, connect null");
1231eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
1232eace7efcSopenharmony_ci    }
1233eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1234eace7efcSopenharmony_ci        return INNER_ERR;
1235eace7efcSopenharmony_ci    }
1236eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(connect->AsObject())) {
1237eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "connect write failed");
1238eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
1239eace7efcSopenharmony_ci    }
1240eace7efcSopenharmony_ci
1241eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::DISCONNECT_ABILITY, data, reply, option);
1242eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1243eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1244eace7efcSopenharmony_ci        return error;
1245eace7efcSopenharmony_ci    }
1246eace7efcSopenharmony_ci    return reply.ReadInt32();
1247eace7efcSopenharmony_ci}
1248eace7efcSopenharmony_ci
1249eace7efcSopenharmony_cisptr<IAbilityScheduler> AbilityManagerProxy::AcquireDataAbility(
1250eace7efcSopenharmony_ci    const Uri &uri, bool tryBind, const sptr<IRemoteObject> &callerToken)
1251eace7efcSopenharmony_ci{
1252eace7efcSopenharmony_ci    int error;
1253eace7efcSopenharmony_ci    MessageParcel data;
1254eace7efcSopenharmony_ci    MessageParcel reply;
1255eace7efcSopenharmony_ci    MessageOption option;
1256eace7efcSopenharmony_ci
1257eace7efcSopenharmony_ci    if (!callerToken) {
1258eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "invalid parameters");
1259eace7efcSopenharmony_ci        return nullptr;
1260eace7efcSopenharmony_ci    }
1261eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1262eace7efcSopenharmony_ci        return nullptr;
1263eace7efcSopenharmony_ci    }
1264eace7efcSopenharmony_ci    if (!data.WriteString(uri.ToString()) || !data.WriteBool(tryBind) || !data.WriteRemoteObject(callerToken)) {
1265eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "data write fail");
1266eace7efcSopenharmony_ci        return nullptr;
1267eace7efcSopenharmony_ci    }
1268eace7efcSopenharmony_ci
1269eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::ACQUIRE_DATA_ABILITY, data, reply, option);
1270eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1271eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1272eace7efcSopenharmony_ci        return nullptr;
1273eace7efcSopenharmony_ci    }
1274eace7efcSopenharmony_ci
1275eace7efcSopenharmony_ci    return iface_cast<IAbilityScheduler>(reply.ReadRemoteObject());
1276eace7efcSopenharmony_ci}
1277eace7efcSopenharmony_ci
1278eace7efcSopenharmony_ciint AbilityManagerProxy::ReleaseDataAbility(
1279eace7efcSopenharmony_ci    sptr<IAbilityScheduler> dataAbilityScheduler, const sptr<IRemoteObject> &callerToken)
1280eace7efcSopenharmony_ci{
1281eace7efcSopenharmony_ci    int error;
1282eace7efcSopenharmony_ci    MessageParcel data;
1283eace7efcSopenharmony_ci    MessageParcel reply;
1284eace7efcSopenharmony_ci    MessageOption option;
1285eace7efcSopenharmony_ci
1286eace7efcSopenharmony_ci    if (!dataAbilityScheduler || !callerToken) {
1287eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
1288eace7efcSopenharmony_ci    }
1289eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1290eace7efcSopenharmony_ci        return INNER_ERR;
1291eace7efcSopenharmony_ci    }
1292eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(dataAbilityScheduler->AsObject()) || !data.WriteRemoteObject(callerToken)) {
1293eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "data write fail");
1294eace7efcSopenharmony_ci        return INNER_ERR;
1295eace7efcSopenharmony_ci    }
1296eace7efcSopenharmony_ci
1297eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::RELEASE_DATA_ABILITY, data, reply, option);
1298eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1299eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1300eace7efcSopenharmony_ci        return error;
1301eace7efcSopenharmony_ci    }
1302eace7efcSopenharmony_ci    return reply.ReadInt32();
1303eace7efcSopenharmony_ci}
1304eace7efcSopenharmony_ci
1305eace7efcSopenharmony_ciint AbilityManagerProxy::AttachAbilityThread(const sptr<IAbilityScheduler> &scheduler, const sptr<IRemoteObject> &token)
1306eace7efcSopenharmony_ci{
1307eace7efcSopenharmony_ci    int error;
1308eace7efcSopenharmony_ci    MessageParcel data;
1309eace7efcSopenharmony_ci    MessageParcel reply;
1310eace7efcSopenharmony_ci    MessageOption option;
1311eace7efcSopenharmony_ci    AbilityRuntime::FreezeUtil::LifecycleFlow flow = {token, AbilityRuntime::FreezeUtil::TimeoutState::LOAD};
1312eace7efcSopenharmony_ci    if (scheduler == nullptr) {
1313eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
1314eace7efcSopenharmony_ci    }
1315eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1316eace7efcSopenharmony_ci        return INNER_ERR;
1317eace7efcSopenharmony_ci    }
1318eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(scheduler->AsObject()) || !data.WriteRemoteObject(token)) {
1319eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "data write fail");
1320eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
1321eace7efcSopenharmony_ci    }
1322eace7efcSopenharmony_ci
1323eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::ATTACH_ABILITY_THREAD, data, reply, option);
1324eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1325eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1326eace7efcSopenharmony_ci        AbilityRuntime::FreezeUtil::GetInstance().AppendLifecycleEvent(flow,
1327eace7efcSopenharmony_ci            std::string("ERROR AttachAbilityThread failed IPC error") + std::to_string(error));
1328eace7efcSopenharmony_ci        return error;
1329eace7efcSopenharmony_ci    }
1330eace7efcSopenharmony_ci    return reply.ReadInt32();
1331eace7efcSopenharmony_ci}
1332eace7efcSopenharmony_ci
1333eace7efcSopenharmony_ciint AbilityManagerProxy::AbilityTransitionDone(const sptr<IRemoteObject> &token, int state, const PacMap &saveData)
1334eace7efcSopenharmony_ci{
1335eace7efcSopenharmony_ci    int error;
1336eace7efcSopenharmony_ci    MessageParcel data;
1337eace7efcSopenharmony_ci    MessageParcel reply;
1338eace7efcSopenharmony_ci    MessageOption option;
1339eace7efcSopenharmony_ci
1340eace7efcSopenharmony_ci    AbilityRuntime::FreezeUtil::LifecycleFlow flow = {token, AbilityRuntime::FreezeUtil::TimeoutState::FOREGROUND};
1341eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1342eace7efcSopenharmony_ci        return INNER_ERR;
1343eace7efcSopenharmony_ci    }
1344eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(token) || !data.WriteInt32(state)) {
1345eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "token or state write fail");
1346eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
1347eace7efcSopenharmony_ci    }
1348eace7efcSopenharmony_ci    if (!data.WriteParcelable(&saveData)) {
1349eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "saveData write fail");
1350eace7efcSopenharmony_ci        AbilityRuntime::FreezeUtil::GetInstance().AppendLifecycleEvent(flow,
1351eace7efcSopenharmony_ci            "write saveData failed");
1352eace7efcSopenharmony_ci        return INNER_ERR;
1353eace7efcSopenharmony_ci    }
1354eace7efcSopenharmony_ci
1355eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::ABILITY_TRANSITION_DONE, data, reply, option);
1356eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1357eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1358eace7efcSopenharmony_ci        AbilityRuntime::FreezeUtil::GetInstance().AppendLifecycleEvent(flow,
1359eace7efcSopenharmony_ci            std::string("ERROR AbilityTransitionDone failed IPC error") + std::to_string(error));
1360eace7efcSopenharmony_ci        return error;
1361eace7efcSopenharmony_ci    }
1362eace7efcSopenharmony_ci    return reply.ReadInt32();
1363eace7efcSopenharmony_ci}
1364eace7efcSopenharmony_ci
1365eace7efcSopenharmony_ciint AbilityManagerProxy::AbilityWindowConfigTransitionDone(
1366eace7efcSopenharmony_ci    const sptr<IRemoteObject> &token, const WindowConfig &windowConfig)
1367eace7efcSopenharmony_ci{
1368eace7efcSopenharmony_ci    int error;
1369eace7efcSopenharmony_ci    MessageParcel data;
1370eace7efcSopenharmony_ci    MessageParcel reply;
1371eace7efcSopenharmony_ci    MessageOption option(MessageOption::TF_ASYNC);
1372eace7efcSopenharmony_ci
1373eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1374eace7efcSopenharmony_ci        return INNER_ERR;
1375eace7efcSopenharmony_ci    }
1376eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(token)) {
1377eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "token or state write fail");
1378eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
1379eace7efcSopenharmony_ci    }
1380eace7efcSopenharmony_ci    if (!data.WriteParcelable(&windowConfig)) {
1381eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "saveData write fail");
1382eace7efcSopenharmony_ci        return INNER_ERR;
1383eace7efcSopenharmony_ci    }
1384eace7efcSopenharmony_ci
1385eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::ABILITY_WINDOW_CONFIG_TRANSITION_DONE, data, reply, option);
1386eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1387eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1388eace7efcSopenharmony_ci        return error;
1389eace7efcSopenharmony_ci    }
1390eace7efcSopenharmony_ci    return reply.ReadInt32();
1391eace7efcSopenharmony_ci}
1392eace7efcSopenharmony_ci
1393eace7efcSopenharmony_ciint AbilityManagerProxy::ScheduleConnectAbilityDone(
1394eace7efcSopenharmony_ci    const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &remoteObject)
1395eace7efcSopenharmony_ci{
1396eace7efcSopenharmony_ci    int error;
1397eace7efcSopenharmony_ci    MessageParcel data;
1398eace7efcSopenharmony_ci    MessageParcel reply;
1399eace7efcSopenharmony_ci    MessageOption option;
1400eace7efcSopenharmony_ci
1401eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1402eace7efcSopenharmony_ci        return INNER_ERR;
1403eace7efcSopenharmony_ci    }
1404eace7efcSopenharmony_ci
1405eace7efcSopenharmony_ci    if (token) {
1406eace7efcSopenharmony_ci        if (!data.WriteBool(true) || !data.WriteRemoteObject(token)) {
1407eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "write flag and token fail");
1408eace7efcSopenharmony_ci            return ERR_INVALID_VALUE;
1409eace7efcSopenharmony_ci        }
1410eace7efcSopenharmony_ci    } else {
1411eace7efcSopenharmony_ci        if (!data.WriteBool(false)) {
1412eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "write flag fail");
1413eace7efcSopenharmony_ci            return ERR_INVALID_VALUE;
1414eace7efcSopenharmony_ci        }
1415eace7efcSopenharmony_ci    }
1416eace7efcSopenharmony_ci
1417eace7efcSopenharmony_ci    if (remoteObject) {
1418eace7efcSopenharmony_ci        if (!data.WriteBool(true) || !data.WriteRemoteObject(remoteObject)) {
1419eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "write flag and remoteObject fail");
1420eace7efcSopenharmony_ci            return ERR_INVALID_VALUE;
1421eace7efcSopenharmony_ci        }
1422eace7efcSopenharmony_ci    } else {
1423eace7efcSopenharmony_ci        if (!data.WriteBool(false)) {
1424eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "write flag fail");
1425eace7efcSopenharmony_ci            return ERR_INVALID_VALUE;
1426eace7efcSopenharmony_ci        }
1427eace7efcSopenharmony_ci    }
1428eace7efcSopenharmony_ci
1429eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::CONNECT_ABILITY_DONE, data, reply, option);
1430eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1431eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1432eace7efcSopenharmony_ci        return error;
1433eace7efcSopenharmony_ci    }
1434eace7efcSopenharmony_ci    return reply.ReadInt32();
1435eace7efcSopenharmony_ci}
1436eace7efcSopenharmony_ci
1437eace7efcSopenharmony_ciint AbilityManagerProxy::ScheduleDisconnectAbilityDone(const sptr<IRemoteObject> &token)
1438eace7efcSopenharmony_ci{
1439eace7efcSopenharmony_ci    int error;
1440eace7efcSopenharmony_ci    MessageParcel data;
1441eace7efcSopenharmony_ci    MessageParcel reply;
1442eace7efcSopenharmony_ci    MessageOption option;
1443eace7efcSopenharmony_ci
1444eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1445eace7efcSopenharmony_ci        return INNER_ERR;
1446eace7efcSopenharmony_ci    }
1447eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(token)) {
1448eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "token write failed.");
1449eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
1450eace7efcSopenharmony_ci    }
1451eace7efcSopenharmony_ci
1452eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::DISCONNECT_ABILITY_DONE, data, reply, option);
1453eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1454eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1455eace7efcSopenharmony_ci        return error;
1456eace7efcSopenharmony_ci    }
1457eace7efcSopenharmony_ci    return reply.ReadInt32();
1458eace7efcSopenharmony_ci}
1459eace7efcSopenharmony_ci
1460eace7efcSopenharmony_ciint AbilityManagerProxy::ScheduleCommandAbilityDone(const sptr<IRemoteObject> &token)
1461eace7efcSopenharmony_ci{
1462eace7efcSopenharmony_ci    int error;
1463eace7efcSopenharmony_ci    MessageParcel data;
1464eace7efcSopenharmony_ci    MessageParcel reply;
1465eace7efcSopenharmony_ci    MessageOption option;
1466eace7efcSopenharmony_ci
1467eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1468eace7efcSopenharmony_ci        return INNER_ERR;
1469eace7efcSopenharmony_ci    }
1470eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(token)) {
1471eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "token write fail");
1472eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
1473eace7efcSopenharmony_ci    }
1474eace7efcSopenharmony_ci
1475eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::COMMAND_ABILITY_DONE, data, reply, option);
1476eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1477eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1478eace7efcSopenharmony_ci        return error;
1479eace7efcSopenharmony_ci    }
1480eace7efcSopenharmony_ci    return reply.ReadInt32();
1481eace7efcSopenharmony_ci}
1482eace7efcSopenharmony_ci
1483eace7efcSopenharmony_ciint AbilityManagerProxy::ScheduleCommandAbilityWindowDone(
1484eace7efcSopenharmony_ci    const sptr<IRemoteObject> &token,
1485eace7efcSopenharmony_ci    const sptr<SessionInfo> &sessionInfo,
1486eace7efcSopenharmony_ci    WindowCommand winCmd,
1487eace7efcSopenharmony_ci    AbilityCommand abilityCmd)
1488eace7efcSopenharmony_ci{
1489eace7efcSopenharmony_ci    int error;
1490eace7efcSopenharmony_ci    MessageParcel data;
1491eace7efcSopenharmony_ci    MessageParcel reply;
1492eace7efcSopenharmony_ci    MessageOption option;
1493eace7efcSopenharmony_ci
1494eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1495eace7efcSopenharmony_ci        return INNER_ERR;
1496eace7efcSopenharmony_ci    }
1497eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(token)) {
1498eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "token write fail");
1499eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
1500eace7efcSopenharmony_ci    }
1501eace7efcSopenharmony_ci    if (!data.WriteParcelable(sessionInfo)) {
1502eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "sessionInfo write fail");
1503eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
1504eace7efcSopenharmony_ci    }
1505eace7efcSopenharmony_ci    if (!data.WriteInt32(winCmd)) {
1506eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "winCmd write fail");
1507eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
1508eace7efcSopenharmony_ci    }
1509eace7efcSopenharmony_ci    if (!data.WriteInt32(abilityCmd)) {
1510eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "abilityCmd write fail");
1511eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
1512eace7efcSopenharmony_ci    }
1513eace7efcSopenharmony_ci
1514eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::COMMAND_ABILITY_WINDOW_DONE, data, reply, option);
1515eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1516eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1517eace7efcSopenharmony_ci        return error;
1518eace7efcSopenharmony_ci    }
1519eace7efcSopenharmony_ci    return reply.ReadInt32();
1520eace7efcSopenharmony_ci}
1521eace7efcSopenharmony_ci
1522eace7efcSopenharmony_civoid AbilityManagerProxy::DumpSysState(
1523eace7efcSopenharmony_ci    const std::string& args, std::vector<std::string>& state, bool isClient, bool isUserId, int UserId)
1524eace7efcSopenharmony_ci{
1525eace7efcSopenharmony_ci    int error;
1526eace7efcSopenharmony_ci    MessageParcel data;
1527eace7efcSopenharmony_ci    MessageParcel reply;
1528eace7efcSopenharmony_ci    MessageOption option;
1529eace7efcSopenharmony_ci
1530eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1531eace7efcSopenharmony_ci        return;
1532eace7efcSopenharmony_ci    }
1533eace7efcSopenharmony_ci    data.WriteString16(Str8ToStr16(args));
1534eace7efcSopenharmony_ci
1535eace7efcSopenharmony_ci    if (!data.WriteBool(isClient)) {
1536eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "data write fail");
1537eace7efcSopenharmony_ci        return ;
1538eace7efcSopenharmony_ci    }
1539eace7efcSopenharmony_ci    if (!data.WriteBool(isUserId)) {
1540eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "data write fail");
1541eace7efcSopenharmony_ci        return ;
1542eace7efcSopenharmony_ci    }
1543eace7efcSopenharmony_ci    if (!data.WriteInt32(UserId)) {
1544eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "data write fail");
1545eace7efcSopenharmony_ci        return ;
1546eace7efcSopenharmony_ci    }
1547eace7efcSopenharmony_ci
1548eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::DUMPSYS_STATE, data, reply, option);
1549eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1550eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1551eace7efcSopenharmony_ci        return;
1552eace7efcSopenharmony_ci    }
1553eace7efcSopenharmony_ci    int32_t stackNum = reply.ReadInt32();
1554eace7efcSopenharmony_ci    for (int i = 0; i < stackNum; i++) {
1555eace7efcSopenharmony_ci        std::string stac = Str16ToStr8(reply.ReadString16());
1556eace7efcSopenharmony_ci        state.emplace_back(stac);
1557eace7efcSopenharmony_ci    }
1558eace7efcSopenharmony_ci}
1559eace7efcSopenharmony_ci
1560eace7efcSopenharmony_civoid AbilityManagerProxy::DumpState(const std::string &args, std::vector<std::string> &state)
1561eace7efcSopenharmony_ci{
1562eace7efcSopenharmony_ci    int error;
1563eace7efcSopenharmony_ci    MessageParcel data;
1564eace7efcSopenharmony_ci    MessageParcel reply;
1565eace7efcSopenharmony_ci    MessageOption option;
1566eace7efcSopenharmony_ci
1567eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1568eace7efcSopenharmony_ci        return;
1569eace7efcSopenharmony_ci    }
1570eace7efcSopenharmony_ci    data.WriteString16(Str8ToStr16(args));
1571eace7efcSopenharmony_ci
1572eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::DUMP_STATE, data, reply, option);
1573eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1574eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1575eace7efcSopenharmony_ci        return;
1576eace7efcSopenharmony_ci    }
1577eace7efcSopenharmony_ci    int32_t stackNum = reply.ReadInt32();
1578eace7efcSopenharmony_ci    for (int i = 0; i < stackNum; i++) {
1579eace7efcSopenharmony_ci        std::string stac = Str16ToStr8(reply.ReadString16());
1580eace7efcSopenharmony_ci        state.emplace_back(stac);
1581eace7efcSopenharmony_ci    }
1582eace7efcSopenharmony_ci}
1583eace7efcSopenharmony_ci
1584eace7efcSopenharmony_ciint AbilityManagerProxy::MinimizeAbility(const sptr<IRemoteObject> &token, bool fromUser)
1585eace7efcSopenharmony_ci{
1586eace7efcSopenharmony_ci    int error;
1587eace7efcSopenharmony_ci    MessageParcel data;
1588eace7efcSopenharmony_ci    MessageParcel reply;
1589eace7efcSopenharmony_ci    MessageOption option;
1590eace7efcSopenharmony_ci
1591eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1592eace7efcSopenharmony_ci        return INNER_ERR;
1593eace7efcSopenharmony_ci    }
1594eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(token)) {
1595eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "token write fail");
1596eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
1597eace7efcSopenharmony_ci    }
1598eace7efcSopenharmony_ci    if (!data.WriteBool(fromUser)) {
1599eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "data write fail");
1600eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
1601eace7efcSopenharmony_ci    }
1602eace7efcSopenharmony_ci
1603eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::MINIMIZE_ABILITY, data, reply, option);
1604eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1605eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1606eace7efcSopenharmony_ci        return error;
1607eace7efcSopenharmony_ci    }
1608eace7efcSopenharmony_ci    return reply.ReadInt32();
1609eace7efcSopenharmony_ci}
1610eace7efcSopenharmony_ci
1611eace7efcSopenharmony_ciint AbilityManagerProxy::MinimizeUIExtensionAbility(const sptr<SessionInfo> &extensionSessionInfo,
1612eace7efcSopenharmony_ci    bool fromUser)
1613eace7efcSopenharmony_ci{
1614eace7efcSopenharmony_ci    int error;
1615eace7efcSopenharmony_ci    MessageParcel data;
1616eace7efcSopenharmony_ci    MessageParcel reply;
1617eace7efcSopenharmony_ci    MessageOption option;
1618eace7efcSopenharmony_ci
1619eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1620eace7efcSopenharmony_ci        return INNER_ERR;
1621eace7efcSopenharmony_ci    }
1622eace7efcSopenharmony_ci    CHECK_POINTER_AND_RETURN_LOG(extensionSessionInfo, ERR_INVALID_VALUE,
1623eace7efcSopenharmony_ci        "connect fail, null extensionSessionInfo");
1624eace7efcSopenharmony_ci    if (extensionSessionInfo) {
1625eace7efcSopenharmony_ci        if (!data.WriteBool(true) || !data.WriteParcelable(extensionSessionInfo)) {
1626eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag and extensionSessionInfo write fail");
1627eace7efcSopenharmony_ci            return INNER_ERR;
1628eace7efcSopenharmony_ci        }
1629eace7efcSopenharmony_ci    } else {
1630eace7efcSopenharmony_ci        if (!data.WriteBool(false)) {
1631eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag write fail");
1632eace7efcSopenharmony_ci            return INNER_ERR;
1633eace7efcSopenharmony_ci        }
1634eace7efcSopenharmony_ci    }
1635eace7efcSopenharmony_ci    if (!data.WriteBool(fromUser)) {
1636eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "data write fail");
1637eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
1638eace7efcSopenharmony_ci    }
1639eace7efcSopenharmony_ci
1640eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::MINIMIZE_UI_EXTENSION_ABILITY, data, reply, option);
1641eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1642eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1643eace7efcSopenharmony_ci        return error;
1644eace7efcSopenharmony_ci    }
1645eace7efcSopenharmony_ci    return reply.ReadInt32();
1646eace7efcSopenharmony_ci}
1647eace7efcSopenharmony_ci
1648eace7efcSopenharmony_ciint AbilityManagerProxy::MinimizeUIAbilityBySCB(const sptr<SessionInfo> &sessionInfo, bool fromUser, uint32_t sceneFlag)
1649eace7efcSopenharmony_ci{
1650eace7efcSopenharmony_ci    int error;
1651eace7efcSopenharmony_ci    MessageParcel data;
1652eace7efcSopenharmony_ci    MessageParcel reply;
1653eace7efcSopenharmony_ci    MessageOption option;
1654eace7efcSopenharmony_ci
1655eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1656eace7efcSopenharmony_ci        return INNER_ERR;
1657eace7efcSopenharmony_ci    }
1658eace7efcSopenharmony_ci    if (sessionInfo) {
1659eace7efcSopenharmony_ci        if (!data.WriteBool(true) || !data.WriteParcelable(sessionInfo)) {
1660eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag and sessionInfo write fail");
1661eace7efcSopenharmony_ci            return INNER_ERR;
1662eace7efcSopenharmony_ci        }
1663eace7efcSopenharmony_ci    } else {
1664eace7efcSopenharmony_ci        if (!data.WriteBool(false)) {
1665eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag write fail");
1666eace7efcSopenharmony_ci            return INNER_ERR;
1667eace7efcSopenharmony_ci        }
1668eace7efcSopenharmony_ci    }
1669eace7efcSopenharmony_ci    if (!data.WriteBool(fromUser)) {
1670eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "fromUser write fail");
1671eace7efcSopenharmony_ci        return INNER_ERR;
1672eace7efcSopenharmony_ci    }
1673eace7efcSopenharmony_ci    if (!data.WriteUint32(sceneFlag)) {
1674eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "sceneFlag write fail");
1675eace7efcSopenharmony_ci        return INNER_ERR;
1676eace7efcSopenharmony_ci    }
1677eace7efcSopenharmony_ci
1678eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::MINIMIZE_UI_ABILITY_BY_SCB, data, reply, option);
1679eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1680eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1681eace7efcSopenharmony_ci        return error;
1682eace7efcSopenharmony_ci    }
1683eace7efcSopenharmony_ci    return reply.ReadInt32();
1684eace7efcSopenharmony_ci}
1685eace7efcSopenharmony_ci
1686eace7efcSopenharmony_ciint AbilityManagerProxy::StopServiceAbility(const Want &want, int32_t userId, const sptr<IRemoteObject> &token)
1687eace7efcSopenharmony_ci{
1688eace7efcSopenharmony_ci    int error;
1689eace7efcSopenharmony_ci    MessageParcel data;
1690eace7efcSopenharmony_ci    MessageParcel reply;
1691eace7efcSopenharmony_ci    MessageOption option;
1692eace7efcSopenharmony_ci
1693eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1694eace7efcSopenharmony_ci        return INNER_ERR;
1695eace7efcSopenharmony_ci    }
1696eace7efcSopenharmony_ci    if (!data.WriteParcelable(&want)) {
1697eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "want write fail");
1698eace7efcSopenharmony_ci        return INNER_ERR;
1699eace7efcSopenharmony_ci    }
1700eace7efcSopenharmony_ci    if (!data.WriteInt32(userId)) {
1701eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "userId write fail");
1702eace7efcSopenharmony_ci        return INNER_ERR;
1703eace7efcSopenharmony_ci    }
1704eace7efcSopenharmony_ci    if (token) {
1705eace7efcSopenharmony_ci        if (!data.WriteBool(true) || !data.WriteRemoteObject(token)) {
1706eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "failedwrite flag and token fail");
1707eace7efcSopenharmony_ci            return ERR_INVALID_VALUE;
1708eace7efcSopenharmony_ci        }
1709eace7efcSopenharmony_ci    } else {
1710eace7efcSopenharmony_ci        if (!data.WriteBool(false)) {
1711eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "write flag fail");
1712eace7efcSopenharmony_ci            return ERR_INVALID_VALUE;
1713eace7efcSopenharmony_ci        }
1714eace7efcSopenharmony_ci    }
1715eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::STOP_SERVICE_ABILITY, data, reply, option);
1716eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1717eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1718eace7efcSopenharmony_ci        return error;
1719eace7efcSopenharmony_ci    }
1720eace7efcSopenharmony_ci    return reply.ReadInt32();
1721eace7efcSopenharmony_ci}
1722eace7efcSopenharmony_ci
1723eace7efcSopenharmony_citemplate <typename T>
1724eace7efcSopenharmony_ciint AbilityManagerProxy::GetParcelableInfos(MessageParcel &reply, std::vector<T> &parcelableInfos)
1725eace7efcSopenharmony_ci{
1726eace7efcSopenharmony_ci    int32_t infoSize = reply.ReadInt32();
1727eace7efcSopenharmony_ci    if (infoSize > CYCLE_LIMIT) {
1728eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "infoSize large");
1729eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
1730eace7efcSopenharmony_ci    }
1731eace7efcSopenharmony_ci
1732eace7efcSopenharmony_ci    for (int32_t i = 0; i < infoSize; i++) {
1733eace7efcSopenharmony_ci        std::unique_ptr<T> info(reply.ReadParcelable<T>());
1734eace7efcSopenharmony_ci        if (!info) {
1735eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "readParcelableInfos fail");
1736eace7efcSopenharmony_ci            return ERR_INVALID_VALUE;
1737eace7efcSopenharmony_ci        }
1738eace7efcSopenharmony_ci        parcelableInfos.emplace_back(*info);
1739eace7efcSopenharmony_ci    }
1740eace7efcSopenharmony_ci    return NO_ERROR;
1741eace7efcSopenharmony_ci}
1742eace7efcSopenharmony_ci
1743eace7efcSopenharmony_ciint AbilityManagerProxy::GetMissionSnapshot(const std::string& deviceId, int32_t missionId,
1744eace7efcSopenharmony_ci    MissionSnapshot& snapshot, bool isLowResolution)
1745eace7efcSopenharmony_ci{
1746eace7efcSopenharmony_ci    int error;
1747eace7efcSopenharmony_ci    MessageParcel data;
1748eace7efcSopenharmony_ci    MessageParcel reply;
1749eace7efcSopenharmony_ci    MessageOption option;
1750eace7efcSopenharmony_ci
1751eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1752eace7efcSopenharmony_ci        return INNER_ERR;
1753eace7efcSopenharmony_ci    }
1754eace7efcSopenharmony_ci    if (!data.WriteString(deviceId)) {
1755eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "deviceId write fail");
1756eace7efcSopenharmony_ci        return INNER_ERR;
1757eace7efcSopenharmony_ci    }
1758eace7efcSopenharmony_ci    if (!data.WriteInt32(missionId)) {
1759eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "missionId write fail");
1760eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
1761eace7efcSopenharmony_ci    }
1762eace7efcSopenharmony_ci    if (!data.WriteBool(isLowResolution)) {
1763eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "isLowResolution write fail");
1764eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
1765eace7efcSopenharmony_ci    }
1766eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::GET_MISSION_SNAPSHOT_INFO, data, reply, option);
1767eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1768eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1769eace7efcSopenharmony_ci        return error;
1770eace7efcSopenharmony_ci    }
1771eace7efcSopenharmony_ci    std::unique_ptr<MissionSnapshot> info(reply.ReadParcelable<MissionSnapshot>());
1772eace7efcSopenharmony_ci    if (!info) {
1773eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "readParcelableInfo fail");
1774eace7efcSopenharmony_ci        auto errorCode = reply.ReadInt32();
1775eace7efcSopenharmony_ci        return errorCode ? errorCode : ERR_UNKNOWN_OBJECT;
1776eace7efcSopenharmony_ci    }
1777eace7efcSopenharmony_ci    snapshot = *info;
1778eace7efcSopenharmony_ci    return reply.ReadInt32();
1779eace7efcSopenharmony_ci}
1780eace7efcSopenharmony_ci#ifdef SUPPORT_SCREEN
1781eace7efcSopenharmony_civoid AbilityManagerProxy::UpdateMissionSnapShot(const sptr<IRemoteObject> &token,
1782eace7efcSopenharmony_ci    const std::shared_ptr<Media::PixelMap> &pixelMap)
1783eace7efcSopenharmony_ci{
1784eace7efcSopenharmony_ci    MessageParcel data;
1785eace7efcSopenharmony_ci    MessageParcel reply;
1786eace7efcSopenharmony_ci    MessageOption option(MessageOption::TF_ASYNC);
1787eace7efcSopenharmony_ci
1788eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1789eace7efcSopenharmony_ci        return;
1790eace7efcSopenharmony_ci    }
1791eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(token)) {
1792eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
1793eace7efcSopenharmony_ci        return;
1794eace7efcSopenharmony_ci    }
1795eace7efcSopenharmony_ci    if (!data.WriteParcelable(pixelMap.get())) {
1796eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write pixelMap fail");
1797eace7efcSopenharmony_ci        return;
1798eace7efcSopenharmony_ci    }
1799eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::UPDATE_MISSION_SNAPSHOT_FROM_WMS,
1800eace7efcSopenharmony_ci        data, reply, option);
1801eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1802eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1803eace7efcSopenharmony_ci    }
1804eace7efcSopenharmony_ci}
1805eace7efcSopenharmony_ci#endif // SUPPORT_SCREEN
1806eace7efcSopenharmony_civoid AbilityManagerProxy::EnableRecoverAbility(const sptr<IRemoteObject>& token)
1807eace7efcSopenharmony_ci{
1808eace7efcSopenharmony_ci    int error;
1809eace7efcSopenharmony_ci    MessageParcel data;
1810eace7efcSopenharmony_ci    MessageParcel reply;
1811eace7efcSopenharmony_ci    MessageOption option(MessageOption::TF_ASYNC);
1812eace7efcSopenharmony_ci
1813eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1814eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "writeInterfaceToken fail");
1815eace7efcSopenharmony_ci        return;
1816eace7efcSopenharmony_ci    }
1817eace7efcSopenharmony_ci
1818eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(token)) {
1819eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "writeRemoteObject fail");
1820eace7efcSopenharmony_ci        return;
1821eace7efcSopenharmony_ci    }
1822eace7efcSopenharmony_ci
1823eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::ABILITY_RECOVERY_ENABLE, data, reply, option);
1824eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1825eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1826eace7efcSopenharmony_ci        return;
1827eace7efcSopenharmony_ci    }
1828eace7efcSopenharmony_ci    return;
1829eace7efcSopenharmony_ci}
1830eace7efcSopenharmony_ci
1831eace7efcSopenharmony_civoid AbilityManagerProxy::ScheduleRecoverAbility(const sptr<IRemoteObject>& token, int32_t reason, const Want *want)
1832eace7efcSopenharmony_ci{
1833eace7efcSopenharmony_ci    int error;
1834eace7efcSopenharmony_ci    MessageParcel data;
1835eace7efcSopenharmony_ci    MessageParcel reply;
1836eace7efcSopenharmony_ci    MessageOption option(MessageOption::TF_ASYNC);
1837eace7efcSopenharmony_ci
1838eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1839eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "writeInterfaceToken fail");
1840eace7efcSopenharmony_ci        return;
1841eace7efcSopenharmony_ci    }
1842eace7efcSopenharmony_ci
1843eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(token)) {
1844eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "writeRemoteObject fail");
1845eace7efcSopenharmony_ci        return;
1846eace7efcSopenharmony_ci    }
1847eace7efcSopenharmony_ci
1848eace7efcSopenharmony_ci    data.WriteInt32(reason);
1849eace7efcSopenharmony_ci
1850eace7efcSopenharmony_ci    if (!data.WriteParcelable(want)) {
1851eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write want fail");
1852eace7efcSopenharmony_ci        return;
1853eace7efcSopenharmony_ci    }
1854eace7efcSopenharmony_ci
1855eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::ABILITY_RECOVERY, data, reply, option);
1856eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1857eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1858eace7efcSopenharmony_ci        return;
1859eace7efcSopenharmony_ci    }
1860eace7efcSopenharmony_ci    return;
1861eace7efcSopenharmony_ci}
1862eace7efcSopenharmony_ci
1863eace7efcSopenharmony_civoid AbilityManagerProxy::SubmitSaveRecoveryInfo(const sptr<IRemoteObject>& token)
1864eace7efcSopenharmony_ci{
1865eace7efcSopenharmony_ci    int error;
1866eace7efcSopenharmony_ci    MessageParcel data;
1867eace7efcSopenharmony_ci    MessageParcel reply;
1868eace7efcSopenharmony_ci    MessageOption option(MessageOption::TF_ASYNC);
1869eace7efcSopenharmony_ci
1870eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1871eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "writeInterfaceToken fail");
1872eace7efcSopenharmony_ci        return;
1873eace7efcSopenharmony_ci    }
1874eace7efcSopenharmony_ci
1875eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(token)) {
1876eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "writeRemoteObject fail");
1877eace7efcSopenharmony_ci        return;
1878eace7efcSopenharmony_ci    }
1879eace7efcSopenharmony_ci
1880eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::ABILITY_RECOVERY_SUBMITINFO, data, reply, option);
1881eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1882eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1883eace7efcSopenharmony_ci        return;
1884eace7efcSopenharmony_ci    }
1885eace7efcSopenharmony_ci    return;
1886eace7efcSopenharmony_ci}
1887eace7efcSopenharmony_ci
1888eace7efcSopenharmony_ciint AbilityManagerProxy::KillProcess(const std::string &bundleName, const bool clearPageStack)
1889eace7efcSopenharmony_ci{
1890eace7efcSopenharmony_ci    MessageParcel data;
1891eace7efcSopenharmony_ci    MessageParcel reply;
1892eace7efcSopenharmony_ci    MessageOption option;
1893eace7efcSopenharmony_ci
1894eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1895eace7efcSopenharmony_ci        return INNER_ERR;
1896eace7efcSopenharmony_ci    }
1897eace7efcSopenharmony_ci    if (!data.WriteString16(Str8ToStr16(bundleName))) {
1898eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "bundleName write fail");
1899eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
1900eace7efcSopenharmony_ci    }
1901eace7efcSopenharmony_ci    if (!data.WriteBool(clearPageStack)) {
1902eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "clearPageStack write fail");
1903eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
1904eace7efcSopenharmony_ci    }
1905eace7efcSopenharmony_ci    int error = SendRequest(AbilityManagerInterfaceCode::KILL_PROCESS, data, reply, option);
1906eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1907eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1908eace7efcSopenharmony_ci        return error;
1909eace7efcSopenharmony_ci    }
1910eace7efcSopenharmony_ci    return reply.ReadInt32();
1911eace7efcSopenharmony_ci}
1912eace7efcSopenharmony_ci
1913eace7efcSopenharmony_civoid AbilityManagerProxy::ScheduleClearRecoveryPageStack()
1914eace7efcSopenharmony_ci{
1915eace7efcSopenharmony_ci    MessageParcel data;
1916eace7efcSopenharmony_ci    MessageParcel reply;
1917eace7efcSopenharmony_ci    MessageOption option;
1918eace7efcSopenharmony_ci
1919eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1920eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "writeInterfaceToken failed");
1921eace7efcSopenharmony_ci        return;
1922eace7efcSopenharmony_ci    }
1923eace7efcSopenharmony_ci
1924eace7efcSopenharmony_ci    int error = SendRequest(AbilityManagerInterfaceCode::CLEAR_RECOVERY_PAGE_STACK, data, reply, option);
1925eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1926eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1927eace7efcSopenharmony_ci        return;
1928eace7efcSopenharmony_ci    }
1929eace7efcSopenharmony_ci    return;
1930eace7efcSopenharmony_ci}
1931eace7efcSopenharmony_ci
1932eace7efcSopenharmony_ci#ifdef ABILITY_COMMAND_FOR_TEST
1933eace7efcSopenharmony_ciint AbilityManagerProxy::ForceTimeoutForTest(const std::string &abilityName, const std::string &state)
1934eace7efcSopenharmony_ci{
1935eace7efcSopenharmony_ci    MessageParcel data;
1936eace7efcSopenharmony_ci    MessageParcel reply;
1937eace7efcSopenharmony_ci    MessageOption option;
1938eace7efcSopenharmony_ci
1939eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1940eace7efcSopenharmony_ci        return INNER_ERR;
1941eace7efcSopenharmony_ci    }
1942eace7efcSopenharmony_ci    if (!data.WriteString16(Str8ToStr16(abilityName))) {
1943eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "abilityName write fail");
1944eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
1945eace7efcSopenharmony_ci    }
1946eace7efcSopenharmony_ci    if (!data.WriteString16(Str8ToStr16(state))) {
1947eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "abilityName write fail");
1948eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
1949eace7efcSopenharmony_ci    }
1950eace7efcSopenharmony_ci    int error = SendRequest(AbilityManagerInterfaceCode::FORCE_TIMEOUT, data, reply, option);
1951eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1952eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1953eace7efcSopenharmony_ci        return error;
1954eace7efcSopenharmony_ci    }
1955eace7efcSopenharmony_ci    return reply.ReadInt32();
1956eace7efcSopenharmony_ci}
1957eace7efcSopenharmony_ci#endif
1958eace7efcSopenharmony_ci
1959eace7efcSopenharmony_ciint AbilityManagerProxy::UninstallApp(const std::string &bundleName, int32_t uid)
1960eace7efcSopenharmony_ci{
1961eace7efcSopenharmony_ci    return UninstallApp(bundleName, uid, 0);
1962eace7efcSopenharmony_ci}
1963eace7efcSopenharmony_ci
1964eace7efcSopenharmony_ciint32_t AbilityManagerProxy::UninstallApp(const std::string &bundleName, int32_t uid, int32_t appIndex)
1965eace7efcSopenharmony_ci{
1966eace7efcSopenharmony_ci    MessageParcel data;
1967eace7efcSopenharmony_ci    MessageParcel reply;
1968eace7efcSopenharmony_ci    MessageOption option;
1969eace7efcSopenharmony_ci
1970eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
1971eace7efcSopenharmony_ci        return INNER_ERR;
1972eace7efcSopenharmony_ci    }
1973eace7efcSopenharmony_ci    if (!data.WriteString16(Str8ToStr16(bundleName))) {
1974eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "bundleName write fail");
1975eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
1976eace7efcSopenharmony_ci    }
1977eace7efcSopenharmony_ci    if (!data.WriteInt32(uid)) {
1978eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "uid write fail");
1979eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
1980eace7efcSopenharmony_ci    }
1981eace7efcSopenharmony_ci    if (!data.WriteInt32(appIndex)) {
1982eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "appIndex write fail");
1983eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
1984eace7efcSopenharmony_ci    }
1985eace7efcSopenharmony_ci    int error = SendRequest(AbilityManagerInterfaceCode::UNINSTALL_APP, data, reply, option);
1986eace7efcSopenharmony_ci    if (error != NO_ERROR) {
1987eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
1988eace7efcSopenharmony_ci        return error;
1989eace7efcSopenharmony_ci    }
1990eace7efcSopenharmony_ci    return reply.ReadInt32();
1991eace7efcSopenharmony_ci}
1992eace7efcSopenharmony_ci
1993eace7efcSopenharmony_ciint32_t AbilityManagerProxy::UpgradeApp(const std::string &bundleName, const int32_t uid, const std::string &exitMsg,
1994eace7efcSopenharmony_ci    int32_t appIndex)
1995eace7efcSopenharmony_ci{
1996eace7efcSopenharmony_ci    MessageParcel data;
1997eace7efcSopenharmony_ci    MessageParcel reply;
1998eace7efcSopenharmony_ci    MessageOption option;
1999eace7efcSopenharmony_ci
2000eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2001eace7efcSopenharmony_ci        return INNER_ERR;
2002eace7efcSopenharmony_ci    }
2003eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, String16, Str8ToStr16(bundleName));
2004eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Int32, uid);
2005eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, String16, Str8ToStr16(exitMsg));
2006eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Int32, appIndex);
2007eace7efcSopenharmony_ci    int error = SendRequest(AbilityManagerInterfaceCode::UPGRADE_APP, data, reply, option);
2008eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2009eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "sendRequest error: %{public}d", error);
2010eace7efcSopenharmony_ci        return error;
2011eace7efcSopenharmony_ci    }
2012eace7efcSopenharmony_ci    return reply.ReadInt32();
2013eace7efcSopenharmony_ci}
2014eace7efcSopenharmony_ci
2015eace7efcSopenharmony_cisptr<IWantSender> AbilityManagerProxy::GetWantSender(
2016eace7efcSopenharmony_ci    const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken, int32_t uid)
2017eace7efcSopenharmony_ci{
2018eace7efcSopenharmony_ci    MessageParcel data;
2019eace7efcSopenharmony_ci    MessageParcel reply;
2020eace7efcSopenharmony_ci    MessageOption option;
2021eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2022eace7efcSopenharmony_ci        return nullptr;
2023eace7efcSopenharmony_ci    }
2024eace7efcSopenharmony_ci    if (!data.WriteParcelable(&wantSenderInfo)) {
2025eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "writeParcelable fail");
2026eace7efcSopenharmony_ci        return nullptr;
2027eace7efcSopenharmony_ci    }
2028eace7efcSopenharmony_ci    if (callerToken) {
2029eace7efcSopenharmony_ci        if (!data.WriteBool(true) || !data.WriteRemoteObject(callerToken)) {
2030eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag and callerToken write fail");
2031eace7efcSopenharmony_ci            return nullptr;
2032eace7efcSopenharmony_ci        }
2033eace7efcSopenharmony_ci    } else {
2034eace7efcSopenharmony_ci        if (!data.WriteBool(false)) {
2035eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag write fail");
2036eace7efcSopenharmony_ci            return nullptr;
2037eace7efcSopenharmony_ci        }
2038eace7efcSopenharmony_ci    }
2039eace7efcSopenharmony_ci
2040eace7efcSopenharmony_ci    if (!data.WriteInt32(uid)) {
2041eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "uid write fail");
2042eace7efcSopenharmony_ci        return nullptr;
2043eace7efcSopenharmony_ci    }
2044eace7efcSopenharmony_ci
2045eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::GET_PENDING_WANT_SENDER, data, reply, option);
2046eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2047eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
2048eace7efcSopenharmony_ci        return nullptr;
2049eace7efcSopenharmony_ci    }
2050eace7efcSopenharmony_ci    sptr<IWantSender> wantSender = iface_cast<IWantSender>(reply.ReadRemoteObject());
2051eace7efcSopenharmony_ci    if (!wantSender) {
2052eace7efcSopenharmony_ci        return nullptr;
2053eace7efcSopenharmony_ci    }
2054eace7efcSopenharmony_ci    return wantSender;
2055eace7efcSopenharmony_ci}
2056eace7efcSopenharmony_ci
2057eace7efcSopenharmony_ciint AbilityManagerProxy::SendWantSender(sptr<IWantSender> target, const SenderInfo &senderInfo)
2058eace7efcSopenharmony_ci{
2059eace7efcSopenharmony_ci    MessageParcel data;
2060eace7efcSopenharmony_ci    MessageParcel reply;
2061eace7efcSopenharmony_ci    MessageOption option;
2062eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2063eace7efcSopenharmony_ci        return INNER_ERR;
2064eace7efcSopenharmony_ci    }
2065eace7efcSopenharmony_ci    if (target == nullptr || !data.WriteRemoteObject(target->AsObject())) {
2066eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "target write fail");
2067eace7efcSopenharmony_ci        return INNER_ERR;
2068eace7efcSopenharmony_ci    }
2069eace7efcSopenharmony_ci    if (!data.WriteParcelable(&senderInfo)) {
2070eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "senderInfo write fail");
2071eace7efcSopenharmony_ci        return INNER_ERR;
2072eace7efcSopenharmony_ci    }
2073eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::SEND_PENDING_WANT_SENDER, data, reply, option);
2074eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2075eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
2076eace7efcSopenharmony_ci        return error;
2077eace7efcSopenharmony_ci    }
2078eace7efcSopenharmony_ci    return reply.ReadInt32();
2079eace7efcSopenharmony_ci}
2080eace7efcSopenharmony_ci
2081eace7efcSopenharmony_civoid AbilityManagerProxy::CancelWantSender(const sptr<IWantSender> &sender)
2082eace7efcSopenharmony_ci{
2083eace7efcSopenharmony_ci    MessageParcel data;
2084eace7efcSopenharmony_ci    MessageParcel reply;
2085eace7efcSopenharmony_ci    MessageOption option;
2086eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2087eace7efcSopenharmony_ci        return;
2088eace7efcSopenharmony_ci    }
2089eace7efcSopenharmony_ci    if (sender == nullptr || !data.WriteRemoteObject(sender->AsObject())) {
2090eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "sender write fail");
2091eace7efcSopenharmony_ci        return;
2092eace7efcSopenharmony_ci    }
2093eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::CANCEL_PENDING_WANT_SENDER, data, reply, option);
2094eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2095eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
2096eace7efcSopenharmony_ci        return;
2097eace7efcSopenharmony_ci    }
2098eace7efcSopenharmony_ci}
2099eace7efcSopenharmony_ci
2100eace7efcSopenharmony_ciint AbilityManagerProxy::GetPendingWantUid(const sptr<IWantSender> &target)
2101eace7efcSopenharmony_ci{
2102eace7efcSopenharmony_ci    MessageParcel data;
2103eace7efcSopenharmony_ci    MessageParcel reply;
2104eace7efcSopenharmony_ci    MessageOption option;
2105eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2106eace7efcSopenharmony_ci        return INNER_ERR;
2107eace7efcSopenharmony_ci    }
2108eace7efcSopenharmony_ci    if (target == nullptr || !data.WriteRemoteObject(target->AsObject())) {
2109eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "target write fail");
2110eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
2111eace7efcSopenharmony_ci    }
2112eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::GET_PENDING_WANT_UID, data, reply, option);
2113eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2114eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
2115eace7efcSopenharmony_ci        return INNER_ERR;
2116eace7efcSopenharmony_ci    }
2117eace7efcSopenharmony_ci    return reply.ReadInt32();
2118eace7efcSopenharmony_ci}
2119eace7efcSopenharmony_ci
2120eace7efcSopenharmony_ciint AbilityManagerProxy::GetPendingWantUserId(const sptr<IWantSender> &target)
2121eace7efcSopenharmony_ci{
2122eace7efcSopenharmony_ci    MessageParcel data;
2123eace7efcSopenharmony_ci    MessageParcel reply;
2124eace7efcSopenharmony_ci    MessageOption option;
2125eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2126eace7efcSopenharmony_ci        return INNER_ERR;
2127eace7efcSopenharmony_ci    }
2128eace7efcSopenharmony_ci    if (target == nullptr || !data.WriteRemoteObject(target->AsObject())) {
2129eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "target write fail");
2130eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
2131eace7efcSopenharmony_ci    }
2132eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::GET_PENDING_WANT_USERID, data, reply, option);
2133eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2134eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
2135eace7efcSopenharmony_ci        return INNER_ERR;
2136eace7efcSopenharmony_ci    }
2137eace7efcSopenharmony_ci    return reply.ReadInt32();
2138eace7efcSopenharmony_ci}
2139eace7efcSopenharmony_ci
2140eace7efcSopenharmony_cistd::string AbilityManagerProxy::GetPendingWantBundleName(const sptr<IWantSender> &target)
2141eace7efcSopenharmony_ci{
2142eace7efcSopenharmony_ci    MessageParcel data;
2143eace7efcSopenharmony_ci    MessageParcel reply;
2144eace7efcSopenharmony_ci    MessageOption option;
2145eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2146eace7efcSopenharmony_ci        return "";
2147eace7efcSopenharmony_ci    }
2148eace7efcSopenharmony_ci    if (target == nullptr || !data.WriteRemoteObject(target->AsObject())) {
2149eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "target write fail");
2150eace7efcSopenharmony_ci        return "";
2151eace7efcSopenharmony_ci    }
2152eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::GET_PENDING_WANT_BUNDLENAME, data, reply, option);
2153eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2154eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
2155eace7efcSopenharmony_ci        return "";
2156eace7efcSopenharmony_ci    }
2157eace7efcSopenharmony_ci    return Str16ToStr8(reply.ReadString16());
2158eace7efcSopenharmony_ci}
2159eace7efcSopenharmony_ci
2160eace7efcSopenharmony_ciint AbilityManagerProxy::GetPendingWantCode(const sptr<IWantSender> &target)
2161eace7efcSopenharmony_ci{
2162eace7efcSopenharmony_ci    MessageParcel data;
2163eace7efcSopenharmony_ci    MessageParcel reply;
2164eace7efcSopenharmony_ci    MessageOption option;
2165eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2166eace7efcSopenharmony_ci        return INNER_ERR;
2167eace7efcSopenharmony_ci    }
2168eace7efcSopenharmony_ci    if (target == nullptr || !data.WriteRemoteObject(target->AsObject())) {
2169eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "target write fail");
2170eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
2171eace7efcSopenharmony_ci    }
2172eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::GET_PENDING_WANT_CODE, data, reply, option);
2173eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2174eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
2175eace7efcSopenharmony_ci        return INNER_ERR;
2176eace7efcSopenharmony_ci    }
2177eace7efcSopenharmony_ci    return reply.ReadInt32();
2178eace7efcSopenharmony_ci}
2179eace7efcSopenharmony_ci
2180eace7efcSopenharmony_ciint AbilityManagerProxy::GetPendingWantType(const sptr<IWantSender> &target)
2181eace7efcSopenharmony_ci{
2182eace7efcSopenharmony_ci    MessageParcel data;
2183eace7efcSopenharmony_ci    MessageParcel reply;
2184eace7efcSopenharmony_ci    MessageOption option;
2185eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2186eace7efcSopenharmony_ci        return INNER_ERR;
2187eace7efcSopenharmony_ci    }
2188eace7efcSopenharmony_ci    if (target == nullptr || !data.WriteRemoteObject(target->AsObject())) {
2189eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "target write fail");
2190eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
2191eace7efcSopenharmony_ci    }
2192eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::GET_PENDING_WANT_TYPE, data, reply, option);
2193eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2194eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
2195eace7efcSopenharmony_ci        return INNER_ERR;
2196eace7efcSopenharmony_ci    }
2197eace7efcSopenharmony_ci    return reply.ReadInt32();
2198eace7efcSopenharmony_ci}
2199eace7efcSopenharmony_ci
2200eace7efcSopenharmony_civoid AbilityManagerProxy::RegisterCancelListener(const sptr<IWantSender> &sender, const sptr<IWantReceiver> &receiver)
2201eace7efcSopenharmony_ci{
2202eace7efcSopenharmony_ci    MessageParcel data;
2203eace7efcSopenharmony_ci    MessageParcel reply;
2204eace7efcSopenharmony_ci    MessageOption option;
2205eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2206eace7efcSopenharmony_ci        return;
2207eace7efcSopenharmony_ci    }
2208eace7efcSopenharmony_ci    if (sender == nullptr || !data.WriteRemoteObject(sender->AsObject())) {
2209eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "sender write fail");
2210eace7efcSopenharmony_ci        return;
2211eace7efcSopenharmony_ci    }
2212eace7efcSopenharmony_ci    if (receiver == nullptr || !data.WriteRemoteObject(receiver->AsObject())) {
2213eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "receiver write fail");
2214eace7efcSopenharmony_ci        return;
2215eace7efcSopenharmony_ci    }
2216eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::REGISTER_CANCEL_LISTENER, data, reply, option);
2217eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2218eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
2219eace7efcSopenharmony_ci        return;
2220eace7efcSopenharmony_ci    }
2221eace7efcSopenharmony_ci}
2222eace7efcSopenharmony_ci
2223eace7efcSopenharmony_civoid AbilityManagerProxy::UnregisterCancelListener(const sptr<IWantSender> &sender, const sptr<IWantReceiver> &receiver)
2224eace7efcSopenharmony_ci{
2225eace7efcSopenharmony_ci    MessageParcel data;
2226eace7efcSopenharmony_ci    MessageParcel reply;
2227eace7efcSopenharmony_ci    MessageOption option;
2228eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2229eace7efcSopenharmony_ci        return;
2230eace7efcSopenharmony_ci    }
2231eace7efcSopenharmony_ci    if (sender == nullptr || !data.WriteRemoteObject(sender->AsObject())) {
2232eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "sender write fail");
2233eace7efcSopenharmony_ci        return;
2234eace7efcSopenharmony_ci    }
2235eace7efcSopenharmony_ci    if (receiver == nullptr || !data.WriteRemoteObject(receiver->AsObject())) {
2236eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "receiver write fail");
2237eace7efcSopenharmony_ci        return;
2238eace7efcSopenharmony_ci    }
2239eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::UNREGISTER_CANCEL_LISTENER, data, reply, option);
2240eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2241eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
2242eace7efcSopenharmony_ci        return;
2243eace7efcSopenharmony_ci    }
2244eace7efcSopenharmony_ci}
2245eace7efcSopenharmony_ci
2246eace7efcSopenharmony_ciint AbilityManagerProxy::GetPendingRequestWant(const sptr<IWantSender> &target, std::shared_ptr<Want> &want)
2247eace7efcSopenharmony_ci{
2248eace7efcSopenharmony_ci    MessageParcel data;
2249eace7efcSopenharmony_ci    MessageParcel reply;
2250eace7efcSopenharmony_ci    MessageOption option;
2251eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2252eace7efcSopenharmony_ci        return INNER_ERR;
2253eace7efcSopenharmony_ci    }
2254eace7efcSopenharmony_ci    if (target == nullptr || !data.WriteRemoteObject(target->AsObject())) {
2255eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "target write fail");
2256eace7efcSopenharmony_ci        return INNER_ERR;
2257eace7efcSopenharmony_ci    }
2258eace7efcSopenharmony_ci    if (want == nullptr || !data.WriteParcelable(want.get())) {
2259eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "want write fail");
2260eace7efcSopenharmony_ci        return INNER_ERR;
2261eace7efcSopenharmony_ci    }
2262eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::GET_PENDING_REQUEST_WANT, data, reply, option);
2263eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2264eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
2265eace7efcSopenharmony_ci        return error;
2266eace7efcSopenharmony_ci    }
2267eace7efcSopenharmony_ci    std::unique_ptr<Want> wantInfo(reply.ReadParcelable<Want>());
2268eace7efcSopenharmony_ci    if (!wantInfo) {
2269eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "readParcelableInfo fail");
2270eace7efcSopenharmony_ci        return INNER_ERR;
2271eace7efcSopenharmony_ci    }
2272eace7efcSopenharmony_ci    want = std::move(wantInfo);
2273eace7efcSopenharmony_ci
2274eace7efcSopenharmony_ci    return NO_ERROR;
2275eace7efcSopenharmony_ci}
2276eace7efcSopenharmony_ci
2277eace7efcSopenharmony_ciint AbilityManagerProxy::GetWantSenderInfo(const sptr<IWantSender> &target, std::shared_ptr<WantSenderInfo> &info)
2278eace7efcSopenharmony_ci{
2279eace7efcSopenharmony_ci    MessageParcel data;
2280eace7efcSopenharmony_ci    MessageParcel reply;
2281eace7efcSopenharmony_ci    MessageOption option;
2282eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2283eace7efcSopenharmony_ci        return INNER_ERR;
2284eace7efcSopenharmony_ci    }
2285eace7efcSopenharmony_ci    if (target == nullptr || !data.WriteRemoteObject(target->AsObject())) {
2286eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "target write fail");
2287eace7efcSopenharmony_ci        return INNER_ERR;
2288eace7efcSopenharmony_ci    }
2289eace7efcSopenharmony_ci    if (info == nullptr || !data.WriteParcelable(info.get())) {
2290eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "info write fail");
2291eace7efcSopenharmony_ci        return INNER_ERR;
2292eace7efcSopenharmony_ci    }
2293eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::GET_PENDING_WANT_SENDER_INFO, data, reply, option);
2294eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2295eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
2296eace7efcSopenharmony_ci        return error;
2297eace7efcSopenharmony_ci    }
2298eace7efcSopenharmony_ci    std::unique_ptr<WantSenderInfo> wantSenderInfo(reply.ReadParcelable<WantSenderInfo>());
2299eace7efcSopenharmony_ci    if (!wantSenderInfo) {
2300eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "readParcelable Info fail");
2301eace7efcSopenharmony_ci        return INNER_ERR;
2302eace7efcSopenharmony_ci    }
2303eace7efcSopenharmony_ci    info = std::move(wantSenderInfo);
2304eace7efcSopenharmony_ci
2305eace7efcSopenharmony_ci    return NO_ERROR;
2306eace7efcSopenharmony_ci}
2307eace7efcSopenharmony_ci
2308eace7efcSopenharmony_ciint AbilityManagerProxy::GetAppMemorySize()
2309eace7efcSopenharmony_ci{
2310eace7efcSopenharmony_ci    MessageParcel data;
2311eace7efcSopenharmony_ci    MessageParcel reply;
2312eace7efcSopenharmony_ci    MessageOption option;
2313eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2314eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write Token fail");
2315eace7efcSopenharmony_ci        return INNER_ERR;
2316eace7efcSopenharmony_ci    }
2317eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::GET_APP_MEMORY_SIZE, data, reply, option);
2318eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2319eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
2320eace7efcSopenharmony_ci        return error;
2321eace7efcSopenharmony_ci    }
2322eace7efcSopenharmony_ci    return reply.ReadInt32();
2323eace7efcSopenharmony_ci}
2324eace7efcSopenharmony_ci
2325eace7efcSopenharmony_cibool AbilityManagerProxy::IsRamConstrainedDevice()
2326eace7efcSopenharmony_ci{
2327eace7efcSopenharmony_ci    MessageParcel data;
2328eace7efcSopenharmony_ci    MessageParcel reply;
2329eace7efcSopenharmony_ci    MessageOption option;
2330eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2331eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write Token faile");
2332eace7efcSopenharmony_ci        return false;
2333eace7efcSopenharmony_ci    }
2334eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::IS_RAM_CONSTRAINED_DEVICE, data, reply, option);
2335eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2336eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
2337eace7efcSopenharmony_ci        return false;
2338eace7efcSopenharmony_ci    }
2339eace7efcSopenharmony_ci    return reply.ReadBool();
2340eace7efcSopenharmony_ci}
2341eace7efcSopenharmony_ci
2342eace7efcSopenharmony_ciint AbilityManagerProxy::ContinueMission(const std::string &srcDeviceId, const std::string &dstDeviceId,
2343eace7efcSopenharmony_ci    int32_t missionId, const sptr<IRemoteObject> &callBack, AAFwk::WantParams &wantParams)
2344eace7efcSopenharmony_ci{
2345eace7efcSopenharmony_ci    TAG_LOGI(AAFwkTag::ABILITYMGR, "called");
2346eace7efcSopenharmony_ci    MessageParcel data;
2347eace7efcSopenharmony_ci    MessageParcel reply;
2348eace7efcSopenharmony_ci    MessageOption option;
2349eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2350eace7efcSopenharmony_ci        return INNER_ERR;
2351eace7efcSopenharmony_ci    }
2352eace7efcSopenharmony_ci    if (!data.WriteString(srcDeviceId)) {
2353eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "srcDeviceId write fail");
2354eace7efcSopenharmony_ci        return INNER_ERR;
2355eace7efcSopenharmony_ci    }
2356eace7efcSopenharmony_ci    if (!data.WriteString(dstDeviceId)) {
2357eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "dstDeviceId write fail");
2358eace7efcSopenharmony_ci        return INNER_ERR;
2359eace7efcSopenharmony_ci    }
2360eace7efcSopenharmony_ci    if (!data.WriteInt32(missionId)) {
2361eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "missionId write fail");
2362eace7efcSopenharmony_ci        return INNER_ERR;
2363eace7efcSopenharmony_ci    }
2364eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(callBack)) {
2365eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "callBack write fail");
2366eace7efcSopenharmony_ci        return INNER_ERR;
2367eace7efcSopenharmony_ci    }
2368eace7efcSopenharmony_ci    if (!data.WriteParcelable(&wantParams)) {
2369eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "wantParams write fail");
2370eace7efcSopenharmony_ci        return INNER_ERR;
2371eace7efcSopenharmony_ci    }
2372eace7efcSopenharmony_ci
2373eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::CONTINUE_MISSION, data, reply, option);
2374eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2375eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "sendRequest error: %{public}d", error);
2376eace7efcSopenharmony_ci        return error;
2377eace7efcSopenharmony_ci    }
2378eace7efcSopenharmony_ci    return reply.ReadInt32();
2379eace7efcSopenharmony_ci}
2380eace7efcSopenharmony_ci
2381eace7efcSopenharmony_ciint AbilityManagerProxy::ContinueMission(AAFwk::ContinueMissionInfo continueMissionInfo,
2382eace7efcSopenharmony_ci    const sptr<IRemoteObject> &callback)
2383eace7efcSopenharmony_ci{
2384eace7efcSopenharmony_ci    MessageParcel data;
2385eace7efcSopenharmony_ci    MessageParcel reply;
2386eace7efcSopenharmony_ci    MessageOption option;
2387eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2388eace7efcSopenharmony_ci        return INNER_ERR;
2389eace7efcSopenharmony_ci    }
2390eace7efcSopenharmony_ci    if (!data.WriteString(continueMissionInfo.srcDeviceId)) {
2391eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "srcDeviceId write fail");
2392eace7efcSopenharmony_ci        return INNER_ERR;
2393eace7efcSopenharmony_ci    }
2394eace7efcSopenharmony_ci    if (!data.WriteString(continueMissionInfo.dstDeviceId)) {
2395eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "dstDeviceId write fail");
2396eace7efcSopenharmony_ci        return INNER_ERR;
2397eace7efcSopenharmony_ci    }
2398eace7efcSopenharmony_ci    if (!data.WriteString(continueMissionInfo.bundleName)) {
2399eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "missionId write fail");
2400eace7efcSopenharmony_ci        return INNER_ERR;
2401eace7efcSopenharmony_ci    }
2402eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(callback)) {
2403eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "callBack write fail");
2404eace7efcSopenharmony_ci        return INNER_ERR;
2405eace7efcSopenharmony_ci    }
2406eace7efcSopenharmony_ci    if (!data.WriteParcelable(&continueMissionInfo.wantParams)) {
2407eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "wantParams write fail");
2408eace7efcSopenharmony_ci        return INNER_ERR;
2409eace7efcSopenharmony_ci    }
2410eace7efcSopenharmony_ci    if (!data.WriteString(continueMissionInfo.srcBundleName)) {
2411eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "srcBundleName write fail");
2412eace7efcSopenharmony_ci        return INNER_ERR;
2413eace7efcSopenharmony_ci    }
2414eace7efcSopenharmony_ci    if (!data.WriteString(continueMissionInfo.continueType)) {
2415eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "continueType write fail");
2416eace7efcSopenharmony_ci        return INNER_ERR;
2417eace7efcSopenharmony_ci    }
2418eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::CONTINUE_MISSION_OF_BUNDLENAME, data, reply, option);
2419eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2420eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
2421eace7efcSopenharmony_ci        return error;
2422eace7efcSopenharmony_ci    }
2423eace7efcSopenharmony_ci    return reply.ReadInt32();
2424eace7efcSopenharmony_ci}
2425eace7efcSopenharmony_ci
2426eace7efcSopenharmony_ciint AbilityManagerProxy::ContinueAbility(const std::string &deviceId, int32_t missionId, uint32_t versionCode)
2427eace7efcSopenharmony_ci{
2428eace7efcSopenharmony_ci    MessageParcel data;
2429eace7efcSopenharmony_ci    MessageParcel reply;
2430eace7efcSopenharmony_ci    MessageOption option;
2431eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2432eace7efcSopenharmony_ci        return INNER_ERR;
2433eace7efcSopenharmony_ci    }
2434eace7efcSopenharmony_ci    if (!data.WriteString(deviceId)) {
2435eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "deviceId write fail");
2436eace7efcSopenharmony_ci        return INNER_ERR;
2437eace7efcSopenharmony_ci    }
2438eace7efcSopenharmony_ci    if (!data.WriteInt32(missionId)) {
2439eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "missionId write fail");
2440eace7efcSopenharmony_ci        return INNER_ERR;
2441eace7efcSopenharmony_ci    }
2442eace7efcSopenharmony_ci    if (!data.WriteUint32(versionCode)) {
2443eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "versionCode write fail");
2444eace7efcSopenharmony_ci        return INNER_ERR;
2445eace7efcSopenharmony_ci    }
2446eace7efcSopenharmony_ci
2447eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::CONTINUE_ABILITY, data, reply, option);
2448eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2449eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
2450eace7efcSopenharmony_ci        return error;
2451eace7efcSopenharmony_ci    }
2452eace7efcSopenharmony_ci    return reply.ReadInt32();
2453eace7efcSopenharmony_ci}
2454eace7efcSopenharmony_ci
2455eace7efcSopenharmony_ciint AbilityManagerProxy::StartContinuation(const Want &want, const sptr<IRemoteObject> &abilityToken, int32_t status)
2456eace7efcSopenharmony_ci{
2457eace7efcSopenharmony_ci    MessageParcel data;
2458eace7efcSopenharmony_ci    MessageParcel reply;
2459eace7efcSopenharmony_ci    MessageOption option = {MessageOption::TF_ASYNC};
2460eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2461eace7efcSopenharmony_ci        return INNER_ERR;
2462eace7efcSopenharmony_ci    }
2463eace7efcSopenharmony_ci    if (!data.WriteParcelable(&want)) {
2464eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "want write fail");
2465eace7efcSopenharmony_ci        return INNER_ERR;
2466eace7efcSopenharmony_ci    }
2467eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(abilityToken)) {
2468eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "abilityToken write fail");
2469eace7efcSopenharmony_ci        return INNER_ERR;
2470eace7efcSopenharmony_ci    }
2471eace7efcSopenharmony_ci    if (!data.WriteInt32(status)) {
2472eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "status write fail");
2473eace7efcSopenharmony_ci        return INNER_ERR;
2474eace7efcSopenharmony_ci    }
2475eace7efcSopenharmony_ci
2476eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::START_CONTINUATION, data, reply, option);
2477eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2478eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
2479eace7efcSopenharmony_ci        return error;
2480eace7efcSopenharmony_ci    }
2481eace7efcSopenharmony_ci    return reply.ReadInt32();
2482eace7efcSopenharmony_ci}
2483eace7efcSopenharmony_ci
2484eace7efcSopenharmony_civoid AbilityManagerProxy::NotifyCompleteContinuation(const std::string &deviceId, int32_t sessionId, bool isSuccess)
2485eace7efcSopenharmony_ci{
2486eace7efcSopenharmony_ci    MessageParcel data;
2487eace7efcSopenharmony_ci    MessageParcel reply;
2488eace7efcSopenharmony_ci    MessageOption option = {MessageOption::TF_ASYNC};
2489eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2490eace7efcSopenharmony_ci        return;
2491eace7efcSopenharmony_ci    }
2492eace7efcSopenharmony_ci    if (!data.WriteString(deviceId)) {
2493eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "deviceId write fail");
2494eace7efcSopenharmony_ci        return;
2495eace7efcSopenharmony_ci    }
2496eace7efcSopenharmony_ci    if (!data.WriteInt32(sessionId)) {
2497eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "sessionId write fail");
2498eace7efcSopenharmony_ci        return;
2499eace7efcSopenharmony_ci    }
2500eace7efcSopenharmony_ci    if (!data.WriteBool(isSuccess)) {
2501eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "result write fail");
2502eace7efcSopenharmony_ci        return;
2503eace7efcSopenharmony_ci    }
2504eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::NOTIFY_COMPLETE_CONTINUATION, data, reply, option);
2505eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2506eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
2507eace7efcSopenharmony_ci        return;
2508eace7efcSopenharmony_ci    }
2509eace7efcSopenharmony_ci}
2510eace7efcSopenharmony_ci
2511eace7efcSopenharmony_ciint AbilityManagerProxy::NotifyContinuationResult(int32_t missionId, int32_t result)
2512eace7efcSopenharmony_ci{
2513eace7efcSopenharmony_ci    MessageParcel data;
2514eace7efcSopenharmony_ci    MessageParcel reply;
2515eace7efcSopenharmony_ci    MessageOption option;
2516eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2517eace7efcSopenharmony_ci        return INNER_ERR;
2518eace7efcSopenharmony_ci    }
2519eace7efcSopenharmony_ci    if (!data.WriteInt32(missionId)) {
2520eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "missionId write fail");
2521eace7efcSopenharmony_ci        return INNER_ERR;
2522eace7efcSopenharmony_ci    }
2523eace7efcSopenharmony_ci    if (!data.WriteInt32(result)) {
2524eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "result write fail");
2525eace7efcSopenharmony_ci        return INNER_ERR;
2526eace7efcSopenharmony_ci    }
2527eace7efcSopenharmony_ci
2528eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::NOTIFY_CONTINUATION_RESULT, data, reply, option);
2529eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2530eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
2531eace7efcSopenharmony_ci        return error;
2532eace7efcSopenharmony_ci    }
2533eace7efcSopenharmony_ci    return reply.ReadInt32();
2534eace7efcSopenharmony_ci}
2535eace7efcSopenharmony_ci
2536eace7efcSopenharmony_ciint AbilityManagerProxy::LockMissionForCleanup(int32_t missionId)
2537eace7efcSopenharmony_ci{
2538eace7efcSopenharmony_ci    int error;
2539eace7efcSopenharmony_ci    MessageParcel data;
2540eace7efcSopenharmony_ci    MessageParcel reply;
2541eace7efcSopenharmony_ci    MessageOption option;
2542eace7efcSopenharmony_ci
2543eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2544eace7efcSopenharmony_ci        return INNER_ERR;
2545eace7efcSopenharmony_ci    }
2546eace7efcSopenharmony_ci    if (!data.WriteInt32(missionId)) {
2547eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "missionId write fail");
2548eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
2549eace7efcSopenharmony_ci    }
2550eace7efcSopenharmony_ci
2551eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::LOCK_MISSION_FOR_CLEANUP, data, reply, option);
2552eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2553eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "send error:%d", error);
2554eace7efcSopenharmony_ci        return error;
2555eace7efcSopenharmony_ci    }
2556eace7efcSopenharmony_ci    return reply.ReadInt32();
2557eace7efcSopenharmony_ci}
2558eace7efcSopenharmony_ci
2559eace7efcSopenharmony_ciint AbilityManagerProxy::UnlockMissionForCleanup(int32_t missionId)
2560eace7efcSopenharmony_ci{
2561eace7efcSopenharmony_ci    HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
2562eace7efcSopenharmony_ci    int error;
2563eace7efcSopenharmony_ci    MessageParcel data;
2564eace7efcSopenharmony_ci    MessageParcel reply;
2565eace7efcSopenharmony_ci    MessageOption option;
2566eace7efcSopenharmony_ci
2567eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2568eace7efcSopenharmony_ci        return INNER_ERR;
2569eace7efcSopenharmony_ci    }
2570eace7efcSopenharmony_ci    if (!data.WriteInt32(missionId)) {
2571eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "writeInt32 fail");
2572eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
2573eace7efcSopenharmony_ci    }
2574eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::UNLOCK_MISSION_FOR_CLEANUP, data, reply, option);
2575eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2576eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "unlock mission,error:%d", error);
2577eace7efcSopenharmony_ci        return error;
2578eace7efcSopenharmony_ci    }
2579eace7efcSopenharmony_ci    return reply.ReadInt32();
2580eace7efcSopenharmony_ci}
2581eace7efcSopenharmony_ci
2582eace7efcSopenharmony_civoid AbilityManagerProxy::SetLockedState(int32_t sessionId, bool lockedState)
2583eace7efcSopenharmony_ci{
2584eace7efcSopenharmony_ci    MessageParcel data;
2585eace7efcSopenharmony_ci
2586eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2587eace7efcSopenharmony_ci        return;
2588eace7efcSopenharmony_ci    }
2589eace7efcSopenharmony_ci
2590eace7efcSopenharmony_ci    if (!data.WriteInt32(sessionId)) {
2591eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "writeInt32 fail");
2592eace7efcSopenharmony_ci        return;
2593eace7efcSopenharmony_ci    }
2594eace7efcSopenharmony_ci
2595eace7efcSopenharmony_ci    if (!data.WriteBool(lockedState)) {
2596eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "writeBool fail");
2597eace7efcSopenharmony_ci        return;
2598eace7efcSopenharmony_ci    }
2599eace7efcSopenharmony_ci
2600eace7efcSopenharmony_ci    MessageParcel reply;
2601eace7efcSopenharmony_ci    MessageOption option(MessageOption::TF_ASYNC);
2602eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::SET_SESSION_LOCKED_STATE, data, reply, option);
2603eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2604eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "error: %d", error);
2605eace7efcSopenharmony_ci        return;
2606eace7efcSopenharmony_ci    }
2607eace7efcSopenharmony_ci    return;
2608eace7efcSopenharmony_ci}
2609eace7efcSopenharmony_ci
2610eace7efcSopenharmony_ciint AbilityManagerProxy::RegisterMissionListener(const sptr<IMissionListener> &listener)
2611eace7efcSopenharmony_ci{
2612eace7efcSopenharmony_ci    int error;
2613eace7efcSopenharmony_ci    MessageParcel data;
2614eace7efcSopenharmony_ci    MessageParcel reply;
2615eace7efcSopenharmony_ci    MessageOption option;
2616eace7efcSopenharmony_ci    if (!listener) {
2617eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "listener null");
2618eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
2619eace7efcSopenharmony_ci    }
2620eace7efcSopenharmony_ci
2621eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2622eace7efcSopenharmony_ci        return INNER_ERR;
2623eace7efcSopenharmony_ci    }
2624eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(listener->AsObject())) {
2625eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write missionListener fail");
2626eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
2627eace7efcSopenharmony_ci    }
2628eace7efcSopenharmony_ci
2629eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::REGISTER_MISSION_LISTENER, data, reply, option);
2630eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2631eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error: %{public}d", error);
2632eace7efcSopenharmony_ci        return error;
2633eace7efcSopenharmony_ci    }
2634eace7efcSopenharmony_ci    return reply.ReadInt32();
2635eace7efcSopenharmony_ci}
2636eace7efcSopenharmony_ci
2637eace7efcSopenharmony_ciint AbilityManagerProxy::RegisterSessionHandler(const sptr<IRemoteObject> &object)
2638eace7efcSopenharmony_ci{
2639eace7efcSopenharmony_ci    if (!object) {
2640eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "handler null");
2641eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
2642eace7efcSopenharmony_ci    }
2643eace7efcSopenharmony_ci    MessageParcel data;
2644eace7efcSopenharmony_ci    MessageParcel reply;
2645eace7efcSopenharmony_ci    MessageOption option;
2646eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2647eace7efcSopenharmony_ci        return INNER_ERR;
2648eace7efcSopenharmony_ci    }
2649eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(object)) {
2650eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write sessionHandler fail");
2651eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
2652eace7efcSopenharmony_ci    }
2653eace7efcSopenharmony_ci    int error = SendRequest(AbilityManagerInterfaceCode::REGISTER_SESSION_HANDLER, data, reply, option);
2654eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2655eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
2656eace7efcSopenharmony_ci        return error;
2657eace7efcSopenharmony_ci    }
2658eace7efcSopenharmony_ci    return reply.ReadInt32();
2659eace7efcSopenharmony_ci}
2660eace7efcSopenharmony_ci
2661eace7efcSopenharmony_ciint AbilityManagerProxy::RegisterMissionListener(const std::string &deviceId,
2662eace7efcSopenharmony_ci    const sptr<IRemoteMissionListener> &listener)
2663eace7efcSopenharmony_ci{
2664eace7efcSopenharmony_ci    MessageParcel data;
2665eace7efcSopenharmony_ci    MessageParcel reply;
2666eace7efcSopenharmony_ci    MessageOption option;
2667eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2668eace7efcSopenharmony_ci        return INNER_ERR;
2669eace7efcSopenharmony_ci    }
2670eace7efcSopenharmony_ci    if (!data.WriteString(deviceId)) {
2671eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "deviceId write fail");
2672eace7efcSopenharmony_ci        return INNER_ERR;
2673eace7efcSopenharmony_ci    }
2674eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(listener->AsObject())) {
2675eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "listener write fail");
2676eace7efcSopenharmony_ci        return INNER_ERR;
2677eace7efcSopenharmony_ci    }
2678eace7efcSopenharmony_ci
2679eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::REGISTER_REMOTE_MISSION_LISTENER,
2680eace7efcSopenharmony_ci        data, reply, option);
2681eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2682eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
2683eace7efcSopenharmony_ci        return error;
2684eace7efcSopenharmony_ci    }
2685eace7efcSopenharmony_ci    return reply.ReadInt32();
2686eace7efcSopenharmony_ci}
2687eace7efcSopenharmony_ci
2688eace7efcSopenharmony_ciint AbilityManagerProxy::RegisterOnListener(const std::string &type,
2689eace7efcSopenharmony_ci    const sptr<IRemoteOnListener> &listener)
2690eace7efcSopenharmony_ci{
2691eace7efcSopenharmony_ci    MessageParcel data;
2692eace7efcSopenharmony_ci    MessageParcel reply;
2693eace7efcSopenharmony_ci    MessageOption option;
2694eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2695eace7efcSopenharmony_ci        return INNER_ERR;
2696eace7efcSopenharmony_ci    }
2697eace7efcSopenharmony_ci    if (!data.WriteString(type)) {
2698eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "type write fail");
2699eace7efcSopenharmony_ci        return INNER_ERR;
2700eace7efcSopenharmony_ci    }
2701eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(listener->AsObject())) {
2702eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "listener write fail");
2703eace7efcSopenharmony_ci        return INNER_ERR;
2704eace7efcSopenharmony_ci    }
2705eace7efcSopenharmony_ci
2706eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::REGISTER_REMOTE_ON_LISTENER, data, reply, option);
2707eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2708eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
2709eace7efcSopenharmony_ci        return error;
2710eace7efcSopenharmony_ci    }
2711eace7efcSopenharmony_ci    return reply.ReadInt32();
2712eace7efcSopenharmony_ci}
2713eace7efcSopenharmony_ci
2714eace7efcSopenharmony_ciint AbilityManagerProxy::RegisterOffListener(const std::string &type,
2715eace7efcSopenharmony_ci    const sptr<IRemoteOnListener> &listener)
2716eace7efcSopenharmony_ci{
2717eace7efcSopenharmony_ci    MessageParcel data;
2718eace7efcSopenharmony_ci    MessageParcel reply;
2719eace7efcSopenharmony_ci    MessageOption option;
2720eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2721eace7efcSopenharmony_ci        return INNER_ERR;
2722eace7efcSopenharmony_ci    }
2723eace7efcSopenharmony_ci    if (!data.WriteString(type)) {
2724eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "type write fail");
2725eace7efcSopenharmony_ci        return INNER_ERR;
2726eace7efcSopenharmony_ci    }
2727eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(listener->AsObject())) {
2728eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "listener write fail");
2729eace7efcSopenharmony_ci        return INNER_ERR;
2730eace7efcSopenharmony_ci    }
2731eace7efcSopenharmony_ci
2732eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::REGISTER_REMOTE_OFF_LISTENER, data, reply, option);
2733eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2734eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
2735eace7efcSopenharmony_ci        return error;
2736eace7efcSopenharmony_ci    }
2737eace7efcSopenharmony_ci    return reply.ReadInt32();
2738eace7efcSopenharmony_ci}
2739eace7efcSopenharmony_ci
2740eace7efcSopenharmony_ciint AbilityManagerProxy::UnRegisterMissionListener(const sptr<IMissionListener> &listener)
2741eace7efcSopenharmony_ci{
2742eace7efcSopenharmony_ci    int error;
2743eace7efcSopenharmony_ci    MessageParcel data;
2744eace7efcSopenharmony_ci    MessageParcel reply;
2745eace7efcSopenharmony_ci    MessageOption option;
2746eace7efcSopenharmony_ci    if (!listener) {
2747eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "listener null");
2748eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
2749eace7efcSopenharmony_ci    }
2750eace7efcSopenharmony_ci
2751eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2752eace7efcSopenharmony_ci        return INNER_ERR;
2753eace7efcSopenharmony_ci    }
2754eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(listener->AsObject())) {
2755eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write missionListener fail");
2756eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
2757eace7efcSopenharmony_ci    }
2758eace7efcSopenharmony_ci
2759eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::UNREGISTER_MISSION_LISTENER, data, reply, option);
2760eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2761eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
2762eace7efcSopenharmony_ci        return error;
2763eace7efcSopenharmony_ci    }
2764eace7efcSopenharmony_ci    return reply.ReadInt32();
2765eace7efcSopenharmony_ci}
2766eace7efcSopenharmony_ci
2767eace7efcSopenharmony_ciint AbilityManagerProxy::GetMissionInfos(const std::string& deviceId, int32_t numMax,
2768eace7efcSopenharmony_ci    std::vector<MissionInfo> &missionInfos)
2769eace7efcSopenharmony_ci{
2770eace7efcSopenharmony_ci    HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
2771eace7efcSopenharmony_ci    int error;
2772eace7efcSopenharmony_ci    MessageParcel data;
2773eace7efcSopenharmony_ci    MessageParcel reply;
2774eace7efcSopenharmony_ci    MessageOption option;
2775eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2776eace7efcSopenharmony_ci        return INNER_ERR;
2777eace7efcSopenharmony_ci    }
2778eace7efcSopenharmony_ci    if (!data.WriteString16(Str8ToStr16(deviceId))) {
2779eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write deviceId fail");
2780eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
2781eace7efcSopenharmony_ci    }
2782eace7efcSopenharmony_ci    if (!data.WriteInt32(numMax)) {
2783eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "writeInt32 fail");
2784eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
2785eace7efcSopenharmony_ci    }
2786eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::GET_MISSION_INFOS, data, reply, option);
2787eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2788eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, " request error:%{public}d", error);
2789eace7efcSopenharmony_ci        return error;
2790eace7efcSopenharmony_ci    }
2791eace7efcSopenharmony_ci    error = GetParcelableInfos<MissionInfo>(reply, missionInfos);
2792eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2793eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "getMissionInfos error: %{public}d", error);
2794eace7efcSopenharmony_ci        return error;
2795eace7efcSopenharmony_ci    }
2796eace7efcSopenharmony_ci    return reply.ReadInt32();
2797eace7efcSopenharmony_ci}
2798eace7efcSopenharmony_ci
2799eace7efcSopenharmony_ciint AbilityManagerProxy::GetMissionInfo(const std::string& deviceId, int32_t missionId,
2800eace7efcSopenharmony_ci    MissionInfo &missionInfo)
2801eace7efcSopenharmony_ci{
2802eace7efcSopenharmony_ci    HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
2803eace7efcSopenharmony_ci    int error;
2804eace7efcSopenharmony_ci    MessageParcel data;
2805eace7efcSopenharmony_ci    MessageParcel reply;
2806eace7efcSopenharmony_ci    MessageOption option;
2807eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2808eace7efcSopenharmony_ci        return INNER_ERR;
2809eace7efcSopenharmony_ci    }
2810eace7efcSopenharmony_ci    if (!data.WriteString16(Str8ToStr16(deviceId))) {
2811eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write deviceId failed");
2812eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
2813eace7efcSopenharmony_ci    }
2814eace7efcSopenharmony_ci    if (!data.WriteInt32(missionId)) {
2815eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "writeInt32 failed");
2816eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
2817eace7efcSopenharmony_ci    }
2818eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::GET_MISSION_INFO_BY_ID, data, reply, option);
2819eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2820eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
2821eace7efcSopenharmony_ci        return error;
2822eace7efcSopenharmony_ci    }
2823eace7efcSopenharmony_ci
2824eace7efcSopenharmony_ci    std::unique_ptr<MissionInfo> info(reply.ReadParcelable<MissionInfo>());
2825eace7efcSopenharmony_ci    if (!info) {
2826eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "read missioninfo fail");
2827eace7efcSopenharmony_ci        return ERR_UNKNOWN_OBJECT;
2828eace7efcSopenharmony_ci    }
2829eace7efcSopenharmony_ci    missionInfo = *info;
2830eace7efcSopenharmony_ci    return reply.ReadInt32();
2831eace7efcSopenharmony_ci}
2832eace7efcSopenharmony_ci
2833eace7efcSopenharmony_ciint AbilityManagerProxy::CleanMission(int32_t missionId)
2834eace7efcSopenharmony_ci{
2835eace7efcSopenharmony_ci    HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
2836eace7efcSopenharmony_ci    int error;
2837eace7efcSopenharmony_ci    MessageParcel data;
2838eace7efcSopenharmony_ci    MessageParcel reply;
2839eace7efcSopenharmony_ci    MessageOption option;
2840eace7efcSopenharmony_ci
2841eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2842eace7efcSopenharmony_ci        return INNER_ERR;
2843eace7efcSopenharmony_ci    }
2844eace7efcSopenharmony_ci    if (!data.WriteInt32(missionId)) {
2845eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "writeInt32 fail");
2846eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
2847eace7efcSopenharmony_ci    }
2848eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::CLEAN_MISSION, data, reply, option);
2849eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2850eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "clean mission, error: %d", error);
2851eace7efcSopenharmony_ci        return error;
2852eace7efcSopenharmony_ci    }
2853eace7efcSopenharmony_ci    return reply.ReadInt32();
2854eace7efcSopenharmony_ci}
2855eace7efcSopenharmony_ci
2856eace7efcSopenharmony_ciint AbilityManagerProxy::CleanAllMissions()
2857eace7efcSopenharmony_ci{
2858eace7efcSopenharmony_ci    HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
2859eace7efcSopenharmony_ci    int error;
2860eace7efcSopenharmony_ci    MessageParcel data;
2861eace7efcSopenharmony_ci    MessageParcel reply;
2862eace7efcSopenharmony_ci    MessageOption option;
2863eace7efcSopenharmony_ci
2864eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2865eace7efcSopenharmony_ci        return INNER_ERR;
2866eace7efcSopenharmony_ci    }
2867eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::CLEAN_ALL_MISSIONS, data, reply, option);
2868eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2869eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%d", error);
2870eace7efcSopenharmony_ci        return error;
2871eace7efcSopenharmony_ci    }
2872eace7efcSopenharmony_ci    return reply.ReadInt32();
2873eace7efcSopenharmony_ci}
2874eace7efcSopenharmony_ci
2875eace7efcSopenharmony_ciint AbilityManagerProxy::MoveMissionToFront(int32_t missionId)
2876eace7efcSopenharmony_ci{
2877eace7efcSopenharmony_ci    HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
2878eace7efcSopenharmony_ci    int error;
2879eace7efcSopenharmony_ci    MessageParcel data;
2880eace7efcSopenharmony_ci    MessageParcel reply;
2881eace7efcSopenharmony_ci    MessageOption option;
2882eace7efcSopenharmony_ci
2883eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2884eace7efcSopenharmony_ci        return INNER_ERR;
2885eace7efcSopenharmony_ci    }
2886eace7efcSopenharmony_ci    if (!data.WriteInt32(missionId)) {
2887eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "writeInt32 fail");
2888eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
2889eace7efcSopenharmony_ci    }
2890eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::MOVE_MISSION_TO_FRONT, data, reply, option);
2891eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2892eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%d", error);
2893eace7efcSopenharmony_ci        return error;
2894eace7efcSopenharmony_ci    }
2895eace7efcSopenharmony_ci    return reply.ReadInt32();
2896eace7efcSopenharmony_ci}
2897eace7efcSopenharmony_ci
2898eace7efcSopenharmony_ciint AbilityManagerProxy::MoveMissionToFront(int32_t missionId, const StartOptions &startOptions)
2899eace7efcSopenharmony_ci{
2900eace7efcSopenharmony_ci    HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
2901eace7efcSopenharmony_ci    int error;
2902eace7efcSopenharmony_ci    MessageParcel data;
2903eace7efcSopenharmony_ci    MessageParcel reply;
2904eace7efcSopenharmony_ci    MessageOption option;
2905eace7efcSopenharmony_ci
2906eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2907eace7efcSopenharmony_ci        return INNER_ERR;
2908eace7efcSopenharmony_ci    }
2909eace7efcSopenharmony_ci    if (!data.WriteInt32(missionId)) {
2910eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "writeInt32 fail");
2911eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
2912eace7efcSopenharmony_ci    }
2913eace7efcSopenharmony_ci    if (!data.WriteParcelable(&startOptions)) {
2914eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "startOptions write fail");
2915eace7efcSopenharmony_ci        return INNER_ERR;
2916eace7efcSopenharmony_ci    }
2917eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::MOVE_MISSION_TO_FRONT_BY_OPTIONS, data, reply, option);
2918eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2919eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%d", error);
2920eace7efcSopenharmony_ci        return error;
2921eace7efcSopenharmony_ci    }
2922eace7efcSopenharmony_ci    return reply.ReadInt32();
2923eace7efcSopenharmony_ci}
2924eace7efcSopenharmony_ci
2925eace7efcSopenharmony_ciint AbilityManagerProxy::MoveMissionsToForeground(const std::vector<int32_t>& missionIds, int32_t topMissionId)
2926eace7efcSopenharmony_ci{
2927eace7efcSopenharmony_ci    MessageParcel data;
2928eace7efcSopenharmony_ci    MessageParcel reply;
2929eace7efcSopenharmony_ci    MessageOption option;
2930eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2931eace7efcSopenharmony_ci        return INNER_ERR;
2932eace7efcSopenharmony_ci    }
2933eace7efcSopenharmony_ci
2934eace7efcSopenharmony_ci    if (!data.WriteInt32Vector(missionIds)) {
2935eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "missionIds write fail");
2936eace7efcSopenharmony_ci        return INNER_ERR;
2937eace7efcSopenharmony_ci    }
2938eace7efcSopenharmony_ci
2939eace7efcSopenharmony_ci    if (!data.WriteInt32(topMissionId)) {
2940eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "topMissionId write fail");
2941eace7efcSopenharmony_ci        return INNER_ERR;
2942eace7efcSopenharmony_ci    }
2943eace7efcSopenharmony_ci
2944eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::MOVE_MISSIONS_TO_FOREGROUND, data, reply, option);
2945eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2946eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
2947eace7efcSopenharmony_ci        return error;
2948eace7efcSopenharmony_ci    }
2949eace7efcSopenharmony_ci
2950eace7efcSopenharmony_ci    return reply.ReadInt32();
2951eace7efcSopenharmony_ci}
2952eace7efcSopenharmony_ci
2953eace7efcSopenharmony_ciint AbilityManagerProxy::MoveMissionsToBackground(const std::vector<int32_t>& missionIds, std::vector<int32_t>& result)
2954eace7efcSopenharmony_ci{
2955eace7efcSopenharmony_ci    MessageParcel data;
2956eace7efcSopenharmony_ci    MessageParcel reply;
2957eace7efcSopenharmony_ci    MessageOption option;
2958eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2959eace7efcSopenharmony_ci        return INNER_ERR;
2960eace7efcSopenharmony_ci    }
2961eace7efcSopenharmony_ci
2962eace7efcSopenharmony_ci    if (!data.WriteInt32Vector(missionIds)) {
2963eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "mission id write fail");
2964eace7efcSopenharmony_ci        return INNER_ERR;
2965eace7efcSopenharmony_ci    }
2966eace7efcSopenharmony_ci
2967eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::MOVE_MISSIONS_TO_BACKGROUND, data, reply, option);
2968eace7efcSopenharmony_ci    if (error != NO_ERROR) {
2969eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
2970eace7efcSopenharmony_ci        return error;
2971eace7efcSopenharmony_ci    }
2972eace7efcSopenharmony_ci
2973eace7efcSopenharmony_ci    if (!reply.ReadInt32Vector(&result)) {
2974eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "read result fail");
2975eace7efcSopenharmony_ci        return INNER_ERR;
2976eace7efcSopenharmony_ci    }
2977eace7efcSopenharmony_ci    return reply.ReadInt32();
2978eace7efcSopenharmony_ci}
2979eace7efcSopenharmony_ci
2980eace7efcSopenharmony_ciint AbilityManagerProxy::StartUser(int userId, sptr<IUserCallback> callback, bool isAppRecovery)
2981eace7efcSopenharmony_ci{
2982eace7efcSopenharmony_ci    MessageParcel data;
2983eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
2984eace7efcSopenharmony_ci        return INNER_ERR;
2985eace7efcSopenharmony_ci    }
2986eace7efcSopenharmony_ci    if (!data.WriteInt32(userId)) {
2987eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "fail");
2988eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
2989eace7efcSopenharmony_ci    }
2990eace7efcSopenharmony_ci    if (!callback) {
2991eace7efcSopenharmony_ci        data.WriteBool(false);
2992eace7efcSopenharmony_ci    } else {
2993eace7efcSopenharmony_ci        data.WriteBool(true);
2994eace7efcSopenharmony_ci        if (!data.WriteRemoteObject(callback->AsObject())) {
2995eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "write IUserCallback fail");
2996eace7efcSopenharmony_ci            return ERR_INVALID_VALUE;
2997eace7efcSopenharmony_ci        }
2998eace7efcSopenharmony_ci    }
2999eace7efcSopenharmony_ci    if (!data.WriteBool(isAppRecovery)) {
3000eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write isAppRecovery fail");
3001eace7efcSopenharmony_ci        return IPC_PROXY_ERR;
3002eace7efcSopenharmony_ci    }
3003eace7efcSopenharmony_ci    MessageParcel reply;
3004eace7efcSopenharmony_ci    MessageOption option(MessageOption::TF_ASYNC);
3005eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::START_USER, data, reply, option);
3006eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3007eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%d", error);
3008eace7efcSopenharmony_ci        return error;
3009eace7efcSopenharmony_ci    }
3010eace7efcSopenharmony_ci    return reply.ReadInt32();
3011eace7efcSopenharmony_ci}
3012eace7efcSopenharmony_ci
3013eace7efcSopenharmony_ciint AbilityManagerProxy::SetMissionContinueState(const sptr<IRemoteObject> &token, const AAFwk::ContinueState &state)
3014eace7efcSopenharmony_ci{
3015eace7efcSopenharmony_ci    MessageParcel data;
3016eace7efcSopenharmony_ci    MessageParcel reply;
3017eace7efcSopenharmony_ci    MessageOption option;
3018eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3019eace7efcSopenharmony_ci        return INNER_ERR;
3020eace7efcSopenharmony_ci    }
3021eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(token)) {
3022eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
3023eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3024eace7efcSopenharmony_ci    }
3025eace7efcSopenharmony_ci    if (!data.WriteInt32(static_cast<int32_t>(state))) {
3026eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write state fail");
3027eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3028eace7efcSopenharmony_ci    }
3029eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::SET_MISSION_CONTINUE_STATE, data, reply, option);
3030eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3031eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
3032eace7efcSopenharmony_ci        return error;
3033eace7efcSopenharmony_ci    }
3034eace7efcSopenharmony_ci    return reply.ReadInt32();
3035eace7efcSopenharmony_ci}
3036eace7efcSopenharmony_ci
3037eace7efcSopenharmony_ciint AbilityManagerProxy::StopUser(int userId, const sptr<IUserCallback> &callback)
3038eace7efcSopenharmony_ci{
3039eace7efcSopenharmony_ci    MessageParcel data;
3040eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3041eace7efcSopenharmony_ci        return INNER_ERR;
3042eace7efcSopenharmony_ci    }
3043eace7efcSopenharmony_ci    if (!data.WriteInt32(userId)) {
3044eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "fail");
3045eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3046eace7efcSopenharmony_ci    }
3047eace7efcSopenharmony_ci
3048eace7efcSopenharmony_ci    if (!callback) {
3049eace7efcSopenharmony_ci        data.WriteBool(false);
3050eace7efcSopenharmony_ci    } else {
3051eace7efcSopenharmony_ci        data.WriteBool(true);
3052eace7efcSopenharmony_ci        if (!data.WriteRemoteObject(callback->AsObject())) {
3053eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "write IUserCallback fail");
3054eace7efcSopenharmony_ci            return ERR_INVALID_VALUE;
3055eace7efcSopenharmony_ci        }
3056eace7efcSopenharmony_ci    }
3057eace7efcSopenharmony_ci    MessageParcel reply;
3058eace7efcSopenharmony_ci    MessageOption option(MessageOption::TF_ASYNC);
3059eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::STOP_USER, data, reply, option);
3060eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3061eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%d", error);
3062eace7efcSopenharmony_ci        return error;
3063eace7efcSopenharmony_ci    }
3064eace7efcSopenharmony_ci    return reply.ReadInt32();
3065eace7efcSopenharmony_ci}
3066eace7efcSopenharmony_ci
3067eace7efcSopenharmony_ciint AbilityManagerProxy::LogoutUser(int32_t userId)
3068eace7efcSopenharmony_ci{
3069eace7efcSopenharmony_ci    MessageParcel data;
3070eace7efcSopenharmony_ci    MessageParcel reply;
3071eace7efcSopenharmony_ci    MessageOption option;
3072eace7efcSopenharmony_ci
3073eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3074eace7efcSopenharmony_ci        return INNER_ERR;
3075eace7efcSopenharmony_ci    }
3076eace7efcSopenharmony_ci    if (!data.WriteInt32(userId)) {
3077eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "fail");
3078eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3079eace7efcSopenharmony_ci    }
3080eace7efcSopenharmony_ci    int error = SendRequest(AbilityManagerInterfaceCode::LOGOUT_USER, data, reply, option);
3081eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3082eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
3083eace7efcSopenharmony_ci        return error;
3084eace7efcSopenharmony_ci    }
3085eace7efcSopenharmony_ci    return reply.ReadInt32();
3086eace7efcSopenharmony_ci}
3087eace7efcSopenharmony_ci
3088eace7efcSopenharmony_ci#ifdef SUPPORT_SCREEN
3089eace7efcSopenharmony_ciint AbilityManagerProxy::SetMissionLabel(const sptr<IRemoteObject> &token, const std::string &label)
3090eace7efcSopenharmony_ci{
3091eace7efcSopenharmony_ci    MessageParcel data;
3092eace7efcSopenharmony_ci    MessageParcel reply;
3093eace7efcSopenharmony_ci    MessageOption option;
3094eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3095eace7efcSopenharmony_ci        return INNER_ERR;
3096eace7efcSopenharmony_ci    }
3097eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(token)) {
3098eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
3099eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3100eace7efcSopenharmony_ci    }
3101eace7efcSopenharmony_ci    if (!data.WriteString16(Str8ToStr16(label))) {
3102eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write label fail");
3103eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3104eace7efcSopenharmony_ci    }
3105eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::SET_MISSION_LABEL, data, reply, option);
3106eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3107eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
3108eace7efcSopenharmony_ci        return error;
3109eace7efcSopenharmony_ci    }
3110eace7efcSopenharmony_ci    return reply.ReadInt32();
3111eace7efcSopenharmony_ci}
3112eace7efcSopenharmony_ci
3113eace7efcSopenharmony_ciint AbilityManagerProxy::SetMissionIcon(const sptr<IRemoteObject> &token,
3114eace7efcSopenharmony_ci    const std::shared_ptr<OHOS::Media::PixelMap> &icon)
3115eace7efcSopenharmony_ci{
3116eace7efcSopenharmony_ci    if (!token || !icon) {
3117eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "abilitytoken or icon invalid");
3118eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3119eace7efcSopenharmony_ci    }
3120eace7efcSopenharmony_ci
3121eace7efcSopenharmony_ci    MessageParcel data;
3122eace7efcSopenharmony_ci    MessageParcel reply;
3123eace7efcSopenharmony_ci    MessageOption option;
3124eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3125eace7efcSopenharmony_ci        return INNER_ERR;
3126eace7efcSopenharmony_ci    }
3127eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(token)) {
3128eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
3129eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3130eace7efcSopenharmony_ci    }
3131eace7efcSopenharmony_ci
3132eace7efcSopenharmony_ci    if (!data.WriteParcelable(icon.get())) {
3133eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write icon fail");
3134eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3135eace7efcSopenharmony_ci    }
3136eace7efcSopenharmony_ci
3137eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::SET_MISSION_ICON, data, reply, option);
3138eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3139eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
3140eace7efcSopenharmony_ci        return error;
3141eace7efcSopenharmony_ci    }
3142eace7efcSopenharmony_ci    return reply.ReadInt32();
3143eace7efcSopenharmony_ci}
3144eace7efcSopenharmony_ci
3145eace7efcSopenharmony_ciint AbilityManagerProxy::RegisterWindowManagerServiceHandler(const sptr<IWindowManagerServiceHandler>& handler,
3146eace7efcSopenharmony_ci    bool animationEnabled)
3147eace7efcSopenharmony_ci{
3148eace7efcSopenharmony_ci    if (!handler) {
3149eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s: handler null", __func__);
3150eace7efcSopenharmony_ci        return INNER_ERR;
3151eace7efcSopenharmony_ci    }
3152eace7efcSopenharmony_ci    MessageParcel data;
3153eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3154eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s: writeInterfaceToken failed", __func__);
3155eace7efcSopenharmony_ci        return INNER_ERR;
3156eace7efcSopenharmony_ci    }
3157eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(handler->AsObject())) {
3158eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s: handler write fail", __func__);
3159eace7efcSopenharmony_ci        return INNER_ERR;
3160eace7efcSopenharmony_ci    }
3161eace7efcSopenharmony_ci    if (!data.WriteBool(animationEnabled)) {
3162eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write animationEnabled fail");
3163eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3164eace7efcSopenharmony_ci    }
3165eace7efcSopenharmony_ci    MessageOption option;
3166eace7efcSopenharmony_ci    MessageParcel reply;
3167eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::REGISTER_WMS_HANDLER, data, reply, option);
3168eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3169eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s:request error:%{public}d", __func__, error);
3170eace7efcSopenharmony_ci        return error;
3171eace7efcSopenharmony_ci    }
3172eace7efcSopenharmony_ci    return reply.ReadInt32();
3173eace7efcSopenharmony_ci}
3174eace7efcSopenharmony_ci
3175eace7efcSopenharmony_civoid AbilityManagerProxy::CompleteFirstFrameDrawing(const sptr<IRemoteObject> &abilityToken)
3176eace7efcSopenharmony_ci{
3177eace7efcSopenharmony_ci    MessageParcel data;
3178eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3179eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s: writeInterfaceToken fail", __func__);
3180eace7efcSopenharmony_ci        return;
3181eace7efcSopenharmony_ci    }
3182eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(abilityToken)) {
3183eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s: abilityToken write fail", __func__);
3184eace7efcSopenharmony_ci        return;
3185eace7efcSopenharmony_ci    }
3186eace7efcSopenharmony_ci    MessageOption option;
3187eace7efcSopenharmony_ci    MessageParcel reply;
3188eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::COMPLETEFIRSTFRAMEDRAWING, data, reply, option);
3189eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3190eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s: request error:%{public}d", __func__, error);
3191eace7efcSopenharmony_ci    }
3192eace7efcSopenharmony_ci}
3193eace7efcSopenharmony_ci
3194eace7efcSopenharmony_ciint AbilityManagerProxy::PrepareTerminateAbility(const sptr<IRemoteObject> &token,
3195eace7efcSopenharmony_ci    sptr<IPrepareTerminateCallback> &callback)
3196eace7efcSopenharmony_ci{
3197eace7efcSopenharmony_ci    if (!callback) {
3198eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "callback null");
3199eace7efcSopenharmony_ci        return INNER_ERR;
3200eace7efcSopenharmony_ci    }
3201eace7efcSopenharmony_ci    int error = 0;
3202eace7efcSopenharmony_ci    MessageParcel data;
3203eace7efcSopenharmony_ci    MessageParcel reply;
3204eace7efcSopenharmony_ci    MessageOption option(MessageOption::TF_SYNC);
3205eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3206eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "writeInterfaceToken fail");
3207eace7efcSopenharmony_ci        return INNER_ERR;
3208eace7efcSopenharmony_ci    }
3209eace7efcSopenharmony_ci    if (token) {
3210eace7efcSopenharmony_ci        if (!data.WriteBool(true) || !data.WriteRemoteObject(token)) {
3211eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "write fail");
3212eace7efcSopenharmony_ci            return INNER_ERR;
3213eace7efcSopenharmony_ci        }
3214eace7efcSopenharmony_ci    } else {
3215eace7efcSopenharmony_ci        if (!data.WriteBool(false)) {
3216eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "write fail");
3217eace7efcSopenharmony_ci            return INNER_ERR;
3218eace7efcSopenharmony_ci        }
3219eace7efcSopenharmony_ci    }
3220eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(callback->AsObject())) {
3221eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "weite callback fail");
3222eace7efcSopenharmony_ci        return INNER_ERR;
3223eace7efcSopenharmony_ci    }
3224eace7efcSopenharmony_ci
3225eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::PREPARE_TERMINATE_ABILITY, data, reply, option);
3226eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3227eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
3228eace7efcSopenharmony_ci        return error;
3229eace7efcSopenharmony_ci    }
3230eace7efcSopenharmony_ci
3231eace7efcSopenharmony_ci    return reply.ReadInt32();
3232eace7efcSopenharmony_ci}
3233eace7efcSopenharmony_ci
3234eace7efcSopenharmony_ciint AbilityManagerProxy::GetDialogSessionInfo(const std::string &dialogSessionId, sptr<DialogSessionInfo> &info)
3235eace7efcSopenharmony_ci{
3236eace7efcSopenharmony_ci    MessageParcel data;
3237eace7efcSopenharmony_ci    MessageParcel reply;
3238eace7efcSopenharmony_ci    MessageOption option;
3239eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3240eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write interface fail");
3241eace7efcSopenharmony_ci        return INNER_ERR;
3242eace7efcSopenharmony_ci    }
3243eace7efcSopenharmony_ci    if (!data.WriteString(dialogSessionId)) {
3244eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write dialogSessionId fail");
3245eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3246eace7efcSopenharmony_ci    }
3247eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::GET_DIALOG_SESSION_INFO, data, reply, option);
3248eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3249eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
3250eace7efcSopenharmony_ci        return error;
3251eace7efcSopenharmony_ci    }
3252eace7efcSopenharmony_ci    info = reply.ReadParcelable<DialogSessionInfo>();
3253eace7efcSopenharmony_ci    if (!info) {
3254eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "readParcelable fail");
3255eace7efcSopenharmony_ci        return ERR_UNKNOWN_OBJECT;
3256eace7efcSopenharmony_ci    }
3257eace7efcSopenharmony_ci    return reply.ReadInt32();
3258eace7efcSopenharmony_ci}
3259eace7efcSopenharmony_ci
3260eace7efcSopenharmony_ciint AbilityManagerProxy::SendDialogResult(const Want &want, const std::string &dialogSessionId, const bool isAllow)
3261eace7efcSopenharmony_ci{
3262eace7efcSopenharmony_ci    MessageParcel data;
3263eace7efcSopenharmony_ci    MessageParcel reply;
3264eace7efcSopenharmony_ci    MessageOption option;
3265eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3266eace7efcSopenharmony_ci        return INNER_ERR;
3267eace7efcSopenharmony_ci    }
3268eace7efcSopenharmony_ci    if (!data.WriteParcelable(&want)) {
3269eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "want write fail");
3270eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3271eace7efcSopenharmony_ci    }
3272eace7efcSopenharmony_ci    if (!data.WriteString(dialogSessionId)) {
3273eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write dialogSessionId fail");
3274eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3275eace7efcSopenharmony_ci    }
3276eace7efcSopenharmony_ci    if (!data.WriteBool(isAllow)) {
3277eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write dialogSessionId fail");
3278eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3279eace7efcSopenharmony_ci    }
3280eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::SEND_DIALOG_RESULT, data, reply, option);
3281eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3282eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error: %{public}d", error);
3283eace7efcSopenharmony_ci        return error;
3284eace7efcSopenharmony_ci    }
3285eace7efcSopenharmony_ci    return reply.ReadInt32();
3286eace7efcSopenharmony_ci}
3287eace7efcSopenharmony_ci
3288eace7efcSopenharmony_ciint32_t AbilityManagerProxy::RegisterAbilityFirstFrameStateObserver(
3289eace7efcSopenharmony_ci    const sptr<IAbilityFirstFrameStateObserver> &observer, const std::string &targetBundleName)
3290eace7efcSopenharmony_ci{
3291eace7efcSopenharmony_ci    TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
3292eace7efcSopenharmony_ci    MessageParcel data;
3293eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3294eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "writeInterfaceToken fail");
3295eace7efcSopenharmony_ci        return INNER_ERR;
3296eace7efcSopenharmony_ci    }
3297eace7efcSopenharmony_ci
3298eace7efcSopenharmony_ci    if (observer == nullptr || !data.WriteRemoteObject(observer->AsObject())) {
3299eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "observer null or write remote fail");
3300eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3301eace7efcSopenharmony_ci    }
3302eace7efcSopenharmony_ci    if (!data.WriteString(targetBundleName)) {
3303eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write target bundleName fail");
3304eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3305eace7efcSopenharmony_ci    }
3306eace7efcSopenharmony_ci
3307eace7efcSopenharmony_ci    MessageParcel reply;
3308eace7efcSopenharmony_ci    MessageOption option;
3309eace7efcSopenharmony_ci    auto ret = SendRequest(AbilityManagerInterfaceCode::REGISTER_ABILITY_FIRST_FRAME_STATE_OBSERVER,
3310eace7efcSopenharmony_ci        data, reply, option);
3311eace7efcSopenharmony_ci    if (ret != NO_ERROR) {
3312eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error: %{public}d", ret);
3313eace7efcSopenharmony_ci        return ret;
3314eace7efcSopenharmony_ci    }
3315eace7efcSopenharmony_ci    return reply.ReadInt32();
3316eace7efcSopenharmony_ci}
3317eace7efcSopenharmony_ci
3318eace7efcSopenharmony_ciint32_t AbilityManagerProxy::UnregisterAbilityFirstFrameStateObserver(
3319eace7efcSopenharmony_ci    const sptr<IAbilityFirstFrameStateObserver> &observer)
3320eace7efcSopenharmony_ci{
3321eace7efcSopenharmony_ci    TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
3322eace7efcSopenharmony_ci    MessageParcel data;
3323eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3324eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write Token fail");
3325eace7efcSopenharmony_ci        return INNER_ERR;
3326eace7efcSopenharmony_ci    }
3327eace7efcSopenharmony_ci    if (observer == nullptr || !data.WriteRemoteObject(observer->AsObject())) {
3328eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "observer null or write remote fail");
3329eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3330eace7efcSopenharmony_ci    }
3331eace7efcSopenharmony_ci
3332eace7efcSopenharmony_ci    MessageParcel reply;
3333eace7efcSopenharmony_ci    MessageOption option;
3334eace7efcSopenharmony_ci    auto ret =
3335eace7efcSopenharmony_ci        SendRequest(AbilityManagerInterfaceCode::UNREGISTER_ABILITY_FIRST_FRAME_STATE_OBSERVER, data, reply, option);
3336eace7efcSopenharmony_ci    if (ret != NO_ERROR) {
3337eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", ret);
3338eace7efcSopenharmony_ci        return ret;
3339eace7efcSopenharmony_ci    }
3340eace7efcSopenharmony_ci    return reply.ReadInt32();
3341eace7efcSopenharmony_ci}
3342eace7efcSopenharmony_ci
3343eace7efcSopenharmony_civoid AbilityManagerProxy::CompleteFirstFrameDrawing(int32_t sessionId)
3344eace7efcSopenharmony_ci{
3345eace7efcSopenharmony_ci    MessageParcel data;
3346eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3347eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "writeInterfaceToken failed");
3348eace7efcSopenharmony_ci        return;
3349eace7efcSopenharmony_ci    }
3350eace7efcSopenharmony_ci    if (!data.WriteInt32(sessionId)) {
3351eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "sessionId write failed");
3352eace7efcSopenharmony_ci        return;
3353eace7efcSopenharmony_ci    }
3354eace7efcSopenharmony_ci    MessageOption option;
3355eace7efcSopenharmony_ci    MessageParcel reply;
3356eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::COMPLETE_FIRST_FRAME_DRAWING_BY_SCB, data, reply, option);
3357eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3358eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
3359eace7efcSopenharmony_ci    }
3360eace7efcSopenharmony_ci}
3361eace7efcSopenharmony_ci#endif
3362eace7efcSopenharmony_ci
3363eace7efcSopenharmony_ciint AbilityManagerProxy::GetAbilityRunningInfos(std::vector<AbilityRunningInfo> &info)
3364eace7efcSopenharmony_ci{
3365eace7efcSopenharmony_ci    MessageParcel data;
3366eace7efcSopenharmony_ci    MessageParcel reply;
3367eace7efcSopenharmony_ci    MessageOption option;
3368eace7efcSopenharmony_ci
3369eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3370eace7efcSopenharmony_ci        return INNER_ERR;
3371eace7efcSopenharmony_ci    }
3372eace7efcSopenharmony_ci
3373eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::GET_ABILITY_RUNNING_INFO, data, reply, option);
3374eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3375eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
3376eace7efcSopenharmony_ci        return error;
3377eace7efcSopenharmony_ci    }
3378eace7efcSopenharmony_ci    error = GetParcelableInfos<AbilityRunningInfo>(reply, info);
3379eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3380eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "getParcelableInfos fail, error:%{public}d", error);
3381eace7efcSopenharmony_ci        return error;
3382eace7efcSopenharmony_ci    }
3383eace7efcSopenharmony_ci    return reply.ReadInt32();
3384eace7efcSopenharmony_ci}
3385eace7efcSopenharmony_ci
3386eace7efcSopenharmony_ciint AbilityManagerProxy::GetExtensionRunningInfos(int upperLimit, std::vector<ExtensionRunningInfo> &info)
3387eace7efcSopenharmony_ci{
3388eace7efcSopenharmony_ci    MessageParcel data;
3389eace7efcSopenharmony_ci    MessageParcel reply;
3390eace7efcSopenharmony_ci    MessageOption option;
3391eace7efcSopenharmony_ci
3392eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3393eace7efcSopenharmony_ci        return INNER_ERR;
3394eace7efcSopenharmony_ci    }
3395eace7efcSopenharmony_ci
3396eace7efcSopenharmony_ci    if (!data.WriteInt32(upperLimit)) {
3397eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "upperLimit write fail");
3398eace7efcSopenharmony_ci        return INNER_ERR;
3399eace7efcSopenharmony_ci    }
3400eace7efcSopenharmony_ci
3401eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::GET_EXTENSION_RUNNING_INFO, data, reply, option);
3402eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3403eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
3404eace7efcSopenharmony_ci        return error;
3405eace7efcSopenharmony_ci    }
3406eace7efcSopenharmony_ci    error = GetParcelableInfos<ExtensionRunningInfo>(reply, info);
3407eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3408eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "getParcelableInfos fail, error: %{public}d", error);
3409eace7efcSopenharmony_ci        return error;
3410eace7efcSopenharmony_ci    }
3411eace7efcSopenharmony_ci    return reply.ReadInt32();
3412eace7efcSopenharmony_ci}
3413eace7efcSopenharmony_ci
3414eace7efcSopenharmony_ciint AbilityManagerProxy::GetProcessRunningInfos(std::vector<AppExecFwk::RunningProcessInfo> &info)
3415eace7efcSopenharmony_ci{
3416eace7efcSopenharmony_ci    MessageParcel data;
3417eace7efcSopenharmony_ci    MessageParcel reply;
3418eace7efcSopenharmony_ci    MessageOption option;
3419eace7efcSopenharmony_ci
3420eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3421eace7efcSopenharmony_ci        return INNER_ERR;
3422eace7efcSopenharmony_ci    }
3423eace7efcSopenharmony_ci
3424eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::GET_PROCESS_RUNNING_INFO, data, reply, option);
3425eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3426eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request, error:%{public}d", error);
3427eace7efcSopenharmony_ci        return error;
3428eace7efcSopenharmony_ci    }
3429eace7efcSopenharmony_ci    error = GetParcelableInfos<AppExecFwk::RunningProcessInfo>(reply, info);
3430eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3431eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "getParcelable error:%{public}d", error);
3432eace7efcSopenharmony_ci        return error;
3433eace7efcSopenharmony_ci    }
3434eace7efcSopenharmony_ci    return reply.ReadInt32();
3435eace7efcSopenharmony_ci}
3436eace7efcSopenharmony_ci
3437eace7efcSopenharmony_ciint AbilityManagerProxy::StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag)
3438eace7efcSopenharmony_ci{
3439eace7efcSopenharmony_ci    TAG_LOGI(AAFwkTag::ABILITYMGR, "called");
3440eace7efcSopenharmony_ci    MessageParcel data;
3441eace7efcSopenharmony_ci    MessageParcel reply;
3442eace7efcSopenharmony_ci    MessageOption option;
3443eace7efcSopenharmony_ci
3444eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3445eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "writeInterfaceToken fail");
3446eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3447eace7efcSopenharmony_ci    }
3448eace7efcSopenharmony_ci    if (!data.WriteString(devId)) {
3449eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write deviceId fail");
3450eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3451eace7efcSopenharmony_ci    }
3452eace7efcSopenharmony_ci
3453eace7efcSopenharmony_ci    if (!data.WriteBool(fixConflict)) {
3454eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "writeBool fail");
3455eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3456eace7efcSopenharmony_ci    }
3457eace7efcSopenharmony_ci
3458eace7efcSopenharmony_ci    if (!data.WriteInt64(tag)) {
3459eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "writeInt64 fail");
3460eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3461eace7efcSopenharmony_ci    }
3462eace7efcSopenharmony_ci
3463eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::START_SYNC_MISSIONS, data, reply, option);
3464eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3465eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
3466eace7efcSopenharmony_ci        return error;
3467eace7efcSopenharmony_ci    }
3468eace7efcSopenharmony_ci    return reply.ReadInt32();
3469eace7efcSopenharmony_ci}
3470eace7efcSopenharmony_ci
3471eace7efcSopenharmony_ciint32_t AbilityManagerProxy::StopSyncRemoteMissions(const std::string& devId)
3472eace7efcSopenharmony_ci{
3473eace7efcSopenharmony_ci    TAG_LOGI(AAFwkTag::ABILITYMGR, "call");
3474eace7efcSopenharmony_ci    MessageParcel data;
3475eace7efcSopenharmony_ci    MessageParcel reply;
3476eace7efcSopenharmony_ci    MessageOption option;
3477eace7efcSopenharmony_ci
3478eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3479eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "writeInterfaceToken fail");
3480eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3481eace7efcSopenharmony_ci    }
3482eace7efcSopenharmony_ci    if (!data.WriteString(devId)) {
3483eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write deviceId fail");
3484eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3485eace7efcSopenharmony_ci    }
3486eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::STOP_SYNC_MISSIONS, data, reply, option);
3487eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3488eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
3489eace7efcSopenharmony_ci        return error;
3490eace7efcSopenharmony_ci    }
3491eace7efcSopenharmony_ci    return reply.ReadInt32();
3492eace7efcSopenharmony_ci}
3493eace7efcSopenharmony_ci
3494eace7efcSopenharmony_ciint AbilityManagerProxy::UnRegisterMissionListener(const std::string &deviceId,
3495eace7efcSopenharmony_ci    const sptr<IRemoteMissionListener> &listener)
3496eace7efcSopenharmony_ci{
3497eace7efcSopenharmony_ci    MessageParcel data;
3498eace7efcSopenharmony_ci    MessageParcel reply;
3499eace7efcSopenharmony_ci    MessageOption option;
3500eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3501eace7efcSopenharmony_ci        return INNER_ERR;
3502eace7efcSopenharmony_ci    }
3503eace7efcSopenharmony_ci    if (!data.WriteString(deviceId)) {
3504eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "deviceId write fail");
3505eace7efcSopenharmony_ci        return INNER_ERR;
3506eace7efcSopenharmony_ci    }
3507eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(listener->AsObject())) {
3508eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "listener write fail");
3509eace7efcSopenharmony_ci        return INNER_ERR;
3510eace7efcSopenharmony_ci    }
3511eace7efcSopenharmony_ci
3512eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::UNREGISTER_REMOTE_MISSION_LISTENER,
3513eace7efcSopenharmony_ci        data, reply, option);
3514eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3515eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
3516eace7efcSopenharmony_ci        return error;
3517eace7efcSopenharmony_ci    }
3518eace7efcSopenharmony_ci    return reply.ReadInt32();
3519eace7efcSopenharmony_ci}
3520eace7efcSopenharmony_ci
3521eace7efcSopenharmony_ciint AbilityManagerProxy::StartAbilityByCall(const Want &want, const sptr<IAbilityConnection> &connect,
3522eace7efcSopenharmony_ci    const sptr<IRemoteObject> &callerToken, int32_t accountId)
3523eace7efcSopenharmony_ci{
3524eace7efcSopenharmony_ci    TAG_LOGD(AAFwkTag::ABILITYMGR, "AbilityManagerProxy::StartAbilityByCall begin.");
3525eace7efcSopenharmony_ci    int error;
3526eace7efcSopenharmony_ci    MessageParcel data;
3527eace7efcSopenharmony_ci    MessageParcel reply;
3528eace7efcSopenharmony_ci    MessageOption option;
3529eace7efcSopenharmony_ci
3530eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3531eace7efcSopenharmony_ci        return INNER_ERR;
3532eace7efcSopenharmony_ci    }
3533eace7efcSopenharmony_ci    if (!data.WriteParcelable(&want)) {
3534eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "want write fail");
3535eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3536eace7efcSopenharmony_ci    }
3537eace7efcSopenharmony_ci    if (connect == nullptr) {
3538eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "resolve fail, null connect");
3539eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3540eace7efcSopenharmony_ci    }
3541eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(connect->AsObject())) {
3542eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "resolve write fail");
3543eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3544eace7efcSopenharmony_ci    }
3545eace7efcSopenharmony_ci    if (callerToken) {
3546eace7efcSopenharmony_ci        if (!data.WriteBool(true) || !data.WriteRemoteObject(callerToken)) {
3547eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "write flag and callerToken failed");
3548eace7efcSopenharmony_ci            return ERR_INVALID_VALUE;
3549eace7efcSopenharmony_ci        }
3550eace7efcSopenharmony_ci    } else {
3551eace7efcSopenharmony_ci        if (!data.WriteBool(false)) {
3552eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "write flag failed");
3553eace7efcSopenharmony_ci            return ERR_INVALID_VALUE;
3554eace7efcSopenharmony_ci        }
3555eace7efcSopenharmony_ci    }
3556eace7efcSopenharmony_ci    if (!data.WriteInt32(accountId)) {
3557eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "accountId write fail");
3558eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3559eace7efcSopenharmony_ci    }
3560eace7efcSopenharmony_ci
3561eace7efcSopenharmony_ci    TAG_LOGD(AAFwkTag::ABILITYMGR, "AbilityManagerProxy::StartAbilityByCall SendRequest Call.");
3562eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::START_CALL_ABILITY, data, reply, option);
3563eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3564eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
3565eace7efcSopenharmony_ci        return error;
3566eace7efcSopenharmony_ci    }
3567eace7efcSopenharmony_ci    TAG_LOGD(AAFwkTag::ABILITYMGR, "AbilityManagerProxy::StartAbilityByCall end.");
3568eace7efcSopenharmony_ci    return reply.ReadInt32();
3569eace7efcSopenharmony_ci}
3570eace7efcSopenharmony_ci
3571eace7efcSopenharmony_civoid AbilityManagerProxy::CallRequestDone(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &callStub)
3572eace7efcSopenharmony_ci{
3573eace7efcSopenharmony_ci    MessageParcel data;
3574eace7efcSopenharmony_ci    MessageParcel reply;
3575eace7efcSopenharmony_ci    MessageOption option(MessageOption::TF_ASYNC);
3576eace7efcSopenharmony_ci
3577eace7efcSopenharmony_ci    if (token == nullptr) {
3578eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request fail, null token ");
3579eace7efcSopenharmony_ci        return;
3580eace7efcSopenharmony_ci    }
3581eace7efcSopenharmony_ci    if (callStub == nullptr) {
3582eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request fail, null callStub");
3583eace7efcSopenharmony_ci        return;
3584eace7efcSopenharmony_ci    }
3585eace7efcSopenharmony_ci
3586eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3587eace7efcSopenharmony_ci        return;
3588eace7efcSopenharmony_ci    }
3589eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(token)) {
3590eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write object fail, write token fail");
3591eace7efcSopenharmony_ci        return;
3592eace7efcSopenharmony_ci    }
3593eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(callStub)) {
3594eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write object fail, write callStub fail");
3595eace7efcSopenharmony_ci        return;
3596eace7efcSopenharmony_ci    }
3597eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::CALL_REQUEST_DONE, data, reply, option);
3598eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3599eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
3600eace7efcSopenharmony_ci        return;
3601eace7efcSopenharmony_ci    }
3602eace7efcSopenharmony_ci}
3603eace7efcSopenharmony_ci
3604eace7efcSopenharmony_ciint AbilityManagerProxy::ReleaseCall(
3605eace7efcSopenharmony_ci    const sptr<IAbilityConnection> &connect, const AppExecFwk::ElementName &element)
3606eace7efcSopenharmony_ci{
3607eace7efcSopenharmony_ci    int error;
3608eace7efcSopenharmony_ci    MessageParcel data;
3609eace7efcSopenharmony_ci    MessageParcel reply;
3610eace7efcSopenharmony_ci    MessageOption option;
3611eace7efcSopenharmony_ci    if (connect == nullptr) {
3612eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "release fail, null connect");
3613eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3614eace7efcSopenharmony_ci    }
3615eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3616eace7efcSopenharmony_ci        return INNER_ERR;
3617eace7efcSopenharmony_ci    }
3618eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(connect->AsObject())) {
3619eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "release connect write fail");
3620eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3621eace7efcSopenharmony_ci    }
3622eace7efcSopenharmony_ci    if (!data.WriteParcelable(&element)) {
3623eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "element error");
3624eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3625eace7efcSopenharmony_ci    }
3626eace7efcSopenharmony_ci
3627eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::RELEASE_CALL_ABILITY, data, reply, option);
3628eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3629eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
3630eace7efcSopenharmony_ci        return error;
3631eace7efcSopenharmony_ci    }
3632eace7efcSopenharmony_ci    return reply.ReadInt32();
3633eace7efcSopenharmony_ci}
3634eace7efcSopenharmony_ci
3635eace7efcSopenharmony_civoid AbilityManagerProxy::GetAbilityTokenByCalleeObj(const sptr<IRemoteObject> &callStub, sptr<IRemoteObject> &token)
3636eace7efcSopenharmony_ci{
3637eace7efcSopenharmony_ci    MessageParcel data;
3638eace7efcSopenharmony_ci    MessageParcel reply;
3639eace7efcSopenharmony_ci    MessageOption option;
3640eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3641eace7efcSopenharmony_ci        return;
3642eace7efcSopenharmony_ci    }
3643eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(callStub)) {
3644eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "writeRemoteObject fail, write callStub fail");
3645eace7efcSopenharmony_ci        return;
3646eace7efcSopenharmony_ci    }
3647eace7efcSopenharmony_ci
3648eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::GET_ABILITY_TOKEN, data, reply, option);
3649eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3650eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
3651eace7efcSopenharmony_ci        return;
3652eace7efcSopenharmony_ci    }
3653eace7efcSopenharmony_ci    token = sptr<IRemoteObject>(reply.ReadRemoteObject());
3654eace7efcSopenharmony_ci}
3655eace7efcSopenharmony_ci
3656eace7efcSopenharmony_ciint AbilityManagerProxy::RegisterSnapshotHandler(const sptr<ISnapshotHandler>& handler)
3657eace7efcSopenharmony_ci{
3658eace7efcSopenharmony_ci    MessageParcel data;
3659eace7efcSopenharmony_ci    MessageParcel reply;
3660eace7efcSopenharmony_ci    MessageOption option;
3661eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3662eace7efcSopenharmony_ci        return INNER_ERR;
3663eace7efcSopenharmony_ci    }
3664eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(handler->AsObject())) {
3665eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "handler write failed");
3666eace7efcSopenharmony_ci        return INNER_ERR;
3667eace7efcSopenharmony_ci    }
3668eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::REGISTER_SNAPSHOT_HANDLER, data, reply, option);
3669eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3670eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
3671eace7efcSopenharmony_ci        return error;
3672eace7efcSopenharmony_ci    }
3673eace7efcSopenharmony_ci    return reply.ReadInt32();
3674eace7efcSopenharmony_ci}
3675eace7efcSopenharmony_ci
3676eace7efcSopenharmony_ciint AbilityManagerProxy::SetAbilityController(const sptr<AppExecFwk::IAbilityController> &abilityController,
3677eace7efcSopenharmony_ci    bool imAStabilityTest)
3678eace7efcSopenharmony_ci{
3679eace7efcSopenharmony_ci    if (!abilityController) {
3680eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "null abilityController");
3681eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3682eace7efcSopenharmony_ci    }
3683eace7efcSopenharmony_ci    MessageParcel data;
3684eace7efcSopenharmony_ci    MessageParcel reply;
3685eace7efcSopenharmony_ci    MessageOption option;
3686eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3687eace7efcSopenharmony_ci        return INNER_ERR;
3688eace7efcSopenharmony_ci    }
3689eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(abilityController->AsObject())) {
3690eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "abilityController write fail");
3691eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3692eace7efcSopenharmony_ci    }
3693eace7efcSopenharmony_ci    if (!data.WriteBool(imAStabilityTest)) {
3694eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "imAStabilityTest write fail");
3695eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3696eace7efcSopenharmony_ci    }
3697eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::SET_ABILITY_CONTROLLER, data, reply, option);
3698eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3699eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
3700eace7efcSopenharmony_ci        return error;
3701eace7efcSopenharmony_ci    }
3702eace7efcSopenharmony_ci    return reply.ReadInt32();
3703eace7efcSopenharmony_ci}
3704eace7efcSopenharmony_ci
3705eace7efcSopenharmony_cibool AbilityManagerProxy::IsRunningInStabilityTest()
3706eace7efcSopenharmony_ci{
3707eace7efcSopenharmony_ci    MessageParcel data;
3708eace7efcSopenharmony_ci    MessageParcel reply;
3709eace7efcSopenharmony_ci    MessageOption option;
3710eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3711eace7efcSopenharmony_ci        return false;
3712eace7efcSopenharmony_ci    }
3713eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::IS_USER_A_STABILITY_TEST, data, reply, option);
3714eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3715eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
3716eace7efcSopenharmony_ci        return false;
3717eace7efcSopenharmony_ci    }
3718eace7efcSopenharmony_ci    return reply.ReadBool();
3719eace7efcSopenharmony_ci}
3720eace7efcSopenharmony_ci
3721eace7efcSopenharmony_ciint AbilityManagerProxy::StartUserTest(const Want &want, const sptr<IRemoteObject> &observer)
3722eace7efcSopenharmony_ci{
3723eace7efcSopenharmony_ci    MessageParcel data;
3724eace7efcSopenharmony_ci    MessageParcel reply;
3725eace7efcSopenharmony_ci    MessageOption option;
3726eace7efcSopenharmony_ci
3727eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3728eace7efcSopenharmony_ci        return INNER_ERR;
3729eace7efcSopenharmony_ci    }
3730eace7efcSopenharmony_ci    if (!data.WriteParcelable(&want)) {
3731eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "want write fail");
3732eace7efcSopenharmony_ci        return INNER_ERR;
3733eace7efcSopenharmony_ci    }
3734eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(observer)) {
3735eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "observer write fail");
3736eace7efcSopenharmony_ci        return INNER_ERR;
3737eace7efcSopenharmony_ci    }
3738eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::START_USER_TEST, data, reply, option);
3739eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3740eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
3741eace7efcSopenharmony_ci        return error;
3742eace7efcSopenharmony_ci    }
3743eace7efcSopenharmony_ci    return reply.ReadInt32();
3744eace7efcSopenharmony_ci}
3745eace7efcSopenharmony_ci
3746eace7efcSopenharmony_ciint AbilityManagerProxy::FinishUserTest(
3747eace7efcSopenharmony_ci    const std::string &msg, const int64_t &resultCode, const std::string &bundleName)
3748eace7efcSopenharmony_ci{
3749eace7efcSopenharmony_ci    MessageParcel data;
3750eace7efcSopenharmony_ci    MessageParcel reply;
3751eace7efcSopenharmony_ci    MessageOption option;
3752eace7efcSopenharmony_ci
3753eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3754eace7efcSopenharmony_ci        return INNER_ERR;
3755eace7efcSopenharmony_ci    }
3756eace7efcSopenharmony_ci    if (!data.WriteString(msg)) {
3757eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "msg write fail");
3758eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3759eace7efcSopenharmony_ci    }
3760eace7efcSopenharmony_ci    if (!data.WriteInt64(resultCode)) {
3761eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "resultCode write fail");
3762eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3763eace7efcSopenharmony_ci    }
3764eace7efcSopenharmony_ci    if (!data.WriteString(bundleName)) {
3765eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "bundleName write fail");
3766eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3767eace7efcSopenharmony_ci    }
3768eace7efcSopenharmony_ci
3769eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::FINISH_USER_TEST, data, reply, option);
3770eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3771eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
3772eace7efcSopenharmony_ci        return error;
3773eace7efcSopenharmony_ci    }
3774eace7efcSopenharmony_ci    return reply.ReadInt32();
3775eace7efcSopenharmony_ci}
3776eace7efcSopenharmony_ci
3777eace7efcSopenharmony_ciint AbilityManagerProxy::GetTopAbility(sptr<IRemoteObject> &token)
3778eace7efcSopenharmony_ci{
3779eace7efcSopenharmony_ci    MessageParcel data;
3780eace7efcSopenharmony_ci    MessageParcel reply;
3781eace7efcSopenharmony_ci    MessageOption option;
3782eace7efcSopenharmony_ci
3783eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3784eace7efcSopenharmony_ci        return INNER_ERR;
3785eace7efcSopenharmony_ci    }
3786eace7efcSopenharmony_ci
3787eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::GET_TOP_ABILITY_TOKEN, data, reply, option);
3788eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3789eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
3790eace7efcSopenharmony_ci        return error;
3791eace7efcSopenharmony_ci    }
3792eace7efcSopenharmony_ci
3793eace7efcSopenharmony_ci    token = sptr<IRemoteObject>(reply.ReadRemoteObject());
3794eace7efcSopenharmony_ci    if (!token) {
3795eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "read IRemoteObject fail");
3796eace7efcSopenharmony_ci        return ERR_UNKNOWN_OBJECT;
3797eace7efcSopenharmony_ci    }
3798eace7efcSopenharmony_ci
3799eace7efcSopenharmony_ci    return reply.ReadInt32();
3800eace7efcSopenharmony_ci}
3801eace7efcSopenharmony_ci
3802eace7efcSopenharmony_ciint AbilityManagerProxy::CheckUIExtensionIsFocused(uint32_t uiExtensionTokenId, bool& isFocused)
3803eace7efcSopenharmony_ci{
3804eace7efcSopenharmony_ci    MessageParcel data;
3805eace7efcSopenharmony_ci    MessageParcel reply;
3806eace7efcSopenharmony_ci    MessageOption option;
3807eace7efcSopenharmony_ci
3808eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3809eace7efcSopenharmony_ci        return INNER_ERR;
3810eace7efcSopenharmony_ci    }
3811eace7efcSopenharmony_ci
3812eace7efcSopenharmony_ci    if (!data.WriteUint32(uiExtensionTokenId)) {
3813eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "uiExtensionTokenId write fail");
3814eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3815eace7efcSopenharmony_ci    }
3816eace7efcSopenharmony_ci
3817eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::CHECK_UI_EXTENSION_IS_FOCUSED, data, reply, option);
3818eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3819eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
3820eace7efcSopenharmony_ci        return error;
3821eace7efcSopenharmony_ci    }
3822eace7efcSopenharmony_ci
3823eace7efcSopenharmony_ci    isFocused = reply.ReadBool();
3824eace7efcSopenharmony_ci    return NO_ERROR;
3825eace7efcSopenharmony_ci}
3826eace7efcSopenharmony_ci
3827eace7efcSopenharmony_ciint AbilityManagerProxy::DelegatorDoAbilityForeground(const sptr<IRemoteObject> &token)
3828eace7efcSopenharmony_ci{
3829eace7efcSopenharmony_ci    MessageParcel data;
3830eace7efcSopenharmony_ci    MessageParcel reply;
3831eace7efcSopenharmony_ci    MessageOption option;
3832eace7efcSopenharmony_ci
3833eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3834eace7efcSopenharmony_ci        return INNER_ERR;
3835eace7efcSopenharmony_ci    }
3836eace7efcSopenharmony_ci
3837eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(token)) {
3838eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "data write fail");
3839eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3840eace7efcSopenharmony_ci    }
3841eace7efcSopenharmony_ci
3842eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::DELEGATOR_DO_ABILITY_FOREGROUND,
3843eace7efcSopenharmony_ci        data, reply, option);
3844eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3845eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
3846eace7efcSopenharmony_ci        return error;
3847eace7efcSopenharmony_ci    }
3848eace7efcSopenharmony_ci
3849eace7efcSopenharmony_ci    return reply.ReadInt32();
3850eace7efcSopenharmony_ci}
3851eace7efcSopenharmony_ci
3852eace7efcSopenharmony_ciint AbilityManagerProxy::DelegatorDoAbilityBackground(const sptr<IRemoteObject> &token)
3853eace7efcSopenharmony_ci{
3854eace7efcSopenharmony_ci    MessageParcel data;
3855eace7efcSopenharmony_ci    MessageParcel reply;
3856eace7efcSopenharmony_ci    MessageOption option;
3857eace7efcSopenharmony_ci
3858eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3859eace7efcSopenharmony_ci        return INNER_ERR;
3860eace7efcSopenharmony_ci    }
3861eace7efcSopenharmony_ci
3862eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(token)) {
3863eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "data write fail");
3864eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3865eace7efcSopenharmony_ci    }
3866eace7efcSopenharmony_ci
3867eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::DELEGATOR_DO_ABILITY_BACKGROUND,
3868eace7efcSopenharmony_ci        data, reply, option);
3869eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3870eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
3871eace7efcSopenharmony_ci        return error;
3872eace7efcSopenharmony_ci    }
3873eace7efcSopenharmony_ci
3874eace7efcSopenharmony_ci    return reply.ReadInt32();
3875eace7efcSopenharmony_ci}
3876eace7efcSopenharmony_ci
3877eace7efcSopenharmony_ciint AbilityManagerProxy::DoAbilityForeground(const sptr<IRemoteObject> &token, uint32_t flag)
3878eace7efcSopenharmony_ci{
3879eace7efcSopenharmony_ci    MessageParcel data;
3880eace7efcSopenharmony_ci    MessageParcel reply;
3881eace7efcSopenharmony_ci    MessageOption option;
3882eace7efcSopenharmony_ci
3883eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3884eace7efcSopenharmony_ci        return INNER_ERR;
3885eace7efcSopenharmony_ci    }
3886eace7efcSopenharmony_ci
3887eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(token)) {
3888eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "data write fail");
3889eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3890eace7efcSopenharmony_ci    }
3891eace7efcSopenharmony_ci
3892eace7efcSopenharmony_ci    if (!data.WriteUint32(flag)) {
3893eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "flag write fail");
3894eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3895eace7efcSopenharmony_ci    }
3896eace7efcSopenharmony_ci
3897eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::DO_ABILITY_FOREGROUND, data, reply, option);
3898eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3899eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
3900eace7efcSopenharmony_ci        return error;
3901eace7efcSopenharmony_ci    }
3902eace7efcSopenharmony_ci
3903eace7efcSopenharmony_ci    return reply.ReadInt32();
3904eace7efcSopenharmony_ci}
3905eace7efcSopenharmony_ci
3906eace7efcSopenharmony_ciint AbilityManagerProxy::DoAbilityBackground(const sptr<IRemoteObject> &token, uint32_t flag)
3907eace7efcSopenharmony_ci{
3908eace7efcSopenharmony_ci    MessageParcel data;
3909eace7efcSopenharmony_ci    MessageParcel reply;
3910eace7efcSopenharmony_ci    MessageOption option;
3911eace7efcSopenharmony_ci
3912eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3913eace7efcSopenharmony_ci        return INNER_ERR;
3914eace7efcSopenharmony_ci    }
3915eace7efcSopenharmony_ci
3916eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(token)) {
3917eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "data write fail");
3918eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3919eace7efcSopenharmony_ci    }
3920eace7efcSopenharmony_ci
3921eace7efcSopenharmony_ci    if (!data.WriteUint32(flag)) {
3922eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "flag write fail");
3923eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
3924eace7efcSopenharmony_ci    }
3925eace7efcSopenharmony_ci
3926eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::DO_ABILITY_BACKGROUND, data, reply, option);
3927eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3928eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
3929eace7efcSopenharmony_ci        return error;
3930eace7efcSopenharmony_ci    }
3931eace7efcSopenharmony_ci
3932eace7efcSopenharmony_ci    return reply.ReadInt32();
3933eace7efcSopenharmony_ci}
3934eace7efcSopenharmony_ci
3935eace7efcSopenharmony_ciint32_t AbilityManagerProxy::GetMissionIdByToken(const sptr<IRemoteObject> &token)
3936eace7efcSopenharmony_ci{
3937eace7efcSopenharmony_ci    if (!token) {
3938eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "token null");
3939eace7efcSopenharmony_ci        return -1;
3940eace7efcSopenharmony_ci    }
3941eace7efcSopenharmony_ci
3942eace7efcSopenharmony_ci    MessageParcel data;
3943eace7efcSopenharmony_ci    MessageParcel reply;
3944eace7efcSopenharmony_ci    MessageOption option;
3945eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3946eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
3947eace7efcSopenharmony_ci        return -1;
3948eace7efcSopenharmony_ci    }
3949eace7efcSopenharmony_ci
3950eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(token)) {
3951eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "data write fail");
3952eace7efcSopenharmony_ci        return -1;
3953eace7efcSopenharmony_ci    }
3954eace7efcSopenharmony_ci
3955eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::GET_MISSION_ID_BY_ABILITY_TOKEN,
3956eace7efcSopenharmony_ci        data, reply, option);
3957eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3958eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
3959eace7efcSopenharmony_ci        return -1;
3960eace7efcSopenharmony_ci    }
3961eace7efcSopenharmony_ci
3962eace7efcSopenharmony_ci    return reply.ReadInt32();
3963eace7efcSopenharmony_ci}
3964eace7efcSopenharmony_ci
3965eace7efcSopenharmony_ciint AbilityManagerProxy::FreeInstallAbilityFromRemote(const Want &want, const sptr<IRemoteObject> &callback,
3966eace7efcSopenharmony_ci    int32_t userId, int requestCode)
3967eace7efcSopenharmony_ci{
3968eace7efcSopenharmony_ci    MessageParcel data;
3969eace7efcSopenharmony_ci    MessageParcel reply;
3970eace7efcSopenharmony_ci    MessageOption option;
3971eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
3972eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
3973eace7efcSopenharmony_ci        return INNER_ERR;
3974eace7efcSopenharmony_ci    }
3975eace7efcSopenharmony_ci
3976eace7efcSopenharmony_ci    if (!data.WriteParcelable(&want)) {
3977eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "want write fail");
3978eace7efcSopenharmony_ci        return INNER_ERR;
3979eace7efcSopenharmony_ci    }
3980eace7efcSopenharmony_ci
3981eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(callback)) {
3982eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "callback write fail");
3983eace7efcSopenharmony_ci        return INNER_ERR;
3984eace7efcSopenharmony_ci    }
3985eace7efcSopenharmony_ci
3986eace7efcSopenharmony_ci    if (!data.WriteInt32(userId)) {
3987eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "userId write fail");
3988eace7efcSopenharmony_ci        return INNER_ERR;
3989eace7efcSopenharmony_ci    }
3990eace7efcSopenharmony_ci
3991eace7efcSopenharmony_ci    if (!data.WriteInt32(requestCode)) {
3992eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "requestCode write fail");
3993eace7efcSopenharmony_ci        return INNER_ERR;
3994eace7efcSopenharmony_ci    }
3995eace7efcSopenharmony_ci
3996eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::FREE_INSTALL_ABILITY_FROM_REMOTE,
3997eace7efcSopenharmony_ci        data, reply, option);
3998eace7efcSopenharmony_ci    if (error != NO_ERROR) {
3999eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
4000eace7efcSopenharmony_ci        return error;
4001eace7efcSopenharmony_ci    }
4002eace7efcSopenharmony_ci
4003eace7efcSopenharmony_ci    return reply.ReadInt32();
4004eace7efcSopenharmony_ci}
4005eace7efcSopenharmony_ci
4006eace7efcSopenharmony_ciint AbilityManagerProxy::AddFreeInstallObserver(const sptr<IRemoteObject> &callerToken,
4007eace7efcSopenharmony_ci    const sptr<AbilityRuntime::IFreeInstallObserver> &observer)
4008eace7efcSopenharmony_ci{
4009eace7efcSopenharmony_ci    MessageParcel data;
4010eace7efcSopenharmony_ci    MessageParcel reply;
4011eace7efcSopenharmony_ci    MessageOption option;
4012eace7efcSopenharmony_ci    if (observer == nullptr) {
4013eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "null observer");
4014eace7efcSopenharmony_ci        return INNER_ERR;
4015eace7efcSopenharmony_ci    }
4016eace7efcSopenharmony_ci
4017eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4018eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4019eace7efcSopenharmony_ci        return INNER_ERR;
4020eace7efcSopenharmony_ci    }
4021eace7efcSopenharmony_ci
4022eace7efcSopenharmony_ci    if (callerToken) {
4023eace7efcSopenharmony_ci        if (!data.WriteBool(true) || !data.WriteRemoteObject(callerToken)) {
4024eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "write flag and callerToken fail");
4025eace7efcSopenharmony_ci            return INNER_ERR;
4026eace7efcSopenharmony_ci        }
4027eace7efcSopenharmony_ci    } else {
4028eace7efcSopenharmony_ci        if (!data.WriteBool(false)) {
4029eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "write flag fail");
4030eace7efcSopenharmony_ci            return INNER_ERR;
4031eace7efcSopenharmony_ci        }
4032eace7efcSopenharmony_ci    }
4033eace7efcSopenharmony_ci
4034eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(observer->AsObject())) {
4035eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "observer write fail");
4036eace7efcSopenharmony_ci        return INNER_ERR;
4037eace7efcSopenharmony_ci    }
4038eace7efcSopenharmony_ci
4039eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::ADD_FREE_INSTALL_OBSERVER, data, reply, option);
4040eace7efcSopenharmony_ci    if (error != NO_ERROR) {
4041eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
4042eace7efcSopenharmony_ci        return error;
4043eace7efcSopenharmony_ci    }
4044eace7efcSopenharmony_ci    return reply.ReadInt32();
4045eace7efcSopenharmony_ci}
4046eace7efcSopenharmony_ci
4047eace7efcSopenharmony_ciint AbilityManagerProxy::DumpAbilityInfoDone(std::vector<std::string> &infos, const sptr<IRemoteObject> &callerToken)
4048eace7efcSopenharmony_ci{
4049eace7efcSopenharmony_ci    MessageParcel data;
4050eace7efcSopenharmony_ci    MessageParcel reply;
4051eace7efcSopenharmony_ci    MessageOption option;
4052eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4053eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4054eace7efcSopenharmony_ci        return INNER_ERR;
4055eace7efcSopenharmony_ci    }
4056eace7efcSopenharmony_ci
4057eace7efcSopenharmony_ci    if (!data.WriteStringVector(infos)) {
4058eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "infos write fail");
4059eace7efcSopenharmony_ci        return INNER_ERR;
4060eace7efcSopenharmony_ci    }
4061eace7efcSopenharmony_ci
4062eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(callerToken)) {
4063eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "infos write fail");
4064eace7efcSopenharmony_ci        return INNER_ERR;
4065eace7efcSopenharmony_ci    }
4066eace7efcSopenharmony_ci
4067eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::DUMP_ABILITY_INFO_DONE, data, reply, option);
4068eace7efcSopenharmony_ci    if (error != NO_ERROR) {
4069eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
4070eace7efcSopenharmony_ci        return error;
4071eace7efcSopenharmony_ci    }
4072eace7efcSopenharmony_ci
4073eace7efcSopenharmony_ci    return reply.ReadInt32();
4074eace7efcSopenharmony_ci}
4075eace7efcSopenharmony_ci
4076eace7efcSopenharmony_ciint32_t AbilityManagerProxy::IsValidMissionIds(
4077eace7efcSopenharmony_ci    const std::vector<int32_t> &missionIds, std::vector<MissionValidResult> &results)
4078eace7efcSopenharmony_ci{
4079eace7efcSopenharmony_ci    TAG_LOGI(AAFwkTag::ABILITYMGR, "call, quert size:%{public}zu", missionIds.size());
4080eace7efcSopenharmony_ci    MessageParcel data;
4081eace7efcSopenharmony_ci    MessageParcel reply;
4082eace7efcSopenharmony_ci    MessageOption option;
4083eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4084eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4085eace7efcSopenharmony_ci        return INNER_ERR;
4086eace7efcSopenharmony_ci    }
4087eace7efcSopenharmony_ci
4088eace7efcSopenharmony_ci    constexpr int32_t MAX_COUNT = 20;
4089eace7efcSopenharmony_ci    int32_t num = static_cast<int32_t>(missionIds.size() > MAX_COUNT ? MAX_COUNT : missionIds.size());
4090eace7efcSopenharmony_ci    data.WriteInt32(num);
4091eace7efcSopenharmony_ci    for (auto i = 0; i < num; ++i) {
4092eace7efcSopenharmony_ci        data.WriteInt32(missionIds.at(i));
4093eace7efcSopenharmony_ci    }
4094eace7efcSopenharmony_ci
4095eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::QUERY_MISSION_VAILD, data, reply, option);
4096eace7efcSopenharmony_ci    if (error != NO_ERROR) {
4097eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
4098eace7efcSopenharmony_ci        return error;
4099eace7efcSopenharmony_ci    }
4100eace7efcSopenharmony_ci
4101eace7efcSopenharmony_ci    auto resultCode = reply.ReadInt32();
4102eace7efcSopenharmony_ci    if (resultCode != ERR_OK) {
4103eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", resultCode);
4104eace7efcSopenharmony_ci        return resultCode;
4105eace7efcSopenharmony_ci    }
4106eace7efcSopenharmony_ci
4107eace7efcSopenharmony_ci    auto infoSize = reply.ReadInt32();
4108eace7efcSopenharmony_ci    for (auto i = 0; i < infoSize && i < MAX_COUNT; ++i) {
4109eace7efcSopenharmony_ci        std::unique_ptr<MissionValidResult> info(reply.ReadParcelable<MissionValidResult>());
4110eace7efcSopenharmony_ci        if (!info) {
4111eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "read result fail");
4112eace7efcSopenharmony_ci            return INNER_ERR;
4113eace7efcSopenharmony_ci        }
4114eace7efcSopenharmony_ci        results.emplace_back(*info);
4115eace7efcSopenharmony_ci    }
4116eace7efcSopenharmony_ci
4117eace7efcSopenharmony_ci    return resultCode;
4118eace7efcSopenharmony_ci}
4119eace7efcSopenharmony_ci
4120eace7efcSopenharmony_ciint AbilityManagerProxy::VerifyPermission(const std::string &permission, int pid, int uid)
4121eace7efcSopenharmony_ci{
4122eace7efcSopenharmony_ci    TAG_LOGI(AAFwkTag::ABILITYMGR, "call");
4123eace7efcSopenharmony_ci    MessageParcel data;
4124eace7efcSopenharmony_ci    MessageParcel reply;
4125eace7efcSopenharmony_ci    MessageOption option;
4126eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4127eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4128eace7efcSopenharmony_ci        return INNER_ERR;
4129eace7efcSopenharmony_ci    }
4130eace7efcSopenharmony_ci
4131eace7efcSopenharmony_ci    if (!data.WriteString(permission)) {
4132eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "permission write fail");
4133eace7efcSopenharmony_ci        return INNER_ERR;
4134eace7efcSopenharmony_ci    }
4135eace7efcSopenharmony_ci
4136eace7efcSopenharmony_ci    if (!data.WriteInt32(pid)) {
4137eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "pid write fail");
4138eace7efcSopenharmony_ci        return INNER_ERR;
4139eace7efcSopenharmony_ci    }
4140eace7efcSopenharmony_ci
4141eace7efcSopenharmony_ci    if (!data.WriteInt32(uid)) {
4142eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "uid write fail");
4143eace7efcSopenharmony_ci        return INNER_ERR;
4144eace7efcSopenharmony_ci    }
4145eace7efcSopenharmony_ci
4146eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::VERIFY_PERMISSION, data, reply, option);
4147eace7efcSopenharmony_ci    if (error != NO_ERROR) {
4148eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
4149eace7efcSopenharmony_ci        return error;
4150eace7efcSopenharmony_ci    }
4151eace7efcSopenharmony_ci
4152eace7efcSopenharmony_ci    return reply.ReadInt32();
4153eace7efcSopenharmony_ci}
4154eace7efcSopenharmony_ci
4155eace7efcSopenharmony_ciint32_t AbilityManagerProxy::RequestDialogService(const Want &want, const sptr<IRemoteObject> &callerToken)
4156eace7efcSopenharmony_ci{
4157eace7efcSopenharmony_ci    TAG_LOGI(AAFwkTag::ABILITYMGR, "call");
4158eace7efcSopenharmony_ci    if (!callerToken) {
4159eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "callerToken invalid");
4160eace7efcSopenharmony_ci        return ERR_INVALID_CALLER;
4161eace7efcSopenharmony_ci    }
4162eace7efcSopenharmony_ci
4163eace7efcSopenharmony_ci    MessageParcel data;
4164eace7efcSopenharmony_ci    MessageParcel reply;
4165eace7efcSopenharmony_ci    MessageOption option;
4166eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4167eace7efcSopenharmony_ci        return INNER_ERR;
4168eace7efcSopenharmony_ci    }
4169eace7efcSopenharmony_ci
4170eace7efcSopenharmony_ci    if (!data.WriteParcelable(&want)) {
4171eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "want write fail");
4172eace7efcSopenharmony_ci        return INNER_ERR;
4173eace7efcSopenharmony_ci    }
4174eace7efcSopenharmony_ci
4175eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(callerToken)) {
4176eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "infos write fail");
4177eace7efcSopenharmony_ci        return INNER_ERR;
4178eace7efcSopenharmony_ci    }
4179eace7efcSopenharmony_ci
4180eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::REQUEST_DIALOG_SERVICE, data, reply, option);
4181eace7efcSopenharmony_ci    if (error != NO_ERROR) {
4182eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
4183eace7efcSopenharmony_ci        return error;
4184eace7efcSopenharmony_ci    }
4185eace7efcSopenharmony_ci    return reply.ReadInt32();
4186eace7efcSopenharmony_ci}
4187eace7efcSopenharmony_ci
4188eace7efcSopenharmony_ciint32_t AbilityManagerProxy::ReportDrawnCompleted(const sptr<IRemoteObject> &callerToken)
4189eace7efcSopenharmony_ci{
4190eace7efcSopenharmony_ci    TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
4191eace7efcSopenharmony_ci    if (callerToken == nullptr) {
4192eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "null callerToken");
4193eace7efcSopenharmony_ci        return INNER_ERR;
4194eace7efcSopenharmony_ci    }
4195eace7efcSopenharmony_ci
4196eace7efcSopenharmony_ci    MessageParcel data;
4197eace7efcSopenharmony_ci    MessageParcel reply;
4198eace7efcSopenharmony_ci    MessageOption option;
4199eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4200eace7efcSopenharmony_ci        return INNER_ERR;
4201eace7efcSopenharmony_ci    }
4202eace7efcSopenharmony_ci
4203eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(callerToken)) {
4204eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "callerToken write fail");
4205eace7efcSopenharmony_ci        return INNER_ERR;
4206eace7efcSopenharmony_ci    }
4207eace7efcSopenharmony_ci
4208eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::REPORT_DRAWN_COMPLETED, data, reply, option);
4209eace7efcSopenharmony_ci    if (error != NO_ERROR) {
4210eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
4211eace7efcSopenharmony_ci        return error;
4212eace7efcSopenharmony_ci    }
4213eace7efcSopenharmony_ci    return reply.ReadInt32();
4214eace7efcSopenharmony_ci}
4215eace7efcSopenharmony_ci
4216eace7efcSopenharmony_ciint32_t AbilityManagerProxy::AcquireShareData(
4217eace7efcSopenharmony_ci    const int32_t &missionId, const sptr<IAcquireShareDataCallback> &shareData)
4218eace7efcSopenharmony_ci{
4219eace7efcSopenharmony_ci    TAG_LOGI(AAFwkTag::ABILITYMGR, "start");
4220eace7efcSopenharmony_ci    MessageParcel data;
4221eace7efcSopenharmony_ci    MessageParcel reply;
4222eace7efcSopenharmony_ci    MessageOption option;
4223eace7efcSopenharmony_ci
4224eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4225eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4226eace7efcSopenharmony_ci        return INNER_ERR;
4227eace7efcSopenharmony_ci    }
4228eace7efcSopenharmony_ci
4229eace7efcSopenharmony_ci    if (!data.WriteInt32(missionId)) {
4230eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "missionId write fail");
4231eace7efcSopenharmony_ci        return INNER_ERR;
4232eace7efcSopenharmony_ci    }
4233eace7efcSopenharmony_ci
4234eace7efcSopenharmony_ci    if (shareData == nullptr || !data.WriteRemoteObject(shareData->AsObject())) {
4235eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "shareData write fail");
4236eace7efcSopenharmony_ci        return INNER_ERR;
4237eace7efcSopenharmony_ci    }
4238eace7efcSopenharmony_ci
4239eace7efcSopenharmony_ci    int32_t error = SendRequest(AbilityManagerInterfaceCode::ACQUIRE_SHARE_DATA, data, reply, option);
4240eace7efcSopenharmony_ci    if (error != NO_ERROR) {
4241eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error: %{public}d", error);
4242eace7efcSopenharmony_ci        return INNER_ERR;
4243eace7efcSopenharmony_ci    }
4244eace7efcSopenharmony_ci    TAG_LOGI(AAFwkTag::ABILITYMGR, "end");
4245eace7efcSopenharmony_ci    return reply.ReadInt32();
4246eace7efcSopenharmony_ci}
4247eace7efcSopenharmony_ci
4248eace7efcSopenharmony_ciint32_t AbilityManagerProxy::ShareDataDone(
4249eace7efcSopenharmony_ci    const sptr<IRemoteObject> &token, const int32_t &resultCode, const int32_t &uniqueId, WantParams &wantParam)
4250eace7efcSopenharmony_ci{
4251eace7efcSopenharmony_ci    TAG_LOGI(AAFwkTag::ABILITYMGR, "start");
4252eace7efcSopenharmony_ci    MessageParcel data;
4253eace7efcSopenharmony_ci    MessageParcel reply;
4254eace7efcSopenharmony_ci    MessageOption option(MessageOption::TF_ASYNC);
4255eace7efcSopenharmony_ci
4256eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4257eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4258eace7efcSopenharmony_ci        return INNER_ERR;
4259eace7efcSopenharmony_ci    }
4260eace7efcSopenharmony_ci
4261eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(token)) {
4262eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "token write fail");
4263eace7efcSopenharmony_ci        return INNER_ERR;
4264eace7efcSopenharmony_ci    }
4265eace7efcSopenharmony_ci
4266eace7efcSopenharmony_ci    if (!data.WriteInt32(resultCode)) {
4267eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "requestCode write fail");
4268eace7efcSopenharmony_ci        return INNER_ERR;
4269eace7efcSopenharmony_ci    }
4270eace7efcSopenharmony_ci
4271eace7efcSopenharmony_ci    if (!data.WriteInt32(uniqueId)) {
4272eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "uniqueId write fail");
4273eace7efcSopenharmony_ci        return INNER_ERR;
4274eace7efcSopenharmony_ci    }
4275eace7efcSopenharmony_ci
4276eace7efcSopenharmony_ci    if (!data.WriteParcelable(&wantParam)) {
4277eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "wantParam write fail");
4278eace7efcSopenharmony_ci        return INNER_ERR;
4279eace7efcSopenharmony_ci    }
4280eace7efcSopenharmony_ci
4281eace7efcSopenharmony_ci    int32_t error = SendRequest(AbilityManagerInterfaceCode::SHARE_DATA_DONE, data, reply, option);
4282eace7efcSopenharmony_ci    if (error != NO_ERROR) {
4283eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request err: %{public}d", error);
4284eace7efcSopenharmony_ci        return error;
4285eace7efcSopenharmony_ci    }
4286eace7efcSopenharmony_ci    TAG_LOGI(AAFwkTag::ABILITYMGR, "end");
4287eace7efcSopenharmony_ci    return reply.ReadInt32();
4288eace7efcSopenharmony_ci}
4289eace7efcSopenharmony_ci
4290eace7efcSopenharmony_ciint32_t AbilityManagerProxy::ForceExitApp(const int32_t pid, const ExitReason &exitReason)
4291eace7efcSopenharmony_ci{
4292eace7efcSopenharmony_ci    TAG_LOGD(AAFwkTag::ABILITYMGR, "start.");
4293eace7efcSopenharmony_ci    MessageParcel data;
4294eace7efcSopenharmony_ci    MessageParcel reply;
4295eace7efcSopenharmony_ci    MessageOption option(MessageOption::TF_ASYNC);
4296eace7efcSopenharmony_ci
4297eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4298eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4299eace7efcSopenharmony_ci        return INNER_ERR;
4300eace7efcSopenharmony_ci    }
4301eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Int32, pid);
4302eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Parcelable, &exitReason);
4303eace7efcSopenharmony_ci
4304eace7efcSopenharmony_ci    int32_t error = SendRequest(AbilityManagerInterfaceCode::FORCE_EXIT_APP, data, reply, option);
4305eace7efcSopenharmony_ci    if (error != NO_ERROR) {
4306eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request err:%{public}d", error);
4307eace7efcSopenharmony_ci        return error;
4308eace7efcSopenharmony_ci    }
4309eace7efcSopenharmony_ci
4310eace7efcSopenharmony_ci    TAG_LOGD(AAFwkTag::ABILITYMGR, "end.");
4311eace7efcSopenharmony_ci    return reply.ReadInt32();
4312eace7efcSopenharmony_ci}
4313eace7efcSopenharmony_ci
4314eace7efcSopenharmony_ciint32_t AbilityManagerProxy::RecordAppExitReason(const ExitReason &exitReason)
4315eace7efcSopenharmony_ci{
4316eace7efcSopenharmony_ci    TAG_LOGD(AAFwkTag::ABILITYMGR, "start.");
4317eace7efcSopenharmony_ci    MessageParcel data;
4318eace7efcSopenharmony_ci    MessageParcel reply;
4319eace7efcSopenharmony_ci    MessageOption option;
4320eace7efcSopenharmony_ci
4321eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4322eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write interface token fail");
4323eace7efcSopenharmony_ci        return INNER_ERR;
4324eace7efcSopenharmony_ci    }
4325eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Parcelable, &exitReason);
4326eace7efcSopenharmony_ci
4327eace7efcSopenharmony_ci    int32_t error = SendRequest(AbilityManagerInterfaceCode::RECORD_APP_EXIT_REASON, data, reply, option);
4328eace7efcSopenharmony_ci    if (error != NO_ERROR) {
4329eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request err:%{public}d", error);
4330eace7efcSopenharmony_ci        return error;
4331eace7efcSopenharmony_ci    }
4332eace7efcSopenharmony_ci
4333eace7efcSopenharmony_ci    TAG_LOGD(AAFwkTag::ABILITYMGR, "end.");
4334eace7efcSopenharmony_ci    return reply.ReadInt32();
4335eace7efcSopenharmony_ci}
4336eace7efcSopenharmony_ci
4337eace7efcSopenharmony_ciint32_t AbilityManagerProxy::RecordProcessExitReason(const int32_t pid, const ExitReason &exitReason)
4338eace7efcSopenharmony_ci{
4339eace7efcSopenharmony_ci    TAG_LOGD(AAFwkTag::ABILITYMGR, "start.");
4340eace7efcSopenharmony_ci    MessageParcel data;
4341eace7efcSopenharmony_ci    MessageParcel reply;
4342eace7efcSopenharmony_ci    MessageOption option;
4343eace7efcSopenharmony_ci
4344eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4345eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4346eace7efcSopenharmony_ci        return INNER_ERR;
4347eace7efcSopenharmony_ci    }
4348eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Int32, pid);
4349eace7efcSopenharmony_ci    PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Parcelable, &exitReason);
4350eace7efcSopenharmony_ci
4351eace7efcSopenharmony_ci    int32_t error = SendRequest(AbilityManagerInterfaceCode::RECORD_PROCESS_EXIT_REASON, data, reply, option);
4352eace7efcSopenharmony_ci    if (error != NO_ERROR) {
4353eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request err:%{public}d", error);
4354eace7efcSopenharmony_ci        return error;
4355eace7efcSopenharmony_ci    }
4356eace7efcSopenharmony_ci
4357eace7efcSopenharmony_ci    TAG_LOGD(AAFwkTag::ABILITYMGR, "end.");
4358eace7efcSopenharmony_ci    return reply.ReadInt32();
4359eace7efcSopenharmony_ci}
4360eace7efcSopenharmony_ci
4361eace7efcSopenharmony_civoid AbilityManagerProxy::SetRootSceneSession(const sptr<IRemoteObject> &rootSceneSession)
4362eace7efcSopenharmony_ci{
4363eace7efcSopenharmony_ci    MessageParcel data;
4364eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4365eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4366eace7efcSopenharmony_ci        return;
4367eace7efcSopenharmony_ci    }
4368eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(rootSceneSession)) {
4369eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write object fail");
4370eace7efcSopenharmony_ci        return;
4371eace7efcSopenharmony_ci    }
4372eace7efcSopenharmony_ci
4373eace7efcSopenharmony_ci    MessageParcel reply;
4374eace7efcSopenharmony_ci    MessageOption option(MessageOption::TF_ASYNC);
4375eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::SET_ROOT_SCENE_SESSION, data, reply, option);
4376eace7efcSopenharmony_ci    if (error != NO_ERROR) {
4377eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
4378eace7efcSopenharmony_ci    }
4379eace7efcSopenharmony_ci}
4380eace7efcSopenharmony_ci
4381eace7efcSopenharmony_civoid AbilityManagerProxy::CallUIAbilityBySCB(const sptr<SessionInfo> &sessionInfo, bool &isColdStart)
4382eace7efcSopenharmony_ci{
4383eace7efcSopenharmony_ci    MessageParcel data;
4384eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4385eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4386eace7efcSopenharmony_ci        return;
4387eace7efcSopenharmony_ci    }
4388eace7efcSopenharmony_ci    if (sessionInfo) {
4389eace7efcSopenharmony_ci        if (!data.WriteBool(true) || !data.WriteParcelable(sessionInfo)) {
4390eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag and sessionInfo write fail");
4391eace7efcSopenharmony_ci            return;
4392eace7efcSopenharmony_ci        }
4393eace7efcSopenharmony_ci    } else {
4394eace7efcSopenharmony_ci        if (!data.WriteBool(false)) {
4395eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag write fail");
4396eace7efcSopenharmony_ci            return;
4397eace7efcSopenharmony_ci        }
4398eace7efcSopenharmony_ci    }
4399eace7efcSopenharmony_ci
4400eace7efcSopenharmony_ci    MessageParcel reply;
4401eace7efcSopenharmony_ci    MessageOption option;
4402eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::CALL_ABILITY_BY_SCB, data, reply, option);
4403eace7efcSopenharmony_ci    if (error != NO_ERROR) {
4404eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
4405eace7efcSopenharmony_ci        return;
4406eace7efcSopenharmony_ci    }
4407eace7efcSopenharmony_ci    isColdStart = reply.ReadBool();
4408eace7efcSopenharmony_ci}
4409eace7efcSopenharmony_ci
4410eace7efcSopenharmony_civoid AbilityManagerProxy::StartSpecifiedAbilityBySCB(const Want &want)
4411eace7efcSopenharmony_ci{
4412eace7efcSopenharmony_ci    MessageParcel data;
4413eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4414eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4415eace7efcSopenharmony_ci        return;
4416eace7efcSopenharmony_ci    }
4417eace7efcSopenharmony_ci
4418eace7efcSopenharmony_ci    if (!data.WriteParcelable(&want)) {
4419eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "want write fail");
4420eace7efcSopenharmony_ci        return;
4421eace7efcSopenharmony_ci    }
4422eace7efcSopenharmony_ci
4423eace7efcSopenharmony_ci    MessageParcel reply;
4424eace7efcSopenharmony_ci    MessageOption option(MessageOption::TF_ASYNC);
4425eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::START_SPECIFIED_ABILITY_BY_SCB, data, reply, option);
4426eace7efcSopenharmony_ci    if (error != NO_ERROR) {
4427eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
4428eace7efcSopenharmony_ci    }
4429eace7efcSopenharmony_ci}
4430eace7efcSopenharmony_ci
4431eace7efcSopenharmony_ciint32_t AbilityManagerProxy::NotifySaveAsResult(const Want &want, int resultCode, int requestCode)
4432eace7efcSopenharmony_ci{
4433eace7efcSopenharmony_ci    MessageParcel data;
4434eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4435eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4436eace7efcSopenharmony_ci        return INNER_ERR;
4437eace7efcSopenharmony_ci    }
4438eace7efcSopenharmony_ci    if (!data.WriteParcelable(&want)) {
4439eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "writeWantObject fail");
4440eace7efcSopenharmony_ci        return INNER_ERR;
4441eace7efcSopenharmony_ci    }
4442eace7efcSopenharmony_ci
4443eace7efcSopenharmony_ci    if (!data.WriteInt32(resultCode)) {
4444eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "resultCode write fail");
4445eace7efcSopenharmony_ci        return INNER_ERR;
4446eace7efcSopenharmony_ci    }
4447eace7efcSopenharmony_ci
4448eace7efcSopenharmony_ci    if (!data.WriteInt32(requestCode)) {
4449eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "requestCode write fail");
4450eace7efcSopenharmony_ci        return INNER_ERR;
4451eace7efcSopenharmony_ci    }
4452eace7efcSopenharmony_ci
4453eace7efcSopenharmony_ci    MessageParcel reply;
4454eace7efcSopenharmony_ci    MessageOption option;
4455eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::NOTIFY_SAVE_AS_RESULT, data, reply, option);
4456eace7efcSopenharmony_ci    if (error != NO_ERROR) {
4457eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
4458eace7efcSopenharmony_ci    }
4459eace7efcSopenharmony_ci
4460eace7efcSopenharmony_ci    return reply.ReadInt32();
4461eace7efcSopenharmony_ci}
4462eace7efcSopenharmony_ci
4463eace7efcSopenharmony_ciint32_t AbilityManagerProxy::SetSessionManagerService(const sptr<IRemoteObject> &sessionManagerService)
4464eace7efcSopenharmony_ci{
4465eace7efcSopenharmony_ci    TAG_LOGI(AAFwkTag::ABILITYMGR, "start");
4466eace7efcSopenharmony_ci    MessageParcel data;
4467eace7efcSopenharmony_ci    MessageParcel reply;
4468eace7efcSopenharmony_ci    MessageOption option;
4469eace7efcSopenharmony_ci
4470eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4471eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4472eace7efcSopenharmony_ci        return INNER_ERR;
4473eace7efcSopenharmony_ci    }
4474eace7efcSopenharmony_ci
4475eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(sessionManagerService)) {
4476eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "token write fail");
4477eace7efcSopenharmony_ci        return INNER_ERR;
4478eace7efcSopenharmony_ci    }
4479eace7efcSopenharmony_ci
4480eace7efcSopenharmony_ci    int32_t error = SendRequest(AbilityManagerInterfaceCode::SET_SESSIONMANAGERSERVICE, data, reply, option);
4481eace7efcSopenharmony_ci    if (error != NO_ERROR) {
4482eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
4483eace7efcSopenharmony_ci        return error;
4484eace7efcSopenharmony_ci    }
4485eace7efcSopenharmony_ci    TAG_LOGI(AAFwkTag::ABILITYMGR, "end");
4486eace7efcSopenharmony_ci    return reply.ReadInt32();
4487eace7efcSopenharmony_ci}
4488eace7efcSopenharmony_ci
4489eace7efcSopenharmony_ciint32_t AbilityManagerProxy::RegisterIAbilityManagerCollaborator(
4490eace7efcSopenharmony_ci    int32_t type, const sptr<IAbilityManagerCollaborator> &impl)
4491eace7efcSopenharmony_ci{
4492eace7efcSopenharmony_ci    if (!impl) {
4493eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "null impl");
4494eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
4495eace7efcSopenharmony_ci    }
4496eace7efcSopenharmony_ci    MessageParcel data;
4497eace7efcSopenharmony_ci    MessageParcel reply;
4498eace7efcSopenharmony_ci    MessageOption option;
4499eace7efcSopenharmony_ci
4500eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4501eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4502eace7efcSopenharmony_ci        return INNER_ERR;
4503eace7efcSopenharmony_ci    }
4504eace7efcSopenharmony_ci    if (!data.WriteInt32(type)) {
4505eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "type write fail");
4506eace7efcSopenharmony_ci        return INNER_ERR;
4507eace7efcSopenharmony_ci    }
4508eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(impl->AsObject())) {
4509eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "impl write fail");
4510eace7efcSopenharmony_ci        return INNER_ERR;
4511eace7efcSopenharmony_ci    }
4512eace7efcSopenharmony_ci
4513eace7efcSopenharmony_ci    auto ret = SendRequest(AbilityManagerInterfaceCode::REGISTER_COLLABORATOR, data, reply, option);
4514eace7efcSopenharmony_ci    if (ret != NO_ERROR) {
4515eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", ret);
4516eace7efcSopenharmony_ci        return ret;
4517eace7efcSopenharmony_ci    }
4518eace7efcSopenharmony_ci    return reply.ReadInt32();
4519eace7efcSopenharmony_ci}
4520eace7efcSopenharmony_ci
4521eace7efcSopenharmony_ciint32_t AbilityManagerProxy::UnregisterIAbilityManagerCollaborator(int32_t type)
4522eace7efcSopenharmony_ci{
4523eace7efcSopenharmony_ci    MessageParcel data;
4524eace7efcSopenharmony_ci    MessageParcel reply;
4525eace7efcSopenharmony_ci    MessageOption option;
4526eace7efcSopenharmony_ci
4527eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4528eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4529eace7efcSopenharmony_ci        return INNER_ERR;
4530eace7efcSopenharmony_ci    }
4531eace7efcSopenharmony_ci    if (!data.WriteInt32(type)) {
4532eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "type write fail");
4533eace7efcSopenharmony_ci        return INNER_ERR;
4534eace7efcSopenharmony_ci    }
4535eace7efcSopenharmony_ci
4536eace7efcSopenharmony_ci    auto ret = SendRequest(AbilityManagerInterfaceCode::UNREGISTER_COLLABORATOR, data, reply, option);
4537eace7efcSopenharmony_ci    if (ret != NO_ERROR) {
4538eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", ret);
4539eace7efcSopenharmony_ci        return ret;
4540eace7efcSopenharmony_ci    }
4541eace7efcSopenharmony_ci    return reply.ReadInt32();
4542eace7efcSopenharmony_ci}
4543eace7efcSopenharmony_ci
4544eace7efcSopenharmony_ciint32_t AbilityManagerProxy::RegisterStatusBarDelegate(sptr<AbilityRuntime::IStatusBarDelegate> delegate)
4545eace7efcSopenharmony_ci{
4546eace7efcSopenharmony_ci    MessageParcel data;
4547eace7efcSopenharmony_ci    MessageParcel reply;
4548eace7efcSopenharmony_ci    MessageOption option;
4549eace7efcSopenharmony_ci
4550eace7efcSopenharmony_ci    if (delegate == nullptr) {
4551eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "null delegate");
4552eace7efcSopenharmony_ci        return ERR_NULL_OBJECT;
4553eace7efcSopenharmony_ci    }
4554eace7efcSopenharmony_ci
4555eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4556eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4557eace7efcSopenharmony_ci        return ERR_NATIVE_IPC_PARCEL_FAILED;
4558eace7efcSopenharmony_ci    }
4559eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(delegate->AsObject())) {
4560eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write delegate fail");
4561eace7efcSopenharmony_ci        return ERR_NATIVE_IPC_PARCEL_FAILED;
4562eace7efcSopenharmony_ci    }
4563eace7efcSopenharmony_ci
4564eace7efcSopenharmony_ci    auto ret = SendRequest(AbilityManagerInterfaceCode::REGISTER_STATUS_BAR_DELEGATE, data, reply, option);
4565eace7efcSopenharmony_ci    if (ret != NO_ERROR) {
4566eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", ret);
4567eace7efcSopenharmony_ci        return ret;
4568eace7efcSopenharmony_ci    }
4569eace7efcSopenharmony_ci    return reply.ReadInt32();
4570eace7efcSopenharmony_ci}
4571eace7efcSopenharmony_ci
4572eace7efcSopenharmony_ciint32_t AbilityManagerProxy::KillProcessWithPrepareTerminate(const std::vector<int32_t>& pids)
4573eace7efcSopenharmony_ci{
4574eace7efcSopenharmony_ci    MessageParcel data;
4575eace7efcSopenharmony_ci    MessageParcel reply;
4576eace7efcSopenharmony_ci    MessageOption option(MessageOption::TF_ASYNC);
4577eace7efcSopenharmony_ci
4578eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4579eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4580eace7efcSopenharmony_ci        return ERR_NATIVE_IPC_PARCEL_FAILED;
4581eace7efcSopenharmony_ci    }
4582eace7efcSopenharmony_ci    if (!data.WriteUint32(pids.size())) {
4583eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write size fail");
4584eace7efcSopenharmony_ci        return ERR_NATIVE_IPC_PARCEL_FAILED;
4585eace7efcSopenharmony_ci    }
4586eace7efcSopenharmony_ci    for (const auto &pid : pids) {
4587eace7efcSopenharmony_ci        if (!data.WriteInt32(pid)) {
4588eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "write pid fail");
4589eace7efcSopenharmony_ci            return ERR_NATIVE_IPC_PARCEL_FAILED;
4590eace7efcSopenharmony_ci        }
4591eace7efcSopenharmony_ci    }
4592eace7efcSopenharmony_ci
4593eace7efcSopenharmony_ci    auto ret = SendRequest(AbilityManagerInterfaceCode::KILL_PROCESS_WITH_PREPARE_TERMINATE, data, reply, option);
4594eace7efcSopenharmony_ci    if (ret != NO_ERROR) {
4595eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", ret);
4596eace7efcSopenharmony_ci    }
4597eace7efcSopenharmony_ci    return ret;
4598eace7efcSopenharmony_ci}
4599eace7efcSopenharmony_ci
4600eace7efcSopenharmony_ciint32_t AbilityManagerProxy::RegisterAutoStartupSystemCallback(const sptr<IRemoteObject> &callback)
4601eace7efcSopenharmony_ci{
4602eace7efcSopenharmony_ci    MessageParcel data;
4603eace7efcSopenharmony_ci    MessageParcel reply;
4604eace7efcSopenharmony_ci    MessageOption option;
4605eace7efcSopenharmony_ci
4606eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4607eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4608eace7efcSopenharmony_ci        return INNER_ERR;
4609eace7efcSopenharmony_ci    }
4610eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(callback)) {
4611eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "callback write fail");
4612eace7efcSopenharmony_ci        return INNER_ERR;
4613eace7efcSopenharmony_ci    }
4614eace7efcSopenharmony_ci
4615eace7efcSopenharmony_ci    auto ret = SendRequest(AbilityManagerInterfaceCode::REGISTER_AUTO_STARTUP_SYSTEM_CALLBACK, data, reply, option);
4616eace7efcSopenharmony_ci    if (ret != NO_ERROR) {
4617eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", ret);
4618eace7efcSopenharmony_ci        return ret;
4619eace7efcSopenharmony_ci    }
4620eace7efcSopenharmony_ci    return reply.ReadInt32();
4621eace7efcSopenharmony_ci}
4622eace7efcSopenharmony_ci
4623eace7efcSopenharmony_ciint32_t AbilityManagerProxy::UnregisterAutoStartupSystemCallback(const sptr<IRemoteObject> &callback)
4624eace7efcSopenharmony_ci{
4625eace7efcSopenharmony_ci    MessageParcel data;
4626eace7efcSopenharmony_ci    MessageParcel reply;
4627eace7efcSopenharmony_ci    MessageOption option;
4628eace7efcSopenharmony_ci
4629eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4630eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4631eace7efcSopenharmony_ci        return INNER_ERR;
4632eace7efcSopenharmony_ci    }
4633eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(callback)) {
4634eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "callback write fail");
4635eace7efcSopenharmony_ci        return INNER_ERR;
4636eace7efcSopenharmony_ci    }
4637eace7efcSopenharmony_ci
4638eace7efcSopenharmony_ci    auto ret = SendRequest(AbilityManagerInterfaceCode::UNREGISTER_AUTO_STARTUP_SYSTEM_CALLBACK, data, reply, option);
4639eace7efcSopenharmony_ci    if (ret != NO_ERROR) {
4640eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", ret);
4641eace7efcSopenharmony_ci        return ret;
4642eace7efcSopenharmony_ci    }
4643eace7efcSopenharmony_ci    return reply.ReadInt32();
4644eace7efcSopenharmony_ci}
4645eace7efcSopenharmony_ci
4646eace7efcSopenharmony_ciint32_t AbilityManagerProxy::SetApplicationAutoStartup(const AutoStartupInfo &info)
4647eace7efcSopenharmony_ci{
4648eace7efcSopenharmony_ci    MessageParcel data;
4649eace7efcSopenharmony_ci    MessageParcel reply;
4650eace7efcSopenharmony_ci    MessageOption option;
4651eace7efcSopenharmony_ci
4652eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4653eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4654eace7efcSopenharmony_ci        return INNER_ERR;
4655eace7efcSopenharmony_ci    }
4656eace7efcSopenharmony_ci    if (!data.WriteParcelable(&info)) {
4657eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write autoStartupInfo fail");
4658eace7efcSopenharmony_ci        return INNER_ERR;
4659eace7efcSopenharmony_ci    }
4660eace7efcSopenharmony_ci
4661eace7efcSopenharmony_ci    auto ret = SendRequest(AbilityManagerInterfaceCode::SET_APPLICATION_AUTO_STARTUP, data, reply, option);
4662eace7efcSopenharmony_ci    if (ret != NO_ERROR) {
4663eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", ret);
4664eace7efcSopenharmony_ci        return ret;
4665eace7efcSopenharmony_ci    }
4666eace7efcSopenharmony_ci    return reply.ReadInt32();
4667eace7efcSopenharmony_ci}
4668eace7efcSopenharmony_ci
4669eace7efcSopenharmony_ciint32_t AbilityManagerProxy::CancelApplicationAutoStartup(const AutoStartupInfo &info)
4670eace7efcSopenharmony_ci{
4671eace7efcSopenharmony_ci    MessageParcel data;
4672eace7efcSopenharmony_ci    MessageParcel reply;
4673eace7efcSopenharmony_ci    MessageOption option;
4674eace7efcSopenharmony_ci
4675eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4676eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4677eace7efcSopenharmony_ci        return INNER_ERR;
4678eace7efcSopenharmony_ci    }
4679eace7efcSopenharmony_ci    if (!data.WriteParcelable(&info)) {
4680eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write autoStartupInfo fail");
4681eace7efcSopenharmony_ci        return INNER_ERR;
4682eace7efcSopenharmony_ci    }
4683eace7efcSopenharmony_ci
4684eace7efcSopenharmony_ci    auto ret = SendRequest(AbilityManagerInterfaceCode::CANCEL_APPLICATION_AUTO_STARTUP, data, reply, option);
4685eace7efcSopenharmony_ci    if (ret != NO_ERROR) {
4686eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", ret);
4687eace7efcSopenharmony_ci        return ret;
4688eace7efcSopenharmony_ci    }
4689eace7efcSopenharmony_ci    return reply.ReadInt32();
4690eace7efcSopenharmony_ci}
4691eace7efcSopenharmony_ci
4692eace7efcSopenharmony_ciint32_t AbilityManagerProxy::QueryAllAutoStartupApplications(std::vector<AutoStartupInfo> &infoList)
4693eace7efcSopenharmony_ci{
4694eace7efcSopenharmony_ci    MessageParcel data;
4695eace7efcSopenharmony_ci    MessageParcel reply;
4696eace7efcSopenharmony_ci    MessageOption option;
4697eace7efcSopenharmony_ci
4698eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4699eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4700eace7efcSopenharmony_ci        return INNER_ERR;
4701eace7efcSopenharmony_ci    }
4702eace7efcSopenharmony_ci
4703eace7efcSopenharmony_ci    auto ret = SendRequest(AbilityManagerInterfaceCode::QUERY_ALL_AUTO_STARTUP_APPLICATION, data, reply, option);
4704eace7efcSopenharmony_ci    if (ret != NO_ERROR) {
4705eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "send request error:%{public}d", ret);
4706eace7efcSopenharmony_ci        return ret;
4707eace7efcSopenharmony_ci    }
4708eace7efcSopenharmony_ci
4709eace7efcSopenharmony_ci    auto resultCode = reply.ReadInt32();
4710eace7efcSopenharmony_ci    if (resultCode != ERR_OK) {
4711eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "reply error:%{public}d", resultCode);
4712eace7efcSopenharmony_ci        return resultCode;
4713eace7efcSopenharmony_ci    }
4714eace7efcSopenharmony_ci
4715eace7efcSopenharmony_ci    auto infoSize = reply.ReadInt32();
4716eace7efcSopenharmony_ci    for (auto i = 0; i < infoSize && i < MAX_AUTO_STARTUP_COUNT; ++i) {
4717eace7efcSopenharmony_ci        std::unique_ptr<AutoStartupInfo> info(reply.ReadParcelable<AutoStartupInfo>());
4718eace7efcSopenharmony_ci        if (!info) {
4719eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "read result fail");
4720eace7efcSopenharmony_ci            return INNER_ERR;
4721eace7efcSopenharmony_ci        }
4722eace7efcSopenharmony_ci        infoList.emplace_back(*info);
4723eace7efcSopenharmony_ci    }
4724eace7efcSopenharmony_ci    return ERR_OK;
4725eace7efcSopenharmony_ci}
4726eace7efcSopenharmony_ci
4727eace7efcSopenharmony_ciint AbilityManagerProxy::PrepareTerminateAbilityBySCB(const sptr<SessionInfo> &sessionInfo, bool &isPrepareTerminate)
4728eace7efcSopenharmony_ci{
4729eace7efcSopenharmony_ci    MessageParcel data;
4730eace7efcSopenharmony_ci    MessageParcel reply;
4731eace7efcSopenharmony_ci    MessageOption option;
4732eace7efcSopenharmony_ci
4733eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4734eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4735eace7efcSopenharmony_ci        return INNER_ERR;
4736eace7efcSopenharmony_ci    }
4737eace7efcSopenharmony_ci    if (sessionInfo) {
4738eace7efcSopenharmony_ci        if (!data.WriteBool(true) || !data.WriteParcelable(sessionInfo)) {
4739eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag and sessionInfo write fail");
4740eace7efcSopenharmony_ci            return INNER_ERR;
4741eace7efcSopenharmony_ci        }
4742eace7efcSopenharmony_ci    } else {
4743eace7efcSopenharmony_ci        if (!data.WriteBool(false)) {
4744eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag write fail");
4745eace7efcSopenharmony_ci            return INNER_ERR;
4746eace7efcSopenharmony_ci        }
4747eace7efcSopenharmony_ci    }
4748eace7efcSopenharmony_ci
4749eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::PREPARE_TERMINATE_ABILITY_BY_SCB,
4750eace7efcSopenharmony_ci        data, reply, option);
4751eace7efcSopenharmony_ci    if (error != NO_ERROR) {
4752eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
4753eace7efcSopenharmony_ci        return error;
4754eace7efcSopenharmony_ci    }
4755eace7efcSopenharmony_ci
4756eace7efcSopenharmony_ci    isPrepareTerminate = reply.ReadBool();
4757eace7efcSopenharmony_ci    return NO_ERROR;
4758eace7efcSopenharmony_ci}
4759eace7efcSopenharmony_ci
4760eace7efcSopenharmony_ciint32_t AbilityManagerProxy::RegisterAppDebugListener(sptr<AppExecFwk::IAppDebugListener> listener)
4761eace7efcSopenharmony_ci{
4762eace7efcSopenharmony_ci    TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
4763eace7efcSopenharmony_ci    MessageParcel data;
4764eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4765eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4766eace7efcSopenharmony_ci        return INNER_ERR;
4767eace7efcSopenharmony_ci    }
4768eace7efcSopenharmony_ci
4769eace7efcSopenharmony_ci    if (listener == nullptr || !data.WriteRemoteObject(listener->AsObject())) {
4770eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write listener fail");
4771eace7efcSopenharmony_ci        return INNER_ERR;
4772eace7efcSopenharmony_ci    }
4773eace7efcSopenharmony_ci
4774eace7efcSopenharmony_ci    MessageParcel reply;
4775eace7efcSopenharmony_ci    MessageOption option(MessageOption::TF_SYNC);
4776eace7efcSopenharmony_ci    int32_t error = SendRequest(AbilityManagerInterfaceCode::REGISTER_APP_DEBUG_LISTENER, data, reply, option);
4777eace7efcSopenharmony_ci    if (error != NO_ERROR) {
4778eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request err:%{public}d", error);
4779eace7efcSopenharmony_ci        return error;
4780eace7efcSopenharmony_ci    }
4781eace7efcSopenharmony_ci    return reply.ReadInt32();
4782eace7efcSopenharmony_ci}
4783eace7efcSopenharmony_ci
4784eace7efcSopenharmony_ciint32_t AbilityManagerProxy::UnregisterAppDebugListener(sptr<AppExecFwk::IAppDebugListener> listener)
4785eace7efcSopenharmony_ci{
4786eace7efcSopenharmony_ci    TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
4787eace7efcSopenharmony_ci    MessageParcel data;
4788eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4789eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4790eace7efcSopenharmony_ci        return INNER_ERR;
4791eace7efcSopenharmony_ci    }
4792eace7efcSopenharmony_ci
4793eace7efcSopenharmony_ci    if (listener == nullptr || !data.WriteRemoteObject(listener->AsObject())) {
4794eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write listener fail");
4795eace7efcSopenharmony_ci        return INNER_ERR;
4796eace7efcSopenharmony_ci    }
4797eace7efcSopenharmony_ci
4798eace7efcSopenharmony_ci    MessageParcel reply;
4799eace7efcSopenharmony_ci    MessageOption option(MessageOption::TF_SYNC);
4800eace7efcSopenharmony_ci    int32_t error = SendRequest(AbilityManagerInterfaceCode::UNREGISTER_APP_DEBUG_LISTENER, data, reply, option);
4801eace7efcSopenharmony_ci    if (error != NO_ERROR) {
4802eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request err:%{public}d", error);
4803eace7efcSopenharmony_ci        return error;
4804eace7efcSopenharmony_ci    }
4805eace7efcSopenharmony_ci    return reply.ReadInt32();
4806eace7efcSopenharmony_ci}
4807eace7efcSopenharmony_ci
4808eace7efcSopenharmony_ciint32_t AbilityManagerProxy::AttachAppDebug(const std::string &bundleName)
4809eace7efcSopenharmony_ci{
4810eace7efcSopenharmony_ci    TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
4811eace7efcSopenharmony_ci    MessageParcel data;
4812eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4813eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4814eace7efcSopenharmony_ci        return INNER_ERR;
4815eace7efcSopenharmony_ci    }
4816eace7efcSopenharmony_ci
4817eace7efcSopenharmony_ci    if (!data.WriteString(bundleName)) {
4818eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "bundleName write fail");
4819eace7efcSopenharmony_ci        return INNER_ERR;
4820eace7efcSopenharmony_ci    }
4821eace7efcSopenharmony_ci
4822eace7efcSopenharmony_ci    MessageParcel reply;
4823eace7efcSopenharmony_ci    MessageOption option;
4824eace7efcSopenharmony_ci    int32_t error = SendRequest(AbilityManagerInterfaceCode::ATTACH_APP_DEBUG, data, reply, option);
4825eace7efcSopenharmony_ci    if (error != NO_ERROR) {
4826eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request err:%{public}d", error);
4827eace7efcSopenharmony_ci        return error;
4828eace7efcSopenharmony_ci    }
4829eace7efcSopenharmony_ci    return reply.ReadInt32();
4830eace7efcSopenharmony_ci}
4831eace7efcSopenharmony_ci
4832eace7efcSopenharmony_ciint32_t AbilityManagerProxy::DetachAppDebug(const std::string &bundleName)
4833eace7efcSopenharmony_ci{
4834eace7efcSopenharmony_ci    TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
4835eace7efcSopenharmony_ci    MessageParcel data;
4836eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4837eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4838eace7efcSopenharmony_ci        return INNER_ERR;
4839eace7efcSopenharmony_ci    }
4840eace7efcSopenharmony_ci
4841eace7efcSopenharmony_ci    if (!data.WriteString(bundleName)) {
4842eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write bundleName fail");
4843eace7efcSopenharmony_ci        return INNER_ERR;
4844eace7efcSopenharmony_ci    }
4845eace7efcSopenharmony_ci
4846eace7efcSopenharmony_ci    MessageParcel reply;
4847eace7efcSopenharmony_ci    MessageOption option;
4848eace7efcSopenharmony_ci    int32_t error = SendRequest(AbilityManagerInterfaceCode::DETACH_APP_DEBUG, data, reply, option);
4849eace7efcSopenharmony_ci    if (error != NO_ERROR) {
4850eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request err:%{public}d", error);
4851eace7efcSopenharmony_ci        return error;
4852eace7efcSopenharmony_ci    }
4853eace7efcSopenharmony_ci    return reply.ReadInt32();
4854eace7efcSopenharmony_ci}
4855eace7efcSopenharmony_ci
4856eace7efcSopenharmony_ciint32_t AbilityManagerProxy::ExecuteIntent(uint64_t key,  const sptr<IRemoteObject> &callerToken,
4857eace7efcSopenharmony_ci    const InsightIntentExecuteParam &param)
4858eace7efcSopenharmony_ci{
4859eace7efcSopenharmony_ci    TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
4860eace7efcSopenharmony_ci    MessageParcel data;
4861eace7efcSopenharmony_ci    MessageParcel reply;
4862eace7efcSopenharmony_ci    MessageOption option;
4863eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4864eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4865eace7efcSopenharmony_ci        return INNER_ERR;
4866eace7efcSopenharmony_ci    }
4867eace7efcSopenharmony_ci
4868eace7efcSopenharmony_ci    if (!data.WriteUint64(key)) {
4869eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write key fail");
4870eace7efcSopenharmony_ci        return INNER_ERR;
4871eace7efcSopenharmony_ci    }
4872eace7efcSopenharmony_ci
4873eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(callerToken)) {
4874eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write callerToken failed.");
4875eace7efcSopenharmony_ci        return INNER_ERR;
4876eace7efcSopenharmony_ci    }
4877eace7efcSopenharmony_ci
4878eace7efcSopenharmony_ci    if (!data.WriteParcelable(&param)) {
4879eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write param fail");
4880eace7efcSopenharmony_ci        return INNER_ERR;
4881eace7efcSopenharmony_ci    }
4882eace7efcSopenharmony_ci
4883eace7efcSopenharmony_ci    int32_t error = SendRequest(AbilityManagerInterfaceCode::EXECUTE_INTENT, data, reply, option);
4884eace7efcSopenharmony_ci    if (error != NO_ERROR) {
4885eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request err:%{public}d", error);
4886eace7efcSopenharmony_ci        return error;
4887eace7efcSopenharmony_ci    }
4888eace7efcSopenharmony_ci
4889eace7efcSopenharmony_ci    return reply.ReadInt32();
4890eace7efcSopenharmony_ci}
4891eace7efcSopenharmony_ci
4892eace7efcSopenharmony_cibool AbilityManagerProxy::IsAbilityControllerStart(const Want &want)
4893eace7efcSopenharmony_ci{
4894eace7efcSopenharmony_ci    MessageParcel data;
4895eace7efcSopenharmony_ci    MessageParcel reply;
4896eace7efcSopenharmony_ci    MessageOption option;
4897eace7efcSopenharmony_ci
4898eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4899eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4900eace7efcSopenharmony_ci        return true;
4901eace7efcSopenharmony_ci    }
4902eace7efcSopenharmony_ci    if (!data.WriteParcelable(&want)) {
4903eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "writeWantObject fail");
4904eace7efcSopenharmony_ci        return true;
4905eace7efcSopenharmony_ci    }
4906eace7efcSopenharmony_ci
4907eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::IS_ABILITY_CONTROLLER_START,
4908eace7efcSopenharmony_ci        data, reply, option);
4909eace7efcSopenharmony_ci    if (error != NO_ERROR) {
4910eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
4911eace7efcSopenharmony_ci        return true;
4912eace7efcSopenharmony_ci    }
4913eace7efcSopenharmony_ci    return reply.ReadBool();
4914eace7efcSopenharmony_ci}
4915eace7efcSopenharmony_ci
4916eace7efcSopenharmony_ciint32_t AbilityManagerProxy::ExecuteInsightIntentDone(const sptr<IRemoteObject> &token, uint64_t intentId,
4917eace7efcSopenharmony_ci    const InsightIntentExecuteResult &result)
4918eace7efcSopenharmony_ci{
4919eace7efcSopenharmony_ci    TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
4920eace7efcSopenharmony_ci    MessageParcel data;
4921eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4922eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write object fail");
4923eace7efcSopenharmony_ci        return INNER_ERR;
4924eace7efcSopenharmony_ci    }
4925eace7efcSopenharmony_ci
4926eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(token)) {
4927eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4928eace7efcSopenharmony_ci        return INNER_ERR;
4929eace7efcSopenharmony_ci    }
4930eace7efcSopenharmony_ci
4931eace7efcSopenharmony_ci    if (!data.WriteInt64(intentId) || !data.WriteParcelable(&result)) {
4932eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write params fail");
4933eace7efcSopenharmony_ci        return INNER_ERR;
4934eace7efcSopenharmony_ci    }
4935eace7efcSopenharmony_ci
4936eace7efcSopenharmony_ci    MessageParcel reply;
4937eace7efcSopenharmony_ci    MessageOption option(MessageOption::TF_ASYNC);
4938eace7efcSopenharmony_ci    auto ret = SendRequest(AbilityManagerInterfaceCode::EXECUTE_INSIGHT_INTENT_DONE, data, reply, option);
4939eace7efcSopenharmony_ci    if (ret != NO_ERROR) {
4940eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request fail:%{public}d", ret);
4941eace7efcSopenharmony_ci        return ret;
4942eace7efcSopenharmony_ci    }
4943eace7efcSopenharmony_ci    return reply.ReadInt32();
4944eace7efcSopenharmony_ci}
4945eace7efcSopenharmony_ci
4946eace7efcSopenharmony_ciint32_t AbilityManagerProxy::GetForegroundUIAbilities(std::vector<AppExecFwk::AbilityStateData> &list)
4947eace7efcSopenharmony_ci{
4948eace7efcSopenharmony_ci    TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
4949eace7efcSopenharmony_ci    MessageParcel data;
4950eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4951eace7efcSopenharmony_ci        return ERR_FLATTEN_OBJECT;
4952eace7efcSopenharmony_ci    }
4953eace7efcSopenharmony_ci
4954eace7efcSopenharmony_ci    MessageParcel reply;
4955eace7efcSopenharmony_ci    MessageOption option;
4956eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::GET_FOREGROUND_UI_ABILITIES, data, reply, option);
4957eace7efcSopenharmony_ci    if (error != NO_ERROR) {
4958eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
4959eace7efcSopenharmony_ci        return error;
4960eace7efcSopenharmony_ci    }
4961eace7efcSopenharmony_ci
4962eace7efcSopenharmony_ci    auto errorCode = GetParcelableInfos<AppExecFwk::AbilityStateData>(reply, list);
4963eace7efcSopenharmony_ci    if (errorCode != NO_ERROR) {
4964eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "get abilities error:%{public}d", errorCode);
4965eace7efcSopenharmony_ci        return errorCode;
4966eace7efcSopenharmony_ci    }
4967eace7efcSopenharmony_ci    return reply.ReadInt32();
4968eace7efcSopenharmony_ci}
4969eace7efcSopenharmony_ci
4970eace7efcSopenharmony_ciint32_t AbilityManagerProxy::OpenFile(const Uri& uri, uint32_t flag)
4971eace7efcSopenharmony_ci{
4972eace7efcSopenharmony_ci    MessageParcel data;
4973eace7efcSopenharmony_ci    MessageParcel reply;
4974eace7efcSopenharmony_ci    MessageOption option;
4975eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
4976eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
4977eace7efcSopenharmony_ci        return false;
4978eace7efcSopenharmony_ci    }
4979eace7efcSopenharmony_ci    if (!data.WriteParcelable(&uri)) {
4980eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write uri fail");
4981eace7efcSopenharmony_ci        return false;
4982eace7efcSopenharmony_ci    }
4983eace7efcSopenharmony_ci    if (!data.WriteInt32(flag)) {
4984eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write flag fail");
4985eace7efcSopenharmony_ci        return false;
4986eace7efcSopenharmony_ci    }
4987eace7efcSopenharmony_ci
4988eace7efcSopenharmony_ci    auto ret = SendRequest(AbilityManagerInterfaceCode::OPEN_FILE, data, reply, option);
4989eace7efcSopenharmony_ci    if (ret != NO_ERROR) {
4990eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request fail:%{public}d", ret);
4991eace7efcSopenharmony_ci        return ret;
4992eace7efcSopenharmony_ci    }
4993eace7efcSopenharmony_ci    return reply.ReadFileDescriptor();
4994eace7efcSopenharmony_ci}
4995eace7efcSopenharmony_ci
4996eace7efcSopenharmony_ciint32_t AbilityManagerProxy::RequestAssertFaultDialog(
4997eace7efcSopenharmony_ci    const sptr<IRemoteObject> &callback, const AAFwk::WantParams &wantParams)
4998eace7efcSopenharmony_ci{
4999eace7efcSopenharmony_ci    TAG_LOGD(AAFwkTag::ABILITYMGR, "Request to display assert fault dialog.");
5000eace7efcSopenharmony_ci    if (callback == nullptr) {
5001eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "null callback");
5002eace7efcSopenharmony_ci        return INNER_ERR;
5003eace7efcSopenharmony_ci    }
5004eace7efcSopenharmony_ci
5005eace7efcSopenharmony_ci    MessageParcel data;
5006eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
5007eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
5008eace7efcSopenharmony_ci        return INNER_ERR;
5009eace7efcSopenharmony_ci    }
5010eace7efcSopenharmony_ci
5011eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(callback)) {
5012eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write callback fail");
5013eace7efcSopenharmony_ci        return INNER_ERR;
5014eace7efcSopenharmony_ci    }
5015eace7efcSopenharmony_ci
5016eace7efcSopenharmony_ci    if (!data.WriteParcelable(&wantParams)) {
5017eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "wantParams write fail");
5018eace7efcSopenharmony_ci        return INNER_ERR;
5019eace7efcSopenharmony_ci    }
5020eace7efcSopenharmony_ci
5021eace7efcSopenharmony_ci    MessageParcel reply;
5022eace7efcSopenharmony_ci    MessageOption option;
5023eace7efcSopenharmony_ci    auto ret = SendRequest(AbilityManagerInterfaceCode::REQUEST_ASSERT_FAULT_DIALOG, data, reply, option);
5024eace7efcSopenharmony_ci    if (ret != NO_ERROR) {
5025eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request fail:%{public}d", ret);
5026eace7efcSopenharmony_ci        return ret;
5027eace7efcSopenharmony_ci    }
5028eace7efcSopenharmony_ci
5029eace7efcSopenharmony_ci    return reply.ReadInt32();
5030eace7efcSopenharmony_ci}
5031eace7efcSopenharmony_ci
5032eace7efcSopenharmony_ciint32_t AbilityManagerProxy::NotifyDebugAssertResult(uint64_t assertFaultSessionId, AAFwk::UserStatus userStatus)
5033eace7efcSopenharmony_ci{
5034eace7efcSopenharmony_ci    TAG_LOGD(AAFwkTag::ABILITYMGR, "Notify user action result to assert fault callback.");
5035eace7efcSopenharmony_ci    MessageParcel data;
5036eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
5037eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
5038eace7efcSopenharmony_ci        return INNER_ERR;
5039eace7efcSopenharmony_ci    }
5040eace7efcSopenharmony_ci
5041eace7efcSopenharmony_ci    if (!data.WriteUint64(assertFaultSessionId)) {
5042eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write assertFaultSessionId fail");
5043eace7efcSopenharmony_ci        return INNER_ERR;
5044eace7efcSopenharmony_ci    }
5045eace7efcSopenharmony_ci
5046eace7efcSopenharmony_ci    if (!data.WriteInt32(static_cast<int32_t>(userStatus))) {
5047eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write userStatus fail");
5048eace7efcSopenharmony_ci        return INNER_ERR;
5049eace7efcSopenharmony_ci    }
5050eace7efcSopenharmony_ci
5051eace7efcSopenharmony_ci    MessageParcel reply;
5052eace7efcSopenharmony_ci    MessageOption option;
5053eace7efcSopenharmony_ci    auto ret = SendRequest(AbilityManagerInterfaceCode::NOTIFY_DEBUG_ASSERT_RESULT, data, reply, option);
5054eace7efcSopenharmony_ci    if (ret != NO_ERROR) {
5055eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request fail:%{public}d", ret);
5056eace7efcSopenharmony_ci        return ret;
5057eace7efcSopenharmony_ci    }
5058eace7efcSopenharmony_ci
5059eace7efcSopenharmony_ci    return reply.ReadInt32();
5060eace7efcSopenharmony_ci}
5061eace7efcSopenharmony_ci
5062eace7efcSopenharmony_ciint32_t AbilityManagerProxy::UpdateSessionInfoBySCB(std::list<SessionInfo> &sessionInfos, int32_t userId,
5063eace7efcSopenharmony_ci    std::vector<int32_t> &sessionIds)
5064eace7efcSopenharmony_ci{
5065eace7efcSopenharmony_ci    MessageParcel data;
5066eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
5067eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
5068eace7efcSopenharmony_ci        return ERR_NATIVE_IPC_PARCEL_FAILED;
5069eace7efcSopenharmony_ci    }
5070eace7efcSopenharmony_ci    auto size = static_cast<int32_t>(sessionInfos.size());
5071eace7efcSopenharmony_ci    int32_t threshold = 512;
5072eace7efcSopenharmony_ci    if (size > threshold) {
5073eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "vector too large");
5074eace7efcSopenharmony_ci        return ERR_NATIVE_IPC_PARCEL_FAILED;
5075eace7efcSopenharmony_ci    }
5076eace7efcSopenharmony_ci    if (!data.WriteInt32(size)) {
5077eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write size fail");
5078eace7efcSopenharmony_ci        return ERR_NATIVE_IPC_PARCEL_FAILED;
5079eace7efcSopenharmony_ci    }
5080eace7efcSopenharmony_ci    for (const auto &info : sessionInfos) {
5081eace7efcSopenharmony_ci        if (!data.WriteParcelable(&info)) {
5082eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "write sessionInfo fail");
5083eace7efcSopenharmony_ci            return ERR_NATIVE_IPC_PARCEL_FAILED;
5084eace7efcSopenharmony_ci        }
5085eace7efcSopenharmony_ci    }
5086eace7efcSopenharmony_ci    if (!data.WriteInt32(userId)) {
5087eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write userId fail");
5088eace7efcSopenharmony_ci        return ERR_NATIVE_IPC_PARCEL_FAILED;
5089eace7efcSopenharmony_ci    }
5090eace7efcSopenharmony_ci
5091eace7efcSopenharmony_ci    MessageParcel reply;
5092eace7efcSopenharmony_ci    MessageOption option;
5093eace7efcSopenharmony_ci    auto ret = SendRequest(AbilityManagerInterfaceCode::UPDATE_SESSION_INFO, data, reply, option);
5094eace7efcSopenharmony_ci    if (ret != NO_ERROR) {
5095eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request fail:%{public}d", ret);
5096eace7efcSopenharmony_ci        return ret;
5097eace7efcSopenharmony_ci    }
5098eace7efcSopenharmony_ci    size = reply.ReadInt32();
5099eace7efcSopenharmony_ci    if (size > threshold) {
5100eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "vector too large");
5101eace7efcSopenharmony_ci        return ERR_NATIVE_IPC_PARCEL_FAILED;
5102eace7efcSopenharmony_ci    }
5103eace7efcSopenharmony_ci    sessionIds.clear();
5104eace7efcSopenharmony_ci    for (auto index = 0; index < size; index++) {
5105eace7efcSopenharmony_ci        sessionIds.emplace_back(reply.ReadInt32());
5106eace7efcSopenharmony_ci    }
5107eace7efcSopenharmony_ci    return NO_ERROR;
5108eace7efcSopenharmony_ci}
5109eace7efcSopenharmony_ci
5110eace7efcSopenharmony_ciErrCode AbilityManagerProxy::SendRequest(AbilityManagerInterfaceCode code, MessageParcel &data, MessageParcel &reply,
5111eace7efcSopenharmony_ci    MessageOption& option)
5112eace7efcSopenharmony_ci{
5113eace7efcSopenharmony_ci    HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
5114eace7efcSopenharmony_ci    sptr<IRemoteObject> remote = Remote();
5115eace7efcSopenharmony_ci    if (remote == nullptr) {
5116eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "null remote");
5117eace7efcSopenharmony_ci        return INNER_ERR;
5118eace7efcSopenharmony_ci    }
5119eace7efcSopenharmony_ci
5120eace7efcSopenharmony_ci    return remote->SendRequest(static_cast<uint32_t>(code), data, reply, option);
5121eace7efcSopenharmony_ci}
5122eace7efcSopenharmony_ci
5123eace7efcSopenharmony_ciint32_t AbilityManagerProxy::SetApplicationAutoStartupByEDM(const AutoStartupInfo &info, bool flag)
5124eace7efcSopenharmony_ci{
5125eace7efcSopenharmony_ci    MessageParcel data;
5126eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
5127eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
5128eace7efcSopenharmony_ci        return INNER_ERR;
5129eace7efcSopenharmony_ci    }
5130eace7efcSopenharmony_ci    if (!data.WriteParcelable(&info)) {
5131eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write AutoStartupInfo fail");
5132eace7efcSopenharmony_ci        return INNER_ERR;
5133eace7efcSopenharmony_ci    }
5134eace7efcSopenharmony_ci    if (!data.WriteBool(flag)) {
5135eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write flag fail");
5136eace7efcSopenharmony_ci        return INNER_ERR;
5137eace7efcSopenharmony_ci    }
5138eace7efcSopenharmony_ci
5139eace7efcSopenharmony_ci    MessageParcel reply;
5140eace7efcSopenharmony_ci    MessageOption option;
5141eace7efcSopenharmony_ci    auto ret = SendRequest(AbilityManagerInterfaceCode::SET_APPLICATION_AUTO_STARTUP_BY_EDM, data, reply, option);
5142eace7efcSopenharmony_ci    if (ret != NO_ERROR) {
5143eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", ret);
5144eace7efcSopenharmony_ci        return ret;
5145eace7efcSopenharmony_ci    }
5146eace7efcSopenharmony_ci    return reply.ReadInt32();
5147eace7efcSopenharmony_ci}
5148eace7efcSopenharmony_ci
5149eace7efcSopenharmony_ciint32_t AbilityManagerProxy::CancelApplicationAutoStartupByEDM(const AutoStartupInfo &info, bool flag)
5150eace7efcSopenharmony_ci{
5151eace7efcSopenharmony_ci    MessageParcel data;
5152eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
5153eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
5154eace7efcSopenharmony_ci        return INNER_ERR;
5155eace7efcSopenharmony_ci    }
5156eace7efcSopenharmony_ci    if (!data.WriteParcelable(&info)) {
5157eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write info fail");
5158eace7efcSopenharmony_ci        return INNER_ERR;
5159eace7efcSopenharmony_ci    }
5160eace7efcSopenharmony_ci    if (!data.WriteBool(flag)) {
5161eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write flag fail");
5162eace7efcSopenharmony_ci        return INNER_ERR;
5163eace7efcSopenharmony_ci    }
5164eace7efcSopenharmony_ci
5165eace7efcSopenharmony_ci    MessageParcel reply;
5166eace7efcSopenharmony_ci    MessageOption option;
5167eace7efcSopenharmony_ci    auto ret = SendRequest(AbilityManagerInterfaceCode::CANCEL_APPLICATION_AUTO_STARTUP_BY_EDM, data, reply, option);
5168eace7efcSopenharmony_ci    if (ret != NO_ERROR) {
5169eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", ret);
5170eace7efcSopenharmony_ci        return ret;
5171eace7efcSopenharmony_ci    }
5172eace7efcSopenharmony_ci    return reply.ReadInt32();
5173eace7efcSopenharmony_ci}
5174eace7efcSopenharmony_ci
5175eace7efcSopenharmony_ciint32_t AbilityManagerProxy::GetUIExtensionRootHostInfo(const sptr<IRemoteObject> token,
5176eace7efcSopenharmony_ci    UIExtensionHostInfo &hostInfo, int32_t userId)
5177eace7efcSopenharmony_ci{
5178eace7efcSopenharmony_ci    if (token == nullptr) {
5179eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "input invalid");
5180eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
5181eace7efcSopenharmony_ci    }
5182eace7efcSopenharmony_ci
5183eace7efcSopenharmony_ci    MessageParcel data;
5184eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
5185eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write object fail");
5186eace7efcSopenharmony_ci        return INNER_ERR;
5187eace7efcSopenharmony_ci    }
5188eace7efcSopenharmony_ci
5189eace7efcSopenharmony_ci    if (!data.WriteBool(true) || !data.WriteRemoteObject(token)) {
5190eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write flag and token fail");
5191eace7efcSopenharmony_ci        return INNER_ERR;
5192eace7efcSopenharmony_ci    }
5193eace7efcSopenharmony_ci
5194eace7efcSopenharmony_ci    if (!data.WriteInt32(userId)) {
5195eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write userId fail");
5196eace7efcSopenharmony_ci        return INNER_ERR;
5197eace7efcSopenharmony_ci    }
5198eace7efcSopenharmony_ci
5199eace7efcSopenharmony_ci    MessageParcel reply;
5200eace7efcSopenharmony_ci    MessageOption option;
5201eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::GET_UI_EXTENSION_ROOT_HOST_INFO, data, reply, option);
5202eace7efcSopenharmony_ci    if (error != NO_ERROR) {
5203eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
5204eace7efcSopenharmony_ci        return error;
5205eace7efcSopenharmony_ci    }
5206eace7efcSopenharmony_ci
5207eace7efcSopenharmony_ci    std::unique_ptr<UIExtensionHostInfo> info(reply.ReadParcelable<UIExtensionHostInfo>());
5208eace7efcSopenharmony_ci    if (info == nullptr) {
5209eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "get host fail");
5210eace7efcSopenharmony_ci        return INNER_ERR;
5211eace7efcSopenharmony_ci    }
5212eace7efcSopenharmony_ci    hostInfo = *info;
5213eace7efcSopenharmony_ci    return reply.ReadInt32();
5214eace7efcSopenharmony_ci}
5215eace7efcSopenharmony_ci
5216eace7efcSopenharmony_ciint32_t AbilityManagerProxy::GetUIExtensionSessionInfo(const sptr<IRemoteObject> token,
5217eace7efcSopenharmony_ci    UIExtensionSessionInfo &uiExtensionSessionInfo, int32_t userId)
5218eace7efcSopenharmony_ci{
5219eace7efcSopenharmony_ci    if (token == nullptr) {
5220eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "input invalid");
5221eace7efcSopenharmony_ci        return ERR_INVALID_VALUE;
5222eace7efcSopenharmony_ci    }
5223eace7efcSopenharmony_ci
5224eace7efcSopenharmony_ci    MessageParcel data;
5225eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
5226eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write object fail");
5227eace7efcSopenharmony_ci        return INNER_ERR;
5228eace7efcSopenharmony_ci    }
5229eace7efcSopenharmony_ci
5230eace7efcSopenharmony_ci    if (!data.WriteBool(true) || !data.WriteRemoteObject(token)) {
5231eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write flag and token fail");
5232eace7efcSopenharmony_ci        return INNER_ERR;
5233eace7efcSopenharmony_ci    }
5234eace7efcSopenharmony_ci
5235eace7efcSopenharmony_ci    if (!data.WriteInt32(userId)) {
5236eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write userId fail");
5237eace7efcSopenharmony_ci        return INNER_ERR;
5238eace7efcSopenharmony_ci    }
5239eace7efcSopenharmony_ci
5240eace7efcSopenharmony_ci    MessageParcel reply;
5241eace7efcSopenharmony_ci    MessageOption option;
5242eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::GET_UI_EXTENSION_SESSION_INFO, data, reply, option);
5243eace7efcSopenharmony_ci    if (error != NO_ERROR) {
5244eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
5245eace7efcSopenharmony_ci        return error;
5246eace7efcSopenharmony_ci    }
5247eace7efcSopenharmony_ci
5248eace7efcSopenharmony_ci    std::unique_ptr<UIExtensionSessionInfo> info(reply.ReadParcelable<UIExtensionSessionInfo>());
5249eace7efcSopenharmony_ci    if (info == nullptr) {
5250eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "get host info fail");
5251eace7efcSopenharmony_ci        return INNER_ERR;
5252eace7efcSopenharmony_ci    }
5253eace7efcSopenharmony_ci    uiExtensionSessionInfo = *info;
5254eace7efcSopenharmony_ci    return reply.ReadInt32();
5255eace7efcSopenharmony_ci}
5256eace7efcSopenharmony_ci
5257eace7efcSopenharmony_ciint32_t AbilityManagerProxy::RestartApp(const AAFwk::Want &want, bool isAppRecovery)
5258eace7efcSopenharmony_ci{
5259eace7efcSopenharmony_ci    MessageParcel data;
5260eace7efcSopenharmony_ci    MessageParcel reply;
5261eace7efcSopenharmony_ci    MessageOption option;
5262eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
5263eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
5264eace7efcSopenharmony_ci        return IPC_PROXY_ERR;
5265eace7efcSopenharmony_ci    }
5266eace7efcSopenharmony_ci    if (!data.WriteParcelable(&want)) {
5267eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "want write fail");
5268eace7efcSopenharmony_ci        return IPC_PROXY_ERR;
5269eace7efcSopenharmony_ci    }
5270eace7efcSopenharmony_ci    if (!data.WriteBool(isAppRecovery)) {
5271eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write isAppRecovery fail");
5272eace7efcSopenharmony_ci        return IPC_PROXY_ERR;
5273eace7efcSopenharmony_ci    }
5274eace7efcSopenharmony_ci    auto ret = SendRequest(AbilityManagerInterfaceCode::RESTART_APP, data, reply, option);
5275eace7efcSopenharmony_ci    if (ret != NO_ERROR) {
5276eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", ret);
5277eace7efcSopenharmony_ci        return ret;
5278eace7efcSopenharmony_ci    }
5279eace7efcSopenharmony_ci    return reply.ReadInt32();
5280eace7efcSopenharmony_ci}
5281eace7efcSopenharmony_ci
5282eace7efcSopenharmony_ciint32_t AbilityManagerProxy::OpenAtomicService(Want& want, const StartOptions &options,
5283eace7efcSopenharmony_ci    sptr<IRemoteObject> callerToken, int32_t requestCode, int32_t userId)
5284eace7efcSopenharmony_ci{
5285eace7efcSopenharmony_ci    MessageParcel data;
5286eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
5287eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
5288eace7efcSopenharmony_ci        return INNER_ERR;
5289eace7efcSopenharmony_ci    }
5290eace7efcSopenharmony_ci    if (!data.WriteParcelable(&want)) {
5291eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write want fail");
5292eace7efcSopenharmony_ci        return INNER_ERR;
5293eace7efcSopenharmony_ci    }
5294eace7efcSopenharmony_ci    if (!data.WriteParcelable(&options)) {
5295eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "options write fail");
5296eace7efcSopenharmony_ci        return INNER_ERR;
5297eace7efcSopenharmony_ci    }
5298eace7efcSopenharmony_ci    if (callerToken != nullptr) {
5299eace7efcSopenharmony_ci        if (!data.WriteBool(true) || !data.WriteRemoteObject(callerToken)) {
5300eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag and callerToken write fail");
5301eace7efcSopenharmony_ci            return INNER_ERR;
5302eace7efcSopenharmony_ci        }
5303eace7efcSopenharmony_ci    } else {
5304eace7efcSopenharmony_ci        if (!data.WriteBool(false)) {
5305eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "flag write fail");
5306eace7efcSopenharmony_ci            return INNER_ERR;
5307eace7efcSopenharmony_ci        }
5308eace7efcSopenharmony_ci    }
5309eace7efcSopenharmony_ci    if (!data.WriteInt32(requestCode)) {
5310eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "requestCode write fail");
5311eace7efcSopenharmony_ci        return INNER_ERR;
5312eace7efcSopenharmony_ci    }
5313eace7efcSopenharmony_ci    if (!data.WriteInt32(userId)) {
5314eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "userId write fail");
5315eace7efcSopenharmony_ci        return INNER_ERR;
5316eace7efcSopenharmony_ci    }
5317eace7efcSopenharmony_ci
5318eace7efcSopenharmony_ci    MessageParcel reply;
5319eace7efcSopenharmony_ci    MessageOption option;
5320eace7efcSopenharmony_ci    auto ret = SendRequest(AbilityManagerInterfaceCode::OPEN_ATOMIC_SERVICE, data, reply, option);
5321eace7efcSopenharmony_ci    if (ret != NO_ERROR) {
5322eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", ret);
5323eace7efcSopenharmony_ci        return ret;
5324eace7efcSopenharmony_ci    }
5325eace7efcSopenharmony_ci    return reply.ReadInt32();
5326eace7efcSopenharmony_ci}
5327eace7efcSopenharmony_ci
5328eace7efcSopenharmony_ciint32_t AbilityManagerProxy::SetResidentProcessEnabled(const std::string &bundleName, bool enable)
5329eace7efcSopenharmony_ci{
5330eace7efcSopenharmony_ci    MessageParcel data;
5331eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
5332eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
5333eace7efcSopenharmony_ci        return INNER_ERR;
5334eace7efcSopenharmony_ci    }
5335eace7efcSopenharmony_ci    if (!data.WriteString(bundleName)) {
5336eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write bundleName fail");
5337eace7efcSopenharmony_ci        return INNER_ERR;
5338eace7efcSopenharmony_ci    }
5339eace7efcSopenharmony_ci    if (!data.WriteBool(enable)) {
5340eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write enable fail");
5341eace7efcSopenharmony_ci        return INNER_ERR;
5342eace7efcSopenharmony_ci    }
5343eace7efcSopenharmony_ci    MessageParcel reply;
5344eace7efcSopenharmony_ci    MessageOption option;
5345eace7efcSopenharmony_ci    auto ret = SendRequest(AbilityManagerInterfaceCode::SET_RESIDENT_PROCESS_ENABLE, data, reply, option);
5346eace7efcSopenharmony_ci    if (ret != NO_ERROR) {
5347eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", ret);
5348eace7efcSopenharmony_ci        return ret;
5349eace7efcSopenharmony_ci    }
5350eace7efcSopenharmony_ci
5351eace7efcSopenharmony_ci    return reply.ReadInt32();
5352eace7efcSopenharmony_ci}
5353eace7efcSopenharmony_ci
5354eace7efcSopenharmony_cibool AbilityManagerProxy::IsEmbeddedOpenAllowed(sptr<IRemoteObject> callerToken, const std::string &appId)
5355eace7efcSopenharmony_ci{
5356eace7efcSopenharmony_ci    if (callerToken == nullptr) {
5357eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "input invalid");
5358eace7efcSopenharmony_ci        return false;
5359eace7efcSopenharmony_ci    }
5360eace7efcSopenharmony_ci
5361eace7efcSopenharmony_ci    MessageParcel data;
5362eace7efcSopenharmony_ci    if (!WriteInterfaceToken (data)) {
5363eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write remote object fail");
5364eace7efcSopenharmony_ci        return false;
5365eace7efcSopenharmony_ci    }
5366eace7efcSopenharmony_ci
5367eace7efcSopenharmony_ci    if (!data.WriteBool(true) || !data.WriteRemoteObject(callerToken)) {
5368eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write flag and callerToken fail");
5369eace7efcSopenharmony_ci        return false;
5370eace7efcSopenharmony_ci    }
5371eace7efcSopenharmony_ci
5372eace7efcSopenharmony_ci    if (!data.WriteString(appId)) {
5373eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write userId fail");
5374eace7efcSopenharmony_ci        return false;
5375eace7efcSopenharmony_ci    }
5376eace7efcSopenharmony_ci
5377eace7efcSopenharmony_ci    MessageParcel reply;
5378eace7efcSopenharmony_ci    MessageOption option;
5379eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::IS_EMBEDDED_OPEN_ALLOWED, data, reply, option);
5380eace7efcSopenharmony_ci    if (error != NO_ERROR) {
5381eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
5382eace7efcSopenharmony_ci        return false;
5383eace7efcSopenharmony_ci    }
5384eace7efcSopenharmony_ci    return reply.ReadBool();
5385eace7efcSopenharmony_ci}
5386eace7efcSopenharmony_ci
5387eace7efcSopenharmony_ciint32_t AbilityManagerProxy::StartShortcut(const Want &want, const StartOptions &startOptions)
5388eace7efcSopenharmony_ci{
5389eace7efcSopenharmony_ci    MessageParcel data;
5390eace7efcSopenharmony_ci    MessageParcel reply;
5391eace7efcSopenharmony_ci    MessageOption option;
5392eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
5393eace7efcSopenharmony_ci        return INNER_ERR;
5394eace7efcSopenharmony_ci    }
5395eace7efcSopenharmony_ci    if (!data.WriteParcelable(&want)) {
5396eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "want write fail");
5397eace7efcSopenharmony_ci        return INNER_ERR;
5398eace7efcSopenharmony_ci    }
5399eace7efcSopenharmony_ci    if (!data.WriteParcelable(&startOptions)) {
5400eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "startOptions write fail");
5401eace7efcSopenharmony_ci        return INNER_ERR;
5402eace7efcSopenharmony_ci    }
5403eace7efcSopenharmony_ci
5404eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::START_SHORTCUT, data, reply, option);
5405eace7efcSopenharmony_ci    if (error != NO_ERROR) {
5406eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
5407eace7efcSopenharmony_ci        return error;
5408eace7efcSopenharmony_ci    }
5409eace7efcSopenharmony_ci    return reply.ReadInt32();
5410eace7efcSopenharmony_ci}
5411eace7efcSopenharmony_ci
5412eace7efcSopenharmony_ciint32_t AbilityManagerProxy::GetAbilityStateByPersistentId(int32_t persistentId, bool &state)
5413eace7efcSopenharmony_ci{
5414eace7efcSopenharmony_ci    MessageParcel data;
5415eace7efcSopenharmony_ci    MessageParcel reply;
5416eace7efcSopenharmony_ci    MessageOption option;
5417eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
5418eace7efcSopenharmony_ci        return IPC_PROXY_ERR;
5419eace7efcSopenharmony_ci    }
5420eace7efcSopenharmony_ci    if (!data.WriteInt32(persistentId)) {
5421eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "want write failed");
5422eace7efcSopenharmony_ci        return IPC_PROXY_ERR;
5423eace7efcSopenharmony_ci    }
5424eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::GET_ABILITY_STATE_BY_PERSISTENT_ID, data, reply, option);
5425eace7efcSopenharmony_ci    if (error != NO_ERROR) {
5426eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
5427eace7efcSopenharmony_ci        return error;
5428eace7efcSopenharmony_ci    }
5429eace7efcSopenharmony_ci    state = reply.ReadBool();
5430eace7efcSopenharmony_ci    return NO_ERROR;
5431eace7efcSopenharmony_ci}
5432eace7efcSopenharmony_ci
5433eace7efcSopenharmony_ci
5434eace7efcSopenharmony_ciint32_t AbilityManagerProxy::TransferAbilityResultForExtension(const sptr<IRemoteObject> &callerToken,
5435eace7efcSopenharmony_ci    int32_t resultCode, const Want &want)
5436eace7efcSopenharmony_ci{
5437eace7efcSopenharmony_ci    if (callerToken == nullptr) {
5438eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "null callerToken");
5439eace7efcSopenharmony_ci        return INNER_ERR;
5440eace7efcSopenharmony_ci    }
5441eace7efcSopenharmony_ci    MessageParcel data;
5442eace7efcSopenharmony_ci    MessageParcel reply;
5443eace7efcSopenharmony_ci    MessageOption option;
5444eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
5445eace7efcSopenharmony_ci        return IPC_PROXY_ERR;
5446eace7efcSopenharmony_ci    }
5447eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(callerToken) || !data.WriteInt32(resultCode)) {
5448eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "callerToken or resultCode write fail");
5449eace7efcSopenharmony_ci        return INNER_ERR;
5450eace7efcSopenharmony_ci    }
5451eace7efcSopenharmony_ci    if (!data.WriteParcelable(&want)) {
5452eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "want write fail");
5453eace7efcSopenharmony_ci        return INNER_ERR;
5454eace7efcSopenharmony_ci    }
5455eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::TRANSFER_ABILITY_RESULT, data, reply, option);
5456eace7efcSopenharmony_ci    if (error != NO_ERROR) {
5457eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
5458eace7efcSopenharmony_ci        return error;
5459eace7efcSopenharmony_ci    }
5460eace7efcSopenharmony_ci    return NO_ERROR;
5461eace7efcSopenharmony_ci}
5462eace7efcSopenharmony_ci
5463eace7efcSopenharmony_civoid AbilityManagerProxy::NotifyFrozenProcessByRSS(const std::vector<int32_t> &pidList, int32_t uid)
5464eace7efcSopenharmony_ci{
5465eace7efcSopenharmony_ci    MessageParcel data;
5466eace7efcSopenharmony_ci    MessageParcel reply;
5467eace7efcSopenharmony_ci    MessageOption option(MessageOption::TF_ASYNC);
5468eace7efcSopenharmony_ci
5469eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
5470eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
5471eace7efcSopenharmony_ci        return;
5472eace7efcSopenharmony_ci    }
5473eace7efcSopenharmony_ci    if (!data.WriteInt32Vector(pidList)) {
5474eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "list write fail");
5475eace7efcSopenharmony_ci        return;
5476eace7efcSopenharmony_ci    }
5477eace7efcSopenharmony_ci    if (!data.WriteInt32(uid)) {
5478eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "uid write fail");
5479eace7efcSopenharmony_ci        return;
5480eace7efcSopenharmony_ci    }
5481eace7efcSopenharmony_ci
5482eace7efcSopenharmony_ci    int error = SendRequest(AbilityManagerInterfaceCode::NOTIFY_FROZEN_PROCESS_BY_RSS, data, reply, option);
5483eace7efcSopenharmony_ci    if (error != NO_ERROR) {
5484eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request err %{public}d", error);
5485eace7efcSopenharmony_ci    }
5486eace7efcSopenharmony_ci}
5487eace7efcSopenharmony_ci
5488eace7efcSopenharmony_ciint AbilityManagerProxy::CleanUIAbilityBySCB(const sptr<SessionInfo> &sessionInfo)
5489eace7efcSopenharmony_ci{
5490eace7efcSopenharmony_ci    int error;
5491eace7efcSopenharmony_ci    MessageParcel data;
5492eace7efcSopenharmony_ci    MessageParcel reply;
5493eace7efcSopenharmony_ci    MessageOption option;
5494eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
5495eace7efcSopenharmony_ci        return INNER_ERR;
5496eace7efcSopenharmony_ci    }
5497eace7efcSopenharmony_ci
5498eace7efcSopenharmony_ci    if (sessionInfo) {
5499eace7efcSopenharmony_ci        if (!data.WriteBool(true) || !data.WriteParcelable(sessionInfo)) {
5500eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "write flag or sessionInfo fail");
5501eace7efcSopenharmony_ci            return INNER_ERR;
5502eace7efcSopenharmony_ci        }
5503eace7efcSopenharmony_ci    } else {
5504eace7efcSopenharmony_ci        if (!data.WriteBool(false)) {
5505eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "write flag fail");
5506eace7efcSopenharmony_ci            return INNER_ERR;
5507eace7efcSopenharmony_ci        }
5508eace7efcSopenharmony_ci    }
5509eace7efcSopenharmony_ci
5510eace7efcSopenharmony_ci    error = SendRequest(AbilityManagerInterfaceCode::CLEAN_UI_ABILITY_BY_SCB, data, reply, option);
5511eace7efcSopenharmony_ci    if (error != NO_ERROR) {
5512eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
5513eace7efcSopenharmony_ci        return error;
5514eace7efcSopenharmony_ci    }
5515eace7efcSopenharmony_ci    return reply.ReadInt32();
5516eace7efcSopenharmony_ci}
5517eace7efcSopenharmony_ci
5518eace7efcSopenharmony_ciint32_t AbilityManagerProxy::PreStartMission(const std::string& bundleName, const std::string& moduleName,
5519eace7efcSopenharmony_ci    const std::string& abilityName, const std::string& startTime)
5520eace7efcSopenharmony_ci{
5521eace7efcSopenharmony_ci    MessageParcel data;
5522eace7efcSopenharmony_ci    MessageParcel reply;
5523eace7efcSopenharmony_ci    MessageOption option;
5524eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
5525eace7efcSopenharmony_ci        return IPC_PROXY_ERR;
5526eace7efcSopenharmony_ci    }
5527eace7efcSopenharmony_ci    if (!data.WriteString(bundleName)) {
5528eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write bundleName fail");
5529eace7efcSopenharmony_ci        return INNER_ERR;
5530eace7efcSopenharmony_ci    }
5531eace7efcSopenharmony_ci    if (!data.WriteString(moduleName)) {
5532eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write moduleName fail");
5533eace7efcSopenharmony_ci        return INNER_ERR;
5534eace7efcSopenharmony_ci    }
5535eace7efcSopenharmony_ci    if (!data.WriteString(abilityName)) {
5536eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write abilityName fail");
5537eace7efcSopenharmony_ci        return INNER_ERR;
5538eace7efcSopenharmony_ci    }
5539eace7efcSopenharmony_ci    if (!data.WriteString(startTime)) {
5540eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write startTime fail");
5541eace7efcSopenharmony_ci        return INNER_ERR;
5542eace7efcSopenharmony_ci    }
5543eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::PRE_START_MISSION, data, reply, option);
5544eace7efcSopenharmony_ci    if (error != NO_ERROR) {
5545eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
5546eace7efcSopenharmony_ci        return error;
5547eace7efcSopenharmony_ci    }
5548eace7efcSopenharmony_ci    return reply.ReadInt32();
5549eace7efcSopenharmony_ci}
5550eace7efcSopenharmony_ci
5551eace7efcSopenharmony_ciErrCode AbilityManagerProxy::OpenLink(const Want& want, sptr<IRemoteObject> callerToken,
5552eace7efcSopenharmony_ci    int32_t userId, int requestCode)
5553eace7efcSopenharmony_ci{
5554eace7efcSopenharmony_ci    if (callerToken == nullptr) {
5555eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "null callerToken");
5556eace7efcSopenharmony_ci        return INNER_ERR;
5557eace7efcSopenharmony_ci    }
5558eace7efcSopenharmony_ci    MessageParcel data;
5559eace7efcSopenharmony_ci    MessageParcel reply;
5560eace7efcSopenharmony_ci    MessageOption option;
5561eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
5562eace7efcSopenharmony_ci        return IPC_PROXY_ERR;
5563eace7efcSopenharmony_ci    }
5564eace7efcSopenharmony_ci    if (!data.WriteParcelable(&want)) {
5565eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "want write fail");
5566eace7efcSopenharmony_ci        return INNER_ERR;
5567eace7efcSopenharmony_ci    }
5568eace7efcSopenharmony_ci    if (!data.WriteRemoteObject(callerToken)) {
5569eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "callerToken write fail");
5570eace7efcSopenharmony_ci        return INNER_ERR;
5571eace7efcSopenharmony_ci    }
5572eace7efcSopenharmony_ci    if (!data.WriteInt32(userId)) {
5573eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "userId write fail");
5574eace7efcSopenharmony_ci        return INNER_ERR;
5575eace7efcSopenharmony_ci    }
5576eace7efcSopenharmony_ci    if (!data.WriteInt32(requestCode)) {
5577eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "requestCode write fail");
5578eace7efcSopenharmony_ci        return INNER_ERR;
5579eace7efcSopenharmony_ci    }
5580eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::OPEN_LINK, data, reply, option);
5581eace7efcSopenharmony_ci    if (error != NO_ERROR) {
5582eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
5583eace7efcSopenharmony_ci        return error;
5584eace7efcSopenharmony_ci    }
5585eace7efcSopenharmony_ci    return reply.ReadInt32();
5586eace7efcSopenharmony_ci}
5587eace7efcSopenharmony_ci
5588eace7efcSopenharmony_ciint32_t AbilityManagerProxy::TerminateMission(int32_t missionId)
5589eace7efcSopenharmony_ci{
5590eace7efcSopenharmony_ci    MessageParcel data;
5591eace7efcSopenharmony_ci    MessageParcel reply;
5592eace7efcSopenharmony_ci    MessageOption option;
5593eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
5594eace7efcSopenharmony_ci        return IPC_PROXY_ERR;
5595eace7efcSopenharmony_ci    }
5596eace7efcSopenharmony_ci    if (!data.WriteInt32(missionId)) {
5597eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "appCloneIndex write fail");
5598eace7efcSopenharmony_ci        return INNER_ERR;
5599eace7efcSopenharmony_ci    }
5600eace7efcSopenharmony_ci
5601eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::TERMINATE_MISSION,
5602eace7efcSopenharmony_ci        data, reply, option);
5603eace7efcSopenharmony_ci    if (error != NO_ERROR) {
5604eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error: %{public}d", error);
5605eace7efcSopenharmony_ci        return error;
5606eace7efcSopenharmony_ci    }
5607eace7efcSopenharmony_ci
5608eace7efcSopenharmony_ci    return reply.ReadInt32();
5609eace7efcSopenharmony_ci}
5610eace7efcSopenharmony_ci
5611eace7efcSopenharmony_ciint32_t AbilityManagerProxy::BlockAllAppStart(bool flag)
5612eace7efcSopenharmony_ci{
5613eace7efcSopenharmony_ci    MessageParcel data;
5614eace7efcSopenharmony_ci    MessageParcel reply;
5615eace7efcSopenharmony_ci    MessageOption option;
5616eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
5617eace7efcSopenharmony_ci        return IPC_PROXY_ERR;
5618eace7efcSopenharmony_ci    }
5619eace7efcSopenharmony_ci    if (!data.WriteBool(flag)) {
5620eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write flag failed.");
5621eace7efcSopenharmony_ci        return INNER_ERR;
5622eace7efcSopenharmony_ci    }
5623eace7efcSopenharmony_ci
5624eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::BLOCK_ALL_APP_START,
5625eace7efcSopenharmony_ci        data, reply, option);
5626eace7efcSopenharmony_ci    if (error != NO_ERROR) {
5627eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "Send request error: %{public}d", error);
5628eace7efcSopenharmony_ci        return error;
5629eace7efcSopenharmony_ci    }
5630eace7efcSopenharmony_ci
5631eace7efcSopenharmony_ci    return reply.ReadInt32();
5632eace7efcSopenharmony_ci}
5633eace7efcSopenharmony_ci
5634eace7efcSopenharmony_ciint32_t AbilityManagerProxy::UpdateAssociateConfigList(const std::map<std::string, std::list<std::string>>& configs,
5635eace7efcSopenharmony_ci    const std::list<std::string>& exportConfigs, int32_t flag)
5636eace7efcSopenharmony_ci{
5637eace7efcSopenharmony_ci    MessageParcel data;
5638eace7efcSopenharmony_ci    MessageParcel reply;
5639eace7efcSopenharmony_ci    MessageOption option;
5640eace7efcSopenharmony_ci    if (!WriteInterfaceToken(data)) {
5641eace7efcSopenharmony_ci        return IPC_PROXY_ERR;
5642eace7efcSopenharmony_ci    }
5643eace7efcSopenharmony_ci
5644eace7efcSopenharmony_ci    if (!UpdateAssociateConfigInner(configs, data)) {
5645eace7efcSopenharmony_ci        return INNER_ERR;
5646eace7efcSopenharmony_ci    }
5647eace7efcSopenharmony_ci
5648eace7efcSopenharmony_ci    int32_t size = static_cast<int32_t>(exportConfigs.size());
5649eace7efcSopenharmony_ci    if (size > MAX_UPDATE_CONFIG_SIZE) {
5650eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "export configs size too large");
5651eace7efcSopenharmony_ci        return INNER_ERR;
5652eace7efcSopenharmony_ci    }
5653eace7efcSopenharmony_ci    if (!data.WriteInt32(size)) {
5654eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write export configs size fail");
5655eace7efcSopenharmony_ci        return INNER_ERR;
5656eace7efcSopenharmony_ci    }
5657eace7efcSopenharmony_ci    for (const auto& config : exportConfigs) {
5658eace7efcSopenharmony_ci        if (!data.WriteString(config)) {
5659eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "write export config item fail");
5660eace7efcSopenharmony_ci            return INNER_ERR;
5661eace7efcSopenharmony_ci        }
5662eace7efcSopenharmony_ci    }
5663eace7efcSopenharmony_ci    if (!data.WriteInt32(flag)) {
5664eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write flag fail");
5665eace7efcSopenharmony_ci        return INNER_ERR;
5666eace7efcSopenharmony_ci    }
5667eace7efcSopenharmony_ci    auto error = SendRequest(AbilityManagerInterfaceCode::UPDATE_ASSOCIATE_CONFIG_LIST, data, reply, option);
5668eace7efcSopenharmony_ci    if (error != NO_ERROR) {
5669eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "request error: %{public}d", error);
5670eace7efcSopenharmony_ci        return error;
5671eace7efcSopenharmony_ci    }
5672eace7efcSopenharmony_ci    return reply.ReadInt32();
5673eace7efcSopenharmony_ci}
5674eace7efcSopenharmony_ci
5675eace7efcSopenharmony_cibool AbilityManagerProxy::UpdateAssociateConfigInner(const std::map<std::string, std::list<std::string>>& configs,
5676eace7efcSopenharmony_ci    MessageParcel& data)
5677eace7efcSopenharmony_ci{
5678eace7efcSopenharmony_ci    int32_t size = static_cast<int32_t>(configs.size());
5679eace7efcSopenharmony_ci    if (size > MAX_UPDATE_CONFIG_SIZE) {
5680eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "configs size too large");
5681eace7efcSopenharmony_ci        return false;
5682eace7efcSopenharmony_ci    }
5683eace7efcSopenharmony_ci    if (!data.WriteInt32(size)) {
5684eace7efcSopenharmony_ci        TAG_LOGE(AAFwkTag::ABILITYMGR, "write configs size fail");
5685eace7efcSopenharmony_ci        return false;
5686eace7efcSopenharmony_ci    }
5687eace7efcSopenharmony_ci    for (const auto& config : configs) {
5688eace7efcSopenharmony_ci        if (!data.WriteString(config.first)) {
5689eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "write config key fail");
5690eace7efcSopenharmony_ci            return false;
5691eace7efcSopenharmony_ci        }
5692eace7efcSopenharmony_ci        size = static_cast<int32_t>(config.second.size());
5693eace7efcSopenharmony_ci        if (size > MAX_UPDATE_CONFIG_SIZE) {
5694eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "config size too large");
5695eace7efcSopenharmony_ci            return false;
5696eace7efcSopenharmony_ci        }
5697eace7efcSopenharmony_ci        if (!data.WriteInt32(size)) {
5698eace7efcSopenharmony_ci            TAG_LOGE(AAFwkTag::ABILITYMGR, "write config item size fail");
5699eace7efcSopenharmony_ci            return false;
5700eace7efcSopenharmony_ci        }
5701eace7efcSopenharmony_ci        for (const auto& item : config.second) {
5702eace7efcSopenharmony_ci            if (!data.WriteString(item)) {
5703eace7efcSopenharmony_ci                TAG_LOGE(AAFwkTag::ABILITYMGR, "write config item fail");
5704eace7efcSopenharmony_ci                return false;
5705eace7efcSopenharmony_ci            }
5706eace7efcSopenharmony_ci        }
5707eace7efcSopenharmony_ci    }
5708eace7efcSopenharmony_ci    return true;
5709eace7efcSopenharmony_ci}
5710eace7efcSopenharmony_ci} // namespace AAFwk
5711eace7efcSopenharmony_ci} // namespace OHOS
5712