• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "system_ability_manager_proxy.h"
17 
18 #include <string>
19 #include <unistd.h>
20 
21 #include "datetime_ex.h"
22 #include "errors.h"
23 #include "ipc_types.h"
24 #include "parcel.h"
25 #include "string_ex.h"
26 
27 #include "sam_log.h"
28 
29 using namespace std;
30 namespace OHOS {
31 namespace {
32 const int32_t RETRY_TIME_OUT_NUMBER = 10;
33 const int32_t SLEEP_INTERVAL_TIME = 100;
34 const int32_t SLEEP_ONE_MILLI_SECOND_TIME = 1000;
35 }
GetSystemAbility(int32_t systemAbilityId)36 sptr<IRemoteObject> SystemAbilityManagerProxy::GetSystemAbility(int32_t systemAbilityId)
37 {
38     return GetSystemAbilityWrapper(systemAbilityId);
39 }
40 
GetSystemAbility(int32_t systemAbilityId,const std::string & deviceId)41 sptr<IRemoteObject> SystemAbilityManagerProxy::GetSystemAbility(int32_t systemAbilityId,
42     const std::string& deviceId)
43 {
44     return GetSystemAbilityWrapper(systemAbilityId, deviceId);
45 }
46 
GetSystemAbilityWrapper(int32_t systemAbilityId,const string & deviceId)47 sptr<IRemoteObject> SystemAbilityManagerProxy::GetSystemAbilityWrapper(int32_t systemAbilityId, const string& deviceId)
48 {
49     if (!CheckInputSysAbilityId(systemAbilityId)) {
50         HILOGW("GetSystemAbilityWrapper systemAbilityId invalid:%{public}d!", systemAbilityId);
51         return nullptr;
52     }
53 
54     bool isExist = false;
55     int32_t timeout = RETRY_TIME_OUT_NUMBER;
56     HILOGD("GetSystemAbilityWrapper:Waiting for sa %{public}d, ", systemAbilityId);
57     do {
58         sptr<IRemoteObject> svc;
59         if (deviceId.empty()) {
60             svc = CheckSystemAbility(systemAbilityId, isExist);
61             if (!isExist) {
62                 HILOGE("%{public}s:sa %{public}d is not exist", __func__, systemAbilityId);
63                 usleep(SLEEP_ONE_MILLI_SECOND_TIME * SLEEP_INTERVAL_TIME);
64                 continue;
65             }
66         } else {
67             svc = CheckSystemAbility(systemAbilityId, deviceId);
68         }
69 
70         if (svc != nullptr) {
71             HILOGD("GetSystemAbilityWrapper found sa %{public}d", systemAbilityId);
72             return svc;
73         }
74         usleep(SLEEP_ONE_MILLI_SECOND_TIME * SLEEP_INTERVAL_TIME);
75     } while (timeout--);
76     HILOGE("GetSystemAbilityWrapper sa %{public}d didn't start. Returning nullptr", systemAbilityId);
77     return nullptr;
78 }
79 
CheckSystemAbilityWrapper(int32_t code,MessageParcel & data)80 sptr<IRemoteObject> SystemAbilityManagerProxy::CheckSystemAbilityWrapper(int32_t code, MessageParcel& data)
81 {
82     auto remote = Remote();
83     if (remote == nullptr) {
84         HILOGI("GetSystemAbilityWrapper remote is nullptr !");
85         return nullptr;
86     }
87     MessageParcel reply;
88     MessageOption option;
89     int32_t err = remote->SendRequest(code, data, reply, option);
90     if (err != ERR_NONE) {
91         HILOGE("CheckSystemAbility SA not found error:%{public}d!", err);
92         return nullptr;
93     }
94     return reply.ReadRemoteObject();
95 }
96 
CheckSystemAbility(int32_t systemAbilityId)97 sptr<IRemoteObject> SystemAbilityManagerProxy::CheckSystemAbility(int32_t systemAbilityId)
98 {
99     HILOGI("%{public}s called", __func__);
100     if (!CheckInputSysAbilityId(systemAbilityId)) {
101         HILOGW("systemAbilityId:%{public}d invalid!", systemAbilityId);
102         return nullptr;
103     }
104     MessageParcel data;
105     bool ret = data.WriteInt32(systemAbilityId);
106     if (!ret) {
107         HILOGW("CheckSystemAbility Write systemAbilityId failed!");
108         return nullptr;
109     }
110     return CheckSystemAbilityWrapper(CHECK_SYSTEM_ABILITY_TRANSACTION, data);
111 }
112 
CheckSystemAbility(int32_t systemAbilityId,const std::string & deviceId)113 sptr<IRemoteObject> SystemAbilityManagerProxy::CheckSystemAbility(int32_t systemAbilityId, const std::string& deviceId)
114 {
115     if (!CheckInputSysAbilityId(systemAbilityId) || deviceId.empty()) {
116         HILOGW("CheckSystemAbility:systemAbilityId:%{public}d or deviceId is nullptr.", systemAbilityId);
117         return nullptr;
118     }
119 
120     HILOGD("CheckSystemAbility: ability id is : %{public}d, deviceId is %{private}s", systemAbilityId,
121         deviceId.c_str());
122 
123     auto remote = Remote();
124     if (remote == nullptr) {
125         HILOGE("CheckSystemAbility remote is nullptr !");
126         return nullptr;
127     }
128 
129     MessageParcel data;
130     if (!data.WriteInterfaceToken(SAMANAGER_INTERFACE_TOKEN)) {
131         return nullptr;
132     }
133     bool ret = data.WriteInt32(systemAbilityId);
134     if (!ret) {
135         HILOGE("CheckSystemAbility parcel write name failed");
136         return nullptr;
137     }
138     ret = data.WriteString(deviceId);
139     if (!ret) {
140         HILOGE("CheckSystemAbility parcel write deviceId failed");
141         return nullptr;
142     }
143 
144     return CheckSystemAbilityWrapper(CHECK_REMOTE_SYSTEM_ABILITY_TRANSACTION, data);
145 }
146 
CheckSystemAbility(int32_t systemAbilityId,bool & isExist)147 sptr<IRemoteObject> SystemAbilityManagerProxy::CheckSystemAbility(int32_t systemAbilityId, bool& isExist)
148 {
149     HILOGD("%{public}s called, ability id is %{public}d, isExist is %{public}d", __func__, systemAbilityId, isExist);
150     if (!CheckInputSysAbilityId(systemAbilityId)) {
151         HILOGW("CheckSystemAbility:systemAbilityId:%{public}d invalid!", systemAbilityId);
152         return nullptr;
153     }
154 
155     auto remote = Remote();
156     if (remote == nullptr) {
157         HILOGE("CheckSystemAbility remote is nullptr !");
158         return nullptr;
159     }
160 
161     MessageParcel data;
162     if (!data.WriteInterfaceToken(SAMANAGER_INTERFACE_TOKEN)) {
163         return nullptr;
164     }
165     bool ret = data.WriteInt32(systemAbilityId);
166     if (!ret) {
167         HILOGW("CheckSystemAbility Write systemAbilityId failed!");
168         return nullptr;
169     }
170 
171     ret = data.WriteBool(isExist);
172     if (!ret) {
173         HILOGW("CheckSystemAbility Write isExist failed!");
174         return nullptr;
175     }
176 
177     MessageParcel reply;
178     MessageOption option;
179     int32_t err = remote->SendRequest(CHECK_SYSTEM_ABILITY_IMMEDIATELY_TRANSACTION, data, reply, option);
180     if (err != ERR_NONE) {
181         HILOGE("CheckSystemAbility SA not found error:%{public}d!", err);
182         return nullptr;
183     }
184     sptr<IRemoteObject> irsp(reply.ReadRemoteObject());
185 
186     ret = reply.ReadBool(isExist);
187     if (!ret) {
188         HILOGW("CheckSystemAbility Read isExist failed!");
189         return nullptr;
190     }
191 
192     return irsp;
193 }
194 
AddOnDemandSystemAbilityInfo(int32_t systemAbilityId,const std::u16string & localAbilityManagerName)195 int32_t SystemAbilityManagerProxy::AddOnDemandSystemAbilityInfo(int32_t systemAbilityId,
196     const std::u16string& localAbilityManagerName)
197 {
198     HILOGI("%{public}s called, system ability name is : %{public}d ", __func__, systemAbilityId);
199     if (!CheckInputSysAbilityId(systemAbilityId) || localAbilityManagerName.empty()) {
200         HILOGI("AddOnDemandSystemAbilityInfo invalid params!");
201         return ERR_INVALID_VALUE;
202     }
203 
204     auto remote = Remote();
205     if (remote == nullptr) {
206         HILOGE("AddOnDemandSystemAbilityInfo remote is nullptr !");
207         return ERR_INVALID_OPERATION;
208     }
209 
210     MessageParcel data;
211     if (!data.WriteInterfaceToken(SAMANAGER_INTERFACE_TOKEN)) {
212         return ERR_FLATTEN_OBJECT;
213     }
214     bool ret = data.WriteInt32(systemAbilityId);
215     if (!ret) {
216         HILOGW("AddOnDemandSystemAbilityInfo Write systemAbilityId failed!");
217         return ERR_FLATTEN_OBJECT;
218     }
219 
220     ret = data.WriteString16(localAbilityManagerName);
221     if (!ret) {
222         HILOGW("AddOnDemandSystemAbilityInfo Write localAbilityManagerName failed!");
223         return ERR_FLATTEN_OBJECT;
224     }
225 
226     MessageParcel reply;
227     MessageOption option;
228     int32_t err = remote->SendRequest(ADD_ONDEMAND_SYSTEM_ABILITY_TRANSACTION, data, reply, option);
229 
230     HILOGI("%{public}s:add ondemand system ability %{public}d %{public}s, return %{public}d",
231         __func__, systemAbilityId, err ? "fail" : "succ", err);
232     if (err != ERR_NONE) {
233         HILOGE("AddOnDemandSystemAbilityInfo SA not found error:%{public}d!", err);
234         return err;
235     }
236 
237     int32_t result = 0;
238     ret = reply.ReadInt32(result);
239     if (!ret) {
240         HILOGW("AddOnDemandSystemAbilityInfo Read result failed!");
241         return ERR_FLATTEN_OBJECT;
242     }
243     return result;
244 }
245 
RemoveSystemAbilityWrapper(int32_t code,MessageParcel & data)246 int32_t SystemAbilityManagerProxy::RemoveSystemAbilityWrapper(int32_t code, MessageParcel& data)
247 {
248     sptr<IRemoteObject> remote = Remote();
249     if (remote == nullptr) {
250         HILOGI("remote is nullptr !");
251         return ERR_INVALID_OPERATION;
252     }
253     MessageParcel reply;
254     MessageOption option;
255     int32_t err = remote->SendRequest(code, data, reply, option);
256     if (err != ERR_NONE) {
257         HILOGE("RemoveSystemAbility SendRequest error:%{public}d!", err);
258         return err;
259     }
260 
261     int32_t result = 0;
262     bool ret = reply.ReadInt32(result);
263     if (!ret) {
264         HILOGW("RemoveSystemAbility Read result failed!");
265         return ERR_FLATTEN_OBJECT;
266     }
267 
268     return result;
269 }
270 
RemoveSystemAbility(int32_t systemAbilityId)271 int32_t SystemAbilityManagerProxy::RemoveSystemAbility(int32_t systemAbilityId)
272 {
273     HILOGI("%{public}s called", __func__);
274     if (!CheckInputSysAbilityId(systemAbilityId)) {
275         HILOGW("systemAbilityId:%{public}d is invalid!", systemAbilityId);
276         return ERR_INVALID_VALUE;
277     }
278 
279     HILOGI("remove system ability id is : %{public}d \n", systemAbilityId);
280     MessageParcel data;
281     if (!data.WriteInterfaceToken(SAMANAGER_INTERFACE_TOKEN)) {
282         return ERR_FLATTEN_OBJECT;
283     }
284     bool ret = data.WriteInt32(systemAbilityId);
285     if (!ret) {
286         HILOGW("RemoveSystemAbility Write systemAbilityId failed!");
287         return ERR_FLATTEN_OBJECT;
288     }
289     return RemoveSystemAbilityWrapper(REMOVE_SYSTEM_ABILITY_TRANSACTION, data);
290 }
291 
ListSystemAbilities(unsigned int dumpFlags)292 std::vector<u16string> SystemAbilityManagerProxy::ListSystemAbilities(unsigned int dumpFlags)
293 {
294     HILOGI("%{public}s called", __func__);
295     std::vector<u16string> saNames;
296 
297     sptr<IRemoteObject> remote = Remote();
298     if (remote == nullptr) {
299         HILOGI("remote is nullptr !");
300         return saNames;
301     }
302 
303     MessageParcel data;
304     if (!data.WriteInterfaceToken(SAMANAGER_INTERFACE_TOKEN)) {
305         HILOGW("ListSystemAbilities write token failed!");
306         return saNames;
307     }
308     bool ret = data.WriteInt32(dumpFlags);
309     if (!ret) {
310         HILOGW("ListSystemAbilities write dumpFlags failed!");
311         return saNames;
312     }
313     MessageParcel reply;
314     MessageOption option;
315     int32_t err = remote->SendRequest(LIST_SYSTEM_ABILITY_TRANSACTION, data, reply, option);
316     if (err != ERR_NONE) {
317         HILOGW("ListSystemAbilities transact failed!");
318         return saNames;
319     }
320     if (reply.ReadInt32() != ERR_NONE) {
321         HILOGW("ListSystemAbilities remote failed!");
322         return saNames;
323     }
324     if (!reply.ReadString16Vector(&saNames)) {
325         HILOGW("ListSystemAbilities read reply failed");
326         saNames.clear();
327     }
328     return saNames;
329 }
330 
SubscribeSystemAbility(int32_t systemAbilityId,const sptr<ISystemAbilityStatusChange> & listener)331 int32_t SystemAbilityManagerProxy::SubscribeSystemAbility(int32_t systemAbilityId,
332     const sptr<ISystemAbilityStatusChange>& listener)
333 {
334     HILOGI("%{public}s called", __func__);
335     if (!CheckInputSysAbilityId(systemAbilityId) || listener == nullptr) {
336         HILOGE("SubscribeSystemAbility systemAbilityId:%{public}d or listener invalid!", systemAbilityId);
337         return ERR_INVALID_VALUE;
338     }
339 
340     HILOGI("SubscribeSystemAbility systemAbilityId:%{public}d", systemAbilityId);
341 
342     sptr<IRemoteObject> remote = Remote();
343     if (remote == nullptr) {
344         HILOGI("remote is nullptr !");
345         return ERR_INVALID_OPERATION;
346     }
347 
348     MessageParcel data;
349     if (!data.WriteInterfaceToken(SAMANAGER_INTERFACE_TOKEN)) {
350         return ERR_FLATTEN_OBJECT;
351     }
352     bool ret = data.WriteInt32(systemAbilityId);
353     if (!ret) {
354         HILOGW("SubscribeSystemAbility Write systemAbilityId failed!");
355         return ERR_FLATTEN_OBJECT;
356     }
357 
358     ret = data.WriteRemoteObject(listener->AsObject());
359     if (!ret) {
360         HILOGW("SubscribeSystemAbility Write listenerName failed!");
361         return ERR_FLATTEN_OBJECT;
362     }
363 
364     MessageParcel reply;
365     MessageOption option;
366     int32_t err = remote->SendRequest(SUBSCRIBE_SYSTEM_ABILITY_TRANSACTION, data, reply, option);
367     if (err != ERR_NONE) {
368         HILOGE("SubscribeSystemAbility SendRequest error:%{public}d!", err);
369         return err;
370     }
371     HILOGI("SubscribeSystemAbility SendRequest succeed!");
372     int32_t result = 0;
373     ret = reply.ReadInt32(result);
374     if (!ret) {
375         HILOGW("SubscribeSystemAbility Read result failed!");
376         return ERR_FLATTEN_OBJECT;
377     }
378 
379     return result;
380 }
381 
UnSubscribeSystemAbility(int32_t systemAbilityId,const sptr<ISystemAbilityStatusChange> & listener)382 int32_t SystemAbilityManagerProxy::UnSubscribeSystemAbility(int32_t systemAbilityId,
383     const sptr<ISystemAbilityStatusChange>& listener)
384 {
385     HILOGI("%{public}s called", __func__);
386     if (!CheckInputSysAbilityId(systemAbilityId) || listener == nullptr) {
387         HILOGE("UnSubscribeSystemAbility systemAbilityId:%{public}d or listener invalid!", systemAbilityId);
388         return ERR_INVALID_VALUE;
389     }
390 
391     HILOGI("UnSubscribeSystemAbility systemAbilityId:%{public}d", systemAbilityId);
392 
393     sptr<IRemoteObject> remote = Remote();
394     if (remote == nullptr) {
395         HILOGI("remote is nullptr !");
396         return ERR_INVALID_OPERATION;
397     }
398 
399     MessageParcel data;
400     if (!data.WriteInterfaceToken(SAMANAGER_INTERFACE_TOKEN)) {
401         return ERR_FLATTEN_OBJECT;
402     }
403     bool ret = data.WriteInt32(systemAbilityId);
404     if (!ret) {
405         HILOGW("UnSubscribeSystemAbility Write systemAbilityId failed!");
406         return ERR_FLATTEN_OBJECT;
407     }
408 
409     ret = data.WriteRemoteObject(listener->AsObject());
410     if (!ret) {
411         HILOGW("UnSubscribeSystemAbility Write listenerSaId failed!");
412         return ERR_FLATTEN_OBJECT;
413     }
414 
415     MessageParcel reply;
416     MessageOption option;
417     int32_t err = remote->SendRequest(UNSUBSCRIBE_SYSTEM_ABILITY_TRANSACTION, data, reply, option);
418     if (err != ERR_NONE) {
419         HILOGE("UnSubscribeSystemAbility SendRequest error:%{public}d!", err);
420         return err;
421     }
422     HILOGI("UnSubscribeSystemAbility SendRequest succeed!");
423     int32_t result = 0;
424     ret = reply.ReadInt32(result);
425     if (!ret) {
426         HILOGW("UnSubscribeSystemAbility Read result failed!");
427         return ERR_FLATTEN_OBJECT;
428     }
429 
430     return result;
431 }
432 
LoadSystemAbility(int32_t systemAbilityId,const sptr<ISystemAbilityLoadCallback> & callback)433 int32_t SystemAbilityManagerProxy::LoadSystemAbility(int32_t systemAbilityId,
434     const sptr<ISystemAbilityLoadCallback>& callback)
435 {
436     if (!CheckInputSysAbilityId(systemAbilityId) || callback == nullptr) {
437         HILOGE("LoadSystemAbility systemAbilityId:%{public}d or callback invalid!", systemAbilityId);
438         return ERR_INVALID_VALUE;
439     }
440 
441     HILOGI("LoadSystemAbility systemAbilityId:%{public}d", systemAbilityId);
442     sptr<IRemoteObject> remote = Remote();
443     if (remote == nullptr) {
444         HILOGE("LoadSystemAbility remote is null!");
445         return ERR_INVALID_OPERATION;
446     }
447 
448     MessageParcel data;
449     if (!data.WriteInterfaceToken(SAMANAGER_INTERFACE_TOKEN)) {
450         HILOGW("LoadSystemAbility Write interface token failed!");
451         return ERR_FLATTEN_OBJECT;
452     }
453     bool ret = data.WriteInt32(systemAbilityId);
454     if (!ret) {
455         HILOGW("LoadSystemAbility Write systemAbilityId failed!");
456         return ERR_FLATTEN_OBJECT;
457     }
458     ret = data.WriteRemoteObject(callback->AsObject());
459     if (!ret) {
460         HILOGW("LoadSystemAbility Write callback failed!");
461         return ERR_FLATTEN_OBJECT;
462     }
463 
464     MessageParcel reply;
465     MessageOption option;
466     int32_t err = remote->SendRequest(LOAD_SYSTEM_ABILITY_TRANSACTION, data, reply, option);
467     if (err != ERR_NONE) {
468         HILOGE("LoadSystemAbility SA invalid error:%{public}d!", err);
469         return err;
470     }
471     HILOGI("LoadSystemAbility SendRequest succeed!");
472     int32_t result = 0;
473     ret = reply.ReadInt32(result);
474     if (!ret) {
475         HILOGW("LoadSystemAbility Read reply failed!");
476         return ERR_FLATTEN_OBJECT;
477     }
478     return result;
479 }
480 
MarshalSAExtraProp(const SAExtraProp & extraProp,MessageParcel & data) const481 int32_t SystemAbilityManagerProxy::MarshalSAExtraProp(const SAExtraProp& extraProp, MessageParcel& data) const
482 {
483     if (!data.WriteBool(extraProp.isDistributed)) {
484         HILOGW("MarshalSAExtraProp Write isDistributed failed!");
485         return ERR_FLATTEN_OBJECT;
486     }
487     if (!data.WriteInt32(extraProp.dumpFlags)) {
488         HILOGW("MarshalSAExtraProp Write dumpFlags failed!");
489         return ERR_FLATTEN_OBJECT;
490     }
491     if (!data.WriteString16(extraProp.capability)) {
492         HILOGW("MarshalSAExtraProp Write capability failed!");
493         return ERR_FLATTEN_OBJECT;
494     }
495     if (!data.WriteString16(extraProp.permission)) {
496         HILOGW("MarshalSAExtraProp Write defPermission failed!");
497         return ERR_FLATTEN_OBJECT;
498     }
499     return ERR_OK;
500 }
501 
AddSystemAbility(int32_t systemAbilityId,const sptr<IRemoteObject> & ability,const SAExtraProp & extraProp)502 int32_t SystemAbilityManagerProxy::AddSystemAbility(int32_t systemAbilityId, const sptr<IRemoteObject>& ability,
503     const SAExtraProp& extraProp)
504 {
505     HILOGI("%{public}s called, saId is %{public}d", __func__, systemAbilityId);
506     if (!CheckInputSysAbilityId(systemAbilityId)) {
507         HILOGW("systemAbilityId:%{public}d invalid.", systemAbilityId);
508         return ERR_INVALID_VALUE;
509     }
510 
511     MessageParcel data;
512     if (!data.WriteInterfaceToken(SAMANAGER_INTERFACE_TOKEN)) {
513         return ERR_FLATTEN_OBJECT;
514     }
515     if (!data.WriteInt32(systemAbilityId)) {
516         HILOGW("AddSystemAbility Write saId failed!");
517         return ERR_FLATTEN_OBJECT;
518     }
519     if (!data.WriteRemoteObject(ability)) {
520         HILOGW("AddSystemAbility Write ability failed!");
521         return ERR_FLATTEN_OBJECT;
522     }
523 
524     int32_t ret = MarshalSAExtraProp(extraProp, data);
525     if (ret != ERR_OK) {
526         HILOGW("AddSystemAbility MarshalSAExtraProp failed!");
527         return ret;
528     }
529     return AddSystemAbilityWrapper(ADD_SYSTEM_ABILITY_TRANSACTION, data);
530 }
531 
AddSystemAbilityWrapper(int32_t code,MessageParcel & data)532 int32_t SystemAbilityManagerProxy::AddSystemAbilityWrapper(int32_t code, MessageParcel& data)
533 {
534     sptr<IRemoteObject> remote = Remote();
535     if (remote == nullptr) {
536         HILOGI("remote is nullptr !");
537         return ERR_INVALID_OPERATION;
538     }
539 
540     MessageParcel reply;
541     MessageOption option;
542     int32_t err = remote->SendRequest(code, data, reply, option);
543     if (err != ERR_NONE) {
544         HILOGE("AddSystemAbility SA invalid error:%{public}d!", err);
545         return err;
546     }
547     int32_t result = 0;
548     bool ret = reply.ReadInt32(result);
549     if (!ret) {
550         HILOGE("AddSystemAbility read result error!");
551         return ERR_FLATTEN_OBJECT;
552     }
553     return result;
554 }
555 
AddSystemProcess(const u16string & procName,const sptr<IRemoteObject> & procObject)556 int32_t SystemAbilityManagerProxy::AddSystemProcess(const u16string& procName, const sptr<IRemoteObject>& procObject)
557 {
558     HILOGI("%{public}s called, process name is %{public}s", __func__, Str16ToStr8(procName).c_str());
559     if (procName.empty()) {
560         HILOGI("process name is invalid!");
561         return ERR_INVALID_VALUE;
562     }
563 
564     MessageParcel data;
565     if (!data.WriteInterfaceToken(SAMANAGER_INTERFACE_TOKEN)) {
566         return ERR_FLATTEN_OBJECT;
567     }
568     if (!data.WriteString16(procName)) {
569         HILOGW("AddSystemProcess Write name failed!");
570         return ERR_FLATTEN_OBJECT;
571     }
572 
573     if (!data.WriteRemoteObject(procObject)) {
574         HILOGW("AddSystemProcess Write ability failed!");
575         return ERR_FLATTEN_OBJECT;
576     }
577     return AddSystemAbilityWrapper(ADD_SYSTEM_PROCESS_TRANSACTION, data);
578 }
579 } // namespace OHOS
580