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 "app_verify_base_info.h"
17 #include "app_domain_verify_parcel_util.h"
18
19 namespace OHOS {
20 namespace AppDomainVerify {
AppVerifyBaseInfo()21 AppVerifyBaseInfo::AppVerifyBaseInfo()
22 {
23 appIdentifier = "";
24 bundleName = "";
25 fingerprint = "";
26 }
27
AppVerifyBaseInfo(const AppVerifyBaseInfo & appVerifyBaseInfo)28 AppVerifyBaseInfo::AppVerifyBaseInfo(const AppVerifyBaseInfo &appVerifyBaseInfo)
29 {
30 appIdentifier = appVerifyBaseInfo.appIdentifier;
31 bundleName = appVerifyBaseInfo.bundleName;
32 fingerprint = appVerifyBaseInfo.fingerprint;
33 }
Marshalling(Parcel & parcel) const34 bool AppVerifyBaseInfo::Marshalling(Parcel &parcel) const
35 {
36 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, appIdentifier);
37 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, bundleName);
38 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, fingerprint);
39 return true;
40 }
ReadFromParcel(Parcel & parcel)41 bool AppVerifyBaseInfo::ReadFromParcel(Parcel &parcel)
42 {
43 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, appIdentifier);
44 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, bundleName);
45 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, fingerprint);
46 return true;
47 }
48
Unmarshalling(Parcel & parcel)49 AppVerifyBaseInfo *AppVerifyBaseInfo::Unmarshalling(Parcel &parcel)
50 {
51 AppVerifyBaseInfo *appVerifyBaseInfo = new (std::nothrow) AppVerifyBaseInfo();
52 if (appVerifyBaseInfo && !appVerifyBaseInfo->ReadFromParcel(parcel)) {
53 APP_DOMAIN_VERIFY_HILOGE(APP_DOMAIN_VERIFY_MODULE_COMMON, "read from parcel failed");
54 delete appVerifyBaseInfo;
55 appVerifyBaseInfo = nullptr;
56 }
57 return appVerifyBaseInfo;
58 }
59
60 } // namespace AppDomainVerify
61 } // namespace OHOS
62