1 /*
2 * Copyright (c) 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 "ability_start_with_wait_observer_data.h"
17
18 #include "hilog_tag_wrapper.h"
19
20 namespace OHOS {
21 namespace AAFwk {
Marshalling(Parcel & parcel) const22 bool AbilityStartWithWaitObserverData::Marshalling(Parcel &parcel) const
23 {
24 if (!parcel.WriteBool(coldStart)) {
25 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write coldStart error");
26 return false;
27 }
28 if (!parcel.WriteUint32(reason)) {
29 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write reason error");
30 return false;
31 }
32 if (!parcel.WriteInt64(startTime)) {
33 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write startTime error");
34 return false;
35 }
36 if (!parcel.WriteInt64(foregroundTime)) {
37 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write foregroundTime error");
38 return false;
39 }
40 if (!parcel.WriteString(bundleName)) {
41 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write bundleName error");
42 return false;
43 }
44 if (!parcel.WriteString(abilityName)) {
45 TAG_LOGE(AAFwkTag::ABILITYMGR, "Write abilityName error");
46 return false;
47 }
48 return true;
49 }
50
ReadFromParcel(Parcel & parcel)51 bool AbilityStartWithWaitObserverData::ReadFromParcel(Parcel &parcel)
52 {
53 coldStart = parcel.ReadBool();
54 reason = parcel.ReadUint32();
55 startTime = parcel.ReadInt64();
56 foregroundTime = parcel.ReadInt64();
57 bundleName = parcel.ReadString();
58 abilityName = parcel.ReadString();
59 return true;
60 }
61
Unmarshalling(Parcel & parcel)62 AbilityStartWithWaitObserverData *AbilityStartWithWaitObserverData::Unmarshalling(Parcel &parcel)
63 {
64 AbilityStartWithWaitObserverData *abilityStartWithWaitData = new (std::nothrow) AbilityStartWithWaitObserverData();
65 if (abilityStartWithWaitData && !abilityStartWithWaitData->ReadFromParcel(parcel)) {
66 TAG_LOGE(AAFwkTag::ABILITYMGR, "ReadFromParcel failed");
67 delete abilityStartWithWaitData;
68 abilityStartWithWaitData = nullptr;
69 }
70 return abilityStartWithWaitData;
71 }
72 } // namespace AAFwk
73 } // namespace OHOS