1 /*
2 * Copyright (c) 2021-2022 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 "hap_token_info_parcel.h"
17 #include "parcel_utils.h"
18
19 namespace OHOS {
20 namespace Security {
21 namespace AccessToken {
Marshalling(Parcel & out) const22 bool HapTokenInfoParcel::Marshalling(Parcel& out) const
23 {
24 RETURN_IF_FALSE(out.WriteUint8(this->hapTokenInfoParams.ver));
25 RETURN_IF_FALSE(out.WriteInt32(this->hapTokenInfoParams.userID));
26 RETURN_IF_FALSE(out.WriteString(this->hapTokenInfoParams.bundleName));
27 RETURN_IF_FALSE(out.WriteInt32(this->hapTokenInfoParams.apiVersion));
28 RETURN_IF_FALSE(out.WriteInt32(this->hapTokenInfoParams.instIndex));
29 RETURN_IF_FALSE(out.WriteInt32(this->hapTokenInfoParams.dlpType));
30 RETURN_IF_FALSE(out.WriteUint32(this->hapTokenInfoParams.tokenID));
31 RETURN_IF_FALSE(out.WriteUint32(this->hapTokenInfoParams.tokenAttr));
32 return true;
33 }
34
Unmarshalling(Parcel & in)35 HapTokenInfoParcel* HapTokenInfoParcel::Unmarshalling(Parcel& in)
36 {
37 auto* hapTokenInfoParcel = new (std::nothrow) HapTokenInfoParcel();
38 if (hapTokenInfoParcel == nullptr) {
39 return nullptr;
40 }
41
42 uint8_t ver;
43 RELEASE_IF_FALSE(in.ReadUint8(ver), hapTokenInfoParcel);
44 hapTokenInfoParcel->hapTokenInfoParams.ver = ver;
45 RELEASE_IF_FALSE(in.ReadInt32(hapTokenInfoParcel->hapTokenInfoParams.userID), hapTokenInfoParcel);
46 hapTokenInfoParcel->hapTokenInfoParams.bundleName = in.ReadString();
47 RELEASE_IF_FALSE(in.ReadInt32(hapTokenInfoParcel->hapTokenInfoParams.apiVersion), hapTokenInfoParcel);
48 RELEASE_IF_FALSE(in.ReadInt32(hapTokenInfoParcel->hapTokenInfoParams.instIndex), hapTokenInfoParcel);
49 RELEASE_IF_FALSE(in.ReadInt32(hapTokenInfoParcel->hapTokenInfoParams.dlpType), hapTokenInfoParcel);
50 RELEASE_IF_FALSE(in.ReadUint32(hapTokenInfoParcel->hapTokenInfoParams.tokenID), hapTokenInfoParcel);
51 RELEASE_IF_FALSE(in.ReadUint32(hapTokenInfoParcel->hapTokenInfoParams.tokenAttr), hapTokenInfoParcel);
52 return hapTokenInfoParcel;
53 }
54 } // namespace AccessToken
55 } // namespace Security
56 } // namespace OHOS
57