1 /* 2 * Copyright (c) 2023 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 "mem_mgr_window_info.h" 17 #include "memmgr_log.h" 18 19 namespace OHOS { 20 namespace Memory { 21 namespace { 22 const std::string TAG = "MemMgrWindowInfo"; 23 } 24 Marshalling(Parcel & parcel) const25bool MemMgrWindowInfo::Marshalling(Parcel &parcel) const 26 { 27 return parcel.WriteUint32(windowId_) && parcel.WriteInt32(pid_) && 28 parcel.WriteInt32(uid_) && parcel.WriteBool(isVisible_); 29 } 30 Unmarshalling(Parcel & parcel)31MemMgrWindowInfo* MemMgrWindowInfo::Unmarshalling(Parcel &parcel) 32 { 33 auto memMgrWindowInfo = new (std::nothrow) MemMgrWindowInfo(); 34 if (memMgrWindowInfo == nullptr) { 35 HILOGE("window visibility info is nullptr."); 36 return nullptr; 37 } 38 bool res = parcel.ReadUint32(memMgrWindowInfo->windowId_) && parcel.ReadInt32(memMgrWindowInfo->pid_) && 39 parcel.ReadInt32(memMgrWindowInfo->uid_) && parcel.ReadBool(memMgrWindowInfo->isVisible_); 40 if (!res) { 41 delete memMgrWindowInfo; 42 return nullptr; 43 } 44 return memMgrWindowInfo; 45 } 46 } 47 } 48 49