1eace7efcSopenharmony_ci/* 2eace7efcSopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 3eace7efcSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4eace7efcSopenharmony_ci * you may not use this file except in compliance with the License. 5eace7efcSopenharmony_ci * You may obtain a copy of the License at 6eace7efcSopenharmony_ci * 7eace7efcSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8eace7efcSopenharmony_ci * 9eace7efcSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10eace7efcSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11eace7efcSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12eace7efcSopenharmony_ci * See the License for the specific language governing permissions and 13eace7efcSopenharmony_ci * limitations under the License. 14eace7efcSopenharmony_ci */ 15eace7efcSopenharmony_ci 16eace7efcSopenharmony_ci#ifndef OHOS_ABILITY_RUNTIME_APPSPAWN_UTIL_H 17eace7efcSopenharmony_ci#define OHOS_ABILITY_RUNTIME_APPSPAWN_UTIL_H 18eace7efcSopenharmony_ci 19eace7efcSopenharmony_ci#include "ability_info.h" 20eace7efcSopenharmony_ci#include "app_spawn_client.h" 21eace7efcSopenharmony_ci#include "global_constant.h" 22eace7efcSopenharmony_ci#include "want.h" 23eace7efcSopenharmony_ci 24eace7efcSopenharmony_cinamespace OHOS { 25eace7efcSopenharmony_cinamespace AppExecFwk { 26eace7efcSopenharmony_cinamespace AppspawnUtil { 27eace7efcSopenharmony_ciconstexpr const char* DLP_PARAMS_INDEX = "ohos.dlp.params.index"; 28eace7efcSopenharmony_ci 29eace7efcSopenharmony_cistatic uint32_t BuildStartFlags(const AAFwk::Want &want, const ApplicationInfo &applicationInfo) 30eace7efcSopenharmony_ci{ 31eace7efcSopenharmony_ci uint32_t startFlags = 0x0; 32eace7efcSopenharmony_ci if (want.GetBoolParam("coldStart", false)) { 33eace7efcSopenharmony_ci startFlags = startFlags | (START_FLAG_BASE << StartFlags::COLD_START); 34eace7efcSopenharmony_ci } 35eace7efcSopenharmony_ci 36eace7efcSopenharmony_ci#ifdef WITH_DLP 37eace7efcSopenharmony_ci if (want.GetIntParam(DLP_PARAMS_INDEX, 0) != 0) { 38eace7efcSopenharmony_ci startFlags = startFlags | (START_FLAG_BASE << StartFlags::DLP_MANAGER); 39eace7efcSopenharmony_ci } 40eace7efcSopenharmony_ci#endif // WITH_DLP 41eace7efcSopenharmony_ci 42eace7efcSopenharmony_ci if (applicationInfo.debug) { 43eace7efcSopenharmony_ci startFlags = startFlags | (START_FLAG_BASE << StartFlags::DEBUGGABLE); 44eace7efcSopenharmony_ci } 45eace7efcSopenharmony_ci if (applicationInfo.asanEnabled) { 46eace7efcSopenharmony_ci startFlags = startFlags | (START_FLAG_BASE << StartFlags::ASANENABLED); 47eace7efcSopenharmony_ci } 48eace7efcSopenharmony_ci if (want.GetBoolParam("nativeDebug", false)) { 49eace7efcSopenharmony_ci startFlags = startFlags | (START_FLAG_BASE << StartFlags::NATIVEDEBUG); 50eace7efcSopenharmony_ci } 51eace7efcSopenharmony_ci if (applicationInfo.gwpAsanEnabled) { 52eace7efcSopenharmony_ci startFlags = startFlags | (START_FLAG_BASE << StartFlags::GWP_ENABLED_FORCE); 53eace7efcSopenharmony_ci } 54eace7efcSopenharmony_ci if (applicationInfo.isSystemApp) { 55eace7efcSopenharmony_ci startFlags = startFlags | (START_FLAG_BASE << StartFlags::GWP_ENABLED_NORMAL); 56eace7efcSopenharmony_ci } 57eace7efcSopenharmony_ci if (applicationInfo.tsanEnabled) { 58eace7efcSopenharmony_ci startFlags = startFlags | (START_FLAG_BASE << StartFlags::TSANENABLED); 59eace7efcSopenharmony_ci } 60eace7efcSopenharmony_ci if (want.GetBoolParam("ohos.ability.params.extensionControl", false)) { 61eace7efcSopenharmony_ci startFlags = startFlags | (START_FLAG_BASE << StartFlags::EXTENSION_CONTROLLED); 62eace7efcSopenharmony_ci } 63eace7efcSopenharmony_ci if (applicationInfo.multiAppMode.multiAppModeType == MultiAppModeType::APP_CLONE && applicationInfo.appIndex > 0 && 64eace7efcSopenharmony_ci applicationInfo.appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { 65eace7efcSopenharmony_ci startFlags = startFlags | (START_FLAG_BASE << APP_FLAGS_CLONE_ENABLE); 66eace7efcSopenharmony_ci } 67eace7efcSopenharmony_ci if (applicationInfo.hwasanEnabled) { 68eace7efcSopenharmony_ci startFlags = startFlags | (START_FLAG_BASE << StartFlags::HWASANENABLED); 69eace7efcSopenharmony_ci } 70eace7efcSopenharmony_ci if (applicationInfo.ubsanEnabled) { 71eace7efcSopenharmony_ci startFlags = startFlags | (START_FLAG_BASE << StartFlags::UBSANENABLED); 72eace7efcSopenharmony_ci } 73eace7efcSopenharmony_ci 74eace7efcSopenharmony_ci return startFlags; 75eace7efcSopenharmony_ci} 76eace7efcSopenharmony_ci 77eace7efcSopenharmony_cistatic uint32_t BuildStartFlags(const AAFwk::Want &want, const AbilityInfo &abilityInfo) 78eace7efcSopenharmony_ci{ 79eace7efcSopenharmony_ci uint32_t startFlags = BuildStartFlags(want, abilityInfo.applicationInfo); 80eace7efcSopenharmony_ci 81eace7efcSopenharmony_ci if (abilityInfo.extensionAbilityType == ExtensionAbilityType::BACKUP) { 82eace7efcSopenharmony_ci startFlags = startFlags | (START_FLAG_BASE << StartFlags::BACKUP_EXTENSION); 83eace7efcSopenharmony_ci } 84eace7efcSopenharmony_ci 85eace7efcSopenharmony_ci return startFlags; 86eace7efcSopenharmony_ci} 87eace7efcSopenharmony_ci} // namespace AppspawnUtil 88eace7efcSopenharmony_ci} // namespace AppExecFwk 89eace7efcSopenharmony_ci} // namespace OHOS 90eace7efcSopenharmony_ci 91eace7efcSopenharmony_ci#endif // OHOS_ABILITY_RUNTIME_APPSPAWN_UTIL_H 92