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 "native_token_info_parcel.h" 17 #include <iosfwd> 18 #include <new> 19 #include <string> 20 #include <vector> 21 #include "access_token.h" 22 #include "parcel_utils.h" 23 24 namespace OHOS { 25 namespace Security { 26 namespace AccessToken { Marshalling(Parcel& out) const27bool NativeTokenInfoParcel::Marshalling(Parcel& out) const 28 { 29 RETURN_IF_FALSE(out.WriteInt32(this->nativeTokenInfoParams.apl)); 30 RETURN_IF_FALSE(out.WriteString(this->nativeTokenInfoParams.processName)); 31 return true; 32 } 33 Unmarshalling(Parcel& in)34NativeTokenInfoParcel* NativeTokenInfoParcel::Unmarshalling(Parcel& in) 35 { 36 auto* nativeTokenInfoParcel = new (std::nothrow) NativeTokenInfoParcel(); 37 if (nativeTokenInfoParcel == nullptr) { 38 return nullptr; 39 } 40 41 int32_t apl; 42 RELEASE_IF_FALSE(in.ReadInt32(apl), nativeTokenInfoParcel); 43 nativeTokenInfoParcel->nativeTokenInfoParams.apl = ATokenAplEnum(apl); 44 nativeTokenInfoParcel->nativeTokenInfoParams.processName = in.ReadString(); 45 return nativeTokenInfoParcel; 46 } 47 } // namespace AccessToken 48 } // namespace Security 49 } // namespace OHOS 50