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/check_encryption_param.h"
17
18 #include "parcel_macro.h"
19 #include "string_ex.h"
20
21 namespace OHOS {
22 namespace AppExecFwk {
ReadFromParcel(Parcel & parcel)23 bool CheckEncryptionParam::ReadFromParcel(Parcel &parcel)
24 {
25 modulePath = Str16ToStr8(parcel.ReadString16());
26 cpuAbi = Str16ToStr8(parcel.ReadString16());
27 targetSoPath = Str16ToStr8(parcel.ReadString16());
28 bundleId = parcel.ReadInt32();
29 installBundleType = static_cast<InstallBundleType>(parcel.ReadInt32());
30 isCompressNativeLibrary = parcel.ReadBool();
31 return true;
32 }
33
Marshalling(Parcel & parcel) const34 bool CheckEncryptionParam::Marshalling(Parcel &parcel) const
35 {
36 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(modulePath));
37 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(cpuAbi));
38 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(targetSoPath));
39 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, bundleId);
40 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(installBundleType));
41 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isCompressNativeLibrary);
42 return true;
43 }
44
Unmarshalling(Parcel & parcel)45 CheckEncryptionParam *CheckEncryptionParam::Unmarshalling(Parcel &parcel)
46 {
47 CheckEncryptionParam *info = new (std::nothrow) CheckEncryptionParam();
48 if (info && !info->ReadFromParcel(parcel)) {
49 APP_LOGW("read from parcel failed");
50 delete info;
51 info = nullptr;
52 }
53 return info;
54 }
55 } // namespace AppExecFwk
56 } // namespace OHOS
57