1 /* 2 * Copyright (c) 2021-2024 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_tag_wrapper.h" 19 #include "ui_extension_utils.h" 20 21 namespace OHOS { 22 namespace AppExecFwk { Marshalling(Parcel & parcel) const23bool AppStateData::Marshalling(Parcel &parcel) const 24 { 25 return (parcel.WriteString(bundleName) && parcel.WriteInt32(uid) && parcel.WriteInt32(state) 26 && parcel.WriteInt32(pid) && parcel.WriteUint32(accessTokenId) && parcel.WriteBool(isFocused) 27 && parcel.WriteInt32(static_cast<int32_t>(extensionType)) && parcel.WriteInt32Vector(renderPids) 28 && parcel.WriteString(callerBundleName) && parcel.WriteBool(isSplitScreenMode) && parcel.WriteInt32(callerUid) 29 && parcel.WriteBool(isFloatingWindowMode) && parcel.WriteInt32(appIndex) && parcel.WriteBool(isPreloadModule) 30 && parcel.WriteBool(isFromWindowFocusChanged)); 31 } 32 ReadFromParcel(Parcel & parcel)33bool AppStateData::ReadFromParcel(Parcel &parcel) 34 { 35 bundleName = parcel.ReadString(); 36 uid = parcel.ReadInt32(); 37 state = parcel.ReadInt32(); 38 pid = parcel.ReadInt32(); 39 accessTokenId = parcel.ReadUint32(); 40 isFocused = parcel.ReadBool(); 41 extensionType = static_cast<ExtensionAbilityType>(parcel.ReadInt32()); 42 parcel.ReadInt32Vector(&renderPids); 43 callerBundleName = parcel.ReadString(); 44 isSplitScreenMode = parcel.ReadBool(); 45 callerUid = parcel.ReadInt32(); 46 isFloatingWindowMode = parcel.ReadBool(); 47 appIndex = parcel.ReadInt32(); 48 isPreloadModule = parcel.ReadBool(); 49 isFromWindowFocusChanged = parcel.ReadBool(); 50 51 return true; 52 } 53 Unmarshalling(Parcel & parcel)54AppStateData *AppStateData::Unmarshalling(Parcel &parcel) 55 { 56 AppStateData *appStateData = new (std::nothrow) AppStateData(); 57 if (appStateData && !appStateData->ReadFromParcel(parcel)) { 58 TAG_LOGW(AAFwkTag::APPMGR, "appStateData failed, because ReadFromParcel failed"); 59 delete appStateData; 60 appStateData = nullptr; 61 } 62 return appStateData; 63 } 64 IsUIExtension(const AppExecFwk::ExtensionAbilityType type)65bool AppStateData::IsUIExtension(const AppExecFwk::ExtensionAbilityType type) 66 { 67 return AAFwk::UIExtensionUtils::IsUIExtension(type); 68 } 69 } // namespace AppExecFwk 70 } // namespace OHOS 71