• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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     return true;
28 }
29 
Unmarshalling(Parcel & parcel)30 AutoStartupInfo *AutoStartupInfo::Unmarshalling(Parcel &parcel)
31 {
32     AutoStartupInfo *info = new (std::nothrow) AutoStartupInfo();
33     if (info == nullptr) {
34         return nullptr;
35     }
36 
37     if (!info->ReadFromParcel(parcel)) {
38         delete info;
39         info = nullptr;
40     }
41     return info;
42 }
43 
Marshalling(Parcel & parcel) const44 bool AutoStartupInfo::Marshalling(Parcel &parcel) const
45 {
46     if (!parcel.WriteString16(Str8ToStr16(bundleName))) {
47         return false;
48     }
49     if (!parcel.WriteString16(Str8ToStr16(abilityName))) {
50         return false;
51     }
52     if (!parcel.WriteString16(Str8ToStr16(moduleName))) {
53         return false;
54     }
55     if (!parcel.WriteString16(Str8ToStr16(abilityTypeName))) {
56         return false;
57     }
58     return true;
59 }
60 } // namespace AbilityRuntime
61 } // namespace OHOS
62