1 /* 2 * Copyright (c) 2021-2025 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 #ifdef SUPPORT_SCREEN 18 #include "pixel_map.h" 19 #endif //SUPPORT_SCREEN 20 21 namespace OHOS { 22 namespace AAFwk { ReadFromParcel(Parcel & parcel)23bool MissionSnapshot::ReadFromParcel(Parcel &parcel) 24 { 25 #ifdef SUPPORT_SCREEN 26 std::unique_ptr<AppExecFwk::ElementName> ability(parcel.ReadParcelable<AppExecFwk::ElementName>()); 27 if (ability == nullptr) { 28 return false; 29 } 30 topAbility = *ability; 31 std::shared_ptr<Media::PixelMap> pixelMap(parcel.ReadParcelable<Media::PixelMap>()); 32 if (pixelMap == nullptr) { 33 return false; 34 } 35 snapshot = pixelMap; 36 #endif 37 return true; 38 } 39 Unmarshalling(Parcel & parcel)40MissionSnapshot *MissionSnapshot::Unmarshalling(Parcel &parcel) 41 { 42 MissionSnapshot *info = new (std::nothrow) MissionSnapshot(); 43 if (info == nullptr) { 44 return nullptr; 45 } 46 47 if (!info->ReadFromParcel(parcel)) { 48 delete info; 49 info = nullptr; 50 } 51 return info; 52 } 53 Marshalling(Parcel & parcel) const54bool MissionSnapshot::Marshalling(Parcel &parcel) const 55 { 56 #ifdef SUPPORT_SCREEN 57 if (!parcel.WriteParcelable(&topAbility)) { 58 return false; 59 } 60 if (!parcel.WriteParcelable(snapshot.get())) { 61 return false; 62 } 63 #endif 64 return true; 65 } 66 } // namespace AAFwk 67 } // namespace OHOS 68