• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 "app_state_data.h"
17 
18 #include "hilog_wrapper.h"
19 
20 namespace OHOS {
21 namespace AppExecFwk {
Marshalling(Parcel & parcel) const22 bool AppStateData::Marshalling(Parcel &parcel) const
23 {
24     return (parcel.WriteString(bundleName) && parcel.WriteInt32(uid) && parcel.WriteInt32(state)
25         && parcel.WriteInt32(pid) && parcel.WriteInt32(accessTokenId) && parcel.WriteBool(isFocused)
26         && parcel.WriteInt32(static_cast<int32_t>(extensionType)) && parcel.WriteInt32Vector(renderPids));
27 }
28 
ReadFromParcel(Parcel & parcel)29 bool AppStateData::ReadFromParcel(Parcel &parcel)
30 {
31     bundleName = parcel.ReadString();
32     uid = parcel.ReadInt32();
33     state = parcel.ReadInt32();
34     pid = parcel.ReadInt32();
35     accessTokenId = parcel.ReadInt32();
36     isFocused = parcel.ReadBool();
37     extensionType = static_cast<ExtensionAbilityType>(parcel.ReadInt32());
38     parcel.ReadInt32Vector(&renderPids);
39 
40     return true;
41 }
42 
Unmarshalling(Parcel & parcel)43 AppStateData *AppStateData::Unmarshalling(Parcel &parcel)
44 {
45     AppStateData *appStateData = new (std::nothrow) AppStateData();
46     if (appStateData && !appStateData->ReadFromParcel(parcel)) {
47         HILOG_WARN("appStateData failed, because ReadFromParcel failed");
48         delete appStateData;
49         appStateData = nullptr;
50     }
51     return appStateData;
52 }
53 }  // namespace AppExecFwk
54 }  // namespace OHOS
55