mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-11-30 10:52:57 +00:00
Merge remote-tracking branch 'ohos/master' into mws_1
This commit is contained in:
commit
7242431e1a
@ -36,6 +36,13 @@ bool UnwrapAutoStartupInfo(napi_env env, napi_value param, AutoStartupInfo &info
|
||||
return false;
|
||||
}
|
||||
|
||||
if (AppExecFwk::IsExistsByPropertyName(env, param, "appCloneIndex")) {
|
||||
if (!AppExecFwk::UnwrapInt32ByPropertyName(env, param, "appCloneIndex", info.appCloneIndex)) {
|
||||
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Convert appCloneIndex failed.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
AppExecFwk::UnwrapStringByPropertyName(env, param, "moduleName", info.moduleName);
|
||||
return true;
|
||||
}
|
||||
@ -120,6 +127,17 @@ napi_value CreateJsAutoStartupInfo(napi_env env, const AutoStartupInfo &info)
|
||||
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Create js AutoStartupInfo failed.");
|
||||
return nullptr;
|
||||
}
|
||||
if (info.appCloneIndex != -1) {
|
||||
napi_value appCloneIndex = AppExecFwk::WrapInt32ToJS(env, info.appCloneIndex);
|
||||
if (appCloneIndex == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Convert ability type name failed.");
|
||||
return nullptr;
|
||||
}
|
||||
if (!AppExecFwk::SetPropertyValueByPropertyName(env, object, "appCloneIndex", appCloneIndex)) {
|
||||
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Create js AutoStartupInfo failed.");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
return object;
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
|
@ -147,6 +147,9 @@ napi_value CreateJsAbilityStateData(napi_env env, const AbilityStateData &abilit
|
||||
napi_set_named_property(env, object, "state", CreateJsValue(env, abilityStateData.abilityState));
|
||||
napi_set_named_property(env, object, "abilityType", CreateJsValue(env, abilityStateData.abilityType));
|
||||
napi_set_named_property(env, object, "isAtomicService", CreateJsValue(env, abilityStateData.isAtomicService));
|
||||
if (abilityStateData.appCloneIndex != -1) {
|
||||
napi_set_named_property(env, object, "appCloneIndex", CreateJsValue(env, abilityStateData.appCloneIndex));
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
|
@ -157,6 +157,10 @@ class ApplicationContext {
|
||||
return this.__context_impl__.setLanguage(language);
|
||||
}
|
||||
|
||||
setFont(font) {
|
||||
return this.__context_impl__.setFont(font);
|
||||
}
|
||||
|
||||
setAutoStartup(info, callback) {
|
||||
return this.__context_impl__.setAutoStartup(info, callback);
|
||||
}
|
||||
|
@ -66,6 +66,9 @@ napi_value CreateJsAbilityStateData(napi_env env, const AbilityStateData &abilit
|
||||
napi_set_named_property(env, object, "state", CreateJsValue(env, abilityStateData.abilityState));
|
||||
napi_set_named_property(env, object, "abilityType", CreateJsValue(env, abilityStateData.abilityType));
|
||||
napi_set_named_property(env, object, "isAtomicService", CreateJsValue(env, abilityStateData.isAtomicService));
|
||||
if (abilityStateData.appCloneIndex != -1) {
|
||||
napi_set_named_property(env, object, "appCloneIndex", CreateJsValue(env, abilityStateData.appCloneIndex));
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "end.");
|
||||
return object;
|
||||
}
|
||||
@ -147,6 +150,9 @@ napi_value CreateJsRunningProcessInfo(napi_env env, const RunningProcessInfo &in
|
||||
napi_set_named_property(env, object, "state", CreateJsValue(env,
|
||||
ConvertToJsAppProcessState(info.state_, info.isFocused)));
|
||||
napi_set_named_property(env, object, "bundleType", CreateJsValue(env, info.bundleType));
|
||||
if (info.appCloneIndex != -1) {
|
||||
napi_set_named_property(env, object, "appCloneIndex", CreateJsValue(env, info.appCloneIndex));
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ const int32_t CREATE_VALUE_ZERO = 0;
|
||||
const int32_t CREATE_VALUE_ONE = 1;
|
||||
const int32_t CREATE_VALUE_TWO = 2;
|
||||
const int32_t CREATE_VALUE_THREE = 3;
|
||||
const int32_t CREATE_VALUE_FOUR = 4;
|
||||
static napi_status SetEnumItem(napi_env env, napi_value object, const char* name, int32_t value)
|
||||
{
|
||||
napi_status status;
|
||||
@ -45,6 +46,7 @@ static napi_value InitAreaModeObject(napi_env env)
|
||||
NAPI_CALL(env, SetEnumItem(env, object, "EL2", CREATE_VALUE_ONE));
|
||||
NAPI_CALL(env, SetEnumItem(env, object, "EL3", CREATE_VALUE_TWO));
|
||||
NAPI_CALL(env, SetEnumItem(env, object, "EL4", CREATE_VALUE_THREE));
|
||||
NAPI_CALL(env, SetEnumItem(env, object, "EL5", CREATE_VALUE_FOUR));
|
||||
|
||||
return object;
|
||||
}
|
||||
|
@ -85,6 +85,12 @@ napi_value WrapConfiguration(napi_env env, const AppExecFwk::Configuration &conf
|
||||
jsValue = WrapDoubleToJS(env, fontWeightScale != "" ? std::stod(fontWeightScale) : 1.0);
|
||||
SetPropertyValueByPropertyName(env, jsObject, "fontWeightScale", jsValue);
|
||||
|
||||
jsValue = WrapStringToJS(env, configuration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_MCC));
|
||||
SetPropertyValueByPropertyName(env, jsObject, "mcc", jsValue);
|
||||
|
||||
jsValue = WrapStringToJS(env, configuration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_MNC));
|
||||
SetPropertyValueByPropertyName(env, jsObject, "mnc", jsValue);
|
||||
|
||||
return jsObject;
|
||||
}
|
||||
|
||||
|
@ -113,6 +113,7 @@ napi_value WantConstantInit(napi_env env, napi_value exports)
|
||||
SetNamedProperty(env, params, "ohos.extra.param.key.supportContinuePageStack", "SUPPORT_CONTINUE_PAGE_STACK_KEY");
|
||||
SetNamedProperty(env, params, "ohos.extra.param.key.supportContinueSourceExit", "SUPPORT_CONTINUE_SOURCE_EXIT_KEY");
|
||||
SetNamedProperty(env, params, "ohos.extra.param.key.showMode", "SHOW_MODE_KEY");
|
||||
SetNamedProperty(env, params, "ohos.extra.param.key.appCloneIndex", "APP_CLONE_INDEX_KEY");
|
||||
napi_property_descriptor exportFuncs[] = {
|
||||
DECLARE_NAPI_PROPERTY("Action", action),
|
||||
DECLARE_NAPI_PROPERTY("Entity", entity),
|
||||
|
@ -136,6 +136,7 @@ ohos_shared_library("abilitykit_utils") {
|
||||
"${ability_runtime_native_path}/ability/native/ability_handler.cpp",
|
||||
"${ability_runtime_native_path}/ability/native/ability_local_record.cpp",
|
||||
"${ability_runtime_native_path}/ability/native/configuration_utils.cpp",
|
||||
"${ability_runtime_native_path}/ability/native/resource_config_helper.cpp",
|
||||
]
|
||||
|
||||
deps = []
|
||||
|
@ -37,66 +37,21 @@ void ConfigurationUtils::UpdateGlobalConfig(const Configuration &configuration,
|
||||
return;
|
||||
}
|
||||
|
||||
std::string language;
|
||||
std::string colormode;
|
||||
std::string hasPointerDevice;
|
||||
GetGlobalConfig(configuration, language, colormode, hasPointerDevice);
|
||||
std::string colorModeIsSetByApp = configuration.GetItem(AAFwk::GlobalConfigurationKey::COLORMODE_IS_SET_BY_APP);
|
||||
std::unique_ptr<Global::Resource::ResConfig> resConfig(Global::Resource::CreateResConfig());
|
||||
if (resConfig == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITY, "Create resource config failed.");
|
||||
return;
|
||||
}
|
||||
resourceManager->GetResConfig(*resConfig);
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
if (!language.empty()) {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
icu::Locale locale = icu::Locale::forLanguageTag(language, status);
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "get Locale::forLanguageTag return[%{public}d].", static_cast<int>(status));
|
||||
if (status == U_ZERO_ERROR) {
|
||||
resConfig->SetLocaleInfo(locale);
|
||||
}
|
||||
|
||||
const icu::Locale *localeInfo = resConfig->GetLocaleInfo();
|
||||
if (localeInfo != nullptr) {
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "Update config, language: %{public}s, script: %{public}s, region: %{public}s",
|
||||
localeInfo->getLanguage(), localeInfo->getScript(), localeInfo->getCountry());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!colormode.empty()) {
|
||||
resConfig->SetColorMode(AppExecFwk::ConvertColorMode(colormode));
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "Update config, colorMode: %{public}d", resConfig->GetColorMode());
|
||||
}
|
||||
|
||||
if (!hasPointerDevice.empty()) {
|
||||
resConfig->SetInputDevice(AppExecFwk::ConvertHasPointerDevice(hasPointerDevice));
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "Update config, hasPointerDevice: %{public}d", resConfig->GetInputDevice());
|
||||
}
|
||||
|
||||
if (!colorModeIsSetByApp.empty()) {
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "set app true");
|
||||
resConfig->SetAppColorMode(true);
|
||||
}
|
||||
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, "resourceManager->UpdateResConfig");
|
||||
Global::Resource::RState ret = resourceManager->UpdateResConfig(*resConfig);
|
||||
if (ret != Global::Resource::RState::SUCCESS) {
|
||||
TAG_LOGE(AAFwkTag::ABILITY, "Update resource config failed with %{public}d.", static_cast<int>(ret));
|
||||
return;
|
||||
}
|
||||
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "Update resource config succeed.");
|
||||
ResourceConfigHelper resourceConfig;
|
||||
GetGlobalConfig(configuration, resourceConfig);
|
||||
resourceConfig.UpdateResConfig(configuration, resourceManager);
|
||||
}
|
||||
|
||||
void ConfigurationUtils::GetGlobalConfig(const Configuration &configuration,
|
||||
std::string &language, std::string &colormode, std::string &hasPointerDevice)
|
||||
OHOS::AbilityRuntime::ResourceConfigHelper &resourceConfig)
|
||||
{
|
||||
language = configuration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE);
|
||||
colormode = configuration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE);
|
||||
hasPointerDevice = configuration.GetItem(AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE);
|
||||
resourceConfig.SetLanguage(configuration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE));
|
||||
resourceConfig.SetColormode(configuration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE));
|
||||
resourceConfig.SetHasPointerDevice(configuration.GetItem(AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE));
|
||||
resourceConfig.SetMcc(configuration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_MCC));
|
||||
resourceConfig.SetMnc(configuration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_MNC));
|
||||
resourceConfig.SetColorModeIsSetByApp(
|
||||
configuration.GetItem(AAFwk::GlobalConfigurationKey::COLORMODE_IS_SET_BY_APP));
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
|
158
frameworks/native/ability/native/resource_config_helper.cpp
Normal file
158
frameworks/native/ability/native/resource_config_helper.cpp
Normal file
@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "resource_config_helper.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "configuration_convertor.h"
|
||||
#include "hitrace_meter.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
using namespace AppExecFwk;
|
||||
|
||||
std::string ResourceConfigHelper::GetLanguage()
|
||||
{
|
||||
return language_;
|
||||
}
|
||||
void ResourceConfigHelper::SetLanguage(std::string language)
|
||||
{
|
||||
language_ = language;
|
||||
}
|
||||
|
||||
std::string ResourceConfigHelper::GetColormode()
|
||||
{
|
||||
return colormode_;
|
||||
}
|
||||
void ResourceConfigHelper::SetColormode(std::string colormode)
|
||||
{
|
||||
colormode_ = colormode;
|
||||
}
|
||||
std::string ResourceConfigHelper::GetHasPointerDevice()
|
||||
{
|
||||
return hasPointerDevice_;
|
||||
}
|
||||
void ResourceConfigHelper::SetHasPointerDevice(std::string hasPointerDevice)
|
||||
{
|
||||
hasPointerDevice_ = hasPointerDevice;
|
||||
}
|
||||
std::string ResourceConfigHelper::GetMcc()
|
||||
{
|
||||
return mcc_;
|
||||
}
|
||||
void ResourceConfigHelper::SetMcc(std::string mcc)
|
||||
{
|
||||
mcc_ = mcc;
|
||||
}
|
||||
std::string ResourceConfigHelper::GetMnc()
|
||||
{
|
||||
return mnc_;
|
||||
}
|
||||
void ResourceConfigHelper::SetMnc(std::string mnc)
|
||||
{
|
||||
mnc_ = mnc;
|
||||
}
|
||||
|
||||
std::string ResourceConfigHelper::GetColorModeIsSetByApp()
|
||||
{
|
||||
return colorModeIsSetByApp_;
|
||||
}
|
||||
void ResourceConfigHelper::SetColorModeIsSetByApp(std::string colorModeIsSetByApp)
|
||||
{
|
||||
colorModeIsSetByApp_ = colorModeIsSetByApp;
|
||||
}
|
||||
|
||||
void ResourceConfigHelper::UpdateResConfig(
|
||||
const AppExecFwk::Configuration &configuration, std::shared_ptr<Global::Resource::ResourceManager> resourceManager)
|
||||
{
|
||||
if (resourceManager == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITY, "Resource manager is invalid.");
|
||||
return;
|
||||
}
|
||||
std::unique_ptr<Global::Resource::ResConfig> resConfig(Global::Resource::CreateResConfig());
|
||||
if (resConfig == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITY, "Create res config failed.");
|
||||
return;
|
||||
}
|
||||
resourceManager->GetResConfig(*resConfig);
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
if (!language_.empty()) {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
icu::Locale locale = icu::Locale::forLanguageTag(language_, status);
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "Get forLanguageTag return[%{public}d].", static_cast<int>(status));
|
||||
if (status == U_ZERO_ERROR) {
|
||||
resConfig->SetLocaleInfo(locale);
|
||||
}
|
||||
const icu::Locale *localeInfo = resConfig->GetLocaleInfo();
|
||||
if (localeInfo != nullptr) {
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "Update config, language: %{public}s, script: %{public}s,"
|
||||
" region: %{public}s", localeInfo->getLanguage(), localeInfo->getScript(), localeInfo->getCountry());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
UpdateResConfig(resConfig);
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, "resourceManager->UpdateResConfig");
|
||||
Global::Resource::RState ret = resourceManager->UpdateResConfig(*resConfig);
|
||||
if (ret != Global::Resource::RState::SUCCESS) {
|
||||
TAG_LOGE(AAFwkTag::ABILITY, "Update resource config failed with %{public}d.", static_cast<int>(ret));
|
||||
return;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "Current colorMode: %{public}d, hasPointerDevice: %{public}d.",
|
||||
resConfig->GetColorMode(), resConfig->GetInputDevice());
|
||||
}
|
||||
|
||||
void ResourceConfigHelper::UpdateResConfig(std::unique_ptr<Global::Resource::ResConfig> &resConfig)
|
||||
{
|
||||
if (resConfig == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITY, "resConfig is nullptr!");
|
||||
return;
|
||||
}
|
||||
if (!colormode_.empty()) {
|
||||
resConfig->SetColorMode(AppExecFwk::ConvertColorMode(colormode_));
|
||||
}
|
||||
if (!hasPointerDevice_.empty()) {
|
||||
resConfig->SetInputDevice(AppExecFwk::ConvertHasPointerDevice(hasPointerDevice_));
|
||||
}
|
||||
if (!colorModeIsSetByApp_.empty()) {
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "set app true");
|
||||
resConfig->SetAppColorMode(true);
|
||||
}
|
||||
if (!mcc_.empty()) {
|
||||
uint32_t mccNum = 0;
|
||||
if (ConvertStringToUint32(mcc_, mccNum)) {
|
||||
resConfig->SetMcc(mccNum);
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "set mcc: %{public}u", resConfig->GetMcc());
|
||||
}
|
||||
}
|
||||
if (!mnc_.empty()) {
|
||||
uint32_t mncNum = 0;
|
||||
if (ConvertStringToUint32(mnc_, mncNum)) {
|
||||
resConfig->SetMnc(mncNum);
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "set mnc: %{public}u", resConfig->GetMnc());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ResourceConfigHelper::ConvertStringToUint32(std::string source, uint32_t &result)
|
||||
{
|
||||
try {
|
||||
result = static_cast<uint32_t>(std::stoi(source));
|
||||
} catch (...) {
|
||||
TAG_LOGW(AAFwkTag::ABILITY, "source:%{public}s is invalid.", source.c_str());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
@ -29,6 +29,7 @@
|
||||
#include "ohos_application.h"
|
||||
#include "reverse_continuation_scheduler_primary_stage.h"
|
||||
#include "runtime.h"
|
||||
#include "resource_config_helper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
@ -299,44 +300,10 @@ void UIAbility::NotifyContinuationResult(const AAFwk::Want &want, bool success)
|
||||
void UIAbility::OnConfigurationUpdatedNotify(const AppExecFwk::Configuration &configuration)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "begin");
|
||||
std::string language;
|
||||
std::string colormode;
|
||||
std::string hasPointerDevice;
|
||||
InitConfigurationProperties(configuration, language, colormode, hasPointerDevice);
|
||||
std::string colorModeIsSetByApp = configuration.GetItem(AAFwk::GlobalConfigurationKey::COLORMODE_IS_SET_BY_APP);
|
||||
// Notify ResourceManager
|
||||
std::unique_ptr<Global::Resource::ResConfig> resConfig(Global::Resource::CreateResConfig());
|
||||
if (resConfig == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::UIABILITY, "Create res config failed.");
|
||||
return;
|
||||
}
|
||||
ResourceConfigHelper resourceConfig;
|
||||
InitConfigurationProperties(configuration, resourceConfig);
|
||||
auto resourceManager = GetResourceManager();
|
||||
if (resourceManager != nullptr) {
|
||||
resourceManager->GetResConfig(*resConfig);
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
if (!language.empty()) {
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
icu::Locale locale = icu::Locale::forLanguageTag(language, status);
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "Get forLanguageTag return[%{public}d].", static_cast<int>(status));
|
||||
if (status == U_ZERO_ERROR) {
|
||||
resConfig->SetLocaleInfo(locale);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (!colormode.empty()) {
|
||||
resConfig->SetColorMode(AppExecFwk::ConvertColorMode(colormode));
|
||||
}
|
||||
if (!hasPointerDevice.empty()) {
|
||||
resConfig->SetInputDevice(AppExecFwk::ConvertHasPointerDevice(hasPointerDevice));
|
||||
}
|
||||
if (!colorModeIsSetByApp.empty()) {
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "set app true");
|
||||
resConfig->SetAppColorMode(true);
|
||||
}
|
||||
resourceManager->UpdateResConfig(*resConfig);
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "Current colorMode: %{public}d, hasPointerDevice: %{public}d.",
|
||||
resConfig->GetColorMode(), resConfig->GetInputDevice());
|
||||
}
|
||||
resourceConfig.UpdateResConfig(configuration, resourceManager);
|
||||
|
||||
if (abilityContext_ != nullptr && application_ != nullptr) {
|
||||
abilityContext_->SetConfiguration(application_->GetConfiguration());
|
||||
@ -346,25 +313,38 @@ void UIAbility::OnConfigurationUpdatedNotify(const AppExecFwk::Configuration &co
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "End.");
|
||||
}
|
||||
|
||||
void UIAbility::InitConfigurationProperties(const AppExecFwk::Configuration &changeConfiguration, std::string &language,
|
||||
std::string &colormode, std::string &hasPointerDevice)
|
||||
void UIAbility::InitConfigurationProperties(const AppExecFwk::Configuration &changeConfiguration,
|
||||
ResourceConfigHelper &resourceConfig)
|
||||
{
|
||||
resourceConfig.SetMcc(changeConfiguration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_MCC));
|
||||
resourceConfig.SetMnc(changeConfiguration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_MNC));
|
||||
resourceConfig.SetColorModeIsSetByApp(
|
||||
changeConfiguration.GetItem(AAFwk::GlobalConfigurationKey::COLORMODE_IS_SET_BY_APP));
|
||||
if (setting_) {
|
||||
auto displayId =
|
||||
std::atoi(setting_->GetProperty(AppExecFwk::AbilityStartSetting::WINDOW_DISPLAY_ID_KEY).c_str());
|
||||
language = changeConfiguration.GetItem(displayId, AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE);
|
||||
colormode = changeConfiguration.GetItem(displayId, AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE);
|
||||
hasPointerDevice = changeConfiguration.GetItem(displayId, AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE);
|
||||
resourceConfig.SetLanguage(changeConfiguration.GetItem(displayId,
|
||||
AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE));
|
||||
resourceConfig.SetColormode(changeConfiguration.GetItem(displayId,
|
||||
AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE));
|
||||
resourceConfig.SetHasPointerDevice(changeConfiguration.GetItem(displayId,
|
||||
AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE));
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "displayId: [%{public}d], language: [%{public}s], colormode: [%{public}s], "
|
||||
"hasPointerDevice: [%{public}s].",
|
||||
displayId, language.c_str(), colormode.c_str(), hasPointerDevice.c_str());
|
||||
"hasPointerDevice: [%{public}s] mcc: [%{public}s], mnc: [%{public}s].", displayId,
|
||||
resourceConfig.GetLanguage().c_str(), resourceConfig.GetColormode().c_str(),
|
||||
resourceConfig.GetHasPointerDevice().c_str(), resourceConfig.GetMcc().c_str(),
|
||||
resourceConfig.GetMnc().c_str());
|
||||
} else {
|
||||
language = changeConfiguration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE);
|
||||
colormode = changeConfiguration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE);
|
||||
hasPointerDevice = changeConfiguration.GetItem(AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE);
|
||||
resourceConfig.SetLanguage(changeConfiguration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE));
|
||||
resourceConfig.SetColormode(changeConfiguration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE));
|
||||
resourceConfig.SetHasPointerDevice(changeConfiguration.GetItem(
|
||||
AAFwk::GlobalConfigurationKey::INPUT_POINTER_DEVICE));
|
||||
TAG_LOGD(AAFwkTag::UIABILITY,
|
||||
"Language: [%{public}s], colormode: [%{public}s], hasPointerDevice: [%{public}s].",
|
||||
language.c_str(), colormode.c_str(), hasPointerDevice.c_str());
|
||||
"Language: [%{public}s], colormode: [%{public}s], hasPointerDevice: [%{public}s] "
|
||||
"mcc: [%{public}s], mnc: [%{public}s].",
|
||||
resourceConfig.GetLanguage().c_str(), resourceConfig.GetColormode().c_str(),
|
||||
resourceConfig.GetHasPointerDevice().c_str(), resourceConfig.GetMcc().c_str(),
|
||||
resourceConfig.GetMnc().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -262,11 +262,14 @@ void JsUIExtension::OnStart(const AAFwk::Want &want)
|
||||
if (InsightIntentExecuteParam::IsInsightIntentExecute(want)) {
|
||||
launchParam.launchReason = AAFwk::LaunchReason::LAUNCHREASON_INSIGHT_INTENT;
|
||||
}
|
||||
napi_value argv[] = {
|
||||
CreateJsLaunchParam(env, launchParam),
|
||||
napiWant
|
||||
};
|
||||
CallObjectMethod("onCreate", argv, ARGC_TWO);
|
||||
int32_t screenMode = want.GetIntParam(AAFwk::SCREEN_MODE_KEY, AAFwk::IDLE_SCREEN_MODE);
|
||||
if (screenMode == AAFwk::EMBEDDED_FULL_SCREEN_MODE) {
|
||||
napi_value argv[] = {napiWant, CreateJsLaunchParam(env, launchParam) };
|
||||
CallObjectMethod("onCreate", argv, ARGC_TWO);
|
||||
} else {
|
||||
napi_value argv[] = {CreateJsLaunchParam(env, launchParam) };
|
||||
CallObjectMethod("onCreate", argv, ARGC_ONE);
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::UI_EXT, "JsUIExtension OnStart end.");
|
||||
}
|
||||
|
||||
|
@ -644,8 +644,10 @@ bool BundleMgrHelper::ImplicitQueryInfos(const Want &want, int32_t flags, int32_
|
||||
newWant.RemoveAllFd();
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
bool findDefaultApp = false;
|
||||
return bundleMgr->ImplicitQueryInfos(newWant, flags, userId, withDefault, abilityInfos, extensionInfos,
|
||||
findDefaultApp);
|
||||
bool ret = bundleMgr->ImplicitQueryInfos(newWant, flags, userId, withDefault, abilityInfos,
|
||||
extensionInfos, findDefaultApp);
|
||||
TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "findDefaultApp is %{public}d.", findDefaultApp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool BundleMgrHelper::CleanBundleDataFiles(const std::string &bundleName, const int32_t userId)
|
||||
|
@ -502,6 +502,19 @@ void ApplicationContext::SetLanguage(const std::string &language)
|
||||
}
|
||||
}
|
||||
|
||||
void ApplicationContext::SetFont(const std::string &font)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "font:%{public}s.", font.c_str());
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
// Notify Window
|
||||
AppExecFwk::Configuration config;
|
||||
config.AddItem(AppExecFwk::ConfigurationInner::APPLICATION_FONT, font);
|
||||
if (appFontCallback_ != nullptr) {
|
||||
appFontCallback_(config);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ApplicationContext::ClearUpApplicationData()
|
||||
{
|
||||
if (contextImpl_ != nullptr) {
|
||||
@ -538,6 +551,11 @@ void ApplicationContext::RegisterAppConfigUpdateObserver(AppConfigUpdateCallback
|
||||
appConfigChangeCallback_ = appConfigChangeCallback;
|
||||
}
|
||||
|
||||
void ApplicationContext::RegisterAppFontObserver(AppConfigUpdateCallback appFontCallback)
|
||||
{
|
||||
appFontCallback_ = appFontCallback;
|
||||
}
|
||||
|
||||
std::string ApplicationContext::GetAppRunningUniqueId() const
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "GetAppRunningUniqueId is %{public}s.", appRunningUniqueId_.c_str());
|
||||
|
@ -71,7 +71,7 @@ const std::string ContextImpl::CONTEXT_DATABASE("database");
|
||||
const std::string ContextImpl::CONTEXT_TEMP("/temp");
|
||||
const std::string ContextImpl::CONTEXT_FILES("/files");
|
||||
const std::string ContextImpl::CONTEXT_HAPS("/haps");
|
||||
const std::string ContextImpl::CONTEXT_ELS[] = {"el1", "el2", "el3", "el4"};
|
||||
const std::string ContextImpl::CONTEXT_ELS[] = {"el1", "el2", "el3", "el4", "el5"};
|
||||
const std::string ContextImpl::CONTEXT_RESOURCE_END = "/resources/resfile";
|
||||
Global::Resource::DeviceType ContextImpl::deviceType_ = Global::Resource::DeviceType::DEVICE_NOT_SET;
|
||||
const std::string OVERLAY_STATE_CHANGED = "usual.event.OVERLAY_STATE_CHANGED";
|
||||
@ -82,6 +82,7 @@ const int32_t API_VERSION_MOD = 100;
|
||||
const int32_t ERR_ABILITY_RUNTIME_EXTERNAL_NOT_SYSTEM_HSP = 16400001;
|
||||
const int AREA2 = 2;
|
||||
const int AREA3 = 3;
|
||||
const int AREA4 = 4;
|
||||
|
||||
std::string ContextImpl::GetBundleName() const
|
||||
{
|
||||
@ -328,8 +329,10 @@ std::string ContextImpl::GetDistributedFilesDir()
|
||||
dir = CONTEXT_DISTRIBUTEDFILES_BASE_BEFORE + std::to_string(GetCurrentAccountId()) +
|
||||
CONTEXT_DISTRIBUTEDFILES_BASE_MIDDLE + GetBundleName();
|
||||
} else {
|
||||
if (currArea_ == CONTEXT_ELS[1] || currArea_ == CONTEXT_ELS[AREA2] || currArea_ == CONTEXT_ELS[AREA3]) {
|
||||
//when areamode swith to el3/el4, the distributedfiles dir should be always el2's distributedfilesdir dir
|
||||
if (currArea_ == CONTEXT_ELS[1] || currArea_ == CONTEXT_ELS[AREA2] || currArea_ == CONTEXT_ELS[AREA3] ||
|
||||
currArea_ == CONTEXT_ELS[AREA4]) {
|
||||
// when areamode swith to el3/el4/el5, the distributedfiles dir should be always el2's
|
||||
// distributedfilesdir dir
|
||||
dir = CONTEXT_DATA_STORAGE + CONTEXT_ELS[1] + CONTEXT_FILE_SEPARATOR + CONTEXT_DISTRIBUTEDFILES;
|
||||
} else {
|
||||
dir = CONTEXT_DATA_STORAGE + currArea_ + CONTEXT_FILE_SEPARATOR + CONTEXT_DISTRIBUTEDFILES;
|
||||
|
@ -666,6 +666,34 @@ napi_value JsApplicationContextUtils::OnSetLanguage(napi_env env, NapiCallbackIn
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
napi_value JsApplicationContextUtils::SetFont(napi_env env, napi_callback_info info)
|
||||
{
|
||||
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsApplicationContextUtils, OnSetFont, APPLICATION_CONTEXT_NAME);
|
||||
}
|
||||
|
||||
napi_value JsApplicationContextUtils::OnSetFont(napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
// only support one params
|
||||
if (info.argc == ARGC_ZERO) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "Not enough params");
|
||||
ThrowInvalidParamError(env, "Not enough params.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
auto applicationContext = applicationContext_.lock();
|
||||
if (!applicationContext) {
|
||||
TAG_LOGW(AAFwkTag::APPKIT, "applicationContext is already released");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
std::string font;
|
||||
if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], font)) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "Parse font failed");
|
||||
ThrowInvalidParamError(env, "Parse param font failed, font must be string.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
applicationContext->SetFont(font);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
napi_value JsApplicationContextUtils::PreloadUIExtensionAbility(napi_env env, napi_callback_info info)
|
||||
{
|
||||
GET_NAPI_INFO_WITH_NAME_AND_CALL(
|
||||
@ -780,6 +808,9 @@ napi_value JsApplicationContextUtils::OnGetRunningProcessInformation(napi_env en
|
||||
napi_set_named_property(env, object, "bundleNames", CreateNativeArray(env, processInfo.bundleNames));
|
||||
napi_set_named_property(env, object,
|
||||
"state", CreateJsValue(env, ConvertToJsAppProcessState(processInfo.state_, processInfo.isFocused)));
|
||||
if (processInfo.appCloneIndex != -1) {
|
||||
napi_set_named_property(env, object, "appCloneIndex", CreateJsValue(env, processInfo.appCloneIndex));
|
||||
}
|
||||
napi_value array = nullptr;
|
||||
napi_create_array_with_length(env, 1, &array);
|
||||
if (array == nullptr) {
|
||||
@ -1512,6 +1543,7 @@ void JsApplicationContextUtils::BindNativeApplicationContext(napi_env env, napi_
|
||||
BindNativeFunction(env, object, "killAllProcesses", MD_NAME, JsApplicationContextUtils::KillProcessBySelf);
|
||||
BindNativeFunction(env, object, "setColorMode", MD_NAME, JsApplicationContextUtils::SetColorMode);
|
||||
BindNativeFunction(env, object, "setLanguage", MD_NAME, JsApplicationContextUtils::SetLanguage);
|
||||
BindNativeFunction(env, object, "setFont", MD_NAME, JsApplicationContextUtils::SetFont);
|
||||
BindNativeFunction(env, object, "clearUpApplicationData", MD_NAME,
|
||||
JsApplicationContextUtils::ClearUpApplicationData);
|
||||
BindNativeFunction(env, object, "preloadUIExtensionAbility", MD_NAME,
|
||||
@ -1522,10 +1554,8 @@ void JsApplicationContextUtils::BindNativeApplicationContext(napi_env env, napi_
|
||||
JsApplicationContextUtils::GetRunningProcessInformation);
|
||||
BindNativeFunction(env, object, "getCurrentAppCloneIndex", MD_NAME,
|
||||
JsApplicationContextUtils::GetCurrentAppCloneIndex);
|
||||
BindNativeFunction(env, object, "getGroupDir", MD_NAME,
|
||||
JsApplicationContextUtils::GetGroupDir);
|
||||
BindNativeFunction(env, object, "restartApp", MD_NAME,
|
||||
JsApplicationContextUtils::RestartApp);
|
||||
BindNativeFunction(env, object, "getGroupDir", MD_NAME, JsApplicationContextUtils::GetGroupDir);
|
||||
BindNativeFunction(env, object, "restartApp", MD_NAME, JsApplicationContextUtils::RestartApp);
|
||||
BindNativeFunction(env, object, "setSupportedProcessCache", MD_NAME,
|
||||
JsApplicationContextUtils::SetSupportedProcessCacheSelf);
|
||||
}
|
||||
|
@ -57,6 +57,7 @@
|
||||
#include "freeze_util.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "resource_config_helper.h"
|
||||
#ifdef SUPPORT_SCREEN
|
||||
#include "locale_config.h"
|
||||
#include "ace_forward_compatibility.h"
|
||||
@ -1110,6 +1111,21 @@ bool MainThread::InitResourceManager(std::shared_ptr<Global::Resource::ResourceM
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "deviceType is %{public}s <----> %{public}d.", deviceType.c_str(),
|
||||
ConvertDeviceType(deviceType));
|
||||
resConfig->SetDeviceType(ConvertDeviceType(deviceType));
|
||||
|
||||
std::string mcc = config.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_MCC);
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "mcc is %{public}s.", mcc.c_str());
|
||||
uint32_t mccNum = 0;
|
||||
if (AbilityRuntime::ResourceConfigHelper::ConvertStringToUint32(mcc, mccNum)) {
|
||||
resConfig->SetMcc(mccNum);
|
||||
}
|
||||
|
||||
std::string mnc = config.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_MNC);
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "mnc is %{public}s.", mnc.c_str());
|
||||
uint32_t mncNum = 0;
|
||||
if (AbilityRuntime::ResourceConfigHelper::ConvertStringToUint32(mnc, mncNum)) {
|
||||
resConfig->SetMnc(mncNum);
|
||||
}
|
||||
|
||||
resourceManager->UpdateResConfig(*resConfig);
|
||||
return true;
|
||||
}
|
||||
@ -3315,5 +3331,52 @@ int32_t MainThread::ScheduleDumpFfrt(std::string& result)
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "MainThread::ScheduleDumpFfrt::pid:%{public}d", getprocpid());
|
||||
return DumpFfrtHelper::DumpFfrt(result);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Notify application to prepare for process caching.
|
||||
*
|
||||
*/
|
||||
void MainThread::ScheduleCacheProcess()
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "ScheduleCacheProcess");
|
||||
wptr<MainThread> weak = this;
|
||||
auto task = [weak]() {
|
||||
auto appThread = weak.promote();
|
||||
if (appThread == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "appThread is nullptr");
|
||||
return;
|
||||
}
|
||||
appThread->HandleCacheProcess();
|
||||
};
|
||||
if (mainHandler_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "handler nullptr");
|
||||
return;
|
||||
}
|
||||
if (!mainHandler_->PostTask(task, "MainThread:ScheduleCacheProcess")) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "PostTask task failed");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Notify application to prepare for process caching.
|
||||
*
|
||||
*/
|
||||
void MainThread::HandleCacheProcess()
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "start.");
|
||||
|
||||
// force gc
|
||||
if (application_ != nullptr) {
|
||||
auto &runtime = application_->GetRuntime();
|
||||
if (runtime == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "runtime nullptr");
|
||||
return;
|
||||
}
|
||||
runtime->ForceFullGC();
|
||||
}
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -200,10 +200,19 @@ void OHOSApplication::SetApplicationContext(
|
||||
abilityRuntimeContext_->RegisterAppConfigUpdateObserver([applicationWptr](const Configuration &config) {
|
||||
std::shared_ptr<OHOSApplication> applicationSptr = applicationWptr.lock();
|
||||
if (applicationSptr == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "application is nullptr.");
|
||||
return;
|
||||
}
|
||||
applicationSptr->OnConfigurationUpdated(config);
|
||||
});
|
||||
abilityRuntimeContext_->RegisterAppFontObserver([applicationWptr](const Configuration &config) {
|
||||
std::shared_ptr<OHOSApplication> applicationSptr = applicationWptr.lock();
|
||||
if (applicationSptr == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "application is nullptr.");
|
||||
return;
|
||||
}
|
||||
applicationSptr->OnFontUpdated(config);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -537,6 +546,22 @@ void OHOSApplication::OnConfigurationUpdated(Configuration config)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Will be Called when the application font of the device changes.
|
||||
*
|
||||
* @param config Indicates the new Configuration object.
|
||||
*/
|
||||
void OHOSApplication::OnFontUpdated(Configuration config)
|
||||
{
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
// Notify Window
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "Update configuration for all window.");
|
||||
auto diffConfiguration = std::make_shared<AppExecFwk::Configuration>(config);
|
||||
Rosen::Window::UpdateConfigurationForAll(diffConfiguration);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Called when the system has determined to trim the memory, for example,
|
||||
|
@ -26,10 +26,12 @@
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
namespace {
|
||||
void PostTaskToHandler(void* handler, uv_io_cb func, void* work, int status, int priority)
|
||||
std::shared_ptr<AppExecFwk::EventHandler> g_eventHandler = nullptr;
|
||||
}
|
||||
void OHOSJsEnvironmentImpl::PostTaskToHandler(void* handler, uv_io_cb func, void* work, int status, int priority)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Enter.");
|
||||
if (!handler || !func || !work) {
|
||||
if (!func || !work) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Invalid parameters!");
|
||||
return;
|
||||
}
|
||||
@ -40,7 +42,6 @@ void PostTaskToHandler(void* handler, uv_io_cb func, void* work, int status, int
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Do uv work end.");
|
||||
};
|
||||
|
||||
auto eventHandler = static_cast<AppExecFwk::EventHandler*>(handler);
|
||||
AppExecFwk::EventQueue::Priority prio = AppExecFwk::EventQueue::Priority::IMMEDIATE;
|
||||
switch (priority) {
|
||||
case uv_qos_t::uv_qos_user_initiated:
|
||||
@ -56,10 +57,15 @@ void PostTaskToHandler(void* handler, uv_io_cb func, void* work, int status, int
|
||||
prio = AppExecFwk::EventQueue::Priority::HIGH;
|
||||
break;
|
||||
}
|
||||
eventHandler->PostTask(task, prio);
|
||||
|
||||
if (g_eventHandler == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Invalid parameters!");
|
||||
return;
|
||||
}
|
||||
g_eventHandler->PostTask(task, prio);
|
||||
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "PostTask end.");
|
||||
}
|
||||
}
|
||||
OHOSJsEnvironmentImpl::OHOSJsEnvironmentImpl()
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
@ -71,6 +77,7 @@ OHOSJsEnvironmentImpl::OHOSJsEnvironmentImpl(const std::shared_ptr<AppExecFwk::E
|
||||
if (eventRunner != nullptr) {
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Create event handler.");
|
||||
eventHandler_ = std::make_shared<AppExecFwk::EventHandler>(eventRunner);
|
||||
g_eventHandler = std::make_shared<AppExecFwk::EventHandler>(eventRunner);
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,7 +143,7 @@ bool OHOSJsEnvironmentImpl::InitLoop(NativeEngine* engine, bool isStage)
|
||||
eventHandler_->AddFileDescriptorListener(fd, events, std::make_shared<OHOSLoopHandler>(uvLoop), "uvLoopTask");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "uv_register_task_to_event, isStage: %{public}d", isStage);
|
||||
if (isStage) {
|
||||
uv_register_task_to_event(uvLoop, PostTaskToHandler, eventHandler_.get());
|
||||
uv_register_task_to_event(uvLoop, PostTaskToHandler, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,8 @@ public:
|
||||
void InitSyscapModule() override;
|
||||
|
||||
private:
|
||||
static void PostTaskToHandler(void* handler, uv_io_cb func, void* work, int status, int priority);
|
||||
|
||||
std::shared_ptr<AppExecFwk::EventHandler> eventHandler_;
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
|
@ -34,7 +34,7 @@ constexpr const char *CONTEXT_TEMP("temp");
|
||||
constexpr const char *CONTEXT_FILES("files");
|
||||
constexpr const char *CONTEXT_HAPS("haps");
|
||||
constexpr const char *CONTEXT_ASSET("asset");
|
||||
constexpr const char *CONTEXT_ELS[] = {"el1", "el2", "el3", "el4"};
|
||||
constexpr const char *CONTEXT_ELS[] = {"el1", "el2", "el3", "el4", "el5"};
|
||||
constexpr const char *CONTEXT_RESOURCE_BASE("/data/storage/el1/bundle");
|
||||
constexpr const char *CONTEXT_RESOURCE_END("/resources/resfile");
|
||||
constexpr int DIR_DEFAULT_PERM = 0770;
|
||||
|
@ -43,6 +43,7 @@ constexpr const char* EMPTY_STRING = "";
|
||||
constexpr const char* APPLICATION_DIRECTION = "ohos.application.direction";
|
||||
constexpr const char* APPLICATION_DENSITYDPI = "ohos.application.densitydpi";
|
||||
constexpr const char* APPLICATION_DISPLAYID = "ohos.application.displayid";
|
||||
constexpr const char* APPLICATION_FONT = "ohos.application.font";
|
||||
|
||||
constexpr const char* COLOR_MODE_LIGHT = "light";
|
||||
constexpr const char* COLOR_MODE_DARK = "dark";
|
||||
|
@ -35,6 +35,7 @@ public:
|
||||
std::string processName;
|
||||
int64_t startTime;
|
||||
int abilityState;
|
||||
int32_t appCloneIndex = -1;
|
||||
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
|
@ -32,6 +32,8 @@ public:
|
||||
std::string abilityName;
|
||||
std::string moduleName;
|
||||
std::string abilityTypeName;
|
||||
std::string accessTokenId;
|
||||
int32_t appCloneIndex = -1;
|
||||
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
|
@ -40,6 +40,7 @@ struct AbilityStateData : public Parcelable {
|
||||
* @param outParcel Indicates the Parcel object to which the Sequenceable object will be marshaled.
|
||||
*/
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
bool MarshallingOne(Parcel &parcel) const;
|
||||
|
||||
/**
|
||||
* @brief Unmarshals this Sequenceable object from a Parcel.
|
||||
@ -61,6 +62,7 @@ struct AbilityStateData : public Parcelable {
|
||||
std::string callerAbilityName;
|
||||
bool isAtomicService = false;
|
||||
int32_t abilityRecordId = 0;
|
||||
int32_t appCloneIndex = -1;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -572,6 +572,7 @@ public:
|
||||
* Check whether the bundle is running.
|
||||
*
|
||||
* @param bundleName Indicates the bundle name of the bundle.
|
||||
* @param appCloneIndex the appindex of the bundle.
|
||||
* @param isRunning Obtain the running status of the application, the result is true if running, false otherwise.
|
||||
* @return Return ERR_OK if success, others fail.
|
||||
*/
|
||||
|
@ -505,6 +505,7 @@ public:
|
||||
* Check whether the bundle is running.
|
||||
*
|
||||
* @param bundleName Indicates the bundle name of the bundle.
|
||||
* @param appCloneIndex the appindex of the bundle.
|
||||
* @param isRunning Obtain the running status of the application, the result is true if running, false otherwise.
|
||||
* @return Return ERR_OK if success, others fail.
|
||||
*/
|
||||
|
@ -64,6 +64,7 @@ private:
|
||||
int32_t HandleScheduleDumpIpcStop(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleScheduleDumpIpcStat(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleScheduleDumpFfrt(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleScheduleCacheProcess(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
using AppSchedulerFunc = int32_t (AppSchedulerHost::*)(MessageParcel &data, MessageParcel &reply);
|
||||
std::map<uint32_t, AppSchedulerFunc> memberFuncMap_;
|
||||
|
@ -272,6 +272,8 @@ public:
|
||||
*/
|
||||
virtual int32_t ScheduleDumpFfrt(std::string& result) = 0;
|
||||
|
||||
virtual void ScheduleCacheProcess() = 0;
|
||||
|
||||
enum class Message {
|
||||
SCHEDULE_FOREGROUND_APPLICATION_TRANSACTION = 0,
|
||||
SCHEDULE_BACKGROUND_APPLICATION_TRANSACTION,
|
||||
@ -302,6 +304,7 @@ public:
|
||||
SCHEDULE_DUMP_IPC_STOP,
|
||||
SCHEDULE_DUMP_IPC_STAT,
|
||||
SCHEDULE_DUMP_FFRT,
|
||||
SCHEDULE_CACHE_PROCESS,
|
||||
};
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
|
@ -232,6 +232,8 @@ public:
|
||||
*/
|
||||
virtual int32_t ScheduleDumpFfrt(std::string& result) override;
|
||||
|
||||
virtual void ScheduleCacheProcess() override;
|
||||
|
||||
private:
|
||||
bool WriteInterfaceToken(MessageParcel &data);
|
||||
void ScheduleMemoryCommon(const int32_t level, const uint32_t operation);
|
||||
|
@ -63,6 +63,7 @@ struct RunningProcessInfo : public Parcelable {
|
||||
bool isAbilityForegrounding = false;
|
||||
bool isTestMode = false;
|
||||
std::int32_t bundleType = 0;
|
||||
std::int32_t appCloneIndex = -1;
|
||||
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
|
@ -52,6 +52,14 @@ bool AbilityStateData::Marshalling(Parcel &parcel) const
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!MarshallingOne(parcel)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AbilityStateData::MarshallingOne(Parcel &parcel) const
|
||||
{
|
||||
if (!parcel.WriteInt32(abilityType)) {
|
||||
return false;
|
||||
}
|
||||
@ -67,6 +75,9 @@ bool AbilityStateData::Marshalling(Parcel &parcel) const
|
||||
if (!parcel.WriteBool(isAtomicService) || !parcel.WriteInt32(abilityRecordId)) {
|
||||
return false;
|
||||
}
|
||||
if (!parcel.WriteInt32(appCloneIndex)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -97,6 +108,7 @@ bool AbilityStateData::ReadFromParcel(Parcel &parcel)
|
||||
callerAbilityName = parcel.ReadString();
|
||||
isAtomicService = parcel.ReadBool();
|
||||
abilityRecordId = parcel.ReadInt32();
|
||||
appCloneIndex = parcel.ReadInt32();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -88,6 +88,8 @@ void AppSchedulerHost::InitMemberFuncMap()
|
||||
&AppSchedulerHost::HandleScheduleDumpIpcStat;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_DUMP_FFRT)] =
|
||||
&AppSchedulerHost::HandleScheduleDumpFfrt;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_CACHE_PROCESS)] =
|
||||
&AppSchedulerHost::HandleScheduleCacheProcess;
|
||||
}
|
||||
|
||||
AppSchedulerHost::~AppSchedulerHost()
|
||||
@ -447,5 +449,12 @@ int32_t AppSchedulerHost::HandleScheduleDumpFfrt(MessageParcel &data, MessagePar
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AppSchedulerHost::HandleScheduleCacheProcess(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HITRACE_METER(HITRACE_TAG_APP);
|
||||
ScheduleCacheProcess();
|
||||
return NO_ERROR;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -751,5 +751,20 @@ int32_t AppSchedulerProxy::SendTransactCmd(uint32_t code, MessageParcel &data,
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void AppSchedulerProxy::ScheduleCacheProcess()
|
||||
{
|
||||
uint32_t operation = static_cast<uint32_t>(IAppScheduler::Message::SCHEDULE_CACHE_PROCESS);
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return;
|
||||
}
|
||||
int32_t ret = SendTransactCmd(operation, data, reply, option);
|
||||
if (ret != NO_ERROR) {
|
||||
TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret);
|
||||
}
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -61,6 +61,7 @@ bool RunningProcessInfo::ReadFromParcel(Parcel &parcel)
|
||||
int32_t extensionType;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, extensionType);
|
||||
extensionType_ = static_cast<ExtensionAbilityType>(extensionType);
|
||||
appCloneIndex = parcel.ReadInt32();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -94,6 +95,7 @@ bool RunningProcessInfo::Marshalling(Parcel &parcel) const
|
||||
}
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(processType_));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(extensionType_));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, appCloneIndex);
|
||||
return true;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
|
@ -28,6 +28,12 @@ config("dataobs_manager_public_config") {
|
||||
}
|
||||
|
||||
ohos_shared_library("dataobs_manager") {
|
||||
branch_protector_ret = "pac_ret"
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
sources = [
|
||||
"${ability_runtime_services_path}/dataobsmgr/src/data_ability_observer_proxy.cpp",
|
||||
"${ability_runtime_services_path}/dataobsmgr/src/data_ability_observer_stub.cpp",
|
||||
|
@ -17,6 +17,7 @@
|
||||
#define OHOS_ABILITY_RUNTIME_CONFIGURATION_UTILS_H
|
||||
|
||||
#include "configuration.h"
|
||||
#include "resource_config_helper.h"
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#include "display_manager.h"
|
||||
#endif
|
||||
@ -40,8 +41,8 @@ public:
|
||||
void UpdateGlobalConfig(const Configuration &configuration, std::shared_ptr<ResourceManager> resourceManager);
|
||||
|
||||
private:
|
||||
void GetGlobalConfig(const Configuration &configuration, std::string &language, std::string &colormode,
|
||||
std::string &hasPointerDevice);
|
||||
void GetGlobalConfig(const Configuration &configuration,
|
||||
OHOS::AbilityRuntime::ResourceConfigHelper &resourceConfig);
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
public:
|
||||
|
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ABILITY_RUNTIME_RESOURCE_CONFIG_HELPER_H
|
||||
#define OHOS_ABILITY_RUNTIME_RESOURCE_CONFIG_HELPER_H
|
||||
#include "resource_manager.h"
|
||||
#include "configuration.h"
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#include "display_manager.h"
|
||||
#endif
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
|
||||
}
|
||||
namespace AbilityRuntime {
|
||||
class ResourceConfigHelper {
|
||||
public:
|
||||
ResourceConfigHelper() = default;
|
||||
~ResourceConfigHelper() = default;
|
||||
std::string GetLanguage();
|
||||
void SetLanguage(std::string language);
|
||||
std::string GetColormode();
|
||||
void SetColormode(std::string colormode);
|
||||
std::string GetHasPointerDevice();
|
||||
void SetHasPointerDevice(std::string hasPointerDevice);
|
||||
std::string GetMcc();
|
||||
void SetMcc(std::string mcc);
|
||||
std::string GetMnc();
|
||||
void SetMnc(std::string mnc);
|
||||
std::string GetColorModeIsSetByApp();
|
||||
void SetColorModeIsSetByApp(std::string colorModeIsSetByApp);
|
||||
|
||||
void UpdateResConfig(const AppExecFwk::Configuration &configuration,
|
||||
std::shared_ptr<Global::Resource::ResourceManager> resourceManager);
|
||||
|
||||
static bool ConvertStringToUint32(std::string source, uint32_t &result);
|
||||
|
||||
private:
|
||||
std::string language_;
|
||||
std::string colormode_;
|
||||
std::string hasPointerDevice_;
|
||||
std::string mcc_;
|
||||
std::string mnc_;
|
||||
std::string colorModeIsSetByApp_;
|
||||
|
||||
void UpdateResConfig(std::unique_ptr<Global::Resource::ResConfig> &resConfig);
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_RESOURCE_CONFIG_HELPER_H
|
@ -28,6 +28,7 @@
|
||||
#include "foundation/ability/ability_runtime/interfaces/kits/native/ability/ability_runtime/ability_context.h"
|
||||
#include "iability_callback.h"
|
||||
#include "want.h"
|
||||
#include "resource_config_helper.h"
|
||||
#ifdef SUPPORT_SCREEN
|
||||
#include "display_manager.h"
|
||||
#include "session_info.h"
|
||||
@ -340,8 +341,8 @@ private:
|
||||
void HandleCreateAsRecovery(const AAFwk::Want &want);
|
||||
void SetStartAbilitySetting(std::shared_ptr<AppExecFwk::AbilityStartSetting> setting);
|
||||
void SetLaunchParam(const AAFwk::LaunchParam &launchParam);
|
||||
void InitConfigurationProperties(const AppExecFwk::Configuration &changeConfiguration, std::string &language,
|
||||
std::string &colormode, std::string &hasPointerDevice);
|
||||
void InitConfigurationProperties(const AppExecFwk::Configuration &changeConfiguration,
|
||||
ResourceConfigHelper &resourceConfig);
|
||||
|
||||
std::shared_ptr<AppExecFwk::ContinuationHandlerStage> continuationHandler_ = nullptr;
|
||||
std::shared_ptr<AppExecFwk::ContinuationManagerStage> continuationManager_ = nullptr;
|
||||
|
@ -91,6 +91,7 @@ public:
|
||||
void SwitchArea(int mode) override;
|
||||
void SetColorMode(int32_t colorMode);
|
||||
void SetLanguage(const std::string &language);
|
||||
void SetFont(const std::string &font);
|
||||
void ClearUpApplicationData();
|
||||
int GetArea() override;
|
||||
std::shared_ptr<AppExecFwk::Configuration> GetConfiguration() const override;
|
||||
@ -110,6 +111,7 @@ public:
|
||||
bool GetApplicationInfoUpdateFlag() const;
|
||||
void SetApplicationInfoUpdateFlag(bool flag);
|
||||
void RegisterAppConfigUpdateObserver(AppConfigUpdateCallback appConfigChangeCallback);
|
||||
void RegisterAppFontObserver(AppConfigUpdateCallback appFontCallback);
|
||||
|
||||
std::string GetAppRunningUniqueId() const;
|
||||
void SetAppRunningUniqueId(const std::string &appRunningUniqueId);
|
||||
@ -128,6 +130,7 @@ private:
|
||||
std::recursive_mutex applicationStateCallbackLock_;
|
||||
bool applicationInfoUpdateFlag_ = false;
|
||||
AppConfigUpdateCallback appConfigChangeCallback_ = nullptr;
|
||||
AppConfigUpdateCallback appFontCallback_ = nullptr;
|
||||
std::string appRunningUniqueId_;
|
||||
int32_t appIndex_ = 0;
|
||||
int32_t appMode_ = 0;
|
||||
|
@ -157,12 +157,19 @@ public:
|
||||
void SetColorMode(int colorMode);
|
||||
|
||||
/**
|
||||
* @brief Set color mode
|
||||
* @brief Set language
|
||||
*
|
||||
* @param colorMode color mode.
|
||||
* @param language language.
|
||||
*/
|
||||
void SetLanguage(std::string language);
|
||||
|
||||
/**
|
||||
* @brief Set font
|
||||
*
|
||||
* @param Font font.
|
||||
*/
|
||||
void SetFont(std::string font);
|
||||
|
||||
/**
|
||||
* @brief clear the application data by app self
|
||||
*/
|
||||
|
@ -94,6 +94,7 @@ public:
|
||||
napi_value OnGetRunningProcessInformation(napi_env env, NapiCallbackInfo& info);
|
||||
napi_value OnSetColorMode(napi_env env, NapiCallbackInfo& info);
|
||||
napi_value OnSetLanguage(napi_env env, NapiCallbackInfo& info);
|
||||
napi_value OnSetFont(napi_env env, NapiCallbackInfo& info);
|
||||
napi_value OnClearUpApplicationData(napi_env env, NapiCallbackInfo& info);
|
||||
napi_value OnRestartApp(napi_env env, NapiCallbackInfo& info);
|
||||
napi_value OnSetSupportedProcessCacheSelf(napi_env env, NapiCallbackInfo& info);
|
||||
@ -114,6 +115,7 @@ public:
|
||||
static napi_value KillProcessBySelf(napi_env env, napi_callback_info info);
|
||||
static napi_value SetColorMode(napi_env env, napi_callback_info info);
|
||||
static napi_value SetLanguage(napi_env env, napi_callback_info info);
|
||||
static napi_value SetFont(napi_env env, napi_callback_info info);
|
||||
static napi_value ClearUpApplicationData(napi_env env, napi_callback_info info);
|
||||
static napi_value GetRunningProcessInformation(napi_env env, napi_callback_info info);
|
||||
static napi_value CreateJsApplicationContext(napi_env env);
|
||||
|
@ -345,6 +345,7 @@ public:
|
||||
*/
|
||||
int32_t ScheduleDumpFfrt(std::string& result) override;
|
||||
|
||||
void ScheduleCacheProcess() override;
|
||||
private:
|
||||
/**
|
||||
*
|
||||
@ -606,6 +607,8 @@ private:
|
||||
|
||||
int32_t ChangeAppGcState(int32_t state);
|
||||
|
||||
void HandleCacheProcess();
|
||||
|
||||
class MainHandler : public EventHandler {
|
||||
public:
|
||||
MainHandler(const std::shared_ptr<EventRunner> &runner, const sptr<MainThread> &thread);
|
||||
|
@ -176,6 +176,14 @@ public:
|
||||
* @param config Indicates the new Configuration object.
|
||||
*/
|
||||
virtual void OnConfigurationUpdated(Configuration config);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Will be Called when the application font of the device changes.
|
||||
*
|
||||
* @param config Indicates the new Configuration object.
|
||||
*/
|
||||
virtual void OnFontUpdated(Configuration config);
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -23,6 +23,7 @@ config("public_js_environment_config") {
|
||||
include_dirs = [
|
||||
"${inner_api_path}",
|
||||
"${utils_path}/include",
|
||||
"${ability_runtime_services_path}/common/include",
|
||||
]
|
||||
}
|
||||
|
||||
@ -44,6 +45,7 @@ ohos_shared_library("js_environment") {
|
||||
"eventhandler:libeventhandler",
|
||||
"faultloggerd:libunwinder",
|
||||
"ffrt:libffrt",
|
||||
"hilog:libhilog",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
|
@ -16,7 +16,8 @@
|
||||
#include "js_environment.h"
|
||||
|
||||
#include "ffrt.h"
|
||||
#include "js_env_logger.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "js_environment_impl.h"
|
||||
#include "native_engine/impl/ark/ark_native_engine.h"
|
||||
#include "uncaught_exception_callback.h"
|
||||
@ -40,12 +41,12 @@ static panda::DFXJSNApi::ProfilerType ConvertProfilerType(JsEnvironment::PROFILE
|
||||
|
||||
JsEnvironment::JsEnvironment(std::unique_ptr<JsEnvironmentImpl> impl) : impl_(std::move(impl))
|
||||
{
|
||||
JSENV_LOG_D("called");
|
||||
TAG_LOGD(AAFwkTag::JSENV, "called");
|
||||
}
|
||||
|
||||
JsEnvironment::~JsEnvironment()
|
||||
{
|
||||
JSENV_LOG_D("called");
|
||||
TAG_LOGD(AAFwkTag::JSENV, "called");
|
||||
|
||||
if (engine_ != nullptr) {
|
||||
delete engine_;
|
||||
@ -60,10 +61,10 @@ JsEnvironment::~JsEnvironment()
|
||||
|
||||
bool JsEnvironment::Initialize(const panda::RuntimeOption& pandaOption, void* jsEngine)
|
||||
{
|
||||
JSENV_LOG_D("Js environment initialize.");
|
||||
TAG_LOGD(AAFwkTag::JSENV, "Js environment initialize.");
|
||||
vm_ = panda::JSNApi::CreateJSVM(pandaOption);
|
||||
if (vm_ == nullptr) {
|
||||
JSENV_LOG_E("Create vm failed.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Create vm failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -74,7 +75,7 @@ bool JsEnvironment::Initialize(const panda::RuntimeOption& pandaOption, void* js
|
||||
void JsEnvironment::InitTimerModule()
|
||||
{
|
||||
if (engine_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid native engine.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid native engine.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -86,7 +87,7 @@ void JsEnvironment::InitTimerModule()
|
||||
void JsEnvironment::InitWorkerModule(std::shared_ptr<WorkerInfo> workerInfo)
|
||||
{
|
||||
if (engine_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid native engine.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid native engine.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -127,7 +128,7 @@ void JsEnvironment::InitSourceMap(const std::shared_ptr<JsEnv::SourceMapOperator
|
||||
{
|
||||
sourceMapOperator_ = operatorObj;
|
||||
if (engine_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid Native Engine.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid Native Engine.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -139,7 +140,7 @@ void JsEnvironment::InitSourceMap(const std::shared_ptr<JsEnv::SourceMapOperator
|
||||
if (sourceMapOperator_ != nullptr && sourceMapOperator_->GetInitStatus()) {
|
||||
return sourceMapOperator_->TranslateBySourceMap(rawStack);
|
||||
} else {
|
||||
JSENV_LOG_E("SourceMap is not initialized yet");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "SourceMap is not initialized yet");
|
||||
return NOT_INIT + rawStack;
|
||||
}
|
||||
};
|
||||
@ -149,7 +150,7 @@ void JsEnvironment::InitSourceMap(const std::shared_ptr<JsEnv::SourceMapOperator
|
||||
if (sourceMapOperator_ != nullptr && sourceMapOperator_->GetInitStatus()) {
|
||||
return sourceMapOperator_->TranslateUrlPositionBySourceMap(url, line, column);
|
||||
}
|
||||
JSENV_LOG_E("SourceMap is not initialized yet");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "SourceMap is not initialized yet");
|
||||
return false;
|
||||
};
|
||||
engine_->RegisterSourceMapTranslateCallback(translateUrlBySourceMapFunc);
|
||||
@ -158,7 +159,7 @@ void JsEnvironment::InitSourceMap(const std::shared_ptr<JsEnv::SourceMapOperator
|
||||
void JsEnvironment::RegisterUncaughtExceptionHandler(const JsEnv::UncaughtExceptionInfo& uncaughtExceptionInfo)
|
||||
{
|
||||
if (engine_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid Native Engine.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid Native Engine.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -169,7 +170,7 @@ void JsEnvironment::RegisterUncaughtExceptionHandler(const JsEnv::UncaughtExcept
|
||||
bool JsEnvironment::LoadScript(const std::string& path, std::vector<uint8_t>* buffer, bool isBundle)
|
||||
{
|
||||
if (engine_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid Native Engine.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid Native Engine.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -183,21 +184,21 @@ bool JsEnvironment::LoadScript(const std::string& path, std::vector<uint8_t>* bu
|
||||
bool JsEnvironment::StartDebugger(
|
||||
std::string& option, uint32_t socketFd, bool isDebugApp, const DebuggerPostTask &debuggerPostTask)
|
||||
{
|
||||
JSENV_LOG_D("call.");
|
||||
TAG_LOGD(AAFwkTag::JSENV, "call.");
|
||||
if (vm_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid vm.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid vm.");
|
||||
return false;
|
||||
}
|
||||
int32_t identifierId = ParseHdcRegisterOption(option);
|
||||
if (identifierId == -1) {
|
||||
JSENV_LOG_E("Abnormal parsing of tid results.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Abnormal parsing of tid results.");
|
||||
return false;
|
||||
}
|
||||
if (isDebugApp) {
|
||||
debugMode_ = panda::JSNApi::StartDebuggerForSocketPair(identifierId, socketFd);
|
||||
} else {
|
||||
if (debuggerPostTask == nullptr) {
|
||||
JSENV_LOG_E("debuggerPostTask is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "debuggerPostTask is nullptr.");
|
||||
return false;
|
||||
}
|
||||
auto startDebuggerForSocketPairTask = [identifierId, socketFd, this]() {
|
||||
@ -211,7 +212,7 @@ bool JsEnvironment::StartDebugger(
|
||||
void JsEnvironment::StopDebugger()
|
||||
{
|
||||
if (vm_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid vm.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid vm.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -222,7 +223,7 @@ void JsEnvironment::StopDebugger(std::string& option)
|
||||
{
|
||||
int32_t identifierId = ParseHdcRegisterOption(option);
|
||||
if (identifierId == -1) {
|
||||
JSENV_LOG_E("Abnormal parsing of tid results.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Abnormal parsing of tid results.");
|
||||
return;
|
||||
}
|
||||
panda::JSNApi::StopDebugger(identifierId);
|
||||
@ -231,7 +232,7 @@ void JsEnvironment::StopDebugger(std::string& option)
|
||||
void JsEnvironment::InitConsoleModule()
|
||||
{
|
||||
if (engine_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid Native Engine.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid Native Engine.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -243,7 +244,7 @@ void JsEnvironment::InitConsoleModule()
|
||||
bool JsEnvironment::InitLoop(bool isStage)
|
||||
{
|
||||
if (engine_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid Native Engine.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid Native Engine.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -256,7 +257,7 @@ bool JsEnvironment::InitLoop(bool isStage)
|
||||
void JsEnvironment::DeInitLoop()
|
||||
{
|
||||
if (engine_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid Native Engine.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid Native Engine.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -268,7 +269,7 @@ void JsEnvironment::DeInitLoop()
|
||||
bool JsEnvironment::LoadScript(const std::string& path, uint8_t* buffer, size_t len, bool isBundle)
|
||||
{
|
||||
if (engine_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid Native Engine.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid Native Engine.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -279,14 +280,14 @@ void JsEnvironment::StartProfiler(const char* libraryPath, uint32_t instanceId,
|
||||
int32_t interval, int tid, bool isDebugApp)
|
||||
{
|
||||
if (vm_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid vm.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid vm.");
|
||||
return;
|
||||
}
|
||||
|
||||
auto debuggerPostTask = [weak = weak_from_this()](std::function<void()>&& task) {
|
||||
auto jsEnv = weak.lock();
|
||||
if (jsEnv == nullptr) {
|
||||
JSENV_LOG_E("JsEnv is invalid.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "JsEnv is invalid.");
|
||||
return;
|
||||
}
|
||||
jsEnv->PostTask(task, "JsEnvironment::StartProfiler");
|
||||
@ -303,7 +304,7 @@ void JsEnvironment::StartProfiler(const char* libraryPath, uint32_t instanceId,
|
||||
void JsEnvironment::DestroyHeapProfiler()
|
||||
{
|
||||
if (vm_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid vm.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid vm.");
|
||||
return;
|
||||
}
|
||||
panda::DFXJSNApi::DestroyHeapProfiler(vm_);
|
||||
@ -312,7 +313,7 @@ void JsEnvironment::DestroyHeapProfiler()
|
||||
void JsEnvironment::GetHeapPrepare()
|
||||
{
|
||||
if (vm_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid vm.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid vm.");
|
||||
return;
|
||||
}
|
||||
panda::DFXJSNApi::GetHeapPrepare(vm_);
|
||||
@ -320,14 +321,14 @@ void JsEnvironment::GetHeapPrepare()
|
||||
|
||||
void JsEnvironment::ReInitJsEnvImpl(std::unique_ptr<JsEnvironmentImpl> impl)
|
||||
{
|
||||
JSENV_LOG_D("ReInit jsenv impl.");
|
||||
TAG_LOGD(AAFwkTag::JSENV, "ReInit jsenv impl.");
|
||||
impl_ = std::move(impl);
|
||||
}
|
||||
|
||||
void JsEnvironment::SetModuleLoadChecker(const std::shared_ptr<ModuleCheckerDelegate>& moduleCheckerDelegate)
|
||||
{
|
||||
if (engine_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid native engine.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid native engine.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -337,7 +338,7 @@ void JsEnvironment::SetModuleLoadChecker(const std::shared_ptr<ModuleCheckerDele
|
||||
void JsEnvironment::SetRequestAotCallback(const RequestAotCallback& cb)
|
||||
{
|
||||
if (vm_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid vm.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid vm.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -354,7 +355,7 @@ DebuggerPostTask JsEnvironment::GetDebuggerPostTask()
|
||||
auto debuggerPostTask = [weak = weak_from_this()](std::function<void()>&& task) {
|
||||
auto jsEnv = weak.lock();
|
||||
if (jsEnv == nullptr) {
|
||||
JSENV_LOG_E("JsEnv is invalid.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "JsEnv is invalid.");
|
||||
return;
|
||||
}
|
||||
jsEnv->PostTask(task, "JsEnvironment:GetDebuggerPostTask");
|
||||
@ -366,14 +367,14 @@ void JsEnvironment::NotifyDebugMode(
|
||||
int tid, const char* libraryPath, uint32_t instanceId, bool debug, bool debugMode)
|
||||
{
|
||||
if (vm_ == nullptr) {
|
||||
JSENV_LOG_E("Invalid vm.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Invalid vm.");
|
||||
return;
|
||||
}
|
||||
panda::JSNApi::DebugOption debugOption = {libraryPath, debug ? debugMode : false};
|
||||
auto debuggerPostTask = [weak = weak_from_this()](std::function<void()>&& task) {
|
||||
auto jsEnv = weak.lock();
|
||||
if (jsEnv == nullptr) {
|
||||
JSENV_LOG_E("JsEnv is invalid.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "JsEnv is invalid.");
|
||||
return;
|
||||
}
|
||||
jsEnv->PostTask(task, "JsEnvironment:NotifyDebugMode");
|
||||
@ -383,7 +384,7 @@ void JsEnvironment::NotifyDebugMode(
|
||||
|
||||
int32_t JsEnvironment::ParseHdcRegisterOption(std::string& option)
|
||||
{
|
||||
JSENV_LOG_D("Start.");
|
||||
TAG_LOGD(AAFwkTag::JSENV, "Start.");
|
||||
std::size_t pos = option.find_first_of(":");
|
||||
if (pos == std::string::npos) {
|
||||
return -1;
|
||||
|
@ -23,7 +23,8 @@
|
||||
#include <sstream>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "js_env_logger.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace JsEnv {
|
||||
@ -146,7 +147,7 @@ std::string SourceMap::TranslateBySourceMap(const std::string& stackStr)
|
||||
std::string column;
|
||||
GetPosInfo(temp, closeBracePos, line, column);
|
||||
if (line.empty() || column.empty()) {
|
||||
JSENV_LOG_W("the stack without line info");
|
||||
TAG_LOGW(AAFwkTag::JSENV, "the stack without line info");
|
||||
break;
|
||||
}
|
||||
std::string sourceInfo;
|
||||
@ -162,7 +163,7 @@ std::string SourceMap::TranslateBySourceMap(const std::string& stackStr)
|
||||
std::string url = key + ".js.map";
|
||||
std::string curSourceMap;
|
||||
if (!ReadSourceMapData(hapPath_, url, curSourceMap)) {
|
||||
JSENV_LOG_W("ReadSourceMapData fail");
|
||||
TAG_LOGW(AAFwkTag::JSENV, "ReadSourceMapData fail");
|
||||
continue;
|
||||
}
|
||||
ExtractSourceMapData(curSourceMap, nonModularMap_);
|
||||
@ -265,11 +266,11 @@ void SourceMap::ExtractSourceMapData(const std::string& sourceMapData, std::shar
|
||||
std::vector<int32_t> ans;
|
||||
|
||||
if (!VlqRevCode(mapping, ans)) {
|
||||
JSENV_LOG_E("decode code fail");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "decode code fail");
|
||||
return;
|
||||
}
|
||||
if (ans.empty()) {
|
||||
JSENV_LOG_E("decode sourcemap fail, mapping: %{public}s", mapping.c_str());
|
||||
TAG_LOGE(AAFwkTag::JSENV, "decode sourcemap fail, mapping: %{public}s", mapping.c_str());
|
||||
break;
|
||||
}
|
||||
if (ans.size() == 1) {
|
||||
@ -525,7 +526,7 @@ bool SourceMap::TranslateUrlPositionBySourceMap(std::string& url, int& line, int
|
||||
if (iter != sourceMaps_.end()) {
|
||||
return GetLineAndColumnNumbers(line, column, *(iter->second), url);
|
||||
}
|
||||
JSENV_LOG_E("TranslateUrlPositionBySourceMap: stageMode sourceMaps find fail");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "TranslateUrlPositionBySourceMap: stageMode sourceMaps find fail");
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
@ -17,7 +17,8 @@
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
#include "js_env_logger.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "native_engine/native_engine.h"
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#include "ui_content.h"
|
||||
@ -32,7 +33,7 @@ constexpr char BACKTRACE[] = "=====================Backtrace====================
|
||||
std::string NapiUncaughtExceptionCallback::GetNativeStrFromJsTaggedObj(napi_value obj, const char* key)
|
||||
{
|
||||
if (obj == nullptr) {
|
||||
JSENV_LOG_E("Failed to get value from key.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Failed to get value from key.");
|
||||
return "";
|
||||
}
|
||||
|
||||
@ -41,7 +42,7 @@ std::string NapiUncaughtExceptionCallback::GetNativeStrFromJsTaggedObj(napi_valu
|
||||
napi_valuetype valueType = napi_undefined;
|
||||
napi_typeof(env_, valueStr, &valueType);
|
||||
if (valueType != napi_string) {
|
||||
JSENV_LOG_E("Failed to convert value from key.");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "Failed to convert value from key.");
|
||||
return "";
|
||||
}
|
||||
|
||||
@ -51,7 +52,7 @@ std::string NapiUncaughtExceptionCallback::GetNativeStrFromJsTaggedObj(napi_valu
|
||||
size_t valueStrLength = 0;
|
||||
napi_get_value_string_utf8(env_, valueStr, valueCStr.get(), valueStrBufLength + 1, &valueStrLength);
|
||||
std::string ret(valueCStr.get(), valueStrLength);
|
||||
JSENV_LOG_D("GetNativeStrFromJsTaggedObj Success.");
|
||||
TAG_LOGD(AAFwkTag::JSENV, "GetNativeStrFromJsTaggedObj Success.");
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -75,7 +76,7 @@ void NapiUncaughtExceptionCallback::operator()(napi_value obj)
|
||||
summary += "Error code:" + errorCode + "\n";
|
||||
}
|
||||
if (errorStack.empty()) {
|
||||
JSENV_LOG_E("errorStack is empty");
|
||||
TAG_LOGE(AAFwkTag::JSENV, "errorStack is empty");
|
||||
return;
|
||||
}
|
||||
auto errorPos = SourceMap::GetErrorPos(topStack);
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include <string>
|
||||
|
||||
#include "ffrt.h"
|
||||
#include "js_env_logger.h"
|
||||
#include "source_map.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -59,7 +58,6 @@ public:
|
||||
std::string TranslateBySourceMap(const std::string& stackStr)
|
||||
{
|
||||
if (sourceMapObj_ == nullptr) {
|
||||
JSENV_LOG_E("sourceMapObj_ is nullptr");
|
||||
return "";
|
||||
}
|
||||
if (isDebugVersion_) {
|
||||
@ -72,7 +70,6 @@ public:
|
||||
bool TranslateUrlPositionBySourceMap(std::string& url, int& line, int& column)
|
||||
{
|
||||
if (sourceMapObj_ == nullptr) {
|
||||
JSENV_LOG_E("sourceMapObj_ is nullptr");
|
||||
return false;
|
||||
}
|
||||
return sourceMapObj_->TranslateUrlPositionBySourceMap(url, line, column);
|
||||
|
@ -22,7 +22,6 @@
|
||||
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "js_env_logger.h"
|
||||
#include "ohos_js_env_logger.h"
|
||||
#include "ohos_js_environment_impl.h"
|
||||
|
||||
@ -97,9 +96,6 @@ HWTEST_F(JsEnvironmentTest, JsEnvInitialize_0100, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(JsEnvironmentTest, JsEnvInitialize_0200, TestSize.Level0)
|
||||
{
|
||||
JSENV_LOG_I("Running in multi-thread, using default thread number.");
|
||||
|
||||
JSENV_LOG_I("Running in thread %{public}" PRIu64 "", gettid());
|
||||
auto jsEnv = std::make_shared<JsEnvironment>(std::make_unique<AbilityRuntime::OHOSJsEnvironmentImpl>());
|
||||
ASSERT_NE(jsEnv, nullptr);
|
||||
|
||||
@ -384,7 +380,6 @@ HWTEST_F(JsEnvironmentTest, PostSyncTask_0100, TestSize.Level0)
|
||||
std::string taskName = "syncTask001";
|
||||
bool taskExecuted = false;
|
||||
auto task = [taskName, &taskExecuted]() {
|
||||
JSENV_LOG_I("%{public}s called.", taskName.c_str());
|
||||
taskExecuted = true;
|
||||
};
|
||||
jsEnv->PostSyncTask(task, taskName);
|
||||
@ -403,7 +398,6 @@ HWTEST_F(JsEnvironmentTest, SetRequestAotCallback_0100, TestSize.Level0)
|
||||
ASSERT_NE(jsEnv, nullptr);
|
||||
|
||||
auto callback = [](const std::string& bundleName, const std::string& moduleName, int32_t triggerMode) -> int32_t {
|
||||
JSENV_LOG_I("set request aot callback.");
|
||||
return 0;
|
||||
};
|
||||
jsEnv->SetRequestAotCallback(callback);
|
||||
@ -538,5 +532,17 @@ HWTEST_F(JsEnvironmentTest, GetHeapPrepare_0200, TestSize.Level0)
|
||||
jsEnv->GetHeapPrepare();
|
||||
ASSERT_NE(jsEnv, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: GetSourceMapOperator_0100
|
||||
* @tc.desc: Js environment GetSourceMapOperator.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(JsEnvironmentTest, GetSourceMapOperator_0100, TestSize.Level0)
|
||||
{
|
||||
auto jsEnv = std::make_shared<JsEnvironment>(std::make_unique<AbilityRuntime::OHOSJsEnvironmentImpl>());
|
||||
jsEnv->GetSourceMapOperator();
|
||||
ASSERT_NE(jsEnv, nullptr);
|
||||
}
|
||||
} // namespace JsEnv
|
||||
} // namespace OHOS
|
||||
|
@ -37,13 +37,14 @@ public:
|
||||
|
||||
int32_t DeleteAutoStartupData(const AutoStartupInfo &info);
|
||||
|
||||
int32_t DeleteAutoStartupData(const std::string &bundleName);
|
||||
int32_t DeleteAutoStartupData(const std::string &bundleName, int32_t uid);
|
||||
|
||||
AutoStartupStatus QueryAutoStartupData(const AutoStartupInfo &info);
|
||||
|
||||
int32_t QueryAllAutoStartupApplications(std::vector<AutoStartupInfo> &infoList);
|
||||
|
||||
int32_t GetCurrentAppAutoStartupData(const std::string &bundleName, std::vector<AutoStartupInfo> &infoList);
|
||||
int32_t GetCurrentAppAutoStartupData(const std::string &bundleName,
|
||||
std::vector<AutoStartupInfo> &infoList, const std::string &accessTokenId);
|
||||
|
||||
private:
|
||||
DistributedKv::Status GetKvStore();
|
||||
@ -55,7 +56,7 @@ private:
|
||||
AutoStartupInfo ConvertAutoStartupInfoFromKeyAndValue(
|
||||
const DistributedKv::Key &key, const DistributedKv::Value &value);
|
||||
bool IsEqual(const DistributedKv::Key &key, const AutoStartupInfo &info);
|
||||
bool IsEqual(const DistributedKv::Key &key, const std::string &bundleName);
|
||||
bool IsEqual(const DistributedKv::Key &key, const std::string &accessTokenId);
|
||||
|
||||
static const DistributedKv::AppId APP_ID;
|
||||
static const DistributedKv::StoreId STORE_ID;
|
||||
|
@ -78,9 +78,10 @@ public:
|
||||
/**
|
||||
* @brief Delete current bundleName auto start up data.
|
||||
* @param bundleName The current bundleName.
|
||||
* @param uid The uid.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
int32_t DeleteAutoStartupData(const std::string &bundleName);
|
||||
int32_t DeleteAutoStartupData(const std::string &bundleName, int32_t uid);
|
||||
|
||||
/**
|
||||
* @brief Check current bundleName auto start up data.
|
||||
@ -137,7 +138,8 @@ private:
|
||||
std::string GetSelfApplicationBundleName();
|
||||
bool CheckSelfApplication(const std::string &bundleName);
|
||||
bool GetBundleInfo(const std::string &bundleName, AppExecFwk::BundleInfo &bundleInfo, int32_t uid = -1);
|
||||
bool GetAbilityData(const AutoStartupInfo &info, bool &isVisible, std::string &abilityTypeName);
|
||||
bool GetAbilityData(const AutoStartupInfo &info, bool &isVisible,
|
||||
std::string &abilityTypeName, std::string &accessTokenId);
|
||||
std::string GetAbilityTypeName(AppExecFwk::AbilityInfo abilityInfo);
|
||||
std::string GetExtensionTypeName(AppExecFwk::ExtensionAbilityInfo extensionInfo);
|
||||
std::shared_ptr<AppExecFwk::BundleMgrClient> GetBundleMgrClient();
|
||||
@ -145,7 +147,7 @@ private:
|
||||
int32_t CheckPermissionForSelf(const std::string &bundleName);
|
||||
int32_t CheckPermissionForEDM();
|
||||
int32_t InnerApplicationAutoStartupByEDM(const AutoStartupInfo &info, bool isSet, bool flag);
|
||||
int32_t GetAbilityInfo(const AutoStartupInfo &info, std::string &abilityTypeName);
|
||||
int32_t GetAbilityInfo(const AutoStartupInfo &info, std::string &abilityTypeName, std::string &accessTokenId);
|
||||
|
||||
mutable std::mutex autoStartUpMutex_;
|
||||
mutable std::mutex deathRecipientsMutex_;
|
||||
|
@ -553,6 +553,7 @@ private:
|
||||
std::shared_ptr<AbilityRecord> GetExtensionByIdFromServiceMap(int32_t abilityRecordId);
|
||||
int TerminateAbilityInner(const sptr<IRemoteObject> &token);
|
||||
bool IsLauncher(std::shared_ptr<AbilityRecord> serviceExtension) const;
|
||||
bool IsSampleManagement(std::shared_ptr<AbilityRecord> serviceExtension) const;
|
||||
void KillProcessesByUserId() const;
|
||||
void SetLastExitReason(const AbilityRequest &abilityRequest, std::shared_ptr<AbilityRecord> &targetService);
|
||||
inline bool IsUIExtensionAbility(const std::shared_ptr<AbilityRecord> &abilityRecord);
|
||||
|
@ -1064,7 +1064,8 @@ public:
|
||||
int requestCode,
|
||||
AbilityRequest &request,
|
||||
const sptr<IRemoteObject> &callerToken,
|
||||
int32_t userId);
|
||||
int32_t userId,
|
||||
bool isNeedSetDebugApp = true);
|
||||
|
||||
/**
|
||||
* Get mission id by target ability token.
|
||||
|
@ -1041,6 +1041,8 @@ private:
|
||||
|
||||
bool GetUriListFromWant(Want &want, std::vector<std::string> &uriVec);
|
||||
|
||||
void PublishFileOpenEvent(const Want &want);
|
||||
|
||||
#ifdef SUPPORT_SCREEN
|
||||
std::shared_ptr<Want> GetWantFromMission() const;
|
||||
void SetShowWhenLocked(const AppExecFwk::AbilityInfo &abilityInfo, sptr<AbilityTransitionInfo> &info) const;
|
||||
|
@ -399,6 +399,7 @@ private:
|
||||
std::shared_ptr<StatusBarDelegateManager> GetStatusBarDelegateManager();
|
||||
int32_t DoProcessAttachment(std::shared_ptr<AbilityRecord> abilityRecord);
|
||||
void BatchCloseUIAbility(const std::unordered_set<std::shared_ptr<AbilityRecord>>& abilitySet);
|
||||
void TerminateSession(std::shared_ptr<AbilityRecord> abilityRecord);
|
||||
int StartWithPersistentIdByDistributed(const AbilityRequest &abilityRequest, int32_t persistentId);
|
||||
|
||||
int32_t userId_ = -1;
|
||||
|
@ -26,8 +26,6 @@
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
struct StartAbilityInfo {
|
||||
static void InitAbilityInfoFromExtension(AppExecFwk::ExtensionAbilityInfo &extensionInfo,
|
||||
AppExecFwk::AbilityInfo &abilityInfo);
|
||||
static std::shared_ptr<StartAbilityInfo> CreateStartAbilityInfo(const Want &want, int32_t userId,
|
||||
int32_t appIndex);
|
||||
static std::shared_ptr<StartAbilityInfo> CreateCallerAbilityInfo(const sptr<IRemoteObject> &callerToken);
|
||||
|
@ -68,6 +68,7 @@
|
||||
*TaskDataPersistenceMgr*;
|
||||
*Token*;
|
||||
*UserController*;
|
||||
*UnlockScreenManager*;
|
||||
*WantSenderInfo*;
|
||||
*SenderInfo*;
|
||||
*AbilityManagerProxy*;
|
||||
|
@ -23,6 +23,10 @@
|
||||
{
|
||||
"type": "filePicker",
|
||||
"typePicker": "sysPicker/filePicker"
|
||||
},
|
||||
{
|
||||
"type": "audioPicker",
|
||||
"typePicker": "sysPicker/audioPicker"
|
||||
}
|
||||
]
|
||||
}
|
@ -18,11 +18,13 @@
|
||||
#include <algorithm>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "accesstoken_kit.h"
|
||||
#include "errors.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "types.h"
|
||||
#include "os_account_manager_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
@ -36,6 +38,8 @@ const std::string JSON_KEY_MODULE_NAME = "moduleName";
|
||||
const std::string JSON_KEY_IS_AUTO_STARTUP = "isAutoStartup";
|
||||
const std::string JSON_KEY_IS_EDM_FORCE = "isEdmForce";
|
||||
const std::string JSON_KEY_TYPE_NAME = "abilityTypeName";
|
||||
const std::string JSON_KEY_APP_CLONE_INDEX = "appCloneIndex";
|
||||
const std::string JSON_KEY_ACCESS_TOKENID = "accessTokenId";
|
||||
} // namespace
|
||||
const DistributedKv::AppId AbilityAutoStartupDataManager::APP_ID = { "auto_startup_storage" };
|
||||
const DistributedKv::StoreId AbilityAutoStartupDataManager::STORE_ID = { "auto_startup_infos" };
|
||||
@ -90,13 +94,14 @@ bool AbilityAutoStartupDataManager::CheckKvStore()
|
||||
int32_t AbilityAutoStartupDataManager::InsertAutoStartupData(
|
||||
const AutoStartupInfo &info, bool isAutoStartup, bool isEdmForce)
|
||||
{
|
||||
if (info.bundleName.empty() || info.abilityName.empty()) {
|
||||
if (info.bundleName.empty() || info.abilityName.empty() || info.accessTokenId.empty()) {
|
||||
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Invalid value.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str());
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP,
|
||||
"bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s, accessTokenId: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str(), info.accessTokenId.c_str());
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(kvStorePtrMutex_);
|
||||
if (!CheckKvStore()) {
|
||||
@ -123,13 +128,14 @@ int32_t AbilityAutoStartupDataManager::InsertAutoStartupData(
|
||||
int32_t AbilityAutoStartupDataManager::UpdateAutoStartupData(
|
||||
const AutoStartupInfo &info, bool isAutoStartup, bool isEdmForce)
|
||||
{
|
||||
if (info.bundleName.empty() || info.abilityName.empty()) {
|
||||
if (info.bundleName.empty() || info.abilityName.empty() || info.accessTokenId.empty()) {
|
||||
TAG_LOGW(AAFwkTag::AUTO_STARTUP, "Invalid value!");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str());
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP,
|
||||
"bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s, accessTokenId: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str(), info.accessTokenId.c_str());
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(kvStorePtrMutex_);
|
||||
if (!CheckKvStore()) {
|
||||
@ -163,13 +169,14 @@ int32_t AbilityAutoStartupDataManager::UpdateAutoStartupData(
|
||||
|
||||
int32_t AbilityAutoStartupDataManager::DeleteAutoStartupData(const AutoStartupInfo &info)
|
||||
{
|
||||
if (info.bundleName.empty() || info.abilityName.empty()) {
|
||||
if (info.bundleName.empty() || info.abilityName.empty() || info.accessTokenId.empty()) {
|
||||
TAG_LOGW(AAFwkTag::AUTO_STARTUP, "Invalid value!");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str());
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP,
|
||||
"bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s, accessTokenId: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str(), info.accessTokenId.c_str());
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(kvStorePtrMutex_);
|
||||
if (!CheckKvStore()) {
|
||||
@ -192,14 +199,23 @@ int32_t AbilityAutoStartupDataManager::DeleteAutoStartupData(const AutoStartupIn
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t AbilityAutoStartupDataManager::DeleteAutoStartupData(const std::string &bundleName)
|
||||
int32_t AbilityAutoStartupDataManager::DeleteAutoStartupData(const std::string &bundleName, int32_t uid)
|
||||
{
|
||||
if (bundleName.empty()) {
|
||||
int32_t userId;
|
||||
if (DelayedSingleton<AppExecFwk::OsAccountManagerWrapper>::GetInstance()->
|
||||
GetOsAccountLocalIdFromUid(uid, userId) != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Get GetOsAccountLocalIdFromUid failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
uint32_t accessTokenId = Security::AccessToken::AccessTokenKit::GetHapTokenID(userId, bundleName, 0);
|
||||
auto accessTokenIdStr = std::to_string(accessTokenId);
|
||||
if (bundleName.empty() || accessTokenIdStr.empty()) {
|
||||
TAG_LOGW(AAFwkTag::AUTO_STARTUP, "Invalid value!");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "bundleName: %{public}s.", bundleName.c_str());
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "bundleName: %{public}s, accessTokenId: %{public}s.",
|
||||
bundleName.c_str(), accessTokenIdStr.c_str());
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(kvStorePtrMutex_);
|
||||
if (!CheckKvStore()) {
|
||||
@ -216,7 +232,7 @@ int32_t AbilityAutoStartupDataManager::DeleteAutoStartupData(const std::string &
|
||||
}
|
||||
|
||||
for (const auto &item : allEntries) {
|
||||
if (IsEqual(item.key, bundleName)) {
|
||||
if (IsEqual(item.key, accessTokenIdStr)) {
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(kvStorePtrMutex_);
|
||||
status = kvStorePtr_->Delete(item.key);
|
||||
@ -234,14 +250,15 @@ int32_t AbilityAutoStartupDataManager::DeleteAutoStartupData(const std::string &
|
||||
AutoStartupStatus AbilityAutoStartupDataManager::QueryAutoStartupData(const AutoStartupInfo &info)
|
||||
{
|
||||
AutoStartupStatus asustatus;
|
||||
if (info.bundleName.empty() || info.abilityName.empty()) {
|
||||
if (info.bundleName.empty() || info.abilityName.empty() || info.accessTokenId.empty()) {
|
||||
TAG_LOGW(AAFwkTag::AUTO_STARTUP, "Invalid value!");
|
||||
asustatus.code = ERR_INVALID_VALUE;
|
||||
return asustatus;
|
||||
}
|
||||
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str());
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP,
|
||||
"bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s, accessTokenId: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str(), info.accessTokenId.c_str());
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(kvStorePtrMutex_);
|
||||
if (!CheckKvStore()) {
|
||||
@ -300,7 +317,7 @@ int32_t AbilityAutoStartupDataManager::QueryAllAutoStartupApplications(std::vect
|
||||
}
|
||||
|
||||
int32_t AbilityAutoStartupDataManager::GetCurrentAppAutoStartupData(
|
||||
const std::string &bundleName, std::vector<AutoStartupInfo> &infoList)
|
||||
const std::string &bundleName, std::vector<AutoStartupInfo> &infoList, const std::string &accessTokenId)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "Called.");
|
||||
{
|
||||
@ -319,7 +336,7 @@ int32_t AbilityAutoStartupDataManager::GetCurrentAppAutoStartupData(
|
||||
}
|
||||
|
||||
for (const auto &item : allEntries) {
|
||||
if (IsEqual(item.key, bundleName)) {
|
||||
if (IsEqual(item.key, accessTokenId)) {
|
||||
infoList.emplace_back(ConvertAutoStartupInfoFromKeyAndValue(item.key, item.value));
|
||||
}
|
||||
}
|
||||
@ -362,6 +379,8 @@ DistributedKv::Key AbilityAutoStartupDataManager::ConvertAutoStartupDataToKey(co
|
||||
{ JSON_KEY_BUNDLE_NAME, info.bundleName },
|
||||
{ JSON_KEY_MODULE_NAME, info.moduleName },
|
||||
{ JSON_KEY_ABILITY_NAME, info.abilityName },
|
||||
{ JSON_KEY_APP_CLONE_INDEX, info.appCloneIndex },
|
||||
{ JSON_KEY_ACCESS_TOKENID, info.accessTokenId },
|
||||
};
|
||||
DistributedKv::Key key(jsonObject.dump());
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "key: %{public}s.", key.ToString().c_str());
|
||||
@ -390,6 +409,10 @@ AutoStartupInfo AbilityAutoStartupDataManager::ConvertAutoStartupInfoFromKeyAndV
|
||||
info.abilityName = jsonObject.at(JSON_KEY_ABILITY_NAME).get<std::string>();
|
||||
}
|
||||
|
||||
if (jsonObject.contains(JSON_KEY_APP_CLONE_INDEX) && jsonObject[JSON_KEY_APP_CLONE_INDEX].is_string()) {
|
||||
info.appCloneIndex = jsonObject.at(JSON_KEY_APP_CLONE_INDEX).get<std::int32_t>();
|
||||
}
|
||||
|
||||
nlohmann::json jsonValueObject = nlohmann::json::parse(value.ToString(), nullptr, false);
|
||||
if (jsonValueObject.is_discarded()) {
|
||||
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Failed to parse jsonValueObject.");
|
||||
@ -400,6 +423,9 @@ AutoStartupInfo AbilityAutoStartupDataManager::ConvertAutoStartupInfoFromKeyAndV
|
||||
info.abilityTypeName = jsonValueObject.at(JSON_KEY_TYPE_NAME).get<std::string>();
|
||||
}
|
||||
|
||||
if (jsonValueObject.contains(JSON_KEY_ACCESS_TOKENID) && jsonValueObject[JSON_KEY_ACCESS_TOKENID].is_string()) {
|
||||
info.accessTokenId = jsonValueObject.at(JSON_KEY_ACCESS_TOKENID).get<std::string>();
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
@ -429,10 +455,23 @@ bool AbilityAutoStartupDataManager::IsEqual(const DistributedKv::Key &key, const
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (jsonObject.contains(JSON_KEY_ACCESS_TOKENID) && jsonObject[JSON_KEY_ACCESS_TOKENID].is_string()) {
|
||||
if (info.accessTokenId != jsonObject.at(JSON_KEY_ACCESS_TOKENID).get<std::string>()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (jsonObject.contains(JSON_KEY_APP_CLONE_INDEX) && jsonObject[JSON_KEY_APP_CLONE_INDEX].is_string()) {
|
||||
if (info.appCloneIndex != jsonObject.at(JSON_KEY_APP_CLONE_INDEX).get<std::int32_t>()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AbilityAutoStartupDataManager::IsEqual(const DistributedKv::Key &key, const std::string &bundleName)
|
||||
bool AbilityAutoStartupDataManager::IsEqual(const DistributedKv::Key &key, const std::string &accessTokenId)
|
||||
{
|
||||
nlohmann::json jsonObject = nlohmann::json::parse(key.ToString(), nullptr, false);
|
||||
if (jsonObject.is_discarded()) {
|
||||
@ -440,8 +479,8 @@ bool AbilityAutoStartupDataManager::IsEqual(const DistributedKv::Key &key, const
|
||||
return false;
|
||||
}
|
||||
|
||||
if (jsonObject.contains(JSON_KEY_BUNDLE_NAME) && jsonObject[JSON_KEY_BUNDLE_NAME].is_string()) {
|
||||
if (bundleName == jsonObject.at(JSON_KEY_BUNDLE_NAME).get<std::string>()) {
|
||||
if (jsonObject.contains(JSON_KEY_ACCESS_TOKENID) && jsonObject[JSON_KEY_ACCESS_TOKENID].is_string()) {
|
||||
if (accessTokenId == jsonObject.at(JSON_KEY_ACCESS_TOKENID).get<std::string>()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
#include "ability_auto_startup_data_manager.h"
|
||||
#include "ability_manager_errors.h"
|
||||
@ -102,8 +103,9 @@ int32_t AbilityAutoStartupService::UnregisterAutoStartupSystemCallback(const spt
|
||||
|
||||
int32_t AbilityAutoStartupService::SetApplicationAutoStartup(const AutoStartupInfo &info)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "Called, bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str());
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP,
|
||||
"Called, bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s, accessTokenId: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str(), info.accessTokenId.c_str());
|
||||
int32_t code = CheckPermissionForSystem();
|
||||
if (code != ERR_OK) {
|
||||
return code;
|
||||
@ -111,7 +113,8 @@ int32_t AbilityAutoStartupService::SetApplicationAutoStartup(const AutoStartupIn
|
||||
|
||||
bool isVisible;
|
||||
std::string abilityTypeName;
|
||||
if (!GetAbilityData(info, isVisible, abilityTypeName)) {
|
||||
std::string accessTokenId;
|
||||
if (!GetAbilityData(info, isVisible, abilityTypeName, accessTokenId)) {
|
||||
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Failed to get ability data.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
@ -123,6 +126,7 @@ int32_t AbilityAutoStartupService::SetApplicationAutoStartup(const AutoStartupIn
|
||||
|
||||
AutoStartupInfo fullInfo(info);
|
||||
fullInfo.abilityTypeName = abilityTypeName;
|
||||
fullInfo.accessTokenId = accessTokenId;
|
||||
|
||||
return InnerSetApplicationAutoStartup(fullInfo);
|
||||
}
|
||||
@ -163,8 +167,9 @@ int32_t AbilityAutoStartupService::InnerSetApplicationAutoStartup(const AutoStar
|
||||
|
||||
int32_t AbilityAutoStartupService::CancelApplicationAutoStartup(const AutoStartupInfo &info)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "Called, bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str());
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP,
|
||||
"Called, bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s, accessTokenId: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str(), info.accessTokenId.c_str());
|
||||
int32_t code = CheckPermissionForSystem();
|
||||
if (code != ERR_OK) {
|
||||
return code;
|
||||
@ -172,7 +177,8 @@ int32_t AbilityAutoStartupService::CancelApplicationAutoStartup(const AutoStartu
|
||||
|
||||
bool isVisible;
|
||||
std::string abilityTypeName;
|
||||
if (!GetAbilityData(info, isVisible, abilityTypeName)) {
|
||||
std::string accessTokenId;
|
||||
if (!GetAbilityData(info, isVisible, abilityTypeName, accessTokenId)) {
|
||||
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Failed to get ability data.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
@ -184,6 +190,7 @@ int32_t AbilityAutoStartupService::CancelApplicationAutoStartup(const AutoStartu
|
||||
|
||||
AutoStartupInfo fullInfo(info);
|
||||
fullInfo.abilityTypeName = abilityTypeName;
|
||||
fullInfo.accessTokenId = accessTokenId;
|
||||
|
||||
return InnerCancelApplicationAutoStartup(fullInfo);
|
||||
}
|
||||
@ -237,17 +244,23 @@ int32_t AbilityAutoStartupService::QueryAllAutoStartupApplicationsWithoutPermiss
|
||||
return DelayedSingleton<AbilityAutoStartupDataManager>::GetInstance()->QueryAllAutoStartupApplications(infoList);
|
||||
}
|
||||
|
||||
int32_t AbilityAutoStartupService::DeleteAutoStartupData(const std::string &bundleName)
|
||||
int32_t AbilityAutoStartupService::DeleteAutoStartupData(const std::string &bundleName, const int32_t uid)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "Called.");
|
||||
return DelayedSingleton<AbilityAutoStartupDataManager>::GetInstance()->DeleteAutoStartupData(bundleName);
|
||||
return DelayedSingleton<AbilityAutoStartupDataManager>::GetInstance()->DeleteAutoStartupData(bundleName, uid);
|
||||
}
|
||||
|
||||
int32_t AbilityAutoStartupService::CheckAutoStartupData(const std::string &bundleName, int32_t uid)
|
||||
{
|
||||
AppExecFwk::BundleInfo bundleInfo;
|
||||
if (!GetBundleInfo(bundleName, bundleInfo, uid)) {
|
||||
return INNER_ERR;
|
||||
}
|
||||
auto tokenId = bundleInfo.applicationInfo.accessTokenId;
|
||||
std::string accessTokenIdStr = std::to_string(tokenId);
|
||||
std::vector<AutoStartupInfo> infoList;
|
||||
int32_t result = DelayedSingleton<AbilityAutoStartupDataManager>::GetInstance()->GetCurrentAppAutoStartupData(
|
||||
bundleName, infoList);
|
||||
bundleName, infoList, accessTokenIdStr);
|
||||
if (result != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Failed to get auto startup data.");
|
||||
return result;
|
||||
@ -256,11 +269,6 @@ int32_t AbilityAutoStartupService::CheckAutoStartupData(const std::string &bundl
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
AppExecFwk::BundleInfo bundleInfo;
|
||||
if (!GetBundleInfo(bundleName, bundleInfo, uid)) {
|
||||
return INNER_ERR;
|
||||
}
|
||||
|
||||
bool isFound = false;
|
||||
for (auto info : infoList) {
|
||||
for (auto abilityInfo : bundleInfo.abilityInfos) {
|
||||
@ -274,15 +282,16 @@ int32_t AbilityAutoStartupService::CheckAutoStartupData(const std::string &bundl
|
||||
|
||||
if (!isFound) {
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "Current bundleName not found in Datebase.");
|
||||
return DelayedSingleton<AbilityAutoStartupDataManager>::GetInstance()->DeleteAutoStartupData(bundleName);
|
||||
return DelayedSingleton<AbilityAutoStartupDataManager>::GetInstance()->DeleteAutoStartupData(bundleName, uid);
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
void AbilityAutoStartupService::ExecuteCallbacks(bool isCallOn, const AutoStartupInfo &info)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str());
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP,
|
||||
"bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s, accessTokenId: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str(), info.accessTokenId.c_str());
|
||||
for (auto item : callbackVector_) {
|
||||
auto remoteSystemCallback = iface_cast<IAutoStartupCallBack>(item);
|
||||
if (remoteSystemCallback != nullptr) {
|
||||
@ -443,15 +452,18 @@ bool AbilityAutoStartupService::GetBundleInfo(
|
||||
}
|
||||
|
||||
bool AbilityAutoStartupService::GetAbilityData(
|
||||
const AutoStartupInfo &info, bool &isVisible, std::string &abilityTypeName)
|
||||
const AutoStartupInfo &info, bool &isVisible, std::string &abilityTypeName, std::string &accessTokenId)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "Called, bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str());
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP,
|
||||
"Called, bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s, accessTokenId: %{public}s.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str(), info.accessTokenId.c_str());
|
||||
AppExecFwk::BundleInfo bundleInfo;
|
||||
if (!GetBundleInfo(info.bundleName, bundleInfo)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto accessTokenIdStr = bundleInfo.applicationInfo.accessTokenId;
|
||||
accessTokenId = std::to_string(accessTokenIdStr);
|
||||
for (auto abilityInfo : bundleInfo.abilityInfos) {
|
||||
if ((abilityInfo.bundleName == info.bundleName) && (abilityInfo.name == info.abilityName)) {
|
||||
if (info.moduleName.empty() || (abilityInfo.moduleName == info.moduleName)) {
|
||||
@ -538,10 +550,11 @@ int32_t AbilityAutoStartupService::CheckPermissionForSelf(const std::string &bun
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t AbilityAutoStartupService::GetAbilityInfo(const AutoStartupInfo &info, std::string &abilityTypeName)
|
||||
int32_t AbilityAutoStartupService::GetAbilityInfo(
|
||||
const AutoStartupInfo &info, std::string &abilityTypeName, std::string &accessTokenId)
|
||||
{
|
||||
bool isVisible = false;
|
||||
if (!GetAbilityData(info, isVisible, abilityTypeName)) {
|
||||
if (!GetAbilityData(info, isVisible, abilityTypeName, accessTokenId)) {
|
||||
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Failed to get ability data.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
@ -561,12 +574,14 @@ int32_t AbilityAutoStartupService::SetApplicationAutoStartupByEDM(const AutoStar
|
||||
return errorCode;
|
||||
}
|
||||
std::string typeName;
|
||||
errorCode = GetAbilityInfo(info, typeName);
|
||||
std::string accessTokenId;
|
||||
errorCode = GetAbilityInfo(info, typeName, accessTokenId);
|
||||
if (errorCode != ERR_OK) {
|
||||
return errorCode;
|
||||
}
|
||||
AutoStartupInfo fullInfo(info);
|
||||
fullInfo.abilityTypeName = typeName;
|
||||
fullInfo.accessTokenId = accessTokenId;
|
||||
return InnerApplicationAutoStartupByEDM(fullInfo, true, flag);
|
||||
}
|
||||
|
||||
@ -577,20 +592,24 @@ int32_t AbilityAutoStartupService::CancelApplicationAutoStartupByEDM(const AutoS
|
||||
return errorCode;
|
||||
}
|
||||
std::string typeName;
|
||||
errorCode = GetAbilityInfo(info, typeName);
|
||||
std::string accessTokenId;
|
||||
errorCode = GetAbilityInfo(info, typeName, accessTokenId);
|
||||
if (errorCode != ERR_OK) {
|
||||
return errorCode;
|
||||
}
|
||||
AutoStartupInfo fullInfo(info);
|
||||
fullInfo.abilityTypeName = typeName;
|
||||
fullInfo.accessTokenId = accessTokenId;
|
||||
return InnerApplicationAutoStartupByEDM(fullInfo, false, flag);
|
||||
}
|
||||
|
||||
int32_t AbilityAutoStartupService::InnerApplicationAutoStartupByEDM(const AutoStartupInfo &info, bool isSet, bool flag)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::AUTO_STARTUP,
|
||||
"Called, bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s, isSet: %{public}d.,"
|
||||
"flag: %{public}d.", info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str(), isSet, flag);
|
||||
"Called, bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s, accessTokenId: %{public}s,"
|
||||
" isSet: %{public}d.,""flag: %{public}d.",
|
||||
info.bundleName.c_str(), info.moduleName.c_str(), info.abilityName.c_str(),
|
||||
info.accessTokenId.c_str(), isSet, flag);
|
||||
AutoStartupStatus status =
|
||||
DelayedSingleton<AbilityAutoStartupDataManager>::GetInstance()->QueryAutoStartupData(info);
|
||||
if (status.code != ERR_OK && status.code != ERR_NAME_NOT_FOUND) {
|
||||
|
@ -58,7 +58,7 @@ void AbilityBundleEventCallback::OnReceiveEvent(const EventFwk::CommonEventData
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "OnReceiveEvent failed, abilityAutoStartupService is nullptr");
|
||||
return;
|
||||
}
|
||||
abilityAutoStartupService_->DeleteAutoStartupData(bundleName);
|
||||
abilityAutoStartupService_->DeleteAutoStartupData(bundleName, uid);
|
||||
} else if (action == EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_ADDED) {
|
||||
// install or uninstall module/bundle
|
||||
HandleUpdatedModuleInfo(bundleName, uid);
|
||||
|
@ -75,6 +75,8 @@ const std::unordered_set<std::string> FROZEN_WHITE_LIST {
|
||||
};
|
||||
constexpr char BUNDLE_NAME_DIALOG[] = "com.ohos.amsdialog";
|
||||
constexpr char ABILITY_NAME_ASSERT_FAULT_DIALOG[] = "AssertFaultDialog";
|
||||
constexpr char BUNDLE_NAME_SAMPLE_MANAGEMENT[] = "com.huawei.hmsapp.samplemanagement";
|
||||
constexpr char ABILITY_NAME_SAMPLE_MANAGEMENT[] = "MspesService";
|
||||
|
||||
bool IsSpecialAbility(const AppExecFwk::AbilityInfo &abilityInfo)
|
||||
{
|
||||
@ -2009,14 +2011,14 @@ void AbilityConnectManager::HandleAbilityDiedTask(
|
||||
if ((IsLauncher(abilityRecord) || abilityRecord->IsSceneBoard()) && token != nullptr) {
|
||||
IN_PROCESS_CALL_WITHOUT_RET(DelayedSingleton<AppScheduler>::GetInstance()->ClearProcessByToken(
|
||||
token->AsObject()));
|
||||
if (abilityRecord->IsSceneBoard() && currentUserId != userId_) {
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "Not the current user's SCB, clear the user and do not restart");
|
||||
KillProcessesByUserId();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (abilityRecord->IsSceneBoard() && currentUserId != userId_) {
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "Not the current user's SCB, clear the user and do not restart");
|
||||
KillProcessesByUserId();
|
||||
return;
|
||||
}
|
||||
if (DelayedSingleton<AppScheduler>::GetInstance()->IsMemorySizeSufficent() ||
|
||||
IsLauncher(abilityRecord) || abilityRecord->IsSceneBoard()) {
|
||||
IsLauncher(abilityRecord) || abilityRecord->IsSceneBoard() || IsSampleManagement(abilityRecord)) {
|
||||
RestartAbility(abilityRecord, currentUserId);
|
||||
}
|
||||
} else {
|
||||
@ -2345,6 +2347,16 @@ bool AbilityConnectManager::IsLauncher(std::shared_ptr<AbilityRecord> serviceExt
|
||||
serviceExtension->GetAbilityInfo().bundleName == AbilityConfig::LAUNCHER_BUNDLE_NAME;
|
||||
}
|
||||
|
||||
bool AbilityConnectManager::IsSampleManagement(std::shared_ptr<AbilityRecord> serviceExtension) const
|
||||
{
|
||||
if (serviceExtension == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "param is nullptr");
|
||||
return false;
|
||||
}
|
||||
return serviceExtension->GetAbilityInfo().name == ABILITY_NAME_SAMPLE_MANAGEMENT &&
|
||||
serviceExtension->GetAbilityInfo().bundleName == BUNDLE_NAME_SAMPLE_MANAGEMENT;
|
||||
}
|
||||
|
||||
void AbilityConnectManager::KillProcessesByUserId() const
|
||||
{
|
||||
auto appScheduler = DelayedSingleton<AppScheduler>::GetInstance();
|
||||
|
@ -988,7 +988,7 @@ int AbilityManagerService::StartAbilityInner(const Want &want, const sptr<IRemot
|
||||
return ShowPickerDialog(want, validUserId, callerToken);
|
||||
}
|
||||
#endif
|
||||
result = GenerateAbilityRequest(want, requestCode, abilityRequest, callerToken, validUserId);
|
||||
result = GenerateAbilityRequest(want, requestCode, abilityRequest, callerToken, validUserId, false);
|
||||
auto abilityRecord = Token::GetAbilityRecordByToken(callerToken);
|
||||
std::string callerBundleName = abilityRecord ? abilityRecord->GetAbilityInfo().bundleName : "";
|
||||
bool selfFreeInstallEnable = (result == RESOLVE_ABILITY_ERR && want.GetElement().GetModuleName() != "" &&
|
||||
@ -1015,7 +1015,7 @@ int AbilityManagerService::StartAbilityInner(const Want &want, const sptr<IRemot
|
||||
}
|
||||
int32_t ret = freeInstallManager_->StartFreeInstall(localWant, validUserId, requestCode, callerToken, false);
|
||||
if (ret == ERR_OK) {
|
||||
result = GenerateAbilityRequest(want, requestCode, abilityRequest, callerToken, validUserId);
|
||||
result = GenerateAbilityRequest(want, requestCode, abilityRequest, callerToken, validUserId, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1186,6 +1186,10 @@ int AbilityManagerService::StartAbilityInner(const Want &want, const sptr<IRemot
|
||||
CHECK_POINTER_AND_RETURN(uiAbilityManager, ERR_INVALID_VALUE);
|
||||
return uiAbilityManager->NotifySCBToStartUIAbility(abilityRequest);
|
||||
}
|
||||
|
||||
SetDebugAppByWaitingDebugFlag(
|
||||
want, abilityRequest.want, abilityRequest.appInfo.bundleName, abilityRequest.appInfo.debug);
|
||||
|
||||
auto missionListManager = GetMissionListManagerByUserId(oriValidUserId);
|
||||
if (missionListManager == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "missionListManager is nullptr. userId=%{public}d", validUserId);
|
||||
@ -2216,8 +2220,8 @@ int AbilityManagerService::CheckOptExtensionAbility(const Want &want, AbilityReq
|
||||
return ERR_STATIC_CFG_PERMISSION;
|
||||
}
|
||||
|
||||
if (extensionType == AppExecFwk::ExtensionAbilityType::DATASHARE ||
|
||||
extensionType == AppExecFwk::ExtensionAbilityType::SERVICE) {
|
||||
if (abilityInfo.extensionAbilityType == AppExecFwk::ExtensionAbilityType::DATASHARE ||
|
||||
abilityInfo.extensionAbilityType == AppExecFwk::ExtensionAbilityType::SERVICE) {
|
||||
result = CheckCallServiceExtensionPermission(abilityRequest);
|
||||
if (result != ERR_OK) {
|
||||
return result;
|
||||
@ -5685,8 +5689,8 @@ void AbilityManagerService::StartHighestPriorityAbility(int32_t userId, bool isB
|
||||
(void)StartAbility(abilityWant, userId, DEFAULT_INVAL_VALUE);
|
||||
}
|
||||
|
||||
int AbilityManagerService::GenerateAbilityRequest(
|
||||
const Want &want, int requestCode, AbilityRequest &request, const sptr<IRemoteObject> &callerToken, int32_t userId)
|
||||
int AbilityManagerService::GenerateAbilityRequest(const Want &want, int requestCode, AbilityRequest &request,
|
||||
const sptr<IRemoteObject> &callerToken, int32_t userId, bool isNeedSetDebugApp)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
auto abilityRecord = Token::GetAbilityRecordByToken(callerToken);
|
||||
@ -5756,8 +5760,9 @@ int AbilityManagerService::GenerateAbilityRequest(
|
||||
AAFwk::PermissionVerification::GetInstance()->VerifyStartRecentAbilityPermission()) {
|
||||
request.startRecent = true;
|
||||
}
|
||||
|
||||
SetDebugAppByWaitingDebugFlag(want, request.want, request.appInfo.bundleName, request.appInfo.debug);
|
||||
if (isNeedSetDebugApp) {
|
||||
SetDebugAppByWaitingDebugFlag(want, request.want, request.appInfo.bundleName, request.appInfo.debug);
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
@ -6421,6 +6426,9 @@ void AbilityManagerService::RetryStartAutoStartupApps(
|
||||
Want want;
|
||||
want.SetElement(element);
|
||||
want.SetParam(Want::PARAM_APP_AUTO_STARTUP_LAUNCH_REASON, true);
|
||||
if (info.appCloneIndex > 0 && info.appCloneIndex <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) {
|
||||
want.SetParam(Want::PARAM_APP_CLONE_INDEX_KEY, info.appCloneIndex);
|
||||
}
|
||||
if (StartAbility(want) != ERR_OK) {
|
||||
failedList.push_back(info);
|
||||
}
|
||||
@ -8014,6 +8022,7 @@ void AbilityManagerService::GetAbilityRunningInfo(std::vector<AbilityRunningInfo
|
||||
runningInfo.pid = processInfo.pid_;
|
||||
runningInfo.uid = processInfo.uid_;
|
||||
runningInfo.processName = processInfo.processName_;
|
||||
runningInfo.appCloneIndex = processInfo.appCloneIndex;
|
||||
info.emplace_back(runningInfo);
|
||||
}
|
||||
|
||||
@ -9899,6 +9908,7 @@ int32_t AbilityManagerService::GetForegroundUIAbilities(std::vector<AppExecFwk::
|
||||
abilityData.pid = info.pid;
|
||||
abilityData.uid = info.uid;
|
||||
abilityData.abilityType = static_cast<int32_t>(AppExecFwk::AbilityType::PAGE);
|
||||
abilityData.appCloneIndex = info.appCloneIndex;
|
||||
AppExecFwk::ApplicationInfo appInfo;
|
||||
if (!StartAbilityUtils::GetApplicationInfo(abilityData.bundleName, GetUserId(), appInfo)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "can not get applicationInfo through bundleName");
|
||||
|
@ -33,6 +33,9 @@
|
||||
#include "bundle_mgr_client.h"
|
||||
#include "configuration_convertor.h"
|
||||
#include "connection_state_manager.h"
|
||||
#include "common_event_data.h"
|
||||
#include "common_event_manager.h"
|
||||
#include "common_event_support.h"
|
||||
#include "freeze_util.h"
|
||||
#include "global_constant.h"
|
||||
#include "hitrace_meter.h"
|
||||
@ -3049,6 +3052,28 @@ bool AbilityRecord::GetUriListFromWant(Want &want, std::vector<std::string> &uri
|
||||
return true;
|
||||
}
|
||||
|
||||
void AbilityRecord::PublishFileOpenEvent(const Want &want)
|
||||
{
|
||||
auto wangUri = want.GetUri();
|
||||
std::string uriStr = wangUri.ToString();
|
||||
if (!uriStr.empty() && wangUri.GetScheme() == "file") {
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "ability record, file uri: %{private}s, isGranted: %{public}d",
|
||||
uriStr.c_str(), isGrantedUriPermission_);
|
||||
Want msgWant;
|
||||
msgWant.SetAction("file.event.OPEN_TIME");
|
||||
msgWant.SetParam("uri", uriStr);
|
||||
auto timeNow = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::system_clock::now().time_since_epoch()).count();
|
||||
std::string currentTime = std::to_string(timeNow);
|
||||
msgWant.SetParam("viewTime", currentTime);
|
||||
EventFwk::CommonEventData commonData{msgWant};
|
||||
EventFwk::CommonEventPublishInfo commonEventPublishInfo;
|
||||
std::vector<std::string> subscriberPermissions = {"ohos.permission.MANAGE_LOCAL_ACCOUNTS"};
|
||||
commonEventPublishInfo.SetSubscriberPermissions(subscriberPermissions);
|
||||
EventFwk::CommonEventManager::PublishCommonEvent(commonData, commonEventPublishInfo);
|
||||
}
|
||||
}
|
||||
|
||||
void AbilityRecord::GrantUriPermission(Want &want, std::string targetBundleName, bool isSandboxApp, uint32_t tokenId)
|
||||
{
|
||||
// reject sandbox to grant uri permission by start ability
|
||||
@ -3089,6 +3114,7 @@ void AbilityRecord::GrantUriPermission(Want &want, std::string targetBundleName,
|
||||
return;
|
||||
}
|
||||
GrantUriPermissionInner(want, uriVec, targetBundleName, tokenId);
|
||||
PublishFileOpenEvent(want);
|
||||
}
|
||||
|
||||
void AbilityRecord::GrantUriPermissionInner(Want &want, std::vector<std::string> &uriVec,
|
||||
|
@ -32,6 +32,7 @@ bool AbilityRunningInfo::ReadFromParcel(Parcel &parcel)
|
||||
processName = Str16ToStr8(parcel.ReadString16());
|
||||
startTime = parcel.ReadInt64();
|
||||
abilityState = parcel.ReadInt32();
|
||||
appCloneIndex = parcel.ReadInt32();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -69,6 +70,9 @@ bool AbilityRunningInfo::Marshalling(Parcel &parcel) const
|
||||
if (!parcel.WriteInt32(abilityState)) {
|
||||
return false;
|
||||
}
|
||||
if (!parcel.WriteInt32(appCloneIndex)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace AAFwk
|
||||
|
@ -24,6 +24,7 @@ bool AutoStartupInfo::ReadFromParcel(Parcel &parcel)
|
||||
abilityName = Str16ToStr8(parcel.ReadString16());
|
||||
moduleName = Str16ToStr8(parcel.ReadString16());
|
||||
abilityTypeName = Str16ToStr8(parcel.ReadString16());
|
||||
appCloneIndex = parcel.ReadInt32();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -55,6 +56,9 @@ bool AutoStartupInfo::Marshalling(Parcel &parcel) const
|
||||
if (!parcel.WriteString16(Str8ToStr16(abilityTypeName))) {
|
||||
return false;
|
||||
}
|
||||
if (!parcel.WriteInt32(appCloneIndex)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
|
@ -52,7 +52,7 @@ void RestartAppManager::AddRestartAppHistory(const RestartAppKeyType &key, time_
|
||||
bool RestartAppManager::IsForegroundToRestartApp() const
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "IsForegroundToRestartApp, called.");
|
||||
auto callerPid = IPCSkeleton::GetCallingRealPid();
|
||||
auto callerPid = IPCSkeleton::GetCallingPid();
|
||||
AppExecFwk::RunningProcessInfo processInfo;
|
||||
DelayedSingleton<AppScheduler>::GetInstance()->GetRunningProcessInfoByPid(callerPid, processInfo);
|
||||
if (processInfo.state_ == AppProcessState::APP_STATE_FOREGROUND || processInfo.isFocused ||
|
||||
|
@ -104,6 +104,8 @@ int UIAbilityLifecycleManager::StartUIAbility(AbilityRequest &abilityRequest, sp
|
||||
if (sessionInfo->isNewWant) {
|
||||
uiAbilityRecord->SetWant(abilityRequest.want);
|
||||
uiAbilityRecord->GetSessionInfo()->want.CloseAllFd();
|
||||
} else {
|
||||
sessionInfo->want.CloseAllFd();
|
||||
}
|
||||
} else {
|
||||
uiAbilityRecord = CreateAbilityRecord(abilityRequest, sessionInfo);
|
||||
@ -259,7 +261,7 @@ int UIAbilityLifecycleManager::AttachAbilityThread(const sptr<IAbilityScheduler>
|
||||
abilityRecord->SetScheduler(scheduler);
|
||||
if (DoProcessAttachment(abilityRecord) != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "do process attachment failed, close the ability.");
|
||||
BatchCloseUIAbility({abilityRecord});
|
||||
TerminateSession(abilityRecord);
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
if (abilityRecord->IsStartedByCall()) {
|
||||
@ -356,7 +358,9 @@ int UIAbilityLifecycleManager::NotifySCBToStartUIAbility(const AbilityRequest &a
|
||||
sessionInfo->processOptions = abilityRequest.processOptions;
|
||||
TAG_LOGI(
|
||||
AAFwkTag::ABILITYMGR, "Reused sessionId: %{public}d, userId: %{public}d.", sessionInfo->persistentId, userId_);
|
||||
return NotifySCBPendingActivation(sessionInfo, abilityRequest);
|
||||
int ret = NotifySCBPendingActivation(sessionInfo, abilityRequest);
|
||||
sessionInfo->want.CloseAllFd();
|
||||
return ret;
|
||||
}
|
||||
|
||||
int UIAbilityLifecycleManager::DispatchState(const std::shared_ptr<AbilityRecord> &abilityRecord, int state)
|
||||
@ -2220,8 +2224,10 @@ int32_t UIAbilityLifecycleManager::KillProcessWithPrepareTerminate(const std::ve
|
||||
}
|
||||
if (needKillProcess) {
|
||||
pidsToKill.push_back(pid);
|
||||
} else if (!abilitysToTerminate.empty()) {
|
||||
BatchCloseUIAbility(abilitysToTerminate);
|
||||
continue;
|
||||
}
|
||||
for (const auto& abilityRecord: abilitysToTerminate) {
|
||||
TerminateSession(abilityRecord);
|
||||
}
|
||||
}
|
||||
if (!pidsToKill.empty()) {
|
||||
@ -2251,6 +2257,18 @@ void UIAbilityLifecycleManager::BatchCloseUIAbility(
|
||||
}
|
||||
}
|
||||
|
||||
void UIAbilityLifecycleManager::TerminateSession(std::shared_ptr<AbilityRecord> abilityRecord)
|
||||
{
|
||||
CHECK_POINTER(abilityRecord);
|
||||
auto sessionInfo = abilityRecord->GetSessionInfo();
|
||||
CHECK_POINTER(sessionInfo);
|
||||
CHECK_POINTER(sessionInfo->sessionToken);
|
||||
auto session = iface_cast<Rosen::ISession>(sessionInfo->sessionToken);
|
||||
CHECK_POINTER(session);
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "call TerminateSession, session id: %{public}d", sessionInfo->persistentId);
|
||||
session->TerminateSession(sessionInfo);
|
||||
}
|
||||
|
||||
int UIAbilityLifecycleManager::ChangeAbilityVisibility(sptr<IRemoteObject> token, bool isShow)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
|
@ -58,11 +58,6 @@ bool UnlockScreenManager::UnlockScreen()
|
||||
if (isScreenLocked && isScreenSecured) {
|
||||
return false;
|
||||
}
|
||||
if (isScreenLocked) {
|
||||
sptr<UnlockScreenCallback> listener = sptr<UnlockScreenCallback>(new (std::nothrow) UnlockScreenCallback());
|
||||
IN_PROCESS_CALL(OHOS::ScreenLock::ScreenLockManager::GetInstance()->Unlock(
|
||||
OHOS::ScreenLock::Action::UNLOCKSCREEN, listener));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -73,6 +68,14 @@ bool UnlockScreenManager::UnlockScreen()
|
||||
PowerMgr::PowerMgrClient::GetInstance().WakeupDevice();
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
if (isScreenLocked) {
|
||||
sptr<UnlockScreenCallback> listener = sptr<UnlockScreenCallback>(new (std::nothrow) UnlockScreenCallback());
|
||||
IN_PROCESS_CALL(OHOS::ScreenLock::ScreenLockManager::GetInstance()->Unlock(
|
||||
OHOS::ScreenLock::Action::UNLOCKSCREEN, listener));
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
|
@ -129,44 +129,6 @@ StartAbilityInfoWrap::~StartAbilityInfoWrap()
|
||||
StartAbilityUtils::skipErms = false;
|
||||
}
|
||||
|
||||
void StartAbilityInfo::InitAbilityInfoFromExtension(AppExecFwk::ExtensionAbilityInfo &extensionInfo,
|
||||
AppExecFwk::AbilityInfo &abilityInfo)
|
||||
{
|
||||
abilityInfo.applicationName = extensionInfo.applicationInfo.name;
|
||||
abilityInfo.applicationInfo = extensionInfo.applicationInfo;
|
||||
abilityInfo.bundleName = extensionInfo.bundleName;
|
||||
abilityInfo.package = extensionInfo.moduleName;
|
||||
abilityInfo.moduleName = extensionInfo.moduleName;
|
||||
abilityInfo.name = extensionInfo.name;
|
||||
abilityInfo.srcEntrance = extensionInfo.srcEntrance;
|
||||
abilityInfo.srcPath = extensionInfo.srcEntrance;
|
||||
abilityInfo.iconPath = extensionInfo.icon;
|
||||
abilityInfo.iconId = extensionInfo.iconId;
|
||||
abilityInfo.label = extensionInfo.label;
|
||||
abilityInfo.labelId = extensionInfo.labelId;
|
||||
abilityInfo.description = extensionInfo.description;
|
||||
abilityInfo.descriptionId = extensionInfo.descriptionId;
|
||||
abilityInfo.priority = extensionInfo.priority;
|
||||
abilityInfo.permissions = extensionInfo.permissions;
|
||||
abilityInfo.readPermission = extensionInfo.readPermission;
|
||||
abilityInfo.writePermission = extensionInfo.writePermission;
|
||||
abilityInfo.uri = extensionInfo.uri;
|
||||
abilityInfo.extensionAbilityType = extensionInfo.type;
|
||||
abilityInfo.visible = extensionInfo.visible;
|
||||
abilityInfo.resourcePath = extensionInfo.resourcePath;
|
||||
abilityInfo.enabled = extensionInfo.enabled;
|
||||
abilityInfo.isModuleJson = true;
|
||||
abilityInfo.isStageBasedModel = true;
|
||||
abilityInfo.process = extensionInfo.process;
|
||||
abilityInfo.metadata = extensionInfo.metadata;
|
||||
abilityInfo.compileMode = extensionInfo.compileMode;
|
||||
abilityInfo.type = AppExecFwk::AbilityType::EXTENSION;
|
||||
abilityInfo.extensionTypeName = extensionInfo.extensionTypeName;
|
||||
if (!extensionInfo.hapPath.empty()) {
|
||||
abilityInfo.hapPath = extensionInfo.hapPath;
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<StartAbilityInfo> StartAbilityInfo::CreateStartAbilityInfo(const Want &want, int32_t userId,
|
||||
int32_t appIndex)
|
||||
{
|
||||
@ -214,7 +176,7 @@ std::shared_ptr<StartAbilityInfo> StartAbilityInfo::CreateStartAbilityInfo(const
|
||||
}
|
||||
request->extensionProcessMode = extensionInfo.extensionProcessMode;
|
||||
// For compatibility translates to AbilityInfo
|
||||
InitAbilityInfoFromExtension(extensionInfo, request->abilityInfo);
|
||||
AbilityRuntime::StartupUtil::InitAbilityInfoFromExtension(extensionInfo, request->abilityInfo);
|
||||
}
|
||||
return request;
|
||||
}
|
||||
@ -254,7 +216,7 @@ std::shared_ptr<StartAbilityInfo> StartAbilityInfo::CreateStartExtensionInfo(con
|
||||
}
|
||||
abilityInfo->extensionProcessMode = extensionInfo.extensionProcessMode;
|
||||
// For compatibility translates to AbilityInfo
|
||||
InitAbilityInfoFromExtension(extensionInfo, abilityInfo->abilityInfo);
|
||||
AbilityRuntime::StartupUtil::InitAbilityInfoFromExtension(extensionInfo, abilityInfo->abilityInfo);
|
||||
|
||||
return abilityInfo;
|
||||
}
|
||||
@ -277,7 +239,7 @@ void StartAbilityInfo::FindExtensionInfo(const Want &want, int32_t flags, int32_
|
||||
if (AbilityRuntime::StartupUtil::IsSupportAppClone(extensionInfo.type)) {
|
||||
abilityInfo->extensionProcessMode = extensionInfo.extensionProcessMode;
|
||||
// For compatibility translates to AbilityInfo
|
||||
InitAbilityInfoFromExtension(extensionInfo, abilityInfo->abilityInfo);
|
||||
AbilityRuntime::StartupUtil::InitAbilityInfoFromExtension(extensionInfo, abilityInfo->abilityInfo);
|
||||
} else {
|
||||
abilityInfo->status = ERR_APP_CLONE_INDEX_INVALID;
|
||||
}
|
||||
|
@ -78,6 +78,7 @@ public:
|
||||
bool IsHandleAppfreeze(const std::string& bundleName);
|
||||
bool IsProcessDebug(int32_t pid, std::string processName);
|
||||
bool IsNeedIgnoreFreezeEvent(int32_t pid);
|
||||
void DeleteStack(int pid);
|
||||
|
||||
private:
|
||||
AppfreezeManager& operator=(const AppfreezeManager&) = delete;
|
||||
@ -86,7 +87,8 @@ private:
|
||||
std::map<int, std::set<int>> BinderParser(std::ifstream& fin, std::string& stack) const;
|
||||
void ParseBinderPids(const std::map<int, std::set<int>>& binderInfo, std::set<int>& pids, int pid, int layer) const;
|
||||
std::set<int> GetBinderPeerPids(std::string& stack, int pid) const;
|
||||
std::string CatchJsonStacktrace(int pid) const;
|
||||
void FindStackByPid(std::string& ret, int pid, const std::string& msg) const;
|
||||
std::string CatchJsonStacktrace(int pid, const std::string& faultType) const;
|
||||
std::string CatcherStacktrace(int pid) const;
|
||||
int AcquireStack(const FaultData& faultData, const AppInfo& appInfo);
|
||||
int NotifyANR(const FaultData& faultData, const AppfreezeManager::AppInfo& appInfo, const std::string& binderInfo);
|
||||
@ -102,6 +104,8 @@ private:
|
||||
static std::shared_ptr<AppfreezeManager> instance_;
|
||||
static ffrt::mutex freezeMutex_;
|
||||
std::map<int32_t, AppFreezeInfo> appfreezeInfo_;
|
||||
static ffrt::mutex catchStackMutex_;
|
||||
static std::map<int, std::string> catchStackMap_;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include "faultloggerd_client.h"
|
||||
#include "file_ex.h"
|
||||
#include "ffrt.h"
|
||||
#include "dfx_dump_catcher.h"
|
||||
#include "directory_ex.h"
|
||||
#include "hisysevent.h"
|
||||
@ -56,6 +57,8 @@ const std::string LOG_FILE_PATH = "data/log/eventlog";
|
||||
std::shared_ptr<AppfreezeManager> AppfreezeManager::instance_ = nullptr;
|
||||
ffrt::mutex AppfreezeManager::singletonMutex_;
|
||||
ffrt::mutex AppfreezeManager::freezeMutex_;
|
||||
ffrt::mutex AppfreezeManager::catchStackMutex_;
|
||||
std::map<int, std::string> AppfreezeManager::catchStackMap_;
|
||||
|
||||
AppfreezeManager::AppfreezeManager()
|
||||
{
|
||||
@ -153,7 +156,7 @@ int AppfreezeManager::AppfreezeHandleWithStack(const FaultData& faultData, const
|
||||
fullStackPath = WriteToFile(fileName, catcherStack);
|
||||
faultNotifyData.errorObject.stack = fullStackPath;
|
||||
} else {
|
||||
catchJsonStack += CatchJsonStacktrace(appInfo.pid);
|
||||
catchJsonStack += CatchJsonStacktrace(appInfo.pid, faultData.errorObject.name);
|
||||
fullStackPath = WriteToFile(fileName, catchJsonStack);
|
||||
faultNotifyData.errorObject.stack = fullStackPath;
|
||||
}
|
||||
@ -379,7 +382,27 @@ void AppfreezeManager::ParseBinderPids(const std::map<int, std::set<int>>& binde
|
||||
}
|
||||
}
|
||||
|
||||
std::string AppfreezeManager::CatchJsonStacktrace(int pid) const
|
||||
void AppfreezeManager::DeleteStack(int pid)
|
||||
{
|
||||
std::lock_guard<ffrt::mutex> lock(catchStackMutex_);
|
||||
auto it = catchStackMap_.find(pid);
|
||||
if (it != catchStackMap_.end()) {
|
||||
catchStackMap_.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
void AppfreezeManager::FindStackByPid(std::string& ret, int pid, const std::string& msg) const
|
||||
{
|
||||
std::lock_guard<ffrt::mutex> lock(catchStackMutex_);
|
||||
auto it = catchStackMap_.find(pid);
|
||||
if (it != catchStackMap_.end()) {
|
||||
ret = it->second;
|
||||
} else {
|
||||
ret = "Failed to dump stacktrace for " + std::to_string(pid) + "\n" + msg;
|
||||
}
|
||||
}
|
||||
|
||||
std::string AppfreezeManager::CatchJsonStacktrace(int pid, const std::string& faultType) const
|
||||
{
|
||||
HITRACE_METER_FMT(HITRACE_TAG_APP, "CatchJsonStacktrace pid:%d", pid);
|
||||
HiviewDFX::DfxDumpCatcher dumplog;
|
||||
@ -387,9 +410,13 @@ std::string AppfreezeManager::CatchJsonStacktrace(int pid) const
|
||||
std::string msg;
|
||||
size_t defaultMaxFaultNum = 256;
|
||||
if (!dumplog.DumpCatch(pid, 0, msg, defaultMaxFaultNum, true)) {
|
||||
ret = "Failed to dump stacktrace for " + std::to_string(pid) + "\n" + msg;
|
||||
FindStackByPid(ret, pid, msg);
|
||||
} else {
|
||||
ret = msg;
|
||||
if (faultType == AppFreezeType::THREAD_BLOCK_3S) {
|
||||
std::lock_guard<ffrt::mutex> lock(catchStackMutex_);
|
||||
catchStackMap_[pid] = msg;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -225,6 +225,14 @@ public:
|
||||
|
||||
int DumpFfrt(std::string& result);
|
||||
|
||||
/**
|
||||
* Notifies the application of process caching.
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
void ScheduleCacheProcess();
|
||||
|
||||
private:
|
||||
mutable std::mutex schedulerMutex_;
|
||||
sptr<IAppScheduler> appThread_ = nullptr;
|
||||
|
@ -652,6 +652,7 @@ private:
|
||||
* Check whether the bundle is running.
|
||||
*
|
||||
* @param bundleName Indicates the bundle name of the bundle.
|
||||
* @param appCloneIndex the appindex of the bundle.
|
||||
* @param isRunning Obtain the running status of the application, the result is true if running, false otherwise.
|
||||
* @return Return ERR_OK if success, others fail.
|
||||
*/
|
||||
@ -671,8 +672,6 @@ private:
|
||||
};
|
||||
|
||||
private:
|
||||
void DumpIpcAllFuncInit();
|
||||
void DumpIpcFuncInit();
|
||||
int DumpIpcAllInner(const AppMgrService::DumpIpcKey key, std::string& result);
|
||||
int DumpIpcWithPidInner(const AppMgrService::DumpIpcKey key,
|
||||
const std::string& optionPid, std::string& result);
|
||||
@ -687,16 +686,16 @@ private:
|
||||
sptr<ISystemAbilityManager> systemAbilityMgr_;
|
||||
sptr<IAmsMgr> amsMgrScheduler_;
|
||||
|
||||
using DumpFuncType = int (AppMgrService::*)(const std::vector<std::u16string>& args, std::string& result);
|
||||
const static std::map<std::string, DumpFuncType> dumpFuncMap_;
|
||||
bool GetDumpIpcKeyByOption(const std::string &option, DumpIpcKey &key);
|
||||
|
||||
const static std::map<std::string, AppMgrService::DumpIpcKey> dumpIpcMap;
|
||||
using DumpFuncType = int (AppMgrService::*)(const std::vector<std::u16string>& args, std::string& result);
|
||||
bool GetDumpFunc(const std::string &optionKey, DumpFuncType &func);
|
||||
|
||||
using DumpIpcAllFuncType = int (AppMgrService::*)(std::string& result);
|
||||
std::map<uint32_t, DumpIpcAllFuncType> dumpIpcAllFuncMap_;
|
||||
DumpIpcAllFuncType GetDumpIpcAllFuncByKey(uint32_t key);
|
||||
|
||||
using DumpIpcFuncType = int (AppMgrService::*)(const int32_t pid, std::string& result);
|
||||
std::map<uint32_t, DumpIpcFuncType> dumpIpcFuncMap_;
|
||||
DumpIpcFuncType GetDumpIpcFuncByKey(uint32_t key);
|
||||
|
||||
DISALLOW_COPY_AND_MOVE(AppMgrService);
|
||||
};
|
||||
|
@ -56,7 +56,9 @@ public:
|
||||
static constexpr uint32_t START_SPECIFIED_PROCESS_TIMEOUT = 2000; // ms
|
||||
static constexpr uint32_t KILL_PROCESS_TIMEOUT = 3000; // ms
|
||||
#endif
|
||||
static constexpr uint32_t DELAY_KILL_PROCESS_TIMEOUT = 1000; // ms
|
||||
static constexpr uint32_t DELAY_KILL_PROCESS_TIMEOUT = 3000; // ms
|
||||
static constexpr uint32_t DELAY_KILL_EXTENSION_PROCESS_TIMEOUT = 500; // ms
|
||||
static constexpr uint32_t DELAY_NOTIFY_PROCESS_CACHED_STATE = 2000; // ms
|
||||
private:
|
||||
std::weak_ptr<AppMgrServiceInner> appMgr_;
|
||||
};
|
||||
|
@ -420,6 +420,7 @@ public:
|
||||
* Check whether the bundle is running.
|
||||
*
|
||||
* @param bundleName Indicates the bundle name of the bundle.
|
||||
* @param appCloneIndex the appindex of the bundle.
|
||||
* @param isRunning Obtain the running status of the application, the result is true if running, false otherwise.
|
||||
* @return Return ERR_OK if success, others fail.
|
||||
*/
|
||||
@ -1454,6 +1455,8 @@ private:
|
||||
|
||||
void SetAppInfo(const BundleInfo &bundleInfo, AppSpawnStartMsg &startMsg);
|
||||
|
||||
bool CreateAbilityInfo(const AAFwk::Want &want, AbilityInfo &abilityInfo);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Notify application status.
|
||||
|
@ -84,9 +84,10 @@ public:
|
||||
/**
|
||||
* CheckAppRunningRecordIsExistByBundleName, Check whether the process of the application exists.
|
||||
*
|
||||
* @param bundleName, the bundle name.
|
||||
*
|
||||
* @return, Return true if exist.
|
||||
* @param bundleName Indicates the bundle name of the bundle.
|
||||
* @param appCloneIndex the appindex of the bundle.
|
||||
* @param isRunning Obtain the running status of the application, the result is true if running, false otherwise.
|
||||
* @return, Return ERR_OK if success, others fail.
|
||||
*/
|
||||
int32_t CheckAppCloneRunningRecordIsExistByBundleName(const std::string &bundleName,
|
||||
int32_t appCloneIndex, bool &isRunning);
|
||||
|
@ -534,6 +534,8 @@ public:
|
||||
|
||||
bool IsLastPageAbilityRecord(const sptr<IRemoteObject> &token);
|
||||
|
||||
bool ExtensionAbilityRecordExists(const sptr<IRemoteObject> &token);
|
||||
|
||||
void SetTerminating();
|
||||
|
||||
bool IsTerminating();
|
||||
@ -628,6 +630,7 @@ public:
|
||||
|
||||
using Closure = std::function<void()>;
|
||||
void PostTask(std::string msg, int64_t timeOut, const Closure &task);
|
||||
bool CancelTask(std::string msg);
|
||||
void RemoveTerminateAbilityTimeoutTask(const sptr<IRemoteObject>& token) const;
|
||||
|
||||
int32_t NotifyLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback,
|
||||
@ -790,6 +793,8 @@ public:
|
||||
bool GetIsGPU();
|
||||
void SetGPUPid(pid_t gpuPid);
|
||||
pid_t GetGPUPid();
|
||||
|
||||
void ScheduleCacheProcess();
|
||||
private:
|
||||
/**
|
||||
* SearchTheModuleInfoNeedToUpdated, Get an uninitialized abilityStage data.
|
||||
|
@ -241,6 +241,8 @@ public:
|
||||
virtual int32_t GetRenderProcessTerminationStatus(const AppSpawnStartMsg &startMsg, int &status);
|
||||
|
||||
private:
|
||||
int32_t SetCloneFlag(const AppSpawnStartMsg &startMsg, AppSpawnReqMsgHandle reqHandle) const;
|
||||
|
||||
std::string serviceName_ = APPSPAWN_SERVER_NAME;
|
||||
AppSpawnClientHandle handle_ = nullptr;
|
||||
SpawnConnectionState state_ = SpawnConnectionState::STATE_NOT_CONNECT;
|
||||
|
@ -81,6 +81,8 @@ public:
|
||||
|
||||
int32_t GetPageAbilitySize();
|
||||
|
||||
bool ExtensionAbilityRecordExists();
|
||||
|
||||
// Get abilities_ for this process
|
||||
/**
|
||||
* @brief Obtains the abilities info for the application record.
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "ability_info.h"
|
||||
#include "app_spawn_client.h"
|
||||
#include "global_constant.h"
|
||||
#include "want.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -57,6 +58,10 @@ static uint32_t BuildStartFlags(const AAFwk::Want &want, const ApplicationInfo &
|
||||
if (want.GetBoolParam("ohos.ability.params.extensionControl", false)) {
|
||||
startFlags = startFlags | (START_FLAG_BASE << StartFlags::EXTENSION_CONTROLLED);
|
||||
}
|
||||
if (applicationInfo.multiAppMode.multiAppModeType == MultiAppModeType::APP_CLONE && applicationInfo.appIndex > 0 &&
|
||||
applicationInfo.appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) {
|
||||
startFlags = startFlags | (START_FLAG_BASE << APP_FLAGS_CLONE_ENABLE);
|
||||
}
|
||||
|
||||
return startFlags;
|
||||
}
|
||||
|
@ -31,19 +31,19 @@
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
namespace {
|
||||
const std::string TASK_TERMINATE_ABILITY = "TerminateAbilityTask";
|
||||
const std::string TASK_UPDATE_ABILITY_STATE = "UpdateAbilityStateTask";
|
||||
const std::string TASK_UPDATE_EXTENSION_STATE = "UpdateExtensionStateTask";
|
||||
const std::string TASK_REGISTER_APP_STATE_CALLBACK = "RegisterAppStateCallbackTask";
|
||||
const std::string TASK_STOP_ALL_PROCESS = "StopAllProcessTask";
|
||||
const std::string TASK_ABILITY_BEHAVIOR_ANALYSIS = "AbilityBehaviorAnalysisTask";
|
||||
const std::string TASK_KILL_PROCESS_BY_ABILITY_TOKEN = "KillProcessByAbilityTokenTask";
|
||||
const std::string TASK_KILL_PROCESSES_BY_USERID = "KillProcessesByUserIdTask";
|
||||
const std::string TASK_KILL_PROCESSES_BY_PIDS = "KillProcessesByPids";
|
||||
const std::string TASK_ATTACH_PID_TO_PARENT = "AttachPidToParent";
|
||||
const std::string TASK_KILL_APPLICATION = "KillApplicationTask";
|
||||
const std::string TASK_CLEAR_PROCESS_BY_ABILITY_TOKEN = "ClearProcessByAbilityTokenTask";
|
||||
const std::string FOUNDATION_NAME = "foundation";
|
||||
constexpr const char* TASK_TERMINATE_ABILITY = "TerminateAbilityTask";
|
||||
constexpr const char* TASK_UPDATE_ABILITY_STATE = "UpdateAbilityStateTask";
|
||||
constexpr const char* TASK_UPDATE_EXTENSION_STATE = "UpdateExtensionStateTask";
|
||||
constexpr const char* TASK_REGISTER_APP_STATE_CALLBACK = "RegisterAppStateCallbackTask";
|
||||
constexpr const char* TASK_STOP_ALL_PROCESS = "StopAllProcessTask";
|
||||
constexpr const char* TASK_ABILITY_BEHAVIOR_ANALYSIS = "AbilityBehaviorAnalysisTask";
|
||||
constexpr const char* TASK_KILL_PROCESS_BY_ABILITY_TOKEN = "KillProcessByAbilityTokenTask";
|
||||
constexpr const char* TASK_KILL_PROCESSES_BY_USERID = "KillProcessesByUserIdTask";
|
||||
constexpr const char* TASK_KILL_PROCESSES_BY_PIDS = "KillProcessesByPids";
|
||||
constexpr const char* TASK_ATTACH_PID_TO_PARENT = "AttachPidToParent";
|
||||
constexpr const char* TASK_KILL_APPLICATION = "KillApplicationTask";
|
||||
constexpr const char* TASK_CLEAR_PROCESS_BY_ABILITY_TOKEN = "ClearProcessByAbilityTokenTask";
|
||||
constexpr const char* FOUNDATION_NAME = "foundation";
|
||||
}; // namespace
|
||||
|
||||
AmsMgrScheduler::AmsMgrScheduler(
|
||||
|
@ -383,5 +383,16 @@ int AppLifeCycleDeal::DumpFfrt(std::string& result)
|
||||
}
|
||||
return appThread->ScheduleDumpFfrt(result);
|
||||
}
|
||||
|
||||
void AppLifeCycleDeal::ScheduleCacheProcess()
|
||||
{
|
||||
auto appThread = GetApplicationClient();
|
||||
if (!appThread) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "appThread is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
appThread->ScheduleCacheProcess();
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -40,9 +40,9 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
const std::string OPTION_KEY_HELP = "-h";
|
||||
const std::string OPTION_KEY_DUMP_IPC = "--ipc";
|
||||
const std::string OPTION_KEY_DUMP_FFRT = "--ffrt";
|
||||
constexpr const char* OPTION_KEY_HELP = "-h";
|
||||
constexpr const char* OPTION_KEY_DUMP_IPC = "--ipc";
|
||||
constexpr const char* OPTION_KEY_DUMP_FFRT = "--ffrt";
|
||||
const int32_t HIDUMPER_SERVICE_UID = 1212;
|
||||
constexpr const int INDEX_PID = 1;
|
||||
constexpr const int INDEX_CMD = 2;
|
||||
@ -56,60 +56,32 @@ using namespace std::chrono_literals;
|
||||
#ifdef ABILITY_COMMAND_FOR_TEST
|
||||
static const int APP_MS_BLOCK = 65;
|
||||
#endif
|
||||
const std::string TASK_INIT_APPMGRSERVICEINNER = "InitAppMgrServiceInnerTask";
|
||||
const std::string TASK_ATTACH_APPLICATION = "AttachApplicationTask";
|
||||
const std::string TASK_APPLICATION_FOREGROUNDED = "ApplicationForegroundedTask";
|
||||
const std::string TASK_APPLICATION_BACKGROUNDED = "ApplicationBackgroundedTask";
|
||||
const std::string TASK_APPLICATION_TERMINATED = "ApplicationTerminatedTask";
|
||||
const std::string TASK_ABILITY_CLEANED = "AbilityCleanedTask";
|
||||
const std::string TASK_ADD_APP_DEATH_RECIPIENT = "AddAppRecipientTask";
|
||||
const std::string TASK_CLEAR_UP_APPLICATION_DATA = "ClearUpApplicationDataTask";
|
||||
const std::string TASK_STARTUP_RESIDENT_PROCESS = "StartupResidentProcess";
|
||||
const std::string TASK_ADD_ABILITY_STAGE_DONE = "AddAbilityStageDone";
|
||||
const std::string TASK_START_USER_TEST_PROCESS = "StartUserTestProcess";
|
||||
const std::string TASK_FINISH_USER_TEST = "FinishUserTest";
|
||||
const std::string TASK_ATTACH_RENDER_PROCESS = "AttachRenderTask";
|
||||
const std::string TASK_ATTACH_CHILD_PROCESS = "AttachChildProcessTask";
|
||||
const std::string TASK_EXIT_CHILD_PROCESS_SAFELY = "ExitChildProcessSafelyTask";
|
||||
const std::string FOUNDATION_PROCESS = "foundation";
|
||||
constexpr const char* TASK_INIT_APPMGRSERVICEINNER = "InitAppMgrServiceInnerTask";
|
||||
constexpr const char* TASK_ATTACH_APPLICATION = "AttachApplicationTask";
|
||||
constexpr const char* TASK_APPLICATION_FOREGROUNDED = "ApplicationForegroundedTask";
|
||||
constexpr const char* TASK_APPLICATION_BACKGROUNDED = "ApplicationBackgroundedTask";
|
||||
constexpr const char* TASK_APPLICATION_TERMINATED = "ApplicationTerminatedTask";
|
||||
constexpr const char* TASK_ABILITY_CLEANED = "AbilityCleanedTask";
|
||||
constexpr const char* TASK_ADD_APP_DEATH_RECIPIENT = "AddAppRecipientTask";
|
||||
constexpr const char* TASK_CLEAR_UP_APPLICATION_DATA = "ClearUpApplicationDataTask";
|
||||
constexpr const char* TASK_STARTUP_RESIDENT_PROCESS = "StartupResidentProcess";
|
||||
constexpr const char* TASK_ADD_ABILITY_STAGE_DONE = "AddAbilityStageDone";
|
||||
constexpr const char* TASK_START_USER_TEST_PROCESS = "StartUserTestProcess";
|
||||
constexpr const char* TASK_FINISH_USER_TEST = "FinishUserTest";
|
||||
constexpr const char* TASK_ATTACH_RENDER_PROCESS = "AttachRenderTask";
|
||||
constexpr const char* TASK_ATTACH_CHILD_PROCESS = "AttachChildProcessTask";
|
||||
constexpr const char* TASK_EXIT_CHILD_PROCESS_SAFELY = "ExitChildProcessSafelyTask";
|
||||
constexpr const char* FOUNDATION_PROCESS = "foundation";
|
||||
constexpr int32_t USER_UID = 2000;
|
||||
} // namespace
|
||||
|
||||
REGISTER_SYSTEM_ABILITY_BY_ID(AppMgrService, APP_MGR_SERVICE_ID, true);
|
||||
|
||||
const std::map<std::string, AppMgrService::DumpFuncType> AppMgrService::dumpFuncMap_ = {
|
||||
std::map<std::string, AppMgrService::DumpFuncType>::value_type(OPTION_KEY_HELP, &AppMgrService::ShowHelp),
|
||||
std::map<std::string, AppMgrService::DumpFuncType>::value_type(OPTION_KEY_DUMP_IPC, &AppMgrService::DumpIpc),
|
||||
std::map<std::string, AppMgrService::DumpFuncType>::value_type(OPTION_KEY_DUMP_FFRT, &AppMgrService::DumpFfrt),
|
||||
};
|
||||
|
||||
const std::map<std::string, AppMgrService::DumpIpcKey> AppMgrService::dumpIpcMap = {
|
||||
std::map<std::string, AppMgrService::DumpIpcKey>::value_type("--start-stat", KEY_DUMP_IPC_START),
|
||||
std::map<std::string, AppMgrService::DumpIpcKey>::value_type("--stop-stat", KEY_DUMP_IPC_STOP),
|
||||
std::map<std::string, AppMgrService::DumpIpcKey>::value_type("--stat", KEY_DUMP_IPC_STAT),
|
||||
};
|
||||
|
||||
void AppMgrService::DumpIpcAllFuncInit()
|
||||
{
|
||||
dumpIpcAllFuncMap_[KEY_DUMP_IPC_START] = &AppMgrService::DumpIpcAllStart;
|
||||
dumpIpcAllFuncMap_[KEY_DUMP_IPC_STOP] = &AppMgrService::DumpIpcAllStop;
|
||||
dumpIpcAllFuncMap_[KEY_DUMP_IPC_STAT] = &AppMgrService::DumpIpcAllStat;
|
||||
}
|
||||
|
||||
void AppMgrService::DumpIpcFuncInit()
|
||||
{
|
||||
dumpIpcFuncMap_[KEY_DUMP_IPC_START] = &AppMgrService::DumpIpcStart;
|
||||
dumpIpcFuncMap_[KEY_DUMP_IPC_STOP] = &AppMgrService::DumpIpcStop;
|
||||
dumpIpcFuncMap_[KEY_DUMP_IPC_STAT] = &AppMgrService::DumpIpcStat;
|
||||
}
|
||||
|
||||
AppMgrService::AppMgrService()
|
||||
{
|
||||
appMgrServiceInner_ = std::make_shared<AppMgrServiceInner>();
|
||||
TAG_LOGI(AAFwkTag::APPMGR, "instance created with no para");
|
||||
PerfProfile::GetInstance().SetAmsLoadStartTime(GetTickCount());
|
||||
DumpIpcAllFuncInit();
|
||||
DumpIpcFuncInit();
|
||||
}
|
||||
|
||||
AppMgrService::AppMgrService(const int32_t serviceId, bool runOnCreate) : SystemAbility(serviceId, runOnCreate)
|
||||
@ -117,8 +89,6 @@ AppMgrService::AppMgrService(const int32_t serviceId, bool runOnCreate) : System
|
||||
appMgrServiceInner_ = std::make_shared<AppMgrServiceInner>();
|
||||
TAG_LOGI(AAFwkTag::APPMGR, "instance created");
|
||||
PerfProfile::GetInstance().SetAmsLoadStartTime(GetTickCount());
|
||||
DumpIpcAllFuncInit();
|
||||
DumpIpcFuncInit();
|
||||
}
|
||||
|
||||
AppMgrService::~AppMgrService()
|
||||
@ -644,6 +614,23 @@ int AppMgrService::Dump(int fd, const std::vector<std::u16string>& args)
|
||||
return errCode;
|
||||
}
|
||||
|
||||
bool AppMgrService::GetDumpFunc(const std::string &optionKey, DumpFuncType &func)
|
||||
{
|
||||
if (optionKey == OPTION_KEY_HELP) {
|
||||
func = &AppMgrService::ShowHelp;
|
||||
return true;
|
||||
}
|
||||
if (optionKey == OPTION_KEY_DUMP_IPC) {
|
||||
func = &AppMgrService::DumpIpc;
|
||||
return true;
|
||||
}
|
||||
if (optionKey == OPTION_KEY_DUMP_FFRT) {
|
||||
func = &AppMgrService::DumpFfrt;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int AppMgrService::Dump(const std::vector<std::u16string>& args, std::string& result)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "Called.");
|
||||
@ -653,14 +640,12 @@ int AppMgrService::Dump(const std::vector<std::u16string>& args, std::string& re
|
||||
}
|
||||
|
||||
std::string optionKey = Str16ToStr8(args[0]);
|
||||
auto itDumpFunc = dumpFuncMap_.find(optionKey);
|
||||
if (itDumpFunc == dumpFuncMap_.end()) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "option key %{public}s does not exist", optionKey.c_str());
|
||||
DumpFuncType dumpFunc;
|
||||
if (!GetDumpFunc(optionKey, dumpFunc)) {
|
||||
result.append("error: unkown option.\n");
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "option key %{public}s does not exist", optionKey.c_str());
|
||||
return DumpErrorCode::ERR_UNKNOWN_OPTION_ERROR;
|
||||
}
|
||||
|
||||
auto dumpFunc = itDumpFunc->second;
|
||||
if (dumpFunc == nullptr) {
|
||||
result.append(MSG_DUMP_FAIL, strlen(MSG_DUMP_FAIL))
|
||||
.append(MSG_DUMP_FAIL_REASON_INTERNAL, strlen(MSG_DUMP_FAIL_REASON_INTERNAL));
|
||||
@ -679,17 +664,25 @@ int AppMgrService::ShowHelp(const std::vector<std::u16string>& args, std::string
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
AppMgrService::DumpIpcAllFuncType AppMgrService::GetDumpIpcAllFuncByKey(uint32_t key)
|
||||
{
|
||||
if (key == KEY_DUMP_IPC_START) {
|
||||
return &AppMgrService::DumpIpcAllStart;
|
||||
}
|
||||
if (key == KEY_DUMP_IPC_STOP) {
|
||||
return &AppMgrService::DumpIpcAllStop;
|
||||
}
|
||||
if (key == KEY_DUMP_IPC_STAT) {
|
||||
return &AppMgrService::DumpIpcAllStat;
|
||||
}
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "option key %{public}d does not exist", key);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int AppMgrService::DumpIpcAllInner(const AppMgrService::DumpIpcKey key, std::string& result)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::APPMGR, "Called.");
|
||||
auto itFunc = dumpIpcAllFuncMap_.find(key);
|
||||
if (itFunc == dumpIpcAllFuncMap_.end()) {
|
||||
result.append(MSG_DUMP_FAIL, strlen(MSG_DUMP_FAIL))
|
||||
.append(MSG_DUMP_FAIL_REASON_INTERNAL, strlen(MSG_DUMP_FAIL_REASON_INTERNAL));
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "option key %{public}d does not exist", key);
|
||||
return DumpErrorCode::ERR_INTERNAL_ERROR;
|
||||
}
|
||||
auto dumpFunc = itFunc->second;
|
||||
auto dumpFunc = GetDumpIpcAllFuncByKey(key);
|
||||
if (dumpFunc == nullptr) {
|
||||
result.append(MSG_DUMP_FAIL, strlen(MSG_DUMP_FAIL))
|
||||
.append(MSG_DUMP_FAIL_REASON_INTERNAL, strlen(MSG_DUMP_FAIL_REASON_INTERNAL));
|
||||
@ -699,6 +692,21 @@ int AppMgrService::DumpIpcAllInner(const AppMgrService::DumpIpcKey key, std::str
|
||||
return (this->*dumpFunc)(result);
|
||||
}
|
||||
|
||||
AppMgrService::DumpIpcFuncType AppMgrService::GetDumpIpcFuncByKey(uint32_t key)
|
||||
{
|
||||
if (key == KEY_DUMP_IPC_START) {
|
||||
return &AppMgrService::DumpIpcStart;
|
||||
}
|
||||
if (key == KEY_DUMP_IPC_STOP) {
|
||||
return &AppMgrService::DumpIpcStop;
|
||||
}
|
||||
if (key == KEY_DUMP_IPC_STAT) {
|
||||
return &AppMgrService::DumpIpcStat;
|
||||
}
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "option key %{public}d does not exist", key);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int AppMgrService::DumpIpcWithPidInner(const AppMgrService::DumpIpcKey key,
|
||||
const std::string& optionPid, std::string& result)
|
||||
{
|
||||
@ -718,14 +726,8 @@ int AppMgrService::DumpIpcWithPidInner(const AppMgrService::DumpIpcKey key,
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "invalid pid: %{public}s", optionPid.c_str());
|
||||
return DumpErrorCode::ERR_INVALID_PID_ERROR;
|
||||
}
|
||||
auto itFunc = dumpIpcFuncMap_.find(key);
|
||||
if (itFunc == dumpIpcFuncMap_.end()) {
|
||||
result.append(MSG_DUMP_FAIL, strlen(MSG_DUMP_FAIL))
|
||||
.append(MSG_DUMP_FAIL_REASON_INTERNAL, strlen(MSG_DUMP_FAIL_REASON_INTERNAL));
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "option key %{public}d does not exist", key);
|
||||
return DumpErrorCode::ERR_INTERNAL_ERROR;
|
||||
}
|
||||
auto dumpFunc = itFunc->second;
|
||||
|
||||
auto dumpFunc = GetDumpIpcFuncByKey(key);
|
||||
if (dumpFunc == nullptr) {
|
||||
result.append(MSG_DUMP_FAIL, strlen(MSG_DUMP_FAIL))
|
||||
.append(MSG_DUMP_FAIL_REASON_INTERNAL, strlen(MSG_DUMP_FAIL_REASON_INTERNAL));
|
||||
@ -771,6 +773,23 @@ int AppMgrService::DumpFfrtInner(const std::string& pidsRaw, std::string& result
|
||||
return appMgrServiceInner_->DumpFfrt(pids, result);
|
||||
}
|
||||
|
||||
bool AppMgrService::GetDumpIpcKeyByOption(const std::string &option, DumpIpcKey &key)
|
||||
{
|
||||
if (option == "--start-stat") {
|
||||
key = KEY_DUMP_IPC_START;
|
||||
return true;
|
||||
}
|
||||
if (option == "--stop-stat") {
|
||||
key = KEY_DUMP_IPC_STOP;
|
||||
return true;
|
||||
}
|
||||
if (option == "--stat") {
|
||||
key = KEY_DUMP_IPC_STAT;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int AppMgrService::DumpIpc(const std::vector<std::u16string>& args, std::string& result)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "Called. AppMgrService::DumpIpc start");
|
||||
@ -792,15 +811,14 @@ int AppMgrService::DumpIpc(const std::vector<std::u16string>& args, std::string&
|
||||
std::string optionPid = Str16ToStr8(args[INDEX_PID]);
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "option pid:%{public}s, option cmd:%{public}s",
|
||||
optionPid.c_str(), optionCmd.c_str());
|
||||
|
||||
auto itDumpKey = dumpIpcMap.find(optionCmd);
|
||||
if (itDumpKey == dumpIpcMap.end()) {
|
||||
|
||||
DumpIpcKey key;
|
||||
if (!GetDumpIpcKeyByOption(optionCmd, key)) {
|
||||
result.append(MSG_DUMP_FAIL, strlen(MSG_DUMP_FAIL))
|
||||
.append(MSG_DUMP_FAIL_REASON_INVALILD_CMD, strlen(MSG_DUMP_FAIL_REASON_INVALILD_CMD));
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "option command %{public}s does not exist", optionCmd.c_str());
|
||||
return DumpErrorCode::ERR_INVALID_CMD_ERROR;
|
||||
}
|
||||
DumpIpcKey key = itDumpKey->second;
|
||||
|
||||
if (optionPid == "-a" || optionPid == "all" || optionPid == "--all") {
|
||||
return DumpIpcAllInner(key, result);
|
||||
|
@ -124,37 +124,37 @@ constexpr int REGISTER_VISIBILITY_DELAY = 5000;
|
||||
// Max render process number limitation for phone device.
|
||||
constexpr int PHONE_MAX_RENDER_PROCESS_NUM = 40;
|
||||
constexpr int PROCESS_RESTART_MARGIN_MICRO_SECONDS = 2000;
|
||||
const std::string CLASS_NAME = "ohos.app.MainThread";
|
||||
const std::string FUNC_NAME = "main";
|
||||
const std::string RENDER_PARAM = "invalidparam";
|
||||
const std::string COLD_START = "coldStart";
|
||||
const std::string PERF_CMD = "perfCmd";
|
||||
const std::string MULTI_THREAD = "multiThread";
|
||||
const std::string DEBUG_CMD = "debugCmd";
|
||||
const std::string ENTER_SANDBOX = "sandboxApp";
|
||||
const std::string PERMISSION_INTERNET = "ohos.permission.INTERNET";
|
||||
const std::string PERMISSION_MANAGE_VPN = "ohos.permission.MANAGE_VPN";
|
||||
const std::string PERMISSION_ACCESS_BUNDLE_DIR = "ohos.permission.ACCESS_BUNDLE_DIR";
|
||||
const std::string DLP_PARAMS_SECURITY_FLAG = "ohos.dlp.params.securityFlag";
|
||||
const std::string SUPPORT_ISOLATION_MODE = "persist.bms.supportIsolationMode";
|
||||
const std::string SUPPORT_SERVICE_EXT_MULTI_PROCESS = "component.startup.extension.multiprocess.enable";
|
||||
const std::string SERVICE_EXT_MULTI_PROCESS_WHITE_LIST = "component.startup.extension.multiprocess.whitelist";
|
||||
const std::string SCENE_BOARD_BUNDLE_NAME = "com.ohos.sceneboard";
|
||||
const std::string DEBUG_APP = "debugApp";
|
||||
const std::string SERVICE_EXTENSION = ":ServiceExtension";
|
||||
const std::string KEEP_ALIVE = ":KeepAlive";
|
||||
const std::string PARAM_SPECIFIED_PROCESS_FLAG = "ohoSpecifiedProcessFlag";
|
||||
const std::string TSAN_FLAG_NAME = "tsanEnabled";
|
||||
const std::string MEMMGR_PROC_NAME = "memmgrservice";
|
||||
const std::string UIEXTENSION_ABILITY_ID = "ability.want.params.uiExtensionAbilityId";
|
||||
const std::string UIEXTENSION_ROOT_HOST_PID = "ability.want.params.uiExtensionRootHostPid";
|
||||
const std::string STRICT_MODE = "strictMode";
|
||||
const std::string RENDER_PROCESS_NAME = ":render";
|
||||
const std::string RENDER_PROCESS_TYPE = "render";
|
||||
const std::string GPU_PROCESS_NAME = ":gpu";
|
||||
const std::string GPU_PROCESS_TYPE = "gpu";
|
||||
const std::string FONT_WGHT_SCALE = "persist.sys.font_wght_scale_for_user0";
|
||||
const std::string FONT_SCALE = "persist.sys.font_scale_for_user0";
|
||||
constexpr const char* CLASS_NAME = "ohos.app.MainThread";
|
||||
constexpr const char* FUNC_NAME = "main";
|
||||
constexpr const char* RENDER_PARAM = "invalidparam";
|
||||
constexpr const char* COLD_START = "coldStart";
|
||||
constexpr const char* PERF_CMD = "perfCmd";
|
||||
constexpr const char* MULTI_THREAD = "multiThread";
|
||||
constexpr const char* DEBUG_CMD = "debugCmd";
|
||||
constexpr const char* ENTER_SANDBOX = "sandboxApp";
|
||||
constexpr const char* PERMISSION_INTERNET = "ohos.permission.INTERNET";
|
||||
constexpr const char* PERMISSION_MANAGE_VPN = "ohos.permission.MANAGE_VPN";
|
||||
constexpr const char* PERMISSION_ACCESS_BUNDLE_DIR = "ohos.permission.ACCESS_BUNDLE_DIR";
|
||||
constexpr const char* DLP_PARAMS_SECURITY_FLAG = "ohos.dlp.params.securityFlag";
|
||||
constexpr const char* SUPPORT_ISOLATION_MODE = "persist.bms.supportIsolationMode";
|
||||
constexpr const char* SUPPORT_SERVICE_EXT_MULTI_PROCESS = "component.startup.extension.multiprocess.enable";
|
||||
constexpr const char* SERVICE_EXT_MULTI_PROCESS_WHITE_LIST = "component.startup.extension.multiprocess.whitelist";
|
||||
constexpr const char* SCENE_BOARD_BUNDLE_NAME = "com.ohos.sceneboard";
|
||||
constexpr const char* DEBUG_APP = "debugApp";
|
||||
constexpr const char* SERVICE_EXTENSION = ":ServiceExtension";
|
||||
constexpr const char* KEEP_ALIVE = ":KeepAlive";
|
||||
constexpr const char* PARAM_SPECIFIED_PROCESS_FLAG = "ohoSpecifiedProcessFlag";
|
||||
constexpr const char* TSAN_FLAG_NAME = "tsanEnabled";
|
||||
constexpr const char* MEMMGR_PROC_NAME = "memmgrservice";
|
||||
constexpr const char* UIEXTENSION_ABILITY_ID = "ability.want.params.uiExtensionAbilityId";
|
||||
constexpr const char* UIEXTENSION_ROOT_HOST_PID = "ability.want.params.uiExtensionRootHostPid";
|
||||
constexpr const char* STRICT_MODE = "strictMode";
|
||||
constexpr const char* RENDER_PROCESS_NAME = ":render";
|
||||
constexpr const char* RENDER_PROCESS_TYPE = "render";
|
||||
constexpr const char* GPU_PROCESS_NAME = ":gpu";
|
||||
constexpr const char* GPU_PROCESS_TYPE = "gpu";
|
||||
constexpr const char* FONT_WGHT_SCALE = "persist.sys.font_wght_scale_for_user0";
|
||||
constexpr const char* FONT_SCALE = "persist.sys.font_scale_for_user0";
|
||||
const int32_t SIGNAL_KILL = 9;
|
||||
constexpr int32_t USER_SCALE = 200000;
|
||||
#define ENUM_TO_STRING(s) #s
|
||||
@ -172,33 +172,36 @@ constexpr ErrCode APPMGR_ERR_OFFSET = ErrCodeOffset(SUBSYS_APPEXECFWK, 0x01);
|
||||
constexpr ErrCode ERR_ALREADY_EXIST_RENDER = APPMGR_ERR_OFFSET + 100;
|
||||
// Error code for reaching render process number limitation.
|
||||
constexpr ErrCode ERR_REACHING_MAXIMUM_RENDER_PROCESS_LIMITATION = APPMGR_ERR_OFFSET + 101;
|
||||
constexpr char EVENT_KEY_UID[] = "UID";
|
||||
constexpr char EVENT_KEY_PID[] = "PID";
|
||||
constexpr char EVENT_KEY_PACKAGE_NAME[] = "PACKAGE_NAME";
|
||||
constexpr char EVENT_KEY_PROCESS_NAME[] = "PROCESS_NAME";
|
||||
constexpr char EVENT_KEY_MESSAGE[] = "MSG";
|
||||
constexpr const char* EVENT_KEY_UID = "UID";
|
||||
constexpr const char* EVENT_KEY_PID = "PID";
|
||||
constexpr const char* EVENT_KEY_PACKAGE_NAME = "PACKAGE_NAME";
|
||||
constexpr const char* EVENT_KEY_PROCESS_NAME = "PROCESS_NAME";
|
||||
constexpr const char* EVENT_KEY_MESSAGE = "MSG";
|
||||
|
||||
// Developer mode param
|
||||
constexpr char DEVELOPER_MODE_STATE[] = "const.security.developermode.state";
|
||||
constexpr char PRODUCT_ASSERT_FAULT_DIALOG_ENABLED[] = "persisit.sys.abilityms.support_assert_fault_dialog";
|
||||
constexpr const char* DEVELOPER_MODE_STATE = "const.security.developermode.state";
|
||||
constexpr const char* PRODUCT_ASSERT_FAULT_DIALOG_ENABLED = "persisit.sys.abilityms.support_assert_fault_dialog";
|
||||
|
||||
constexpr char BUNDLE_NAME_SAMPLE_MANAGEMENT[] = "com.huawei.hmsapp.samplemanagement";
|
||||
|
||||
// Msg length is less than 48 characters
|
||||
const std::string EVENT_MESSAGE_TERMINATE_ABILITY_TIMEOUT = "Terminate Ability TimeOut!";
|
||||
const std::string EVENT_MESSAGE_TERMINATE_APPLICATION_TIMEOUT = "Terminate Application TimeOut!";
|
||||
const std::string EVENT_MESSAGE_ADD_ABILITY_STAGE_INFO_TIMEOUT = "Add Ability Stage TimeOut!";
|
||||
const std::string EVENT_MESSAGE_START_SPECIFIED_PROCESS_TIMEOUT = "Start Specified Process Timeout!";
|
||||
const std::string EVENT_MESSAGE_START_SPECIFIED_ABILITY_TIMEOUT = "Start Specified Ability TimeOut!";
|
||||
const std::string EVENT_MESSAGE_START_PROCESS_SPECIFIED_ABILITY_TIMEOUT = "Start Process Specified Ability TimeOut!";
|
||||
const std::string EVENT_MESSAGE_DEFAULT = "AppMgrServiceInner HandleTimeOut!";
|
||||
const std::string SUPPORT_CALL_NOTIFY_MEMORY_CHANGED =
|
||||
constexpr const char* EVENT_MESSAGE_TERMINATE_ABILITY_TIMEOUT = "Terminate Ability TimeOut!";
|
||||
constexpr const char* EVENT_MESSAGE_TERMINATE_APPLICATION_TIMEOUT = "Terminate Application TimeOut!";
|
||||
constexpr const char* EVENT_MESSAGE_ADD_ABILITY_STAGE_INFO_TIMEOUT = "Add Ability Stage TimeOut!";
|
||||
constexpr const char* EVENT_MESSAGE_START_SPECIFIED_PROCESS_TIMEOUT = "Start Specified Process Timeout!";
|
||||
constexpr const char* EVENT_MESSAGE_START_SPECIFIED_ABILITY_TIMEOUT = "Start Specified Ability TimeOut!";
|
||||
constexpr const char* EVENT_MESSAGE_START_PROCESS_SPECIFIED_ABILITY_TIMEOUT =
|
||||
"Start Process Specified Ability TimeOut!";
|
||||
constexpr const char* EVENT_MESSAGE_DEFAULT = "AppMgrServiceInner HandleTimeOut!";
|
||||
constexpr const char* SUPPORT_CALL_NOTIFY_MEMORY_CHANGED =
|
||||
"persist.sys.abilityms.support_call_notify_memory_changed";
|
||||
|
||||
const std::string SYSTEM_BASIC = "system_basic";
|
||||
const std::string SYSTEM_CORE = "system_core";
|
||||
const std::string ABILITY_OWNER_USERID = "AbilityMS_Owner_UserId";
|
||||
const std::string PROCESS_EXIT_EVENT_TASK = "Send Process Exit Event Task";
|
||||
const std::string KILL_PROCESS_REASON_PREFIX = "Kill Reason:";
|
||||
const std::string PRELOAD_APPLIATION_TASK = "PreloadApplicactionTask";
|
||||
constexpr const char* SYSTEM_BASIC = "system_basic";
|
||||
constexpr const char* SYSTEM_CORE = "system_core";
|
||||
constexpr const char* ABILITY_OWNER_USERID = "AbilityMS_Owner_UserId";
|
||||
constexpr const char* PROCESS_EXIT_EVENT_TASK = "Send Process Exit Event Task";
|
||||
constexpr const char* KILL_PROCESS_REASON_PREFIX = "Kill Reason:";
|
||||
constexpr const char* PRELOAD_APPLIATION_TASK = "PreloadApplicactionTask";
|
||||
|
||||
constexpr int32_t ROOT_UID = 0;
|
||||
constexpr int32_t FOUNDATION_UID = 5523;
|
||||
@ -1614,7 +1617,7 @@ int32_t AppMgrServiceInner::NotifyMemoryLevel(int32_t level)
|
||||
bool isMemmgrCall = AAFwk::PermissionVerification::GetInstance()->CheckSpecificSystemAbilityAccessPermission(
|
||||
MEMMGR_PROC_NAME);
|
||||
if (!isMemmgrCall) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "callerToken not %{public}s. %{public}s", MEMMGR_PROC_NAME.c_str(), __func__);
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "callerToken not %{public}s. %{public}s", MEMMGR_PROC_NAME, __func__);
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
if (!(level == OHOS::AppExecFwk::MemoryLevel::MEMORY_LEVEL_MODERATE ||
|
||||
@ -1638,7 +1641,7 @@ int32_t AppMgrServiceInner::NotifyProcMemoryLevel(const std::map<pid_t, MemoryLe
|
||||
bool isMemmgrCall = AAFwk::PermissionVerification::GetInstance()->CheckSpecificSystemAbilityAccessPermission(
|
||||
MEMMGR_PROC_NAME);
|
||||
if (!isMemmgrCall) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "callerToken not %{public}s. %{public}s", MEMMGR_PROC_NAME.c_str(), __func__);
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "callerToken not %{public}s. %{public}s", MEMMGR_PROC_NAME, __func__);
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
if (!appRunningManager_) {
|
||||
@ -1714,6 +1717,10 @@ void AppMgrServiceInner::GetRunningProcess(const std::shared_ptr<AppRunningRecor
|
||||
auto appInfo = appRecord->GetApplicationInfo();
|
||||
if (appInfo) {
|
||||
info.bundleType = static_cast<int32_t>(appInfo->bundleType);
|
||||
if (static_cast<int32_t>(appInfo->multiAppMode.multiAppModeType) ==
|
||||
static_cast<int32_t>(MultiAppModeType::APP_CLONE)) {
|
||||
info.appCloneIndex = appRecord->GetAppIndex();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2744,7 +2751,7 @@ void AppMgrServiceInner::QueryExtensionSandBox(const std::string &moduleName, co
|
||||
DataGroupInfoList extensionDataGroupInfoList;
|
||||
if (infoIter != extensionInfos.end()) {
|
||||
startMsg.isolatedExtension = infoIter->needCreateSandbox;
|
||||
startMsg.extensionSandboxPath = infoIter->moduleName + "/" + infoIter->name;
|
||||
startMsg.extensionSandboxPath = infoIter->moduleName + "-" + infoIter->name;
|
||||
startMsg.strictMode = strictMode;
|
||||
for (auto dataGroupInfo : dataGroupInfoList) {
|
||||
auto groupIdExisted = [&dataGroupInfo](const std::string &dataGroupId) {
|
||||
@ -5163,6 +5170,11 @@ int32_t AppMgrServiceInner::NotifyAppFault(const FaultData &faultData)
|
||||
}
|
||||
|
||||
dfxTaskHandler_->SubmitTask(notifyAppTask, "NotifyAppFaultTask");
|
||||
constexpr int delayTime = 15 * 1000; // 15s
|
||||
auto task = [pid, innerService = shared_from_this()]() {
|
||||
AppExecFwk::AppfreezeManager::GetInstance()->DeleteStack(pid);
|
||||
};
|
||||
dfxTaskHandler_->SubmitTask(task, "DeleteStack", delayTime);
|
||||
|
||||
if (appRecord->GetApplicationInfo()->asanEnabled) {
|
||||
TAG_LOGI(AAFwkTag::APPMGR,
|
||||
@ -5354,6 +5366,10 @@ int32_t AppMgrServiceInner::IsAppRunning(const std::string &bundleName, int32_t
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Permission verification failed.");
|
||||
return ERR_PERMISSION_DENIED;
|
||||
}
|
||||
if (remoteClientManager_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "The remoteClientManager is nullptr.");
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
auto bundleMgrHelper = remoteClientManager_->GetBundleManagerHelper();
|
||||
if (bundleMgrHelper == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "The bundleMgrHelper is nullptr.");
|
||||
@ -5380,26 +5396,60 @@ int32_t AppMgrServiceInner::IsAppRunning(const std::string &bundleName, int32_t
|
||||
return appRunningManager_->CheckAppCloneRunningRecordIsExistByBundleName(bundleName, appCloneIndex, isRunning);
|
||||
}
|
||||
|
||||
bool AppMgrServiceInner::CreateAbilityInfo(const AAFwk::Want &want, AbilityInfo &abilityInfo)
|
||||
{
|
||||
auto&& bundleMgrHelper = remoteClientManager_->GetBundleManagerHelper();
|
||||
if (!bundleMgrHelper) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Get bundle manager helper error.");
|
||||
return false;
|
||||
}
|
||||
auto userId = GetCurrentAccountId();
|
||||
auto abilityInfoFlag = AbilityRuntime::StartupUtil::BuildAbilityInfoFlag();
|
||||
if (IN_PROCESS_CALL(bundleMgrHelper->QueryAbilityInfo(want, abilityInfoFlag, userId, abilityInfo))) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "QueryAbilityInfo failed.");
|
||||
return true;
|
||||
}
|
||||
std::vector<AppExecFwk::ExtensionAbilityInfo> extensionInfos;
|
||||
int32_t appIndex = want.GetIntParam(AppspawnUtil::DLP_PARAMS_INDEX, 0);
|
||||
if (appIndex == 0) {
|
||||
if (!IN_PROCESS_CALL(bundleMgrHelper->QueryExtensionAbilityInfos(want, abilityInfoFlag,
|
||||
userId, extensionInfos))) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "QueryExtensionAbilityInfos failed.");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!IN_PROCESS_CALL(bundleMgrHelper->GetSandboxExtAbilityInfos(want, appIndex,
|
||||
abilityInfoFlag, userId, extensionInfos))) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "GetSandboxExtAbilityInfos failed.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (extensionInfos.size() <= 0) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Get extension info failed.");
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
AppExecFwk::ExtensionAbilityInfo extensionInfo = extensionInfos.front();
|
||||
AbilityRuntime::StartupUtil::InitAbilityInfoFromExtension(extensionInfo, abilityInfo);
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t AppMgrServiceInner::StartNativeProcessForDebugger(const AAFwk::Want &want)
|
||||
{
|
||||
if (!remoteClientManager_ || !appRunningManager_) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "remoteClientManager or appRunningManager is nullptr!");
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
auto&& bundleMgrHelper = remoteClientManager_->GetBundleManagerHelper();
|
||||
if (!bundleMgrHelper) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Get bundle manager helper error.");
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
TAG_LOGI(AAFwkTag::APPMGR, "debuggablePipe bundleName:%{public}s", want.GetElement().GetBundleName().c_str());
|
||||
TAG_LOGI(AAFwkTag::APPMGR, "debuggablePipe moduleName:%{public}s", want.GetElement().GetModuleName().c_str());
|
||||
TAG_LOGI(AAFwkTag::APPMGR, "debuggablePipe abilityName:%{public}s", want.GetElement().GetAbilityName().c_str());
|
||||
|
||||
AbilityInfo abilityInfo;
|
||||
auto userId = GetCurrentAccountId();
|
||||
auto abilityInfoFlag = AbilityRuntime::StartupUtil::BuildAbilityInfoFlag();
|
||||
IN_PROCESS_CALL_WITHOUT_RET(bundleMgrHelper->QueryAbilityInfo(want, abilityInfoFlag, userId, abilityInfo));
|
||||
if (!CreateAbilityInfo(want, abilityInfo)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "CreateAbilityInfo failed!");
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
BundleInfo bundleInfo;
|
||||
HapModuleInfo hapModuleInfo;
|
||||
auto appInfo = std::make_shared<ApplicationInfo>(abilityInfo.applicationInfo);
|
||||
@ -5927,7 +5977,8 @@ void AppMgrServiceInner::ClearAppRunningDataForKeepAlive(const std::shared_ptr<A
|
||||
}
|
||||
|
||||
if (appRecord->IsKeepAliveApp()) {
|
||||
if (ExitResidentProcessManager::GetInstance().RecordExitResidentBundleName(appRecord->GetBundleName())) {
|
||||
if (appRecord->GetBundleName() != BUNDLE_NAME_SAMPLE_MANAGEMENT &&
|
||||
ExitResidentProcessManager::GetInstance().RecordExitResidentBundleName(appRecord->GetBundleName())) {
|
||||
TAG_LOGI(AAFwkTag::APPMGR, "memory size is insufficent, record exit resident process info");
|
||||
return;
|
||||
}
|
||||
@ -6663,7 +6714,7 @@ int32_t AppMgrServiceInner::NotifyMemorySizeStateChanged(bool isMemorySizeSuffic
|
||||
MEMMGR_PROC_NAME);
|
||||
bool isSupportCall = OHOS::system::GetBoolParameter(SUPPORT_CALL_NOTIFY_MEMORY_CHANGED, false);
|
||||
if (!isMemmgrCall && !isSupportCall) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "callerToken not %{public}s. %{public}s", MEMMGR_PROC_NAME.c_str(), __func__);
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "callerToken not %{public}s. %{public}s", MEMMGR_PROC_NAME, __func__);
|
||||
return ERR_PERMISSION_DENIED;
|
||||
}
|
||||
|
||||
|
@ -569,7 +569,9 @@ void AppRunningManager::TerminateAbility(const sptr<IRemoteObject> &token, bool
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "The ability is the last in the app:%{public}s.", appRecord->GetName().c_str());
|
||||
appRecord->SetTerminating();
|
||||
if (clearMissionFlag && appMgrServiceInner != nullptr) {
|
||||
appRecord->PostTask("DELAY_KILL_PROCESS", AMSEventHandler::DELAY_KILL_PROCESS_TIMEOUT, killProcess);
|
||||
auto delayTime = appRecord->ExtensionAbilityRecordExists(token) ?
|
||||
AMSEventHandler::DELAY_KILL_EXTENSION_PROCESS_TIMEOUT : AMSEventHandler::DELAY_KILL_PROCESS_TIMEOUT;
|
||||
appRecord->PostTask("DELAY_KILL_PROCESS", delayTime, killProcess);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -619,6 +621,10 @@ int32_t AppRunningManager::AssignRunningProcessInfoByAppRecord(
|
||||
if (appInfo) {
|
||||
info.bundleType = static_cast<int32_t>(appInfo->bundleType);
|
||||
}
|
||||
if (appInfo && (static_cast<int32_t>(appInfo->multiAppMode.multiAppModeType) ==
|
||||
static_cast<int32_t>(MultiAppModeType::APP_CLONE))) {
|
||||
info.appCloneIndex = appRecord->GetAppIndex();
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
@ -1499,10 +1505,13 @@ bool AppRunningManager::IsAppProcessesAllCached(const std::string &bundleName, i
|
||||
if (itemRecord == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if (itemRecord->GetBundleName() == bundleName && itemRecord->GetUid() == uid &&
|
||||
cachedSet.find(itemRecord) == cachedSet.end() &&
|
||||
DelayedSingleton<CacheProcessManager>::GetInstance()->IsAppSupportProcessCache(itemRecord)) {
|
||||
return false;
|
||||
if (itemRecord->GetBundleName() == bundleName && itemRecord->GetUid() == uid) {
|
||||
auto supportCache =
|
||||
DelayedSingleton<CacheProcessManager>::GetInstance()->IsAppSupportProcessCache(itemRecord);
|
||||
// need wait for unsupported processes
|
||||
if ((cachedSet.find(itemRecord) == cachedSet.end() && supportCache) || !supportCache) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -795,11 +795,15 @@ void AppRunningRecord::StateChangedNotifyObserver(
|
||||
abilityStateData.abilityType = static_cast<int32_t>(ability->GetAbilityInfo()->type);
|
||||
abilityStateData.isFocused = ability->GetFocusFlag();
|
||||
abilityStateData.abilityRecordId = ability->GetAbilityRecordId();
|
||||
auto applicationInfo = GetApplicationInfo();
|
||||
if (applicationInfo && (static_cast<int32_t>(applicationInfo->multiAppMode.multiAppModeType) ==
|
||||
static_cast<int32_t>(MultiAppModeType::APP_CLONE))) {
|
||||
abilityStateData.appCloneIndex = appIndex_;
|
||||
}
|
||||
if (ability->GetWant() != nullptr) {
|
||||
abilityStateData.callerAbilityName = ability->GetWant()->GetStringParam(Want::PARAM_RESV_CALLER_ABILITY_NAME);
|
||||
abilityStateData.callerBundleName = ability->GetWant()->GetStringParam(Want::PARAM_RESV_CALLER_BUNDLE_NAME);
|
||||
}
|
||||
auto applicationInfo = GetApplicationInfo();
|
||||
if (applicationInfo && applicationInfo->bundleType == AppExecFwk::BundleType::ATOMIC_SERVICE) {
|
||||
abilityStateData.isAtomicService = true;
|
||||
}
|
||||
@ -1340,6 +1344,22 @@ bool AppRunningRecord::IsLastAbilityRecord(const sptr<IRemoteObject> &token)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AppRunningRecord::ExtensionAbilityRecordExists(const sptr<IRemoteObject> &token)
|
||||
{
|
||||
auto moduleRecord = GetModuleRunningRecordByToken(token);
|
||||
if (!moduleRecord) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "can not find module record");
|
||||
return false;
|
||||
}
|
||||
auto moduleRecordList = GetAllModuleRecord();
|
||||
for (auto moduleRecord : moduleRecordList) {
|
||||
if (moduleRecord && moduleRecord->ExtensionAbilityRecordExists()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AppRunningRecord::IsLastPageAbilityRecord(const sptr<IRemoteObject> &token)
|
||||
{
|
||||
auto moduleRecord = GetModuleRunningRecordByToken(token);
|
||||
@ -1351,7 +1371,9 @@ bool AppRunningRecord::IsLastPageAbilityRecord(const sptr<IRemoteObject> &token)
|
||||
int32_t pageAbilitySize = 0;
|
||||
auto moduleRecordList = GetAllModuleRecord();
|
||||
for (auto moduleRecord : moduleRecordList) {
|
||||
pageAbilitySize += moduleRecord->GetPageAbilitySize() ;
|
||||
if (moduleRecord) {
|
||||
pageAbilitySize += moduleRecord->GetPageAbilitySize();
|
||||
}
|
||||
if (pageAbilitySize > 1) {
|
||||
return false;
|
||||
}
|
||||
@ -2275,5 +2297,23 @@ pid_t AppRunningRecord::GetGPUPid()
|
||||
{
|
||||
return gpuPid_;
|
||||
}
|
||||
|
||||
void AppRunningRecord::ScheduleCacheProcess()
|
||||
{
|
||||
if (appLifeCycleDeal_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "appLifeCycleDeal_ is null");
|
||||
return;
|
||||
}
|
||||
appLifeCycleDeal_->ScheduleCacheProcess();
|
||||
}
|
||||
|
||||
bool AppRunningRecord::CancelTask(std::string msg)
|
||||
{
|
||||
if (!taskHandler_) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "taskHandler_ is nullptr");
|
||||
return false;
|
||||
}
|
||||
return taskHandler_->CancelTask(msg);
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -25,19 +25,19 @@
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
namespace {
|
||||
const std::string HSPLIST_BUNDLES = "bundles";
|
||||
const std::string HSPLIST_MODULES = "modules";
|
||||
const std::string HSPLIST_VERSIONS = "versions";
|
||||
const std::string DATAGROUPINFOLIST_DATAGROUPID = "dataGroupId";
|
||||
const std::string DATAGROUPINFOLIST_GID = "gid";
|
||||
const std::string DATAGROUPINFOLIST_DIR = "dir";
|
||||
const std::string JSON_DATA_APP = "/data/app/el2/";
|
||||
const std::string JSON_GROUP = "/group/";
|
||||
const std::string VERSION_PREFIX = "v";
|
||||
const std::string APPSPAWN_CLIENT_USER_NAME = "APP_MANAGER_SERVICE";
|
||||
constexpr int32_t RIGHT_SHIFT_STEP = 1;
|
||||
constexpr int32_t START_FLAG_TEST_NUM = 1;
|
||||
const std::string MAX_CHILD_PROCESS = "MaxChildProcess";
|
||||
constexpr const char* HSPLIST_BUNDLES = "bundles";
|
||||
constexpr const char* HSPLIST_MODULES = "modules";
|
||||
constexpr const char* HSPLIST_VERSIONS = "versions";
|
||||
constexpr const char* DATAGROUPINFOLIST_DATAGROUPID = "dataGroupId";
|
||||
constexpr const char* DATAGROUPINFOLIST_GID = "gid";
|
||||
constexpr const char* DATAGROUPINFOLIST_DIR = "dir";
|
||||
constexpr const char* JSON_DATA_APP = "/data/app/el2/";
|
||||
constexpr const char* JSON_GROUP = "/group/";
|
||||
constexpr const char* VERSION_PREFIX = "v";
|
||||
constexpr const char* APPSPAWN_CLIENT_USER_NAME = "APP_MANAGER_SERVICE";
|
||||
constexpr int32_t RIGHT_SHIFT_STEP = 1;
|
||||
constexpr int32_t START_FLAG_TEST_NUM = 1;
|
||||
constexpr const char* MAX_CHILD_PROCESS = "MaxChildProcess";
|
||||
}
|
||||
AppSpawnClient::AppSpawnClient(bool isNWebSpawn)
|
||||
{
|
||||
@ -169,7 +169,7 @@ int32_t AppSpawnClient::SetDacInfo(const AppSpawnStartMsg &startMsg, AppSpawnReq
|
||||
for (uint32_t i = startMsg.gids.size(); i < appDacInfo.gidCount; i++) {
|
||||
appDacInfo.gidTable[i] = startMsg.dataGroupInfoList[i - startMsg.gids.size()].gid;
|
||||
}
|
||||
ret = strcpy_s(appDacInfo.userName, sizeof(appDacInfo.userName), APPSPAWN_CLIENT_USER_NAME.c_str());
|
||||
ret = strcpy_s(appDacInfo.userName, sizeof(appDacInfo.userName), APPSPAWN_CLIENT_USER_NAME);
|
||||
if (ret) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "failed to set dac userName!");
|
||||
return ret;
|
||||
@ -246,6 +246,19 @@ int32_t AppSpawnClient::SetAppExtension(const AppSpawnStartMsg &startMsg, AppSpa
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t AppSpawnClient::SetCloneFlag(const AppSpawnStartMsg &startMsg, AppSpawnReqMsgHandle reqHandle) const
|
||||
{
|
||||
int32_t ret = 0;
|
||||
if (startMsg.flags & APP_FLAGS_CLONE_ENABLE) {
|
||||
ret = AppSpawnReqMsgSetAppFlag(reqHandle, APP_FLAGS_CLONE_ENABLE);
|
||||
if (ret != 0) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "SetCloneFlag failed, ret: %{public}d", ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t AppSpawnClient::AppspawnSetExtMsg(const AppSpawnStartMsg &startMsg, AppSpawnReqMsgHandle reqHandle)
|
||||
{
|
||||
int32_t ret = 0;
|
||||
@ -331,7 +344,7 @@ int32_t AppSpawnClient::AppspawnSetExtMsgMore(const AppSpawnStartMsg &startMsg,
|
||||
}
|
||||
|
||||
std::string maxChildProcessStr = std::to_string(startMsg.maxChildProcess);
|
||||
if ((ret = AppSpawnReqMsgAddExtInfo(reqHandle, MAX_CHILD_PROCESS.c_str(),
|
||||
if ((ret = AppSpawnReqMsgAddExtInfo(reqHandle, MAX_CHILD_PROCESS,
|
||||
reinterpret_cast<const uint8_t*>(maxChildProcessStr.c_str()), maxChildProcessStr.size()))) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Send maxChildProcess failed, ret: %{public}d", ret);
|
||||
return ret;
|
||||
@ -400,6 +413,10 @@ int32_t AppSpawnClient::AppspawnCreateDefaultMsg(const AppSpawnStartMsg &startMs
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "SetAppExtension failed, ret: %{public}d", ret);
|
||||
break;
|
||||
}
|
||||
if ((ret = SetCloneFlag(startMsg, reqHandle))) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "SetCloneFlag failed, ret: %{public}d", ret);
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
} while (0);
|
||||
|
||||
|
@ -23,19 +23,19 @@
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
namespace {
|
||||
const std::string HSPLIST_BUNDLES = "bundles";
|
||||
const std::string HSPLIST_MODULES = "modules";
|
||||
const std::string HSPLIST_VERSIONS = "versions";
|
||||
const std::string HSPLIST_SOCKET_TYPE = "|HspList|";
|
||||
const std::string OVERLAY_SOCKET_TYPE = "|Overlay|";
|
||||
const std::string DATA_GROUP_SOCKET_TYPE = "|DataGroup|";
|
||||
const std::string APP_ENV_TYPE = "|AppEnv|";
|
||||
const std::string DATAGROUPINFOLIST_DATAGROUPID = "dataGroupId";
|
||||
const std::string DATAGROUPINFOLIST_GID = "gid";
|
||||
const std::string DATAGROUPINFOLIST_DIR = "dir";
|
||||
const std::string JSON_DATA_APP = "/data/app/el2/";
|
||||
const std::string JSON_GROUP = "/group/";
|
||||
const std::string VERSION_PREFIX = "v";
|
||||
constexpr const char* HSPLIST_BUNDLES = "bundles";
|
||||
constexpr const char* HSPLIST_MODULES = "modules";
|
||||
constexpr const char* HSPLIST_VERSIONS = "versions";
|
||||
constexpr const char* HSPLIST_SOCKET_TYPE = "|HspList|";
|
||||
constexpr const char* OVERLAY_SOCKET_TYPE = "|Overlay|";
|
||||
constexpr const char* DATA_GROUP_SOCKET_TYPE = "|DataGroup|";
|
||||
constexpr const char* APP_ENV_TYPE = "|AppEnv|";
|
||||
constexpr const char* DATAGROUPINFOLIST_DATAGROUPID = "dataGroupId";
|
||||
constexpr const char* DATAGROUPINFOLIST_GID = "gid";
|
||||
constexpr const char* DATAGROUPINFOLIST_DIR = "dir";
|
||||
constexpr const char* JSON_DATA_APP = "/data/app/el2/";
|
||||
constexpr const char* JSON_GROUP = "/group/";
|
||||
constexpr const char* VERSION_PREFIX = "v";
|
||||
}
|
||||
|
||||
AppSpawnMsgWrapper::~AppSpawnMsgWrapper()
|
||||
|
@ -25,6 +25,7 @@
|
||||
namespace {
|
||||
const std::string MAX_PROC_CACHE_NUM = "persist.sys.abilityms.maxProcessCacheNum";
|
||||
const std::string PROCESS_CACHE_API_CHECK_CONFIG = "persist.sys.abilityms.processCacheApiCheck";
|
||||
const std::string SHELL_ASSISTANT_BUNDLENAME = "com.huawei.shell_assistant";
|
||||
constexpr int32_t API12 = 12;
|
||||
constexpr int32_t API_VERSION_MOD = 100;
|
||||
}
|
||||
@ -105,9 +106,16 @@ bool CacheProcessManager::CheckAndCacheProcess(const std::shared_ptr<AppRunningR
|
||||
appRecord->GetName().c_str());
|
||||
return true;
|
||||
}
|
||||
TAG_LOGI(AAFwkTag::APPMGR, "%{public}s is cached, %{public}s", appRecord->GetName().c_str(),
|
||||
PrintCacheQueue().c_str());
|
||||
CheckAndNotifyCachedState(appRecord);
|
||||
appRecord->ScheduleCacheProcess();
|
||||
auto notifyCached = [appRecord]() {
|
||||
DelayedSingleton<CacheProcessManager>::GetInstance()->CheckAndNotifyCachedState(appRecord);
|
||||
};
|
||||
std::string taskName = "DELAY_CACHED_STATE_NOTIFY";
|
||||
auto res = appRecord->CancelTask(taskName);
|
||||
if (res) {
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "Early delay task canceled.");
|
||||
}
|
||||
appRecord->PostTask(taskName, AMSEventHandler::DELAY_NOTIFY_PROCESS_CACHED_STATE, notifyCached);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -234,6 +242,13 @@ bool CacheProcessManager::IsAppSupportProcessCache(const std::shared_ptr<AppRunn
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "Keepalive app.");
|
||||
return false;
|
||||
}
|
||||
if (appRecord->GetParentAppRecord() != nullptr) {
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "Child App, not support.");
|
||||
return false;
|
||||
}
|
||||
if (appRecord->GetBundleName() == SHELL_ASSISTANT_BUNDLENAME) {
|
||||
return false;
|
||||
}
|
||||
auto supportState = appRecord->GetSupportProcessCacheState();
|
||||
switch (supportState) {
|
||||
case SupportProcessCacheState::UNSPECIFIED:
|
||||
|
@ -109,7 +109,7 @@ int32_t ModuleRunningRecord::GetPageAbilitySize()
|
||||
for (auto it : abilities_) {
|
||||
std::shared_ptr<AbilityRunningRecord> abilityRunningRecord = it.second;
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = abilityRunningRecord->GetAbilityInfo();
|
||||
if (abilityInfo->type == AbilityType::PAGE) {
|
||||
if (abilityInfo && abilityInfo->type == AbilityType::PAGE) {
|
||||
pageAbilitySize++;
|
||||
}
|
||||
}
|
||||
@ -117,6 +117,19 @@ int32_t ModuleRunningRecord::GetPageAbilitySize()
|
||||
return pageAbilitySize;
|
||||
}
|
||||
|
||||
bool ModuleRunningRecord::ExtensionAbilityRecordExists()
|
||||
{
|
||||
std::lock_guard<ffrt::mutex> lock(abilitiesMutex_);
|
||||
for (auto it : abilities_) {
|
||||
std::shared_ptr<AbilityRunningRecord> abilityRunningRecord = it.second;
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = abilityRunningRecord->GetAbilityInfo();
|
||||
if (abilityInfo && abilityInfo->type != AbilityType::PAGE) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::map<const sptr<IRemoteObject>, std::shared_ptr<AbilityRunningRecord>> ModuleRunningRecord::GetAbilities()
|
||||
const
|
||||
{
|
||||
|
@ -60,7 +60,8 @@ inline std::unordered_set<AppExecFwk::ExtensionAbilityType> GetUiExtensionSet()
|
||||
AppExecFwk::ExtensionAbilityType::SYSPICKER_CAMERA,
|
||||
AppExecFwk::ExtensionAbilityType::SYSPICKER_FILEPICKER,
|
||||
AppExecFwk::ExtensionAbilityType::AUTO_FILL_SMART,
|
||||
AppExecFwk::ExtensionAbilityType::LIVEVIEW_LOCKSCREEN
|
||||
AppExecFwk::ExtensionAbilityType::LIVEVIEW_LOCKSCREEN,
|
||||
AppExecFwk::ExtensionAbilityType::SYSPICKER_AUDIOPICKER
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,12 @@ config("dataobsms_config") {
|
||||
}
|
||||
|
||||
ohos_shared_library("dataobsms") {
|
||||
branch_protector_ret = "pac_ret"
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
shlib_type = "sa"
|
||||
sources = dataobsms_files
|
||||
|
||||
@ -58,6 +64,12 @@ ohos_shared_library("dataobsms") {
|
||||
|
||||
# Note: Just for test
|
||||
ohos_static_library("dataobsms_static") {
|
||||
branch_protector_ret = "pac_ret"
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
sources = dataobsms_files
|
||||
|
||||
configs = [ ":dataobsms_config" ]
|
||||
|
@ -30,17 +30,17 @@ export default class SelectorExtensionAbility extends UIExtensionAbility {
|
||||
|
||||
onSessionCreate(want: Want, session: UIExtensionContentSession) {
|
||||
const storage: LocalStorage = new LocalStorage({
|
||||
"session": session,
|
||||
"extensionAbility": this,
|
||||
"callerWant": want
|
||||
'session': session,
|
||||
'extensionAbility': this,
|
||||
'callerWant': want
|
||||
} as Record<string, object>);
|
||||
globalThis.ExtensionType = 'UIExtension';
|
||||
if (systemparameter.getSync('persist.sys.abilityms.isdialogconfirmpermission', 'false') === 'false' &&
|
||||
globalThis.preferences.getSync('isdialogconfirmpermission', 'false') === 'false') {
|
||||
globalThis.currentURL = 'pages/PhonePage';
|
||||
session.loadContent("pages/permissionConfirmDialog", storage);
|
||||
session.loadContent('pages/permissionConfirmDialog', storage);
|
||||
} else {
|
||||
session.loadContent("pages/PhonePage", storage);
|
||||
session.loadContent('pages/PhonePage', storage);
|
||||
}
|
||||
try {
|
||||
const bgColor: string = '#40FFFFFF';
|
||||
|
@ -21,9 +21,9 @@ export type UIExtensionActionFunction = (storage?: LocalStorage) => UIExtensionI
|
||||
export type CustomActionFunction = () => void
|
||||
|
||||
export class UIExtensionInfo {
|
||||
readonly bundleName: string;
|
||||
readonly abilityName: string;
|
||||
readonly parameters?: Record<string, Object>;
|
||||
public readonly bundleName: string;
|
||||
public readonly abilityName: string;
|
||||
public readonly parameters?: Record<string, Object>;
|
||||
|
||||
constructor(bundleName: string, abilityName: string, parameters?: Record<string, Object>) {
|
||||
this.bundleName = bundleName;
|
||||
@ -50,19 +50,20 @@ export enum IntentType {
|
||||
}
|
||||
|
||||
export class TargetAction {
|
||||
readonly type: TargetType;
|
||||
readonly actionExecution: UIAbilityActionExecution | UIExtensionActionFunction | CustomActionFunction | null;
|
||||
public readonly type: TargetType;
|
||||
public readonly actionExecution: UIAbilityActionExecution | UIExtensionActionFunction | CustomActionFunction | null;
|
||||
|
||||
constructor(type: TargetType, actionExecution: UIAbilityActionExecution | UIExtensionActionFunction | CustomActionFunction | null) {
|
||||
constructor(type: TargetType, actionExecution: UIAbilityActionExecution | UIExtensionActionFunction |
|
||||
CustomActionFunction | null) {
|
||||
this.type = type;
|
||||
this.actionExecution = actionExecution;
|
||||
}
|
||||
}
|
||||
|
||||
export class TargetInfo {
|
||||
readonly filterAbilityInfo: bundleManager.ExtensionAbilityInfo | null;
|
||||
readonly targetAction: TargetAction | null;
|
||||
readonly visible: boolean;
|
||||
public readonly filterAbilityInfo: bundleManager.ExtensionAbilityInfo | null;
|
||||
public readonly targetAction: TargetAction | null;
|
||||
public readonly visible: boolean;
|
||||
|
||||
constructor(filterAbilityInfo: bundleManager.ExtensionAbilityInfo | null, targetAction: TargetAction | null,
|
||||
visible: boolean=true) {
|
||||
@ -73,11 +74,11 @@ export class TargetInfo {
|
||||
}
|
||||
|
||||
export class AbilityInfoParam {
|
||||
bundleName: string;
|
||||
moduleName: string;
|
||||
abilityName: string | null;
|
||||
abilityIconId: number;
|
||||
abilityLabelId: number;
|
||||
public bundleName: string;
|
||||
public moduleName: string;
|
||||
public abilityName: string | null;
|
||||
public abilityIconId: number;
|
||||
public abilityLabelId: number;
|
||||
|
||||
constructor(bundleName: string, moduleName: string,
|
||||
abilityName: string, abilityIconId: number, abilityLabelId: number) {
|
||||
|
@ -60,7 +60,8 @@ export namespace TargetManager {
|
||||
|
||||
function buildUIExtensionTargetAction(callerWant: Want, params: TargetActionBuilderParam): TargetAction {
|
||||
if (callerWant.parameters){
|
||||
callerWant.parameters['ability.want.params.uiExtensionType'] = callerWant.parameters['ability.want.params.uiExtensionTargetType'];
|
||||
callerWant.parameters['ability.want.params.uiExtensionType'] =
|
||||
callerWant.parameters['ability.want.params.uiExtensionTargetType'];
|
||||
callerWant.parameters['ability.want.params.uiExtensionTargetType'] = '';
|
||||
}
|
||||
return new TargetAction(TargetType.UI_EXTENSION, (storage?: LocalStorage) => {
|
||||
@ -68,7 +69,8 @@ export namespace TargetManager {
|
||||
})
|
||||
}
|
||||
|
||||
export function removePartialTargetListIfExceedsMax(targetInfoArray: Array<TargetInfo>, maxSize: number): Array<TargetInfo> {
|
||||
export function removePartialTargetListIfExceedsMax(
|
||||
targetInfoArray: Array<TargetInfo>, maxSize: number): Array<TargetInfo> {
|
||||
if (targetInfoArray.length <= maxSize) {
|
||||
return targetInfoArray;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ import { TargetManager } from '../data/TargetManager';
|
||||
import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession';
|
||||
import wantConstant from '@ohos.app.ability.wantConstant';
|
||||
import BreakpointSystem, { ColumnType } from '../utils/BreakpointSystem';
|
||||
import { MediaSyncFacade } from '../utils/MediaQueryFacade';
|
||||
import { mediaSyncFacade } from '../utils/MediaQueryFacade';
|
||||
import mediaquery from '@ohos.mediaquery';
|
||||
import uriPermissionManager from '@ohos.application.uriPermissionManager';
|
||||
import Want from '@ohos.app.ability.Want';
|
||||
@ -28,7 +28,7 @@ import { TipsDialogComponent } from '../view/TipsDialogComponent';
|
||||
import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant';
|
||||
import { AbilityInfoUtils } from '../utils/AbilityInfoUtils';
|
||||
import UIExtensionAbility from '@ohos.app.ability.UIExtensionAbility';
|
||||
import { LocalStorageKeyConstants, TargetsUpperLimitOneLine } from '../utils/Constants';
|
||||
import { localStorageKeyConstants, TargetsUpperLimitOneLine } from '../utils/Constants';
|
||||
|
||||
const storage = LocalStorage.GetShared();
|
||||
|
||||
@ -41,7 +41,7 @@ const FOUR_COLUMN_WIDTH: number = 600;
|
||||
struct PhonePage {
|
||||
@Provide openUIExtension: boolean = false;
|
||||
@Provide uiExtensionInfo: UIExtensionInfo | null = null;
|
||||
@Provide @Watch("onLevel2PageChanged") level2Page: boolean = false;
|
||||
@Provide @Watch('onLevel2PageChanged') level2Page: boolean = false;
|
||||
@Provide realHeight: number | PanelHeight = PanelHeight.WRAP_CONTENT;
|
||||
@State displayException: boolean = false;
|
||||
@State targetInfoArray: Array<TargetInfo> = [];
|
||||
@ -64,7 +64,7 @@ struct PhonePage {
|
||||
|
||||
aboutToAppear() {
|
||||
console.info(TAG, `aboutToAppear`);
|
||||
if (!storage || !storage.get(LocalStorageKeyConstants.CALLER_WANT)) {
|
||||
if (!storage || !storage.get(localStorageKeyConstants.CALLER_WANT)) {
|
||||
console.error(TAG, `storage or callerWant is null`);
|
||||
return;
|
||||
}
|
||||
@ -91,14 +91,14 @@ struct PhonePage {
|
||||
}
|
||||
|
||||
refreshTarget() {
|
||||
this.targetInfoArraylevel2 = TargetManager.getAvailableTargets(storage.get(LocalStorageKeyConstants.CALLER_WANT)??{
|
||||
});
|
||||
this.targetInfoArraylevel2 =
|
||||
TargetManager.getAvailableTargets(storage.get(localStorageKeyConstants.CALLER_WANT)??{});
|
||||
this.getTargetsToDisplay();
|
||||
}
|
||||
|
||||
registerBreakpointSystem() {
|
||||
const context: Context = getContext(this);
|
||||
(MediaSyncFacade["BREAK_POINT_SYSTEM"] as BreakpointSystem).register((columnType: ColumnType) => {
|
||||
(mediaSyncFacade['BREAK_POINT_SYSTEM'] as BreakpointSystem).register((columnType: ColumnType) => {
|
||||
if (columnType === ColumnType.BREAKPOINT_8_COLUMN || columnType === ColumnType.BREAKPOINT_12_COLUMN) {
|
||||
this.maxLengthOneLine = TargetsUpperLimitOneLine.BREAKPOINT_8_12_COLUMN;
|
||||
const displayData: display.Display = display.getDefaultDisplaySync();
|
||||
@ -106,12 +106,14 @@ struct PhonePage {
|
||||
this.panelTopPadding = (displayData.height / displayData.densityPixels - this.statusBarHeight) *
|
||||
(this.isLandscape ? 0.1 : 0.2) + this.statusBarHeight;
|
||||
}
|
||||
this.panelHeight = displayData.height / displayData.densityPixels - this.statusBarHeight - this.panelTopPadding;
|
||||
this.panelHeight =
|
||||
displayData.height / displayData.densityPixels - this.statusBarHeight - this.panelTopPadding;
|
||||
} else {
|
||||
this.maxLengthOneLine = TargetsUpperLimitOneLine.BREAKPOINT_4_COLUMN;
|
||||
const displayData: display.Display = display.getDefaultDisplaySync();
|
||||
this.panelTopPadding = 8;
|
||||
this.panelHeight = displayData.height / displayData.densityPixels - this.statusBarHeight - this.panelTopPadding;
|
||||
this.panelHeight =
|
||||
displayData.height / displayData.densityPixels - this.statusBarHeight - this.panelTopPadding;
|
||||
}
|
||||
if (!this.level2Page) {
|
||||
this.targetInfoArray = TargetManager.removePartialTargetListIfExceedsMax
|
||||
@ -166,12 +168,13 @@ struct PhonePage {
|
||||
autoCancel: false,
|
||||
backgroundColor: $r('sys.color.ohos_id_color_dialog_bg'),
|
||||
maskColor: $r('sys.color.ohos_id_color_mask_thin'),
|
||||
alignment: DeviceInfoUtil.isTable() ||
|
||||
(display.isFoldable() && display.getFoldDisplayMode() === display.FoldDisplayMode.FOLD_DISPLAY_MODE_FULL)
|
||||
? DialogAlignment.Center : DialogAlignment.Bottom,
|
||||
alignment: DeviceInfoUtil.isTable() || (display.isFoldable() &&
|
||||
display.getFoldDisplayMode() === display.FoldDisplayMode.FOLD_DISPLAY_MODE_FULL) ?
|
||||
DialogAlignment.Center : DialogAlignment.Bottom,
|
||||
offset: { dx: 0, dy: DeviceInfoUtil.isTable() ? 0 : this.tipsDialogBottomOffset },
|
||||
cancel: () => {
|
||||
const session: UIExtensionContentSession = storage.get(LocalStorageKeyConstants.SESSION) as UIExtensionContentSession;
|
||||
const session: UIExtensionContentSession =
|
||||
storage.get(localStorageKeyConstants.SESSION) as UIExtensionContentSession;
|
||||
session.terminateSelf();
|
||||
storage.clear();
|
||||
}
|
||||
@ -191,7 +194,8 @@ struct PhonePage {
|
||||
}
|
||||
.type(PanelType.CUSTOM)
|
||||
.customHeight(this.level2Page ? this.realHeight > this.panelHeight ? this.panelHeight : this.realHeight :
|
||||
this.titleHeight + this.rowHeight * (this.targetInfoArray.length > this.maxLengthOneLine ? 2 : 1) + this.rowTopPadding)
|
||||
this.titleHeight + this.rowHeight * (this.targetInfoArray.length > this.maxLengthOneLine ? 2 : 1) +
|
||||
this.rowTopPadding)
|
||||
.backgroundColor($r('sys.color.ohos_id_color_panel_bg'))
|
||||
.dragBar(false)
|
||||
.width(this.maxLengthOneLine === TargetsUpperLimitOneLine.BREAKPOINT_4_COLUMN ? '100%' : 480)
|
||||
|
@ -31,7 +31,7 @@ export namespace AbilityInfoUtils {
|
||||
let moduleContext: Context | undefined =
|
||||
context?.createModuleContext(abilityInfoParam.bundleName, abilityInfoParam.moduleName);
|
||||
if (!moduleContext) {
|
||||
throw { code: 1000, data: "Get module context error." } as BusinessError<string> as Error;
|
||||
throw { code: 1000, data: 'Get module context error.' } as BusinessError<string> as Error;
|
||||
}
|
||||
|
||||
const resourceManager = moduleContext.resourceManager;
|
||||
@ -47,7 +47,7 @@ export namespace AbilityInfoUtils {
|
||||
let moduleContext: Context | undefined = context.createModuleContext(abilityInfoParam.bundleName,
|
||||
abilityInfoParam.moduleName);
|
||||
if (!moduleContext) {
|
||||
throw { code: 1000, data: "Get module context error." } as BusinessError<string> as Error;
|
||||
throw { code: 1000, data: 'Get module context error.' } as BusinessError<string> as Error;
|
||||
}
|
||||
const resourceManager = moduleContext.resourceManager;
|
||||
let icon = resourceManager.getDrawableDescriptor(abilityInfoParam.abilityIconId);
|
||||
|
@ -20,9 +20,9 @@ const TAG = 'BreakpointSystem';
|
||||
type triggerFunc = (columnType: ColumnType) => void;
|
||||
|
||||
export enum ColumnType {
|
||||
BREAKPOINT_4_COLUMN = "sm",
|
||||
BREAKPOINT_8_COLUMN = "md",
|
||||
BREAKPOINT_12_COLUMN = "lg"
|
||||
BREAKPOINT_4_COLUMN = 'sm',
|
||||
BREAKPOINT_8_COLUMN = 'md',
|
||||
BREAKPOINT_12_COLUMN = 'lg'
|
||||
}
|
||||
|
||||
export const BREAKPOINT_VALUE = [0, 520, 840]
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user