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 "display_change_info.h"
17 #include "window_manager_hilog.h"
18 
19 namespace OHOS {
20 namespace Rosen {
21 namespace {
22 constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "DisplayChangeInfo"};
23 }
Marshalling(Parcel & parcel) const24 bool DisplayChangeInfo::Marshalling(Parcel& parcel) const
25 {
26     return parcel.WriteUint32(static_cast<uint32_t>(action_)) && parcel.WriteUint64(toScreenId_) &&
27         parcel.WriteUint64(fromScreenId_) && parcel.WriteString(abilityName_) && parcel.WriteString(bundleName_);
28 }
29 
Unmarshalling(Parcel & parcel)30 DisplayChangeInfo* DisplayChangeInfo::Unmarshalling(Parcel& parcel)
31 {
32     auto info = new (std::nothrow) DisplayChangeInfo();
33     if (!info) {
34         WLOGFE("new info failed");
35         return nullptr;
36     }
37     info->action_ = static_cast<ActionType>(parcel.ReadUint32());
38     bool res = parcel.ReadUint64(info->toScreenId_) && parcel.ReadUint64(info->fromScreenId_) &&
39         parcel.ReadString(info->abilityName_) && parcel.ReadString(info->bundleName_);
40     if (!res) {
41         delete info;
42         WLOGFE("read info failed");
43         return nullptr;
44     }
45     return info;
46 }
47 } // namespace Rosen
48 } // namepsace OHOS