1 /*
2 * Copyright (c) 2023-2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "ability_manager_collaborator_proxy.h"
17
18 #include "configuration.h"
19 #include "hilog_tag_wrapper.h"
20
21 namespace OHOS {
22 namespace AAFwk {
NotifyStartAbility(const AppExecFwk::AbilityInfo & abilityInfo,int32_t userId,Want & want,uint64_t accessTokenIDEx)23 int32_t AbilityManagerCollaboratorProxy::NotifyStartAbility(
24 const AppExecFwk::AbilityInfo &abilityInfo, int32_t userId, Want &want, uint64_t accessTokenIDEx)
25 {
26 MessageParcel data;
27 MessageParcel reply;
28 MessageOption option(MessageOption::TF_SYNC);
29
30 if (!data.WriteInterfaceToken(AbilityManagerCollaboratorProxy::GetDescriptor())) {
31 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write interface token failed.");
32 return ERR_INVALID_OPERATION;
33 }
34 if (!data.WriteParcelable(&abilityInfo)) {
35 TAG_LOGE(AAFwkTag::ABILITYMGR, "abilityInfo write failed.");
36 return ERR_INVALID_OPERATION;
37 }
38 if (!data.WriteInt32(userId)) {
39 TAG_LOGE(AAFwkTag::ABILITYMGR, "userId write failed.");
40 return ERR_INVALID_OPERATION;
41 }
42 if (!data.WriteParcelable(&want)) {
43 TAG_LOGE(AAFwkTag::ABILITYMGR, "want write failed.");
44 return ERR_INVALID_OPERATION;
45 }
46 if (!data.WriteUint64(accessTokenIDEx)) {
47 TAG_LOGE(AAFwkTag::ABILITYMGR, "accessTokenIDEx write failed.");
48 return ERR_INVALID_OPERATION;
49 }
50 int32_t ret = SendTransactCmd(IAbilityManagerCollaborator::NOTIFY_START_ABILITY, data, reply, option);
51 if (ret != NO_ERROR) {
52 TAG_LOGE(AAFwkTag::ABILITYMGR, "Send request error: %{public}d", ret);
53 return ret;
54 }
55 ret = reply.ReadInt32();
56 if (ret != NO_ERROR) {
57 TAG_LOGE(AAFwkTag::ABILITYMGR, "notify start ability failed");
58 return ERR_INVALID_OPERATION;
59 }
60 std::unique_ptr<Want> wantInfo(reply.ReadParcelable<Want>());
61 if (!wantInfo) {
62 TAG_LOGE(AAFwkTag::ABILITYMGR, "readParcelableInfo failed");
63 return ERR_INVALID_OPERATION;
64 }
65 want = *wantInfo;
66 return NO_ERROR;
67 }
68
NotifyMissionCreated(int32_t missionId,const Want & want)69 int32_t AbilityManagerCollaboratorProxy::NotifyMissionCreated(int32_t missionId, const Want &want)
70 {
71 MessageParcel data;
72 MessageParcel reply;
73 MessageOption option(MessageOption::TF_SYNC);
74
75 if (!data.WriteInterfaceToken(AbilityManagerCollaboratorProxy::GetDescriptor())) {
76 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write interface token failed.");
77 return ERR_INVALID_OPERATION;
78 }
79 if (!data.WriteInt32(missionId)) {
80 TAG_LOGE(AAFwkTag::ABILITYMGR, "missionId write failed.");
81 return ERR_INVALID_OPERATION;
82 }
83 if (!data.WriteParcelable(&want)) {
84 TAG_LOGE(AAFwkTag::ABILITYMGR, "want write failed.");
85 return ERR_INVALID_OPERATION;
86 }
87 int32_t ret = SendTransactCmd(IAbilityManagerCollaborator::NOTIFY_MISSION_CREATED, data, reply, option);
88 if (ret != NO_ERROR) {
89 TAG_LOGE(AAFwkTag::ABILITYMGR, "Send request error: %{public}d", ret);
90 return ret;
91 }
92 return NO_ERROR;
93 }
94
NotifyMissionCreated(const sptr<SessionInfo> & sessionInfo)95 int32_t AbilityManagerCollaboratorProxy::NotifyMissionCreated(const sptr<SessionInfo> &sessionInfo)
96 {
97 MessageParcel data;
98 MessageParcel reply;
99 MessageOption option(MessageOption::TF_SYNC);
100
101 if (!data.WriteInterfaceToken(AbilityManagerCollaboratorProxy::GetDescriptor())) {
102 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write interface token failed.");
103 return ERR_INVALID_OPERATION;
104 }
105 if (sessionInfo) {
106 if (!data.WriteBool(true) || !data.WriteParcelable(sessionInfo)) {
107 TAG_LOGE(AAFwkTag::ABILITYMGR, "flag and sessionInfo write failed.");
108 return ERR_INVALID_OPERATION;
109 }
110 } else {
111 if (!data.WriteBool(false)) {
112 TAG_LOGE(AAFwkTag::ABILITYMGR, "flag write failed.");
113 return ERR_INVALID_OPERATION;
114 }
115 }
116 int32_t ret = SendTransactCmd(IAbilityManagerCollaborator::NOTIFY_MISSION_CREATED_BY_SCB, data, reply, option);
117 if (ret != NO_ERROR) {
118 TAG_LOGE(AAFwkTag::ABILITYMGR, "Send request error: %{public}d", ret);
119 return ret;
120 }
121 return NO_ERROR;
122 }
123
NotifyLoadAbility(const AppExecFwk::AbilityInfo & abilityInfo,int32_t missionId,const Want & want)124 int32_t AbilityManagerCollaboratorProxy::NotifyLoadAbility(
125 const AppExecFwk::AbilityInfo &abilityInfo, int32_t missionId, const Want &want)
126 {
127 MessageParcel data;
128 MessageParcel reply;
129 MessageOption option(MessageOption::TF_SYNC);
130
131 if (!data.WriteInterfaceToken(AbilityManagerCollaboratorProxy::GetDescriptor())) {
132 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write interface token failed.");
133 return ERR_INVALID_OPERATION;
134 }
135 if (!data.WriteParcelable(&abilityInfo)) {
136 TAG_LOGE(AAFwkTag::ABILITYMGR, "abilityInfo write failed.");
137 return ERR_INVALID_OPERATION;
138 }
139 if (!data.WriteInt32(missionId)) {
140 TAG_LOGE(AAFwkTag::ABILITYMGR, "missionId write failed.");
141 return ERR_INVALID_OPERATION;
142 }
143 if (!data.WriteParcelable(&want)) {
144 TAG_LOGE(AAFwkTag::ABILITYMGR, "want write failed.");
145 return ERR_INVALID_OPERATION;
146 }
147 int32_t ret = SendTransactCmd(IAbilityManagerCollaborator::NOTIFY_LOAD_ABILITY, data, reply, option);
148 if (ret != NO_ERROR) {
149 TAG_LOGE(AAFwkTag::ABILITYMGR, "Send request error: %{public}d", ret);
150 return ret;
151 }
152 return NO_ERROR;
153 }
154
NotifyLoadAbility(const AppExecFwk::AbilityInfo & abilityInfo,const sptr<SessionInfo> & sessionInfo)155 int32_t AbilityManagerCollaboratorProxy::NotifyLoadAbility(
156 const AppExecFwk::AbilityInfo &abilityInfo, const sptr<SessionInfo> &sessionInfo)
157 {
158 MessageParcel data;
159 MessageParcel reply;
160 MessageOption option(MessageOption::TF_SYNC);
161
162 if (!data.WriteInterfaceToken(AbilityManagerCollaboratorProxy::GetDescriptor())) {
163 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write interface token failed.");
164 return ERR_INVALID_OPERATION;
165 }
166 if (!data.WriteParcelable(&abilityInfo)) {
167 TAG_LOGE(AAFwkTag::ABILITYMGR, "abilityInfo write failed.");
168 return ERR_INVALID_OPERATION;
169 }
170 if (sessionInfo) {
171 if (!data.WriteBool(true) || !data.WriteParcelable(sessionInfo)) {
172 TAG_LOGE(AAFwkTag::ABILITYMGR, "flag and sessionInfo write failed.");
173 return ERR_INVALID_OPERATION;
174 }
175 } else {
176 if (!data.WriteBool(false)) {
177 TAG_LOGE(AAFwkTag::ABILITYMGR, "flag write failed.");
178 return ERR_INVALID_OPERATION;
179 }
180 }
181 int32_t ret = SendTransactCmd(IAbilityManagerCollaborator::NOTIFY_LOAD_ABILITY_BY_SCB, data, reply, option);
182 if (ret != NO_ERROR) {
183 TAG_LOGE(AAFwkTag::ABILITYMGR, "Send request error: %{public}d", ret);
184 return ret;
185 }
186 return NO_ERROR;
187 }
188
NotifyMoveMissionToBackground(int32_t missionId)189 int32_t AbilityManagerCollaboratorProxy::NotifyMoveMissionToBackground(int32_t missionId)
190 {
191 MessageParcel data;
192 MessageParcel reply;
193 MessageOption option(MessageOption::TF_ASYNC);
194
195 if (!data.WriteInterfaceToken(AbilityManagerCollaboratorProxy::GetDescriptor())) {
196 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write interface token failed.");
197 return ERR_INVALID_OPERATION;
198 }
199 if (!data.WriteInt32(missionId)) {
200 TAG_LOGE(AAFwkTag::ABILITYMGR, "missionId write failed.");
201 return ERR_INVALID_OPERATION;
202 }
203 int32_t ret = SendTransactCmd(
204 IAbilityManagerCollaborator::NOTIFY_MOVE_MISSION_TO_BACKGROUND, data, reply, option);
205 if (ret != NO_ERROR) {
206 TAG_LOGE(AAFwkTag::ABILITYMGR, "Send request error: %{public}d", ret);
207 return ret;
208 }
209 return NO_ERROR;
210 }
211
NotifyPreloadAbility(const std::string & bundleName)212 int32_t AbilityManagerCollaboratorProxy::NotifyPreloadAbility(const std::string &bundleName)
213 {
214 MessageParcel data;
215 MessageParcel reply;
216 MessageOption option(MessageOption::TF_ASYNC);
217
218 if (!data.WriteInterfaceToken(AbilityManagerCollaboratorProxy::GetDescriptor())) {
219 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write interface token failed.");
220 return ERR_INVALID_OPERATION;
221 }
222 if (!data.WriteString16(Str8ToStr16(bundleName))) {
223 TAG_LOGE(AAFwkTag::ABILITYMGR, "bundleName write failed.");
224 return ERR_INVALID_OPERATION;
225 }
226 auto remote = Remote();
227 if (!remote) {
228 TAG_LOGE(AAFwkTag::ABILITYMGR, "remote is nullptr");
229 return ERR_INVALID_OPERATION;
230 }
231 int32_t ret = remote->SendRequest(
232 IAbilityManagerCollaborator::NOTIFY_PRELOAD_ABILITY, data, reply, option);
233 if (ret != NO_ERROR) {
234 TAG_LOGE(AAFwkTag::ABILITYMGR, "Send request error: %{public}d", ret);
235 return ret;
236 }
237 return NO_ERROR;
238 }
239
NotifyMoveMissionToForeground(int32_t missionId)240 int32_t AbilityManagerCollaboratorProxy::NotifyMoveMissionToForeground(int32_t missionId)
241 {
242 MessageParcel data;
243 MessageParcel reply;
244 MessageOption option(MessageOption::TF_ASYNC);
245
246 if (!data.WriteInterfaceToken(AbilityManagerCollaboratorProxy::GetDescriptor())) {
247 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write interface token failed.");
248 return ERR_INVALID_OPERATION;
249 }
250 if (!data.WriteInt32(missionId)) {
251 TAG_LOGE(AAFwkTag::ABILITYMGR, "missionId write failed.");
252 return ERR_INVALID_OPERATION;
253 }
254 int32_t ret = SendTransactCmd(
255 IAbilityManagerCollaborator::NOTIFY_MOVE_MISSION_TO_FOREGROUND, data, reply, option);
256 if (ret != NO_ERROR) {
257 TAG_LOGE(AAFwkTag::ABILITYMGR, "Send request error: %{public}d", ret);
258 return ret;
259 }
260 return NO_ERROR;
261 }
262
NotifyTerminateMission(int32_t missionId)263 int32_t AbilityManagerCollaboratorProxy::NotifyTerminateMission(int32_t missionId)
264 {
265 MessageParcel data;
266 MessageParcel reply;
267 MessageOption option(MessageOption::TF_ASYNC);
268
269 if (!data.WriteInterfaceToken(AbilityManagerCollaboratorProxy::GetDescriptor())) {
270 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write interface token failed.");
271 return ERR_INVALID_OPERATION;
272 }
273 if (!data.WriteInt32(missionId)) {
274 TAG_LOGE(AAFwkTag::ABILITYMGR, "missionId write failed.");
275 return ERR_INVALID_OPERATION;
276 }
277 int32_t ret = SendTransactCmd(
278 IAbilityManagerCollaborator::NOTIFY_TERMINATE_MISSION, data, reply, option);
279 if (ret != NO_ERROR) {
280 TAG_LOGE(AAFwkTag::ABILITYMGR, "Send request error: %{public}d", ret);
281 return ret;
282 }
283 return NO_ERROR;
284 }
285
NotifyClearMission(int32_t missionId)286 int32_t AbilityManagerCollaboratorProxy::NotifyClearMission(int32_t missionId)
287 {
288 MessageParcel data;
289 MessageParcel reply;
290 MessageOption option(MessageOption::TF_SYNC);
291
292 if (!data.WriteInterfaceToken(AbilityManagerCollaboratorProxy::GetDescriptor())) {
293 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write interface token failed.");
294 return ERR_INVALID_OPERATION;
295 }
296 if (!data.WriteInt32(missionId)) {
297 TAG_LOGE(AAFwkTag::ABILITYMGR, "missionId write failed.");
298 return ERR_INVALID_OPERATION;
299 }
300 int32_t ret = SendTransactCmd(
301 IAbilityManagerCollaborator::NOTIFY_CLEAR_MISSION, data, reply, option);
302 if (ret != NO_ERROR) {
303 TAG_LOGE(AAFwkTag::ABILITYMGR, "Send request error: %{public}d", ret);
304 return ret;
305 }
306 return NO_ERROR;
307 }
308
NotifyRemoveShellProcess(int32_t pid,int32_t type,const std::string & reason)309 int32_t AbilityManagerCollaboratorProxy::NotifyRemoveShellProcess(int32_t pid, int32_t type, const std::string &reason)
310 {
311 MessageParcel data;
312 MessageParcel reply;
313 MessageOption option(MessageOption::TF_ASYNC);
314
315 if (!data.WriteInterfaceToken(AbilityManagerCollaboratorProxy::GetDescriptor())) {
316 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write interface token failed.");
317 return ERR_INVALID_OPERATION;
318 }
319 if (!data.WriteInt32(pid)) {
320 TAG_LOGE(AAFwkTag::ABILITYMGR, "pid write failed.");
321 return ERR_INVALID_OPERATION;
322 }
323 if (!data.WriteInt32(type)) {
324 TAG_LOGE(AAFwkTag::ABILITYMGR, "type write failed.");
325 return ERR_INVALID_OPERATION;
326 }
327 if (!data.WriteString16(Str8ToStr16(reason))) {
328 TAG_LOGE(AAFwkTag::ABILITYMGR, "reason write failed.");
329 return ERR_INVALID_OPERATION;
330 }
331 int32_t ret = SendTransactCmd(
332 IAbilityManagerCollaborator::NOTIFY_REMOVE_SHELL_PROCESS, data, reply, option);
333 if (ret != NO_ERROR) {
334 TAG_LOGE(AAFwkTag::ABILITYMGR, "Send request error: %{public}d", ret);
335 return ret;
336 }
337 return NO_ERROR;
338 }
339
UpdateMissionInfo(InnerMissionInfoDto & info)340 void AbilityManagerCollaboratorProxy::UpdateMissionInfo(InnerMissionInfoDto &info)
341 {
342 MessageParcel data;
343 MessageParcel reply;
344 MessageOption option;
345
346 if (!data.WriteInterfaceToken(AbilityManagerCollaboratorProxy::GetDescriptor())) {
347 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write interface token failed.");
348 return;
349 }
350
351 if (!data.WriteParcelable(&info)) {
352 TAG_LOGE(AAFwkTag::ABILITYMGR, "write mission info failed.");
353 return;
354 }
355
356 int32_t ret = SendTransactCmd(IAbilityManagerCollaborator::UPDATE_MISSION_INFO, data, reply, option);
357 if (ret != NO_ERROR) {
358 TAG_LOGE(AAFwkTag::ABILITYMGR, "Send request error: %{public}d", ret);
359 return;
360 }
361
362 std::unique_ptr<InnerMissionInfoDto> innerInfo(reply.ReadParcelable<InnerMissionInfoDto>());
363 if (!innerInfo) {
364 TAG_LOGE(AAFwkTag::ABILITYMGR, "Get InnerMissionInfoDto error.");
365 return;
366 }
367 info = *innerInfo;
368 return;
369 }
370
UpdateMissionInfo(sptr<SessionInfo> & sessionInfo)371 void AbilityManagerCollaboratorProxy::UpdateMissionInfo(sptr<SessionInfo> &sessionInfo)
372 {
373 MessageParcel data;
374 MessageParcel reply;
375 MessageOption option;
376
377 if (!data.WriteInterfaceToken(AbilityManagerCollaboratorProxy::GetDescriptor())) {
378 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write interface token failed.");
379 return;
380 }
381
382 if (sessionInfo) {
383 if (!data.WriteBool(true) || !data.WriteParcelable(sessionInfo)) {
384 TAG_LOGE(AAFwkTag::ABILITYMGR, "flag and sessionInfo write failed.");
385 return;
386 }
387 } else {
388 if (!data.WriteBool(false)) {
389 TAG_LOGE(AAFwkTag::ABILITYMGR, "flag write failed.");
390 return;
391 }
392 }
393
394 int32_t ret = SendTransactCmd(IAbilityManagerCollaborator::UPDATE_MISSION_INFO_BY_SCB, data, reply, option);
395 if (ret != NO_ERROR) {
396 TAG_LOGE(AAFwkTag::ABILITYMGR, "Send request error: %{public}d", ret);
397 return;
398 }
399
400 sessionInfo = reply.ReadParcelable<SessionInfo>();
401 return;
402 }
403
CheckCallAbilityPermission(const Want & want)404 int32_t AbilityManagerCollaboratorProxy::CheckCallAbilityPermission(const Want &want)
405 {
406 MessageParcel data;
407 MessageParcel reply;
408 MessageOption option;
409
410 if (!data.WriteInterfaceToken(AbilityManagerCollaboratorProxy::GetDescriptor())) {
411 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write interface token failed.");
412 return ERR_INVALID_OPERATION;
413 }
414
415 if (!data.WriteParcelable(&want)) {
416 TAG_LOGE(AAFwkTag::ABILITYMGR, "want write failed.");
417 return ERR_INVALID_OPERATION;
418 }
419 int32_t ret = SendTransactCmd(IAbilityManagerCollaborator::CHECK_CALL_ABILITY_PERMISSION,
420 data, reply, option);
421 if (ret != NO_ERROR) {
422 TAG_LOGE(AAFwkTag::ABILITYMGR, "Send request error: %{public}d", ret);
423 return ret;
424 }
425 return reply.ReadInt32();
426 }
427
UpdateConfiguration(const AppExecFwk::Configuration & config,int32_t userId)428 bool AbilityManagerCollaboratorProxy::UpdateConfiguration(const AppExecFwk::Configuration &config, int32_t userId)
429 {
430 MessageParcel data;
431 MessageParcel reply;
432 MessageOption option(MessageOption::TF_ASYNC);
433 if (!data.WriteInterfaceToken(AbilityManagerCollaboratorProxy::GetDescriptor())) {
434 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write interface token failed.");
435 return false;
436 }
437 if (!data.WriteParcelable(&config)) {
438 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write config failed.");
439 return false;
440 }
441 if (!data.WriteInt32(userId)) {
442 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write usr failed.");
443 return false;
444 }
445 auto error = SendTransactCmd(IAbilityManagerCollaborator::UPDATE_CONFIGURATION, data, reply, option);
446 if (error != NO_ERROR) {
447 TAG_LOGE(AAFwkTag::ABILITYMGR, "Send config error: %{public}d", error);
448 return true;
449 }
450 return true;
451 }
452
OpenFile(const Uri & uri,uint32_t flag)453 int32_t AbilityManagerCollaboratorProxy::OpenFile(const Uri& uri, uint32_t flag)
454 {
455 MessageParcel data;
456 MessageParcel reply;
457 MessageOption option;
458 if (!data.WriteInterfaceToken(AbilityManagerCollaboratorProxy::GetDescriptor())) {
459 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write interface token failed.");
460 return false;
461 }
462 if (!data.WriteParcelable(&uri)) {
463 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write uri failed.");
464 return false;
465 }
466 if (!data.WriteInt32(flag)) {
467 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write flag failed.");
468 return false;
469 }
470
471 int32_t ret = SendTransactCmd(IAbilityManagerCollaborator::OPEN_FILE, data, reply, option);
472 if (ret != NO_ERROR) {
473 TAG_LOGE(AAFwkTag::ABILITYMGR, "Send request error: %{public}d", ret);
474 return -1;
475 }
476 return reply.ReadFileDescriptor();
477 }
478
NotifyMissionBindPid(int32_t missionId,int32_t pid)479 void AbilityManagerCollaboratorProxy::NotifyMissionBindPid(int32_t missionId, int32_t pid)
480 {
481 MessageParcel data;
482 MessageParcel reply;
483 MessageOption option(MessageOption::TF_ASYNC);
484 if (!data.WriteInterfaceToken(AbilityManagerCollaboratorProxy::GetDescriptor())) {
485 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write interface token failed.");
486 return;
487 }
488 if (!data.WriteInt32(missionId)) {
489 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write missionId failed.");
490 return;
491 }
492 if (!data.WriteInt32(pid)) {
493 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write pid failed.");
494 return;
495 }
496 auto error = SendTransactCmd(IAbilityManagerCollaborator::NOTIFY_MISSION_BIND_PID, data, reply, option);
497 if (error != NO_ERROR) {
498 TAG_LOGE(AAFwkTag::ABILITYMGR, "Send config error: %{public}d", error);
499 }
500 }
501
CheckStaticCfgPermission(const Want & want,bool isImplicit)502 int32_t AbilityManagerCollaboratorProxy::CheckStaticCfgPermission(const Want &want, bool isImplicit)
503 {
504 MessageParcel data;
505 MessageParcel reply;
506 MessageOption option(MessageOption::TF_SYNC);
507 if (!data.WriteInterfaceToken(AbilityManagerCollaboratorProxy::GetDescriptor())) {
508 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write interface token failed.");
509 return ERR_INVALID_OPERATION;
510 }
511 if (!data.WriteParcelable(&want)) {
512 TAG_LOGE(AAFwkTag::ABILITYMGR, "want write failed.");
513 return ERR_INVALID_OPERATION;
514 }
515 if (!data.WriteBool(isImplicit)) {
516 TAG_LOGE(AAFwkTag::ABILITYMGR, "isImplicit write failed.");
517 return ERR_INVALID_OPERATION;
518 }
519 int32_t ret = SendTransactCmd(IAbilityManagerCollaborator::CHECK_STATIC_CFG_PERMISSION,
520 data, reply, option);
521 if (ret != NO_ERROR) {
522 TAG_LOGE(AAFwkTag::ABILITYMGR, "Send request error: %{public}d", ret);
523 return ret;
524 }
525 return reply.ReadInt32();
526 }
527
SendTransactCmd(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)528 int32_t AbilityManagerCollaboratorProxy::SendTransactCmd(uint32_t code, MessageParcel &data,
529 MessageParcel &reply, MessageOption &option)
530 {
531 sptr<IRemoteObject> remote = Remote();
532 if (remote == nullptr) {
533 TAG_LOGE(AAFwkTag::ABILITYMGR, "Remote is nullptr.");
534 return ERR_NULL_OBJECT;
535 }
536
537 return remote->SendRequest(code, data, reply, option);
538 }
539 } // namespace AAFwk
540 } // namespace OHOS
541