mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 12:43:16 -04:00
Comment: 部件化治理支持独立编译
This commit is contained in:
+7
-12
@@ -64,16 +64,21 @@
|
||||
"hitrace",
|
||||
"hiview",
|
||||
"i18n",
|
||||
"icu",
|
||||
"image_framework",
|
||||
"init",
|
||||
"input",
|
||||
"ipc",
|
||||
"json",
|
||||
"jsoncpp",
|
||||
"kv_store",
|
||||
"libuv",
|
||||
"memmgr",
|
||||
"memmgr_override",
|
||||
"memory_utils",
|
||||
"napi",
|
||||
"netmanager_base",
|
||||
"node",
|
||||
"os_account",
|
||||
"relational_store",
|
||||
"resource_management",
|
||||
@@ -84,20 +89,10 @@
|
||||
"toolchain",
|
||||
"webview",
|
||||
"window_manager",
|
||||
"icu",
|
||||
"jsoncpp",
|
||||
"libuv",
|
||||
"zlib",
|
||||
"node"
|
||||
"zlib"
|
||||
],
|
||||
"third_party": [
|
||||
"icu",
|
||||
"json",
|
||||
"jsoncpp",
|
||||
"libjpeg-turbo",
|
||||
"libuv",
|
||||
"node",
|
||||
"zlib"
|
||||
"libjpeg-turbo"
|
||||
]
|
||||
},
|
||||
"build": {
|
||||
|
||||
@@ -43,6 +43,8 @@ group("napi_packages") {
|
||||
"${ability_runtime_napi_path}/app/js_app_manager:appmanager",
|
||||
"${ability_runtime_napi_path}/app/recovery:apprecovery_napi",
|
||||
"${ability_runtime_napi_path}/app/test_runner:testrunner_napi",
|
||||
"${ability_runtime_napi_path}/app_startup/async_task_callback:asynctaskcallback_napi",
|
||||
"${ability_runtime_napi_path}/app_startup/async_task_excutor:asynctaskexcutor_napi",
|
||||
"${ability_runtime_napi_path}/app_startup/startup_config_entry:startupconfigentry_napi",
|
||||
"${ability_runtime_napi_path}/app_startup/startup_listener:startuplistener_napi",
|
||||
"${ability_runtime_napi_path}/app_startup/startup_manager:startupmanager_napi",
|
||||
|
||||
@@ -124,6 +124,11 @@ public:
|
||||
GET_NAPI_INFO_AND_CALL(env, info, JsAbilityManager, OnIsEmbeddedOpenAllowed);
|
||||
}
|
||||
|
||||
static napi_value SetResidentProcessEnabled(napi_env env, napi_callback_info info)
|
||||
{
|
||||
GET_CB_INFO_AND_CALL(env, info, JsAbilityManager, OnSetResidentProcessEnabled);
|
||||
}
|
||||
|
||||
static napi_value NotifyDebugAssertResult(napi_env env, napi_callback_info info)
|
||||
{
|
||||
GET_CB_INFO_AND_CALL(env, info, JsAbilityManager, OnNotifyDebugAssertResult);
|
||||
@@ -152,15 +157,15 @@ private:
|
||||
}
|
||||
if (!AppExecFwk::IsTypeForNapiValue(env, argv[INDEX_ONE], napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Invalid param.");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param observer failed, must be a AbilityForegroundStateObserver");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
std::string type = ParseParamType(env, argc, argv);
|
||||
if (type == ON_OFF_TYPE_ABILITY_FOREGROUND_STATE) {
|
||||
OnOnAbilityForeground(env, argc, argv);
|
||||
return OnOnAbilityForeground(env, argc, argv);
|
||||
}
|
||||
|
||||
ThrowInvalidParamError(env, "Parse param type failed, must be a string, value must be abilityForegroundState");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -198,14 +203,15 @@ private:
|
||||
}
|
||||
if (argc == ARGC_TWO && !AppExecFwk::IsTypeForNapiValue(env, argv[INDEX_ONE], napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Invalid param.");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param observer failed, must be a AbilityForegroundStateObserver");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
std::string type = ParseParamType(env, argc, argv);
|
||||
if (type == ON_OFF_TYPE_ABILITY_FOREGROUND_STATE) {
|
||||
OnOffAbilityForeground(env, argc, argv);
|
||||
return OnOffAbilityForeground(env, argc, argv);
|
||||
}
|
||||
ThrowInvalidParamError(env, "Parse param type failed, must be a string, value must be abilityForegroundState");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -237,19 +243,19 @@ private:
|
||||
std::string assertSessionStr;
|
||||
if (!ConvertFromJsValue(env, argv[INDEX_ZERO], assertSessionStr) || !CheckIsNumString(assertSessionStr)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Convert session id error.");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param sessionId failed, must be a string");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
uint64_t assertSessionId = std::stoull(assertSessionStr);
|
||||
if (assertSessionId == 0) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Convert session id failed.");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param sessionId failed, value must not be equal to zero");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
int32_t userStatus;
|
||||
if (!ConvertFromJsValue(env, argv[INDEX_ONE], userStatus)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Convert status failed.");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param status failed, must be a UserStatus");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -340,7 +346,7 @@ private:
|
||||
int upperLimit = -1;
|
||||
if (!ConvertFromJsValue(env, info.argv[0], upperLimit)) {
|
||||
#ifdef ENABLE_ERRCODE
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param upperLimit failed, must be a number");
|
||||
#endif
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
@@ -391,7 +397,7 @@ private:
|
||||
AppExecFwk::Configuration changeConfig;
|
||||
if (!UnwrapConfiguration(env, info.argv[0], changeConfig)) {
|
||||
#ifdef ENABLE_ERRCODE
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param config failed, must be a Configuration");
|
||||
#else
|
||||
complete = [](napi_env env, NapiAsyncTask& task, int32_t status) {
|
||||
task.Reject(env, CreateJsError(env, ERR_INVALID_VALUE, "config is invalid."));
|
||||
@@ -456,12 +462,12 @@ private:
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "%{public}s is called", __FUNCTION__);
|
||||
if (info.argc < ARGC_ONE) {
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
int32_t missionId = -1;
|
||||
if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], missionId)) {
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param missionId failed, must be a number");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
napi_value lastParam = info.argc > ARGC_ONE ? info.argv[INDEX_ONE] : nullptr;
|
||||
@@ -509,7 +515,7 @@ private:
|
||||
int reqCode = 0;
|
||||
if (!ConvertFromJsValue(env, info.argv[1], reqCode)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Get requestCode param error");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param requestCode failed, must be a number");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -517,7 +523,7 @@ private:
|
||||
int resultCode = ERR_OK;
|
||||
if (!AppExecFwk::UnWrapAbilityResult(env, info.argv[0], resultCode, want)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Unrwrap abilityResult param error");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param parameter failed, must be a AbilityResult");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -563,6 +569,58 @@ private:
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value OnSetResidentProcessEnabled(napi_env env, size_t argc, napi_value *argv)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "Called.");
|
||||
if (argc < ARGC_TWO) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Not enough params when off.");
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
std::string bundleName;
|
||||
if (!ConvertFromJsValue(env, argv[INDEX_ZERO], bundleName) || bundleName.empty()) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Convert session id error.");
|
||||
auto errMsg = "Non empty package name needs to be provided";
|
||||
ThrowError(env, static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INVALID_PARAM), errMsg);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
bool enableState = false;
|
||||
if (!ConvertFromJsValue(env, argv[INDEX_ONE], enableState)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Convert status failed.");
|
||||
auto errMsg = "The second parameter needs to provide a Boolean type setting value";
|
||||
ThrowError(env, static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INVALID_PARAM), errMsg);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
auto innerErrorCode = std::make_shared<int32_t>(ERR_OK);
|
||||
NapiAsyncTask::ExecuteCallback execute = [bundleName, enableState, innerErrorCode, env]() {
|
||||
auto amsClient = AbilityManagerClient::GetInstance();
|
||||
if (amsClient == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Ability manager service instance is nullptr.");
|
||||
*innerErrorCode = static_cast<int32_t>(AAFwk::INNER_ERR);
|
||||
return;
|
||||
}
|
||||
*innerErrorCode = amsClient->SetResidentProcessEnabled(bundleName, enableState);
|
||||
};
|
||||
|
||||
NapiAsyncTask::CompleteCallback complete = [innerErrorCode](napi_env env, NapiAsyncTask &task, int32_t status) {
|
||||
if (*innerErrorCode != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Set resident process result failed, error is %{public}d.",
|
||||
*innerErrorCode);
|
||||
task.Reject(env, CreateJsErrorByNativeErr(env, *innerErrorCode));
|
||||
return;
|
||||
}
|
||||
task.ResolveWithNoError(env, CreateJsUndefined(env));
|
||||
};
|
||||
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::Schedule("JsAbilityManager::OnSetResidentProcessEnabled", env,
|
||||
CreateAsyncTaskWithLastParam(env, nullptr, std::move(execute), std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value OnIsEmbeddedOpenAllowed(napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "Called.");
|
||||
@@ -576,26 +634,26 @@ private:
|
||||
napi_status status = OHOS::AbilityRuntime::IsStageContext(env, info.argv[0], stageMode);
|
||||
if (status != napi_ok || !stageMode) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "it is not a stage mode");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param context failed, must be stageMode");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
auto context = OHOS::AbilityRuntime::GetStageModeContext(env, info.argv[0]);
|
||||
if (context == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "get context failed");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param context failed, must not be nullptr");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
auto uiAbilityContext = AbilityRuntime::Context::ConvertTo<AbilityRuntime::AbilityContext>(context);
|
||||
if (uiAbilityContext == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "convert to UIAbility context failed");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param context failed, must be UIAbilityContext");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
std::string appId;
|
||||
if (!ConvertFromJsValue(env, info.argv[1], appId)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "OnOpenAtomicService, parse appId failed.");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param appId failed, must be a string");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -644,6 +702,8 @@ napi_value JsAbilityManagerInit(napi_env env, napi_value exportObj)
|
||||
BindNativeFunction(
|
||||
env, exportObj, "notifyDebugAssertResult", moduleName, JsAbilityManager::NotifyDebugAssertResult);
|
||||
BindNativeFunction(env, exportObj, "isEmbeddedOpenAllowed", moduleName, JsAbilityManager::IsEmbeddedOpenAllowed);
|
||||
BindNativeFunction(
|
||||
env, exportObj, "setResidentProcessEnabled", moduleName, JsAbilityManager::SetResidentProcessEnabled);
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "end");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ private:
|
||||
|
||||
std::string type;
|
||||
if (!ConvertFromJsValue(env, argv[INDEX_ZERO], type) || type != ON_OFF_TYPE) {
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parameter error: Parse type failed, must be a string error.");
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "Parse type failed");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
@@ -297,7 +297,7 @@ private:
|
||||
|
||||
if (!CheckTypeForNapiValue(env, argv[INDEX_ONE], napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "Invalid param");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parameter error: Parse ovserver failed, must be a ErrorObserver.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -363,7 +363,7 @@ private:
|
||||
std::string type;
|
||||
if (!ConvertFromJsValue(env, argv[INDEX_ZERO], type) || type != ON_OFF_TYPE) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "Parse type failed");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parameter error: Parse type failed, must be a string error.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -434,7 +434,7 @@ private:
|
||||
int32_t observerId = -1;
|
||||
if (!ConvertFromJsValue(env, argv[INDEX_ONE], observerId)) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "Parse observerId failed");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parameter error: Parse observerId failed, must be a number.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
if (observer_ == nullptr) {
|
||||
@@ -511,23 +511,23 @@ private:
|
||||
}
|
||||
if (!CheckTypeForNapiValue(env, argv[INDEX_ONE], napi_number)) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "OnSetLoopWatch: Invalid param");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parameter error: Failed to parse timeout, must be a number.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
if (!CheckTypeForNapiValue(env, argv[INDEX_TWO], napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "OnSetLoopWatch: Invalid param");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parameter error: Failed to parse observer, must be a LoopObserver.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
int64_t number;
|
||||
if (!ConvertFromJsNumber(env, argv[INDEX_ONE], number)) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "OnSetLoopWatch: Parse timeout failed");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parameter error: Failed to parse timeout, must be a number.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
if (number <= 0) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "The timeout cannot be less than 0");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parameter error: The timeout cannot be less than 0.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "ability_manager_interface.h"
|
||||
#include "ability_runtime_error_util.h"
|
||||
#include "app_mgr_interface.h"
|
||||
#include "application_info.h"
|
||||
#include "event_runner.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
@@ -99,6 +100,11 @@ public:
|
||||
GET_CB_INFO_AND_CALL(env, info, JsAppManager, OnGetRunningProcessInformation);
|
||||
}
|
||||
|
||||
static napi_value GetRunningProcessInformationByBundleType(napi_env env, napi_callback_info info)
|
||||
{
|
||||
GET_CB_INFO_AND_CALL(env, info, JsAppManager, OnGetRunningProcessInformationByBundleType);
|
||||
}
|
||||
|
||||
static napi_value IsRunningInStabilityTest(napi_env env, napi_callback_info info)
|
||||
{
|
||||
GET_CB_INFO_AND_CALL(env, info, JsAppManager, OnIsRunningInStabilityTest);
|
||||
@@ -233,7 +239,8 @@ private:
|
||||
}
|
||||
|
||||
if (!CheckOnOffType(env, argc, argv)) {
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param type failed, must be a string,"
|
||||
"value must be applicationState, appForegroundState or abilityFirstFrameState");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -279,7 +286,7 @@ private:
|
||||
}
|
||||
if (!AppExecFwk::IsTypeForNapiValue(env, argv[INDEX_ONE], napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Invalid param");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param observer failed, must be a ApplicationStateObserver");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
std::vector<std::string> bundleNameList;
|
||||
@@ -322,7 +329,7 @@ private:
|
||||
}
|
||||
if (!AppExecFwk::IsTypeForNapiValue(env, argv[INDEX_ONE], napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Invalid param.");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param observer failed, must be a AppForegroundStateObserver");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
if (observerForeground_ == nullptr) {
|
||||
@@ -385,7 +392,7 @@ private:
|
||||
if (!AppExecFwk::IsTypeForNapiValue(env, argv[INDEX_ONE], napi_object) ||
|
||||
!IsJSFunctionExist(env, argv[INDEX_ONE], "onAbilityFirstFrameDrawn")) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Invalid param.");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param observer failed, must be a AbilityFirstFrameStateObserver");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
std::string bundleName;
|
||||
@@ -393,7 +400,7 @@ private:
|
||||
if (!IsParasNullOrUndefined(env, argv[INDEX_TWO]) &&
|
||||
(!ConvertFromJsValue(env, argv[INDEX_TWO], bundleName) || bundleName.empty())) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Get bundleName error or bundleName empty!");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
}
|
||||
@@ -439,7 +446,7 @@ private:
|
||||
(!AppExecFwk::IsTypeForNapiValue(env, argv[INDEX_ONE], napi_object) ||
|
||||
!IsJSFunctionExist(env, argv[INDEX_ONE], "onAbilityFirstFrameDrawn"))) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Invalid param.");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param observer failed, must be a AbilityFirstFrameStateObserver");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
}
|
||||
@@ -463,20 +470,21 @@ private:
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
if (!CheckOnOffType(env, argc, argv)) {
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param type failed, must be a string,"
|
||||
"value must be applicationState, appForegroundState or abilityFirstFrameState");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
int64_t observerId = -1;
|
||||
napi_get_value_int64(env, argv[INDEX_ONE], &observerId);
|
||||
if (observer_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "observer_ is nullpter, please register first");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "observer_ is nullptr, please register first");
|
||||
ThrowInvalidParamError(env, "observer is nullptr, please register first");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
if (!observer_->FindObserverByObserverId(observerId)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "not find observer, observer:%{public}d", static_cast<int32_t>(observerId));
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "not find observerId");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "find observer exist observer:%{public}d", static_cast<int32_t>(observerId));
|
||||
@@ -518,7 +526,7 @@ private:
|
||||
int32_t observerId = -1;
|
||||
if (!ConvertFromJsValue(env, argv[INDEX_ONE], observerId)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Parse observerId failed");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param observerId failed, must be a number");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -529,7 +537,7 @@ private:
|
||||
}
|
||||
if (!observerSync_->FindObserverByObserverId(observerId)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "not find observer, observer:%{public}d", static_cast<int32_t>(observerId));
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "not find observerId");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
int32_t ret = appManager_->UnregisterApplicationStateObserver(observerSync_);
|
||||
@@ -553,7 +561,7 @@ private:
|
||||
}
|
||||
if (argc == ARGC_TWO && !AppExecFwk::IsTypeForNapiValue(env, argv[INDEX_ONE], napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Invalid param.");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param observer failed, must be a AppForegroundStateObserver");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
if (observerForeground_ == nullptr || appManager_ == nullptr) {
|
||||
@@ -632,6 +640,49 @@ private:
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value OnGetRunningProcessInformationByBundleType(napi_env env, size_t argc, napi_value* argv)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "called");
|
||||
if (argc < ARGC_ONE) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Not enough params.");
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
int32_t bundleType = -1;
|
||||
if (!ConvertFromJsValue(env, argv[INDEX_ZERO], bundleType)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "get bundleType error!");
|
||||
ThrowInvalidParamError(env, "failed to get bundleType");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
if (bundleType < 0) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Invalid bundle type:%{public}d", bundleType);
|
||||
ThrowInvalidParamError(env, "invalid bundle type");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
NapiAsyncTask::CompleteCallback complete =
|
||||
[appManager = appManager_, bundleType](napi_env env, NapiAsyncTask &task, int32_t status) {
|
||||
if (appManager == nullptr) {
|
||||
TAG_LOGW(AAFwkTag::APPMGR, "appManager nullptr");
|
||||
task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INNER));
|
||||
return;
|
||||
}
|
||||
std::vector<AppExecFwk::RunningProcessInfo> infos;
|
||||
auto ret = appManager->GetRunningProcessesByBundleType(
|
||||
static_cast<AppExecFwk::BundleType>(bundleType), infos);
|
||||
if (ret == 0) {
|
||||
task.ResolveWithNoError(env, CreateJsRunningProcessInfoArray(env, infos));
|
||||
} else {
|
||||
task.Reject(env, CreateJsError(env, GetJsErrorCodeByNativeError(ret)));
|
||||
}
|
||||
};
|
||||
|
||||
napi_value lastParam = (argc > ARGC_ONE) ? argv[INDEX_ONE] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::Schedule("JSAppManager::OnGetRunningProcessInformationByBundleType",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value OnIsRunningInStabilityTest(napi_env env, size_t argc, napi_value* argv)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "called");
|
||||
@@ -666,7 +717,7 @@ private:
|
||||
std::string bundleName;
|
||||
if (!ConvertFromJsValue(env, argv[0], bundleName)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "get bundleName error!");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -705,7 +756,7 @@ private:
|
||||
std::string bundleName;
|
||||
if (!ConvertFromJsValue(env, argv[0], bundleName)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "get bundleName failed!");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -743,14 +794,14 @@ private:
|
||||
std::string bundleName;
|
||||
if (!ConvertFromJsValue(env, argv[0], bundleName)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "get bundleName wrong!");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
uint32_t versionCode = 0;
|
||||
if (!ConvertFromJsValue(env, argv[1], versionCode)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "get versionCode failed!");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param versionCode failed, must be a number");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -785,13 +836,13 @@ private:
|
||||
std::string bundleName;
|
||||
if (!ConvertFromJsValue(env, argv[0], bundleName)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Parse bundleName failed");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
int32_t accountId = -1;
|
||||
if (!ConvertFromJsValue(env, argv[1], accountId)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Parse userId failed");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param accountId failed, must be a number");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -871,7 +922,7 @@ private:
|
||||
int32_t pid;
|
||||
if (!ConvertFromJsValue(env, argv[0], pid)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "get pid failed");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param pid failed, must be a number");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -910,7 +961,7 @@ private:
|
||||
bool isPromiseType = false;
|
||||
if (!ConvertFromJsValue(env, argv[0], bundleName)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "First parameter must be string");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
if (argc == ARGC_ONE) {
|
||||
@@ -922,11 +973,11 @@ private:
|
||||
} else if (argc == ARGC_THREE) {
|
||||
if (!ConvertFromJsValue(env, argv[1], userId)) {
|
||||
TAG_LOGW(AAFwkTag::APPMGR, "Must input userid and use callback when argc is three.");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param userId failed, must be a number");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
} else {
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "The number of param exceeded");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -963,7 +1014,7 @@ private:
|
||||
std::string bundleName;
|
||||
if (!ConvertFromJsValue(env, argv[0], bundleName)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Get bundle name wrong.");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -1139,6 +1190,8 @@ napi_value JsAppManagerInit(napi_env env, napi_value exportObj)
|
||||
JsAppManager::IsApplicationRunning);
|
||||
BindNativeFunction(env, exportObj, "preloadApplication", moduleName,
|
||||
JsAppManager::PreloadApplication);
|
||||
BindNativeFunction(env, exportObj, "getRunningProcessInformationByBundleType", moduleName,
|
||||
JsAppManager::GetRunningProcessInformationByBundleType);
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "end");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -146,6 +146,7 @@ napi_value CreateJsRunningProcessInfo(napi_env env, const RunningProcessInfo &in
|
||||
napi_set_named_property(env, object, "bundleNames", CreateNativeArray(env, info.bundleNames));
|
||||
napi_set_named_property(env, object, "state", CreateJsValue(env,
|
||||
ConvertToJsAppProcessState(info.state_, info.isFocused)));
|
||||
napi_set_named_property(env, object, "bundleType", CreateJsValue(env, info.bundleType));
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
# Copyright (c) 2024 Huawei Device Co., Ltd.libasynctaskexcutorcallback_napi
|
||||
# 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("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni")
|
||||
import("//build/ohos.gni")
|
||||
|
||||
es2abc_gen_abc("gen_async_task_callback_abc") {
|
||||
src_js = rebase_path("async_task_callback.ts")
|
||||
dst_file = rebase_path(target_out_dir + "/async_task_callback.abc")
|
||||
in_puts = [ "async_task_callback.ts" ]
|
||||
out_puts = [ target_out_dir + "/async_task_callback.abc" ]
|
||||
extra_args = [ "--module" ]
|
||||
}
|
||||
|
||||
gen_js_obj("async_task_callback_js") {
|
||||
input = "async_task_callback.ts"
|
||||
output = target_out_dir + "/async_task_callback.o"
|
||||
}
|
||||
|
||||
gen_js_obj("async_task_callback_abc") {
|
||||
input = get_label_info(":gen_async_task_callback_abc", "target_out_dir") +
|
||||
"/async_task_callback.abc"
|
||||
output = target_out_dir + "/async_task_callback_abc.o"
|
||||
dep = ":gen_async_task_callback_abc"
|
||||
}
|
||||
|
||||
ohos_shared_library("asynctaskcallback_napi") {
|
||||
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"
|
||||
|
||||
sources = [ "async_task_callback_module.cpp" ]
|
||||
|
||||
deps = [
|
||||
":async_task_callback_abc",
|
||||
":async_task_callback_js",
|
||||
]
|
||||
|
||||
external_deps = [ "napi:ace_napi" ]
|
||||
|
||||
relative_install_dir = "module/app/appstartup"
|
||||
subsystem_name = "ability"
|
||||
part_name = "ability_runtime"
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
class AsyncTaskCallback {
|
||||
private __impl__: AsyncTaskCallback;
|
||||
constructor(object) {
|
||||
"use sendable"
|
||||
this.__impl__ = object;
|
||||
}
|
||||
|
||||
onAsyncTaskCompleted(startupName) {
|
||||
console.log('AsyncTaskCallback onAsyncTaskCompleted called, startupName: ' + startupName);
|
||||
this.__impl__.onAsyncTaskCompleted(startupName);
|
||||
}
|
||||
}
|
||||
|
||||
export default AsyncTaskCallback;
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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_engine/native_engine.h"
|
||||
|
||||
extern const char _binary_async_task_callback_abc_start[];
|
||||
extern const char _binary_async_task_callback_abc_end[];
|
||||
|
||||
static napi_module _module = {
|
||||
.nm_version = 0,
|
||||
.nm_filename = "app/appstartup/libasynctaskcallback_napi.so/async_task_callback.js",
|
||||
.nm_modname = "app.appstartup.AsyncTaskCallback",
|
||||
};
|
||||
extern "C" __attribute__((constructor))
|
||||
void NAPI_app_appstartup_AsyncTaskCallback_AutoRegister()
|
||||
{
|
||||
napi_module_register(&_module);
|
||||
}
|
||||
|
||||
extern "C" __attribute__((visibility("default")))
|
||||
void NAPI_app_appstartup_AsyncTaskCallback_GetABCCode(const char **buf, int *buflen)
|
||||
{
|
||||
if (buf != nullptr) {
|
||||
*buf = _binary_async_task_callback_abc_start;
|
||||
}
|
||||
if (buflen != nullptr) {
|
||||
*buflen = _binary_async_task_callback_abc_end - _binary_async_task_callback_abc_start;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni")
|
||||
import("//build/ohos.gni")
|
||||
|
||||
es2abc_gen_abc("gen_async_task_excutor_abc") {
|
||||
src_js = rebase_path("async_task_excutor.ts")
|
||||
dst_file = rebase_path(target_out_dir + "/async_task_excutor.abc")
|
||||
in_puts = [ "async_task_excutor.ts" ]
|
||||
out_puts = [ target_out_dir + "/async_task_excutor.abc" ]
|
||||
extra_args = [ "--module" ]
|
||||
}
|
||||
|
||||
gen_js_obj("async_task_excutor_js") {
|
||||
input = "async_task_excutor.ts"
|
||||
output = target_out_dir + "/async_task_excutor.o"
|
||||
}
|
||||
|
||||
gen_js_obj("async_task_excutor_abc") {
|
||||
input = get_label_info(":gen_async_task_excutor_abc", "target_out_dir") +
|
||||
"/async_task_excutor.abc"
|
||||
output = target_out_dir + "/async_task_excutor_abc.o"
|
||||
dep = ":gen_async_task_excutor_abc"
|
||||
}
|
||||
|
||||
ohos_shared_library("asynctaskexcutor_napi") {
|
||||
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"
|
||||
|
||||
sources = [ "async_task_excutor_module.cpp" ]
|
||||
|
||||
deps = [
|
||||
":async_task_excutor_abc",
|
||||
":async_task_excutor_js",
|
||||
]
|
||||
|
||||
external_deps = [ "napi:ace_napi" ]
|
||||
|
||||
relative_install_dir = "module/app/appstartup"
|
||||
subsystem_name = "ability"
|
||||
part_name = "ability_runtime"
|
||||
}
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
function concurrentFunc(startup, asyncCallback, context, startupName) {
|
||||
"use concurrent";
|
||||
console.log('concurrentFunc start.');
|
||||
let taskPool = requireNapi('taskpool');
|
||||
startup.init(context);
|
||||
taskPool.Task.sendData(asyncCallback, startupName);
|
||||
console.log('concurrentFunc end.');
|
||||
}
|
||||
|
||||
function receiveResult(asyncCallback, startupName) {
|
||||
console.log('receiveResult called.');
|
||||
asyncCallback.onAsyncTaskCompleted(startupName);
|
||||
}
|
||||
|
||||
function pushTask(startup, asyncCallback, context, startupName) {
|
||||
console.log('pushTask start.');
|
||||
let taskPool = requireNapi('taskpool');
|
||||
let task = new taskPool.Task(concurrentFunc, startup, asyncCallback, context, startupName);
|
||||
task.onReceiveData(receiveResult);
|
||||
taskPool.execute(task);
|
||||
console.log('pushTask end.');
|
||||
}
|
||||
|
||||
class AsyncTaskExcutor {
|
||||
public asyncPushTask(startup, asyncCallback, context, startupName) {
|
||||
console.log('asyncPushTask AsyncPushTask start.');
|
||||
pushTask(startup, asyncCallback, context, startupName);
|
||||
console.log('asyncPushTask AsyncPushTask end.');
|
||||
}
|
||||
}
|
||||
|
||||
export default AsyncTaskExcutor;
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
#include "native_engine/native_engine.h"
|
||||
|
||||
extern const char _binary_async_task_excutor_abc_start[];
|
||||
extern const char _binary_async_task_excutor_abc_end[];
|
||||
|
||||
static napi_module _module = {
|
||||
.nm_version = 0,
|
||||
.nm_filename = "app/appstartup/libasynctaskexcutor_napi.so/async_task_excutor.js",
|
||||
.nm_modname = "app.appstartup.AsyncTaskExcutor",
|
||||
};
|
||||
extern "C" __attribute__((constructor))
|
||||
void NAPI_app_appstartup_AsyncTaskExcutor_AutoRegister()
|
||||
{
|
||||
napi_module_register(&_module);
|
||||
}
|
||||
|
||||
extern "C" __attribute__((visibility("default")))
|
||||
void NAPI_app_appstartup_AsyncTaskExcutor_GetABCCode(const char **buf, int *buflen)
|
||||
{
|
||||
if (buf != nullptr) {
|
||||
*buf = _binary_async_task_excutor_abc_start;
|
||||
}
|
||||
if (buflen != nullptr) {
|
||||
*buflen = _binary_async_task_excutor_abc_end - _binary_async_task_excutor_abc_start;
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "js_startup_task_result.h"
|
||||
#include "napi/native_api.h"
|
||||
#include "startup_manager.h"
|
||||
#include "js_error_utils.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
@@ -67,7 +68,7 @@ napi_value JsStartupManager::OnRun(napi_env env, NapiCallbackInfo &info)
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "called.");
|
||||
if (info.argc < ARGC_ONE) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "the param is invalid.");
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -115,13 +116,13 @@ napi_value JsStartupManager::OnGetResult(napi_env env, NapiCallbackInfo &info)
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "called.");
|
||||
if (info.argc < ARGC_ONE) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "the param is invalid.");
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
std::string startupTask;
|
||||
if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], startupTask)) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "convert startupTask name failed.");
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowInvalidParamError(env, "Parameter error: Failed to convert startupTask, must be a string.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -129,18 +130,18 @@ napi_value JsStartupManager::OnGetResult(napi_env env, NapiCallbackInfo &info)
|
||||
int32_t res = DelayedSingleton<StartupManager>::GetInstance()->GetResult(startupTask, result);
|
||||
if (res != ERR_OK || result == nullptr || result->GetResultCode() != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "%{public}s, failed to get result.", startupTask.c_str());
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowInvalidParamError(env, "%{public}s, failed to get result.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
if (result->GetResultType() != StartupTaskResult::ResultType::JS) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "%{public}s, the result type is not js.", startupTask.c_str());
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowInvalidParamError(env, "%{public}s, the result type is not js.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
std::shared_ptr<JsStartupTaskResult> jsResult = std::static_pointer_cast<JsStartupTaskResult>(result);
|
||||
if (jsResult == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "%{public}s, failed to convert to js result.", startupTask.c_str());
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowInvalidParamError(env, "%{public}s, failed to convert to js result.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
std::shared_ptr<NativeReference> jsResultRef = jsResult->GetJsStartupResultRef();
|
||||
@@ -155,13 +156,14 @@ napi_value JsStartupManager::OnIsInitialized(napi_env env, NapiCallbackInfo &inf
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "called.");
|
||||
if (info.argc < ARGC_ONE) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "the param is invalid.");
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
std::string startupTask;
|
||||
if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], startupTask)) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "convert startupTask name failed.");
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowInvalidParamError(env, "Parameter error: Failed to convert startupTask,"
|
||||
"must be a string or startupTask name is not matched.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -169,7 +171,7 @@ napi_value JsStartupManager::OnIsInitialized(napi_env env, NapiCallbackInfo &inf
|
||||
int32_t res = DelayedSingleton<StartupManager>::GetInstance()->IsInitialized(startupTask, isInitialized);
|
||||
if (res != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "%{public}s, failed to get result, res = %{public}d.", startupTask.c_str(), res);
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowInvalidParamError(env, "%{public}s, failed to get result, res = %{public}d.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
return CreateJsValue(env, isInitialized);
|
||||
@@ -180,20 +182,21 @@ napi_value JsStartupManager::OnRemoveResult(napi_env env, NapiCallbackInfo &info
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "called.");
|
||||
if (info.argc < ARGC_ONE) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "the param is invalid.");
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
std::string startupTask;
|
||||
if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], startupTask)) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "convert startupTask name failed.");
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowInvalidParamError(env, "Parameter error: Failed to convert startupTask,"
|
||||
"must be a string or startupTask name is not matched.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
int32_t res = DelayedSingleton<StartupManager>::GetInstance()->RemoveResult(startupTask);
|
||||
if (res != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "%{public}s, failed to remove result, res = %{public}d.", startupTask.c_str(), res);
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowInvalidParamError(env, "%{public}s, failed to get result, res = %{public}d.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
return CreateJsUndefined(env);
|
||||
@@ -225,6 +228,7 @@ int32_t JsStartupManager::GetDependencies(napi_env env, napi_value value, std::v
|
||||
napi_is_array(env, value, &isArray);
|
||||
if (!isArray) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "value is not array.");
|
||||
ThrowInvalidParamError(env, "Parameter error: StartupTasks must be a Array.");
|
||||
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
@@ -239,12 +243,14 @@ int32_t JsStartupManager::GetDependencies(napi_env env, napi_value value, std::v
|
||||
napi_typeof(env, napiDep, &valueType);
|
||||
if (valueType != napi_string) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "element is not string.");
|
||||
ThrowInvalidParamError(env, "Parameter error: StartupTasks element must be a string.");
|
||||
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
std::string startupTask;
|
||||
if (!ConvertFromJsValue(env, napiDep, startupTask)) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "convert startupTask name failed.");
|
||||
ThrowInvalidParamError(env, "Parameter error: Convert startupTask name failed. Please check it.");
|
||||
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
|
||||
}
|
||||
dependencies.push_back(startupTask);
|
||||
@@ -261,6 +267,7 @@ int32_t JsStartupManager::GetConfig(napi_env env, napi_value value, std::shared_
|
||||
}
|
||||
if (startupConfig->Init(value) != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "failed to init config");
|
||||
ThrowInvalidParamError(env, "Parameter error: Failed to init config, must be a StartupConfig.");
|
||||
return ERR_STARTUP_INVALID_VALUE;
|
||||
}
|
||||
config = startupConfig;
|
||||
|
||||
@@ -15,15 +15,15 @@ import("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni")
|
||||
import("//build/ohos.gni")
|
||||
|
||||
es2abc_gen_abc("gen_startup_task_abc") {
|
||||
src_js = rebase_path("startup_task.js")
|
||||
src_js = rebase_path("startup_task.ts")
|
||||
dst_file = rebase_path(target_out_dir + "/startup_task.abc")
|
||||
in_puts = [ "startup_task.js" ]
|
||||
in_puts = [ "startup_task.ts" ]
|
||||
out_puts = [ target_out_dir + "/startup_task.abc" ]
|
||||
extra_args = [ "--module" ]
|
||||
}
|
||||
|
||||
gen_js_obj("startup_task_js") {
|
||||
input = "startup_task.js"
|
||||
input = "startup_task.ts"
|
||||
output = target_out_dir + "/startup_task.o"
|
||||
}
|
||||
|
||||
|
||||
+4
@@ -14,6 +14,10 @@
|
||||
*/
|
||||
|
||||
class StartupTask {
|
||||
constructor () {
|
||||
"use sendable"
|
||||
}
|
||||
|
||||
onDependenceCompleted(dependence, result) {
|
||||
console.log('onDependenceCompleted');
|
||||
}
|
||||
@@ -15,8 +15,6 @@
|
||||
|
||||
#include "native_engine/native_engine.h"
|
||||
|
||||
extern const char _binary_startup_task_js_start[];
|
||||
extern const char _binary_startup_task_js_end[];
|
||||
extern const char _binary_startup_task_abc_start[];
|
||||
extern const char _binary_startup_task_abc_end[];
|
||||
|
||||
@@ -31,18 +29,6 @@ void NAPI_app_appstartup_StartupTask_AutoRegister()
|
||||
napi_module_register(&_module);
|
||||
}
|
||||
|
||||
extern "C" __attribute__((visibility("default")))
|
||||
void NAPI_app_appstartup_StartupTask_GetJSCode(const char **buf, int *bufLen)
|
||||
{
|
||||
if (buf != nullptr) {
|
||||
*buf = _binary_startup_task_js_start;
|
||||
}
|
||||
|
||||
if (bufLen != nullptr) {
|
||||
*bufLen = _binary_startup_task_js_end - _binary_startup_task_js_start;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" __attribute__((visibility("default")))
|
||||
void NAPI_app_appstartup_StartupTask_GetABCCode(const char **buf, int *buflen)
|
||||
{
|
||||
|
||||
@@ -49,6 +49,15 @@ class BusinessError extends Error {
|
||||
}
|
||||
}
|
||||
|
||||
class ThrowInvalidParamError extends Error {
|
||||
constructor(msg) {
|
||||
let code = ERROR_CODE_INVALID_PARAM;
|
||||
let oriMsg = ERROR_MSG_INVALID_PARAM;
|
||||
super(code);
|
||||
this.msg = oriMsg + msg;
|
||||
}
|
||||
}
|
||||
|
||||
class Callee extends rpc.RemoteObject {
|
||||
constructor(des) {
|
||||
if (typeof des === 'string') {
|
||||
@@ -118,7 +127,8 @@ class Callee extends rpc.RemoteObject {
|
||||
if (typeof method !== 'string' || method === '' || typeof callback !== 'function') {
|
||||
console.log(
|
||||
'Callee on error, method is [' + typeof method + '], typeof callback [' + typeof callback + ']');
|
||||
throw new BusinessError(ERROR_CODE_INVALID_PARAM);
|
||||
throw new ThrowInvalidParamError('Parameter error: Failed to get method or callback.' +
|
||||
'method must be a non-empty string, callback must be a function.');
|
||||
}
|
||||
|
||||
if (this.callList == null) {
|
||||
@@ -138,7 +148,7 @@ class Callee extends rpc.RemoteObject {
|
||||
off(method) {
|
||||
if (typeof method !== 'string' || method === '') {
|
||||
console.log('Callee off error, method is [' + typeof method + ']');
|
||||
throw new BusinessError(ERROR_CODE_INVALID_PARAM);
|
||||
throw new ThrowInvalidParamError('Parameter error: Failed to get method, must be a string.');
|
||||
}
|
||||
|
||||
if (this.callList == null) {
|
||||
|
||||
@@ -46,6 +46,15 @@ class BusinessError extends Error {
|
||||
}
|
||||
}
|
||||
|
||||
class ThrowInvalidParamError extends Error {
|
||||
constructor(msg) {
|
||||
let code = ERROR_CODE_INVALID_PARAM;
|
||||
let oriMsg = ERROR_MSG_INVALID_PARAM;
|
||||
super(code);
|
||||
this.msg = oriMsg + msg;
|
||||
}
|
||||
}
|
||||
|
||||
class Caller {
|
||||
constructor(obj) {
|
||||
console.log('Caller::constructor obj is ' + typeof obj);
|
||||
@@ -181,7 +190,7 @@ class Caller {
|
||||
console.log('Caller onRelease jscallback called.');
|
||||
if (typeof callback !== 'function') {
|
||||
console.log('Caller onRelease ' + typeof callback);
|
||||
throw new BusinessError(ERROR_CODE_INVALID_PARAM);
|
||||
throw new ThrowInvalidParamError('Parameter error: Failed to get callback, must be a function.');
|
||||
}
|
||||
|
||||
if (this.releaseState === true) {
|
||||
@@ -196,7 +205,7 @@ class Caller {
|
||||
console.log('Caller onRemoteStateChange jscallback called.');
|
||||
if (typeof callback !== 'function') {
|
||||
console.log('Caller onRemoteStateChange ' + typeof callback);
|
||||
throw new BusinessError(ERROR_CODE_INVALID_PARAM);
|
||||
throw new ThrowInvalidParamError('Parameter error: Failed to get callback, must be a function.');
|
||||
}
|
||||
|
||||
if (this.releaseState === true) {
|
||||
@@ -212,12 +221,12 @@ class Caller {
|
||||
if (typeof type !== 'string' || type !== 'release') {
|
||||
console.log(
|
||||
'Caller onRelease error, input [type] is invalid.');
|
||||
throw new BusinessError(ERROR_CODE_INVALID_PARAM);
|
||||
throw new ThrowInvalidParamError('Parameter error: Failed to get type, must be string type release.');
|
||||
}
|
||||
|
||||
if (typeof callback !== 'function') {
|
||||
console.log('Caller onRelease error ' + typeof callback);
|
||||
throw new BusinessError(ERROR_CODE_INVALID_PARAM);
|
||||
throw new ThrowInvalidParamError('Parameter error: Failed to get callback, must be a function.');
|
||||
}
|
||||
|
||||
if (this.releaseState === true) {
|
||||
@@ -232,12 +241,12 @@ class Caller {
|
||||
if (typeof type !== 'string' || type !== 'release') {
|
||||
console.log(
|
||||
'Caller onRelease error, input [type] is invalid.');
|
||||
throw new BusinessError(ERROR_CODE_INVALID_PARAM);
|
||||
throw new ThrowInvalidParamError('Parameter error: Failed to get type, must be string type release.');
|
||||
}
|
||||
|
||||
if (callback && typeof callback !== 'function') {
|
||||
console.log('Caller onRelease error ' + typeof callback);
|
||||
throw new BusinessError(ERROR_CODE_INVALID_PARAM);
|
||||
throw new ThrowInvalidParamError('Parameter error: Failed to get callback, must be a function.');
|
||||
}
|
||||
// Empty
|
||||
}
|
||||
@@ -245,12 +254,13 @@ class Caller {
|
||||
callCheck(method, data) {
|
||||
if (typeof method !== 'string' || typeof data !== 'object') {
|
||||
console.log('Caller callCheck ' + typeof method + ' ' + typeof data);
|
||||
return new BusinessError(ERROR_CODE_INVALID_PARAM);
|
||||
return new ThrowInvalidParamError('Parameter error: Failed to get method or data, ' +
|
||||
'method must be a string, data must be a rpc.Parcelable');
|
||||
}
|
||||
|
||||
if (method === '' || data == null) {
|
||||
console.log('Caller callCheck ' + method + ', ' + data);
|
||||
return new BusinessError(ERROR_CODE_INVALID_PARAM);
|
||||
return new ThrowInvalidParamError('Parameter error: method or data is empty, Please check it.');
|
||||
}
|
||||
|
||||
if (this.releaseState === true) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# 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
|
||||
@@ -55,6 +55,8 @@ ohos_shared_library("napi_ability_common") {
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
public_external_deps = [ "bundle_framework:appexecfwk_core" ]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
defines = [ "SUPPORT_GRAPHICS" ]
|
||||
}
|
||||
|
||||
@@ -1748,83 +1748,73 @@ HapModuleInfoCB *CreateHapModuleInfoCBInfo(napi_env env)
|
||||
return hapModuleInfoCB;
|
||||
}
|
||||
|
||||
napi_value WrapHapModuleInfo(napi_env env, const HapModuleInfoCB &hapModuleInfoCB)
|
||||
napi_value WrapHapModuleInfo(napi_env env, const HapModuleInfoCB &cb)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called.", __func__);
|
||||
napi_value result = nullptr;
|
||||
napi_value proValue = nullptr;
|
||||
NAPI_CALL(env, napi_create_object(env, &result));
|
||||
NAPI_CALL(
|
||||
env, napi_create_string_utf8(env, hapModuleInfoCB.hapModuleInfo.name.c_str(), NAPI_AUTO_LENGTH, &proValue));
|
||||
NAPI_CALL(env, napi_create_string_utf8(env, cb.hapModuleInfo.name.c_str(), NAPI_AUTO_LENGTH, &proValue));
|
||||
NAPI_CALL(env, napi_set_named_property(env, result, "name", proValue));
|
||||
|
||||
NAPI_CALL(env,
|
||||
napi_create_string_utf8(env, hapModuleInfoCB.hapModuleInfo.description.c_str(), NAPI_AUTO_LENGTH, &proValue));
|
||||
NAPI_CALL(env, napi_create_string_utf8(env, cb.hapModuleInfo.description.c_str(), NAPI_AUTO_LENGTH, &proValue));
|
||||
NAPI_CALL(env, napi_set_named_property(env, result, "description", proValue));
|
||||
|
||||
NAPI_CALL(
|
||||
env, napi_create_string_utf8(env, hapModuleInfoCB.hapModuleInfo.iconPath.c_str(), NAPI_AUTO_LENGTH, &proValue));
|
||||
NAPI_CALL(env, napi_create_string_utf8(env, cb.hapModuleInfo.iconPath.c_str(), NAPI_AUTO_LENGTH, &proValue));
|
||||
NAPI_CALL(env, napi_set_named_property(env, result, "icon", proValue));
|
||||
|
||||
NAPI_CALL(
|
||||
env, napi_create_string_utf8(env, hapModuleInfoCB.hapModuleInfo.label.c_str(), NAPI_AUTO_LENGTH, &proValue));
|
||||
NAPI_CALL(env, napi_create_string_utf8(env, cb.hapModuleInfo.label.c_str(), NAPI_AUTO_LENGTH, &proValue));
|
||||
NAPI_CALL(env, napi_set_named_property(env, result, "label", proValue));
|
||||
|
||||
NAPI_CALL(env,
|
||||
napi_create_string_utf8(env, hapModuleInfoCB.hapModuleInfo.backgroundImg.c_str(), NAPI_AUTO_LENGTH, &proValue));
|
||||
NAPI_CALL(env, napi_create_string_utf8(env, cb.hapModuleInfo.backgroundImg.c_str(), NAPI_AUTO_LENGTH, &proValue));
|
||||
NAPI_CALL(env, napi_set_named_property(env, result, "backgroundImg", proValue));
|
||||
|
||||
NAPI_CALL(env,
|
||||
napi_create_string_utf8(env, hapModuleInfoCB.hapModuleInfo.moduleName.c_str(), NAPI_AUTO_LENGTH, &proValue));
|
||||
NAPI_CALL(env, napi_create_string_utf8(env, cb.hapModuleInfo.moduleName.c_str(), NAPI_AUTO_LENGTH, &proValue));
|
||||
NAPI_CALL(env, napi_set_named_property(env, result, "moduleName", proValue));
|
||||
|
||||
NAPI_CALL(env, napi_create_int32(env, hapModuleInfoCB.hapModuleInfo.supportedModes, &proValue));
|
||||
NAPI_CALL(env, napi_create_int32(env, cb.hapModuleInfo.supportedModes, &proValue));
|
||||
NAPI_CALL(env, napi_set_named_property(env, result, "supportedModes", proValue));
|
||||
|
||||
NAPI_CALL(env, napi_create_int32(env, hapModuleInfoCB.hapModuleInfo.descriptionId, &proValue));
|
||||
NAPI_CALL(env, napi_create_int32(env, cb.hapModuleInfo.descriptionId, &proValue));
|
||||
NAPI_CALL(env, napi_set_named_property(env, result, "descriptionId", proValue));
|
||||
|
||||
NAPI_CALL(env, napi_create_int32(env, hapModuleInfoCB.hapModuleInfo.labelId, &proValue));
|
||||
NAPI_CALL(env, napi_create_int32(env, cb.hapModuleInfo.labelId, &proValue));
|
||||
NAPI_CALL(env, napi_set_named_property(env, result, "labelId", proValue));
|
||||
|
||||
NAPI_CALL(env, napi_create_int32(env, hapModuleInfoCB.hapModuleInfo.iconId, &proValue));
|
||||
NAPI_CALL(env, napi_create_int32(env, cb.hapModuleInfo.iconId, &proValue));
|
||||
NAPI_CALL(env, napi_set_named_property(env, result, "iconId", proValue));
|
||||
|
||||
NAPI_CALL(env,
|
||||
napi_create_string_utf8(
|
||||
env, hapModuleInfoCB.hapModuleInfo.mainAbility.c_str(), NAPI_AUTO_LENGTH, &proValue));
|
||||
NAPI_CALL(env, napi_create_string_utf8(env, cb.hapModuleInfo.mainAbility.c_str(), NAPI_AUTO_LENGTH, &proValue));
|
||||
NAPI_CALL(env, napi_set_named_property(env, result, "mainAbilityName", proValue));
|
||||
|
||||
NAPI_CALL(env, napi_get_boolean(env, hapModuleInfoCB.hapModuleInfo.installationFree, &proValue));
|
||||
NAPI_CALL(env, napi_get_boolean(env, cb.hapModuleInfo.installationFree, &proValue));
|
||||
NAPI_CALL(env, napi_set_named_property(env, result, "installationFree", proValue));
|
||||
|
||||
napi_value jsArrayreqCapabilities = nullptr;
|
||||
NAPI_CALL(env, napi_create_array(env, &jsArrayreqCapabilities));
|
||||
for (size_t i = 0; i < hapModuleInfoCB.hapModuleInfo.reqCapabilities.size(); i++) {
|
||||
for (size_t i = 0; i < cb.hapModuleInfo.reqCapabilities.size(); i++) {
|
||||
proValue = nullptr;
|
||||
NAPI_CALL(env,
|
||||
napi_create_string_utf8(
|
||||
env, hapModuleInfoCB.hapModuleInfo.reqCapabilities.at(i).c_str(), NAPI_AUTO_LENGTH, &proValue));
|
||||
napi_create_string_utf8(env, cb.hapModuleInfo.reqCapabilities.at(i).c_str(), NAPI_AUTO_LENGTH, &proValue));
|
||||
NAPI_CALL(env, napi_set_element(env, jsArrayreqCapabilities, i, proValue));
|
||||
}
|
||||
NAPI_CALL(env, napi_set_named_property(env, result, "reqCapabilities", jsArrayreqCapabilities));
|
||||
|
||||
napi_value jsArraydeviceTypes = nullptr;
|
||||
NAPI_CALL(env, napi_create_array(env, &jsArraydeviceTypes));
|
||||
for (size_t i = 0; i < hapModuleInfoCB.hapModuleInfo.deviceTypes.size(); i++) {
|
||||
for (size_t i = 0; i < cb.hapModuleInfo.deviceTypes.size(); i++) {
|
||||
proValue = nullptr;
|
||||
NAPI_CALL(env,
|
||||
napi_create_string_utf8(
|
||||
env, hapModuleInfoCB.hapModuleInfo.deviceTypes.at(i).c_str(), NAPI_AUTO_LENGTH, &proValue));
|
||||
napi_create_string_utf8(env, cb.hapModuleInfo.deviceTypes.at(i).c_str(), NAPI_AUTO_LENGTH, &proValue));
|
||||
NAPI_CALL(env, napi_set_element(env, jsArraydeviceTypes, i, proValue));
|
||||
}
|
||||
NAPI_CALL(env, napi_set_named_property(env, result, "deviceTypes", jsArraydeviceTypes));
|
||||
|
||||
napi_value abilityInfos = nullptr;
|
||||
NAPI_CALL(env, napi_create_array(env, &abilityInfos));
|
||||
for (size_t i = 0; i < hapModuleInfoCB.hapModuleInfo.abilityInfos.size(); i++) {
|
||||
for (size_t i = 0; i < cb.hapModuleInfo.abilityInfos.size(); i++) {
|
||||
napi_value abilityInfo = nullptr;
|
||||
abilityInfo = WrapAbilityInfo(env, hapModuleInfoCB.hapModuleInfo.abilityInfos.at(i));
|
||||
abilityInfo = WrapAbilityInfo(env, cb.hapModuleInfo.abilityInfos.at(i));
|
||||
NAPI_CALL(env, napi_set_element(env, abilityInfos, i, abilityInfo));
|
||||
}
|
||||
NAPI_CALL(env, napi_set_named_property(env, result, "abilityInfo", abilityInfos));
|
||||
@@ -2413,11 +2403,7 @@ napi_value GetContextAsync(
|
||||
TAG_LOGD(AAFwkTag::JSNAPI, "napi_create_reference");
|
||||
napi_create_reference(env, args[argCallback], 1, &asyncCallbackInfo->cbInfo.callback);
|
||||
}
|
||||
napi_create_async_work(
|
||||
env,
|
||||
nullptr,
|
||||
resourceName,
|
||||
GetContextAsyncExecuteCB,
|
||||
napi_create_async_work(env, nullptr, resourceName, GetContextAsyncExecuteCB,
|
||||
[](napi_env env, napi_status, void *data) {
|
||||
TAG_LOGI(AAFwkTag::JSNAPI, "GetContextAsync, main event thread complete.");
|
||||
AsyncCallbackInfo *asyncCallbackInfo = static_cast<AsyncCallbackInfo *>(data);
|
||||
@@ -2443,9 +2429,7 @@ napi_value GetContextAsync(
|
||||
delete asyncCallbackInfo;
|
||||
asyncCallbackInfo = nullptr;
|
||||
TAG_LOGI(AAFwkTag::JSNAPI, "GetContextAsync, main event thread complete end.");
|
||||
},
|
||||
static_cast<void *>(asyncCallbackInfo),
|
||||
&asyncCallbackInfo->asyncWork);
|
||||
}, static_cast<void *>(asyncCallbackInfo), &asyncCallbackInfo->asyncWork);
|
||||
napi_queue_async_work_with_qos(env, asyncCallbackInfo->asyncWork, napi_qos_user_initiated);
|
||||
napi_value result = nullptr;
|
||||
napi_get_null(env, &result);
|
||||
@@ -2604,11 +2588,7 @@ napi_value GetWantAsync(napi_env env, napi_value *args, const size_t argCallback
|
||||
TAG_LOGD(AAFwkTag::JSNAPI, "napi_create_reference.");
|
||||
napi_create_reference(env, args[argCallback], 1, &asyncCallbackInfo->cbInfo.callback);
|
||||
}
|
||||
napi_create_async_work(
|
||||
env,
|
||||
nullptr,
|
||||
resourceName,
|
||||
GetWantExecuteCB,
|
||||
napi_create_async_work(env, nullptr, resourceName, GetWantExecuteCB,
|
||||
[](napi_env env, napi_status, void *data) {
|
||||
TAG_LOGI(AAFwkTag::JSNAPI, "GetWantAsync, main event thread complete.");
|
||||
AsyncCallbackInfo *asyncCallbackInfo = static_cast<AsyncCallbackInfo *>(data);
|
||||
@@ -3689,14 +3669,12 @@ napi_value AcquireDataAbilityHelperWrap(napi_env env, napi_callback_info info, D
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
napi_valuetype valuetype = napi_undefined;
|
||||
NAPI_CALL(env, napi_typeof(env, args[uriIndex], &valuetype));
|
||||
if (valuetype != napi_string) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, Wrong argument type.", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
napi_value result = nullptr;
|
||||
NAPI_CALL(env, napi_new_instance(env, GetGlobalDataAbilityHelper(env), uriIndex + 1, &args[PARAM0], &result));
|
||||
|
||||
@@ -4098,15 +4076,13 @@ napi_value JsNapiCommon::JsConnectAbility(napi_env env, napi_callback_info info,
|
||||
abilityConnection->AddConnectionCallback(connectionCallback);
|
||||
// Judge connection-state
|
||||
auto connectionState = abilityConnection->GetConnectionState();
|
||||
TAG_LOGI(AAFwkTag::JSNAPI, "connectionState = %{public}d", connectionState);
|
||||
if (connectionState == CONNECTION_STATE_CONNECTED) {
|
||||
TAG_LOGI(AAFwkTag::JSNAPI, "Ability is connected, callback to client.");
|
||||
abilityConnection->HandleOnAbilityConnectDone(*connectionCallback, ERR_OK);
|
||||
return CreateJsValue(env, id);
|
||||
} else if (connectionState == CONNECTION_STATE_CONNECTING) {
|
||||
TAG_LOGI(AAFwkTag::JSNAPI, "Ability is connecting, just wait callback.");
|
||||
return CreateJsValue(env, id);
|
||||
} else {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "AbilityConnection has disconnected, erase it.");
|
||||
RemoveConnectionLocked(want);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -60,6 +60,8 @@ ohos_shared_library("napi_common") {
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
public_external_deps = [ "bundle_framework:appexecfwk_core" ]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
defines = [ "SUPPORT_GRAPHICS" ]
|
||||
}
|
||||
|
||||
+1
-1
@@ -105,7 +105,7 @@ private:
|
||||
InsightIntentExecuteParam param;
|
||||
if (!UnwrapExecuteParam(env, info.argv[INDEX_ZERO], param)) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "CheckOnOffType, Parse on off type failed");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parameter error: Parse param failed, param must be a ExecuteParam.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ ohos_shared_library("dialogsession_napi") {
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
"${ability_runtime_napi_path}/inner/napi_common:napi_common",
|
||||
"${ability_runtime_native_path}/appkit:app_context",
|
||||
"//third_party/json:nlohmann_json_static",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
@@ -44,6 +43,7 @@ ohos_shared_library("dialogsession_napi") {
|
||||
"hilog:libhilog",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
"json:nlohmann_json_static",
|
||||
"jsoncpp:jsoncpp",
|
||||
"napi:ace_napi",
|
||||
"samgr:samgr_proxy",
|
||||
|
||||
@@ -46,7 +46,6 @@ ohos_shared_library("missionmanager") {
|
||||
]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
include_dirs += []
|
||||
external_deps += [
|
||||
"graphic_2d:color_manager",
|
||||
"icu:shared_icuuc",
|
||||
|
||||
@@ -146,7 +146,7 @@ private:
|
||||
}
|
||||
|
||||
if (!CheckOnOffType(env, argc, argv)) {
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param type failed, must be a string, value must be mission");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ private:
|
||||
}
|
||||
if (!AppExecFwk::IsTypeForNapiValue(env, argv[1], napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::MISSION, "Invalid param");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param listener failed, must be a MissionListener");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -230,14 +230,14 @@ private:
|
||||
}
|
||||
|
||||
if (!CheckOnOffType(env, argc, argv)) {
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param type failed, must be a string, value must be mission");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
int32_t missionListenerId = -1;
|
||||
if (!ConvertFromJsValue(env, argv[ARGC_ONE], missionListenerId)) {
|
||||
TAG_LOGE(AAFwkTag::MISSION, "Parse missionListenerId failed");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param listenerId failed, must be a number");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ private:
|
||||
int32_t missionListenerId = -1;
|
||||
if (!ConvertFromJsValue(env, argv[INDEX_ONE], missionListenerId)) {
|
||||
TAG_LOGE(AAFwkTag::MISSION, "Parse missionListenerId failed");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param listenerId failed, must be a number");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -326,13 +326,13 @@ private:
|
||||
std::string deviceId;
|
||||
if (!ConvertFromJsValue(env, argv[0], deviceId)) {
|
||||
TAG_LOGE(AAFwkTag::MISSION, "Parse deviceId failed");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param deviceId failed, must be a string");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
int numMax = -1;
|
||||
if (!ConvertFromJsValue(env, argv[1], numMax)) {
|
||||
TAG_LOGE(AAFwkTag::MISSION, "Parse numMax failed");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param numMax failed, must be a number");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -366,13 +366,13 @@ private:
|
||||
std::string deviceId;
|
||||
if (!ConvertFromJsValue(env, argv[0], deviceId)) {
|
||||
TAG_LOGE(AAFwkTag::MISSION, "Parse deviceId failed");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param deviceId failed, must be a string");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
int32_t missionId = -1;
|
||||
if (!ConvertFromJsValue(env, argv[1], missionId)) {
|
||||
TAG_LOGE(AAFwkTag::MISSION, "Parse missionId failed");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param missionId failed, must be a number");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -467,13 +467,13 @@ private:
|
||||
|
||||
if (!ConvertFromJsValue(env, argv[0], deviceId)) {
|
||||
TAG_LOGE(AAFwkTag::MISSION, "missionSnapshot: Parse deviceId failed");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param deviceId failed, must be a string");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ConvertFromJsValue(env, argv[1], missionId)) {
|
||||
TAG_LOGE(AAFwkTag::MISSION, "missionSnapshot: Parse missionId failed");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param missionId failed, must be a number");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -491,7 +491,7 @@ private:
|
||||
int32_t missionId = -1;
|
||||
if (!ConvertFromJsValue(env, argv[0], missionId)) {
|
||||
TAG_LOGE(AAFwkTag::MISSION, "OnLockMission Parse missionId failed");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param missionId failed, must be a number");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -524,7 +524,7 @@ private:
|
||||
int32_t missionId = -1;
|
||||
if (!ConvertFromJsValue(env, argv[0], missionId)) {
|
||||
TAG_LOGE(AAFwkTag::MISSION, "OnUnlockMission Parse missionId failed");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param missionId failed, must be a number");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -557,7 +557,7 @@ private:
|
||||
int32_t missionId = -1;
|
||||
if (!ConvertFromJsValue(env, argv[0], missionId)) {
|
||||
TAG_LOGE(AAFwkTag::MISSION, "OnClearMission Parse missionId failed");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param missionId failed, must be a number");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -611,7 +611,7 @@ private:
|
||||
int32_t missionId = -1;
|
||||
if (!ConvertFromJsValue(env, argv[0], missionId)) {
|
||||
TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionToFront Parse missionId failed");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param missionId failed, must be a number");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
decltype(argc) unwrapArgc = 1;
|
||||
@@ -654,7 +654,7 @@ private:
|
||||
napi_get_array_length(env, argv[0], &nativeArrayLen);
|
||||
if (nativeArrayLen == 0) {
|
||||
TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionsToForeground MissionId is null");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param missionIds failed, the size of missionIds must above zero");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
napi_value element = nullptr;
|
||||
@@ -663,7 +663,7 @@ private:
|
||||
napi_get_element(env, argv[0], i, &element);
|
||||
if (!ConvertFromJsValue(env, element, missionId)) {
|
||||
TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionsToForeground Parse missionId failed");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param missionIds failed, missionId must be a number");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
missionIds.push_back(missionId);
|
||||
@@ -674,7 +674,7 @@ private:
|
||||
if (argc > ARGC_ONE && AppExecFwk::IsTypeForNapiValue(env, argv[1], napi_number)) {
|
||||
if (!ConvertFromJsValue(env, argv[1], topMissionId)) {
|
||||
TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionsToForeground Parse topMissionId failed");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param topMission failed, must be a number");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
unwrapArgc++;
|
||||
@@ -713,7 +713,7 @@ private:
|
||||
napi_get_array_length(env, argv[0], &nativeArrayLen);
|
||||
if (nativeArrayLen == 0) {
|
||||
TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionsToBackground MissionId is null");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param missionIds failed, the size of missionIds must above zero");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
napi_value element = nullptr;
|
||||
@@ -722,7 +722,7 @@ private:
|
||||
napi_get_element(env, argv[0], i, &element);
|
||||
if (!ConvertFromJsValue(env, element, missionId)) {
|
||||
TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionsToBackground Parse topMissionId failed");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param missionIds failed, missionId must be a number");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
missionIds.push_back(missionId);
|
||||
|
||||
@@ -45,7 +45,6 @@ ohos_shared_library("missionmanager_napi") {
|
||||
]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
include_dirs += []
|
||||
external_deps += [
|
||||
"graphic_2d:color_manager",
|
||||
"icu:shared_icuuc",
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "napi_common_util.h"
|
||||
#include "quick_fix_error_utils.h"
|
||||
#include "quick_fix_manager_client.h"
|
||||
#include "js_error_utils.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
@@ -79,14 +80,14 @@ private:
|
||||
TAG_LOGD(AAFwkTag::QUICKFIX, "function called.");
|
||||
if (info.argc != ARGC_ONE && info.argc != ARGC_TWO) {
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "The number of parameter is invalid.");
|
||||
Throw(env, AAFwk::ERR_QUICKFIX_PARAM_INVALID);
|
||||
ThrowInvalidParamError(env, "Parameter error: The number of parameter is invalid.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
std::string bundleName;
|
||||
if (!OHOS::AppExecFwk::UnwrapStringFromJS2(env, info.argv[0], bundleName)) {
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "The bundleName is invalid.");
|
||||
Throw(env, AAFwk::ERR_QUICKFIX_PARAM_INVALID);
|
||||
ThrowInvalidParamError(env, "Parameter error: The bundleName is invalid, must be a string.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -114,14 +115,14 @@ private:
|
||||
TAG_LOGD(AAFwkTag::QUICKFIX, "function called.");
|
||||
if (info.argc != ARGC_ONE && info.argc != ARGC_TWO) {
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "The number of parameter is invalid.");
|
||||
Throw(env, AAFwk::ERR_QUICKFIX_PARAM_INVALID);
|
||||
ThrowInvalidParamError(env, "Parameter error: The number of parameter is invalid.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
std::vector<std::string> hapQuickFixFiles;
|
||||
if (!OHOS::AppExecFwk::UnwrapArrayStringFromJS(env, info.argv[0], hapQuickFixFiles)) {
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "Hap quick fix files is invalid.");
|
||||
Throw(env, AAFwk::ERR_QUICKFIX_PARAM_INVALID);
|
||||
ThrowInvalidParamError(env, "Parameter error: Hap quick fix files is invalid, must be a Array<string>.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -148,14 +149,14 @@ private:
|
||||
TAG_LOGD(AAFwkTag::QUICKFIX, "called.");
|
||||
if (info.argc == ARGC_ZERO) {
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "The number of parameter is invalid.");
|
||||
Throw(env, AAFwk::ERR_QUICKFIX_PARAM_INVALID);
|
||||
ThrowInvalidParamError(env, "Parameter error: The number of parameter is invalid.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
std::string bundleName;
|
||||
if (!ConvertFromJsValue(env, info.argv[ARGC_ZERO], bundleName)) {
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "The bundleName is invalid.");
|
||||
Throw(env, AAFwk::ERR_QUICKFIX_PARAM_INVALID);
|
||||
ThrowInvalidParamError(env, "Parameter error: The bundleName is invalid, must be a string.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,9 @@
|
||||
#include "js_runtime_utils.h"
|
||||
#include "napi_common.h"
|
||||
#include "start_options.h"
|
||||
#include "tokenid_kit.h"
|
||||
#include "want_agent_helper.h"
|
||||
#include "tokenid_kit.h"
|
||||
#include "js_error_utils.h"
|
||||
|
||||
using namespace OHOS::AbilityRuntime;
|
||||
namespace OHOS {
|
||||
@@ -318,13 +319,12 @@ napi_value JsWantAgent::OnEqual(napi_env env, napi_callback_info info)
|
||||
napi_value argv[ARGS_MAX_COUNT] = {nullptr};
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
TAG_LOGD(AAFwkTag::WANTAGENT, "enter, argc = %{public}d", static_cast<int32_t>(argc));
|
||||
int32_t errCode = BUSINESS_ERROR_CODE_OK;
|
||||
WantAgent* pWantAgentFirst = nullptr;
|
||||
WantAgent* pWantAgentSecond = nullptr;
|
||||
if (argc < ARGC_TWO || argc > ARGC_THREE) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Not enough params");
|
||||
#ifdef ENABLE_ERRCODE
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowTooFewParametersError(env);
|
||||
#endif
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
@@ -333,12 +333,10 @@ napi_value JsWantAgent::OnEqual(napi_env env, napi_callback_info info)
|
||||
if (!CheckTypeForNapiValue(env, argv[0], napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Wrong argument type. Object expected.");
|
||||
#ifdef ENABLE_ERRCODE
|
||||
errCode = ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
|
||||
AbilityRuntimeErrorUtil::Throw(env, errCode);
|
||||
ThrowInvalidParamError(env, "Wrong argument type. Agent must be a WantAgent.");
|
||||
return CreateJsUndefined(env);
|
||||
#else
|
||||
errCode = ERR_NOT_OK;
|
||||
return RetErrMsg(env, lastParam, errCode);
|
||||
return RetErrMsg(env, lastParam, ERR_NOT_OK);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -346,22 +344,20 @@ napi_value JsWantAgent::OnEqual(napi_env env, napi_callback_info info)
|
||||
if (pWantAgentFirst == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Parse pWantAgentFirst failed");
|
||||
#ifdef ENABLE_ERRCODE
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowInvalidParamError(env, "Parse pWantAgentFirst failed. Agent must be a WantAgent.");
|
||||
return CreateJsUndefined(env);
|
||||
#else
|
||||
errCode = ERR_NOT_OK;
|
||||
return RetErrMsg(env, lastParam, errCode);
|
||||
return RetErrMsg(env, lastParam, ERR_NOT_OK);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!CheckTypeForNapiValue(env, argv[1], napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Wrong argument type. Object expected.");
|
||||
#ifdef ENABLE_ERRCODE
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowInvalidParamError(env, "Wrong argument type. OtherAgent must be a WantAgent.");
|
||||
return CreateJsUndefined(env);
|
||||
#else
|
||||
errCode = ERR_NOT_OK;
|
||||
return RetErrMsg(env, lastParam, errCode);
|
||||
return RetErrMsg(env, lastParam, ERR_NOT_OK);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -369,11 +365,10 @@ napi_value JsWantAgent::OnEqual(napi_env env, napi_callback_info info)
|
||||
if (pWantAgentSecond == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Parse pWantAgentSceond failed");
|
||||
#ifdef ENABLE_ERRCODE
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowInvalidParamError(env, "Parse pWantAgentSceond failed. OtherAgent must be a WantAgent.");
|
||||
return CreateJsUndefined(env);
|
||||
#else
|
||||
errCode = ERR_NOT_OK;
|
||||
return RetErrMsg(env, lastParam, errCode);
|
||||
return RetErrMsg(env, lastParam, ERR_NOT_OK);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -421,12 +416,14 @@ napi_value JsWantAgent::OnGetWant(napi_env env, napi_callback_info info)
|
||||
WantAgent* pWantAgent = nullptr;
|
||||
if (argc > ARGC_TWO || argc < ARGC_ONE) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Not enough arguments");
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
napi_value lastParam = (argc >= ARGC_TWO) ? argv[INDEX_ONE] : nullptr;
|
||||
if (!CheckTypeForNapiValue(env, argv[0], napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Wrong parameter type. Object expected.");
|
||||
ThrowInvalidParamError(env, "Wrong argument type. Agent must be a WantAgent.");
|
||||
errCode = ERR_NOT_OK;
|
||||
return RetErrMsg(env, lastParam, errCode);
|
||||
}
|
||||
@@ -434,6 +431,7 @@ napi_value JsWantAgent::OnGetWant(napi_env env, napi_callback_info info)
|
||||
UnwrapWantAgent(env, argv[0], reinterpret_cast<void **>(&pWantAgent));
|
||||
if (pWantAgent == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Parse pWantAgent error");
|
||||
ThrowInvalidParamError(env, "Parse pWantAgent error. Agent must be a WantAgent.");
|
||||
errCode = ERR_NOT_OK;
|
||||
return RetErrMsg(env, lastParam, errCode);
|
||||
}
|
||||
@@ -466,12 +464,14 @@ napi_value JsWantAgent::OnGetOperationType(napi_env env, napi_callback_info info
|
||||
WantAgent* pWantAgent = nullptr;
|
||||
if (argc > ARGC_TWO || argc < ARGC_ONE) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Not enough params");
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
napi_value lastParam = (argc >= ARGC_TWO) ? argv[INDEX_ONE] : nullptr;
|
||||
if (!CheckTypeForNapiValue(env, argv[0], napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Wrong argument type. Object expected.");
|
||||
ThrowInvalidParamError(env, "Wrong argument type. Agent must be a WantAgent.");
|
||||
errCode = ERR_NOT_OK;
|
||||
return RetErrMsg(env, lastParam, errCode);
|
||||
}
|
||||
@@ -479,6 +479,7 @@ napi_value JsWantAgent::OnGetOperationType(napi_env env, napi_callback_info info
|
||||
UnwrapWantAgent(env, argv[0], reinterpret_cast<void **>(&pWantAgent));
|
||||
if (pWantAgent == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Parse pWantAgent failed");
|
||||
ThrowInvalidParamError(env, "Parse pWantAgent failed. Agent must be a WantAgent.");
|
||||
errCode = ERR_NOT_OK;
|
||||
return RetErrMsg(env, lastParam, errCode);
|
||||
}
|
||||
@@ -502,12 +503,11 @@ napi_value JsWantAgent::OnGetBundleName(napi_env env, napi_callback_info info)
|
||||
size_t argc = ARGS_MAX_COUNT;
|
||||
napi_value argv[ARGS_MAX_COUNT] = {nullptr};
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
int32_t errCode = BUSINESS_ERROR_CODE_OK;
|
||||
WantAgent* pWantAgent = nullptr;
|
||||
if (argc > ARGC_TWO || argc < ARGC_ONE) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Not enough params");
|
||||
#ifdef ENABLE_ERRCODE
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowTooFewParametersError(env);
|
||||
#endif
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
@@ -516,11 +516,10 @@ napi_value JsWantAgent::OnGetBundleName(napi_env env, napi_callback_info info)
|
||||
if (!CheckTypeForNapiValue(env, argv[0], napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Wrong argument type. Object expected.");
|
||||
#ifdef ENABLE_ERRCODE
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowInvalidParamError(env, "Wrong argument type. Agent must be a WantAgent.");
|
||||
return CreateJsUndefined(env);
|
||||
#else
|
||||
errCode = ERR_NOT_OK;
|
||||
return RetErrMsg(env, lastParam, errCode);
|
||||
return RetErrMsg(env, lastParam, ERR_NOT_OK);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -528,12 +527,10 @@ napi_value JsWantAgent::OnGetBundleName(napi_env env, napi_callback_info info)
|
||||
if (pWantAgent == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Parse pWantAgent failed");
|
||||
#ifdef ENABLE_ERRCODE
|
||||
errCode = ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
|
||||
AbilityRuntimeErrorUtil::Throw(env, errCode);
|
||||
ThrowInvalidParamError(env, "Parse pWantAgent failed. Agent must be a WantAgent.");
|
||||
return CreateJsUndefined(env);
|
||||
#else
|
||||
errCode = ERR_NOT_OK;
|
||||
return RetErrMsg(env, lastParam, errCode);
|
||||
return RetErrMsg(env, lastParam, ERR_NOT_OK);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -566,13 +563,11 @@ napi_value JsWantAgent::OnGetUid(napi_env env, napi_callback_info info)
|
||||
size_t argc = ARGS_MAX_COUNT;
|
||||
napi_value argv[ARGS_MAX_COUNT] = {nullptr};
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
int32_t errCode = BUSINESS_ERROR_CODE_OK;
|
||||
WantAgent* pWantAgent = nullptr;
|
||||
if (argc > ARGC_TWO || argc < ARGC_ONE) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Not enough params");
|
||||
#ifdef ENABLE_ERRCODE
|
||||
errCode = ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
|
||||
AbilityRuntimeErrorUtil::Throw(env, errCode);
|
||||
ThrowTooFewParametersError(env);
|
||||
#endif
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
@@ -581,12 +576,10 @@ napi_value JsWantAgent::OnGetUid(napi_env env, napi_callback_info info)
|
||||
if (!CheckTypeForNapiValue(env, argv[0], napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Wrong argument type. Object expected.");
|
||||
#ifdef ENABLE_ERRCODE
|
||||
errCode = ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
|
||||
AbilityRuntimeErrorUtil::Throw(env, errCode);
|
||||
ThrowInvalidParamError(env, "Wrong argument type. Agent must be a WantAgent.");
|
||||
return CreateJsUndefined(env);
|
||||
#else
|
||||
errCode = ERR_NOT_OK;
|
||||
return RetErrMsg(env, lastParam, errCode);
|
||||
return RetErrMsg(env, lastParam, ERR_NOT_OK);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -594,11 +587,10 @@ napi_value JsWantAgent::OnGetUid(napi_env env, napi_callback_info info)
|
||||
if (pWantAgent == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Parse pWantAgent error");
|
||||
#ifdef ENABLE_ERRCODE
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowInvalidParamError(env, "Parse pWantAgent error. Agent must be a WantAgent.");
|
||||
return CreateJsUndefined(env);
|
||||
#else
|
||||
errCode = ERR_NOT_OK;
|
||||
return RetErrMsg(env, lastParam, errCode);
|
||||
return RetErrMsg(env, lastParam, ERR_NOT_OK);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -627,7 +619,6 @@ napi_value JsWantAgent::OnGetUid(napi_env env, napi_callback_info info)
|
||||
napi_value JsWantAgent::OnCancel(napi_env env, napi_callback_info info)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::WANTAGENT, "%{public}s is called", __FUNCTION__);
|
||||
int32_t errCode = BUSINESS_ERROR_CODE_OK;
|
||||
WantAgent* pWantAgent = nullptr;
|
||||
size_t argc = ARGS_MAX_COUNT;
|
||||
napi_value argv[ARGS_MAX_COUNT] = {nullptr};
|
||||
@@ -635,7 +626,7 @@ napi_value JsWantAgent::OnCancel(napi_env env, napi_callback_info info)
|
||||
if (argc > ARGC_TWO || argc < ARGC_ONE) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Not enough params");
|
||||
#ifdef ENABLE_ERRCODE
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowTooFewParametersError(env);
|
||||
#endif
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
@@ -644,12 +635,10 @@ napi_value JsWantAgent::OnCancel(napi_env env, napi_callback_info info)
|
||||
if (!CheckTypeForNapiValue(env, argv[0], napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Wrong argument type. Object expected.");
|
||||
#ifdef ENABLE_ERRCODE
|
||||
errCode = ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
|
||||
AbilityRuntimeErrorUtil::Throw(env, errCode);
|
||||
ThrowInvalidParamError(env, "Wrong argument type. Agent must be a WantAgent.");
|
||||
return CreateJsUndefined(env);
|
||||
#else
|
||||
errCode = ERR_NOT_OK;
|
||||
return RetErrMsg(env, lastParam, errCode);
|
||||
return RetErrMsg(env, lastParam, ERR_NOT_OK);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -657,11 +646,10 @@ napi_value JsWantAgent::OnCancel(napi_env env, napi_callback_info info)
|
||||
if (pWantAgent == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Parse pWantAgent failed");
|
||||
#ifdef ENABLE_ERRCODE
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
ThrowInvalidParamError(env, "Parse pWantAgent error. Agent must be a WantAgent.");
|
||||
return CreateJsUndefined(env);
|
||||
#else
|
||||
errCode = ERR_NOT_OK;
|
||||
return RetErrMsg(env, lastParam, errCode);
|
||||
return RetErrMsg(env, lastParam, ERR_NOT_OK);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -696,6 +684,7 @@ napi_value JsWantAgent::OnTrigger(napi_env env, napi_callback_info info)
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
if (argc != ARGC_THREE) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Not enough params");
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -720,11 +709,13 @@ int32_t JsWantAgent::UnWrapTriggerInfoParam(napi_env env, napi_callback_info inf
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
if (argc != ARGC_THREE) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Not enough params");
|
||||
ThrowTooFewParametersError(env);
|
||||
return ERR_NOT_OK;
|
||||
}
|
||||
|
||||
if (!CheckTypeForNapiValue(env, argv[ARGC_ZERO], napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Wrong argument type. Object expected.");
|
||||
ThrowInvalidParamError(env, "Wrong argument type. Agent must be a WantAgent.");
|
||||
return ERR_NOT_OK;
|
||||
}
|
||||
WantAgent* pWantAgent = nullptr;
|
||||
@@ -732,6 +723,7 @@ int32_t JsWantAgent::UnWrapTriggerInfoParam(napi_env env, napi_callback_info inf
|
||||
|
||||
if (pWantAgent == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Parse pWantAgent failed");
|
||||
ThrowInvalidParamError(env, "Parse pWantAgent failed. Agent must be a WantAgent.");
|
||||
return ERR_NOT_OK;
|
||||
}
|
||||
wantAgent = std::make_shared<WantAgent>(*pWantAgent);
|
||||
@@ -739,6 +731,7 @@ int32_t JsWantAgent::UnWrapTriggerInfoParam(napi_env env, napi_callback_info inf
|
||||
int32_t ret = GetTriggerInfo(env, argv[ARGC_ONE], triggerInfo);
|
||||
if (ret != BUSINESS_ERROR_CODE_OK) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Get trigger info error");
|
||||
ThrowInvalidParamError(env, "Get trigger info error. TriggerInfo must be a TriggerInfo.");
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1046,6 +1039,7 @@ napi_value JsWantAgent::OnGetWantAgent(napi_env env, napi_callback_info info)
|
||||
TAG_LOGD(AAFwkTag::WANTAGENT, "enter, argc = %{public}d", static_cast<int32_t>(argc));
|
||||
if (argc > ARGC_TWO || argc < ARGC_ONE) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Not enough params");
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -1054,6 +1048,7 @@ napi_value JsWantAgent::OnGetWantAgent(napi_env env, napi_callback_info info)
|
||||
int32_t ret = GetWantAgentParam(env, info, *spParas);
|
||||
if (ret != 0) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "Failed to get wantAgent parameter.");
|
||||
ThrowInvalidParamError(env, "Failed to get wantAgent parameter. Agent must be a WantAgent.");
|
||||
return RetErrMsg(env, lastParam, ret);
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,10 @@ ohos_shared_library("ability_context_native") {
|
||||
"ipc:ipc_core",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
public_external_deps = [ "ability_base:extractortool" ]
|
||||
public_external_deps = [
|
||||
"ability_base:extractortool",
|
||||
"background_task_mgr:bgtaskmgr_innerkits",
|
||||
]
|
||||
if (ability_runtime_graphics) {
|
||||
external_deps += [
|
||||
"ace_engine:ace_uicontent",
|
||||
|
||||
@@ -119,7 +119,6 @@ config("abilitykit_utils_public_config") {
|
||||
]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
include_dirs += []
|
||||
defines = [ "SUPPORT_GRAPHICS" ]
|
||||
}
|
||||
}
|
||||
@@ -147,13 +146,16 @@ ohos_shared_library("abilitykit_utils") {
|
||||
external_deps = [
|
||||
"ability_base:configuration",
|
||||
"ability_base:want",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_napi",
|
||||
"napi:ace_napi",
|
||||
"resource_management:global_resmgr",
|
||||
]
|
||||
|
||||
public_external_deps = [
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"jsoncpp:jsoncpp",
|
||||
@@ -161,9 +163,9 @@ ohos_shared_library("abilitykit_utils") {
|
||||
]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
deps += [ "//third_party/icu/icu4c:shared_icuuc" ]
|
||||
external_deps += [
|
||||
"ability_base:session_info",
|
||||
"icu:shared_icuuc",
|
||||
"window_manager:libwm",
|
||||
]
|
||||
public_external_deps += [
|
||||
@@ -271,11 +273,14 @@ ohos_shared_library("abilitykit_native") {
|
||||
"resource_management:global_resmgr",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
public_external_deps = [
|
||||
"accessibility:accessibility_common",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"jsoncpp:jsoncpp",
|
||||
"libuv:uv",
|
||||
]
|
||||
|
||||
defines = []
|
||||
|
||||
if (background_task_mgr_continuous_task_enable) {
|
||||
@@ -300,11 +305,11 @@ ohos_shared_library("abilitykit_native") {
|
||||
"${ability_runtime_native_path}/ability/native/ability_window.cpp",
|
||||
"${ability_runtime_native_path}/ability/native/page_ability_impl.cpp",
|
||||
]
|
||||
deps += [ "//third_party/icu/icu4c:shared_icuuc" ]
|
||||
|
||||
external_deps += [
|
||||
"ability_base:session_info",
|
||||
"form_fwk:form_manager",
|
||||
"icu:shared_icuuc",
|
||||
"image_framework:image",
|
||||
"image_framework:image",
|
||||
"image_framework:image_native",
|
||||
@@ -382,11 +387,13 @@ ohos_shared_library("extensionkit_native") {
|
||||
"hitrace:hitrace_meter",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
public_deps = [ ":abilitykit_utils" ]
|
||||
|
||||
public_external_deps = [
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"jsoncpp:jsoncpp",
|
||||
]
|
||||
public_deps = [ ":abilitykit_utils" ]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
external_deps += [ "ability_base:session_info" ]
|
||||
@@ -528,9 +535,9 @@ ohos_shared_library("uiabilitykit_native") {
|
||||
]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
deps += [ "//third_party/icu/icu4c:shared_icuuc" ]
|
||||
external_deps += [
|
||||
"ability_base:session_info",
|
||||
"icu:shared_icuuc",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libwsutils",
|
||||
"window_manager:windowstage_kit",
|
||||
@@ -635,6 +642,7 @@ ohos_shared_library("form_extension") {
|
||||
"form_fwk:form_manager",
|
||||
"form_fwk:formutil_napi",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"napi:ace_napi",
|
||||
@@ -793,8 +801,8 @@ ohos_shared_library("data_ability_helper") {
|
||||
"${ability_runtime_native_path}/ability/native/data_ability_helper.cpp",
|
||||
]
|
||||
|
||||
configs = []
|
||||
public_configs = []
|
||||
configs = [ ":ability_config" ]
|
||||
public_configs = [ ":ability_public_config" ]
|
||||
|
||||
deps = [ ":abilitykit_native" ]
|
||||
|
||||
|
||||
@@ -76,6 +76,8 @@ constexpr const char* ERROR_MSG_NOT_SUPPORT_CROSS_APP_START =
|
||||
constexpr const char* ERROR_MSG_CANNOT_MATCH_ANY_COMPONENT = "Can not match any component.";
|
||||
constexpr const char* ERROR_MSG_TARGET_BUNDLE_NOT_EXIST = "The target bundle does not exist.";
|
||||
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.";
|
||||
|
||||
// follow ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST of appexecfwk_errors.h in bundle_framework
|
||||
constexpr int32_t ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST = 8521220;
|
||||
@@ -128,6 +130,7 @@ static std::unordered_map<AbilityErrorCode, const char*> ERR_CODE_MAP = {
|
||||
{ AbilityErrorCode::ERROR_CODE_CANNOT_MATCH_ANY_COMPONENT, ERROR_MSG_CANNOT_MATCH_ANY_COMPONENT },
|
||||
{ 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 },
|
||||
};
|
||||
|
||||
static std::unordered_map<int32_t, AbilityErrorCode> INNER_TO_JS_ERROR_CODE_MAP {
|
||||
@@ -183,6 +186,7 @@ static std::unordered_map<int32_t, AbilityErrorCode> INNER_TO_JS_ERROR_CODE_MAP
|
||||
{ERR_START_OTHER_APP_FAILED, AbilityErrorCode::ERROR_CODE_NOT_SUPPORT_CROSS_APP_START},
|
||||
{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},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1086,6 +1086,7 @@ int32_t JsUIAbility::OnSaveState(int32_t reason, WantParams &wantParams)
|
||||
|
||||
void JsUIAbility::OnConfigurationUpdated(const Configuration &configuration)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
UIAbility::OnConfigurationUpdated(configuration);
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "Called.");
|
||||
if (abilityContext_ == nullptr) {
|
||||
|
||||
+25
-1
@@ -46,6 +46,8 @@ constexpr const char *WANT_PARAMS_UPDATE_POPUP_HEIGHT = "ohos.ability.params.pop
|
||||
constexpr const char *WANT_PARAMS_UPDATE_POPUP_PLACEMENT = "ohos.ability.params.popupPlacement";
|
||||
constexpr const char *CONFIG_POPUP_SIZE = "popupSize";
|
||||
constexpr const char *CONFIG_POPUP_PLACEMENT = "placement";
|
||||
constexpr const char *WANT_PARAMS_FILL_CONTENT = "ohos.ability.params.fillContent";
|
||||
constexpr const char *ERROR_MSG_INVALID_PARAM = "Invalid input parameter, unable to parse json.";
|
||||
} // namespace
|
||||
|
||||
JsFillRequestCallback::JsFillRequestCallback(
|
||||
@@ -113,7 +115,25 @@ napi_value JsFillRequestCallback::OnFillRequestFailed(napi_env env, NapiCallback
|
||||
napi_value JsFillRequestCallback::OnFillRequestCanceled(napi_env env, NapiCallbackInfo &info)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::AUTOFILL_EXT, "Called.");
|
||||
SendResultCodeAndViewData(JsAutoFillExtensionUtil::AutoFillResultCode::CALLBACK_CANCEL, "");
|
||||
if (info.argc < ARGC_ONE) {
|
||||
SendResultCodeAndViewData(JsAutoFillExtensionUtil::AutoFillResultCode::CALLBACK_CANCEL, "");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
if (!IsTypeForNapiValue(env, info.argv[INDEX_ZERO], napi_string)) {
|
||||
TAG_LOGE(AAFwkTag::AUTOFILL_EXT, "Failed to parse fillContent JsonString!");
|
||||
ThrowError(env, static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INVALID_PARAM), ERROR_MSG_INVALID_PARAM);
|
||||
SendResultCodeAndViewData(
|
||||
JsAutoFillExtensionUtil::AutoFillResultCode::CALLBACK_FAILED_INVALID_PARAM, "");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
std::string jsonString = UnwrapStringFromJS(env, info.argv[INDEX_ZERO], "");
|
||||
if (jsonString.empty()) {
|
||||
TAG_LOGE(AAFwkTag::AUTOFILL_EXT, "JsonString is empty");
|
||||
SendResultCodeAndViewData(
|
||||
JsAutoFillExtensionUtil::AutoFillResultCode::CALLBACK_FAILED_INVALID_PARAM, "");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
SendResultCodeAndViewData(JsAutoFillExtensionUtil::AutoFillResultCode::CALLBACK_CANCEL, jsonString);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -190,6 +210,10 @@ void JsFillRequestCallback::SendResultCodeAndViewData(
|
||||
want.SetParam(WANT_PARAMS_AUTO_FILL_CMD, WANT_PARAMS_AUTO_FILL_CMD_AUTOFILL);
|
||||
}
|
||||
|
||||
if (resultCode == JsAutoFillExtensionUtil::AutoFillResultCode::CALLBACK_CANCEL) {
|
||||
want.SetParam(WANT_PARAMS_FILL_CONTENT, jsString);
|
||||
}
|
||||
|
||||
auto ret = uiWindow_->TransferAbilityResult(resultCode, want);
|
||||
if (ret != Rosen::WMError::WM_OK) {
|
||||
TAG_LOGE(AAFwkTag::AUTOFILL_EXT, "Transfer ability result failed.");
|
||||
|
||||
@@ -46,6 +46,7 @@ namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
namespace {
|
||||
bool g_jitEnabled = false;
|
||||
AbilityRuntime::Runtime::DebugOption g_debugOption;
|
||||
}
|
||||
bool ChildProcessManager::signalRegistered_ = false;
|
||||
|
||||
@@ -79,7 +80,12 @@ ChildProcessManagerErrorCode ChildProcessManager::StartChildProcessBySelfFork(co
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "Fork process failed");
|
||||
return ChildProcessManagerErrorCode::ERR_FORK_FAILED;
|
||||
}
|
||||
MakeProcessName(srcEntry); // set process name
|
||||
if (pid == 0) {
|
||||
const char *processName = g_debugOption.processName.c_str();
|
||||
if (prctl(PR_SET_NAME, processName) < 0) {
|
||||
TAG_LOGW(AAFwkTag::PROCESSMGR, "Set process name failed with %{public}d", errno);
|
||||
}
|
||||
HandleChildProcessBySelfFork(srcEntry, bundleInfo);
|
||||
}
|
||||
return ChildProcessManagerErrorCode::ERR_OK;
|
||||
@@ -88,7 +94,8 @@ ChildProcessManagerErrorCode ChildProcessManager::StartChildProcessBySelfFork(co
|
||||
ChildProcessManagerErrorCode ChildProcessManager::StartChildProcessByAppSpawnFork(
|
||||
const std::string &srcEntry, pid_t &pid)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::PROCESSMGR, "called.");
|
||||
TAG_LOGI(AAFwkTag::PROCESSMGR, "called, startWitDebug: %{public}d, processName: %{public}s, native: %{public}d",
|
||||
g_debugOption.isStartWithDebug, g_debugOption.processName.c_str(), g_debugOption.isStartWithNative);
|
||||
ChildProcessManagerErrorCode errorCode = PreCheck();
|
||||
if (errorCode != ChildProcessManagerErrorCode::ERR_OK) {
|
||||
return errorCode;
|
||||
@@ -98,7 +105,8 @@ ChildProcessManagerErrorCode ChildProcessManager::StartChildProcessByAppSpawnFor
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "GetAppMgr failed.");
|
||||
return ChildProcessManagerErrorCode::ERR_GET_APP_MGR_FAILED;
|
||||
}
|
||||
auto ret = appMgr->StartChildProcess(srcEntry, pid);
|
||||
auto ret = appMgr->StartChildProcess(srcEntry, pid, childProcessCount_, g_debugOption.isStartWithDebug);
|
||||
childProcessCount_++;
|
||||
TAG_LOGD(AAFwkTag::PROCESSMGR, "AppMgr StartChildProcess ret:%{public}d", ret);
|
||||
if (ret != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "AppMgr StartChildProcess failed, ret:%{public}d", ret);
|
||||
@@ -164,6 +172,10 @@ void ChildProcessManager::HandleChildProcessBySelfFork(const std::string &srcEnt
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "Failed to create child process runtime");
|
||||
return;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::PROCESSMGR, "StartDebugMode, isStartWithDebug is %{public}d, processName is %{public}s, "
|
||||
"isDebugApp is %{public}d, isStartWithNative is %{public}d.", g_debugOption.isStartWithDebug,
|
||||
g_debugOption.processName.c_str(), g_debugOption.isDebugApp, g_debugOption.isStartWithNative);
|
||||
runtime->StartDebugMode(g_debugOption);
|
||||
LoadJsFile(srcEntry, hapModuleInfo, runtime);
|
||||
TAG_LOGD(AAFwkTag::PROCESSMGR, "HandleChildProcessBySelfFork end.");
|
||||
exit(0);
|
||||
@@ -291,5 +303,33 @@ void ChildProcessManager::SetForkProcessJITEnabled(bool jitEnabled)
|
||||
{
|
||||
g_jitEnabled = jitEnabled;
|
||||
}
|
||||
|
||||
void ChildProcessManager::SetForkProcessDebugOption(const std::string bundleName, const bool isStartWithDebug,
|
||||
const bool isDebugApp, const bool isStartWithNative)
|
||||
{
|
||||
g_debugOption.bundleName = bundleName;
|
||||
g_debugOption.isStartWithDebug = isStartWithDebug;
|
||||
g_debugOption.isDebugApp = isDebugApp;
|
||||
g_debugOption.isStartWithNative = isStartWithNative;
|
||||
}
|
||||
|
||||
void ChildProcessManager::MakeProcessName(const std::string &srcEntry)
|
||||
{
|
||||
std::string processName = g_debugOption.bundleName;
|
||||
if (srcEntry.empty()) {
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "srcEntry empty.");
|
||||
} else {
|
||||
TAG_LOGW(AAFwkTag::PROCESSMGR, "srcEntry is not empty.");
|
||||
std::string filename = std::filesystem::path(srcEntry).stem();
|
||||
if (!filename.empty()) {
|
||||
processName.append(":");
|
||||
processName.append(filename);
|
||||
}
|
||||
}
|
||||
processName.append(std::to_string(childProcessCount_));
|
||||
childProcessCount_++;
|
||||
TAG_LOGD(AAFwkTag::PROCESSMGR, "SetForkProcessDebugOption processName is %{public}s", processName.c_str());
|
||||
g_debugOption.processName = processName;
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "configuration_convertor.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#include "window.h"
|
||||
#endif
|
||||
@@ -29,6 +30,7 @@ using namespace AppExecFwk;
|
||||
void ConfigurationUtils::UpdateGlobalConfig(const Configuration &configuration,
|
||||
std::shared_ptr<ResourceManager> resourceManager)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "Enter");
|
||||
if (resourceManager == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITY, "Resource manager is invalid.");
|
||||
@@ -73,6 +75,7 @@ void ConfigurationUtils::UpdateGlobalConfig(const Configuration &configuration,
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "Update config, hasPointerDevice: %{public}d", resConfig->GetInputDevice());
|
||||
}
|
||||
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, "resourceManager->UpdateResConfig");
|
||||
Global::Resource::RState ret = resourceManager->UpdateResConfig(*resConfig);
|
||||
if (ret != Global::Resource::RState::SUCCESS) {
|
||||
TAG_LOGE(AAFwkTag::ABILITY, "Update resource config failed with %{public}d.", static_cast<int>(ret));
|
||||
|
||||
@@ -221,7 +221,6 @@ private:
|
||||
AAFwk::Want want;
|
||||
AAFwk::StartOptions startOptions;
|
||||
if (!CheckStartAbilityInputParam(env, info, want, startOptions, unwrapArgc)) {
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -272,22 +271,26 @@ private:
|
||||
{
|
||||
if (info.argc != ARGC_TWO) {
|
||||
TAG_LOGE(AAFwkTag::SERVICE_EXT, "wrong arguments num");
|
||||
ThrowTooFewParametersError(env);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CheckTypeForNapiValue(env, info.argv[ARGC_ZERO], napi_string)) {
|
||||
TAG_LOGE(AAFwkTag::SERVICE_EXT, "link must be string");
|
||||
ThrowInvalidParamError(env, "Parse param link failed, must be a string");
|
||||
return false;
|
||||
}
|
||||
if (!ConvertFromJsValue(env, info.argv[ARGC_ZERO], linkValue) || !CheckUrl(linkValue)) {
|
||||
TAG_LOGE(AAFwkTag::SERVICE_EXT, "link parameter invalid");
|
||||
ThrowInvalidParamError(env, "link parameter invalid");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (CheckTypeForNapiValue(env, info.argv[INDEX_ONE], napi_object)) {
|
||||
TAG_LOGD(AAFwkTag::SERVICE_EXT, "OpenLinkOptions is used.");
|
||||
if (!AppExecFwk::UnwrapOpenLinkOptions(env, info.argv[INDEX_ONE], openLinkOptions, want)) {
|
||||
TAG_LOGE(AAFwkTag::SERVICE_EXT, "openLinkOptions parse failed");
|
||||
TAG_LOGE(AAFwkTag::SERVICE_EXT, "OpenLinkOptions parse failed");
|
||||
ThrowInvalidParamError(env, "Parse param options failed, must be a OpenLinkOptions");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -307,7 +310,6 @@ private:
|
||||
|
||||
if (!ParseOpenLinkParams(env, info, linkValue, openLinkOptions, want)) {
|
||||
TAG_LOGE(AAFwkTag::SERVICE_EXT, "parse openLink arguments failed");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -361,7 +363,6 @@ private:
|
||||
AAFwk::Want want;
|
||||
AAFwk::StartOptions startOptions;
|
||||
if (!CheckStartAbilityInputParam(env, info, want, startOptions, unwrapArgc)) {
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -396,11 +397,13 @@ private:
|
||||
AAFwk::Want& want, AAFwk::StartOptions& startOptions, size_t& unwrapArgc) const
|
||||
{
|
||||
if (info.argc < ARGC_ONE) {
|
||||
ThrowTooFewParametersError(env);
|
||||
return false;
|
||||
}
|
||||
unwrapArgc = ARGC_ZERO;
|
||||
// Check input want
|
||||
if (!AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want)) {
|
||||
ThrowInvalidParamError(env, "Parse param want failed, must be a Want");
|
||||
return false;
|
||||
}
|
||||
++unwrapArgc;
|
||||
@@ -423,7 +426,6 @@ private:
|
||||
AAFwk::Want want;
|
||||
int32_t accountId = DEFAULT_INVAL_VALUE;
|
||||
if (!CheckStartAbilityByCallInputParam(env, info, want, accountId)) {
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -463,6 +465,7 @@ private:
|
||||
napi_env env, NapiCallbackInfo& info, AAFwk::Want& want, int32_t& accountId)
|
||||
{
|
||||
if (!AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want)) {
|
||||
ThrowInvalidParamError(env, "Parse param want failed, must be a Want");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -470,10 +473,12 @@ private:
|
||||
if (CheckTypeForNapiValue(env, info.argv[INDEX_ONE], napi_number)) {
|
||||
if (!ConvertFromJsValue(env, info.argv[1], accountId)) {
|
||||
TAG_LOGE(AAFwkTag::SERVICE_EXT, "check input param accountId failed");
|
||||
ThrowInvalidParamError(env, "Parse param accountId failed, must be a number");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
TAG_LOGE(AAFwkTag::SERVICE_EXT, "input parameter type invalid");
|
||||
ThrowInvalidParamError(env, "Parse param accountId failed, must be a number");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -574,7 +579,6 @@ private:
|
||||
AAFwk::Want want;
|
||||
int32_t accountId = 0;
|
||||
if (!CheckStartAbilityWithAccountInputParam(env, info, want, accountId, unwrapArgc)) {
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -612,15 +616,18 @@ private:
|
||||
AAFwk::Want& want, int32_t& accountId, size_t& unwrapArgc) const
|
||||
{
|
||||
if (info.argc < ARGC_TWO) {
|
||||
ThrowTooFewParametersError(env);
|
||||
return false;
|
||||
}
|
||||
unwrapArgc = ARGC_ZERO;
|
||||
// Check input want
|
||||
if (!AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want)) {
|
||||
ThrowInvalidParamError(env, "Parse param want failed, must be a Want");
|
||||
return false;
|
||||
}
|
||||
++unwrapArgc;
|
||||
if (!AppExecFwk::UnwrapInt32FromJS2(env, info.argv[INDEX_ONE], accountId)) {
|
||||
ThrowInvalidParamError(env, "Parse param accountId failed, must be a number");
|
||||
return false;
|
||||
}
|
||||
++unwrapArgc;
|
||||
@@ -667,12 +674,14 @@ private:
|
||||
// Unwrap want and connection
|
||||
AAFwk::Want want;
|
||||
sptr<JSServiceExtensionConnection> connection = new JSServiceExtensionConnection(env);
|
||||
if (!AppExecFwk::UnwrapWant(env, info.argv[0], want) ||
|
||||
!CheckConnectionParam(env, info.argv[1], connection, want)) {
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
if (!AppExecFwk::UnwrapWant(env, info.argv[0], want)) {
|
||||
ThrowInvalidParamError(env, "Parse param want failed, must be a Want");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
if (!CheckConnectionParam(env, info.argv[1], connection, want)) {
|
||||
ThrowInvalidParamError(env, "Parse param options failed, must be a ConnectOptions");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
int64_t connectId = connection->GetConnectionId();
|
||||
auto innerErrorCode = std::make_shared<int>(ERR_OK);
|
||||
auto execute = GetConnectAbilityExecFunc(want, connection, connectId, innerErrorCode);
|
||||
@@ -710,10 +719,12 @@ private:
|
||||
AAFwk::Want want;
|
||||
int32_t accountId = 0;
|
||||
sptr<JSServiceExtensionConnection> connection = new JSServiceExtensionConnection(env);
|
||||
if (!AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want) ||
|
||||
!AppExecFwk::UnwrapInt32FromJS2(env, info.argv[INDEX_ONE], accountId) ||
|
||||
!CheckConnectionParam(env, info.argv[INDEX_TWO], connection, want)) {
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
size_t unwrapArgc = 0;
|
||||
if (!CheckStartAbilityWithAccountInputParam(env, info, want, accountId, unwrapArgc)) {
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
if (!CheckConnectionParam(env, info.argv[INDEX_TWO], connection, want)) {
|
||||
ThrowInvalidParamError(env, "Parse param options failed, must be a ConnectOptions");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
int64_t connectId = connection->GetConnectionId();
|
||||
@@ -778,7 +789,7 @@ private:
|
||||
}
|
||||
int64_t connectId = -1;
|
||||
if (!AppExecFwk::UnwrapInt64FromJS2(env, info.argv[INDEX_ZERO], connectId)) {
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param connection failed, must be a number");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -845,7 +856,7 @@ private:
|
||||
}
|
||||
AAFwk::Want want;
|
||||
if (!AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want)) {
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param want failed, must be a Want");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -882,9 +893,8 @@ private:
|
||||
}
|
||||
AAFwk::Want want;
|
||||
int32_t accountId = -1;
|
||||
if (!AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want) ||
|
||||
!AppExecFwk::UnwrapInt32FromJS2(env, info.argv[INDEX_ONE], accountId)) {
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
size_t unwrapArgc = 0;
|
||||
if (!CheckStartAbilityWithAccountInputParam(env, info, want, accountId, unwrapArgc)) {
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -921,7 +931,7 @@ private:
|
||||
}
|
||||
AAFwk::Want want;
|
||||
if (!AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want)) {
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param want failed, must be a Want");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -958,10 +968,8 @@ private:
|
||||
}
|
||||
AAFwk::Want want;
|
||||
int32_t accountId = -1;
|
||||
if (!AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want) ||
|
||||
!AppExecFwk::UnwrapInt32FromJS2(env, info.argv[INDEX_ONE], accountId)) {
|
||||
TAG_LOGD(AAFwkTag::SERVICE_EXT, "Failed, input parameter type invalid");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
size_t unwrapArgc = 0;
|
||||
if (!CheckStartAbilityWithAccountInputParam(env, info, want, accountId, unwrapArgc)) {
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -1000,7 +1008,7 @@ private:
|
||||
AAFwk::Want want;
|
||||
if (!AppExecFwk::UnwrapWant(env, info.argv[0], want)) {
|
||||
TAG_LOGE(AAFwkTag::SERVICE_EXT, "Failed to parse want!");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parse param want failed, must be a Want");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
|
||||
@@ -141,7 +141,6 @@ std::shared_ptr<ExtensionCommon> JsUIExtensionBase::Init(const std::shared_ptr<A
|
||||
std::string moduleName(abilityInfo_->moduleName);
|
||||
moduleName.append("::").append(abilityInfo_->name);
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
napi_env env = jsRuntime_.GetNapiEnv();
|
||||
|
||||
jsObj_ = jsRuntime_.LoadModule(
|
||||
moduleName, srcPath, abilityInfo_->hapPath, abilityInfo_->compileMode == CompileMode::ES_MODULE);
|
||||
@@ -150,25 +149,26 @@ std::shared_ptr<ExtensionCommon> JsUIExtensionBase::Init(const std::shared_ptr<A
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
napi_value obj = jsObj_->GetNapiValue();
|
||||
if (!CheckTypeForNapiValue(env, obj, napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "obj is not object");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BindContext(env, obj);
|
||||
BindContext();
|
||||
|
||||
return JsExtensionCommon::Create(jsRuntime_, static_cast<NativeReference&>(*jsObj_), shellContextRef_);
|
||||
}
|
||||
|
||||
void JsUIExtensionBase::BindContext(napi_env env, napi_value obj)
|
||||
void JsUIExtensionBase::BindContext()
|
||||
{
|
||||
if (context_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "context_ is nullptr");
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
if (jsObj_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "jsObj_ is nullptr");
|
||||
return;
|
||||
}
|
||||
if (obj == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "obj is nullptr");
|
||||
napi_env env = jsRuntime_.GetNapiEnv();
|
||||
napi_value obj = jsObj_->GetNapiValue();
|
||||
if (!CheckTypeForNapiValue(env, obj, napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "obj is not object");
|
||||
return;
|
||||
}
|
||||
if (context_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "context_ is nullptr");
|
||||
return;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::UI_EXT, "BindContext CreateJsUIExtensionContext.");
|
||||
|
||||
+95
-31
@@ -238,7 +238,7 @@ napi_value JsUIExtensionContentSession::OnStartAbility(napi_env env, NapiCallbac
|
||||
size_t unwrapArgc = 1;
|
||||
if (!OHOS::AppExecFwk::UnwrapWant(env, info.argv[0], want)) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "Failed to parse want!");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parameter error: Failed to parse want! Want must be a Want.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
if (!want.HasParameter(Want::PARAM_BACK_TO_OTHER_MISSION_STACK)) {
|
||||
@@ -331,7 +331,7 @@ napi_value JsUIExtensionContentSession::OnStartAbilityAsCaller(napi_env env, Nap
|
||||
AAFwk::Want want;
|
||||
bool unWrapWantFlag = OHOS::AppExecFwk::UnwrapWant(env, info.argv[0], want);
|
||||
if (!unWrapWantFlag) {
|
||||
ThrowTooFewParametersError(env);
|
||||
ThrowInvalidParamError(env, "Parameter error: Parse want failed! Want must be a Want.");
|
||||
}
|
||||
decltype(info.argc) unwrapArgc = 1;
|
||||
TAG_LOGI(AAFwkTag::UI_EXT, "StartAbilityAsCaller, ability:%{public}s.", want.GetElement().GetAbilityName().c_str());
|
||||
@@ -340,7 +340,7 @@ napi_value JsUIExtensionContentSession::OnStartAbilityAsCaller(napi_env env, Nap
|
||||
TAG_LOGD(AAFwkTag::UI_EXT, "OnStartAbilityAsCaller start options is used.");
|
||||
bool unWrapStartOptionsFlag = AppExecFwk::UnwrapStartOptions(env, info.argv[INDEX_ONE], startOptions);
|
||||
if (!unWrapStartOptionsFlag) {
|
||||
ThrowTooFewParametersError(env);
|
||||
ThrowInvalidParamError(env, "Parameter error: Parse startOptions failed! Options must be a StartOption.");
|
||||
}
|
||||
unwrapArgc++;
|
||||
}
|
||||
@@ -380,7 +380,10 @@ NapiAsyncTask::ExecuteCallback JsUIExtensionContentSession::StartAbilityExecuteC
|
||||
AAFwk::StartOptions startOptions;
|
||||
if (info.argc > ARGC_ONE && CheckTypeForNapiValue(env, info.argv[1], napi_object)) {
|
||||
TAG_LOGD(AAFwkTag::UI_EXT, "OnStartAbility start options is used.");
|
||||
AppExecFwk::UnwrapStartOptions(env, info.argv[1], startOptions);
|
||||
bool unWrapStartOptionsFlag = AppExecFwk::UnwrapStartOptions(env, info.argv[1], startOptions);
|
||||
if (!unWrapStartOptionsFlag) {
|
||||
ThrowInvalidParamError(env, "Parameter error: Parse startOptions failed! Options must be a StartOption.");
|
||||
}
|
||||
unwrapArgc++;
|
||||
}
|
||||
|
||||
@@ -425,7 +428,7 @@ napi_value JsUIExtensionContentSession::OnStartAbilityForResult(napi_env env, Na
|
||||
AAFwk::Want want;
|
||||
if (!AppExecFwk::UnwrapWant(env, info.argv[0], want)) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "Error to parse want!");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Failed to parse want! Want must be a Want.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
if (!want.HasParameter(Want::PARAM_BACK_TO_OTHER_MISSION_STACK)) {
|
||||
@@ -435,7 +438,10 @@ napi_value JsUIExtensionContentSession::OnStartAbilityForResult(napi_env env, Na
|
||||
AAFwk::StartOptions startOptions;
|
||||
if (info.argc > ARGC_ONE && CheckTypeForNapiValue(env, info.argv[1], napi_object)) {
|
||||
TAG_LOGD(AAFwkTag::UI_EXT, "OnStartAbilityForResult start options is used.");
|
||||
AppExecFwk::UnwrapStartOptions(env, info.argv[1], startOptions);
|
||||
bool unWrapStartOptionsFlag = AppExecFwk::UnwrapStartOptions(env, info.argv[1], startOptions);
|
||||
if (!unWrapStartOptionsFlag) {
|
||||
ThrowInvalidParamError(env, "Parameter error: Parse startOptions failed! Options must be a StartOption.");
|
||||
}
|
||||
unwrapArgc++;
|
||||
}
|
||||
|
||||
@@ -546,15 +552,15 @@ napi_value JsUIExtensionContentSession::OnTerminateSelfWithResult(napi_env env,
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::UI_EXT, "called");
|
||||
if (info.argc < ARGC_ONE) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "invalid param");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "Not enough params.");
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
int resultCode = 0;
|
||||
AAFwk::Want want;
|
||||
if (!AppExecFwk::UnWrapAbilityResult(env, info.argv[INDEX_ZERO], resultCode, want)) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "OnTerminateSelfWithResult Failed to parse ability result!");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parameter error: Failed to parse parameter! Parameter must be a AbilityResult.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -591,14 +597,14 @@ napi_value JsUIExtensionContentSession::OnSendData(napi_env env, NapiCallbackInf
|
||||
TAG_LOGD(AAFwkTag::UI_EXT, "called");
|
||||
CHECK_IS_SYSTEM_APP;
|
||||
if (info.argc < ARGC_ONE) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "invalid param");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "Not enough params.");
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
AAFwk::WantParams params;
|
||||
if (!AppExecFwk::UnwrapWantParams(env, info.argv[INDEX_ZERO], params)) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "OnSendData Failed to parse param!");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "OnSendData Failed to parse param! Data must be a Record<string, Object>.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -622,9 +628,15 @@ napi_value JsUIExtensionContentSession::OnSetReceiveDataCallback(napi_env env, N
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::UI_EXT, "called");
|
||||
CHECK_IS_SYSTEM_APP;
|
||||
if (info.argc < ARGC_ONE || !CheckTypeForNapiValue(env, info.argv[INDEX_ZERO], napi_function)) {
|
||||
if (info.argc < ARGC_ONE) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "Not enough params.");
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
if (!CheckTypeForNapiValue(env, info.argv[INDEX_ZERO], napi_function)) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "invalid param");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parameter error: Callback must be a function.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -664,9 +676,15 @@ napi_value JsUIExtensionContentSession::OnSetReceiveDataForResultCallback(napi_e
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::UI_EXT, "called");
|
||||
CHECK_IS_SYSTEM_APP;
|
||||
if (info.argc < ARGC_ONE || !CheckTypeForNapiValue(env, info.argv[INDEX_ZERO], napi_function)) {
|
||||
if (info.argc < ARGC_ONE) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "Not enough params.");
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
if (!CheckTypeForNapiValue(env, info.argv[INDEX_ZERO], napi_function)) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "invalid param");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parameter error: Callback must be a function.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -710,14 +728,25 @@ napi_value JsUIExtensionContentSession::OnLoadContent(napi_env env, NapiCallback
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::UI_EXT, "called");
|
||||
std::string contextPath;
|
||||
if (info.argc < ARGC_ONE || !ConvertFromJsValue(env, info.argv[INDEX_ZERO], contextPath)) {
|
||||
if (info.argc < ARGC_ONE) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "Not enough params.");
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], contextPath)) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "invalid param");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parameter error: Path must be a string.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::UI_EXT, "contextPath: %{public}s", contextPath.c_str());
|
||||
napi_value storage = nullptr;
|
||||
if (info.argc > ARGC_ONE && CheckTypeForNapiValue(env, info.argv[INDEX_ONE], napi_object)) {
|
||||
if (info.argc > ARGC_ONE) {
|
||||
if (!CheckTypeForNapiValue(env, info.argv[INDEX_ONE], napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "invalid param");
|
||||
ThrowInvalidParamError(env, "Parameter error: Storage must be a LocalStorage.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
storage = info.argv[INDEX_ONE];
|
||||
}
|
||||
if (uiWindow_ == nullptr || sessionInfo_ == nullptr) {
|
||||
@@ -747,9 +776,15 @@ napi_value JsUIExtensionContentSession::OnSetWindowBackgroundColor(napi_env env,
|
||||
TAG_LOGD(AAFwkTag::UI_EXT, "called");
|
||||
CHECK_IS_SYSTEM_APP;
|
||||
std::string color;
|
||||
if (info.argc < ARGC_ONE || !ConvertFromJsValue(env, info.argv[INDEX_ZERO], color)) {
|
||||
if (info.argc < ARGC_ONE) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "Not enough params.");
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], color)) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "invalid param");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parameter error: Parse color failed! Color must be a string.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -772,9 +807,15 @@ napi_value JsUIExtensionContentSession::OnSetWindowPrivacyMode(napi_env env, Nap
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::UI_EXT, "called");
|
||||
bool isPrivacyMode = false;
|
||||
if (info.argc < ARGC_ONE || !ConvertFromJsValue(env, info.argv[INDEX_ZERO], isPrivacyMode)) {
|
||||
if (info.argc < ARGC_ONE) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "Not enough params.");
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], isPrivacyMode)) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "invalid param");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
ThrowInvalidParamError(env, "Parameter error: Failed to parse isPrivacyMode! IsPrivacyMode must be a boolean.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
auto selfToken = IPCSkeleton::GetSelfTokenID();
|
||||
@@ -808,16 +849,13 @@ napi_value JsUIExtensionContentSession::OnSetWindowPrivacyMode(napi_env env, Nap
|
||||
napi_value JsUIExtensionContentSession::OnStartAbilityByType(napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::UI_EXT, "called");
|
||||
if (info.argc < ARGC_THREE) {
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
|
||||
std::string type;
|
||||
AAFwk::WantParams wantParam;
|
||||
if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], type) ||
|
||||
!AppExecFwk::UnwrapWantParams(env, info.argv[INDEX_ONE], wantParam)) {
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
|
||||
bool checkResult = CheckStartAbilityByTypeParam(env, info, type, wantParam);
|
||||
if (!checkResult) {
|
||||
TAG_LOGI(AAFwkTag::UI_EXT, "check startAbilityByCall param failed.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@@ -860,6 +898,32 @@ napi_value JsUIExtensionContentSession::OnStartAbilityByType(napi_env env, NapiC
|
||||
return result;
|
||||
}
|
||||
|
||||
bool JsUIExtensionContentSession::CheckStartAbilityByTypeParam(napi_env env,
|
||||
NapiCallbackInfo& info, std::string type, AAFwk::WantParams wantParam)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::UI_EXT, "start");
|
||||
|
||||
if (info.argc < ARGC_THREE) {
|
||||
TAG_LOGW(AAFwkTag::UI_EXT, "Not enough params.");
|
||||
ThrowTooFewParametersError(env);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], type)) {
|
||||
TAG_LOGW(AAFwkTag::UI_EXT, "Failed to parse type!");
|
||||
ThrowInvalidParamError(env, "Parameter error: Failed to parse type! Type must be a string.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!AppExecFwk::UnwrapWantParams(env, info.argv[INDEX_ONE], wantParam)) {
|
||||
TAG_LOGW(AAFwkTag::UI_EXT, "Failed to parse wantParam");
|
||||
ThrowInvalidParamError(env, "Parameter error: Failed to parse wantParam, must be a Record<string, Object>.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
napi_value JsUIExtensionContentSession::CreateJsUIExtensionContentSession(napi_env env,
|
||||
sptr<AAFwk::SessionInfo> sessionInfo, sptr<Rosen::Window> uiWindow,
|
||||
std::weak_ptr<AbilityRuntime::Context> context,
|
||||
|
||||
@@ -64,8 +64,6 @@ config("appkit_public_config") {
|
||||
]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
include_dirs += []
|
||||
|
||||
defines = [
|
||||
"SUPPORT_GRAPHICS",
|
||||
"SUPPORT_APP_PREFERRED_LANGUAGE",
|
||||
@@ -195,7 +193,6 @@ ohos_shared_library("appkit_native") {
|
||||
public_external_deps = [ "ability_base:configuration" ]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
deps += []
|
||||
external_deps += [
|
||||
"ace_engine:ace_forward_compatibility",
|
||||
"graphic_2d:librender_service_client",
|
||||
@@ -272,6 +269,7 @@ ohos_shared_library("app_context") {
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
"napi:ace_napi",
|
||||
@@ -281,7 +279,6 @@ ohos_shared_library("app_context") {
|
||||
public_external_deps = [ "ability_base:configuration" ]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
deps += []
|
||||
external_deps += [
|
||||
"i18n:intl_util",
|
||||
"icu:shared_icuuc",
|
||||
@@ -333,6 +330,7 @@ ohos_shared_library("app_context_utils") {
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_core",
|
||||
"napi:ace_napi",
|
||||
"resource_management:global_resmgr",
|
||||
@@ -340,7 +338,6 @@ ohos_shared_library("app_context_utils") {
|
||||
]
|
||||
public_external_deps = [ "ability_base:configuration" ]
|
||||
if (ability_runtime_graphics) {
|
||||
deps += []
|
||||
external_deps += [
|
||||
"i18n:intl_util",
|
||||
"icu:shared_icuuc",
|
||||
@@ -405,7 +402,6 @@ ohos_shared_library("appkit_delegator") {
|
||||
]
|
||||
public_external_deps = [ "ability_base:configuration" ]
|
||||
if (ability_runtime_graphics) {
|
||||
deps += []
|
||||
external_deps += [ "icu:shared_icuuc" ]
|
||||
}
|
||||
|
||||
@@ -452,7 +448,6 @@ ohos_shared_library("appkit_manager_helper") {
|
||||
]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
deps += []
|
||||
external_deps += [ "icu:shared_icuuc" ]
|
||||
}
|
||||
|
||||
|
||||
@@ -185,6 +185,7 @@ ErrCode BundleMgrHelper::GetSandboxHapModuleInfo(const AbilityInfo &abilityInfo,
|
||||
|
||||
sptr<IBundleMgr> BundleMgrHelper::Connect()
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called.");
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (bundleMgr_ == nullptr) {
|
||||
|
||||
@@ -48,6 +48,8 @@ constexpr const char* EXCLUDE_FROM_AUTO_START = "excludeFromAutoStart";
|
||||
constexpr const char* RUN_ON_THREAD = "runOnThread";
|
||||
constexpr const char* WAIT_ON_MAIN_THREAD = "waitOnMainThread";
|
||||
constexpr const char* CONFIG_ENTRY = "configEntry";
|
||||
constexpr const char *MAIN_THREAD = "mainThread";
|
||||
constexpr const char *TASKPOOL = "taskpool";
|
||||
|
||||
napi_value AttachAbilityStageContext(napi_env env, void *value, void *)
|
||||
{
|
||||
@@ -569,8 +571,16 @@ void JsAbilityStage::SetOptionalParameters(
|
||||
jsStartupTask.SetIsExcludeFromAutoStart(false);
|
||||
}
|
||||
|
||||
// always true
|
||||
jsStartupTask.SetCallCreateOnMainThread(true);
|
||||
if (module.contains(RUN_ON_THREAD) && module[RUN_ON_THREAD].is_string()) {
|
||||
std::string profileName = module.at(RUN_ON_THREAD).get<std::string>();
|
||||
if (profileName == MAIN_THREAD) {
|
||||
jsStartupTask.SetCallCreateOnMainThread(true);
|
||||
} else if (profileName == TASKPOOL) {
|
||||
jsStartupTask.SetCallCreateOnMainThread(false);
|
||||
} else {
|
||||
TAG_LOGW(AAFwkTag::APPKIT, "RunOnThread configuration is invalid.");
|
||||
}
|
||||
}
|
||||
|
||||
if (module.contains(WAIT_ON_MAIN_THREAD) && module[WAIT_ON_MAIN_THREAD].is_boolean()) {
|
||||
jsStartupTask.SetWaitOnMainThread(module.at(WAIT_ON_MAIN_THREAD).get<bool>());
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "configuration_convertor.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "running_process_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "file_ex.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "ipc_singleton.h"
|
||||
#include "js_runtime_utils.h"
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
@@ -366,6 +367,7 @@ std::shared_ptr<Context> ContextImpl::CreateModuleContext(const std::string &mod
|
||||
|
||||
std::shared_ptr<Context> ContextImpl::CreateModuleContext(const std::string &bundleName, const std::string &moduleName)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "begin.");
|
||||
if (bundleName.empty() || moduleName.empty()) {
|
||||
return nullptr;
|
||||
@@ -608,6 +610,7 @@ std::string ContextImpl::GetBaseDir() const
|
||||
|
||||
int ContextImpl::GetCurrentAccountId() const
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
int userId = 0;
|
||||
auto instance = DelayedSingleton<AppExecFwk::OsAccountManagerWrapper>::GetInstance();
|
||||
if (instance == nullptr) {
|
||||
@@ -620,6 +623,7 @@ int ContextImpl::GetCurrentAccountId() const
|
||||
|
||||
int ContextImpl::GetCurrentActiveAccountId() const
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
std::vector<int> accountIds;
|
||||
auto instance = DelayedSingleton<AppExecFwk::OsAccountManagerWrapper>::GetInstance();
|
||||
if (instance == nullptr) {
|
||||
@@ -647,6 +651,7 @@ int ContextImpl::GetCurrentActiveAccountId() const
|
||||
|
||||
std::shared_ptr<Context> ContextImpl::CreateBundleContext(const std::string &bundleName)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "begin.");
|
||||
if (parentContext_ != nullptr) {
|
||||
return parentContext_->CreateBundleContext(bundleName);
|
||||
@@ -670,6 +675,7 @@ std::shared_ptr<Context> ContextImpl::CreateBundleContext(const std::string &bun
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "length: %{public}zu, bundleName: %{public}s",
|
||||
(size_t)bundleName.length(), bundleName.c_str());
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, "bundleMgr_->GetBundleInfo");
|
||||
bundleMgr_->GetBundleInfo(bundleName, AppExecFwk::BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, accountId);
|
||||
|
||||
if (bundleInfo.name.empty() || bundleInfo.applicationInfo.name.empty()) {
|
||||
@@ -690,6 +696,7 @@ std::shared_ptr<Context> ContextImpl::CreateBundleContext(const std::string &bun
|
||||
void ContextImpl::InitResourceManager(const AppExecFwk::BundleInfo &bundleInfo,
|
||||
const std::shared_ptr<ContextImpl> &appContext, bool currentBundle, const std::string& moduleName)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "begin, bundleName:%{public}s, moduleName:%{public}s",
|
||||
bundleInfo.name.c_str(), moduleName.c_str());
|
||||
|
||||
@@ -722,6 +729,7 @@ void ContextImpl::InitResourceManager(const AppExecFwk::BundleInfo &bundleInfo,
|
||||
std::shared_ptr<Global::Resource::ResourceManager> ContextImpl::InitOthersResourceManagerInner(
|
||||
const AppExecFwk::BundleInfo &bundleInfo, bool currentBundle, const std::string& moduleName)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
std::unique_ptr<Global::Resource::ResConfig> resConfig(Global::Resource::CreateResConfig());
|
||||
std::string hapPath;
|
||||
std::vector<std::string> overlayPaths;
|
||||
@@ -741,6 +749,7 @@ std::shared_ptr<Global::Resource::ResourceManager> ContextImpl::InitOthersResour
|
||||
std::shared_ptr<Global::Resource::ResourceManager> ContextImpl::InitResourceManagerInner(
|
||||
const AppExecFwk::BundleInfo &bundleInfo, bool currentBundle, const std::string& moduleName)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
std::shared_ptr<Global::Resource::ResourceManager> resourceManager = InitOthersResourceManagerInner(
|
||||
bundleInfo, currentBundle, moduleName);
|
||||
if (resourceManager == nullptr) {
|
||||
@@ -753,71 +762,75 @@ std::shared_ptr<Global::Resource::ResourceManager> ContextImpl::InitResourceMana
|
||||
std::regex outer_pattern(ABS_CODE_PATH);
|
||||
std::regex hsp_pattern(std::string(ABS_CODE_PATH) + FILE_SEPARATOR + bundleInfo.name + PATTERN_VERSION);
|
||||
std::string hsp_sandbox = std::string(LOCAL_CODE_PATH) + FILE_SEPARATOR + bundleInfo.name + FILE_SEPARATOR;
|
||||
for (auto hapModuleInfo : bundleInfo.hapModuleInfos) {
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "hapModuleInfo abilityInfo size: %{public}zu",
|
||||
hapModuleInfo.abilityInfos.size());
|
||||
if (!moduleName.empty() && hapModuleInfo.moduleName != moduleName) {
|
||||
continue;
|
||||
}
|
||||
std::string loadPath = hapModuleInfo.hapPath.empty() ? hapModuleInfo.resourcePath : hapModuleInfo.hapPath;
|
||||
if (loadPath.empty()) {
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "loadPath is empty");
|
||||
continue;
|
||||
}
|
||||
if (currentBundle) {
|
||||
loadPath = std::regex_replace(loadPath, inner_pattern, LOCAL_CODE_PATH);
|
||||
} else if (bundleInfo.applicationInfo.bundleType == AppExecFwk::BundleType::SHARED) {
|
||||
loadPath = std::regex_replace(loadPath, hsp_pattern, hsp_sandbox);
|
||||
} else if (bundleInfo.applicationInfo.bundleType == AppExecFwk::BundleType::APP_SERVICE_FWK) {
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "System hsp path, not need translate.");
|
||||
} else {
|
||||
loadPath = std::regex_replace(loadPath, outer_pattern, LOCAL_BUNDLES);
|
||||
}
|
||||
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "loadPath: %{public}s", loadPath.c_str());
|
||||
// getOverlayPath
|
||||
std::vector<AppExecFwk::OverlayModuleInfo> overlayModuleInfos;
|
||||
auto res = GetOverlayModuleInfos(bundleInfo.name, hapModuleInfo.moduleName, overlayModuleInfos);
|
||||
if (res != ERR_OK) {
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "Get overlay paths from bms failed.");
|
||||
}
|
||||
if (overlayModuleInfos.size() == 0) {
|
||||
if (!resourceManager->AddResource(loadPath.c_str())) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "AddResource fail, moduleResPath: %{public}s", loadPath.c_str());
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, "for (auto hapModuleInfo : bundleInfo.hapModuleInfos)");
|
||||
for (auto hapModuleInfo : bundleInfo.hapModuleInfos) {
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "hapModuleInfo abilityInfo size: %{public}zu",
|
||||
hapModuleInfo.abilityInfos.size());
|
||||
if (!moduleName.empty() && hapModuleInfo.moduleName != moduleName) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
std::vector<std::string> overlayPaths;
|
||||
for (auto it : overlayModuleInfos) {
|
||||
if (std::regex_search(it.hapPath, std::regex(GetBundleName()))) {
|
||||
it.hapPath = std::regex_replace(it.hapPath, inner_pattern, LOCAL_CODE_PATH);
|
||||
} else {
|
||||
it.hapPath = std::regex_replace(it.hapPath, outer_pattern, LOCAL_BUNDLES);
|
||||
}
|
||||
if (it.state == AppExecFwk::OverlayState::OVERLAY_ENABLE) {
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "hapPath: %{public}s", it.hapPath.c_str());
|
||||
overlayPaths.emplace_back(it.hapPath);
|
||||
}
|
||||
std::string loadPath =
|
||||
hapModuleInfo.hapPath.empty() ? hapModuleInfo.resourcePath : hapModuleInfo.hapPath;
|
||||
if (loadPath.empty()) {
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "loadPath is empty");
|
||||
continue;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "OverlayPaths size:%{public}zu.", overlayPaths.size());
|
||||
if (!resourceManager->AddResource(loadPath, overlayPaths)) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "AddResource failed");
|
||||
}
|
||||
|
||||
if (currentBundle) {
|
||||
// add listen overlay change
|
||||
overlayModuleInfos_ = overlayModuleInfos;
|
||||
EventFwk::MatchingSkills matchingSkills;
|
||||
matchingSkills.AddEvent(OVERLAY_STATE_CHANGED);
|
||||
EventFwk::CommonEventSubscribeInfo subscribeInfo(matchingSkills);
|
||||
subscribeInfo.SetThreadMode(EventFwk::CommonEventSubscribeInfo::COMMON);
|
||||
auto callback = [this, resourceManager, bundleName = bundleInfo.name, moduleName =
|
||||
hapModuleInfo.moduleName, loadPath](const EventFwk::CommonEventData &data) {
|
||||
TAG_LOGI(AAFwkTag::APPKIT, "On overlay changed.");
|
||||
this->OnOverlayChanged(data, resourceManager, bundleName, moduleName, loadPath);
|
||||
};
|
||||
auto subscriber = std::make_shared<AppExecFwk::OverlayEventSubscriber>(subscribeInfo, callback);
|
||||
bool subResult = EventFwk::CommonEventManager::SubscribeCommonEvent(subscriber);
|
||||
TAG_LOGI(AAFwkTag::APPKIT, "Overlay event subscriber register result is %{public}d", subResult);
|
||||
loadPath = std::regex_replace(loadPath, inner_pattern, LOCAL_CODE_PATH);
|
||||
} else if (bundleInfo.applicationInfo.bundleType == AppExecFwk::BundleType::SHARED) {
|
||||
loadPath = std::regex_replace(loadPath, hsp_pattern, hsp_sandbox);
|
||||
} else if (bundleInfo.applicationInfo.bundleType == AppExecFwk::BundleType::APP_SERVICE_FWK) {
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "System hsp path, not need translate.");
|
||||
} else {
|
||||
loadPath = std::regex_replace(loadPath, outer_pattern, LOCAL_BUNDLES);
|
||||
}
|
||||
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "loadPath: %{public}s", loadPath.c_str());
|
||||
// getOverlayPath
|
||||
std::vector<AppExecFwk::OverlayModuleInfo> overlayModuleInfos;
|
||||
auto res = GetOverlayModuleInfos(bundleInfo.name, hapModuleInfo.moduleName, overlayModuleInfos);
|
||||
if (res != ERR_OK) {
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "Get overlay paths from bms failed.");
|
||||
}
|
||||
if (overlayModuleInfos.size() == 0) {
|
||||
if (!resourceManager->AddResource(loadPath.c_str())) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "AddResource fail, moduleResPath: %{public}s", loadPath.c_str());
|
||||
}
|
||||
} else {
|
||||
std::vector<std::string> overlayPaths;
|
||||
for (auto it : overlayModuleInfos) {
|
||||
if (std::regex_search(it.hapPath, std::regex(GetBundleName()))) {
|
||||
it.hapPath = std::regex_replace(it.hapPath, inner_pattern, LOCAL_CODE_PATH);
|
||||
} else {
|
||||
it.hapPath = std::regex_replace(it.hapPath, outer_pattern, LOCAL_BUNDLES);
|
||||
}
|
||||
if (it.state == AppExecFwk::OverlayState::OVERLAY_ENABLE) {
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "hapPath: %{public}s", it.hapPath.c_str());
|
||||
overlayPaths.emplace_back(it.hapPath);
|
||||
}
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "OverlayPaths size:%{public}zu.", overlayPaths.size());
|
||||
if (!resourceManager->AddResource(loadPath, overlayPaths)) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "AddResource failed");
|
||||
}
|
||||
|
||||
if (currentBundle) {
|
||||
// add listen overlay change
|
||||
overlayModuleInfos_ = overlayModuleInfos;
|
||||
EventFwk::MatchingSkills matchingSkills;
|
||||
matchingSkills.AddEvent(OVERLAY_STATE_CHANGED);
|
||||
EventFwk::CommonEventSubscribeInfo subscribeInfo(matchingSkills);
|
||||
subscribeInfo.SetThreadMode(EventFwk::CommonEventSubscribeInfo::COMMON);
|
||||
auto callback = [this, resourceManager, bundleName = bundleInfo.name, moduleName =
|
||||
hapModuleInfo.moduleName, loadPath](const EventFwk::CommonEventData &data) {
|
||||
TAG_LOGI(AAFwkTag::APPKIT, "On overlay changed.");
|
||||
this->OnOverlayChanged(data, resourceManager, bundleName, moduleName, loadPath);
|
||||
};
|
||||
auto subscriber = std::make_shared<AppExecFwk::OverlayEventSubscriber>(subscribeInfo, callback);
|
||||
bool subResult = EventFwk::CommonEventManager::SubscribeCommonEvent(subscriber);
|
||||
TAG_LOGI(AAFwkTag::APPKIT, "Overlay event subscriber register result is %{public}d", subResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -827,6 +840,7 @@ std::shared_ptr<Global::Resource::ResourceManager> ContextImpl::InitResourceMana
|
||||
|
||||
void ContextImpl::UpdateResConfig(std::shared_ptr<Global::Resource::ResourceManager> &resourceManager)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
std::unique_ptr<Global::Resource::ResConfig> resConfig(Global::Resource::CreateResConfig());
|
||||
if (resConfig == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "create ResConfig failed");
|
||||
@@ -866,6 +880,7 @@ void ContextImpl::UpdateResConfig(std::shared_ptr<Global::Resource::ResourceMana
|
||||
|
||||
ErrCode ContextImpl::GetBundleManager()
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
std::lock_guard<std::mutex> lock(bundleManagerMutex_);
|
||||
if (bundleMgr_ != nullptr && !resetFlag_) {
|
||||
return ERR_OK;
|
||||
@@ -1059,6 +1074,7 @@ Global::Resource::DeviceType ContextImpl::GetDeviceType() const
|
||||
|
||||
ErrCode ContextImpl::GetOverlayMgrProxy()
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
int errCode = GetBundleManager();
|
||||
if (errCode != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "failed, errCode: %{public}d.", errCode);
|
||||
@@ -1083,16 +1099,19 @@ ErrCode ContextImpl::GetOverlayMgrProxy()
|
||||
int ContextImpl::GetOverlayModuleInfos(const std::string &bundleName, const std::string &moduleName,
|
||||
std::vector<AppExecFwk::OverlayModuleInfo> &overlayModuleInfos)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
int errCode = GetOverlayMgrProxy();
|
||||
if (errCode != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "failed, errCode: %{public}d.", errCode);
|
||||
return errCode;
|
||||
}
|
||||
|
||||
auto ret = overlayMgrProxy_->GetTargetOverlayModuleInfo(moduleName, overlayModuleInfos);
|
||||
if (ret != ERR_OK) {
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "GetOverlayModuleInfo form bms failed.");
|
||||
return ret;
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, "overlayMgrProxy_->GetTargetOverlayModuleInfo");
|
||||
auto ret = overlayMgrProxy_->GetTargetOverlayModuleInfo(moduleName, overlayModuleInfos);
|
||||
if (ret != ERR_OK) {
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "GetOverlayModuleInfo form bms failed.");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
std::sort(overlayModuleInfos.begin(), overlayModuleInfos.end(),
|
||||
[](const AppExecFwk::OverlayModuleInfo& lhs, const AppExecFwk::OverlayModuleInfo& rhs) -> bool {
|
||||
@@ -1105,6 +1124,7 @@ int ContextImpl::GetOverlayModuleInfos(const std::string &bundleName, const std:
|
||||
std::vector<std::string> ContextImpl::GetAddOverlayPaths(
|
||||
const std::vector<AppExecFwk::OverlayModuleInfo> &overlayModuleInfos)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
std::vector<std::string> addPaths;
|
||||
for (auto it : overlayModuleInfos) {
|
||||
auto iter = std::find_if(
|
||||
@@ -1125,6 +1145,7 @@ std::vector<std::string> ContextImpl::GetAddOverlayPaths(
|
||||
std::vector<std::string> ContextImpl::GetRemoveOverlayPaths(
|
||||
const std::vector<AppExecFwk::OverlayModuleInfo> &overlayModuleInfos)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
std::vector<std::string> removePaths;
|
||||
for (auto it : overlayModuleInfos) {
|
||||
auto iter = std::find_if(
|
||||
@@ -1146,6 +1167,7 @@ void ContextImpl::OnOverlayChanged(const EventFwk::CommonEventData &data,
|
||||
const std::shared_ptr<Global::Resource::ResourceManager> &resourceManager, const std::string &bundleName,
|
||||
const std::string &moduleName, const std::string &loadPath)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "begin.");
|
||||
auto want = data.GetWant();
|
||||
std::string action = want.GetAction();
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "js_data_struct_converter.h"
|
||||
#include "js_runtime_utils.h"
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "form_mgr_errors.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
@@ -48,6 +49,7 @@ int FormExtensionContext::UpdateForm(const int64_t formId, const AppExecFwk::For
|
||||
}
|
||||
|
||||
// update form request to fms
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, "AppExecFwk::FormMgr::GetInstance().UpdateForm");
|
||||
return AppExecFwk::FormMgr::GetInstance().UpdateForm(formId, formProviderData);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "ability_manager.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "singleton.h"
|
||||
#include "sys_mgr_client.h"
|
||||
#include "system_ability_definition.h"
|
||||
@@ -52,6 +53,7 @@ int32_t AbilityManager::ClearUpApplicationData(const std::string &bundleName)
|
||||
|
||||
std::vector<RunningProcessInfo> AbilityManager::GetAllRunningProcesses()
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "%s, %d", __func__, __LINE__);
|
||||
auto object = OHOS::DelayedSingleton<SysMrgClient>::GetInstance()->GetSystemAbility(APP_MGR_SERVICE_ID);
|
||||
sptr<IAppMgr> appMgr_ = iface_cast<IAppMgr>(object);
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "ohos_application.h"
|
||||
#include "uri_permission_manager_client.h"
|
||||
|
||||
@@ -159,6 +160,7 @@ void ApplicationImpl::PerformMemoryLevel(int level)
|
||||
*/
|
||||
void ApplicationImpl::PerformConfigurationUpdated(const Configuration &config)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "called");
|
||||
if (application_ != nullptr) {
|
||||
application_->OnConfigurationUpdated(config);
|
||||
|
||||
@@ -152,6 +152,15 @@ void ChildMainThread::HandleLoadJs()
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "Failed to create child process runtime");
|
||||
return;
|
||||
}
|
||||
AbilityRuntime::Runtime::DebugOption debugOption;
|
||||
debugOption.isStartWithDebug = processInfo_->isStartWithDebug;
|
||||
debugOption.processName = processInfo_->processName;
|
||||
debugOption.isDebugApp = processInfo_->isDebugApp;
|
||||
debugOption.isStartWithNative = processInfo_->isStartWithNative;
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "StartDebugMode, isStartWithDebug is %{public}d, processName is %{public}s, "
|
||||
"isDebugApp is %{public}d, isStartWithNative is %{public}d.", processInfo_->isStartWithDebug,
|
||||
processInfo_->processName.c_str(), processInfo_->isDebugApp, processInfo_->isStartWithNative);
|
||||
runtime_->StartDebugMode(debugOption);
|
||||
childProcessManager.LoadJsFile(processInfo_->srcEntry, hapModuleInfo, runtime_);
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "ChildMainThread::HandleLoadJs end.");
|
||||
ExitProcessSafely();
|
||||
|
||||
@@ -825,6 +825,7 @@ void MainThread::ScheduleProfileChanged(const Profile &profile)
|
||||
*/
|
||||
void MainThread::ScheduleConfigurationUpdated(const Configuration &config)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "called");
|
||||
wptr<MainThread> weak = this;
|
||||
auto task = [weak, config]() {
|
||||
@@ -1378,8 +1379,16 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
|
||||
options.uid = bundleInfo.applicationInfo.uid;
|
||||
options.apiTargetVersion = appInfo.apiTargetVersion;
|
||||
options.pkgContextInfoJsonStringMap = pkgContextInfoJsonStringMap;
|
||||
if (applicationInfo_->appProvisionType == Constants::APP_PROVISION_TYPE_DEBUG) {
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Start Multi-Thread Mode: %{public}d.", appLaunchData.GetMultiThread());
|
||||
options.isMultiThread = appLaunchData.GetMultiThread();
|
||||
}
|
||||
options.jitEnabled = appLaunchData.IsJITEnabled();
|
||||
AbilityRuntime::ChildProcessManager::GetInstance().SetForkProcessJITEnabled(appLaunchData.IsJITEnabled());
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "isStartWithDebug:%{public}d, debug:%{public}d, isNativeStart:%{public}d",
|
||||
appLaunchData.GetDebugApp(), appInfo.debug, appLaunchData.isNativeStart());
|
||||
AbilityRuntime::ChildProcessManager::GetInstance().SetForkProcessDebugOption(appInfo.bundleName,
|
||||
appLaunchData.GetDebugApp(), appInfo.debug, appLaunchData.isNativeStart());
|
||||
if (!bundleInfo.hapModuleInfos.empty()) {
|
||||
for (auto hapModuleInfo : bundleInfo.hapModuleInfos) {
|
||||
options.hapModulePath[hapModuleInfo.moduleName] = hapModuleInfo.hapPath;
|
||||
|
||||
@@ -428,6 +428,7 @@ void OHOSApplication::UnregisterElementsCallbacks(const std::shared_ptr<Elements
|
||||
*/
|
||||
void OHOSApplication::OnConfigurationUpdated(Configuration config)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "called");
|
||||
if (!abilityRecordMgr_ || !configuration_) {
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "abilityRecordMgr_ or configuration_ is null");
|
||||
@@ -487,8 +488,11 @@ void OHOSApplication::OnConfigurationUpdated(Configuration config)
|
||||
config.RemoveItem(AAFwk::GlobalConfigurationKey::COLORMODE_IS_SET_BY_SA);
|
||||
}
|
||||
std::vector<std::string> changeKeyV;
|
||||
configuration_->CompareDifferent(changeKeyV, config);
|
||||
configuration_->Merge(changeKeyV, config);
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, "configuration_->CompareDifferent");
|
||||
configuration_->CompareDifferent(changeKeyV, config);
|
||||
configuration_->Merge(changeKeyV, config);
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "configuration_: %{public}s", configuration_->GetName().c_str());
|
||||
|
||||
// Update resConfig of resource manager, which belongs to application context.
|
||||
|
||||
@@ -19,8 +19,13 @@
|
||||
#include "hilog_wrapper.h"
|
||||
#include "js_runtime_utils.h"
|
||||
|
||||
namespace {
|
||||
constexpr size_t ARGC_ONE = 1;
|
||||
constexpr int32_t INDEX_ZERO = 0;
|
||||
}
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
std::map<std::string, std::weak_ptr<StartupTask>> AsyncTaskCallBack::jsStartupTaskObjects_;
|
||||
JsStartupTask::JsStartupTask(const std::string &name, JsRuntime &jsRuntime,
|
||||
std::unique_ptr<NativeReference> &startupJsRef, std::shared_ptr<NativeReference> &contextJsRef)
|
||||
: StartupTask(name), jsRuntime_(jsRuntime), startupJsRef_(std::move(startupJsRef)), contextJsRef_(contextJsRef) {}
|
||||
@@ -52,8 +57,77 @@ int32_t JsStartupTask::RunTaskInit(std::unique_ptr<StartupTaskResultCallback> ca
|
||||
startupTask->SaveResult(result);
|
||||
startupTask->CallExtraCallback(result);
|
||||
});
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "%{public}s, RunOnMainThread", name_.c_str());
|
||||
return JsStartupTaskExecutor::RunOnMainThread(jsRuntime_, startupJsRef_, contextJsRef_, std::move(callback));
|
||||
|
||||
if (callCreateOnMainThread_) {
|
||||
return JsStartupTaskExecutor::RunOnMainThread(jsRuntime_, startupJsRef_, contextJsRef_, std::move(callback));
|
||||
}
|
||||
|
||||
if (LoadJsAsyncTaskExcutor() != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "Load async task excutor is failed.");
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
LoadJsAsyncTaskCallback();
|
||||
|
||||
startupTaskResultCallback_ = std::move(callback);
|
||||
|
||||
auto startupName = GetName();
|
||||
auto result = JsStartupTaskExecutor::RunOnTaskPool(
|
||||
jsRuntime_, startupJsRef_, contextJsRef_, AsyncTaskExcutorJsRef_, AsyncTaskExcutorCallbackJsRef_, startupName);
|
||||
if (result == ERR_OK) {
|
||||
AsyncTaskCallBack::jsStartupTaskObjects_.emplace(startupName, shared_from_this());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t JsStartupTask::LoadJsAsyncTaskExcutor()
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "Called.");
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
auto env = jsRuntime_.GetNapiEnv();
|
||||
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
if (object == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "Object is nullptr.");
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
AsyncTaskExcutorJsRef_ =
|
||||
JsRuntime::LoadSystemModuleByEngine(env, "app.appstartup.AsyncTaskExcutor", &object, 1);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
void JsStartupTask::LoadJsAsyncTaskCallback()
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "Called.");
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
auto env = jsRuntime_.GetNapiEnv();
|
||||
|
||||
napi_value config;
|
||||
std::string value = "This is callback value";
|
||||
NAPI_CALL_RETURN_VOID(
|
||||
env, napi_create_string_utf8(env, value.c_str(), value.length(), &config));
|
||||
|
||||
napi_property_descriptor props[] = {
|
||||
DECLARE_NAPI_STATIC_FUNCTION("onAsyncTaskCompleted", AsyncTaskCallBack::AsyncTaskCompleted),
|
||||
DECLARE_NAPI_INSTANCE_PROPERTY("config", config),
|
||||
};
|
||||
napi_value asyncTaskCallbackClass = nullptr;
|
||||
napi_define_sendable_class(env, "AsyncTaskCallback", NAPI_AUTO_LENGTH, AsyncTaskCallBack::Constructor,
|
||||
nullptr, sizeof(props) / sizeof(props[0]), props, nullptr, &asyncTaskCallbackClass);
|
||||
AsyncTaskExcutorCallbackJsRef_ =
|
||||
JsRuntime::LoadSystemModuleByEngine(env, "app.appstartup.AsyncTaskCallback", &asyncTaskCallbackClass, 1);
|
||||
}
|
||||
|
||||
void JsStartupTask::OnAsyncTaskCompleted()
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "Called.");
|
||||
if (startupTaskResultCallback_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "Startup task result callback object is nullptr.");
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<StartupTaskResult> result = std::make_shared<JsStartupTaskResult>(nullptr);
|
||||
startupTaskResultCallback_->Call(result);
|
||||
}
|
||||
|
||||
int32_t JsStartupTask::RunTaskOnDependencyCompleted(const std::string &dependencyName,
|
||||
@@ -111,5 +185,40 @@ napi_value JsStartupTask::GetDependencyResult(napi_env env, const std::string &d
|
||||
return jsResultRef->GetNapiValue();
|
||||
}
|
||||
}
|
||||
|
||||
napi_value AsyncTaskCallBack::AsyncTaskCompleted(napi_env env, napi_callback_info info)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "Called.");
|
||||
size_t argc = ARGC_ONE;
|
||||
napi_value argv[ARGC_ONE] = { nullptr };
|
||||
napi_value thisVar = nullptr;
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, nullptr));
|
||||
|
||||
std::string startupName;
|
||||
if (!ConvertFromJsValue(env, argv[INDEX_ZERO], startupName)) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "Convert from js startupName error.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
std::shared_ptr<StartupTask> startupTask;
|
||||
for (auto iter : AsyncTaskCallBack::jsStartupTaskObjects_) {
|
||||
if (iter.first == startupName) {
|
||||
startupTask = iter.second.lock();
|
||||
}
|
||||
}
|
||||
|
||||
if (startupTask != nullptr) {
|
||||
startupTask->OnAsyncTaskCompleted();
|
||||
AsyncTaskCallBack::jsStartupTaskObjects_.erase(startupName);
|
||||
}
|
||||
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
napi_value AsyncTaskCallBack::Constructor(napi_env env, napi_callback_info cbinfo)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "Called.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -21,7 +21,9 @@
|
||||
#include "js_startup_task_result.h"
|
||||
|
||||
#define TMP_NAPI_ANONYMOUS_FUNC "_"
|
||||
|
||||
namespace {
|
||||
constexpr size_t ARGC_FOUR = 4;
|
||||
}
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
int32_t JsStartupTaskExecutor::RunOnMainThread(JsRuntime &jsRuntime,
|
||||
@@ -39,10 +41,43 @@ int32_t JsStartupTaskExecutor::RunOnMainThread(JsRuntime &jsRuntime,
|
||||
return HandleReturnVal(env, returnVal, callback);
|
||||
}
|
||||
|
||||
int32_t JsStartupTaskExecutor::RunOnTaskPool(JsRuntime &jsRuntime,
|
||||
const std::unique_ptr<NativeReference> &startup, const std::shared_ptr<NativeReference> &context,
|
||||
std::unique_ptr<StartupTaskResultCallback> callback)
|
||||
int32_t JsStartupTaskExecutor::RunOnTaskPool(
|
||||
JsRuntime &jsRuntime,
|
||||
const std::unique_ptr<NativeReference> &startup,
|
||||
const std::shared_ptr<NativeReference> &context,
|
||||
const std::unique_ptr<NativeReference> &asyncTaskExcutor,
|
||||
const std::unique_ptr<NativeReference> &asyncTaskCallback,
|
||||
const std::string &startupName)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::STARTUP, "Called.");
|
||||
HandleScope handleScope(jsRuntime);
|
||||
auto env = jsRuntime.GetNapiEnv();
|
||||
|
||||
if (startup == nullptr || context == nullptr || asyncTaskExcutor == nullptr || asyncTaskCallback == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "AsyncTaskExcutor or startup or context or async task callback is null.");
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
napi_value asyncTaskExcutorValue = asyncTaskExcutor->GetNapiValue();
|
||||
if (!CheckTypeForNapiValue(env, asyncTaskExcutorValue, napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "AsyncTaskExcutor is not napi object.");
|
||||
return ERR_STARTUP_INTERNAL_ERROR;
|
||||
}
|
||||
napi_value asyncPushTask = nullptr;
|
||||
napi_get_named_property(env, asyncTaskExcutorValue, "asyncPushTask", &asyncPushTask);
|
||||
if (asyncPushTask == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "Failed to get property asyncPushTask from AsyncTaskExcutor.");
|
||||
return ERR_STARTUP_FAILED_TO_EXECUTE_STARTUP;
|
||||
}
|
||||
bool isCallable = false;
|
||||
napi_is_callable(env, asyncPushTask, &isCallable);
|
||||
if (!isCallable) {
|
||||
TAG_LOGE(AAFwkTag::STARTUP, "AsyncPushTask is not callable.");
|
||||
return ERR_STARTUP_FAILED_TO_EXECUTE_STARTUP;
|
||||
}
|
||||
napi_value returnVal = nullptr;
|
||||
napi_value argv[] = { startup->GetNapiValue(), asyncTaskCallback->GetNapiValue(),
|
||||
context->GetNapiValue(), CreateJsValue(env, startupName) };
|
||||
napi_call_function(env, asyncTaskExcutorValue, asyncPushTask, ARGC_FOUR, argv, &returnVal);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@ const std::map<int32_t, std::string> ERR_MSG_MAP = {
|
||||
|
||||
std::string StartupUtils::GetErrorMessage(int32_t errCode)
|
||||
{
|
||||
std::string errMsg;
|
||||
auto iter = ERR_MSG_MAP.find(errCode);
|
||||
if (iter == ERR_MSG_MAP.end()) {
|
||||
return ERR_MSG_MAP.at(ERR_STARTUP_INTERNAL_ERROR);
|
||||
|
||||
@@ -54,6 +54,7 @@ Watchdog::~Watchdog()
|
||||
|
||||
void Watchdog::Init(const std::shared_ptr<EventHandler> mainHandler)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(cvMutex_);
|
||||
Watchdog::appMainHandler_ = mainHandler;
|
||||
if (appMainHandler_ != nullptr) {
|
||||
TAG_LOGD(AAFwkTag::APPDFR, "Watchdog init send event");
|
||||
@@ -85,6 +86,7 @@ void Watchdog::Stop()
|
||||
|
||||
void Watchdog::SetAppMainThreadState(const bool appMainThreadState)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(cvMutex_);
|
||||
appMainThreadIsAlive_.store(appMainThreadState);
|
||||
}
|
||||
|
||||
@@ -95,12 +97,14 @@ void Watchdog::SetBundleInfo(const std::string& bundleName, const std::string& b
|
||||
|
||||
void Watchdog::SetBackgroundStatus(const bool isInBackground)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(cvMutex_);
|
||||
isInBackground_.store(isInBackground);
|
||||
OHOS::HiviewDFX::Watchdog::GetInstance().SetForeground(!isInBackground);
|
||||
}
|
||||
|
||||
void Watchdog::AllowReportEvent()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(cvMutex_);
|
||||
needReport_.store(true);
|
||||
isSixSecondEvent_.store(false);
|
||||
backgroundReportCount_.store(0);
|
||||
@@ -118,6 +122,7 @@ bool Watchdog::IsReportEvent()
|
||||
|
||||
bool Watchdog::IsStopWatchdog()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(cvMutex_);
|
||||
return stopWatchdog_;
|
||||
}
|
||||
|
||||
|
||||
+25
-6
@@ -44,14 +44,15 @@ napi_value JsInsightIntentContext::OnStartAbility(napi_env env, NapiCallbackInfo
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::INTENT, "enter");
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
if (info.argc == 0) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "not enough args");
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
// unwrap want
|
||||
AAFwk::Want want;
|
||||
OHOS::AppExecFwk::UnwrapWant(env, info.argv[0], want);
|
||||
|
||||
bool checkParamResult = CheckStartAbilityParam(env, info, want);
|
||||
if (!checkParamResult) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "check startAbility param failed");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
auto context = context_.lock();
|
||||
if (context == nullptr) {
|
||||
@@ -116,5 +117,23 @@ napi_value CreateJsInsightIntentContext(napi_env env, const std::shared_ptr<Insi
|
||||
TAG_LOGD(AAFwkTag::INTENT, "end");
|
||||
return contextObj;
|
||||
}
|
||||
|
||||
bool CheckStartAbilityParam(napi_env env, NapiCallbackInfo& info, AAFwk::Want want)
|
||||
{
|
||||
if (info.argc == 0) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "not enough args");
|
||||
ThrowTooFewParametersError(env);
|
||||
return false;
|
||||
}
|
||||
|
||||
// unwrap want
|
||||
bool unwrapWantFlag = OHOS::AppExecFwk::UnwrapWant(env, info.argv[0], want);
|
||||
if (!unwrapWantFlag) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Failed to parse want.");
|
||||
ThrowInvalidParamError(env, "Parameter error: Failed to parse want, must be a Want.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -617,6 +617,10 @@ void JsRuntime::PostPreload(const Options& options)
|
||||
std::string sandBoxAnFilePath = SANDBOX_ARK_CACHE_PATH + options.arkNativeFilePath;
|
||||
postOption.SetAnDir(sandBoxAnFilePath);
|
||||
}
|
||||
if (options.isMultiThread) {
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Start Multi-Thread Mode: %{public}d.", options.isMultiThread);
|
||||
panda::JSNApi::SetMultiThreadCheck();
|
||||
}
|
||||
bool profileEnabled = OHOS::system::GetBoolParameter("ark.profile", false);
|
||||
postOption.SetEnableProfile(profileEnabled);
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "ASMM JIT Verify PostFork, jitEnabled: %{public}d", options.jitEnabled);
|
||||
@@ -792,6 +796,11 @@ bool JsRuntime::CreateJsEnv(const Options& options)
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "ASMM JIT Verify CreateJsEnv, jitEnabled: %{public}d", options.jitEnabled);
|
||||
pandaOption.SetEnableJIT(options.jitEnabled);
|
||||
|
||||
if (options.isMultiThread) {
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Start Multi Thread Mode: %{public}d.", options.isMultiThread);
|
||||
panda::JSNApi::SetMultiThreadCheck();
|
||||
}
|
||||
|
||||
if (IsUseAbilityRuntime(options)) {
|
||||
// aot related
|
||||
bool aotEnabled = OHOS::system::GetBoolParameter("persist.ark.aot", true);
|
||||
|
||||
@@ -105,10 +105,7 @@ ohos_shared_library("ability_simulator_inner") {
|
||||
|
||||
configs = [ "${windowmanager_path}/previewer:previewer_window_config" ]
|
||||
|
||||
deps = [
|
||||
":gen_obj_src_js_mock_abc",
|
||||
"//third_party/jsoncpp:jsoncpp_static",
|
||||
]
|
||||
deps = [ ":gen_obj_src_js_mock_abc" ]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:string_utils",
|
||||
@@ -116,6 +113,7 @@ ohos_shared_library("ability_simulator_inner") {
|
||||
"ets_utils:console",
|
||||
"ets_utils:timer",
|
||||
"hilog:libhilog",
|
||||
"jsoncpp:jsoncpp_static",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ struct DebuggerTask {
|
||||
std::function<void()> func;
|
||||
};
|
||||
|
||||
class SimulatorImpl : public Simulator {
|
||||
class SimulatorImpl : public Simulator, public std::enable_shared_from_this<SimulatorImpl> {
|
||||
public:
|
||||
SimulatorImpl() = default;
|
||||
~SimulatorImpl();
|
||||
@@ -124,6 +124,7 @@ private:
|
||||
panda::ecmascript::EcmaVM *vm_ = nullptr;
|
||||
DebuggerTask debuggerTask_;
|
||||
napi_env nativeEngine_ = nullptr;
|
||||
TerminateCallback terminateCallback_;
|
||||
|
||||
int64_t currentId_ = 0;
|
||||
std::unordered_map<int64_t, std::shared_ptr<NativeReference>> abilities_;
|
||||
@@ -357,6 +358,7 @@ int64_t SimulatorImpl::StartAbility(
|
||||
}
|
||||
|
||||
++currentId_;
|
||||
terminateCallback_ = callback;
|
||||
InitResourceMgr();
|
||||
InitJsAbilityContext(nativeEngine_, instanceValue);
|
||||
DispatchStartLifecycle(instanceValue);
|
||||
@@ -684,6 +686,20 @@ bool SimulatorImpl::OnInit()
|
||||
return false;
|
||||
}
|
||||
napi_env env = reinterpret_cast<napi_env>(nativeEngine);
|
||||
auto uncaughtTask = [weak = weak_from_this()](napi_value value) {
|
||||
TAG_LOGE(AAFwkTag::ABILITY_SIM, "uncaught exception");
|
||||
auto self = weak.lock();
|
||||
if (self == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITY_SIM, "SimulatorImpl is nullptr.");
|
||||
return;
|
||||
}
|
||||
if (self->terminateCallback_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITY_SIM, "terminateCallback is nullptr.");
|
||||
return;
|
||||
}
|
||||
self->terminateCallback_(self->currentId_);
|
||||
};
|
||||
nativeEngine->RegisterNapiUncaughtExceptionHandler(uncaughtTask);
|
||||
|
||||
napi_value globalObj;
|
||||
napi_get_global(env, &globalObj);
|
||||
|
||||
@@ -27,6 +27,8 @@ config("ability_manager_public_config") {
|
||||
"include/",
|
||||
"include/status_bar_delegate",
|
||||
"${ability_runtime_path}/interfaces/kits/native/ability/native",
|
||||
"${ability_runtime_path}/interfaces/kits/native/ability/native/continuation/kits",
|
||||
"${ability_runtime_path}/interfaces/kits/native/ability/native/continuation/distributed",
|
||||
"${bundlefwk_inner_api_path}/appexecfwk_base/include",
|
||||
"${ability_runtime_innerkits_path}/ability_manager/include",
|
||||
"${ability_runtime_innerkits_path}/app_manager/include/appmgr",
|
||||
@@ -150,6 +152,7 @@ ohos_shared_library("ability_manager") {
|
||||
"relational_store:native_rdb",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
public_external_deps = [
|
||||
"ability_base:configuration",
|
||||
"ability_base:want",
|
||||
|
||||
@@ -1451,6 +1451,15 @@ public:
|
||||
*/
|
||||
int32_t NotifyDebugAssertResult(uint64_t assertFaultSessionId, AAFwk::UserStatus userStatus);
|
||||
|
||||
/**
|
||||
* Set the enable status for starting and stopping resident processes.
|
||||
* The caller application can only set the resident status of the configured process.
|
||||
* @param bundleName The bundle name of the resident process.
|
||||
* @param enable Set resident process enable status.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
int32_t SetResidentProcessEnabled(const std::string &bundleName, bool enable);
|
||||
|
||||
/**
|
||||
* Starts a new ability with specific start options.
|
||||
*
|
||||
|
||||
@@ -499,6 +499,11 @@ enum {
|
||||
* Result(2097248) for get ExtensionName by uid fail.
|
||||
*/
|
||||
GET_EXTENSION_NAME_BY_UID_FAIL,
|
||||
|
||||
/**
|
||||
* Native error(2097249) no resident process permissions set.
|
||||
*/
|
||||
ERR_NO_RESIDENT_PERMISSION,
|
||||
};
|
||||
|
||||
enum {
|
||||
|
||||
@@ -1522,6 +1522,18 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the enable status for starting and stopping resident processes.
|
||||
* The caller application can only set the resident status of the configured process.
|
||||
* @param bundleName The bundle name of the resident process.
|
||||
* @param enable Set resident process enable status.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int32_t SetResidentProcessEnabled(const std::string &bundleName, bool enable)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Querying whether to allow embedded startup of atomic service.
|
||||
*
|
||||
|
||||
@@ -241,6 +241,9 @@ enum class AbilityManagerInterfaceCode {
|
||||
// Starts a new ability by shortcut.
|
||||
START_SHORTCUT = 79,
|
||||
|
||||
// Set resident process enable status.
|
||||
SET_RESIDENT_PROCESS_ENABLE = 80,
|
||||
|
||||
// ipc id 1001-2000 for DMS
|
||||
// ipc id for starting ability (1001)
|
||||
START_ABILITY = 1001,
|
||||
|
||||
@@ -285,6 +285,13 @@ public:
|
||||
*/
|
||||
virtual void SetAppAssertionPauseState(int32_t pid, bool flag) {}
|
||||
|
||||
/**
|
||||
* @brief Set resident process enable status.
|
||||
* @param bundleName The application bundle name.
|
||||
* @param enable The current updated enable status.
|
||||
*/
|
||||
virtual void SetKeepAliveEnableState(const std::string &bundleName, bool enable) {};
|
||||
|
||||
/**
|
||||
* To clear the process by ability token.
|
||||
*
|
||||
@@ -342,6 +349,7 @@ public:
|
||||
KILL_PROCESSES_BY_PIDS,
|
||||
ATTACH_PID_TO_PARENT,
|
||||
IS_MEMORY_SIZE_SUFFICIENT,
|
||||
SET_KEEP_ALIVE_ENABLE_STATE,
|
||||
};
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
|
||||
@@ -262,6 +262,13 @@ public:
|
||||
*/
|
||||
void SetAppAssertionPauseState(int32_t pid, bool flag) override;
|
||||
|
||||
/**
|
||||
* @brief Set resident process enable status.
|
||||
* @param bundleName The application bundle name.
|
||||
* @param enable The current updated enable status.
|
||||
*/
|
||||
void SetKeepAliveEnableState(const std::string &bundleName, bool enable) override;
|
||||
|
||||
/**
|
||||
* To clear the process by ability token.
|
||||
*
|
||||
|
||||
@@ -83,6 +83,7 @@ private:
|
||||
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);
|
||||
|
||||
using AmsMgrFunc = int32_t (AmsMgrStub::*)(MessageParcel &data, MessageParcel &reply);
|
||||
std::map<uint32_t, AmsMgrFunc> memberFuncMap_;
|
||||
|
||||
@@ -172,6 +172,16 @@ public:
|
||||
return perfCmd_;
|
||||
}
|
||||
|
||||
inline void SetMultiThread(const bool multiThread)
|
||||
{
|
||||
isMultiThread_ = multiThread;
|
||||
}
|
||||
|
||||
inline bool GetMultiThread() const
|
||||
{
|
||||
return isMultiThread_;
|
||||
}
|
||||
|
||||
inline void SetJITEnabled(const bool jitEnabled)
|
||||
{
|
||||
jitEnabled_ = jitEnabled;
|
||||
@@ -238,6 +248,7 @@ private:
|
||||
std::string perfCmd_;
|
||||
bool jitEnabled_ = false;
|
||||
bool isNativeStart_ = false;
|
||||
bool isMultiThread_ = false;
|
||||
std::string appRunningUniqueId_;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
|
||||
@@ -612,6 +612,13 @@ public:
|
||||
*/
|
||||
bool IsAttachDebug(const std::string &bundleName);
|
||||
|
||||
/**
|
||||
* @brief Set resident process enable status.
|
||||
* @param bundleName The application bundle name.
|
||||
* @param enable The current updated enable status.
|
||||
*/
|
||||
void SetKeepAliveEnableState(const std::string &bundleName, bool enable);
|
||||
|
||||
/**
|
||||
* Set application assertion pause state.
|
||||
*
|
||||
|
||||
@@ -143,6 +143,17 @@ public:
|
||||
*/
|
||||
virtual int GetAllRunningProcesses(std::vector<RunningProcessInfo> &info) = 0;
|
||||
|
||||
/**
|
||||
* GetRunningProcessesByBundleType, call GetRunningProcessesByBundleType() through proxy project.
|
||||
* Obtains information about application processes by bundle type that are running on the device.
|
||||
*
|
||||
* @param bundleType, bundle type of the processes
|
||||
* @param info, app name in Application record.
|
||||
* @return ERR_OK ,return back success,others fail.
|
||||
*/
|
||||
virtual int GetRunningProcessesByBundleType(const BundleType bundleType,
|
||||
std::vector<RunningProcessInfo> &info) = 0;
|
||||
|
||||
/**
|
||||
* GetAllRenderProcesses, call GetAllRenderProcesses() through proxy project.
|
||||
* Obtains information about render processes that are running on the device.
|
||||
@@ -539,7 +550,8 @@ public:
|
||||
* @param childPid Created child process pid.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int32_t StartChildProcess(const std::string &srcEntry, pid_t &childPid) = 0;
|
||||
virtual int32_t StartChildProcess(const std::string &srcEntry, pid_t &childPid, int32_t childProcessCount,
|
||||
bool isStartWithDebug) = 0;
|
||||
|
||||
/**
|
||||
* Get child process record for self.
|
||||
|
||||
@@ -98,6 +98,7 @@ enum class AppMgrInterfaceCode {
|
||||
NOTIFY_MEMORY_SIZE_STATE_CHANGED = 72,
|
||||
PRELOAD_APPLICATION = 73,
|
||||
SET_SUPPORTED_PROCESS_CACHE_SELF = 74,
|
||||
APP_GET_RUNNING_PROCESSES_BY_BUNDLE_TYPE = 75,
|
||||
};
|
||||
} // AppExecFwk
|
||||
} // OHOS
|
||||
|
||||
@@ -122,6 +122,17 @@ public:
|
||||
*/
|
||||
virtual int32_t GetAllRunningProcesses(std::vector<RunningProcessInfo> &info) override;
|
||||
|
||||
/**
|
||||
* GetRunningProcessesByBundleType, call GetRunningProcessesByBundleType() through proxy project.
|
||||
* Obtains information about application processes by bundle type that are running on the device.
|
||||
*
|
||||
* @param bundleType, bundle type of the processes
|
||||
* @param info, app name in Application record.
|
||||
* @return ERR_OK ,return back success,others fail.
|
||||
*/
|
||||
virtual int GetRunningProcessesByBundleType(const BundleType bundleType,
|
||||
std::vector<RunningProcessInfo> &info) override;
|
||||
|
||||
/**
|
||||
* GetAllRenderProcesses, call GetAllRenderProcesses() through proxy project.
|
||||
* Obtains information about render processes that are running on the device.
|
||||
@@ -476,7 +487,8 @@ public:
|
||||
* @param childPid Created child process pid.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
int32_t StartChildProcess(const std::string &srcEntry, pid_t &childPid) override;
|
||||
int32_t StartChildProcess(const std::string &srcEntry, pid_t &childPid, int32_t childProcessCount,
|
||||
bool isStartWithDebug) override;
|
||||
|
||||
/**
|
||||
* Get child process record for self.
|
||||
|
||||
@@ -65,6 +65,7 @@ private:
|
||||
int32_t HandleGetAmsMgr(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleClearUpApplicationData(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleGetAllRunningProcesses(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleGetRunningProcessesByBundleType(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleGetProcessRunningInfosByUserId(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleGetProcessRunningInformation(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleGetAllRenderProcesses(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
@@ -30,6 +30,9 @@ struct ChildProcessInfo : public Parcelable {
|
||||
std::string processName;
|
||||
std::string srcEntry;
|
||||
bool jitEnabled = false;
|
||||
bool isDebugApp = true;
|
||||
bool isStartWithDebug = false;
|
||||
bool isStartWithNative = false;
|
||||
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
|
||||
@@ -62,6 +62,7 @@ struct RunningProcessInfo : public Parcelable {
|
||||
bool isTestProcess = false;
|
||||
bool isAbilityForegrounding = false;
|
||||
bool isTestMode = false;
|
||||
std::int32_t bundleType = 0;
|
||||
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
|
||||
@@ -840,6 +840,31 @@ int32_t AmsMgrProxy::DetachAppDebug(const std::string &bundleName)
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
void AmsMgrProxy::SetKeepAliveEnableState(const std::string &bundleName, bool enable)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "Called.");
|
||||
MessageParcel data;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Write interface token failed.");
|
||||
return;
|
||||
}
|
||||
if (bundleName.empty() || !data.WriteString(bundleName)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Write bundle name fail.");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteBool(enable)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Write flag fail.");
|
||||
return;
|
||||
}
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
auto ret = SendTransactCmd(static_cast<uint32_t>(IAmsMgr::Message::SET_KEEP_ALIVE_ENABLE_STATE),
|
||||
data, reply, option);
|
||||
if (ret != NO_ERROR) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Send request failed, err: %{public}d", ret);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t AmsMgrProxy::SetAppWaitingDebug(const std::string &bundleName, bool isPersist)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "Called.");
|
||||
|
||||
@@ -122,6 +122,8 @@ void AmsMgrStub::CreateMemberFuncMap()
|
||||
&AmsMgrStub::HandleAttachPidToParent;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAmsMgr::Message::IS_MEMORY_SIZE_SUFFICIENT)] =
|
||||
&AmsMgrStub::HandleIsMemorySizeSufficent;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAmsMgr::Message::SET_KEEP_ALIVE_ENABLE_STATE)] =
|
||||
&AmsMgrStub::HandleSetKeepAliveEnableState;
|
||||
}
|
||||
|
||||
int AmsMgrStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
@@ -598,6 +600,15 @@ int32_t AmsMgrStub::HandleIsWaitingDebugApp(MessageParcel &data, MessageParcel &
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AmsMgrStub::HandleSetKeepAliveEnableState(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "Called.");
|
||||
auto bundleName = data.ReadString();
|
||||
auto enable = data.ReadBool();
|
||||
SetKeepAliveEnableState(bundleName, enable);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AmsMgrStub::HandleClearNonPersistWaitingDebugFlag(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "Called.");
|
||||
|
||||
@@ -96,6 +96,12 @@ bool AppLaunchData::Marshalling(Parcel &parcel) const
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Marshalling, Failed to write app running unique id.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!parcel.WriteBool(isMultiThread_)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Failed to write is multi thread flag.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -140,6 +146,7 @@ bool AppLaunchData::ReadFromParcel(Parcel &parcel)
|
||||
jitEnabled_ = parcel.ReadBool();
|
||||
isNativeStart_ = parcel.ReadBool();
|
||||
appRunningUniqueId_ = parcel.ReadString();
|
||||
isMultiThread_ = parcel.ReadBool();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "app_service_manager.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "app_mem_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
@@ -508,6 +509,7 @@ void AppMgrClient::PrepareTerminate(const sptr<IRemoteObject> &token)
|
||||
|
||||
void AppMgrClient::GetRunningProcessInfoByToken(const sptr<IRemoteObject> &token, AppExecFwk::RunningProcessInfo &info)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
|
||||
if (service != nullptr) {
|
||||
sptr<IAmsMgr> amsService = service->GetAmsMgr();
|
||||
@@ -595,6 +597,14 @@ void AppMgrClient::StartSpecifiedAbility(const AAFwk::Want &want, const AppExecF
|
||||
amsService->StartSpecifiedAbility(want, abilityInfo);
|
||||
}
|
||||
|
||||
void AppMgrClient::SetKeepAliveEnableState(const std::string &bundleName, bool enable)
|
||||
{
|
||||
if (!IsAmsServiceReady()) {
|
||||
return;
|
||||
}
|
||||
amsService_->SetKeepAliveEnableState(bundleName, enable);
|
||||
}
|
||||
|
||||
void AppMgrClient::StartSpecifiedProcess(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "call.");
|
||||
|
||||
@@ -218,6 +218,7 @@ int32_t AppMgrProxy::ClearUpApplicationDataBySelf(int32_t userId)
|
||||
|
||||
int32_t AppMgrProxy::GetAllRunningProcesses(std::vector<RunningProcessInfo> &info)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
@@ -236,6 +237,31 @@ int32_t AppMgrProxy::GetAllRunningProcesses(std::vector<RunningProcessInfo> &inf
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t AppMgrProxy::GetRunningProcessesByBundleType(const BundleType bundleType,
|
||||
std::vector<RunningProcessInfo> &info)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
if (!data.WriteInt32(static_cast<int32_t>(bundleType))) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Bundle type write failed.");
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
if (!SendTransactCmd(AppMgrInterfaceCode::APP_GET_RUNNING_PROCESSES_BY_BUNDLE_TYPE, data, reply)) {
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
auto error = GetParcelableInfos<RunningProcessInfo>(reply, info);
|
||||
if (error != NO_ERROR) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "GetParcelableInfos fail, error: %{public}d", error);
|
||||
return error;
|
||||
}
|
||||
int result = reply.ReadInt32();
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t AppMgrProxy::GetAllRenderProcesses(std::vector<RenderProcessInfo> &info)
|
||||
{
|
||||
MessageParcel data;
|
||||
@@ -545,6 +571,7 @@ int AppMgrProxy::UnregisterApplicationStateObserver(
|
||||
int32_t AppMgrProxy::RegisterAbilityForegroundStateObserver(const sptr<IAbilityForegroundStateObserver> &observer)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "Called.");
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
if (observer == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Observer is null.");
|
||||
return ERR_INVALID_VALUE;
|
||||
@@ -1600,7 +1627,8 @@ int32_t AppMgrProxy::IsApplicationRunning(const std::string &bundleName, bool &i
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t AppMgrProxy::StartChildProcess(const std::string &srcEntry, pid_t &childPid)
|
||||
int32_t AppMgrProxy::StartChildProcess(const std::string &srcEntry, pid_t &childPid, int32_t childProcessCount,
|
||||
bool isStartWithDebug)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "called");
|
||||
if (srcEntry.empty()) {
|
||||
@@ -1616,6 +1644,14 @@ int32_t AppMgrProxy::StartChildProcess(const std::string &srcEntry, pid_t &child
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Write param srcEntry failed.");
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
if (!data.WriteInt32(childProcessCount)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Write param childProcessCount failed.");
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
if (!data.WriteBool(isStartWithDebug)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Write param isStartWithDebug failed.");
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
@@ -188,6 +188,8 @@ AppMgrStub::AppMgrStub()
|
||||
&AppMgrStub::HandleNotifyMemorySizeStateChanged;
|
||||
memberFuncMap_[static_cast<uint32_t>(AppMgrInterfaceCode::SET_SUPPORTED_PROCESS_CACHE_SELF)] =
|
||||
&AppMgrStub::HandleSetSupportedProcessCacheSelf;
|
||||
memberFuncMap_[static_cast<uint32_t>(AppMgrInterfaceCode::APP_GET_RUNNING_PROCESSES_BY_BUNDLE_TYPE)] =
|
||||
&AppMgrStub::HandleGetRunningProcessesByBundleType;
|
||||
}
|
||||
|
||||
AppMgrStub::~AppMgrStub()
|
||||
@@ -324,6 +326,24 @@ int32_t AppMgrStub::HandleGetAllRunningProcesses(MessageParcel &data, MessagePar
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AppMgrStub::HandleGetRunningProcessesByBundleType(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HITRACE_METER(HITRACE_TAG_APP);
|
||||
int32_t bundleType = data.ReadInt32();
|
||||
std::vector<RunningProcessInfo> info;
|
||||
auto result = GetRunningProcessesByBundleType(static_cast<BundleType>(bundleType), info);
|
||||
reply.WriteInt32(info.size());
|
||||
for (auto &it : info) {
|
||||
if (!reply.WriteParcelable(&it)) {
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
}
|
||||
if (!reply.WriteInt32(result)) {
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AppMgrStub::HandleGetProcessRunningInfosByUserId(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HITRACE_METER(HITRACE_TAG_APP);
|
||||
@@ -501,6 +521,7 @@ int32_t AppMgrStub::HandleUnregisterApplicationStateObserver(MessageParcel &data
|
||||
|
||||
int32_t AppMgrStub::HandleRegisterAbilityForegroundStateObserver(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
auto callback = iface_cast<AppExecFwk::IAbilityForegroundStateObserver>(data.ReadRemoteObject());
|
||||
if (callback == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Callback is null.");
|
||||
@@ -1098,7 +1119,9 @@ int32_t AppMgrStub::HandleStartChildProcess(MessageParcel &data, MessageParcel &
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "called.");
|
||||
std::string srcEntry = data.ReadString();
|
||||
int32_t childPid = 0;
|
||||
int32_t result = StartChildProcess(srcEntry, childPid);
|
||||
int32_t childProcessCount = data.ReadInt32();
|
||||
int32_t isStartWithDebug = data.ReadBool();
|
||||
int32_t result = StartChildProcess(srcEntry, childPid, childProcessCount, isStartWithDebug);
|
||||
if (!reply.WriteInt32(result)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Write result error.");
|
||||
return ERR_INVALID_VALUE;
|
||||
|
||||
@@ -268,6 +268,7 @@ int32_t AppSchedulerHost::HandleScheduleProfileChanged(MessageParcel &data, Mess
|
||||
|
||||
int32_t AppSchedulerHost::HandleScheduleConfigurationUpdated(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HITRACE_METER(HITRACE_TAG_APP);
|
||||
std::unique_ptr<Configuration> configuration(data.ReadParcelable<Configuration>());
|
||||
if (!configuration) {
|
||||
|
||||
@@ -345,6 +345,7 @@ void AppSchedulerProxy::ScheduleProfileChanged(const Profile &profile)
|
||||
|
||||
void AppSchedulerProxy::ScheduleConfigurationUpdated(const Configuration &config)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
@@ -705,12 +706,14 @@ int32_t AppSchedulerProxy::ScheduleDumpIpcStat(std::string& result)
|
||||
int32_t AppSchedulerProxy::SendTransactCmd(uint32_t code, MessageParcel &data,
|
||||
MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Remote is nullptr.");
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, "remote->SendRequest");
|
||||
auto ret = remote->SendRequest(code, data, reply, option);
|
||||
if (ret != NO_ERROR) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Send request failed with error code: %{public}d", ret);
|
||||
|
||||
@@ -41,6 +41,9 @@ bool ChildProcessInfo::ReadFromParcel(Parcel &parcel)
|
||||
processName = Str16ToStr8(parcel.ReadString16());
|
||||
srcEntry = Str16ToStr8(parcel.ReadString16());
|
||||
jitEnabled = parcel.ReadBool();
|
||||
isDebugApp = parcel.ReadBool();
|
||||
isStartWithDebug = parcel.ReadBool();
|
||||
isStartWithNative = parcel.ReadBool();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -65,6 +68,9 @@ bool ChildProcessInfo::Marshalling(Parcel &parcel) const
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(processName));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String16, parcel, Str8ToStr16(srcEntry));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, jitEnabled);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isDebugApp);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isStartWithDebug);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isStartWithNative);
|
||||
return true;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
|
||||
@@ -48,6 +48,9 @@ bool RunningProcessInfo::ReadFromParcel(Parcel &parcel)
|
||||
isTestProcess = parcel.ReadBool();
|
||||
isAbilityForegrounding = parcel.ReadBool();
|
||||
isTestMode = parcel.ReadBool();
|
||||
int32_t bundleTypeData;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, bundleTypeData);
|
||||
bundleType = static_cast<int32_t>(bundleTypeData);
|
||||
if (!parcel.ReadStringVector(&bundleNames)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "read bundleNames failed.");
|
||||
return false;
|
||||
@@ -84,6 +87,7 @@ bool RunningProcessInfo::Marshalling(Parcel &parcel) const
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isTestProcess);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isAbilityForegrounding);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isTestMode);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(bundleType));
|
||||
if (!parcel.WriteStringVector(bundleNames)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "write bundleNames failed.");
|
||||
return false;
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
|
||||
private:
|
||||
void SendAutoFillSucess(const AAFwk::Want &want);
|
||||
void SendAutoFillFailed(int32_t errCode);
|
||||
void SendAutoFillFailed(int32_t errCode, const AAFwk::Want &want = AAFwk::Want());
|
||||
void CloseModalUIExtension();
|
||||
void HandleReloadInModal(const AAFwk::WantParams &wantParams);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
virtual ~IFillRequestCallback() {}
|
||||
|
||||
virtual void OnFillRequestSuccess(const AbilityBase::ViewData &viewData) = 0;
|
||||
virtual void OnFillRequestFailed(int32_t errCode) = 0;
|
||||
virtual void OnFillRequestFailed(int32_t errCode, const std::string& fillContent = "") = 0;
|
||||
};
|
||||
} // AbilityRuntime
|
||||
} // OHOS
|
||||
|
||||
@@ -31,6 +31,7 @@ constexpr static char WANT_PARAMS_AUTO_FILL_CMD_KEY[] = "ohos.ability.params.aut
|
||||
constexpr static char WANT_PARAMS_UPDATE_POPUP_WIDTH[] = "ohos.ability.params.popupWidth";
|
||||
constexpr static char WANT_PARAMS_UPDATE_POPUP_HEIGHT[] = "ohos.ability.params.popupHeight";
|
||||
constexpr static char WANT_PARAMS_UPDATE_POPUP_PLACEMENT[] = "ohos.ability.params.popupPlacement";
|
||||
constexpr static char WANT_PARAMS_FILL_CONTENT[] = "ohos.ability.params.fillContent";
|
||||
} // namespace
|
||||
void AutoFillExtensionCallback::OnResult(int32_t errCode, const AAFwk::Want &want)
|
||||
{
|
||||
@@ -50,7 +51,7 @@ void AutoFillExtensionCallback::OnResult(int32_t errCode, const AAFwk::Want &wan
|
||||
} else {
|
||||
auto resultCode = (errCode == AutoFill::AUTO_FILL_CANCEL) ?
|
||||
AutoFill::AUTO_FILL_CANCEL : AutoFill::AUTO_FILL_FAILED;
|
||||
SendAutoFillFailed(resultCode);
|
||||
SendAutoFillFailed(resultCode, want);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,10 +255,11 @@ void AutoFillExtensionCallback::SendAutoFillSucess(const AAFwk::Want &want)
|
||||
}
|
||||
}
|
||||
|
||||
void AutoFillExtensionCallback::SendAutoFillFailed(int32_t errCode)
|
||||
void AutoFillExtensionCallback::SendAutoFillFailed(int32_t errCode, const AAFwk::Want &want)
|
||||
{
|
||||
if (fillCallback_ != nullptr) {
|
||||
fillCallback_->OnFillRequestFailed(errCode);
|
||||
std::string fillContent = want.GetStringParam(WANT_PARAMS_FILL_CONTENT);
|
||||
fillCallback_->OnFillRequestFailed(errCode, fillContent);
|
||||
fillCallback_ = nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,8 @@ public:
|
||||
bool LoadJsFile(const std::string &srcEntry, const AppExecFwk::HapModuleInfo &hapModuleInfo,
|
||||
std::unique_ptr<AbilityRuntime::Runtime> &runtime);
|
||||
void SetForkProcessJITEnabled(bool jitEnabled);
|
||||
void SetForkProcessDebugOption(const std::string bundleName, const bool isStartWithDebug, const bool isDebugApp,
|
||||
const bool isStartWithNative);
|
||||
|
||||
private:
|
||||
ChildProcessManager();
|
||||
@@ -57,9 +59,11 @@ private:
|
||||
void HandleChildProcessBySelfFork(const std::string &srcEntry, const AppExecFwk::BundleInfo &bundleInfo);
|
||||
bool hasChildProcessRecord();
|
||||
sptr<AppExecFwk::IAppMgr> GetAppMgr();
|
||||
void MakeProcessName(const std::string &srcEntry);
|
||||
|
||||
static bool signalRegistered_;
|
||||
bool isChildProcessBySelfFork_ = false;
|
||||
int32_t childProcessCount_ = 0;
|
||||
|
||||
DISALLOW_COPY_AND_MOVE(ChildProcessManager);
|
||||
};
|
||||
|
||||
+11
@@ -60,6 +60,17 @@ private:
|
||||
*/
|
||||
napi_value CreateJsInsightIntentContext(napi_env env, const std::shared_ptr<InsightIntentContext>& context);
|
||||
|
||||
/**
|
||||
* Function of check startAbiliryParam parammeters.
|
||||
*
|
||||
* @param env, the napi environment.
|
||||
* @param info, Indicates the parameters from js.
|
||||
* @param want, the want of the ability to start.
|
||||
*
|
||||
* @return result of check startAbiliryParam parammeters.
|
||||
*/
|
||||
bool CheckStartAbilityParam(napi_env env, NapiCallbackInfo& info, AAFwk::Want want);
|
||||
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_JS_INSIGHT_INTENT_CONTEXT_H
|
||||
|
||||
@@ -27,6 +27,12 @@ ohos_shared_library("napi_base_context") {
|
||||
|
||||
external_deps = [ "napi:ace_napi" ]
|
||||
|
||||
public_external_deps = [
|
||||
"form_fwk:form_manager",
|
||||
"window_manager:libdm",
|
||||
"window_manager:libwm",
|
||||
]
|
||||
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
subsystem_name = "ability"
|
||||
part_name = "ability_runtime"
|
||||
|
||||
@@ -78,6 +78,7 @@ int32_t QuickFixManagerClient::GetApplyedQuickFixInfo(const std::string &bundleN
|
||||
|
||||
sptr<IQuickFixManager> QuickFixManagerClient::GetQuickFixMgrProxy()
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
TAG_LOGD(AAFwkTag::QUICKFIX, "function called.");
|
||||
auto quickFixMgr = GetQuickFixMgr();
|
||||
if (quickFixMgr != nullptr) {
|
||||
@@ -143,11 +144,13 @@ void QuickFixManagerClient::QfmsDeathRecipient::OnRemoteDied([[maybe_unused]] co
|
||||
|
||||
bool QuickFixManagerClient::LoadQuickFixMgrService()
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(loadSaMutex_);
|
||||
loadSaFinished_ = false;
|
||||
}
|
||||
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, "GetSystemAbilityManager");
|
||||
auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (systemAbilityMgr == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "Failed to get SystemAbilityManager.");
|
||||
|
||||
@@ -60,6 +60,7 @@ public:
|
||||
bool isStageModel = true;
|
||||
bool isTestFramework = false;
|
||||
bool jitEnabled = false;
|
||||
bool isMultiThread = false;
|
||||
int32_t uid = -1;
|
||||
// ArkTsCard start
|
||||
bool isUnique = false;
|
||||
@@ -71,10 +72,11 @@ public:
|
||||
};
|
||||
|
||||
struct DebugOption {
|
||||
std::string bundleName = "";
|
||||
std::string perfCmd;
|
||||
bool isStartWithDebug = false;
|
||||
std::string processName = "";
|
||||
bool isDebugApp = true;
|
||||
bool isStartWithDebug = false;
|
||||
bool isStartWithNative = false;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# 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
|
||||
@@ -36,7 +36,6 @@ config("wantagent_innerkits_public_config") {
|
||||
"${ability_runtime_innerkits_path}/wantagent/include",
|
||||
"${ability_runtime_services_path}/abilitymgr/include",
|
||||
"${ability_runtime_innerkits_path}/app_manager/include/appmgr",
|
||||
"${bundlefwk_inner_api_path}/appexecfwk_core/include/bundlemgr",
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit/app",
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit",
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime",
|
||||
@@ -77,12 +76,15 @@ ohos_shared_library("wantagent_innerkits") {
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_core",
|
||||
"napi:ace_napi",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
public_external_deps = [
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"eventhandler:libeventhandler",
|
||||
"icu:shared_icuuc",
|
||||
"image_framework:image_native",
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "ability_runtime_error_util.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "want_agent_client.h"
|
||||
#include "want_agent_log_wrapper.h"
|
||||
#include "want_sender_info.h"
|
||||
@@ -431,6 +432,7 @@ ErrCode PendingWant::GetBundleName(const sptr<AAFwk::IWantSender> &target, std::
|
||||
|
||||
std::shared_ptr<Want> PendingWant::GetWant(const sptr<AAFwk::IWantSender> &target)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
std::shared_ptr<Want> want = std::make_shared<Want>();
|
||||
int ret = WantAgentClient::GetInstance().GetPendingRequestWant(target, want);
|
||||
return ret ? nullptr : want;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "ability_util.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "system_ability_definition.h"
|
||||
@@ -261,6 +262,7 @@ void WantAgentClient::UnregisterCancelListener(
|
||||
|
||||
ErrCode WantAgentClient::GetPendingRequestWant(const sptr<IWantSender> &target, std::shared_ptr<Want> &want)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
CHECK_POINTER_AND_RETURN(target, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_WANTAGENT);
|
||||
CHECK_POINTER_AND_RETURN(want, INVALID_PARAMETERS_ERR);
|
||||
auto abms = GetAbilityManager();
|
||||
@@ -340,6 +342,7 @@ ErrCode WantAgentClient::GetWantSenderInfo(const sptr<IWantSender> &target, std:
|
||||
|
||||
sptr<IRemoteObject> WantAgentClient::GetAbilityManager()
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (proxy_ == nullptr) {
|
||||
auto systemManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "ability_runtime_error_util.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "want_params_wrapper.h"
|
||||
#include "pending_want.h"
|
||||
#include "want_agent_client.h"
|
||||
@@ -295,6 +296,7 @@ ErrCode WantAgentHelper::GetUid(const std::shared_ptr<WantAgent> &agent, int32_t
|
||||
|
||||
std::shared_ptr<Want> WantAgentHelper::GetWant(const std::shared_ptr<WantAgent> &agent)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
if (agent == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgentHelper::GetWant WantAgent invalid input param.");
|
||||
return nullptr;
|
||||
|
||||
@@ -144,6 +144,9 @@ enum class AbilityErrorCode {
|
||||
// invalid caller.
|
||||
ERROR_CODE_INVALID_CALLER = 16200001,
|
||||
|
||||
// Setting permissions for resident processes
|
||||
ERROR_CODE_NO_RESIDENT_PERMISSION = 16200006,
|
||||
|
||||
// no such mission id.
|
||||
ERROR_CODE_NO_MISSION_ID = 16300001,
|
||||
|
||||
|
||||
@@ -151,8 +151,8 @@ public:
|
||||
*/
|
||||
void SetContext(const std::shared_ptr<UIExtensionContext> &context) override;
|
||||
|
||||
private:
|
||||
void BindContext(napi_env env, napi_value obj);
|
||||
void BindContext() override;
|
||||
protected:
|
||||
napi_value CallObjectMethod(const char *name, napi_value const *argv = nullptr, size_t argc = 0);
|
||||
void ForegroundWindow(const AAFwk::Want &want, const sptr<AAFwk::SessionInfo> &sessionInfo);
|
||||
void BackgroundWindow(const sptr<AAFwk::SessionInfo> &sessionInfo);
|
||||
@@ -168,15 +168,16 @@ private:
|
||||
void PostInsightIntentExecuted(const sptr<AAFwk::SessionInfo> &sessionInfo,
|
||||
const AppExecFwk::InsightIntentExecuteResult &result, bool needForeground);
|
||||
|
||||
protected:
|
||||
JsRuntime &jsRuntime_;
|
||||
std::unique_ptr<NativeReference> jsObj_;
|
||||
std::shared_ptr<NativeReference> shellContextRef_;
|
||||
std::unique_ptr<NativeReference> jsObj_;
|
||||
std::shared_ptr<UIExtensionContext> context_;
|
||||
std::map<uint64_t, sptr<Rosen::Window>> uiWindowMap_;
|
||||
std::set<uint64_t> foregroundWindows_;
|
||||
std::map<uint64_t, std::shared_ptr<NativeReference>> contentSessions_;
|
||||
std::shared_ptr<AbilityResultListeners> abilityResultListeners_ = nullptr;
|
||||
std::shared_ptr<AppExecFwk::AbilityInfo> abilityInfo_;
|
||||
std::shared_ptr<UIExtensionContext> context_;
|
||||
sptr<IRemoteObject> token_ = nullptr;
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
|
||||
+2
@@ -117,6 +117,8 @@ protected:
|
||||
napi_env env, NapiCallbackInfo& info, std::shared_ptr<int> &innerErrorCode);
|
||||
void StartAbilityForResultRuntimeTask(napi_env env, AAFwk::Want &want,
|
||||
std::shared_ptr<NapiAsyncTask> asyncTask, size_t& unwrapArgc, AAFwk::StartOptions startOptions);
|
||||
bool CheckStartAbilityByTypeParam(napi_env env, NapiCallbackInfo& info, std::string type,
|
||||
AAFwk::WantParams wantParam);
|
||||
|
||||
private:
|
||||
sptr<AAFwk::SessionInfo> sessionInfo_;
|
||||
|
||||
+2
-1
@@ -55,8 +55,9 @@ protected:
|
||||
virtual napi_value OnReportDrawnCompleted(napi_env env, NapiCallbackInfo& info);
|
||||
virtual napi_value OnOpenAtomicService(napi_env env, NapiCallbackInfo& info);
|
||||
|
||||
private:
|
||||
protected:
|
||||
std::weak_ptr<UIExtensionContext> context_;
|
||||
private:
|
||||
sptr<JsFreeInstallObserver> freeInstallObserver_ = nullptr;
|
||||
friend class JsEmbeddableUIAbilityContext;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user