1 /* 2 * Copyright (c) 2021 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 "launch_param.h" 17 18 namespace OHOS { 19 namespace AAFwk { ReadFromParcel(Parcel & parcel)20bool LaunchParam::ReadFromParcel(Parcel &parcel) 21 { 22 int32_t reason = 0; 23 if (!parcel.ReadInt32(reason)) { 24 return false; 25 } 26 launchReason = static_cast<LaunchReason>(reason); 27 28 if (!parcel.ReadInt32(reason)) { 29 return false; 30 } 31 lastExitReason = static_cast<LastExitReason>(reason); 32 return true; 33 } 34 Unmarshalling(Parcel & parcel)35LaunchParam *LaunchParam::Unmarshalling(Parcel &parcel) 36 { 37 LaunchParam *param = new (std::nothrow) LaunchParam(); 38 if (param == nullptr) { 39 return nullptr; 40 } 41 42 if (!param->ReadFromParcel(parcel)) { 43 delete param; 44 param = nullptr; 45 } 46 return param; 47 } 48 Marshalling(Parcel & parcel) const49bool LaunchParam::Marshalling(Parcel &parcel) const 50 { 51 // write launchReason 52 if (!parcel.WriteInt32(static_cast<int32_t>(launchReason))) { 53 return false; 54 } 55 // write lastExitReason 56 if (!parcel.WriteInt32(static_cast<int32_t>(lastExitReason))) { 57 return false; 58 } 59 return true; 60 } 61 } // namespace AAFwk 62 } // namespace OHOS 63