mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 22:21:36 -04:00
@@ -43,6 +43,9 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
namespace {
|
||||
bool g_jitEnabled = false;
|
||||
}
|
||||
bool ChildProcessManager::signalRegistered_ = false;
|
||||
|
||||
ChildProcessManager::ChildProcessManager()
|
||||
@@ -155,7 +158,7 @@ void ChildProcessManager::HandleChildProcessBySelfFork(const std::string &srcEnt
|
||||
return;
|
||||
}
|
||||
|
||||
auto runtime = CreateRuntime(bundleInfo, hapModuleInfo, false);
|
||||
auto runtime = CreateRuntime(bundleInfo, hapModuleInfo, false, g_jitEnabled);
|
||||
if (!runtime) {
|
||||
HILOG_ERROR("Failed to create child process runtime");
|
||||
return;
|
||||
@@ -192,7 +195,7 @@ bool ChildProcessManager::LoadJsFile(const std::string &srcEntry, const AppExecF
|
||||
}
|
||||
|
||||
std::unique_ptr<AbilityRuntime::Runtime> ChildProcessManager::CreateRuntime(const AppExecFwk::BundleInfo &bundleInfo,
|
||||
const AppExecFwk::HapModuleInfo &hapModuleInfo, const bool fromAppSpawn)
|
||||
const AppExecFwk::HapModuleInfo &hapModuleInfo, const bool fromAppSpawn, const bool jitEnabled)
|
||||
{
|
||||
AppExecFwk::ApplicationInfo applicationInfo = bundleInfo.applicationInfo;
|
||||
AbilityRuntime::Runtime::Options options;
|
||||
@@ -206,6 +209,7 @@ std::unique_ptr<AbilityRuntime::Runtime> ChildProcessManager::CreateRuntime(cons
|
||||
options.arkNativeFilePath = applicationInfo.arkNativeFilePath;
|
||||
options.apiTargetVersion = applicationInfo.apiTargetVersion;
|
||||
options.loadAce = true;
|
||||
options.jitEnabled = jitEnabled;
|
||||
|
||||
std::shared_ptr<AppExecFwk::EventRunner> eventRunner =
|
||||
fromAppSpawn ? AppExecFwk::EventRunner::GetMainEventRunner() : AppExecFwk::EventRunner::Create();
|
||||
@@ -282,5 +286,9 @@ sptr<AppExecFwk::IAppMgr> ChildProcessManager::GetAppMgr()
|
||||
return iface_cast<AppExecFwk::IAppMgr>(object);
|
||||
}
|
||||
|
||||
void ChildProcessManager::SetForkProcessJITEnabled(bool jitEnabled)
|
||||
{
|
||||
g_jitEnabled = jitEnabled;
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
@@ -146,7 +146,7 @@ void ChildMainThread::HandleLoadJs()
|
||||
return;
|
||||
}
|
||||
|
||||
runtime_ = childProcessManager.CreateRuntime(bundleInfoCopy, hapModuleInfo, true);
|
||||
runtime_ = childProcessManager.CreateRuntime(bundleInfoCopy, hapModuleInfo, true, processInfo_->jitEnabled);
|
||||
if (!runtime_) {
|
||||
HILOG_ERROR("Failed to create child process runtime");
|
||||
return;
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "bundle_mgr_proxy.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "child_main_thread.h"
|
||||
#include "child_process_manager.h"
|
||||
#include "configuration_convertor.h"
|
||||
#include "common_event_manager.h"
|
||||
#include "context_deal.h"
|
||||
@@ -1339,6 +1340,8 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
|
||||
options.arkNativeFilePath = bundleInfo.applicationInfo.arkNativeFilePath;
|
||||
options.uid = bundleInfo.applicationInfo.uid;
|
||||
options.apiTargetVersion = appInfo.apiTargetVersion;
|
||||
options.jitEnabled = appLaunchData.IsJITEnabled();
|
||||
AbilityRuntime::ChildProcessManager::GetInstance().SetForkProcessJITEnabled(appLaunchData.IsJITEnabled());
|
||||
if (!bundleInfo.hapModuleInfos.empty()) {
|
||||
for (auto hapModuleInfo : bundleInfo.hapModuleInfos) {
|
||||
options.hapModulePath[hapModuleInfo.moduleName] = hapModuleInfo.hapPath;
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "extract_resource_manager.h"
|
||||
#include "file_path_utils.h"
|
||||
#include "hdc_register.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "hot_reloader.h"
|
||||
@@ -612,6 +613,8 @@ void JsRuntime::PostPreload(const Options& options)
|
||||
}
|
||||
bool profileEnabled = OHOS::system::GetBoolParameter("ark.profile", false);
|
||||
postOption.SetEnableProfile(profileEnabled);
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "ASMM JIT Verify PostFork, jitEnabled: %{public}d", options.jitEnabled);
|
||||
postOption.SetEnableJIT(options.jitEnabled);
|
||||
panda::JSNApi::PostFork(vm, postOption);
|
||||
reinterpret_cast<NativeEngine*>(env)->ReinitUVLoop();
|
||||
uv_loop_s* loop = nullptr;
|
||||
@@ -772,6 +775,8 @@ bool JsRuntime::CreateJsEnv(const Options& options)
|
||||
std::string asmOpcodeDisableRange = OHOS::system::GetParameter("persist.ark.asmopcodedisablerange", "");
|
||||
pandaOption.SetEnableAsmInterpreter(asmInterpreterEnabled);
|
||||
pandaOption.SetAsmOpcodeDisableRange(asmOpcodeDisableRange);
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "ASMM JIT Verify CreateJsEnv, jitEnabled: %{public}d", options.jitEnabled);
|
||||
pandaOption.SetEnableJIT(options.jitEnabled);
|
||||
|
||||
if (IsUseAbilityRuntime(options)) {
|
||||
// aot related
|
||||
@@ -1549,6 +1554,7 @@ void JsRuntime::SetChildOptions(const Options& options)
|
||||
childOptions_->apiTargetVersion = options.apiTargetVersion;
|
||||
childOptions_->packagePathStr = options.packagePathStr;
|
||||
childOptions_->assetBasePathStr = options.assetBasePathStr;
|
||||
childOptions_->jitEnabled = options.jitEnabled;
|
||||
}
|
||||
|
||||
std::shared_ptr<Runtime::Options> JsRuntime::GetChildOptions()
|
||||
|
||||
@@ -86,6 +86,7 @@ napi_status NativeRuntimeImpl::CreateJsEnv(const Options& options, std::shared_p
|
||||
std::string asmOpcodeDisableRange = OHOS::system::GetParameter("persist.ark.asmopcodedisablerange", "");
|
||||
pandaOption.SetEnableAsmInterpreter(asmInterpreterEnabled);
|
||||
pandaOption.SetAsmOpcodeDisableRange(asmOpcodeDisableRange);
|
||||
pandaOption.SetEnableJIT(options.jitEnabled);
|
||||
|
||||
bool useAbilityRuntime = (options.isStageModel) || (options.isTestFramework);
|
||||
if (useAbilityRuntime) {
|
||||
|
||||
@@ -172,6 +172,16 @@ public:
|
||||
return perfCmd_;
|
||||
}
|
||||
|
||||
inline void SetJITEnabled(const bool jitEnabled)
|
||||
{
|
||||
jitEnabled_ = jitEnabled;
|
||||
}
|
||||
|
||||
inline bool IsJITEnabled() const
|
||||
{
|
||||
return jitEnabled_;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief read this Sequenceable object from a Parcel.
|
||||
*
|
||||
@@ -204,6 +214,7 @@ private:
|
||||
std::shared_ptr<UserTestRecord> userTestRecord_ = nullptr;
|
||||
bool debugApp_ = false;
|
||||
std::string perfCmd_;
|
||||
bool jitEnabled_ = false;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -29,6 +29,7 @@ struct ChildProcessInfo : public Parcelable {
|
||||
std::string bundleName;
|
||||
std::string processName;
|
||||
std::string srcEntry;
|
||||
bool jitEnabled = false;
|
||||
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
|
||||
@@ -97,6 +97,11 @@ bool AppLaunchData::Marshalling(Parcel &parcel) const
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!parcel.WriteBool(jitEnabled_)) {
|
||||
HILOG_ERROR("Failed to write jitEnabled.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -138,6 +143,7 @@ bool AppLaunchData::ReadFromParcel(Parcel &parcel)
|
||||
|
||||
debugApp_ = parcel.ReadBool();
|
||||
perfCmd_ = parcel.ReadString();
|
||||
jitEnabled_ = parcel.ReadBool();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ bool ChildProcessInfo::ReadFromParcel(Parcel &parcel)
|
||||
bundleName = Str16ToStr8(parcel.ReadString16());
|
||||
processName = Str16ToStr8(parcel.ReadString16());
|
||||
srcEntry = Str16ToStr8(parcel.ReadString16());
|
||||
jitEnabled = parcel.ReadBool();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -62,6 +63,7 @@ bool ChildProcessInfo::Marshalling(Parcel &parcel) const
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(bundleName));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(processName));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(srcEntry));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, jitEnabled);
|
||||
return true;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
|
||||
@@ -44,9 +44,10 @@ public:
|
||||
bool GetBundleInfo(AppExecFwk::BundleInfo &bundleInfo);
|
||||
bool GetHapModuleInfo(const AppExecFwk::BundleInfo &bundleInfo, AppExecFwk::HapModuleInfo &hapModuleInfo);
|
||||
std::unique_ptr<AbilityRuntime::Runtime> CreateRuntime(const AppExecFwk::BundleInfo &bundleInfo,
|
||||
const AppExecFwk::HapModuleInfo &hapModuleInfo, const bool fromAppSpawn);
|
||||
const AppExecFwk::HapModuleInfo &hapModuleInfo, const bool fromAppSpawn, const bool jitEnabled);
|
||||
bool LoadJsFile(const std::string &srcEntry, const AppExecFwk::HapModuleInfo &hapModuleInfo,
|
||||
std::unique_ptr<AbilityRuntime::Runtime> &runtime);
|
||||
void SetForkProcessJITEnabled(bool jitEnabled);
|
||||
|
||||
private:
|
||||
ChildProcessManager();
|
||||
|
||||
@@ -59,6 +59,7 @@ public:
|
||||
bool isJsFramework = false;
|
||||
bool isStageModel = true;
|
||||
bool isTestFramework = false;
|
||||
bool jitEnabled = false;
|
||||
int32_t uid = -1;
|
||||
// ArkTsCard start
|
||||
bool isUnique = false;
|
||||
|
||||
@@ -38,6 +38,7 @@ ohos_shared_library("libappms") {
|
||||
include_dirs = [ "${ability_runtime_services_path}/appdfr/include" ]
|
||||
sources = [
|
||||
"src/ability_running_record.cpp",
|
||||
"src/advanced_security_mode_manager.cpp",
|
||||
"src/ams_mgr_scheduler.cpp",
|
||||
"src/app_config_data_manager.cpp",
|
||||
"src/app_death_recipient.cpp",
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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_ADVANCED_SECURITY_MODE_MANAGER_H
|
||||
#define OHOS_ABILITY_RUNTIME_ADVANCED_SECURITY_MODE_MANAGER_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
class AdvancedSecurityModeManager {
|
||||
public:
|
||||
AdvancedSecurityModeManager();
|
||||
virtual ~AdvancedSecurityModeManager();
|
||||
|
||||
void Init();
|
||||
bool IsJITEnabled();
|
||||
|
||||
private:
|
||||
bool isAdvSecModeEnabled_ = false;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_ADVANCED_SECURITY_MODE_MANAGER_H
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "ability_debug_response_interface.h"
|
||||
#include "ability_foreground_state_observer_interface.h"
|
||||
#include "ability_info.h"
|
||||
#include "advanced_security_mode_manager.h"
|
||||
#include "app_death_recipient.h"
|
||||
#include "app_debug_listener_interface.h"
|
||||
#include "app_debug_manager.h"
|
||||
@@ -1254,6 +1255,8 @@ private:
|
||||
int32_t NotifyAbilitysDebugChange(const std::string &bundleName, const bool &isAppDebug);
|
||||
int32_t NotifyAbilitysAssertDebugChange(const std::shared_ptr<AppRunningRecord> &appRecord, bool isAssertDebug);
|
||||
|
||||
void SetProcessJITState(const std::shared_ptr<AppRunningRecord> appRecord);
|
||||
|
||||
bool JudgeSelfCalledByToken(const sptr<IRemoteObject> &token, const PageStateData &pageStateData);
|
||||
|
||||
void ParseServiceExtMultiProcessWhiteList();
|
||||
@@ -1329,6 +1332,7 @@ private:
|
||||
mutable std::map<int64_t, std::string> killedPorcessMap_;
|
||||
std::shared_ptr<AbilityRuntime::AppRunningStatusModule> appRunningStatusModule_;
|
||||
std::vector<std::string> serviceExtensionWhiteList_;
|
||||
std::shared_ptr<AdvancedSecurityModeManager> securityModeManager_;
|
||||
std::shared_ptr<AAFwk::TaskHandlerWrap> dfxTaskHandler_;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
|
||||
@@ -731,6 +731,9 @@ public:
|
||||
|
||||
void SetAssertionPauseFlag(bool flag);
|
||||
bool IsAssertionPause() const;
|
||||
|
||||
void SetJITEnabled(const bool jitEnabled);
|
||||
bool IsJITEnabled() const;
|
||||
private:
|
||||
/**
|
||||
* SearchTheModuleInfoNeedToUpdated, Get an uninitialized abilityStage data.
|
||||
@@ -842,6 +845,7 @@ private:
|
||||
std::string perfCmd_;
|
||||
int64_t startTimeMillis_ = 0; // The time of app start(CLOCK_MONOTONIC)
|
||||
int64_t restartTimeMillis_ = 0; // The time of last trying app restart
|
||||
bool jitEnabled_ = false;
|
||||
|
||||
std::shared_ptr<UserTestRecord> userTestRecord_ = nullptr;
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "advanced_security_mode_manager.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "parameters.h"
|
||||
#include "time_util.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
namespace {
|
||||
const std::string PARAM_GLOBAL_ADVANCED_MODE_STATE = "ohos.boot.advsecmode.state";
|
||||
}
|
||||
AdvancedSecurityModeManager::AdvancedSecurityModeManager()
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "ASMM constructor");
|
||||
}
|
||||
|
||||
AdvancedSecurityModeManager::~AdvancedSecurityModeManager()
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "ASMM deconstructor");
|
||||
}
|
||||
|
||||
void AdvancedSecurityModeManager::Init()
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
int32_t state = OHOS::system::GetIntParameter<int32_t>(PARAM_GLOBAL_ADVANCED_MODE_STATE, 0);
|
||||
isAdvSecModeEnabled_ = state > 0;
|
||||
TAG_LOGI(AAFwkTag::APPMGR, "ASMM Init isAdvSecModeEnabled:%{public}d.", isAdvSecModeEnabled_);
|
||||
}
|
||||
|
||||
bool AdvancedSecurityModeManager::IsJITEnabled()
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "ASMM IsJITEnabled %{public}d", !isAdvSecModeEnabled_);
|
||||
return !isAdvSecModeEnabled_;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
@@ -230,7 +230,8 @@ AppMgrServiceInner::AppMgrServiceInner()
|
||||
appRunningManager_(std::make_shared<AppRunningManager>()),
|
||||
configuration_(std::make_shared<Configuration>()),
|
||||
appDebugManager_(std::make_shared<AppDebugManager>()),
|
||||
appRunningStatusModule_(std::make_shared<AbilityRuntime::AppRunningStatusModule>())
|
||||
appRunningStatusModule_(std::make_shared<AbilityRuntime::AppRunningStatusModule>()),
|
||||
securityModeManager_(std::make_shared<AdvancedSecurityModeManager>())
|
||||
{}
|
||||
|
||||
void AppMgrServiceInner::Init()
|
||||
@@ -243,6 +244,9 @@ void AppMgrServiceInner::Init()
|
||||
DelayedSingleton<AppStateObserverManager>::GetInstance()->Init();
|
||||
DelayedSingleton<RenderStateObserverManager>::GetInstance()->Init();
|
||||
dfxTaskHandler_ = AAFwk::TaskHandlerWrap::CreateQueueHandler("dfx_freeze_task_queue");
|
||||
if (securityModeManager_) {
|
||||
securityModeManager_->Init();
|
||||
}
|
||||
}
|
||||
|
||||
AppMgrServiceInner::~AppMgrServiceInner()
|
||||
@@ -2227,6 +2231,7 @@ void AppMgrServiceInner::StartProcess(const std::string &appName, const std::str
|
||||
startMsg.procName = processName;
|
||||
startMsg.accessTokenIdEx = bundleInfo.applicationInfo.accessTokenIdEx;
|
||||
|
||||
SetProcessJITState(appRecord);
|
||||
PerfProfile::GetInstance().SetAppForkStartTime(GetTickCount());
|
||||
pid_t pid = 0;
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "bundleName: %{public}s.", bundleName.c_str());
|
||||
@@ -2254,6 +2259,22 @@ void AppMgrServiceInner::StartProcess(const std::string &appName, const std::str
|
||||
ProcessAppDebug(appRecord, appRecord->IsDebugApp());
|
||||
}
|
||||
|
||||
void AppMgrServiceInner::SetProcessJITState(const std::shared_ptr<AppRunningRecord> appRecord)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "SetProcessJITState called.");
|
||||
if (!appRecord) {
|
||||
HILOG_ERROR("appRecord is nullptr.");
|
||||
return;
|
||||
}
|
||||
if (!securityModeManager_) {
|
||||
HILOG_ERROR("securityModeManager_ is nullptr.");
|
||||
appRecord->SetJITEnabled(true);
|
||||
return;
|
||||
}
|
||||
appRecord->SetJITEnabled(securityModeManager_->IsJITEnabled());
|
||||
}
|
||||
|
||||
AppDebugInfo AppMgrServiceInner::MakeAppDebugInfo(
|
||||
const std::shared_ptr<AppRunningRecord> &appRecord, const bool &isDebugStart)
|
||||
{
|
||||
@@ -5404,6 +5425,7 @@ int32_t AppMgrServiceInner::GetChildProcessInfo(const std::shared_ptr<ChildProce
|
||||
info.bundleName = appRecord->GetBundleName();
|
||||
info.processName = childProcessRecord->GetProcessName();
|
||||
info.srcEntry = childProcessRecord->GetSrcEntry();
|
||||
info.jitEnabled = appRecord->IsJITEnabled();
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -431,6 +431,8 @@ void AppRunningRecord::LaunchApplication(const Configuration &config)
|
||||
launchData.SetAppIndex(appIndex_);
|
||||
launchData.SetDebugApp(isDebugApp_);
|
||||
launchData.SetPerfCmd(perfCmd_);
|
||||
launchData.SetJITEnabled(jitEnabled_);
|
||||
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "app is %{public}s.", GetName().c_str());
|
||||
appLifeCycleDeal_->LaunchApplication(launchData, config);
|
||||
}
|
||||
@@ -1976,6 +1978,16 @@ std::map<int32_t, std::shared_ptr<ChildProcessRecord>> AppRunningRecord::GetChil
|
||||
return childProcessRecordMap_;
|
||||
}
|
||||
|
||||
void AppRunningRecord::SetJITEnabled(const bool jitEnabled)
|
||||
{
|
||||
jitEnabled_ = jitEnabled;
|
||||
}
|
||||
|
||||
bool AppRunningRecord::IsJITEnabled() const
|
||||
{
|
||||
return jitEnabled_;
|
||||
}
|
||||
|
||||
int32_t AppRunningRecord::GetAssignTokenId() const
|
||||
{
|
||||
return assignTokenId_;
|
||||
|
||||
@@ -349,6 +349,7 @@ group("unittest") {
|
||||
"ability_timeout_test",
|
||||
"ability_token_proxy_test:unittest",
|
||||
"ability_token_stub_test:unittest",
|
||||
"advanced_security_mode_manager_test:unittest",
|
||||
"ams_ability_running_record_test:unittest",
|
||||
"ams_app_death_recipient_test:unittest",
|
||||
"ams_app_life_cycle_test:unittest",
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
# 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.
|
||||
|
||||
import("//build/test.gni")
|
||||
import("//foundation/ability/ability_runtime/ability_runtime.gni")
|
||||
|
||||
module_output_path = "ability_runtime/appmgrservice"
|
||||
|
||||
ohos_unittest("advanced_security_mode_manager_test") {
|
||||
module_out_path = module_output_path
|
||||
|
||||
configs = [ "${ability_runtime_services_path}/common:common_config" ]
|
||||
|
||||
include_dirs = [
|
||||
"${ability_runtime_services_path}/appmgr/include",
|
||||
"${ability_runtime_path}/utils/global/time/include",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"${ability_runtime_services_path}/appmgr/src/advanced_security_mode_manager.cpp",
|
||||
"advanced_security_mode_manager_test.cpp",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_services_path}/appmgr:libappms",
|
||||
"//third_party/googletest:gtest_main",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"init:libbegetutil",
|
||||
]
|
||||
}
|
||||
|
||||
group("unittest") {
|
||||
testonly = true
|
||||
|
||||
deps = [ ":advanced_security_mode_manager_test" ]
|
||||
}
|
||||
Executable
+73
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#define private public
|
||||
#include "advanced_security_mode_manager.h"
|
||||
#undef private
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "parameters.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
class AdvancedSecurityModeManagerTest : public testing::Test {
|
||||
public:
|
||||
void SetUp();
|
||||
void TearDown();
|
||||
|
||||
protected:
|
||||
bool deviceAdvSecModeEnabled_ = false;
|
||||
};
|
||||
|
||||
void AdvancedSecurityModeManagerTest::SetUp()
|
||||
{
|
||||
int32_t state = OHOS::system::GetIntParameter<int32_t>("ohos.boot.advsecmode.state", 0);
|
||||
deviceAdvSecModeEnabled_ = state > 0;
|
||||
}
|
||||
|
||||
void AdvancedSecurityModeManagerTest::TearDown()
|
||||
{}
|
||||
|
||||
/**
|
||||
* @tc.number: AdvancedSecurityModeManager_Init_0100
|
||||
* @tc.desc: Test Init works
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(AdvancedSecurityModeManagerTest, AdvancedSecurityModeManager_Init_0100, TestSize.Level0)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::TEST, "AdvancedSecurityModeManager_Init_0100 start.");
|
||||
auto manager = std::make_shared<AdvancedSecurityModeManager>();
|
||||
manager->Init();
|
||||
EXPECT_EQ(manager->isAdvSecModeEnabled_, deviceAdvSecModeEnabled_);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: AdvancedSecurityModeManager_IsJITEnabled_0100
|
||||
* @tc.desc: Test IsJITEnabled works
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(AdvancedSecurityModeManagerTest, AdvancedSecurityModeManager_IsJITEnabled_0100, TestSize.Level0)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::TEST, "AdvancedSecurityModeManager_IsJITEnabled_0100 start.");
|
||||
auto manager = std::make_shared<AdvancedSecurityModeManager>();
|
||||
manager->isAdvSecModeEnabled_ = true;
|
||||
EXPECT_EQ(manager->IsJITEnabled(), false);
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
@@ -28,6 +28,7 @@ ohos_unittest("AmsAbilityRunningRecordTest") {
|
||||
|
||||
sources = [
|
||||
"${ability_runtime_services_path}/appmgr/src/ability_running_record.cpp",
|
||||
"${ability_runtime_services_path}/appmgr/src/advanced_security_mode_manager.cpp",
|
||||
"${ability_runtime_services_path}/appmgr/src/app_config_data_manager.cpp",
|
||||
"${ability_runtime_services_path}/appmgr/src/app_death_recipient.cpp",
|
||||
"${ability_runtime_services_path}/appmgr/src/app_debug_manager.cpp",
|
||||
|
||||
@@ -27,6 +27,7 @@ ohos_unittest("AmsRecentAppListTest") {
|
||||
|
||||
sources = [
|
||||
"${ability_runtime_services_path}/appmgr/src/ability_running_record.cpp",
|
||||
"${ability_runtime_services_path}/appmgr/src/advanced_security_mode_manager.cpp",
|
||||
"${ability_runtime_services_path}/appmgr/src/app_config_data_manager.cpp",
|
||||
"${ability_runtime_services_path}/appmgr/src/app_death_recipient.cpp",
|
||||
"${ability_runtime_services_path}/appmgr/src/app_debug_manager.cpp",
|
||||
|
||||
@@ -31,6 +31,7 @@ ohos_unittest("AmsServiceAppSpawnClientTest") {
|
||||
|
||||
sources = [
|
||||
"${ability_runtime_services_path}/appmgr/src/ability_running_record.cpp",
|
||||
"${ability_runtime_services_path}/appmgr/src/advanced_security_mode_manager.cpp",
|
||||
"${ability_runtime_services_path}/appmgr/src/app_config_data_manager.cpp",
|
||||
"${ability_runtime_services_path}/appmgr/src/app_death_recipient.cpp",
|
||||
"${ability_runtime_services_path}/appmgr/src/app_debug_manager.cpp",
|
||||
|
||||
@@ -27,6 +27,7 @@ ohos_unittest("AmsServiceLoadAbilityProcessTest") {
|
||||
|
||||
sources = [
|
||||
"${ability_runtime_services_path}/appmgr/src/ability_running_record.cpp",
|
||||
"${ability_runtime_services_path}/appmgr/src/advanced_security_mode_manager.cpp",
|
||||
"${ability_runtime_services_path}/appmgr/src/app_config_data_manager.cpp",
|
||||
"${ability_runtime_services_path}/appmgr/src/app_death_recipient.cpp",
|
||||
"${ability_runtime_services_path}/appmgr/src/app_debug_manager.cpp",
|
||||
|
||||
@@ -29,6 +29,7 @@ ohos_unittest("AmsServiceStartupTest") {
|
||||
|
||||
sources = [
|
||||
"${ability_runtime_services_path}/appmgr/src/ability_running_record.cpp",
|
||||
"${ability_runtime_services_path}/appmgr/src/advanced_security_mode_manager.cpp",
|
||||
"${ability_runtime_services_path}/appmgr/src/app_config_data_manager.cpp",
|
||||
"${ability_runtime_services_path}/appmgr/src/app_death_recipient.cpp",
|
||||
"${ability_runtime_services_path}/appmgr/src/app_debug_manager.cpp",
|
||||
|
||||
@@ -23,6 +23,7 @@ ohos_unittest("AMSEventHandlerTest") {
|
||||
|
||||
sources = [
|
||||
"${ability_runtime_services_path}/appmgr/src/ability_running_record.cpp",
|
||||
"${ability_runtime_services_path}/appmgr/src/advanced_security_mode_manager.cpp",
|
||||
"${ability_runtime_services_path}/appmgr/src/app_config_data_manager.cpp",
|
||||
"${ability_runtime_services_path}/appmgr/src/app_death_recipient.cpp",
|
||||
"${ability_runtime_services_path}/appmgr/src/app_debug_manager.cpp",
|
||||
|
||||
@@ -28,6 +28,7 @@ ohos_unittest("AppRunningProcessesInfoTest") {
|
||||
|
||||
sources = [
|
||||
"${ability_runtime_services_path}/appmgr/src/ability_running_record.cpp",
|
||||
"${ability_runtime_services_path}/appmgr/src/advanced_security_mode_manager.cpp",
|
||||
"${ability_runtime_services_path}/appmgr/src/app_config_data_manager.cpp",
|
||||
"${ability_runtime_services_path}/appmgr/src/app_debug_manager.cpp",
|
||||
"${ability_runtime_services_path}/appmgr/src/app_mgr_service_inner.cpp",
|
||||
|
||||
@@ -1748,6 +1748,10 @@ HWTEST_F(MainThreadTest, HandleLaunchApplication_0500, TestSize.Level1)
|
||||
launchData.SetPerfCmd(perfCmd);
|
||||
EXPECT_EQ(launchData.GetPerfCmd(), perfCmd);
|
||||
|
||||
// check JIT enabled
|
||||
launchData.SetJITEnabled(true)
|
||||
EXPECT_EQ(launchData.IsJITEnabled(), true);
|
||||
|
||||
// check debug app
|
||||
bool appDebug = true;
|
||||
launchData.SetDebugApp(appDebug);
|
||||
|
||||
@@ -155,7 +155,7 @@ HWTEST_F(ChildProcessManagerTest, CreateRuntime_0100, TestSize.Level0)
|
||||
ret = ChildProcessManager::GetInstance().GetHapModuleInfo(bundleInfo, hapModuleInfo);
|
||||
EXPECT_TRUE(ret);
|
||||
|
||||
auto runtime = ChildProcessManager::GetInstance().CreateRuntime(bundleInfo, hapModuleInfo, false);
|
||||
auto runtime = ChildProcessManager::GetInstance().CreateRuntime(bundleInfo, hapModuleInfo, false, false);
|
||||
EXPECT_TRUE(runtime != nullptr);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user