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 "mission_snapshot.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 MissionSnapshot::ReadFromParcel(Parcel &parcel) 25 { 26 #ifdef SUPPORT_GRAPHICS 27 std::unique_ptr<AppExecFwk::ElementName> ability(parcel.ReadParcelable<AppExecFwk::ElementName>()); 28 if (ability == nullptr) { 29 return false; 30 } 31 topAbility = *ability; 32 std::shared_ptr<Media::PixelMap> pixelMap(parcel.ReadParcelable<Media::PixelMap>()); 33 if (pixelMap == nullptr) { 34 return false; 35 } 36 snapshot = pixelMap; 37 #endif 38 return true; 39 } 40 Unmarshalling(Parcel & parcel)41MissionSnapshot *MissionSnapshot::Unmarshalling(Parcel &parcel) 42 { 43 MissionSnapshot *info = new (std::nothrow) MissionSnapshot(); 44 45 if (!info->ReadFromParcel(parcel)) { 46 delete info; 47 info = nullptr; 48 } 49 return info; 50 } 51 Marshalling(Parcel & parcel) const52bool MissionSnapshot::Marshalling(Parcel &parcel) const 53 { 54 if (!parcel.WriteParcelable(&topAbility)) { 55 return false; 56 } 57 #ifdef SUPPORT_GRAPHICS 58 if (!parcel.WriteParcelable(snapshot.get())) { 59 return false; 60 } 61 #endif 62 return true; 63 } 64 } // namespace AAFwk 65 } // namespace OHOS 66