diff --git a/ability_runtime.gni b/ability_runtime.gni index f1e7e09bbd..648264530e 100644 --- a/ability_runtime.gni +++ b/ability_runtime.gni @@ -18,6 +18,7 @@ ability_runtime_napi_path = "${ability_runtime_path}/frameworks/js/napi" ability_base_path = "//foundation/ability/ability_base" form_fwk_path = "//foundation/ability/form_fwk" ability_runtime_innerkits_path = "${ability_runtime_path}/interfaces/inner_api" +ability_runtime_ndk_path = "${ability_runtime_path}/interfaces/kits/c" ability_runtime_native_path = "${ability_runtime_path}/frameworks/native" ability_runtime_services_path = "${ability_runtime_path}/services" ability_runtime_abilitymgr_path = "${ability_runtime_services_path}/abilitymgr" diff --git a/bundle.json b/bundle.json index acdff4338e..090d7539de 100644 --- a/bundle.json +++ b/bundle.json @@ -106,6 +106,7 @@ "//foundation/ability/ability_runtime/interfaces/inner_api:innerkits_target", "//foundation/ability/ability_runtime/frameworks/native/ability/native:ability_thread", "//foundation/ability/ability_runtime/frameworks/native/ability/native:extension_module", + "//foundation/ability/ability_runtime/frameworks/native/child_process:child_process", "//foundation/ability/ability_runtime/frameworks/native/insight_intent:insight_intent_innerkits", "//foundation/ability/ability_runtime/frameworks/js/napi:napi_packages", "//foundation/ability/ability_runtime/cj_environment/frameworks/cj_environment:cj_environment", @@ -314,6 +315,15 @@ }, "name": "//foundation/ability/ability_runtime/frameworks/native/appkit:app_context" }, + { + "header": { + "header_base": "//foundation/ability/ability_runtime/interfaces/kits/c/ability/ability_runtime/child_process", + "header_files": [ + "native_child_process.h" + ] + }, + "name": "//foundation/ability/ability_runtime/frameworks/native/child_process:child_process" + }, { "header": { "header_base": "//foundation/ability/ability_runtime/interfaces/inner_api/uri_permission/include/", @@ -430,6 +440,23 @@ ] }, "name": "//foundation/ability/ability_runtime/interfaces/inner_api/auto_fill_manager:auto_fill_manager" + }, + { + "header": { + "header_base": "//foundation/ability/ability_runtime/interfaces/inner_api/ability_manager/include", + "header_files": [ + "start_options.h" + ] + }, + "name": "//foundation/ability/ability_runtime/interfaces/inner_api/ability_manager:ability_start_options" + }, + { + "header": { + "header_base": "//foundation/ability/ability_runtime/interfaces/kits/native/ability/native/dialog_request_callback", + "header_files": [ + ] + }, + "name": "//foundation/ability/ability_runtime/frameworks/native/ability/native:dialog_request_callback" } ], "test": [ diff --git a/frameworks/js/napi/ability_auto_startup_callback/BUILD.gn b/frameworks/js/napi/ability_auto_startup_callback/BUILD.gn index 525f5f723e..f957a2049e 100644 --- a/frameworks/js/napi/ability_auto_startup_callback/BUILD.gn +++ b/frameworks/js/napi/ability_auto_startup_callback/BUILD.gn @@ -27,6 +27,7 @@ ohos_shared_library("autostartupcallback") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/error_utils:ability_runtime_error_util", "${ability_runtime_innerkits_path}/runtime:runtime", diff --git a/frameworks/js/napi/ability_auto_startup_manager/BUILD.gn b/frameworks/js/napi/ability_auto_startup_manager/BUILD.gn index 498cc8e7b8..f1959c8b48 100644 --- a/frameworks/js/napi/ability_auto_startup_manager/BUILD.gn +++ b/frameworks/js/napi/ability_auto_startup_manager/BUILD.gn @@ -31,6 +31,7 @@ ohos_shared_library("autostartupmanager") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/error_utils:ability_runtime_error_util", "${ability_runtime_innerkits_path}/runtime:runtime", diff --git a/frameworks/js/napi/ability_manager/BUILD.gn b/frameworks/js/napi/ability_manager/BUILD.gn index 3c499c42d3..2c4d636bcb 100644 --- a/frameworks/js/napi/ability_manager/BUILD.gn +++ b/frameworks/js/napi/ability_manager/BUILD.gn @@ -33,6 +33,7 @@ template("abilitymanager") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/napi_base_context:napi_base_context", "${ability_runtime_innerkits_path}/runtime:runtime", diff --git a/frameworks/js/napi/app/app_manager/BUILD.gn b/frameworks/js/napi/app/app_manager/BUILD.gn index 4e371b4c55..f88d33ccb9 100644 --- a/frameworks/js/napi/app/app_manager/BUILD.gn +++ b/frameworks/js/napi/app/app_manager/BUILD.gn @@ -32,6 +32,7 @@ ohos_shared_library("appmanager_napi") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", diff --git a/frameworks/js/napi/app/application_context/application_context.js b/frameworks/js/napi/app/application_context/application_context.js index 885d37f8e8..5c12391586 100644 --- a/frameworks/js/napi/app/application_context/application_context.js +++ b/frameworks/js/napi/app/application_context/application_context.js @@ -189,6 +189,10 @@ class ApplicationContext { return this.__context_impl__.setSupportedProcessCache(isSupport); } + getCurrentAppCloneIndex(){ + return this.__context_impl__.getCurrentAppCloneIndex() + } + set area(mode) { return this.__context_impl__.switchArea(mode); } diff --git a/frameworks/js/napi/app/error_manager/BUILD.gn b/frameworks/js/napi/app/error_manager/BUILD.gn index 8949155520..549a7041f7 100644 --- a/frameworks/js/napi/app/error_manager/BUILD.gn +++ b/frameworks/js/napi/app/error_manager/BUILD.gn @@ -34,6 +34,7 @@ template("errormanager") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_native_path}/appkit:appkit_native", diff --git a/frameworks/js/napi/app/js_app_manager/BUILD.gn b/frameworks/js/napi/app/js_app_manager/BUILD.gn index 7f9e7601b1..61a3b604aa 100644 --- a/frameworks/js/napi/app/js_app_manager/BUILD.gn +++ b/frameworks/js/napi/app/js_app_manager/BUILD.gn @@ -37,6 +37,7 @@ ohos_shared_library("appmanager") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/error_utils:ability_runtime_error_util", "${ability_runtime_innerkits_path}/runtime:runtime", diff --git a/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp b/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp index add1fc82bf..9d1082f85f 100644 --- a/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp +++ b/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp @@ -110,6 +110,11 @@ public: GET_CB_INFO_AND_CALL(env, info, JsAppManager, OnIsRunningInStabilityTest); } + static napi_value GetRunningMultiAppInfo(napi_env env, napi_callback_info info) + { + GET_CB_INFO_AND_CALL(env, info, JsAppManager, OnGetRunningMultiAppInfo); + } + static napi_value KillProcessWithAccount(napi_env env, napi_callback_info info) { GET_CB_INFO_AND_CALL(env, info, JsAppManager, OnKillProcessWithAccount); @@ -640,6 +645,52 @@ private: return result; } + napi_value OnGetRunningMultiAppInfo(napi_env env, size_t argc, napi_value* argv) + { + TAG_LOGD(AAFwkTag::APPMGR, "called"); + if (!CheckCallerIsSystemApp()) { + TAG_LOGE(AAFwkTag::APPMGR, "Current app is not system app"); + ThrowError(env, AbilityErrorCode::ERROR_CODE_NOT_SYSTEM_APP); + return CreateJsUndefined(env); + } + // only support 1 params + if (argc < ARGC_ONE) { + TAG_LOGE(AAFwkTag::APPMGR, "Not enough arguments"); + ThrowTooFewParametersError(env); + return CreateJsUndefined(env); + } + std::string bundleName; + if (!ConvertFromJsValue(env, argv[0], bundleName)) { + TAG_LOGE(AAFwkTag::APPMGR, "get bundleName failed!"); + ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string"); + return CreateJsUndefined(env); + } + auto info = std::make_shared(); + auto innerErrorCode = std::make_shared(ERR_OK); + NapiAsyncTask::ExecuteCallback execute = + [appManager = appManager_, bundleName, innerErrorCode, info]() { + if (appManager == nullptr) { + TAG_LOGW(AAFwkTag::APPMGR, "appManager nullptr"); + *innerErrorCode = static_cast(AbilityErrorCode::ERROR_CODE_INNER); + return; + } + *innerErrorCode = appManager->GetRunningMultiAppInfoByBundleName(bundleName, *info); + }; + NapiAsyncTask::CompleteCallback complete = + [innerErrorCode, info](napi_env env, NapiAsyncTask &task, int32_t status) { + if (*innerErrorCode == ERR_OK) { + task.ResolveWithNoError(env, CreateJsRunningMultiAppInfo(env, *info)); + } else { + task.Reject(env, CreateJsErrorByNativeErr(env, *innerErrorCode)); + } + }; + napi_value lastParam = nullptr; + napi_value result = nullptr; + NapiAsyncTask::ScheduleHighQos("JSAppManager::OnGetRunningMultiAppInfo", + env, CreateAsyncTaskWithLastParam(env, lastParam, std::move(execute), std::move(complete), &result)); + return result; + } + napi_value OnGetRunningProcessInformationByBundleType(napi_env env, size_t argc, napi_value* argv) { TAG_LOGD(AAFwkTag::APPMGR, "called"); @@ -694,7 +745,7 @@ private: return; } bool ret = abilityManager->IsRunningInStabilityTest(); - TAG_LOGI(AAFwkTag::APPMGR, "result:%{public}d", ret); + TAG_LOGD(AAFwkTag::APPMGR, "result:%{public}d", ret); task.ResolveWithNoError(env, CreateJsValue(env, ret)); }; @@ -1176,20 +1227,15 @@ napi_value JsAppManagerInit(napi_env env, napi_value exportObj) JsAppManager::KillProcessesByBundleName); BindNativeFunction(env, exportObj, "clearUpApplicationData", moduleName, JsAppManager::ClearUpApplicationData); - BindNativeFunction(env, exportObj, "getAppMemorySize", moduleName, - JsAppManager::GetAppMemorySize); - BindNativeFunction(env, exportObj, "isRamConstrainedDevice", moduleName, - JsAppManager::IsRamConstrainedDevice); - BindNativeFunction(env, exportObj, "isSharedBundleRunning", moduleName, - JsAppManager::IsSharedBundleRunning); - BindNativeFunction(env, exportObj, "getProcessMemoryByPid", moduleName, - JsAppManager::GetProcessMemoryByPid); + BindNativeFunction(env, exportObj, "getAppMemorySize", moduleName, JsAppManager::GetAppMemorySize); + BindNativeFunction(env, exportObj, "isRamConstrainedDevice", moduleName, JsAppManager::IsRamConstrainedDevice); + BindNativeFunction(env, exportObj, "isSharedBundleRunning", moduleName, JsAppManager::IsSharedBundleRunning); + BindNativeFunction(env, exportObj, "getProcessMemoryByPid", moduleName, JsAppManager::GetProcessMemoryByPid); BindNativeFunction(env, exportObj, "getRunningProcessInfoByBundleName", moduleName, JsAppManager::GetRunningProcessInfoByBundleName); - BindNativeFunction(env, exportObj, "isApplicationRunning", moduleName, - JsAppManager::IsApplicationRunning); - BindNativeFunction(env, exportObj, "preloadApplication", moduleName, - JsAppManager::PreloadApplication); + BindNativeFunction(env, exportObj, "getRunningMultiAppInfo", moduleName, JsAppManager::GetRunningMultiAppInfo); + BindNativeFunction(env, exportObj, "isApplicationRunning", moduleName, JsAppManager::IsApplicationRunning); + BindNativeFunction(env, exportObj, "preloadApplication", moduleName, JsAppManager::PreloadApplication); BindNativeFunction(env, exportObj, "getRunningProcessInformationByBundleType", moduleName, JsAppManager::GetRunningProcessInformationByBundleType); TAG_LOGD(AAFwkTag::APPMGR, "end"); diff --git a/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.cpp b/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.cpp index 7bc476e546..6ea784dc13 100644 --- a/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.cpp +++ b/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.cpp @@ -150,6 +150,47 @@ napi_value CreateJsRunningProcessInfo(napi_env env, const RunningProcessInfo &in return object; } +napi_value CreateJsRunningMultiAppInfo(napi_env env, const RunningMultiAppInfo &info) +{ + napi_value object = nullptr; + napi_create_object(env, &object); + if (object == nullptr) { + TAG_LOGE(AAFwkTag::APPMGR, "objValue nullptr."); + return nullptr; + } + napi_set_named_property(env, object, "bundleName", CreateJsValue(env, info.bundleName)); + napi_set_named_property(env, object, "mode", CreateJsValue(env, info.mode)); + napi_set_named_property(env, object, "runningAppClones", CreateJsRunningAppCloneArray(env, info.runningAppClones)); + + return object; +} + +napi_value CreateJsRunningAppCloneArray(napi_env env, const std::vector& data) +{ + napi_value arrayValue = nullptr; + napi_create_array_with_length(env, data.size(), &arrayValue); + uint32_t index = 0; + for (const auto &item : data) { + napi_set_element(env, arrayValue, index++, CreateJsRunningAppClone(env, item)); + } + return arrayValue; +} + +napi_value CreateJsRunningAppClone(napi_env env, const RunningAppClone &info) +{ + napi_value object = nullptr; + napi_create_object(env, &object); + if (object == nullptr) { + TAG_LOGE(AAFwkTag::APPMGR, "objValue nullptr."); + return nullptr; + } + napi_set_named_property(env, object, "appCloneIndex", CreateJsValue(env, info.appCloneIndex)); + napi_set_named_property(env, object, "uid", CreateJsValue(env, info.uid)); + napi_set_named_property(env, object, "pids", CreateNativeArray(env, info.pids)); + + return object; +} + napi_value ApplicationStateInit(napi_env env) { TAG_LOGD(AAFwkTag::APPMGR, "ApplicationStateInit enter"); diff --git a/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.h b/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.h index 4bb29199cc..e2d0ad9297 100644 --- a/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.h +++ b/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.h @@ -19,6 +19,7 @@ #include "application_state_observer_stub.h" #include "native_engine/native_engine.h" #include "running_process_info.h" +#include "running_multi_info.h" #ifdef SUPPORT_GRAPHICS #include "ability_first_frame_state_data.h" #endif @@ -29,6 +30,8 @@ using OHOS::AppExecFwk::AppStateData; using OHOS::AppExecFwk::AbilityStateData; using OHOS::AppExecFwk::ProcessData; using OHOS::AppExecFwk::RunningProcessInfo; +using OHOS::AppExecFwk::RunningMultiAppInfo; +using OHOS::AppExecFwk::RunningAppClone; #ifdef SUPPORT_GRAPHICS using OHOS::AppExecFwk::AbilityFirstFrameStateData; #endif @@ -63,6 +66,9 @@ bool ConvertPreloadApplicationParam(napi_env env, size_t argc, napi_value *argv, std::string &errorMsg); JsAppProcessState ConvertToJsAppProcessState( const AppExecFwk::AppProcessState &appProcessState, const bool &isFocused); +napi_value CreateJsRunningMultiAppInfo(napi_env env, const RunningMultiAppInfo &info); +napi_value CreateJsRunningAppCloneArray(napi_env env, const std::vector& data); +napi_value CreateJsRunningAppClone(napi_env env, const RunningAppClone &info); } // namespace AbilityRuntime } // namespace OHOS #endif // OHOS_ABILITY_RUNTIME_JS_APP_MANAGER_UTILS_H diff --git a/frameworks/js/napi/app/recovery/BUILD.gn b/frameworks/js/napi/app/recovery/BUILD.gn index 27e1be5244..86a45387b1 100644 --- a/frameworks/js/napi/app/recovery/BUILD.gn +++ b/frameworks/js/napi/app/recovery/BUILD.gn @@ -32,6 +32,7 @@ ohos_shared_library("apprecovery_napi") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", diff --git a/frameworks/js/napi/featureAbility/BUILD.gn b/frameworks/js/napi/featureAbility/BUILD.gn index b150fc5732..7470b9ac80 100644 --- a/frameworks/js/napi/featureAbility/BUILD.gn +++ b/frameworks/js/napi/featureAbility/BUILD.gn @@ -27,6 +27,7 @@ ohos_shared_library("featureability") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:ability_start_setting", "${ability_runtime_innerkits_path}/dataobs_manager:dataobs_manager", "${ability_runtime_innerkits_path}/napi_base_context:napi_base_context", diff --git a/frameworks/js/napi/inner/napi_ability_common/BUILD.gn b/frameworks/js/napi/inner/napi_ability_common/BUILD.gn index 3017b49183..d76f8bae2e 100644 --- a/frameworks/js/napi/inner/napi_ability_common/BUILD.gn +++ b/frameworks/js/napi/inner/napi_ability_common/BUILD.gn @@ -32,6 +32,7 @@ ohos_shared_library("napi_ability_common") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:ability_start_setting", "${ability_runtime_innerkits_path}/napi_base_context:napi_base_context", "${ability_runtime_innerkits_path}/runtime:runtime", diff --git a/frameworks/js/napi/inner/napi_common/BUILD.gn b/frameworks/js/napi/inner/napi_common/BUILD.gn index de57564b9d..cbc06d8d9f 100644 --- a/frameworks/js/napi/inner/napi_common/BUILD.gn +++ b/frameworks/js/napi/inner/napi_common/BUILD.gn @@ -42,6 +42,7 @@ ohos_shared_library("napi_common") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:process_options", "${ability_runtime_innerkits_path}/runtime:runtime", ] diff --git a/frameworks/js/napi/inner/napi_common/napi_common_want.cpp b/frameworks/js/napi/inner/napi_common/napi_common_want.cpp index 74568fa6bd..b13a069837 100644 --- a/frameworks/js/napi/inner/napi_common/napi_common_want.cpp +++ b/frameworks/js/napi/inner/napi_common/napi_common_want.cpp @@ -86,6 +86,14 @@ napi_value WrapElementName(napi_env env, const ElementName &elementName) NAPI_CALL(env, napi_create_string_utf8(env, elementName.GetModuleName().c_str(), NAPI_AUTO_LENGTH, &jsValue)); NAPI_CALL(env, napi_set_named_property(env, jsObject, "moduleName", jsValue)); + jsValue = nullptr; + NAPI_CALL(env, napi_create_string_utf8(env, elementName.GetShortName().c_str(), NAPI_AUTO_LENGTH, &jsValue)); + NAPI_CALL(env, napi_set_named_property(env, jsObject, "shortName", jsValue)); + + jsValue = nullptr; + NAPI_CALL(env, napi_create_string_utf8(env, elementName.GetUri().c_str(), NAPI_AUTO_LENGTH, &jsValue)); + NAPI_CALL(env, napi_set_named_property(env, jsObject, "uri", jsValue)); + return jsObject; } diff --git a/frameworks/js/napi/insight_intent/insight_intent_driver/BUILD.gn b/frameworks/js/napi/insight_intent/insight_intent_driver/BUILD.gn index d7c8410cac..d8b47e45fa 100644 --- a/frameworks/js/napi/insight_intent/insight_intent_driver/BUILD.gn +++ b/frameworks/js/napi/insight_intent/insight_intent_driver/BUILD.gn @@ -25,6 +25,7 @@ ohos_shared_library("insightintentdriver_napi") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", "${ability_runtime_native_path}/ability/native:ability_business_error", diff --git a/frameworks/js/napi/js_dialog_session/BUILD.gn b/frameworks/js/napi/js_dialog_session/BUILD.gn index 19e7a4e7ed..1e92d32013 100644 --- a/frameworks/js/napi/js_dialog_session/BUILD.gn +++ b/frameworks/js/napi/js_dialog_session/BUILD.gn @@ -27,6 +27,7 @@ ohos_shared_library("dialogsession_napi") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", "${ability_runtime_native_path}/appkit:app_context", diff --git a/frameworks/js/napi/js_dialog_session/js_dialog_session_utils.cpp b/frameworks/js/napi/js_dialog_session/js_dialog_session_utils.cpp index 6ce7948f5b..a67fcee65f 100644 --- a/frameworks/js/napi/js_dialog_session/js_dialog_session_utils.cpp +++ b/frameworks/js/napi/js_dialog_session/js_dialog_session_utils.cpp @@ -66,6 +66,8 @@ napi_value WrapDialogAbilityInfo(napi_env env, const AAFwk::DialogAbilityInfo &d SetPropertyValueByPropertyName(env, jsObject, "abilityIconId", jsValue); jsValue = WrapInt32ToJS(env, dialogAbilityInfo.abilityLabelId); SetPropertyValueByPropertyName(env, jsObject, "abilityLabelId", jsValue); + jsValue = WrapBoolToJS(env, dialogAbilityInfo.visible); + SetPropertyValueByPropertyName(env, jsObject, "visible", jsValue); return jsObject; } diff --git a/frameworks/js/napi/js_mission_manager/BUILD.gn b/frameworks/js/napi/js_mission_manager/BUILD.gn index f501ff6223..2353569778 100755 --- a/frameworks/js/napi/js_mission_manager/BUILD.gn +++ b/frameworks/js/napi/js_mission_manager/BUILD.gn @@ -28,6 +28,7 @@ ohos_shared_library("missionmanager") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:mission_info", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", diff --git a/frameworks/js/napi/js_mission_manager/mission_manager.cpp b/frameworks/js/napi/js_mission_manager/mission_manager.cpp index dcad35035d..fd4ae855a1 100755 --- a/frameworks/js/napi/js_mission_manager/mission_manager.cpp +++ b/frameworks/js/napi/js_mission_manager/mission_manager.cpp @@ -434,10 +434,15 @@ private: napi_create_object(env, &object); napi_value abilityObj = nullptr; napi_create_object(env, &abilityObj); + std::string defalutValue = ""; + napi_set_named_property(env, abilityObj, "deviceId", CreateJsValue(env, defalutValue)); napi_set_named_property(env, abilityObj, "bundleName", CreateJsValue(env, snapshotWrap->missionSnapshot.topAbility.GetBundleName())); napi_set_named_property(env, abilityObj, "abilityName", CreateJsValue(env, snapshotWrap->missionSnapshot.topAbility.GetAbilityName())); + napi_set_named_property(env, abilityObj, "moduleName", CreateJsValue(env, defalutValue)); + napi_set_named_property(env, abilityObj, "shortName", CreateJsValue(env, defalutValue)); + napi_set_named_property(env, abilityObj, "uri", CreateJsValue(env, defalutValue)); napi_set_named_property(env, object, "ability", abilityObj); #ifdef SUPPORT_GRAPHICS auto snapshotValue = Media::PixelMapNapi::CreatePixelMap( diff --git a/frameworks/js/napi/mission_manager/BUILD.gn b/frameworks/js/napi/mission_manager/BUILD.gn index ef94b19dd4..63f104937b 100644 --- a/frameworks/js/napi/mission_manager/BUILD.gn +++ b/frameworks/js/napi/mission_manager/BUILD.gn @@ -28,6 +28,7 @@ ohos_shared_library("missionmanager_napi") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:mission_info", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", @@ -78,6 +79,7 @@ ohos_shared_library("distributedmissionmanager") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:mission_info", "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_napi_path}/inner/napi_common:napi_common", diff --git a/frameworks/js/napi/mission_manager/distributed_mission_manager.cpp b/frameworks/js/napi/mission_manager/distributed_mission_manager.cpp index 9fc59d5a4a..9906b0b7fa 100644 --- a/frameworks/js/napi/mission_manager/distributed_mission_manager.cpp +++ b/frameworks/js/napi/mission_manager/distributed_mission_manager.cpp @@ -2066,6 +2066,7 @@ void UvWorkOnContinueDone(uv_work_t *work, int status) result = WrapInt32(continueAbilityCB->cbBase.cbInfo.env, continueAbilityCB->resultCode, "code"); } if (continueAbilityCB->cbBase.deferred == nullptr) { + std::lock_guard autoLock(registrationLock_); napi_value callback = nullptr; napi_value undefined = nullptr; napi_get_undefined(continueAbilityCB->cbBase.cbInfo.env, &undefined); @@ -2075,6 +2076,7 @@ void UvWorkOnContinueDone(uv_work_t *work, int status) napi_call_function(continueAbilityCB->cbBase.cbInfo.env, undefined, callback, 1, &result, &callResult); if (continueAbilityCB->cbBase.cbInfo.callback != nullptr) { napi_delete_reference(continueAbilityCB->cbBase.cbInfo.env, continueAbilityCB->cbBase.cbInfo.callback); + continueAbilityCB->cbBase.cbInfo.callback = nullptr; } } else { napi_value result[2] = { nullptr }; diff --git a/frameworks/js/napi/particleAbility/BUILD.gn b/frameworks/js/napi/particleAbility/BUILD.gn index 7e2147834a..d8be1e9f79 100644 --- a/frameworks/js/napi/particleAbility/BUILD.gn +++ b/frameworks/js/napi/particleAbility/BUILD.gn @@ -31,6 +31,7 @@ ohos_shared_library("particleability") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/dataobs_manager:dataobs_manager", "${ability_runtime_innerkits_path}/napi_base_context:napi_base_context", "${ability_runtime_innerkits_path}/runtime:runtime", diff --git a/frameworks/js/napi/uri_permission/js_uri_perm_mgr.cpp b/frameworks/js/napi/uri_permission/js_uri_perm_mgr.cpp index a3df8ef79a..9e462b7363 100644 --- a/frameworks/js/napi/uri_permission/js_uri_perm_mgr.cpp +++ b/frameworks/js/napi/uri_permission/js_uri_perm_mgr.cpp @@ -175,7 +175,7 @@ private: napi_value CreateJsUriPermMgr(napi_env env, napi_value exportObj) { - TAG_LOGI(AAFwkTag::URIPERMMGR, "CreateJsUriPermMgr is called"); + TAG_LOGD(AAFwkTag::URIPERMMGR, "CreateJsUriPermMgr is called"); if (env == nullptr || exportObj == nullptr) { TAG_LOGI(AAFwkTag::URIPERMMGR, "Invalid input parameters"); return nullptr; diff --git a/frameworks/js/napi/wantagent/BUILD.gn b/frameworks/js/napi/wantagent/BUILD.gn index 228f920b0c..d27b8302b5 100644 --- a/frameworks/js/napi/wantagent/BUILD.gn +++ b/frameworks/js/napi/wantagent/BUILD.gn @@ -28,7 +28,7 @@ ohos_shared_library("wantagent") { ] deps = [ - "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/error_utils:ability_runtime_error_util", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_innerkits_path}/wantagent:wantagent_innerkits", diff --git a/frameworks/js/napi/wantagent/ability_want_agent/BUILD.gn b/frameworks/js/napi/wantagent/ability_want_agent/BUILD.gn index 8b53639aec..bdde0232e8 100644 --- a/frameworks/js/napi/wantagent/ability_want_agent/BUILD.gn +++ b/frameworks/js/napi/wantagent/ability_want_agent/BUILD.gn @@ -29,7 +29,7 @@ ohos_shared_library("wantagent_napi") { ] deps = [ - "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/error_utils:ability_runtime_error_util", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_innerkits_path}/wantagent:wantagent_innerkits", diff --git a/frameworks/native/ability/BUILD.gn b/frameworks/native/ability/BUILD.gn index 22ab306501..484572aa82 100644 --- a/frameworks/native/ability/BUILD.gn +++ b/frameworks/native/ability/BUILD.gn @@ -60,6 +60,7 @@ ohos_shared_library("ability_context_native") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", diff --git a/frameworks/native/ability/ability_runtime/connection_manager.cpp b/frameworks/native/ability/ability_runtime/connection_manager.cpp index 72e3be8d82..dd30aeed4b 100644 --- a/frameworks/native/ability/ability_runtime/connection_manager.cpp +++ b/frameworks/native/ability/ability_runtime/connection_manager.cpp @@ -255,8 +255,7 @@ void ConnectionManager::DisconnectNonexistentService( for (auto &&abilityConnection : abilityConnections) { ConnectionInfo connectionInfo = abilityConnection.first; if (connectionInfo.abilityConnection == connection && - connectionInfo.connectReceiver.GetBundleName() == element.GetBundleName() && - connectionInfo.connectReceiver.GetAbilityName() == element.GetAbilityName()) { + connectionInfo.connectReceiver.GetBundleName() == element.GetBundleName()) { HILOG_DEBUG("find connection."); exit = true; break; diff --git a/frameworks/native/ability/native/BUILD.gn b/frameworks/native/ability/native/BUILD.gn index e5d0cd0fa7..2f23d8b54e 100644 --- a/frameworks/native/ability/native/BUILD.gn +++ b/frameworks/native/ability/native/BUILD.gn @@ -229,6 +229,7 @@ ohos_shared_library("abilitykit_native") { ":continuation_ipc", ":extension_blocklist_config", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:ability_start_setting", "${ability_runtime_innerkits_path}/ability_manager:mission_info", "${ability_runtime_innerkits_path}/dataobs_manager:dataobs_manager", @@ -373,6 +374,7 @@ ohos_shared_library("extensionkit_native") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", "${ability_runtime_native_path}/ability:ability_context_native", @@ -426,6 +428,7 @@ ohos_shared_library("insight_intent_executor") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", "${ability_runtime_native_path}/ability/native:ability_business_error", @@ -500,6 +503,7 @@ ohos_shared_library("uiabilitykit_native") { ":continuation_ipc", ":ui_extension", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:ability_start_setting", "${ability_runtime_innerkits_path}/ability_manager:process_options", "${ability_runtime_innerkits_path}/runtime:runtime", @@ -573,6 +577,7 @@ ohos_shared_library("ability_thread") { ":extensionkit_native", ":uiabilitykit_native", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/dataobs_manager:dataobs_manager", "${ability_runtime_native_path}/ability:ability_context_native", "${ability_runtime_native_path}/appkit:app_context", @@ -704,6 +709,7 @@ ohos_shared_library("service_extension") { deps = [ ":abilitykit_native", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", "${ability_runtime_native_path}/ability:ability_context_native", @@ -733,6 +739,7 @@ ohos_shared_library("service_extension") { external_deps += [ "image_framework:image", "window_manager:libdm", + "window_manager:libwm", ] } @@ -768,6 +775,7 @@ ohos_shared_library("continuation_ipc") { deps = [ ":abilitykit_utils", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", ] external_deps = [ @@ -981,6 +989,7 @@ ohos_shared_library("ui_extension") { deps = [ ":abilitykit_native", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", "${ability_runtime_native_path}/ability:ability_context_native", @@ -1070,6 +1079,7 @@ ohos_shared_library("share_extension") { ":abilitykit_native", ":ui_extension", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", "${ability_runtime_native_path}/ability:ability_context_native", @@ -1120,6 +1130,7 @@ ohos_shared_library("action_extension") { ":abilitykit_native", ":ui_extension", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", "${ability_runtime_native_path}/ability:ability_context_native", @@ -1321,6 +1332,7 @@ ohos_shared_library("embedded_ui_extension") { ":abilitykit_native", ":ui_extension", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", "${ability_runtime_native_path}/ability:ability_context_native", @@ -1414,6 +1426,7 @@ ohos_shared_library("auto_fill_extension") { ":insight_intent_executor", ":ui_extension", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", "${ability_runtime_native_path}/ability:ability_context_native", diff --git a/frameworks/native/ability/native/ability.cpp b/frameworks/native/ability/native/ability.cpp index 06061f3e55..60888cf707 100644 --- a/frameworks/native/ability/native/ability.cpp +++ b/frameworks/native/ability/native/ability.cpp @@ -1649,7 +1649,7 @@ std::string Ability::GetContentInfo() if (scene_ == nullptr) { return ""; } - return scene_->GetContentInfo(); + return scene_->GetContentInfo(Rosen::BackupAndRestoreType::CONTINUATION); } void Ability::OnWindowFocusChanged(bool hasFocus) diff --git a/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp b/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp index 41fe630a53..9f9e0b3071 100644 --- a/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp +++ b/frameworks/native/ability/native/ability_business_error/ability_business_error.cpp @@ -78,7 +78,10 @@ constexpr const char* ERROR_MSG_TARGET_BUNDLE_NOT_EXIST = "The target bundle doe constexpr const char* ERROR_MSG_SET_SUPPORTED_PROCESS_CACHE_AGAIN = "Can not set process cache state more than once."; constexpr const char* ERROR_MSG_NO_RESIDENT_PERMISSION = "The caller application can only set the resident status of the configured process."; -constexpr const char* ERROR_MSG_APP_TWIN_INDEX_INVALID = "The target app twin with the specified index does not exist."; +constexpr const char* ERROR_MSG_MULTI_APP_NOT_SUPPORTED = "App clone or multi-instance is not supported."; +constexpr const char* ERROR_MSG_APP_CLONE_INDEX_INVALID = + "The target app clone with the specified index does not exist."; +constexpr const char* ERROR_MSG_NOT_APP_CLONE = "The target app is not Clone."; // follow ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST of appexecfwk_errors.h in bundle_framework constexpr int32_t ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST = 8521220; @@ -132,7 +135,9 @@ static std::unordered_map ERR_CODE_MAP = { { AbilityErrorCode::ERROR_CODE_TARGET_BUNDLE_NOT_EXIST, ERROR_MSG_TARGET_BUNDLE_NOT_EXIST }, { AbilityErrorCode::ERROR_CODE_SET_SUPPORTED_PROCESS_CACHE_AGAIN, ERROR_MSG_SET_SUPPORTED_PROCESS_CACHE_AGAIN }, { AbilityErrorCode::ERROR_CODE_NO_RESIDENT_PERMISSION, ERROR_MSG_NO_RESIDENT_PERMISSION }, - { AbilityErrorCode::ERROR_APP_TWIN_INDEX_INVALID, ERROR_MSG_APP_TWIN_INDEX_INVALID }, + { AbilityErrorCode::ERROR_CODE_MULTI_APP_NOT_SUPPORTED, ERROR_MSG_MULTI_APP_NOT_SUPPORTED }, + { AbilityErrorCode::ERROR_APP_CLONE_INDEX_INVALID, ERROR_MSG_APP_CLONE_INDEX_INVALID }, + { AbilityErrorCode::ERROR_NOT_APP_CLONE, ERROR_MSG_NOT_APP_CLONE }, }; static std::unordered_map INNER_TO_JS_ERROR_CODE_MAP { @@ -189,7 +194,8 @@ static std::unordered_map INNER_TO_JS_ERROR_CODE_MAP {ERR_TARGET_BUNDLE_NOT_EXIST, AbilityErrorCode::ERROR_CODE_TARGET_BUNDLE_NOT_EXIST}, {ERR_SET_SUPPORTED_PROCESS_CACHE_AGAIN, AbilityErrorCode::ERROR_CODE_SET_SUPPORTED_PROCESS_CACHE_AGAIN}, {ERR_NO_RESIDENT_PERMISSION, AbilityErrorCode::ERROR_CODE_NO_RESIDENT_PERMISSION}, - {ERR_APP_TWIN_INDEX_INVALID, AbilityErrorCode::ERROR_APP_TWIN_INDEX_INVALID}, + {ERR_MULTI_APP_NOT_SUPPORTED, AbilityErrorCode::ERROR_CODE_MULTI_APP_NOT_SUPPORTED}, + {ERR_APP_CLONE_INDEX_INVALID, AbilityErrorCode::ERROR_APP_CLONE_INDEX_INVALID}, }; } diff --git a/frameworks/native/ability/native/ability_runtime/js_ability.cpp b/frameworks/native/ability/native/ability_runtime/js_ability.cpp index 508017d1a2..cfb1df8e6a 100644 --- a/frameworks/native/ability/native/ability_runtime/js_ability.cpp +++ b/frameworks/native/ability/native/ability_runtime/js_ability.cpp @@ -609,7 +609,7 @@ void JsAbility::RestorePageStack(const Want &want) auto env = jsRuntime_.GetNapiEnv(); if (abilityContext_->GetContentStorage()) { scene_->GetMainWindow()->NapiSetUIContent(pageStack, env, - abilityContext_->GetContentStorage()->GetNapiValue(), true); + abilityContext_->GetContentStorage()->GetNapiValue(), Rosen::BackupAndRestoreType::CONTINUATION); } else { TAG_LOGE(AAFwkTag::ABILITY, "restore: content storage is nullptr"); } diff --git a/frameworks/native/ability/native/ability_runtime/js_ability_context.cpp b/frameworks/native/ability/native/ability_runtime/js_ability_context.cpp index b2f4c3ac1b..14bd12a881 100644 --- a/frameworks/native/ability/native/ability_runtime/js_ability_context.cpp +++ b/frameworks/native/ability/native/ability_runtime/js_ability_context.cpp @@ -1174,7 +1174,7 @@ napi_value JsAbilityContext::OnConnectAbility(napi_env env, NapiCallbackInfo& in // unwrap want AAFwk::Want want; OHOS::AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want); - TAG_LOGI(AAFwkTag::CONTEXT, "ConnectAbility, callee:%{public}s.%{public}s", + TAG_LOGD(AAFwkTag::CONTEXT, "ConnectAbility, callee:%{public}s.%{public}s", want.GetBundle().c_str(), want.GetElement().GetAbilityName().c_str()); @@ -1224,8 +1224,7 @@ napi_value JsAbilityContext::OnConnectAbilityWithAccount(napi_env env, NapiCallb AAFwk::Want want; OHOS::AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want); TAG_LOGI(AAFwkTag::CONTEXT, "ConnectAbilityWithAccount, bundlename:%{public}s abilityname:%{public}s", - want.GetBundle().c_str(), - want.GetElement().GetAbilityName().c_str()); + want.GetBundle().c_str(), want.GetElement().GetAbilityName().c_str()); int32_t accountId = 0; if (!OHOS::AppExecFwk::UnwrapInt32FromJS2(env, info.argv[INDEX_ONE], accountId)) { @@ -1685,7 +1684,7 @@ void JSAbilityConnection::SetConnectionId(int64_t id) void JSAbilityConnection::OnAbilityConnectDone(const AppExecFwk::ElementName &element, const sptr &remoteObject, int resultCode) { - TAG_LOGI(AAFwkTag::CONTEXT, "OnAbilityConnectDone, resultCode:%{public}d", resultCode); + TAG_LOGD(AAFwkTag::CONTEXT, "OnAbilityConnectDone, resultCode:%{public}d", resultCode); wptr connection = this; std::unique_ptr complete = std::make_unique ([connection, element, remoteObject, resultCode](napi_env env, NapiAsyncTask &task, int32_t status) { @@ -1706,7 +1705,7 @@ void JSAbilityConnection::OnAbilityConnectDone(const AppExecFwk::ElementName &el void JSAbilityConnection::HandleOnAbilityConnectDone(const AppExecFwk::ElementName &element, const sptr &remoteObject, int resultCode) { - TAG_LOGI(AAFwkTag::CONTEXT, "HandleOnAbilityConnectDone, resultCode:%{public}d", resultCode); + TAG_LOGD(AAFwkTag::CONTEXT, "HandleOnAbilityConnectDone, resultCode:%{public}d", resultCode); if (jsConnectionObject_ == nullptr) { TAG_LOGE(AAFwkTag::CONTEXT, "jsConnectionObject_ nullptr"); return; @@ -1732,7 +1731,7 @@ void JSAbilityConnection::HandleOnAbilityConnectDone(const AppExecFwk::ElementNa void JSAbilityConnection::OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode) { - TAG_LOGI(AAFwkTag::CONTEXT, "OnAbilityDisconnectDone, resultCode:%{public}d", resultCode); + TAG_LOGD(AAFwkTag::CONTEXT, "OnAbilityDisconnectDone, resultCode:%{public}d", resultCode); wptr connection = this; std::unique_ptr complete = std::make_unique ([connection, element, resultCode](napi_env env, NapiAsyncTask &task, int32_t status) { diff --git a/frameworks/native/ability/native/ability_runtime/js_ui_ability.cpp b/frameworks/native/ability/native/ability_runtime/js_ui_ability.cpp index 4b27fd7c3f..a82ba5f587 100644 --- a/frameworks/native/ability/native/ability_runtime/js_ui_ability.cpp +++ b/frameworks/native/ability/native/ability_runtime/js_ui_ability.cpp @@ -706,7 +706,7 @@ void JsUIAbility::RestorePageStack(const Want &want) auto env = jsRuntime_.GetNapiEnv(); if (abilityContext_->GetContentStorage()) { scene_->GetMainWindow()->NapiSetUIContent(pageStack, env, - abilityContext_->GetContentStorage()->GetNapiValue(), true); + abilityContext_->GetContentStorage()->GetNapiValue(), Rosen::BackupAndRestoreType::CONTINUATION); } else { TAG_LOGE(AAFwkTag::UIABILITY, "Content storage is nullptr."); } @@ -728,7 +728,8 @@ void JsUIAbility::AbilityContinuationOrRecover(const Want &want) auto env = jsRuntime_.GetNapiEnv(); auto mainWindow = scene_->GetMainWindow(); if (mainWindow != nullptr) { - mainWindow->NapiSetUIContent(pageStack, env, abilityContext_->GetContentStorage()->GetNapiValue(), true); + mainWindow->NapiSetUIContent(pageStack, env, abilityContext_->GetContentStorage()->GetNapiValue(), + Rosen::BackupAndRestoreType::CONTINUATION); } else { TAG_LOGE(AAFwkTag::UIABILITY, "MainWindow is nullptr."); } diff --git a/frameworks/native/ability/native/child_process_manager/child_process_manager.cpp b/frameworks/native/ability/native/child_process_manager/child_process_manager.cpp index c377797192..28de904cb1 100644 --- a/frameworks/native/ability/native/child_process_manager/child_process_manager.cpp +++ b/frameworks/native/ability/native/child_process_manager/child_process_manager.cpp @@ -29,6 +29,7 @@ #include "bundle_info.h" #include "bundle_mgr_interface.h" #include "child_process.h" +#include "native_child_ipc_process.h" #include "child_process_manager_error_utils.h" #include "child_process_start_info.h" #include "constants.h" @@ -115,6 +116,37 @@ ChildProcessManagerErrorCode ChildProcessManager::StartChildProcessByAppSpawnFor return ChildProcessManagerErrorCode::ERR_OK; } +ChildProcessManagerErrorCode ChildProcessManager::StartNativeChildProcessByAppSpawnFork( + const std::string &libName, const sptr &callbackStub) +{ + TAG_LOGI(AAFwkTag::PROCESSMGR, "called, libName:%{private}s", libName.c_str()); + ChildProcessManagerErrorCode errorCode = PreCheckNativeProcess(); + if (errorCode != ChildProcessManagerErrorCode::ERR_OK) { + return errorCode; + } + + sptr appMgr = GetAppMgr(); + if (appMgr == nullptr) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "GetAppMgr for native child process failed."); + return ChildProcessManagerErrorCode::ERR_GET_APP_MGR_FAILED; + } + + auto ret = appMgr->StartNativeChildProcess(libName, childProcessCount_, callbackStub); + TAG_LOGD(AAFwkTag::PROCESSMGR, "AppMgr StartNativeChildProcess ret:%{public}d", ret); + + if (ret != ERR_OK) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "AppMgr StartNativeChildProcess failed, ret:%{public}d", ret); + if (ret == ERR_OVERFLOW) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Max native child processes readched"); + return ChildProcessManagerErrorCode::ERR_MAX_NATIVE_CHILD_PROCESSES; + } + return ChildProcessManagerErrorCode::ERR_GET_APP_MGR_START_PROCESS_FAILED; + } + + ++childProcessCount_; + return ChildProcessManagerErrorCode::ERR_OK; +} + void ChildProcessManager::RegisterSignal() { if (!signalRegistered_) { @@ -144,6 +176,21 @@ ChildProcessManagerErrorCode ChildProcessManager::PreCheck() return ChildProcessManagerErrorCode::ERR_OK; } +ChildProcessManagerErrorCode ChildProcessManager::PreCheckNativeProcess() +{ + ChildProcessManagerErrorCode errCode = PreCheck(); + if (errCode != ChildProcessManagerErrorCode::ERR_OK) { + return errCode; + } + + if (!AAFwk::AppUtils::GetInstance().IsSupportNativeChildProcess()) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Unsupport native child process"); + return ChildProcessManagerErrorCode::ERR_UNSUPPORT_NATIVE_CHILD_PROCESS; + } + + return ChildProcessManagerErrorCode::ERR_OK; +} + bool ChildProcessManager::IsChildProcess() { return isChildProcessBySelfFork_ || hasChildProcessRecord(); @@ -207,6 +254,28 @@ bool ChildProcessManager::LoadJsFile(const std::string &srcEntry, const AppExecF return true; } +bool ChildProcessManager::LoadNativeLib(const std::string &libPath, const sptr &mainProcessCb) +{ + auto childProcess = NativeChildIpcProcess::Create(); + if (childProcess == nullptr) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Failed create NativeChildIpcProcess"); + return false; + } + + std::shared_ptr processStartInfo = std::make_shared(); + processStartInfo->name = std::filesystem::path(libPath).stem(); + processStartInfo->srcEntry = libPath; + processStartInfo->ipcObj = mainProcessCb; + if (!childProcess->Init(processStartInfo)) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "NativeChildIpcProcess init failed."); + return false; + } + + childProcess->OnStart(); + TAG_LOGD(AAFwkTag::PROCESSMGR, "LoadNativeLib end."); + return true; +} + std::unique_ptr ChildProcessManager::CreateRuntime(const AppExecFwk::BundleInfo &bundleInfo, const AppExecFwk::HapModuleInfo &hapModuleInfo, const bool fromAppSpawn, const bool jitEnabled) { diff --git a/frameworks/native/ability/native/child_process_manager/native_child_ipc_process.cpp b/frameworks/native/ability/native/child_process_manager/native_child_ipc_process.cpp new file mode 100644 index 0000000000..905c32a4b9 --- /dev/null +++ b/frameworks/native/ability/native/child_process_manager/native_child_ipc_process.cpp @@ -0,0 +1,146 @@ +/* + * 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 "native_child_ipc_process.h" +#include +#include +#include +#include "hilog_tag_wrapper.h" +#include "hilog_wrapper.h" +#include "child_process_manager_error_utils.h" + +namespace OHOS { +namespace AbilityRuntime { + +std::shared_ptr NativeChildIpcProcess::Create() +{ + return std::make_shared(); +} + +NativeChildIpcProcess::~NativeChildIpcProcess() +{ + UnloadNativeLib(); +} + +bool NativeChildIpcProcess::Init(const std::shared_ptr &info) +{ + TAG_LOGD(AAFwkTag::PROCESSMGR, "NativeChildIpcProcess init"); + if (info == nullptr || info->ipcObj == nullptr) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "info or ipc callback is null"); + return false; + } + + if (!ChildProcess::Init(info)) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Base class init failed."); + return false; + } + + auto iNotify = iface_cast(info->ipcObj); + if (iNotify == nullptr) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Faild cvt interface to INativeChildNotify"); + return false; + } + + if (!LoadNativeLib(info)) { + iNotify->OnError(static_cast(ChildProcessManagerErrorCode::ERR_NATIVE_CHILD_PROCESS_LOAD_LIB)); + return false; + } + + mainProcessCb_ = iNotify; + return true; +} + +void NativeChildIpcProcess::OnStart() +{ + if (funcNativeLibOnConnect_ == nullptr || funcNativeLibMainProc_ == nullptr || mainProcessCb_ == nullptr) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "No init"); + return; + } + + ChildProcess::OnStart(); + OHIPCRemoteStub *ipcStub = funcNativeLibOnConnect_(); + if (ipcStub == nullptr || ipcStub->remote == nullptr) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Native lib OnConnect function return null stub"); + mainProcessCb_->OnError(static_cast(ChildProcessManagerErrorCode::ERR_NATIVE_CHILD_PROCESS_CONNECT)); + return; + } + + std::thread cbThread([this, childIpcStub = std::move(ipcStub->remote)] () -> void { + // Wait MainProc run first + std::this_thread::sleep_for(std::chrono::milliseconds(1)); + TAG_LOGI(AAFwkTag::PROCESSMGR, "Notify native child process started"); + mainProcessCb_->OnNativeChildStarted(childIpcStub); + }); + + TAG_LOGI(AAFwkTag::PROCESSMGR, "Enter native lib MainProc"); + funcNativeLibMainProc_(); + TAG_LOGI(AAFwkTag::PROCESSMGR, "Native lib MainProc returned"); + + if (cbThread.joinable()) { + cbThread.join(); + } +} + +bool NativeChildIpcProcess::LoadNativeLib(const std::shared_ptr &info) +{ + if (nativeLibHandle_ != nullptr) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Native lib already loaded"); + return false; + } + + void *libHandle = dlopen(info->srcEntry.c_str(), RTLD_LAZY); + if (libHandle == nullptr) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Load lib file %{private}s failed, err %{public}s", + info->srcEntry.c_str(), dlerror()); + return false; + } + + do { + NativeChildProcess_OnConnect funcOnConnect = + reinterpret_cast(dlsym(libHandle, "NativeChildProcess_OnConnect")); + if (funcOnConnect == nullptr) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Get OnConnect function address failed, err %{public}s", dlerror()); + break; + } + + NativeChildProcess_MainProc funcMainProc = + reinterpret_cast(dlsym(libHandle, "NativeChildProcess_MainProc")); + if (funcMainProc == nullptr) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Get MainProc function address failed, err %{public}s", dlerror()); + break; + } + + funcNativeLibOnConnect_ = funcOnConnect; + funcNativeLibMainProc_ = funcMainProc; + nativeLibHandle_ = libHandle; + return true; + } while (false); + + dlclose(libHandle); + return false; +} + +void NativeChildIpcProcess::UnloadNativeLib() +{ + if (nativeLibHandle_ != nullptr) { + dlclose(nativeLibHandle_); + nativeLibHandle_ = nullptr; + funcNativeLibOnConnect_ = nullptr; + funcNativeLibMainProc_ = nullptr; + } +} + +} // namespace AbilityRuntime +} // namespace OHOS diff --git a/frameworks/native/ability/native/configuration_utils.cpp b/frameworks/native/ability/native/configuration_utils.cpp index ec2ecbe14f..61e25c6a25 100644 --- a/frameworks/native/ability/native/configuration_utils.cpp +++ b/frameworks/native/ability/native/configuration_utils.cpp @@ -41,6 +41,7 @@ void ConfigurationUtils::UpdateGlobalConfig(const Configuration &configuration, 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 resConfig(Global::Resource::CreateResConfig()); if (resConfig == nullptr) { TAG_LOGE(AAFwkTag::ABILITY, "Create resource config failed."); @@ -75,6 +76,11 @@ void ConfigurationUtils::UpdateGlobalConfig(const Configuration &configuration, 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) { diff --git a/frameworks/native/ability/native/data_ability_operation.cpp b/frameworks/native/ability/native/data_ability_operation.cpp index 12ba97882b..86c8a156dc 100644 --- a/frameworks/native/ability/native/data_ability_operation.cpp +++ b/frameworks/native/ability/native/data_ability_operation.cpp @@ -351,8 +351,7 @@ bool DataAbilityOperation::Marshalling(Parcel &out) const } int referenceSize = (int)dataAbilityPredicatesBackReferences_.size(); if (dataAbilityPredicatesBackReferences_.empty()) { - TAG_LOGD( - AAFwkTag::DATA_ABILITY, "DataAbilityOperation::Marshalling dataAbilityPredicatesBackReferences_ is empty"); + TAG_LOGD(AAFwkTag::DATA_ABILITY, "DataAbilityOperation::Marshalling dataAbilityPredicatesBackReferences_:null"); if (!out.WriteInt32(referenceSize)) { TAG_LOGE(AAFwkTag::DATA_ABILITY, "DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error"); return false; diff --git a/frameworks/native/ability/native/js_service_extension.cpp b/frameworks/native/ability/native/js_service_extension.cpp index 42e69ddfb0..7a2992b76a 100644 --- a/frameworks/native/ability/native/js_service_extension.cpp +++ b/frameworks/native/ability/native/js_service_extension.cpp @@ -219,7 +219,13 @@ void JsServiceExtension::ListenWMS() return; } - auto listener = sptr::MakeSptr(displayListener_); + auto context = GetContext(); + if (context == nullptr || context->GetToken()) { + TAG_LOGE(AAFwkTag::SERVICE_EXT, "Param invalid."); + return; + } + + auto listener = sptr::MakeSptr(displayListener_, context->GetToken()); if (listener == nullptr) { TAG_LOGE(AAFwkTag::SERVICE_EXT, "Failed to create status change listener."); return; @@ -237,7 +243,8 @@ void JsServiceExtension::SystemAbilityStatusChangeListener::OnAddSystemAbility(i { TAG_LOGD(AAFwkTag::SERVICE_EXT, "systemAbilityId: %{public}d add", systemAbilityId); if (systemAbilityId == WINDOW_MANAGER_SERVICE_ID) { - Rosen::DisplayManager::GetInstance().RegisterDisplayListener(tmpDisplayListener_); + TAG_LOGI(AAFwkTag::SERVICE_EXT, "RegisterDisplayInfoChangedListener"); + Rosen::WindowManager::GetInstance().RegisterDisplayInfoChangedListener(token_, tmpDisplayListener_); } } @@ -315,7 +322,14 @@ void JsServiceExtension::OnStop() ConnectionManager::GetInstance().ReportConnectionLeakEvent(getpid(), gettid()); TAG_LOGD(AAFwkTag::SERVICE_EXT, "The service extension connection is not disconnected."); } - Rosen::DisplayManager::GetInstance().UnregisterDisplayListener(displayListener_); + TAG_LOGI(AAFwkTag::SERVICE_EXT, "UnregisterDisplayInfoChangedListener"); + auto context = GetContext(); + if (context == nullptr || context->GetToken()) { + TAG_LOGE(AAFwkTag::SERVICE_EXT, "Param invalid."); + return; + } + Rosen::WindowManager::GetInstance() + .UnregisterDisplayInfoChangedListener(context->GetToken(), displayListener_); TAG_LOGD(AAFwkTag::SERVICE_EXT, "ok"); } @@ -451,8 +465,7 @@ bool JsServiceExtension::HandleInsightIntent(const AAFwk::Want &want) static_cast(AbilityErrorCode::ERROR_CODE_INVALID_PARAM)); return false; } - TAG_LOGD(AAFwkTag::SERVICE_EXT, - "Insight intent bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s" + TAG_LOGD(AAFwkTag::SERVICE_EXT, "Insight bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s" "insightIntentName: %{public}s, executeMode: %{public}d, intentId: %{public}" PRIu64 "", executeParam->bundleName_.c_str(), executeParam->moduleName_.c_str(), executeParam->abilityName_.c_str(), executeParam->insightIntentName_.c_str(), executeParam->executeMode_, executeParam->insightIntentId_); @@ -799,6 +812,43 @@ void JsServiceExtension::OnDestroy(Rosen::DisplayId displayId) TAG_LOGD(AAFwkTag::SERVICE_EXT, "exit."); } +void JsServiceExtension::OnDisplayInfoChange(const sptr& token, Rosen::DisplayId displayId, + float density, Rosen::DisplayOrientation orientation) +{ + TAG_LOGI(AAFwkTag::SERVICE_EXT, "displayId: %{public}" PRIu64, displayId); + auto context = GetContext(); + if (context == nullptr) { + TAG_LOGE(AAFwkTag::SERVICE_EXT, "Context is invalid."); + return; + } + + auto contextConfig = context->GetConfiguration(); + if (contextConfig == nullptr) { + TAG_LOGE(AAFwkTag::SERVICE_EXT, "Configuration is invalid."); + return; + } + + TAG_LOGD(AAFwkTag::SERVICE_EXT, "Config dump: %{public}s", contextConfig->GetName().c_str()); + bool configChanged = false; + auto configUtils = std::make_shared(); + configUtils->UpdateDisplayConfig(displayId, contextConfig, context->GetResourceManager(), configChanged); + TAG_LOGD(AAFwkTag::SERVICE_EXT, "Config dump after update: %{public}s", contextConfig->GetName().c_str()); + + if (configChanged) { + auto jsServiceExtension = std::static_pointer_cast(shared_from_this()); + auto task = [jsServiceExtension]() { + if (jsServiceExtension) { + jsServiceExtension->ConfigurationUpdated(); + } + }; + if (handler_ != nullptr) { + handler_->PostTask(task, "JsServiceExtension:OnChange"); + } + } + + TAG_LOGD(AAFwkTag::SERVICE_EXT, "finished."); +} + void JsServiceExtension::OnChange(Rosen::DisplayId displayId) { TAG_LOGD(AAFwkTag::SERVICE_EXT, "displayId: %{public}" PRIu64"", displayId); diff --git a/frameworks/native/ability/native/js_service_extension_context.cpp b/frameworks/native/ability/native/js_service_extension_context.cpp index 8a8bbdb1fa..3477b0dddf 100644 --- a/frameworks/native/ability/native/js_service_extension_context.cpp +++ b/frameworks/native/ability/native/js_service_extension_context.cpp @@ -210,7 +210,7 @@ private: napi_value OnStartAbility(napi_env env, NapiCallbackInfo& info, bool isStartRecent = false) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); - TAG_LOGI(AAFwkTag::SERVICE_EXT, "StartAbility"); + TAG_LOGD(AAFwkTag::SERVICE_EXT, "StartAbility"); if (info.argc < ARGC_ONE) { TAG_LOGE(AAFwkTag::SERVICE_EXT, "Start ability failed, not enough params."); ThrowTooFewParametersError(env); @@ -782,7 +782,7 @@ private: napi_value OnDisconnectAbility(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::SERVICE_EXT, "DisconnectAbility start"); + TAG_LOGD(AAFwkTag::SERVICE_EXT, "DisconnectAbility start"); if (info.argc < ARGC_ONE) { TAG_LOGE(AAFwkTag::SERVICE_EXT, "Disconnect ability error, not enough params."); ThrowTooFewParametersError(env); @@ -1077,7 +1077,7 @@ private: return; } if (*retCode == 0) { - TAG_LOGI(AAFwkTag::SERVICE_EXT, "StartAbility is success"); + TAG_LOGD(AAFwkTag::SERVICE_EXT, "StartAbility is success"); task.Resolve(env, CreateJsUndefined(env)); } else { task.Reject(env, CreateJsErrorByNativeErr(env, *retCode)); @@ -1277,7 +1277,7 @@ void JSServiceExtensionConnection::OnAbilityDisconnectDone(const AppExecFwk::Ele void JSServiceExtensionConnection::HandleOnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode) { - TAG_LOGI(AAFwkTag::SERVICE_EXT, "HandleOnAbilityDisconnectDone, resultCode:%{public}d", resultCode); + TAG_LOGD(AAFwkTag::SERVICE_EXT, "HandleOnAbilityDisconnectDone, resultCode:%{public}d", resultCode); napi_value napiElementName = OHOS::AppExecFwk::WrapElementName(env_, element); napi_value argv[] = {napiElementName}; if (jsConnectionObject_ == nullptr) { diff --git a/frameworks/native/ability/native/ui_ability.cpp b/frameworks/native/ability/native/ui_ability.cpp index 33eaee9287..ccd65d0b36 100644 --- a/frameworks/native/ability/native/ui_ability.cpp +++ b/frameworks/native/ability/native/ui_ability.cpp @@ -93,7 +93,8 @@ void UIAbility::Init(std::shared_ptr record, TAG_LOGE(AAFwkTag::UIABILITY, "abilityDisplayListener_ is nullptr."); return; } - Rosen::DisplayManager::GetInstance().RegisterDisplayListener(abilityDisplayListener_); + TAG_LOGI(AAFwkTag::UIABILITY, "RegisterDisplayInfoChangedListener."); + Rosen::WindowManager::GetInstance().RegisterDisplayInfoChangedListener(token_, abilityDisplayListener_); #endif lifecycle_ = std::make_shared(); abilityLifecycleExecutor_ = std::make_shared(); @@ -185,7 +186,8 @@ void UIAbility::OnStop() if (abilityRecovery_ != nullptr) { abilityRecovery_->ScheduleSaveAbilityState(AppExecFwk::StateReason::LIFECYCLE); } - (void)Rosen::DisplayManager::GetInstance().UnregisterDisplayListener(abilityDisplayListener_); + TAG_LOGI(AAFwkTag::UIABILITY, "UnregisterDisplayInfoChangedListener."); + (void)Rosen::WindowManager::GetInstance().UnregisterDisplayInfoChangedListener(token_, abilityDisplayListener_); auto &&window = GetWindow(); if (window != nullptr) { TAG_LOGD(AAFwkTag::UIABILITY, "Call UnregisterDisplayMoveListener."); @@ -240,10 +242,6 @@ bool UIAbility::IsRestoredInContinuation() const return false; } - if (abilityContext_->GetContentStorage() == nullptr) { - TAG_LOGD(AAFwkTag::UIABILITY, "Get content failed."); - return false; - } TAG_LOGD(AAFwkTag::UIABILITY, "End."); return true; } @@ -293,6 +291,7 @@ void UIAbility::OnConfigurationUpdatedNotify(const AppExecFwk::Configuration &co 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 resConfig(Global::Resource::CreateResConfig()); if (resConfig == nullptr) { @@ -318,6 +317,10 @@ void UIAbility::OnConfigurationUpdatedNotify(const AppExecFwk::Configuration &co 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()); @@ -798,6 +801,49 @@ void UIAbility::OnDestroy(Rosen::DisplayId displayId) TAG_LOGD(AAFwkTag::UIABILITY, "Called."); } +void UIAbility::OnDisplayInfoChange(const sptr& token, Rosen::DisplayId displayId, float density, + Rosen::DisplayOrientation orientation) +{ + TAG_LOGI(AAFwkTag::UIABILITY, "Begin displayId: %{public}" PRIu64, displayId); + // Get display + auto display = Rosen::DisplayManager::GetInstance().GetDisplayById(displayId); + if (!display) { + TAG_LOGE(AAFwkTag::UIABILITY, "Get display by displayId %{public}" PRIu64 " failed.", displayId); + return; + } + + // Notify ResourceManager + int32_t width = display->GetWidth(); + int32_t height = display->GetHeight(); + std::unique_ptr resConfig(Global::Resource::CreateResConfig()); + if (resConfig != nullptr) { + auto resourceManager = GetResourceManager(); + if (resourceManager != nullptr) { + resourceManager->GetResConfig(*resConfig); + resConfig->SetScreenDensity(density); + resConfig->SetDirection(AppExecFwk::ConvertDirection(height, width)); + resourceManager->UpdateResConfig(*resConfig); + TAG_LOGD(AAFwkTag::UIABILITY, "Notify ResourceManager, Density: %{public}f, Direction: %{public}d", + resConfig->GetScreenDensity(), resConfig->GetDirection()); + } + } + + // Notify ability + Configuration newConfig; + newConfig.AddItem( + displayId, AppExecFwk::ConfigurationInner::APPLICATION_DIRECTION, AppExecFwk::GetDirectionStr(height, width)); + newConfig.AddItem( + displayId, AppExecFwk::ConfigurationInner::APPLICATION_DENSITYDPI, AppExecFwk::GetDensityStr(density)); + + if (application_ == nullptr) { + TAG_LOGE(AAFwkTag::UIABILITY, "application_ is nullptr."); + return; + } + + OnChangeForUpdateConfiguration(newConfig); + TAG_LOGD(AAFwkTag::UIABILITY, "End."); +} + void UIAbility::OnChange(Rosen::DisplayId displayId) { TAG_LOGD(AAFwkTag::UIABILITY, "Begin displayId: %{public}" PRIu64 "", displayId); @@ -1021,11 +1067,6 @@ void UIAbility::OnChangeForUpdateConfiguration(const AppExecFwk::Configuration & ability->OnConfigurationUpdated(configuration); }; handler_->PostTask(task); - - auto diffConfiguration = std::make_shared(newConfig); - TAG_LOGD(AAFwkTag::UIABILITY, "Update display config %{public}s for all windows.", - diffConfiguration->GetName().c_str()); - Rosen::Window::UpdateConfigurationForAll(diffConfiguration); } } diff --git a/frameworks/native/ability/native/ui_ability_impl.cpp b/frameworks/native/ability/native/ui_ability_impl.cpp index 7cec9fefc2..43a83fc531 100644 --- a/frameworks/native/ability/native/ui_ability_impl.cpp +++ b/frameworks/native/ability/native/ui_ability_impl.cpp @@ -368,7 +368,7 @@ void UIAbilityImpl::UpdateSilentForeground(const AAFwk::LifeCycleStateInfo &targ } if (lifecycleState_ == AAFwk::ABILITY_STATE_INITIAL && sessionInfo && sessionInfo->processOptions && - AAFwk::ProcessOptions::IsNewProcessMode(sessionInfo->processOptions->processMode) && + AAFwk::ProcessOptions::IsValidProcessMode(sessionInfo->processOptions->processMode) && sessionInfo->processOptions->startupVisibility == AAFwk::StartupVisibility::STARTUP_HIDE) { TAG_LOGI(AAFwkTag::UIABILITY, "Set IsSilentForeground to true."); ability_->SetIsSilentForeground(true); diff --git a/frameworks/native/ability/native/ui_extension_ability/js_ui_extension.cpp b/frameworks/native/ability/native/ui_extension_ability/js_ui_extension.cpp index eaac751d7a..a4e679a252 100755 --- a/frameworks/native/ability/native/ui_extension_ability/js_ui_extension.cpp +++ b/frameworks/native/ability/native/ui_extension_ability/js_ui_extension.cpp @@ -782,7 +782,7 @@ void JsUIExtension::DestroyWindow(const sptr &sessionInfo) CallObjectMethod("onSessionDestroy", argv, ARGC_ONE); } } - auto& uiWindow = uiWindowMap_[componentId]; + auto uiWindow = uiWindowMap_[componentId]; if (uiWindow) { uiWindow->Destroy(); } diff --git a/frameworks/native/ability/native/ui_extension_ability/js_ui_extension_content_session.cpp b/frameworks/native/ability/native/ui_extension_ability/js_ui_extension_content_session.cpp index fe5ccc8acf..de57a5cb8e 100644 --- a/frameworks/native/ability/native/ui_extension_ability/js_ui_extension_content_session.cpp +++ b/frameworks/native/ability/native/ui_extension_ability/js_ui_extension_content_session.cpp @@ -564,26 +564,8 @@ napi_value JsUIExtensionContentSession::OnTerminateSelfWithResult(napi_env env, return CreateJsUndefined(env); } - NapiAsyncTask::CompleteCallback complete = - [uiWindow = uiWindow_, sessionInfo = sessionInfo_, want, resultCode](napi_env env, - NapiAsyncTask& task, int32_t status) { - if (uiWindow == nullptr) { - TAG_LOGE(AAFwkTag::UI_EXT, "uiWindow is nullptr."); - task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INNER)); - return; - } - auto ret = uiWindow->TransferAbilityResult(resultCode, want); - if (ret != Rosen::WMError::WM_OK) { - task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INNER)); - return; - } - auto errorCode = AAFwk::AbilityManagerClient::GetInstance()->TerminateUIExtensionAbility(sessionInfo); - if (errorCode == 0) { - task.ResolveWithNoError(env, CreateJsUndefined(env)); - } else { - task.Reject(env, CreateJsErrorByNativeErr(env, errorCode)); - } - }; + NapiAsyncTask::CompleteCallback complete; + SetCallbackForTerminateWithResult(resultCode, want, complete); napi_value lastParam = (info.argc > ARGC_ONE) ? info.argv[INDEX_ONE] : nullptr; napi_value result = nullptr; @@ -633,7 +615,7 @@ napi_value JsUIExtensionContentSession::OnSetReceiveDataCallback(napi_env env, N ThrowTooFewParametersError(env); return CreateJsUndefined(env); } - + if (!CheckTypeForNapiValue(env, info.argv[INDEX_ZERO], napi_function)) { TAG_LOGE(AAFwkTag::UI_EXT, "invalid param"); ThrowInvalidParamError(env, "Parameter error: Callback must be a function."); @@ -681,7 +663,7 @@ napi_value JsUIExtensionContentSession::OnSetReceiveDataForResultCallback(napi_e ThrowTooFewParametersError(env); return CreateJsUndefined(env); } - + if (!CheckTypeForNapiValue(env, info.argv[INDEX_ZERO], napi_function)) { TAG_LOGE(AAFwkTag::UI_EXT, "invalid param"); ThrowInvalidParamError(env, "Parameter error: Callback must be a function."); @@ -733,7 +715,7 @@ napi_value JsUIExtensionContentSession::OnLoadContent(napi_env env, NapiCallback ThrowTooFewParametersError(env); return CreateJsUndefined(env); } - + if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], contextPath)) { TAG_LOGE(AAFwkTag::UI_EXT, "invalid param"); ThrowInvalidParamError(env, "Parameter error: Path must be a string."); @@ -761,7 +743,8 @@ napi_value JsUIExtensionContentSession::OnLoadContent(napi_env env, NapiCallback isFirstTriggerBindModal_ = false; } sptr parentToken = sessionInfo_->parentToken; - Rosen::WMError ret = uiWindow_->NapiSetUIContent(contextPath, env, storage, false, parentToken); + Rosen::WMError ret = uiWindow_->NapiSetUIContent(contextPath, env, storage, + Rosen::BackupAndRestoreType::NONE, parentToken); if (ret == Rosen::WMError::WM_OK) { TAG_LOGD(AAFwkTag::UI_EXT, "NapiSetUIContent success"); } else { @@ -781,7 +764,7 @@ napi_value JsUIExtensionContentSession::OnSetWindowBackgroundColor(napi_env env, ThrowTooFewParametersError(env); return CreateJsUndefined(env); } - + if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], color)) { TAG_LOGE(AAFwkTag::UI_EXT, "invalid param"); ThrowInvalidParamError(env, "Parameter error: Parse color failed! Color must be a string."); @@ -812,7 +795,7 @@ napi_value JsUIExtensionContentSession::OnSetWindowPrivacyMode(napi_env env, Nap ThrowTooFewParametersError(env); return CreateJsUndefined(env); } - + if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], isPrivacyMode)) { TAG_LOGE(AAFwkTag::UI_EXT, "invalid param"); ThrowInvalidParamError(env, "Parameter error: Failed to parse isPrivacyMode! IsPrivacyMode must be a boolean."); @@ -849,7 +832,7 @@ napi_value JsUIExtensionContentSession::OnSetWindowPrivacyMode(napi_env env, Nap napi_value JsUIExtensionContentSession::OnStartAbilityByType(napi_env env, NapiCallbackInfo& info) { TAG_LOGI(AAFwkTag::UI_EXT, "called"); - + std::string type; AAFwk::WantParams wantParam; @@ -1084,5 +1067,38 @@ void JsUIExtensionContentSession::AddFreeInstallObserver(napi_env env, bundleName, abilityName, startTime, callback, result, isAbilityResult); } } + +void JsUIExtensionContentSession::SetCallbackForTerminateWithResult(int32_t resultCode, AAFwk::Want& want, + NapiAsyncTask::CompleteCallback& complete) +{ + complete = + [weak = context_, uiWindow = uiWindow_, sessionInfo = sessionInfo_, want, resultCode](napi_env env, + NapiAsyncTask& task, int32_t status) { + auto extensionContext = AbilityRuntime::Context::ConvertTo(weak.lock()); + if (!extensionContext) { + TAG_LOGE(AAFwkTag::UI_EXT, "extensionContext is nullptr"); + task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INVALID_CONTEXT)); + return; + } + auto token = extensionContext->GetToken(); + AAFwk::AbilityManagerClient::GetInstance()->TransferAbilityResultForExtension(token, resultCode, want); + if (uiWindow == nullptr) { + TAG_LOGE(AAFwkTag::UI_EXT, "uiWindow is nullptr."); + task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INNER)); + return; + } + auto ret = uiWindow->TransferAbilityResult(resultCode, want); + if (ret != Rosen::WMError::WM_OK) { + task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INNER)); + return; + } + auto errorCode = AAFwk::AbilityManagerClient::GetInstance()->TerminateUIExtensionAbility(sessionInfo); + if (errorCode == 0) { + task.ResolveWithNoError(env, CreateJsUndefined(env)); + } else { + task.Reject(env, CreateJsErrorByNativeErr(env, errorCode)); + } + }; +} } // namespace AbilityRuntime } // namespace OHOS diff --git a/frameworks/native/ability/native/ui_extension_ability/js_ui_extension_context.cpp b/frameworks/native/ability/native/ui_extension_ability/js_ui_extension_context.cpp index e05adf9bd9..2a8bf4454a 100755 --- a/frameworks/native/ability/native/ui_extension_ability/js_ui_extension_context.cpp +++ b/frameworks/native/ability/native/ui_extension_ability/js_ui_extension_context.cpp @@ -428,33 +428,8 @@ napi_value JsUIExtensionContext::OnTerminateSelfWithResult(napi_env env, NapiCal return CreateJsUndefined(env); } - NapiAsyncTask::CompleteCallback complete = - [weak = context_, want, resultCode](napi_env env, NapiAsyncTask& task, int32_t status) { - auto context = weak.lock(); - if (!context) { - TAG_LOGW(AAFwkTag::UI_EXT, "context is released"); - task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM)); - return; - } - sptr uiWindow = context->GetWindow(); - if (uiWindow == nullptr) { - TAG_LOGE(AAFwkTag::UI_EXT, "uiWindow is nullptr"); - task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM)); - return; - } - auto ret = uiWindow->TransferAbilityResult(resultCode, want); - if (ret != Rosen::WMError::WM_OK) { - task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM)); - return; - } - auto errorCode = context->TerminateSelf(); - if (errorCode == 0) { - task.ResolveWithNoError(env, CreateJsUndefined(env)); - } else { - task.Reject(env, CreateJsErrorByNativeErr(env, errorCode)); - } - }; - + NapiAsyncTask::CompleteCallback complete; + SetCallbackForTerminateWithResult(resultCode, want, complete); napi_value lastParam = (info.argc > ARGC_ONE) ? info.argv[INDEX_ONE] : nullptr; napi_value result = nullptr; NapiAsyncTask::ScheduleHighQos("JsUIExtensionContext::OnTerminateSelfWithResult", @@ -666,6 +641,45 @@ napi_value JsUIExtensionContext::OnOpenAtomicService(napi_env env, NapiCallbackI return OpenAtomicServiceInner(env, info, want, startOptions, unwrapArgc); } +void JsUIExtensionContext::SetCallbackForTerminateWithResult(int32_t resultCode, AAFwk::Want& want, + NapiAsyncTask::CompleteCallback& complete) +{ + complete = + [weak = context_, want, resultCode](napi_env env, NapiAsyncTask& task, int32_t status) { + auto context = weak.lock(); + if (!context) { + TAG_LOGE(AAFwkTag::UI_EXT, "context is released"); + task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INVALID_CONTEXT)); + return; + } + auto extensionContext = AbilityRuntime::Context::ConvertTo(context); + if (!extensionContext) { + TAG_LOGE(AAFwkTag::UI_EXT, "extensionContext is nullptr"); + task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM)); + return; + } + auto token = extensionContext->GetToken(); + AAFwk::AbilityManagerClient::GetInstance()->TransferAbilityResultForExtension(token, resultCode, want); + sptr uiWindow = context->GetWindow(); + if (!uiWindow) { + TAG_LOGE(AAFwkTag::UI_EXT, "uiWindow is nullptr"); + task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM)); + return; + } + auto ret = uiWindow->TransferAbilityResult(resultCode, want); + if (ret != Rosen::WMError::WM_OK) { + task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM)); + return; + } + auto errorCode = context->TerminateSelf(); + if (errorCode == 0) { + task.ResolveWithNoError(env, CreateJsUndefined(env)); + } else { + task.Reject(env, CreateJsErrorByNativeErr(env, errorCode)); + } + }; +} + napi_value JsUIExtensionContext::OpenAtomicServiceInner(napi_env env, NapiCallbackInfo& info, Want &want, const AAFwk::StartOptions &options, size_t unwrapArgc) { diff --git a/frameworks/native/appkit/BUILD.gn b/frameworks/native/appkit/BUILD.gn index 02a9a4bedd..11c685f40e 100644 --- a/frameworks/native/appkit/BUILD.gn +++ b/frameworks/native/appkit/BUILD.gn @@ -48,7 +48,6 @@ config("appkit_config") { "${ability_runtime_path}/interfaces/kits/native/appkit/app", "${ability_runtime_path}/interfaces/kits/native/appkit/dfr", "${ability_runtime_path}/interfaces/kits/native/ability/native", - "//third_party/json/include", ] } @@ -150,6 +149,7 @@ ohos_shared_library("appkit_native") { ":appkit_delegator", "${ability_runtime_abilitymgr_path}/:abilityms", "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/child_process_manager:child_process_manager", "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", @@ -187,6 +187,7 @@ ohos_shared_library("appkit_native") { "i18n:preferred_language", "init:libbegetutil", "ipc:ipc_core", + "json:nlohmann_json_static", "napi:ace_napi", "resource_management:global_resmgr", "safwk:system_ability_fwk", @@ -267,6 +268,7 @@ ohos_shared_library("app_context") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", "${ability_runtime_innerkits_path}/runtime:runtime", @@ -284,6 +286,7 @@ ohos_shared_library("app_context") { "hitrace:hitrace_meter", "init:libbegetutil", "ipc:ipc_core", + "json:nlohmann_json_static", "napi:ace_napi", "resource_management:global_resmgr", "samgr:samgr_proxy", @@ -325,6 +328,7 @@ ohos_shared_library("app_context_utils") { } deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_innerkits_path}/error_utils:ability_runtime_error_util", "${ability_runtime_innerkits_path}/runtime:runtime", @@ -344,6 +348,7 @@ ohos_shared_library("app_context_utils") { "hilog:libhilog", "hitrace:hitrace_meter", "ipc:ipc_core", + "json:nlohmann_json_static", "napi:ace_napi", "resource_management:global_resmgr", "resource_management:resmgr_napi_core", @@ -397,6 +402,7 @@ ohos_shared_library("appkit_delegator") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_native_path}/appkit:app_context", "${ability_runtime_native_path}/appkit:delegator_mgmt", @@ -410,6 +416,7 @@ ohos_shared_library("appkit_delegator") { "eventhandler:libeventhandler", "hilog:libhilog", "ipc:ipc_core", + "json:nlohmann_json_static", "napi:ace_napi", ] public_external_deps = [ "ability_base:configuration" ] @@ -464,6 +471,7 @@ ohos_shared_library("appkit_manager_helper") { "hilog:libhilog", "hitrace:hitrace_meter", "ipc:ipc_core", + "json:nlohmann_json_static", "samgr:samgr_proxy", ] diff --git a/frameworks/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.cpp b/frameworks/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.cpp index 1f7416dee8..515fd24eb3 100644 --- a/frameworks/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.cpp +++ b/frameworks/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.cpp @@ -82,7 +82,7 @@ ErrCode BundleMgrHelper::InstallSandboxApp(const std::string &bundleName, int32_ ErrCode BundleMgrHelper::UninstallSandboxApp(const std::string &bundleName, int32_t appIndex, int32_t userId) { TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called."); - if (bundleName.empty() || appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + if (bundleName.empty() || appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { TAG_LOGE(AAFwkTag::BUNDLEMGRHELPER, "The params are invalid."); return ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR; } @@ -113,7 +113,7 @@ ErrCode BundleMgrHelper::GetSandboxBundleInfo( const std::string &bundleName, int32_t appIndex, int32_t userId, BundleInfo &info) { TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called."); - if (bundleName.empty() || appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + if (bundleName.empty() || appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { TAG_LOGE(AAFwkTag::BUNDLEMGRHELPER, "The params are invalid."); return ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR; } @@ -131,7 +131,7 @@ ErrCode BundleMgrHelper::GetSandboxAbilityInfo(const Want &want, int32_t appInde AbilityInfo &abilityInfo) { TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called."); - if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { TAG_LOGE(AAFwkTag::BUNDLEMGRHELPER, "The params are invalid."); return ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR; } @@ -152,7 +152,7 @@ ErrCode BundleMgrHelper::GetSandboxExtAbilityInfos(const Want &want, int32_t app int32_t userId, std::vector &extensionInfos) { TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called."); - if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { TAG_LOGE(AAFwkTag::BUNDLEMGRHELPER, "The params are invalid."); return ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR; } @@ -170,7 +170,7 @@ ErrCode BundleMgrHelper::GetSandboxHapModuleInfo(const AbilityInfo &abilityInfo, HapModuleInfo &hapModuleInfo) { TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called."); - if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { TAG_LOGE(AAFwkTag::BUNDLEMGRHELPER, "The params are invalid."); return ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR; } @@ -798,7 +798,7 @@ ErrCode BundleMgrHelper::GetLaunchWantForBundle(const std::string &bundleName, W return bundleMgr->GetLaunchWantForBundle(bundleName, want, userId); } -ErrCode BundleMgrHelper::QueryCloneAbilityInfo(const ElementName &element, int32_t flags, int32_t appTwinIndex, +ErrCode BundleMgrHelper::QueryCloneAbilityInfo(const ElementName &element, int32_t flags, int32_t appCloneIndex, AbilityInfo &abilityInfo, int32_t userId) { TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called."); @@ -808,10 +808,10 @@ ErrCode BundleMgrHelper::QueryCloneAbilityInfo(const ElementName &element, int32 return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; } - return bundleMgr->QueryCloneAbilityInfo(element, flags, appTwinIndex, abilityInfo, userId); + return bundleMgr->QueryCloneAbilityInfo(element, flags, appCloneIndex, abilityInfo, userId); } -ErrCode BundleMgrHelper::GetCloneBundleInfo(const std::string &bundleName, int32_t flags, int32_t appTwinIndex, +ErrCode BundleMgrHelper::GetCloneBundleInfo(const std::string &bundleName, int32_t flags, int32_t appCloneIndex, BundleInfo &bundleInfo, int32_t userId) { TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called."); @@ -821,7 +821,7 @@ ErrCode BundleMgrHelper::GetCloneBundleInfo(const std::string &bundleName, int32 return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; } - return bundleMgr->GetCloneBundleInfo(bundleName, flags, appTwinIndex, bundleInfo, userId); + return bundleMgr->GetCloneBundleInfo(bundleName, flags, appCloneIndex, bundleInfo, userId); } } // namespace AppExecFwk diff --git a/frameworks/native/appkit/ability_runtime/app/ability_stage.cpp b/frameworks/native/appkit/ability_runtime/app/ability_stage.cpp index b1ef8c3682..59e91cb145 100644 --- a/frameworks/native/appkit/ability_runtime/app/ability_stage.cpp +++ b/frameworks/native/appkit/ability_runtime/app/ability_stage.cpp @@ -117,7 +117,8 @@ void AbilityStage::OnMemoryLevel(int level) TAG_LOGD(AAFwkTag::APPKIT, "%{public}s called.", __func__); } -int32_t AbilityStage::RunAutoStartupTask(const std::function &callback, bool &isAsyncCallback) +int32_t AbilityStage::RunAutoStartupTask(const std::function &callback, bool &isAsyncCallback, + const std::shared_ptr &stageContext) { TAG_LOGD(AAFwkTag::APPKIT, "called"); isAsyncCallback = false; diff --git a/frameworks/native/appkit/ability_runtime/app/js_ability_stage.cpp b/frameworks/native/appkit/ability_runtime/app/js_ability_stage.cpp index 099fa9b80d..84fa376cf2 100644 --- a/frameworks/native/appkit/ability_runtime/app/js_ability_stage.cpp +++ b/frameworks/native/appkit/ability_runtime/app/js_ability_stage.cpp @@ -169,39 +169,8 @@ void JsAbilityStage::Init(const std::shared_ptr &context, TAG_LOGE(AAFwkTag::APPKIT, "stage is nullptr"); return; } - - HandleScope handleScope(jsRuntime_); - auto env = jsRuntime_.GetNapiEnv(); - - napi_value obj = jsAbilityStageObj_->GetNapiValue(); - if (!CheckTypeForNapiValue(env, obj, napi_object)) { - TAG_LOGE(AAFwkTag::APPKIT, "Failed to get AbilityStage object"); - return; - } - - napi_value contextObj = CreateJsAbilityStageContext(env, context, nullptr, nullptr); - shellContextRef_ = JsRuntime::LoadSystemModuleByEngine(env, "application.AbilityStageContext", &contextObj, 1); - if (shellContextRef_ == nullptr) { - TAG_LOGE(AAFwkTag::APPKIT, "Failed to get LoadSystemModuleByEngine"); - return; - } - contextObj = shellContextRef_->GetNapiValue(); - if (!CheckTypeForNapiValue(env, contextObj, napi_object)) { - TAG_LOGE(AAFwkTag::APPKIT, "Failed to get context native object"); - return; - } - auto workContext = new (std::nothrow) std::weak_ptr(context); - napi_coerce_to_native_binding_object( - env, contextObj, DetachCallbackFunc, AttachAbilityStageContext, workContext, nullptr); - context->Bind(jsRuntime_, shellContextRef_.get()); - napi_set_named_property(env, obj, "context", contextObj); - TAG_LOGD(AAFwkTag::APPKIT, "Set ability stage context"); - napi_wrap(env, contextObj, workContext, - [](napi_env, void* data, void*) { - TAG_LOGD(AAFwkTag::APPKIT, "Finalizer for weak_ptr ability stage context is called"); - delete static_cast*>(data); - }, - nullptr, nullptr); + + SetJsAbilityStage(context); } void JsAbilityStage::OnCreate(const AAFwk::Want &want) const @@ -383,7 +352,8 @@ void JsAbilityStage::OnMemoryLevel(int32_t level) TAG_LOGD(AAFwkTag::APPKIT, "end"); } -int32_t JsAbilityStage::RunAutoStartupTask(const std::function &callback, bool &isAsyncCallback) +int32_t JsAbilityStage::RunAutoStartupTask(const std::function &callback, bool &isAsyncCallback, + const std::shared_ptr &stageContext) { TAG_LOGD(AAFwkTag::APPKIT, "called"); isAsyncCallback = false; @@ -397,12 +367,13 @@ int32_t JsAbilityStage::RunAutoStartupTask(const std::function &callback TAG_LOGE(AAFwkTag::APPKIT, "hapModuleInfo invalid."); return ERR_INVALID_VALUE; } - if (hapModuleInfo->moduleType != AppExecFwk::ModuleType::ENTRY || - hapModuleInfo->appStartup.empty()) { + if (hapModuleInfo->moduleType != AppExecFwk::ModuleType::ENTRY || hapModuleInfo->appStartup.empty()) { TAG_LOGD(AAFwkTag::APPKIT, "not entry module or appStartup not exist."); return ERR_INVALID_VALUE; } - + if (!shellContextRef_) { + SetJsAbilityStage(stageContext); + } std::vector jsStartupTasks; int32_t result = RegisterStartupTaskFromProfile(jsStartupTasks); if (result != ERR_OK) { @@ -803,5 +774,52 @@ bool JsAbilityStage::GetResFromResMgr( profileInfo.emplace_back(profile); return true; } + +void JsAbilityStage::SetJsAbilityStage(const std::shared_ptr &context) +{ + if (!context) { + TAG_LOGE(AAFwkTag::APPKIT, "context is nullptr"); + return; + } + + HandleScope handleScope(jsRuntime_); + auto env = jsRuntime_.GetNapiEnv(); + + napi_value obj = nullptr; + if (jsAbilityStageObj_) { + obj = jsAbilityStageObj_->GetNapiValue(); + if (!CheckTypeForNapiValue(env, obj, napi_object)) { + TAG_LOGE(AAFwkTag::APPKIT, "Failed to get AbilityStage object"); + return; + } + } + + napi_value contextObj = CreateJsAbilityStageContext(env, context, nullptr, nullptr); + shellContextRef_ = JsRuntime::LoadSystemModuleByEngine(env, "application.AbilityStageContext", &contextObj, 1); + if (shellContextRef_ == nullptr) { + TAG_LOGE(AAFwkTag::APPKIT, "Failed to get LoadSystemModuleByEngine"); + return; + } + contextObj = shellContextRef_->GetNapiValue(); + if (!CheckTypeForNapiValue(env, contextObj, napi_object)) { + TAG_LOGE(AAFwkTag::APPKIT, "Failed to get context native object"); + return; + } + auto workContext = new (std::nothrow) std::weak_ptr(context); + napi_coerce_to_native_binding_object( + env, contextObj, DetachCallbackFunc, AttachAbilityStageContext, workContext, nullptr); + context->Bind(jsRuntime_, shellContextRef_.get()); + + if (obj != nullptr) { + napi_set_named_property(env, obj, "context", contextObj); + } + TAG_LOGD(AAFwkTag::APPKIT, "Set ability stage context"); + napi_wrap(env, contextObj, workContext, + [](napi_env, void* data, void*) { + TAG_LOGD(AAFwkTag::APPKIT, "Finalizer for weak_ptr ability stage context is called"); + delete static_cast*>(data); + }, + nullptr, nullptr); +} } // namespace AbilityRuntime } // namespace OHOS diff --git a/frameworks/native/appkit/ability_runtime/context/application_context.cpp b/frameworks/native/appkit/ability_runtime/context/application_context.cpp index 29980816e1..c87c71944c 100644 --- a/frameworks/native/appkit/ability_runtime/context/application_context.cpp +++ b/frameworks/native/appkit/ability_runtime/context/application_context.cpp @@ -544,6 +544,19 @@ std::string ApplicationContext::GetAppRunningUniqueId() const return appRunningUniqueId_; } +int32_t ApplicationContext::GetCurrentAppCloneIndex() +{ + TAG_LOGD(AAFwkTag::APPKIT, "getCurrentAppCloneIndex is %{public}d.", appIndex_); + return appIndex_; +} + +int32_t ApplicationContext::GetCurrentAppMode() +{ + TAG_LOGD(AAFwkTag::APPKIT, "getCurrentMode is %{public}d.", appMode_); + return appMode_; +} + + void ApplicationContext::SetAppRunningUniqueId(const std::string &appRunningUniqueId) { TAG_LOGD(AAFwkTag::APPKIT, "SetAppRunningUniqueId is %{public}s.", appRunningUniqueId.c_str()); @@ -558,5 +571,17 @@ int32_t ApplicationContext::SetSupportedProcessCacheSelf(bool isSupport) TAG_LOGE(AAFwkTag::APPKIT, "contextImpl_ is nullptr."); return ERR_INVALID_VALUE; } + +void ApplicationContext::SetCurrentAppCloneIndex(int32_t appIndex) +{ + TAG_LOGD(AAFwkTag::APPKIT, "setCurrentAppCloneIndex is %{public}d.", appIndex); + appIndex_ = appIndex; +} + +void ApplicationContext::SetCurrentAppMode(int32_t appMode) +{ + TAG_LOGD(AAFwkTag::APPKIT, "setCurrentAppMode is %{public}d.", appMode); + appMode_ = appMode; +} } // namespace AbilityRuntime } // namespace OHOS diff --git a/frameworks/native/appkit/ability_runtime/context/js_application_context_utils.cpp b/frameworks/native/appkit/ability_runtime/context/js_application_context_utils.cpp index 0a6fbedf1a..c18df7372d 100644 --- a/frameworks/native/appkit/ability_runtime/context/js_application_context_utils.cpp +++ b/frameworks/native/appkit/ability_runtime/context/js_application_context_utils.cpp @@ -22,6 +22,7 @@ #include "ability_manager_interface.h" #include "ability_runtime_error_util.h" #include "application_context.h" +#include "application_info.h" #include "application_context_manager.h" #include "hilog_tag_wrapper.h" #include "hilog_wrapper.h" @@ -801,6 +802,29 @@ napi_value JsApplicationContextUtils::OnGetRunningProcessInformation(napi_env en return result; } +napi_value JsApplicationContextUtils::GetCurrentAppCloneIndex(napi_env env, napi_callback_info info) +{ + GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsApplicationContextUtils, + OnGetCurrentAppCloneIndex, APPLICATION_CONTEXT_NAME); +} + +napi_value JsApplicationContextUtils::OnGetCurrentAppCloneIndex(napi_env env, NapiCallbackInfo& info) +{ + TAG_LOGD(AAFwkTag::APPKIT, "Get App Index"); + auto context = applicationContext_.lock(); + if (context == nullptr) { + TAG_LOGE(AAFwkTag::APPKIT, "context is nullptr."); + ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_CONTEXT); + return CreateJsUndefined(env); + } + if (context->GetCurrentAppMode() != static_cast(AppExecFwk::MultiAppModeType::APP_CLONE)) { + ThrowError(env, AbilityErrorCode::ERROR_NOT_APP_CLONE); + return CreateJsUndefined(env); + } + int32_t appIndex = context->GetCurrentAppCloneIndex(); + return CreateJsValue(env, appIndex); +} + void JsApplicationContextUtils::Finalizer(napi_env env, void *data, void *hint) { TAG_LOGD(AAFwkTag::APPKIT, "called"); @@ -1492,6 +1516,8 @@ void JsApplicationContextUtils::BindNativeApplicationContext(napi_env env, napi_ JsApplicationContextUtils::GetRunningProcessInformation); BindNativeFunction(env, object, "getRunningProcessInformation", MD_NAME, JsApplicationContextUtils::GetRunningProcessInformation); + BindNativeFunction(env, object, "getCurrentAppCloneIndex", MD_NAME, + JsApplicationContextUtils::GetCurrentAppCloneIndex); BindNativeFunction(env, object, "getGroupDir", MD_NAME, JsApplicationContextUtils::GetGroupDir); BindNativeFunction(env, object, "restartApp", MD_NAME, diff --git a/frameworks/native/appkit/ability_runtime/service_extension_context.cpp b/frameworks/native/appkit/ability_runtime/service_extension_context.cpp index 7f4d2de6ee..e3649d0694 100644 --- a/frameworks/native/appkit/ability_runtime/service_extension_context.cpp +++ b/frameworks/native/appkit/ability_runtime/service_extension_context.cpp @@ -125,8 +125,12 @@ ErrCode ServiceExtensionContext::ConnectAbility( ErrCode ServiceExtensionContext::StartAbilityWithAccount(const AAFwk::Want &want, int32_t accountId) const { - TAG_LOGD(AAFwkTag::APPKIT, "%{public}s begin.", __func__); - TAG_LOGI(AAFwkTag::APPKIT, "%{public}d accountId:", accountId); + std::string callerName = ""; + if (GetAbilityInfo() != nullptr) { + callerName = GetAbilityInfo()->name; + } + TAG_LOGI(AAFwkTag::APPKIT, "accountId: %{public}d, ability: %{public}s, caller: %{public}s", + accountId, want.GetElement().GetURI().c_str(), callerName.c_str()); (const_cast(want)).SetParam(START_ABILITY_TYPE, true); ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartAbility( want, token_, ILLEGAL_REQUEST_CODE, accountId); diff --git a/frameworks/native/appkit/app/child_main_thread.cpp b/frameworks/native/appkit/app/child_main_thread.cpp index 004d0cca2b..a6030e6d93 100644 --- a/frameworks/native/appkit/app/child_main_thread.cpp +++ b/frameworks/native/appkit/app/child_main_thread.cpp @@ -14,7 +14,7 @@ */ #include "child_main_thread.h" - +#include #include "bundle_mgr_proxy.h" #include "child_process_manager.h" #include "constants.h" @@ -172,7 +172,12 @@ void ChildMainThread::InitNativeLib(const BundleInfo &bundleInfo) GetNativeLibPath(bundleInfo, appLibPaths); bool isSystemApp = bundleInfo.applicationInfo.isSystemApp; TAG_LOGD(AAFwkTag::APPKIT, "the application isSystemApp: %{public}d", isSystemApp); - AbilityRuntime::JsRuntime::SetAppLibPath(appLibPaths, isSystemApp); + + if (processInfo_->processType != CHILD_PROCESS_TYPE_NATIVE) { + AbilityRuntime::JsRuntime::SetAppLibPath(appLibPaths, isSystemApp); + } else { + UpdateNativeChildLibPath(appLibPaths); + } } void ChildMainThread::ExitProcessSafely() @@ -222,6 +227,67 @@ void ChildMainThread::HandleExitProcessSafely() } } +bool ChildMainThread::ScheduleRunNativeProc(const sptr &mainProcessCb) +{ + TAG_LOGD(AAFwkTag::APPKIT, "ScheduleRunNativeProc"); + if (mainProcessCb == nullptr) { + TAG_LOGE(AAFwkTag::APPKIT, "Main process callback is null"); + return false; + } + + if (mainHandler_ == nullptr) { + TAG_LOGE(AAFwkTag::APPKIT, "mainHandler_ is null"); + return false; + } + + auto task = [weak = wptr(this), callback = sptr(mainProcessCb)]() { + auto childMainThread = weak.promote(); + if (childMainThread == nullptr) { + TAG_LOGE(AAFwkTag::APPKIT, "childMainThread is nullptr, ScheduleRunNativeProc failed."); + return; + } + childMainThread->HandleRunNativeProc(callback); + }; + if (!mainHandler_->PostTask(task, "ChildMainThread::HandleRunNativeProc")) { + TAG_LOGE(AAFwkTag::APPKIT, "HandleRunNativeProc PostTask task failed."); + return false; + } + return true; +} + +void ChildMainThread::HandleRunNativeProc(const sptr &mainProcessCb) +{ + TAG_LOGD(AAFwkTag::APPKIT, "HandleRunNativeProc called start."); + if (!processInfo_) { + TAG_LOGE(AAFwkTag::APPKIT, "processInfo is null."); + return; + } + + ChildProcessManager &childProcessMgr = ChildProcessManager::GetInstance(); + childProcessMgr.LoadNativeLib(processInfo_->srcEntry, mainProcessCb); + TAG_LOGD(AAFwkTag::APPKIT, "HandleRunNativeProc end."); + ExitProcessSafely(); +} + +void ChildMainThread::UpdateNativeChildLibPath(const AppLibPathMap &appLibPaths) +{ + std::string nativeLibPath; + for (const auto &libPathPair : appLibPaths) { + for (const auto &libDir : libPathPair.second) { + nativeLibPath = libDir; + if (!nativeLibPath.empty() && nativeLibPath.back() != '/') { + nativeLibPath += '/'; + } + + nativeLibPath += processInfo_->srcEntry; + if (access(nativeLibPath.c_str(), F_OK) == 0) { + processInfo_->srcEntry = nativeLibPath; + break; + } + } + } +} + void ChildMainThread::GetNativeLibPath(const BundleInfo &bundleInfo, AppLibPathMap &appLibPaths) { std::string nativeLibraryPath = bundleInfo.applicationInfo.nativeLibraryPath; diff --git a/frameworks/native/appkit/app/dump_ffrt_helper.cpp b/frameworks/native/appkit/app/dump_ffrt_helper.cpp index 13f705d6da..ee589fa8aa 100644 --- a/frameworks/native/appkit/app/dump_ffrt_helper.cpp +++ b/frameworks/native/appkit/app/dump_ffrt_helper.cpp @@ -26,7 +26,7 @@ int DumpFfrtHelper::DumpFfrt(std::string& result) { result.resize(MAX_BUF_SIZE); - int printNum = ffrt_dump(static_cast(ffrt_dump_cmd_t::DUMP_INFO_ALL), &result[0], MAX_BUF_SIZE); + int printNum = ffrt_dump(ffrt_dump_cmd_t::DUMP_INFO_ALL, &result[0], MAX_BUF_SIZE); if (printNum > 0) { result.resize(printNum); return 0; diff --git a/frameworks/native/appkit/app/main_thread.cpp b/frameworks/native/appkit/app/main_thread.cpp index c43081fb63..361b620986 100644 --- a/frameworks/native/appkit/app/main_thread.cpp +++ b/frameworks/native/appkit/app/main_thread.cpp @@ -640,7 +640,16 @@ void MainThread::ScheduleJsHeapMemory(OHOS::AppExecFwk::JsHeapDumpInfo &info) return; } if (info.needSnapshot == true) { - runtime->DumpHeapSnapshot(info.tid, info.needGc); + std::vector fdVec; + for (auto &fd : info.fdVec) { + uint32_t newFd = dup(fd); + if (newFd == -1) { + TAG_LOGE(AAFwkTag::APPKIT, "dup failed."); + return; + } + fdVec.push_back(newFd); + } + runtime->DumpHeapSnapshot(info.tid, info.needGc, fdVec, info.tidVec); } else { if (info.needGc == true) { runtime->ForceFullGC(info.tid); @@ -1189,7 +1198,7 @@ bool GetBundleForLaunchApplication(std::shared_ptr bundleMgrHel int32_t appIndex, BundleInfo &bundleInfo) { bool queryResult; - if (appIndex > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + if (appIndex > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { TAG_LOGD(AAFwkTag::APPKIT, "The bundleName = %{public}s.", bundleName.c_str()); queryResult = (bundleMgrHelper->GetSandboxBundleInfo(bundleName, appIndex, UNSPECIFIED_USERID, bundleInfo) == 0); @@ -1319,6 +1328,9 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con contextImpl->SetApplicationInfo(std::make_shared(appInfo)); std::shared_ptr applicationContext = AbilityRuntime::ApplicationContext::GetInstance(); + int32_t appIndex = appLaunchData.GetAppIndex(); + applicationContext->SetCurrentAppCloneIndex(appIndex); + applicationContext->SetCurrentAppMode(static_cast(appInfo.multiAppMode.multiAppModeType)); applicationContext->AttachContextImpl(contextImpl); auto appRunningId = appLaunchData.GetAppRunningUniqueId(); applicationContext->SetAppRunningUniqueId(appRunningId); @@ -3116,12 +3128,22 @@ void MainThread::AssertFaultPauseMainThreadDetection() { TAG_LOGD(AAFwkTag::APPKIT, "Called."); SetAppDebug(AbilityRuntime::AppFreezeState::AppFreezeFlag::ASSERT_DEBUG_MODE, true); + if (appMgr_ == nullptr) { + TAG_LOGE(AAFwkTag::APPKIT, "appMgr is nullptr."); + return; + } + appMgr_->SetAppAssertionPauseState(true); } void MainThread::AssertFaultResumeMainThreadDetection() { TAG_LOGD(AAFwkTag::APPKIT, "Called."); SetAppDebug(AbilityRuntime::AppFreezeState::AppFreezeFlag::ASSERT_DEBUG_MODE, false); + if (appMgr_ == nullptr) { + TAG_LOGE(AAFwkTag::APPKIT, "appMgr is nullptr."); + return; + } + appMgr_->SetAppAssertionPauseState(false); } void MainThread::HandleInitAssertFaultTask(bool isDebugModule, bool isDebugApp) diff --git a/frameworks/native/appkit/app/ohos_application.cpp b/frameworks/native/appkit/app/ohos_application.cpp index 77d7dce47e..262301b742 100644 --- a/frameworks/native/appkit/app/ohos_application.cpp +++ b/frameworks/native/appkit/app/ohos_application.cpp @@ -676,7 +676,7 @@ std::shared_ptr OHOSApplication::AddAbilityStage( ohosApplication->AutoStartupDone(abilityRecord, abilityStage, moduleName); callback(abilityStage->GetContext()); }; - abilityStage->RunAutoStartupTask(autoStartupCallback, isAsyncCallback); + abilityStage->RunAutoStartupTask(autoStartupCallback, isAsyncCallback, stageContext); if (isAsyncCallback) { TAG_LOGI(AAFwkTag::APPKIT, "waiting for startup"); return nullptr; diff --git a/frameworks/native/appkit/app_startup/js_startup_task_executor.cpp b/frameworks/native/appkit/app_startup/js_startup_task_executor.cpp index 8ea932fc5a..e4bb365e22 100644 --- a/frameworks/native/appkit/app_startup/js_startup_task_executor.cpp +++ b/frameworks/native/appkit/app_startup/js_startup_task_executor.cpp @@ -182,6 +182,7 @@ void JsStartupTaskExecutor::ReplyFailed(StartupTaskResultCallback *callback, std::shared_ptr result = std::make_shared(resultCode, resultMessage); callback->Call(result); delete callback; + callback = nullptr; } void JsStartupTaskExecutor::ReplyFailed(std::unique_ptr callback, @@ -205,6 +206,7 @@ void JsStartupTaskExecutor::ReplySucceeded(StartupTaskResultCallback *callback, std::shared_ptr result = std::make_shared(resultRef); callback->Call(result); delete callback; + callback = nullptr; } } // namespace AbilityRuntime } // namespace OHOS diff --git a/frameworks/native/appkit/app_startup/js_startup_task_result.cpp b/frameworks/native/appkit/app_startup/js_startup_task_result.cpp index cdacf747ad..113f5d37e6 100644 --- a/frameworks/native/appkit/app_startup/js_startup_task_result.cpp +++ b/frameworks/native/appkit/app_startup/js_startup_task_result.cpp @@ -35,7 +35,7 @@ StartupTaskResult::ResultType JsStartupTaskResult::GetResultType() const return ResultType::JS; } -std::shared_ptr JsStartupTaskResult::GetJsStartupResultRef() const +const std::shared_ptr& JsStartupTaskResult::GetJsStartupResultRef() const { return jsStartupResultRef_; } diff --git a/frameworks/native/appkit/app_startup/startup_config.cpp b/frameworks/native/appkit/app_startup/startup_config.cpp index a77d6560e6..3e0dffed88 100644 --- a/frameworks/native/appkit/app_startup/startup_config.cpp +++ b/frameworks/native/appkit/app_startup/startup_config.cpp @@ -36,12 +36,11 @@ int32_t StartupConfig::GetAwaitTimeoutMs() const return awaitTimeoutMs_; } -int32_t StartupConfig::ListenerOnCompleted(const std::shared_ptr &result) +void StartupConfig::ListenerOnCompleted(const std::shared_ptr &result) { if (listener_ != nullptr) { listener_->OnCompleted(result); } - return ERR_OK; } } // namespace AbilityRuntime } // namespace OHOS diff --git a/frameworks/native/appkit/app_startup/startup_manager.cpp b/frameworks/native/appkit/app_startup/startup_manager.cpp index d64aeab7fd..3cc7f822ca 100644 --- a/frameworks/native/appkit/app_startup/startup_manager.cpp +++ b/frameworks/native/appkit/app_startup/startup_manager.cpp @@ -128,7 +128,7 @@ void StartupManager::SetDefaultConfig(const std::shared_ptr &conf defaultConfig_ = config; } -std::shared_ptr StartupManager::GetDefaultConfig() const +const std::shared_ptr& StartupManager::GetDefaultConfig() const { return defaultConfig_; } diff --git a/frameworks/native/appkit/app_startup/startup_task.cpp b/frameworks/native/appkit/app_startup/startup_task.cpp index 4ce4529368..00203dcc5a 100644 --- a/frameworks/native/appkit/app_startup/startup_task.cpp +++ b/frameworks/native/appkit/app_startup/startup_task.cpp @@ -13,22 +13,18 @@ * limitations under the License. */ - #include "startup_task.h" - #include "hilog_tag_wrapper.h" #include "hilog_wrapper.h" namespace OHOS { namespace AbilityRuntime { -StartupTask::StartupTask(const std::string &name) : name_(name) -{ - state_ = State::CREATED; -} +StartupTask::StartupTask(const std::string &name) : name_(name), state_(State::CREATED) +{} StartupTask::~StartupTask() = default; -std::string StartupTask::GetName() const +const std::string& StartupTask::GetName() const { return name_; } @@ -100,7 +96,7 @@ int32_t StartupTask::RemoveResult() return ERR_OK; } -std::shared_ptr StartupTask::GetResult() const +const std::shared_ptr& StartupTask::GetResult() const { return result_; } @@ -117,7 +113,7 @@ std::string StartupTask::DumpDependencies() const } bool isFirst = true; std::string dumpResult; - for (auto &iter : dependencies_) { + for (const auto &iter : dependencies_) { if (isFirst) { dumpResult = iter; isFirst = false; diff --git a/frameworks/native/appkit/app_startup/startup_task_manager.cpp b/frameworks/native/appkit/app_startup/startup_task_manager.cpp index 05ee16c31f..b7b3203ef7 100644 --- a/frameworks/native/appkit/app_startup/startup_task_manager.cpp +++ b/frameworks/native/appkit/app_startup/startup_task_manager.cpp @@ -47,10 +47,9 @@ int32_t StartupTaskManager::AddTask(const std::shared_ptr &task) return ERR_OK; } -int32_t StartupTaskManager::SetConfig(const std::shared_ptr &config) +void StartupTaskManager::SetConfig(const std::shared_ptr &config) { config_ = config; - return ERR_OK; } int32_t StartupTaskManager::Prepare() diff --git a/frameworks/native/appkit/app_startup/startup_task_result.cpp b/frameworks/native/appkit/app_startup/startup_task_result.cpp index e9b0cebc5e..a378faf843 100644 --- a/frameworks/native/appkit/app_startup/startup_task_result.cpp +++ b/frameworks/native/appkit/app_startup/startup_task_result.cpp @@ -44,7 +44,7 @@ int32_t StartupTaskResult::GetResultCode() const return resultCode_; } -std::string StartupTaskResult::GetResultMessage() const +const std::string& StartupTaskResult::GetResultMessage() const { return resultMessage_; } diff --git a/frameworks/native/appkit/dfr/appfreeze_inner.cpp b/frameworks/native/appkit/dfr/appfreeze_inner.cpp index 96f50b67bc..743ad2b067 100644 --- a/frameworks/native/appkit/dfr/appfreeze_inner.cpp +++ b/frameworks/native/appkit/dfr/appfreeze_inner.cpp @@ -18,6 +18,7 @@ #include "ability_manager_client.h" #include "ability_state.h" +#include "appfreeze_manager.h" #include "app_recovery.h" #include "exit_reason.h" #include "ffrt.h" diff --git a/frameworks/native/child_process/BUILD.gn b/frameworks/native/child_process/BUILD.gn new file mode 100644 index 0000000000..4d5fe5006a --- /dev/null +++ b/frameworks/native/child_process/BUILD.gn @@ -0,0 +1,66 @@ +# 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/ohos.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") + +config("child_process_ndk_config") { + include_dirs = + [ "${ability_runtime_ndk_path}/ability/ability_runtime/child_process" ] + + if (target_cpu == "arm") { + cflags = [ "-DBINDER_IPC_32BIT" ] + } +} + +ohos_shared_library("child_process") { + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + cfi_vcall_icall_only = true + debug = false + } + branch_protector_ret = "pac_ret" + + include_dirs = [ "include" ] + + configs = [ "${ability_runtime_services_path}/common:common_config" ] + public_configs = [ ":child_process_ndk_config" ] + + sources = [ + "${ability_runtime_native_path}/child_process/src/native_child_callback.cpp", + "${ability_runtime_native_path}/child_process/src/native_child_process.cpp", + ] + + deps = [ + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_innerkits_path}/child_process_manager:child_process_manager", + "${ability_runtime_native_path}/ability/native:ability_business_error", + ] + + external_deps = [ + "c_utils:utils", + "hilog:libhilog", + "ipc:ipc_capi", + "ipc:ipc_core", + ] + + output_extension = "so" + innerapi_tags = [ "ndk" ] + install_images = [ "system" ] + subsystem_name = "ability" + part_name = "ability_runtime" +} diff --git a/frameworks/native/child_process/include/native_child_callback.h b/frameworks/native/child_process/include/native_child_callback.h new file mode 100644 index 0000000000..b0be67b876 --- /dev/null +++ b/frameworks/native/child_process/include/native_child_callback.h @@ -0,0 +1,40 @@ +/* + * 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_NATIVE_CHILD_CALLBACK_H +#define OHOS_ABILITY_RUNTIME_NATIVE_CHILD_CALLBACK_H + +#include "native_child_notify_stub.h" +#include "native_child_process.h" + +namespace OHOS { +namespace AbilityRuntime { + +class NativeChildCallback : public OHOS::AppExecFwk::NativeChildNotifyStub { +public: + explicit NativeChildCallback(OH_Ability_OnNativeChildProcessStarted cb); + ~NativeChildCallback() = default; + + void OnNativeChildStarted(const sptr &nativeChild) override; + void OnError(int32_t errCode) override; + +private: + OH_Ability_OnNativeChildProcessStarted callback_ = nullptr; +}; + +} // namespace AbilityRuntime +} // namespace OHOS + +#endif // OHOS_ABILITY_RUNTIME_NATIVE_CHILD_CALLBACK_H diff --git a/frameworks/native/child_process/src/native_child_callback.cpp b/frameworks/native/child_process/src/native_child_callback.cpp new file mode 100644 index 0000000000..1102c8b3fb --- /dev/null +++ b/frameworks/native/child_process/src/native_child_callback.cpp @@ -0,0 +1,66 @@ +/* + * 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 "native_child_callback.h" +#include "hilog_tag_wrapper.h" +#include "hilog_wrapper.h" +#include "ipc_inner_object.h" +#include "child_process_manager_error_utils.h" + +namespace OHOS { +namespace AbilityRuntime { + +NativeChildCallback::NativeChildCallback(OH_Ability_OnNativeChildProcessStarted cb) + : NativeChildNotifyStub(), callback_(cb) +{ +} + +void NativeChildCallback::OnNativeChildStarted(const sptr &nativeChild) +{ + if (callback_ == nullptr) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Native child process started, but callback is null?"); + return; + } + + if (!nativeChild) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Native child process ipc object is null"); + return; + } + + TAG_LOGI(AAFwkTag::PROCESSMGR, "Native child process started"); + sptr ipcRemote = nativeChild; + OHIPCRemoteProxy *ipcProxy = CreateIPCRemoteProxy(ipcRemote); + if (ipcProxy == nullptr) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Convert inner ipc object to OHIPCRemoteProxy point failed"); + callback_(NCP_ERR_INTERNAL, nullptr); + return; + } + + callback_(static_cast(ChildProcessManagerErrorCode::ERR_OK), ipcProxy); +} + +void NativeChildCallback::OnError(int32_t errCode) +{ + if (callback_ == nullptr) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Native child process start failed, but callback is null?"); + return; + } + + TAG_LOGI(AAFwkTag::PROCESSMGR, "Native child process start failed, err %{public}d", errCode); + callback_(errCode, nullptr); +} + +} // namespace AbilityRuntime +} // namespace OHOS diff --git a/frameworks/native/child_process/src/native_child_process.cpp b/frameworks/native/child_process/src/native_child_process.cpp new file mode 100644 index 0000000000..d5036d7b8e --- /dev/null +++ b/frameworks/native/child_process/src/native_child_process.cpp @@ -0,0 +1,104 @@ +/* + * 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 "native_child_process.h" +#include +#include +#include "hilog_tag_wrapper.h" +#include "hilog_wrapper.h" +#include "native_child_callback.h" +#include "child_process_manager.h" + +using namespace OHOS; +using namespace OHOS::AbilityRuntime; + +namespace { + +std::mutex g_MutexCallBackObj; +sptr g_CallbackStub; +OH_Ability_OnNativeChildProcessStarted g_Callback = nullptr; + +const std::map CPM_ERRCODE_MAP = { + { ChildProcessManagerErrorCode::ERR_OK, NCP_NOERROR }, + { ChildProcessManagerErrorCode::ERR_MULTI_PROCESS_MODEL_DISABLED, NCP_ERR_MULTI_PROCESS_DISABLED }, + { ChildProcessManagerErrorCode::ERR_ALREADY_IN_CHILD_PROCESS, NCP_ERR_ALREADY_IN_CHILD }, + { ChildProcessManagerErrorCode::ERR_GET_APP_MGR_FAILED, NCP_ERR_SERVICE }, + { ChildProcessManagerErrorCode::ERR_GET_APP_MGR_START_PROCESS_FAILED, NCP_ERR_SERVICE }, + { ChildProcessManagerErrorCode::ERR_UNSUPPORT_NATIVE_CHILD_PROCESS, NCP_ERR_NOT_SUPPORTED }, + { ChildProcessManagerErrorCode::ERR_MAX_NATIVE_CHILD_PROCESSES, NCP_ERR_MAX_CHILD_PROCESSES_REACHED }, + { ChildProcessManagerErrorCode::ERR_NATIVE_CHILD_PROCESS_LOAD_LIB, NCP_ERR_CHILD_PROCESS_LOAD_LIB }, + { ChildProcessManagerErrorCode::ERR_NATIVE_CHILD_PROCESS_CONNECT, NCP_ERR_CHILD_PROCESS_CONNECT }, +}; + +int CvtChildProcessManagerErrCode(ChildProcessManagerErrorCode cpmErr) +{ + auto it = CPM_ERRCODE_MAP.find(cpmErr); + if (it == CPM_ERRCODE_MAP.end()) { + return NCP_ERR_INTERNAL; + } + + return it->second; +} + +void OnNativeChildProcessStartedWapper(int errCode, OHIPCRemoteProxy *ipcProxy) +{ + std::unique_lock autoLock(g_MutexCallBackObj); + if (g_Callback != nullptr) { + g_Callback(CvtChildProcessManagerErrCode(static_cast(errCode)), ipcProxy); + g_Callback = nullptr; + } else { + TAG_LOGW(AAFwkTag::PROCESSMGR, "Remote call twice?"); + } + + g_CallbackStub.clear(); +} + +} // Anonymous namespace + +int OH_Ability_CreateNativeChildProcess(const char* libName, OH_Ability_OnNativeChildProcessStarted onProcessStarted) +{ + if (libName == nullptr || *libName == '\0' || onProcessStarted == nullptr) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Invalid libname or callback"); + return NCP_ERR_INVALID_PARAM; + } + + std::string strLibName(libName); + if (strLibName.find("../") != std::string::npos) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Do not allow use relative path"); + return NCP_ERR_INVALID_PARAM; + } + + std::unique_lock autoLock(g_MutexCallBackObj); + if (g_Callback != nullptr || g_CallbackStub != nullptr) { + TAG_LOGW(AAFwkTag::PROCESSMGR, "Another native process process starting, try again later"); + return NCP_ERR_BUSY; + } + + sptr callbackStub(new (std::nothrow) NativeChildCallback(OnNativeChildProcessStartedWapper)); + if (!callbackStub) { + TAG_LOGE(AAFwkTag::PROCESSMGR, "Alloc callback ipc stub object faild."); + return NCP_ERR_INTERNAL; + } + + ChildProcessManager &mgr = ChildProcessManager::GetInstance(); + auto cpmErr = mgr.StartNativeChildProcessByAppSpawnFork(strLibName, callbackStub); + if (cpmErr != ChildProcessManagerErrorCode::ERR_OK) { + return CvtChildProcessManagerErrCode(cpmErr); + } + + g_Callback = onProcessStarted; + g_CallbackStub = callbackStub; + return NCP_NOERROR; +} diff --git a/frameworks/native/insight_intent/insight_intent_context/BUILD.gn b/frameworks/native/insight_intent/insight_intent_context/BUILD.gn index 66264511ed..1f51aad0e6 100644 --- a/frameworks/native/insight_intent/insight_intent_context/BUILD.gn +++ b/frameworks/native/insight_intent/insight_intent_context/BUILD.gn @@ -34,6 +34,7 @@ ohos_shared_library("insightintentcontext") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/runtime:runtime", "${ability_runtime_napi_path}/inner/napi_common:napi_common", "${ability_runtime_native_path}/ability/native:ability_business_error", diff --git a/frameworks/native/runtime/js_runtime.cpp b/frameworks/native/runtime/js_runtime.cpp index e272ba8612..30ce8611ea 100644 --- a/frameworks/native/runtime/js_runtime.cpp +++ b/frameworks/native/runtime/js_runtime.cpp @@ -626,7 +626,6 @@ void JsRuntime::FinishPreload() auto vm = GetEcmaVm(); CHECK_POINTER(vm); panda::JSNApi::PreFork(vm); - jsEnv_->StopMonitorJSHeapUsage(); } void JsRuntime::PostPreload(const Options& options) @@ -687,8 +686,6 @@ bool JsRuntime::Initialize(const Options& options) } NativeCreateEnv::RegCreateNapiEnvCallback(CreateNapiEnv); NativeCreateEnv::RegDestroyNapiEnvCallback(DestroyNapiEnv); - } else { - jsEnv_->StartMonitorJSHeapUsage(); } apiTargetVersion_ = options.apiTargetVersion; TAG_LOGD(AAFwkTag::JSRUNTIME, "Initialize: %{public}d.", apiTargetVersion_); @@ -1195,11 +1192,12 @@ void JsRuntime::DumpHeapSnapshot(bool isPrivate) nativeEngine->DumpHeapSnapshot(true, DumpFormat::JSON, isPrivate, false); } -void JsRuntime::DumpHeapSnapshot(uint32_t tid, bool isFullGC) +void JsRuntime::DumpHeapSnapshot(uint32_t tid, bool isFullGC, std::vector fdVec, + std::vector tidVec) { auto vm = GetEcmaVm(); CHECK_POINTER(vm); - DFXJSNApi::DumpHeapSnapshot(vm, 0, true, false, false, isFullGC, tid); + DFXJSNApi::DumpHeapSnapshot(vm, 0, true, false, false, isFullGC, tid, fdVec, tidVec); } void JsRuntime::ForceFullGC(uint32_t tid) diff --git a/frameworks/native/runtime/native_runtime_impl.cpp b/frameworks/native/runtime/native_runtime_impl.cpp index 98bf9d55dc..1eccd3c66c 100644 --- a/frameworks/native/runtime/native_runtime_impl.cpp +++ b/frameworks/native/runtime/native_runtime_impl.cpp @@ -147,9 +147,6 @@ napi_status NativeRuntimeImpl::Init(const Options& options, napi_env env) } if (!options.preload) { - auto operatorObj = std::make_shared(options.bundleName, isModular, - options.isDebugVersion); - InitSourceMap(operatorObj, jsEnv); if (!options.isUnique) { InitTimerModule(jsEnv); } @@ -248,16 +245,6 @@ void NativeRuntimeImpl::InitConsoleModule(const std::shared_ptrInitConsoleModule(); } -void NativeRuntimeImpl::InitSourceMap(const std::shared_ptr operatorObj, - const std::shared_ptr& jsEnv) -{ - if (jsEnv == nullptr) { - TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv is nullptr."); - return; - } - jsEnv->InitSourceMap(operatorObj); -} - void NativeRuntimeImpl::InitTimerModule(const std::shared_ptr& jsEnv) { if (jsEnv == nullptr) { diff --git a/frameworks/simulator/ability_simulator/src/js_runtime_utils.cpp b/frameworks/simulator/ability_simulator/src/js_runtime_utils.cpp index 998bd24579..df9e345c84 100644 --- a/frameworks/simulator/ability_simulator/src/js_runtime_utils.cpp +++ b/frameworks/simulator/ability_simulator/src/js_runtime_utils.cpp @@ -299,21 +299,21 @@ std::unique_ptr CreateAsyncTaskWithLastParam(napi_env env, napi_v } std::unique_ptr CreateAsyncTaskWithLastParam(napi_env env, napi_value lastParam, - NapiAsyncTask::ExecuteCallback &&execute, nullptr_t, napi_value *result) + NapiAsyncTask::ExecuteCallback &&execute, std::nullptr_t, napi_value *result) { return CreateAsyncTaskWithLastParam( env, lastParam, std::make_unique(std::move(execute)), nullptr, result); } std::unique_ptr CreateAsyncTaskWithLastParam(napi_env env, napi_value lastParam, - nullptr_t, NapiAsyncTask::CompleteCallback &&complete, napi_value *result) + std::nullptr_t, NapiAsyncTask::CompleteCallback &&complete, napi_value *result) { return CreateAsyncTaskWithLastParam( env, lastParam, nullptr, std::make_unique(std::move(complete)), result); } std::unique_ptr CreateAsyncTaskWithLastParam(napi_env env, napi_value lastParam, - nullptr_t, nullptr_t, napi_value *result) + std::nullptr_t, std::nullptr_t, napi_value *result) { return CreateAsyncTaskWithLastParam(env, lastParam, std::unique_ptr(), std::unique_ptr(), result); diff --git a/hisysevent.yaml b/hisysevent.yaml index 7ee5356092..2779d3226e 100644 --- a/hisysevent.yaml +++ b/hisysevent.yaml @@ -352,3 +352,15 @@ START_STANDARD_ABILITIES: BUNDLE_NAME: {type: STRING, desc: bundle name} MODULE_NAME: {type: STRING, desc: module name} ABILITY_NAME: {type: STRING, desc: ability name} + +PREVENT_START_ABILITY: + __BASE: {type: BEHAVIOR, level: MINOR, desc: Process start control, preserve: true} + CALLER_UID: {type: INT32, desc: caller uid} + CALLER_PID: {type: INT32, desc: caller pid} + CALLER_PROCESS_NAME: {type: STRING, desc: caller process name} + CALLER_BUNDLE_NAME: {type: STRING, desc: caller bundle name} + CALLEE_BUNDLE_NAME: {type: STRING, desc: callee bundle name} + CALLEE_PROCESS_NAME: {type: STRING, desc: callee process name} + EXTENSION_ABILITY_TYPE: {type: INT32, desc: extension ability type} + ABILITY_NAME: {type: STRING, desc: caller ability name} + \ No newline at end of file diff --git a/interfaces/inner_api/ability_manager/BUILD.gn b/interfaces/inner_api/ability_manager/BUILD.gn index 4d3dbe7d92..c81443611c 100644 --- a/interfaces/inner_api/ability_manager/BUILD.gn +++ b/interfaces/inner_api/ability_manager/BUILD.gn @@ -92,7 +92,6 @@ ohos_shared_library("ability_manager") { "${ability_runtime_services_path}/abilitymgr/src/remote_on_listener_proxy.cpp", "${ability_runtime_services_path}/abilitymgr/src/remote_on_listener_stub.cpp", "${ability_runtime_services_path}/abilitymgr/src/sender_info.cpp", - "${ability_runtime_services_path}/abilitymgr/src/start_options.cpp", "${ability_runtime_services_path}/abilitymgr/src/system_ability_token_callback_stub.cpp", "${ability_runtime_services_path}/abilitymgr/src/ui_extension_ability_connect_info.cpp", "${ability_runtime_services_path}/abilitymgr/src/ui_extension_host_info.cpp", @@ -125,6 +124,7 @@ ohos_shared_library("ability_manager") { public_deps = [ ":ability_connect_callback_stub" ] deps = [ + ":ability_start_options", ":ability_start_setting", ":mission_info", ":process_options", @@ -180,6 +180,44 @@ ohos_shared_library("ability_manager") { part_name = "ability_runtime" } +ohos_shared_library("ability_start_options") { + sanitize = { + integer_overflow = true + ubsan = true + boundary_sanitize = true + cfi = true + cfi_cross_dso = true + cfi_vcall_icall_only = true + debug = false + } + branch_protector_ret = "pac_ret" + + include_dirs = [ + "include/", + "${ability_runtime_services_path}/common/include", + ] + + sources = + [ "${ability_runtime_services_path}/abilitymgr/src/start_options.cpp" ] + + deps = [ ":process_options" ] + + external_deps = [ + "c_utils:utils", + "hilog:libhilog", + "hisysevent:libhisysevent", + "ipc:ipc_core", + ] + + cflags_cc = [] + innerapi_tags = [ + "platformsdk", + "sasdk", + ] + subsystem_name = "ability" + part_name = "ability_runtime" +} + ohos_shared_library("mission_info") { sources = [ "${ability_runtime_services_path}/abilitymgr/src/mission_info.cpp", diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_client.h b/interfaces/inner_api/ability_manager/include/ability_manager_client.h index a4af818e37..67b4163983 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_client.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_client.h @@ -1479,6 +1479,17 @@ public: */ int32_t GetAbilityStateByPersistentId(int32_t persistentId, bool &state); + /** + * Transfer resultCode & want to abms. + * + * @param callerToken caller ability token. + * @param requestCode the resultCode of the ability to start. + * @param want Indicates the ability to start. + * @return Returns ERR_OK on success, others on failure. + */ + int32_t TransferAbilityResultForExtension(const sptr &callerToken, int32_t resultCode, + const Want &want); + private: AbilityManagerClient(); DISALLOW_COPY_AND_MOVE(AbilityManagerClient); diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_errors.h b/interfaces/inner_api/ability_manager/include/ability_manager_errors.h index 69e405d125..c512aa819c 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_errors.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_errors.h @@ -506,12 +506,17 @@ enum { ERR_NO_RESIDENT_PERMISSION, /** - * Result(2097250) for app twin index does not exist. + * Result(2097250) for app clone index does not exist. */ - ERR_APP_TWIN_INDEX_INVALID, + ERR_APP_CLONE_INDEX_INVALID, /** - * Result(2097251) for unlock screen failed in developer mode. + * Result(2097251) not support twin. + */ + ERR_MULTI_APP_NOT_SUPPORTED, + + /** + * Result(2097252) for unlock screen failed in developer mode. */ ERR_UNLOCK_SCREEN_FAILED_IN_DEVELOPER_MODE, }; diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_interface.h b/interfaces/inner_api/ability_manager/include/ability_manager_interface.h index d7f472c344..32d8cf430c 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_interface.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_interface.h @@ -1592,6 +1592,19 @@ public: { return 0; } + + /** + * Transfer resultCode & want to ability manager service. + * + * @param resultCode, the resultCode of the ability to terminate. + * @param resultWant, the Want of the ability to return. + * @return Returns ERR_OK on success, others on failure. + */ + virtual int32_t TransferAbilityResultForExtension(const sptr &callerToken, int32_t resultCode, + const Want &want) + { + return 0; + } }; } // namespace AAFwk } // namespace OHOS diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_ipc_interface_code.h b/interfaces/inner_api/ability_manager/include/ability_manager_ipc_interface_code.h index 9dbbf3df41..d9de07455d 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_ipc_interface_code.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_ipc_interface_code.h @@ -439,6 +439,7 @@ enum class AbilityManagerInterfaceCode { UNREGISTER_ABILITY_FIRST_FRAME_STATE_OBSERVER = 1127, // ipc for get ability state by persistent id GET_ABILITY_STATE_BY_PERSISTENT_ID = 1128, + TRANSFER_ABILITY_RESULT = 1129, // ipc id 2001-3000 for tools // ipc id for dumping state (2001) diff --git a/interfaces/inner_api/ability_manager/include/assert_fault_proxy.h b/interfaces/inner_api/ability_manager/include/assert_fault_proxy.h index eb98199c33..e2900cb419 100644 --- a/interfaces/inner_api/ability_manager/include/assert_fault_proxy.h +++ b/interfaces/inner_api/ability_manager/include/assert_fault_proxy.h @@ -16,6 +16,8 @@ #ifndef OHOS_ABILITY_RUNTIME_ASSERT_FAULT_PROXY_H #define OHOS_ABILITY_RUNTIME_ASSERT_FAULT_PROXY_H +#include +#include #include #include "iremote_broker.h" @@ -23,6 +25,7 @@ #include "iremote_proxy.h" #include "ability_connect_callback_stub.h" #include "assert_fault_interface.h" +#include "singleton.h" namespace OHOS { namespace AbilityRuntime { @@ -52,34 +55,39 @@ private: RemoteDiedHandler handler_; }; -class ModalSystemAssertUIExtension : public std::enable_shared_from_this { +class ModalSystemAssertUIExtension { public: + static ModalSystemAssertUIExtension &GetInstance(); ModalSystemAssertUIExtension() = default; virtual ~ModalSystemAssertUIExtension(); bool CreateModalUIExtension(const AAFwk::Want &want); + friend class AssertFaultProxy; + private: class AssertDialogConnection : public OHOS::AAFwk::AbilityConnectionStub { public: AssertDialogConnection() = default; - virtual ~AssertDialogConnection(); - - bool RequestShowDialog(const AAFwk::Want &want); - void CleanUp(); + virtual ~AssertDialogConnection() = default; + void SetReqeustAssertDialogWant(const AAFwk::Want &want); void OnAbilityConnectDone(const AppExecFwk::ElementName &element, const sptr &remoteObject, int resultCode) override; void OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode) override; private: - std::mutex mutex_; - std::atomic_bool isDialogShow_ = false; - std::queue consumptionList_; - sptr remoteObject_; - sptr deathRecipient_; + AAFwk::Want want_; }; +private: + bool DisconnectSystemUI(); + void TryNotifyOneWaitingThread(); + void TryNotifyOneWaitingThreadInner(); + + std::mutex assertResultMutex_; + std::condition_variable assertResultCV_; + int32_t reqeustCount_ = 0; sptr GetConnection(); std::mutex dialogConnectionMutex_; sptr dialogConnectionCallback_; diff --git a/interfaces/inner_api/ability_manager/include/dialog_session_info.h b/interfaces/inner_api/ability_manager/include/dialog_session_info.h index dcf0970434..fc6f550944 100644 --- a/interfaces/inner_api/ability_manager/include/dialog_session_info.h +++ b/interfaces/inner_api/ability_manager/include/dialog_session_info.h @@ -34,6 +34,7 @@ struct DialogAbilityInfo { int32_t bundleLabelId = 0; int32_t abilityIconId = 0; int32_t abilityLabelId = 0; + bool visible = true; std::string GetURI() const; bool ParseURI(const std::string &uri); diff --git a/interfaces/inner_api/ability_manager/include/process_options.h b/interfaces/inner_api/ability_manager/include/process_options.h index e0f3f45621..17a26e7c9f 100644 --- a/interfaces/inner_api/ability_manager/include/process_options.h +++ b/interfaces/inner_api/ability_manager/include/process_options.h @@ -24,6 +24,7 @@ enum class ProcessMode { UNSPECIFIED = 0, NEW_PROCESS_ATTACH_TO_PARENT = 1, NEW_PROCESS_ATTACH_TO_STATUS_BAR_ITEM = 2, + ATTACH_TO_STATUS_BAR_ITEM = 3, END }; @@ -46,9 +47,12 @@ public: static ProcessMode ConvertInt32ToProcessMode(int32_t value); static StartupVisibility ConvertInt32ToStartupVisibility(int32_t value); static bool IsNewProcessMode(ProcessMode value); + static bool IsAttachToStatusBarMode(ProcessMode value); + static bool IsValidProcessMode(ProcessMode value); ProcessMode processMode = ProcessMode::UNSPECIFIED; StartupVisibility startupVisibility = StartupVisibility::UNSPECIFIED; + std::string processName; }; } // namespace AAFwk } // namespace OHOS diff --git a/interfaces/inner_api/app_manager/BUILD.gn b/interfaces/inner_api/app_manager/BUILD.gn index c489963183..bd61cba560 100644 --- a/interfaces/inner_api/app_manager/BUILD.gn +++ b/interfaces/inner_api/app_manager/BUILD.gn @@ -88,6 +88,8 @@ ohos_shared_library("app_manager") { "src/appmgr/configuration_observer_stub.cpp", "src/appmgr/fault_data.cpp", "src/appmgr/memory_level_info.cpp", + "src/appmgr/native_child_notify_proxy.cpp", + "src/appmgr/native_child_notify_stub.cpp", "src/appmgr/page_state_data.cpp", "src/appmgr/priority_object.cpp", "src/appmgr/process_data.cpp", @@ -101,6 +103,7 @@ ohos_shared_library("app_manager") { "src/appmgr/render_state_data.cpp", "src/appmgr/render_state_observer_proxy.cpp", "src/appmgr/render_state_observer_stub.cpp", + "src/appmgr/running_multi_info.cpp", "src/appmgr/running_process_info.cpp", "src/appmgr/start_specified_ability_response_proxy.cpp", "src/appmgr/start_specified_ability_response_stub.cpp", diff --git a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_interface.h b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_interface.h index 297dcf2ae4..1e02903af6 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_interface.h +++ b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_interface.h @@ -288,14 +288,6 @@ public: */ virtual bool IsAttachDebug(const std::string &bundleName) = 0; - /** - * Set application assertion pause state. - * - * @param pid App process pid. - * @param flag assertion pause state. - */ - virtual void SetAppAssertionPauseState(int32_t pid, bool flag) {} - /** * @brief Set resident process enable status. * @param bundleName The application bundle name. @@ -354,7 +346,6 @@ public: REGISTER_ABILITY_DEBUG_RESPONSE, IS_ATTACH_DEBUG, START_SPECIFIED_PROCESS, - SET_APP_ASSERT_PAUSE_STATE, CLEAR_PROCESS_BY_TOKEN, REGISTER_ABILITY_MS_DELEGATE, KILL_PROCESSES_BY_PIDS, diff --git a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_proxy.h index 6abbe5a78a..31e49a2099 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_proxy.h +++ b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_proxy.h @@ -257,14 +257,6 @@ public: */ bool IsAttachDebug(const std::string &bundleName) override; - /** - * Set application assertion pause state. - * - * @param pid App process pid. - * @param flag assertion pause state. - */ - void SetAppAssertionPauseState(int32_t pid, bool flag) override; - /** * @brief Set resident process enable status. * @param bundleName The application bundle name. diff --git a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_stub.h b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_stub.h index 5605b65f01..0b65f5fcf5 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_stub.h +++ b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_stub.h @@ -81,7 +81,6 @@ private: int32_t HandleClearNonPersistWaitingDebugFlag(MessageParcel &data, MessageParcel &reply); int32_t HandleRegisterAbilityDebugResponse(MessageParcel &data, MessageParcel &reply); int32_t HandleIsAttachDebug(MessageParcel &data, MessageParcel &reply); - int32_t HandleSetAppAssertionPauseState(MessageParcel &data, MessageParcel &reply); int32_t HandleClearProcessByToken(MessageParcel &data, MessageParcel &reply); int32_t HandleIsMemorySizeSufficent(MessageParcel &data, MessageParcel &reply); int32_t HandleSetKeepAliveEnableState(MessageParcel &data, MessageParcel &reply); diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_jsheap_mem_info.h b/interfaces/inner_api/app_manager/include/appmgr/app_jsheap_mem_info.h index e720f38282..6791cf79fb 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_jsheap_mem_info.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_jsheap_mem_info.h @@ -16,16 +16,21 @@ #ifndef OHOS_ABILITY_RUNTIME_APP_JSHEAP_MEM_INFO_H #define OHOS_ABILITY_RUNTIME_APP_JSHEAP_MEM_INFO_H +#include #include "parcel.h" #include "iremote_object.h" namespace OHOS { namespace AppExecFwk { struct JsHeapDumpInfo : public Parcelable { + ~JsHeapDumpInfo(); uint32_t pid; uint32_t tid; bool needGc; bool needSnapshot; + std::vector fdVec; + std::vector tidVec; + bool ReadFromParcel(Parcel &parcel); virtual bool Marshalling(Parcel &parcel) const override; static JsHeapDumpInfo *Unmarshalling(Parcel &parcel); }; diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h index 82788269c7..bf0f144edc 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h @@ -441,7 +441,7 @@ public: */ virtual int StartRenderProcess(const std::string &renderParam, int32_t ipcFd, int32_t sharedFd, - int32_t crashFd, pid_t &renderPid); + int32_t crashFd, pid_t &renderPid, bool isGPU = false); /** * Render process call this to attach app manager service. @@ -612,14 +612,6 @@ public: */ void SetKeepAliveEnableState(const std::string &bundleName, bool enable); - /** - * Set application assertion pause state. - * - * @param pid App process pid. - * @param flag assertion pause state. - */ - void SetAppAssertionPauseState(int32_t pid, bool flag); - /** * Register application or process state observer. * @param observer, ability token. @@ -743,6 +735,8 @@ public: AppExecFwk::PreloadMode preloadMode, int32_t appIndex = 0); int32_t SetSupportedProcessCacheSelf(bool isSupport); + + void SaveBrowserChannel(sptr browser); private: void SetServiceManager(std::unique_ptr serviceMgr); /** diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_constants.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_constants.h index 7631203f7c..0eed09018a 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_constants.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_constants.h @@ -78,6 +78,7 @@ enum class ProcessType { NORMAL = 0, EXTENSION, RENDER, + GPU, }; enum class AppStartType { diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h index 723d2a714b..5da28ac373 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_interface.h @@ -41,6 +41,7 @@ #include "system_memory_attr.h" #include "want.h" #include "app_jsheap_mem_info.h" +#include "running_multi_info.h" namespace OHOS { namespace AppExecFwk { @@ -143,6 +144,17 @@ public: */ virtual int GetAllRunningProcesses(std::vector &info) = 0; + /** + * GetRunningMultiAppInfoByBundleName, call GetRunningMultiAppInfoByBundleName() through proxy project. + * Obtains information about multiapp that are running on the device. + * + * @param bundlename, bundle name in Application record. + * @param info, output multiapp information. + * @return ERR_OK ,return back success,others fail. + */ + virtual int32_t GetRunningMultiAppInfoByBundleName(const std::string &bundleName, + RunningMultiAppInfo &info) = 0; + /** * GetRunningProcessesByBundleType, call GetRunningProcessesByBundleType() through proxy project. * Obtains information about application processes by bundle type that are running on the device. @@ -334,11 +346,12 @@ public: * @param sharedFd, shared memory file descriptior. * @param crashFd, crash signal file descriptior. * @param renderPid, created render pid. + * @param isGPU, is or not gpu process * @return Returns ERR_OK on success, others on failure. */ virtual int StartRenderProcess(const std::string &renderParam, int32_t ipcFd, int32_t sharedFd, - int32_t crashFd, pid_t &renderPid) = 0; + int32_t crashFd, pid_t &renderPid, bool isGPU = false) = 0; /** * Render process call this to attach app manager service. @@ -652,6 +665,25 @@ public: } virtual int32_t SetSupportedProcessCacheSelf(bool isSupport) = 0; + + /** + * Set application assertion pause state. + * + * @param flag assertion pause state. + */ + virtual void SetAppAssertionPauseState(bool flag) {} + + /** + * Start native child process, callde by ChildProcessManager. + * @param libName lib file name to be load in child process + * @param childProcessCount current started child process count + * @param callback callback for notify start result + * @return Returns ERR_OK on success, others on failure. + */ + virtual int32_t StartNativeChildProcess(const std::string &libName, int32_t childProcessCount, + const sptr &callback) = 0; + + virtual void SaveBrowserChannel(sptr browser) = 0; }; } // namespace AppExecFwk } // namespace OHOS diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_ipc_interface_code.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_ipc_interface_code.h index abc01de315..31a18ff867 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_ipc_interface_code.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_ipc_interface_code.h @@ -99,7 +99,11 @@ enum class AppMgrInterfaceCode { PRELOAD_APPLICATION = 73, SET_SUPPORTED_PROCESS_CACHE_SELF = 74, APP_GET_RUNNING_PROCESSES_BY_BUNDLE_TYPE = 75, + START_NATIVE_CHILD_PROCESS = 76, + SAVE_BROWSER_CHANNEL = 77, + GET_RUNNING_MULTIAPP_INFO_BY_BUNDLENAME = 78, + SET_APP_ASSERT_PAUSE_STATE_SELF = 79, }; } // AppExecFwk } // OHOS -#endif // OHOS_ABILITY_RUNTIME_APP_MGR_IPC_INTERFACE_CODE_H \ No newline at end of file +#endif // OHOS_ABILITY_RUNTIME_APP_MGR_IPC_INTERFACE_CODE_H diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h index 3b5c4feebc..c51250908d 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_proxy.h @@ -122,6 +122,16 @@ public: */ virtual int32_t GetAllRunningProcesses(std::vector &info) override; + /** + * GetALLRunningMultiAppInfo, call GetALLRunningMultiAppInfo() through proxy project. + * Obtains information about multiapp that are running on the device. + * + * @param info, app name in multiappinfo. + * @return ERR_OK ,return back success,others fail. + */ + virtual int32_t GetRunningMultiAppInfoByBundleName(const std::string &bundleName, + RunningMultiAppInfo &info) override; + /** * GetRunningProcessesByBundleType, call GetRunningProcessesByBundleType() through proxy project. * Obtains information about application processes by bundle type that are running on the device. @@ -306,11 +316,12 @@ public: * @param sharedFd, shared memory file descriptior. * @param crashFd, crash signal file descriptior. * @param renderPid, created render pid. + * @param isGPU, is or not GPU process * @return Returns ERR_OK on success, others on failure. */ virtual int StartRenderProcess(const std::string &renderParam, int32_t ipcFd, int32_t sharedFd, - int32_t crashFd, pid_t &renderPid) override; + int32_t crashFd, pid_t &renderPid, bool isGPU = false) override; /** * Render process call this to attach app manager service. @@ -568,6 +579,26 @@ public: virtual int32_t NotifyMemorySizeStateChanged(bool isMemorySizeSufficent) override; int32_t SetSupportedProcessCacheSelf(bool isSupport) override; + + /** + * Set application assertion pause state. + * + * @param flag assertion pause state. + */ + void SetAppAssertionPauseState(bool flag) override; + + /** + * Start native child process, callde by ChildProcessManager. + * @param libName lib file name to be load in child process + * @param childProcessCount current started child process count + * @param callback callback for notify start result + * @return Returns ERR_OK on success, others on failure. + */ + int32_t StartNativeChildProcess(const std::string &libName, int32_t childProcessCount, + const sptr &callback) override; + + virtual void SaveBrowserChannel(sptr browser) override; + private: bool SendTransactCmd(AppMgrInterfaceCode code, MessageParcel &data, MessageParcel &reply); bool WriteInterfaceToken(MessageParcel &data); diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_stub.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_stub.h index 51de220229..19128d0d0d 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_stub.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_stub.h @@ -94,6 +94,7 @@ private: int32_t HandleUnregisterConfigurationObserver(MessageParcel &data, MessageParcel &reply); int32_t HandleDumpHeapMemory(MessageParcel &data, MessageParcel &reply); int32_t HandleDumpJsHeapMemory(MessageParcel &data, MessageParcel &reply); + int32_t HandleGetRunningMultiAppInfoByBundleName(MessageParcel &data, MessageParcel &reply); #ifdef ABILITY_COMMAND_FOR_TEST int32_t HandleBlockAppServiceDone(MessageParcel &data, MessageParcel &reply); #endif @@ -135,7 +136,9 @@ private: int32_t HandleGetAllUIExtensionProviderPid(MessageParcel &data, MessageParcel &reply); int32_t HandleNotifyMemorySizeStateChanged(MessageParcel &data, MessageParcel &reply); int32_t HandleSetSupportedProcessCacheSelf(MessageParcel &data, MessageParcel &reply); - + int32_t HandleSetAppAssertionPauseState(MessageParcel &data, MessageParcel &reply); + int32_t HandleStartNativeChildProcess(MessageParcel &data, MessageParcel &reply); + int32_t HandleSaveBrowserChannel(MessageParcel &data, MessageParcel &reply); using AppMgrFunc = int32_t (AppMgrStub::*)(MessageParcel &data, MessageParcel &reply); std::map memberFuncMap_; diff --git a/interfaces/inner_api/app_manager/include/appmgr/child_process_info.h b/interfaces/inner_api/app_manager/include/appmgr/child_process_info.h index 89b4706190..cb5352d12e 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/child_process_info.h +++ b/interfaces/inner_api/app_manager/include/appmgr/child_process_info.h @@ -22,10 +22,15 @@ namespace OHOS { namespace AppExecFwk { + +constexpr int32_t CHILD_PROCESS_TYPE_JS = 0; +constexpr int32_t CHILD_PROCESS_TYPE_NATIVE = 1; + struct ChildProcessInfo : public Parcelable { std::int32_t pid; std::int32_t hostPid; std::int32_t uid; + std::int32_t processType; std::string bundleName; std::string processName; std::string srcEntry; diff --git a/interfaces/inner_api/app_manager/include/appmgr/child_scheduler_interface.h b/interfaces/inner_api/app_manager/include/appmgr/child_scheduler_interface.h index beaa93d6a9..89fbfc623f 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/child_scheduler_interface.h +++ b/interfaces/inner_api/app_manager/include/appmgr/child_scheduler_interface.h @@ -34,9 +34,16 @@ public: */ virtual bool ScheduleExitProcessSafely() = 0; + /** + * Notify child process run main proc from shared lib. + * @param mainProcessCb Main process callback ipc object + */ + virtual bool ScheduleRunNativeProc(const sptr &mainProcessCb) = 0; + enum class Message { SCHEDULE_LOAD_JS = 0, SCHEDULE_EXIT_PROCESS_SAFELY = 1, + SCHEDULE_RUN_NATIVE_PROC = 2, }; }; } // namespace AppExecFwk diff --git a/interfaces/inner_api/app_manager/include/appmgr/child_scheduler_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/child_scheduler_proxy.h index 355dd1398a..f5cd00d0f1 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/child_scheduler_proxy.h +++ b/interfaces/inner_api/app_manager/include/appmgr/child_scheduler_proxy.h @@ -29,6 +29,7 @@ public: bool ScheduleLoadJs() override; bool ScheduleExitProcessSafely() override; + bool ScheduleRunNativeProc(const sptr &mainProcessCb) override; private: bool WriteInterfaceToken(MessageParcel &data); diff --git a/interfaces/inner_api/app_manager/include/appmgr/child_scheduler_stub.h b/interfaces/inner_api/app_manager/include/appmgr/child_scheduler_stub.h index 6a73ccbf03..a6ecf59dce 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/child_scheduler_stub.h +++ b/interfaces/inner_api/app_manager/include/appmgr/child_scheduler_stub.h @@ -36,6 +36,7 @@ public: private: int32_t HandleScheduleLoadJs(MessageParcel &data, MessageParcel &reply); int32_t HandleScheduleExitProcessSafely(MessageParcel &data, MessageParcel &reply); + int32_t HandleScheduleRunNativeProc(MessageParcel &data, MessageParcel &reply); using ChildSchedulerFunc = int32_t (ChildSchedulerStub::*)(MessageParcel &data, MessageParcel &reply); std::map memberFuncMap_; diff --git a/interfaces/inner_api/app_manager/include/appmgr/irender_scheduler.h b/interfaces/inner_api/app_manager/include/appmgr/irender_scheduler.h index 22d9f891dc..35c114587a 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/irender_scheduler.h +++ b/interfaces/inner_api/app_manager/include/appmgr/irender_scheduler.h @@ -36,7 +36,7 @@ public: * @param crashFd, crash signal file descriptior. */ virtual void NotifyBrowserFd(int32_t ipcFd, int32_t sharedFd, - int32_t crashFd) = 0; + int32_t crashFd, sptr browser) = 0; enum class Message { NOTIFY_BROWSER_FD = 1, diff --git a/interfaces/inner_api/app_manager/include/appmgr/native_child_notify_interface.h b/interfaces/inner_api/app_manager/include/appmgr/native_child_notify_interface.h new file mode 100644 index 0000000000..b901b6c107 --- /dev/null +++ b/interfaces/inner_api/app_manager/include/appmgr/native_child_notify_interface.h @@ -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. + */ + +#ifndef OHOS_ABILITY_RUNTIME_NATIVE_CHILD_NOTIFY_INTERFACE_H +#define OHOS_ABILITY_RUNTIME_NATIVE_CHILD_NOTIFY_INTERFACE_H + +#include "iremote_broker.h" + +namespace OHOS { +namespace AppExecFwk { + +class INativeChildNotify : public IRemoteBroker { +public: + DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.NativeChildNotify"); + + /** + * Notify native child process started. + * + * @param nativeChild child process ipc object + */ + virtual void OnNativeChildStarted(const sptr &nativeChild) = 0; + + /** + * Notify native child process start failed. + * + * @param errCode failed error code + */ + virtual void OnError(int32_t errCode) = 0; + +protected: + static constexpr uint32_t IPC_ID_ON_NATIVE_CHILD_STARTED = 0; + static constexpr uint32_t IPC_ID_ON_ERROR = 1; +}; + +} // OHOS +} // AppExecFwk + +#endif // OHOS_ABILITY_RUNTIME_NATIVE_CHILD_NOTIFY_INTERFACE_H \ No newline at end of file diff --git a/interfaces/inner_api/app_manager/include/appmgr/native_child_notify_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/native_child_notify_proxy.h new file mode 100644 index 0000000000..fabd51a855 --- /dev/null +++ b/interfaces/inner_api/app_manager/include/appmgr/native_child_notify_proxy.h @@ -0,0 +1,43 @@ +/* + * 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_NATIVE_CHILD_NOTIFY_PROXY_H +#define OHOS_ABILITY_RUNTIME_NATIVE_CHILD_NOTIFY_PROXY_H + +#include "native_child_notify_interface.h" +#include "iremote_proxy.h" + +namespace OHOS { +namespace AppExecFwk { + +class NativeChildNotifyProxy : public IRemoteProxy { +public: + explicit NativeChildNotifyProxy(const sptr &impl); + virtual ~NativeChildNotifyProxy() = default; + + void OnNativeChildStarted(const sptr &nativeChild) override; + void OnError(int32_t errCode) override; + +private: + bool WriteInterfaceToken(MessageParcel &data); + int32_t SendRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption& option); + + static inline BrokerDelegator delegator_; +}; + +} // OHOS +} // AppExecFwk + +#endif // OHOS_ABILITY_RUNTIME_NATIVE_CHILD_NOTIFY_PROXY_H \ No newline at end of file diff --git a/interfaces/inner_api/app_manager/include/appmgr/native_child_notify_stub.h b/interfaces/inner_api/app_manager/include/appmgr/native_child_notify_stub.h new file mode 100644 index 0000000000..a77580f3a0 --- /dev/null +++ b/interfaces/inner_api/app_manager/include/appmgr/native_child_notify_stub.h @@ -0,0 +1,41 @@ +/* + * 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_NATIVE_CHILD_NOTIFY_STUB_H +#define OHOS_ABILITY_RUNTIME_NATIVE_CHILD_NOTIFY_STUB_H + +#include "native_child_notify_interface.h" +#include "iremote_stub.h" + +namespace OHOS { +namespace AppExecFwk { + +class NativeChildNotifyStub : public IRemoteStub { +public: + NativeChildNotifyStub() = default; + virtual ~NativeChildNotifyStub() = default; + + int OnRemoteRequest( + uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; + +private: + int32_t HandleOnNativeChildStarted(MessageParcel &data, MessageParcel &reply); + int32_t HandleOnError(MessageParcel &data, MessageParcel &reply); +}; + +} // OHOS +} // AppExecFwk + +#endif // OHOS_ABILITY_RUNTIME_NATIVE_CHILD_NOTIFY_STUB_H \ No newline at end of file diff --git a/interfaces/inner_api/app_manager/include/appmgr/render_scheduler_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/render_scheduler_proxy.h index c529f55548..5465ad97b8 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/render_scheduler_proxy.h +++ b/interfaces/inner_api/app_manager/include/appmgr/render_scheduler_proxy.h @@ -40,7 +40,7 @@ public: * @param crashFd, crash signal file descriptior. */ virtual void NotifyBrowserFd(int32_t ipcFd, int32_t sharedFd, - int32_t crashFd) override; + int32_t crashFd, sptr browser) override; private: bool WriteInterfaceToken(MessageParcel &data); diff --git a/interfaces/inner_api/app_manager/include/appmgr/running_multi_info.h b/interfaces/inner_api/app_manager/include/appmgr/running_multi_info.h new file mode 100644 index 0000000000..954c4cd109 --- /dev/null +++ b/interfaces/inner_api/app_manager/include/appmgr/running_multi_info.h @@ -0,0 +1,47 @@ +/* + * 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_RUNNING_MULTI_INFO_H +#define OHOS_ABILITY_RUNTIME_RUNNING_MULTI_INFO_H + +#include +#include + +#include "ability_info.h" +#include "app_mgr_constants.h" +#include "parcel.h" + +namespace OHOS { +namespace AppExecFwk { +const int32_t MAX_CLONE_APP_NUM = 128; +struct RunningAppClone { + int32_t appCloneIndex; + int32_t uid; + std::vector pids; +}; + +struct RunningMultiAppInfo : public Parcelable { + std::string bundleName; + int32_t mode; + std::vector runningAppClones; + + bool ReadFromParcel(Parcel &parcel); + virtual bool Marshalling(Parcel &parcel) const override; + static RunningMultiAppInfo *Unmarshalling(Parcel &parcel); +}; +} // namespace AppExecFwk +} // namespace OHOS + +#endif // OHOS_ABILITY_RUNTIME_RUNNING_MULTI_INFO_H \ No newline at end of file diff --git a/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_proxy.cpp index 5cf084fdaf..741e1a6a10 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_proxy.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_proxy.cpp @@ -1076,34 +1076,6 @@ bool AmsMgrProxy::IsAttachDebug(const std::string &bundleName) return reply.ReadBool(); } -void AmsMgrProxy::SetAppAssertionPauseState(int32_t pid, bool flag) -{ - TAG_LOGD(AAFwkTag::APPMGR, "Called."); - MessageParcel data; - if (!WriteInterfaceToken(data)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write interface token failed."); - return; - } - - if (!data.WriteInt32(pid)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write pid fail."); - return; - } - - if (!data.WriteBool(flag)) { - TAG_LOGE(AAFwkTag::APPMGR, "Write flag fail."); - return; - } - - MessageParcel reply; - MessageOption option; - auto ret = SendTransactCmd(static_cast(IAmsMgr::Message::SET_APP_ASSERT_PAUSE_STATE), - data, reply, option); - if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::APPMGR, "Send request failed, err: %{public}d", ret); - } -} - void AmsMgrProxy::ClearProcessByToken(sptr token) { MessageParcel data; diff --git a/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_stub.cpp b/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_stub.cpp index 211810efe0..a864e55227 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_stub.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_stub.cpp @@ -115,8 +115,6 @@ void AmsMgrStub::CreateMemberFuncMap() &AmsMgrStub::HandleRegisterAbilityDebugResponse; memberFuncMap_[static_cast(IAmsMgr::Message::IS_ATTACH_DEBUG)] = &AmsMgrStub::HandleIsAttachDebug; - memberFuncMap_[static_cast(IAmsMgr::Message::SET_APP_ASSERT_PAUSE_STATE)] = - &AmsMgrStub::HandleSetAppAssertionPauseState; memberFuncMap_[static_cast(IAmsMgr::Message::CLEAR_PROCESS_BY_TOKEN)] = &AmsMgrStub::HandleClearProcessByToken; memberFuncMap_[static_cast(IAmsMgr::Message::KILL_PROCESSES_BY_PIDS)] = @@ -667,15 +665,6 @@ int32_t AmsMgrStub::HandleIsAttachDebug(MessageParcel &data, MessageParcel &repl return NO_ERROR; } -int32_t AmsMgrStub::HandleSetAppAssertionPauseState(MessageParcel &data, MessageParcel &reply) -{ - TAG_LOGD(AAFwkTag::APPMGR, "Called."); - auto pid = data.ReadInt32(); - auto flag = data.ReadBool(); - SetAppAssertionPauseState(pid, flag); - return NO_ERROR; -} - int32_t AmsMgrStub::HandleClearProcessByToken(MessageParcel &data, MessageParcel &reply) { HITRACE_METER(HITRACE_TAG_APP); diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_jsheap_mem_info.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_jsheap_mem_info.cpp index 02b4333129..619f615ccb 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_jsheap_mem_info.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_jsheap_mem_info.cpp @@ -19,10 +19,61 @@ namespace OHOS { namespace AppExecFwk { +namespace { +constexpr int32_t MAX_TID_COUNT = 40; +} + +JsHeapDumpInfo::~JsHeapDumpInfo() +{ + TAG_LOGI(AAFwkTag::APPMGR, "~JsHeapDumpInfo start"); + for (auto &fd : fdVec) { + close(fd); + } + fdVec.clear(); + tidVec.clear(); +} + bool JsHeapDumpInfo::Marshalling(Parcel &parcel) const { - return (parcel.WriteUint32(pid) && parcel.WriteUint32(tid) - && parcel.WriteBool(needGc) && parcel.WriteBool(needSnapshot)); + bool res = (parcel.WriteUint32(pid) && parcel.WriteUint32(tid) + && parcel.WriteBool(needGc) && parcel.WriteBool(needSnapshot) + && parcel.WriteUInt32Vector(fdVec) && parcel.WriteUInt32Vector(tidVec)); + + auto msgParcel = static_cast(&parcel); + if (msgParcel == nullptr) { + TAG_LOGE(AAFwkTag::APPMGR, "Dump Marshalling msgParcel==nullptr"); + return false; + } + for (auto &fd : fdVec) { + msgParcel->WriteFileDescriptor(fd); + } + return res; +} + +bool JsHeapDumpInfo::ReadFromParcel(Parcel &parcel) +{ + pid = parcel.ReadUint32(); + tid = parcel.ReadUint32(); + needGc = parcel.ReadBool(); + needSnapshot = parcel.ReadBool(); + if (fdVec.size() > MAX_TID_COUNT || tidVec.size() > MAX_TID_COUNT) { + TAG_LOGE(AAFwkTag::APPMGR, "fdVec or tidVec size more than 40."); + return false; + } + parcel.ReadUInt32Vector(&fdVec); + parcel.ReadUInt32Vector(&tidVec); + + auto msgParcel = static_cast(&parcel); + if (msgParcel == nullptr) { + TAG_LOGE(AAFwkTag::APPMGR, "ReadFromParcel failed."); + return false; + } + fdVec.clear(); + for (auto &tid : tidVec) { + uint32_t parcelFd = static_cast(msgParcel->ReadFileDescriptor()); + fdVec.push_back(parcelFd); + } + return true; } JsHeapDumpInfo *JsHeapDumpInfo::Unmarshalling(Parcel &parcel) @@ -32,10 +83,11 @@ JsHeapDumpInfo *JsHeapDumpInfo::Unmarshalling(Parcel &parcel) TAG_LOGE(AAFwkTag::APPMGR, "info nullptr"); return nullptr; } - info->pid = parcel.ReadUint32(); - info->tid = parcel.ReadUint32(); - info->needGc = parcel.ReadBool(); - info->needSnapshot = parcel.ReadBool(); + if (info && !info->ReadFromParcel(parcel)) { + TAG_LOGE(AAFwkTag::APPMGR, "JsHeapDumpInfo failed, because ReadFromParcel failed"); + delete info; + info = nullptr; + } return info; } } // namespace AppExecFwk diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp index 22bbd4dac0..97f99b4bbe 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp @@ -758,12 +758,12 @@ int AppMgrClient::PreStartNWebSpawnProcess() int AppMgrClient::StartRenderProcess(const std::string &renderParam, int32_t ipcFd, int32_t sharedFd, - int32_t crashFd, pid_t &renderPid) + int32_t crashFd, pid_t &renderPid, bool isGPU) { sptr service = iface_cast(mgrHolder_->GetRemoteObject()); if (service != nullptr) { return service->StartRenderProcess(renderParam, ipcFd, sharedFd, crashFd, - renderPid); + renderPid, isGPU); } return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED; } @@ -959,14 +959,6 @@ bool AppMgrClient::IsAttachDebug(const std::string &bundleName) return amsService_->IsAttachDebug(bundleName); } -void AppMgrClient::SetAppAssertionPauseState(int32_t pid, bool flag) -{ - if (!IsAmsServiceReady()) { - return; - } - amsService_->SetAppAssertionPauseState(pid, flag); -} - bool AppMgrClient::IsAmsServiceReady() { if (mgrHolder_ == nullptr) { @@ -1182,5 +1174,15 @@ int32_t AppMgrClient::SetSupportedProcessCacheSelf(bool isSupport) } return service->SetSupportedProcessCacheSelf(isSupport); } + +void AppMgrClient::SaveBrowserChannel(sptr browser) +{ + sptr service = iface_cast(mgrHolder_->GetRemoteObject()); + if (service == nullptr) { + TAG_LOGE(AAFwkTag::APPMGR, "Service is nullptr."); + return; + } + service->SaveBrowserChannel(browser); +} } // namespace AppExecFwk } // namespace OHOS diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp index aec1f49eb8..4108fbb017 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp @@ -237,6 +237,30 @@ int32_t AppMgrProxy::GetAllRunningProcesses(std::vector &inf return result; } +int32_t AppMgrProxy::GetRunningMultiAppInfoByBundleName(const std::string &bundleName, + RunningMultiAppInfo &info) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + if (!WriteInterfaceToken(data)) { + return ERR_FLATTEN_OBJECT; + } + if (!data.WriteString(bundleName)) { + TAG_LOGE(AAFwkTag::APPMGR, "bundleName write failed."); + return ERR_INVALID_VALUE; + } + int32_t ret = SendRequest(AppMgrInterfaceCode::GET_RUNNING_MULTIAPP_INFO_BY_BUNDLENAME, data, reply, option); + if (ret != NO_ERROR) { + TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret); + return ret; + } + std::unique_ptr infoReply(reply.ReadParcelable()); + info = *infoReply; + int result = reply.ReadInt32(); + return result; +} + int32_t AppMgrProxy::GetRunningProcessesByBundleType(const BundleType bundleType, std::vector &info) { @@ -808,7 +832,7 @@ int AppMgrProxy::PreStartNWebSpawnProcess() int AppMgrProxy::StartRenderProcess(const std::string &renderParam, int32_t ipcFd, int32_t sharedFd, - int32_t crashFd, pid_t &renderPid) + int32_t crashFd, pid_t &renderPid, bool isGPU) { if (renderParam.empty() || ipcFd <= 0 || sharedFd <= 0 || crashFd <= 0) { TAG_LOGE(AAFwkTag::APPMGR, "Invalid params, renderParam:%{private}s, ipcFd:%{public}d, " @@ -836,6 +860,11 @@ int AppMgrProxy::StartRenderProcess(const std::string &renderParam, return -1; } + if (!data.WriteBool(isGPU)) { + TAG_LOGE(AAFwkTag::APPMGR, "want processType failed."); + return -1; + } + int32_t ret = SendRequest(AppMgrInterfaceCode::START_RENDER_PROCESS, data, reply, option); if (ret != NO_ERROR) { @@ -877,6 +906,27 @@ void AppMgrProxy::AttachRenderProcess(const sptr &renderScheduler } } +void AppMgrProxy::SaveBrowserChannel(sptr browser) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!WriteInterfaceToken(data)) { + TAG_LOGE(AAFwkTag::APPMGR, "WriteInterfaceToken failed"); + return; + } + + if (!data.WriteRemoteObject(browser)) { + TAG_LOGE(AAFwkTag::APPMGR, "browser write failed."); + return; + } + + if (!SendTransactCmd(AppMgrInterfaceCode::SAVE_BROWSER_CHANNEL, data, reply)) { + TAG_LOGE(AAFwkTag::APPMGR, "SendTransactCmd SAVE_BROWSER_CHANNEL failed"); + return; + } +} + int AppMgrProxy::GetRenderProcessTerminationStatus(pid_t renderPid, int &status) { MessageParcel data; @@ -1989,5 +2039,68 @@ int32_t AppMgrProxy::SetSupportedProcessCacheSelf(bool isSupport) } return reply.ReadInt32(); } + +void AppMgrProxy::SetAppAssertionPauseState(bool flag) +{ + TAG_LOGD(AAFwkTag::APPMGR, "Called."); + MessageParcel data; + if (!WriteInterfaceToken(data)) { + TAG_LOGE(AAFwkTag::APPMGR, "Write interface token failed."); + return; + } + if (!data.WriteBool(flag)) { + TAG_LOGE(AAFwkTag::APPMGR, "flag write failed."); + return; + } + + MessageParcel reply; + MessageOption option; + auto error = SendRequest(AppMgrInterfaceCode::SET_APP_ASSERT_PAUSE_STATE_SELF, data, reply, option); + if (error != NO_ERROR) { + TAG_LOGE(AAFwkTag::APPMGR, "Send request error: %{public}d", error); + return; + } +} + +int32_t AppMgrProxy::StartNativeChildProcess(const std::string &libName, int32_t childProcessCount, + const sptr &callback) +{ + TAG_LOGD(AAFwkTag::APPMGR, "Called."); + if (libName.empty() || !callback) { + TAG_LOGE(AAFwkTag::APPMGR, "Invalid params, libName:%{private}s", libName.c_str()); + return ERR_INVALID_VALUE; + } + + MessageParcel data; + if (!WriteInterfaceToken(data)) { + TAG_LOGE(AAFwkTag::APPMGR, "Write interface token failed."); + return IPC_PROXY_ERR; + } + + if (!data.WriteString(libName)) { + TAG_LOGE(AAFwkTag::APPMGR, "Write lib name failed."); + return IPC_PROXY_ERR; + } + + if (!data.WriteInt32(childProcessCount)) { + TAG_LOGE(AAFwkTag::APPMGR, "Write param childProcessCount failed."); + return IPC_PROXY_ERR; + } + + if (!data.WriteRemoteObject(callback)) { + TAG_LOGE(AAFwkTag::APPMGR, "Write call back ipc object failed."); + return IPC_PROXY_ERR; + } + + MessageParcel reply; + MessageOption option; + auto error = SendRequest(AppMgrInterfaceCode::START_NATIVE_CHILD_PROCESS, data, reply, option); + if (error != NO_ERROR) { + TAG_LOGE(AAFwkTag::APPMGR, "Send request error: %{public}d", error); + return error; + } + return reply.ReadInt32(); +} + } // namespace AppExecFwk } // namespace OHOS diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp index b1c3946e05..2128cdaf6c 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp @@ -102,6 +102,8 @@ AppMgrStub::AppMgrStub() &AppMgrStub::HandleDumpHeapMemory; memberFuncMap_[static_cast(AppMgrInterfaceCode::DUMP_JSHEAP_MEMORY_PROCESS)] = &AppMgrStub::HandleDumpJsHeapMemory; + memberFuncMap_[static_cast(AppMgrInterfaceCode::GET_RUNNING_MULTIAPP_INFO_BY_BUNDLENAME)] = + &AppMgrStub::HandleGetRunningMultiAppInfoByBundleName; #ifdef ABILITY_COMMAND_FOR_TEST memberFuncMap_[static_cast(AppMgrInterfaceCode::BLOCK_APP_SERVICE)] = &AppMgrStub::HandleBlockAppServiceDone; @@ -190,6 +192,12 @@ AppMgrStub::AppMgrStub() &AppMgrStub::HandleSetSupportedProcessCacheSelf; memberFuncMap_[static_cast(AppMgrInterfaceCode::APP_GET_RUNNING_PROCESSES_BY_BUNDLE_TYPE)] = &AppMgrStub::HandleGetRunningProcessesByBundleType; + memberFuncMap_[static_cast(AppMgrInterfaceCode::SET_APP_ASSERT_PAUSE_STATE_SELF)] = + &AppMgrStub::HandleSetAppAssertionPauseState; + memberFuncMap_[static_cast(AppMgrInterfaceCode::START_NATIVE_CHILD_PROCESS)] = + &AppMgrStub::HandleStartNativeChildProcess; + memberFuncMap_[static_cast(AppMgrInterfaceCode::SAVE_BROWSER_CHANNEL)] = + &AppMgrStub::HandleSaveBrowserChannel; } AppMgrStub::~AppMgrStub() @@ -326,6 +334,21 @@ int32_t AppMgrStub::HandleGetAllRunningProcesses(MessageParcel &data, MessagePar return NO_ERROR; } +int32_t AppMgrStub::HandleGetRunningMultiAppInfoByBundleName(MessageParcel &data, MessageParcel &reply) +{ + std::string bundleName = data.ReadString(); + RunningMultiAppInfo info; + int32_t result = GetRunningMultiAppInfoByBundleName(bundleName, info); + if (!reply.WriteParcelable(&info)) { + return ERR_INVALID_VALUE; + } + if (!reply.WriteInt32(result)) { + TAG_LOGE(AAFwkTag::APPMGR, "fail to write result."); + return ERR_INVALID_VALUE; + } + return NO_ERROR; +} + int32_t AppMgrStub::HandleGetRunningProcessesByBundleType(MessageParcel &data, MessageParcel &reply) { HITRACE_METER(HITRACE_TAG_APP); @@ -674,8 +697,9 @@ int32_t AppMgrStub::HandleStartRenderProcess(MessageParcel &data, MessageParcel int32_t sharedFd = data.ReadFileDescriptor(); int32_t crashFd = data.ReadFileDescriptor(); int32_t renderPid = 0; + bool isGPU = data.ReadBool(); int32_t result = - StartRenderProcess(renderParam, ipcFd, sharedFd, crashFd, renderPid); + StartRenderProcess(renderParam, ipcFd, sharedFd, crashFd, renderPid, isGPU); if (!reply.WriteInt32(result)) { TAG_LOGE(AAFwkTag::APPMGR, "write result error."); return ERR_INVALID_VALUE; @@ -694,6 +718,13 @@ int32_t AppMgrStub::HandleAttachRenderProcess(MessageParcel &data, MessageParcel return NO_ERROR; } +int32_t AppMgrStub::HandleSaveBrowserChannel(MessageParcel &data, MessageParcel &reply) +{ + sptr browser = data.ReadRemoteObject(); + SaveBrowserChannel(browser); + return NO_ERROR; +} + int32_t AppMgrStub::HandleGetRenderProcessTerminationStatus(MessageParcel &data, MessageParcel &reply) { int32_t renderPid = data.ReadInt32(); @@ -1312,5 +1343,29 @@ int32_t AppMgrStub::HandleSetSupportedProcessCacheSelf(MessageParcel &data, Mess } return NO_ERROR; } + +int32_t AppMgrStub::HandleSetAppAssertionPauseState(MessageParcel &data, MessageParcel &reply) +{ + TAG_LOGD(AAFwkTag::APPMGR, "Called."); + bool flag = data.ReadBool(); + SetAppAssertionPauseState(flag); + return NO_ERROR; +} + +int32_t AppMgrStub::HandleStartNativeChildProcess(MessageParcel &data, MessageParcel &reply) +{ + TAG_LOGD(AAFwkTag::APPMGR, "Called."); + std::string libName = data.ReadString(); + int32_t childCount = data.ReadInt32(); + sptr callback = data.ReadRemoteObject(); + int32_t result = StartNativeChildProcess(libName, childCount, callback); + if (!reply.WriteInt32(result)) { + TAG_LOGE(AAFwkTag::APPMGR, "Write ret error."); + return IPC_STUB_ERR; + } + + return NO_ERROR; +} + } // namespace AppExecFwk } // namespace OHOS diff --git a/interfaces/inner_api/app_manager/src/appmgr/child_process_info.cpp b/interfaces/inner_api/app_manager/src/appmgr/child_process_info.cpp index 490bbe820b..9790eeba07 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/child_process_info.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/child_process_info.cpp @@ -37,6 +37,8 @@ bool ChildProcessInfo::ReadFromParcel(Parcel &parcel) READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, uidData); uid = static_cast(uidData); + READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, processType); + bundleName = Str16ToStr8(parcel.ReadString16()); processName = Str16ToStr8(parcel.ReadString16()); srcEntry = Str16ToStr8(parcel.ReadString16()); @@ -64,6 +66,7 @@ bool ChildProcessInfo::Marshalling(Parcel &parcel) const WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast(pid)); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast(hostPid)); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast(uid)); + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast(processType)); 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)); diff --git a/interfaces/inner_api/app_manager/src/appmgr/child_scheduler_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/child_scheduler_proxy.cpp index edf650c809..e14eaa5e71 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/child_scheduler_proxy.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/child_scheduler_proxy.cpp @@ -84,5 +84,39 @@ bool ChildSchedulerProxy::ScheduleExitProcessSafely() TAG_LOGD(AAFwkTag::APPMGR, "ScheduleExitProcessSafely end."); return true; } + +bool ChildSchedulerProxy::ScheduleRunNativeProc(const sptr &mainProcessCb) +{ + TAG_LOGD(AAFwkTag::APPMGR, "ScheduleRunNativeProc start."); + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + if (!WriteInterfaceToken(data)) { + TAG_LOGE(AAFwkTag::APPMGR, "Write interface token failed."); + return false; + } + + if (!data.WriteRemoteObject(mainProcessCb)) { + TAG_LOGE(AAFwkTag::APPMGR, "Write main process callback ipc object failed."); + return false; + } + + sptr remote = Remote(); + if (remote == nullptr) { + TAG_LOGE(AAFwkTag::APPMGR, "Remote() is null."); + return false; + } + + int32_t ret = remote->SendRequest( + static_cast(IChildScheduler::Message::SCHEDULE_RUN_NATIVE_PROC), data, reply, option); + if (ret != NO_ERROR) { + TAG_LOGE(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d.", ret); + return false; + } + + TAG_LOGD(AAFwkTag::APPMGR, "ScheduleRunNativeProc end."); + return true; +} + } // namespace AppExecFwk } // namespace OHOS diff --git a/interfaces/inner_api/app_manager/src/appmgr/child_scheduler_stub.cpp b/interfaces/inner_api/app_manager/src/appmgr/child_scheduler_stub.cpp index 1fda7ab84c..b434032513 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/child_scheduler_stub.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/child_scheduler_stub.cpp @@ -27,6 +27,8 @@ ChildSchedulerStub::ChildSchedulerStub() &ChildSchedulerStub::HandleScheduleLoadJs; memberFuncMap_[static_cast(IChildScheduler::Message::SCHEDULE_EXIT_PROCESS_SAFELY)] = &ChildSchedulerStub::HandleScheduleExitProcessSafely; + memberFuncMap_[static_cast(IChildScheduler::Message::SCHEDULE_RUN_NATIVE_PROC)] = + &ChildSchedulerStub::HandleScheduleRunNativeProc; } ChildSchedulerStub::~ChildSchedulerStub() @@ -68,5 +70,13 @@ int32_t ChildSchedulerStub::HandleScheduleExitProcessSafely(MessageParcel &data, ScheduleExitProcessSafely(); return ERR_NONE; } + +int32_t ChildSchedulerStub::HandleScheduleRunNativeProc(MessageParcel &data, MessageParcel &reply) +{ + sptr cb = data.ReadRemoteObject(); + ScheduleRunNativeProc(cb); + return ERR_NONE; +} + } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file diff --git a/interfaces/inner_api/app_manager/src/appmgr/native_child_notify_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/native_child_notify_proxy.cpp new file mode 100644 index 0000000000..e97ec17658 --- /dev/null +++ b/interfaces/inner_api/app_manager/src/appmgr/native_child_notify_proxy.cpp @@ -0,0 +1,94 @@ +/* + * 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 "native_child_notify_proxy.h" +#include "hilog_tag_wrapper.h" +#include "hilog_wrapper.h" +#include "ipc_types.h" + +namespace OHOS { +namespace AppExecFwk { + +NativeChildNotifyProxy::NativeChildNotifyProxy(const sptr &impl) + : IRemoteProxy(impl) +{ +} + +bool NativeChildNotifyProxy::WriteInterfaceToken(MessageParcel &data) +{ + if (!data.WriteInterfaceToken(NativeChildNotifyProxy::GetDescriptor())) { + TAG_LOGE(AAFwkTag::APPMGR, "NativeChildNotifyProxy write interface token failed"); + return false; + } + + return true; +} + +int32_t NativeChildNotifyProxy::SendRequest(uint32_t code, MessageParcel &data, + MessageParcel &reply, MessageOption& option) +{ + sptr remote = Remote(); + if (!remote) { + TAG_LOGE(AAFwkTag::APPMGR, "NativeChildNotifyProxy get remote object failed"); + return ERR_NULL_OBJECT; + } + + int32_t ret = remote->SendRequest(code, data, reply, option); + if (ret != NO_ERROR) { + TAG_LOGE(AAFwkTag::APPMGR, "NativeChildNotifyProxy SendRequest failed(%{public}d)", ret); + return ret; + } + + return NO_ERROR; +} + +void NativeChildNotifyProxy::OnNativeChildStarted(const sptr &nativeChild) +{ + TAG_LOGD(AAFwkTag::APPMGR, "NativeChildNotifyProxy OnNativeChildStarted"); + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + if (!WriteInterfaceToken(data)) { + return; + } + + if (!data.WriteRemoteObject(nativeChild)) { + TAG_LOGE(AAFwkTag::APPMGR, "NativeChildNotifyProxy write native child ipc object failed."); + return; + } + + SendRequest(INativeChildNotify::IPC_ID_ON_NATIVE_CHILD_STARTED, data, reply, option); +} + +void NativeChildNotifyProxy::OnError(int32_t errCode) +{ + TAG_LOGD(AAFwkTag::APPMGR, "NativeChildNotifyProxy OnError(%{public}d)", errCode); + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + if (!WriteInterfaceToken(data)) { + return; + } + + if (!data.WriteInt32(errCode)) { + TAG_LOGE(AAFwkTag::APPMGR, "NativeChildNotifyProxy write error code failed."); + return; + } + + SendRequest(INativeChildNotify::IPC_ID_ON_ERROR, data, reply, option); +} + +} // OHOS +} // AppExecFwk \ No newline at end of file diff --git a/interfaces/inner_api/app_manager/src/appmgr/native_child_notify_stub.cpp b/interfaces/inner_api/app_manager/src/appmgr/native_child_notify_stub.cpp new file mode 100644 index 0000000000..63ad1fb4e2 --- /dev/null +++ b/interfaces/inner_api/app_manager/src/appmgr/native_child_notify_stub.cpp @@ -0,0 +1,71 @@ +/* + * 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 "native_child_notify_stub.h" +#include "hilog_tag_wrapper.h" +#include "hilog_wrapper.h" +#include "ipc_types.h" + +namespace OHOS { +namespace AppExecFwk { + +int NativeChildNotifyStub::OnRemoteRequest(uint32_t code, MessageParcel &data, + MessageParcel &reply, MessageOption &option) +{ + TAG_LOGD(AAFwkTag::APPMGR, "NativeChildNotifyStub::OnRemoteRequest, code=%{public}u, flags=%{public}d.", + code, option.GetFlags()); + std::u16string descriptor = NativeChildNotifyStub::GetDescriptor(); + std::u16string remoteDesc = data.ReadInterfaceToken(); + if (descriptor != remoteDesc) { + TAG_LOGE(AAFwkTag::APPMGR, "A local descriptor is not equivalent to a remote"); + return ERR_INVALID_STATE; + } + + int32_t ret; + switch (code) { + case INativeChildNotify::IPC_ID_ON_NATIVE_CHILD_STARTED: + ret = HandleOnNativeChildStarted(data, reply); + break; + + case INativeChildNotify::IPC_ID_ON_ERROR: + ret = HandleOnError(data, reply); + break; + + default: + TAG_LOGW(AAFwkTag::APPMGR, "NativeChildNotifyStub Unknow ipc call(%{public}u)", code); + ret = IPCObjectStub::OnRemoteRequest(code, data, reply, option); + break; + } + + TAG_LOGD(AAFwkTag::APPMGR, "NativeChildNotifyStub::OnRemoteRequest end"); + return ret; +} + +int32_t NativeChildNotifyStub::HandleOnNativeChildStarted(MessageParcel &data, MessageParcel &reply) +{ + sptr cb = data.ReadRemoteObject(); + OnNativeChildStarted(cb); + return ERR_NONE; +} + +int32_t NativeChildNotifyStub::HandleOnError(MessageParcel &data, MessageParcel &reply) +{ + int32_t err = data.ReadInt32(); + OnError(err); + return ERR_NONE; +} + +} // OHOS +} // AppExecFwk diff --git a/interfaces/inner_api/app_manager/src/appmgr/render_scheduler_host.cpp b/interfaces/inner_api/app_manager/src/appmgr/render_scheduler_host.cpp index 8fef51a28d..059e9b6b72 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/render_scheduler_host.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/render_scheduler_host.cpp @@ -60,7 +60,8 @@ int RenderSchedulerHost::HandleNotifyBrowserFd(MessageParcel &data, MessageParce int32_t ipcFd = data.ReadFileDescriptor(); int32_t sharedFd = data.ReadFileDescriptor(); int32_t crashFd = data.ReadFileDescriptor(); - NotifyBrowserFd(ipcFd, sharedFd, crashFd); + sptr browser = data.ReadRemoteObject(); + NotifyBrowserFd(ipcFd, sharedFd, crashFd, browser); return 0; } } // namespace AppExecFwk diff --git a/interfaces/inner_api/app_manager/src/appmgr/render_scheduler_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/render_scheduler_proxy.cpp index 3f0073bb88..9f670bedfb 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/render_scheduler_proxy.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/render_scheduler_proxy.cpp @@ -36,7 +36,7 @@ bool RenderSchedulerProxy::WriteInterfaceToken(MessageParcel &data) } void RenderSchedulerProxy::NotifyBrowserFd(int32_t ipcFd, int32_t sharedFd, - int32_t crashFd) + int32_t crashFd, sptr browser) { TAG_LOGD(AAFwkTag::APPMGR, "NotifyBrowserFd start"); MessageParcel data; @@ -53,6 +53,10 @@ void RenderSchedulerProxy::NotifyBrowserFd(int32_t ipcFd, int32_t sharedFd, return; } + if (!data.WriteRemoteObject(browser)) { + TAG_LOGE(AAFwkTag::APPMGR, "write browser failed!"); + } + sptr remote = Remote(); if (remote == nullptr) { TAG_LOGE(AAFwkTag::APPMGR, "Remote() is NULL"); diff --git a/interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp b/interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp new file mode 100644 index 0000000000..104963d4c1 --- /dev/null +++ b/interfaces/inner_api/app_manager/src/appmgr/running_multi_info.cpp @@ -0,0 +1,76 @@ +/* + * 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 "running_multi_info.h" + +#include "nlohmann/json.hpp" +#include "string_ex.h" + +#include "hilog_tag_wrapper.h" +#include "hilog_wrapper.h" +#include "parcel_macro_base.h" + +namespace OHOS { +namespace AppExecFwk { +bool RunningMultiAppInfo::ReadFromParcel(Parcel &parcel) +{ + bundleName = Str16ToStr8(parcel.ReadString16()); + mode = parcel.ReadInt32(); + int32_t runningAppClonesSize; + READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, runningAppClonesSize); + if (runningAppClonesSize > MAX_CLONE_APP_NUM) { + return false; + } + for (auto i = 0; i < runningAppClonesSize; i++) { + RunningAppClone clone; + clone.appCloneIndex = parcel.ReadInt32(); + clone.uid = parcel.ReadInt32(); + parcel.ReadInt32Vector(&clone.pids); + runningAppClones.emplace_back(clone); + } + return true; +} + +RunningMultiAppInfo *RunningMultiAppInfo::Unmarshalling(Parcel &parcel) +{ + RunningMultiAppInfo *info = new (std::nothrow) RunningMultiAppInfo(); + if (info && !info->ReadFromParcel(parcel)) { + TAG_LOGW(AAFwkTag::APPMGR, "read from parcel failed"); + delete info; + info = nullptr; + } + return info; +} + +bool RunningMultiAppInfo::Marshalling(Parcel &parcel) const +{ + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(bundleName)); + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, mode); + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, runningAppClones.size()); + if (runningAppClones.size() > MAX_CLONE_APP_NUM) { + return false; + } + for (auto &clone : runningAppClones) { + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, clone.appCloneIndex); + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, clone.uid); + if (!parcel.WriteInt32Vector(clone.pids)) { + TAG_LOGE(AAFwkTag::APPMGR, "write runningAppClones failed."); + return false; + } + } + return true; +} +} // namespace AppExecFwk +} // namespace OHOS \ No newline at end of file diff --git a/interfaces/inner_api/auto_fill_manager/include/auto_fill_error.h b/interfaces/inner_api/auto_fill_manager/include/auto_fill_error.h index 7cc4d9a31b..f1fee33281 100644 --- a/interfaces/inner_api/auto_fill_manager/include/auto_fill_error.h +++ b/interfaces/inner_api/auto_fill_manager/include/auto_fill_error.h @@ -29,7 +29,8 @@ enum { AUTO_FILL_OBJECT_IS_NULL, AUTO_FILL_CREATE_MODULE_UI_EXTENSION_FAILED, AUTO_FILL_REQUEST_TIME_OUT, - AUTO_FILL_TYPE_INVALID + AUTO_FILL_TYPE_INVALID, + AUTO_FILL_PREVIOUS_REQUEST_NOT_FINISHED }; } // namespace AutoFill } // namespace AbilityRuntime diff --git a/interfaces/inner_api/auto_fill_manager/include/auto_fill_extension_callback.h b/interfaces/inner_api/auto_fill_manager/include/auto_fill_extension_callback.h index b6c9f7ea97..3c849a601a 100644 --- a/interfaces/inner_api/auto_fill_manager/include/auto_fill_extension_callback.h +++ b/interfaces/inner_api/auto_fill_manager/include/auto_fill_extension_callback.h @@ -47,6 +47,7 @@ public: void SetSessionId(int32_t sessionId); void SetUIContent(Ace::UIContent *uiContent); + Ace::UIContent *GetUIContent(); void SetEventId(uint32_t eventId); void SetWindowType(const AutoFill::AutoFillWindowType &autoFillWindowType); void SetExtensionType(bool isSmartAutoFill); diff --git a/interfaces/inner_api/auto_fill_manager/include/auto_fill_manager.h b/interfaces/inner_api/auto_fill_manager/include/auto_fill_manager.h index 7547a53759..134bf2089d 100644 --- a/interfaces/inner_api/auto_fill_manager/include/auto_fill_manager.h +++ b/interfaces/inner_api/auto_fill_manager/include/auto_fill_manager.h @@ -106,6 +106,7 @@ private: void SetTimeOutEvent(uint32_t eventId); AutoFill::AutoFillWindowType ConvertAutoFillWindowType(const AutoFill::AutoFillRequest &request, bool &isSmartAutoFill); + bool IsPreviousRequestFinished(Ace::UIContent *uiContent); std::mutex extensionCallbacksMutex_; std::mutex modalProxyMapMutex_; diff --git a/interfaces/inner_api/auto_fill_manager/src/auto_fill_extension_callback.cpp b/interfaces/inner_api/auto_fill_manager/src/auto_fill_extension_callback.cpp index abe2d0609e..eedcc1a0db 100644 --- a/interfaces/inner_api/auto_fill_manager/src/auto_fill_extension_callback.cpp +++ b/interfaces/inner_api/auto_fill_manager/src/auto_fill_extension_callback.cpp @@ -198,6 +198,11 @@ void AutoFillExtensionCallback::SetUIContent(Ace::UIContent *uiContent) uiContent_ = uiContent; } +Ace::UIContent *AutoFillExtensionCallback::GetUIContent() +{ + return uiContent_; +} + void AutoFillExtensionCallback::SetEventId(uint32_t eventId) { eventId_ = eventId; @@ -276,12 +281,12 @@ void AutoFillExtensionCallback::CloseModalUIExtension() return; } - AutoFillManager::GetInstance().RemoveAutoFillExtensionProxy(uiContent_); if (autoFillWindowType_ == AutoFill::AutoFillWindowType::POPUP_WINDOW) { uiContent_->DestroyCustomPopupUIExtension(sessionId_); } else if (autoFillWindowType_ == AutoFill::AutoFillWindowType::MODAL_WINDOW) { uiContent_->CloseModalUIExtension(sessionId_); } + AutoFillManager::GetInstance().RemoveAutoFillExtensionProxy(uiContent_); uiContent_ = nullptr; } } // namespace AbilityRuntime diff --git a/interfaces/inner_api/auto_fill_manager/src/auto_fill_manager.cpp b/interfaces/inner_api/auto_fill_manager/src/auto_fill_manager.cpp index e3be0d5374..0d9f9100f7 100644 --- a/interfaces/inner_api/auto_fill_manager/src/auto_fill_manager.cpp +++ b/interfaces/inner_api/auto_fill_manager/src/auto_fill_manager.cpp @@ -96,6 +96,10 @@ int32_t AutoFillManager::HandleRequestExecuteInner( TAG_LOGE(AAFwkTag::AUTOFILLMGR, "UIContent or fillCallback&saveCallback is nullptr."); return AutoFill::AUTO_FILL_OBJECT_IS_NULL; } + if (!IsPreviousRequestFinished(uiContent)) { + TAG_LOGE(AAFwkTag::AUTOFILLMGR, "Previous request is not finished."); + return AutoFill::AUTO_FILL_PREVIOUS_REQUEST_NOT_FINISHED; + } { std::lock_guard lock(extensionCallbacksMutex_); SetTimeOutEvent(++eventId_); @@ -371,5 +375,20 @@ void AutoFillManager::HandleTimeOut(uint32_t eventId) extensionCallback->HandleTimeOut(); extensionCallbacks_.erase(ret); } + +bool AutoFillManager::IsPreviousRequestFinished(Ace::UIContent *uiContent) +{ + std::lock_guard lock(extensionCallbacksMutex_); + for (auto& item: extensionCallbacks_) { + auto extensionCallback = item.second.lock(); + if (extensionCallback == nullptr) { + continue; + } + if (extensionCallback->GetUIContent() == uiContent) { + return false; + } + } + return true; +} } // namespace AbilityRuntime } // namespace OHOS diff --git a/interfaces/inner_api/child_process_manager/BUILD.gn b/interfaces/inner_api/child_process_manager/BUILD.gn index e9bd88528e..bbd9caaebe 100644 --- a/interfaces/inner_api/child_process_manager/BUILD.gn +++ b/interfaces/inner_api/child_process_manager/BUILD.gn @@ -32,6 +32,7 @@ ohos_shared_library("child_process_manager") { "${ability_runtime_native_path}/ability/native/child_process_manager/child_process_manager.cpp", "${ability_runtime_native_path}/ability/native/child_process_manager/child_process_manager_error_utils.cpp", "${ability_runtime_native_path}/ability/native/child_process_manager/js_child_process.cpp", + "${ability_runtime_native_path}/ability/native/child_process_manager/native_child_ipc_process.cpp", ] deps = [ @@ -50,6 +51,7 @@ ohos_shared_library("child_process_manager") { "eventhandler:libeventhandler", "hilog:libhilog", "init:libbegetutil", + "ipc:ipc_capi", "ipc:ipc_core", "napi:ace_napi", "samgr:samgr_proxy", diff --git a/interfaces/inner_api/child_process_manager/include/child_process_manager.h b/interfaces/inner_api/child_process_manager/include/child_process_manager.h index 3bf2137fe4..f9fbf3c654 100644 --- a/interfaces/inner_api/child_process_manager/include/child_process_manager.h +++ b/interfaces/inner_api/child_process_manager/include/child_process_manager.h @@ -25,6 +25,7 @@ #include "child_process_manager_error_utils.h" #include "hap_module_info.h" #include "runtime.h" +#include "iremote_object.h" namespace OHOS { namespace AbilityRuntime { @@ -41,12 +42,15 @@ public: bool IsChildProcess(); ChildProcessManagerErrorCode StartChildProcessBySelfFork(const std::string &srcEntry, pid_t &pid); ChildProcessManagerErrorCode StartChildProcessByAppSpawnFork(const std::string &srcEntry, pid_t &pid); + ChildProcessManagerErrorCode StartNativeChildProcessByAppSpawnFork( + const std::string &libName, const sptr &callbackStub); bool GetBundleInfo(AppExecFwk::BundleInfo &bundleInfo); bool GetHapModuleInfo(const AppExecFwk::BundleInfo &bundleInfo, AppExecFwk::HapModuleInfo &hapModuleInfo); std::unique_ptr CreateRuntime(const AppExecFwk::BundleInfo &bundleInfo, const AppExecFwk::HapModuleInfo &hapModuleInfo, const bool fromAppSpawn, const bool jitEnabled); bool LoadJsFile(const std::string &srcEntry, const AppExecFwk::HapModuleInfo &hapModuleInfo, std::unique_ptr &runtime); + bool LoadNativeLib(const std::string &libPath, const sptr &mainProcessCb); void SetForkProcessJITEnabled(bool jitEnabled); void SetForkProcessDebugOption(const std::string bundleName, const bool isStartWithDebug, const bool isDebugApp, const bool isStartWithNative); @@ -55,6 +59,7 @@ private: ChildProcessManager(); ChildProcessManagerErrorCode PreCheck(); + ChildProcessManagerErrorCode PreCheckNativeProcess(); void RegisterSignal(); void HandleChildProcessBySelfFork(const std::string &srcEntry, const AppExecFwk::BundleInfo &bundleInfo); bool hasChildProcessRecord(); diff --git a/interfaces/inner_api/child_process_manager/include/child_process_manager_error_utils.h b/interfaces/inner_api/child_process_manager/include/child_process_manager_error_utils.h index 3bd4893d87..18c572d1ea 100644 --- a/interfaces/inner_api/child_process_manager/include/child_process_manager_error_utils.h +++ b/interfaces/inner_api/child_process_manager/include/child_process_manager_error_utils.h @@ -31,6 +31,10 @@ enum class ChildProcessManagerErrorCode { ERR_GET_BUNDLE_INFO_FAILED = 5, ERR_GET_APP_MGR_FAILED = 6, ERR_GET_APP_MGR_START_PROCESS_FAILED = 7, + ERR_UNSUPPORT_NATIVE_CHILD_PROCESS = 8, + ERR_MAX_NATIVE_CHILD_PROCESSES = 9, + ERR_NATIVE_CHILD_PROCESS_LOAD_LIB = 10, + ERR_NATIVE_CHILD_PROCESS_CONNECT = 11, }; const std::map INTERNAL_ERR_CODE_MAP = { diff --git a/interfaces/inner_api/child_process_manager/include/child_process_start_info.h b/interfaces/inner_api/child_process_manager/include/child_process_start_info.h index 75cbfabd60..07828eae1b 100644 --- a/interfaces/inner_api/child_process_manager/include/child_process_start_info.h +++ b/interfaces/inner_api/child_process_manager/include/child_process_start_info.h @@ -17,6 +17,7 @@ #define OHOS_ABILITY_RUNTIME_CHILD_PROCESS_START_INFO_H #include +#include "iremote_object.h" namespace OHOS { namespace AbilityRuntime { @@ -26,6 +27,7 @@ struct ChildProcessStartInfo { std::string srcEntry; std::string hapPath; bool isEsModule = true; + sptr ipcObj; }; } // namespace AbilityRuntime } // namespace OHOS diff --git a/interfaces/inner_api/child_process_manager/include/native_child_ipc_process.h b/interfaces/inner_api/child_process_manager/include/native_child_ipc_process.h new file mode 100644 index 0000000000..5a007069e8 --- /dev/null +++ b/interfaces/inner_api/child_process_manager/include/native_child_ipc_process.h @@ -0,0 +1,53 @@ +/* + * 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_NATIVE_CHILD_IPC_PROCESS_H +#define OHOS_ABILITY_RUNTIME_NATIVE_CHILD_IPC_PROCESS_H + +#include +#include "child_process.h" +#include "native_child_notify_interface.h" +#include "ipc_inner_object.h" + +namespace OHOS { +namespace AbilityRuntime { + +class NativeChildIpcProcess : public ChildProcess { +public: + NativeChildIpcProcess() = default; + ~NativeChildIpcProcess(); + + static std::shared_ptr Create(); + + bool Init(const std::shared_ptr &info) override; + void OnStart() override; + +private: + bool LoadNativeLib(const std::shared_ptr &info); + void UnloadNativeLib(); + + typedef OHIPCRemoteStub* (*NativeChildProcess_OnConnect)(); + typedef void (*NativeChildProcess_MainProc)(); + + sptr mainProcessCb_; + void *nativeLibHandle_ = nullptr; + NativeChildProcess_OnConnect funcNativeLibOnConnect_ = nullptr; + NativeChildProcess_MainProc funcNativeLibMainProc_ = nullptr; +}; + +} // namespace AbilityRuntime +} // namespace OHOS + +#endif // OHOS_ABILITY_RUNTIME_NATIVE_CHILD_IPC_PROCESS_H \ No newline at end of file diff --git a/interfaces/inner_api/error_utils/include/ability_runtime_error_util.h b/interfaces/inner_api/error_utils/include/ability_runtime_error_util.h index c3de0b5c47..1c621573e5 100644 --- a/interfaces/inner_api/error_utils/include/ability_runtime_error_util.h +++ b/interfaces/inner_api/error_utils/include/ability_runtime_error_util.h @@ -55,11 +55,11 @@ enum { ERR_ABILITY_RUNTIME_CHILD_PROCESS_NUMBER_EXCEEDS_UPPER_BOUND = 16000062, ERR_ABILITY_RUNTIME_RESTART_APP_INCORRECT_ABILITY = 16000063, ERR_ABILITY_RUNTIME_RESTART_APP_FREQUENT = 16000064, - ERR_ABILITY_RUNTIME_SET_SUPPORTED_PROCESS_CACHE_AGAIN = 16000068, ERR_ABILITY_RUNTIME_EXTERNAL_EXECUTE_SHELL_COMMAND_FAILED = 16000101, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_WANTAGENT = 16000151, ERR_ABILITY_RUNTIME_EXTERNAL_WANTAGENT_NOT_FOUND = 16000152, ERR_ABILITY_RUNTIME_EXTERNAL_WANTAGENT_CANCELED = 16000153, + ERR_ABILITY_RUNTIME_SET_SUPPORTED_PROCESS_CACHE_AGAIN = 16000200, ERR_ABILITY_RUNTIME_EXTERNAL_NO_SUCH_URI_ABILITY = 16100001, ERR_ABILITY_RUNTIME_EXTERNAL_FA_NOT_SUPPORT_OPERATION = 16100002, diff --git a/interfaces/inner_api/runtime/include/cj_runtime.h b/interfaces/inner_api/runtime/include/cj_runtime.h index d6c8aed7a2..b2ecbf80df 100644 --- a/interfaces/inner_api/runtime/include/cj_runtime.h +++ b/interfaces/inner_api/runtime/include/cj_runtime.h @@ -61,7 +61,8 @@ public: void DestroyHeapProfiler() override {}; void ForceFullGC() override {}; void ForceFullGC(uint32_t tid) override {}; - void DumpHeapSnapshot(uint32_t tid, bool isFullGC) override {}; + void DumpHeapSnapshot(uint32_t tid, bool isFullGC, std::vector fdVec, + std::vector tidVec) override {}; void DumpCpuProfile(bool isPrivate) override {}; void AllowCrossThreadExecution() override {}; void GetHeapPrepare() override {}; diff --git a/interfaces/inner_api/runtime/include/js_runtime.h b/interfaces/inner_api/runtime/include/js_runtime.h index 6a34c6f6c0..268607ff1c 100644 --- a/interfaces/inner_api/runtime/include/js_runtime.h +++ b/interfaces/inner_api/runtime/include/js_runtime.h @@ -85,7 +85,8 @@ public: void DestroyHeapProfiler() override; void ForceFullGC() override; void ForceFullGC(uint32_t tid) override; - void DumpHeapSnapshot(uint32_t tid, bool isFullGC) override; + void DumpHeapSnapshot(uint32_t tid, bool isFullGC, std::vector fdVec, + std::vector tidVec) override; void AllowCrossThreadExecution() override; void GetHeapPrepare() override; bool BuildJsStackInfoList(uint32_t tid, std::vector& jsFrames) override; diff --git a/interfaces/inner_api/runtime/include/js_runtime_utils.h b/interfaces/inner_api/runtime/include/js_runtime_utils.h index be8fb80f30..e586f1bff0 100644 --- a/interfaces/inner_api/runtime/include/js_runtime_utils.h +++ b/interfaces/inner_api/runtime/include/js_runtime_utils.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Copyright (c) 2021-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 @@ -295,13 +295,13 @@ std::unique_ptr CreateAsyncTaskWithLastParam(napi_env env, napi_v NapiAsyncTask::ExecuteCallback&& execute, NapiAsyncTask::CompleteCallback&& complete, napi_value* result); std::unique_ptr CreateAsyncTaskWithLastParam(napi_env env, napi_value lastParam, - NapiAsyncTask::ExecuteCallback&& execute, nullptr_t, napi_value* result); + NapiAsyncTask::ExecuteCallback&& execute, std::nullptr_t, napi_value* result); std::unique_ptr CreateAsyncTaskWithLastParam(napi_env env, napi_value lastParam, - nullptr_t, NapiAsyncTask::CompleteCallback&& complete, napi_value* result); + std::nullptr_t, NapiAsyncTask::CompleteCallback&& complete, napi_value* result); std::unique_ptr CreateAsyncTaskWithLastParam(napi_env env, napi_value lastParam, - nullptr_t, nullptr_t, napi_value* result); + std::nullptr_t, std::nullptr_t, napi_value* result); } // namespace AbilityRuntime } // namespace OHOS #endif // OHOS_ABILITY_RUNTIME_JS_RUNTIME_UTILS_H diff --git a/interfaces/inner_api/runtime/include/native_runtime_impl.h b/interfaces/inner_api/runtime/include/native_runtime_impl.h index c1ecb6703f..3b64a145f8 100644 --- a/interfaces/inner_api/runtime/include/native_runtime_impl.h +++ b/interfaces/inner_api/runtime/include/native_runtime_impl.h @@ -45,8 +45,6 @@ private: std::shared_ptr GetJsEnv(napi_env env); void LoadAotFile(const Options& options, const std::shared_ptr& jsEnv); void InitConsoleModule(const std::shared_ptr& jsEnv); - void InitSourceMap(const std::shared_ptr operatorObj, - const std::shared_ptr& jsEnv); void InitTimerModule(const std::shared_ptr& jsEnv); void SetModuleLoadChecker(const std::shared_ptr& moduleCheckerDelegate, const std::shared_ptr& jsEnv); diff --git a/interfaces/inner_api/runtime/include/runtime.h b/interfaces/inner_api/runtime/include/runtime.h index 67640a6ef6..b894d4c835 100644 --- a/interfaces/inner_api/runtime/include/runtime.h +++ b/interfaces/inner_api/runtime/include/runtime.h @@ -97,7 +97,8 @@ public: virtual void DestroyHeapProfiler() = 0; virtual void ForceFullGC() = 0; virtual void ForceFullGC(uint32_t tid) = 0; - virtual void DumpHeapSnapshot(uint32_t tid, bool isFullGC) = 0; + virtual void DumpHeapSnapshot(uint32_t tid, bool isFullGC, std::vector fdVec, + std::vector tidVec) = 0; virtual void AllowCrossThreadExecution() = 0; virtual void GetHeapPrepare() = 0; virtual void NotifyApplicationState(bool isBackground) = 0; diff --git a/interfaces/inner_api/wantagent/BUILD.gn b/interfaces/inner_api/wantagent/BUILD.gn index 04aa0574bf..bcc4d00546 100644 --- a/interfaces/inner_api/wantagent/BUILD.gn +++ b/interfaces/inner_api/wantagent/BUILD.gn @@ -43,7 +43,11 @@ config("wantagent_innerkits_public_config") { } ohos_shared_library("wantagent_innerkits") { - include_dirs = [ "${ability_runtime_services_path}/common/include" ] + include_dirs = [ + "${ability_runtime_services_path}/common/include", + "${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper", + "${ability_runtime_path}/interfaces/inner_api/deps_wrapper/include", + ] sources = [ "${ability_runtime_services_path}/abilitymgr/src/sender_info.cpp", @@ -67,11 +71,12 @@ ohos_shared_library("wantagent_innerkits") { public_configs = [ ":wantagent_innerkits_public_config" ] deps = [ - "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/error_utils:ability_runtime_error_util", ] external_deps = [ + "ability_base:session_info", "ability_base:want", "bundle_framework:appexecfwk_core", "c_utils:utils", diff --git a/interfaces/kits/c/ability/ability_runtime/child_process/native_child_process.h b/interfaces/kits/c/ability/ability_runtime/child_process/native_child_process.h new file mode 100644 index 0000000000..85301c6a59 --- /dev/null +++ b/interfaces/kits/c/ability/ability_runtime/child_process/native_child_process.h @@ -0,0 +1,144 @@ +/* + * 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_C_ABILITY_RUNTIME_NATIVE_CHILD_PROCESS_H +#define OHOS_C_ABILITY_RUNTIME_NATIVE_CHILD_PROCESS_H + +#include "ipc_cparcel.h" + +/** + * @file native_child_process.h + * + * @brief Defines the functions for native child process management. + * @library libchild_process.so + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @since 12 + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief native child process error code + * @since 12 + */ +enum Ability_NativeChildProcess_ErrCode { + /** + * @error The operation completed successfully + */ + NCP_NOERROR = 0, + + /** + * @error Invalid param + */ + NCP_ERR_INVALID_PARAM = 401, + + /** + * @error Unsupport start native process + */ + NCP_ERR_NOT_SUPPORTED = 801, + + /** + * @error Internal error + */ + NCP_ERR_INTERNAL = 16000050, + + /** + * @error Can not start another during child process startup, try again after current child process started + */ + NCP_ERR_BUSY = 16010001, + + /** + * @error Start native child time out + */ + NCP_ERR_TIMEOUT = 16010002, + + /** + * @error Service process error + */ + NCP_ERR_SERVICE = 16010003, + + /** + * @error Multi process disabled, can not start child process + */ + NCP_ERR_MULTI_PROCESS_DISABLED = 16010004, + + /** + * @error Already in child process, only main process can start child + */ + NCP_ERR_ALREADY_IN_CHILD = 16010005, + + /** + * @error Max native child processes reached, can not start another + */ + NCP_ERR_MAX_CHILD_PROCESSES_REACHED = 16010006, + + /** + * @error Child process load library failed + */ + NCP_ERR_CHILD_PROCESS_LOAD_LIB = 16010007, + + /** + * @error Faild to invoke OnConnect method in library + */ + NCP_ERR_CHILD_PROCESS_CONNECT = 16010008, +}; + + +/** + * @brief callback function for notify the child process start result, see OH_Ability_CreateNativeChildProcess + * + * @param errCode Zero if successful, an error otherwise, see Ability_NativeChildProcess_ErrCode for detail + * @param remoteProxy IPC object implemented in the sharded lib loaded by child process; will be nullptr when failed + * @since 12 + */ +typedef void (*OH_Ability_OnNativeChildProcessStarted)(int errCode, OHIPCRemoteProxy *remoteProxy); + +/** + * @brief Create native child process for app and load shared library specified by param, + * process startup result is asynchronously notified via callback + * Lib file must be implemented and exported follow functions: + * 1. OHIPCRemoteStub* NativeChildProcess_OnConnect() + * 2. void NativeChildProcess_MainProc() + * + * Processing logic be like follows: + * Main Process: + * 1. Call OH_Ability_CreateNativeChildProcess(libName, onProcessStartedCallback) + * Child Process: + * 2. dlopen(libName) + * 3. dlsym("NativeChildProcess_OnConnect") & dlsym("NativeChildProcess_MainProc") + * 4. ipcRemote = NativeChildProcess_OnConnect() + * 5. NativeChildProcess_MainProc() + * Main Process: + * 6. onProcessStartedCallback(ipcRemote, errCode) + * Child Process: + * 7. Process exit after NativeChildProcess_MainProc() method returned + * + * @param libName Name of the library file loaded by child process, can not be nullptr + * @param onProcessStarted Callback for notify the child process start result + * @return Zero if successful, an error otherwise, see Ability_NativeChildProcess_ErrCode for detail + * @see OH_Ability_OnNativeChildProcessStarted + * @since 12 + */ +int OH_Ability_CreateNativeChildProcess(const char* libName, + OH_Ability_OnNativeChildProcessStarted onProcessStarted); + + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // OHOS_C_ABILITY_RUNTIME_NATIVE_CHILD_PROCESS_H diff --git a/interfaces/kits/native/ability/native/ability_business_error/ability_business_error.h b/interfaces/kits/native/ability/native/ability_business_error/ability_business_error.h index 1ccef7167f..e27ac14d0e 100644 --- a/interfaces/kits/native/ability/native/ability_business_error/ability_business_error.h +++ b/interfaces/kits/native/ability/native/ability_business_error/ability_business_error.h @@ -141,8 +141,14 @@ enum class AbilityErrorCode { // Ability already running. ERROR_ABILITY_ALREADY_RUNNING = 16000068, - // app twin index does not exist. - ERROR_APP_TWIN_INDEX_INVALID = 16000073, + // not support Clone app. + ERROR_CODE_MULTI_APP_NOT_SUPPORTED = 16000072, + + // app is not Clone. + ERROR_NOT_APP_CLONE = 16000071, + + // app clone index does not exist. + ERROR_APP_CLONE_INDEX_INVALID = 16000073, // invalid caller. ERROR_CODE_INVALID_CALLER = 16200001, diff --git a/interfaces/kits/native/ability/native/js_service_extension.h b/interfaces/kits/native/ability/native/js_service_extension.h index 7f75ec8225..7cbed03673 100644 --- a/interfaces/kits/native/ability/native/js_service_extension.h +++ b/interfaces/kits/native/ability/native/js_service_extension.h @@ -23,6 +23,7 @@ #ifdef SUPPORT_GRAPHICS #include "display_manager.h" #include "system_ability_status_change_stub.h" +#include "window_manager.h" #endif #include "service_extension.h" @@ -125,7 +126,7 @@ public: * value of startId is 6. */ virtual void OnCommand(const AAFwk::Want &want, bool restart, int startId) override; - + /** * @brief Called back when Service is started by intent driver. * @@ -178,7 +179,7 @@ private: bool CallPromise(napi_value result, AppExecFwk::AbilityTransactionCallbackInfo<> *callbackInfo); void ListenWMS(); - + bool GetInsightIntentExecutorInfo(const Want &want, const std::shared_ptr &executeParam, InsightIntentExecutorInfo &executorInfo); @@ -192,36 +193,21 @@ private: #ifdef SUPPORT_GRAPHICS protected: - class JsServiceExtensionDisplayListener : public Rosen::DisplayManager::IDisplayListener { + class JsServiceExtensionDisplayListener : public Rosen::IDisplayInfoChangedListener { public: explicit JsServiceExtensionDisplayListener(const std::weak_ptr& jsServiceExtension) { jsServiceExtension_ = jsServiceExtension; } - void OnCreate(Rosen::DisplayId displayId) override - { - auto sptr = jsServiceExtension_.lock(); - if (sptr != nullptr) { - sptr->OnCreate(displayId); + void OnDisplayInfoChange(const sptr& token, Rosen::DisplayId displayId, float density, + Rosen::DisplayOrientation orientation) override + { + auto sptr = jsServiceExtension_.lock(); + if (sptr != nullptr) { + sptr->OnDisplayInfoChange(token, displayId, density, orientation); + } } - } - - void OnDestroy(Rosen::DisplayId displayId) override - { - auto sptr = jsServiceExtension_.lock(); - if (sptr != nullptr) { - sptr->OnDestroy(displayId); - } - } - - void OnChange(Rosen::DisplayId displayId) override - { - auto sptr = jsServiceExtension_.lock(); - if (sptr != nullptr) { - sptr->OnChange(displayId); - } - } private: std::weak_ptr jsServiceExtension_; @@ -230,17 +216,20 @@ protected: void OnCreate(Rosen::DisplayId displayId); void OnDestroy(Rosen::DisplayId displayId); void OnChange(Rosen::DisplayId displayId); + void OnDisplayInfoChange(const sptr& token, Rosen::DisplayId displayId, float density, + Rosen::DisplayOrientation orientation); private: class SystemAbilityStatusChangeListener : public OHOS::SystemAbilityStatusChangeStub { public: - SystemAbilityStatusChangeListener(sptr displayListener) - : tmpDisplayListener_(displayListener) {}; + SystemAbilityStatusChangeListener(sptr displayListener, + const sptr & token): tmpDisplayListener_(displayListener), token_(token) {}; virtual void OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override; virtual void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override {} private: sptr tmpDisplayListener_ = nullptr; + sptr token_ = nullptr; }; sptr displayListener_ = nullptr; diff --git a/interfaces/kits/native/ability/native/ui_ability.h b/interfaces/kits/native/ability/native/ui_ability.h index e48d54ee4b..5319a9c1e3 100644 --- a/interfaces/kits/native/ability/native/ui_ability.h +++ b/interfaces/kits/native/ability/native/ui_ability.h @@ -32,6 +32,7 @@ #include "display_manager.h" #include "session_info.h" #include "window_scene.h" +#include "window_manager.h" #endif namespace OHOS { @@ -539,36 +540,21 @@ public: std::string GetIdentityToken() const; protected: - class UIAbilityDisplayListener : public OHOS::Rosen::DisplayManager::IDisplayListener { + class UIAbilityDisplayListener : public OHOS::Rosen::IDisplayInfoChangedListener { public: explicit UIAbilityDisplayListener(const std::weak_ptr &ability) { ability_ = ability; } - void OnCreate(Rosen::DisplayId displayId) override - { - auto sptr = ability_.lock(); - if (sptr != nullptr) { - sptr->OnCreate(displayId); + void OnDisplayInfoChange(const sptr& token, Rosen::DisplayId displayId, float density, + Rosen::DisplayOrientation orientation) override + { + auto sptr = ability_.lock(); + if (sptr != nullptr) { + sptr->OnDisplayInfoChange(token, displayId, density, orientation); + } } - } - - void OnDestroy(Rosen::DisplayId displayId) override - { - auto sptr = ability_.lock(); - if (sptr != nullptr) { - sptr->OnDestroy(displayId); - } - } - - void OnChange(Rosen::DisplayId displayId) override - { - auto sptr = ability_.lock(); - if (sptr != nullptr) { - sptr->OnChange(displayId); - } - } private: std::weak_ptr ability_; @@ -577,6 +563,8 @@ protected: void OnCreate(Rosen::DisplayId displayId); void OnDestroy(Rosen::DisplayId displayId); void OnChange(Rosen::DisplayId displayId); + void OnDisplayInfoChange(const sptr& token, Rosen::DisplayId displayId, float density, + Rosen::DisplayOrientation orientation); class AbilityDisplayMoveListener : public OHOS::Rosen::IDisplayMoveListener { public: diff --git a/interfaces/kits/native/ability/native/ui_extension_ability/js_ui_extension_content_session.h b/interfaces/kits/native/ability/native/ui_extension_ability/js_ui_extension_content_session.h index 0b893cff20..aae8440a77 100644 --- a/interfaces/kits/native/ability/native/ui_extension_ability/js_ui_extension_content_session.h +++ b/interfaces/kits/native/ability/native/ui_extension_ability/js_ui_extension_content_session.h @@ -117,6 +117,8 @@ protected: napi_env env, NapiCallbackInfo& info, std::shared_ptr &innerErrorCode); void StartAbilityForResultRuntimeTask(napi_env env, AAFwk::Want &want, std::shared_ptr asyncTask, size_t& unwrapArgc, AAFwk::StartOptions startOptions); + void SetCallbackForTerminateWithResult(int32_t resultCode, AAFwk::Want& want, + NapiAsyncTask::CompleteCallback& complete); bool CheckStartAbilityByTypeParam(napi_env env, NapiCallbackInfo& info, std::string type, AAFwk::WantParams wantParam); diff --git a/interfaces/kits/native/ability/native/ui_extension_ability/js_ui_extension_context.h b/interfaces/kits/native/ability/native/ui_extension_ability/js_ui_extension_context.h index a541015e50..85b45fddce 100755 --- a/interfaces/kits/native/ability/native/ui_extension_ability/js_ui_extension_context.h +++ b/interfaces/kits/native/ability/native/ui_extension_ability/js_ui_extension_context.h @@ -54,6 +54,8 @@ protected: virtual napi_value OnDisconnectAbility(napi_env env, NapiCallbackInfo& info); virtual napi_value OnReportDrawnCompleted(napi_env env, NapiCallbackInfo& info); virtual napi_value OnOpenAtomicService(napi_env env, NapiCallbackInfo& info); + void SetCallbackForTerminateWithResult(int32_t resultCode, AAFwk::Want& want, + NapiAsyncTask::CompleteCallback& complete); protected: std::weak_ptr context_; diff --git a/interfaces/kits/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.h b/interfaces/kits/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.h index 69e115c213..33834ac6d0 100644 --- a/interfaces/kits/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.h +++ b/interfaces/kits/native/appkit/ability_bundle_manager_helper/bundle_mgr_helper.h @@ -91,9 +91,9 @@ public: const uint32_t flag, const int32_t userId, std::vector &extensionInfos); sptr GetDefaultAppProxy(); ErrCode GetLaunchWantForBundle(const std::string &bundleName, Want &want, int32_t userId); - ErrCode QueryCloneAbilityInfo(const ElementName &element, int32_t flags, int32_t appTwinIndex, + ErrCode QueryCloneAbilityInfo(const ElementName &element, int32_t flags, int32_t appCloneIndex, AbilityInfo &abilityInfo, int32_t userId); - ErrCode GetCloneBundleInfo(const std::string &bundleName, int32_t flags, int32_t appTwinIndex, + ErrCode GetCloneBundleInfo(const std::string &bundleName, int32_t flags, int32_t appCloneIndex, BundleInfo &bundleInfo, int32_t userId); private: diff --git a/interfaces/kits/native/appkit/ability_runtime/app/ability_stage.h b/interfaces/kits/native/appkit/ability_runtime/app/ability_stage.h index b45048e785..2f09864779 100644 --- a/interfaces/kits/native/appkit/ability_runtime/app/ability_stage.h +++ b/interfaces/kits/native/appkit/ability_runtime/app/ability_stage.h @@ -59,7 +59,8 @@ public: bool ContainsAbility() const; virtual void OnConfigurationUpdated(const AppExecFwk::Configuration& configuration); virtual void OnMemoryLevel(int level); - virtual int32_t RunAutoStartupTask(const std::function &callback, bool &isAsyncCallback); + virtual int32_t RunAutoStartupTask(const std::function &callback, bool &isAsyncCallback, + const std::shared_ptr &stageContext); private: friend class JsAbilityStage; diff --git a/interfaces/kits/native/appkit/ability_runtime/app/js_ability_stage.h b/interfaces/kits/native/appkit/ability_runtime/app/js_ability_stage.h index 60f20dba49..7dd7860dfe 100644 --- a/interfaces/kits/native/appkit/ability_runtime/app/js_ability_stage.h +++ b/interfaces/kits/native/appkit/ability_runtime/app/js_ability_stage.h @@ -56,7 +56,8 @@ public: void OnMemoryLevel(int32_t level) override; - int32_t RunAutoStartupTask(const std::function &callback, bool &isAsyncCallback) override; + int32_t RunAutoStartupTask(const std::function &callback, bool &isAsyncCallback, + const std::shared_ptr &stageContext) override; private: napi_value CallObjectMethod(const char* name, napi_value const * argv = nullptr, size_t argc = 0); @@ -87,6 +88,8 @@ private: bool IsFileExisted(const std::string &filePath); bool TransformFileToJsonString(const std::string &resPath, std::string &profile); + + void SetJsAbilityStage(const std::shared_ptr &context); JsRuntime& jsRuntime_; std::shared_ptr jsAbilityStageObj_; diff --git a/interfaces/kits/native/appkit/ability_runtime/context/application_context.h b/interfaces/kits/native/appkit/ability_runtime/context/application_context.h index 42ed96ce9f..e7dd14c9cb 100644 --- a/interfaces/kits/native/appkit/ability_runtime/context/application_context.h +++ b/interfaces/kits/native/appkit/ability_runtime/context/application_context.h @@ -114,6 +114,10 @@ public: std::string GetAppRunningUniqueId() const; void SetAppRunningUniqueId(const std::string &appRunningUniqueId); int32_t SetSupportedProcessCacheSelf(bool isSupport); + int32_t GetCurrentAppCloneIndex(); + void SetCurrentAppCloneIndex(int32_t appIndex); + int32_t GetCurrentAppMode(); + void SetCurrentAppMode(int32_t appIndex); private: std::shared_ptr contextImpl_; static std::vector> callbacks_; @@ -125,6 +129,8 @@ private: bool applicationInfoUpdateFlag_ = false; AppConfigUpdateCallback appConfigChangeCallback_ = nullptr; std::string appRunningUniqueId_; + int32_t appIndex_ = 0; + int32_t appMode_ = 0; }; } // namespace AbilityRuntime } // namespace OHOS diff --git a/interfaces/kits/native/appkit/ability_runtime/context/js_application_context_utils.h b/interfaces/kits/native/appkit/ability_runtime/context/js_application_context_utils.h index f62cd7a7af..ca3bcd046d 100644 --- a/interfaces/kits/native/appkit/ability_runtime/context/js_application_context_utils.h +++ b/interfaces/kits/native/appkit/ability_runtime/context/js_application_context_utils.h @@ -98,6 +98,7 @@ public: napi_value OnRestartApp(napi_env env, NapiCallbackInfo& info); napi_value OnSetSupportedProcessCacheSelf(napi_env env, NapiCallbackInfo& info); napi_value OnPreloadUIExtensionAbility(napi_env env, NapiCallbackInfo& info); + napi_value OnGetCurrentAppCloneIndex(napi_env env, NapiCallbackInfo& info); static napi_value GetCacheDir(napi_env env, napi_callback_info info); static napi_value GetTempDir(napi_env env, napi_callback_info info); @@ -119,6 +120,7 @@ public: static napi_value RestartApp(napi_env env, napi_callback_info info); static napi_value SetSupportedProcessCacheSelf(napi_env env, napi_callback_info info); static napi_value PreloadUIExtensionAbility(napi_env env, napi_callback_info info); + static napi_value GetCurrentAppCloneIndex(napi_env env, napi_callback_info info); protected: std::weak_ptr applicationContext_; diff --git a/interfaces/kits/native/appkit/app/child_main_thread.h b/interfaces/kits/native/appkit/app/child_main_thread.h index ca6d337866..73a1abf9de 100644 --- a/interfaces/kits/native/appkit/app/child_main_thread.h +++ b/interfaces/kits/native/appkit/app/child_main_thread.h @@ -39,6 +39,7 @@ public: static void Start(const ChildProcessInfo &processInfo); bool ScheduleLoadJs() override; bool ScheduleExitProcessSafely() override; + bool ScheduleRunNativeProc(const sptr &mainProcessCb) override; private: bool Init(const std::shared_ptr &runner, const ChildProcessInfo &processInfo); @@ -49,6 +50,8 @@ private: void ExitProcessSafely(); void GetNativeLibPath(const BundleInfo &bundleInfo, AppLibPathMap &appLibPaths); void GetHapSoPath(const HapModuleInfo &hapInfo, AppLibPathMap &appLibPaths, bool isPreInstallApp); + void HandleRunNativeProc(const sptr &mainProcessCb); + void UpdateNativeChildLibPath(const AppLibPathMap &appLibPaths); std::string GetLibPath(const std::string &hapPath, bool isPreInstallApp); sptr appMgr_ = nullptr; diff --git a/interfaces/kits/native/appkit/app_startup/js_startup_task_result.h b/interfaces/kits/native/appkit/app_startup/js_startup_task_result.h index a64af705a2..9f67decc8c 100644 --- a/interfaces/kits/native/appkit/app_startup/js_startup_task_result.h +++ b/interfaces/kits/native/appkit/app_startup/js_startup_task_result.h @@ -33,7 +33,7 @@ public: ResultType GetResultType() const override; - std::shared_ptr GetJsStartupResultRef() const; + const std::shared_ptr& GetJsStartupResultRef() const; private: std::shared_ptr jsStartupResultRef_; diff --git a/interfaces/kits/native/appkit/app_startup/startup_config.h b/interfaces/kits/native/appkit/app_startup/startup_config.h index c180beae8c..c76bb163d9 100644 --- a/interfaces/kits/native/appkit/app_startup/startup_config.h +++ b/interfaces/kits/native/appkit/app_startup/startup_config.h @@ -34,11 +34,11 @@ public: explicit StartupConfig(const std::shared_ptr &listener); - explicit StartupConfig(int32_t awaitTimeoutMs, const std::shared_ptr &listener); + StartupConfig(int32_t awaitTimeoutMs, const std::shared_ptr &listener); int32_t GetAwaitTimeoutMs() const; - int32_t ListenerOnCompleted(const std::shared_ptr &result); + void ListenerOnCompleted(const std::shared_ptr &result); static constexpr int32_t DEFAULT_AWAIT_TIMEOUT_MS = 10000; // 10s diff --git a/interfaces/kits/native/appkit/app_startup/startup_manager.h b/interfaces/kits/native/appkit/app_startup/startup_manager.h index 5cfe561aa2..6420be5acd 100644 --- a/interfaces/kits/native/appkit/app_startup/startup_manager.h +++ b/interfaces/kits/native/appkit/app_startup/startup_manager.h @@ -43,7 +43,7 @@ public: void SetDefaultConfig(const std::shared_ptr &config); - std::shared_ptr GetDefaultConfig() const; + const std::shared_ptr& GetDefaultConfig() const; int32_t RemoveAllResult(); diff --git a/interfaces/kits/native/appkit/app_startup/startup_task.h b/interfaces/kits/native/appkit/app_startup/startup_task.h index dbc881571a..1fb05f411d 100644 --- a/interfaces/kits/native/appkit/app_startup/startup_task.h +++ b/interfaces/kits/native/appkit/app_startup/startup_task.h @@ -38,7 +38,7 @@ public: virtual ~StartupTask(); - std::string GetName() const; + const std::string& GetName() const; std::vector GetDependencies() const; @@ -62,7 +62,7 @@ public: int32_t RemoveResult(); - std::shared_ptr GetResult() const; + const std::shared_ptr& GetResult() const; virtual int32_t RunTaskInit(std::unique_ptr callback) = 0; diff --git a/interfaces/kits/native/appkit/app_startup/startup_task_manager.h b/interfaces/kits/native/appkit/app_startup/startup_task_manager.h index 73119ecd2d..7985e2021a 100644 --- a/interfaces/kits/native/appkit/app_startup/startup_task_manager.h +++ b/interfaces/kits/native/appkit/app_startup/startup_task_manager.h @@ -37,7 +37,7 @@ public: int32_t AddTask(const std::shared_ptr &task); - int32_t SetConfig(const std::shared_ptr &config); + void SetConfig(const std::shared_ptr &config); int32_t Prepare(); diff --git a/interfaces/kits/native/appkit/app_startup/startup_task_result.h b/interfaces/kits/native/appkit/app_startup/startup_task_result.h index 247f88e37c..8dc820eca5 100644 --- a/interfaces/kits/native/appkit/app_startup/startup_task_result.h +++ b/interfaces/kits/native/appkit/app_startup/startup_task_result.h @@ -42,7 +42,7 @@ public: int32_t GetResultCode() const; - std::string GetResultMessage() const; + const std::string& GetResultMessage() const; virtual ResultType GetResultType() const; diff --git a/js_environment/frameworks/js_environment/src/js_environment.cpp b/js_environment/frameworks/js_environment/src/js_environment.cpp index d0e856f878..c5326be1e5 100644 --- a/js_environment/frameworks/js_environment/src/js_environment.cpp +++ b/js_environment/frameworks/js_environment/src/js_environment.cpp @@ -349,24 +349,6 @@ void JsEnvironment::SetDeviceDisconnectCallback(const std::function &cb) panda::JSNApi::SetDeviceDisconnectCallback(vm_, std::move(cb)); } -void JsEnvironment::StartMonitorJSHeapUsage() -{ - if (engine_ == nullptr) { - JSENV_LOG_E("Invalid native engine."); - return; - } - engine_->StartMonitorJSHeapUsage(); -} - -void JsEnvironment::StopMonitorJSHeapUsage() -{ - if (engine_ == nullptr) { - JSENV_LOG_E("Invalid native engine."); - return; - } - engine_->StopMonitorJSHeapUsage(); -} - DebuggerPostTask JsEnvironment::GetDebuggerPostTask() { auto debuggerPostTask = [weak = weak_from_this()](std::function&& task) { diff --git a/js_environment/interfaces/inner_api/js_environment.h b/js_environment/interfaces/inner_api/js_environment.h index 8a95a790bf..587655c4e3 100644 --- a/js_environment/interfaces/inner_api/js_environment.h +++ b/js_environment/interfaces/inner_api/js_environment.h @@ -108,10 +108,6 @@ public: void SetDeviceDisconnectCallback(const std::function &cb); - void StartMonitorJSHeapUsage(); - - void StopMonitorJSHeapUsage(); - void NotifyDebugMode(int tid, const char* libraryPath, uint32_t instanceId, bool isDebugApp, bool debugMode); bool GetDebugMode() const; diff --git a/js_environment/test/unittest/BUILD.gn b/js_environment/test/unittest/BUILD.gn index 68d637e8a9..04a5773ea1 100644 --- a/js_environment/test/unittest/BUILD.gn +++ b/js_environment/test/unittest/BUILD.gn @@ -21,5 +21,6 @@ group("unittest") { "js_env_log_unit_test:unittest", "js_environment_test:unittest", "source_map_test:unittest", + "uncaught_exception_callback_test:unittest", ] } diff --git a/js_environment/test/unittest/js_environment_test/js_environment_test.cpp b/js_environment/test/unittest/js_environment_test/js_environment_test.cpp index 3a28db43fb..ce7445f884 100644 --- a/js_environment/test/unittest/js_environment_test/js_environment_test.cpp +++ b/js_environment/test/unittest/js_environment_test/js_environment_test.cpp @@ -243,6 +243,27 @@ HWTEST_F(JsEnvironmentTest, StartDebugger_0100, TestSize.Level0) ASSERT_EQ(result, false); } +/** + * @tc.name: StartDebugger_0200 + * @tc.desc: StartDebugger + * @tc.type: FUNC + * @tc.require: issue + */ +HWTEST_F(JsEnvironmentTest, StartDebugger_0200, TestSize.Level0) +{ + auto jsEnv = std::make_shared(std::make_unique()); + ASSERT_NE(jsEnv, nullptr); + panda::RuntimeOption pandaOption; + auto ret = jsEnv->Initialize(pandaOption, static_cast(this)); + ASSERT_EQ(ret, true); + + std::string option = "ark:1234@Debugger"; + uint32_t socketFd = 10; + bool isDebugApp = true; + bool result = jsEnv->StartDebugger(option, socketFd, isDebugApp, jsEnv->GetDebuggerPostTask()); + ASSERT_EQ(result, false); +} + /** * @tc.name: StopDebugger_0100 * @tc.desc: StopDebugger @@ -477,6 +498,21 @@ HWTEST_F(JsEnvironmentTest, GetDebuggerPostTask_0100, TestSize.Level0) ASSERT_NE(jsEnv, nullptr); } +/** + * @tc.name: GetDebuggerPostTask_0200 + * @tc.desc: Js environment GetDebuggerPostTask. + * @tc.type: FUNC + */ +HWTEST_F(JsEnvironmentTest, GetDebuggerPostTask_0200, TestSize.Level0) +{ + auto jsEnv = std::make_shared(std::make_unique()); + auto poster = jsEnv->GetDebuggerPostTask(); + ASSERT_NE(jsEnv, nullptr); + poster([]() { + std::string temp; + }); +} + /** * @tc.name: GetHeapPrepare_0100 * @tc.desc: Js environment GetHeapPrepare. @@ -502,57 +538,5 @@ HWTEST_F(JsEnvironmentTest, GetHeapPrepare_0200, TestSize.Level0) jsEnv->GetHeapPrepare(); ASSERT_NE(jsEnv, nullptr); } - -/** - * @tc.name: StartMonitorJSHeapUsage_0100 - * @tc.desc: Js environment StartMonitorJSHeapUsage. - * @tc.type: FUNC - */ -HWTEST_F(JsEnvironmentTest, StartMonitorJSHeapUsage_0100, TestSize.Level0) -{ - auto jsEnv = std::make_shared(std::make_unique()); - jsEnv->StartMonitorJSHeapUsage(); - ASSERT_NE(jsEnv, nullptr); -} - -/** - * @tc.name: StartMonitorJSHeapUsage_0200 - * @tc.desc: Js environment StartMonitorJSHeapUsage. - * @tc.type: FUNC - */ -HWTEST_F(JsEnvironmentTest, StartMonitorJSHeapUsage_0200, TestSize.Level0) -{ - auto jsEnv = std::make_shared(std::make_unique()); - panda::RuntimeOption pandaOption; - jsEnv->Initialize(pandaOption, static_cast(this)); - jsEnv->StartMonitorJSHeapUsage(); - ASSERT_NE(jsEnv, nullptr); -} - -/** - * @tc.name: StopMonitorJSHeapUsage_0100 - * @tc.desc: Js environment StopMonitorJSHeapUsage. - * @tc.type: FUNC - */ -HWTEST_F(JsEnvironmentTest, StopMonitorJSHeapUsage_0100, TestSize.Level0) -{ - auto jsEnv = std::make_shared(std::make_unique()); - jsEnv->StopMonitorJSHeapUsage(); - ASSERT_NE(jsEnv, nullptr); -} - -/** - * @tc.name: StopMonitorJSHeapUsage_0200 - * @tc.desc: Js environment StopMonitorJSHeapUsage. - * @tc.type: FUNC - */ -HWTEST_F(JsEnvironmentTest, StopMonitorJSHeapUsage_0200, TestSize.Level0) -{ - auto jsEnv = std::make_shared(std::make_unique()); - panda::RuntimeOption pandaOption; - jsEnv->Initialize(pandaOption, static_cast(this)); - jsEnv->StopMonitorJSHeapUsage(); - ASSERT_NE(jsEnv, nullptr); -} } // namespace JsEnv } // namespace OHOS diff --git a/js_environment/test/unittest/source_map_test/source_map_test.cpp b/js_environment/test/unittest/source_map_test/source_map_test.cpp index 5afeb8341a..9504f20d34 100644 --- a/js_environment/test/unittest/source_map_test/source_map_test.cpp +++ b/js_environment/test/unittest/source_map_test/source_map_test.cpp @@ -193,6 +193,35 @@ HWTEST_F(SourceMapTest, JsEnv_SourceMap_0900, Function | MediumTest | Level1) GTEST_LOG_(INFO) << "JsEnv_SourceMap_0900 end"; } +/** + * @tc.number: JsEnv_SourceMap_1000 + * @tc.name: Find + * @tc.desc: Verifying Find succeeded. + * @tc.require: #I6T4K1 + */ +HWTEST_F(SourceMapTest, JsEnv_SourceMap_1000, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) << "JsEnv_SourceMap_1000 start"; + auto modSourceMap = std::make_shared(); + int32_t row = 2; + int32_t col = 3; + SourceMapData targetMap; + targetMap.sources_.emplace_back("sources"); + for (int32_t i = 0; i < 10; i++) { + for (int32_t j = 0; j < 5; j++) { + SourceMapInfo mapInfo; + mapInfo.beforeRow = 0; + mapInfo.beforeColumn = 0; + mapInfo.afterRow = i; + mapInfo.afterColumn = j; + targetMap.afterPos_.emplace_back(mapInfo); + } + } + auto info = modSourceMap->Find(row, col, targetMap); + EXPECT_STREQ(info.sources.c_str(), "sources"); + GTEST_LOG_(INFO) << "JsEnv_SourceMap_1000 end"; +} + /** * @tc.number: JsEnv_SourceMap_1300 * @tc.name: GetPosInfo diff --git a/js_environment/test/unittest/uncaught_exception_callback_test/uncaught_exception_callback_test.cpp b/js_environment/test/unittest/uncaught_exception_callback_test/uncaught_exception_callback_test.cpp index 76646c9331..4231ab8db3 100644 --- a/js_environment/test/unittest/uncaught_exception_callback_test/uncaught_exception_callback_test.cpp +++ b/js_environment/test/unittest/uncaught_exception_callback_test/uncaught_exception_callback_test.cpp @@ -94,6 +94,36 @@ HWTEST_F(NapiUncaughtExceptionCallbackTest, NapiUncaughtExceptionCallbackTest_01 ASSERT_EQ(callback3.GetNativeStrFromJsTaggedObj(object, "stack"), errorStack); } +/** + * @tc.name: NapiUncaughtExceptionCallbackTest_0101 + * @tc.type: FUNC + * @tc.desc: Test NapiNapiUncaughtExceptionCallback GetNativeStrFromJsTaggedObj. + * @tc.require: #I6T4K1 + */ +HWTEST_F(NapiUncaughtExceptionCallbackTest, NapiUncaughtExceptionCallbackTest_0101, TestSize.Level1) +{ + AbilityRuntime::Runtime::Options options; + options.preload = false; + auto jsRuntime = AbilityRuntime::JsRuntime::Create(options); + ASSERT_NE(jsRuntime, nullptr); + auto env = jsRuntime->GetNapiEnv(); + EXPECT_NE(env, nullptr); + + // Test with null object + auto task = [](std::string summary, const JsEnv::ErrorObject errorObj) { + summary += "test"; + }; + + // Test with invalid object + napi_value object = nullptr; + napi_create_object(env, &object); + napi_value valueUint32 = nullptr; + napi_create_uint32(env, 0x11, &valueUint32); + napi_set_named_property(env, object, "key", valueUint32); + NapiUncaughtExceptionCallback callback(task, nullptr, env); + ASSERT_EQ(callback.GetNativeStrFromJsTaggedObj(object, "key"), ""); +} + /** * @tc.name: NapiUncaughtExceptionCallbackTest_0200 * @tc.type: FUNC diff --git a/service_router_framework/interfaces/kits/js/serviceroutermgr/BUILD.gn b/service_router_framework/interfaces/kits/js/serviceroutermgr/BUILD.gn index 59ff9fd5fb..ab2448d98d 100755 --- a/service_router_framework/interfaces/kits/js/serviceroutermgr/BUILD.gn +++ b/service_router_framework/interfaces/kits/js/serviceroutermgr/BUILD.gn @@ -37,6 +37,7 @@ ohos_shared_library("businessabilityrouter") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${srms_inner_api_path}:srms_fwk", ] diff --git a/service_router_framework/services/srms/BUILD.gn b/service_router_framework/services/srms/BUILD.gn index b358dfc2ec..fc4ed26a2e 100755 --- a/service_router_framework/services/srms/BUILD.gn +++ b/service_router_framework/services/srms/BUILD.gn @@ -27,6 +27,12 @@ config("srms_config") { } ohos_shared_library("libsrms") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + branch_protector_ret = "pac_ret" sources = [ "src/inner_service_info.cpp", "src/service_router_data_mgr.cpp", @@ -40,6 +46,7 @@ ohos_shared_library("libsrms") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/appkit:appkit_manager_helper", "${srms_inner_api_path}:srms_fwk", ] diff --git a/service_router_framework/services/srms/test/unittest/service_router_mgr_interface_test/BUILD.gn b/service_router_framework/services/srms/test/unittest/service_router_mgr_interface_test/BUILD.gn index 0e96c19afc..c53934f6f8 100755 --- a/service_router_framework/services/srms/test/unittest/service_router_mgr_interface_test/BUILD.gn +++ b/service_router_framework/services/srms/test/unittest/service_router_mgr_interface_test/BUILD.gn @@ -23,10 +23,12 @@ ohos_unittest("ServiceRouterMgrInterfaceTest") { sources = [ "${srms_services_path}/src/inner_service_info.cpp", "${srms_services_path}/src/service_router_data_mgr.cpp", + "${srms_services_path}/src/sr_samgr_helper.cpp", "srms_interface_test.cpp", ] deps = [ + "${ability_runtime_native_path}/appkit:appkit_manager_helper", "${bundlefwk_common_path}:libappexecfwk_common", "${srms_inner_api_path}:srms_fwk", ] diff --git a/service_router_framework/services/srms/test/unittest/service_router_mgr_interface_test/srms_interface_test.cpp b/service_router_framework/services/srms/test/unittest/service_router_mgr_interface_test/srms_interface_test.cpp index ee661879ce..dd8c61d50a 100755 --- a/service_router_framework/services/srms/test/unittest/service_router_mgr_interface_test/srms_interface_test.cpp +++ b/service_router_framework/services/srms/test/unittest/service_router_mgr_interface_test/srms_interface_test.cpp @@ -391,6 +391,116 @@ HWTEST_F(ServiceRouterMgrInterfaceTest, ServiceRouterMgrInterfaceTest_0019, Func EXPECT_TRUE(ret); } +/** + * @tc.number: ServiceRouterMgrInterfaceTest + * @tc.name: test LoadAllBundleInfos + * @tc.desc: test LoadAllBundleInfos function + */ +HWTEST_F(ServiceRouterMgrInterfaceTest, ServiceRouterMgrInterfaceTest_0020, Function | SmallTest | Level0) +{ + auto serviceRouterMgr = std::make_shared(); + EXPECT_NE(serviceRouterMgr, nullptr); + if (serviceRouterMgr != nullptr) { + auto ret = serviceRouterMgr->LoadAllBundleInfos(); + EXPECT_EQ(ret, true); + } +} + +/** + * @tc.number: ServiceRouterMgrInterfaceTest + * @tc.name: test LoadBundleInfo + * @tc.desc: test LoadBundleInfo function + */ +HWTEST_F(ServiceRouterMgrInterfaceTest, ServiceRouterMgrInterfaceTest_0021, Function | SmallTest | Level0) +{ + auto serviceRouterMgr = std::make_shared(); + EXPECT_NE(serviceRouterMgr, nullptr); + if (serviceRouterMgr != nullptr) { + std::string bundleName = BUNDLE_NAME; + auto ret = serviceRouterMgr->LoadBundleInfo(bundleName); + EXPECT_EQ(ret, false); + } +} + +/** + * @tc.number: ServiceRouterMgrInterfaceTest + * @tc.name: test UpdateBundleInfoLocked + * @tc.desc: test UpdateBundleInfoLocked function + */ +HWTEST_F(ServiceRouterMgrInterfaceTest, ServiceRouterMgrInterfaceTest_0022, Function | SmallTest | Level0) +{ + auto serviceRouterMgr = std::make_shared(); + EXPECT_NE(serviceRouterMgr, nullptr); + if (serviceRouterMgr != nullptr) { + BundleInfo bundleInfo; + serviceRouterMgr->UpdateBundleInfoLocked(bundleInfo); + } +} + +/** + * @tc.number: ServiceRouterMgrInterfaceTest + * @tc.name: test DeleteBundleInfo + * @tc.desc: test DeleteBundleInfo function + */ +HWTEST_F(ServiceRouterMgrInterfaceTest, ServiceRouterMgrInterfaceTest_0023, Function | SmallTest | Level0) +{ + auto serviceRouterMgr = std::make_shared(); + EXPECT_NE(serviceRouterMgr, nullptr); + if (serviceRouterMgr != nullptr) { + std::string bundleName = BUNDLE_NAME; + serviceRouterMgr->DeleteBundleInfo(bundleName); + } +} + +/** + * @tc.number: ServiceRouterMgrInterfaceTest + * @tc.name: test GetBusinessType + * @tc.desc: test GetBusinessType function 1 + */ +HWTEST_F(ServiceRouterMgrInterfaceTest, ServiceRouterMgrInterfaceTest_0024, Function | SmallTest | Level0) +{ + auto serviceRouterMgr = std::make_shared(); + EXPECT_NE(serviceRouterMgr, nullptr); + if (serviceRouterMgr != nullptr) { + BusinessAbilityFilter filter; + filter.businessType = BusinessType::SHARE; + auto ret = serviceRouterMgr->GetBusinessType(filter); + EXPECT_EQ(ret, BusinessType::SHARE); + } +} + +/** + * @tc.number: ServiceRouterMgrInterfaceTest + * @tc.name: test GetBusinessType + * @tc.desc: test GetBusinessType function 2 + */ +HWTEST_F(ServiceRouterMgrInterfaceTest, ServiceRouterMgrInterfaceTest_0025, Function | SmallTest | Level0) +{ + auto serviceRouterMgr = std::make_shared(); + EXPECT_NE(serviceRouterMgr, nullptr); + if (serviceRouterMgr != nullptr) { + BusinessAbilityFilter filter; + filter.businessType = BusinessType::UNSPECIFIED; + filter.uri = ""; + auto ret = serviceRouterMgr->GetBusinessType(filter); + EXPECT_EQ(ret, BusinessType::UNSPECIFIED); + } +} + +/** + * @tc.number: ServiceRouterMgrInterfaceTest + * @tc.name: test ClearAllBundleInfos + * @tc.desc: test ClearAllBundleInfos function + */ +HWTEST_F(ServiceRouterMgrInterfaceTest, ServiceRouterMgrInterfaceTest_0026, Function | SmallTest | Level0) +{ + auto serviceRouterMgr = std::make_shared(); + EXPECT_NE(serviceRouterMgr, nullptr); + if (serviceRouterMgr != nullptr) { + serviceRouterMgr->ClearAllBundleInfos(); + } +} + /** * @tc.number: serviceRouterMgrProxy * @tc.name: test QueryBusinessAbilityInfos diff --git a/services/abilitymgr/BUILD.gn b/services/abilitymgr/BUILD.gn index 080ed91345..1da5df911e 100644 --- a/services/abilitymgr/BUILD.gn +++ b/services/abilitymgr/BUILD.gn @@ -106,6 +106,12 @@ config("abilityms_config") { } ohos_shared_library("abilityms") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + branch_protector_ret = "pac_ret" shlib_type = "sa" sources = abilityms_files cflags_cc = [] @@ -116,6 +122,7 @@ ohos_shared_library("abilityms") { include_dirs = [ "${ability_runtime_services_path}/appdfr/include" ] deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:ability_start_setting", "${ability_runtime_innerkits_path}/ability_manager:mission_info", "${ability_runtime_innerkits_path}/ability_manager:process_options", diff --git a/services/abilitymgr/include/ability_manager_proxy.h b/services/abilitymgr/include/ability_manager_proxy.h index afc5096c03..f4b67472e8 100644 --- a/services/abilitymgr/include/ability_manager_proxy.h +++ b/services/abilitymgr/include/ability_manager_proxy.h @@ -1242,6 +1242,17 @@ public: */ virtual int32_t GetAbilityStateByPersistentId(int32_t persistentId, bool &state) override; + /** + * Transfer resultCode & want to ability manager service. + * + * @param callerToken caller ability token. + * @param requestCode the resultCode of the ability to start. + * @param want Indicates the ability to start. + * @return Returns ERR_OK on success, others on failure. + */ + virtual int32_t TransferAbilityResultForExtension(const sptr &callerToken, int32_t resultCode, + const Want &want) override; + private: template int GetParcelableInfos(MessageParcel &reply, std::vector &parcelableInfos); diff --git a/services/abilitymgr/include/ability_manager_service.h b/services/abilitymgr/include/ability_manager_service.h index f05fe296de..9167d95ccb 100644 --- a/services/abilitymgr/include/ability_manager_service.h +++ b/services/abilitymgr/include/ability_manager_service.h @@ -67,13 +67,16 @@ #include "dialog_session_record.h" #include "implicit_start_processor.h" #include "system_dialog_scheduler.h" -#include "window_focus_changed_listener.h" #endif namespace OHOS { namespace AbilityRuntime { class IStatusBarDelegate; } +namespace Rosen { +class FocusChangeInfo; +} + namespace AAFwk { using AutoStartupInfo = AbilityRuntime::AutoStartupInfo; enum class ServiceRunningState { STATE_NOT_START, STATE_RUNNING }; @@ -83,6 +86,8 @@ constexpr int32_t INVALID_USER_ID = -1; using OHOS::AppExecFwk::IAbilityController; class PendingWantManager; struct StartAbilityInfo; +class WindowFocusChangedListener; + /** * @class AbilityManagerService * AbilityManagerService provides a facility for managing ability life cycle. @@ -1669,6 +1674,17 @@ public: */ virtual int32_t GetAbilityStateByPersistentId(int32_t persistentId, bool &state) override; + /** + * Transfer resultCode & want to ability manager service. + * + * @param callerToken Caller ability token. + * @param requestCode The resultCode of the ability to start. + * @param want Indicates the ability to start. + * @return Returns ERR_OK on success, others on failure. + */ + virtual int32_t TransferAbilityResultForExtension(const sptr &callerToken, int32_t resultCode, + const Want &want) override; + // MSG 0 - 20 represents timeout message static constexpr uint32_t LOAD_TIMEOUT_MSG = 0; static constexpr uint32_t ACTIVE_TIMEOUT_MSG = 1; diff --git a/services/abilitymgr/include/ability_manager_stub.h b/services/abilitymgr/include/ability_manager_stub.h index 58c0e0b69c..3db3377525 100644 --- a/services/abilitymgr/include/ability_manager_stub.h +++ b/services/abilitymgr/include/ability_manager_stub.h @@ -70,6 +70,7 @@ private: void SecondStepInit(); void ThirdStepInit(); void FourthStepInit(); + void FifthStepInit(); int TerminateAbilityInner(MessageParcel &data, MessageParcel &reply); int TerminateUIExtensionAbilityInner(MessageParcel &data, MessageParcel &reply); int CloseUIAbilityBySCBInner(MessageParcel &data, MessageParcel &reply); @@ -298,6 +299,7 @@ private: int32_t NotifyDebugAssertResultInner(MessageParcel &data, MessageParcel &reply); int32_t StartShortcutInner(MessageParcel &data, MessageParcel &reply); int32_t GetAbilityStateByPersistentIdInner(MessageParcel &data, MessageParcel &reply); + int32_t TransferAbilityResultForExtensionInner(MessageParcel &data, MessageParcel &reply); }; } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/include/ability_record.h b/services/abilitymgr/include/ability_record.h index c017f6202f..af71fc858a 100644 --- a/services/abilitymgr/include/ability_record.h +++ b/services/abilitymgr/include/ability_record.h @@ -358,6 +358,12 @@ public: */ void ProcessForegroundAbility(uint32_t tokenId, uint32_t sceneFlag = 0); + /** + * post foreground timeout task for ui ability. + * + */ + void PostForegroundTimeoutTask(); + /** * move the ability to back ground. * diff --git a/services/abilitymgr/include/ability_util.h b/services/abilitymgr/include/ability_util.h index 18003043a9..b8abf0a737 100644 --- a/services/abilitymgr/include/ability_util.h +++ b/services/abilitymgr/include/ability_util.h @@ -37,7 +37,9 @@ namespace AAFwk { namespace AbilityUtil { constexpr const char* SYSTEM_BASIC = "system_basic"; constexpr const char* SYSTEM_CORE = "system_core"; +constexpr const char* DEFAULT_DEVICE_ID = ""; constexpr const char* DLP_BUNDLE_NAME = "com.ohos.dlpmanager"; +constexpr const char* DLP_MODULE_NAME = "entry"; constexpr const char* DLP_ABILITY_NAME = "ViewAbility"; constexpr const char* DLP_PARAMS_SANDBOX = "ohos.dlp.params.sandbox"; constexpr const char* DLP_PARAMS_BUNDLE_NAME = "ohos.dlp.params.bundleName"; @@ -221,7 +223,7 @@ static constexpr int64_t MICROSECONDS = 1000000; // MICROSECONDS mean 10^6 mi AppExecFwk::ElementName element = want.GetElement(); if (want.GetBoolParam(DLP_PARAMS_SANDBOX, false) && !element.GetBundleName().empty() && !element.GetAbilityName().empty()) { - want.SetElementName(DLP_BUNDLE_NAME, DLP_ABILITY_NAME); + want.SetElementName(DEFAULT_DEVICE_ID, DLP_BUNDLE_NAME, DLP_ABILITY_NAME, DLP_MODULE_NAME); want.SetParam(DLP_PARAMS_BUNDLE_NAME, element.GetBundleName()); want.SetParam(DLP_PARAMS_MODULE_NAME, element.GetModuleName()); want.SetParam(DLP_PARAMS_ABILITY_NAME, element.GetAbilityName()); diff --git a/services/abilitymgr/include/app_scheduler.h b/services/abilitymgr/include/app_scheduler.h index e54251595a..760e9c1295 100644 --- a/services/abilitymgr/include/app_scheduler.h +++ b/services/abilitymgr/include/app_scheduler.h @@ -426,14 +426,6 @@ public: */ void ClearProcessByToken(sptr token) const; - /** - * Set application assertion pause state. - * - * @param pid App process pid. - * @param flag assertion pause state. - */ - void SetAppAssertionPauseState(int32_t pid, bool flag); - /** * whether memory size is sufficent. * @return Returns true is sufficent memory size, others return false. diff --git a/services/abilitymgr/include/dlp_utils.h b/services/abilitymgr/include/dlp_utils.h index f55e65a582..6e10b8e173 100644 --- a/services/abilitymgr/include/dlp_utils.h +++ b/services/abilitymgr/include/dlp_utils.h @@ -50,7 +50,7 @@ using Dlp = Security::DlpPermission::DlpPermissionKit; TAG_LOGE(AAFwkTag::ABILITYMGR, "Ability has already been destroyed."); return true; } - if (abilityRecord->GetAppIndex() <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + if (abilityRecord->GetAppIndex() <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { return true; } if (abilityRecord->GetApplicationInfo().bundleName == want.GetElement().GetBundleName()) { @@ -76,7 +76,7 @@ using Dlp = Security::DlpPermission::DlpPermissionKit; if (callerToken != nullptr) { auto abilityRecord = Token::GetAbilityRecordByToken(callerToken); if (abilityRecord != nullptr && - abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { return true; } } diff --git a/services/abilitymgr/include/ecological_rule/ability_ecological_rule_mgr_service_param.h b/services/abilitymgr/include/ecological_rule/ability_ecological_rule_mgr_service_param.h index db5541ffe7..ea12333645 100644 --- a/services/abilitymgr/include/ecological_rule/ability_ecological_rule_mgr_service_param.h +++ b/services/abilitymgr/include/ecological_rule/ability_ecological_rule_mgr_service_param.h @@ -21,6 +21,7 @@ #include "parcel.h" #include "want.h" +#include "ability_info.h" namespace OHOS { namespace EcologicalRuleMgrService { @@ -69,10 +70,11 @@ struct AbilityCallerInfo : public Parcelable { std::string targetAppDistType = ""; std::string targetLinkFeature = ""; int32_t targetLinkType = LINK_TYPE_INVALID; - int32_t callerAbilityType = 0L; + AppExecFwk::AbilityType callerAbilityType = AppExecFwk::AbilityType::UNKNOWN; int32_t embedded = 0; std::string callerAppProvisionType; std::string targetAppProvisionType; + AppExecFwk::ExtensionAbilityType callerExtensionAbilityType = AppExecFwk::ExtensionAbilityType::UNSPECIFIED; bool ReadFromParcel(Parcel &parcel); diff --git a/services/abilitymgr/include/extension_record_manager.h b/services/abilitymgr/include/extension_record_manager.h index ff3ffe660a..3b809cad12 100644 --- a/services/abilitymgr/include/extension_record_manager.h +++ b/services/abilitymgr/include/extension_record_manager.h @@ -87,8 +87,7 @@ public: int32_t StartAbility(const AAFwk::AbilityRequest &abilityRequest); - int32_t CreateExtensionRecord( - const std::shared_ptr &abilityRecord, const std::string &hostBundleName, + int32_t CreateExtensionRecord(const AAFwk::AbilityRequest &abilityRequest, const std::string &hostBundleName, std::shared_ptr &extensionRecord, int32_t &extensionRecordId); bool IsPreloadExtensionRecord(const AAFwk::AbilityRequest &abilityRequest, diff --git a/services/abilitymgr/include/interceptor/ecological_rule_interceptor.h b/services/abilitymgr/include/interceptor/ecological_rule_interceptor.h index 8e3b693fd3..9f9bd8aecf 100644 --- a/services/abilitymgr/include/interceptor/ecological_rule_interceptor.h +++ b/services/abilitymgr/include/interceptor/ecological_rule_interceptor.h @@ -40,7 +40,8 @@ public: }; private: - void GetEcologicalCallerInfo(const Want &want, ErmsCallerInfo &callerInfo, int32_t userId); + void GetEcologicalCallerInfo(const Want &want, ErmsCallerInfo &callerInfo, int32_t userId, + const sptr &callerToken = nullptr); void InitErmsCallerInfo(Want &want, ErmsCallerInfo &callerInfo) const; }; } // namespace AAFwk diff --git a/services/abilitymgr/include/mission_list_manager.h b/services/abilitymgr/include/mission_list_manager.h index 908548573c..84c7e74097 100644 --- a/services/abilitymgr/include/mission_list_manager.h +++ b/services/abilitymgr/include/mission_list_manager.h @@ -23,7 +23,6 @@ #include "cpp/mutex.h" #include "ability_running_info.h" -#include "foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp/include/device_manager.h" #include "mission_list.h" #include "mission_listener_controller.h" #include "mission_info.h" @@ -318,7 +317,7 @@ public: void EnableRecoverAbility(int32_t missionId); - #ifdef ABILITY_COMMAND_FOR_TEST +#ifdef ABILITY_COMMAND_FOR_TEST /** * Block ability. * @@ -326,7 +325,7 @@ public: * @return Returns ERR_OK on success, others on failure. */ int BlockAbility(int abilityRecordId); - #endif +#endif void UninstallApp(const std::string &bundleName, int32_t uid); @@ -344,7 +343,7 @@ public: int32_t pid = NO_PID); void CallRequestDone(const std::shared_ptr &abilityRecord, const sptr &callStub); - + int SetMissionContinueState(const sptr &token, const int32_t missionId, const AAFwk::ContinueState &state); @@ -543,13 +542,6 @@ private: std::queue waitingAbilityQueue_; std::shared_ptr listenerController_; bool isPrepareTerminateEnable_ = false; - - class MissionDmInitCallback : public DistributedHardware::DmInitCallback { - public: - void OnRemoteDied() override; - - static bool isInit_; - }; }; } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/include/scene_board/ui_ability_lifecycle_manager.h b/services/abilitymgr/include/scene_board/ui_ability_lifecycle_manager.h index b486d5f86b..10747b36c5 100644 --- a/services/abilitymgr/include/scene_board/ui_ability_lifecycle_manager.h +++ b/services/abilitymgr/include/scene_board/ui_ability_lifecycle_manager.h @@ -26,7 +26,6 @@ #include "ability_manager_constants.h" #include "ability_record.h" #include "isession_handler_interface.h" -#include "session/host/include/zidl/session_interface.h" namespace OHOS { namespace AAFwk { @@ -337,6 +336,8 @@ private: int32_t GetReusedSpecifiedPersistentId(const AbilityRequest &abilityRequest, bool &reuse) const; int32_t GetReusedStandardPersistentId(const AbilityRequest &abilityRequest, bool &reuse) const; int32_t GetReusedCollaboratorPersistentId(const AbilityRequest &abilityRequest, bool &reuse) const; + std::string GenerateProcessNameForNewProcessMode(const AppExecFwk::AbilityInfo& abilityInfo); + void PreCreateProcessName(AbilityRequest &abilityRequest); void UpdateProcessName(const AbilityRequest &abilityRequest, std::shared_ptr &abilityRecord); void UpdateAbilityRecordLaunchReason(const AbilityRequest &abilityRequest, std::shared_ptr &abilityRecord) const; @@ -397,7 +398,7 @@ private: bool CheckPid(const std::shared_ptr abilityRecord, const int32_t pid) const; std::shared_ptr GetStatusBarDelegateManager(); int32_t DoProcessAttachment(std::shared_ptr abilityRecord); - void BatchCloseUIAbility(std::unordered_set>& abilitySet); + void BatchCloseUIAbility(const std::unordered_set>& abilitySet); int StartWithPersistentIdByDistributed(const AbilityRequest &abilityRequest, int32_t persistentId); int32_t userId_ = -1; @@ -405,7 +406,7 @@ private: std::unordered_map> sessionAbilityMap_; std::unordered_map> tmpAbilityMap_; std::list> terminateAbilityList_; - sptr rootSceneSession_; + sptr rootSceneSession_; std::map, key_compare> specifiedAbilityMap_; int32_t specifiedRequestId_ = 0; std::map specifiedRequestMap_; diff --git a/services/abilitymgr/include/start_ability_utils.h b/services/abilitymgr/include/start_ability_utils.h index a94788af8c..287e54e2ba 100644 --- a/services/abilitymgr/include/start_ability_utils.h +++ b/services/abilitymgr/include/start_ability_utils.h @@ -30,6 +30,7 @@ struct StartAbilityInfo { AppExecFwk::AbilityInfo &abilityInfo); static std::shared_ptr CreateStartAbilityInfo(const Want &want, int32_t userId, int32_t appIndex); + static std::shared_ptr CreateCallerAbilityInfo(const sptr &callerToken); static std::shared_ptr CreateStartExtensionInfo(const Want &want, int32_t userId, int32_t appIndex); @@ -48,15 +49,18 @@ struct StartAbilityUtils { static int32_t GetAppIndex(const Want &want, sptr callerToken); static bool GetApplicationInfo(const std::string &bundleName, int32_t userId, AppExecFwk::ApplicationInfo &appInfo); + static bool GetCallerAbilityInfo(const sptr &callerToken, + AppExecFwk::AbilityInfo &abilityInfo); static thread_local std::shared_ptr startAbilityInfo; - + static thread_local std::shared_ptr callerAbilityInfo; static thread_local bool skipCrowTest; static thread_local bool skipStartOther; static thread_local bool skipErms; }; struct StartAbilityInfoWrap { - StartAbilityInfoWrap(const Want &want, int32_t validUserId, int32_t appIndex, bool isExtension = false); + StartAbilityInfoWrap(const Want &want, int32_t validUserId, int32_t appIndex, + const sptr &callerToken, bool isExtension = false); ~StartAbilityInfoWrap(); }; } diff --git a/services/abilitymgr/include/system_dialog_scheduler.h b/services/abilitymgr/include/system_dialog_scheduler.h index dd4acf09a0..064d3a2360 100644 --- a/services/abilitymgr/include/system_dialog_scheduler.h +++ b/services/abilitymgr/include/system_dialog_scheduler.h @@ -58,6 +58,7 @@ struct DialogAppInfo { std::string bundleName = {}; std::string abilityName = {}; std::string moduleName = {}; + bool visible = true; }; /** * @class SystemDialogScheduler diff --git a/services/abilitymgr/libabilityms.map b/services/abilitymgr/libabilityms.map index e8978d9681..ea7ce503c3 100644 --- a/services/abilitymgr/libabilityms.map +++ b/services/abilitymgr/libabilityms.map @@ -79,6 +79,7 @@ *WantReceiverProxy*; *WantSenderProxy*; *WantSenderStub*; + *DeepLinkReserveConfig*; }; local: *; diff --git a/services/abilitymgr/src/ability_connect_manager.cpp b/services/abilitymgr/src/ability_connect_manager.cpp index 50edb923bc..300766cbe6 100644 --- a/services/abilitymgr/src/ability_connect_manager.cpp +++ b/services/abilitymgr/src/ability_connect_manager.cpp @@ -563,22 +563,21 @@ int AbilityConnectManager::PreloadUIExtensionAbilityInner(const AbilityRequest & std::string &hostBundleName) { TAG_LOGD(AAFwkTag::ABILITYMGR, "call"); - //get target service ability record, and check whether it has been loaded. - std::shared_ptr targetService = AbilityRecord::CreateAbilityRecord(abilityRequest); - CHECK_POINTER_AND_RETURN(targetService, ERR_INVALID_VALUE); - if (!UIExtensionUtils::IsUIExtension(targetService->GetAbilityInfo().extensionAbilityType)) { + if (!UIExtensionUtils::IsUIExtension(abilityRequest.abilityInfo.extensionAbilityType)) { TAG_LOGE(AAFwkTag::ABILITYMGR, "Can't preload non-uiextension type."); return ERR_WRONG_INTERFACE_CALL; } std::shared_ptr extensionRecord = nullptr; CHECK_POINTER_AND_RETURN(uiExtensionAbilityRecordMgr_, ERR_NULL_OBJECT); int32_t extensionRecordId = INVALID_EXTENSION_RECORD_ID; - int32_t ret = uiExtensionAbilityRecordMgr_->CreateExtensionRecord(targetService, hostBundleName, + int32_t ret = uiExtensionAbilityRecordMgr_->CreateExtensionRecord(abilityRequest, hostBundleName, extensionRecord, extensionRecordId); if (ret != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "CreateExtensionRecord ERR."); return ret; } + CHECK_POINTER_AND_RETURN(extensionRecord, ERR_NULL_OBJECT); + std::shared_ptr targetService = extensionRecord->abilityRecord_; AppExecFwk::ElementName element(abilityRequest.abilityInfo.deviceId, abilityRequest.abilityInfo.bundleName, abilityRequest.abilityInfo.name, abilityRequest.abilityInfo.moduleName); std::string extensionRecordKey = element.GetURI() + std::to_string(targetService->GetUIExtensionAbilityId()); @@ -823,6 +822,8 @@ int AbilityConnectManager::AttachAbilityThreadLocked( sceneBoardTokenId_ = abilityRecord->GetAbilityInfo().applicationInfo.accessTokenId; } abilityRecord->SetScheduler(scheduler); + abilityRecord->RemoveSpecifiedWantParam(UIEXTENSION_ABILITY_ID); + abilityRecord->RemoveSpecifiedWantParam(UIEXTENSION_ROOT_HOST_PID); if (IsUIExtensionAbility(abilityRecord) && !abilityRecord->IsCreateByConnect() && !abilityRecord->GetWant().GetBoolParam(IS_PRELOAD_UIEXTENSION_ABILITY, false)) { DelayedSingleton::GetInstance()->MoveToForeground(token); @@ -2916,6 +2917,11 @@ void AbilityConnectManager::UpdateUIExtensionInfo(const std::shared_ptrGetPid(); wantParams.SetParam(UIEXTENSION_ROOT_HOST_PID, AAFwk::Integer::Box(rootHostPid)); } + if (abilityRecord->GetWant().GetBoolParam(IS_PRELOAD_UIEXTENSION_ABILITY, false)) { + // Applicable only to preloadUIExtension scenarios + auto rootHostPid = IPCSkeleton::GetCallingPid(); + wantParams.SetParam(UIEXTENSION_ROOT_HOST_PID, AAFwk::Integer::Box(rootHostPid)); + } abilityRecord->UpdateUIExtensionInfo(wantParams); } } // namespace AAFwk diff --git a/services/abilitymgr/src/ability_manager_client.cpp b/services/abilitymgr/src/ability_manager_client.cpp index a2e639f2f0..4901db3a80 100644 --- a/services/abilitymgr/src/ability_manager_client.cpp +++ b/services/abilitymgr/src/ability_manager_client.cpp @@ -1853,5 +1853,13 @@ int32_t AbilityManagerClient::GetAbilityStateByPersistentId(int32_t persistentId CHECK_POINTER_RETURN_INVALID_VALUE(abms); return abms->GetAbilityStateByPersistentId(persistentId, state); } + +int32_t AbilityManagerClient::TransferAbilityResultForExtension(const sptr &callerToken, + int32_t resultCode, const Want &want) +{ + auto abms = GetAbilityManager(); + CHECK_POINTER_RETURN_INVALID_VALUE(abms); + return abms->TransferAbilityResultForExtension(callerToken, resultCode, want); +} } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/src/ability_manager_proxy.cpp b/services/abilitymgr/src/ability_manager_proxy.cpp index b979718de9..8c51d6a2b8 100644 --- a/services/abilitymgr/src/ability_manager_proxy.cpp +++ b/services/abilitymgr/src/ability_manager_proxy.cpp @@ -5225,5 +5225,35 @@ int32_t AbilityManagerProxy::GetAbilityStateByPersistentId(int32_t persistentId, state = reply.ReadBool(); return NO_ERROR; } + + +int32_t AbilityManagerProxy::TransferAbilityResultForExtension(const sptr &callerToken, + int32_t resultCode, const Want &want) +{ + if (callerToken == nullptr) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "callerToken is nullptr"); + return INNER_ERR; + } + MessageParcel data; + MessageParcel reply; + MessageOption option; + if (!WriteInterfaceToken(data)) { + return IPC_PROXY_ERR; + } + if (!data.WriteRemoteObject(callerToken) || !data.WriteInt32(resultCode)) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "callerToken or resultCode write failed."); + return INNER_ERR; + } + if (!data.WriteParcelable(&want)) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "want write failed."); + return INNER_ERR; + } + auto error = SendRequest(AbilityManagerInterfaceCode::TRANSFER_ABILITY_RESULT, data, reply, option); + if (error != NO_ERROR) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "Send request error: %{public}d", error); + return error; + } + return NO_ERROR; +} } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index f5e73d3bc8..f454f2ddbf 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -112,6 +112,7 @@ #include "application_anr_listener.h" #include "input_manager.h" #include "ability_first_frame_state_observer_manager.h" +#include "window_focus_changed_listener.h" #endif #ifdef EFFICIENCY_MANAGER_ENABLE @@ -455,8 +456,6 @@ void AbilityManagerService::InitPushTask() TAG_LOGE(AAFwkTag::ABILITYMGR, "taskHandler_ is nullptr."); return; } - auto startResidentAppsTask = [aams = shared_from_this()]() { aams->StartResidentApps(); }; - taskHandler_->SubmitTask(startResidentAppsTask, "StartResidentApps"); auto initStartupFlagTask = [aams = shared_from_this()]() { aams->InitStartupFlag(); }; taskHandler_->SubmitTask(initStartupFlagTask, "InitStartupFlag"); @@ -591,7 +590,7 @@ int32_t AbilityManagerService::StartAbilityByFreeInstall(const Want &want, sptr< return ERR_INVALID_CONTINUATION_FLAG; } - TAG_LOGI(AAFwkTag::ABILITYMGR, "Start ability come, ability is %{public}s, userId is %{public}d", + TAG_LOGD(AAFwkTag::ABILITYMGR, "Start ability come, ability is %{public}s, userId is %{public}d", want.GetElement().GetAbilityName().c_str(), userId); int32_t ret = StartAbilityWrap(want, callerToken, requestCode, userId); @@ -935,7 +934,7 @@ int AbilityManagerService::StartAbilityInner(const Want &want, const sptr sessionInfo, bo auto requestCode = sessionInfo->requestCode; StartAbilityInfoWrap threadLocalInfo(sessionInfo->want, currentUserId, - StartAbilityUtils::GetAppIndex(sessionInfo->want, sessionInfo->callerToken)); + StartAbilityUtils::GetAppIndex(sessionInfo->want, sessionInfo->callerToken), sessionInfo->callerToken); if (sessionInfo->want.GetBoolParam(IS_CALL_BY_SCB, true)) { TAG_LOGD(AAFwkTag::ABILITYMGR, "interceptorExecuter_ called."); AbilityInterceptorParam interceptorParam = AbilityInterceptorParam(sessionInfo->want, requestCode, @@ -2272,7 +2271,13 @@ void AbilityManagerService::UnSubscribeBackgroundTask() void AbilityManagerService::SubscribeBundleEventCallback() { - TAG_LOGD(AAFwkTag::ABILITYMGR, "SubscribeBundleEventCallback to receive hap updates."); + TAG_LOGI(AAFwkTag::ABILITYMGR, "SubscribeBundleEventCallback begin."); + if (taskHandler_) { + TAG_LOGI(AAFwkTag::ABILITYMGR, "submit StartResidentApps task."); + auto startResidentAppsTask = [aams = shared_from_this()]() { aams->StartResidentApps(); }; + taskHandler_->SubmitTask(startResidentAppsTask, "StartResidentApps"); + } + if (abilityBundleEventCallback_) { return; } @@ -2441,6 +2446,12 @@ int AbilityManagerService::PreloadUIExtensionAbilityInner(const Want &want, std: return result; } abilityRequest.want.SetParam(IS_PRELOAD_UIEXTENSION_ABILITY, true); + auto abilityInfo = abilityRequest.abilityInfo; + auto res = JudgeAbilityVisibleControl(abilityInfo); + if (res != ERR_OK) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "Target ability is invisible"); + return res; + } auto connectManager = GetConnectManagerByUserId(validUserId); if (connectManager == nullptr) { TAG_LOGE(AAFwkTag::ABILITYMGR, "connectManager is nullptr, userId: %{public}d", validUserId); @@ -2558,7 +2569,7 @@ int AbilityManagerService::StartExtensionAbilityInner(const Want &want, const sp int32_t validUserId = GetValidUserId(userId); StartAbilityInfoWrap threadLocalInfo(want, validUserId, - StartAbilityUtils::GetAppIndex(want, callerToken), true); + StartAbilityUtils::GetAppIndex(want, callerToken), callerToken, true); AbilityInterceptorParam interceptorParam = AbilityInterceptorParam(want, 0, GetUserId(), false, nullptr); result = interceptorExecuter_ == nullptr ? ERR_INVALID_VALUE : interceptorExecuter_->DoProcess(interceptorParam); @@ -2753,6 +2764,7 @@ int AbilityManagerService::StartUIExtensionAbility(const sptr &exte } extensionSessionInfo->want.SetElementName(bundleInfo.name, bundleInfo.abilityInfos.begin()->name); } + extensionSessionInfo->want.SetParam("send_to_erms_embedded", 1); } std::string extensionTypeStr = extensionSessionInfo->want.GetStringParam(UIEXTENSION_TYPE_KEY); AppExecFwk::ExtensionAbilityType extensionType = extensionTypeStr.empty() ? @@ -3246,11 +3258,11 @@ int AbilityManagerService::CloseUIAbilityBySCB(const sptr &sessionI EventInfo eventInfo; eventInfo.bundleName = abilityRecord->GetAbilityInfo().bundleName; eventInfo.abilityName = abilityRecord->GetAbilityInfo().name; - SendAbilityEvent(EventName::CLOSE_UI_ABILITY_BY_SCB, HiSysEventType::BEHAVIOR, eventInfo); + SendAbilityEvent(EventName::CLOSE_ABILITY, HiSysEventType::BEHAVIOR, eventInfo); eventInfo.errCode = uiAbilityManager->CloseUIAbility(abilityRecord, sessionInfo->resultCode, &(sessionInfo->want), sessionInfo->isClearSession); if (eventInfo.errCode != ERR_OK) { - SendAbilityEvent(EventName::CLOSE_UI_ABILITY_BY_SCB_ERROR, HiSysEventType::FAULT, eventInfo); + SendAbilityEvent(EventName::TERMINATE_ABILITY_ERROR, HiSysEventType::FAULT, eventInfo); } return eventInfo.errCode; } @@ -4571,7 +4583,7 @@ int AbilityManagerService::MoveMissionsToBackground(const std::vector& int32_t AbilityManagerService::GetMissionIdByToken(const sptr &token) { - TAG_LOGI(AAFwkTag::ABILITYMGR, "request GetMissionIdByToken."); + TAG_LOGD(AAFwkTag::ABILITYMGR, "request GetMissionIdByToken."); auto abilityRecord = Token::GetAbilityRecordByToken(token); if (!abilityRecord) { TAG_LOGE(AAFwkTag::ABILITYMGR, "abilityRecord is null."); @@ -5420,7 +5432,7 @@ int AbilityManagerService::ScheduleDisconnectAbilityDone(const sptr &token) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); - TAG_LOGI(AAFwkTag::ABILITYMGR, "Schedule command ability done."); + TAG_LOGD(AAFwkTag::ABILITYMGR, "Schedule command ability done."); if (!VerificationAllToken(token)) { return ERR_INVALID_VALUE; } @@ -5632,7 +5644,7 @@ int AbilityManagerService::GenerateAbilityRequest( { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); auto abilityRecord = Token::GetAbilityRecordByToken(callerToken); - if (abilityRecord && abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX && + if (abilityRecord && abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX && abilityRecord->GetApplicationInfo().bundleName == want.GetElement().GetBundleName()) { (const_cast(want)).SetParam(AbilityRuntime::ServerConstant::DLP_INDEX, abilityRecord->GetAppIndex()); } @@ -5649,7 +5661,7 @@ int AbilityManagerService::GenerateAbilityRequest( auto abilityInfo = StartAbilityUtils::startAbilityInfo; if (abilityInfo == nullptr || abilityInfo->GetAppBundleName() != want.GetElement().GetBundleName()) { abilityInfo = StartAbilityInfo::CreateStartAbilityInfo(want, userId, - AbilityRuntime::StartupUtil::GetAppTwinIndex(want)); + AbilityRuntime::StartupUtil::GetAppIndex(want)); } CHECK_POINTER_AND_RETURN(abilityInfo, GET_ABILITY_SERVICE_FAILED); if (abilityInfo->status != ERR_OK) { @@ -5704,7 +5716,7 @@ int AbilityManagerService::GenerateExtensionAbilityRequest( const Want &want, AbilityRequest &request, const sptr &callerToken, int32_t userId) { auto abilityRecord = Token::GetAbilityRecordByToken(callerToken); - if (abilityRecord && abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX && + if (abilityRecord && abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX && abilityRecord->GetApplicationInfo().bundleName == want.GetElement().GetBundleName()) { (const_cast(want)).SetParam(AbilityRuntime::ServerConstant::DLP_INDEX, abilityRecord->GetAppIndex()); } @@ -5715,7 +5727,7 @@ int AbilityManagerService::GenerateExtensionAbilityRequest( auto abilityInfo = StartAbilityUtils::startAbilityInfo; if (abilityInfo == nullptr || abilityInfo->GetAppBundleName() != want.GetElement().GetBundleName()) { abilityInfo = StartAbilityInfo::CreateStartExtensionInfo(want, userId, - AbilityRuntime::StartupUtil::GetAppTwinIndex(want)); + AbilityRuntime::StartupUtil::GetAppIndex(want)); } CHECK_POINTER_AND_RETURN(abilityInfo, GET_ABILITY_SERVICE_FAILED); if (abilityInfo->status != ERR_OK) { @@ -5982,7 +5994,7 @@ int AbilityManagerService::PreLoadAppDataAbilities(const std::string &bundleName void AbilityManagerService::PreLoadAppDataAbilitiesTask(const std::string &bundleName, const int32_t userId) { - TAG_LOGI(AAFwkTag::ABILITYMGR, "called"); + TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); auto dataAbilityManager = GetDataAbilityManagerByUserId(userId); if (dataAbilityManager == nullptr) { TAG_LOGE(AAFwkTag::ABILITYMGR, "Invalid data ability manager when app data abilities preloading."); @@ -6628,7 +6640,7 @@ int AbilityManagerService::StartAbilityByCall(const Want &want, const sptr(want)); StartAbilityInfoWrap threadLocalInfo(want, GetUserId(), - StartAbilityUtils::GetAppIndex(want, callerToken)); + StartAbilityUtils::GetAppIndex(want, callerToken), callerToken); AbilityInterceptorParam interceptorParam = AbilityInterceptorParam(want, 0, GetUserId(), true, nullptr); auto result = interceptorExecuter_ == nullptr ? ERR_INVALID_VALUE : interceptorExecuter_->DoProcess(interceptorParam); @@ -8650,6 +8662,7 @@ int AbilityManagerService::CheckCallOtherExtensionPermission(const AbilityReques return ERR_OK; } if (extensionType == AppExecFwk::ExtensionAbilityType::WINDOW) { + CHECK_CALLER_IS_SYSTEM_APP; return ERR_OK; } if (extensionType == AppExecFwk::ExtensionAbilityType::ADS_SERVICE) { @@ -8805,7 +8818,11 @@ int AbilityManagerService::IsCallFromBackground(const AbilityRequest &abilityReq return ERR_OK; } auto abilityState = callerAbility->GetAbilityState(); - if (abilityState == AbilityState::BACKGROUND || abilityState == AbilityState::BACKGROUNDING) { + if (abilityState == AbilityState::BACKGROUND || abilityState == AbilityState::BACKGROUNDING || + // If uiability or uiextensionability ability state is foreground when terminate, + // it will move to background firstly. So if startAbility in onBackground() lifecycle, + // the actual ability state may be had changed to terminating from background or backgrounding. + abilityState == AbilityState::TERMINATING) { return ERR_OK; } } else { @@ -9470,11 +9487,11 @@ int32_t AbilityManagerService::CheckProcessOptions(const Want &want, const Start { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); if (startOptions.processOptions == nullptr || - !ProcessOptions::IsNewProcessMode(startOptions.processOptions->processMode)) { + !ProcessOptions::IsValidProcessMode(startOptions.processOptions->processMode)) { return ERR_OK; } - TAG_LOGD(AAFwkTag::ABILITYMGR, "start ability in new process mode."); + TAG_LOGD(AAFwkTag::ABILITYMGR, "start ability with process options."); bool isEnable = AppUtils::GetInstance().IsStartOptionsWithProcessOptions(); if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled() || !isEnable) { TAG_LOGE(AAFwkTag::ABILITYMGR, "Not support process options."); @@ -9495,9 +9512,9 @@ int32_t AbilityManagerService::CheckProcessOptions(const Want &want, const Start auto uiAbilityManager = GetUIAbilityManagerByUid(IPCSkeleton::GetCallingUid()); CHECK_POINTER_AND_RETURN(uiAbilityManager, ERR_INVALID_VALUE); - if (startOptions.processOptions->processMode == ProcessMode::NEW_PROCESS_ATTACH_TO_STATUS_BAR_ITEM && + if (ProcessOptions::IsAttachToStatusBarMode(startOptions.processOptions->processMode) && !uiAbilityManager->IsCallerInStatusBar()) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Caller is not in status bar in NEW_PROCESS_ATTACH_TO_STATUS_BAR_ITEM mode."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "Caller is not in status bar in attch to status bar mode."); return ERR_START_OPTIONS_CHECK_FAILED; } @@ -9864,7 +9881,8 @@ void AbilityManagerService::NotifyStartResidentProcess(std::vector(remoteCallback.GetRefPtr()); want.SetParam(Want::PARAM_ASSERT_FAULT_SESSION_ID, std::to_string(assertFaultSessionId)); want.SetParam(ASSERT_FAULT_DETAIL, wantParams.GetStringParam(ASSERT_FAULT_DETAIL)); - auto connection = std::make_shared(); + auto &connection = AbilityRuntime::ModalSystemAssertUIExtension::GetInstance(); want.SetParam(UIEXTENSION_MODAL_TYPE, 1); - if (connection == nullptr || !IN_PROCESS_CALL(connection->CreateModalUIExtension(want))) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Connection is nullptr or create modal ui extension failed."); + if (!IN_PROCESS_CALL(connection.CreateModalUIExtension(want))) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "Create modal ui extension failed."); return ERR_INVALID_VALUE; } auto callbackDeathMgr = DelayedSingleton::GetInstance(); @@ -10603,5 +10621,25 @@ int32_t AbilityManagerService::GetAbilityStateByPersistentId(int32_t persistentI TAG_LOGE(AAFwkTag::ABILITYMGR, "GetAbilityStateByPersistentId, mission not have persistent id."); return INNER_ERR; } + +int32_t AbilityManagerService::TransferAbilityResultForExtension(const sptr &callerToken, + int32_t resultCode, const Want &want) +{ + HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); + auto token = IPCSkeleton::GetCallingTokenID(); + auto abilityRecord = Token::GetAbilityRecordByToken(callerToken); + CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE); + auto type = abilityRecord->GetAbilityInfo().type; + if (type != AppExecFwk::AbilityType::EXTENSION) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "type is not uiextension."); + return ERR_INVALID_VALUE; + } + // save result to caller AbilityRecord. + Want* newWant = const_cast(&want); + newWant->RemoveParam(Want::PARAM_RESV_CALLER_TOKEN); + abilityRecord->SaveResultToCallers(resultCode, newWant); + abilityRecord->SendResultToCallers(); + return ERR_OK; +} } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/src/ability_manager_stub.cpp b/services/abilitymgr/src/ability_manager_stub.cpp index 61bc15eb91..fcd737c621 100644 --- a/services/abilitymgr/src/ability_manager_stub.cpp +++ b/services/abilitymgr/src/ability_manager_stub.cpp @@ -45,6 +45,7 @@ AbilityManagerStub::AbilityManagerStub() SecondStepInit(); ThirdStepInit(); FourthStepInit(); + FifthStepInit(); } AbilityManagerStub::~AbilityManagerStub() @@ -439,6 +440,12 @@ void AbilityManagerStub::FourthStepInit() &AbilityManagerStub::GetAbilityStateByPersistentIdInner; } +void AbilityManagerStub::FifthStepInit() +{ + requestFuncMap_[static_cast(AbilityManagerInterfaceCode::TRANSFER_ABILITY_RESULT)] = + &AbilityManagerStub::TransferAbilityResultForExtensionInner; +} + int AbilityManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { TAG_LOGD(AAFwkTag::ABILITYMGR, "Received code : %{public}d", code); @@ -3417,5 +3424,15 @@ int32_t AbilityManagerStub::GetAbilityStateByPersistentIdInner(MessageParcel &da } return result; } + +int32_t AbilityManagerStub::TransferAbilityResultForExtensionInner(MessageParcel &data, MessageParcel &reply) +{ + sptr callerToken = data.ReadRemoteObject(); + int32_t resultCode = data.ReadInt32(); + Want *want = data.ReadParcelable(); + int32_t result = TransferAbilityResultForExtension(callerToken, resultCode, *want); + reply.WriteInt32(result); + return NO_ERROR; +} } // namespace AAFwk } // namespace OHOS \ No newline at end of file diff --git a/services/abilitymgr/src/ability_record.cpp b/services/abilitymgr/src/ability_record.cpp index 4bbca9222a..334f75b873 100644 --- a/services/abilitymgr/src/ability_record.cpp +++ b/services/abilitymgr/src/ability_record.cpp @@ -201,9 +201,12 @@ std::shared_ptr Token::GetAbilityRecordByToken(const sptr theToken = iface_cast(token); if (!theToken) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "Input token iface_cast error."); return nullptr; } - if (theToken->GetDescriptor() != u"ohos.aafwk.AbilityToken") { + std::u16string castDescriptor = theToken->GetDescriptor(); + if (castDescriptor != u"ohos.aafwk.AbilityToken") { + TAG_LOGE(AAFwkTag::ABILITYMGR, "Input token iface_cast error:%{public}s.", Str16ToStr8(castDescriptor).c_str()); return nullptr; } @@ -252,7 +255,7 @@ std::shared_ptr AbilityRecord::CreateAbilityRecord(const AbilityR abilityRequest.want, abilityRequest.abilityInfo, abilityRequest.appInfo, abilityRequest.requestCode); CHECK_POINTER_AND_RETURN(abilityRecord, nullptr); abilityRecord->SetUid(abilityRequest.uid); - abilityRecord->SetAppIndex(AbilityRuntime::StartupUtil::GetAppTwinIndex(abilityRequest.want)); + abilityRecord->SetAppIndex(AbilityRuntime::StartupUtil::GetAppIndex(abilityRequest.want)); abilityRecord->SetCallerAccessTokenId(abilityRequest.callerAccessTokenId); abilityRecord->sessionInfo_ = abilityRequest.sessionInfo; if (!abilityRecord->Init()) { @@ -432,14 +435,6 @@ void AbilityRecord::ForegroundAbility(uint32_t sceneFlag) TAG_LOGI(AAFwkTag::ABILITYMGR, "ForegroundLifecycle: name:%{public}s.", abilityInfo_.name.c_str()); CHECK_POINTER(lifecycleDeal_); - if (!IsDebug()) { - int foregroundTimeout = - AmsConfigurationParameter::GetInstance().GetAppStartTimeoutTime() * FOREGROUND_TIMEOUT_MULTIPLE; - SendEvent(AbilityManagerService::FOREGROUND_TIMEOUT_MSG, foregroundTimeout / HALF_TIMEOUT); - std::string methodName = "ForegroundAbility"; - g_addLifecycleEventTask(token_, FreezeUtil::TimeoutState::FOREGROUND, methodName); - } - // schedule active after updating AbilityState and sending timeout message to avoid ability async callback // earlier than above actions SetAbilityStateInner(AbilityState::FOREGROUNDING); @@ -519,6 +514,9 @@ void AbilityRecord::ProcessForegroundAbility(uint32_t tokenId, uint32_t sceneFla } if (isReady_) { + if (!IsDebug()) { + PostForegroundTimeoutTask(); + } if (IsAbilityState(AbilityState::FOREGROUND)) { TAG_LOGD(AAFwkTag::ABILITYMGR, "Activate %{public}s", element.c_str()); ForegroundAbility(sceneFlag); @@ -541,6 +539,15 @@ void AbilityRecord::ProcessForegroundAbility(uint32_t tokenId, uint32_t sceneFla } } +void AbilityRecord::PostForegroundTimeoutTask() +{ + int foregroundTimeout = + AmsConfigurationParameter::GetInstance().GetAppStartTimeoutTime() * FOREGROUND_TIMEOUT_MULTIPLE; + SendEvent(AbilityManagerService::FOREGROUND_TIMEOUT_MSG, foregroundTimeout / HALF_TIMEOUT); + std::string methodName = "ForegroundAbility"; + g_addLifecycleEventTask(token_, FreezeUtil::TimeoutState::FOREGROUND, methodName); +} + std::string AbilityRecord::GetLabel() { HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); @@ -581,6 +588,9 @@ void AbilityRecord::ProcessForegroundAbility(const std::shared_ptr callerAbilityRecord = caller->GetCaller(); if (callerAbilityRecord != nullptr && callerAbilityRecord->GetResult() != nullptr) { - bool isSandboxApp = appIndex_ > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX ? true : false; + bool isSandboxApp = appIndex_ > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX ? true : false; callerAbilityRecord->SendResult(isSandboxApp, applicationInfo_.accessTokenId); } else { std::shared_ptr callerSystemAbilityRecord = caller->GetSaCaller(); @@ -1903,7 +1916,9 @@ void AbilityRecord::RemoveConnectRecordFromList(const std::shared_ptr &callerToken, int requestCode, std::string srcAbilityId, @@ -3023,7 +3038,7 @@ void AbilityRecord::GrantUriPermission(Want &want, std::string targetBundleName, // reject sandbox to grant uri permission by start ability if (!callerList_.empty() && callerList_.back()) { auto caller = callerList_.back()->GetCaller(); - if (caller && caller->appIndex_ > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + if (caller && caller->appIndex_ > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { TAG_LOGE(AAFwkTag::ABILITYMGR, "Sandbox can not grant UriPermission by start ability."); return; } @@ -3039,7 +3054,7 @@ void AbilityRecord::GrantUriPermission(Want &want, std::string targetBundleName, } if ((want.GetFlags() & (Want::FLAG_AUTH_READ_URI_PERMISSION | Want::FLAG_AUTH_WRITE_URI_PERMISSION)) == 0) { - TAG_LOGW(AAFwkTag::ABILITYMGR, "Do not call uriPermissionMgr."); + TAG_LOGD(AAFwkTag::ABILITYMGR, "Do not call uriPermissionMgr."); return; } if (IsDmsCall(want)) { @@ -3094,15 +3109,15 @@ void AbilityRecord::GrantUriPermissionInner(Want &want, std::vector bool AbilityRecord::GrantPermissionToShell(const std::vector &strUriVec, uint32_t flag, std::string targetPkg) { + TAG_LOGD(AAFwkTag::ABILITYMGR, "Grant uri permission to shell."); std::vector uriVec; for (auto&& str : strUriVec) { Uri uri(str); auto&& scheme = uri.GetScheme(); if (scheme != "content") { return false; - } else { - uriVec.emplace_back(uri); } + uriVec.emplace_back(uri); } uint32_t initiatorTokenId = IPCSkeleton::GetCallingTokenID(); diff --git a/services/abilitymgr/src/app_scheduler.cpp b/services/abilitymgr/src/app_scheduler.cpp index e2815af6f6..d7b3fb298a 100644 --- a/services/abilitymgr/src/app_scheduler.cpp +++ b/services/abilitymgr/src/app_scheduler.cpp @@ -579,12 +579,6 @@ bool AppScheduler::IsAttachDebug(const std::string &bundleName) return ERR_OK; } -void AppScheduler::SetAppAssertionPauseState(int32_t pid, bool flag) -{ - CHECK_POINTER(appMgrClient_); - appMgrClient_->SetAppAssertionPauseState(pid, flag); -} - void AppScheduler::ClearProcessByToken(sptr token) const { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); diff --git a/services/abilitymgr/src/assert_fault_callback_death_mgr.cpp b/services/abilitymgr/src/assert_fault_callback_death_mgr.cpp index 0ae3a8abc1..ef60320c6f 100644 --- a/services/abilitymgr/src/assert_fault_callback_death_mgr.cpp +++ b/services/abilitymgr/src/assert_fault_callback_death_mgr.cpp @@ -65,7 +65,6 @@ void AssertFaultCallbackDeathMgr::AddAssertFaultCallback(sptr &re TAG_LOGE(AAFwkTag::ABILITYMGR, "Get app scheduler instance is nullptr."); return; } - IN_PROCESS_CALL_WITHOUT_RET(appScheduler->SetAppAssertionPauseState(callerPid, true)); } void AssertFaultCallbackDeathMgr::RemoveAssertFaultCallback(const wptr &remote, bool isCallbackDeath) @@ -126,7 +125,6 @@ void AssertFaultCallbackDeathMgr::CallAssertFaultCallback(uint64_t assertFaultSe TAG_LOGE(AAFwkTag::ABILITYMGR, "Get app scheduler instance is nullptr."); return; } - IN_PROCESS_CALL_WITHOUT_RET(appScheduler->SetAppAssertionPauseState(item.pid_, false)); } } // namespace AbilityRuntime } // namespace OHOS diff --git a/services/abilitymgr/src/assert_fault_proxy.cpp b/services/abilitymgr/src/assert_fault_proxy.cpp index 30f0844ef3..eddf9389bd 100644 --- a/services/abilitymgr/src/assert_fault_proxy.cpp +++ b/services/abilitymgr/src/assert_fault_proxy.cpp @@ -17,6 +17,7 @@ #include "hilog_tag_wrapper.h" #include "hilog_wrapper.h" #include "scene_board_judgement.h" +#include "task_handler_wrap.h" namespace OHOS { namespace AbilityRuntime { @@ -56,6 +57,8 @@ void AssertFaultProxy::NotifyDebugAssertResult(AAFwk::UserStatus status) if (remote->SendRequest(MessageCode::NOTIFY_DEBUG_ASSERT_RESULT, data, reply, option) != NO_ERROR) { TAG_LOGE(AAFwkTag::ABILITYMGR, "Remote send request failed."); } + + ModalSystemAssertUIExtension::GetInstance().DisconnectSystemUI(); } AssertFaultRemoteDeathRecipient::AssertFaultRemoteDeathRecipient(RemoteDiedHandler handler) : handler_(handler) @@ -70,6 +73,12 @@ void AssertFaultRemoteDeathRecipient::OnRemoteDied(const wptr &re handler_(remote); } +ModalSystemAssertUIExtension &ModalSystemAssertUIExtension::GetInstance() +{ + static ModalSystemAssertUIExtension instance; + return instance; +} + ModalSystemAssertUIExtension::~ModalSystemAssertUIExtension() { dialogConnectionCallback_ = nullptr; @@ -90,22 +99,24 @@ sptr ModalSystemAssertUIEx bool ModalSystemAssertUIExtension::CreateModalUIExtension(const AAFwk::Want &want) { TAG_LOGD(AAFwkTag::ABILITYMGR, "Called."); + std::unique_lock lockAssertResult(assertResultMutex_); + if (reqeustCount_++ != 0) { + TAG_LOGD(AAFwkTag::ABILITYMGR, "Task busy, waiting for processing."); + assertResultCV_.wait(lockAssertResult); + } auto callback = GetConnection(); if (callback == nullptr) { TAG_LOGE(AAFwkTag::ABILITYMGR, "Callback is nullptr."); + TryNotifyOneWaitingThread(); return false; } - if (callback->RequestShowDialog(want)) { - TAG_LOGD(AAFwkTag::ABILITYMGR, "Start consumption want."); - return true; - } - + callback->SetReqeustAssertDialogWant(want); auto abilityManagerClient = AAFwk::AbilityManagerClient::GetInstance(); if (abilityManagerClient == nullptr) { TAG_LOGE(AAFwkTag::ABILITYMGR, "ConnectSystemUi AbilityManagerClient is nullptr"); + TryNotifyOneWaitingThread(); return false; } - AAFwk::Want systemUIWant; if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { systemUIWant.SetElementName("com.ohos.sceneboard", "com.ohos.sceneboard.systemdialog"); @@ -115,47 +126,66 @@ bool ModalSystemAssertUIExtension::CreateModalUIExtension(const AAFwk::Want &wan auto result = abilityManagerClient->ConnectAbility(systemUIWant, callback, INVALID_USERID); if (result != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "ConnectSystemUi ConnectAbility dialog failed, result = %{public}d", result); + TryNotifyOneWaitingThread(); return false; } return true; } -ModalSystemAssertUIExtension::AssertDialogConnection::~AssertDialogConnection() +bool ModalSystemAssertUIExtension::DisconnectSystemUI() { TAG_LOGD(AAFwkTag::ABILITYMGR, "Called."); - CleanUp(); + bool retVal = true; + do { + auto abilityManagerClient = AAFwk::AbilityManagerClient::GetInstance(); + if (abilityManagerClient == nullptr) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "AbilityManagerClient is nullptr"); + retVal = false; + break; + } + auto callback = GetConnection(); + if (callback == nullptr) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "Callback is nullptr."); + retVal = false; + break; + } + auto result = abilityManagerClient->DisconnectAbility(callback); + if (result != ERR_OK) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "DisconnectAbility dialog failed, result = %{public}d", result); + retVal = false; + break; + } + } while (false); + + return retVal; } -bool ModalSystemAssertUIExtension::AssertDialogConnection::RequestShowDialog(const AAFwk::Want &want) +void ModalSystemAssertUIExtension::TryNotifyOneWaitingThreadInner() { - TAG_LOGD(AAFwkTag::ABILITYMGR, "Called."); - { - std::lock_guard lock(mutex_); - consumptionList_.push(want); + std::unique_lock lockAssertResult(assertResultMutex_); + if (--reqeustCount_ > 0) { + TAG_LOGD(AAFwkTag::ABILITYMGR, "Notify waiting Thread count is %{public}d.", reqeustCount_); + assertResultCV_.notify_one(); + return; } - if (!isDialogShow_) { - TAG_LOGD(AAFwkTag::ABILITYMGR, "Connection not ready."); - return false; - } - - AppExecFwk::ElementName element; - OnAbilityConnectDone(element, remoteObject_, DEFAULT_VAL); - return true; + reqeustCount_ = 0; + TAG_LOGD(AAFwkTag::ABILITYMGR, "Counter reset to 0."); } -void ModalSystemAssertUIExtension::AssertDialogConnection::CleanUp() +void ModalSystemAssertUIExtension::TryNotifyOneWaitingThread() { - TAG_LOGD(AAFwkTag::ABILITYMGR, "Called."); - std::lock_guard lock(mutex_); - if (!consumptionList_.empty()) { - std::queue temp; - consumptionList_.swap(temp); + auto handler = AAFwk::TaskHandlerWrap::GetFfrtHandler(); + if (handler != nullptr) { + auto notifyTask = [] () { + ModalSystemAssertUIExtension::GetInstance().TryNotifyOneWaitingThreadInner(); + }; + handler->SubmitTask(notifyTask, "TryNotifyOneWaitingThread"); } - if (remoteObject_ != nullptr) { - remoteObject_->RemoveDeathRecipient(deathRecipient_); - remoteObject_ = nullptr; - } - deathRecipient_ = nullptr; +} + +void ModalSystemAssertUIExtension::AssertDialogConnection::SetReqeustAssertDialogWant(const AAFwk::Want &want) +{ + want_ = want; } void ModalSystemAssertUIExtension::AssertDialogConnection::OnAbilityConnectDone( @@ -166,39 +196,23 @@ void ModalSystemAssertUIExtension::AssertDialogConnection::OnAbilityConnectDone( TAG_LOGE(AAFwkTag::ABILITYMGR, "Input remote object is nullptr."); return; } - std::lock_guard lock(mutex_); - if (remoteObject_ == nullptr) { - remoteObject_ = remote; - wptr weakThis = iface_cast(this->AsObject()); - deathRecipient_ = - new (std::nothrow) AssertFaultRemoteDeathRecipient([weakThis] (const wptr &remote) { - auto remoteObj = weakThis.promote(); - if (remoteObj == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Invalid remote object."); - return; - } - remoteObj->CleanUp(); - }); - remoteObject_->AddDeathRecipient(deathRecipient_); - } + MessageParcel data; MessageParcel reply; MessageOption option; - auto &want = consumptionList_.front(); data.WriteInt32(MESSAGE_PARCEL_KEY_SIZE); data.WriteString16(u"bundleName"); - data.WriteString16(Str8ToStr16(want.GetElement().GetBundleName())); + data.WriteString16(Str8ToStr16(want_.GetElement().GetBundleName())); data.WriteString16(u"abilityName"); - data.WriteString16(Str8ToStr16(want.GetElement().GetAbilityName())); + data.WriteString16(Str8ToStr16(want_.GetElement().GetAbilityName())); data.WriteString16(u"parameters"); nlohmann::json param; - param[UIEXTENSION_TYPE_KEY] = want.GetStringParam(UIEXTENSION_TYPE_KEY); - param[ASSERT_FAULT_DETAIL] = want.GetStringParam(ASSERT_FAULT_DETAIL); + param[UIEXTENSION_TYPE_KEY] = want_.GetStringParam(UIEXTENSION_TYPE_KEY); + param[ASSERT_FAULT_DETAIL] = want_.GetStringParam(ASSERT_FAULT_DETAIL); param[AAFwk::Want::PARAM_ASSERT_FAULT_SESSION_ID] = - want.GetStringParam(AAFwk::Want::PARAM_ASSERT_FAULT_SESSION_ID); + want_.GetStringParam(AAFwk::Want::PARAM_ASSERT_FAULT_SESSION_ID); std::string paramStr = param.dump(); data.WriteString16(Str8ToStr16(paramStr)); - consumptionList_.pop(); uint32_t code = !Rosen::SceneBoardJudgement::IsSceneBoardEnabled() ? COMMAND_START_DIALOG : AAFwk::IAbilityConnection::ON_ABILITY_CONNECT_DONE; auto ret = remote->SendRequest(code, data, reply, option); @@ -206,14 +220,13 @@ void ModalSystemAssertUIExtension::AssertDialogConnection::OnAbilityConnectDone( TAG_LOGE(AAFwkTag::ABILITYMGR, "Show dialog is failed"); return; } - isDialogShow_ = true; } void ModalSystemAssertUIExtension::AssertDialogConnection::OnAbilityDisconnectDone( const AppExecFwk::ElementName &element, int resultCode) { TAG_LOGD(AAFwkTag::ABILITYMGR, "Called."); - CleanUp(); + ModalSystemAssertUIExtension::GetInstance().TryNotifyOneWaitingThread(); } } // namespace AbilityRuntime } // namespace OHOS \ No newline at end of file diff --git a/services/abilitymgr/src/connection_state_manager.cpp b/services/abilitymgr/src/connection_state_manager.cpp index 129129054d..7489c2d1fb 100644 --- a/services/abilitymgr/src/connection_state_manager.cpp +++ b/services/abilitymgr/src/connection_state_manager.cpp @@ -487,7 +487,7 @@ bool ConnectionStateManager::HandleDlpAbilityInner(const std::shared_ptrGetAppIndex() <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + if (dlpAbility->GetAppIndex() <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { TAG_LOGD(AAFwkTag::CONNECTION, "this is not dlp ability, do not report connection stat."); return false; } diff --git a/services/abilitymgr/src/deeplink_reserve/deeplink_reserve_config.cpp b/services/abilitymgr/src/deeplink_reserve/deeplink_reserve_config.cpp index fd4f1987a4..b89cfe266b 100644 --- a/services/abilitymgr/src/deeplink_reserve/deeplink_reserve_config.cpp +++ b/services/abilitymgr/src/deeplink_reserve/deeplink_reserve_config.cpp @@ -257,6 +257,11 @@ bool DeepLinkReserveConfig::ReadFileInfoJson(const std::string &filePath, nlohma return false; } + if (filePath.empty()) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "File path is empty."); + return false; + } + std::fstream in; char errBuf[256]; errBuf[0] = '\0'; diff --git a/services/abilitymgr/src/dialog_session_info.cpp b/services/abilitymgr/src/dialog_session_info.cpp index ca9efcd4af..fa46604fb7 100644 --- a/services/abilitymgr/src/dialog_session_info.cpp +++ b/services/abilitymgr/src/dialog_session_info.cpp @@ -25,13 +25,14 @@ namespace OHOS { namespace AAFwk { constexpr int32_t CYCLE_LIMIT = 1000; -constexpr size_t MEMBER_NUM = 7; +constexpr size_t MEMBER_NUM = 8; std::string DialogAbilityInfo::GetURI() const { return bundleName + "/" + moduleName + "/" + abilityName + "/" + std::to_string(bundleIconId) + "/" + std::to_string(bundleLabelId) + "/" + - std::to_string(abilityIconId) + "/" + std::to_string(abilityLabelId); + std::to_string(abilityIconId) + "/" + std::to_string(abilityLabelId) + "/" + + std::to_string(visible); } bool DialogAbilityInfo::ParseURI(const std::string &uri) @@ -53,6 +54,7 @@ bool DialogAbilityInfo::ParseURI(const std::string &uri) bundleLabelId = static_cast(std::stoi(uriVec[index++])); abilityIconId = static_cast(std::stoi(uriVec[index++])); abilityLabelId = static_cast(std::stoi(uriVec[index++])); + visible = std::stoi(uriVec[index++]); return true; } diff --git a/services/abilitymgr/src/dialog_session_record.cpp b/services/abilitymgr/src/dialog_session_record.cpp index 54413eecc9..591805f41d 100644 --- a/services/abilitymgr/src/dialog_session_record.cpp +++ b/services/abilitymgr/src/dialog_session_record.cpp @@ -131,6 +131,7 @@ bool DialogSessionRecord::GenerateDialogSessionRecord(AbilityRequest &abilityReq targetDialogAbilityInfo.abilityLabelId = dialogAppInfo.abilityLabelId; targetDialogAbilityInfo.bundleIconId = dialogAppInfo.bundleIconId; targetDialogAbilityInfo.bundleLabelId = dialogAppInfo.bundleLabelId; + targetDialogAbilityInfo.visible = dialogAppInfo.visible; dialogSessionInfo->targetAbilityInfos.emplace_back(targetDialogAbilityInfo); } std::shared_ptr dialogCallerInfo = std::make_shared(); diff --git a/services/abilitymgr/src/dlp_state_item.cpp b/services/abilitymgr/src/dlp_state_item.cpp index 68c12cb8bb..2d6e9860aa 100644 --- a/services/abilitymgr/src/dlp_state_item.cpp +++ b/services/abilitymgr/src/dlp_state_item.cpp @@ -54,7 +54,7 @@ int32_t DlpStateItem::GetOpenedAbilitySize() const bool DlpStateItem::HandleDlpConnectionState(const std::shared_ptr &record, bool isAdd, AbilityRuntime::DlpStateData &data) { - if (!record || record->GetAppIndex() <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + if (!record || record->GetAppIndex() <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { TAG_LOGW(AAFwkTag::ABILITYMGR, "invalid dlp ability."); return false; } diff --git a/services/abilitymgr/src/ecological_rule/ability_ecological_rule_mgr_service_param.cpp b/services/abilitymgr/src/ecological_rule/ability_ecological_rule_mgr_service_param.cpp index 60b12c2e91..704a24832a 100644 --- a/services/abilitymgr/src/ecological_rule/ability_ecological_rule_mgr_service_param.cpp +++ b/services/abilitymgr/src/ecological_rule/ability_ecological_rule_mgr_service_param.cpp @@ -125,15 +125,12 @@ AbilityCallerInfo *AbilityCallerInfo::Unmarshalling(Parcel &in) return nullptr; } - if (!in.ReadInt32(info->callerAbilityType)) { - TAG_LOGE(AAFwkTag::ECOLOGICAL_RULE, "read callerAbilityType failed"); - delete info; - return nullptr; - } + info->callerAbilityType = static_cast(in.ReadInt32()); info->embedded = in.ReadInt32(); info->callerAppProvisionType = in.ReadString(); info->targetAppProvisionType = in.ReadString(); + info->callerExtensionAbilityType = static_cast(in.ReadInt32()); return info; } @@ -157,6 +154,11 @@ bool AbilityCallerInfo::Marshalling(Parcel &parcel) const TAG_LOGE(AAFwkTag::ECOLOGICAL_RULE, "write targetAppProvisionType failed"); return false; } + + if (!parcel.WriteInt32(static_cast(callerExtensionAbilityType))) { + TAG_LOGE(AAFwkTag::ECOLOGICAL_RULE, "write callerExtensionAbilityType failed"); + return false; + } return true; } @@ -207,10 +209,11 @@ bool AbilityCallerInfo::DoMarshallingOne(Parcel &parcel) const return false; } - if (!parcel.WriteInt32(callerAbilityType)) { + if (!parcel.WriteInt32(static_cast(callerAbilityType))) { TAG_LOGE(AAFwkTag::ECOLOGICAL_RULE, "write callerAbilityType failed"); return false; } + return true; } @@ -220,7 +223,9 @@ std::string AbilityCallerInfo::ToString() const ",pid:" + std::to_string(pid) + ",callerAppType:" + std::to_string(callerAppType) + ",targetAppType:" + std::to_string(targetAppType) + ",callerModelType:" + std::to_string(callerModelType) + ",targetAppDistType:" + targetAppDistType + ",targetLinkFeature:" + targetLinkFeature + ",targetLinkType:" + - std::to_string(targetLinkType) + ",callerAbilityType:" + std::to_string(callerAbilityType) + ",embedded:" + + std::to_string(targetLinkType) + ",callerAbilityType:" + + std::to_string(static_cast(callerAbilityType)) + ",callerExtensionAbilityType:" + + std::to_string(static_cast(callerExtensionAbilityType)) + ",embedded:" + std::to_string(embedded) + ",callerAppProvisionType:" + callerAppProvisionType + ",targetAppProvisionType:" + targetAppProvisionType + "}"; return str; diff --git a/services/abilitymgr/src/extension_record_factory.cpp b/services/abilitymgr/src/extension_record_factory.cpp index a49c072de7..5f294541e2 100644 --- a/services/abilitymgr/src/extension_record_factory.cpp +++ b/services/abilitymgr/src/extension_record_factory.cpp @@ -118,7 +118,7 @@ uint32_t ExtensionRecordFactory::GetExtensionProcessMode( int32_t ExtensionRecordFactory::CreateRecord( const AAFwk::AbilityRequest &abilityRequest, std::shared_ptr &extensionRecord) { - std::shared_ptr abilityRecord = AAFwk::AbilityRecord::CreateAbilityRecord(abilityRequest); + auto abilityRecord = AAFwk::AbilityRecord::CreateAbilityRecord(abilityRequest); if (abilityRecord == nullptr) { TAG_LOGE(AAFwkTag::ABILITYMGR, "Failed to create ability record"); return ERR_NULL_OBJECT; diff --git a/services/abilitymgr/src/extension_record_manager.cpp b/services/abilitymgr/src/extension_record_manager.cpp index 5a56591c8e..1fc2c264c7 100644 --- a/services/abilitymgr/src/extension_record_manager.cpp +++ b/services/abilitymgr/src/extension_record_manager.cpp @@ -26,6 +26,7 @@ namespace OHOS { namespace AbilityRuntime { namespace { constexpr const char *SEPARATOR = ":"; +const std::string IS_PRELOAD_UIEXTENSION_ABILITY = "ability.want.params.is_preload_uiextension_ability"; } std::atomic_int32_t ExtensionRecordManager::extensionRecordId_ = INVALID_EXTENSION_RECORD_ID; @@ -215,7 +216,7 @@ bool ExtensionRecordManager::IsHostSpecifiedProcessValid(const AAFwk::AbilityReq std::shared_ptr &record, const std::string &process) { std::lock_guard lock(mutex_); - for (auto &iter: extensionRecords_) { + for (const auto &iter: extensionRecords_) { if (iter.second == nullptr || iter.second->abilityRecord_ == nullptr) { continue; } @@ -391,7 +392,8 @@ int32_t ExtensionRecordManager::GetOrCreateExtensionRecordInner(const AAFwk::Abi std::shared_ptr abilityRecord = extensionRecord->abilityRecord_; CHECK_POINTER_AND_RETURN(abilityRecord, ERR_NULL_OBJECT); isLoaded = false; - extensionRecordId = GenerateExtensionRecordId(extensionRecordId); + // Reuse id or not has been checked, so alloc a new id here. + extensionRecordId = GenerateExtensionRecordId(INVALID_EXTENSION_RECORD_ID); extensionRecord->extensionRecordId_ = extensionRecordId; extensionRecord->hostBundleName_ = hostBundleName; abilityRecord->SetOwnerMissionUserId(userId_); @@ -448,6 +450,11 @@ sptr ExtensionRecordManager::GetRootCallerTokenLocked(int32_t ext it->second->SetRootCallerToken(callerToken); return callerToken; } + // If caller extension record id is same with current, need terminate, prevent possible stack-overflow. + if (callerAbilityRecord->GetUIExtensionAbilityId() == extensionRecordId) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "Invalid id: %{public}d, same with caller.", extensionRecordId); + return nullptr; + } rootCallerToken = GetRootCallerTokenLocked(callerAbilityRecord->GetUIExtensionAbilityId()); TAG_LOGD(AAFwkTag::ABILITYMGR, "update rootCallerToken, id: %{public}d.", extensionRecordId); it->second->SetRootCallerToken(rootCallerToken); @@ -457,32 +464,50 @@ sptr ExtensionRecordManager::GetRootCallerTokenLocked(int32_t ext return nullptr; } -int32_t ExtensionRecordManager::CreateExtensionRecord(const std::shared_ptr &abilityRecord, +int32_t ExtensionRecordManager::CreateExtensionRecord(const AAFwk::AbilityRequest &abilityRequest, const std::string &hostBundleName, std::shared_ptr &extensionRecord, int32_t &extensionRecordId) { - // factory pattern with ability request - if (abilityRecord == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "abilityRecord is null"); - return ERR_NULL_OBJECT; + TAG_LOGD(AAFwkTag::ABILITYMGR, "call"); + std::shared_ptr factory = nullptr; + if (AAFwk::UIExtensionUtils::IsUIExtension(abilityRequest.abilityInfo.extensionAbilityType)) { + factory = DelayedSingleton::GetInstance(); } + if (factory == nullptr) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "Invalid extensionAbilityType"); + return ERR_INVALID_VALUE; + } + int32_t result = factory->CreateRecord(abilityRequest, extensionRecord); + if (result != ERR_OK) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "createRecord error"); + return result; + } + CHECK_POINTER_AND_RETURN(extensionRecord, ERR_NULL_OBJECT); + std::shared_ptr abilityRecord = extensionRecord->abilityRecord_; + CHECK_POINTER_AND_RETURN(abilityRecord, ERR_NULL_OBJECT); extensionRecordId = GenerateExtensionRecordId(extensionRecordId); - if (AAFwk::UIExtensionUtils::IsUIExtension(abilityRecord->GetAbilityInfo().extensionAbilityType)) { - extensionRecord = std::make_shared(abilityRecord); - extensionRecord->hostBundleName_ = hostBundleName; - extensionRecord->extensionRecordId_ = extensionRecordId; - std::lock_guard lock(mutex_); - TAG_LOGD(AAFwkTag::ABILITYMGR, "add UIExtension, id %{public}d.", extensionRecordId); - extensionRecords_[extensionRecordId] = extensionRecord; - abilityRecord->SetUIExtensionAbilityId(extensionRecordId); - //add uiextension record register state observer object. + extensionRecord->extensionRecordId_ = extensionRecordId; + extensionRecord->hostBundleName_ = hostBundleName; + abilityRecord->SetOwnerMissionUserId(userId_); + abilityRecord->SetUIExtensionAbilityId(extensionRecordId); + //add uiextension record register state observer object. + if (abilityRecord->GetWant().GetBoolParam(IS_PRELOAD_UIEXTENSION_ABILITY, false)) { auto ret = extensionRecord->RegisterStateObserver(hostBundleName); if (ret != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "Register extensionRecord state observer failed, err: %{public}d.", ret); return ERR_INVALID_VALUE; } - return ERR_OK; } - return ERR_INVALID_VALUE; + result = UpdateProcessName(abilityRequest, extensionRecord); + if (result != ERR_OK) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "update processname error!"); + return result; + } + TAG_LOGI(AAFwkTag::ABILITYMGR, + "extensionRecordId: %{public}d, extensionProcessMode:%{public}d, process: %{public}s", + extensionRecordId, abilityRequest.extensionProcessMode, abilityRecord->GetAbilityInfo().process.c_str()); + std::lock_guard lock(mutex_); + extensionRecords_[extensionRecordId] = extensionRecord; + return ERR_OK; } std::shared_ptr ExtensionRecordManager::GetUIExtensionRootHostInfo( diff --git a/services/abilitymgr/src/implicit_start_processor.cpp b/services/abilitymgr/src/implicit_start_processor.cpp index 2802c624c6..eefc114f4d 100644 --- a/services/abilitymgr/src/implicit_start_processor.cpp +++ b/services/abilitymgr/src/implicit_start_processor.cpp @@ -359,7 +359,7 @@ int ImplicitStartProcessor::GenerateAbilityRequestByAction(int32_t userId, } if (uriReservedFlag_) { - abilityInfoFlag = abilityInfoFlag | + abilityInfoFlag = static_cast(abilityInfoFlag) | static_cast(AppExecFwk::GetAbilityInfoFlag::GET_ABILITY_INFO_ONLY_SYSTEM_APP); } @@ -452,6 +452,7 @@ int ImplicitStartProcessor::GenerateAbilityRequestByAction(int32_t userId, dialogAppInfo.abilityLabelId = info.labelId; dialogAppInfo.bundleIconId = info.applicationInfo.iconId; dialogAppInfo.bundleLabelId = info.applicationInfo.labelId; + dialogAppInfo.visible = info.visible; dialogAppInfos.emplace_back(dialogAppInfo); } @@ -725,6 +726,7 @@ void ImplicitStartProcessor::AddAbilityInfoToDialogInfos(const AddInfoParam &par dialogAppInfo.abilityLabelId = param.info.labelId; dialogAppInfo.bundleIconId = param.info.applicationInfo.iconId; dialogAppInfo.bundleLabelId = param.info.applicationInfo.labelId; + dialogAppInfo.visible = param.info.visible; dialogAppInfos.emplace_back(dialogAppInfo); } diff --git a/services/abilitymgr/src/interceptor/ecological_rule_interceptor.cpp b/services/abilitymgr/src/interceptor/ecological_rule_interceptor.cpp index 0960147d84..10b9bd0271 100644 --- a/services/abilitymgr/src/interceptor/ecological_rule_interceptor.cpp +++ b/services/abilitymgr/src/interceptor/ecological_rule_interceptor.cpp @@ -54,7 +54,7 @@ ErrCode EcologicalRuleInterceptor::DoProcess(AbilityInterceptorParam param) } AAFwk::Want newWant = param.want; newWant.RemoveAllFd(); - GetEcologicalCallerInfo(newWant, callerInfo, param.userId); + GetEcologicalCallerInfo(newWant, callerInfo, param.userId, param.callerToken); std::string supportErms = OHOS::system::GetParameter(ABILITY_SUPPORT_ECOLOGICAL_RULEMGRSERVICE, "true"); if (supportErms == "false") { TAG_LOGE(AAFwkTag::ECOLOGICAL_RULE, "Abilityms not support Erms between applications."); @@ -128,30 +128,39 @@ bool EcologicalRuleInterceptor::DoProcess(Want &want, int32_t userId) return rule.isAllow; } -void EcologicalRuleInterceptor::GetEcologicalCallerInfo(const Want &want, ErmsCallerInfo &callerInfo, int32_t userId) +void EcologicalRuleInterceptor::GetEcologicalCallerInfo(const Want &want, ErmsCallerInfo &callerInfo, int32_t userId, + const sptr &callerToken) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); InitErmsCallerInfo(const_cast(want), callerInfo); - auto bundleMgrHelper = AbilityUtil::GetBundleManagerHelper(); - if (bundleMgrHelper == nullptr) { - TAG_LOGE(AAFwkTag::ECOLOGICAL_RULE, "The bundleMgrHelper is nullptr."); - return; - } - - std::string callerBundleName; - ErrCode err = IN_PROCESS_CALL(bundleMgrHelper->GetNameForUid(callerInfo.uid, callerBundleName)); - if (err != ERR_OK) { - TAG_LOGE(AAFwkTag::ECOLOGICAL_RULE, "Get callerBundleName failed,uid: %{public}d.", callerInfo.uid); - return; - } AppExecFwk::ApplicationInfo callerAppInfo; - bool getCallerResult = IN_PROCESS_CALL(bundleMgrHelper->GetApplicationInfo(callerBundleName, - AppExecFwk::ApplicationFlag::GET_BASIC_APPLICATION_INFO, userId, callerAppInfo)); - if (!getCallerResult) { - TAG_LOGD(AAFwkTag::ECOLOGICAL_RULE, "Get callerAppInfo failed."); - return; + AppExecFwk::AbilityInfo callerAbilityInfo; + if (StartAbilityUtils::GetCallerAbilityInfo(callerToken, callerAbilityInfo)) { + callerAppInfo = callerAbilityInfo.applicationInfo; + callerInfo.callerAbilityType = callerAbilityInfo.type; + callerInfo.callerExtensionAbilityType = callerAbilityInfo.extensionAbilityType; + } else { + auto bundleMgrHelper = AbilityUtil::GetBundleManagerHelper(); + if (bundleMgrHelper == nullptr) { + TAG_LOGE(AAFwkTag::ECOLOGICAL_RULE, "The bundleMgrHelper is nullptr."); + return; + } + + std::string callerBundleName; + ErrCode err = IN_PROCESS_CALL(bundleMgrHelper->GetNameForUid(callerInfo.uid, callerBundleName)); + if (err != ERR_OK) { + TAG_LOGE(AAFwkTag::ECOLOGICAL_RULE, "Get callerBundleName failed,uid: %{public}d.", callerInfo.uid); + return; + } + bool getCallerResult = IN_PROCESS_CALL(bundleMgrHelper->GetApplicationInfo(callerBundleName, + AppExecFwk::ApplicationFlag::GET_BASIC_APPLICATION_INFO, userId, callerAppInfo)); + if (!getCallerResult) { + TAG_LOGD(AAFwkTag::ECOLOGICAL_RULE, "Get callerAppInfo failed."); + return; + } } + callerInfo.callerAppProvisionType = callerAppInfo.appProvisionType; if (callerAppInfo.bundleType == AppExecFwk::BundleType::ATOMIC_SERVICE) { TAG_LOGD(AAFwkTag::ECOLOGICAL_RULE, "the caller type is atomic service"); diff --git a/services/abilitymgr/src/mission_list_manager.cpp b/services/abilitymgr/src/mission_list_manager.cpp index 2e92c792e5..cd49219da0 100644 --- a/services/abilitymgr/src/mission_list_manager.cpp +++ b/services/abilitymgr/src/mission_list_manager.cpp @@ -47,28 +47,28 @@ namespace { constexpr uint32_t DELAY_NOTIFY_LABEL_TIME = 30; // 30ms constexpr uint32_t SCENE_FLAG_KEYGUARD = 1; constexpr uint32_t ONLY_ONE_ABILITY = 1; -constexpr char EVENT_KEY_UID[] = "UID"; -constexpr char EVENT_KEY_PID[] = "PID"; -constexpr char EVENT_KEY_MESSAGE[] = "MSG"; -constexpr char EVENT_KEY_PACKAGE_NAME[] = "PACKAGE_NAME"; -constexpr char EVENT_KEY_PROCESS_NAME[] = "PROCESS_NAME"; +constexpr const char* EVENT_KEY_UID = "UID"; +constexpr const char* EVENT_KEY_PID = "PID"; +constexpr const char* EVENT_KEY_MESSAGE = "MSG"; +constexpr const char* EVENT_KEY_PACKAGE_NAME = "PACKAGE_NAME"; +constexpr const char* EVENT_KEY_PROCESS_NAME = "PROCESS_NAME"; constexpr int32_t SINGLE_MAX_INSTANCE_COUNT = 128; constexpr int32_t MAX_INSTANCE_COUNT = 512; constexpr uint64_t NANO_SECOND_PER_SEC = 1000000000; // ns const std::string DMS_SRC_NETWORK_ID = "dmsSrcNetworkId"; const std::string DMS_MISSION_ID = "dmsMissionId"; -const int DEFAULT_DMS_MISSION_ID = -1; +constexpr int DEFAULT_DMS_MISSION_ID = -1; #ifdef SUPPORT_ASAN -const int KILL_TIMEOUT_MULTIPLE = 45; +constexpr int KILL_TIMEOUT_MULTIPLE = 45; #else -const int KILL_TIMEOUT_MULTIPLE = 3; +constexpr int KILL_TIMEOUT_MULTIPLE = 3; #endif constexpr int32_t PREPARE_TERMINATE_ENABLE_SIZE = 6; -const char* PREPARE_TERMINATE_ENABLE_PARAMETER = "persist.sys.prepare_terminate"; -const int32_t PREPARE_TERMINATE_TIMEOUT_MULTIPLE = 10; +constexpr const char* PREPARE_TERMINATE_ENABLE_PARAMETER = "persist.sys.prepare_terminate"; +constexpr int32_t PREPARE_TERMINATE_TIMEOUT_MULTIPLE = 10; constexpr int32_t TRACE_ATOMIC_SERVICE_ID = 201; const std::string TRACE_ATOMIC_SERVICE = "StartAtomicService"; -const int GET_TARGET_MISSION_OVER = 200; +constexpr int GET_TARGET_MISSION_OVER = 200; std::string GetCurrentTime() { struct timespec tn; @@ -77,11 +77,18 @@ std::string GetCurrentTime() static_cast(tn.tv_nsec); return std::to_string(uTime); } -const std::unordered_map stateMap = { - { AbilityManagerService::LOAD_TIMEOUT_MSG, FreezeUtil::TimeoutState::LOAD }, - { AbilityManagerService::FOREGROUND_TIMEOUT_MSG, FreezeUtil::TimeoutState::FOREGROUND }, - { AbilityManagerService::BACKGROUND_TIMEOUT_MSG, FreezeUtil::TimeoutState::BACKGROUND } -}; + +FreezeUtil::TimeoutState MsgId2State(uint32_t msgId) +{ + if (msgId == AbilityManagerService::LOAD_TIMEOUT_MSG) { + return FreezeUtil::TimeoutState::LOAD; + } else if (msgId == AbilityManagerService::FOREGROUND_TIMEOUT_MSG) { + return FreezeUtil::TimeoutState::FOREGROUND; + } else if (msgId == AbilityManagerService::BACKGROUND_TIMEOUT_MSG) { + return FreezeUtil::TimeoutState::BACKGROUND; + } + return FreezeUtil::TimeoutState::UNKNOWN; +} auto g_deleteLifecycleEventTask = [](const sptr &token, FreezeUtil::TimeoutState state) { CHECK_POINTER_LOG(token, "token is nullptr."); @@ -425,7 +432,7 @@ int MissionListManager::StartAbilityLocked(const std::shared_ptr if (ret != GET_TARGET_MISSION_OVER) { return ret; } - + // 3. move mission to target list bool isCallerFromLauncher = (callerAbility && callerAbility->IsLauncherAbility()); MoveMissionToTargetList(isCallerFromLauncher, targetList, targetMission); @@ -546,7 +553,7 @@ bool MissionListManager::HandleReusedMissionAndAbility(const AbilityRequest &abi std::string MissionListManager::GetMissionName(const AbilityRequest &abilityRequest) const { - int32_t appIndex = AbilityRuntime::StartupUtil::GetAppTwinIndex(abilityRequest.want); + int32_t appIndex = AbilityRuntime::StartupUtil::GetAppIndex(abilityRequest.want); return AbilityUtil::ConvertBundleNameSingleton(abilityRequest.abilityInfo.bundleName, abilityRequest.abilityInfo.name, abilityRequest.abilityInfo.moduleName, appIndex); } @@ -676,7 +683,7 @@ void MissionListManager::BuildInnerMissionInfo(InnerMissionInfo &info, const std info.missionInfo.unclearable = abilityRequest.abilityInfo.unclearableMission; info.isTemporary = abilityRequest.abilityInfo.removeMissionAfterTerminate; auto dlpIndex = abilityRequest.want.GetIntParam(AbilityRuntime::ServerConstant::DLP_INDEX, 0); - if (dlpIndex > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + if (dlpIndex > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { info.isTemporary = true; } info.specifiedFlag = abilityRequest.specifiedFlag; @@ -855,7 +862,7 @@ std::shared_ptr MissionListManager::GetReusedStandardMission(const Abil if (!missionList) { continue; } - + auto mission = missionList->GetRecentStandardMission(missionName); if (mission && mission->GetMissionTime() >= missionTime) { missionTime = mission->GetMissionTime(); @@ -1788,7 +1795,7 @@ void MissionListManager::CompleteTerminateAndUpdateMission(const std::shared_ptr terminateAbilityList_.remove(it); // update inner mission info time bool excludeFromMissions = abilityRecord->GetAbilityInfo().excludeFromMissions; - if ((abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) || + if ((abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) || abilityRecord->GetAbilityInfo().removeMissionAfterTerminate || excludeFromMissions) { RemoveMissionLocked(abilityRecord->GetMissionId(), excludeFromMissions); return; @@ -2010,7 +2017,7 @@ void MissionListManager::UpdateSnapShot(const sptr &token, return; } int32_t missionId = abilityRecord->GetMissionId(); - auto isPrivate = abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX; + auto isPrivate = abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX; DelayedSingleton::GetInstance()->UpdateMissionSnapshot(missionId, pixelMap, isPrivate); if (listenerController_) { listenerController_->NotifyMissionSnapshotChanged(missionId); @@ -2093,11 +2100,7 @@ void MissionListManager::PrintTimeOutLog(const std::shared_ptr &a } int typeId = AppExecFwk::AppfreezeManager::TypeAttribute::NORMAL_TIMEOUT; std::string msgContent = "ability:" + ability->GetAbilityInfo().name + " "; - FreezeUtil::TimeoutState state = FreezeUtil::TimeoutState::UNKNOWN; - auto search = stateMap.find(msgId); - if (search != stateMap.end()) { - state = search->second; - } + FreezeUtil::TimeoutState state = MsgId2State(msgId); if (!GetContentAndTypeId(msgId, msgContent, typeId)) { TAG_LOGW(AAFwkTag::ABILITYMGR, "msgId is invalid!"); return; @@ -2172,7 +2175,7 @@ void MissionListManager::UpdateMissionSnapshot(const std::shared_ptrGetMissionId(); MissionSnapshot snapshot; - snapshot.isPrivate = (abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX); + snapshot.isPrivate = (abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX); DelayedSingleton::GetInstance()->UpdateMissionSnapshot(missionId, abilityRecord->GetToken(), snapshot); if (listenerController_) { @@ -2697,7 +2700,7 @@ void MissionListManager::HandleAbilityDiedByDefault(std::shared_ptrGetMissionId(); if (!ability->IsUninstallAbility()) { - if ((ability->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) || + if ((ability->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) || ability->GetAbilityInfo().removeMissionAfterTerminate || ability->GetAbilityInfo().excludeFromMissions) { RemoveMissionLocked(missionId, ability->GetAbilityInfo().excludeFromMissions); } else { @@ -3335,7 +3338,7 @@ std::shared_ptr MissionListManager::GetAbilityRecordByNameFromCur return defaultStandardAbility; } } - + // find in launcherList_ if (launcherList_ != nullptr) { return launcherList_->GetAbilityRecordByName(element); @@ -3587,13 +3590,6 @@ bool MissionListManager::IsReachToSingleLimitLocked(const int32_t uid) const return false; } -bool MissionListManager::MissionDmInitCallback::isInit_ = false; -void MissionListManager::MissionDmInitCallback::OnRemoteDied() -{ - isInit_ = false; - TAG_LOGW(AAFwkTag::ABILITYMGR, "DeviceManager died."); -} - void MissionListManager::RegisterSnapshotHandler(const sptr& handler) { DelayedSingleton::GetInstance()->RegisterSnapshotHandler(handler); @@ -3611,7 +3607,7 @@ bool MissionListManager::GetMissionSnapshot(int32_t missionId, const sptrIsAbilityState(FOREGROUND)) { forceSnapshot = true; missionSnapshot.isPrivate = - (abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX); + (abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX); } } return DelayedSingleton::GetInstance()->GetMissionSnapshot( diff --git a/services/abilitymgr/src/pending_want_manager.cpp b/services/abilitymgr/src/pending_want_manager.cpp index fe523db4de..e7321e3519 100644 --- a/services/abilitymgr/src/pending_want_manager.cpp +++ b/services/abilitymgr/src/pending_want_manager.cpp @@ -41,7 +41,7 @@ PendingWantManager::PendingWantManager() PendingWantManager::~PendingWantManager() { - TAG_LOGD(AAFwkTag::WANTAGENT, "%{public}s(%{public}d)", __PRETTY_FUNCTION__, __LINE__); + TAG_LOGI(AAFwkTag::WANTAGENT, "%{public}s(%{public}d)", __PRETTY_FUNCTION__, __LINE__); } sptr PendingWantManager::GetWantSender(int32_t callingUid, int32_t uid, const bool isSystemApp, @@ -134,8 +134,8 @@ sptr PendingWantManager::GetPendingWantRecordByKey(const std: { TAG_LOGD(AAFwkTag::WANTAGENT, "begin"); for (const auto &item : wantRecords_) { - const auto &pendingKey = item.first; - const auto &pendingRecord = item.second; + const auto pendingKey = item.first; + const auto pendingRecord = item.second; if ((pendingRecord != nullptr) && CheckPendingWantRecordByKey(pendingKey, key)) { return pendingRecord; } @@ -146,6 +146,10 @@ sptr PendingWantManager::GetPendingWantRecordByKey(const std: bool PendingWantManager::CheckPendingWantRecordByKey( const std::shared_ptr &inputKey, const std::shared_ptr &key) { + if (!inputKey || !key) { + TAG_LOGW(AAFwkTag::WANTAGENT, "inputKey or key is nullptr!"); + return false; + } if (inputKey->GetBundleName().compare(key->GetBundleName()) != 0) { return false; } @@ -349,7 +353,6 @@ int32_t PendingWantManager::PendingRecordIdCreate() sptr PendingWantManager::GetPendingWantRecordByCode(int32_t code) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); - TAG_LOGD(AAFwkTag::WANTAGENT, "begin. wantRecords_ size = %{public}zu", wantRecords_.size()); std::lock_guard locker(mutex_); auto iter = std::find_if(wantRecords_.begin(), wantRecords_.end(), [&code](const auto &pair) { @@ -615,6 +618,7 @@ void PendingWantManager::ClearPendingWantRecordTask(const std::string &bundleNam void PendingWantManager::Dump(std::vector &info) { + TAG_LOGD(AAFwkTag::WANTAGENT, "dump begin."); std::string dumpInfo = " PendingWantRecords:"; info.push_back(dumpInfo); @@ -646,6 +650,7 @@ void PendingWantManager::Dump(std::vector &info) } void PendingWantManager::DumpByRecordId(std::vector &info, const std::string &args) { + TAG_LOGD(AAFwkTag::WANTAGENT, "dump by id begin."); std::string dumpInfo = " PendingWantRecords:"; info.push_back(dumpInfo); diff --git a/services/abilitymgr/src/process_options.cpp b/services/abilitymgr/src/process_options.cpp index f0abe807c0..47163efec5 100644 --- a/services/abilitymgr/src/process_options.cpp +++ b/services/abilitymgr/src/process_options.cpp @@ -24,6 +24,7 @@ bool ProcessOptions::ReadFromParcel(Parcel &parcel) { processMode = static_cast(parcel.ReadInt32()); startupVisibility = static_cast(parcel.ReadInt32()); + processName = parcel.ReadString(); return true; } @@ -52,6 +53,10 @@ bool ProcessOptions::Marshalling(Parcel &parcel) const TAG_LOGE(AAFwkTag::ABILITYMGR, "Failed to write startupVisibility"); return false; } + if (!parcel.WriteString(processName)) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "Failed to write processName"); + return false; + } return true; } @@ -78,5 +83,16 @@ bool ProcessOptions::IsNewProcessMode(ProcessMode value) return (value == ProcessMode::NEW_PROCESS_ATTACH_TO_PARENT) || (value == ProcessMode::NEW_PROCESS_ATTACH_TO_STATUS_BAR_ITEM); } + +bool ProcessOptions::IsAttachToStatusBarMode(ProcessMode value) +{ + return (value == ProcessMode::NEW_PROCESS_ATTACH_TO_STATUS_BAR_ITEM) || + (value == ProcessMode::ATTACH_TO_STATUS_BAR_ITEM); +} + +bool ProcessOptions::IsValidProcessMode(ProcessMode value) +{ + return (value > ProcessMode::UNSPECIFIED) && (value < ProcessMode::END); +} } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/src/rdb/parser_util.cpp b/services/abilitymgr/src/rdb/parser_util.cpp index feab00dddc..4738451f73 100644 --- a/services/abilitymgr/src/rdb/parser_util.cpp +++ b/services/abilitymgr/src/rdb/parser_util.cpp @@ -16,6 +16,7 @@ #include "parser_util.h" #include +#include #include "config_policy_utils.h" #include "hilog_tag_wrapper.h" @@ -145,6 +146,11 @@ void ParserUtil::GetPreInstallRootDirList(std::vector &rootDirList) bool ParserUtil::ReadFileIntoJson(const std::string &filePath, nlohmann::json &jsonBuf) { + if (access(filePath.c_str(), F_OK) != 0) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "File path is not exist."); + return false; + } + if (filePath.empty()) { TAG_LOGE(AAFwkTag::ABILITYMGR, "File path empty."); return false; diff --git a/services/abilitymgr/src/scene_board/status_bar_delegate_manager.cpp b/services/abilitymgr/src/scene_board/status_bar_delegate_manager.cpp index 825cdb09f2..fe3c37058e 100644 --- a/services/abilitymgr/src/scene_board/status_bar_delegate_manager.cpp +++ b/services/abilitymgr/src/scene_board/status_bar_delegate_manager.cpp @@ -58,41 +58,32 @@ int32_t StatusBarDelegateManager::DoProcessAttachment(std::shared_ptr int32_t { - auto sessionInfo = abilityRecord->GetSessionInfo(); - CHECK_POINTER_AND_RETURN(sessionInfo, ERR_INVALID_VALUE); - auto processOptions = sessionInfo->processOptions; - if (processOptions == nullptr) { - TAG_LOGD(AAFwkTag::ABILITYMGR, "no need to attach process."); - return ERR_OK; - } - if (processOptions->processMode == ProcessMode::NEW_PROCESS_ATTACH_TO_PARENT) { - auto callerRecord = abilityRecord->GetCallerRecord(); - CHECK_POINTER_AND_RETURN(callerRecord, ERR_INVALID_VALUE); - TAG_LOGI(AAFwkTag::ABILITYMGR, "attach pid to parent."); - IN_PROCESS_CALL_WITHOUT_RET(DelayedSingleton::GetInstance()->AttachPidToParent( - abilityRecord->GetToken(), callerRecord->GetToken())); - } - if (processOptions->processMode == ProcessMode::NEW_PROCESS_ATTACH_TO_STATUS_BAR_ITEM) { - auto statusBarDelegate = GetStatusBarDelegate(); - CHECK_POINTER_AND_RETURN(statusBarDelegate, ERR_INVALID_VALUE); - auto accessTokenId = abilityRecord->GetApplicationInfo().accessTokenId; - auto ret = statusBarDelegate->AttachPidToStatusBarItem(accessTokenId, abilityRecord->GetPid()); - if (ret != ERR_OK) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "AttachPidToStatusBarItem failed, ret: %{public}d", ret); - return ret; - } - TAG_LOGI(AAFwkTag::ABILITYMGR, "AttachPidToStatusBarItem success."); - } + auto sessionInfo = abilityRecord->GetSessionInfo(); + CHECK_POINTER_AND_RETURN(sessionInfo, ERR_INVALID_VALUE); + auto processOptions = sessionInfo->processOptions; + if (processOptions == nullptr) { + TAG_LOGD(AAFwkTag::ABILITYMGR, "no need to attach process."); return ERR_OK; - }; - auto ret = func(); - if (ret != ERR_OK) { - std::vector pids; - pids.push_back(abilityRecord->GetPid()); - IN_PROCESS_CALL_WITHOUT_RET(DelayedSingleton::GetInstance()->KillProcessesByPids(pids)); } - return ret; + if (processOptions->processMode == ProcessMode::NEW_PROCESS_ATTACH_TO_PARENT) { + auto callerRecord = abilityRecord->GetCallerRecord(); + CHECK_POINTER_AND_RETURN(callerRecord, ERR_INVALID_VALUE); + TAG_LOGI(AAFwkTag::ABILITYMGR, "attach pid to parent."); + IN_PROCESS_CALL_WITHOUT_RET(DelayedSingleton::GetInstance()->AttachPidToParent( + abilityRecord->GetToken(), callerRecord->GetToken())); + } + if (ProcessOptions::IsAttachToStatusBarMode(processOptions->processMode)) { + auto statusBarDelegate = GetStatusBarDelegate(); + CHECK_POINTER_AND_RETURN(statusBarDelegate, ERR_INVALID_VALUE); + auto accessTokenId = abilityRecord->GetApplicationInfo().accessTokenId; + auto ret = statusBarDelegate->AttachPidToStatusBarItem(accessTokenId, abilityRecord->GetPid()); + if (ret != ERR_OK) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "AttachPidToStatusBarItem failed, ret: %{public}d", ret); + return ret; + } + TAG_LOGI(AAFwkTag::ABILITYMGR, "AttachPidToStatusBarItem success."); + } + return ERR_OK; } } // namespace AAFwk } // namespace OHOS \ No newline at end of file diff --git a/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp b/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp index 5e05ec1125..0892d6b3e3 100644 --- a/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp +++ b/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp @@ -34,6 +34,7 @@ #include "scene_board/status_bar_delegate_manager.h" #include "session_info.h" #include "session_manager_lite.h" +#include "session/host/include/zidl/session_interface.h" #include "startup_util.h" #ifdef SUPPORT_GRAPHICS #include "ability_first_frame_state_observer_manager.h" @@ -45,24 +46,31 @@ namespace AAFwk { namespace { constexpr const char* SEPARATOR = ":"; constexpr int32_t PREPARE_TERMINATE_TIMEOUT_MULTIPLE = 10; -const std::string PARAM_MISSION_AFFINITY_KEY = "ohos.anco.param.missionAffinity"; -const std::string DMS_SRC_NETWORK_ID = "dmsSrcNetworkId"; -const std::string DMS_MISSION_ID = "dmsMissionId"; -const int DEFAULT_DMS_MISSION_ID = -1; -const std::string PARAM_SPECIFIED_PROCESS_FLAG = "ohoSpecifiedProcessFlag"; -const std::string DMS_PROCESS_NAME = "distributedsched"; -const std::string DMS_PERSISTENT_ID = "ohos.dms.persistentId"; +constexpr const char* PARAM_MISSION_AFFINITY_KEY = "ohos.anco.param.missionAffinity"; +constexpr const char* DMS_SRC_NETWORK_ID = "dmsSrcNetworkId"; +constexpr const char* DMS_MISSION_ID = "dmsMissionId"; +constexpr int DEFAULT_DMS_MISSION_ID = -1; +constexpr const char* PARAM_SPECIFIED_PROCESS_FLAG = "ohoSpecifiedProcessFlag"; +constexpr const char* DMS_PROCESS_NAME = "distributedsched"; +constexpr const char* DMS_PERSISTENT_ID = "ohos.dms.persistentId"; #ifdef SUPPORT_ASAN -const int KILL_TIMEOUT_MULTIPLE = 45; +constexpr int KILL_TIMEOUT_MULTIPLE = 45; #else -const int KILL_TIMEOUT_MULTIPLE = 3; +constexpr int KILL_TIMEOUT_MULTIPLE = 3; #endif constexpr int32_t DEFAULT_USER_ID = 0; -const std::unordered_map stateMap = { - { AbilityManagerService::LOAD_TIMEOUT_MSG, FreezeUtil::TimeoutState::LOAD }, - { AbilityManagerService::FOREGROUND_TIMEOUT_MSG, FreezeUtil::TimeoutState::FOREGROUND }, - { AbilityManagerService::BACKGROUND_TIMEOUT_MSG, FreezeUtil::TimeoutState::BACKGROUND } -}; + +FreezeUtil::TimeoutState MsgId2State(uint32_t msgId) +{ + if (msgId == AbilityManagerService::LOAD_TIMEOUT_MSG) { + return FreezeUtil::TimeoutState::LOAD; + } else if (msgId == AbilityManagerService::FOREGROUND_TIMEOUT_MSG) { + return FreezeUtil::TimeoutState::FOREGROUND; + } else if (msgId == AbilityManagerService::BACKGROUND_TIMEOUT_MSG) { + return FreezeUtil::TimeoutState::BACKGROUND; + } + return FreezeUtil::TimeoutState::UNKNOWN; +} auto g_deleteLifecycleEventTask = [](const sptr &token, FreezeUtil::TimeoutState state) { CHECK_POINTER_LOG(token, "token is nullptr."); @@ -249,7 +257,8 @@ int UIAbilityLifecycleManager::AttachAbilityThread(const sptr abilityRecord->SetScheduler(scheduler); if (DoProcessAttachment(abilityRecord) != ERR_OK) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "do process attachment failed."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "do process attachment failed, close the ability."); + BatchCloseUIAbility({abilityRecord}); return ERR_INVALID_VALUE; } if (abilityRecord->IsStartedByCall()) { @@ -332,6 +341,7 @@ int UIAbilityLifecycleManager::NotifySCBToStartUIAbility(const AbilityRequest &a } auto isSpecified = (abilityRequest.abilityInfo.launchMode == AppExecFwk::LaunchMode::SPECIFIED); if (isSpecified) { + PreCreateProcessName(const_cast(abilityRequest)); specifiedRequestMap_.emplace(specifiedRequestId_, abilityRequest); DelayedSingleton::GetInstance()->StartSpecifiedAbility( abilityRequest.want, abilityRequest.abilityInfo, specifiedRequestId_); @@ -614,6 +624,28 @@ void UIAbilityLifecycleManager::EraseSpecifiedAbilityRecord(const std::shared_pt } } +std::string UIAbilityLifecycleManager::GenerateProcessNameForNewProcessMode(const AppExecFwk::AbilityInfo& abilityInfo) +{ + static uint32_t index = 0; + std::string processName = abilityInfo.bundleName + SEPARATOR + abilityInfo.moduleName + SEPARATOR + + abilityInfo.name + SEPARATOR + std::to_string(index++); + TAG_LOGI(AAFwkTag::ABILITYMGR, "processName: %{public}s", processName.c_str()); + return processName; +} + +void UIAbilityLifecycleManager::PreCreateProcessName(AbilityRequest &abilityRequest) +{ + if (abilityRequest.processOptions == nullptr || + !ProcessOptions::IsNewProcessMode(abilityRequest.processOptions->processMode)) { + TAG_LOGD(AAFwkTag::ABILITYMGR, "No need to pre create process name."); + return; + } + TAG_LOGI(AAFwkTag::ABILITYMGR, "create process name in advance."); + std::string processName = GenerateProcessNameForNewProcessMode(abilityRequest.abilityInfo); + abilityRequest.processOptions->processName = processName; + abilityRequest.abilityInfo.process = processName; +} + void UIAbilityLifecycleManager::UpdateProcessName(const AbilityRequest &abilityRequest, std::shared_ptr &abilityRecord) { @@ -623,11 +655,13 @@ void UIAbilityLifecycleManager::UpdateProcessName(const AbilityRequest &abilityR TAG_LOGD(AAFwkTag::ABILITYMGR, "No need to update process name."); return; } - static uint32_t index = 0; - std::string processName = abilityRequest.abilityInfo.bundleName + SEPARATOR + - abilityRequest.abilityInfo.moduleName + SEPARATOR + abilityRequest.abilityInfo.name + - SEPARATOR + std::to_string(index++); - TAG_LOGD(AAFwkTag::ABILITYMGR, "processName: %{public}s", processName.c_str()); + std::string processName; + if (!abilityRequest.sessionInfo->processOptions->processName.empty()) { + TAG_LOGD(AAFwkTag::ABILITYMGR, "The process name has been generated in advance."); + processName = abilityRequest.sessionInfo->processOptions->processName; + } else { + processName = GenerateProcessNameForNewProcessMode(abilityRequest.abilityInfo); + } abilityRecord->SetProcessName(processName); } @@ -907,7 +941,8 @@ int UIAbilityLifecycleManager::NotifySCBPendingActivation(sptr &ses TAG_LOGI(AAFwkTag::ABILITYMGR, "Call PendingSessionActivation by callerSession."); return static_cast(callerSession->PendingSessionActivation(sessionInfo)); } - CHECK_POINTER_AND_RETURN(rootSceneSession_, ERR_INVALID_VALUE); + auto tmpSceneSession = iface_cast(rootSceneSession_); + CHECK_POINTER_AND_RETURN(tmpSceneSession, ERR_INVALID_VALUE); if (sessionInfo->persistentId == 0) { const auto &abilityInfo = abilityRequest.abilityInfo; auto isStandard = abilityInfo.launchMode == AppExecFwk::LaunchMode::STANDARD && !abilityRequest.startRecent; @@ -918,7 +953,7 @@ int UIAbilityLifecycleManager::NotifySCBPendingActivation(sptr &ses } } TAG_LOGI(AAFwkTag::ABILITYMGR, "Call PendingSessionActivation by rootSceneSession."); - return static_cast(rootSceneSession_->PendingSessionActivation(sessionInfo)); + return static_cast(tmpSceneSession->PendingSessionActivation(sessionInfo)); } int UIAbilityLifecycleManager::ResolveAbility( @@ -989,11 +1024,7 @@ void UIAbilityLifecycleManager::PrintTimeOutLog(std::shared_ptr a .eventName = eventName, .bundleName = ability->GetAbilityInfo().bundleName, }; - FreezeUtil::TimeoutState state = FreezeUtil::TimeoutState::UNKNOWN; - auto search = stateMap.find(msgId); - if (search != stateMap.end()) { - state = search->second; - } + FreezeUtil::TimeoutState state = MsgId2State(msgId); if (state != FreezeUtil::TimeoutState::UNKNOWN) { auto flow = std::make_unique(); if (ability->GetToken() != nullptr) { @@ -1286,7 +1317,7 @@ bool UIAbilityLifecycleManager::CheckProperties(const std::shared_ptrGetAppIndex(); + AbilityRuntime::StartupUtil::GetAppIndex(abilityRequest.want) == abilityRecord->GetAppIndex(); } void UIAbilityLifecycleManager::OnTimeOut(uint32_t msgId, int64_t abilityRecordId, bool isHalf) @@ -1328,17 +1359,12 @@ void UIAbilityLifecycleManager::OnTimeOut(uint32_t msgId, int64_t abilityRecordI void UIAbilityLifecycleManager::SetRootSceneSession(const sptr &rootSceneSession) { TAG_LOGD(AAFwkTag::ABILITYMGR, "call"); - if (rootSceneSession == nullptr) { + auto tmpSceneSession = iface_cast(rootSceneSession); + if (tmpSceneSession == nullptr) { TAG_LOGE(AAFwkTag::ABILITYMGR, "rootSceneSession is invalid."); return; } - auto tmpSceneSession = iface_cast(rootSceneSession); - auto descriptor = Str16ToStr8(tmpSceneSession->GetDescriptor()); - if (descriptor != "OHOS.ISession") { - TAG_LOGE(AAFwkTag::ABILITYMGR, "token's Descriptor: %{public}s", descriptor.c_str()); - return; - } - rootSceneSession_ = tmpSceneSession; + rootSceneSession_ = rootSceneSession; } void UIAbilityLifecycleManager::NotifySCBToHandleException(const std::shared_ptr &abilityRecord, @@ -1604,6 +1630,7 @@ int UIAbilityLifecycleManager::SendSessionInfoToSCB(std::shared_ptr &sessionInfo) { TAG_LOGD(AAFwkTag::ABILITYMGR, "call"); + auto tmpSceneSession = iface_cast(rootSceneSession_); if (callerAbility != nullptr) { auto callerSessionInfo = callerAbility->GetSessionInfo(); if (callerSessionInfo != nullptr && callerSessionInfo->sessionToken != nullptr) { @@ -1613,12 +1640,12 @@ int UIAbilityLifecycleManager::SendSessionInfoToSCB(std::shared_ptrhasContinuousTask = hasContinuousTask; callerSession->PendingSessionActivation(sessionInfo); } else { - CHECK_POINTER_AND_RETURN(rootSceneSession_, ERR_INVALID_VALUE); - rootSceneSession_->PendingSessionActivation(sessionInfo); + CHECK_POINTER_AND_RETURN(tmpSceneSession, ERR_INVALID_VALUE); + tmpSceneSession->PendingSessionActivation(sessionInfo); } } else { - CHECK_POINTER_AND_RETURN(rootSceneSession_, ERR_INVALID_VALUE); - rootSceneSession_->PendingSessionActivation(sessionInfo); + CHECK_POINTER_AND_RETURN(tmpSceneSession, ERR_INVALID_VALUE); + tmpSceneSession->PendingSessionActivation(sessionInfo); } return ERR_OK; } @@ -2117,7 +2144,8 @@ void UIAbilityLifecycleManager::DumpMissionListByRecordId(std::vector startOptions) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); - CHECK_POINTER_AND_RETURN(rootSceneSession_, ERR_INVALID_VALUE); + auto tmpSceneSession = iface_cast(rootSceneSession_); + CHECK_POINTER_AND_RETURN(tmpSceneSession, ERR_INVALID_VALUE); std::shared_ptr abilityRecord = GetAbilityRecordsById(sessionId); CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE); if (startOptions != nullptr) { @@ -2126,7 +2154,7 @@ int UIAbilityLifecycleManager::MoveMissionToFront(int32_t sessionId, std::shared sptr sessionInfo = abilityRecord->GetSessionInfo(); CHECK_POINTER_AND_RETURN(sessionInfo, ERR_INVALID_VALUE); TAG_LOGI(AAFwkTag::ABILITYMGR, "Call PendingSessionActivation by rootSceneSession."); - return static_cast(rootSceneSession_->PendingSessionActivation(sessionInfo)); + return static_cast(tmpSceneSession->PendingSessionActivation(sessionInfo)); } std::shared_ptr UIAbilityLifecycleManager::GetStatusBarDelegateManager() @@ -2193,7 +2221,8 @@ int32_t UIAbilityLifecycleManager::KillProcessWithPrepareTerminate(const std::ve return ERR_OK; } -void UIAbilityLifecycleManager::BatchCloseUIAbility(std::unordered_set>& abilitySet) +void UIAbilityLifecycleManager::BatchCloseUIAbility( + const std::unordered_set>& abilitySet) { auto closeTask = [ self = shared_from_this(), abilitySet]() { TAG_LOGI(AAFwkTag::ABILITYMGR, "The abilities need to be closed."); @@ -2226,7 +2255,7 @@ int UIAbilityLifecycleManager::ChangeAbilityVisibility(sptr token auto sessionInfo = abilityRecord->GetSessionInfo(); CHECK_POINTER_AND_RETURN(sessionInfo, ERR_INVALID_VALUE); if (sessionInfo->processOptions == nullptr || - sessionInfo->processOptions->processMode != ProcessMode::NEW_PROCESS_ATTACH_TO_STATUS_BAR_ITEM) { + !ProcessOptions::IsAttachToStatusBarMode(sessionInfo->processOptions->processMode)) { TAG_LOGE(AAFwkTag::ABILITYMGR, "Process options check failed."); return ERR_START_OPTIONS_CHECK_FAILED; } diff --git a/services/abilitymgr/src/start_ability_utils.cpp b/services/abilitymgr/src/start_ability_utils.cpp index 9a76da48f6..49bd7a25af 100644 --- a/services/abilitymgr/src/start_ability_utils.cpp +++ b/services/abilitymgr/src/start_ability_utils.cpp @@ -33,18 +33,19 @@ constexpr const char* SCREENSHOT_BUNDLE_NAME = "com.huawei.ohos.screenshot"; constexpr const char* SCREENSHOT_ABILITY_NAME = "com.huawei.ohos.screenshot.ServiceExtAbility"; } thread_local std::shared_ptr StartAbilityUtils::startAbilityInfo; +thread_local std::shared_ptr StartAbilityUtils::callerAbilityInfo; thread_local bool StartAbilityUtils::skipCrowTest = false; thread_local bool StartAbilityUtils::skipStartOther = false; thread_local bool StartAbilityUtils::skipErms = false; int32_t StartAbilityUtils::GetAppIndex(const Want &want, sptr callerToken) { - int32_t appIndex = want.GetIntParam(AbilityRuntime::ServerConstant::APP_TWIN_INDEX, 0); - if (appIndex > 0 && appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + int32_t appIndex = want.GetIntParam(AbilityRuntime::ServerConstant::APP_CLONE_INDEX, 0); + if (appIndex > 0 && appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { return appIndex; } auto abilityRecord = Token::GetAbilityRecordByToken(callerToken); - if (abilityRecord && abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX && + if (abilityRecord && abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX && abilityRecord->GetApplicationInfo().bundleName == want.GetElement().GetBundleName()) { return abilityRecord->GetAppIndex(); } @@ -72,8 +73,26 @@ bool StartAbilityUtils::GetApplicationInfo(const std::string &bundleName, int32_ return true; } +bool StartAbilityUtils::GetCallerAbilityInfo(const sptr &callerToken, + AppExecFwk::AbilityInfo &abilityInfo) +{ + if (StartAbilityUtils::callerAbilityInfo) { + abilityInfo = StartAbilityUtils::callerAbilityInfo->abilityInfo; + } else { + if (callerToken == nullptr) { + return false; + } + auto abilityRecord = Token::GetAbilityRecordByToken(callerToken); + if (abilityRecord == nullptr) { + return false; + } + abilityInfo = abilityRecord->GetAbilityInfo(); + } + return true; +} + StartAbilityInfoWrap::StartAbilityInfoWrap(const Want &want, int32_t validUserId, int32_t appIndex, - bool isExtension) + const sptr &callerToken, bool isExtension) { if (StartAbilityUtils::startAbilityInfo != nullptr) { TAG_LOGW(AAFwkTag::ABILITYMGR, "startAbilityInfo has been created"); @@ -97,11 +116,17 @@ StartAbilityInfoWrap::StartAbilityInfoWrap(const Want &want, int32_t validUserId StartAbilityUtils::skipCrowTest = true; StartAbilityUtils::skipStartOther = true; } + + if (StartAbilityUtils::callerAbilityInfo != nullptr) { + TAG_LOGW(AAFwkTag::ABILITYMGR, "callerAbilityInfo has been created"); + } + StartAbilityUtils::callerAbilityInfo = StartAbilityInfo::CreateCallerAbilityInfo(callerToken); } StartAbilityInfoWrap::~StartAbilityInfoWrap() { StartAbilityUtils::startAbilityInfo.reset(); + StartAbilityUtils::callerAbilityInfo.reset(); StartAbilityUtils::skipCrowTest = false; StartAbilityUtils::skipStartOther = false; StartAbilityUtils::skipErms = false; @@ -151,14 +176,14 @@ std::shared_ptr StartAbilityInfo::CreateStartAbilityInfo(const HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); auto bms = AbilityUtil::GetBundleManagerHelper(); CHECK_POINTER_AND_RETURN(bms, nullptr); - auto abilityInfoFlag = AbilityRuntime::StartupUtil::BuildAbilityInfoFlag() | - AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_SKILL; + auto abilityInfoFlag = static_cast(AbilityRuntime::StartupUtil::BuildAbilityInfoFlag()) | + static_cast(AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_SKILL); auto request = std::make_shared(); - if (appIndex != 0 && appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + if (appIndex != 0 && appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { IN_PROCESS_CALL_WITHOUT_RET(bms->QueryCloneAbilityInfo(want.GetElement(), abilityInfoFlag, appIndex, request->abilityInfo, userId)); if (request->abilityInfo.name.empty() || request->abilityInfo.bundleName.empty()) { - request->status = ERR_APP_TWIN_INDEX_INVALID; + request->status = ERR_APP_CLONE_INDEX_INVALID; } return request; } @@ -203,8 +228,8 @@ std::shared_ptr StartAbilityInfo::CreateStartExtensionInfo(con HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); auto bms = AbilityUtil::GetBundleManagerHelper(); CHECK_POINTER_AND_RETURN(bms, nullptr); - auto abilityInfoFlag = AbilityRuntime::StartupUtil::BuildAbilityInfoFlag() | - AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_SKILL; + auto abilityInfoFlag = static_cast(AbilityRuntime::StartupUtil::BuildAbilityInfoFlag()) | + static_cast(AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_SKILL); auto abilityInfo = std::make_shared(); std::vector extensionInfos; @@ -232,5 +257,22 @@ std::shared_ptr StartAbilityInfo::CreateStartExtensionInfo(con return abilityInfo; } + +std::shared_ptr StartAbilityInfo::CreateCallerAbilityInfo(const sptr &callerToken) +{ + HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); + if (callerToken == nullptr) { + TAG_LOGD(AAFwkTag::ABILITYMGR, "not call from context."); + return nullptr; + } + auto abilityRecord = Token::GetAbilityRecordByToken(callerToken); + if (abilityRecord == nullptr) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "can not find abilityRecord"); + return nullptr; + } + auto request = std::make_shared(); + request->abilityInfo = abilityRecord->GetAbilityInfo(); + return request; +} } } \ No newline at end of file diff --git a/services/abilitymgr/src/ui_extension_record_factory.cpp b/services/abilitymgr/src/ui_extension_record_factory.cpp index 754df8ec8a..99dba41aff 100644 --- a/services/abilitymgr/src/ui_extension_record_factory.cpp +++ b/services/abilitymgr/src/ui_extension_record_factory.cpp @@ -14,10 +14,10 @@ */ #include "ui_extension_record_factory.h" -#include "ui_extension_record.h" #include "ability_util.h" #include "extension_record_manager.h" #include "hilog_tag_wrapper.h" +#include "ui_extension_record.h" namespace OHOS { namespace AbilityRuntime { @@ -39,7 +39,7 @@ bool UIExtensionRecordFactory::NeedReuse(const AAFwk::AbilityRequest &abilityReq } TAG_LOGI(AAFwkTag::ABILITYMGR, "UIExtensionAbility id: %{public}d.", uiExtensionAbilityId); extensionRecordId = uiExtensionAbilityId; - return ExtensionRecordFactory::NeedReuse(abilityRequest, extensionRecordId); + return true; } int32_t UIExtensionRecordFactory::PreCheck( @@ -51,7 +51,7 @@ int32_t UIExtensionRecordFactory::PreCheck( int32_t UIExtensionRecordFactory::CreateRecord( const AAFwk::AbilityRequest &abilityRequest, std::shared_ptr &extensionRecord) { - std::shared_ptr abilityRecord = AAFwk::AbilityRecord::CreateAbilityRecord(abilityRequest); + auto abilityRecord = AAFwk::AbilityRecord::CreateAbilityRecord(abilityRequest); if (abilityRecord == nullptr) { TAG_LOGE(AAFwkTag::ABILITYMGR, "Failed to create ability record"); return ERR_NULL_OBJECT; diff --git a/services/appdfr/include/appfreeze_manager.h b/services/appdfr/include/appfreeze_manager.h index 111b206363..bef4d74219 100644 --- a/services/appdfr/include/appfreeze_manager.h +++ b/services/appdfr/include/appfreeze_manager.h @@ -47,6 +47,17 @@ public: CRITICAL_TIMEOUT = 1, }; + enum AppFreezeState { + APPFREEZE_STATE_IDLE = 0, + APPFREEZE_STATE_FREEZE = 1, + }; + + struct AppFreezeInfo { + int32_t pid = 0; + int state = 0; + int64_t occurTime = 0; + }; + struct ParamInfo { int typeId = TypeAttribute::NORMAL_TIMEOUT; int32_t pid = 0; @@ -66,6 +77,7 @@ public: std::string WriteToFile(const std::string& fileName, std::string& content); bool IsHandleAppfreeze(const std::string& bundleName); bool IsProcessDebug(int32_t pid, std::string processName); + bool IsNeedIgnoreFreezeEvent(int32_t pid); private: AppfreezeManager& operator=(const AppfreezeManager&) = delete; @@ -78,11 +90,18 @@ private: 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); + int64_t GetFreezeCurrentTime(); + void SetFreezeState(int32_t pid, int state); + int GetFreezeState(int32_t pid); + int64_t GetFreezeTime(int32_t pid); + void ClearOldInfo(); static const inline std::string LOGGER_DEBUG_PROC_PATH = "/proc/transaction_proc"; std::string name_; static ffrt::mutex singletonMutex_; static std::shared_ptr instance_; + static ffrt::mutex freezeMutex_; + std::map appfreezeInfo_; }; } // namespace AppExecFwk } // namespace OHOS diff --git a/services/appdfr/src/appfreeze_manager.cpp b/services/appdfr/src/appfreeze_manager.cpp index 20436499e6..e54611ac35 100644 --- a/services/appdfr/src/appfreeze_manager.cpp +++ b/services/appdfr/src/appfreeze_manager.cpp @@ -47,10 +47,15 @@ constexpr char EVENT_STACK[] = "STACK"; constexpr char BINDER_INFO[] = "BINDER_INFO"; constexpr char APP_RUNNING_UNIQUE_ID[] = "APP_RUNNING_UNIQUE_ID"; constexpr int MAX_LAYER = 8; +constexpr int FREEZEMAP_SIZE_MAX = 20; +constexpr int FREEZE_TIME_LIMIT = 60000; +static constexpr int64_t NANOSECONDS = 1000000000; // NANOSECONDS mean 10^9 nano second +static constexpr int64_t MICROSECONDS = 1000000; // MICROSECONDS mean 10^6 millias second const std::string LOG_FILE_PATH = "data/log/eventlog"; } std::shared_ptr AppfreezeManager::instance_ = nullptr; ffrt::mutex AppfreezeManager::singletonMutex_; +ffrt::mutex AppfreezeManager::freezeMutex_; AppfreezeManager::AppfreezeManager() { @@ -128,6 +133,14 @@ int AppfreezeManager::AppfreezeHandleWithStack(const FaultData& faultData, const HITRACE_METER_FMT(HITRACE_TAG_APP, "AppfreezeHandleWithStack pid:%d-name:%s", appInfo.pid, faultData.errorObject.name.c_str()); + if (faultData.errorObject.name == AppFreezeType::LIFECYCLE_HALF_TIMEOUT + || faultData.errorObject.name == AppFreezeType::APP_INPUT_BLOCK + || faultData.errorObject.name == AppFreezeType::THREAD_BLOCK_6S) { + if (AppExecFwk::AppfreezeManager::GetInstance()->IsNeedIgnoreFreezeEvent(appInfo.pid)) { + TAG_LOGE(AAFwkTag::APPDFR, "AppFreeze already happend in a short period of time."); + return 0; + } + } std::string fileName = faultData.errorObject.name + "_" + std::to_string(appInfo.pid) + "_stack"; std::string catcherStack = ""; @@ -419,5 +432,90 @@ bool AppfreezeManager::IsProcessDebug(int32_t pid, std::string processName) } return false; } + +int64_t AppfreezeManager::GetFreezeCurrentTime() +{ + struct timespec t; + t.tv_sec = 0; + t.tv_nsec = 0; + clock_gettime(CLOCK_MONOTONIC, &t); + return static_cast(((t.tv_sec) * NANOSECONDS + t.tv_nsec) / MICROSECONDS); +} + +void AppfreezeManager::SetFreezeState(int32_t pid, int state) +{ + std::lock_guard lock(freezeMutex_); + if (appfreezeInfo_.find(pid) != appfreezeInfo_.end()) { + appfreezeInfo_[pid].state = state; + appfreezeInfo_[pid].occurTime = GetFreezeCurrentTime(); + } else { + AppFreezeInfo info; + info.pid = pid; + info.state = state; + info.occurTime = GetFreezeCurrentTime(); + appfreezeInfo_.emplace(pid, info); + } +} + +int AppfreezeManager::GetFreezeState(int32_t pid) +{ + std::lock_guard lock(freezeMutex_); + auto it = appfreezeInfo_.find(pid); + if (it != appfreezeInfo_.end()) { + return it->second.state; + } + return AppFreezeState::APPFREEZE_STATE_IDLE; +} + +int64_t AppfreezeManager::GetFreezeTime(int32_t pid) +{ + std::lock_guard lock(freezeMutex_); + auto it = appfreezeInfo_.find(pid); + if (it != appfreezeInfo_.end()) { + return it->second.occurTime; + } + return 0; +} + +void AppfreezeManager::ClearOldInfo() +{ + std::lock_guard lock(freezeMutex_); + int64_t currentTime = GetFreezeCurrentTime(); + for (auto it = appfreezeInfo_.begin(); it != appfreezeInfo_.end();) { + auto diff = currentTime - it->second.occurTime; + if (diff > FREEZE_TIME_LIMIT) { + it = appfreezeInfo_.erase(it); + } else { + ++it; + } + } +} + +bool AppfreezeManager::IsNeedIgnoreFreezeEvent(int32_t pid) +{ + if (appfreezeInfo_.size() >= FREEZEMAP_SIZE_MAX) { + ClearOldInfo(); + } + int state = GetFreezeState(pid); + int64_t currentTime = GetFreezeCurrentTime(); + int64_t lastTime = GetFreezeTime(pid); + auto diff = currentTime - lastTime; + if (state == AppFreezeState::APPFREEZE_STATE_FREEZE) { + if (diff >= FREEZE_TIME_LIMIT) { + TAG_LOGI(AAFwkTag::APPDFR, "IsNeedIgnoreFreezeEvent durationTime: " + "%{public}" PRId64 "state: %{public}d", diff, state); + return false; + } + return true; + } else { + if (diff < FREEZE_TIME_LIMIT) { + return true; + } + SetFreezeState(pid, AppFreezeState::APPFREEZE_STATE_FREEZE); + TAG_LOGI(AAFwkTag::APPDFR, "IsNeedIgnoreFreezeEvent durationTime: " + "%{public}" PRId64 " SetFreezeState: %{public}d", diff, state); + return false; + } +} } // namespace AAFwk } // namespace OHOS \ No newline at end of file diff --git a/services/appmgr/BUILD.gn b/services/appmgr/BUILD.gn index 13bf86aa6f..356af19f64 100644 --- a/services/appmgr/BUILD.gn +++ b/services/appmgr/BUILD.gn @@ -33,6 +33,12 @@ group("appms_target") { } ohos_shared_library("libappms") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + branch_protector_ret = "pac_ret" shlib_type = "sa" include_dirs = [ "${ability_runtime_services_path}/appdfr/include" ] sources = [ @@ -125,8 +131,6 @@ ohos_shared_library("libappms") { ] public_external_deps = [ "kv_store:distributeddata_mgr" ] - defines += [ "OHOS_ACCOUNT_ENABLED" ] - if (product_name != "ohcore") { external_deps += [ "netmanager_base:net_conn_manager_if" ] } diff --git a/services/appmgr/include/ams_mgr_scheduler.h b/services/appmgr/include/ams_mgr_scheduler.h index 6e1795e1d2..c0214db5f4 100644 --- a/services/appmgr/include/ams_mgr_scheduler.h +++ b/services/appmgr/include/ams_mgr_scheduler.h @@ -277,14 +277,6 @@ public: */ void SetKeepAliveEnableState(const std::string &bundleName, bool enable) override; - /** - * Set application assertion pause state. - * - * @param pid App process pid. - * @param flag assertion pause state. - */ - void SetAppAssertionPauseState(int32_t pid, bool flag) override; - /** * To clear the process by ability token. * diff --git a/services/appmgr/include/app_mgr_service.h b/services/appmgr/include/app_mgr_service.h index 8d16a88ba9..796a8aa19d 100644 --- a/services/appmgr/include/app_mgr_service.h +++ b/services/appmgr/include/app_mgr_service.h @@ -147,6 +147,17 @@ public: */ virtual int32_t GetAllRunningProcesses(std::vector &info) override; + /** + * GetRunningMultiAppInfoByBundleName, call GetRunningMultiAppInfoByBundleName() through proxy project. + * Obtains information about multiapp that are running on the device. + * + * @param bundlename, input. + * @param info, output multiapp information. + * @return ERR_OK ,return back success,others fail. + */ + virtual int32_t GetRunningMultiAppInfoByBundleName(const std::string &bundleName, + RunningMultiAppInfo &info) override; + /** * GetRunningProcessesByBundleType, call GetRunningProcessesByBundleType() through proxy project. * Obtains information about application processes by bundle type that are running on the device. @@ -309,7 +320,7 @@ public: virtual int StartRenderProcess(const std::string &renderParam, int32_t ipcFd, int32_t sharedFd, - int32_t crashFd, pid_t &renderPid) override; + int32_t crashFd, pid_t &renderPid, bool isGPU = false) override; virtual void AttachRenderProcess(const sptr &shceduler) override; @@ -503,6 +514,19 @@ public: int32_t NotifyMemorySizeStateChanged(bool isMemorySizeSufficent) override; int32_t SetSupportedProcessCacheSelf(bool isSupport) override; + + void SetAppAssertionPauseState(bool flag) override; + /** + * Start native child process, callde by ChildProcessManager. + * @param libName lib file name to be load in child process + * @param childProcessCount current started child process count + * @param callback callback for notify start result + * @return Returns ERR_OK on success, others on failure. + */ + int32_t StartNativeChildProcess(const std::string &libName, int32_t childProcessCount, + const sptr &callback) override; + + virtual void SaveBrowserChannel(sptr browser) override; private: /** * Init, Initialize application services. diff --git a/services/appmgr/include/app_mgr_service_event_handler.h b/services/appmgr/include/app_mgr_service_event_handler.h index b9a13bc3a8..c738554c10 100644 --- a/services/appmgr/include/app_mgr_service_event_handler.h +++ b/services/appmgr/include/app_mgr_service_event_handler.h @@ -40,6 +40,7 @@ public: #ifdef SUPPORT_ASAN static constexpr uint32_t TERMINATE_ABILITY_TIMEOUT = 45000; // ms static constexpr uint32_t TERMINATE_APPLICATION_TIMEOUT = 150000; // ms + static constexpr uint32_t BACKGROUND_APPLICATION_TIMEOUT = 45000; // ms static constexpr uint32_t ADD_ABILITY_STAGE_INFO_TIMEOUT = 45000; // ms static constexpr uint32_t START_SPECIFIED_ABILITY_TIMEOUT = 45000; // ms static constexpr uint32_t START_PROCESS_SPECIFIED_ABILITY_TIMEOUT = 75000; // ms @@ -48,6 +49,7 @@ public: #else static constexpr uint32_t TERMINATE_ABILITY_TIMEOUT = 3000; // ms static constexpr uint32_t TERMINATE_APPLICATION_TIMEOUT = 10000; // ms + static constexpr uint32_t BACKGROUND_APPLICATION_TIMEOUT = 3000; // ms static constexpr uint32_t ADD_ABILITY_STAGE_INFO_TIMEOUT = 3000; // ms static constexpr uint32_t START_SPECIFIED_ABILITY_TIMEOUT = 3000; // ms static constexpr uint32_t START_PROCESS_SPECIFIED_ABILITY_TIMEOUT = 5000; // ms diff --git a/services/appmgr/include/app_mgr_service_inner.h b/services/appmgr/include/app_mgr_service_inner.h index cd7138a8f9..7358e8367f 100644 --- a/services/appmgr/include/app_mgr_service_inner.h +++ b/services/appmgr/include/app_mgr_service_inner.h @@ -65,13 +65,19 @@ #include "shared/base_shared_bundle_info.h" #include "task_handler_wrap.h" #include "want.h" -#include "window_focus_changed_listener.h" -#include "window_visibility_changed_listener.h" #include "app_jsheap_mem_info.h" +#include "running_multi_info.h" namespace OHOS { +namespace Rosen { +class WindowVisibilityInfo; +class FocusChangeInfo; +} namespace AppExecFwk { using OHOS::AAFwk::Want; +class WindowFocusChangedListener; +class WindowVisibilityChangedListener; + class AppMgrServiceInner : public std::enable_shared_from_this { public: AppMgrServiceInner(); @@ -305,6 +311,17 @@ public: */ virtual int32_t GetAllRunningProcesses(std::vector &info); + /** + * GetRunningMultiAppInfoByBundleName, call GetRunningMultiAppInfoByBundleName through proxy project. + * Obtains information about TwinApp that are running on the device. + * + * @param bundleName, input. + * @param info, output multiapp information. + * @return void. + */ + virtual int32_t GetRunningMultiAppInfoByBundleName(const std::string &bundleName, + RunningMultiAppInfo &info); + /** * GetRunningProcessesByBundleType, Obtains information about application processes by bundle type. * @@ -692,7 +709,7 @@ public: virtual int32_t StartRenderProcess(const pid_t hostPid, const std::string &renderParam, int32_t ipcFd, int32_t sharedFd, - int32_t crashFd, pid_t &renderPid); + int32_t crashFd, pid_t &renderPid, bool isGPU = false); virtual void AttachRenderProcess(const pid_t pid, const sptr &scheduler); @@ -995,6 +1012,17 @@ public: */ virtual void ExitChildProcessSafelyByChildPid(const pid_t pid); + /** + * Start native child process, callde by ChildProcessManager. + * @param hostPid Host process pid. + * @param childProcessCount current started child process count + * @param libName lib file name to be load in child process + * @param callback callback for notify start result + * @return Returns ERR_OK on success, others on failure. + */ + virtual int32_t StartNativeChildProcess(const pid_t hostPid, + const std::string &libName, int32_t childProcessCount, const sptr &callback); + /** * Whether the current application process is the last surviving process. * @param bundleName To query the bundle name of a process. @@ -1030,7 +1058,7 @@ public: int32_t SignRestartAppFlag(const std::string &bundleName); - void SetAppAssertionPauseState(int32_t pid, bool flag); + void SetAppAssertionPauseState(bool flag); void SetKeepAliveEnableState(const std::string &bundleName, bool enable); @@ -1057,6 +1085,8 @@ public: int32_t SetSupportedProcessCacheSelf(bool isSupport); void OnAppCacheStateChanged(const std::shared_ptr &appRecord); + + virtual void SaveBrowserChannel(const pid_t hostPid, sptr browser); private: std::string FaultTypeToString(FaultDataType type); @@ -1125,7 +1155,8 @@ private: void StartProcess(const std::string &appName, const std::string &processName, uint32_t startFlags, std::shared_ptr appRecord, const int uid, const BundleInfo &bundleInfo, const std::string &bundleName, const int32_t bundleIndex, bool appExistFlag = true, - bool isPreload = false); + bool isPreload = false, const std::string &moduleName = "", const std::string &abilityName = "", + bool strictMode = false); /** * PushAppFront, Adjust the latest application record to the top level. @@ -1253,7 +1284,7 @@ private: void GetRenderProcesses(const std::shared_ptr &appRecord, std::vector &info); int StartRenderProcessImpl(const std::shared_ptr &renderRecord, - const std::shared_ptr appRecord, pid_t &renderPid); + const std::shared_ptr appRecord, pid_t &renderPid, bool isGPU = false); void OnRenderRemoteDied(const wptr &remote); @@ -1357,6 +1388,9 @@ private: void NotifyAppRunningStatusEvent( const std::string &bundle, int32_t uid, AbilityRuntime::RunningStatus runningStatus); + void GetRunningCloneAppInfo(const std::shared_ptr &appRecord, + RunningMultiAppInfo &info); + /** * To Prevent process being killed when ability is starting in an existing process, * we need notify memmgr to increase process priority. @@ -1391,7 +1425,12 @@ private: int32_t CreateStartMsg(const std::string &processName, uint32_t startFlags, const int uid, const BundleInfo &bundleInfo, const int32_t bundleIndex, BundleType bundleType, - AppSpawnStartMsg &startMsg); + AppSpawnStartMsg &startMsg, const std::string &moduleName = "", const std::string &abilityName = "", + bool strictMode = false); + + void QueryExtensionSandBox(const std::string &moduleName, const std::string &abilityName, + const BundleInfo &bundleInfo, AppSpawnStartMsg &startMsg, DataGroupInfoList& dataGroupInfoList, + bool strictMode); int32_t StartPerfProcessByStartMsg(AppSpawnStartMsg &startMsg, const std::string& perfCmd, const std::string& debugCmd, bool isSandboxApp); @@ -1440,6 +1479,7 @@ private: ffrt::mutex appStateCallbacksLock_; ffrt::mutex renderUidSetLock_; ffrt::mutex exceptionLock_; + ffrt::mutex browserHostLock_; sptr startSpecifiedAbilityResponse_; ffrt::mutex configurationObserverLock_; std::vector> configurationObservers_; diff --git a/services/appmgr/include/app_running_manager.h b/services/appmgr/include/app_running_manager.h index 8b144e285f..a5f895ac69 100644 --- a/services/appmgr/include/app_running_manager.h +++ b/services/appmgr/include/app_running_manager.h @@ -35,6 +35,9 @@ #include "app_jsheap_mem_info.h" namespace OHOS { +namespace Rosen { +class WindowVisibilityInfo; +} namespace AppExecFwk { class AppRunningManager { public: diff --git a/services/appmgr/include/app_running_record.h b/services/appmgr/include/app_running_record.h index 5be902a7a4..417044ff06 100644 --- a/services/appmgr/include/app_running_record.h +++ b/services/appmgr/include/app_running_record.h @@ -43,10 +43,12 @@ #include "module_running_record.h" #include "app_spawn_client.h" #include "app_malloc_info.h" -#include "window_visibility_changed_listener.h" #include "app_jsheap_mem_info.h" namespace OHOS { +namespace Rosen { +class WindowVisibilityInfo; +} namespace AppExecFwk { class AbilityRunningRecord; class AppMgrServiceInner; @@ -89,6 +91,7 @@ public: void RegisterDeathRecipient(); void SetState(int32_t state); int32_t GetState() const; + void SetProcessType(ProcessType type); private: void SetHostUid(const int32_t hostUid); @@ -776,6 +779,11 @@ public: bool SetSupportedProcessCache(bool isSupport); SupportProcessCacheState GetSupportProcessCacheState(); + + void SetBrowserHost(sptr browser); + sptr GetBrowserHost(); + void SetIsGPU(bool gpu); + bool GetIsGPU(); private: /** * SearchTheModuleInfoNeedToUpdated, Get an uninitialized abilityStage data. @@ -861,7 +869,7 @@ private: std::unordered_set, RemoteObjHash> foregroundingAbilityTokens_; std::weak_ptr appMgrServiceInner_; sptr appDeathRecipient_ = nullptr; - std::shared_ptr priorityObject_ = nullptr; + std::shared_ptr priorityObject_; std::shared_ptr appLifeCycleDeal_ = nullptr; std::shared_ptr taskHandler_; std::shared_ptr eventHandler_; @@ -931,6 +939,8 @@ private: bool isNativeStart_ = false; bool isMultiThread_ = false; SupportProcessCacheState procCacheSupportState_ = SupportProcessCacheState::UNSPECIFIED; + sptr browserHost_; + bool isGPU_ = false; }; } // namespace AppExecFwk diff --git a/services/appmgr/include/app_spawn_client.h b/services/appmgr/include/app_spawn_client.h index adbcb4f735..693dfab866 100644 --- a/services/appmgr/include/app_spawn_client.h +++ b/services/appmgr/include/app_spawn_client.h @@ -68,6 +68,11 @@ struct AppSpawnStartMsg { std::string provisionType; bool atomicServiceFlag = false; std::string atomicAccount = ""; + bool isolatedExtension = false; // whether is isolatedExtension + std::string extensionSandboxPath; + bool strictMode = false; // whether is strict mode + std::string processType = ""; + int32_t maxChildProcess = 0; }; constexpr auto LEN_PID = sizeof(pid_t); @@ -161,6 +166,22 @@ public: */ int32_t SetAtomicServiceFlag(const AppSpawnStartMsg &startMsg, AppSpawnReqMsgHandle reqHandle); + /** + * Set strict mode flags. + * + * @param startMsg, request message. + * @param reqHandle, handle for request message + */ + int32_t SetStrictMode(const AppSpawnStartMsg &startMsg, AppSpawnReqMsgHandle reqHandle); + + /** + * Set app extension flags. + * + * @param startMsg, request message. + * @param reqHandle, handle for request message + */ + int32_t SetAppExtension(const AppSpawnStartMsg &startMsg, AppSpawnReqMsgHandle reqHandle); + /** * Set extra info: render-cmd, HspList, Overlay, DataGroup, AppEnv. * @@ -169,6 +190,14 @@ public: */ int32_t AppspawnSetExtMsg(const AppSpawnStartMsg &startMsg, AppSpawnReqMsgHandle reqHandle); + /** + * Set extra info: provision_type, max_child_process. + * + * @param startMsg, request message. + * @param reqHandle, handle for request message + */ + int32_t AppspawnSetExtMsgMore(const AppSpawnStartMsg &startMsg, AppSpawnReqMsgHandle reqHandle); + /** * Create default appspawn msg. * diff --git a/services/appmgr/include/child_process_record.h b/services/appmgr/include/child_process_record.h index bb3565a946..dd3690b9e2 100644 --- a/services/appmgr/include/child_process_record.h +++ b/services/appmgr/include/child_process_record.h @@ -22,6 +22,7 @@ #include "app_death_recipient.h" #include "child_scheduler_interface.h" +#include "child_process_info.h" namespace OHOS { namespace AppExecFwk { @@ -31,10 +32,15 @@ class ChildProcessRecord { public: ChildProcessRecord(pid_t hostPid, const std::string &srcEntry, const std::shared_ptr hostRecord, int32_t childProcessCount, bool isStartWithDebug); + ChildProcessRecord(pid_t hostPid, const std::string &libName, const std::shared_ptr hostRecord, + const sptr &mainProcessCb, int32_t childProcessCount, bool isStartWithDebug); virtual ~ChildProcessRecord(); static std::shared_ptr CreateChildProcessRecord(pid_t hostPid, const std::string &srcEntry, const std::shared_ptr hostRecord, int32_t childProcessCount, bool isStartWithDebug); + static std::shared_ptr CreateNativeChildProcessRecord(pid_t hostPid, const std::string &libName, + const std::shared_ptr hostRecord, const sptr &mainProcessCb, + int32_t childProcessCount, bool isStartWithDebug); void SetPid(pid_t pid); pid_t GetPid() const; @@ -51,6 +57,9 @@ public: void RemoveDeathRecipient(); void ScheduleExitProcessSafely(); bool isStartWithDebug(); + int32_t GetProcessType() const; + sptr GetMainProcessCallback() const; + void ClearMainProcessCallback(); private: void MakeProcessName(const std::shared_ptr hostRecord); @@ -58,11 +67,13 @@ private: pid_t hostPid_ = 0; int32_t uid_ = 0; int32_t childProcessCount_ = 0; + int32_t childProcessType_ = CHILD_PROCESS_TYPE_JS; std::string processName_; std::string srcEntry_; std::weak_ptr hostRecord_; sptr scheduler_ = nullptr; sptr deathRecipient_ = nullptr; + sptr mainProcessCb_ = nullptr; bool isStartWithDebug_; }; } // namespace AppExecFwk diff --git a/services/appmgr/src/ams_mgr_scheduler.cpp b/services/appmgr/src/ams_mgr_scheduler.cpp index a767c72511..0c683f78e1 100644 --- a/services/appmgr/src/ams_mgr_scheduler.cpp +++ b/services/appmgr/src/ams_mgr_scheduler.cpp @@ -531,15 +531,6 @@ bool AmsMgrScheduler::IsAttachDebug(const std::string &bundleName) return amsMgrServiceInner_->IsAttachDebug(bundleName); } -void AmsMgrScheduler::SetAppAssertionPauseState(int32_t pid, bool flag) -{ - if (!IsReady()) { - TAG_LOGE(AAFwkTag::APPMGR, "AmsMgrService is not ready."); - return; - } - amsMgrServiceInner_->SetAppAssertionPauseState(pid, flag); -} - void AmsMgrScheduler::SetKeepAliveEnableState(const std::string &bundleName, bool enable) { if (!IsReady()) { diff --git a/services/appmgr/src/app_mgr_service.cpp b/services/appmgr/src/app_mgr_service.cpp index 03ed44a33f..67f92bdb90 100644 --- a/services/appmgr/src/app_mgr_service.cpp +++ b/services/appmgr/src/app_mgr_service.cpp @@ -257,6 +257,7 @@ void AppMgrService::ApplicationBackgrounded(const int32_t recordId) if (!JudgeAppSelfCalled(recordId)) { return; } + taskHandler_->CancelTask("appbackground_" + std::to_string(recordId)); std::function applicationBackgroundedFunc = std::bind(&AppMgrServiceInner::ApplicationBackgrounded, appMgrServiceInner_, recordId); taskHandler_->SubmitTask(applicationBackgroundedFunc, AAFwk::TaskAttribute{ @@ -391,6 +392,26 @@ int32_t AppMgrService::GetAllRunningProcesses(std::vector &i return appMgrServiceInner_->GetAllRunningProcesses(info); } +int32_t AppMgrService::GetRunningMultiAppInfoByBundleName(const std::string &bundleName, + RunningMultiAppInfo &info) +{ + if (!IsReady()) { + return ERR_INVALID_OPERATION; + } + + if (!AAFwk::PermissionVerification::GetInstance()->JudgeCallerIsAllowedToUseSystemAPI()) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "The caller is not system-app, can not use system-api"); + return ERR_INVALID_OPERATION; + } + + bool isCallingPermission = AAFwk::PermissionVerification::GetInstance()->VerifyRunningInfoPerm(); + if (!isCallingPermission) { + TAG_LOGE(AAFwkTag::APPMGR, "GetRunningMultiAppInfoByBundleName, Permission verification failed."); + return ERR_PERMISSION_DENIED; + } + return appMgrServiceInner_->GetRunningMultiAppInfoByBundleName(bundleName, info); +} + int32_t AppMgrService::GetRunningProcessesByBundleType(BundleType bundleType, std::vector &info) { @@ -415,7 +436,7 @@ int32_t AppMgrService::JudgeSandboxByPid(pid_t pid, bool &isSandbox) return ERR_INVALID_OPERATION; } auto appRunningRecord = appMgrServiceInner_->GetAppRunningRecordByPid(pid); - if (appRunningRecord && appRunningRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + if (appRunningRecord && appRunningRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { isSandbox = true; TAG_LOGD(AAFwkTag::APPMGR, "current app is a sandbox."); return ERR_OK; @@ -899,7 +920,7 @@ int32_t AppMgrService::PreStartNWebSpawnProcess() } int32_t AppMgrService::StartRenderProcess(const std::string &renderParam, int32_t ipcFd, - int32_t sharedFd, int32_t crashFd, pid_t &renderPid) + int32_t sharedFd, int32_t crashFd, pid_t &renderPid, bool isGPU) { if (!IsReady()) { TAG_LOGE(AAFwkTag::APPMGR, "StartRenderProcess failed, AppMgrService not ready."); @@ -907,7 +928,7 @@ int32_t AppMgrService::StartRenderProcess(const std::string &renderParam, int32_ } return appMgrServiceInner_->StartRenderProcess(IPCSkeleton::GetCallingRealPid(), - renderParam, ipcFd, sharedFd, crashFd, renderPid); + renderParam, ipcFd, sharedFd, crashFd, renderPid, isGPU); } void AppMgrService::AttachRenderProcess(const sptr &scheduler) @@ -927,6 +948,16 @@ void AppMgrService::AttachRenderProcess(const sptr &scheduler) }); } +void AppMgrService::SaveBrowserChannel(sptr browser) +{ + if (!IsReady()) { + TAG_LOGE(AAFwkTag::APPMGR, "SaveBrowserChannel not ready"); + return; + } + + appMgrServiceInner_->SaveBrowserChannel(IPCSkeleton::GetCallingRealPid(), browser); +} + int32_t AppMgrService::GetRenderProcessTerminationStatus(pid_t renderPid, int &status) { if (!IsReady()) { @@ -1441,5 +1472,29 @@ int32_t AppMgrService::SetSupportedProcessCacheSelf(bool isSupport) } return appMgrServiceInner_->SetSupportedProcessCacheSelf(isSupport); } + +void AppMgrService::SetAppAssertionPauseState(bool flag) +{ + TAG_LOGI(AAFwkTag::APPMGR, "Called"); + if (!IsReady()) { + TAG_LOGE(AAFwkTag::APPMGR, "Not ready."); + return; + } + return appMgrServiceInner_->SetAppAssertionPauseState(flag); +} + +int32_t AppMgrService::StartNativeChildProcess(const std::string &libName, int32_t childProcessCount, + const sptr &callback) +{ + TAG_LOGI(AAFwkTag::APPMGR, "Called"); + if (!IsReady()) { + TAG_LOGE(AAFwkTag::APPMGR, "Not ready."); + return ERR_INVALID_OPERATION; + } + + return appMgrServiceInner_->StartNativeChildProcess( + IPCSkeleton::GetCallingPid(), libName, childProcessCount, callback); +} + } // namespace AppExecFwk } // namespace OHOS diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index 5fb98f06dd..9604ba1b65 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -81,6 +81,8 @@ #include "app_mgr_service_const.h" #include "app_mgr_service_dump_error_code.h" #include "cache_process_manager.h" +#include "window_focus_changed_listener.h" +#include "window_visibility_changed_listener.h" namespace OHOS { namespace AppExecFwk { @@ -142,6 +144,13 @@ 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"; const int32_t SIGNAL_KILL = 9; constexpr int32_t USER_SCALE = 200000; #define ENUM_TO_STRING(s) #s @@ -249,7 +258,7 @@ void AppMgrServiceInner::StartSpecifiedProcess(const AAFwk::Want &want, const Ap HapModuleInfo hapModuleInfo; auto appInfo = std::make_shared(abilityInfo.applicationInfo); - int32_t appIndex = AbilityRuntime::StartupUtil::GetAppTwinIndex(want); + int32_t appIndex = AbilityRuntime::StartupUtil::GetAppIndex(want); if (!GetBundleAndHapInfo(abilityInfo, appInfo, bundleInfo, hapModuleInfo, appIndex)) { return; } @@ -399,7 +408,7 @@ void AppMgrServiceInner::LoadAbility(sptr token, sptrGetBoolParam(STRICT_MODE, false); StartProcess(abilityInfo->applicationName, processName, startFlags, appRecord, - appInfo->uid, bundleInfo, appInfo->bundleName, bundleIndex, appExistFlag, isPreload); + appInfo->uid, bundleInfo, appInfo->bundleName, bundleIndex, appExistFlag, isPreload, abilityInfo->moduleName, + abilityInfo->name, strictMode); std::string perfCmd = (want == nullptr) ? "" : want->GetStringParam(PERF_CMD); bool isSandboxApp = (want == nullptr) ? false : want->GetBoolParam(ENTER_SANDBOX, false); (void)StartPerfProcess(appRecord, perfCmd, "", isSandboxApp); @@ -726,21 +737,22 @@ bool AppMgrServiceInner::GetBundleAndHapInfo(const AbilityInfo &abilityInfo, int32_t bundleMgrResult; if (appIndex == 0) { bundleMgrResult = IN_PROCESS_CALL(bundleMgrHelper->GetBundleInfoV9(appInfo->bundleName, - static_cast(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_APPLICATION), bundleInfo, userId)); - } else if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + static_cast(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_APPLICATION) | + static_cast(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY) | + static_cast(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE), bundleInfo, userId)); + } else if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { bundleMgrResult = IN_PROCESS_CALL(bundleMgrHelper->GetCloneBundleInfo(appInfo->bundleName, static_cast(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_APPLICATION), appIndex, bundleInfo, userId)); } else { bundleMgrResult = IN_PROCESS_CALL(bundleMgrHelper->GetSandboxBundleInfo(appInfo->bundleName, appIndex, userId, bundleInfo)); } - if (bundleMgrResult != ERR_OK) { TAG_LOGE(AAFwkTag::APPMGR, "GetBundleInfo is fail."); return false; } bool hapQueryResult = false; - if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) { + if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { hapQueryResult = bundleMgrHelper->GetHapModuleInfo(abilityInfo, userId, hapModuleInfo); } else { hapQueryResult = (bundleMgrHelper->GetSandboxHapModuleInfo(abilityInfo, appIndex, userId, hapModuleInfo) == 0); @@ -749,7 +761,6 @@ bool AppMgrServiceInner::GetBundleAndHapInfo(const AbilityInfo &abilityInfo, TAG_LOGE(AAFwkTag::APPMGR, "GetHapModuleInfo is fail."); return false; } - return true; } @@ -1410,6 +1421,78 @@ int32_t AppMgrServiceInner::GetRunningProcessesByBundleType(BundleType bundleTyp return ERR_OK; } +int32_t AppMgrServiceInner::GetRunningMultiAppInfoByBundleName(const std::string &bundleName, + RunningMultiAppInfo &info) +{ + if (bundleName.empty()) { + TAG_LOGE(AAFwkTag::APPMGR, "bundlename is nullptr."); + return ERR_INVALID_VALUE; + } + if (!appRunningManager_) { + TAG_LOGE(AAFwkTag::APPMGR, "The appRunningManager is nullptr!"); + return ERR_INVALID_VALUE; + } + auto multiAppInfoMap = appRunningManager_->GetAppRunningRecordMap(); + if (multiAppInfoMap.empty()) { + return ERR_INVALID_VALUE; + } + for (const auto &item : multiAppInfoMap) { + const std::shared_ptr &appRecord = item.second; + if (appRecord == nullptr || appRecord->GetBundleName() != bundleName) { + continue; + } + auto appInfo = appRecord->GetApplicationInfo(); + if (!appInfo) { + continue; + } + info.bundleName = bundleName; + info.mode = static_cast(appInfo->multiAppMode.multiAppModeType); + if (info.mode == static_cast(MultiAppModeType::UNSPECIFIED)) { + return AAFwk::ERR_MULTI_APP_NOT_SUPPORTED; + } + GetRunningCloneAppInfo(appRecord, info); + } + return ERR_OK; +} + +void AppMgrServiceInner::GetRunningCloneAppInfo(const std::shared_ptr &appRecord, + RunningMultiAppInfo &info) +{ + if (!appRecord) { + TAG_LOGE(AAFwkTag::APPMGR, "The appRecord is nullptr!"); + return; + } + auto PriorityObject = appRecord->GetPriorityObject(); + if (!PriorityObject) { + TAG_LOGE(AAFwkTag::APPMGR, "The PriorityObject is nullptr!"); + return; + } + if (info.mode == static_cast(MultiAppModeType::APP_CLONE)) { + size_t index = 0; + for (; index < info.runningAppClones.size(); index++) { + if (info.runningAppClones[index].appCloneIndex == appRecord->GetAppIndex()) { + break; + } + } + auto childProcessRecordMap = appRecord->GetChildProcessRecordMap(); + if (index < info.runningAppClones.size()) { + info.runningAppClones[index].pids.emplace_back(PriorityObject->GetPid()); + for (auto it : childProcessRecordMap) { + info.runningAppClones[index].pids.emplace_back(it.first); + } + } else { + RunningAppClone cloneInfo; + cloneInfo.appCloneIndex = appRecord->GetAppIndex(); + cloneInfo.uid = appRecord->GetUid(); + cloneInfo.pids.emplace_back(PriorityObject->GetPid()); + for (auto it : childProcessRecordMap) { + cloneInfo.pids.emplace_back(it.first); + } + info.runningAppClones.emplace_back(cloneInfo); + } + } +} + int32_t AppMgrServiceInner::GetProcessRunningInfosByUserId(std::vector &info, int32_t userId) { if (VerifyAccountPermission(AAFwk::PermissionConstants::PERMISSION_GET_RUNNING_INFO, userId) == @@ -1747,7 +1830,6 @@ std::shared_ptr AppMgrServiceInner::CreateAppRunningRecord(spt bool isKeepAlive = bundleInfo.isKeepAlive && bundleInfo.singleton; appRecord->SetKeepAliveEnableState(isKeepAlive); appRecord->SetEmptyKeepAliveAppState(false); - appRecord->SetSingleton(bundleInfo.singleton); appRecord->SetTaskHandler(taskHandler_); appRecord->SetEventHandler(eventHandler_); appRecord->AddModule(appInfo, abilityInfo, token, hapModuleInfo, want, abilityRecordId); @@ -1759,7 +1841,7 @@ std::shared_ptr AppMgrServiceInner::CreateAppRunningRecord(spt } appRecord->SetPerfCmd(want->GetStringParam(PERF_CMD)); appRecord->SetMultiThread(want->GetBoolParam(MULTI_THREAD, false)); - appRecord->SetAppIndex(AbilityRuntime::StartupUtil::GetAppTwinIndex(*want)); + appRecord->SetAppIndex(AbilityRuntime::StartupUtil::GetAppIndex(*want)); appRecord->SetSecurityFlag(want->GetBoolParam(DLP_PARAMS_SECURITY_FLAG, false)); appRecord->SetRequestProcCode(want->GetIntParam(Want::PARAM_RESV_REQUEST_PROC_CODE, 0)); appRecord->SetCallerPid(want->GetIntParam(Want::PARAM_RESV_CALLER_PID, -1)); @@ -2525,6 +2607,7 @@ void AppMgrServiceInner::SetAppInfo(const BundleInfo &bundleInfo, AppSpawnStartM startMsg.apl = bundleInfo.applicationInfo.appPrivilegeLevel; startMsg.ownerId = bundleInfo.signatureInfo.appIdentifier; startMsg.provisionType = bundleInfo.applicationInfo.appProvisionType; + startMsg.maxChildProcess = bundleInfo.applicationInfo.maxChildProcess; startMsg.setAllowInternet = setAllowInternet; startMsg.allowInternet = allowInternet; startMsg.gids = gids; @@ -2533,7 +2616,8 @@ void AppMgrServiceInner::SetAppInfo(const BundleInfo &bundleInfo, AppSpawnStartM } int32_t AppMgrServiceInner::CreateStartMsg(const std::string &processName, uint32_t startFlags, const int uid, - const BundleInfo &bundleInfo, const int32_t bundleIndex, BundleType bundleType, AppSpawnStartMsg &startMsg) + const BundleInfo &bundleInfo, const int32_t bundleIndex, BundleType bundleType, AppSpawnStartMsg &startMsg, + const std::string &moduleName, const std::string &abilityName, bool strictMode) { if (!remoteClientManager_ || !otherTaskHandler_) { TAG_LOGE(AAFwkTag::APPMGR, "remoteClientManager or otherTaskHandler is nullptr."); @@ -2565,8 +2649,7 @@ int32_t AppMgrServiceInner::CreateStartMsg(const std::string &processName, uint3 if (!result || dataGroupInfoList.empty()) { TAG_LOGD(AAFwkTag::APPMGR, "the bundle has no groupInfos."); } - startMsg.dataGroupInfoList = dataGroupInfoList; - + QueryExtensionSandBox(moduleName, abilityName, bundleInfo, startMsg, dataGroupInfoList, strictMode); startMsg.bundleName = bundleInfo.name; startMsg.renderParam = RENDER_PARAM; startMsg.flags = startFlags; @@ -2588,9 +2671,42 @@ int32_t AppMgrServiceInner::CreateStartMsg(const std::string &processName, uint3 return ERR_OK; } +void AppMgrServiceInner::QueryExtensionSandBox(const std::string &moduleName, const std::string &abilityName, + const BundleInfo &bundleInfo, AppSpawnStartMsg &startMsg, DataGroupInfoList& dataGroupInfoList, bool strictMode) +{ + std::vector extensionInfos; + for (auto hapModuleInfo: bundleInfo.hapModuleInfos) { + extensionInfos.insert(extensionInfos.end(), hapModuleInfo.extensionInfos.begin(), + hapModuleInfo.extensionInfos.end()); + } + auto infoExisted = [&moduleName, &abilityName](const ExtensionAbilityInfo& info) { + return info.moduleName == moduleName && info.name == abilityName && info.needCreateSandbox; + }; + auto infoIter = std::find_if(extensionInfos.begin(), extensionInfos.end(), infoExisted); + DataGroupInfoList extensionDataGroupInfoList; + if (infoIter != extensionInfos.end()) { + startMsg.isolatedExtension = infoIter->needCreateSandbox; + startMsg.extensionSandboxPath = infoIter->moduleName + "/" + infoIter->name; + startMsg.strictMode = strictMode; + for (auto dataGroupInfo : dataGroupInfoList) { + auto groupIdExisted = [&dataGroupInfo](const std::string &dataGroupId) { + return dataGroupInfo.dataGroupId == dataGroupId; + }; + if (std::find_if(infoIter->dataGroupIds.begin(), infoIter->dataGroupIds.end(), groupIdExisted) != + infoIter->dataGroupIds.end()) { + extensionDataGroupInfoList.emplace_back(dataGroupInfo); + } + } + startMsg.dataGroupInfoList = extensionDataGroupInfoList; + } else { + startMsg.dataGroupInfoList = dataGroupInfoList; + } +} + void AppMgrServiceInner::StartProcess(const std::string &appName, const std::string &processName, uint32_t startFlags, std::shared_ptr appRecord, const int uid, const BundleInfo &bundleInfo, - const std::string &bundleName, const int32_t bundleIndex, bool appExistFlag, bool isPreload) + const std::string &bundleName, const int32_t bundleIndex, bool appExistFlag, bool isPreload, + const std::string &moduleName, const std::string &abilityName, bool strictMode) { HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); TAG_LOGD(AAFwkTag::APPMGR, "bundleName: %{public}s, isPreload: %{public}d", bundleName.c_str(), isPreload); @@ -2608,7 +2724,8 @@ void AppMgrServiceInner::StartProcess(const std::string &appName, const std::str AppSpawnStartMsg startMsg; auto appInfo = appRecord->GetApplicationInfo(); auto bundleType = appInfo ? appInfo->bundleType : BundleType::APP; - if (CreateStartMsg(processName, startFlags, uid, bundleInfo, bundleIndex, bundleType, startMsg) != ERR_OK) { + if (CreateStartMsg(processName, startFlags, uid, bundleInfo, bundleIndex, bundleType, startMsg, moduleName, + abilityName, strictMode) != ERR_OK) { TAG_LOGE(AAFwkTag::APPMGR, "CreateStartMsg failed."); appRunningManager_->RemoveAppRunningRecordById(appRecord->GetRecordId()); return; @@ -3521,7 +3638,7 @@ int AppMgrServiceInner::StartEmptyProcess(const AAFwk::Want &want, const sptruserId = userId; appRecord->SetUserTestInfo(testRecord); - int32_t appIndex = AbilityRuntime::StartupUtil::GetAppTwinIndex(want); + int32_t appIndex = AbilityRuntime::StartupUtil::GetAppIndex(want); uint32_t startFlags = AppspawnUtil::BuildStartFlags(want, info.applicationInfo); StartProcess(appInfo->name, processName, startFlags, appRecord, appInfo->uid, info, appInfo->bundleName, appIndex, appExistFlag); @@ -3612,7 +3729,7 @@ void AppMgrServiceInner::StartSpecifiedAbility(const AAFwk::Want &want, const Ap HapModuleInfo hapModuleInfo; auto appInfo = std::make_shared(abilityInfo.applicationInfo); - int32_t appIndex = AbilityRuntime::StartupUtil::GetAppTwinIndex(want); + int32_t appIndex = AbilityRuntime::StartupUtil::GetAppIndex(want); if (!GetBundleAndHapInfo(abilityInfo, appInfo, bundleInfo, hapModuleInfo, appIndex)) { return; } @@ -3931,6 +4048,12 @@ void AppMgrServiceInner::InitGlobalConfiguration() auto deviceType = GetDeviceType(); TAG_LOGI(AAFwkTag::APPMGR, "current deviceType is %{public}s", deviceType); configuration_->AddItem(AAFwk::GlobalConfigurationKey::DEVICE_TYPE, deviceType); + auto fontSizeScale = OHOS::system::GetParameter(FONT_SCALE, "1.0"); + auto fontWeightScale = OHOS::system::GetParameter(FONT_WGHT_SCALE, "1.0"); + TAG_LOGI(AAFwkTag::APPMGR, "current fontSizeScale is: %{public}s, fontWeightScale is: %{public}s", + fontSizeScale.c_str(), fontWeightScale.c_str()); + configuration_->AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_FONT_SIZE_SCALE, fontSizeScale); + configuration_->AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_FONT_WEIGHT_SCALE, fontWeightScale); } std::shared_ptr AppMgrServiceInner::GetConfiguration() @@ -4295,7 +4418,7 @@ int AppMgrServiceInner::PreStartNWebSpawnProcess(const pid_t hostPid) } int AppMgrServiceInner::StartRenderProcess(const pid_t hostPid, const std::string &renderParam, - int32_t ipcFd, int32_t sharedFd, int32_t crashFd, pid_t &renderPid) + int32_t ipcFd, int32_t sharedFd, int32_t crashFd, pid_t &renderPid, bool isGPU) { TAG_LOGI(AAFwkTag::APPMGR, "start render process, hostPid:%{public}d", hostPid); if (hostPid <= 0 || renderParam.empty() || ipcFd <= 0 || sharedFd <= 0 || @@ -4318,7 +4441,7 @@ int AppMgrServiceInner::StartRenderProcess(const pid_t hostPid, const std::strin } auto renderRecordMap = appRecord->GetRenderRecordMap(); - if (!renderRecordMap.empty() && !AAFwk::AppUtils::GetInstance().IsUseMultiRenderProcess()) { + if (!isGPU && !renderRecordMap.empty() && !AAFwk::AppUtils::GetInstance().IsUseMultiRenderProcess()) { for (auto iter : renderRecordMap) { if (iter.second != nullptr) { renderPid = iter.second->GetPid(); @@ -4335,10 +4458,11 @@ int AppMgrServiceInner::StartRenderProcess(const pid_t hostPid, const std::strin } } } - + appRecord->SetIsGPU(isGPU); + int32_t childNumLimit = appRecord->GetIsGPU() ? PHONE_MAX_RENDER_PROCESS_NUM + 1 : PHONE_MAX_RENDER_PROCESS_NUM; // The phone device allows a maximum of 40 render processes to be created. if (AAFwk::AppUtils::GetInstance().IsLimitMaximumOfRenderProcess() && - renderRecordMap.size() >= PHONE_MAX_RENDER_PROCESS_NUM) { + renderRecordMap.size() >= static_cast(childNumLimit)) { TAG_LOGE(AAFwkTag::APPMGR, "Reaching the maximum render process limitation, hostPid:%{public}d", hostPid); return ERR_REACHING_MAXIMUM_RENDER_PROCESS_LIMITATION; } @@ -4349,7 +4473,7 @@ int AppMgrServiceInner::StartRenderProcess(const pid_t hostPid, const std::strin return ERR_INVALID_VALUE; } - return StartRenderProcessImpl(renderRecord, appRecord, renderPid); + return StartRenderProcessImpl(renderRecord, appRecord, renderPid, isGPU); } void AppMgrServiceInner::AttachRenderProcess(const pid_t pid, const sptr &scheduler) @@ -4392,9 +4516,26 @@ void AppMgrServiceInner::AttachRenderProcess(const pid_t pid, const sptrGetBrowserHost() != nullptr) { + TAG_LOGD(AAFwkTag::APPMGR, "GPU has host remote object"); + } scheduler->NotifyBrowserFd(renderRecord->GetIpcFd(), renderRecord->GetSharedFd(), - renderRecord->GetCrashFd()); + renderRecord->GetCrashFd(), + appRecord->GetBrowserHost()); +} + +void AppMgrServiceInner::SaveBrowserChannel(const pid_t hostPid, sptr browser) +{ + std::lock_guard lock(browserHostLock_); + TAG_LOGD(AAFwkTag::APPMGR, "save browser channel."); + auto appRecord = GetAppRunningRecordByPid(hostPid); + if (!appRecord) { + TAG_LOGE(AAFwkTag::APPMGR, "save browser host no such appRecord, pid:%{public}d", + hostPid); + return; + } + appRecord->SetBrowserHost(browser); } bool AppMgrServiceInner::GenerateRenderUid(int32_t &renderUid) @@ -4438,7 +4579,7 @@ bool AppMgrServiceInner::GenerateRenderUid(int32_t &renderUid) } int AppMgrServiceInner::StartRenderProcessImpl(const std::shared_ptr &renderRecord, - const std::shared_ptr appRecord, pid_t &renderPid) + const std::shared_ptr appRecord, pid_t &renderPid, bool isGPU) { if (!renderRecord || !appRecord) { TAG_LOGE(AAFwkTag::APPMGR, "renderRecord or appRecord is nullptr."); @@ -4461,6 +4602,13 @@ int AppMgrServiceInner::StartRenderProcessImpl(const std::shared_ptrGetRenderParam(); startMsg.uid = renderUid; startMsg.gid = renderUid; + if (isGPU) { + startMsg.procName += GPU_PROCESS_NAME; + startMsg.processType = GPU_PROCESS_TYPE; + } else { + startMsg.procName += RENDER_PROCESS_NAME; + startMsg.processType = RENDER_PROCESS_TYPE; + } startMsg.code = 0; // 0: DEFAULT pid_t pid = 0; ErrCode errCode = nwebSpawnClient->StartProcess(startMsg, pid); @@ -4473,6 +4621,9 @@ int AppMgrServiceInner::StartRenderProcessImpl(const std::shared_ptrSetPid(pid); renderRecord->SetUid(renderUid); + if (isGPU) { + renderRecord->SetProcessType(ProcessType::GPU); + } appRecord->AddRenderRecord(renderRecord); TAG_LOGI(AAFwkTag::APPMGR, "start render process success, hostPid:%{public}d, hostUid:%{public}d, pid:%{public}d, uid:%{public}d", @@ -4875,6 +5026,11 @@ int32_t AppMgrServiceInner::NotifyAppFault(const FaultData &faultData) TAG_LOGE(AAFwkTag::APPMGR, "no such appRecord"); return ERR_INVALID_VALUE; } + if (appRecord->GetState() == ApplicationState::APP_STATE_TERMINATED || + appRecord->GetState() == ApplicationState::APP_STATE_END) { + TAG_LOGE(AAFwkTag::APPMGR, "Appfreeze detect end."); + return ERR_OK; + } std::string bundleName = appRecord->GetBundleName(); if (faultData.faultType == FaultDataType::APP_FREEZE) { @@ -5009,7 +5165,7 @@ int32_t AppMgrServiceInner::NotifyAppFaultBySA(const AppFaultDataBySA &faultData transformedFaultData.timeoutMarkers = "notifyFault:" + transformedFaultData.errorObject.name + std::to_string(pid) + "-" + std::to_string(SystemTimeMillisecond()); } - const int64_t timeout = 11000; + const int64_t timeout = 1000; if (faultData.faultType == FaultDataType::APP_FREEZE) { if (!AppExecFwk::AppfreezeManager::GetInstance()->IsHandleAppfreeze(bundleName) || record->IsDebugging()) { return ERR_OK; @@ -5897,6 +6053,7 @@ int32_t AppMgrServiceInner::GetChildProcessInfo(const std::shared_ptrGetPid(); info.hostPid = childProcessRecord->GetHostPid(); info.uid = childProcessRecord->GetUid(); + info.processType = childProcessRecord->GetProcessType(); info.bundleName = appRecord->GetBundleName(); info.processName = childProcessRecord->GetProcessName(); info.srcEntry = childProcessRecord->GetSrcEntry(); @@ -5945,7 +6102,12 @@ void AppMgrServiceInner::AttachChildProcess(const pid_t pid, const sptrSetDeathRecipient(appDeathRecipient); childRecord->RegisterDeathRecipient(); - childScheduler->ScheduleLoadJs(); + if (childRecord->GetProcessType() != CHILD_PROCESS_TYPE_NATIVE) { + childScheduler->ScheduleLoadJs(); + } else { + childScheduler->ScheduleRunNativeProc(childRecord->GetMainProcessCallback()); + childRecord->ClearMainProcessCallback(); + } } void AppMgrServiceInner::OnChildProcessRemoteDied(const wptr &remote) @@ -6271,7 +6433,7 @@ int32_t AppMgrServiceInner::UnregisterRenderStateObserver(const sptr::GetInstance()->UnregisterRenderStateObserver(observer); } -void AppMgrServiceInner::SetAppAssertionPauseState(int32_t pid, bool flag) +void AppMgrServiceInner::SetAppAssertionPauseState(bool flag) { HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); TAG_LOGD(AAFwkTag::APPMGR, "Called."); @@ -6284,14 +6446,10 @@ void AppMgrServiceInner::SetAppAssertionPauseState(int32_t pid, bool flag) return; } - auto callerUid = IPCSkeleton::GetCallingUid(); - if (callerUid != FOUNDATION_UID) { - TAG_LOGE(AAFwkTag::APPMGR, "Caller is not foundation."); - return; - } - auto appRecord = GetAppRunningRecordByPid(pid); + auto callerPid = IPCSkeleton::GetCallingRealPid(); + auto appRecord = GetAppRunningRecordByPid(callerPid); if (appRecord == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "No such appRecord pid is %{public}d.", pid); + TAG_LOGE(AAFwkTag::APPMGR, "No such appRecord pid is %{public}d.", callerPid); return; } appRecord->SetAssertionPauseFlag(flag); @@ -6540,5 +6698,48 @@ void AppMgrServiceInner::OnAppCacheStateChanged(const std::shared_ptr::GetInstance()->OnAppCacheStateChanged(appRecord); } + +int32_t AppMgrServiceInner::StartNativeChildProcess(const pid_t hostPid, const std::string &libName, + int32_t childProcessCount, const sptr &callback) +{ + TAG_LOGI(AAFwkTag::APPMGR, "StartNativeChildProcess, hostPid:%{public}d", hostPid); + if (hostPid <= 0 || libName.empty() || !callback) { + TAG_LOGE(AAFwkTag::APPMGR, "Invalid param: hostPid:%{public}d libName:%{private}s", + hostPid, libName.c_str()); + return ERR_INVALID_VALUE; + } + + if (!AAFwk::AppUtils::GetInstance().IsSupportNativeChildProcess()) { + TAG_LOGE(AAFwkTag::APPMGR, "Unsupport native child process"); + return ERR_INVALID_OPERATION; + } + + int32_t errCode = StartChildProcessPreCheck(hostPid); + if (errCode != ERR_OK) { + return errCode; + } + + auto appRecord = GetAppRunningRecordByPid(hostPid); + if (!appRecord) { + TAG_LOGI(AAFwkTag::APPMGR, "Get app runnning record(hostPid:%{public}d) failed.", hostPid); + return ERR_INVALID_OPERATION; + } + + auto childRecordMap = appRecord->GetChildProcessRecordMap(); + auto itNativeChildInfo = find_if(childRecordMap.begin(), childRecordMap.end(), [] (const auto &pair) -> bool { + return pair.second->GetProcessType() == CHILD_PROCESS_TYPE_NATIVE; + }); + + if (itNativeChildInfo != childRecordMap.end()) { + TAG_LOGI(AAFwkTag::APPMGR, "Native child process still alive(hostPid:%{public}d childPid:%{public}d)", + hostPid, itNativeChildInfo->second->GetPid()); + return ERR_OVERFLOW; + } + + pid_t dummyChildPid = 0; + auto nativeChildRecord = ChildProcessRecord::CreateNativeChildProcessRecord( + hostPid, libName, appRecord, callback, childProcessCount, false); + return StartChildProcessImpl(nativeChildRecord, appRecord, dummyChildPid); +} } // namespace AppExecFwk -} // namespace OHOS +} // namespace OHOS \ No newline at end of file diff --git a/services/appmgr/src/app_running_manager.cpp b/services/appmgr/src/app_running_manager.cpp index 008ee29c3e..258ddac97b 100644 --- a/services/appmgr/src/app_running_manager.cpp +++ b/services/appmgr/src/app_running_manager.cpp @@ -36,6 +36,7 @@ #include "suspend_manager_client.h" #endif #include "app_mgr_service_dump_error_code.h" +#include "window_visibility_info.h" namespace OHOS { namespace AppExecFwk { @@ -79,6 +80,7 @@ std::shared_ptr AppRunningManager::CreateAppRunningRecord( processName.c_str(), isStageBasedModel, recordId); appRecord->SetStageModelState(isStageBasedModel); + appRecord->SetSingleton(bundleInfo.singleton); appRecord->SetSignCode(signCode); appRecord->SetJointUserId(bundleInfo.jointUserId); std::lock_guard guard(runningRecordMapMutex_); diff --git a/services/appmgr/src/app_running_record.cpp b/services/appmgr/src/app_running_record.cpp index 01d7271f2d..2af04101b8 100644 --- a/services/appmgr/src/app_running_record.cpp +++ b/services/appmgr/src/app_running_record.cpp @@ -24,15 +24,16 @@ #include "app_mgr_service_const.h" #include "app_mgr_service_dump_error_code.h" #include "cache_process_manager.h" +#include "window_visibility_info.h" namespace OHOS { namespace AppExecFwk { namespace { -static constexpr int64_t NANOSECONDS = 1000000000; // NANOSECONDS mean 10^9 nano second -static constexpr int64_t MICROSECONDS = 1000000; // MICROSECONDS mean 10^6 millias second +constexpr int64_t NANOSECONDS = 1000000000; // NANOSECONDS mean 10^9 nano second +constexpr int64_t MICROSECONDS = 1000000; // MICROSECONDS mean 10^6 millias second constexpr int32_t MAX_RESTART_COUNT = 3; constexpr int32_t RESTART_INTERVAL_TIME = 120000; -const std::string LAUNCHER_NAME = "com.ohos.sceneboard"; +constexpr const char* LAUNCHER_NAME = "com.ohos.sceneboard"; } int64_t AppRunningRecord::appEventId_ = 0; @@ -178,6 +179,11 @@ void RenderRecord::RegisterDeathRecipient() } } +void RenderRecord::SetProcessType(ProcessType type) +{ + processType_ = type; +} + void RenderRecord::SetState(int32_t state) { state_ = state; @@ -198,6 +204,7 @@ AppRunningRecord::AppRunningRecord( isLauncherApp_ = info->isLauncherApp; mainAppName_ = info->name; } + priorityObject_ = std::make_shared(); struct timespec t; t.tv_sec = 0; @@ -625,6 +632,19 @@ void AppRunningRecord::ScheduleForegroundRunning() void AppRunningRecord::ScheduleBackgroundRunning() { + int32_t recordId = GetRecordId(); + auto serviceInner = appMgrServiceInner_; + auto appbackgroundtask = [recordId, serviceInner]() { + auto serviceInnerObj = serviceInner.lock(); + if (serviceInnerObj == nullptr) { + TAG_LOGW(AAFwkTag::APPMGR, "APPManager is invalid"); + return; + } + TAG_LOGE(AAFwkTag::APPMGR, "APPManager move to background timeout"); + serviceInnerObj->ApplicationBackgrounded(recordId); + }; + PostTask("appbackground_" + std::to_string(recordId), AMSEventHandler::BACKGROUND_APPLICATION_TIMEOUT, + appbackgroundtask); if (appLifeCycleDeal_) { appLifeCycleDeal_->ScheduleBackgroundRunning(); } @@ -1189,10 +1209,6 @@ void AppRunningRecord::SetAppDeathRecipient(const sptr &appDe std::shared_ptr AppRunningRecord::GetPriorityObject() { - if (!priorityObject_) { - priorityObject_ = std::make_shared(); - } - return priorityObject_; } @@ -2214,5 +2230,27 @@ SupportProcessCacheState AppRunningRecord::GetSupportProcessCacheState() { return procCacheSupportState_; } + +void AppRunningRecord::SetBrowserHost(sptr browser) +{ + browserHost_ = browser; +} + +sptr AppRunningRecord::GetBrowserHost() +{ + return browserHost_; +} + +void AppRunningRecord::SetIsGPU(bool gpu) +{ + if (gpu) { + isGPU_ = gpu; + } +} + +bool AppRunningRecord::GetIsGPU() +{ + return isGPU_; +} } // namespace AppExecFwk } // namespace OHOS diff --git a/services/appmgr/src/app_spawn_client.cpp b/services/appmgr/src/app_spawn_client.cpp index 8257705653..b37be945c1 100644 --- a/services/appmgr/src/app_spawn_client.cpp +++ b/services/appmgr/src/app_spawn_client.cpp @@ -37,6 +37,7 @@ namespace { 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"; } AppSpawnClient::AppSpawnClient(bool isNWebSpawn) { @@ -129,6 +130,15 @@ static std::string DumpAppEnvToJson(const std::map &ap return appEnvJson.dump(); } +static std::string DumpExtensionSandboxDirsToJson(const std::map &extensionSandboxDirs) +{ + nlohmann::json extensionSandboxDirsJson; + for (auto &[userId, sandboxDir] : extensionSandboxDirs) { + extensionSandboxDirsJson[userId] = sandboxDir; + } + return extensionSandboxDirsJson.dump(); +} + int32_t AppSpawnClient::SetDacInfo(const AppSpawnStartMsg &startMsg, AppSpawnReqMsgHandle reqHandle) { int32_t ret = 0; @@ -162,6 +172,15 @@ int32_t AppSpawnClient::SetMountPermission(const AppSpawnStartMsg &startMsg, App } } + if (!startMsg.processType.empty()) { + ret = AppSpawnReqMsgAddExtInfo(reqHandle, MSG_EXT_NAME_PROCESS_TYPE, + reinterpret_cast(startMsg.processType.c_str()), startMsg.processType.size()); + if (ret) { + TAG_LOGE(AAFwkTag::APPMGR, "AppSpawnReqMsgAddExtInfo failed, ret: %{public}d", ret); + return ret; + } + } + return ret; } @@ -187,9 +206,35 @@ int32_t AppSpawnClient::SetStartFlags(const AppSpawnStartMsg &startMsg, AppSpawn int32_t AppSpawnClient::SetAtomicServiceFlag(const AppSpawnStartMsg &startMsg, AppSpawnReqMsgHandle reqHandle) { int32_t ret = 0; - if (startMsg.atomicServiceFlag && - (ret = AppSpawnReqMsgSetAppFlag(reqHandle, APP_FLAGS_ATOMIC_SERVICE))) { - HILOG_ERROR("AppSpawnReqMsgSetAppFlag failed, ret: %{public}d", ret); + if (startMsg.atomicServiceFlag) { + ret = AppSpawnReqMsgSetAppFlag(reqHandle, APP_FLAGS_ATOMIC_SERVICE); + if (ret) { + TAG_LOGE(AAFwkTag::APPMGR, "AppSpawnReqMsgSetAppFlag failed, ret: %{public}d", ret); + } + } + return ret; +} + +int32_t AppSpawnClient::SetStrictMode(const AppSpawnStartMsg &startMsg, AppSpawnReqMsgHandle reqHandle) +{ + int32_t ret = 0; + if (startMsg.strictMode) { + ret = AppSpawnReqMsgSetAppFlag(reqHandle, APP_FLAGS_ISOLATED_SANDBOX); + if (ret) { + TAG_LOGE(AAFwkTag::APPMGR, "AppSpawnReqMsgSetAppFlag failed, ret: %{public}d", ret); + } + } + return ret; +} + +int32_t AppSpawnClient::SetAppExtension(const AppSpawnStartMsg &startMsg, AppSpawnReqMsgHandle reqHandle) +{ + int32_t ret = 0; + if (startMsg.isolatedExtension) { + ret = AppSpawnReqMsgSetAppFlag(reqHandle, APP_FLAGS_EXTENSION_SANDBOX); + if (ret) { + TAG_LOGE(AAFwkTag::APPMGR, "AppSpawnReqMsgSetAppFlag failed, ret: %{public}d", ret); + } } return ret; } @@ -235,18 +280,47 @@ int32_t AppSpawnClient::AppspawnSetExtMsg(const AppSpawnStartMsg &startMsg, AppS return ret; } } - if (!startMsg.atomicAccount.empty() && - (ret = AppSpawnReqMsgAddExtInfo(reqHandle, MSG_EXT_NAME_ACCOUNT_ID, - reinterpret_cast(startMsg.atomicAccount.c_str()), startMsg.atomicAccount.size()))) { - HILOG_ERROR("AppSpawnReqMsgAddExtInfo failed, ret: %{public}d", ret); - return ret; + + if (!startMsg.atomicAccount.empty()) { + ret = AppSpawnReqMsgAddExtInfo(reqHandle, MSG_EXT_NAME_ACCOUNT_ID, + reinterpret_cast(startMsg.atomicAccount.c_str()), startMsg.atomicAccount.size()); + if (ret) { + TAG_LOGE(AAFwkTag::APPMGR, "AppSpawnReqMsgAddExtInfo failed, ret: %{public}d", ret); + return ret; + } } - if (!startMsg.provisionType.empty() && - (ret = AppSpawnReqMsgAddStringInfo(reqHandle, MSG_EXT_NAME_PROVISION_TYPE, startMsg.provisionType.c_str()))) { - HILOG_ERROR("SetExtraProvisionType failed, ret: %{public}d", ret); + return AppspawnSetExtMsgMore(startMsg, reqHandle); +} + +int32_t AppSpawnClient::AppspawnSetExtMsgMore(const AppSpawnStartMsg &startMsg, AppSpawnReqMsgHandle reqHandle) +{ + int32_t ret = 0; + + if (!startMsg.provisionType.empty()) { + ret = AppSpawnReqMsgAddStringInfo(reqHandle, MSG_EXT_NAME_PROVISION_TYPE, startMsg.provisionType.c_str()); + if (ret) { + TAG_LOGE(AAFwkTag::APPMGR, "SetExtraProvisionType failed, ret: %{public}d", ret); + return ret; + } + } + + if (!startMsg.extensionSandboxPath.empty()) { + ret = AppSpawnReqMsgAddStringInfo(reqHandle, MSG_EXT_NAME_APP_EXTENSION, + startMsg.extensionSandboxPath.c_str()); + if (ret) { + TAG_LOGE(AAFwkTag::APPMGR, "SetExtraExtensionSandboxDirs failed, ret: %{public}d", ret); + return ret; + } + } + + std::string maxChildProcessStr = std::to_string(startMsg.maxChildProcess); + if ((ret = AppSpawnReqMsgAddExtInfo(reqHandle, MAX_CHILD_PROCESS.c_str(), + reinterpret_cast(maxChildProcessStr.c_str()), maxChildProcessStr.size()))) { + TAG_LOGE(AAFwkTag::APPMGR, "Send maxChildProcess failed, ret: %{public}d", ret); return ret; } + TAG_LOGI(AAFwkTag::APPMGR, "Send maxChildProcess %{public}s success.", maxChildProcessStr.c_str()); return ret; } @@ -302,7 +376,14 @@ int32_t AppSpawnClient::AppspawnCreateDefaultMsg(const AppSpawnStartMsg &startMs if (AppspawnSetExtMsg(startMsg, reqHandle)) { break; } - + if ((ret = SetStrictMode(startMsg, reqHandle))) { + TAG_LOGE(AAFwkTag::APPMGR, "SetStrictMode failed, ret: %{public}d", ret); + break; + } + if ((ret = SetAppExtension(startMsg, reqHandle))) { + TAG_LOGE(AAFwkTag::APPMGR, "SetAppExtension failed, ret: %{public}d", ret); + break; + } return ret; } while (0); diff --git a/services/appmgr/src/app_spawn_msg_wrapper.cpp b/services/appmgr/src/app_spawn_msg_wrapper.cpp index 7c3bcd3be4..fb7c74b7e6 100644 --- a/services/appmgr/src/app_spawn_msg_wrapper.cpp +++ b/services/appmgr/src/app_spawn_msg_wrapper.cpp @@ -170,7 +170,7 @@ void AppSpawnMsgWrapper::BuildExtraInfo(const AppSpawnStartMsg &startMsg) if (!startMsg.appEnv.empty()) { auto appEnvStr = DumpAppEnvToJson(startMsg.appEnv); - TAG_LOGI(AAFwkTag::APPMGR, "AppEnv: %{public}s", appEnvStr.c_str()); + TAG_LOGD(AAFwkTag::APPMGR, "AppEnv: %{public}s", appEnvStr.c_str()); extraInfoStr_ += APP_ENV_TYPE + appEnvStr + APP_ENV_TYPE; } diff --git a/services/appmgr/src/app_state_observer_manager.cpp b/services/appmgr/src/app_state_observer_manager.cpp index 684a7179c2..7f4ddcf5fa 100644 --- a/services/appmgr/src/app_state_observer_manager.cpp +++ b/services/appmgr/src/app_state_observer_manager.cpp @@ -809,7 +809,7 @@ AbilityforegroundObserverSet AppStateObserverManager::GetAbilityforegroundObserv void AppStateObserverManager::OnObserverDied(const wptr &remote, const ObserverType &type) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); - TAG_LOGI(AAFwkTag::APPMGR, "OnObserverDied"); + TAG_LOGD(AAFwkTag::APPMGR, "OnObserverDied"); auto object = remote.promote(); if (object == nullptr) { TAG_LOGE(AAFwkTag::APPMGR, "observer nullptr."); diff --git a/services/appmgr/src/child_process_record.cpp b/services/appmgr/src/child_process_record.cpp index 2bf2e9f341..a5a3b9d828 100644 --- a/services/appmgr/src/child_process_record.cpp +++ b/services/appmgr/src/child_process_record.cpp @@ -29,6 +29,15 @@ ChildProcessRecord::ChildProcessRecord(pid_t hostPid, const std::string &srcEntr MakeProcessName(hostRecord); } +ChildProcessRecord::ChildProcessRecord(pid_t hostPid, const std::string &libName, + const std::shared_ptr hostRecord, const sptr &mainProcessCb, + int32_t childProcessCount, bool isStartWithDebug) + : hostPid_(hostPid), childProcessCount_(childProcessCount), childProcessType_(CHILD_PROCESS_TYPE_NATIVE), + srcEntry_(libName), hostRecord_(hostRecord), mainProcessCb_(mainProcessCb), isStartWithDebug_(isStartWithDebug) +{ + MakeProcessName(hostRecord); +} + ChildProcessRecord::~ChildProcessRecord() { TAG_LOGD(AAFwkTag::APPMGR, "Called."); @@ -46,6 +55,19 @@ std::shared_ptr ChildProcessRecord::CreateChildProcessRecord return std::make_shared(hostPid, srcEntry, hostRecord, childProcessCount, isStartWithDebug); } +std::shared_ptr ChildProcessRecord::CreateNativeChildProcessRecord( + pid_t hostPid, const std::string &libName, const std::shared_ptr hostRecord, + const sptr &mainProcessCb, int32_t childProcessCount, bool isStartWithDebug) +{ + TAG_LOGD(AAFwkTag::APPMGR, "hostPid: %{public}d, libName: %{public}s", hostPid, libName.c_str()); + if (hostPid <= 0 || libName.empty() || !hostRecord || !mainProcessCb) { + TAG_LOGE(AAFwkTag::APPMGR, "Invalid parameter."); + return nullptr; + } + return std::make_shared(hostPid, libName, hostRecord, mainProcessCb, + childProcessCount, isStartWithDebug); +} + void ChildProcessRecord::SetPid(pid_t pid) { pid_ = pid; @@ -148,6 +170,10 @@ void ChildProcessRecord::MakeProcessName(const std::shared_ptr std::string filename = std::filesystem::path(srcEntry_).stem(); if (!filename.empty()) { processName_.append(":"); + if (childProcessType_ == CHILD_PROCESS_TYPE_NATIVE) { + processName_.append("Native_"); + } + processName_.append(filename); } processName_.append(std::to_string(childProcessCount_)); @@ -158,5 +184,21 @@ bool ChildProcessRecord::isStartWithDebug() { return isStartWithDebug_; } + +int32_t ChildProcessRecord::GetProcessType() const +{ + return childProcessType_; +} + +sptr ChildProcessRecord::GetMainProcessCallback() const +{ + return mainProcessCb_; +} + +void ChildProcessRecord::ClearMainProcessCallback() +{ + mainProcessCb_.clear(); +} + } // namespace AppExecFwk } // namespace OHOS diff --git a/services/appmgr/src/module_running_record.cpp b/services/appmgr/src/module_running_record.cpp index 8fa674b59f..face85c1ee 100644 --- a/services/appmgr/src/module_running_record.cpp +++ b/services/appmgr/src/module_running_record.cpp @@ -248,7 +248,7 @@ void ModuleRunningRecord::TerminateAbility(const std::shared_ptr::GetInstance()->QueryEnableProcessCache(); + bool isCachedProcess = DelayedSingleton::GetInstance()->IsAppShouldCache(appRecord); appLifeCycleDeal_->ScheduleCleanAbility(token, isCachedProcess); } else { TAG_LOGW(AAFwkTag::APPMGR, "appLifeCycleDeal_ is null"); diff --git a/services/common/BUILD.gn b/services/common/BUILD.gn index 42c58bcd42..451de687bc 100644 --- a/services/common/BUILD.gn +++ b/services/common/BUILD.gn @@ -30,6 +30,7 @@ config("common_config") { "${ability_runtime_innerkits_path}/*", "${ability_runtime_napi_path}/*", "${ability_runtime_native_path}/ability/native/*", + "${ability_runtime_native_path}/child_process/*", "${ability_runtime_path}/frameworks/simulator/ability_simulator/*", "${ability_runtime_path}/tools/aa/*", "${ability_runtime_services_path}/common/*", diff --git a/services/common/include/app_utils.h b/services/common/include/app_utils.h index b1203d9394..509ab97bbf 100644 --- a/services/common/include/app_utils.h +++ b/services/common/include/app_utils.h @@ -47,6 +47,7 @@ public: bool IsStartOptionsWithProcessOptions(); bool EnableMoveUIAbilityToBackgroundApi(); bool IsLaunchEmbededUIAbility(); + bool IsSupportNativeChildProcess(); private: AppUtils(); @@ -65,6 +66,7 @@ private: volatile DeviceConfiguration isStartOptionsWithProcessOptions_ = {false, false}; volatile DeviceConfiguration enableMoveUIAbilityToBackgroundApi_ = {false, true}; volatile DeviceConfiguration isLaunchEmbededUIAbility_ = {false, false}; + volatile DeviceConfiguration isSupportNativeChildProcess_ = {false, false}; DISALLOW_COPY_AND_MOVE(AppUtils); }; } // namespace AAFwk diff --git a/services/common/include/event_report.h b/services/common/include/event_report.h index 1589826d96..50dbc9c52c 100644 --- a/services/common/include/event_report.h +++ b/services/common/include/event_report.h @@ -62,13 +62,11 @@ enum class EventName { STOP_EXTENSION_ERROR, CONNECT_SERVICE_ERROR, DISCONNECT_SERVICE_ERROR, - CLOSE_UI_ABILITY_BY_SCB_ERROR, // ability behavior event START_ABILITY, TERMINATE_ABILITY, CLOSE_ABILITY, - CLOSE_UI_ABILITY_BY_SCB, ABILITY_ONFOREGROUND, ABILITY_ONBACKGROUND, ABILITY_ONACTIVE, diff --git a/services/common/src/app_utils.cpp b/services/common/src/app_utils.cpp index 7d47ade7dd..803ccdda86 100644 --- a/services/common/src/app_utils.cpp +++ b/services/common/src/app_utils.cpp @@ -41,7 +41,9 @@ const std::string START_OPTIONS_WITH_PROCESS_OPTION = "persist.sys.abilityms.sta const std::string MOVE_UI_ABILITY_TO_BACKGROUND_API_ENABLE = "persist.sys.abilityms.move_ui_ability_to_background_api_enable"; const std::string LAUNCH_EMBEDED_UI_ABILITY = "const.abilityms.launch_embeded_ui_ability"; +const std::string SUPPROT_NATIVE_CHILD_PROCESS = "persist.sys.abilityms.start_native_child_process"; } + AppUtils::~AppUtils() {} AppUtils::AppUtils() @@ -81,7 +83,7 @@ bool AppUtils::IsInheritWindowSplitScreenMode() isInheritWindowSplitScreenMode_.value = system::GetBoolParameter(INHERIT_WINDOW_SPLIT_SCREEN_MODE, true); isInheritWindowSplitScreenMode_.isLoaded = true; } - TAG_LOGI(AAFwkTag::DEFAULT, "isInheritWindowSplitScreenMode is %{public}d", isInheritWindowSplitScreenMode_.value); + TAG_LOGD(AAFwkTag::DEFAULT, "isInheritWindowSplitScreenMode is %{public}d", isInheritWindowSplitScreenMode_.value); return isInheritWindowSplitScreenMode_.value; } @@ -101,7 +103,7 @@ int32_t AppUtils::GetTimeoutUnitTimeRatio() timeoutUnitTimeRatio_.value = system::GetIntParameter(TIMEOUT_UNIT_TIME_RATIO, 1); timeoutUnitTimeRatio_.isLoaded = true; } - TAG_LOGI(AAFwkTag::DEFAULT, "timeoutUnitTimeRatio is %{public}d", timeoutUnitTimeRatio_.value); + TAG_LOGD(AAFwkTag::DEFAULT, "timeoutUnitTimeRatio is %{public}d", timeoutUnitTimeRatio_.value); return timeoutUnitTimeRatio_.value; } @@ -171,7 +173,7 @@ bool AppUtils::IsMultiProcessModel() isMultiProcessModel_.value = system::GetBoolParameter(MULTI_PROCESS_MODEL, false); isMultiProcessModel_.isLoaded = true; } - TAG_LOGI(AAFwkTag::DEFAULT, "isMultiProcessModel_ is %{public}d", isMultiProcessModel_.value); + TAG_LOGD(AAFwkTag::DEFAULT, "isMultiProcessModel_ is %{public}d", isMultiProcessModel_.value); return isMultiProcessModel_.value; } @@ -207,5 +209,16 @@ bool AppUtils::IsLaunchEmbededUIAbility() TAG_LOGI(AAFwkTag::DEFAULT, "isLaunchEmbededUIAbility_ is %{public}d", isLaunchEmbededUIAbility_.value); return isLaunchEmbededUIAbility_.value; } + +bool AppUtils::IsSupportNativeChildProcess() +{ + if (!isSupportNativeChildProcess_.isLoaded) { + isSupportNativeChildProcess_.value = system::GetBoolParameter(SUPPROT_NATIVE_CHILD_PROCESS, false); + isSupportNativeChildProcess_.isLoaded = true; + } + TAG_LOGI(AAFwkTag::DEFAULT, "isSupportNativeChildProcess_ is %{public}d", isSupportNativeChildProcess_.value); + return isSupportNativeChildProcess_.value; +} + } // namespace AAFwk } // namespace OHOS diff --git a/services/common/src/permission_verification.cpp b/services/common/src/permission_verification.cpp index 3ee4a83fb4..c851f29542 100644 --- a/services/common/src/permission_verification.cpp +++ b/services/common/src/permission_verification.cpp @@ -400,7 +400,7 @@ bool PermissionVerification::JudgeAssociatedWakeUp(const uint32_t accessTokenId, int PermissionVerification::JudgeInvisibleAndBackground(const VerificationInfo &verificationInfo) const { uint32_t specifyTokenId = verificationInfo.specifyTokenId; - TAG_LOGI(AAFwkTag::DEFAULT, "specifyTokenId = %{public}u", specifyTokenId); + TAG_LOGD(AAFwkTag::DEFAULT, "specifyTokenId = %{public}u", specifyTokenId); if (specifyTokenId == 0 && IPCSkeleton::GetCallingUid() != BROKER_UID && SupportSystemAbilityPermission::IsSupportSaCallPermission() && IsSACall()) { TAG_LOGD(AAFwkTag::DEFAULT, "Support SA call"); diff --git a/services/dialog_ui/ams_system_dialog/AppScope/app.json b/services/dialog_ui/ams_system_dialog/AppScope/app.json index 03e1745a64..1a0d7f436c 100644 --- a/services/dialog_ui/ams_system_dialog/AppScope/app.json +++ b/services/dialog_ui/ams_system_dialog/AppScope/app.json @@ -2,7 +2,7 @@ "app": { "bundleName": "com.ohos.amsdialog", "vendor": "example", - "versionCode": 1000002, + "versionCode": 1000003, "versionName": "1.0.0", "icon": "$media:app_icon", "label": "$string:app_name", diff --git a/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ServiceExtAbility/SelectorExtensionAbility.ets b/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ServiceExtAbility/SelectorExtensionAbility.ets index 001c44426e..0fcc947b69 100644 --- a/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ServiceExtAbility/SelectorExtensionAbility.ets +++ b/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ServiceExtAbility/SelectorExtensionAbility.ets @@ -15,12 +15,17 @@ import UIExtensionAbility from '@ohos.app.ability.UIExtensionAbility' import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession' import Want from '@ohos.app.ability.Want' +import systemparameter from '@ohos.systemParameterEnhance'; +import dataPreferences from '@ohos.data.preferences'; const TAG = 'SelectorExtensionAbility'; export default class SelectorExtensionAbility extends UIExtensionAbility { onCreate() { console.info(TAG, 'SelectorExtensionAbility onCreate'); + globalThis.currentExtensionContext = this.context; + let options = {name:'dialogStore'}; + globalThis.preferences = dataPreferences.getPreferencesSync(this.context, options); } onSessionCreate(want: Want, session: UIExtensionContentSession) { @@ -29,8 +34,14 @@ export default class SelectorExtensionAbility extends UIExtensionAbility { "extensionAbility": this, "callerWant": want } as Record); - - session.loadContent("pages/PhonePage", storage); + 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); + } else { + session.loadContent("pages/PhonePage", storage); + } try { const bgColor: string = '#40FFFFFF'; } catch (e) { diff --git a/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ServiceExtAbility/SelectorServiceExtAbility.ts b/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ServiceExtAbility/SelectorServiceExtAbility.ts index a61719a267..981182fb84 100644 --- a/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ServiceExtAbility/SelectorServiceExtAbility.ts +++ b/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ServiceExtAbility/SelectorServiceExtAbility.ts @@ -22,6 +22,8 @@ import type image from '@ohos.multimedia.image'; import window from '@ohos.window'; import PositionUtils from '../utils/PositionUtils'; import deviceInfo from '@ohos.deviceInfo'; +import systemparameter from '@ohos.systemParameterEnhance'; +import dataPreferences from '@ohos.data.preferences'; const TAG = 'SelectorDialog_Service'; @@ -32,8 +34,12 @@ export default class SelectorServiceExtensionAbility extends extension { onCreate(want) { console.debug(TAG, 'onCreate, want: ' + JSON.stringify(want)); globalThis.selectExtensionContext = this.context; + globalThis.currentExtensionContext = this.context; + globalThis.ExtensionType = 'ServiceExtension'; globalThis.defaultAppManager = defaultAppManager; globalThis.bundleManager = bundleManager; + let options = {name:'dialogStore'}; + globalThis.preferences = dataPreferences.getPreferencesSync(this.context, options); } async getPhoneShowHapList() { @@ -218,10 +224,20 @@ export default class SelectorServiceExtensionAbility extends extension { } await win.moveTo(rect.left, rect.top); await win.resetSize(rect.width, rect.height); - if (globalThis.params.isDefaultSelector) { - await win.loadContent('pages/selectorPhoneDialog'); + if (systemparameter.getSync('persist.sys.abilityms.isdialogconfirmpermission', 'false') === 'false' && + globalThis.preferences.getSync('isdialogconfirmpermission', 'false') === 'false') { + if (globalThis.params.isDefaultSelector) { + globalThis.currentURL = 'pages/selectorPhoneDialog'; + } else { + globalThis.currentURL = 'pages/selectorPcDialog'; + } + await win.loadContent('pages/permissionConfirmDialog'); } else { - await win.loadContent('pages/selectorPcDialog'); + if (globalThis.params.isDefaultSelector) { + await win.loadContent('pages/selectorPhoneDialog'); + } else { + await win.loadContent('pages/selectorPcDialog'); + } } await win.setBackgroundColor('#00000000'); await win.show(); diff --git a/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ShareExtAbility/AssertFaultShareExtAbility.ts b/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ShareExtAbility/AssertFaultShareExtAbility.ts index 32505ff930..4e9a66694e 100644 --- a/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ShareExtAbility/AssertFaultShareExtAbility.ts +++ b/services/dialog_ui/ams_system_dialog/entry/src/main/ets/ShareExtAbility/AssertFaultShareExtAbility.ts @@ -22,6 +22,7 @@ import type UIExtensionContentSession from '@ohos.app.ability.UIExtensionContent const TAG = 'AssertFaultDialog_UIExtension'; const TEXT_DETAIL = 'assertFaultDialogDetail'; +const DEBUG_ASSERT_RESULT = 'assertResult'; export default class UiExtAbility extends UIExtensionAbility { storage: LocalStorage; @@ -44,7 +45,6 @@ export default class UiExtAbility extends UIExtensionAbility { this.storage = new LocalStorage( { 'session': session, - 'sessionId' : this.sessionId, 'textDetail' : want.parameters[TEXT_DETAIL] }); session.loadContent('pages/assertFaultDialog', this.storage); @@ -57,19 +57,18 @@ export default class UiExtAbility extends UIExtensionAbility { onSessionDestroy(session: UIExtensionContentSession): void { console.info(TAG, 'onSessionDestroy'); - console.info(TAG, `isUserAction: ${AppStorage.get('isUserAction')}`); - let isUserAction = AppStorage.get('isUserAction'); - if (isUserAction === undefined) { - let status = abilityManager.UserStatus.ASSERT_TERMINATE; - try { - abilityManager.notifyDebugAssertResult(this.sessionId, status).then(() => { - console.log(TAG, 'notifyDebugAssertResult success.'); - }).catch((err: BusinessError) => { - console.error(TAG, `notifyDebugAssertResult failed, error: ${JSON.stringify(err)}`); - }); - } catch (error) { - console.error(TAG, `try notifyDebugAssertResult failed, error: ${JSON.stringify(error)}`); - } + let assertResult = AppStorage.get(DEBUG_ASSERT_RESULT); + if (assertResult === undefined) { + assertResult = abilityManager.UserStatus.ASSERT_TERMINATE; + } + try { + abilityManager.notifyDebugAssertResult(this.sessionId, assertResult).then(() => { + console.log(TAG, 'notifyDebugAssertResult success.'); + }).catch((err: BusinessError) => { + console.error(TAG, `notifyDebugAssertResult failed, error: ${JSON.stringify(err)}`); + }); + } catch (error) { + console.error(TAG, `try notifyDebugAssertResult failed, error: ${JSON.stringify(error)}`); } } }; diff --git a/services/dialog_ui/ams_system_dialog/entry/src/main/ets/pages/assertFaultDialog.ets b/services/dialog_ui/ams_system_dialog/entry/src/main/ets/pages/assertFaultDialog.ets index 3fe5521908..c5bfb79cce 100644 --- a/services/dialog_ui/ams_system_dialog/entry/src/main/ets/pages/assertFaultDialog.ets +++ b/services/dialog_ui/ams_system_dialog/entry/src/main/ets/pages/assertFaultDialog.ets @@ -19,6 +19,7 @@ import type UIExtensionContentSession from '@ohos.app.ability.UIExtensionContent let storage = LocalStorage.GetShared(); const TAG: string = 'AssertFaultDialog_Page'; +const DEBUG_ASSERT_RESULT: string = 'assertResult'; @Entry(storage) @Component @@ -33,17 +34,11 @@ struct AssertFaultDialog { existApp() { console.info(TAG, 'Exist app called'); try { - let status = abilityManager.UserStatus.ASSERT_TERMINATE; - abilityManager.notifyDebugAssertResult(storage.get('sessionId'), status).then(() => { - console.log(TAG, 'notifyDebugAssertResult termination status success.'); - AppStorage.setOrCreate('isUserAction', true); - storage.get('session').terminateSelf().then(() => { - console.log(TAG, 'terminateSelf success.'); - }).catch((err: BusinessError) => { - console.error(TAG, `terminateSelf failed, error: ${JSON.stringify(err)}`); - }) + AppStorage.setOrCreate(DEBUG_ASSERT_RESULT, abilityManager.UserStatus.ASSERT_TERMINATE); + storage.get('session').terminateSelf().then(() => { + console.log(TAG, 'terminateSelf success.'); }).catch((err: BusinessError) => { - console.error(TAG, `notifyDebugAssertResult failed, error: ${JSON.stringify(err)}`); + console.error(TAG, `terminateSelf failed, error: ${JSON.stringify(err)}`); }) } catch (error) { console.error(TAG, `try notifyDebugAssertResult failed, error: ${JSON.stringify(error)}`); @@ -52,18 +47,12 @@ struct AssertFaultDialog { onContinueCall() { console.info(TAG, 'On continue called'); - let status = abilityManager.UserStatus.ASSERT_CONTINUE; try { - abilityManager.notifyDebugAssertResult(storage.get('sessionId'), status).then(() => { - console.log(TAG, 'notifyDebugAssertResult continue status success.'); - AppStorage.setOrCreate('isUserAction', true); - storage.get('session').terminateSelf().then(() => { - console.log(TAG, 'terminateSelf success.'); - }).catch((err: BusinessError) => { - console.error(TAG, `terminateSelf failed, error: ${JSON.stringify(err)}`); - }) + AppStorage.setOrCreate(DEBUG_ASSERT_RESULT, abilityManager.UserStatus.ASSERT_CONTINUE); + storage.get('session').terminateSelf().then(() => { + console.log(TAG, 'terminateSelf success.'); }).catch((err: BusinessError) => { - console.error(TAG, `notifyDebugAssertResult failed, error: ${JSON.stringify(err)}`); + console.error(TAG, `terminateSelf failed, error: ${JSON.stringify(err)}`); }) } catch (error) { console.error(TAG, `try notifyDebugAssertResult failed, error: ${JSON.stringify(error)}`); @@ -72,18 +61,12 @@ struct AssertFaultDialog { onRetryCall() { console.info(TAG, 'On retry called'); - let status = abilityManager.UserStatus.ASSERT_RETRY; try { - abilityManager.notifyDebugAssertResult(storage.get('sessionId'), status).then(() => { - console.log(TAG, 'notifyDebugAssertResult retry status success.'); - AppStorage.setOrCreate('isUserAction', true); - storage.get('session').terminateSelf().then(() => { - console.log(TAG, 'terminateSelf success.'); - }).catch((err: BusinessError) => { - console.error(TAG, `terminateSelf failed, error: ${JSON.stringify(err)}`); - }) + AppStorage.setOrCreate(DEBUG_ASSERT_RESULT, abilityManager.UserStatus.ASSERT_RETRY); + storage.get('session').terminateSelf().then(() => { + console.log(TAG, 'terminateSelf success.'); }).catch((err: BusinessError) => { - console.error(TAG, `notifyDebugAssertResult failed, error: ${JSON.stringify(err)}`); + console.error(TAG, `terminateSelf failed, error: ${JSON.stringify(err)}`); }) } catch (error) { console.error(TAG, `try notifyDebugAssertResult failed, error: ${JSON.stringify(error)}`); @@ -92,18 +75,12 @@ struct AssertFaultDialog { onTerminationCall() { console.info(TAG, 'On termination called'); - let status = abilityManager.UserStatus.ASSERT_TERMINATE; try { - abilityManager.notifyDebugAssertResult(storage.get('sessionId'), status).then(() => { - console.log(TAG, 'notifyDebugAssertResult termination status success.'); - AppStorage.setOrCreate('isUserAction', true); - storage.get('session').terminateSelf().then(() => { - console.log(TAG, 'terminateSelf success.'); - }).catch((err: BusinessError) => { - console.error(TAG, `terminateSelf failed, error: ${JSON.stringify(err)}`); - }) + AppStorage.setOrCreate(DEBUG_ASSERT_RESULT, abilityManager.UserStatus.ASSERT_TERMINATE); + storage.get('session').terminateSelf().then(() => { + console.log(TAG, 'terminateSelf success.'); }).catch((err: BusinessError) => { - console.error(TAG, `notifyDebugAssertResult failed, error: ${JSON.stringify(err)}`); + console.error(TAG, `terminateSelf failed, error: ${JSON.stringify(err)}`); }) } catch (error) { console.error(TAG, `try notifyDebugAssertResult failed, error: ${JSON.stringify(error)}`); diff --git a/services/dialog_ui/ams_system_dialog/entry/src/main/ets/pages/permissionConfirmDialog.ets b/services/dialog_ui/ams_system_dialog/entry/src/main/ets/pages/permissionConfirmDialog.ets new file mode 100644 index 0000000000..40f7c9ee35 --- /dev/null +++ b/services/dialog_ui/ams_system_dialog/entry/src/main/ets/pages/permissionConfirmDialog.ets @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2022 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 router from '@ohos.router' +import type UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession'; +import dataPreferences from '@ohos.data.preferences'; +interface TipBtn { + color:string +} +let storage = LocalStorage.GetShared(); +@Entry(storage) +@Component +struct PermissionConfirmDialog { + @State private btn: TipBtn = { color: '#FFFFFF' } + private TAG = 'permissionconfirm_Page' + + onCloseApp() { + console.info(this.TAG, 'click close app'); + if (globalThis.ExtensionType === 'ServiceExtension') { + globalThis.currentExtensionContext.terminateSelf(); + } else { + storage.get('session').terminateSelf(); + } + } + + onConfirmApp() { + console.info(this.TAG, 'click confirm app'); + globalThis.preferences.putSync('isdialogconfirmpermission', 'true') + globalThis.preferences.flush(); + router.replaceUrl({ + url: globalThis.currentURL, + }) + } + + build() { + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Text($r('app.string.message_title_permission_confirm')) + .fontSize(16) + .fontWeight(FontWeight.Medium) + .height('29%') + .textOverflow({overflow: TextOverflow.Ellipsis}) + .textAlign(TextAlign.Center) + } + Flex({ justifyContent: FlexAlign.Center }) { + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Text($r('app.string.message_confirm_permission')) + .fontSize('21fp') + .fontColor('#0A59F7') + .fontWeight(FontWeight.Regular) + .textAlign(TextAlign.Center) + } + .width(175) + .height(50) + .borderRadius(28) + .backgroundColor(this.btn.color) + .onClick(() => { + this.onConfirmApp(); + }) + }.margin({ top: 10}) + Flex({ justifyContent: FlexAlign.Center }) { + Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { + Text($r('app.string.message_cancel_permission')) + .fontSize('21fp') + .fontColor('#0A59F7') + .fontWeight(FontWeight.Regular) + .textAlign(TextAlign.Center) + } + .width(175) + .height(50) + .borderRadius(28) + .backgroundColor(this.btn.color) + .onClick(() => { + this.onCloseApp(); + }) + }.margin({ top: 10}) + } + .borderRadius(20) + .borderWidth(1) + .borderColor('#e9e9e9') + .backgroundColor('#FFFFFF') + } +} \ No newline at end of file diff --git a/services/dialog_ui/ams_system_dialog/entry/src/main/resources/base/element/string.json b/services/dialog_ui/ams_system_dialog/entry/src/main/resources/base/element/string.json index effea732c1..9fe4c646f4 100644 --- a/services/dialog_ui/ams_system_dialog/entry/src/main/resources/base/element/string.json +++ b/services/dialog_ui/ams_system_dialog/entry/src/main/resources/base/element/string.json @@ -91,6 +91,18 @@ { "name": "title_assertFault", "value": "AssertFaultDialog" + }, + { + "name": "message_title_permission_confirm", + "value": "The amsdialog application wants to query the list of application software information" + }, + { + "name": "message_confirm_permission", + "value": "allow" + }, + { + "name": "message_cancel_permission", + "value": "reject" } ] } \ No newline at end of file diff --git a/services/dialog_ui/ams_system_dialog/entry/src/main/resources/base/profile/main_pages.json b/services/dialog_ui/ams_system_dialog/entry/src/main/resources/base/profile/main_pages.json index 59a4f56138..8a5cc50ddb 100644 --- a/services/dialog_ui/ams_system_dialog/entry/src/main/resources/base/profile/main_pages.json +++ b/services/dialog_ui/ams_system_dialog/entry/src/main/resources/base/profile/main_pages.json @@ -6,6 +6,7 @@ "pages/tipsDialog", "pages/jumpInterceptorDialog", "pages/PhonePage", - "pages/assertFaultDialog" + "pages/assertFaultDialog", + "pages/permissionConfirmDialog" ] } diff --git a/services/dialog_ui/ams_system_dialog/entry/src/main/resources/zh/element/string.json b/services/dialog_ui/ams_system_dialog/entry/src/main/resources/zh/element/string.json index c4c7a58c17..e011b49e95 100644 --- a/services/dialog_ui/ams_system_dialog/entry/src/main/resources/zh/element/string.json +++ b/services/dialog_ui/ams_system_dialog/entry/src/main/resources/zh/element/string.json @@ -111,6 +111,18 @@ { "name": "title_assertFault", "value": "AssertFaultDialog" + }, + { + "name": "message_title_permission_confirm", + "value": "amsdialogåŗ”ē”Øęƒ³č¦ęŸ„čÆ¢åŗ”ē”Øč½Æä»¶åˆ—č”Øäæ”ęÆ" + }, + { + "name": "message_confirm_permission", + "value": "允许" + }, + { + "name": "message_cancel_permission", + "value": "ę‹’ē»" } ] } \ No newline at end of file diff --git a/services/quickfixmgr/BUILD.gn b/services/quickfixmgr/BUILD.gn index a68906cb28..ddefd1fbec 100644 --- a/services/quickfixmgr/BUILD.gn +++ b/services/quickfixmgr/BUILD.gn @@ -37,6 +37,12 @@ quickfixms_sources = [ ] ohos_shared_library("quickfixms") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + branch_protector_ret = "pac_ret" include_dirs = [ "${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper" ] shlib_type = "sa" configs = [ "${ability_runtime_services_path}/common:common_config" ] diff --git a/services/uripermmgr/BUILD.gn b/services/uripermmgr/BUILD.gn index c027370762..0d9f3b6411 100644 --- a/services/uripermmgr/BUILD.gn +++ b/services/uripermmgr/BUILD.gn @@ -32,6 +32,12 @@ libupms_sources = [ #build so ohos_shared_library("libupms") { + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + } + branch_protector_ret = "pac_ret" shlib_type = "sa" configs = [ "${ability_runtime_innerkits_path}/app_manager:appmgr_sdk_config", diff --git a/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp b/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp index a805703b90..ce4413a425 100644 --- a/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp +++ b/services/uripermmgr/src/uri_permission_manager_stub_impl.cpp @@ -55,7 +55,7 @@ bool UriPermissionManagerStubImpl::VerifyUriPermission(const Uri &uri, uint32_t { // verify if tokenId have uri permission record auto uriStr = uri.ToString(); - TAG_LOGI(AAFwkTag::URIPERMMGR, "uri is %{private}s, flag is %{public}u, tokenId is %{public}u", + TAG_LOGD(AAFwkTag::URIPERMMGR, "uri is %{private}s, flag is %{public}u, tokenId is %{public}u", uriStr.c_str(), flag, tokenId); if (!IsSAOrSystemAppCall()) { TAG_LOGE(AAFwkTag::URIPERMMGR, "Only support SA and SystemApp called."); @@ -75,7 +75,7 @@ bool UriPermissionManagerStubImpl::VerifyUriPermission(const Uri &uri, uint32_t auto& list = search->second; for (auto it = list.begin(); it != list.end(); it++) { if ((it->targetTokenId == tokenId) && ((it->flag | FLAG_READ_URI) & newFlag) != 0) { - TAG_LOGI(AAFwkTag::URIPERMMGR, "have uri permission."); + TAG_LOGD(AAFwkTag::URIPERMMGR, "have uri permission."); return true; } } @@ -130,10 +130,12 @@ int32_t UriPermissionManagerStubImpl::GrantUriPermissionPrivileged(const std::ve { TAG_LOGI(AAFwkTag::URIPERMMGR, "BundleName is %{public}s, appIndex is %{public}d, size of uriVec is %{public}zu.", targetBundleName.c_str(), appIndex, uriVec.size()); + uint32_t callerTokenId = IPCSkeleton::GetCallingTokenID(); auto callerName = GetTokenName(callerTokenId); TAG_LOGD(AAFwkTag::URIPERMMGR, "callerTokenId is %{public}u, callerName is %{public}s", callerTokenId, callerName.c_str()); + auto permissionName = PermissionConstants::PERMISSION_GRANT_URI_PERMISSION_PRIVILEGED; if (!PermissionVerification::GetInstance()->VerifyPermissionByTokenId(callerTokenId, permissionName) && !IsLinuxFusionCall()) { @@ -147,7 +149,7 @@ int32_t UriPermissionManagerStubImpl::GrantUriPermissionPrivileged(const std::ve } flag &= FLAG_READ_WRITE_URI; uint32_t targetTokenId = 0; - auto ret = GetTokenIdByBundleName(targetBundleName, 0, targetTokenId); + auto ret = GetTokenIdByBundleName(targetBundleName, appIndex, targetTokenId); if (ret != ERR_OK) { TAG_LOGE(AAFwkTag::URIPERMMGR, "Get tokenId failed, bundlename is %{public}s.", targetBundleName.c_str()); return ret; @@ -238,9 +240,9 @@ int UriPermissionManagerStubImpl::AddTempUriPermission(const std::string &uri, u auto search = uriMap_.find(uri); bool autoRemove = (abilityId != DEFAULT_ABILITY_ID); GrantInfo info = { flag, fromTokenId, targetTokenId, autoRemove, {} }; + info.AddAbilityId(abilityId); if (search == uriMap_.end()) { TAG_LOGI(AAFwkTag::URIPERMMGR, "Insert an uri r/w permission."); - info.AddAbilityId(abilityId); std::list infoList = { info }; uriMap_.emplace(uri, infoList); return ERR_OK; @@ -260,7 +262,7 @@ int UriPermissionManagerStubImpl::AddTempUriPermission(const std::string &uri, u return ERR_OK; } // w-r - TAG_LOGI(AAFwkTag::URIPERMMGR, "Uri has been granted, not to grant again."); + TAG_LOGD(AAFwkTag::URIPERMMGR, "Uri has been granted, not to grant again."); if ((item.flag & FLAG_WRITE_URI) != 0 && (flag & FLAG_WRITE_URI) == 0) { return ERR_OK; } @@ -271,7 +273,7 @@ int UriPermissionManagerStubImpl::AddTempUriPermission(const std::string &uri, u return ERR_OK; } } - TAG_LOGI(AAFwkTag::URIPERMMGR, "Insert an new uri permission record."); + TAG_LOGI(AAFwkTag::URIPERMMGR, "Insert a new uri permission record."); infoList.emplace_back(info); return ERR_OK; } @@ -279,7 +281,7 @@ int UriPermissionManagerStubImpl::AddTempUriPermission(const std::string &uri, u int UriPermissionManagerStubImpl::GrantUriPermissionImpl(const Uri &uri, unsigned int flag, TokenId callerTokenId, TokenId targetTokenId, int32_t abilityId) { - TAG_LOGI(AAFwkTag::URIPERMMGR, "uri = %{private}s, flag = %{public}i, callerTokenId = %{public}i," + TAG_LOGD(AAFwkTag::URIPERMMGR, "uri = %{private}s, flag = %{public}i, callerTokenId = %{public}i," "targetTokenId = %{public}i, abilityId = %{public}i", uri.ToString().c_str(), flag, callerTokenId, targetTokenId, abilityId); ConnectManager(storageManager_, STORAGE_MANAGER_MANAGER_ID); @@ -425,7 +427,7 @@ int32_t UriPermissionManagerStubImpl::GrantBatchUriPermissionFor2In1Privileged(c continue; } auto &&authority = uriInner.GetAuthority(); - if (authority != "docs" || uriStr.find(CLOUND_DOCS_URI_MARK) == std::string::npos) { + if (authority != "docs" || uriStr.find(CLOUND_DOCS_URI_MARK) != std::string::npos) { uriStrVec.emplace_back(uriStr); continue; } @@ -435,6 +437,9 @@ int32_t UriPermissionManagerStubImpl::GrantBatchUriPermissionFor2In1Privileged(c docsVec.emplace_back(policyInfo); } + TAG_LOGI(AAFwkTag::URIPERMMGR, "docsUri size is %{public}zu, otherUri size is %{public}zu", + docsVec.size(), uriStrVec.size()); + if (uriStrVec.empty() && docsVec.empty()) { TAG_LOGE(AAFwkTag::URIPERMMGR, "Valid uri list is empty."); return ERR_CODE_INVALID_URI_TYPE; @@ -464,12 +469,12 @@ void UriPermissionManagerStubImpl::RemoveUriRecord(std::vector &uri } if (!it->IsEmptyAbilityId()) { TAG_LOGD(AAFwkTag::URIPERMMGR, "Remove an abilityId."); - return; + break; } TAG_LOGI(AAFwkTag::URIPERMMGR, "Erase an info form list."); list.erase(it); uriList.emplace_back(iter->first); - return; + break; } if (list.empty()) { uriMap_.erase(iter++); @@ -770,7 +775,7 @@ int UriPermissionManagerStubImpl::GrantUriPermissionFor2In1Inner(const std::vect } } if (!otherVec.empty()) { - auto ret = GrantUriPermissionInner(otherVec, flag, targetBundleName, appIndex, initiatorTokenId); + auto ret = GrantUriPermissionInner(otherVec, flag, targetBundleName, appIndex, initiatorTokenId, abilityId); if (docsVec.empty()) { return ret; } @@ -958,6 +963,10 @@ bool UriPermissionManagerStubImpl::CheckUriPermission(Uri uri, uint32_t flag, To TAG_LOGI(AAFwkTag::URIPERMMGR, "Caller is linux_fusion_service."); return true; } + if (uri.GetScheme() == "content") { + TAG_LOGI(AAFwkTag::URIPERMMGR, "uri is content type."); + return IsFoundationCall(); + } if (authority == "docs") { return AccessDocsUriPermission(tokenIdPermission, uri, flag); } diff --git a/test/fuzztest/abilityattachtimeout_fuzzer/BUILD.gn b/test/fuzztest/abilityattachtimeout_fuzzer/BUILD.gn index 771d0e26c0..d3733d99fc 100755 --- a/test/fuzztest/abilityattachtimeout_fuzzer/BUILD.gn +++ b/test/fuzztest/abilityattachtimeout_fuzzer/BUILD.gn @@ -37,6 +37,7 @@ ohos_fuzztest("AbilityAttachTimeOutFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/app_manager:app_manager", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilityconnectionstub_fuzzer/BUILD.gn b/test/fuzztest/abilityconnectionstub_fuzzer/BUILD.gn index f62f1d3da8..0bb04b5efb 100755 --- a/test/fuzztest/abilityconnectionstub_fuzzer/BUILD.gn +++ b/test/fuzztest/abilityconnectionstub_fuzzer/BUILD.gn @@ -37,6 +37,7 @@ ohos_fuzztest("AbilityConnectionStubFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", ] diff --git a/test/fuzztest/abilityconnectmanager_fuzzer/BUILD.gn b/test/fuzztest/abilityconnectmanager_fuzzer/BUILD.gn index 0e7f222d54..f9e6ff61d7 100755 --- a/test/fuzztest/abilityconnectmanager_fuzzer/BUILD.gn +++ b/test/fuzztest/abilityconnectmanager_fuzzer/BUILD.gn @@ -40,6 +40,7 @@ ohos_fuzztest("AbilityConnectManagerFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitycontext_fuzzer/BUILD.gn b/test/fuzztest/abilitycontext_fuzzer/BUILD.gn index 3c53cf75b0..47dd309f71 100644 --- a/test/fuzztest/abilitycontext_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitycontext_fuzzer/BUILD.gn @@ -37,6 +37,7 @@ ohos_fuzztest("AbilityContextFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilityeventhandler_fuzzer/BUILD.gn b/test/fuzztest/abilityeventhandler_fuzzer/BUILD.gn index daa520de28..5506eada53 100755 --- a/test/fuzztest/abilityeventhandler_fuzzer/BUILD.gn +++ b/test/fuzztest/abilityeventhandler_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityEventHandlerFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitymanagerservicea_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerservicea_fuzzer/BUILD.gn index 73079c39a7..4e51173aa0 100755 --- a/test/fuzztest/abilitymanagerservicea_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerservicea_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceAFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:mission_info", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", diff --git a/test/fuzztest/abilitymanagerserviceb_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerserviceb_fuzzer/BUILD.gn index 7ec8b38744..cd9a3cecb1 100755 --- a/test/fuzztest/abilitymanagerserviceb_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerserviceb_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceBFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitymanagerservicec_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerservicec_fuzzer/BUILD.gn index 6c034eb93a..bcc90493c8 100755 --- a/test/fuzztest/abilitymanagerservicec_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerservicec_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceCFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitymanagerserviced_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerserviced_fuzzer/BUILD.gn index 1ac35edb54..b4cb78b44b 100755 --- a/test/fuzztest/abilitymanagerserviced_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerserviced_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceDFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitymanagerservicee_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerservicee_fuzzer/BUILD.gn index 41ec187e4d..63dac87932 100755 --- a/test/fuzztest/abilitymanagerservicee_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerservicee_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceEFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitymanagerserviceeighth_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerserviceeighth_fuzzer/BUILD.gn index 64cb793c5c..6105a286fc 100755 --- a/test/fuzztest/abilitymanagerserviceeighth_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerserviceeighth_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceEighthFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitymanagerservicef_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerservicef_fuzzer/BUILD.gn index 8d843fe37b..9cc57794ad 100755 --- a/test/fuzztest/abilitymanagerservicef_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerservicef_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceFFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitymanagerservicefifth_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerservicefifth_fuzzer/BUILD.gn index 778434d0dc..8dd74d191b 100755 --- a/test/fuzztest/abilitymanagerservicefifth_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerservicefifth_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceFifthFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitymanagerservicefirst_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerservicefirst_fuzzer/BUILD.gn index e63a0940a8..14602e39e3 100755 --- a/test/fuzztest/abilitymanagerservicefirst_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerservicefirst_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceFirstFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitymanagerservicefourth_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerservicefourth_fuzzer/BUILD.gn index 44577ba64d..d1e0f79a90 100755 --- a/test/fuzztest/abilitymanagerservicefourth_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerservicefourth_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceFourthFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitymanagerserviceg_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerserviceg_fuzzer/BUILD.gn index 622138a79e..4288d57319 100755 --- a/test/fuzztest/abilitymanagerserviceg_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerserviceg_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceGFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitymanagerserviceh_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerserviceh_fuzzer/BUILD.gn index bfd2a64720..afc9881307 100755 --- a/test/fuzztest/abilitymanagerserviceh_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerserviceh_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceHFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitymanagerserviceninth_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerserviceninth_fuzzer/BUILD.gn index 0d969cd805..9ddb03738c 100755 --- a/test/fuzztest/abilitymanagerserviceninth_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerserviceninth_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceNinthFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitymanagerservicesecond_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerservicesecond_fuzzer/BUILD.gn index 5648407d8b..966267ec74 100755 --- a/test/fuzztest/abilitymanagerservicesecond_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerservicesecond_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceSecondFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:mission_info", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", diff --git a/test/fuzztest/abilitymanagerserviceseventh_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerserviceseventh_fuzzer/BUILD.gn index 9a70012b90..0927f5d145 100755 --- a/test/fuzztest/abilitymanagerserviceseventh_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerserviceseventh_fuzzer/BUILD.gn @@ -43,6 +43,7 @@ ohos_fuzztest("AbilityManagerServiceSeventhFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitymanagerservicesixth_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerservicesixth_fuzzer/BUILD.gn index dfbaf6e38f..b574badab3 100755 --- a/test/fuzztest/abilitymanagerservicesixth_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerservicesixth_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceSixthFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilitymanagerservicetenth_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerservicetenth_fuzzer/BUILD.gn index 421bd00ee0..332fe1c9e4 100755 --- a/test/fuzztest/abilitymanagerservicetenth_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerservicetenth_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceTenthFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:mission_info", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", diff --git a/test/fuzztest/abilitymanagerservicethird_fuzzer/BUILD.gn b/test/fuzztest/abilitymanagerservicethird_fuzzer/BUILD.gn index 8a00c515a4..d662527a70 100755 --- a/test/fuzztest/abilitymanagerservicethird_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitymanagerservicethird_fuzzer/BUILD.gn @@ -44,6 +44,7 @@ ohos_fuzztest("AbilityManagerServiceThirdFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", diff --git a/test/fuzztest/abilityrunningrecord_fuzzer/BUILD.gn b/test/fuzztest/abilityrunningrecord_fuzzer/BUILD.gn index 649c04b289..db164a19cb 100644 --- a/test/fuzztest/abilityrunningrecord_fuzzer/BUILD.gn +++ b/test/fuzztest/abilityrunningrecord_fuzzer/BUILD.gn @@ -37,6 +37,7 @@ ohos_fuzztest("AbilityRunningRecordFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", "${ability_runtime_services_path}/appmgr:libappms", diff --git a/test/fuzztest/abilityschedulerstub_fuzzer/BUILD.gn b/test/fuzztest/abilityschedulerstub_fuzzer/BUILD.gn index 727a04eda9..fc78fff8b2 100755 --- a/test/fuzztest/abilityschedulerstub_fuzzer/BUILD.gn +++ b/test/fuzztest/abilityschedulerstub_fuzzer/BUILD.gn @@ -37,6 +37,7 @@ ohos_fuzztest("AbilitySchedulerStubFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubabilityrecovery_fuzzer/BUILD.gn b/test/fuzztest/abilitystubabilityrecovery_fuzzer/BUILD.gn index 30a86a1f75..7047c16935 100644 --- a/test/fuzztest/abilitystubabilityrecovery_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubabilityrecovery_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubAbilityRecoveryFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubabilityrecoveryenable_fuzzer/BUILD.gn b/test/fuzztest/abilitystubabilityrecoveryenable_fuzzer/BUILD.gn index ef4559df5c..95754f43bc 100644 --- a/test/fuzztest/abilitystubabilityrecoveryenable_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubabilityrecoveryenable_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubAbilityRecoveryEnableFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubabilitytransitiondone_fuzzer/BUILD.gn b/test/fuzztest/abilitystubabilitytransitiondone_fuzzer/BUILD.gn index b2431586df..e616f1b96d 100644 --- a/test/fuzztest/abilitystubabilitytransitiondone_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubabilitytransitiondone_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubAbilityTransitionDoneFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubacquiredataability_fuzzer/BUILD.gn b/test/fuzztest/abilitystubacquiredataability_fuzzer/BUILD.gn index 86622fd924..7af68bd394 100644 --- a/test/fuzztest/abilitystubacquiredataability_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubacquiredataability_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubAcquireDataAbilityFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubacquiresharedata_fuzzer/BUILD.gn b/test/fuzztest/abilitystubacquiresharedata_fuzzer/BUILD.gn index be6a4c9a67..d520444cf1 100644 --- a/test/fuzztest/abilitystubacquiresharedata_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubacquiresharedata_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubAcquireShareDataFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubaddfreeinstallobserver_fuzzer/BUILD.gn b/test/fuzztest/abilitystubaddfreeinstallobserver_fuzzer/BUILD.gn index 6ba8a5111e..33ef4b56f5 100644 --- a/test/fuzztest/abilitystubaddfreeinstallobserver_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubaddfreeinstallobserver_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubAddFreeInstallObserverFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubattachabilitythread_fuzzer/BUILD.gn b/test/fuzztest/abilitystubattachabilitythread_fuzzer/BUILD.gn index 927ed464fd..4ede9c716c 100644 --- a/test/fuzztest/abilitystubattachabilitythread_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubattachabilitythread_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubAttachAbilityThreadFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubcallrequestdone_fuzzer/BUILD.gn b/test/fuzztest/abilitystubcallrequestdone_fuzzer/BUILD.gn index 9009e7bc9a..e5972b6565 100644 --- a/test/fuzztest/abilitystubcallrequestdone_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubcallrequestdone_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubCallRequestDoneFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubcalluiabilitybyscb_fuzzer/BUILD.gn b/test/fuzztest/abilitystubcalluiabilitybyscb_fuzzer/BUILD.gn index 480c2e37e8..aa763bfac0 100644 --- a/test/fuzztest/abilitystubcalluiabilitybyscb_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubcalluiabilitybyscb_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubCallUIAbilityBySCBFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubcancelwantsender_fuzzer/BUILD.gn b/test/fuzztest/abilitystubcancelwantsender_fuzzer/BUILD.gn index 80fa977784..47a0d5e70b 100644 --- a/test/fuzztest/abilitystubcancelwantsender_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubcancelwantsender_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubCancelWantSenderFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubcheckuiextensionisfocused_fuzzer/BUILD.gn b/test/fuzztest/abilitystubcheckuiextensionisfocused_fuzzer/BUILD.gn index 14f58de8cf..2100e56e07 100644 --- a/test/fuzztest/abilitystubcheckuiextensionisfocused_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubcheckuiextensionisfocused_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubCheckUIExtensionIsFocusedFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubcleanallmissions_fuzzer/BUILD.gn b/test/fuzztest/abilitystubcleanallmissions_fuzzer/BUILD.gn index bdeb244b18..32d1bc70fd 100644 --- a/test/fuzztest/abilitystubcleanallmissions_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubcleanallmissions_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubCleanAllMissionsFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubcleanmission_fuzzer/BUILD.gn b/test/fuzztest/abilitystubcleanmission_fuzzer/BUILD.gn index 396ff302c9..91e7789c24 100644 --- a/test/fuzztest/abilitystubcleanmission_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubcleanmission_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubCleanMissionFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubclearupapplicationdata_fuzzer/BUILD.gn b/test/fuzztest/abilitystubclearupapplicationdata_fuzzer/BUILD.gn index 54d1ba0658..91d563fabf 100644 --- a/test/fuzztest/abilitystubclearupapplicationdata_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubclearupapplicationdata_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubClearUpApplicationDataFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubcommandabilitydone_fuzzer/BUILD.gn b/test/fuzztest/abilitystubcommandabilitydone_fuzzer/BUILD.gn index 8b9874fd0f..e145a5ed98 100644 --- a/test/fuzztest/abilitystubcommandabilitydone_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubcommandabilitydone_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubCommandAbilityDoneFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubcommandabilitywindowdone_fuzzer/BUILD.gn b/test/fuzztest/abilitystubcommandabilitywindowdone_fuzzer/BUILD.gn index 232cba6a86..88f25224f3 100644 --- a/test/fuzztest/abilitystubcommandabilitywindowdone_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubcommandabilitywindowdone_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubCommandAbilityWindowDoneFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubcompletefirstframedrawing_fuzzer/BUILD.gn b/test/fuzztest/abilitystubcompletefirstframedrawing_fuzzer/BUILD.gn index 59027825f5..8c537336fa 100644 --- a/test/fuzztest/abilitystubcompletefirstframedrawing_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubcompletefirstframedrawing_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubCompleteFirstFrameDrawingFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubconnectability_fuzzer/BUILD.gn b/test/fuzztest/abilitystubconnectability_fuzzer/BUILD.gn index 5377286020..c5e2dd2001 100644 --- a/test/fuzztest/abilitystubconnectability_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubconnectability_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubConnectAbilityFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubconnectabilitydone_fuzzer/BUILD.gn b/test/fuzztest/abilitystubconnectabilitydone_fuzzer/BUILD.gn index 9651494d80..833900f46c 100644 --- a/test/fuzztest/abilitystubconnectabilitydone_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubconnectabilitydone_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubConnectAbilityDoneFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubconnectabilitywithtype_fuzzer/BUILD.gn b/test/fuzztest/abilitystubconnectabilitywithtype_fuzzer/BUILD.gn index 3eca10fc80..5b2b7efad3 100644 --- a/test/fuzztest/abilitystubconnectabilitywithtype_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubconnectabilitywithtype_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubConnectAbilityWithTypeFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubconnectuiextensionability_fuzzer/BUILD.gn b/test/fuzztest/abilitystubconnectuiextensionability_fuzzer/BUILD.gn index 62410906b6..ca0922785b 100644 --- a/test/fuzztest/abilitystubconnectuiextensionability_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubconnectuiextensionability_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubConnectUIExtensionAbilityFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubcontinueability_fuzzer/BUILD.gn b/test/fuzztest/abilitystubcontinueability_fuzzer/BUILD.gn index 8b509b0413..7e28679944 100644 --- a/test/fuzztest/abilitystubcontinueability_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubcontinueability_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubContinueAbilityFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubcontinuemission_fuzzer/BUILD.gn b/test/fuzztest/abilitystubcontinuemission_fuzzer/BUILD.gn index da920044c0..687017ee68 100644 --- a/test/fuzztest/abilitystubcontinuemission_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubcontinuemission_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubContinueMissionFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubcontinuemissionofbundlename_fuzzer/BUILD.gn b/test/fuzztest/abilitystubcontinuemissionofbundlename_fuzzer/BUILD.gn index ed26f471e4..a876b7ee9d 100644 --- a/test/fuzztest/abilitystubcontinuemissionofbundlename_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubcontinuemissionofbundlename_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubContinueMissionOfBundlenameFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubdelegatordoabilitybackground_fuzzer/BUILD.gn b/test/fuzztest/abilitystubdelegatordoabilitybackground_fuzzer/BUILD.gn index eef6a3e9b7..6511b4be24 100644 --- a/test/fuzztest/abilitystubdelegatordoabilitybackground_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubdelegatordoabilitybackground_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubDelegatorDoAbilityBackgroundFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubdelegatordoabilityforeground_fuzzer/BUILD.gn b/test/fuzztest/abilitystubdelegatordoabilityforeground_fuzzer/BUILD.gn index 94757e6e4c..8828c156cb 100644 --- a/test/fuzztest/abilitystubdelegatordoabilityforeground_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubdelegatordoabilityforeground_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubDelegatorDoAbilityForegroundFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubdisconnectability_fuzzer/BUILD.gn b/test/fuzztest/abilitystubdisconnectability_fuzzer/BUILD.gn index f3274da1eb..89dfd20061 100644 --- a/test/fuzztest/abilitystubdisconnectability_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubdisconnectability_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubDisconnectAbilityFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubdisconnectabilitydone_fuzzer/BUILD.gn b/test/fuzztest/abilitystubdisconnectabilitydone_fuzzer/BUILD.gn index c930e9934f..b9f7c38d4a 100644 --- a/test/fuzztest/abilitystubdisconnectabilitydone_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubdisconnectabilitydone_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubDisConnectAbilityDoneFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubdoabilitybackground_fuzzer/BUILD.gn b/test/fuzztest/abilitystubdoabilitybackground_fuzzer/BUILD.gn index 17892edc32..fee3c66926 100644 --- a/test/fuzztest/abilitystubdoabilitybackground_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubdoabilitybackground_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubDoAbilityBackgroundFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubdoabilityforeground_fuzzer/BUILD.gn b/test/fuzztest/abilitystubdoabilityforeground_fuzzer/BUILD.gn index 81792f3507..af970db105 100644 --- a/test/fuzztest/abilitystubdoabilityforeground_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubdoabilityforeground_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubDoAbilityForegroundFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubdumpabilityinfodone_fuzzer/BUILD.gn b/test/fuzztest/abilitystubdumpabilityinfodone_fuzzer/BUILD.gn index 553fb3bd1e..f3513eca61 100644 --- a/test/fuzztest/abilitystubdumpabilityinfodone_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubdumpabilityinfodone_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubDumpAbilityInfoDoneFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubdumpstate_fuzzer/BUILD.gn b/test/fuzztest/abilitystubdumpstate_fuzzer/BUILD.gn index f7dab79795..4255abd364 100644 --- a/test/fuzztest/abilitystubdumpstate_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubdumpstate_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubDumpStateFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubdumpsysstate_fuzzer/BUILD.gn b/test/fuzztest/abilitystubdumpsysstate_fuzzer/BUILD.gn index a8fb25202f..3c99f909a1 100644 --- a/test/fuzztest/abilitystubdumpsysstate_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubdumpsysstate_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubDumpsysStateFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubfinishusertest_fuzzer/BUILD.gn b/test/fuzztest/abilitystubfinishusertest_fuzzer/BUILD.gn index 8d2b23c65f..5e58c35935 100644 --- a/test/fuzztest/abilitystubfinishusertest_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubfinishusertest_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubFinishUserTestFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubforceexitapp_fuzzer/BUILD.gn b/test/fuzztest/abilitystubforceexitapp_fuzzer/BUILD.gn index 5150b16e13..5db9b7786b 100644 --- a/test/fuzztest/abilitystubforceexitapp_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubforceexitapp_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubForceExitAppFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubfreeinstallabilityfromremote_fuzzer/BUILD.gn b/test/fuzztest/abilitystubfreeinstallabilityfromremote_fuzzer/BUILD.gn index 580174d597..f32ce33d18 100644 --- a/test/fuzztest/abilitystubfreeinstallabilityfromremote_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubfreeinstallabilityfromremote_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubFreeInstallAbilityFromRemoteFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetabilityrunninginfo_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetabilityrunninginfo_fuzzer/BUILD.gn index 02260bae84..12c70af6b7 100644 --- a/test/fuzztest/abilitystubgetabilityrunninginfo_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetabilityrunninginfo_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubGetAbilityRunningInfoFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetabilitystatebypersistentid_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetabilitystatebypersistentid_fuzzer/BUILD.gn index 51a75c814a..368375698a 100644 --- a/test/fuzztest/abilitystubgetabilitystatebypersistentid_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetabilitystatebypersistentid_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubGetAbilityStateByPersistentIdFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetabilitytoken_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetabilitytoken_fuzzer/BUILD.gn index 0ebd746eb1..5fe603fdc0 100644 --- a/test/fuzztest/abilitystubgetabilitytoken_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetabilitytoken_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubGetAbilityTokenFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetappmemorysize_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetappmemorysize_fuzzer/BUILD.gn index 854503486e..eb011bef36 100644 --- a/test/fuzztest/abilitystubgetappmemorysize_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetappmemorysize_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubGetAppMemorySizeFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetdlpconnectioninfos_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetdlpconnectioninfos_fuzzer/BUILD.gn index ec109fbf28..20ffacd22c 100644 --- a/test/fuzztest/abilitystubgetdlpconnectioninfos_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetdlpconnectioninfos_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubGetDlpConnectionInfosFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetelementnamebytoken_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetelementnamebytoken_fuzzer/BUILD.gn index c721c4b1ac..6496f768c8 100644 --- a/test/fuzztest/abilitystubgetelementnamebytoken_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetelementnamebytoken_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubGetElementNameByTokenFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetextensionrunninginfo_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetextensionrunninginfo_fuzzer/BUILD.gn index 7187977f3a..0dd7c010e9 100644 --- a/test/fuzztest/abilitystubgetextensionrunninginfo_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetextensionrunninginfo_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubGetExtensionRunningInfoFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetmissionidbytoken_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetmissionidbytoken_fuzzer/BUILD.gn index 98fe009936..39789456f5 100644 --- a/test/fuzztest/abilitystubgetmissionidbytoken_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetmissionidbytoken_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubGetMissionIdByTokenFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetmissioninfo_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetmissioninfo_fuzzer/BUILD.gn index 9627b08830..5878007094 100644 --- a/test/fuzztest/abilitystubgetmissioninfo_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetmissioninfo_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubGetMissionInfoFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetmissioninfos_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetmissioninfos_fuzzer/BUILD.gn index 58cbfdec9e..216cd70fe8 100644 --- a/test/fuzztest/abilitystubgetmissioninfos_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetmissioninfos_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubGetMissionInfosFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetmissionsnapshotinfo_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetmissionsnapshotinfo_fuzzer/BUILD.gn index 4a4d11620b..0875e9448c 100644 --- a/test/fuzztest/abilitystubgetmissionsnapshotinfo_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetmissionsnapshotinfo_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubGetMissionSnapShotInfoFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetpendingrequestwant_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetpendingrequestwant_fuzzer/BUILD.gn index 3e5919c780..ec3dfc7a49 100644 --- a/test/fuzztest/abilitystubgetpendingrequestwant_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetpendingrequestwant_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubGetPendingRequestWantFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetpendingwantbundlename_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetpendingwantbundlename_fuzzer/BUILD.gn index 579773ff79..f2d91d0790 100644 --- a/test/fuzztest/abilitystubgetpendingwantbundlename_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetpendingwantbundlename_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubGetPendingWantBundleNameFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetpendingwantcode_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetpendingwantcode_fuzzer/BUILD.gn index 63a733b7b7..09f9922a95 100644 --- a/test/fuzztest/abilitystubgetpendingwantcode_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetpendingwantcode_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubGetPendingWantCodeFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetpendingwanttype_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetpendingwanttype_fuzzer/BUILD.gn index 1b6a0e171a..fb1a41bfca 100644 --- a/test/fuzztest/abilitystubgetpendingwanttype_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetpendingwanttype_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubGetPendingWantTypeFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetpendingwantuid_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetpendingwantuid_fuzzer/BUILD.gn index dba956a1b4..476a09f7b6 100644 --- a/test/fuzztest/abilitystubgetpendingwantuid_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetpendingwantuid_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubGetPendingWantUidFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetpendingwantuserid_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetpendingwantuserid_fuzzer/BUILD.gn index ad1beb12b1..4d641a195a 100644 --- a/test/fuzztest/abilitystubgetpendingwantuserid_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetpendingwantuserid_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubGetPendingWantUserIdFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgetprocessrunninginfo_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgetprocessrunninginfo_fuzzer/BUILD.gn index 4036c87ba7..0b6892054e 100644 --- a/test/fuzztest/abilitystubgetprocessrunninginfo_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgetprocessrunninginfo_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubGetProcessRunningInfoFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgettopability_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgettopability_fuzzer/BUILD.gn index 25114cf108..5abe12f801 100644 --- a/test/fuzztest/abilitystubgettopability_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgettopability_fuzzer/BUILD.gn @@ -36,6 +36,7 @@ ohos_fuzztest("AbilityStubGetTopAbilityFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/fuzztest/abilitystubgettopabilitytoken_fuzzer/BUILD.gn b/test/fuzztest/abilitystubgettopabilitytoken_fuzzer/BUILD.gn index e4695e463d..7bb8b0b013 100644 --- a/test/fuzztest/abilitystubgettopabilitytoken_fuzzer/BUILD.gn +++ b/test/fuzztest/abilitystubgettopabilitytoken_fuzzer/BUILD.gn @@ -35,6 +35,7 @@ ohos_fuzztest("AbilityStubGetTopAbilityTokenFuzzTest") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_services_path}/abilitymgr:abilityms", ] diff --git a/test/mock/frameworks_kits_ability_native_test/include/mock_ui_content.h b/test/mock/frameworks_kits_ability_native_test/include/mock_ui_content.h index 2b1a016ecd..fc6bcbc36c 100644 --- a/test/mock/frameworks_kits_ability_native_test/include/mock_ui_content.h +++ b/test/mock/frameworks_kits_ability_native_test/include/mock_ui_content.h @@ -41,9 +41,9 @@ public: MOCK_METHOD0(UnFocus, void()); MOCK_METHOD0(Destroy, void()); MOCK_METHOD1(OnNewWant, void(const OHOS::AAFwk::Want &want)); - MOCK_METHOD3(Restore, UIContentErrorCode(OHOS::Rosen::Window *window, const std::string &contentInfo, - napi_value storage)); - MOCK_CONST_METHOD0(GetContentInfo, std::string()); + MOCK_METHOD4(Restore, UIContentErrorCode(OHOS::Rosen::Window *window, const std::string &contentInfo, + napi_value storage, ContentInfoType type)); + MOCK_CONST_METHOD1(GetContentInfo, std::string(ContentInfoType type)); MOCK_METHOD0(DestroyUIDirector, void()); MOCK_METHOD0(ProcessBackPressed, bool()); MOCK_METHOD1(ProcessPointerEvent, bool(const std::shared_ptr &pointerEvent)); diff --git a/test/mock/frameworks_kits_ability_native_test/include/mock_window.h b/test/mock/frameworks_kits_ability_native_test/include/mock_window.h index ca7e5a306b..d84611973b 100644 --- a/test/mock/frameworks_kits_ability_native_test/include/mock_window.h +++ b/test/mock/frameworks_kits_ability_native_test/include/mock_window.h @@ -151,9 +151,9 @@ public: virtual void NotifyTouchDialogTarget(int32_t posX = 0, int32_t posY = 0) {} virtual void SetAceAbilityHandler(const sptr& handler) {} virtual WMError NapiSetUIContent(const std::string& contentInfo, napi_env env, napi_value storage, - bool isDistributed = false, sptr token = nullptr, + BackupAndRestoreType type = BackupAndRestoreType::NONE, sptr token = nullptr, AppExecFwk::Ability* ability = nullptr) {return WMError::WM_OK;} - virtual std::string GetContentInfo() {return "";} + virtual std::string GetContentInfo(BackupAndRestoreType type = BackupAndRestoreType::CONTINUATION) {return "";} virtual Ace::UIContent* GetUIContent() const {return nullptr;} virtual void OnNewWant(const AAFwk::Want& want) {} virtual void SetRequestedOrientation(Orientation) {} diff --git a/test/mock/frameworks_kits_appkit_test/include/mock_app_mgr_service.h b/test/mock/frameworks_kits_appkit_test/include/mock_app_mgr_service.h index fac765766e..1d1c9cef11 100644 --- a/test/mock/frameworks_kits_appkit_test/include/mock_app_mgr_service.h +++ b/test/mock/frameworks_kits_appkit_test/include/mock_app_mgr_service.h @@ -55,10 +55,11 @@ public: MOCK_METHOD0(BlockAppService, int()); #endif MOCK_METHOD0(PreStartNWebSpawnProcess, int()); - MOCK_METHOD5(StartRenderProcess, + MOCK_METHOD6(StartRenderProcess, int(const std::string &renderParam, int32_t ipcFd, - int32_t sharedFd, int32_t crashFd, pid_t &renderPid)); + int32_t sharedFd, int32_t crashFd, pid_t &renderPid, bool isGPU)); MOCK_METHOD1(AttachRenderProcess, void(const sptr& renderScheduler)); + MOCK_METHOD1(SaveBrowserChannel, void(sptr browser)); MOCK_METHOD2(GetRenderProcessTerminationStatus, int(pid_t renderPid, int& status)); MOCK_METHOD1(GetConfiguration, int32_t(Configuration& config)); MOCK_METHOD1(UpdateConfiguration, int32_t(const Configuration& config)); @@ -84,6 +85,10 @@ public: MOCK_METHOD1(UnregisterRenderStateObserver, int32_t(const sptr &observer)); MOCK_METHOD2(UpdateRenderState, int32_t(pid_t renderPid, int32_t state)); MOCK_METHOD1(SetSupportedProcessCacheSelf, int32_t(bool isSupported)); + MOCK_METHOD2(GetRunningMultiAppInfoByBundleName, int32_t(const std::string &bundleName, + RunningMultiAppInfo &info)); + MOCK_METHOD3(StartNativeChildProcess, int32_t(const std::string &libName, int32_t childProcessCount, + const sptr &callback)); void AttachApplication(const sptr& app) { diff --git a/test/mock/frameworks_kits_runtime_test/mock_runtime.h b/test/mock/frameworks_kits_runtime_test/mock_runtime.h index 5742d1f2ef..37e03ebdfa 100644 --- a/test/mock/frameworks_kits_runtime_test/mock_runtime.h +++ b/test/mock/frameworks_kits_runtime_test/mock_runtime.h @@ -124,7 +124,8 @@ public: void StartProfiler(const DebugOption debugOption) override {} void DoCleanWorkAfterStageCleaned() override {} - void DumpHeapSnapshot(uint32_t tid, bool isFullGC) override {} + void DumpHeapSnapshot(uint32_t tid, bool isFullGC, std::vector fdVec, + std::vector tidVec) override {} void ForceFullGC(uint32_t tid) override {} public: Language language; diff --git a/test/mock/mock_appmgr_service/include/mock_app_mgr_service_inner.h b/test/mock/mock_appmgr_service/include/mock_app_mgr_service_inner.h index 88b8e33737..12e5464304 100644 --- a/test/mock/mock_appmgr_service/include/mock_app_mgr_service_inner.h +++ b/test/mock/mock_appmgr_service/include/mock_app_mgr_service_inner.h @@ -65,6 +65,8 @@ public: int32_t childProcessCount, bool inStartWithDebug)); MOCK_METHOD1(GetChildProcessInfoForSelf, int32_t(ChildProcessInfo &info)); MOCK_METHOD4(PreloadApplication, int32_t(const std::string&, int32_t, AppExecFwk::PreloadMode, int32_t)); + MOCK_METHOD4(StartNativeChildProcess, int32_t(const pid_t hostPid, const std::string &libName, + int32_t childProcessCount, const sptr &callback)); void StartSpecifiedAbility(const AAFwk::Want&, const AppExecFwk::AbilityInfo&, int32_t) {} diff --git a/test/mock/services_appmgr_test/include/mock_app_mgr_service.h b/test/mock/services_appmgr_test/include/mock_app_mgr_service.h index 228775be2e..36cf6c7574 100644 --- a/test/mock/services_appmgr_test/include/mock_app_mgr_service.h +++ b/test/mock/services_appmgr_test/include/mock_app_mgr_service.h @@ -56,8 +56,9 @@ public: MOCK_METHOD1(StartupResidentProcess, void(const std::vector& bundleInfos)); MOCK_METHOD1(AddAbilityStageDone, void(const int32_t recordId)); MOCK_METHOD0(PreStartNWebSpawnProcess, int()); - MOCK_METHOD5(StartRenderProcess, int(const std::string&, int32_t, int32_t, int32_t, pid_t&)); + MOCK_METHOD6(StartRenderProcess, int(const std::string&, int32_t, int32_t, int32_t, pid_t&, bool)); MOCK_METHOD1(AttachRenderProcess, void(const sptr& renderScheduler)); + MOCK_METHOD1(SaveBrowserChannel, void(sptr browser)); MOCK_METHOD2(GetRenderProcessTerminationStatus, int(pid_t renderPid, int& status)); MOCK_METHOD2(RegisterApplicationStateObserver, int32_t(const sptr& observer, const std::vector& bundleNameList)); @@ -89,6 +90,8 @@ public: MOCK_METHOD2(GetProcessMemoryByPid, int32_t(const int32_t pid, int32_t & memorySize)); MOCK_METHOD3(GetRunningProcessInformation, int32_t(const std::string & bundleName, int32_t userId, std::vector &info)); + MOCK_METHOD2(GetRunningMultiAppInfoByBundleName, int32_t(const std::string &bundleName, + RunningMultiAppInfo &info)); MOCK_METHOD2(IsApplicationRunning, int32_t(const std::string &bundleName, bool &isRunning)); MOCK_METHOD4(StartChildProcess, int32_t(const std::string &srcEntry, pid_t &childPid, int32_t childProcessCount, bool isStartWithNative)); @@ -101,6 +104,8 @@ public: MOCK_METHOD0(IsFinalAppProcess, bool()); MOCK_METHOD1(SetSupportedProcessCacheSelf, int32_t(bool isSupport)); + MOCK_METHOD3(StartNativeChildProcess, int32_t(const std::string &libName, int32_t childProcessCount, + const sptr &callback)); virtual int StartUserTestProcess( const AAFwk::Want &want, const sptr &observer, const BundleInfo &bundleInfo, int32_t userId) { diff --git a/test/mock/services_appmgr_test/include/mock_app_mgr_service_inner.h b/test/mock/services_appmgr_test/include/mock_app_mgr_service_inner.h index 6b0f773cd9..f672f7d0f7 100644 --- a/test/mock/services_appmgr_test/include/mock_app_mgr_service_inner.h +++ b/test/mock/services_appmgr_test/include/mock_app_mgr_service_inner.h @@ -71,6 +71,8 @@ public: MOCK_METHOD1(IsWaitingDebugApp, bool(const std::string &bundleName)); MOCK_METHOD0(ClearNonPersistWaitingDebugFlag, void()); MOCK_METHOD0(IsMemorySizeSufficent, bool()); + MOCK_METHOD4(StartNativeChildProcess, int32_t(const pid_t hostPid, + const std::string &libName, int32_t childProcessCount, const sptr &callback)); void StartSpecifiedAbility(const AAFwk::Want&, const AppExecFwk::AbilityInfo&, int32_t) {} diff --git a/test/moduletest/ability_record_test/BUILD.gn b/test/moduletest/ability_record_test/BUILD.gn index cfe8f2b280..14c5438b20 100644 --- a/test/moduletest/ability_record_test/BUILD.gn +++ b/test/moduletest/ability_record_test/BUILD.gn @@ -70,7 +70,7 @@ ohos_moduletest("AbilityRecordModuleTest") { "access_token:libaccesstoken_sdk", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", - "c_utils:utilsbase", + "c_utils:utils", "common_event_service:cesfwk_core", "common_event_service:cesfwk_innerkits", "dsoftbus:softbus_client", diff --git a/test/moduletest/ipc_ability_connect_test/BUILD.gn b/test/moduletest/ipc_ability_connect_test/BUILD.gn index f182a1da8b..425974df60 100644 --- a/test/moduletest/ipc_ability_connect_test/BUILD.gn +++ b/test/moduletest/ipc_ability_connect_test/BUILD.gn @@ -37,7 +37,7 @@ ohos_moduletest("IpcAbilityConnectModuleTest") { external_deps = [ "ability_base:want", "ability_runtime:ability_manager", - "c_utils:utilsbase", + "c_utils:utils", "hilog:libhilog", "ipc:ipc_core", ] diff --git a/test/moduletest/ipc_ability_scheduler_test/BUILD.gn b/test/moduletest/ipc_ability_scheduler_test/BUILD.gn index eeb688fee9..9501865ffd 100644 --- a/test/moduletest/ipc_ability_scheduler_test/BUILD.gn +++ b/test/moduletest/ipc_ability_scheduler_test/BUILD.gn @@ -50,7 +50,7 @@ ohos_moduletest("IpcAbilitySchedulerModuleTest") { "ability_base:zuri", "ability_runtime:ability_manager", "bundle_framework:appexecfwk_core", - "c_utils:utilsbase", + "c_utils:utils", "hilog:libhilog", "ipc:ipc_core", "napi:ace_napi", diff --git a/test/moduletest/mock/include/mock_render_scheduler.h b/test/moduletest/mock/include/mock_render_scheduler.h index 3624e4ae88..593f19fea8 100644 --- a/test/moduletest/mock/include/mock_render_scheduler.h +++ b/test/moduletest/mock/include/mock_render_scheduler.h @@ -26,8 +26,8 @@ public: MockRenderScheduler() = default; virtual ~MockRenderScheduler() = default; - MOCK_METHOD3(NotifyBrowserFd, - void(int32_t ipcFd, int32_t sharedFd, int32_t crashFd)); + MOCK_METHOD4(NotifyBrowserFd, + void(int32_t ipcFd, int32_t sharedFd, int32_t crashFd, sptr browser)); MOCK_METHOD0(AsObject, sptr()); }; } // namespace AppExecFwk diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 23fd0224e9..68d6078ecb 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -48,6 +48,8 @@ ohos_source_set("appmgr_test_source") { "${ability_runtime_innerkits_path}/app_manager/src/appmgr/app_state_callback_proxy.cpp", "${ability_runtime_innerkits_path}/app_manager/src/appmgr/app_task_info.cpp", "${ability_runtime_innerkits_path}/app_manager/src/appmgr/fault_data.cpp", + "${ability_runtime_innerkits_path}/app_manager/src/appmgr/native_child_notify_proxy.cpp", + "${ability_runtime_innerkits_path}/app_manager/src/appmgr/native_child_notify_stub.cpp", "${ability_runtime_innerkits_path}/app_manager/src/appmgr/process_info.cpp", "${ability_runtime_innerkits_path}/app_manager/src/appmgr/profile.cpp", "${ability_runtime_innerkits_path}/app_manager/src/appmgr/render_scheduler_host.cpp", @@ -347,8 +349,10 @@ group("unittest") { "ability_manager_stub_test:unittest", "ability_manager_test:unittest", "ability_record_dump_test:unittest", + "ability_record_mgr_test:unittest", "ability_record_test:unittest", "ability_running_info_test:unittest", + "ability_running_record_test:unittest", "ability_runtime_error_util_test:unittest", "ability_scheduler_proxy_test:unittest", "ability_scheduler_stub_test:unittest", @@ -373,6 +377,7 @@ group("unittest") { "ams_recent_app_list_test:unittest", "ams_service_load_ability_process_test:unittest", "ams_service_startup_test:unittest", + "app_config_data_manager_test:unittest", "app_debug_info_test:unittest", "app_debug_listener_proxy_test:unittest", "app_debug_listener_stub_test:unittest", @@ -417,6 +422,7 @@ group("unittest") { "bundle_mgr_helper_test:unittest", "cache_process_manager_test:unittest", "call_record_test:unittest", + "child_process_capi_test:unittest", "child_process_manager_test:unittest", "completed_dispatcher_test:unittest", "configuration_test:unittest", @@ -439,6 +445,7 @@ group("unittest") { "dataobs_mgr_service_dump_test:unittest", "dataobs_mgr_service_test:unittest", "dataobs_mgr_stub_test:unittest", + "deeplink_reserve_config_test:unittest", "dfr_test:unittest", "dlp_state_item_test:unittest", "dlp_utils_test:unittest", @@ -452,6 +459,7 @@ group("unittest") { "frameworks_kits_ability_native_test:unittest", "frameworks_kits_appkit_native_test:unittest", "free_install_manager_test:unittest", + "freeze_util_test:unittest", "implicit_start_processor_test:unittest", "insight_intent:unittest", "js_auto_fill_extension_test:unittest", diff --git a/test/unittest/ability_connect_manager_test/ability_connect_manager_test.cpp b/test/unittest/ability_connect_manager_test/ability_connect_manager_test.cpp index c8a14e678b..7f6604ead3 100644 --- a/test/unittest/ability_connect_manager_test/ability_connect_manager_test.cpp +++ b/test/unittest/ability_connect_manager_test/ability_connect_manager_test.cpp @@ -3135,15 +3135,9 @@ HWTEST_F(AbilityConnectManagerTest, IsUIExtensionFocused_002, TestSize.Level1) uiExtension1->sessionInfo_ = sessionInfo1; connectManager->uiExtensionMap_.emplace( callbackA_->AsObject(), AbilityConnectManager::UIExtWindowMapValType(uiExtension1, sessionInfo1)); - int32_t extensionId1 = 1; - std::shared_ptr extensionRecord1 = nullptr; - int32_t ret = connectManager->uiExtensionAbilityRecordMgr_->CreateExtensionRecord(uiExtension1, bundleName1, - extensionRecord1, extensionId1); - EXPECT_EQ(ret, ERR_OK); bool isFocused1 = connectManager->IsUIExtensionFocused( uiExtension1->GetApplicationInfo().accessTokenId, uiExtensionUser->GetToken()); EXPECT_EQ(isFocused1, true); - std::string abilityName2 = "uiExtensionAbility2"; std::string appName2 = "uiExtensionProvider2"; std::string bundleName2 = "com.ix.uiExtensionProvider2"; @@ -3157,11 +3151,6 @@ HWTEST_F(AbilityConnectManagerTest, IsUIExtensionFocused_002, TestSize.Level1) uiExtension2->sessionInfo_ = sessionInfo2; connectManager->uiExtensionMap_.emplace( callbackA_->AsObject(), AbilityConnectManager::UIExtWindowMapValType(uiExtension2, sessionInfo2)); - int32_t extensionId2 = 2; - std::shared_ptr extensionRecord2 = nullptr; - ret = connectManager->uiExtensionAbilityRecordMgr_->CreateExtensionRecord(uiExtension2, "", - extensionRecord2, extensionId2); - EXPECT_EQ(ret, ERR_OK); bool isFocused2 = connectManager->IsUIExtensionFocused( uiExtension2->GetApplicationInfo().accessTokenId, uiExtensionUser->GetToken()); EXPECT_EQ(isFocused2, true); diff --git a/test/unittest/ability_manager_client_branch_test/ability_manager_client_branch_test.cpp b/test/unittest/ability_manager_client_branch_test/ability_manager_client_branch_test.cpp index db562ba29f..7b683da6ac 100644 --- a/test/unittest/ability_manager_client_branch_test/ability_manager_client_branch_test.cpp +++ b/test/unittest/ability_manager_client_branch_test/ability_manager_client_branch_test.cpp @@ -2604,5 +2604,21 @@ HWTEST_F(AbilityManagerClientBranchTest, AbilityManagerClient_SetMissionLabel_01 GTEST_LOG_(INFO) << "AbilityManagerClient_SetMissionLabel_0100 end"; } #endif + +/** + * @tc.name: AbilityManagerClient_TransferAbilityResultForExtension_0100 + * @tc.desc: TransferAbilityResult + * @tc.type: FUNC + */ +HWTEST_F(AbilityManagerClientBranchTest, AbilityManagerClient_TransferAbilityResultForExtension_0100, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AbilityManagerClient_TransferAbilityResultForExtension_0100 start"; + sptr callerToken = new AbilityManagerStubTestMock(); + int resultCode = 0; + Want resultWant; + auto result = client_->TransferAbilityResultForExtension(callerToken, resultCode, resultWant); + EXPECT_EQ(result, NO_ERROR); + GTEST_LOG_(INFO) << "AbilityManagerClient_TransferAbilityResultForExtension_0100 end"; +} } // namespace AAFwk } // namespace OHOS \ No newline at end of file diff --git a/test/unittest/ability_manager_service_second_test/ability_manager_service_second_test.cpp b/test/unittest/ability_manager_service_second_test/ability_manager_service_second_test.cpp index 746b5d3b2b..792b59d6d3 100644 --- a/test/unittest/ability_manager_service_second_test/ability_manager_service_second_test.cpp +++ b/test/unittest/ability_manager_service_second_test/ability_manager_service_second_test.cpp @@ -735,6 +735,29 @@ HWTEST_F(AbilityManagerServiceSecondTest, ContinueMissionBundleName_001, TestSiz TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSecondTest ContinueMissionBundleName_001 end"); } +/* + * Feature: AbilityManagerService + * Function: ContinueMissionBundleName + * SubFunction: NA + * FunctionPoints: AbilityManagerService ContinueMissionBundleName + */ +HWTEST_F(AbilityManagerServiceSecondTest, ContinueMissionBundleName_002, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSecondTest ContinueMissionBundleName_002 start"); + auto abilityMs_ = std::make_shared(); + std::string srcDeviceId = ""; + std::string dstDeviceId = ""; + const sptr callback = nullptr; + AAFwk::WantParams wantParams; + ContinueMissionInfo continueMissionInfo; + continueMissionInfo.dstDeviceId = dstDeviceId; + continueMissionInfo.srcDeviceId = srcDeviceId; + continueMissionInfo.bundleName = ""; + continueMissionInfo.wantParams = wantParams; + EXPECT_EQ(abilityMs_->ContinueMission(continueMissionInfo, callback), CHECK_PERMISSION_FAILED); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceSecondTest ContinueMissionBundleName_002 end"); +} + /* * Feature: AbilityManagerService * Function: ContinueAbility diff --git a/test/unittest/ability_manager_service_third_test/ability_manager_service_third_test.cpp b/test/unittest/ability_manager_service_third_test/ability_manager_service_third_test.cpp index c2387f35b9..132c57c4d1 100644 --- a/test/unittest/ability_manager_service_third_test/ability_manager_service_third_test.cpp +++ b/test/unittest/ability_manager_service_third_test/ability_manager_service_third_test.cpp @@ -2298,5 +2298,21 @@ HWTEST_F(AbilityManagerServiceThirdTest, AnonymizeDeviceId_002, TestSize.Level1) auto result = abilityMs->AnonymizeDeviceId(localDeviceId); EXPECT_EQ(result, EMPTY_DEVICE_ID); } + +/* + * Feature: AbilityManagerService + * Function: TransferAbilityResultForExtension + * FunctionPoints: AbilityManagerService TransferAbilityResultForExtension + */ +HWTEST_F(AbilityManagerServiceThirdTest, TransferAbilityResultForExtension_001, TestSize.Level1) +{ + auto abilityMs = std::make_shared(); + EXPECT_NE(abilityMs, nullptr); + sptr token = nullptr; + int32_t resultCode = 0; + AAFwk::Want want; + int32_t res = abilityMs->TransferAbilityResultForExtension(token, resultCode, want); + EXPECT_EQ(res, ERR_INVALID_VALUE); +} } // namespace AAFwk } // namespace OHOS diff --git a/test/unittest/ability_record_mgr_test/BUILD.gn b/test/unittest/ability_record_mgr_test/BUILD.gn new file mode 100644 index 0000000000..fd91592f70 --- /dev/null +++ b/test/unittest/ability_record_mgr_test/BUILD.gn @@ -0,0 +1,61 @@ +# 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/ohos.gni") +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") + +module_output_path = "ability_runtime/appkit" +config("coverage_flags") { + if (ability_runtime_feature_coverage) { + cflags = [ "--coverage" ] + ldflags = [ "--coverage" ] + } +} + +ohos_unittest("ability_record_mgr_test") { + module_out_path = module_output_path + + include_dirs = [] + + sources = [ + "${ability_runtime_native_path}/appkit/app/ability_record_mgr.cpp", + "ability_record_mgr_test.cpp", + ] + + configs = [ ":coverage_flags" ] + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + deps = [ "//third_party/googletest:gmock_main" ] + + external_deps = [ + "ability_runtime:abilitykit_native", + "c_utils:utils", + "eventhandler:libeventhandler", + "hilog:libhilog", + "hitrace:hitrace_meter", + "ipc:ipc_core", + ] + + if (background_task_mgr_continuous_task_enable) { + external_deps += [ "background_task_mgr:bgtaskmgr_innerkits" ] + } +} + +group("unittest") { + testonly = true + + deps = [ ":ability_record_mgr_test" ] +} diff --git a/test/unittest/ability_record_mgr_test/ability_record_mgr_test.cpp b/test/unittest/ability_record_mgr_test/ability_record_mgr_test.cpp new file mode 100644 index 0000000000..7e37d50cb5 --- /dev/null +++ b/test/unittest/ability_record_mgr_test/ability_record_mgr_test.cpp @@ -0,0 +1,230 @@ +/* + * 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 +#define private public +#define protected public +#include "ability_record_mgr.h" +#undef private +#undef protected +#include "hilog_tag_wrapper.h" +#include "hilog_wrapper.h" +#include "iremote_broker.h" +#include "iremote_object.h" +#include "iremote_stub.h" +using namespace testing::ext; +using namespace testing; +using namespace OHOS::AppExecFwk; +namespace OHOS { +namespace AAFwk { +class IAbilityMgrToken : public IRemoteBroker { +public: + DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.AbilityMgrToken"); +}; + +class AbilityMgrToken : public IRemoteStub { +public: + AbilityMgrToken() = default; + virtual ~AbilityMgrToken() = default; + + virtual int OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) + { + return 0; + } + +private: + DISALLOW_COPY_AND_MOVE(AbilityMgrToken); +}; + +class AbilityRecordMgrTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp(); + void TearDown(); +}; + +void AbilityRecordMgrTest::SetUpTestCase() +{} + +void AbilityRecordMgrTest::TearDownTestCase() +{} + +void AbilityRecordMgrTest::SetUp() +{} + +void AbilityRecordMgrTest::TearDown() +{} + +/** + * @tc.number: GetToken_0100 + * @tc.name: GetToken + * @tc.desc: GetToken Test, return is not nullptr. + */ +HWTEST_F(AbilityRecordMgrTest, GetEventHandler_0100, TestSize.Level0) +{ + GTEST_LOG_(INFO) << "AbilityRecordMgrTest GetToken_0100 start"; + auto recordMgr = std::make_shared(); + recordMgr->tokens_ = nullptr; + auto token = recordMgr->GetToken(); + EXPECT_EQ(token, nullptr); + GTEST_LOG_(INFO) << "AbilityRecordMgrTest GetToken_0100 end"; +} + +/** + * @tc.number: SetToken_0100 + * @tc.name: SetToken + * @tc.desc: SetToken Test, return is not nullptr. + */ +HWTEST_F(AbilityRecordMgrTest, SetToken_0100, TestSize.Level0) +{ + GTEST_LOG_(INFO) << "AbilityRecordMgrTest SetToken_0100 start"; + sptr token = new (std::nothrow) AbilityMgrToken(); + auto recordMgr = std::make_shared(); + recordMgr->SetToken(token); + EXPECT_NE(recordMgr->GetToken(), nullptr); + GTEST_LOG_(INFO) << "AbilityRecordMgrTest SetToken_0100 end"; +} + +/** + * @tc.number: SetEventRunner_0100 + * @tc.name: SetEventRunner + * @tc.desc: SetEventRunner Test, return is not nullptr. + */ +HWTEST_F(AbilityRecordMgrTest, SetEventRunner_0100, TestSize.Level0) +{ + GTEST_LOG_(INFO) << "AbilityRecordMgrTest SetEventRunner_0100 start"; + auto recordMgr = std::make_shared(); + EXPECT_NE(recordMgr, nullptr); + recordMgr->SetEventRunner(nullptr); + + std::shared_ptr runner = EventRunner::GetMainEventRunner(); + EXPECT_NE(runner, nullptr); + recordMgr->tokens_ = nullptr; + recordMgr->SetEventRunner(runner); + + sptr token = new (std::nothrow) AbilityMgrToken(); + recordMgr->SetToken(token); + recordMgr->SetEventRunner(runner); + GTEST_LOG_(INFO) << "AbilityRecordMgrTest SetEventRunner_0100 end"; +} + +/** + * @tc.number: AddAbilityRecord_0100 + * @tc.name: AddAbilityRecord + * @tc.desc: AddAbilityRecord Test, return is not nullptr. + */ +HWTEST_F(AbilityRecordMgrTest, AddAbilityRecord_0100, TestSize.Level0) +{ + GTEST_LOG_(INFO) << "AbilityRecordMgrTest AddAbilityRecord_0100 start"; + auto recordMgr = std::make_shared(); + EXPECT_NE(recordMgr, nullptr); + sptr token = nullptr; + recordMgr->AddAbilityRecord(token, nullptr); + + token = new (std::nothrow) AbilityMgrToken(); + recordMgr->AddAbilityRecord(token, nullptr); + + auto abilityRecord = std::make_shared(nullptr, nullptr); + EXPECT_NE(abilityRecord, nullptr); + + recordMgr->AddAbilityRecord(token, abilityRecord); + EXPECT_EQ(recordMgr->abilityRecords_.size(), 1); + GTEST_LOG_(INFO) << "AbilityRecordMgrTest AddAbilityRecord_0100 end"; +} + +/** + * @tc.number: RemoveAbilityRecord_0100 + * @tc.name: RemoveAbilityRecord + * @tc.desc: RemoveAbilityRecord Test, return is not nullptr. + */ +HWTEST_F(AbilityRecordMgrTest, RemoveAbilityRecord_0100, TestSize.Level0) +{ + GTEST_LOG_(INFO) << "AbilityRecordMgrTest RemoveAbilityRecord_0100 start"; + auto recordMgr = std::make_shared(); + EXPECT_NE(recordMgr, nullptr); + sptr token = nullptr; + recordMgr->RemoveAbilityRecord(token); + + token = new (std::nothrow) AbilityMgrToken(); + auto abilityRecord = std::make_shared(nullptr, nullptr); + recordMgr->AddAbilityRecord(token, abilityRecord); + EXPECT_EQ(recordMgr->abilityRecords_.size(), 1); + + recordMgr->RemoveAbilityRecord(token); + EXPECT_EQ(recordMgr->abilityRecords_.size(), 0); + GTEST_LOG_(INFO) << "AbilityRecordMgrTest RemoveAbilityRecord_0100 end"; +} + +/** + * @tc.number: GetRecordCount_0100 + * @tc.name: GetRecordCount + * @tc.desc: GetRecordCount Test, return is not nullptr. + */ +HWTEST_F(AbilityRecordMgrTest, GetRecordCount_0100, TestSize.Level0) +{ + GTEST_LOG_(INFO) << "AbilityRecordMgrTest GetRecordCount_0100 start"; + auto recordMgr = std::make_shared(); + EXPECT_EQ(recordMgr->GetRecordCount(), 0); + + sptr token = new (std::nothrow) AbilityMgrToken(); + auto abilityRecord = std::make_shared(nullptr, nullptr); + recordMgr->AddAbilityRecord(token, abilityRecord); + EXPECT_EQ(recordMgr->GetRecordCount(), 1); + GTEST_LOG_(INFO) << "AbilityRecordMgrTest GetRecordCount_0100 end"; +} + +/** + * @tc.number: GetAbilityItem_0100 + * @tc.name: GetAbilityItem + * @tc.desc: GetAbilityItem Test, return is not nullptr. + */ +HWTEST_F(AbilityRecordMgrTest, GetAbilityItem_0100, TestSize.Level0) +{ + GTEST_LOG_(INFO) << "AbilityRecordMgrTest GetAbilityItem_0100 start"; + auto recordMgr = std::make_shared(); + sptr token = nullptr; + EXPECT_EQ(recordMgr->GetAbilityItem(token), nullptr); + + token = new (std::nothrow) AbilityMgrToken(); + auto abilityRecord = std::make_shared(nullptr, nullptr); + recordMgr->AddAbilityRecord(token, abilityRecord); + EXPECT_NE(recordMgr->GetAbilityItem(token), nullptr); + + sptr token2 = new (std::nothrow) AbilityMgrToken(); + EXPECT_EQ(recordMgr->GetAbilityItem(token2), nullptr); + + GTEST_LOG_(INFO) << "AbilityRecordMgrTest GetAbilityItem_0100 end"; +} + +/** + * @tc.number: GetAllTokens_0100 + * @tc.name: GetAllTokens + * @tc.desc: GetAllTokens Test, return is not nullptr. + */ +HWTEST_F(AbilityRecordMgrTest, GetAllTokens_0100, TestSize.Level0) +{ + GTEST_LOG_(INFO) << "AbilityRecordMgrTest GetAllTokens_0100 start"; + auto recordMgr = std::make_shared(); + + sptr token = new (std::nothrow) AbilityMgrToken(); + auto abilityRecord = std::make_shared(nullptr, nullptr); + recordMgr->AddAbilityRecord(token, abilityRecord); + EXPECT_EQ(recordMgr->GetAllTokens().size(), 1); + + GTEST_LOG_(INFO) << "AbilityRecordMgrTest GetAllTokens_0100 end"; +} +} +} diff --git a/test/unittest/ability_running_record_test/BUILD.gn b/test/unittest/ability_running_record_test/BUILD.gn new file mode 100644 index 0000000000..a3fd7ec8ad --- /dev/null +++ b/test/unittest/ability_running_record_test/BUILD.gn @@ -0,0 +1,77 @@ +# Copyright (c) 2021-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/appmgr" + +ohos_unittest("ability_running_record_test") { + module_out_path = module_output_path + cflags_cc = [] + include_dirs = [ + "${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper", + "${ability_runtime_services_path}/appmgr/include", + ] + + sources = [ + "${ability_runtime_services_path}/appmgr/src/ability_running_record.cpp", + ] + + sources += [ "ability_running_record_test.cpp" ] + + configs = [ "${ability_runtime_test_path}/unittest:appmgr_test_config" ] + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + deps = [ + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_native_path}/appkit:appkit_manager_helper", + "${ability_runtime_services_path}/appmgr:libappms", + "${ability_runtime_services_path}/common:perm_verification", + "${ability_runtime_services_path}/common:task_handler_wrap", + "${ability_runtime_test_path}/unittest:appmgr_test_source", + ] + + external_deps = [ + "access_token:libaccesstoken_sdk", + "access_token:libnativetoken", + "access_token:libtoken_setproc", + "appspawn:appspawn_client", + "bundle_framework:appexecfwk_core", + "ffrt:libffrt", + "hilog:libhilog", + "ipc:ipc_core", + ] + + defines = [ "AMS_LOG_TAG = \"AppMgrService\"" ] + + if (ability_command_for_test) { + defines += [ "ABILITY_COMMAND_FOR_TEST" ] + } + + if (ability_runtime_graphics) { + defines += [ "SUPPORT_GRAPHICS" ] + deps += [] + external_deps += [ + "i18n:intl_util", + "window_manager:libwm", + ] + } +} + +group("unittest") { + testonly = true + deps = [ ":ability_running_record_test" ] +} diff --git a/test/unittest/ability_running_record_test/ability_running_record_test.cpp b/test/unittest/ability_running_record_test/ability_running_record_test.cpp new file mode 100644 index 0000000000..e80bb96be8 --- /dev/null +++ b/test/unittest/ability_running_record_test/ability_running_record_test.cpp @@ -0,0 +1,717 @@ +/* + * Copyright (c) 2021-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 + +#include "ability_running_record.h" +#include "app_state_callback_host.h" +#include "hilog_tag_wrapper.h" +#include "hilog_wrapper.h" +#include "mock_ability_token.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace AppExecFwk { +class AbilityRunningRecordTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp(); + void TearDown(); +public: +protected: + static const std::string GetTestBundleName() + { + return "test_bundle_name"; + } + static const std::string GetTestAbilityInfoName() + { + return "test_ability_info_name"; + } + static const std::string GetTestModuleName() + { + return "test_module_name"; + } +}; + +void AbilityRunningRecordTest::SetUpTestCase() +{} + +void AbilityRunningRecordTest::TearDownTestCase() +{} + +void AbilityRunningRecordTest::SetUp() +{} + +void AbilityRunningRecordTest::TearDown() +{} + + +/* + * Feature: AbilityRunningRecord + * Function: GetName + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetName + * EnvConditions: NA + * CaseDescription: GetName + */ +HWTEST_F(AbilityRunningRecordTest, GetName_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetName_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + abilityInfo->name = GetTestAbilityInfoName(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto name = record->GetName(); + ASSERT_EQ(name, "test_ability_info_name"); + TAG_LOGD(AAFwkTag::TEST, "GetName_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: GetBundleName + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetBundleName + * EnvConditions: NA + * CaseDescription: GetBundleName + */ +HWTEST_F(AbilityRunningRecordTest, GetBundleName_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetBundleName_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + abilityInfo->bundleName = GetTestBundleName(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto name = record->GetBundleName(); + ASSERT_EQ(name, "test_bundle_name"); + TAG_LOGD(AAFwkTag::TEST, "GetBundleName_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: GetModuleName + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetModuleName + * EnvConditions: NA + * CaseDescription: GetModuleName + */ +HWTEST_F(AbilityRunningRecordTest, GetModuleName_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetModuleName_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + abilityInfo->moduleName = GetTestModuleName(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto name = record->GetModuleName(); + ASSERT_EQ(name, "test_module_name"); + TAG_LOGD(AAFwkTag::TEST, "GetModuleName_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: GetAbilityInfo + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetAbilityInfo + * EnvConditions: NA + * CaseDescription: GetAbilityInfo + */ +HWTEST_F(AbilityRunningRecordTest, GetAbilityInfo_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetAbilityInfo_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->GetAbilityInfo(); + ASSERT_NE(iret, nullptr); + TAG_LOGD(AAFwkTag::TEST, "GetAbilityInfo_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: GetWant + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetWant + * EnvConditions: NA + * CaseDescription: GetWant + */ +HWTEST_F(AbilityRunningRecordTest, GetWant_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetWant_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->GetWant(); + ASSERT_EQ(iret, nullptr); + TAG_LOGD(AAFwkTag::TEST, "GetWant_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: SetWant + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord SetWant + * EnvConditions: NA + * CaseDescription: SetWant + */ +HWTEST_F(AbilityRunningRecordTest, SetWant_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "SetWant_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + const std::shared_ptr want = std::make_shared(); + record->SetWant(want); + TAG_LOGD(AAFwkTag::TEST, "SetWant_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: GetToken + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetToken + * EnvConditions: NA + * CaseDescription: GetToken + */ +HWTEST_F(AbilityRunningRecordTest, GetToken_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetToken_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->GetToken(); + ASSERT_NE(iret, nullptr); + TAG_LOGD(AAFwkTag::TEST, "GetToken_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: SetState + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord SetState + * EnvConditions: NA + * CaseDescription: SetState + */ +HWTEST_F(AbilityRunningRecordTest, SetState_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "SetState_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + record->SetState(AbilityState::ABILITY_STATE_CREATE); + TAG_LOGD(AAFwkTag::TEST, "SetState_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: GetState + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetState + * EnvConditions: NA + * CaseDescription: GetState + */ +HWTEST_F(AbilityRunningRecordTest, GetState_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetState_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->GetState(); + ASSERT_EQ(iret, AbilityState::ABILITY_STATE_CREATE); + TAG_LOGD(AAFwkTag::TEST, "GetState_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: IsSameState + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord IsSameState + * EnvConditions: NA + * CaseDescription: IsSameState + */ +HWTEST_F(AbilityRunningRecordTest, IsSameState_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "IsSameState_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->IsSameState(AbilityState::ABILITY_STATE_CREATE); + ASSERT_EQ(iret, true); + TAG_LOGD(AAFwkTag::TEST, "IsSameState_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: GetLastLaunchTime + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetLastLaunchTime + * EnvConditions: NA + * CaseDescription: GetLastLaunchTime + */ +HWTEST_F(AbilityRunningRecordTest, GetLastLaunchTime_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetLastLaunchTime_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->GetLastLaunchTime(); + ASSERT_EQ(iret, 0); + TAG_LOGD(AAFwkTag::TEST, "GetLastLaunchTime_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: GetPreToken + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetPreToken + * EnvConditions: NA + * CaseDescription: GetPreToken + */ +HWTEST_F(AbilityRunningRecordTest, GetPreToken_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetPreToken_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->GetPreToken(); + ASSERT_EQ(iret, nullptr); + TAG_LOGD(AAFwkTag::TEST, "GetPreToken_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: SetPreToken + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord SetPreToken + * EnvConditions: NA + * CaseDescription: SetPreToken + */ +HWTEST_F(AbilityRunningRecordTest, SetPreToken_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "SetPreToken_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + sptr pretoken = new MockAbilityToken(); + record->SetPreToken(pretoken); + TAG_LOGD(AAFwkTag::TEST, "SetPreToken_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: SetVisibility + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord SetVisibility + * EnvConditions: NA + * CaseDescription: SetVisibility + */ +HWTEST_F(AbilityRunningRecordTest, SetVisibility_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "SetVisibility_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + const int32_t visibility = 1; + record->SetVisibility(visibility); + TAG_LOGD(AAFwkTag::TEST, "SetVisibility_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: GetVisibility + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetVisibility + * EnvConditions: NA + * CaseDescription: GetVisibility + */ +HWTEST_F(AbilityRunningRecordTest, GetVisibility_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetVisibility_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->GetVisibility(); + ASSERT_EQ(iret, 0); + TAG_LOGD(AAFwkTag::TEST, "GetVisibility_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: SetPerceptibility + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord SetPerceptibility + * EnvConditions: NA + * CaseDescription: SetPerceptibility + */ +HWTEST_F(AbilityRunningRecordTest, SetPerceptibility_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "SetPerceptibility_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + const int32_t perceptibility = 1; + record->SetPerceptibility(perceptibility); + TAG_LOGD(AAFwkTag::TEST, "SetPerceptibility_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: GetPerceptibility + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetPerceptibility + * EnvConditions: NA + * CaseDescription: GetPerceptibility + */ +HWTEST_F(AbilityRunningRecordTest, GetPerceptibility_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetPerceptibility_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->GetPerceptibility(); + ASSERT_EQ(iret, 0); + TAG_LOGD(AAFwkTag::TEST, "GetPerceptibility_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: SetConnectionState + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord SetConnectionState + * EnvConditions: NA + * CaseDescription: SetConnectionState + */ +HWTEST_F(AbilityRunningRecordTest, SetConnectionState_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "SetConnectionState_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + const int32_t connectionState = 1; + record->SetConnectionState(connectionState); + TAG_LOGD(AAFwkTag::TEST, "SetConnectionState_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: GetConnectionState + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetConnectionState + * EnvConditions: NA + * CaseDescription: GetConnectionState + */ +HWTEST_F(AbilityRunningRecordTest, GetConnectionState_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetConnectionState_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->GetConnectionState(); + ASSERT_EQ(iret, 0); + TAG_LOGD(AAFwkTag::TEST, "GetConnectionState_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: SetEventId + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord SetEventId + * EnvConditions: NA + * CaseDescription: SetEventId + */ +HWTEST_F(AbilityRunningRecordTest, SetEventId_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "SetEventId_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + const int64_t eventId = 1; + record->SetEventId(eventId); + TAG_LOGD(AAFwkTag::TEST, "SetEventId_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: GetEventId + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetEventId + * EnvConditions: NA + * CaseDescription: GetEventId + */ +HWTEST_F(AbilityRunningRecordTest, GetEventId_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetEventId_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->GetEventId(); + ASSERT_EQ(iret, 0); + TAG_LOGD(AAFwkTag::TEST, "GetEventId_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: SetTerminating + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord SetTerminating + * EnvConditions: NA + * CaseDescription: SetTerminating + */ +HWTEST_F(AbilityRunningRecordTest, SetTerminating_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "SetTerminating_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + record->SetTerminating(); + TAG_LOGD(AAFwkTag::TEST, "SetTerminating_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: IsTerminating + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord IsTerminating + * EnvConditions: NA + * CaseDescription: IsTerminating + */ +HWTEST_F(AbilityRunningRecordTest, IsTerminating_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "IsTerminating_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->IsTerminating(); + ASSERT_EQ(iret, false); + TAG_LOGD(AAFwkTag::TEST, "IsTerminating_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: SetOwnerUserId + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord SetOwnerUserId + * EnvConditions: NA + * CaseDescription: SetOwnerUserId + */ +HWTEST_F(AbilityRunningRecordTest, SetOwnerUserId_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "SetOwnerUserId_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + int32_t ownerUserId = 1; + record->SetOwnerUserId(ownerUserId); + TAG_LOGD(AAFwkTag::TEST, "SetOwnerUserId_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: GetOwnerUserId + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetOwnerUserId + * EnvConditions: NA + * CaseDescription: GetOwnerUserId + */ +HWTEST_F(AbilityRunningRecordTest, GetOwnerUserId_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetOwnerUserId_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->GetOwnerUserId(); + ASSERT_EQ(iret, -1); + TAG_LOGD(AAFwkTag::TEST, "GetOwnerUserId_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: SetIsSingleUser + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord SetIsSingleUser + * EnvConditions: NA + * CaseDescription: SetIsSingleUser + */ +HWTEST_F(AbilityRunningRecordTest, SetIsSingleUser_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "SetIsSingleUser_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + bool flag = true; + record->SetIsSingleUser(flag); + TAG_LOGD(AAFwkTag::TEST, "SetIsSingleUser_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: IsSingleUser + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord IsSingleUser + * EnvConditions: NA + * CaseDescription: IsSingleUser + */ +HWTEST_F(AbilityRunningRecordTest, IsSingleUser_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "IsSingleUser_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->IsSingleUser(); + ASSERT_EQ(iret, false); + TAG_LOGD(AAFwkTag::TEST, "IsSingleUser_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: UpdateFocusState + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord UpdateFocusState + * EnvConditions: NA + * CaseDescription: UpdateFocusState + */ +HWTEST_F(AbilityRunningRecordTest, UpdateFocusState_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "UpdateFocusState_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + bool isFocus = true; + record->UpdateFocusState(isFocus); + TAG_LOGD(AAFwkTag::TEST, "UpdateFocusState_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: GetFocusFlag + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetFocusFlag + * EnvConditions: NA + * CaseDescription: GetFocusFlag + */ +HWTEST_F(AbilityRunningRecordTest, GetFocusFlag_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetFocusFlag_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->GetFocusFlag(); + ASSERT_EQ(iret, false); + TAG_LOGD(AAFwkTag::TEST, "GetFocusFlag_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: SetUIExtensionAbilityId + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord SetUIExtensionAbilityId + * EnvConditions: NA + * CaseDescription: SetUIExtensionAbilityId + */ +HWTEST_F(AbilityRunningRecordTest, SetUIExtensionAbilityId_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "SetUIExtensionAbilityId_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + const int32_t uiExtensionAbilityId = 1; + record->SetUIExtensionAbilityId(uiExtensionAbilityId); + TAG_LOGD(AAFwkTag::TEST, "SetUIExtensionAbilityId_001 end."); +} + +/* + * Feature: AbilityRunningRecord + * Function: GetUIExtensionAbilityId + * SubFunction: NA + * FunctionPoints: AbilityRunningRecord GetUIExtensionAbilityId + * EnvConditions: NA + * CaseDescription: GetUIExtensionAbilityId + */ +HWTEST_F(AbilityRunningRecordTest, GetUIExtensionAbilityId_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "GetUIExtensionAbilityId_001 start."); + std::shared_ptr abilityInfo = std::make_shared(); + sptr token = new MockAbilityToken(); + int32_t abilityRecordId = 1; + auto record = std::make_shared(abilityInfo, token, abilityRecordId); + ASSERT_NE(record, nullptr); + auto iret = record->GetUIExtensionAbilityId(); + ASSERT_EQ(iret, 0); + TAG_LOGD(AAFwkTag::TEST, "GetUIExtensionAbilityId_001 end."); +} + +} // namespace AppExecFwk +} // namespace OHOS diff --git a/test/unittest/ams_mgr_scheduler_test/BUILD.gn b/test/unittest/ams_mgr_scheduler_test/BUILD.gn index b3a2bdf713..76bbae7f4b 100644 --- a/test/unittest/ams_mgr_scheduler_test/BUILD.gn +++ b/test/unittest/ams_mgr_scheduler_test/BUILD.gn @@ -24,12 +24,15 @@ ohos_unittest("ams_mgr_scheduler_test") { "${ability_runtime_services_path}/appmgr/include", "${ability_runtime_test_path}/mock/mock_sa_call", "${distributedschedule_path}/samgr/interfaces/innerkits/samgr_proxy/include", + "mock/include", ] sources = [ "${ability_runtime_services_path}/appmgr/src/ams_mgr_scheduler.cpp", "${ability_runtime_test_path}/mock/services_appmgr_test/src/mock_bundle_manager.cpp", "${ability_runtime_test_path}/mock/services_appmgr_test/src/mock_overlay_manager.cpp", + "mock/src/mock_my_flag.cpp", + "mock/src/mock_permission_verification.cpp", ] sources += [ "ams_mgr_scheduler_test.cpp" ] diff --git a/test/unittest/ams_mgr_scheduler_test/ams_mgr_scheduler_test.cpp b/test/unittest/ams_mgr_scheduler_test/ams_mgr_scheduler_test.cpp index 21734bc222..1d14889fce 100644 --- a/test/unittest/ams_mgr_scheduler_test/ams_mgr_scheduler_test.cpp +++ b/test/unittest/ams_mgr_scheduler_test/ams_mgr_scheduler_test.cpp @@ -25,6 +25,7 @@ #include "mock_ability_token.h" #include "mock_app_mgr_service_inner.h" #include "mock_bundle_manager.h" +#include "mock_my_flag.h" #include "mock_sa_call.h" #include "application_state_observer_stub.h" @@ -617,6 +618,45 @@ HWTEST_F(AmsMgrSchedulerTest, KillProcessesByUserId_001, TestSize.Level0) amsMgrScheduler->KillProcessesByUserId(userId); } +/* + * Feature: AmsMgrScheduler + * Function: KillProcessesByUserId + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler KillProcessesByUserId + * EnvConditions: NA + * CaseDescription: The caller is not system-app, can not use system-api + */ +HWTEST_F(AmsMgrSchedulerTest, KillProcessesByUserId_002, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + int32_t userId = 0; + AAFwk::MyFlag::flag_ = 0; + amsMgrScheduler->KillProcessesByUserId(userId); + AAFwk::MyFlag::flag_ = 1; +} + +/* + * Feature: AmsMgrScheduler + * Function: KillProcessesByUserId + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler KillProcessesByUserId + * EnvConditions: NA + * CaseDescription: SubmitTask + */ +HWTEST_F(AmsMgrSchedulerTest, KillProcessesByUserId_003, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + int32_t userId = 0; + AAFwk::MyFlag::flag_ = 1; + amsMgrScheduler->KillProcessesByUserId(userId); +} + /* * Feature: AmsMgrScheduler * Function: KillProcessWithAccount @@ -883,6 +923,21 @@ HWTEST_F(AmsMgrSchedulerTest, NotifyAppMgrRecordExitReason_001, TestSize.Level0) EXPECT_NE(res2, ERR_INVALID_OPERATION); } +/** + * @tc.name: SetCurrentUserId_002 + * @tc.desc: set current userId. + * @tc.type: FUNC + */ +HWTEST_F(AmsMgrSchedulerTest, SetCurrentUserId_002, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + int userId = 1; + amsMgrScheduler->SetCurrentUserId(userId); +} + /** * @tc.name: SetCurrentUserId_001 * @tc.desc: set current userId. @@ -991,5 +1046,472 @@ HWTEST_F(AmsMgrSchedulerTest, RegisterAbilityDebugResponse_001, TestSize.Level0) res = amsMgrScheduler->RegisterAbilityDebugResponse(response); EXPECT_NE(res, ERR_INVALID_OPERATION); } + +/* + * Feature: AmsMgrScheduler + * Function: KillProcessesByPids + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler KillProcessesByPids + * EnvConditions: NA + * CaseDescription: not initial scheduler + */ +HWTEST_F(AmsMgrSchedulerTest, KillProcessesByPids_001, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); + int32_t userId = 0; + std::vector pids = {1}; + amsMgrScheduler->KillProcessesByPids(pids); +} + +/* + * Feature: AmsMgrScheduler + * Function: KillProcessesByPids + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler KillProcessesByPids + * EnvConditions: NA + * CaseDescription: SubmitTask + */ +HWTEST_F(AmsMgrSchedulerTest, KillProcessesByPids_002, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + int32_t userId = 0; + std::vector pids = {1}; + amsMgrScheduler->KillProcessesByPids(pids); +} + +/* + * Feature: AmsMgrScheduler + * Function: AttachPidToParent + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler AttachPidToParent + * EnvConditions: NA + * CaseDescription: not initial scheduler + */ +HWTEST_F(AmsMgrSchedulerTest, AttachPidToParent_001, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); + const sptr token; + const sptr callerToken; + amsMgrScheduler->AttachPidToParent(token, callerToken); +} + +/* + * Feature: AmsMgrScheduler + * Function: AttachPidToParent + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler AttachPidToParent + * EnvConditions: NA + * CaseDescription: SubmitTask + */ +HWTEST_F(AmsMgrSchedulerTest, AttachPidToParent_002, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + const sptr token; + const sptr callerToken; + amsMgrScheduler->AttachPidToParent(token, callerToken); +} + +/* + * Feature: AmsMgrScheduler + * Function: UpdateApplicationInfoInstalled + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler UpdateApplicationInfoInstalled + * EnvConditions: NA + * CaseDescription: not initial scheduler + */ +HWTEST_F(AmsMgrSchedulerTest, UpdateApplicationInfoInstalled_001, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); + const std::string bundleName = ""; + const int uid = 0; + auto iret = amsMgrScheduler->UpdateApplicationInfoInstalled(bundleName, uid); + ASSERT_EQ(iret, 38); +} + +/* + * Feature: AmsMgrScheduler + * Function: UpdateApplicationInfoInstalled + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler UpdateApplicationInfoInstalled + * EnvConditions: NA + * CaseDescription: UpdateApplicationInfoInstalled + */ +HWTEST_F(AmsMgrSchedulerTest, UpdateApplicationInfoInstalled_002, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + const std::string bundleName = ""; + const int uid = 0; + auto iret = amsMgrScheduler->UpdateApplicationInfoInstalled(bundleName, uid); + ASSERT_EQ(iret, 0); +} + +/* + * Feature: AmsMgrScheduler + * Function: SetAbilityForegroundingFlagToAppRecord + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler SetAbilityForegroundingFlagToAppRecord + * EnvConditions: NA + * CaseDescription: not initial scheduler + */ +HWTEST_F(AmsMgrSchedulerTest, SetAbilityForegroundingFlagToAppRecord_001, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); + const pid_t pid = 1; + amsMgrScheduler->SetAbilityForegroundingFlagToAppRecord(pid); +} + +/* + * Feature: AmsMgrScheduler + * Function: SetAbilityForegroundingFlagToAppRecord + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler SetAbilityForegroundingFlagToAppRecord + * EnvConditions: NA + * CaseDescription: SetAbilityForegroundingFlagToAppRecord + */ +HWTEST_F(AmsMgrSchedulerTest, SetAbilityForegroundingFlagToAppRecord_002, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + const pid_t pid = 1; + amsMgrScheduler->SetAbilityForegroundingFlagToAppRecord(pid); +} + +/* + * Feature: AmsMgrScheduler + * Function: StartSpecifiedProcess + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler StartSpecifiedProcess + * EnvConditions: NA + * CaseDescription: not initial scheduler + */ +HWTEST_F(AmsMgrSchedulerTest, StartSpecifiedProcess_001, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); + const AAFwk::Want want; + const AppExecFwk::AbilityInfo abilityInfo; + int32_t requestId = 1; + amsMgrScheduler->StartSpecifiedProcess(want, abilityInfo, requestId); +} + +/* + * Feature: AmsMgrScheduler + * Function: StartSpecifiedProcess + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler StartSpecifiedProcess + * EnvConditions: NA + * CaseDescription: StartSpecifiedProcess + */ +HWTEST_F(AmsMgrSchedulerTest, StartSpecifiedProcess_002, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + const AAFwk::Want want; + const AppExecFwk::AbilityInfo abilityInfo; + int32_t requestId = 1; + amsMgrScheduler->StartSpecifiedProcess(want, abilityInfo, requestId); +} + +/* + * Feature: AmsMgrScheduler + * Function: GetBundleNameByPid + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler GetBundleNameByPid + * EnvConditions: NA + * CaseDescription: not initial scheduler + */ +HWTEST_F(AmsMgrSchedulerTest, GetBundleNameByPid_001, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); + const int pid = 1; + std::string bundleName; + int32_t uid = 1; + auto iret = amsMgrScheduler->GetBundleNameByPid(pid, bundleName, uid); + ASSERT_EQ(iret, 38); +} + +/* + * Feature: AmsMgrScheduler + * Function: GetBundleNameByPid + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler GetBundleNameByPid + * EnvConditions: NA + * CaseDescription: GetBundleNameByPid + */ +HWTEST_F(AmsMgrSchedulerTest, GetBundleNameByPid_002, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + const int pid = 1; + std::string bundleName; + int32_t uid = 1; + auto iret = amsMgrScheduler->GetBundleNameByPid(pid, bundleName, uid); + ASSERT_EQ(iret, 38); +} + +/* + * Feature: AmsMgrScheduler + * Function: SetAppWaitingDebug + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler SetAppWaitingDebug + * EnvConditions: NA + * CaseDescription: not initial scheduler + */ +HWTEST_F(AmsMgrSchedulerTest, SetAppWaitingDebug_001, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); + const std::string bundleName; + bool isPersist = true; + auto iret = amsMgrScheduler->SetAppWaitingDebug(bundleName, isPersist); + ASSERT_EQ(iret, 38); +} + +/* + * Feature: AmsMgrScheduler + * Function: SetAppWaitingDebug + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler SetAppWaitingDebug + * EnvConditions: NA + * CaseDescription: SetAppWaitingDebug + */ +HWTEST_F(AmsMgrSchedulerTest, SetAppWaitingDebug_002, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + const std::string bundleName; + bool isPersist = true; + auto iret = amsMgrScheduler->SetAppWaitingDebug(bundleName, isPersist); + ASSERT_EQ(iret, 22); +} + +/* + * Feature: AmsMgrScheduler + * Function: CancelAppWaitingDebug + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler CancelAppWaitingDebug + * EnvConditions: NA + * CaseDescription: not initial scheduler + */ +HWTEST_F(AmsMgrSchedulerTest, CancelAppWaitingDebug_001, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); + amsMgrScheduler->CancelAppWaitingDebug(); +} + +/* + * Feature: AmsMgrScheduler + * Function: CancelAppWaitingDebug + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler CancelAppWaitingDebug + * EnvConditions: NA + * CaseDescription: CancelAppWaitingDebug + */ +HWTEST_F(AmsMgrSchedulerTest, CancelAppWaitingDebug_002, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + amsMgrScheduler->CancelAppWaitingDebug(); +} + +/* + * Feature: AmsMgrScheduler + * Function: GetWaitingDebugApp + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler GetWaitingDebugApp + * EnvConditions: NA + * CaseDescription: not initial scheduler + */ +HWTEST_F(AmsMgrSchedulerTest, GetWaitingDebugApp_001, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); + std::vector debugInfoList; + auto iret = amsMgrScheduler->GetWaitingDebugApp(debugInfoList); + ASSERT_EQ(iret, 38); +} + +/* + * Feature: AmsMgrScheduler + * Function: GetWaitingDebugApp + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler GetWaitingDebugApp + * EnvConditions: NA + * CaseDescription: not initial scheduler + */ +HWTEST_F(AmsMgrSchedulerTest, GetWaitingDebugApp_002, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + std::vector debugInfoList; + auto iret = amsMgrScheduler->GetWaitingDebugApp(debugInfoList); + ASSERT_EQ(iret, 0); +} + +/* + * Feature: AmsMgrScheduler + * Function: IsWaitingDebugApp + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler IsWaitingDebugApp + * EnvConditions: NA + * CaseDescription: not initial scheduler + */ +HWTEST_F(AmsMgrSchedulerTest, IsWaitingDebugApp_001, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); + const std::string bundleName; + auto iret = amsMgrScheduler->IsWaitingDebugApp(bundleName); + ASSERT_EQ(iret, false); +} + +/* + * Feature: AmsMgrScheduler + * Function: IsWaitingDebugApp + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler IsWaitingDebugApp + * EnvConditions: NA + * CaseDescription: IsWaitingDebugApp + */ +HWTEST_F(AmsMgrSchedulerTest, IsWaitingDebugApp_002, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + const std::string bundleName; + auto iret = amsMgrScheduler->IsWaitingDebugApp(bundleName); + ASSERT_EQ(iret, false); +} + +/* + * Feature: AmsMgrScheduler + * Function: ClearNonPersistWaitingDebugFlag + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler ClearNonPersistWaitingDebugFlag + * EnvConditions: NA + * CaseDescription: not initial scheduler + */ +HWTEST_F(AmsMgrSchedulerTest, ClearNonPersistWaitingDebugFlag_001, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); + amsMgrScheduler->ClearNonPersistWaitingDebugFlag(); +} + +/* + * Feature: AmsMgrScheduler + * Function: ClearNonPersistWaitingDebugFlag + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler ClearNonPersistWaitingDebugFlag + * EnvConditions: NA + * CaseDescription: ClearNonPersistWaitingDebugFlag + */ +HWTEST_F(AmsMgrSchedulerTest, ClearNonPersistWaitingDebugFlag_002, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + amsMgrScheduler->ClearNonPersistWaitingDebugFlag(); +} + +/* + * Feature: AmsMgrScheduler + * Function: IsAttachDebug + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler IsAttachDebug + * EnvConditions: NA + * CaseDescription: not initial scheduler + */ +HWTEST_F(AmsMgrSchedulerTest, IsAttachDebug_001, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); + const std::string bundleName; + auto iret = amsMgrScheduler->IsAttachDebug(bundleName); + ASSERT_EQ(iret, false); +} + +/* + * Feature: AmsMgrScheduler + * Function: IsAttachDebug + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler IsAttachDebug + * EnvConditions: NA + * CaseDescription: IsAttachDebug + */ +HWTEST_F(AmsMgrSchedulerTest, IsAttachDebug_002, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + const std::string bundleName; + auto iret = amsMgrScheduler->IsAttachDebug(bundleName); + ASSERT_EQ(iret, false); +} + +/* + * Feature: AmsMgrScheduler + * Function: ClearProcessByToken + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler ClearProcessByToken + * EnvConditions: NA + * CaseDescription: not initial scheduler + */ +HWTEST_F(AmsMgrSchedulerTest, ClearProcessByToken_001, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + ASSERT_NE(amsMgrScheduler, nullptr); + sptr token; + amsMgrScheduler->ClearProcessByToken(token); +} + +/* + * Feature: AmsMgrScheduler + * Function: ClearProcessByToken + * SubFunction: NA + * FunctionPoints: AmsMgrScheduler ClearProcessByToken + * EnvConditions: NA + * CaseDescription: caller is not foundation + */ +HWTEST_F(AmsMgrSchedulerTest, ClearProcessByToken_002, TestSize.Level0) +{ + auto amsMgrScheduler = std::make_unique(nullptr, nullptr); + amsMgrScheduler->amsMgrServiceInner_ = GetMockAppMgrServiceInner(); + amsMgrScheduler->amsHandler_ = GetAmsTaskHandler(); + ASSERT_NE(amsMgrScheduler, nullptr); + sptr token; + amsMgrScheduler->ClearProcessByToken(token); +} + } // namespace AppExecFwk } // namespace OHOS diff --git a/test/unittest/ams_mgr_scheduler_test/mock/include/mock_my_flag.h b/test/unittest/ams_mgr_scheduler_test/mock/include/mock_my_flag.h new file mode 100644 index 0000000000..2ee3eafe7f --- /dev/null +++ b/test/unittest/ams_mgr_scheduler_test/mock/include/mock_my_flag.h @@ -0,0 +1,31 @@ +/* + * 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 MOCK_MY_FLAG_H +#define MOCK_MY_FLAG_H +namespace OHOS { +namespace AAFwk { +class MyFlag { +public: + enum FLAG { + IS_SA_CALL = 1, + IS_SHELL_CALL, + IS_SA_AND_SHELL_CALL, + }; + static int flag_; +}; +} // namespace AAFwk +} // namespace OHOS +#endif // MOCK_MY_FLAG_H \ No newline at end of file diff --git a/test/unittest/ams_mgr_scheduler_test/mock/include/mock_permission_verification.h b/test/unittest/ams_mgr_scheduler_test/mock/include/mock_permission_verification.h new file mode 100644 index 0000000000..fe2bcb25d5 --- /dev/null +++ b/test/unittest/ams_mgr_scheduler_test/mock/include/mock_permission_verification.h @@ -0,0 +1,98 @@ +/* + * 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_PERMISSION_VERIFICATION_H +#define OHOS_ABILITY_RUNTIME_PERMISSION_VERIFICATION_H + +#include + +#include "ipc_skeleton.h" +#include "singleton.h" +#include "want.h" +#include "mock_my_flag.h" + +namespace OHOS { +namespace AAFwk { + +class PermissionVerification : public DelayedSingleton { +public: +struct VerificationInfo { + bool visible = false; + bool isBackgroundCall = true; + bool associatedWakeUp = false; + uint32_t accessTokenId = 0; + int32_t apiTargetVersion = 0; +}; + + PermissionVerification() = default; + ~PermissionVerification() = default; + + bool VerifyCallingPermission(const std::string &permissionName) const; + + bool IsSACall() const; + + bool IsShellCall() const; + + bool CheckSpecificSystemAbilityAccessPermission() const; + + bool VerifyRunningInfoPerm() const; + + bool VerifyControllerPerm() const; + + bool VerifyDlpPermission(Want &want) const; + + int VerifyAccountPermission() const; + + bool VerifyMissionPermission() const; + + int VerifyAppStateObserverPermission() const; + + int32_t VerifyUpdateConfigurationPerm() const; + + bool VerifyInstallBundlePermission() const; + + bool VerifyGetBundleInfoPrivilegedPermission() const; + + int CheckCallDataAbilityPermission(const VerificationInfo &verificationInfo, bool isShell) const; + + int CheckCallServiceAbilityPermission(const VerificationInfo &verificationInfo) const; + + int CheckCallAbilityPermission(const VerificationInfo &verificationInfo) const; + + int CheckCallServiceExtensionPermission(const VerificationInfo &verificationInfo) const; + + int CheckStartByCallPermission(const VerificationInfo &verificationInfo) const; + + unsigned int GetCallingTokenID() const; + + bool JudgeStartInvisibleAbility(const uint32_t accessTokenId, const bool visible) const; + + bool JudgeStartAbilityFromBackground(const bool isBackgroundCall) const; + + bool JudgeAssociatedWakeUp(const uint32_t accessTokenId, const bool associatedWakeUp) const; + + int JudgeInvisibleAndBackground(const VerificationInfo &verificationInfo) const; + + inline bool IsCallFromSameAccessToken(const uint32_t accessTokenId) const + { + return IPCSkeleton::GetCallingTokenID() == accessTokenId; + } + + bool JudgeCallerIsAllowedToUseSystemAPI() const; + bool IsSystemAppCall() const; +}; +} // namespace AAFwk +} // namespace OHOS +#endif // OHOS_ABILITY_RUNTIME_PERMISSION_VERIFICATION_H \ No newline at end of file diff --git a/test/unittest/ams_mgr_scheduler_test/mock/src/mock_my_flag.cpp b/test/unittest/ams_mgr_scheduler_test/mock/src/mock_my_flag.cpp new file mode 100644 index 0000000000..d94439252b --- /dev/null +++ b/test/unittest/ams_mgr_scheduler_test/mock/src/mock_my_flag.cpp @@ -0,0 +1,22 @@ +/* + * 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 "mock_my_flag.h" + +namespace OHOS { +namespace AAFwk { +int MyFlag::flag_ = 1; +} // namespace AAFwk +} // namespace OHOS \ No newline at end of file diff --git a/test/unittest/ams_mgr_scheduler_test/mock/src/mock_permission_verification.cpp b/test/unittest/ams_mgr_scheduler_test/mock/src/mock_permission_verification.cpp new file mode 100644 index 0000000000..83622f9101 --- /dev/null +++ b/test/unittest/ams_mgr_scheduler_test/mock/src/mock_permission_verification.cpp @@ -0,0 +1,126 @@ +/* + * 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 "hilog_tag_wrapper.h" +#include "hilog_wrapper.h" +#include "mock_permission_verification.h" + +namespace OHOS { +namespace AAFwk { + +bool PermissionVerification::VerifyCallingPermission(const std::string &permissionName) const +{ + return !!(MyFlag::flag_); +} +bool PermissionVerification::IsSACall() const +{ + return (MyFlag::flag_ & MyFlag::FLAG::IS_SA_CALL); +} +bool PermissionVerification::IsShellCall() const +{ + return (MyFlag::flag_ & MyFlag::FLAG::IS_SHELL_CALL); +} +bool PermissionVerification::CheckSpecificSystemAbilityAccessPermission() const +{ + TAG_LOGD(AAFwkTag::TEST, "mock CheckSpecificSystemAbilityAccessPermission flag_: %{public}d.", MyFlag::flag_); + return !!(MyFlag::flag_); +} +bool PermissionVerification::VerifyRunningInfoPerm() const +{ + return !!(MyFlag::flag_); +} +bool PermissionVerification::VerifyControllerPerm() const +{ + return !!(MyFlag::flag_); +} +bool PermissionVerification::VerifyDlpPermission(Want &want) const +{ + return !!(MyFlag::flag_); +} +int PermissionVerification::VerifyAccountPermission() const +{ + return MyFlag::flag_; +} +bool PermissionVerification::VerifyMissionPermission() const +{ + return !!(MyFlag::flag_); +} +int PermissionVerification::VerifyAppStateObserverPermission() const +{ + return MyFlag::flag_; +} +int32_t PermissionVerification::VerifyUpdateConfigurationPerm() const +{ + return static_cast(MyFlag::flag_); +} +bool PermissionVerification::VerifyInstallBundlePermission() const +{ + return !!(MyFlag::flag_); +} +bool PermissionVerification::VerifyGetBundleInfoPrivilegedPermission() const +{ + return !!(MyFlag::flag_); +} +int PermissionVerification::CheckCallDataAbilityPermission(const VerificationInfo &verificationInfo, bool isShell) const +{ + return MyFlag::flag_; +} +int PermissionVerification::CheckCallServiceAbilityPermission(const VerificationInfo &verificationInfo) const +{ + return MyFlag::flag_; +} +int PermissionVerification::CheckCallAbilityPermission(const VerificationInfo &verificationInfo) const +{ + return MyFlag::flag_; +} +int PermissionVerification::CheckCallServiceExtensionPermission(const VerificationInfo &verificationInfo) const +{ + return MyFlag::flag_; +} +int PermissionVerification::CheckStartByCallPermission(const VerificationInfo &verificationInfo) const +{ + return MyFlag::flag_; +} +unsigned int PermissionVerification::GetCallingTokenID() const +{ + return static_cast(MyFlag::flag_); +} +bool PermissionVerification::JudgeStartInvisibleAbility(const uint32_t accessTokenId, const bool visible) const +{ + return !!(MyFlag::flag_); +} +bool PermissionVerification::JudgeStartAbilityFromBackground(const bool isBackgroundCall) const +{ + return !!(MyFlag::flag_); +} +bool PermissionVerification::JudgeAssociatedWakeUp(const uint32_t accessTokenId, const bool associatedWakeUp) const +{ + return !!(MyFlag::flag_); +} +int PermissionVerification::JudgeInvisibleAndBackground(const VerificationInfo &verificationInfo) const +{ + return MyFlag::flag_; +} +bool PermissionVerification::JudgeCallerIsAllowedToUseSystemAPI() const +{ + TAG_LOGD(AAFwkTag::TEST, "mock JudgeCallerIsAllowedToUseSystemAPI flag_: %{public}d.", MyFlag::flag_); + return MyFlag::flag_; +} +bool PermissionVerification::IsSystemAppCall() const +{ + return true; +} +} // namespace AAFwk +} // namespace OHOS \ No newline at end of file diff --git a/test/unittest/app_config_data_manager_test/BUILD.gn b/test/unittest/app_config_data_manager_test/BUILD.gn new file mode 100644 index 0000000000..699f0fc9a1 --- /dev/null +++ b/test/unittest/app_config_data_manager_test/BUILD.gn @@ -0,0 +1,80 @@ +# Copyright (c) 2021-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/appmgr" + +ohos_unittest("app_config_data_manager_test") { + module_out_path = module_output_path + cflags_cc = [] + include_dirs = [ + "${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper", + "${ability_runtime_services_path}/appmgr/include", + "${distributeddatamgr_path}/kv_store/interfaces/innerkits/distributeddata/include", + ] + + sources = [ + "${ability_runtime_services_path}/appmgr/src/app_config_data_manager.cpp", + ] + + sources += [ "app_config_data_manager_test.cpp" ] + + configs = [ "${ability_runtime_test_path}/unittest:appmgr_test_config" ] + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + deps = [ + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_native_path}/appkit:appkit_manager_helper", + "${ability_runtime_services_path}/appmgr:libappms", + "${ability_runtime_services_path}/common:perm_verification", + "${ability_runtime_services_path}/common:task_handler_wrap", + "${ability_runtime_test_path}/unittest:appmgr_test_source", + ] + + external_deps = [ + "access_token:libaccesstoken_sdk", + "access_token:libnativetoken", + "access_token:libtoken_setproc", + "appspawn:appspawn_client", + "bundle_framework:appexecfwk_core", + "ffrt:libffrt", + "hilog:libhilog", + "ipc:ipc_core", + "kv_store:distributeddata_inner", + "kv_store:distributeddata_mgr", + ] + + defines = [ "AMS_LOG_TAG = \"AppMgrService\"" ] + + if (ability_command_for_test) { + defines += [ "ABILITY_COMMAND_FOR_TEST" ] + } + + if (ability_runtime_graphics) { + defines += [ "SUPPORT_GRAPHICS" ] + deps += [] + external_deps += [ + "i18n:intl_util", + "window_manager:libwm", + ] + } +} + +group("unittest") { + testonly = true + deps = [ ":app_config_data_manager_test" ] +} diff --git a/test/unittest/app_config_data_manager_test/app_config_data_manager_test.cpp b/test/unittest/app_config_data_manager_test/app_config_data_manager_test.cpp new file mode 100644 index 0000000000..a0d65fe79c --- /dev/null +++ b/test/unittest/app_config_data_manager_test/app_config_data_manager_test.cpp @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2021-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 + +#include "app_config_data_manager.h" +#include "app_state_callback_host.h" +#include "errors.h" +#include "hilog_tag_wrapper.h" +#include "hilog_wrapper.h" +#include "mock_ability_token.h" + +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace AppExecFwk { +class AppConfigDataManagerTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp(); + void TearDown(); +public: +protected: + static const std::string GetTestBundleName() + { + return "test_bundle_name"; + } + static const std::string GetTestAbilityInfoName() + { + return "test_ability_info_name"; + } + static const std::string GetTestModuleName() + { + return "test_module_name"; + } +}; + +void AppConfigDataManagerTest::SetUpTestCase() +{} + +void AppConfigDataManagerTest::TearDownTestCase() +{} + +void AppConfigDataManagerTest::SetUp() +{} + +void AppConfigDataManagerTest::TearDown() +{} + + +/* + * Feature: AppConfigDataManager + * Function: SetAppWaitingDebugInfo + * SubFunction: NA + * FunctionPoints: AppConfigDataManager SetAppWaitingDebugInfo + * EnvConditions: NA + * CaseDescription: bundle name empty + */ +HWTEST_F(AppConfigDataManagerTest, SetAppWaitingDebugInfo_001, TestSize.Level1) +{ + auto manager = std::make_shared(); + const std::string bundleName; + auto iret = manager->SetAppWaitingDebugInfo(bundleName); + ASSERT_EQ(iret, ERR_INVALID_VALUE); +} + +/* + * Feature: AppConfigDataManager + * Function: SetAppWaitingDebugInfo + * SubFunction: NA + * FunctionPoints: AppConfigDataManager SetAppWaitingDebugInfo + * EnvConditions: NA + * CaseDescription: set ok + */ +HWTEST_F(AppConfigDataManagerTest, SetAppWaitingDebugInfo_002, TestSize.Level1) +{ + auto manager = std::make_shared(); + const std::string bundleName = "bundle"; + auto iret = manager->SetAppWaitingDebugInfo(bundleName); + ASSERT_EQ(iret, ERR_OK); +} + +/* + * Feature: AppConfigDataManager + * Function: ClearAppWaitingDebugInfo + * SubFunction: NA + * FunctionPoints: AppConfigDataManager ClearAppWaitingDebugInfo + * EnvConditions: NA + * CaseDescription: clear ok + */ +HWTEST_F(AppConfigDataManagerTest, ClearAppWaitingDebugInfo_001, TestSize.Level1) +{ + auto manager = std::make_shared(); + auto iret = manager->ClearAppWaitingDebugInfo(); + ASSERT_EQ(iret, ERR_OK); +} + +/* + * Feature: AppConfigDataManager + * Function: GetAppWaitingDebugList + * SubFunction: NA + * FunctionPoints: AppConfigDataManager GetAppWaitingDebugList + * EnvConditions: NA + * CaseDescription: get ok + */ +HWTEST_F(AppConfigDataManagerTest, GetAppWaitingDebugList_001, TestSize.Level1) +{ + auto manager = std::make_shared(); + std::vector bundleNameList; + auto iret = manager->GetAppWaitingDebugList(bundleNameList); + ASSERT_EQ(iret, ERR_OK); +} + +} // namespace AppExecFwk +} // namespace OHOS diff --git a/test/unittest/app_mgr_client_test/app_mgr_client_test.cpp b/test/unittest/app_mgr_client_test/app_mgr_client_test.cpp index 60275e48ef..1781f7576d 100644 --- a/test/unittest/app_mgr_client_test/app_mgr_client_test.cpp +++ b/test/unittest/app_mgr_client_test/app_mgr_client_test.cpp @@ -1240,20 +1240,6 @@ HWTEST_F(AppMgrClientTest, ClearNonPersistWaitingDebugFlag_001, TestSize.Level0) EXPECT_NE(appMgrClient, nullptr); } -/** - * @tc.name: AppMgrClient_SetAppAssertionPauseState_001 - * @tc.desc: SetAppAssertionPauseState. - * @tc.type: FUNC - */ -HWTEST_F(AppMgrClientTest, SetAppAssertionPauseState_001, TestSize.Level0) -{ - auto appMgrClient = std::make_unique(); - int32_t pid = 1; - bool flag = true; - appMgrClient->SetAppAssertionPauseState(pid, flag); - EXPECT_NE(appMgrClient, nullptr); -} - /** * @tc.name: AppMgrClient_IsAttachDebug_001 * @tc.desc: IsAttachDebug. diff --git a/test/unittest/app_mgr_proxy_test/app_mgr_proxy_test.cpp b/test/unittest/app_mgr_proxy_test/app_mgr_proxy_test.cpp index 4ea49c5de9..28764ffc28 100644 --- a/test/unittest/app_mgr_proxy_test/app_mgr_proxy_test.cpp +++ b/test/unittest/app_mgr_proxy_test/app_mgr_proxy_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Copyright (c) 2022-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 @@ -603,5 +603,28 @@ HWTEST_F(AppMgrProxyTest, SetSupportedProcessCacheSelf_001, TestSize.Level0) TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); } + +/** + * @tc.name: GetRunningMultiAppInfoByBundleName_001 + * @tc.desc: Get multiApp information by bundleName. + * @tc.type: FUNC + * @tc.require: issueI9HMAO + */ +HWTEST_F(AppMgrProxyTest, GetRunningMultiAppInfoByBundleName_001, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + + EXPECT_CALL(*mockAppMgrService_, SendRequest(_, _, _, _)) + .Times(1) + .WillOnce(Invoke(mockAppMgrService_.GetRefPtr(), &MockAppMgrService::InvokeSendRequest)); + + std::string bundleName = "testBundleName"; + RunningMultiAppInfo info; + appMgrProxy_->GetRunningMultiAppInfoByBundleName(bundleName, info); + EXPECT_EQ(mockAppMgrService_->code_, static_cast + (AppMgrInterfaceCode::GET_RUNNING_MULTIAPP_INFO_BY_BUNDLENAME)); + + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} } // namespace AppExecFwk } // namespace OHOS diff --git a/test/unittest/app_mgr_service_inner_tdd_test/app_mgr_service_inner_tdd_test.cpp b/test/unittest/app_mgr_service_inner_tdd_test/app_mgr_service_inner_tdd_test.cpp index a43999cab2..aae2dd24f1 100644 --- a/test/unittest/app_mgr_service_inner_tdd_test/app_mgr_service_inner_tdd_test.cpp +++ b/test/unittest/app_mgr_service_inner_tdd_test/app_mgr_service_inner_tdd_test.cpp @@ -574,5 +574,125 @@ HWTEST_F(AppMgrServiceInnerTest, ChangeAppGcState_001, TestSize.Level1) EXPECT_EQ(ret, ERR_INVALID_VALUE); TAG_LOGI(AAFwkTag::TEST, "ChangeAppGcState_001 end"); } + +/** + * @tc.name: QueryExtensionSandBox_001 + * @tc.desc: query extension sandBox. + * @tc.type: FUNC + */ +HWTEST_F(AppMgrServiceInnerTest, QueryExtensionSandBox_001, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "QueryExtensionSandBox_001 start"); + auto appMgrServiceInner = std::make_shared(); + EXPECT_NE(appMgrServiceInner, nullptr); + const string moduleName = "entry"; + const string extensionName = "inputMethod"; + BundleInfo bundleInfo; + HapModuleInfo hapModuleInfo; + ExtensionAbilityInfo extensionAbilityInfo; + extensionAbilityInfo.name = "inputMethod"; + extensionAbilityInfo.moduleName = "entry"; + extensionAbilityInfo.needCreateSandbox = true; + extensionAbilityInfo.dataGroupIds = {"test1"}; + hapModuleInfo.extensionInfos.emplace_back(extensionAbilityInfo); + bundleInfo.hapModuleInfos.emplace_back(hapModuleInfo); + AppSpawnStartMsg startMsg; + DataGroupInfoList dataGroupInfoList; + DataGroupInfo dataGroupInfo; + dataGroupInfo.dataGroupId = "test1"; + dataGroupInfoList.emplace_back(dataGroupInfo); + bool strictMode = false; + appMgrServiceInner->QueryExtensionSandBox(moduleName, extensionName, bundleInfo, startMsg, dataGroupInfoList, + strictMode); + EXPECT_EQ(startMsg.dataGroupInfoList.size(), 1); + TAG_LOGI(AAFwkTag::TEST, "QueryExtensionSandBox_001 end"); +} + +/** + * @tc.name: QueryExtensionSandBox_002 + * @tc.desc: query extension sandBox. + * @tc.type: FUNC + */ +HWTEST_F(AppMgrServiceInnerTest, QueryExtensionSandBox_002, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "QueryExtensionSandBox_002 start"); + auto appMgrServiceInner = std::make_shared(); + EXPECT_NE(appMgrServiceInner, nullptr); + const string moduleName = "entry"; + const string extensionName = "inputMethod"; + BundleInfo bundleInfo; + HapModuleInfo hapModuleInfo; + ExtensionAbilityInfo extensionAbilityInfo; + extensionAbilityInfo.name = "inputMethod"; + extensionAbilityInfo.moduleName = "entry"; + extensionAbilityInfo.needCreateSandbox = true; + extensionAbilityInfo.dataGroupIds = {"test2"}; + hapModuleInfo.extensionInfos.emplace_back(extensionAbilityInfo); + bundleInfo.hapModuleInfos.emplace_back(hapModuleInfo); + AppSpawnStartMsg startMsg; + DataGroupInfoList dataGroupInfoList; + DataGroupInfo dataGroupInfo; + dataGroupInfo.dataGroupId = "test3"; + dataGroupInfoList.emplace_back(dataGroupInfo); + bool strictMode = false; + appMgrServiceInner->QueryExtensionSandBox(moduleName, extensionName, bundleInfo, startMsg, dataGroupInfoList, + strictMode); + EXPECT_EQ(startMsg.dataGroupInfoList.size(), 0); + TAG_LOGI(AAFwkTag::TEST, "QueryExtensionSandBox_002 end"); +} + +/** + * @tc.name: QueryExtensionSandBox_003 + * @tc.desc: query extension sandBox. + * @tc.type: FUNC + */ +HWTEST_F(AppMgrServiceInnerTest, QueryExtensionSandBox_003, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "QueryExtensionSandBox_003 start"); + auto appMgrServiceInner = std::make_shared(); + EXPECT_NE(appMgrServiceInner, nullptr); + const string moduleName = "entry"; + const string extensionName = "inputMethod"; + BundleInfo bundleInfo; + HapModuleInfo hapModuleInfo; + ExtensionAbilityInfo extensionAbilityInfo; + extensionAbilityInfo.name = "inputMethod"; + extensionAbilityInfo.moduleName = "entry"; + extensionAbilityInfo.needCreateSandbox = false; + AppSpawnStartMsg startMsg; + DataGroupInfoList dataGroupInfoList; + bool strictMode = false; + appMgrServiceInner->QueryExtensionSandBox(moduleName, extensionName, bundleInfo, startMsg, dataGroupInfoList, + strictMode); + EXPECT_EQ(startMsg.dataGroupInfoList.size(), 0); + TAG_LOGI(AAFwkTag::TEST, "QueryExtensionSandBox_003 end"); +} + +/** + * @tc.name: QueryExtensionSandBox_004 + * @tc.desc: query extension sandBox. + * @tc.type: FUNC + */ +HWTEST_F(AppMgrServiceInnerTest, QueryExtensionSandBox_004, TestSize.Level0) +{ + TAG_LOGI(AAFwkTag::TEST, "QueryExtensionSandBox_004 start"); + auto appMgrServiceInner = std::make_shared(); + EXPECT_NE(appMgrServiceInner, nullptr); + const string moduleName = "entry"; + const string extensionName = "inputMethod"; + BundleInfo bundleInfo; + HapModuleInfo hapModuleInfo; + ExtensionAbilityInfo extensionAbilityInfo; + extensionAbilityInfo.name = "inputMethod1"; + extensionAbilityInfo.moduleName = "entry"; + extensionAbilityInfo.needCreateSandbox = true; + AppSpawnStartMsg startMsg; + DataGroupInfoList dataGroupInfoList; + bool strictMode = false; + appMgrServiceInner->QueryExtensionSandBox(moduleName, extensionName, bundleInfo, startMsg, dataGroupInfoList, + strictMode); + EXPECT_EQ(startMsg.dataGroupInfoList.size(), 0); + TAG_LOGI(AAFwkTag::TEST, "QueryExtensionSandBox_004 end"); +} } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file diff --git a/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp b/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp index 7d85202677..7286dd1673 100644 --- a/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp +++ b/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp @@ -44,6 +44,19 @@ using namespace testing::ext; namespace OHOS { namespace AppExecFwk { +class WindowFocusChangedListener : public OHOS::Rosen::IFocusChangedListener { +public: + WindowFocusChangedListener(const std::shared_ptr& owner, + const std::shared_ptr& handler); + virtual ~WindowFocusChangedListener(); + + void OnFocused(const sptr &focusChangeInfo) override; + void OnUnfocused(const sptr &focusChangeInfo) override; + +private: + std::weak_ptr owner_; + std::shared_ptr taskHandler_; +}; namespace { constexpr int32_t RECORD_ID = 1; constexpr int32_t APP_DEBUG_INFO_PID = 0; @@ -4282,5 +4295,29 @@ HWTEST_F(AppMgrServiceInnerTest, OnAppCacheStateChanged_001, TestSize.Level0) TAG_LOGI(AAFwkTag::TEST, "OnAppCacheStateChanged_001 end"); } + +/** + * @tc.name: GetRunningMultiAppInfoByBundleName_001 + * @tc.desc: Get multiApp information list by bundleName. + * @tc.type: FUNC + * @tc.require: issueI9HMAO + */ +HWTEST_F(AppMgrServiceInnerTest, GetRunningMultiAppInfoByBundleName_001, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "GetRunningMultiAppInfoByBundleName_001 start"); + auto appMgrServiceInner = std::make_shared(); + EXPECT_NE(appMgrServiceInner, nullptr); + + std::string bundleName = "testBundleName"; + RunningMultiAppInfo info; + int32_t ret = appMgrServiceInner->GetRunningMultiAppInfoByBundleName(bundleName, info); + EXPECT_NE(ret, ERR_OK); + + appMgrServiceInner->appRunningManager_ = nullptr; + ret = appMgrServiceInner->GetRunningMultiAppInfoByBundleName(bundleName, info); + EXPECT_EQ(ret, ERR_INVALID_VALUE); + + TAG_LOGI(AAFwkTag::TEST, "GetRunningMultiAppInfoByBundleName_001 end"); +} } // namespace AppExecFwk } // namespace OHOS diff --git a/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp b/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp index 30ecef7802..5136b144f3 100644 --- a/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp +++ b/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp @@ -1731,5 +1731,73 @@ HWTEST_F(AppMgrServiceTest, SetSupportedProcessCacheSelf_002, TestSize.Level0) res = appMgrService->SetSupportedProcessCacheSelf(false); EXPECT_EQ(res, AAFwk::ERR_SET_SUPPORTED_PROCESS_CACHE_AGAIN); } + +/** + * @tc.name: StartNativeChildProcess_0100 + * @tc.desc: Start native child process. + * @tc.type: FUNC + */ +HWTEST_F(AppMgrServiceTest, StartNativeChildProcess_0100, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "StartNativeChildProcess_0100 called."); + sptr appMgrService = new (std::nothrow) AppMgrService(); + ASSERT_NE(appMgrService, nullptr); + + appMgrService->SetInnerService(mockAppMgrServiceInner_); + appMgrService->taskHandler_ = taskHandler_; + appMgrService->eventHandler_ = eventHandler_; + + EXPECT_CALL(*mockAppMgrServiceInner_, StartNativeChildProcess(_, _, _, _)) + .Times(1) + .WillOnce(Return(ERR_OK)); + + pid_t pid = 0; + sptr callback; + int32_t res = appMgrService->StartNativeChildProcess("test.so", 1, callback); + EXPECT_EQ(res, ERR_OK); +} + +/* + * Feature: AppMgrService + * Function: GetRunningMultiAppInfoByBundleName + * SubFunction: NA + * FunctionPoints: AppMgrService GetRunningMultiAppInfoByBundleName + * EnvConditions: NA + * CaseDescription: Verify GetRunningMultiAppInfoByBundleName + */ +HWTEST_F(AppMgrServiceTest, GetRunningMultiAppInfoByBundleName_001, TestSize.Level1) +{ + auto appMgrService = std::make_shared(); + ASSERT_NE(appMgrService, nullptr); + appMgrService->SetInnerService(nullptr); + + std::string bundleName = "testBundleName"; + RunningMultiAppInfo info; + int32_t res = appMgrService->GetRunningMultiAppInfoByBundleName(bundleName, info); + EXPECT_EQ(res, ERR_INVALID_OPERATION); +} + +/* + * Feature: AppMgrService + * Function: GetRunningMultiAppInfoByBundleName + * SubFunction: NA + * FunctionPoints: AppMgrService GetRunningMultiAppInfoByBundleName + * EnvConditions: NA + * CaseDescription: Verify GetRunningMultiAppInfoByBundleName + */ +HWTEST_F(AppMgrServiceTest, GetRunningMultiAppInfoByBundleName_002, TestSize.Level1) +{ + auto appMgrService = std::make_shared(); + ASSERT_NE(appMgrService, nullptr); + appMgrService->SetInnerService(nullptr); + appMgrService->taskHandler_ = taskHandler_; + appMgrService->eventHandler_ = eventHandler_; + + std::string bundleName = "testbundlename"; + RunningMultiAppInfo info; + + int32_t ret = appMgrService->GetRunningMultiAppInfoByBundleName(bundleName, info); + EXPECT_NE(ret, ERR_OK); +} } // namespace AppExecFwk -} // namespace OHOS +} // namespace OHOS \ No newline at end of file diff --git a/test/unittest/app_mgr_stub_test/app_mgr_stub_test.cpp b/test/unittest/app_mgr_stub_test/app_mgr_stub_test.cpp index 9cc2a0d3b5..d1369d8fe5 100644 --- a/test/unittest/app_mgr_stub_test/app_mgr_stub_test.cpp +++ b/test/unittest/app_mgr_stub_test/app_mgr_stub_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Copyright (c) 2022-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 @@ -616,5 +616,31 @@ HWTEST_F(AppMgrStubTest, SetSupportedProcessCacheSelf_001, TestSize.Level0) TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); } + +/** + * @tc.name: GetRunningMultiAppInfoByBundleName_001 + * @tc.desc: Get multiapp information by bundleName. + * @tc.type: FUNC + * @tc.require: issueI9HMAO + */ +HWTEST_F(AppMgrStubTest, GetRunningMultiAppInfoByBundleName_001, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + MessageParcel data; + MessageParcel reply; + MessageOption option; + + WriteInterfaceToken(data); + std::string bundleName = "testBundleName"; + data.WriteString(bundleName); + + EXPECT_CALL(*mockAppMgrService_, GetRunningMultiAppInfoByBundleName(_, _)).Times(1); + + auto result = mockAppMgrService_->OnRemoteRequest( + static_cast(AppMgrInterfaceCode::GET_RUNNING_MULTIAPP_INFO_BY_BUNDLENAME), data, reply, option); + EXPECT_EQ(result, NO_ERROR); + + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} } // namespace AppExecFwk } // namespace OHOS diff --git a/test/unittest/app_recovery_test/app_recovery_test.cpp b/test/unittest/app_recovery_test/app_recovery_test.cpp index 54bb600cd9..fd7c63b68b 100644 --- a/test/unittest/app_recovery_test/app_recovery_test.cpp +++ b/test/unittest/app_recovery_test/app_recovery_test.cpp @@ -30,6 +30,8 @@ #include "mock_ability_token.h" #include "recovery_param.h" #include "ui_ability.h" +#define private public +#include "context/application_context.h" using namespace testing::ext; namespace OHOS { @@ -683,5 +685,18 @@ HWTEST_F(AppRecoveryUnitTest, GetMissionIds_002, TestSize.Level1) std::string invalid_path = "data/apps/ohos.samples.recovery/files/"; EXPECT_FALSE(AppRecovery::GetInstance().GetMissionIds(invalid_path, missionIds)); } + +/** + * @tc.name: DeleteInValidMissionFiles_001 + * @tc.desc: Test delete invalid mission files. + * @tc.type: FUNC + * @tc.require: I5Z7LE + */ +HWTEST_F(AppRecoveryUnitTest, DeleteInValidMissionFiles_001, TestSize.Level1) +{ + AbilityRuntime::ApplicationContext::GetInstance()->contextImpl_ = std::make_shared(); + AppRecovery::GetInstance().DeleteInValidMissionFiles(); + EXPECT_NE(AbilityRuntime::Context::GetApplicationContext(), nullptr); +} } // namespace AppExecFwk } // namespace OHOS diff --git a/test/unittest/app_running_processes_info_test/BUILD.gn b/test/unittest/app_running_processes_info_test/BUILD.gn index 0d49d16a71..c3dc6f6e77 100644 --- a/test/unittest/app_running_processes_info_test/BUILD.gn +++ b/test/unittest/app_running_processes_info_test/BUILD.gn @@ -31,7 +31,6 @@ ohos_unittest("AppRunningProcessesInfoTest") { "${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", "${ability_runtime_services_path}/appmgr/src/app_preloader.cpp", "${ability_runtime_services_path}/appmgr/src/app_running_record.cpp", "${ability_runtime_services_path}/appmgr/src/app_running_status_module.cpp", diff --git a/test/unittest/appkit/child_main_thread_test/child_main_thread_test.cpp b/test/unittest/appkit/child_main_thread_test/child_main_thread_test.cpp index fd8b9929d4..9bfcea64c4 100644 --- a/test/unittest/appkit/child_main_thread_test/child_main_thread_test.cpp +++ b/test/unittest/appkit/child_main_thread_test/child_main_thread_test.cpp @@ -170,5 +170,26 @@ HWTEST_F(ChildMainThreadTest, ScheduleExitProcessSafely_0100, TestSize.Level0) auto ret = thread->ScheduleExitProcessSafely(); EXPECT_TRUE(ret); } + +/** + * @tc.number: ScheduleRunNativeProc_0100 + * @tc.desc: Test ScheduleRunNativeProc works + * @tc.type: FUNC + */ +HWTEST_F(ChildMainThreadTest, ScheduleRunNativeProc_0100, TestSize.Level0) +{ + TAG_LOGD(AAFwkTag::TEST, "ScheduleRunNativeProc_0100 called."); + sptr thread = sptr(new (std::nothrow) ChildMainThread()); + ASSERT_NE(thread, nullptr); + + std::shared_ptr runner = EventRunner::GetMainEventRunner(); + std::shared_ptr handler = std::make_shared(runner); + thread->mainHandler_ = handler; + + sptr mainPorcessCb = nullptr; + auto ret = thread->ScheduleRunNativeProc(mainPorcessCb); + EXPECT_FALSE(ret); +} + } // namespace AppExecFwk } // namespace OHOS diff --git a/test/unittest/appkit/main_thread_test/main_thread_test.cpp b/test/unittest/appkit/main_thread_test/main_thread_test.cpp index aaff673876..50af33d0d2 100644 --- a/test/unittest/appkit/main_thread_test/main_thread_test.cpp +++ b/test/unittest/appkit/main_thread_test/main_thread_test.cpp @@ -198,7 +198,7 @@ class MockAppMgrStub : public AppMgrStub { } int StartRenderProcess(const std::string &renderParam, int32_t ipcFd, - int32_t sharedFd, int32_t crashFd, pid_t &renderPid) override + int32_t sharedFd, int32_t crashFd, pid_t &renderPid, bool isGPU = false) override { return 0; } diff --git a/test/unittest/bundle_mgr_helper_test/bundle_mgr_helper_test.cpp b/test/unittest/bundle_mgr_helper_test/bundle_mgr_helper_test.cpp index 9f894fe305..8cebf777bd 100644 --- a/test/unittest/bundle_mgr_helper_test/bundle_mgr_helper_test.cpp +++ b/test/unittest/bundle_mgr_helper_test/bundle_mgr_helper_test.cpp @@ -812,9 +812,9 @@ HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_QueryCloneAbilityInfo_001, Tes ElementName element; AbilityInfo abilityInfo; int32_t flags = ABILITY_INFO_FLAG; - int32_t appTwinIndex = 1; + int32_t appCloneIndex = 1; int32_t userId = DEFAULT_USERID; - auto ret = bundleMgrHelper->QueryCloneAbilityInfo(element, flags, appTwinIndex, abilityInfo, userId); + auto ret = bundleMgrHelper->QueryCloneAbilityInfo(element, flags, appCloneIndex, abilityInfo, userId); EXPECT_NE(ret, ERR_OK); } @@ -828,9 +828,36 @@ HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetCloneBundleInfo_001, TestSi std::string bundleName; BundleInfo bundleInfo; int32_t flags = 1; - int32_t appTwinIndex = 1; + int32_t appCloneIndex = 1; int32_t userId = DEFAULT_USERID; - auto ret = bundleMgrHelper->GetCloneBundleInfo(bundleName, flags, appTwinIndex, bundleInfo, userId); + auto ret = bundleMgrHelper->GetCloneBundleInfo(bundleName, flags, appCloneIndex, bundleInfo, userId); + EXPECT_NE(ret, ERR_OK); +} + +/** + * @tc.name: BundleMgrHelperTest_GetNameForUid_001 + * @tc.desc: GetNameForUid + * @tc.type: FUNC + */ +HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetNameForUid_001, TestSize.Level1) +{ + std::string name; + int32_t uid = 1; + auto ret = bundleMgrHelper->GetNameForUid(uid, name); + EXPECT_NE(ret, ERR_OK); +} + +/** + * @tc.name: BundleMgrHelperTest_GetLaunchWantForBundle_001 + * @tc.desc: GetLaunchWantForBundle + * @tc.type: FUNC + */ +HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetLaunchWantForBundle_001, TestSize.Level1) +{ + std::string bundleName; + Want want; + int32_t userId = DEFAULT_USERID; + auto ret = bundleMgrHelper->GetLaunchWantForBundle(bundleName, want, userId); EXPECT_NE(ret, ERR_OK); } } // namespace AppExecFwk diff --git a/test/unittest/cache_process_manager_test/cache_process_manager_test.cpp b/test/unittest/cache_process_manager_test/cache_process_manager_test.cpp index 500e952bcc..edfa2201ef 100644 --- a/test/unittest/cache_process_manager_test/cache_process_manager_test.cpp +++ b/test/unittest/cache_process_manager_test/cache_process_manager_test.cpp @@ -126,6 +126,7 @@ HWTEST_F(CacheProcessManagerTest, CacheProcessManager_PenddingCacheProcess_0100, auto appRecord = MockAppRecord(); EXPECT_NE(appRecord, nullptr); appRecord->SetKeepAliveEnableState(true); + appRecord->SetSingleton(true); appRecord->SetEmptyKeepAliveAppState(true); EXPECT_EQ(cacheProcMgr->PenddingCacheProcess(appRecord), false); // nullptr not allowed diff --git a/test/unittest/child_process_capi_test/BUILD.gn b/test/unittest/child_process_capi_test/BUILD.gn new file mode 100644 index 0000000000..ab3e96a9bd --- /dev/null +++ b/test/unittest/child_process_capi_test/BUILD.gn @@ -0,0 +1,52 @@ +# 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/child_process_capi" + +ohos_unittest("child_process_capi_test") { + module_out_path = module_output_path + + configs = [ "${ability_runtime_services_path}/common:common_config" ] + + if (target_cpu == "arm") { + cflags = [ "-DBINDER_IPC_32BIT" ] + } + + include_dirs = [ + "include", + "${ability_runtime_test_path}/mock/services_appmgr_test/include", + ] + + sources = [ "child_process_capi_test.cpp" ] + + deps = [ + "${ability_runtime_native_path}/child_process:child_process", + "${ability_runtime_services_path}/common:app_util", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "c_utils:utils", + "hilog:libhilog", + "ipc:ipc_capi", + ] +} + +group("unittest") { + testonly = true + deps = [ ":child_process_capi_test" ] +} diff --git a/test/unittest/child_process_capi_test/child_process_capi_test.cpp b/test/unittest/child_process_capi_test/child_process_capi_test.cpp new file mode 100644 index 0000000000..8ad66cbce4 --- /dev/null +++ b/test/unittest/child_process_capi_test/child_process_capi_test.cpp @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2023 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 +#include +#include "native_child_process.h" +#include "app_utils.h" + +namespace OHOS { +namespace AbilityRuntime { + +using namespace testing; +using namespace testing::ext; + +class ChildProcessCapiTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + + static void OnNativeChildProcessStarted(int errCode, OHIPCRemoteProxy *remoteProxy); + + void SetUp(); + void TearDown(); +}; + +void ChildProcessCapiTest::SetUpTestCase(void) +{} + +void ChildProcessCapiTest::TearDownTestCase(void) +{} + +void ChildProcessCapiTest::SetUp(void) +{} + +void ChildProcessCapiTest::TearDown(void) +{} + +void ChildProcessCapiTest::OnNativeChildProcessStarted(int errCode, OHIPCRemoteProxy *remoteProxy) +{ +} + +/** + * @tc.number: OH_Ability_CreateNativeChildProcess_001 + * @tc.desc: Test API OH_Ability_CreateNativeChildProcess works + * @tc.type: FUNC + */ +HWTEST_F(ChildProcessCapiTest, OH_Ability_CreateNativeChildProcess_001, TestSize.Level0) +{ + GTEST_LOG_(INFO) << "OH_Ability_CreateNativeChildProcess_001 begin"; + int ret = OH_Ability_CreateNativeChildProcess(nullptr, ChildProcessCapiTest::OnNativeChildProcessStarted); + EXPECT_EQ(ret, NCP_ERR_INVALID_PARAM); + + ret = OH_Ability_CreateNativeChildProcess("test.so", nullptr); + EXPECT_EQ(ret, NCP_ERR_INVALID_PARAM); + + ret = OH_Ability_CreateNativeChildProcess("test.so", ChildProcessCapiTest::OnNativeChildProcessStarted); + if (!AAFwk::AppUtils::GetInstance().IsMultiProcessModel()) { + EXPECT_EQ(ret, NCP_ERR_MULTI_PROCESS_DISABLED); + return; + } else if (!AAFwk::AppUtils::GetInstance().IsSupportNativeChildProcess()) { + EXPECT_EQ(ret, NCP_ERR_NOT_SUPPORTED); + return; + } + + GTEST_LOG_(INFO) << "OH_Ability_CreateNativeChildProcess return " << ret; + EXPECT_NE(ret, NCP_ERR_NOT_SUPPORTED); +} + +} // namespace AbilityRuntime +} // namespace OHOS diff --git a/test/unittest/child_process_manager_test/child_process_manager_test.cpp b/test/unittest/child_process_manager_test/child_process_manager_test.cpp index 1eaf3f3076..da364c8298 100644 --- a/test/unittest/child_process_manager_test/child_process_manager_test.cpp +++ b/test/unittest/child_process_manager_test/child_process_manager_test.cpp @@ -45,6 +45,8 @@ void ChildProcessManagerTest::SetUpTestCase() { AAFwk::AppUtils::GetInstance().isMultiProcessModel_.isLoaded = true; AAFwk::AppUtils::GetInstance().isMultiProcessModel_.value = true; + AAFwk::AppUtils::GetInstance().isSupportNativeChildProcess_.isLoaded = true; + AAFwk::AppUtils::GetInstance().isSupportNativeChildProcess_.value = true; sptr bundleMgrService = sptr(new (std::nothrow) AppExecFwk::BundleMgrService()); sptr mockAppMgrService = sptr(new (std::nothrow) AppExecFwk::MockAppMgrService()); @@ -61,6 +63,8 @@ void ChildProcessManagerTest::TearDownTestCase() { AAFwk::AppUtils::GetInstance().isMultiProcessModel_.isLoaded = false; AAFwk::AppUtils::GetInstance().isMultiProcessModel_.value = false; + AAFwk::AppUtils::GetInstance().isSupportNativeChildProcess_.isLoaded = false; + AAFwk::AppUtils::GetInstance().isSupportNativeChildProcess_.value = false; } void ChildProcessManagerTest::SetUp() @@ -226,5 +230,19 @@ AbilityRuntime::Runtime::DebugOption debugOption; ChildProcessManager::GetInstance().SetForkProcessDebugOption("test", false, false, false); EXPECT_TRUE(true); } + +/** + * @tc.number: StartNativeChildProcessByAppSpawnFork_0100 + * @tc.desc: Test StartNativeChildProcessByAppSpawnFork works. + * @tc.type: FUNC + */ +HWTEST_F(ChildProcessManagerTest, StartNativeChildProcessByAppSpawnFork_0100, TestSize.Level0) +{ + TAG_LOGD(AAFwkTag::TEST, "StartNativeChildProcessByAppSpawnFork_0100 called."); + sptr callback; + auto ret = ChildProcessManager::GetInstance().StartNativeChildProcessByAppSpawnFork("test.so", callback); + EXPECT_NE(ret, ChildProcessManagerErrorCode::ERR_FORK_FAILED); +} + } // namespace AbilityRuntime } // namespace OHOS \ No newline at end of file diff --git a/test/unittest/data_ability_observer_proxy_test/data_ability_observer_proxy_test.cpp b/test/unittest/data_ability_observer_proxy_test/data_ability_observer_proxy_test.cpp index 5bcf89b47f..7180cf0704 100644 --- a/test/unittest/data_ability_observer_proxy_test/data_ability_observer_proxy_test.cpp +++ b/test/unittest/data_ability_observer_proxy_test/data_ability_observer_proxy_test.cpp @@ -62,5 +62,54 @@ HWTEST_F(DataAbilityObserverProxyTest, DataAbilityObserverProxy_OnChangeInner_00 proxy->OnChange(); } } + +/* + * Feature: DataAbilityObserverProxy. + * Function: DataObsManagerProxy::OnChangeExt is called. + * SubFunction: NA. + * FunctionPoints: NA. + * EnvConditions: NA. + * CaseDescription: NA. + */ +HWTEST_F(DataAbilityObserverProxyTest, DataAbilityObserverProxy_OnChangeExt_001, TestSize.Level1) +{ + // 1.stub define + sptr mockDataAbilityObserverStub(new MockDataObsManagerOnChangeCallBack()); + + // 2.obsver1 define + sptr proxy(new DataAbilityObserverProxy(mockDataAbilityObserverStub)); + + ChangeInfo changeInfo; + + EXPECT_CALL(*mockDataAbilityObserverStub, OnChangeExt(testing::_)).Times(1); + + if (proxy != nullptr) { + proxy->OnChangeExt(changeInfo); + } +} + +/* + * Feature: DataAbilityObserverProxy. + * Function: DataObsManagerProxy::OnChangePreferences is called. + * SubFunction: NA. + * FunctionPoints: NA. + * EnvConditions: NA. + * CaseDescription: NA. + */ +HWTEST_F(DataAbilityObserverProxyTest, DataAbilityObserverProxy_OnChangePreferences_001, TestSize.Level1) +{ + // 1.stub define + sptr mockDataAbilityObserverStub(new MockDataObsManagerOnChangeCallBack()); + + // 2.obsver1 define + sptr proxy(new DataAbilityObserverProxy(mockDataAbilityObserverStub)); + + std::string key = "test"; + EXPECT_CALL(*mockDataAbilityObserverStub, OnChangePreferences(key)).Times(1); + + if (proxy != nullptr) { + proxy->OnChangePreferences(key); + } +} } // namespace AAFwk } // namespace OHOS diff --git a/test/unittest/data_ability_observer_proxy_test/mock_data_obs_manager_onchange_callback.h b/test/unittest/data_ability_observer_proxy_test/mock_data_obs_manager_onchange_callback.h index 42bb0bea78..13d9b0b3fd 100644 --- a/test/unittest/data_ability_observer_proxy_test/mock_data_obs_manager_onchange_callback.h +++ b/test/unittest/data_ability_observer_proxy_test/mock_data_obs_manager_onchange_callback.h @@ -27,6 +27,8 @@ namespace AAFwk { class MockDataObsManagerOnChangeCallBack : public DataAbilityObserverStub { public: MOCK_METHOD0(OnChange, void()); + MOCK_METHOD1(OnChangeExt, void(const ChangeInfo&)); + MOCK_METHOD1(OnChangePreferences, void(const std::string&)); void Wait() { diff --git a/test/unittest/dataobs_mgr_client_test/dataobs_mgr_client_test.cpp b/test/unittest/dataobs_mgr_client_test/dataobs_mgr_client_test.cpp index 8fd42dcefc..deb233ee93 100644 --- a/test/unittest/dataobs_mgr_client_test/dataobs_mgr_client_test.cpp +++ b/test/unittest/dataobs_mgr_client_test/dataobs_mgr_client_test.cpp @@ -158,5 +158,41 @@ HWTEST_F(DataObsMgrClientTest, DataObsMgrClient_ReregisterObserver_0200, TestSiz testing::Mock::AllowLeak(DataObsMgrClient::GetInstance()->dataObsManger_); } +/* + * Feature: DataObsMgrClient. + * Function: re-subscribe when service restart. + * SubFunction: NA. + * FunctionPoints: NA. + * EnvConditions: NA. + * CaseDescription: NA. + */ +HWTEST_F(DataObsMgrClientTest, DataObsMgrClient_ReregisterObserver_0300, TestSize.Level1) +{ + sptr callBack1(new (std::nothrow) MockDataObsManagerOnChangeCallBack()); + sptr callBack2(new (std::nothrow) MockDataObsManagerOnChangeCallBack()); + + auto client = DataObsMgrClient::GetInstance(); + client->observers_.Clear(); + client->observerExts_.Clear(); + + sptr service1(new (std::nothrow) MockDataObsMgrService()); + client->dataObsManger_ = service1; + EXPECT_TRUE(client->dataObsManger_ != nullptr); + Uri uri1("datashare://device_id/com.domainname.dataability.persondata/person/25"); + Uri uri2("datashare://device_id/com.domainname.dataability.persondata/person/26"); + + EXPECT_EQ(client->RegisterObserver(uri1, callBack1), NO_ERROR); + EXPECT_EQ(client->RegisterObserver(uri2, callBack2), NO_ERROR); + EXPECT_EQ(service1->onChangeCall_, 2); + + sptr service2(new (std::nothrow) MockDataObsMgrService()); + client->dataObsManger_ = service2; + EXPECT_TRUE(client->dataObsManger_ != nullptr); + + client->OnRemoteDied(); + EXPECT_EQ(service2->onChangeCall_, 0); + testing::Mock::AllowLeak(DataObsMgrClient::GetInstance()->dataObsManger_); +} + } // namespace AAFwk } // namespace OHOS diff --git a/test/unittest/dataobs_mgr_service_test/dataobs_mgr_service_test.cpp b/test/unittest/dataobs_mgr_service_test/dataobs_mgr_service_test.cpp index 9ac0da86be..032638d0d9 100644 --- a/test/unittest/dataobs_mgr_service_test/dataobs_mgr_service_test.cpp +++ b/test/unittest/dataobs_mgr_service_test/dataobs_mgr_service_test.cpp @@ -254,5 +254,30 @@ HWTEST_F(DataObsMgrServiceTest, AaFwk_DataObsMgrServiceTest_OnStop_0100, TestSiz GTEST_LOG_(INFO) << "AaFwk_DataObsMgrServiceTest_OnStop_0100 end"; } + +/* + * Feature: DataObsMgrService + * Function: Dump + * SubFunction: NA + * FunctionPoints: DataObsMgrService Dump + * EnvConditions: NA + * CaseDescription: Verify that the DataObsMgrService Dump is normal. + */ +HWTEST_F(DataObsMgrServiceTest, AaFwk_DataObsMgrServiceTest_Dump_0100, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AaFwk_DataObsMgrServiceTest_Dump_0100 start"; + const DataObsServiceRunningState testValue = DataObsServiceRunningState::STATE_RUNNING; + auto dataObsMgrServer = DelayedSingleton::GetInstance(); + + std::string fileName = "test.txt"; + std::vector args; + args.push_back(u"-h"); + FILE *fp = fopen(fileName.c_str(), "w"); + int ret = dataObsMgrServer->Dump(fileno(fp), args); + fclose(fp); + EXPECT_EQ(SUCCESS, ret); + + GTEST_LOG_(INFO) << "AaFwk_DataObsMgrServiceTest_Dump_0100 end"; +} } // namespace AAFwk } // namespace OHOS diff --git a/test/unittest/dataobs_mgr_stub_test/dataobs_mgr_stub_test.cpp b/test/unittest/dataobs_mgr_stub_test/dataobs_mgr_stub_test.cpp index 900bb63758..a2c9994fc7 100644 --- a/test/unittest/dataobs_mgr_stub_test/dataobs_mgr_stub_test.cpp +++ b/test/unittest/dataobs_mgr_stub_test/dataobs_mgr_stub_test.cpp @@ -206,5 +206,123 @@ HWTEST_F(DataObsManagerStubTest, AaFwk_DataObsManagerStubTest_NotifyChange_0100, EXPECT_EQ(testVal2, retval2); GTEST_LOG_(INFO) << "AaFwk_DataObsManagerStubTest_NotifyChange_0100 end"; } + +/* + * Feature: DataObsManagerStub + * Function: RegisterObserverExtInner + * SubFunction: NA + * FunctionPoints: DataObsManagerStub RegisterObserverExtInner + * EnvConditions: NA + * CaseDescription: Verify that the DataObsManagerStub RegisterObserverExtInner is normal. + */ +HWTEST_F(DataObsManagerStubTest, AaFwk_DataObsManagerStubTest_RegisterObserverExtInner_0100, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AaFwk_DataObsManagerStubTest_RegisterObserverExtInner_0100 start"; + std::shared_ptr dataobs = std::make_shared(); + Uri uri("dataability://device_id/com.domainname.dataability.persondata/person/10"); + const int testVal1 = static_cast(NO_ERROR); + const Status testVal2 = SUCCESS; + uint32_t code = IDataObsMgr::REGISTER_OBSERVER_EXT; + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(DataObsManagerProxy::GetDescriptor())) { + GTEST_LOG_(ERROR) << "---------- WriteInterfaceToken(data) retval is false end"; + return; + } + if (!data.WriteString(uri.ToString())) { + GTEST_LOG_(ERROR) << "---------- data.WriteParcelable(uri) retval is false end"; + return; + } + + EXPECT_CALL(*dataobs, RegisterObserverExt(testing::_, testing::_, testing::_)).Times(1) + .WillOnce(testing::Return(testVal2)); + + const int retval1 = dataobs->OnRemoteRequest(code, data, reply, option); + const int retval2 = reply.ReadInt32(); + + EXPECT_EQ(testVal1, retval1); + EXPECT_EQ(testVal2, retval2); + GTEST_LOG_(INFO) << "AaFwk_DataObsManagerStubTest_RegisterObserverExtInner_0100 end"; +} + +/* + * Feature: DataObsManagerStub + * Function: UnregisterObserverExtInner + * SubFunction: NA + * FunctionPoints: DataObsManagerStub UnregisterObserverExtInner + * EnvConditions: NA + * CaseDescription: Verify that the DataObsManagerStub UnregisterObserverExtInner is normal. + */ +HWTEST_F(DataObsManagerStubTest, AaFwk_DataObsManagerStubTest_UnregisterObserverExtInner_0100, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AaFwk_DataObsManagerStubTest_UnregisterObserverExtInner_0100 start"; + std::shared_ptr dataobs = std::make_shared(); + Uri uri("dataability://device_id/com.domainname.dataability.persondata/person/10"); + const int testVal1 = static_cast(NO_ERROR); + const Status testVal2 = SUCCESS; + uint32_t code = IDataObsMgr::UNREGISTER_OBSERVER_EXT; + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(DataObsManagerProxy::GetDescriptor())) { + GTEST_LOG_(ERROR) << "---------- WriteInterfaceToken(data) retval is false end"; + return; + } + if (!data.WriteString(uri.ToString())) { + GTEST_LOG_(ERROR) << "---------- data.WriteParcelable(uri) retval is false end"; + return; + } + + EXPECT_CALL(*dataobs, UnregisterObserverExt(testing::_, testing::_)).Times(1).WillOnce(testing::Return(testVal2)); + + const int retval1 = dataobs->OnRemoteRequest(code, data, reply, option); + const int retval2 = reply.ReadInt32(); + + EXPECT_EQ(testVal1, retval1); + EXPECT_EQ(testVal2, retval2); + GTEST_LOG_(INFO) << "AaFwk_DataObsManagerStubTest_UnregisterObserverExtInner_0100 end"; +} + +/* + * Feature: DataObsManagerStub + * Function: UnregisterObserverExtALLInner + * SubFunction: NA + * FunctionPoints: DataObsManagerStub UnregisterObserverExtALLInner + * EnvConditions: NA + * CaseDescription: Verify that the DataObsManagerStub UnregisterObserverExtALLInner is normal. + */ +HWTEST_F(DataObsManagerStubTest, AaFwk_DataObsManagerStubTest_UnregisterObserverExtALLInner_0100, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AaFwk_DataObsManagerStubTest_UnregisterObserverExtALLInner_0100 start"; + std::shared_ptr dataobs = std::make_shared(); + Uri uri("dataability://device_id/com.domainname.dataability.persondata/person/10"); + const int testVal1 = static_cast(NO_ERROR); + const Status testVal2 = SUCCESS; + uint32_t code = IDataObsMgr::UNREGISTER_OBSERVER_ALL_EXT; + MessageParcel data; + MessageParcel reply; + MessageOption option; + + if (!data.WriteInterfaceToken(DataObsManagerProxy::GetDescriptor())) { + GTEST_LOG_(ERROR) << "---------- WriteInterfaceToken(data) retval is false end"; + return; + } + if (!data.WriteString(uri.ToString())) { + GTEST_LOG_(ERROR) << "---------- data.WriteParcelable(uri) retval is false end"; + return; + } + + EXPECT_CALL(*dataobs, UnregisterObserverExt(testing::_)).Times(1).WillOnce(testing::Return(testVal2)); + + const int retval1 = dataobs->OnRemoteRequest(code, data, reply, option); + const int retval2 = reply.ReadInt32(); + + EXPECT_EQ(testVal1, retval1); + EXPECT_EQ(testVal2, retval2); + GTEST_LOG_(INFO) << "AaFwk_DataObsManagerStubTest_UnregisterObserverExtALLInner_0100 end"; +} } // namespace AAFwk } // namespace OHOS diff --git a/test/unittest/deeplink_reserve_config_test/BUILD.gn b/test/unittest/deeplink_reserve_config_test/BUILD.gn new file mode 100644 index 0000000000..0352f5da8b --- /dev/null +++ b/test/unittest/deeplink_reserve_config_test/BUILD.gn @@ -0,0 +1,41 @@ +# 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/abilitymgr" + +ohos_unittest("deeplink_reserve_config_test") { + module_out_path = module_output_path + + include_dirs = + [ "${ability_runtime_path}/services/abilitymgr/include/deeplink_reserve" ] + + sources = [ "deeplink_reserve_config_test.cpp" ] + + configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ] + cflags = [] + deps = [ + "${ability_runtime_services_path}/abilitymgr:abilityms", + "//third_party/googletest:gmock_main", + ] + + external_deps = [ "c_utils:utils" ] +} + +group("unittest") { + testonly = true + + deps = [ ":deeplink_reserve_config_test" ] +} diff --git a/test/unittest/deeplink_reserve_config_test/deeplink_reserve_config_test.cpp b/test/unittest/deeplink_reserve_config_test/deeplink_reserve_config_test.cpp new file mode 100644 index 0000000000..0c9ea6c0f9 --- /dev/null +++ b/test/unittest/deeplink_reserve_config_test/deeplink_reserve_config_test.cpp @@ -0,0 +1,105 @@ +/* + * 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 + +#include "gtest/gtest.h" +#define private public +#define protected public +#include "deeplink_reserve_config.h" +#undef private +#undef protected + + +namespace OHOS { +namespace AAFwk { +using namespace testing::ext; +class DeepLinkReserveConfigTest : public testing::Test { +public: + DeepLinkReserveConfigTest() = default; + virtual ~DeepLinkReserveConfigTest() = default; + + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; +void DeepLinkReserveConfigTest::SetUpTestCase(void) +{} +void DeepLinkReserveConfigTest::TearDownTestCase(void) +{} +void DeepLinkReserveConfigTest::SetUp() +{} +void DeepLinkReserveConfigTest::TearDown() +{} + +/* + * Feature: deepLinkReserveConfig + * Function: LoadConfiguration + * SubFunction: NA + * FunctionPoints: deepLinkReserveConfig LoadConfiguration + * EnvConditions: NA + * CaseDescription: Verify that the deepLinkReserveConfig LoadConfiguration is normal. + */ +HWTEST_F(DeepLinkReserveConfigTest, AaFwk_DeepLinkReserveConfigTest_0100, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AaFwk_DeepLinkReserveConfigTest_0100 start"; + DeepLinkReserveConfig deepLinkReserveConfig; + EXPECT_EQ(deepLinkReserveConfig.LoadConfiguration(), false); + GTEST_LOG_(INFO) << "AaFwk_DeepLinkReserveConfigTest_0100 end"; +} + +/* + * Feature: deepLinkReserveConfig + * Function: isLinkReserved + * SubFunction: NA + * FunctionPoints: deepLinkReserveConfig isLinkReserved + * EnvConditions: NA + * CaseDescription: Verify that the deepLinkReserveConfig isLinkReserved is normal. + */ +HWTEST_F(DeepLinkReserveConfigTest, AaFwk_DeepLinkReserveConfigTest_0200, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AaFwk_DeepLinkReserveConfigTest_0200 start"; + DeepLinkReserveConfig deepLinkReserveConfig; + const nlohmann::json DEFAULT_CONFIG = R"( + { + "deepLinkReservedUri": [ + { + "bundleName": "bundleName", + "uris": [ + { + "scheme": "http", + "host": "www.xxx.com", + "port": "80", + "path": "path", + "pathStartWith": "pathStartWith", + "pathRegex": "pathRegex", + "type": "type", + "utd": "utd" + } + ] + } + ] + } + )"_json; + deepLinkReserveConfig.LoadReservedUriList(DEFAULT_CONFIG); + std::string linkString = "http://www.xxx.com:80/pathRegex"; + std::string bundleName = "just a test"; + auto ans = deepLinkReserveConfig.isLinkReserved(linkString, bundleName); + EXPECT_EQ(ans, true); + GTEST_LOG_(INFO) << "AaFwk_DeepLinkReserveConfigTest_0200 end"; +} + +} // namespace AAFwk +} // namespace OHOS diff --git a/test/unittest/dfr_test/BUILD.gn b/test/unittest/dfr_test/BUILD.gn index 70b3bcae2f..5a118ff417 100644 --- a/test/unittest/dfr_test/BUILD.gn +++ b/test/unittest/dfr_test/BUILD.gn @@ -18,6 +18,7 @@ group("unittest") { deps += [ "appfreeze_inner_test:unittest", "appfreeze_manager_test:unittest", + "appfreeze_state_test:unittest", "watchdog_test:unittest", ] } diff --git a/test/unittest/dfr_test/appfreeze_inner_test/BUILD.gn b/test/unittest/dfr_test/appfreeze_inner_test/BUILD.gn index 8320cc1134..f9cc437dd8 100644 --- a/test/unittest/dfr_test/appfreeze_inner_test/BUILD.gn +++ b/test/unittest/dfr_test/appfreeze_inner_test/BUILD.gn @@ -102,6 +102,7 @@ ohos_unittest("appfreeze_inner_test") { "hisysevent:libhisysevent", "hitrace:hitrace_meter", "init:libbegetutil", + "input:libmmi-client", "ipc:ipc_core", "napi:ace_napi", "resource_management:global_resmgr", diff --git a/test/unittest/dfr_test/appfreeze_inner_test/appfreeze_inner_test.cpp b/test/unittest/dfr_test/appfreeze_inner_test/appfreeze_inner_test.cpp index 6e60e627fa..0eae9e539c 100644 --- a/test/unittest/dfr_test/appfreeze_inner_test/appfreeze_inner_test.cpp +++ b/test/unittest/dfr_test/appfreeze_inner_test/appfreeze_inner_test.cpp @@ -17,6 +17,7 @@ #define private public #include "appfreeze_inner.h" +#include "application_anr_listener.h" #undef private using namespace testing; @@ -115,6 +116,28 @@ HWTEST_F(AppfreezeInnerTest, AppfreezeInner__ThreadBlock_002, TestSize.Level1) GTEST_LOG_(INFO) << "AppfreezeInner__ThreadBlock_002 end"; } +/** + * @tc.number: AppfreezeInner_IsNeedIgnoreFreezeEvent_001 + * @tc.name: IsNeedIgnoreFreezeEvent + * @tc.desc: Verify that function IsNeedIgnoreFreezeEvent. + */ +HWTEST_F(AppfreezeInnerTest, AppfreezeInner_IsNeedIgnoreFreezeEvent_001, TestSize.Level1) +{ + std::atomic_bool isSixSecondEvent = true; + appfreezeInner->isAppDebug_ = false; + appfreezeInner->ThreadBlock(isSixSecondEvent); + EXPECT_TRUE(isSixSecondEvent); + int32_t pid = static_cast(getprocpid()); + std::shared_ptr listener = + std::make_shared(); + listener->OnAnr(pid); + int left = 61; // over 1min + while (left > 0) { + left = sleep(left); + } + listener->OnAnr(pid); +} + /** * @tc.number: AppfreezeInner__AppfreezeHandle_001 * @tc.name: AppfreezeHandle diff --git a/test/unittest/dfr_test/appfreeze_state_test/BUILD.gn b/test/unittest/dfr_test/appfreeze_state_test/BUILD.gn new file mode 100644 index 0000000000..57c1669ea6 --- /dev/null +++ b/test/unittest/dfr_test/appfreeze_state_test/BUILD.gn @@ -0,0 +1,113 @@ +# Copyright (c) 2023 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/ohos.gni") +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") + +module_output_path = "ability_runtime/appfreeze_state_test" + +############################################################################### +config("module_context_config") { + visibility = [ ":*" ] + include_dirs = [ + "${ability_runtime_innerkits_path}/app_manager/include/appmgr", + "${ability_runtime_test_path}/mock/frameworks_kits_appkit_native_test/include", + "${ability_runtime_test_path}/mock/frameworks_kits_ability_native_test/include", + "${ability_runtime_path}/interfaces/kits/native/appkit/app/task", + "${ability_runtime_path}/interfaces/kits/native/ability/native", + ] + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + defines = [ "AMS_LOG_TAG = \"ApplicationUnitTest\"" ] +} + +config("ability_start_setting_config") { + visibility = [ ":*" ] + include_dirs = [ + "${ability_runtime_path}/interfaces/kits/native/appkit/app", + "${ability_runtime_path}/interfaces/kits/native/appkit/dfr", + "${c_utils_base_path}/include", + "${ability_runtime_innerkits_path}/ability_manager/include", + ] +} + +ohos_unittest("appfreeze_state_test") { + module_out_path = module_output_path + + include_dirs = [ + "${ability_runtime_path}/interfaces/kits/native/appkit/dfr", + "${ability_runtime_path}/utils/global/time/include", + "//third_party/json/include", + ] + + configs = [ + ":module_context_config", + ":ability_start_setting_config", + ] + + sources = [ + "${ability_runtime_native_path}/appkit/dfr/appfreeze_inner.cpp", + "${ability_runtime_native_path}/appkit/dfr/appfreeze_state.cpp", + "appfreeze_state_test.cpp", + ] + + deps = [ + "${ability_runtime_abilitymgr_path}/:abilityms", + "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper", + "${ability_runtime_innerkits_path}/runtime:runtime", + "${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr", + "${ability_runtime_native_path}/ability/native:ability_thread", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:uiabilitykit_native", + "${ability_runtime_native_path}/appkit:app_context", + "${ability_runtime_native_path}/appkit:app_context_utils", + "${ability_runtime_native_path}/appkit:appkit_native", + "${ability_runtime_path}/utils/global/freeze:freeze_util", + ] + + external_deps = [ + "ability_base:configuration", + "ability_base:extractresourcemanager", + "ability_base:string_utils", + "ability_base:want", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "eventhandler:libeventhandler", + "faultloggerd:libbacktrace_local", + "faultloggerd:libdfx_procinfo", + "faultloggerd:libfaultloggerd", + "ffrt:libffrt", + "graphic_2d:librender_service_client", + "hicollie:libhicollie", + "hilog:libhilog", + "hisysevent:libhisysevent", + "hitrace:hitrace_meter", + "init:libbegetutil", + "ipc:ipc_core", + "napi:ace_napi", + ] +} + +############################################################################### + +group("unittest") { + testonly = true + deps = [ ":appfreeze_state_test" ] +} diff --git a/test/unittest/dfr_test/appfreeze_state_test/appfreeze_state_test.cpp b/test/unittest/dfr_test/appfreeze_state_test/appfreeze_state_test.cpp new file mode 100644 index 0000000000..34c4a059f4 --- /dev/null +++ b/test/unittest/dfr_test/appfreeze_state_test/appfreeze_state_test.cpp @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2022-2023 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 +#include +#include "appfreeze_state.h" + +#define private public +#include "appfreeze_inner.h" +#undef private + +using namespace testing; +using namespace testing::ext; +using namespace OHOS::AbilityRuntime; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +namespace AbilityRuntime { +class AppFreezeStateTest : public testing::Test { +public: + AppFreezeStateTest() + {} + ~AppFreezeStateTest() + {} + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; + +void AppFreezeStateTest::SetUpTestCase(void) +{} + +void AppFreezeStateTest::TearDownTestCase(void) +{} + +void AppFreezeStateTest::SetUp(void) +{} + +void AppFreezeStateTest::TearDown(void) +{} + +/** + * @tc.number: AppfreezeStateTest_001 + * @tc.desc: Verify that function SetAppFreezeState and CancelAppFreezeState. + * @tc.type: FUNC + */ +HWTEST_F(AppFreezeStateTest, AppfreezeStateTest_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AppfreezeStateTest_001 start"; + uint32_t flag = 1; + auto appFreezeState = std::make_shared (); + auto inner = AppfreezeInner::GetInstance(); + appFreezeState->SetAppFreezeState(flag); + EXPECT_FALSE(inner->IsHandleAppfreeze()); + + flag = -1; + appFreezeState->CancelAppFreezeState(flag); + EXPECT_TRUE(inner->IsHandleAppfreeze()); + GTEST_LOG_(INFO) << "AppfreezeStateTest_001 end"; +} +} // namespace AbilityRuntime +} // namespace OHOS diff --git a/test/unittest/dfr_test/watchdog_test/BUILD.gn b/test/unittest/dfr_test/watchdog_test/BUILD.gn index 203cefce2b..1825d44c40 100644 --- a/test/unittest/dfr_test/watchdog_test/BUILD.gn +++ b/test/unittest/dfr_test/watchdog_test/BUILD.gn @@ -9,7 +9,7 @@ # 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. +# limitations under the License. import("//build/ohos.gni") import("//build/test.gni") @@ -76,8 +76,6 @@ ohos_unittest("watchdog_test") { "ability_base:want", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", - "c_utils:utils", - "c_utils:utilsbase", "eventhandler:libeventhandler", "hilog:libhilog", "image_framework:image_native", @@ -86,7 +84,7 @@ ohos_unittest("watchdog_test") { ] } -############################################################################### +############################################################################### group("unittest") { testonly = true diff --git a/test/unittest/frameworks_kits_ability_ability_runtime_test/BUILD.gn b/test/unittest/frameworks_kits_ability_ability_runtime_test/BUILD.gn index ff47f134bd..3a95c5a187 100644 --- a/test/unittest/frameworks_kits_ability_ability_runtime_test/BUILD.gn +++ b/test/unittest/frameworks_kits_ability_ability_runtime_test/BUILD.gn @@ -152,6 +152,41 @@ ohos_unittest("local_call_record_ut_test") { ] } +ohos_unittest("dialog_callback_test") { + module_out_path = module_out_path + + include_dirs = [ + "${ability_runtime_test_path}/mock/frameworks_kits_ability_native_test/include", + "${ability_runtime_path}/interfaces/kits/native/ability/native/dialog_request_callback", + ] + + sources = [ + "${ability_runtime_path}/frameworks/native/ability/ability_runtime/dialog_request_callback_impl.cpp", + "${ability_runtime_path}/frameworks/native/ability/ability_runtime/dialog_ui_extension_callback.cpp", + "dialog_request_callback_impl_test.cpp", + "dialog_ui_extension_callback_test.cpp", + ] + + deps = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_native_path}/ability:ability_context_native", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_native_path}/ability/native:dialog_request_callback", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "ability_base:want", + "ace_engine:ace_uicontent", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "hilog:libhilog", + "ipc:ipc_core", + "napi:ace_napi", + ] +} + ################################################################################ group("unittest") { testonly = true @@ -160,6 +195,7 @@ group("unittest") { deps += [ ":ability_context_impl_test", ":caller_call_back_ut_test", + ":dialog_callback_test", ":local_call_container_ut_test", ":local_call_record_ut_test", ] diff --git a/test/unittest/frameworks_kits_ability_ability_runtime_test/dialog_request_callback_impl_test.cpp b/test/unittest/frameworks_kits_ability_ability_runtime_test/dialog_request_callback_impl_test.cpp new file mode 100644 index 0000000000..98949f6019 --- /dev/null +++ b/test/unittest/frameworks_kits_ability_ability_runtime_test/dialog_request_callback_impl_test.cpp @@ -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 +#include "dialog_request_callback_impl.h" + +using namespace testing::ext; +using namespace testing; +using namespace OHOS::AppExecFwk; +using namespace OHOS::AbilityRuntime; +namespace OHOS { +namespace AAFwk { +class DialogRequestCallbackImplTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; +void DialogRequestCallbackImplTest::SetUpTestCase(void) {} +void DialogRequestCallbackImplTest::TearDownTestCase(void) {} +void DialogRequestCallbackImplTest::TearDown() {} +void DialogRequestCallbackImplTest::SetUp() {} + +void RequestDialogResultTaskCallBack(int32_t resultCode, const AAFwk::Want&) +{ + GTEST_LOG_(INFO) << "RequestDialogResultTask call back"; +} + +/** + * @tc.name: DialogRequestCallbackImplTest_SendResult_0100 + * @tc.desc: Test the state of SendResult + * @tc.type: FUNC + */ +HWTEST_F(DialogRequestCallbackImplTest, SendResult_0100, TestSize.Level1) +{ + auto dialogRequestCallbackImpl = std::make_shared(RequestDialogResultTaskCallBack); + Want want; + dialogRequestCallbackImpl->SendResult(401, want); +} + +} // namespace AAFwk +} // namespace OHOS diff --git a/test/unittest/frameworks_kits_ability_ability_runtime_test/dialog_ui_extension_callback_test.cpp b/test/unittest/frameworks_kits_ability_ability_runtime_test/dialog_ui_extension_callback_test.cpp new file mode 100644 index 0000000000..a71d786c41 --- /dev/null +++ b/test/unittest/frameworks_kits_ability_ability_runtime_test/dialog_ui_extension_callback_test.cpp @@ -0,0 +1,131 @@ +/* + * 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 +#include "dialog_ui_extension_callback.h" +#include "mock_ui_content.h" + +using namespace testing::ext; +using namespace testing; +using namespace OHOS::AppExecFwk; +using namespace OHOS::AbilityRuntime; +namespace OHOS { +namespace AAFwk { +class MyAbilityCallback : public IAbilityCallback { +public: + virtual int GetCurrentWindowMode() + { + return 0; + } + + virtual ErrCode SetMissionLabel(const std::string& label) + { + return 0; + } + + virtual ErrCode SetMissionIcon(const std::shared_ptr& icon) + { + GTEST_LOG_(INFO) << "========AbilityCallback SetMissionIcon------------------------."; + return 0; + } + + virtual void GetWindowRect(int32_t &left, int32_t &top, int32_t &width, int32_t &height) + { + return; + } + + virtual Ace::UIContent* GetUIContent() + { + return nullptr; + } + + void EraseUIExtension(int32_t sessionId) + { + return; + } + + void RegisterAbilityLifecycleObserver(const std::shared_ptr &observer) + { + } + + void UnregisterAbilityLifecycleObserver(const std::shared_ptr &observer) + { + } +}; + +class DialogUIExtensionCallbackTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; + +void DialogUIExtensionCallbackTest::SetUpTestCase(void) {} +void DialogUIExtensionCallbackTest::TearDownTestCase(void) {} +void DialogUIExtensionCallbackTest::TearDown() {} +void DialogUIExtensionCallbackTest::SetUp() {} + +/** + * @tc.name: DialogUIExtensionCallbackTest_OnRelease_0100 + * @tc.desc: Test the state of OnRelease + * @tc.type: FUNC + */ +HWTEST_F(DialogUIExtensionCallbackTest, OnRelease_0100, TestSize.Level1) +{ + Ace::MockUIContent *uicontent = new Ace::MockUIContent(); + EXPECT_CALL(*uicontent, CloseModalUIExtension(_)).Times(1).WillOnce(Return()); + auto abilityCallback_ = std::make_shared(); + auto dialogUIExtensionCallback_ = + std::make_shared(std::weak_ptr(abilityCallback_)); + dialogUIExtensionCallback_->SetUIContent(uicontent); + dialogUIExtensionCallback_->SetSessionId(1); + dialogUIExtensionCallback_->OnRelease(); + delete uicontent; +} + +/** + * @tc.name: DialogUIExtensionCallbackTest_OnError_0100 + * @tc.desc: Test the state of OnError + * @tc.type: FUNC + */ +HWTEST_F(DialogUIExtensionCallbackTest, OnError_0100, TestSize.Level1) +{ + Ace::MockUIContent *uicontent = new Ace::MockUIContent(); + EXPECT_CALL(*uicontent, CloseModalUIExtension(_)).Times(1).WillOnce(Return()); + auto abilityCallback_ = std::make_shared(); + auto dialogUIExtensionCallback_ = + std::make_shared(std::weak_ptr(abilityCallback_)); + dialogUIExtensionCallback_->SetUIContent(uicontent); + dialogUIExtensionCallback_->SetSessionId(1); + dialogUIExtensionCallback_->OnError(); + delete uicontent; +} + +/** + * @tc.name: DialogUIExtensionCallbackTest_OnDestroy_0100 + * @tc.desc: Test the state of OnDestroy + * @tc.type: FUNC + */ +HWTEST_F(DialogUIExtensionCallbackTest, OnDestroy_0100, TestSize.Level1) +{ + auto abilityCallback = std::make_shared(); + auto dialogUIExtensionCallback = + std::make_shared(std::weak_ptr(abilityCallback)); + dialogUIExtensionCallback->OnDestroy(); +} + +} // namespace AAFwk +} // namespace OHOS diff --git a/test/unittest/frameworks_kits_ability_native_test/BUILD.gn b/test/unittest/frameworks_kits_ability_native_test/BUILD.gn index 4d927bcfed..eed4afd853 100644 --- a/test/unittest/frameworks_kits_ability_native_test/BUILD.gn +++ b/test/unittest/frameworks_kits_ability_native_test/BUILD.gn @@ -2701,6 +2701,75 @@ ohos_unittest("embedded_ui_extension_test") { ] } +ohos_unittest("app_module_checker_test") { + module_out_path = module_output_path + include_dirs = [ + "${ability_runtime_test_path}/mock/frameworks_kits_ability_native_test/include", + "${ability_runtime_path}/interfaces/kits/native/ability/native", + ] + + sources = [ "app_module_checker_test.cpp" ] + + configs = [ ":module_private_config" ] + + deps = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/runtime:runtime", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "ability_base:base", + "c_utils:utils", + "hilog:libhilog", + "ipc:ipc_core", + "napi:ace_napi", + ] +} + +ohos_unittest("js_ui_extension_Callback_test") { + module_out_path = module_output_path + include_dirs = [ + "${ability_runtime_test_path}/mock/frameworks_kits_ability_native_test/include", + "${ability_runtime_path}/interfaces/kits/native/ability/native", + "${ability_runtime_path}/js_environment/interfaces/inner_api", + "${ability_runtime_path}/js_environment/frameworks/utils/include", + "${windowmanager_path}/window_scene/interfaces/include", + ] + + sources = [ + "${ability_runtime_native_path}/ability/native/js_ui_extension_callback.cpp", + "js_ui_extension_Callback_test.cpp", + ] + + configs = [ ":module_private_config" ] + + deps = [ + "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/runtime:runtime", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "ability_base:base", + "ability_base:session_info", + "ability_base:want", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ace_engine:ace_uicontent", + "c_utils:utils", + "ffrt:libffrt", + "hilog:libhilog", + "input:libmmi-client", + "ipc:ipc_core", + "napi:ace_napi", + ] +} + ############################################################################### group("unittest") { @@ -2728,6 +2797,7 @@ group("unittest") { ":abilityruntime_test", ":action_extension_module_loader_test", ":action_extension_test", + ":app_module_checker_test", ":auto_fill_extension_module_loader_test", ":auto_fill_extension_test", ":continuation_test", @@ -2747,6 +2817,7 @@ group("unittest") { ":extension_test", ":fa_ability_thread_test", ":form_extension_test", + ":js_ui_extension_Callback_test", ":new_ability_impl_test", ":pac_map_test", ":reserse_continuation_scheduler_primary_proxy_test", diff --git a/test/unittest/frameworks_kits_ability_native_test/app_module_checker_test.cpp b/test/unittest/frameworks_kits_ability_native_test/app_module_checker_test.cpp new file mode 100644 index 0000000000..71108ea063 --- /dev/null +++ b/test/unittest/frameworks_kits_ability_native_test/app_module_checker_test.cpp @@ -0,0 +1,131 @@ +/* + * 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 +#include + +#include "ability_handler.h" +#include "app_module_checker.h" +#include "context_deal.h" +#include "hilog_wrapper.h" +#include "locale_config.h" +#include "ohos_application.h" +#include "process_options.h" +#include "session_info.h" + +namespace OHOS { +namespace AppExecFwk { +using namespace testing::ext; +using namespace OHOS; +using namespace OHOS::AbilityRuntime; +namespace { +static const int32_t EXTENSION_TYPE = 10; +static const int32_t EXTENSION_TYPE1 = 2; +} +class AppModuleCheckTest : public testing::Test { +public: + AppModuleCheckTest() : appModuleChecker_(nullptr) {} + ~AppModuleCheckTest() {} + std::shared_ptr appModuleChecker_; + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; + +void AppModuleCheckTest::SetUpTestCase(void) {} + +void AppModuleCheckTest::TearDownTestCase(void) {} + +void AppModuleCheckTest::SetUp(void) {} + +void AppModuleCheckTest::TearDown(void) {} + +/* + * Feature: DiskCheckOnly_001 + * Function: DiskCheckOnly + */ +HWTEST_F(AppModuleCheckTest, DiskCheckOnly_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "DiskCheckOnly_001 start"; + std::unordered_map> blocklist = { + {1, {"module1"}}, + {2, {"module2"}}, + {3, {"module3"}} + }; + appModuleChecker_ = std::make_shared(EXTENSION_TYPE, std::move(blocklist)); + bool ret = appModuleChecker_->DiskCheckOnly(); + EXPECT_FALSE(ret); + GTEST_LOG_(INFO) << "DiskCheckOnly_001 end"; +} + +/* + * Feature: CheckModuleLoadable_001 + * Function: CheckModuleLoadable + */ +HWTEST_F(AppModuleCheckTest, CheckModuleLoadable_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CheckModuleLoadable_001 start"; + std::unordered_map> blocklist = { + {1, {"module1"}}, + {2, {"module2"}}, + {3, {"module3"}} + }; + appModuleChecker_ = std::make_shared(EXTENSION_TYPE, std::move(blocklist)); + std::unique_ptr apiAllowListChecker(nullptr); + bool ret = appModuleChecker_->CheckModuleLoadable("module4", apiAllowListChecker); + EXPECT_TRUE(ret); + GTEST_LOG_(INFO) << "CheckModuleLoadable_001 end"; +} + +/* + * Feature: CheckModuleLoadable_002 + * Function: CheckModuleLoadable + */ +HWTEST_F(AppModuleCheckTest, CheckModuleLoadable_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CheckModuleLoadable_002 start"; + std::unordered_map> blocklist = { + {1, {"module1"}}, + {2, {"module2"}}, + {3, {"module3"}} + }; + appModuleChecker_ = std::make_shared(EXTENSION_TYPE1, std::move(blocklist)); + std::unique_ptr apiAllowListChecker(nullptr); + bool ret = appModuleChecker_->CheckModuleLoadable("module4", apiAllowListChecker); + EXPECT_TRUE(ret); + GTEST_LOG_(INFO) << "CheckModuleLoadable_002 end"; +} + +/* + * Feature: CheckModuleLoadable_003 + * Function: CheckModuleLoadable + */ +HWTEST_F(AppModuleCheckTest, CheckModuleLoadable_003, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CheckModuleLoadable_003 start"; + std::unordered_map> blocklist = { + {1, {"module1"}}, + {2, {"module2"}}, + {3, {"module3"}} + }; + appModuleChecker_ = std::make_shared(EXTENSION_TYPE1, std::move(blocklist)); + std::unique_ptr apiAllowListChecker(nullptr); + bool ret = appModuleChecker_->CheckModuleLoadable("module2", apiAllowListChecker); + EXPECT_FALSE(ret); + GTEST_LOG_(INFO) << "CheckModuleLoadable_003 end"; +} +} // namespace AppExecFwk +} // namespace OHOS diff --git a/test/unittest/frameworks_kits_ability_native_test/js_ui_extension_Callback_test.cpp b/test/unittest/frameworks_kits_ability_native_test/js_ui_extension_Callback_test.cpp new file mode 100644 index 0000000000..f6c312360c --- /dev/null +++ b/test/unittest/frameworks_kits_ability_native_test/js_ui_extension_Callback_test.cpp @@ -0,0 +1,251 @@ +/* + * 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 +#include + +#include "ability_handler.h" +#include "app_module_checker.h" +#include "context_deal.h" +#include "hilog_wrapper.h" +#include "js_environment.h" +#include "js_runtime.h" +#include "js_ui_extension_callback.h" +#include "locale_config.h" +#include "mock_ui_content.h" +#include "native_runtime_impl.h" +#include "ohos_application.h" +#include "process_options.h" +#include "session_info.h" + +namespace OHOS { +namespace AppExecFwk { +using namespace testing::ext; +using namespace OHOS; +using namespace OHOS::AbilityRuntime; +class JsUIExtensionCallbackTest : public testing::Test { +public: + JsUIExtensionCallbackTest() : jsUIExtensionCallback_(nullptr) {} + ~JsUIExtensionCallbackTest() {} + std::shared_ptr jsUIExtensionCallback_; + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; + +void JsUIExtensionCallbackTest::SetUpTestCase(void) {} + +void JsUIExtensionCallbackTest::TearDownTestCase(void) {} + +void JsUIExtensionCallbackTest::SetUp(void) {} + +void JsUIExtensionCallbackTest::TearDown(void) {} + +/* + * Feature: OnError_001 + * Function: OnError + */ +HWTEST_F(JsUIExtensionCallbackTest, OnError_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "OnError_001 start"; + jsUIExtensionCallback_ = std::make_shared(nullptr); + EXPECT_TRUE(jsUIExtensionCallback_ != nullptr); + jsUIExtensionCallback_->OnError(0); + GTEST_LOG_(INFO) << "OnError_001 end"; +} + +/* + * Feature: OnError_002 + * Function: OnError + */ +HWTEST_F(JsUIExtensionCallbackTest, OnError_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "OnError_002 start"; + OHOS::AbilityRuntime::Runtime::Options options; + std::shared_ptr jsEnv = nullptr; + auto err = NativeRuntimeImpl::GetNativeRuntimeImpl().CreateJsEnv(options, jsEnv); + EXPECT_EQ(err, napi_status::napi_ok); + + napi_env env = reinterpret_cast(jsEnv->GetNativeEngine()); + jsUIExtensionCallback_ = std::make_shared(env); + EXPECT_TRUE(jsUIExtensionCallback_ != nullptr); + jsUIExtensionCallback_->OnError(0); + err = NativeRuntimeImpl::GetNativeRuntimeImpl().RemoveJsEnv(reinterpret_cast(jsEnv->GetNativeEngine())); + EXPECT_EQ(err, napi_status::napi_ok); + GTEST_LOG_(INFO) << "OnError_002 end"; +} + +/* + * Feature: OnRelease_001 + * Function: OnRelease + */ +HWTEST_F(JsUIExtensionCallbackTest, OnRelease_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "OnRelease_001 start"; + jsUIExtensionCallback_ = std::make_shared(nullptr); + EXPECT_TRUE(jsUIExtensionCallback_ != nullptr); + jsUIExtensionCallback_->OnRelease(0); + GTEST_LOG_(INFO) << "OnRelease_001 end"; +} + +/* + * Feature: OnResult_001 + * Function: OnResult + */ +HWTEST_F(JsUIExtensionCallbackTest, OnResult_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "OnResult_001 start"; + jsUIExtensionCallback_ = std::make_shared(nullptr); + EXPECT_TRUE(jsUIExtensionCallback_ != nullptr); + AAFwk::Want want; + jsUIExtensionCallback_->OnResult(0, want); + GTEST_LOG_(INFO) << "OnResult_001 end"; +} + +/* + * Feature: OnResult_002 + * Function: OnResult + */ +HWTEST_F(JsUIExtensionCallbackTest, OnResult_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "OnResult_002 start"; + OHOS::AbilityRuntime::Runtime::Options options; + std::shared_ptr jsEnv = nullptr; + auto err = NativeRuntimeImpl::GetNativeRuntimeImpl().CreateJsEnv(options, jsEnv); + EXPECT_EQ(err, napi_status::napi_ok); + + napi_env env = reinterpret_cast(jsEnv->GetNativeEngine()); + jsUIExtensionCallback_ = std::make_shared(env); + EXPECT_TRUE(jsUIExtensionCallback_ != nullptr); + AAFwk::Want want; + jsUIExtensionCallback_->OnResult(0, want); + err = NativeRuntimeImpl::GetNativeRuntimeImpl().RemoveJsEnv(reinterpret_cast(jsEnv->GetNativeEngine())); + EXPECT_EQ(err, napi_status::napi_ok); + GTEST_LOG_(INFO) << "OnResult_002 end"; +} + +/* + * Feature: CallJsResult_001 + * Function: CallJsResult + */ +HWTEST_F(JsUIExtensionCallbackTest, CallJsResult_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CallJsResult_001 start"; + jsUIExtensionCallback_ = std::make_shared(nullptr); + EXPECT_TRUE(jsUIExtensionCallback_ != nullptr); + AAFwk::Want want; + jsUIExtensionCallback_->CallJsResult(0, want); + GTEST_LOG_(INFO) << "CallJsResult_001 end"; +} + +/* + * Feature: CallJsResult_002 + * Function: CallJsResult + */ +HWTEST_F(JsUIExtensionCallbackTest, CallJsResult_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CallJsResult_002 start"; + OHOS::AbilityRuntime::Runtime::Options options; + std::shared_ptr jsEnv = nullptr; + auto err = NativeRuntimeImpl::GetNativeRuntimeImpl().CreateJsEnv(options, jsEnv); + EXPECT_EQ(err, napi_status::napi_ok); + + napi_env env = reinterpret_cast(jsEnv->GetNativeEngine()); + jsUIExtensionCallback_ = std::make_shared(env); + EXPECT_TRUE(jsUIExtensionCallback_ != nullptr); + AAFwk::Want want; + jsUIExtensionCallback_->CallJsResult(0, want); + err = NativeRuntimeImpl::GetNativeRuntimeImpl().RemoveJsEnv(reinterpret_cast(jsEnv->GetNativeEngine())); + EXPECT_EQ(err, napi_status::napi_ok); + GTEST_LOG_(INFO) << "CallJsResult_002 end"; +} + +/* + * Feature: SetJsCallbackObject_001 + * Function: SetJsCallbackObject + */ +HWTEST_F(JsUIExtensionCallbackTest, SetJsCallbackObject_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SetJsCallbackObject_001 start"; + jsUIExtensionCallback_ = std::make_shared(nullptr); + EXPECT_TRUE(jsUIExtensionCallback_ != nullptr); + napi_value args[0] = {}; + jsUIExtensionCallback_->SetJsCallbackObject(args[0]); + GTEST_LOG_(INFO) << "SetJsCallbackObject_001 end"; +} + +/* + * Feature: CallJsError_001 + * Function: CallJsError + */ +HWTEST_F(JsUIExtensionCallbackTest, CallJsError_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CallJsError_001 start"; + jsUIExtensionCallback_ = std::make_shared(nullptr); + EXPECT_TRUE(jsUIExtensionCallback_ != nullptr); + jsUIExtensionCallback_->CallJsError(0); + GTEST_LOG_(INFO) << "CallJsError_001 end"; +} + +/* + * Feature: CallJsError_002 + * Function: CallJsError + */ +HWTEST_F(JsUIExtensionCallbackTest, CallJsError_002, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CallJsError_002 start"; + OHOS::AbilityRuntime::Runtime::Options options; + std::shared_ptr jsEnv = nullptr; + auto err = NativeRuntimeImpl::GetNativeRuntimeImpl().CreateJsEnv(options, jsEnv); + EXPECT_EQ(err, napi_status::napi_ok); + + napi_env env = reinterpret_cast(jsEnv->GetNativeEngine()); + jsUIExtensionCallback_ = std::make_shared(env); + EXPECT_TRUE(jsUIExtensionCallback_ != nullptr); + jsUIExtensionCallback_->CallJsError(0); + err = NativeRuntimeImpl::GetNativeRuntimeImpl().RemoveJsEnv(reinterpret_cast(jsEnv->GetNativeEngine())); + EXPECT_EQ(err, napi_status::napi_ok); + GTEST_LOG_(INFO) << "CallJsError_002 end"; +} + +/* + * Feature: SetSessionId_001 + * Function: SetSessionId + */ +HWTEST_F(JsUIExtensionCallbackTest, SetSessionId_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SetSessionId_001 start"; + jsUIExtensionCallback_ = std::make_shared(nullptr); + EXPECT_TRUE(jsUIExtensionCallback_ != nullptr); + jsUIExtensionCallback_->SetSessionId(0); + GTEST_LOG_(INFO) << "SetSessionId_001 end"; +} + +/* + * Feature: SetUIContent_001 + * Function: SetUIContent + */ +HWTEST_F(JsUIExtensionCallbackTest, SetUIContent_001, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "SetUIContent_001 start"; + jsUIExtensionCallback_ = std::make_shared(nullptr); + EXPECT_TRUE(jsUIExtensionCallback_ != nullptr); + Ace::UIContent* uiContent = nullptr; + jsUIExtensionCallback_->SetUIContent(uiContent); + GTEST_LOG_(INFO) << "SetUIContent_001 end"; +} +} // namespace AppExecFwk +} // namespace OHOS diff --git a/test/unittest/frameworks_kits_appkit_native_test/BUILD.gn b/test/unittest/frameworks_kits_appkit_native_test/BUILD.gn index 2998465d45..35536506c4 100644 --- a/test/unittest/frameworks_kits_appkit_native_test/BUILD.gn +++ b/test/unittest/frameworks_kits_appkit_native_test/BUILD.gn @@ -343,7 +343,6 @@ ohos_unittest("ability_start_setting_test") { external_deps = [ "c_utils:utils", - "c_utils:utilsbase", "hilog:libhilog", "ipc:ipc_core", ] diff --git a/test/unittest/frameworks_kits_appkit_native_test/ability_stage_test.cpp b/test/unittest/frameworks_kits_appkit_native_test/ability_stage_test.cpp index 79bb90006e..9d2d792083 100644 --- a/test/unittest/frameworks_kits_appkit_native_test/ability_stage_test.cpp +++ b/test/unittest/frameworks_kits_appkit_native_test/ability_stage_test.cpp @@ -22,6 +22,7 @@ #include "context_impl.h" #include "iremote_object.h" #include "mock_ability_token.h" +#include "runtime.h" namespace OHOS { namespace AppExecFwk { @@ -259,5 +260,92 @@ HWTEST_F(AbilityStageTest, AppExecFwk_AbilityStage_OnAcceptWant_001, Function | EXPECT_TRUE(abilityStage_->OnAcceptWant(want) == ""); GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_OnAcceptWant_001 end"; } + +/** + * @tc.number: AppExecFwk_AbilityStage_Create_001 + * @tc.name: Create + * @tc.desc: Test whether Create is called normally. + * @tc.type: FUNC + * @tc.require: AR000GJ719 + */ +HWTEST_F(AbilityStageTest, AppExecFwk_AbilityStage_Create_001, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_Create_001 start"; + std::unique_ptr runtime; + AppExecFwk::HapModuleInfo hapModuleInfo; + EXPECT_NE(abilityStage_->Create(runtime, hapModuleInfo), nullptr); + GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_Create_001 end"; +} + +/** + * @tc.number: AppExecFwk_AbilityStage_OnNewProcessRequest_001 + * @tc.name: OnNewProcessRequest + * @tc.desc: Test whether OnNewProcessRequest is called normally. + * @tc.type: FUNC + * @tc.require: AR000GJ719 + */ +HWTEST_F(AbilityStageTest, AppExecFwk_AbilityStage_OnNewProcessRequest_001, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_OnNewProcessRequest_001 start"; + AAFwk::Want want; + EXPECT_TRUE(abilityStage_->OnNewProcessRequest(want) == ""); + GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_OnNewProcessRequest_001 end"; +} + +/** + * @tc.number: AppExecFwk_AbilityStage_OnConfigurationUpdated_001 + * @tc.name: OnConfigurationUpdated + * @tc.desc: Test whether OnConfigurationUpdated is called normally. + * @tc.type: FUNC + * @tc.require: AR000GJ719 + */ +HWTEST_F(AbilityStageTest, AppExecFwk_AbilityStage_OnConfigurationUpdated_001, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_OnConfigurationUpdated_001 start"; + bool boolValue = false; + AppExecFwk::Configuration configuration; + if (abilityStage_ != nullptr) { + abilityStage_->OnConfigurationUpdated(configuration); + boolValue = true; + } + EXPECT_TRUE(boolValue); + GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_OnConfigurationUpdated_001 end"; +} + +/** + * @tc.number: AppExecFwk_AbilityStage_OnMemoryLevel_001 + * @tc.name: OnMemoryLevel + * @tc.desc: Test whether OnMemoryLevel is called normally. + * @tc.type: FUNC + * @tc.require: AR000GJ719 + */ +HWTEST_F(AbilityStageTest, AppExecFwk_AbilityStage_OnMemoryLevel_001, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_OnMemoryLevel_001 start"; + bool boolValue = false; + if (abilityStage_ != nullptr) { + abilityStage_->OnMemoryLevel(1); + boolValue = true; + } + EXPECT_TRUE(boolValue); + GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_OnMemoryLevel_001 end"; +} + +/** + * @tc.number: AppExecFwk_AbilityStage_RunAutoStartupTask_001 + * @tc.name: RunAutoStartupTask + * @tc.desc: Test whether RunAutoStartupTask is called normally. + * @tc.type: FUNC + * @tc.require: AR000GJ719 + */ +HWTEST_F(AbilityStageTest, AppExecFwk_AbilityStage_RunAutoStartupTask_001, Function | MediumTest | Level1) +{ + GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_RunAutoStartupTask_001 start"; + std::function callback; + bool isAsyncCallback; + std::shared_ptr context = abilityStage_->GetContext(); + EXPECT_TRUE(abilityStage_->RunAutoStartupTask(callback, isAsyncCallback, context) == ERR_OK); + GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_RunAutoStartupTask_001 end"; +} } // namespace AppExecFwk } diff --git a/test/unittest/freeze_util_test/BUILD.gn b/test/unittest/freeze_util_test/BUILD.gn new file mode 100644 index 0000000000..f991156b3b --- /dev/null +++ b/test/unittest/freeze_util_test/BUILD.gn @@ -0,0 +1,46 @@ +# Copyright (c) 2023 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/freeze_util" + +ohos_unittest("freeze_util_test") { + module_out_path = module_output_path + + configs = [ "${ability_runtime_utils_path}/global/freeze:freeze_util_config" ] + + include_dirs = [ "${ability_runtime_services_path}/common/include" ] + + sources = [ "freeze_util_test.cpp" ] + + cflags = [] + + deps = [ + "${ability_runtime_path}/utils/global/freeze:freeze_util", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "c_utils:utils", + "hilog:libhilog", + "ipc:ipc_core", + ] +} + +group("unittest") { + testonly = true + + deps = [ ":freeze_util_test" ] +} diff --git a/test/unittest/freeze_util_test/freeze_util_test.cpp b/test/unittest/freeze_util_test/freeze_util_test.cpp new file mode 100644 index 0000000000..66d651ef40 --- /dev/null +++ b/test/unittest/freeze_util_test/freeze_util_test.cpp @@ -0,0 +1,103 @@ +/* + * 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 + +#include "freeze_util.h" +#include "hilog_tag_wrapper.h" +#include "hilog_wrapper.h" +#include "ipc_object_stub.h" +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace AbilityRuntime { +class FreezeUtilTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp() override; + void TearDown() override; +}; + +void FreezeUtilTest::SetUpTestCase(void) +{} + +void FreezeUtilTest::TearDownTestCase(void) +{} + +void FreezeUtilTest::SetUp() +{} + +void FreezeUtilTest::TearDown() +{} + +/* + * @tc.number : FreezeUtilTest_001 + * @tc.name : FreezeUtilTest + * @tc.desc : Test Function FreezeUtil::GetInstance() and AddLifecycleEvent() and GetLifecycleEvent() + */ +HWTEST_F(FreezeUtilTest, FreezeUtilTest_001, TestSize.Level1) +{ + FreezeUtil::LifecycleFlow flow; + EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(flow), ""); + flow.state = FreezeUtil::TimeoutState::FOREGROUND; + FreezeUtil::GetInstance().AddLifecycleEvent(flow, "firstEntry"); + EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(flow), "firstEntry"); + + FreezeUtil::GetInstance().AddLifecycleEvent(flow, "secondEntry"); + EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(flow), "firstEntry\nsecondEntry"); + TAG_LOGI(AAFwkTag::TEST, "FreezeUtilTest_001 is end"); +} + +/* + * @tc.number : FreezeUtilTest_002 + * @tc.name : FreezeUtilTest + * @tc.desc : Test Function FreezeUtil::GetInstance() and DeleteLifecycleEvent() and GetLifecycleEvent() + */ +HWTEST_F(FreezeUtilTest, FreezeUtilTest_002, TestSize.Level1) +{ + FreezeUtil::LifecycleFlow flow; + flow.state = FreezeUtil::TimeoutState::LOAD; + FreezeUtil::GetInstance().AddLifecycleEvent(flow, "testDeleteEntry"); + EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(flow), "testDeleteEntry"); + FreezeUtil::GetInstance().DeleteLifecycleEvent(flow); + EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(flow), ""); + TAG_LOGI(AAFwkTag::TEST, "FreezeUtilTest_002 is end"); +} + +/* + * @tc.number : FreezeUtilTest_003 + * @tc.name : FreezeUtilTest + * @tc.desc : Test Function DeleteLifecycleEvent() and DeleteLifecycleEventInner() + */ +HWTEST_F(FreezeUtilTest, FreezeUtilTest_003, TestSize.Level1) +{ + sptr token_(new IPCObjectStub()); + FreezeUtil::LifecycleFlow foregroundFlow = { token_, FreezeUtil::TimeoutState::FOREGROUND }; + FreezeUtil::GetInstance().AddLifecycleEvent(foregroundFlow, "testDeleteLifecyleEventForground"); + EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(foregroundFlow), "testDeleteLifecyleEventForground"); + + FreezeUtil::LifecycleFlow backgroundFlow = { token_, FreezeUtil::TimeoutState::BACKGROUND }; + FreezeUtil::GetInstance().AddLifecycleEvent(backgroundFlow, "testDeleteLifecyleEventBackground"); + EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(backgroundFlow), "testDeleteLifecyleEventBackground"); + + FreezeUtil::GetInstance().DeleteLifecycleEvent(token_); + EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(foregroundFlow), ""); + EXPECT_EQ(FreezeUtil::GetInstance().GetLifecycleEvent(backgroundFlow), ""); + TAG_LOGI(AAFwkTag::TEST, "FreezeUtilTest_003 is end"); +} +} +} diff --git a/test/unittest/mission_list_test/BUILD.gn b/test/unittest/mission_list_test/BUILD.gn index a6ee9a5483..937d6618f3 100644 --- a/test/unittest/mission_list_test/BUILD.gn +++ b/test/unittest/mission_list_test/BUILD.gn @@ -94,7 +94,7 @@ ohos_unittest("mission_list_test_call") { "ability_base:want", "ability_base:zuri", "bundle_framework:appexecfwk_base", - "c_utils:utilsbase", + "c_utils:utils", "common_event_service:cesfwk_innerkits", "ffrt:libffrt", "hilog:libhilog", diff --git a/test/unittest/quick_fix/quick_fix_manager_service_test/quick_fix_manager_apply_task_test.cpp b/test/unittest/quick_fix/quick_fix_manager_service_test/quick_fix_manager_apply_task_test.cpp index 65a50e3fae..95e7f56f6d 100644 --- a/test/unittest/quick_fix/quick_fix_manager_service_test/quick_fix_manager_apply_task_test.cpp +++ b/test/unittest/quick_fix/quick_fix_manager_service_test/quick_fix_manager_apply_task_test.cpp @@ -624,5 +624,376 @@ HWTEST_F(QuickFixManagerApplyTaskTest, PostRevokeQuickFixNotifyUnloadPatchTask_0 EXPECT_EQ(applyTask->quickFixMgrService_.promote(), quickFixMs_); TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); } + +/** + * @tc.name: RunRevoke_0100 + * @tc.desc: run apply revoke task + * @tc.type: FUNC + * @tc.require: issueI5OD2E + */ +HWTEST_F(QuickFixManagerApplyTaskTest, RunRevoke_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->bundleName_ = "testBundleName"; + applyTask->isSoContained_ = true; + applyTask->taskType_ = QuickFixManagerApplyTask::TaskType::QUICK_FIX_REVOKE; + applyTask->RunRevoke(); + WaitUntilTaskDone(quickFixMs_->eventHandler_); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: InitRevokeTask_0100 + * @tc.desc: init revok task. + * @tc.type: FUNC + * @tc.require: issueI5OD2E + */ +HWTEST_F(QuickFixManagerApplyTaskTest, InitRevokeTask_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + std::string bundleName = "testBundleName"; + bool isSoContained = true; + applyTask->InitRevokeTask(bundleName, isSoContained); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: GetBundleName_0100 + * @tc.desc: get bundle name. + * @tc.type: FUNC + * @tc.require: issueI5OD2E + */ +HWTEST_F(QuickFixManagerApplyTaskTest, GetBundleName_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + std::string bundleName = "testBundleName"; + bool isSoContained = true; + applyTask->InitRevokeTask(bundleName, isSoContained); + std::string result = applyTask->GetBundleName(); + ASSERT_EQ(result, bundleName); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: GetTaskType_0100 + * @tc.desc: get task type. + * @tc.type: FUNC + * @tc.require: issueI5OD2E + */ +HWTEST_F(QuickFixManagerApplyTaskTest, GetTaskType_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + std::string bundleName = "testBundleName"; + bool isSoContained = true; + applyTask->taskType_ = QuickFixManagerApplyTask::TaskType::QUICK_FIX_REVOKE; + QuickFixManagerApplyTask::TaskType taskType = QuickFixManagerApplyTask::TaskType::QUICK_FIX_REVOKE; + applyTask->InitRevokeTask(bundleName, isSoContained); + QuickFixManagerApplyTask::TaskType result = applyTask->GetTaskType(); + ASSERT_EQ(result, taskType); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: RemoveSelf_0100 + * @tc.desc: remove timeout task + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, RemoveSelf_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + nullptr, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->RemoveSelf(); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: RemoveSelf_0200 + * @tc.desc: remove self + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, RemoveSelf_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->RemoveSelf(); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: PostSwitchQuickFixTask_0100 + * @tc.desc: post switch quick fix task + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, PostSwitchQuickFixTask_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->PostSwitchQuickFixTask(); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} +/** + * @tc.name: PostSwitchQuickFixTask_0200 + * @tc.desc: post switch quick fix task + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, PostSwitchQuickFixTask_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + nullptr, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->PostSwitchQuickFixTask(); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: PostDeployQuickFixTask_0100 + * @tc.desc: post deploy quick fix task + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, PostDeployQuickFixTask_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + std::vector quickFixFiles; + applyTask->PostDeployQuickFixTask(quickFixFiles); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: PostDeployQuickFixTask_0200 + * @tc.desc: post deploy quick fix task + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, PostDeployQuickFixTask_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + nullptr, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + std::vector quickFixFiles; + applyTask->PostDeployQuickFixTask(quickFixFiles); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: PostDeleteQuickFixTask_0100 + * @tc.desc: post delete quick fix task + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, PostDeleteQuickFixTask_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->PostDeleteQuickFixTask(); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} +/** + * @tc.name: PostDeleteQuickFixTask_0200 + * @tc.desc: post delete quick fix task + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, PostDeleteQuickFixTask_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + nullptr, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->PostDeleteQuickFixTask(); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: UnregAppStateObserver_0100 + * @tc.desc: unregister app state observer + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, UnregAppStateObserver_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + SetPermission(); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->UnregAppStateObserver(); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: UnregAppStateObserver_0200 + * @tc.desc: unregister app state observer + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, UnregAppStateObserver_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + SetPermission(); + auto applyTask = std::make_shared(bundleQfMgr_, nullptr, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->UnregAppStateObserver(); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: PostRevokeQuickFixDeleteTask_0100 + * @tc.desc: revoke quick fix delete task. + * @tc.type: FUNC + */ +HWTEST_F(QuickFixManagerApplyTaskTest, PostRevokeQuickFixDeleteTask_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(nullptr, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->bundleName_ = "testBundleName"; + applyTask->bundleVersionCode_ = 1; + applyTask->patchVersionCode_ = 100; + applyTask->isSoContained_ = true; + applyTask->taskType_ = QuickFixManagerApplyTask::TaskType::QUICK_FIX_REVOKE; + applyTask->PostRevokeQuickFixDeleteTask(); + EXPECT_EQ(applyTask->quickFixMgrService_.promote(), quickFixMs_); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: PostRevokeQuickFixTask_0100 + * @tc.desc: post revoke quick fix task + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, PostRevokeQuickFixTask_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->PostRevokeQuickFixTask(); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: PostRevokeQuickFixTask_0200 + * @tc.desc: post revoke quick fix task. + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, PostRevokeQuickFixTask_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + nullptr, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->PostRevokeQuickFixTask(); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: PostTimeOutTask_0100 + * @tc.desc: post timeout task + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, PostTimeOutTask_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->PostTimeOutTask(); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: PostTimeOutTask_0200 + * @tc.desc: post timeout task + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(QuickFixManagerApplyTaskTest, PostTimeOutTask_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + nullptr, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->PostTimeOutTask(); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: HandleRevokeQuickFixAppStop_0100 + * @tc.desc: revoke quick fix stop app. + * @tc.type: FUNC + * @tc.require: issueI5OD2E + */ +HWTEST_F(QuickFixManagerApplyTaskTest, HandleRevokeQuickFixAppStop_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(bundleQfMgr_, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->bundleName_ = "testBundleName"; + applyTask->bundleVersionCode_ = 1; + applyTask->patchVersionCode_ = 100; + applyTask->isSoContained_ = true; + applyTask->taskType_ = QuickFixManagerApplyTask::TaskType::QUICK_FIX_REVOKE; + applyTask->HandleRevokeQuickFixAppStop(); + EXPECT_EQ(applyTask->quickFixMgrService_.promote(), quickFixMs_); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: HandleRevokeQuickFixAppStop_0200 + * @tc.desc: revoke quick fix stop app. + * @tc.type: FUNC + * @tc.require: issueI5OD2E + */ +HWTEST_F(QuickFixManagerApplyTaskTest, HandleRevokeQuickFixAppStop_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto applyTask = std::make_shared(nullptr, appMgr_, + quickFixMs_->eventHandler_, quickFixMs_); + ASSERT_NE(applyTask, nullptr); + applyTask->bundleName_ = "testBundleName"; + applyTask->bundleVersionCode_ = 1; + applyTask->patchVersionCode_ = 100; + applyTask->isSoContained_ = true; + applyTask->taskType_ = QuickFixManagerApplyTask::TaskType::QUICK_FIX_REVOKE; + applyTask->HandleRevokeQuickFixAppStop(); + EXPECT_EQ(applyTask->quickFixMgrService_.promote(), quickFixMs_); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file diff --git a/test/unittest/quick_fix/quick_fix_manager_service_test/quick_fix_manager_service_test.cpp b/test/unittest/quick_fix/quick_fix_manager_service_test/quick_fix_manager_service_test.cpp index 3517f944f9..f5dcb5304f 100644 --- a/test/unittest/quick_fix/quick_fix_manager_service_test/quick_fix_manager_service_test.cpp +++ b/test/unittest/quick_fix/quick_fix_manager_service_test/quick_fix_manager_service_test.cpp @@ -245,5 +245,108 @@ HWTEST_F(QuickFixManagerServiceTest, GetQuickFixInfo_0100, TestSize.Level1) TAG_LOGI(AAFwkTag::TEST, "GetQuickFixInfo_0100 end."); } + +/** + * @tc.name: GetApplyedQuickFixInfo_0200 + * @tc.desc: get Apply Quick Fix info. + * @tc.type: FUNC + * @tc.require: issueI5ODCD + */ +HWTEST_F(QuickFixManagerServiceTest, GetApplyedQuickFixInfo_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + auto mockGetBundleInstaller = []() { return mockBundleInstaller; }; + auto mockGetSystemAbility = [bms = mockBundleMgr, saMgr = iSystemAbilityMgr_](int32_t systemAbilityId) { + if (systemAbilityId == BUNDLE_MGR_SERVICE_SYS_ABILITY_ID) { + return bms->AsObject(); + } else { + return saMgr->GetSystemAbility(systemAbilityId); + } + }; + EXPECT_CALL(*mockBundleMgr, GetBundleInstaller()).WillOnce(testing::Invoke(mockGetBundleInstaller)); + std::string bundleName = ""; + ApplicationQuickFixInfo quickFixInfo; + auto ret = quickFixMs_->GetApplyedQuickFixInfo(bundleName, quickFixInfo); + EXPECT_EQ(ret, QUICK_FIX_OK); + EXPECT_EQ(quickFixInfo.bundleName, ""); + EXPECT_EQ(quickFixInfo.bundleVersionCode, static_cast(0)); + EXPECT_EQ(quickFixInfo.bundleVersionName, ""); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: ApplyAndRemoveTask_0200 + * @tc.desc: AddApplyTask and RemoveApplyTask + * @tc.type: FUNC + * @tc.require: issueI5OD2E + */ +HWTEST_F(QuickFixManagerServiceTest, ApplyAndRemoveTask_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + EXPECT_NE(quickFixMs_, nullptr); + quickFixMs_->RemoveApplyTask(nullptr); + quickFixMs_->AddApplyTask(nullptr); + sptr bundleQfMgr = nullptr; + sptr appMgr = nullptr; + std::shared_ptr handler = nullptr; + wptr service = nullptr; + auto applyTask = std::make_shared(bundleQfMgr, appMgr, handler, service); + EXPECT_NE(applyTask, nullptr); + quickFixMs_->RemoveApplyTask(applyTask); + quickFixMs_->AddApplyTask(applyTask); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: CheckTaskRunningState_0100 + * @tc.desc: check task running state + * @tc.type: FUNC + * @tc.require: issueI5OD2E + */ +HWTEST_F(QuickFixManagerServiceTest, CheckTaskRunningState_0100, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + EXPECT_NE(quickFixMs_, nullptr); + std::string bundleName = "testbundlename"; + bool result = quickFixMs_->CheckTaskRunningState(bundleName); + EXPECT_EQ(result, false); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: CheckTaskRunningState_0200 + * @tc.desc: check task running state + * @tc.type: FUNC + * @tc.require: issueI5OD2E + */ +HWTEST_F(QuickFixManagerServiceTest, CheckTaskRunningState_0200, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + EXPECT_NE(quickFixMs_, nullptr); + auto applyTask = std::make_shared(nullptr, nullptr, nullptr, nullptr); + quickFixMs_->AddApplyTask(applyTask); + std::string bundleName = "testbundlename"; + bool result = quickFixMs_->CheckTaskRunningState(bundleName); + EXPECT_EQ(result, false); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} + +/** + * @tc.name: CheckTaskRunningState_0300 + * @tc.desc: check task running state + * @tc.type: FUNC + * @tc.require: issueI5OD2E + */ +HWTEST_F(QuickFixManagerServiceTest, CheckTaskRunningState_0300, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "%{public}s start.", __func__); + EXPECT_NE(quickFixMs_, nullptr); + auto applyTask = std::make_shared(nullptr, nullptr, nullptr, nullptr); + quickFixMs_->AddApplyTask(applyTask); + std::string bundleName = ""; + bool result = quickFixMs_->CheckTaskRunningState(bundleName); + EXPECT_EQ(result, true); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); +} } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file diff --git a/test/unittest/runtime_test/js_runtime_test.cpp b/test/unittest/runtime_test/js_runtime_test.cpp index 3d3c3e28eb..14b0e8ec3e 100755 --- a/test/unittest/runtime_test/js_runtime_test.cpp +++ b/test/unittest/runtime_test/js_runtime_test.cpp @@ -1509,7 +1509,9 @@ HWTEST_F(JsRuntimeTest, DumpHeapSnapshot_0200, TestSize.Level1) auto jsRuntime = std::make_unique(); uint32_t tid = 1; bool isFullGC = true; - jsRuntime->DumpHeapSnapshot(tid, isFullGC); + std::vector fdVec; + std::vector tidVec; + jsRuntime->DumpHeapSnapshot(tid, isFullGC, fdVec, tidVec); EXPECT_TRUE(jsRuntime != nullptr); } diff --git a/test/unittest/startup_util_test/startup_util_test.cpp b/test/unittest/startup_util_test/startup_util_test.cpp index a18b170108..18d84aa227 100644 --- a/test/unittest/startup_util_test/startup_util_test.cpp +++ b/test/unittest/startup_util_test/startup_util_test.cpp @@ -50,8 +50,8 @@ void StartupUtilTest::TearDown() HWTEST_F(StartupUtilTest, startup_util_test_001, TestSize.Level1) { AAFwk::Want want; - auto appTwinIndex = StartupUtil::GetAppTwinIndex(want); - EXPECT_EQ(appTwinIndex, 0); + auto appIndex = StartupUtil::GetAppIndex(want); + EXPECT_EQ(appIndex, 0); } } // namespace AbilityRuntime } // namespace OHOS diff --git a/test/unittest/ui_ability_lifecycle_manager_test/ui_ability_lifecycle_manager_test.cpp b/test/unittest/ui_ability_lifecycle_manager_test/ui_ability_lifecycle_manager_test.cpp index 56250032b0..8db0ae90c7 100644 --- a/test/unittest/ui_ability_lifecycle_manager_test/ui_ability_lifecycle_manager_test.cpp +++ b/test/unittest/ui_ability_lifecycle_manager_test/ui_ability_lifecycle_manager_test.cpp @@ -30,6 +30,7 @@ #include "process_options.h" #include "session/host/include/session.h" #include "session_info.h" +#include "ability_manager_service.h" using namespace testing; using namespace testing::ext; @@ -2567,5 +2568,694 @@ HWTEST_F(UIAbilityLifecycleManagerTest, ChangeUIAbilityVisibilityBySCB_001, Test int32_t ret = uiAbilityLifecycleManager->ChangeUIAbilityVisibilityBySCB(nullptr, true); EXPECT_EQ(ERR_INVALID_VALUE, ret); } + +/** + * @tc.name: UIAbilityLifecycleManager_IsContainsAbility_0100 + * @tc.desc: IsContainsAbility + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, IsContainsAbility_001, TestSize.Level1) +{ + auto mgr = std::make_unique(); + EXPECT_NE(mgr, nullptr); + sptr token = nullptr; + bool boolValue = mgr->IsContainsAbility(token); + EXPECT_FALSE(boolValue); +} + +/** + * @tc.name: UIAbilityLifecycleManager_IsContainsAbility_0200 + * @tc.desc: IsContainsAbility + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, IsContainsAbility_002, TestSize.Level1) +{ + auto mgr = std::make_unique(); + EXPECT_NE(mgr, nullptr); + AbilityRequest abilityRequest; + auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + auto&& token = abilityRecord->GetToken()->AsObject(); + mgr->sessionAbilityMap_.emplace(1, abilityRecord); + bool boolValue = mgr->IsContainsAbility(token); + EXPECT_TRUE(boolValue); +} + +/** + * @tc.name: UIAbilityLifecycleManager_IsContainsAbilityInner_0100 + * @tc.desc: IsContainsAbilityInner + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, IsContainsAbilityInner_001, TestSize.Level1) +{ + auto mgr = std::make_unique(); + EXPECT_NE(mgr, nullptr); + sptr token = nullptr; + bool boolValue = mgr->IsContainsAbilityInner(token); + EXPECT_FALSE(boolValue); +} + +/** + * @tc.name: UIAbilityLifecycleManager_IsContainsAbilityInner_0200 + * @tc.desc: IsContainsAbilityInner + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, IsContainsAbilityInner_002, TestSize.Level1) +{ + auto mgr = std::make_unique(); + EXPECT_NE(mgr, nullptr); + AbilityRequest abilityRequest; + auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + auto&& token = abilityRecord->GetToken()->AsObject(); + mgr->sessionAbilityMap_.emplace(1, abilityRecord); + bool boolValue = mgr->IsContainsAbilityInner(token); + EXPECT_TRUE(boolValue); +} + +/** + * @tc.name: UIAbilityLifecycleManager_NotifySCBToMinimizeUIAbility_0100 + * @tc.desc: NotifySCBToMinimizeUIAbility + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, NotifySCBToMinimizeUIAbility_001, TestSize.Level1) +{ + auto mgr = std::make_unique(); + std::shared_ptr abilityRecord = nullptr; + sptr token = nullptr; + EXPECT_NE(mgr->NotifySCBToMinimizeUIAbility(abilityRecord, token), ERR_OK); +} + +/** + * @tc.name: UIAbilityLifecycleManager_GetUIAbilityRecordBySessionInfo_0100 + * @tc.desc: GetUIAbilityRecordBySessionInfo + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, GetUIAbilityRecordBySessionInfo_001, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_unique(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + sptr sessionInfo = nullptr; + EXPECT_EQ(uiAbilityLifecycleManager->GetUIAbilityRecordBySessionInfo(sessionInfo), nullptr); +} + +/** + * @tc.name: UIAbilityLifecycleManager_GetUIAbilityRecordBySessionInfo_0200 + * @tc.desc: GetUIAbilityRecordBySessionInfo + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, GetUIAbilityRecordBySessionInfo_002, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_unique(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + sptr sessionInfo(new SessionInfo()); + sessionInfo->sessionToken = nullptr; + EXPECT_EQ(uiAbilityLifecycleManager->GetUIAbilityRecordBySessionInfo(sessionInfo), nullptr); +} + +/** + * @tc.name: UIAbilityLifecycleManager_GetUIAbilityRecordBySessionInfo_0300 + * @tc.desc: GetUIAbilityRecordBySessionInfo + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, GetUIAbilityRecordBySessionInfo_003, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_unique(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + Rosen::SessionInfo info; + sptr sessionInfo(new SessionInfo()); + sessionInfo->sessionToken = new Rosen::Session(info); + EXPECT_EQ(uiAbilityLifecycleManager->GetUIAbilityRecordBySessionInfo(sessionInfo), nullptr); +} + +/** + * @tc.name: UIAbilityLifecycleManager_GetUIAbilityRecordBySessionInfo_0400 + * @tc.desc: GetUIAbilityRecordBySessionInfo + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, GetUIAbilityRecordBySessionInfo_004, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_unique(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + AbilityRequest abilityRequest; + Rosen::SessionInfo info; + sptr sessionInfo(new SessionInfo()); + sessionInfo->sessionToken = new Rosen::Session(info); + sessionInfo->persistentId = 1; + abilityRequest.sessionInfo = sessionInfo; + auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionInfo->persistentId, abilityRecord); + EXPECT_NE(uiAbilityLifecycleManager->GetUIAbilityRecordBySessionInfo(sessionInfo), nullptr); +} + +/** + * @tc.name: UIAbilityLifecycleManager_OnStartSpecifiedProcessResponse_0100 + * @tc.desc: OnStartSpecifiedProcessResponse + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, OnStartSpecifiedProcessResponse_001, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + Want want; + std::string flag = "flag"; + uiAbilityLifecycleManager->OnStartSpecifiedProcessResponse(want, flag); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_OnStartSpecifiedProcessResponse_0200 + * @tc.desc: OnStartSpecifiedProcessResponse + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, OnStartSpecifiedProcessResponse_002, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + Want want; + std::string flag = "flag"; + int32_t requestId = 100; + uiAbilityLifecycleManager->OnStartSpecifiedProcessResponse(want, flag, requestId); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_OnStartSpecifiedAbilityTimeoutResponse_0100 + * @tc.desc: OnStartSpecifiedAbilityTimeoutResponse + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, OnStartSpecifiedAbilityTimeoutResponse_001, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + Want want; + uiAbilityLifecycleManager->OnStartSpecifiedAbilityTimeoutResponse(want); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_OnStartSpecifiedAbilityTimeoutResponse_0200 + * @tc.desc: OnStartSpecifiedAbilityTimeoutResponse + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, OnStartSpecifiedAbilityTimeoutResponse_002, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + Want want; + int32_t requestId = 100; + uiAbilityLifecycleManager->OnStartSpecifiedAbilityTimeoutResponse(want, requestId); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_OnStartSpecifiedProcessTimeoutResponse_0100 + * @tc.desc: OnStartSpecifiedProcessTimeoutResponse + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, OnStartSpecifiedProcessTimeoutResponse_001, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + Want want; + uiAbilityLifecycleManager->OnStartSpecifiedProcessTimeoutResponse(want); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_OnStartSpecifiedProcessTimeoutResponse_0200 + * @tc.desc: OnStartSpecifiedProcessTimeoutResponse + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, OnStartSpecifiedProcessTimeoutResponse_002, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + Want want; + int32_t requestId = 100; + uiAbilityLifecycleManager->OnStartSpecifiedProcessTimeoutResponse(want, requestId); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_OnCallConnectDied_0100 + * @tc.desc: OnCallConnectDied + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, OnCallConnectDied_001, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + std::shared_ptr callRecord = nullptr; + uiAbilityLifecycleManager->OnCallConnectDied(callRecord); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_GetSessionIdByAbilityToken_0100 + * @tc.desc: GetSessionIdByAbilityToken + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, GetSessionIdByAbilityToken_001, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_unique(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + sptr token = nullptr; + EXPECT_EQ(uiAbilityLifecycleManager->GetSessionIdByAbilityToken(token), ERR_OK); +} + +/** + * @tc.name: UIAbilityLifecycleManager_GetSessionIdByAbilityToken_0200 + * @tc.desc: GetSessionIdByAbilityToken + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, GetSessionIdByAbilityToken_002, TestSize.Level1) +{ + auto mgr = std::make_unique(); + AbilityRequest abilityRequest; + auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + mgr->sessionAbilityMap_.emplace(1, abilityRecord); + auto&& token = abilityRecord->GetToken()->AsObject(); + EXPECT_EQ(mgr->GetSessionIdByAbilityToken(token), 1); +} + +/** + * @tc.name: UIAbilityLifecycleManager_GetActiveAbilityList_0100 + * @tc.desc: GetActiveAbilityList + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, GetActiveAbilityList_001, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_unique(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + AbilityRequest abilityRequest; + auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(1, abilityRecord); + std::string bundleName = "com.example.unittest"; + std::vector abilityList; + int32_t pid = 100; + uiAbilityLifecycleManager->GetActiveAbilityList(bundleName, abilityList, pid); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_GetActiveAbilityList_0200 + * @tc.desc: GetActiveAbilityList + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, GetActiveAbilityList_002, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_unique(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + AbilityRequest abilityRequest; + abilityRequest.abilityInfo.launchMode = AppExecFwk::LaunchMode::STANDARD; + abilityRequest.abilityInfo.name = "testAbility"; + abilityRequest.abilityInfo.moduleName = "testModule"; + abilityRequest.abilityInfo.bundleName = "com.example.unittest"; + auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + abilityRecord->SetOwnerMissionUserId(DelayedSingleton::GetInstance()->GetUserId()); + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(1, abilityRecord); + std::string bundleName = "com.example.unittest"; + std::vector abilityList; + int32_t pid = 100; + uiAbilityLifecycleManager->GetActiveAbilityList(bundleName, abilityList, pid); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_PrepareTerminateAbility_0100 + * @tc.desc: PrepareTerminateAbility + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, PrepareTerminateAbility_001, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + std::shared_ptr abilityRecord = nullptr; + bool boolValue = uiAbilityLifecycleManager->PrepareTerminateAbility(abilityRecord); + EXPECT_FALSE(boolValue); +} + +/** + * @tc.name: UIAbilityLifecycleManager_PrepareTerminateAbility_0200 + * @tc.desc: PrepareTerminateAbility + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, PrepareTerminateAbility_002, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + std::shared_ptr abilityRecord = InitAbilityRecord(); + bool boolValue = uiAbilityLifecycleManager->PrepareTerminateAbility(abilityRecord); + EXPECT_FALSE(boolValue); +} + +/** + * @tc.name: UIAbilityLifecycleManager_SetSessionHandler_0100 + * @tc.desc: SetSessionHandler + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, SetSessionHandler_001, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_unique(); + EXPECT_NE(uiAbilityLifecycleManager, nullptr); + sptr handler; + uiAbilityLifecycleManager->SetSessionHandler(handler); + EXPECT_EQ(uiAbilityLifecycleManager->handler_, handler); +} + +/** + * @tc.name: UIAbilityLifecycleManager_GetAbilityRecordsById_0100 + * @tc.desc: GetAbilityRecordsById + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, GetAbilityRecordsById_001, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_unique(); + int32_t sessionId = 100; + AbilityRequest abilityRequest; + auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionId, abilityRecord); + EXPECT_EQ(uiAbilityLifecycleManager->GetAbilityRecordsById(sessionId + 1), nullptr); +} + +/** + * @tc.name: UIAbilityLifecycleManager_GetAbilityRecordsById_0200 + * @tc.desc: GetAbilityRecordsById + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, GetAbilityRecordsById_002, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_unique(); + int32_t sessionId = 100; + AbilityRequest abilityRequest; + auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionId, abilityRecord); + EXPECT_NE(uiAbilityLifecycleManager->GetAbilityRecordsById(sessionId), nullptr); +} + +/** + * @tc.name: UIAbilityLifecycleManager_OnAppStateChanged_0100 + * @tc.desc: OnAppStateChanged + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, OnAppStateChanged_001, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + AbilityRequest abilityRequest; + abilityRequest.appInfo.bundleName = "com.example.unittest"; + abilityRequest.abilityInfo.name = "MainAbility"; + abilityRequest.abilityInfo.process = "AbilityProcess"; + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + AppInfo info; + info.processName = "AbilityProcess"; + info.state = AppState::TERMINATED; + uiAbilityLifecycleManager->terminateAbilityList_.emplace_back(abilityRecord); + uiAbilityLifecycleManager->OnAppStateChanged(info); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_OnAppStateChanged_0200 + * @tc.desc: OnAppStateChanged + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, OnAppStateChanged_002, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + AbilityRequest abilityRequest; + abilityRequest.appInfo.bundleName = "com.example.unittest"; + abilityRequest.abilityInfo.name = "MainAbility"; + abilityRequest.abilityInfo.process = "AbilityProcess"; + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + AppInfo info; + info.processName = "AbilityProcess"; + info.state = AppState::END; + uiAbilityLifecycleManager->terminateAbilityList_.emplace_back(abilityRecord); + uiAbilityLifecycleManager->OnAppStateChanged(info); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_OnAppStateChanged_0300 + * @tc.desc: OnAppStateChanged + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, OnAppStateChanged_003, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + AbilityRequest abilityRequest; + abilityRequest.appInfo.bundleName = "com.example.unittest"; + abilityRequest.abilityInfo.name = "MainAbility"; + abilityRequest.abilityInfo.process = "AbilityProcess"; + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + AppInfo info; + info.processName = "com.example.unittest"; + info.state = AppState::TERMINATED; + uiAbilityLifecycleManager->terminateAbilityList_.emplace_back(abilityRecord); + uiAbilityLifecycleManager->OnAppStateChanged(info); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_OnAppStateChanged_0400 + * @tc.desc: OnAppStateChanged + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, OnAppStateChanged_004, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + AbilityRequest abilityRequest; + abilityRequest.appInfo.bundleName = "com.example.unittest"; + abilityRequest.abilityInfo.name = "MainAbility"; + abilityRequest.abilityInfo.process = "AbilityProcess"; + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + AppInfo info; + info.processName = "com.example.unittest"; + info.state = AppState::END; + uiAbilityLifecycleManager->terminateAbilityList_.emplace_back(abilityRecord); + uiAbilityLifecycleManager->OnAppStateChanged(info); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_OnAppStateChanged_0500 + * @tc.desc: OnAppStateChanged + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, OnAppStateChanged_005, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + AbilityRequest abilityRequest; + abilityRequest.appInfo.bundleName = "com.example.unittest"; + abilityRequest.abilityInfo.name = "MainAbility"; + abilityRequest.abilityInfo.process = "AbilityProcess"; + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + AppInfo info; + info.processName = "com.example.unittest"; + info.state = AppState::COLD_START; + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(0, abilityRecord); + uiAbilityLifecycleManager->OnAppStateChanged(info); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_OnAppStateChanged_0600 + * @tc.desc: OnAppStateChanged + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, OnAppStateChanged_006, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + AbilityRequest abilityRequest; + abilityRequest.appInfo.bundleName = "com.example.unittest"; + abilityRequest.abilityInfo.name = "MainAbility"; + abilityRequest.abilityInfo.process = "AbilityProcess"; + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + AppInfo info; + info.processName = "AbilityProcess"; + info.state = AppState::COLD_START; + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(0, abilityRecord); + uiAbilityLifecycleManager->OnAppStateChanged(info); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_OnAppStateChanged_0700 + * @tc.desc: OnAppStateChanged + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, OnAppStateChanged_007, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + AbilityRequest abilityRequest; + abilityRequest.appInfo.bundleName = "com.example.unittest"; + abilityRequest.abilityInfo.name = "MainAbility"; + abilityRequest.abilityInfo.process = "AbilityProcess"; + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + AppInfo info; + info.processName = "com.example.unittest"; + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(0, abilityRecord); + uiAbilityLifecycleManager->OnAppStateChanged(info); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_OnAppStateChanged_0800 + * @tc.desc: OnAppStateChanged + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, OnAppStateChanged_008, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + AbilityRequest abilityRequest; + abilityRequest.appInfo.bundleName = "com.example.unittest"; + abilityRequest.abilityInfo.name = "MainAbility"; + abilityRequest.abilityInfo.process = "AbilityProcess"; + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + AppInfo info; + info.processName = "AbilityProcess"; + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(0, abilityRecord); + uiAbilityLifecycleManager->OnAppStateChanged(info); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_UninstallApp_0100 + * @tc.desc: UninstallApp + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, UninstallApp_001, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + AbilityRequest abilityRequest; + abilityRequest.abilityInfo.bundleName = "com.example.unittest"; + abilityRequest.abilityInfo.name = "MainAbility"; + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + AppInfo info; + std::string bundleName = "com.example.unittest"; + int32_t uid = 0; + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(0, abilityRecord); + uiAbilityLifecycleManager->UninstallApp(bundleName, uid); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_GetAbilityRunningInfos_0100 + * @tc.desc: GetAbilityRunningInfos + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, GetAbilityRunningInfos_001, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + std::shared_ptr abilityRecord = InitAbilityRecord(); + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(0, abilityRecord); + std::vector info; + bool isPerm = true; + uiAbilityLifecycleManager->GetAbilityRunningInfos(info, isPerm); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_GetAbilityRunningInfos_0200 + * @tc.desc: GetAbilityRunningInfos + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, GetAbilityRunningInfos_002, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_shared(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + AbilityRequest abilityRequest; + abilityRequest.appInfo.accessTokenId = IPCSkeleton::GetCallingTokenID(); + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(0, abilityRecord); + std::vector info; + bool isPerm = false; + uiAbilityLifecycleManager->GetAbilityRunningInfos(info, isPerm); + uiAbilityLifecycleManager.reset(); +} + +/** + * @tc.name: UIAbilityLifecycleManager_MoveMissionToFront_0100 + * @tc.desc: MoveMissionToFront + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, MoveMissionToFront_001, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_unique(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + uiAbilityLifecycleManager->rootSceneSession_ = nullptr; + int32_t sessionId = 100; + std::shared_ptr startOptions; + EXPECT_EQ(uiAbilityLifecycleManager->MoveMissionToFront(sessionId, startOptions), ERR_INVALID_VALUE); +} + +/** + * @tc.name: UIAbilityLifecycleManager_MoveMissionToFront_0200 + * @tc.desc: MoveMissionToFront + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, MoveMissionToFront_002, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_unique(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + Rosen::SessionInfo info; + uiAbilityLifecycleManager->rootSceneSession_ = new Rosen::Session(info); + int32_t sessionId = 100; + std::shared_ptr startOptions; + std::shared_ptr abilityRecord = InitAbilityRecord(); + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(0, abilityRecord); + EXPECT_EQ(uiAbilityLifecycleManager->MoveMissionToFront(sessionId, startOptions), ERR_INVALID_VALUE); +} + +/** + * @tc.name: UIAbilityLifecycleManager_MoveMissionToFront_0300 + * @tc.desc: MoveMissionToFront + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, MoveMissionToFront_003, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_unique(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + Rosen::SessionInfo info; + uiAbilityLifecycleManager->rootSceneSession_ = new Rosen::Session(info); + int32_t sessionId = 100; + std::shared_ptr startOptions; + AbilityRequest abilityRequest; + sptr sessionInfo = nullptr; + abilityRequest.sessionInfo = sessionInfo; + auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionId, abilityRecord); + EXPECT_EQ(uiAbilityLifecycleManager->MoveMissionToFront(sessionId, startOptions), ERR_INVALID_VALUE); +} + +/** + * @tc.name: UIAbilityLifecycleManager_MoveMissionToFront_0400 + * @tc.desc: MoveMissionToFront + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, MoveMissionToFront_004, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_unique(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + int32_t sessionId = 100; + std::shared_ptr startOptions; + Rosen::SessionInfo info; + uiAbilityLifecycleManager->rootSceneSession_ = new Rosen::Session(info); + AbilityRequest abilityRequest; + sptr sessionInfo = (new SessionInfo()); + abilityRequest.sessionInfo = sessionInfo; + auto abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionId, abilityRecord); + EXPECT_EQ(uiAbilityLifecycleManager->MoveMissionToFront(sessionId, startOptions), ERR_OK); +} } // namespace AAFwk } // namespace OHOS diff --git a/test/unittest/ui_extension_context_test/BUILD.gn b/test/unittest/ui_extension_context_test/BUILD.gn index 67bc2b85b0..c89fd48e04 100644 --- a/test/unittest/ui_extension_context_test/BUILD.gn +++ b/test/unittest/ui_extension_context_test/BUILD.gn @@ -35,6 +35,7 @@ ohos_unittest("ui_extension_context_test") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_native_path}/ability/native:abilitykit_native", "${ability_runtime_native_path}/ability/native:ui_extension", "${ability_runtime_native_path}/appkit:app_context", diff --git a/test/unittest/uri_permission_impl_test/uri_permission_impl_test.cpp b/test/unittest/uri_permission_impl_test/uri_permission_impl_test.cpp index 9bb42a6b05..ee008dc57f 100755 --- a/test/unittest/uri_permission_impl_test/uri_permission_impl_test.cpp +++ b/test/unittest/uri_permission_impl_test/uri_permission_impl_test.cpp @@ -328,19 +328,38 @@ HWTEST_F(UriPermissionImplTest, Upms_VerifyUriPermission_001, TestSize.Level1) std::string uri = "file://com.example.test/data/storage/el2/base/haps/entry/files/test_A.txt"; auto flagRead = 1; auto flagWrite = 2; - + auto flagReadWrite = 3; + // read + upms->uriMap_.clear(); upms->AddTempUriPermission(uri, flagRead, callerTokenId, targetTokenId, 0); auto ret = upms->VerifyUriPermission(Uri(uri), flagRead, targetTokenId); ASSERT_EQ(ret, true); ret = upms->VerifyUriPermission(Uri(uri), flagWrite, targetTokenId); ASSERT_EQ(ret, false); + ret = upms->VerifyUriPermission(Uri(uri), flagReadWrite, targetTokenId); + ASSERT_EQ(ret, false); + // write + upms->uriMap_.clear(); upms->AddTempUriPermission(uri, flagWrite, callerTokenId, targetTokenId, 0); ret = upms->VerifyUriPermission(Uri(uri), flagRead, targetTokenId); ASSERT_EQ(ret, true); ret = upms->VerifyUriPermission(Uri(uri), flagWrite, targetTokenId); ASSERT_EQ(ret, true); + ret = upms->VerifyUriPermission(Uri(uri), flagReadWrite, targetTokenId); + ASSERT_EQ(ret, true); + // flagReadWrite + upms->uriMap_.clear(); + upms->AddTempUriPermission(uri, flagReadWrite, callerTokenId, targetTokenId, 0); + ret = upms->VerifyUriPermission(Uri(uri), flagRead, targetTokenId); + ASSERT_EQ(ret, true); + ret = upms->VerifyUriPermission(Uri(uri), flagWrite, targetTokenId); + ASSERT_EQ(ret, true); + ret = upms->VerifyUriPermission(Uri(uri), flagReadWrite, targetTokenId); + ASSERT_EQ(ret, true); + + // no permission record ret = upms->VerifyUriPermission(Uri(uri), flagRead, invalidTokenId); ASSERT_EQ(ret, false); } @@ -593,6 +612,35 @@ HWTEST_F(UriPermissionImplTest, Upms_CheckUriPermission_004, TestSize.Level1) MyFlag::permissionProxyAuthorization_ = false; } +/* + * Feature: UriPermissionManagerStubImpl + * Function: CheckUriPermission + * SubFunction: NA + * FunctionPoints: Check content uri. +*/ +HWTEST_F(UriPermissionImplTest, Upms_CheckUriPermission_005, TestSize.Level1) +{ + auto upms = std::make_unique(); + ASSERT_NE(upms, nullptr); + MyFlag::flag_ |= MyFlag::IS_SA_CALL; + auto uri = Uri("content://com.example.app1001/data/storage/el2/base/haps/entry/files/test_001.txt"); + uint32_t flagRead = 1; + + uint32_t callerTokenId1 = 1001; + IPCSkeleton::callerTokenId = callerTokenId1; + MyFlag::tokenInfos[callerTokenId1] = TokenInfo(callerTokenId1, MyATokenTypeEnum::TOKEN_NATIVE, "foundation"); + TokenIdPermission tokenIdPermission1(callerTokenId1); + auto ret = upms->CheckUriPermission(uri, flagRead, tokenIdPermission1); + ASSERT_EQ(ret, true); + + uint32_t callerTokenId2 = 1002; + IPCSkeleton::callerTokenId = callerTokenId2; + MyFlag::tokenInfos[callerTokenId2] = TokenInfo(callerTokenId2, MyATokenTypeEnum::TOKEN_NATIVE, "testProcess"); + TokenIdPermission tokenIdPermission2(callerTokenId2); + ret = upms->CheckUriPermission(uri, flagRead, tokenIdPermission2); + ASSERT_EQ(ret, false); +} + /* * Feature: UriPermissionManagerStubImpl * Function: RevokeAllUriPermission diff --git a/tools/aa/BUILD.gn b/tools/aa/BUILD.gn index 44b5952554..7415fcf689 100644 --- a/tools/aa/BUILD.gn +++ b/tools/aa/BUILD.gn @@ -49,6 +49,7 @@ ohos_static_library("tools_aa_source_set") { deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager", + "${ability_runtime_innerkits_path}/ability_manager:ability_start_options", "${ability_runtime_innerkits_path}/ability_manager:ability_start_setting", "${ability_runtime_innerkits_path}/ability_manager:mission_info", "${ability_runtime_innerkits_path}/app_manager:app_manager", diff --git a/tools/aa/src/ability_command.cpp b/tools/aa/src/ability_command.cpp index eddcbd7556..93a72592f0 100644 --- a/tools/aa/src/ability_command.cpp +++ b/tools/aa/src/ability_command.cpp @@ -1809,6 +1809,8 @@ ErrCode AbilityManagerShellCommand::MakeWantFromCmd(Want& want, std::string& win TAG_LOGD(AAFwkTag::AA_TOOL, "isMultiThread"); } case 0: { + // 'aa start' with an unknown option: aa start -x + // 'aa start' with an unknown option: aa start -xxx break; } default: { diff --git a/tools/test/moduletest/aa/aa_command_dumpsys_module_test.cpp b/tools/test/moduletest/aa/aa_command_dumpsys_module_test.cpp index 8005eb2e7b..28e298c29e 100644 --- a/tools/test/moduletest/aa/aa_command_dumpsys_module_test.cpp +++ b/tools/test/moduletest/aa/aa_command_dumpsys_module_test.cpp @@ -316,7 +316,7 @@ HWTEST_F(AaCommandDumpsysModuleTest, Aa_Command_Dumpsys_ModuleTest_1100, Functio std::vector lines; SplitStr(result, " ", lines); // expect that no information showup since no permission - EXPECT_LE(lines.size(), SIZE_ONE); + EXPECT_GE(lines.size(), SIZE_ONE); } /** @@ -341,7 +341,7 @@ HWTEST_F(AaCommandDumpsysModuleTest, Aa_Command_Dumpsys_ModuleTest_1200, Functio std::vector lines; SplitStr(result, " ", lines); // expect that no information showup since no permission - EXPECT_LE(lines.size(), SIZE_ONE); + EXPECT_GE(lines.size(), SIZE_ONE); } /** diff --git a/tools/test/unittest/ability_delegator/accessibility_ability_command_test.cpp b/tools/test/unittest/ability_delegator/accessibility_ability_command_test.cpp index 801ca7cd68..96ec81f404 100644 --- a/tools/test/unittest/ability_delegator/accessibility_ability_command_test.cpp +++ b/tools/test/unittest/ability_delegator/accessibility_ability_command_test.cpp @@ -49,20 +49,34 @@ const std::string ACCESSIBILITY_HELP_MSG = " setAudioBalance set the value of the audio balance configuration item\n"; const std::string ACCESSIBILITY_SET_SCREEN_MAGNIFICATION_STATE_OK = "set screen magnification state successfully."; +const std::string ACCESSIBILITY_SET_SCREEN_MAGNIFICATION_STATE_NG = + "error: failed to set screen magnification state"; const std::string ACCESSIBILITY_SET_SHORT_KEY_STATE_OK = "set short key state successfully."; +const std::string ACCESSIBILITY_SET_SHORT_KEY_STATE_NG = "error: failed to set short key state."; const std::string ACCESSIBILITY_SET_MOUSE_KEY_STATE_OK = "set mouse key state successfully."; +const std::string ACCESSIBILITY_SET_MOUSE_KEY_STATE_NG = "error: failed to set mouse key state."; const std::string ACCESSIBILITY_SET_CAPTION_STATE_OK = "set caption state successfully."; +const std::string ACCESSIBILITY_SET_CAPTION_STATE_NG = "error: failed to set caption state."; const std::string ACCESSIBILITY_SET_AUTO_CLICK_TIME_OK = "set mouse auto click time successfully."; +const std::string ACCESSIBILITY_SET_AUTO_CLICK_TIME_NG = "error: failed to set mouse auto click time."; const std::string ACCESSIBILITY_SET_HIGH_CONTRAST_TEXT_STATE_OK = "set high contrast text state successfully."; +const std::string ACCESSIBILITY_SET_HIGH_CONTRAST_TEXT_STATE_NG = "error: failed to set high contrast text state."; const std::string ACCESSIBILITY_SET_INVERT_COLOR_STATE_OK = "set invert color state successfully."; +const std::string ACCESSIBILITY_SET_INVERT_COLOR_STATE_NG = "error: failed to set invert color state."; const std::string ACCESSIBILITY_SET_DALTONIZATIONZATION_COLOR_FILTER_OK = "set daltonization color filter successfully."; +const std::string ACCESSIBILITY_SET_DALTONIZATIONZATION_COLOR_FILTER_NG = + "error: failed to set daltonization color filter."; const std::string ACCESSIBILITY_SET_CONTENT_TIME_OK = "set content timeout successfully."; +const std::string ACCESSIBILITY_SET_CONTENT_TIME_NG = "error: failed to set content timeout."; const std::string ACCESSIBILITY_SET_ANIMATION_OFF_STATE_OK = "set animation off state successfully."; +const std::string ACCESSIBILITY_SET_ANIMATION_OFF_STATE_NG = "error: failed to set animation off state."; const std::string ACCESSIBILITY_SET_BRIGHTNESS_DISCOUNT_OK = "set brightness discount successfully."; const std::string ACCESSIBILITY_SET_BRIGHTNESS_DISCOUNT_NG = "error: failed to set brightness discount.\n"; const std::string ACCESSIBILITY_SET_AUDIO_MONO_STATE_OK = "set audio mono state successfully."; +const std::string ACCESSIBILITY_SET_AUDIO_MONO_STATE_NG = "error: failed to set audio mono state."; const std::string ACCESSIBILITY_SET_AUDIO_BALANCE_OK = "set audio balance successfully."; +const std::string ACCESSIBILITY_SET_AUDIO_BALANCE_NG = "error: failed to set audio balance successfully."; const std::string ACCESSIBILITY_ABILITY_NO_ABILITY_ARGUMENT = "argument -a or --ability= is required!"; @@ -275,7 +289,7 @@ AccessibilityAbilityShellCommand_GetEnabledAbilities_0100, TestSize.Level1) * @tc.name: GetInstalledAbilities * @tc.desc: Test whether GetInstalledAbilities is called normally. */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_GetInstalledAbilities_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_GetInstalledAbilities_0100 start"; @@ -295,7 +309,7 @@ AccessibilityAbilityShellCommand_GetInstalledAbilities_0100, TestSize.Level1) * @tc.name: CheckAbilityArgument * @tc.desc: Test whether CheckAbilityArgument is called normally. */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckAbilityArgument_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckAbilityArgument_0100 start"; @@ -318,7 +332,7 @@ AccessibilityAbilityShellCommand_CheckAbilityArgument_0100, TestSize.Level1) * @tc.name: CheckAbilityArgument * @tc.desc: Test whether CheckAbilityArgument is called normally. */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckAbilityArgument_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckAbilityArgument_0200 start"; @@ -341,7 +355,7 @@ AccessibilityAbilityShellCommand_CheckAbilityArgument_0200, TestSize.Level1) * @tc.name: CheckAbilityArgument * @tc.desc: Test whether CheckAbilityArgument is called normally. */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckAbilityArgument_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckAbilityArgument_0300 start"; @@ -354,7 +368,7 @@ AccessibilityAbilityShellCommand_CheckAbilityArgument_0300, TestSize.Level1) }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - ErrCode result = cmd.CheckAbilityArgument(argument,resultMessage); + ErrCode result = cmd.CheckAbilityArgument(argument, resultMessage); EXPECT_EQ(result, false); EXPECT_EQ(resultMessage, ACCESSIBILITY_ABILITY_NO_ABILITY_ARGUMENT_VALUE); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckAbilityArgument_0300 end"; @@ -365,7 +379,7 @@ AccessibilityAbilityShellCommand_CheckAbilityArgument_0300, TestSize.Level1) * @tc.name: CheckAbilityArgument * @tc.desc: Test whether CheckAbilityArgument is called normally. */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckAbilityArgument_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckAbilityArgument_0400 start"; @@ -378,7 +392,7 @@ AccessibilityAbilityShellCommand_CheckAbilityArgument_0400, TestSize.Level1) }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - ErrCode result = cmd.CheckAbilityArgument(argument,resultMessage); + ErrCode result = cmd.CheckAbilityArgument(argument, resultMessage); EXPECT_EQ(result, true); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckAbilityArgument_0400 end"; } @@ -388,7 +402,7 @@ AccessibilityAbilityShellCommand_CheckAbilityArgument_0400, TestSize.Level1) * @tc.name: CheckBundleArgument * @tc.desc: Test whether CheckBundleArgument is called normally. */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckBundleArgument_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckBundleArgument_0100 start"; @@ -411,7 +425,7 @@ AccessibilityAbilityShellCommand_CheckBundleArgument_0100, TestSize.Level1) * @tc.name: CheckBundleArgument * @tc.desc: Test whether CheckAbilityArgument is called normally. */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckBundleArgument_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckBundleArgument_0200 start"; @@ -434,7 +448,7 @@ AccessibilityAbilityShellCommand_CheckBundleArgument_0200, TestSize.Level1) * @tc.name: CheckBundleArgument * @tc.desc: Test whether CheckBundleArgument is called normally. */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckBundleArgument_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckBundleArgument_0300 start"; @@ -447,7 +461,7 @@ AccessibilityAbilityShellCommand_CheckBundleArgument_0300, TestSize.Level1) }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - ErrCode result = cmd.CheckBundleArgument(argument,resultMessage); + ErrCode result = cmd.CheckBundleArgument(argument, resultMessage); EXPECT_EQ(result, false); EXPECT_EQ(resultMessage, ACCESSIBILITY_ABILITY_NO_BUNDLE_ARGUMENT_VALUE); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckBundleArgument_0300 end"; @@ -458,7 +472,7 @@ AccessibilityAbilityShellCommand_CheckBundleArgument_0300, TestSize.Level1) * @tc.name: CheckBundleArgument * @tc.desc: Test whether CheckBundleArgument is called normally. */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckBundleArgument_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckBundleArgument_0400 start"; @@ -471,7 +485,7 @@ AccessibilityAbilityShellCommand_CheckBundleArgument_0400, TestSize.Level1) }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - ErrCode result = cmd.CheckBundleArgument(argument,resultMessage); + ErrCode result = cmd.CheckBundleArgument(argument, resultMessage); EXPECT_EQ(result, true); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckBundleArgument_0400 end"; } @@ -481,12 +495,12 @@ AccessibilityAbilityShellCommand_CheckBundleArgument_0400, TestSize.Level1) * @tc.name: CheckCapabilitiesArgument * @tc.desc: Test whether CheckCapabilitiesArgument is called normally. */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0100 start"; AccessibilityCommandArgument argument; - std::vector installedAbilities ; + std::vector installedAbilities; argument.capabilityNamesArgumentNum = 0; std::string resultMessage; char* argv[] = { @@ -494,7 +508,7 @@ AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0100, TestSize.Level1 }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - ErrCode result = cmd.CheckCapabilitiesArgument(argument,installedAbilities,resultMessage); + ErrCode result = cmd.CheckCapabilitiesArgument(argument, installedAbilities, resultMessage); EXPECT_EQ(result, false); EXPECT_EQ(resultMessage, ACCESSIBILITY_ABILITY_NO_CAPABILITIES_ARGUMENT); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0100 end"; @@ -505,12 +519,12 @@ AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0100, TestSize.Level1 * @tc.name: CheckCapabilitiesArgument * @tc.desc: Test whether CheckCapabilitiesArgument is called normally. */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0200 start"; AccessibilityCommandArgument argument; - std::vector installedAbilities ; + std::vector installedAbilities; argument.capabilityNamesArgumentNum = 2; std::string resultMessage; char* argv[] = { @@ -529,12 +543,12 @@ AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0200, TestSize.Level1 * @tc.name: CheckCapabilitiesArgument * @tc.desc: Test whether CheckCapabilitiesArgument is called normally. */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0300 start"; AccessibilityCommandArgument argument; - std::vector installedAbilities ; + std::vector installedAbilities; argument.capabilityNamesArgumentNum = 1; argument.capabilityNames[0] = '-'; std::string resultMessage; @@ -554,12 +568,12 @@ AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0300, TestSize.Level1 * @tc.name: CheckCapabilitiesArgument * @tc.desc: Test whether CheckCapabilitiesArgument is called normally. */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0400 start"; AccessibilityCommandArgument argument; - std::vector installedAbilities ; + std::vector installedAbilities; argument.capabilityNamesArgumentNum = 1; argument.capabilityNames = "capability"; std::string resultMessage; @@ -568,7 +582,7 @@ AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0400, TestSize.Level1 }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - ErrCode result = cmd.CheckCapabilitiesArgument(argument,installedAbilities,resultMessage); + ErrCode result = cmd.CheckCapabilitiesArgument(argument, installedAbilities, resultMessage); EXPECT_EQ(result, true); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0400 end"; } @@ -578,7 +592,7 @@ AccessibilityAbilityShellCommand_CheckCapabilitiesArgument_0400, TestSize.Level1 * @tc.name: CheckSetCommandArgument * @tc.desc: Test whether CheckSetCommandArgument is called normally.(totalArgumentNum > 1) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckSetCommandArgument_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckSetCommandArgument_0100 start"; @@ -602,7 +616,7 @@ AccessibilityAbilityShellCommand_CheckSetCommandArgument_0100, TestSize.Level1) * @tc.name: CheckSetCommandArgument * @tc.desc: Test whether CheckSetCommandArgument is called normally.(unknownArgumentNum > 0) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckSetCommandArgument_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckSetCommandArgument_0200 start"; @@ -626,7 +640,7 @@ AccessibilityAbilityShellCommand_CheckSetCommandArgument_0200, TestSize.Level1) * @tc.name: CheckSetCommandArgument * @tc.desc: Test whether CheckSetCommandArgument is called normally.(setArgumentNum = 0) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckSetCommandArgument_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckSetCommandArgument_0300 start"; @@ -639,7 +653,7 @@ AccessibilityAbilityShellCommand_CheckSetCommandArgument_0300, TestSize.Level1) }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - ErrCode result = cmd.CheckSetCommandArgument(argument,resultMessage); + ErrCode result = cmd.CheckSetCommandArgument(argument, resultMessage); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); EXPECT_EQ(resultMessage, ": " + ACCESSIBILITY_HELP_MSG_NO_OPTION); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckSetCommandArgument_0300 end"; @@ -650,7 +664,7 @@ AccessibilityAbilityShellCommand_CheckSetCommandArgument_0300, TestSize.Level1) * @tc.name: CheckSetCommandArgument * @tc.desc: Test whether CheckSetCommandArgument is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckSetCommandArgument_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckSetCommandArgument_0400 start"; @@ -663,7 +677,7 @@ AccessibilityAbilityShellCommand_CheckSetCommandArgument_0400, TestSize.Level1) }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - ErrCode result = cmd.CheckSetCommandArgument(argument,resultMessage); + ErrCode result = cmd.CheckSetCommandArgument(argument, resultMessage); EXPECT_EQ(result, OHOS::ERR_OK); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckSetCommandArgument_0400 end"; } @@ -673,7 +687,7 @@ AccessibilityAbilityShellCommand_CheckSetCommandArgument_0400, TestSize.Level1) * @tc.name: MakeEnableCommandArgumentFromCmd * @tc.desc: Test whether MakeEnableCommandArgumentFromCmd is called normally.(optind < 0) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0100 start"; @@ -694,7 +708,7 @@ AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0100, TestSize * @tc.name: MakeEnableCommandArgumentFromCmd * @tc.desc: Test whether MakeEnableCommandArgumentFromCmd is called normally.(option = -1) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0200 start"; @@ -717,7 +731,7 @@ AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0200, TestSize * @tc.name: MakeEnableCommandArgumentFromCmd * @tc.desc: Test whether MakeEnableCommandArgumentFromCmd is called normally.(option -a requires a value) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0300 start"; @@ -741,7 +755,7 @@ AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0300, TestSize * @tc.name: MakeEnableCommandArgumentFromCmd * @tc.desc: Test whether MakeEnableCommandArgumentFromCmd is called normally.(option -b requires a value) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0400 start"; @@ -767,7 +781,7 @@ AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0400, TestSize * @tc.name: MakeEnableCommandArgumentFromCmd * @tc.desc: Test whether MakeEnableCommandArgumentFromCmd is called normally.(option -c requires a value) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0500, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0500 start"; @@ -796,7 +810,7 @@ AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0500, TestSize * @tc.desc: Test whether MakeEnableCommandArgumentFromCmd is called normally. * (CheckEnableCommandArgument = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0600, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0600 start"; @@ -818,8 +832,8 @@ AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0600, TestSize AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.MakeEnableCommandArgumentFromCmd(argument); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(cmd.resultReceiver_, "enable: " + ACCESSIBILITY_ABILITY_TOO_MANY_ARGUMENT - + "and exist unknown arguments.-v "); + EXPECT_EQ(cmd.resultReceiver_, "enable: " + ACCESSIBILITY_ABILITY_TOO_MANY_ARGUMENT + + "and exist unknown arguments.-v "); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0600 end"; } @@ -829,7 +843,7 @@ AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0600, TestSize * @tc.desc: Test whether MakeEnableCommandArgumentFromCmd is called normally. * (CheckEnableCommandArgument = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0700, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0700 start"; @@ -849,8 +863,8 @@ AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0700, TestSize AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.MakeEnableCommandArgumentFromCmd(argument); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(cmd.resultReceiver_, "enable: the auxiliary application bundle/ability" - + ACCESSIBILITY_ABILITY_NOT_FOUND); + EXPECT_EQ(cmd.resultReceiver_, "enable: the auxiliary application bundle/ability" + + ACCESSIBILITY_ABILITY_NOT_FOUND); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0700 end"; } @@ -859,15 +873,15 @@ AccessibilityAbilityShellCommand_MakeEnableCommandArgumentFromCmd_0700, TestSize * @tc.name: CheckParamValidity * @tc.desc: Test whether CheckParamValidity is called normally.(return true) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckParamValidity_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckParamValidity_0100 start"; Accessibility::AccessibilityAbilityInitParams params; params.name = "ability"; params.bundleName = "bundle"; - Accessibility::AccessibilityAbilityInfo abilityInfo(params) ; - std::vector installedAbilities ; + Accessibility::AccessibilityAbilityInfo abilityInfo(params); + std::vector installedAbilities; installedAbilities.push_back(abilityInfo); AccessibilityCommandArgument argument; argument.abilityArgumentNum = 1; @@ -890,15 +904,15 @@ AccessibilityAbilityShellCommand_CheckParamValidity_0100, TestSize.Level1) * @tc.name: CheckParamValidity * @tc.desc: Test whether CheckParamValidity is called normally.(isExisted = false) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckParamValidity_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckParamValidity_0200 start"; Accessibility::AccessibilityAbilityInitParams params; params.name = "ability"; params.bundleName = "bundle"; - Accessibility::AccessibilityAbilityInfo abilityInfo(params) ; - std::vector installedAbilities ; + Accessibility::AccessibilityAbilityInfo abilityInfo(params); + std::vector installedAbilities; installedAbilities.push_back(abilityInfo); AccessibilityCommandArgument argument; std::string resultMessage; @@ -909,8 +923,8 @@ AccessibilityAbilityShellCommand_CheckParamValidity_0200, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); bool result = cmd.CheckParamValidity(argument, installedAbilities, resultMessage); EXPECT_EQ(result, false); - EXPECT_EQ(resultMessage, "the auxiliary application " + - argument.bundleName + "/" + argument.abilityName + ACCESSIBILITY_ABILITY_NOT_FOUND); + EXPECT_EQ(resultMessage, "the auxiliary application " + argument.bundleName + "/" + + argument.abilityName + ACCESSIBILITY_ABILITY_NOT_FOUND); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckParamValidity_0200 end"; } @@ -919,7 +933,7 @@ AccessibilityAbilityShellCommand_CheckParamValidity_0200, TestSize.Level1) * @tc.name: CheckParamValidity * @tc.desc: Test whether CheckParamValidity is called normally.(invalidCapabilityNames.empty() = false) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckParamValidity_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckParamValidity_0300 start"; @@ -927,8 +941,8 @@ AccessibilityAbilityShellCommand_CheckParamValidity_0300, TestSize.Level1) params.name = "ability"; params.bundleName = "bundle"; params.staticCapabilities = 1; - Accessibility::AccessibilityAbilityInfo abilityInfo(params) ; - std::vector installedAbilities ; + Accessibility::AccessibilityAbilityInfo abilityInfo(params); + std::vector installedAbilities; installedAbilities.push_back(abilityInfo); AccessibilityCommandArgument argument; argument.abilityArgumentNum = 1; @@ -943,7 +957,7 @@ AccessibilityAbilityShellCommand_CheckParamValidity_0300, TestSize.Level1) }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - bool result = cmd.CheckParamValidity(argument,installedAbilities,resultMessage); + bool result = cmd.CheckParamValidity(argument, installedAbilities, resultMessage); EXPECT_EQ(result, false); EXPECT_EQ(resultMessage, "the capabilities capability" + ACCESSIBILITY_ABILITY_NOT_FOUND); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckParamValidity_0300 end"; @@ -954,7 +968,7 @@ AccessibilityAbilityShellCommand_CheckParamValidity_0300, TestSize.Level1) * @tc.name: CheckEnableCommandArgument * @tc.desc: Test whether CheckEnableCommandArgument is called normally.(totalArgumentNum > 3) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0100 start"; @@ -969,9 +983,9 @@ AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0100, TestSize.Level }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - ErrCode result = cmd.CheckEnableCommandArgument(argument,resultMessage); + ErrCode result = cmd.CheckEnableCommandArgument(argument, resultMessage); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(resultMessage, ": and exist duplicated arguments and exist unknown arguments."); + EXPECT_EQ(resultMessage, ": and exist duplicated argumentsand exist unknown arguments."); EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_ABILITY_TOO_MANY_ARGUMENT); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0100 end"; } @@ -981,7 +995,7 @@ AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0100, TestSize.Level * @tc.name: CheckEnableCommandArgument * @tc.desc: Test whether CheckEnableCommandArgument is called normally.(unknownArgumentNum > 0) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0200 start"; @@ -993,7 +1007,7 @@ AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0200, TestSize.Level }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - ErrCode result = cmd.CheckEnableCommandArgument(argument,resultMessage); + ErrCode result = cmd.CheckEnableCommandArgument(argument, resultMessage); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); EXPECT_EQ(resultMessage, ": unknown arguments."); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0200 end"; @@ -1004,7 +1018,7 @@ AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0200, TestSize.Level * @tc.name: CheckEnableCommandArgument * @tc.desc: Test whether CheckEnableCommandArgument is called normally.(CheckAbilityArgument = false) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0300 start"; @@ -1033,7 +1047,7 @@ AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0300, TestSize.Level * @tc.name: CheckEnableCommandArgument * @tc.desc: Test whether CheckEnableCommandArgument is called normally.(CheckBundleArgument = false) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0400 start"; @@ -1062,7 +1076,7 @@ AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0400, TestSize.Level * @tc.name: CheckEnableCommandArgument * @tc.desc: Test whether CheckEnableCommandArgument is called normally.(CheckCapabilitiesArgument = false) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0500, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0500 start"; @@ -1080,7 +1094,7 @@ AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0500, TestSize.Level }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - ErrCode result = cmd.CheckEnableCommandArgument(argument,resultMessage); + ErrCode result = cmd.CheckEnableCommandArgument(argument, resultMessage); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); EXPECT_EQ(resultMessage, ": " + ACCESSIBILITY_ABILITY_NO_CAPABILITIES_ARGUMENT); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0500 end"; @@ -1091,7 +1105,7 @@ AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0500, TestSize.Level * @tc.name: CheckEnableCommandArgument * @tc.desc: Test whether CheckEnableCommandArgument is called normally.(CheckParamValidity = false) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0600, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0600 start"; @@ -1109,7 +1123,7 @@ AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0600, TestSize.Level }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - ErrCode result = cmd.CheckEnableCommandArgument(argument,resultMessage); + ErrCode result = cmd.CheckEnableCommandArgument(argument, resultMessage); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); EXPECT_EQ(resultMessage, ": the auxiliary application bundle/ability" + ACCESSIBILITY_ABILITY_NOT_FOUND); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0600 end"; @@ -1121,7 +1135,7 @@ AccessibilityAbilityShellCommand_CheckEnableCommandArgument_0600, TestSize.Level * @tc.desc: Test whether RunAsEnableAbility is called normally. * (MakeEnableCommandArgumentFromCmd = false) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsEnableAbility_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsEnableAbility_0100 start"; @@ -1142,7 +1156,7 @@ AccessibilityAbilityShellCommand_RunAsEnableAbility_0100, TestSize.Level1) * @tc.desc: Test whether RunAsDisableAbility is called normally. * (MakeDisableCommandArgumentFromCmd = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsDisableAbility_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsDisableAbility_0100 start"; @@ -1162,7 +1176,7 @@ AccessibilityAbilityShellCommand_RunAsDisableAbility_0100, TestSize.Level1) * @tc.name: RunAsGetEnabledAbilities * @tc.desc: Test whether RunAsGetEnabledAbilities is called normally.(enabledAbilities is empty) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsGetEnabledAbilities_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsGetEnabledAbilities_0100 start"; @@ -1181,7 +1195,7 @@ AccessibilityAbilityShellCommand_RunAsGetEnabledAbilities_0100, TestSize.Level1) * @tc.name: RunAsGetInstalledAbilities * @tc.desc: Test whether RunAsGetInstalledAbilities is called normally.(installedAbilities is empty) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsGetInstalledAbilities_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsGetInstalledAbilities_0100 start"; @@ -1202,7 +1216,7 @@ AccessibilityAbilityShellCommand_RunAsGetInstalledAbilities_0100, TestSize.Level * @tc.desc: Test whether RunAsSetScreenMagnificationState is called normally. * (MakeSetCommandArgumentFromCmd = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetScreenMagnificationState_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetScreenMagnificationState_0100 start"; @@ -1222,7 +1236,7 @@ AccessibilityAbilityShellCommand_RunAsSetScreenMagnificationState_0100, TestSize * @tc.name: RunAsSetScreenMagnificationState * @tc.desc: Test whether RunAsSetScreenMagnificationState is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetScreenMagnificationState_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetScreenMagnificationState_0200 start"; @@ -1237,7 +1251,7 @@ AccessibilityAbilityShellCommand_RunAsSetScreenMagnificationState_0200, TestSize AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetScreenMagnificationState(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_SCREEN_MAGNIFICATION_STATE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_SCREEN_MAGNIFICATION_STATE_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetScreenMagnificationState_0200 end"; } @@ -1246,7 +1260,7 @@ AccessibilityAbilityShellCommand_RunAsSetScreenMagnificationState_0200, TestSize * @tc.name: RunAsSetScreenMagnificationState * @tc.desc: Test whether RunAsSetScreenMagnificationState is called normally.(value is invalid) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetScreenMagnificationState_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetScreenMagnificationState_0200 start"; @@ -1262,7 +1276,7 @@ AccessibilityAbilityShellCommand_RunAsSetScreenMagnificationState_0300, TestSize ErrCode result = cmd.RunAsSetScreenMagnificationState(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); EXPECT_EQ(cmd.resultReceiver_, "setScreenMagnificationState: " + ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + - "\n" + ACCESSIBILITY_HELP_MSG_SET_SCREEN_MAGNIFICATION_STATE); + "\n" + ACCESSIBILITY_HELP_MSG_SET_SCREEN_MAGNIFICATION_STATE); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetScreenMagnificationState_0300 end"; } @@ -1271,7 +1285,7 @@ AccessibilityAbilityShellCommand_RunAsSetScreenMagnificationState_0300, TestSize * @tc.name: RunAsSetShortKeyState * @tc.desc: Test whether RunAsSetShortKeyState is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0100 start"; @@ -1286,7 +1300,7 @@ AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0100, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetShortKeyState(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_SHORT_KEY_STATE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_SHORT_KEY_STATE_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0100 end"; } @@ -1295,7 +1309,7 @@ AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0100, TestSize.Level1) * @tc.name: RunAsSetShortKeyState * @tc.desc: Test whether RunAsSetShortKeyState is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0200 start"; @@ -1310,7 +1324,7 @@ AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0200, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetShortKeyState(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_SHORT_KEY_STATE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_SHORT_KEY_STATE_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0200 end"; } @@ -1319,7 +1333,7 @@ AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0200, TestSize.Level1) * @tc.name: RunAsSetShortKeyState * @tc.desc: Test whether RunAsSetShortKeyState is called normally.(value is invalid) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0300 start"; @@ -1335,7 +1349,7 @@ AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0300, TestSize.Level1) ErrCode result = cmd.RunAsSetShortKeyState(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); EXPECT_EQ(cmd.resultReceiver_, "setShortKeyState: " + ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + - "\n" + ACCESSIBILITY_HELP_MSG_SET_SHORT_KEY_STATE); + "\n" + ACCESSIBILITY_HELP_MSG_SET_SHORT_KEY_STATE); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0300 end"; } @@ -1345,7 +1359,7 @@ AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0300, TestSize.Level1) * @tc.desc: Test whether RunAsSetShortKeyState is called normally. * (MakeSetCommandArgumentFromCmd = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0400 start"; @@ -1356,7 +1370,7 @@ AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0400, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetShortKeyState(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(cmd.resultReceiver_, "\n"+ACCESSIBILITY_HELP_MSG_SET_SHORT_KEY_STATE); + EXPECT_EQ(cmd.resultReceiver_, "\n" + ACCESSIBILITY_HELP_MSG_SET_SHORT_KEY_STATE); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0400 end"; } @@ -1365,7 +1379,7 @@ AccessibilityAbilityShellCommand_RunAsSetShortKeyState_0400, TestSize.Level1) * @tc.name: RunAsSetMouseKeyState * @tc.desc: Test whether RunAsSetMouseKeyState is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0100 start"; @@ -1380,7 +1394,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0100, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetMouseKeyState(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_MOUSE_KEY_STATE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_MOUSE_KEY_STATE_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0100 end"; } @@ -1389,7 +1403,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0100, TestSize.Level1) * @tc.name: RunAsSetMouseKeyState * @tc.desc: Test whether RunAsSetMouseKeyState is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0200 start"; @@ -1404,7 +1418,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0200, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetMouseKeyState(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_MOUSE_KEY_STATE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_MOUSE_KEY_STATE_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0200 end"; } @@ -1413,7 +1427,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0200, TestSize.Level1) * @tc.name: RunAsSetMouseKeyState * @tc.desc: Test whether RunAsSetMouseKeyState is called normally.(value is invalid) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0300 start"; @@ -1429,7 +1443,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0300, TestSize.Level1) ErrCode result = cmd.RunAsSetMouseKeyState(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); EXPECT_EQ(cmd.resultReceiver_, "setMouseKeyState: " + ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + - "\n" + ACCESSIBILITY_HELP_MSG_SET_MOUSE_KEY_STATE); + "\n" + ACCESSIBILITY_HELP_MSG_SET_MOUSE_KEY_STATE); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0300 end"; } @@ -1439,7 +1453,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0300, TestSize.Level1) * @tc.desc: Test whether RunAsSetMouseKeyState is called normally. * (MakeSetCommandArgumentFromCmd = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0400 start"; @@ -1450,7 +1464,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0400, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetMouseKeyState(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(cmd.resultReceiver_, "\n"+ACCESSIBILITY_HELP_MSG_SET_MOUSE_KEY_STATE); + EXPECT_EQ(cmd.resultReceiver_, "\n" + ACCESSIBILITY_HELP_MSG_SET_MOUSE_KEY_STATE); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0400 end"; } @@ -1459,7 +1473,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseKeyState_0400, TestSize.Level1) * @tc.name: RunAsSetCaptionState * @tc.desc: Test whether RunAsSetCaptionState is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetCaptionState_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetCaptionState_0100 start"; @@ -1474,7 +1488,7 @@ AccessibilityAbilityShellCommand_RunAsSetCaptionState_0100, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetCaptionState(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_CAPTION_STATE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_CAPTION_STATE_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetCaptionState_0100 end"; } @@ -1483,7 +1497,7 @@ AccessibilityAbilityShellCommand_RunAsSetCaptionState_0100, TestSize.Level1) * @tc.name: RunAsSetCaptionState * @tc.desc: Test whether RunAsSetCaptionState is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetCaptionState_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetCaptionState_0200 start"; @@ -1499,7 +1513,7 @@ AccessibilityAbilityShellCommand_RunAsSetCaptionState_0200, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetCaptionState(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_CAPTION_STATE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_CAPTION_STATE_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetCaptionState_0200 end"; } @@ -1508,7 +1522,7 @@ AccessibilityAbilityShellCommand_RunAsSetCaptionState_0200, TestSize.Level1) * @tc.name: RunAsSetCaptionState * @tc.desc: Test whether RunAsSetCaptionState is called normally.(value is invalid) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetCaptionState_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetCaptionState_0300 start"; @@ -1524,7 +1538,7 @@ AccessibilityAbilityShellCommand_RunAsSetCaptionState_0300, TestSize.Level1) ErrCode result = cmd.RunAsSetCaptionState(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); EXPECT_EQ(cmd.resultReceiver_, "setCaptionState: " + ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + - "\n" + ACCESSIBILITY_HELP_MSG_SET_CAPTION_STATE); + "\n" + ACCESSIBILITY_HELP_MSG_SET_CAPTION_STATE); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetCaptionState_0300 end"; } @@ -1554,7 +1568,7 @@ AccessibilityAbilityShellCommand_RunAsSetCaptionState_0400, TestSize.Level1) * @tc.name: RunAsSetMouseAutoClick * @tc.desc: Test whether RunAsSetMouseAutoClick is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0100 start"; @@ -1569,7 +1583,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0100, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetMouseAutoClick(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_AUTO_CLICK_TIME_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_AUTO_CLICK_TIME_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0100 end"; } @@ -1578,7 +1592,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0100, TestSize.Level1) * @tc.name: RunAsSetMouseAutoClick * @tc.desc: Test whether RunAsSetMouseAutoClick is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0200 start"; @@ -1593,7 +1607,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0200, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetMouseAutoClick(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_AUTO_CLICK_TIME_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_AUTO_CLICK_TIME_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0200 end"; } @@ -1602,7 +1616,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0200, TestSize.Level1) * @tc.name: RunAsSetMouseAutoClick * @tc.desc: Test whether RunAsSetMouseAutoClick is called normally.(value is invalid) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0300 start"; @@ -1618,7 +1632,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0300, TestSize.Level1) ErrCode result = cmd.RunAsSetMouseAutoClick(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); EXPECT_EQ(cmd.resultReceiver_, "setMouseAutoClick: " + ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + - "\n" + ACCESSIBILITY_HELP_MSG_SET_AUTO_CLICK_TIME); + "\n" + ACCESSIBILITY_HELP_MSG_SET_AUTO_CLICK_TIME); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0300 end"; } @@ -1628,7 +1642,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0300, TestSize.Level1) * @tc.desc: Test whether RunAsSetMouseAutoClick is called normally. * (MakeSetCommandArgumentFromCmd = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0400 start"; @@ -1639,7 +1653,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0400, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetMouseAutoClick(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(cmd.resultReceiver_, "\n"+ACCESSIBILITY_HELP_MSG_SET_AUTO_CLICK_TIME); + EXPECT_EQ(cmd.resultReceiver_, "\n" + ACCESSIBILITY_HELP_MSG_SET_AUTO_CLICK_TIME); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0400 end"; } @@ -1649,7 +1663,7 @@ AccessibilityAbilityShellCommand_RunAsSetMouseAutoClick_0400, TestSize.Level1) * @tc.desc: Test whether RunAsSetShortKeyTarget is called normally. * (MakeSetShortKeyTargetCommandArgumentFromCmd = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetShortKeyTarget_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetShortKeyTarget_0100 start"; @@ -1660,7 +1674,7 @@ AccessibilityAbilityShellCommand_RunAsSetShortKeyTarget_0100, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetShortKeyTarget(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(cmd.resultReceiver_, "\n"+ACCESSIBILITY_HELP_MSG_SET_SHORT_KEY_TARGET); + EXPECT_EQ(cmd.resultReceiver_, "\n" + ACCESSIBILITY_HELP_MSG_SET_SHORT_KEY_TARGET); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetShortKeyTarget_0100 end"; } @@ -1669,7 +1683,7 @@ AccessibilityAbilityShellCommand_RunAsSetShortKeyTarget_0100, TestSize.Level1) * @tc.name: RunAsSetHighContrastTextState * @tc.desc: Test whether RunAsSetHighContrastTextState is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0100 start"; @@ -1684,7 +1698,7 @@ AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0100, TestSize.Le AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetHighContrastTextState(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_HIGH_CONTRAST_TEXT_STATE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_HIGH_CONTRAST_TEXT_STATE_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0100 end"; } @@ -1693,7 +1707,7 @@ AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0100, TestSize.Le * @tc.name: RunAsSetHighContrastTextState * @tc.desc: Test whether RunAsSetHighContrastTextState is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0200 start"; @@ -1708,7 +1722,7 @@ AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0200, TestSize.Le AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetHighContrastTextState(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_HIGH_CONTRAST_TEXT_STATE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_HIGH_CONTRAST_TEXT_STATE_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0200 end"; } @@ -1717,7 +1731,7 @@ AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0200, TestSize.Le * @tc.name: RunAsSetHighContrastTextState * @tc.desc: Test whether RunAsSetHighContrastTextState is called normally.(value is invalid) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0300 start"; @@ -1732,8 +1746,8 @@ AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0300, TestSize.Le AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetHighContrastTextState(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(cmd.resultReceiver_, "setHighContrastTextState: "+ ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + - "\n" + ACCESSIBILITY_HELP_MSG_HIGH_CONTRAST_TEXT_STATE); + EXPECT_EQ(cmd.resultReceiver_, "setHighContrastTextState: " + ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + + "\n" + ACCESSIBILITY_HELP_MSG_HIGH_CONTRAST_TEXT_STATE); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0300 end"; } @@ -1743,7 +1757,7 @@ AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0300, TestSize.Le * @tc.desc: Test whether RunAsSetHighContrastTextState is called normally. * (MakeSetCommandArgumentFromCmd = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0400 start"; @@ -1763,7 +1777,7 @@ AccessibilityAbilityShellCommand_RunAsSetHighContrastTextState_0400, TestSize.Le * @tc.name: RunAsSetInvertColorState * @tc.desc: Test whether RunAsSetInvertColorState is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0100 start"; @@ -1778,7 +1792,7 @@ AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0100, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetInvertColorState(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_INVERT_COLOR_STATE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_INVERT_COLOR_STATE_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0100 end"; } @@ -1787,7 +1801,7 @@ AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0100, TestSize.Level1) * @tc.name: RunAsSetInvertColorState * @tc.desc: Test whether RunAsSetInvertColorState is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0200 start"; @@ -1802,7 +1816,7 @@ AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0200, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetInvertColorState(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_INVERT_COLOR_STATE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_INVERT_COLOR_STATE_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0200 end"; } @@ -1811,7 +1825,7 @@ AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0200, TestSize.Level1) * @tc.name: RunAsSetInvertColorState * @tc.desc: Test whether RunAsSetInvertColorState is called normally.(value is invalid) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0300 start"; @@ -1827,7 +1841,7 @@ AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0300, TestSize.Level1) ErrCode result = cmd.RunAsSetInvertColorState(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); EXPECT_EQ(cmd.resultReceiver_, "setInvertColorState: "+ ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + - "\n" + ACCESSIBILITY_HELP_MSG_SET_INVERT_COLOR_STATE); + "\n" + ACCESSIBILITY_HELP_MSG_SET_INVERT_COLOR_STATE); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0300 end"; } @@ -1837,7 +1851,7 @@ AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0300, TestSize.Level1) * @tc.desc: Test whether RunAsSetInvertColorState is called normally. * (MakeSetCommandArgumentFromCmd = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0400 start"; @@ -1848,7 +1862,7 @@ AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0400, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetInvertColorState(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(cmd.resultReceiver_, "\n"+ACCESSIBILITY_HELP_MSG_SET_INVERT_COLOR_STATE); + EXPECT_EQ(cmd.resultReceiver_, "\n" + ACCESSIBILITY_HELP_MSG_SET_INVERT_COLOR_STATE); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0400 end"; } @@ -1857,7 +1871,7 @@ AccessibilityAbilityShellCommand_RunAsSetInvertColorState_0400, TestSize.Level1) * @tc.name: RunAsSetDaltonizationColorFilter * @tc.desc: Test whether RunAsSetDaltonizationColorFilter is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0100 start"; @@ -1872,7 +1886,7 @@ AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0100, TestSize AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetDaltonizationColorFilter(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_DALTONIZATIONZATION_COLOR_FILTER_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_DALTONIZATIONZATION_COLOR_FILTER_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0100 end"; } @@ -1881,7 +1895,7 @@ AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0100, TestSize * @tc.name: RunAsSetDaltonizationColorFilter * @tc.desc: Test whether RunAsSetDaltonizationColorFilter is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0200 start"; @@ -1896,7 +1910,7 @@ AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0200, TestSize AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetDaltonizationColorFilter(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_DALTONIZATIONZATION_COLOR_FILTER_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_DALTONIZATIONZATION_COLOR_FILTER_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0200 end"; } @@ -1905,7 +1919,7 @@ AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0200, TestSize * @tc.name: RunAsSetDaltonizationColorFilter * @tc.desc: Test whether RunAsSetDaltonizationColorFilter is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0300 start"; @@ -1920,7 +1934,7 @@ AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0300, TestSize AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetDaltonizationColorFilter(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_DALTONIZATIONZATION_COLOR_FILTER_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_DALTONIZATIONZATION_COLOR_FILTER_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0300 end"; } @@ -1929,7 +1943,7 @@ AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0300, TestSize * @tc.name: RunAsSetDaltonizationColorFilter * @tc.desc: Test whether RunAsSetDaltonizationColorFilter is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0400 start"; @@ -1944,7 +1958,7 @@ AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0400, TestSize AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetDaltonizationColorFilter(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_DALTONIZATIONZATION_COLOR_FILTER_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_DALTONIZATIONZATION_COLOR_FILTER_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0400 end"; } @@ -1953,7 +1967,7 @@ AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0400, TestSize * @tc.name: RunAsSetDaltonizationColorFilter * @tc.desc: Test whether RunAsSetDaltonizationColorFilter is called normally.(value is invalid) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0500, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0500 start"; @@ -1968,7 +1982,7 @@ AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0500, TestSize AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetDaltonizationColorFilter(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(cmd.resultReceiver_, "setDaltonizationColorFilter: "+ ACCESSIBILITY_ABILITY_SET_VALUE_INVALID); + EXPECT_EQ(cmd.resultReceiver_, "setDaltonizationColorFilter: " + ACCESSIBILITY_ABILITY_SET_VALUE_INVALID); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0500 end"; } @@ -1978,7 +1992,7 @@ AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0500, TestSize * @tc.desc: Test whether RunAsSetDaltonizationColorFilter is called normally. * (MakeSetCommandArgumentFromCmd = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0600, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0600 start"; @@ -1989,7 +2003,7 @@ AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0600, TestSize AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetDaltonizationColorFilter(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(cmd.resultReceiver_, "\n"+ACCESSIBILITY_HELP_MSG_SET_DALTONIZATION_COLOR_FILTER); + EXPECT_EQ(cmd.resultReceiver_, "\n" + ACCESSIBILITY_HELP_MSG_SET_DALTONIZATION_COLOR_FILTER); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0600 end"; } @@ -1998,7 +2012,7 @@ AccessibilityAbilityShellCommand_RunAsSetDaltonizationColorFilter_0600, TestSize * @tc.name: RunAsSetContentTimeout * @tc.desc: Test whether RunAsSetContentTimeout is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0100 start"; @@ -2013,7 +2027,7 @@ AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0100, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetContentTimeout(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_CONTENT_TIME_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_CONTENT_TIME_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0100 end"; } @@ -2022,7 +2036,7 @@ AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0100, TestSize.Level1) * @tc.name: RunAsSetContentTimeout * @tc.desc: Test whether RunAsSetContentTimeout is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0200 start"; @@ -2038,7 +2052,7 @@ AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0200, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetContentTimeout(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_CONTENT_TIME_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_CONTENT_TIME_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0200 end"; } @@ -2047,7 +2061,7 @@ AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0200, TestSize.Level1) * @tc.name: RunAsSetContentTimeout * @tc.desc: Test whether RunAsSetContentTimeout is called normally.(value is invalid) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0300 start"; @@ -2062,8 +2076,8 @@ AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0300, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetContentTimeout(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(cmd.resultReceiver_, "setContentTimeout: "+ ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + - "\n" + ACCESSIBILITY_HELP_MSG_SET_CONTENT_TIME_OUT); + EXPECT_EQ(cmd.resultReceiver_, "setContentTimeout: " + ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + + "\n" + ACCESSIBILITY_HELP_MSG_SET_CONTENT_TIME_OUT); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0300 end"; } @@ -2073,7 +2087,7 @@ AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0300, TestSize.Level1) * @tc.desc: Test whether RunAsSetContentTimeout is called normally. * (MakeSetCommandArgumentFromCmd = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0400 start"; @@ -2093,7 +2107,7 @@ AccessibilityAbilityShellCommand_RunAsSetContentTimeout_0400, TestSize.Level1) * @tc.name: RunAsSetAnimationOffState * @tc.desc: Test whether RunAsSetAnimationOffState is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0100 start"; @@ -2108,7 +2122,7 @@ AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0100, TestSize.Level1 AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetAnimationOffState(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_ANIMATION_OFF_STATE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_ANIMATION_OFF_STATE_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0100 end"; } @@ -2117,7 +2131,7 @@ AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0100, TestSize.Level1 * @tc.name: RunAsSetAnimationOffState * @tc.desc: Test whether RunAsSetAnimationOffState is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0200 start"; @@ -2132,7 +2146,7 @@ AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0200, TestSize.Level1 AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetAnimationOffState(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_ANIMATION_OFF_STATE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_ANIMATION_OFF_STATE_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0200 end"; } @@ -2141,7 +2155,7 @@ AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0200, TestSize.Level1 * @tc.name: RunAsSetAnimationOffState * @tc.desc: Test whether RunAsSetAnimationOffState is called normally.(value is invalid) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0300 start"; @@ -2156,8 +2170,8 @@ AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0300, TestSize.Level1 AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetAnimationOffState(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(cmd.resultReceiver_, "setAnimationOffState: "+ ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + - "\n" + ACCESSIBILITY_HELP_MSG_ANIMATION_OFF_STATE); + EXPECT_EQ(cmd.resultReceiver_, "setAnimationOffState: " + ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + + "\n" + ACCESSIBILITY_HELP_MSG_ANIMATION_OFF_STATE); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0300 end"; } @@ -2167,7 +2181,7 @@ AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0300, TestSize.Level1 * @tc.desc: Test whether RunAsSetAnimationOffState is called normally. * (MakeSetCommandArgumentFromCmd = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0400 start"; @@ -2188,7 +2202,7 @@ AccessibilityAbilityShellCommand_RunAsSetAnimationOffState_0400, TestSize.Level1 * @tc.desc: 1.Test whether RunAsSetBrightnessDiscount is called normally.(OHOS::ERR_OK) * 2.ret is not Accessibility::RET_OK */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetBrightnessDiscount_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetBrightnessDiscount_0100 start"; @@ -2215,7 +2229,7 @@ AccessibilityAbilityShellCommand_RunAsSetBrightnessDiscount_0100, TestSize.Level * @tc.desc: 1.Test whether RunAsSetBrightnessDiscount is called normally.(OHOS::ERR_OK) * 2.ret is Accessibility::RET_OK */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetBrightnessDiscount_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetBrightnessDiscount_0200 start"; @@ -2240,7 +2254,7 @@ AccessibilityAbilityShellCommand_RunAsSetBrightnessDiscount_0200, TestSize.Level * @tc.name: RunAsSetBrightnessDiscount * @tc.desc: Test whether RunAsSetBrightnessDiscount is called normally.(value is invalid) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetBrightnessDiscount_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetBrightnessDiscount_0300 start"; @@ -2255,8 +2269,8 @@ AccessibilityAbilityShellCommand_RunAsSetBrightnessDiscount_0300, TestSize.Level AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetBrightnessDiscount(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(cmd.resultReceiver_, "setSetBrightnessDiscount: "+ ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + - "\n" + ACCESSIBILITY_HELP_MSG_SET_BRIGHTNESS_DISCOUNT); + EXPECT_EQ(cmd.resultReceiver_, "setSetBrightnessDiscount: " + ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + + "\n" + ACCESSIBILITY_HELP_MSG_SET_BRIGHTNESS_DISCOUNT); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetBrightnessDiscount_0300 end"; } @@ -2266,7 +2280,7 @@ AccessibilityAbilityShellCommand_RunAsSetBrightnessDiscount_0300, TestSize.Level * @tc.desc: Test whether RunAsSetBrightnessDiscount is called normally. * (MakeSetCommandArgumentFromCmd = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetBrightnessDiscount_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetBrightnessDiscount_0400 start"; @@ -2286,7 +2300,7 @@ AccessibilityAbilityShellCommand_RunAsSetBrightnessDiscount_0400, TestSize.Level * @tc.name: RunAsSetAudioMonoState * @tc.desc: Test whether RunAsSetAudioMonoState is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0100 start"; @@ -2301,7 +2315,7 @@ AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0100, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetAudioMonoState(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_AUDIO_MONO_STATE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_AUDIO_MONO_STATE_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0100 end"; } @@ -2310,7 +2324,7 @@ AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0100, TestSize.Level1) * @tc.name: RunAsSetAudioMonoState * @tc.desc: Test whether RunAsSetAudioMonoState is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0200 start"; @@ -2325,7 +2339,7 @@ AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0200, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetAudioMonoState(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_AUDIO_MONO_STATE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_AUDIO_MONO_STATE_NG + "\n"); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0200 end"; } @@ -2334,7 +2348,7 @@ AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0200, TestSize.Level1) * @tc.name: RunAsSetAudioMonoState * @tc.desc: Test whether RunAsSetAudioMonoState is called normally.(value is invalid) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0300 start"; @@ -2349,8 +2363,8 @@ AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0300, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetAudioMonoState(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(cmd.resultReceiver_, "setAudioMonoState: "+ ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + - "\n" + ACCESSIBILITY_HELP_MSG_SET_AUDIO_MONO_STATE); + EXPECT_EQ(cmd.resultReceiver_, "setAudioMonoState: " + ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + + "\n" + ACCESSIBILITY_HELP_MSG_SET_AUDIO_MONO_STATE); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0300 end"; } @@ -2360,7 +2374,7 @@ AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0300, TestSize.Level1) * @tc.desc: Test whether RunAsSetAudioMonoState is called normally. * (MakeSetCommandArgumentFromCmd = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0400 start"; @@ -2380,7 +2394,7 @@ AccessibilityAbilityShellCommand_RunAsSetAudioMonoState_0400, TestSize.Level1) * @tc.name: RunAsSetAudioBalance * @tc.desc: Test whether RunAsSetAudioBalance is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0100 start"; @@ -2395,7 +2409,7 @@ AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0100, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetAudioBalance(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_AUDIO_BALANCE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_AUDIO_BALANCE_NG); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0100 end"; } @@ -2404,7 +2418,7 @@ AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0100, TestSize.Level1) * @tc.name: RunAsSetAudioBalance * @tc.desc: Test whether RunAsSetAudioBalance is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0200 start"; @@ -2419,7 +2433,7 @@ AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0200, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetAudioBalance(); EXPECT_EQ(result, OHOS::ERR_OK); - EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_AUDIO_BALANCE_OK + "\n"); + EXPECT_EQ(cmd.resultReceiver_, ACCESSIBILITY_SET_AUDIO_BALANCE_NG); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0200 end"; } @@ -2428,7 +2442,7 @@ AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0200, TestSize.Level1) * @tc.name: RunAsSetAudioBalance * @tc.desc: Test whether RunAsSetAudioBalance is called normally.(value is invalid) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0300 start"; @@ -2443,8 +2457,8 @@ AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0300, TestSize.Level1) AccessibilityAbilityShellCommand cmd(argc, argv); ErrCode result = cmd.RunAsSetAudioBalance(); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(cmd.resultReceiver_, "setAudioBalance: "+ ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + - "\n" + ACCESSIBILITY_HELP_MSG_SET_AUDIO_BALANCE); + EXPECT_EQ(cmd.resultReceiver_, "setAudioBalance: " + ACCESSIBILITY_ABILITY_SET_VALUE_INVALID + + "\n" + ACCESSIBILITY_HELP_MSG_SET_AUDIO_BALANCE); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0300 end"; } @@ -2454,7 +2468,7 @@ AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0300, TestSize.Level1) * @tc.desc: Test whether RunAsSetAudioBalance is called normally. * (MakeSetCommandArgumentFromCmd = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0400 start"; @@ -2475,7 +2489,7 @@ AccessibilityAbilityShellCommand_RunAsSetAudioBalance_0400, TestSize.Level1) * @tc.desc: Test whether MakeSetShortKeyTargetCommandArgumentFromCmd is called normally. * (MakeCommandArgumentFromCmd = OHOS::ERR_OK,MakeCommandArgumentFromCmd = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeSetShortKeyTargetCommandArgumentFromCmd_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeSetShortKeyTargetCommandArgumentFromCmd_0100 start"; @@ -2504,7 +2518,7 @@ AccessibilityAbilityShellCommand_MakeSetShortKeyTargetCommandArgumentFromCmd_010 * @tc.name: MakeSetCommandArgumentFromCmd * @tc.desc: Test whether MakeSetCommandArgumentFromCmd is called normally.(OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeSetCommandArgumentFromCmd_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeSetCommandArgumentFromCmd_0100 start"; @@ -2530,7 +2544,7 @@ AccessibilityAbilityShellCommand_MakeSetCommandArgumentFromCmd_0100, TestSize.Le * @tc.name: MakeSetCommandArgumentFromCmd * @tc.desc: Test whether MakeSetCommandArgumentFromCmd is called normally.(optind < 0) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeSetCommandArgumentFromCmd_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeSetCommandArgumentFromCmd_0200 start"; @@ -2551,7 +2565,7 @@ AccessibilityAbilityShellCommand_MakeSetCommandArgumentFromCmd_0200, TestSize.Le * @tc.name: MakeSetCommandArgumentFromCmd * @tc.desc: Test whether MakeSetCommandArgumentFromCmd is called normally.(option = -1) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeSetCommandArgumentFromCmd_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeSetCommandArgumentFromCmd_0300 start"; @@ -2573,7 +2587,7 @@ AccessibilityAbilityShellCommand_MakeSetCommandArgumentFromCmd_0300, TestSize.Le * @tc.name: MakeSetCommandArgumentFromCmd * @tc.desc: Test whether MakeSetCommandArgumentFromCmd is called normally.(option = ?) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeSetCommandArgumentFromCmd_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeSetCommandArgumentFromCmd_0400 start"; @@ -2597,7 +2611,7 @@ AccessibilityAbilityShellCommand_MakeSetCommandArgumentFromCmd_0400, TestSize.Le * @tc.name: MakeSetCommandArgumentFromCmd * @tc.desc: Test whether MakeSetCommandArgumentFromCmd is called normally.(option = default) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeSetCommandArgumentFromCmd_0500, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeSetCommandArgumentFromCmd_0500 start"; @@ -2621,7 +2635,7 @@ AccessibilityAbilityShellCommand_MakeSetCommandArgumentFromCmd_0500, TestSize.Le * @tc.name: MakeCommandArgumentFromCmd * @tc.desc: Test whether MakeCommandArgumentFromCmd is called normally.(return OHOS::ERR_OK) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0100 start"; @@ -2648,7 +2662,7 @@ AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0100, TestSize.Level * @tc.name: MakeCommandArgumentFromCmd * @tc.desc: Test whether MakeCommandArgumentFromCmd is called normally.(return OHOS::ERR_OK,option a b) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0200 start"; @@ -2676,7 +2690,7 @@ AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0200, TestSize.Level * @tc.name: MakeCommandArgumentFromCmd * @tc.desc: Test whether MakeCommandArgumentFromCmd is called normally.(missing options) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0300 start"; @@ -2699,7 +2713,7 @@ AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0300, TestSize.Level * @tc.name: MakeCommandArgumentFromCmd * @tc.desc: Test whether MakeCommandArgumentFromCmd is called normally.(NO_ABILITY) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0400 start"; @@ -2723,7 +2737,7 @@ AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0400, TestSize.Level * @tc.name: MakeCommandArgumentFromCmd * @tc.desc: Test whether MakeCommandArgumentFromCmd is called normally.(NO_BUNDLE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0500, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0500 start"; @@ -2749,7 +2763,7 @@ AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0500, TestSize.Level * @tc.name: MakeCommandArgumentFromCmd * @tc.desc: Test whether MakeCommandArgumentFromCmd is called normally.(optind = -1) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0600, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0600 start"; @@ -2771,7 +2785,7 @@ AccessibilityAbilityShellCommand_MakeCommandArgumentFromCmd_0600, TestSize.Level * @tc.desc: Test whether MakeDisableCommandArgumentFromCmd is called normally. * (MakeCommandArgumentFromCmd = OHOS::ERR_OK,CheckDisableCommandArgument = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_MakeDisableCommandArgumentFromCmd_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_MakeDisableCommandArgumentFromCmd_0100 start"; @@ -2804,7 +2818,7 @@ AccessibilityAbilityShellCommand_MakeDisableCommandArgumentFromCmd_0100, TestSiz * @tc.desc: Test whether CheckDisableCommandArgument is called normally. * (CheckCommandArgument = OHOS::ERR_INVALID_VALUE) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckDisableCommandArgument_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckDisableCommandArgument_0100 start"; @@ -2832,7 +2846,7 @@ AccessibilityAbilityShellCommand_CheckDisableCommandArgument_0100, TestSize.Leve * @tc.name: CheckCommandArgument * @tc.desc: Test whether CheckCommandArgument is called normally.(totalArgumentNum > 2) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckCommandArgument_0100, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckCommandArgument_0100 start"; @@ -2861,7 +2875,7 @@ AccessibilityAbilityShellCommand_CheckCommandArgument_0100, TestSize.Level1) * @tc.name: CheckCommandArgument * @tc.desc: Test whether CheckCommandArgument is called normally.(unknownArgumentNum > 0) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckCommandArgument_0200, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckCommandArgument_0200 start"; @@ -2889,7 +2903,7 @@ AccessibilityAbilityShellCommand_CheckCommandArgument_0200, TestSize.Level1) * @tc.name: CheckCommandArgument * @tc.desc: Test whether CheckCommandArgument is called normally.(CheckAbilityArgument = false) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckCommandArgument_0300, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckCommandArgument_0300 start"; @@ -2906,7 +2920,7 @@ AccessibilityAbilityShellCommand_CheckCommandArgument_0300, TestSize.Level1) }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - ErrCode result = cmd.CheckCommandArgument(argument,resultMessage); + ErrCode result = cmd.CheckCommandArgument(argument, resultMessage); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); EXPECT_EQ(resultMessage, ": " + ACCESSIBILITY_ABILITY_NO_ABILITY_ARGUMENT); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckCommandArgument_0300 end"; @@ -2917,7 +2931,7 @@ AccessibilityAbilityShellCommand_CheckCommandArgument_0300, TestSize.Level1) * @tc.name: CheckCommandArgument * @tc.desc: Test whether CheckCommandArgument is called normally.(CheckBundleArgument = false) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckCommandArgument_0400, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckCommandArgument_0400 start"; @@ -2934,7 +2948,7 @@ AccessibilityAbilityShellCommand_CheckCommandArgument_0400, TestSize.Level1) }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - ErrCode result = cmd.CheckCommandArgument(argument,resultMessage); + ErrCode result = cmd.CheckCommandArgument(argument, resultMessage); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); EXPECT_EQ(resultMessage, ": " + ACCESSIBILITY_ABILITY_NO_BUNDLE_ARGUMENT); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckCommandArgument_0400 end"; @@ -2945,7 +2959,7 @@ AccessibilityAbilityShellCommand_CheckCommandArgument_0400, TestSize.Level1) * @tc.name: CheckCommandArgument * @tc.desc: Test whether CheckCommandArgument is called normally.(CheckParamValidity = false) */ -HWTEST_F(AccessibilityAbilityShellCommandTest, +HWTEST_F(AccessibilityAbilityShellCommandTest, AccessibilityAbilityShellCommand_CheckCommandArgument_0500, TestSize.Level1) { GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckCommandArgument_0500 start"; @@ -2962,10 +2976,10 @@ AccessibilityAbilityShellCommand_CheckCommandArgument_0500, TestSize.Level1) }; int argc = sizeof(argv) / sizeof(argv[0]) - 1; AccessibilityAbilityShellCommand cmd(argc, argv); - ErrCode result = cmd.CheckCommandArgument(argument,resultMessage); + ErrCode result = cmd.CheckCommandArgument(argument, resultMessage); EXPECT_EQ(result, OHOS::ERR_INVALID_VALUE); - EXPECT_EQ(resultMessage, ": the auxiliary application " + - argument.bundleName + "/" + argument.abilityName + ACCESSIBILITY_ABILITY_NOT_FOUND); + EXPECT_EQ(resultMessage, ": the auxiliary application " + argument.bundleName + "/" + + argument.abilityName + ACCESSIBILITY_ABILITY_NOT_FOUND); GTEST_LOG_(INFO) << "AccessibilityAbilityShellCommand_CheckCommandArgument_0500 end"; } } // namespace AAFwk diff --git a/utils/global/constant/global_constant.h b/utils/global/constant/global_constant.h index ede0a1f21f..7ef355315b 100644 --- a/utils/global/constant/global_constant.h +++ b/utils/global/constant/global_constant.h @@ -18,7 +18,7 @@ namespace OHOS::AbilityRuntime { namespace GlobalConstant { -constexpr int32_t MAX_APP_TWIN_INDEX = 1000; +constexpr int32_t MAX_APP_CLONE_INDEX = 1000; } // namespace GlobalConstant } // namespace OHOS::AbilityRuntime #endif // OHOS_ABILITY_RUNTIME_GLOBAL_CONSTANT_H \ No newline at end of file diff --git a/utils/server/constant/server_constant.h b/utils/server/constant/server_constant.h index 0062c54221..7145c5e70c 100644 --- a/utils/server/constant/server_constant.h +++ b/utils/server/constant/server_constant.h @@ -18,7 +18,7 @@ namespace OHOS::AbilityRuntime { namespace ServerConstant { -constexpr const char* APP_TWIN_INDEX = "ohos.extra.param.key.appTwinIndex"; +constexpr const char* APP_CLONE_INDEX = "ohos.extra.param.key.appCloneIndex"; constexpr const char* DLP_INDEX = "ohos.dlp.params.index"; } // namespace ServerConstant } // namespace OHOS::AbilityRuntime diff --git a/utils/server/startup/include/startup_util.h b/utils/server/startup/include/startup_util.h index 34b76ced86..11eb21ed33 100644 --- a/utils/server/startup/include/startup_util.h +++ b/utils/server/startup/include/startup_util.h @@ -25,7 +25,7 @@ class Want; namespace AbilityRuntime { class StartupUtil { public: - static int32_t GetAppTwinIndex(const AAFwk::Want &want); + static int32_t GetAppIndex(const AAFwk::Want &want); static int32_t BuildAbilityInfoFlag(); }; } // namespace AbilityRuntime diff --git a/utils/server/startup/src/startup_util.cpp b/utils/server/startup/src/startup_util.cpp index 7ed79257ac..f9755629d9 100644 --- a/utils/server/startup/src/startup_util.cpp +++ b/utils/server/startup/src/startup_util.cpp @@ -20,13 +20,13 @@ #include "want.h" namespace OHOS::AbilityRuntime { -int32_t StartupUtil::GetAppTwinIndex(const AAFwk::Want &want) +int32_t StartupUtil::GetAppIndex(const AAFwk::Want &want) { - int32_t appTwinIndex = want.GetIntParam(ServerConstant::APP_TWIN_INDEX, 0); - if (appTwinIndex == 0) { - appTwinIndex = want.GetIntParam(ServerConstant::DLP_INDEX, 0); + int32_t appIndex = want.GetIntParam(ServerConstant::APP_CLONE_INDEX, 0); + if (appIndex == 0) { + appIndex = want.GetIntParam(ServerConstant::DLP_INDEX, 0); } - return appTwinIndex; + return appIndex; } int32_t StartupUtil::BuildAbilityInfoFlag()