• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "window_visibility_info.h"
17 #include "window_manager_hilog.h"
18 
19 namespace OHOS::Rosen {
20 namespace {
21 constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowVisibilityInfo"};
22 }
23 
Marshalling(Parcel & parcel) const24 bool WindowVisibilityInfo::Marshalling(Parcel& parcel) const
25 {
26     return parcel.WriteUint32(windowId_) && parcel.WriteInt32(pid_) &&
27            parcel.WriteInt32(uid_) && parcel.WriteUint32(static_cast<uint32_t>(visibilityState_)) &&
28            parcel.WriteUint32(static_cast<uint32_t>(windowType_)) &&
29            parcel.WriteUint32(static_cast<uint32_t>(windowStatus_)) && parcel.WriteInt32(rect_.posX_) &&
30            parcel.WriteInt32(rect_.posY_) && parcel.WriteUint32(rect_.width_) && parcel.WriteUint32(rect_.height_) &&
31            parcel.WriteString(bundleName_) && parcel.WriteString(abilityName_) && parcel.WriteBool(isFocused_) &&
32            parcel.WriteInt32(appIndex_) && parcel.WriteBool(isSystem_);
33 }
34 
Unmarshalling(Parcel & parcel)35 WindowVisibilityInfo* WindowVisibilityInfo::Unmarshalling(Parcel& parcel)
36 {
37     auto windowVisibilityInfo = new (std::nothrow) WindowVisibilityInfo();
38     if (windowVisibilityInfo == nullptr) {
39         WLOGFE("window visibility info is nullptr.");
40         return nullptr;
41     }
42 
43     uint32_t visibilityState = 0;
44     bool res = parcel.ReadUint32(windowVisibilityInfo->windowId_) && parcel.ReadInt32(windowVisibilityInfo->pid_) &&
45         parcel.ReadInt32(windowVisibilityInfo->uid_) && parcel.ReadUint32(visibilityState);
46     if (!res) {
47         delete windowVisibilityInfo;
48         return nullptr;
49     }
50     windowVisibilityInfo->visibilityState_ = static_cast<WindowVisibilityState>(visibilityState);
51     windowVisibilityInfo->windowType_ = static_cast<WindowType>(parcel.ReadUint32());
52     windowVisibilityInfo->windowStatus_ = static_cast<WindowStatus>(parcel.ReadUint32());
53     windowVisibilityInfo->rect_ = { parcel.ReadInt32(), parcel.ReadInt32(), parcel.ReadUint32(), parcel.ReadUint32() };
54     windowVisibilityInfo->bundleName_ = parcel.ReadString();
55     windowVisibilityInfo->abilityName_ = parcel.ReadString();
56     windowVisibilityInfo->isFocused_ = parcel.ReadBool();
57     windowVisibilityInfo->appIndex_ = parcel.ReadInt32();
58     windowVisibilityInfo->isSystem_ = parcel.ReadBool();
59     return windowVisibilityInfo;
60 }
61 } // namespace OHOS::Rosen
62