mirror of
https://github.com/openharmony/bundlemanager_bundle_framework.git
synced 2026-08-25 12:50:23 -04:00
!12011 merge arktsRun1 into master
Add ArkTSRunType Created-by: dddzzzhhh Commit-by: daizihan Merged-by: openharmony_ci Description: **IssueNo**: https://gitcode.com/openharmony/arkcompiler_ets_frontend/issues/11953 **Description**: **稳定性自检:** | 自检项 | 自检结果 | | ------------------------------------------------------------ | -------- | | 涉及跨进程调用的相关操作需要抛至主线程或加锁防止并发 | | | 成员变量进行赋值或创建需要排查并发 | | | 谨慎在lambda表达式中使用引用捕获 | | | 谨慎在未经拷贝的情况下使用外部传入的string、C字符串 | | | map\vector\list\set等stl模板类使用时需要排查并发 | | | 谨慎考虑加锁范围 | | | 在IPC通信中谨慎使用同步通信方式 | | | 禁止传递this指针至其他模块或线程(特别是eventhandler任务) | | | 禁止将外部传入的裸指针在内部直接构造智能指针 | | | 禁止多个独立创建的智能指针管理同一地址 | | | 禁止在析构函数中抛异步任务 | | | 禁止js对象在非js线程(例如在IPC线程)创建、使用或销毁 | | | 禁止在对外接口中未经判空直接使用外部传入的指针 | | | 禁止接口返回局部变量引用 | | | 禁止在信号函数中加锁 | | | 禁止在关键流程(SA启动、应用启动等主流程)执行耗时的操作 | | | 禁止将同一个cpp编译在不同的so中 | | **安全编码自检:** | 自检项 | 自检结果 | | -------------------------------------------------------------- | -------- | | 裸指针避免通过隐式转换构造为sptr | | | json对象在取值之前必须先判断类型,避免类型不匹配 | | | 序列化时必须对传入的数组大小进行校验,避免出现超大数组 | | | 避免使用未明确位宽的整型,选择使用int8_t、uint8_t等类型 | | | 外部传入的路径要做规范化校验,对路径中的.、..、../等特殊字符严格校验 | | | 指针变量、表示资源描述符的变量、bool变量必须赋初值 | | | readParcelable获取的对象使用前需要判空 | | | 分配和释放内存的函数需要成对出现 | | | 申请内存后异常退出前需要及时进行内存释放 | | | 内存申请前必须对内存大小进行合法性校验 | | | 内存分配后必须判断是否成功 | | | 禁止使用realloc、alloca函数 | | | 禁止打印文件路径、口令等敏感信息,如有需要,使用private修饰 | | | 禁止打印内存地址 | | | 整数之间运算时必须严格检查,确保不会出现溢出、反转、除0 | | | 禁止对有符号整数进行位操作符运算 | | | 禁止对指针进行逻辑或位运算 | | | 循环次数如果收外部数据控制,需要检验其合法性 | | | 禁止使用内存操作类危险函数,需要使用安全函数 | | | 谨慎使用不可重入函数 | | | 必须检查安全函数的返回值,并进行正确处理 | | | 禁止仅通过TokenType类型判断绕过权限校验 | | **TDD Result**: **XTS Result**: ### 是否已执行L0用例 - [ ] 已验证 - [ ] 不涉及。如不涉及,请写明理由 See merge request: openharmony/bundlemanager_bundle_framework!12011
This commit is contained in:
@@ -266,6 +266,7 @@ constexpr const char* DEVICE_MODE_DISTRIBUTION_POLICY_KEY = "ohos.bms.param.devi
|
||||
|
||||
constexpr const char* ARKTS_MODE = "arkTSMode";
|
||||
constexpr const char* MODULE_ARKTS_MODE = "moduleArkTSMode";
|
||||
constexpr const char* ARKTS_RUN_TYPE = "arkTSRunType";
|
||||
constexpr const char* AOT_COMPILE_STATUS = "aotCompileStatus";
|
||||
constexpr const char* ARKTS_MODE_DYNAMIC = "dynamic";
|
||||
constexpr const char* ARKTS_MODE_STATIC = "static";
|
||||
|
||||
@@ -1937,6 +1937,18 @@ void from_json(const nlohmann::json &jsonObject, Module &module)
|
||||
module.moduleArkTSMode,
|
||||
false,
|
||||
g_parseResult);
|
||||
std::string arkTSRunType = module.moduleArkTSMode;
|
||||
BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
|
||||
jsonObjectEnd,
|
||||
Constants::ARKTS_RUN_TYPE,
|
||||
arkTSRunType,
|
||||
false,
|
||||
g_parseResult);
|
||||
// In API version 23 and earlier, arkTSRunType may differ from moduleArkTSMode.
|
||||
// Starting from API version 24, the two fields have the same value.
|
||||
if (!arkTSRunType.empty() && arkTSRunType != module.moduleArkTSMode) {
|
||||
module.moduleArkTSMode = arkTSRunType;
|
||||
}
|
||||
BMSJsonUtil::GetStrValueIfFindKey(jsonObject,
|
||||
jsonObjectEnd,
|
||||
Constants::ARKTS_MODE,
|
||||
|
||||
+138
-1
@@ -1902,6 +1902,51 @@ const nlohmann::json MODULE_JSON_16 = R"(
|
||||
}
|
||||
})"_json;
|
||||
|
||||
const nlohmann::json MODULE_JSON_17 = R"(
|
||||
{
|
||||
"app": {
|
||||
"bundleName": "com.example.arktsruntest",
|
||||
"debug": true,
|
||||
"icon": "$media:app_icon",
|
||||
"iconId": 16777220,
|
||||
"label": "$string:app_name",
|
||||
"labelId": 16777216,
|
||||
"minAPIVersion": 9,
|
||||
"minMinorAPIVersion": 0,
|
||||
"minPatchAPIVersion": 0,
|
||||
"targetAPIVersion": 9,
|
||||
"vendor": "example",
|
||||
"versionCode": 1000000,
|
||||
"versionName": "1.0.0"
|
||||
},
|
||||
"module": {
|
||||
"deliveryWithInstall": true,
|
||||
"description": "$string:entry_desc",
|
||||
"descriptionId": 16777219,
|
||||
"deviceTypes": ["default"],
|
||||
"abilities": [{
|
||||
"description": "$string:MainAbility_desc",
|
||||
"descriptionId": 16777217,
|
||||
"icon": "$media:icon",
|
||||
"iconId": 16777221,
|
||||
"label": "$string:MainAbility_label",
|
||||
"labelId": 16777218,
|
||||
"name": "MainAbility",
|
||||
"launchType": "unknowlaunchType",
|
||||
"orientation": "unknoworientation",
|
||||
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
|
||||
"visible": true
|
||||
}],
|
||||
"name": "entry",
|
||||
"installationFree": false,
|
||||
"mainElement": "MainAbility",
|
||||
"pages": "$profile:main_pages",
|
||||
"srcEntrance": "./ets/Application/AbilityStage.ts",
|
||||
"type": "entry",
|
||||
"virtualMachine": "ark0.0.0.3"
|
||||
}
|
||||
})"_json;
|
||||
|
||||
InnerBundleInfo CreateInnerBundleInfoForTest(const std::string &bundleName,
|
||||
const std::string &modulePackage, const std::string &moduleName, int32_t userId, int32_t uid)
|
||||
{
|
||||
@@ -6884,6 +6929,98 @@ HWTEST_F(BmsBundleParserTest, to_json_sceneAnimationParams, Function | MediumTes
|
||||
EXPECT_EQ(jsonObject["sceneAnimationParams"]["abilityName"], "testAbilityName");
|
||||
EXPECT_EQ(jsonObject["sceneAnimationParams"]["disabledDesktopBehaviors"], "PULL_DOWN_SEARCH|LONG_CLICK");
|
||||
EXPECT_EQ(jsonObject["sceneAnimationParams"]["triggerTypes"].size(), 1);
|
||||
EXPECT_EQ(jsonObject["sceneAnimationParams"]["triggerTypes"][0], SceneAnimationTriggerType::SHAKE);
|
||||
EXPECT_EQ(jsonObject["sceneAnimationParams"]["triggerTypes"][0], SceneAnimationTriggerType::SHAKE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: TransformTo_arkTSRunType_0100
|
||||
* @tc.name: arkTSRunType differs from moduleArkTSMode
|
||||
* @tc.desc: moduleArkTSMode=dynamic, arkTSRunType=static → overwritten to static
|
||||
*/
|
||||
HWTEST_F(BmsBundleParserTest, TransformTo_arkTSRunType_0100, Function | SmallTest | Level1)
|
||||
{
|
||||
nlohmann::json profileJson = MODULE_JSON_17;
|
||||
profileJson["module"]["moduleArkTSMode"] = "dynamic";
|
||||
profileJson["module"]["arkTSRunType"] = "static";
|
||||
ModuleProfile moduleProfile;
|
||||
InnerBundleInfo innerBundleInfo;
|
||||
std::ostringstream profileFileBuffer;
|
||||
profileFileBuffer << profileJson.dump();
|
||||
BundleExtractor bundleExtractor(EMPTY_NAME);
|
||||
ErrCode result = moduleProfile.TransformTo(
|
||||
profileFileBuffer, bundleExtractor, innerBundleInfo);
|
||||
EXPECT_EQ(result, ERR_OK) << profileFileBuffer.str();
|
||||
auto iter = innerBundleInfo.innerModuleInfos_.find("entry");
|
||||
ASSERT_NE(iter, innerBundleInfo.innerModuleInfos_.end());
|
||||
EXPECT_EQ(iter->second.moduleArkTSMode, Constants::ARKTS_MODE_STATIC);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: TransformTo_arkTSRunType_0200
|
||||
* @tc.name: arkTSRunType is same as moduleArkTSMode
|
||||
* @tc.desc: both dynamic → moduleArkTSMode remains dynamic
|
||||
*/
|
||||
HWTEST_F(BmsBundleParserTest, TransformTo_arkTSRunType_0200, Function | SmallTest | Level1)
|
||||
{
|
||||
nlohmann::json profileJson = MODULE_JSON_17;
|
||||
profileJson["module"]["moduleArkTSMode"] = "dynamic";
|
||||
profileJson["module"]["arkTSRunType"] = "dynamic";
|
||||
ModuleProfile moduleProfile;
|
||||
InnerBundleInfo innerBundleInfo;
|
||||
std::ostringstream profileFileBuffer;
|
||||
profileFileBuffer << profileJson.dump();
|
||||
BundleExtractor bundleExtractor(EMPTY_NAME);
|
||||
ErrCode result = moduleProfile.TransformTo(
|
||||
profileFileBuffer, bundleExtractor, innerBundleInfo);
|
||||
EXPECT_EQ(result, ERR_OK) << profileFileBuffer.str();
|
||||
auto iter = innerBundleInfo.innerModuleInfos_.find("entry");
|
||||
ASSERT_NE(iter, innerBundleInfo.innerModuleInfos_.end());
|
||||
EXPECT_EQ(iter->second.moduleArkTSMode, Constants::ARKTS_MODE_DYNAMIC);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: TransformTo_arkTSRunType_0300
|
||||
* @tc.name: arkTSRunType is empty string
|
||||
* @tc.desc: moduleArkTSMode=static, arkTSRunType="" → not overwritten
|
||||
*/
|
||||
HWTEST_F(BmsBundleParserTest, TransformTo_arkTSRunType_0300, Function | SmallTest | Level1)
|
||||
{
|
||||
nlohmann::json profileJson = MODULE_JSON_17;
|
||||
profileJson["module"]["moduleArkTSMode"] = "static";
|
||||
profileJson["module"]["arkTSRunType"] = "";
|
||||
ModuleProfile moduleProfile;
|
||||
InnerBundleInfo innerBundleInfo;
|
||||
std::ostringstream profileFileBuffer;
|
||||
profileFileBuffer << profileJson.dump();
|
||||
BundleExtractor bundleExtractor(EMPTY_NAME);
|
||||
ErrCode result = moduleProfile.TransformTo(
|
||||
profileFileBuffer, bundleExtractor, innerBundleInfo);
|
||||
EXPECT_EQ(result, ERR_OK) << profileFileBuffer.str();
|
||||
auto iter = innerBundleInfo.innerModuleInfos_.find("entry");
|
||||
ASSERT_NE(iter, innerBundleInfo.innerModuleInfos_.end());
|
||||
EXPECT_EQ(iter->second.moduleArkTSMode, Constants::ARKTS_MODE_STATIC);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.number: TransformTo_arkTSRunType_0400
|
||||
* @tc.name: arkTSRunType is absent
|
||||
* @tc.desc: moduleArkTSMode=dynamic, arkTSRunType key not present → remains dynamic
|
||||
*/
|
||||
HWTEST_F(BmsBundleParserTest, TransformTo_arkTSRunType_0400, Function | SmallTest | Level1)
|
||||
{
|
||||
nlohmann::json profileJson = MODULE_JSON_17;
|
||||
profileJson["module"]["moduleArkTSMode"] = "dynamic";
|
||||
ModuleProfile moduleProfile;
|
||||
InnerBundleInfo innerBundleInfo;
|
||||
std::ostringstream profileFileBuffer;
|
||||
profileFileBuffer << profileJson.dump();
|
||||
BundleExtractor bundleExtractor(EMPTY_NAME);
|
||||
ErrCode result = moduleProfile.TransformTo(
|
||||
profileFileBuffer, bundleExtractor, innerBundleInfo);
|
||||
EXPECT_EQ(result, ERR_OK) << profileFileBuffer.str();
|
||||
auto iter = innerBundleInfo.innerModuleInfos_.find("entry");
|
||||
ASSERT_NE(iter, innerBundleInfo.innerModuleInfos_.end());
|
||||
EXPECT_EQ(iter->second.moduleArkTSMode, Constants::ARKTS_MODE_DYNAMIC);
|
||||
}
|
||||
|
||||
} // OHOS
|
||||
Reference in New Issue
Block a user