• 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 
16 #include "ipc/create_dir_param.h"
17 
18 #include "app_log_wrapper.h"
19 #include "parcel_macro.h"
20 #include "string_ex.h"
21 
22 namespace OHOS {
23 namespace AppExecFwk {
ReadFromParcel(Parcel & parcel)24 bool CreateDirParam::ReadFromParcel(Parcel &parcel)
25 {
26     bundleName = Str16ToStr8(parcel.ReadString16());
27     apl = Str16ToStr8(parcel.ReadString16());
28     userId = parcel.ReadInt32();
29     uid = parcel.ReadInt32();
30     gid = parcel.ReadInt32();
31     isPreInstallApp = parcel.ReadBool();
32     debug = parcel.ReadBool();
33     createDirFlag = static_cast<CreateDirFlag>(parcel.ReadInt32());
34     return true;
35 }
36 
Marshalling(Parcel & parcel) const37 bool CreateDirParam::Marshalling(Parcel &parcel) const
38 {
39     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(bundleName));
40     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(apl));
41     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, userId);
42     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, uid);
43     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, gid);
44     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isPreInstallApp);
45     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, debug);
46     WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(createDirFlag));
47     return true;
48 }
49 
Unmarshalling(Parcel & parcel)50 CreateDirParam *CreateDirParam::Unmarshalling(Parcel &parcel)
51 {
52     CreateDirParam *info = new (std::nothrow) CreateDirParam();
53     if (info) {
54         info->ReadFromParcel(parcel);
55     }
56     return info;
57 }
58 }  // namespace AppExecFwk
59 }  // namespace OHOS
60