• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2025 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 #include "auto_startup_info.h"
16 
17 #include "string_ex.h"
18 
19 namespace OHOS {
20 namespace AbilityRuntime {
ReadFromParcel(Parcel & parcel)21 bool AutoStartupInfo::ReadFromParcel(Parcel &parcel)
22 {
23     bundleName = Str16ToStr8(parcel.ReadString16());
24     abilityName = Str16ToStr8(parcel.ReadString16());
25     moduleName = Str16ToStr8(parcel.ReadString16());
26     abilityTypeName = Str16ToStr8(parcel.ReadString16());
27     appCloneIndex = parcel.ReadInt32();
28     userId = parcel.ReadInt32();
29     setterUserId = parcel.ReadInt32();
30     canUserModify = parcel.ReadBool();
31     return true;
32 }
33 
Unmarshalling(Parcel & parcel)34 AutoStartupInfo *AutoStartupInfo::Unmarshalling(Parcel &parcel)
35 {
36     AutoStartupInfo *info = new (std::nothrow) AutoStartupInfo();
37     if (info == nullptr) {
38         return nullptr;
39     }
40 
41     if (!info->ReadFromParcel(parcel)) {
42         delete info;
43         info = nullptr;
44     }
45     return info;
46 }
47 
Marshalling(Parcel & parcel) const48 bool AutoStartupInfo::Marshalling(Parcel &parcel) const
49 {
50     if (!parcel.WriteString16(Str8ToStr16(bundleName))) {
51         return false;
52     }
53     if (!parcel.WriteString16(Str8ToStr16(abilityName))) {
54         return false;
55     }
56     if (!parcel.WriteString16(Str8ToStr16(moduleName))) {
57         return false;
58     }
59     if (!parcel.WriteString16(Str8ToStr16(abilityTypeName))) {
60         return false;
61     }
62     if (!parcel.WriteInt32(appCloneIndex)) {
63         return false;
64     }
65     if (!parcel.WriteInt32(userId)) {
66         return false;
67     }
68     if (!parcel.WriteInt32(setterUserId)) {
69         return false;
70     }
71     if (!parcel.WriteBool(canUserModify)) {
72         return false;
73     }
74     return true;
75 }
76 } // namespace AbilityRuntime
77 } // namespace OHOS
78