1/* 2 * Copyright (c) 2024 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 "window_pid_visibility_info.h" 17#include "window_manager_hilog.h" 18 19namespace OHOS::Rosen { 20 21bool WindowPidVisibilityInfo::Marshalling(Parcel& parcel) const 22{ 23 return parcel.WriteInt32(pid_) && parcel.WriteUint32(static_cast<uint32_t>(visibilityState_)); 24} 25 26WindowPidVisibilityInfo* WindowPidVisibilityInfo::Unmarshalling(Parcel& parcel) 27{ 28 auto windowPidVisibilityInfo = new (std::nothrow) WindowPidVisibilityInfo(); 29 if (windowPidVisibilityInfo == nullptr) { 30 TLOGE(WmsLogTag::WMS_LIFE, "window pid visibility info is nullptr."); 31 return nullptr; 32 } 33 34 uint32_t visibilityState = 0; 35 bool res = parcel.ReadInt32(windowPidVisibilityInfo->pid_) && parcel.ReadUint32(visibilityState); 36 if (!res) { 37 delete windowPidVisibilityInfo; 38 return nullptr; 39 } 40 windowPidVisibilityInfo->visibilityState_ = static_cast<WindowPidVisibilityState>(visibilityState); 41 return windowPidVisibilityInfo; 42} 43} // namespace OHOS::Rosen 44