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 "ability_mission_info.h" 17 18 #include "hilog_wrapper.h" 19 #include "nlohmann/json.hpp" 20 #include "string_ex.h" 21 22 namespace OHOS { 23 namespace AAFwk { ReadFromParcel(Parcel & parcel)24bool AbilityMissionInfo::ReadFromParcel(Parcel &parcel) 25 { 26 id = parcel.ReadInt32(); 27 runingState = parcel.ReadInt32(); 28 missionStackId = parcel.ReadInt32(); 29 30 auto want = parcel.ReadParcelable<Want>(); 31 if (want == nullptr) { 32 return false; 33 } 34 baseWant = *want; 35 36 auto bAbility = parcel.ReadParcelable<AppExecFwk::ElementName>(); 37 if (bAbility == nullptr) { 38 return false; 39 } 40 baseAbility = *bAbility; 41 42 auto tAbility = parcel.ReadParcelable<AppExecFwk::ElementName>(); 43 if (tAbility == nullptr) { 44 return false; 45 } 46 topAbility = *tAbility; 47 48 size = parcel.ReadInt32(); 49 50 auto mDescription = parcel.ReadParcelable<MissionDescriptionInfo>(); 51 if (mDescription == nullptr) { 52 return false; 53 } 54 missionDescription = *mDescription; 55 56 return true; 57 } 58 Unmarshalling(Parcel & parcel)59AbilityMissionInfo *AbilityMissionInfo::Unmarshalling(Parcel &parcel) 60 { 61 AbilityMissionInfo *info = new (std::nothrow) AbilityMissionInfo(); 62 if (info == nullptr) { 63 return nullptr; 64 } 65 66 if (!info->ReadFromParcel(parcel)) { 67 delete info; 68 info = nullptr; 69 } 70 return info; 71 } 72 Marshalling(Parcel & parcel) const73bool AbilityMissionInfo::Marshalling(Parcel &parcel) const 74 { 75 parcel.WriteInt32(id); 76 parcel.WriteInt32(runingState); 77 parcel.WriteInt32(missionStackId); 78 parcel.WriteParcelable(&baseWant); 79 parcel.WriteParcelable(&baseAbility); 80 parcel.WriteParcelable(&topAbility); 81 parcel.WriteInt32(size); 82 parcel.WriteParcelable(&missionDescription); 83 84 return true; 85 } 86 } // namespace AAFwk 87 } // namespace OHOS