mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 22:21:36 -04:00
Merge branch 'master' of gitee.com:openharmony/ability_ability_runtime into unlockaa-0517
Signed-off-by: 夏良伟 <xialiangwei1@huawei.com>
This commit is contained in:
@@ -18,6 +18,7 @@ ability_runtime_napi_path = "${ability_runtime_path}/frameworks/js/napi"
|
||||
ability_base_path = "//foundation/ability/ability_base"
|
||||
form_fwk_path = "//foundation/ability/form_fwk"
|
||||
ability_runtime_innerkits_path = "${ability_runtime_path}/interfaces/inner_api"
|
||||
ability_runtime_ndk_path = "${ability_runtime_path}/interfaces/kits/c"
|
||||
ability_runtime_native_path = "${ability_runtime_path}/frameworks/native"
|
||||
ability_runtime_services_path = "${ability_runtime_path}/services"
|
||||
ability_runtime_abilitymgr_path = "${ability_runtime_services_path}/abilitymgr"
|
||||
|
||||
+27
@@ -106,6 +106,7 @@
|
||||
"//foundation/ability/ability_runtime/interfaces/inner_api:innerkits_target",
|
||||
"//foundation/ability/ability_runtime/frameworks/native/ability/native:ability_thread",
|
||||
"//foundation/ability/ability_runtime/frameworks/native/ability/native:extension_module",
|
||||
"//foundation/ability/ability_runtime/frameworks/native/child_process:child_process",
|
||||
"//foundation/ability/ability_runtime/frameworks/native/insight_intent:insight_intent_innerkits",
|
||||
"//foundation/ability/ability_runtime/frameworks/js/napi:napi_packages",
|
||||
"//foundation/ability/ability_runtime/cj_environment/frameworks/cj_environment:cj_environment",
|
||||
@@ -314,6 +315,15 @@
|
||||
},
|
||||
"name": "//foundation/ability/ability_runtime/frameworks/native/appkit:app_context"
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"header_base": "//foundation/ability/ability_runtime/interfaces/kits/c/ability/ability_runtime/child_process",
|
||||
"header_files": [
|
||||
"native_child_process.h"
|
||||
]
|
||||
},
|
||||
"name": "//foundation/ability/ability_runtime/frameworks/native/child_process:child_process"
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"header_base": "//foundation/ability/ability_runtime/interfaces/inner_api/uri_permission/include/",
|
||||
@@ -430,6 +440,23 @@
|
||||
]
|
||||
},
|
||||
"name": "//foundation/ability/ability_runtime/interfaces/inner_api/auto_fill_manager:auto_fill_manager"
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"header_base": "//foundation/ability/ability_runtime/interfaces/inner_api/ability_manager/include",
|
||||
"header_files": [
|
||||
"start_options.h"
|
||||
]
|
||||
},
|
||||
"name": "//foundation/ability/ability_runtime/interfaces/inner_api/ability_manager:ability_start_options"
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"header_base": "//foundation/ability/ability_runtime/interfaces/kits/native/ability/native/dialog_request_callback",
|
||||
"header_files": [
|
||||
]
|
||||
},
|
||||
"name": "//foundation/ability/ability_runtime/frameworks/native/ability/native:dialog_request_callback"
|
||||
}
|
||||
],
|
||||
"test": [
|
||||
|
||||
@@ -27,6 +27,7 @@ ohos_shared_library("autostartupcallback") {
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/app_manager:app_manager",
|
||||
"${ability_runtime_innerkits_path}/error_utils:ability_runtime_error_util",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
|
||||
@@ -31,6 +31,7 @@ ohos_shared_library("autostartupmanager") {
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/app_manager:app_manager",
|
||||
"${ability_runtime_innerkits_path}/error_utils:ability_runtime_error_util",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
|
||||
@@ -33,6 +33,7 @@ template("abilitymanager") {
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/app_manager:app_manager",
|
||||
"${ability_runtime_innerkits_path}/napi_base_context:napi_base_context",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
|
||||
@@ -32,6 +32,7 @@ ohos_shared_library("appmanager_napi") {
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/app_manager:app_manager",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
"${ability_runtime_napi_path}/inner/napi_common:napi_common",
|
||||
|
||||
@@ -189,6 +189,10 @@ class ApplicationContext {
|
||||
return this.__context_impl__.setSupportedProcessCache(isSupport);
|
||||
}
|
||||
|
||||
getCurrentAppCloneIndex(){
|
||||
return this.__context_impl__.getCurrentAppCloneIndex()
|
||||
}
|
||||
|
||||
set area(mode) {
|
||||
return this.__context_impl__.switchArea(mode);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ template("errormanager") {
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/app_manager:app_manager",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
"${ability_runtime_native_path}/appkit:appkit_native",
|
||||
|
||||
@@ -37,6 +37,7 @@ ohos_shared_library("appmanager") {
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/app_manager:app_manager",
|
||||
"${ability_runtime_innerkits_path}/error_utils:ability_runtime_error_util",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
|
||||
@@ -110,6 +110,11 @@ public:
|
||||
GET_CB_INFO_AND_CALL(env, info, JsAppManager, OnIsRunningInStabilityTest);
|
||||
}
|
||||
|
||||
static napi_value GetRunningMultiAppInfo(napi_env env, napi_callback_info info)
|
||||
{
|
||||
GET_CB_INFO_AND_CALL(env, info, JsAppManager, OnGetRunningMultiAppInfo);
|
||||
}
|
||||
|
||||
static napi_value KillProcessWithAccount(napi_env env, napi_callback_info info)
|
||||
{
|
||||
GET_CB_INFO_AND_CALL(env, info, JsAppManager, OnKillProcessWithAccount);
|
||||
@@ -640,6 +645,52 @@ private:
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value OnGetRunningMultiAppInfo(napi_env env, size_t argc, napi_value* argv)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "called");
|
||||
if (!CheckCallerIsSystemApp()) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Current app is not system app");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_NOT_SYSTEM_APP);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
// only support 1 params
|
||||
if (argc < ARGC_ONE) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Not enough arguments");
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
std::string bundleName;
|
||||
if (!ConvertFromJsValue(env, argv[0], bundleName)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "get bundleName failed!");
|
||||
ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
auto info = std::make_shared<RunningMultiAppInfo>();
|
||||
auto innerErrorCode = std::make_shared<int32_t>(ERR_OK);
|
||||
NapiAsyncTask::ExecuteCallback execute =
|
||||
[appManager = appManager_, bundleName, innerErrorCode, info]() {
|
||||
if (appManager == nullptr) {
|
||||
TAG_LOGW(AAFwkTag::APPMGR, "appManager nullptr");
|
||||
*innerErrorCode = static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INNER);
|
||||
return;
|
||||
}
|
||||
*innerErrorCode = appManager->GetRunningMultiAppInfoByBundleName(bundleName, *info);
|
||||
};
|
||||
NapiAsyncTask::CompleteCallback complete =
|
||||
[innerErrorCode, info](napi_env env, NapiAsyncTask &task, int32_t status) {
|
||||
if (*innerErrorCode == ERR_OK) {
|
||||
task.ResolveWithNoError(env, CreateJsRunningMultiAppInfo(env, *info));
|
||||
} else {
|
||||
task.Reject(env, CreateJsErrorByNativeErr(env, *innerErrorCode));
|
||||
}
|
||||
};
|
||||
napi_value lastParam = nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::ScheduleHighQos("JSAppManager::OnGetRunningMultiAppInfo",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, std::move(execute), std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value OnGetRunningProcessInformationByBundleType(napi_env env, size_t argc, napi_value* argv)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "called");
|
||||
@@ -694,7 +745,7 @@ private:
|
||||
return;
|
||||
}
|
||||
bool ret = abilityManager->IsRunningInStabilityTest();
|
||||
TAG_LOGI(AAFwkTag::APPMGR, "result:%{public}d", ret);
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "result:%{public}d", ret);
|
||||
task.ResolveWithNoError(env, CreateJsValue(env, ret));
|
||||
};
|
||||
|
||||
@@ -1176,20 +1227,15 @@ napi_value JsAppManagerInit(napi_env env, napi_value exportObj)
|
||||
JsAppManager::KillProcessesByBundleName);
|
||||
BindNativeFunction(env, exportObj, "clearUpApplicationData", moduleName,
|
||||
JsAppManager::ClearUpApplicationData);
|
||||
BindNativeFunction(env, exportObj, "getAppMemorySize", moduleName,
|
||||
JsAppManager::GetAppMemorySize);
|
||||
BindNativeFunction(env, exportObj, "isRamConstrainedDevice", moduleName,
|
||||
JsAppManager::IsRamConstrainedDevice);
|
||||
BindNativeFunction(env, exportObj, "isSharedBundleRunning", moduleName,
|
||||
JsAppManager::IsSharedBundleRunning);
|
||||
BindNativeFunction(env, exportObj, "getProcessMemoryByPid", moduleName,
|
||||
JsAppManager::GetProcessMemoryByPid);
|
||||
BindNativeFunction(env, exportObj, "getAppMemorySize", moduleName, JsAppManager::GetAppMemorySize);
|
||||
BindNativeFunction(env, exportObj, "isRamConstrainedDevice", moduleName, JsAppManager::IsRamConstrainedDevice);
|
||||
BindNativeFunction(env, exportObj, "isSharedBundleRunning", moduleName, JsAppManager::IsSharedBundleRunning);
|
||||
BindNativeFunction(env, exportObj, "getProcessMemoryByPid", moduleName, JsAppManager::GetProcessMemoryByPid);
|
||||
BindNativeFunction(env, exportObj, "getRunningProcessInfoByBundleName", moduleName,
|
||||
JsAppManager::GetRunningProcessInfoByBundleName);
|
||||
BindNativeFunction(env, exportObj, "isApplicationRunning", moduleName,
|
||||
JsAppManager::IsApplicationRunning);
|
||||
BindNativeFunction(env, exportObj, "preloadApplication", moduleName,
|
||||
JsAppManager::PreloadApplication);
|
||||
BindNativeFunction(env, exportObj, "getRunningMultiAppInfo", moduleName, JsAppManager::GetRunningMultiAppInfo);
|
||||
BindNativeFunction(env, exportObj, "isApplicationRunning", moduleName, JsAppManager::IsApplicationRunning);
|
||||
BindNativeFunction(env, exportObj, "preloadApplication", moduleName, JsAppManager::PreloadApplication);
|
||||
BindNativeFunction(env, exportObj, "getRunningProcessInformationByBundleType", moduleName,
|
||||
JsAppManager::GetRunningProcessInformationByBundleType);
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "end");
|
||||
|
||||
@@ -150,6 +150,47 @@ napi_value CreateJsRunningProcessInfo(napi_env env, const RunningProcessInfo &in
|
||||
return object;
|
||||
}
|
||||
|
||||
napi_value CreateJsRunningMultiAppInfo(napi_env env, const RunningMultiAppInfo &info)
|
||||
{
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
if (object == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "objValue nullptr.");
|
||||
return nullptr;
|
||||
}
|
||||
napi_set_named_property(env, object, "bundleName", CreateJsValue(env, info.bundleName));
|
||||
napi_set_named_property(env, object, "mode", CreateJsValue(env, info.mode));
|
||||
napi_set_named_property(env, object, "runningAppClones", CreateJsRunningAppCloneArray(env, info.runningAppClones));
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
napi_value CreateJsRunningAppCloneArray(napi_env env, const std::vector<RunningAppClone>& data)
|
||||
{
|
||||
napi_value arrayValue = nullptr;
|
||||
napi_create_array_with_length(env, data.size(), &arrayValue);
|
||||
uint32_t index = 0;
|
||||
for (const auto &item : data) {
|
||||
napi_set_element(env, arrayValue, index++, CreateJsRunningAppClone(env, item));
|
||||
}
|
||||
return arrayValue;
|
||||
}
|
||||
|
||||
napi_value CreateJsRunningAppClone(napi_env env, const RunningAppClone &info)
|
||||
{
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
if (object == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "objValue nullptr.");
|
||||
return nullptr;
|
||||
}
|
||||
napi_set_named_property(env, object, "appCloneIndex", CreateJsValue(env, info.appCloneIndex));
|
||||
napi_set_named_property(env, object, "uid", CreateJsValue(env, info.uid));
|
||||
napi_set_named_property(env, object, "pids", CreateNativeArray(env, info.pids));
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
napi_value ApplicationStateInit(napi_env env)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "ApplicationStateInit enter");
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "application_state_observer_stub.h"
|
||||
#include "native_engine/native_engine.h"
|
||||
#include "running_process_info.h"
|
||||
#include "running_multi_info.h"
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#include "ability_first_frame_state_data.h"
|
||||
#endif
|
||||
@@ -29,6 +30,8 @@ using OHOS::AppExecFwk::AppStateData;
|
||||
using OHOS::AppExecFwk::AbilityStateData;
|
||||
using OHOS::AppExecFwk::ProcessData;
|
||||
using OHOS::AppExecFwk::RunningProcessInfo;
|
||||
using OHOS::AppExecFwk::RunningMultiAppInfo;
|
||||
using OHOS::AppExecFwk::RunningAppClone;
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
using OHOS::AppExecFwk::AbilityFirstFrameStateData;
|
||||
#endif
|
||||
@@ -63,6 +66,9 @@ bool ConvertPreloadApplicationParam(napi_env env, size_t argc, napi_value *argv,
|
||||
std::string &errorMsg);
|
||||
JsAppProcessState ConvertToJsAppProcessState(
|
||||
const AppExecFwk::AppProcessState &appProcessState, const bool &isFocused);
|
||||
napi_value CreateJsRunningMultiAppInfo(napi_env env, const RunningMultiAppInfo &info);
|
||||
napi_value CreateJsRunningAppCloneArray(napi_env env, const std::vector<RunningAppClone>& data);
|
||||
napi_value CreateJsRunningAppClone(napi_env env, const RunningAppClone &info);
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_JS_APP_MANAGER_UTILS_H
|
||||
|
||||
@@ -32,6 +32,7 @@ ohos_shared_library("apprecovery_napi") {
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/app_manager:app_manager",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
"${ability_runtime_napi_path}/inner/napi_common:napi_common",
|
||||
|
||||
@@ -27,6 +27,7 @@ ohos_shared_library("featureability") {
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_setting",
|
||||
"${ability_runtime_innerkits_path}/dataobs_manager:dataobs_manager",
|
||||
"${ability_runtime_innerkits_path}/napi_base_context:napi_base_context",
|
||||
|
||||
@@ -32,6 +32,7 @@ ohos_shared_library("napi_ability_common") {
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_setting",
|
||||
"${ability_runtime_innerkits_path}/napi_base_context:napi_base_context",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
|
||||
@@ -42,6 +42,7 @@ ohos_shared_library("napi_common") {
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:process_options",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
]
|
||||
|
||||
@@ -86,6 +86,14 @@ napi_value WrapElementName(napi_env env, const ElementName &elementName)
|
||||
NAPI_CALL(env, napi_create_string_utf8(env, elementName.GetModuleName().c_str(), NAPI_AUTO_LENGTH, &jsValue));
|
||||
NAPI_CALL(env, napi_set_named_property(env, jsObject, "moduleName", jsValue));
|
||||
|
||||
jsValue = nullptr;
|
||||
NAPI_CALL(env, napi_create_string_utf8(env, elementName.GetShortName().c_str(), NAPI_AUTO_LENGTH, &jsValue));
|
||||
NAPI_CALL(env, napi_set_named_property(env, jsObject, "shortName", jsValue));
|
||||
|
||||
jsValue = nullptr;
|
||||
NAPI_CALL(env, napi_create_string_utf8(env, elementName.GetUri().c_str(), NAPI_AUTO_LENGTH, &jsValue));
|
||||
NAPI_CALL(env, napi_set_named_property(env, jsObject, "uri", jsValue));
|
||||
|
||||
return jsObject;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ ohos_shared_library("insightintentdriver_napi") {
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
"${ability_runtime_napi_path}/inner/napi_common:napi_common",
|
||||
"${ability_runtime_native_path}/ability/native:ability_business_error",
|
||||
|
||||
@@ -27,6 +27,7 @@ ohos_shared_library("dialogsession_napi") {
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
"${ability_runtime_napi_path}/inner/napi_common:napi_common",
|
||||
"${ability_runtime_native_path}/appkit:app_context",
|
||||
|
||||
@@ -66,6 +66,8 @@ napi_value WrapDialogAbilityInfo(napi_env env, const AAFwk::DialogAbilityInfo &d
|
||||
SetPropertyValueByPropertyName(env, jsObject, "abilityIconId", jsValue);
|
||||
jsValue = WrapInt32ToJS(env, dialogAbilityInfo.abilityLabelId);
|
||||
SetPropertyValueByPropertyName(env, jsObject, "abilityLabelId", jsValue);
|
||||
jsValue = WrapBoolToJS(env, dialogAbilityInfo.visible);
|
||||
SetPropertyValueByPropertyName(env, jsObject, "visible", jsValue);
|
||||
|
||||
return jsObject;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ ohos_shared_library("missionmanager") {
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:mission_info",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
"${ability_runtime_napi_path}/inner/napi_common:napi_common",
|
||||
|
||||
@@ -434,10 +434,15 @@ private:
|
||||
napi_create_object(env, &object);
|
||||
napi_value abilityObj = nullptr;
|
||||
napi_create_object(env, &abilityObj);
|
||||
std::string defalutValue = "";
|
||||
napi_set_named_property(env, abilityObj, "deviceId", CreateJsValue(env, defalutValue));
|
||||
napi_set_named_property(env, abilityObj, "bundleName",
|
||||
CreateJsValue(env, snapshotWrap->missionSnapshot.topAbility.GetBundleName()));
|
||||
napi_set_named_property(env, abilityObj, "abilityName",
|
||||
CreateJsValue(env, snapshotWrap->missionSnapshot.topAbility.GetAbilityName()));
|
||||
napi_set_named_property(env, abilityObj, "moduleName", CreateJsValue(env, defalutValue));
|
||||
napi_set_named_property(env, abilityObj, "shortName", CreateJsValue(env, defalutValue));
|
||||
napi_set_named_property(env, abilityObj, "uri", CreateJsValue(env, defalutValue));
|
||||
napi_set_named_property(env, object, "ability", abilityObj);
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
auto snapshotValue = Media::PixelMapNapi::CreatePixelMap(
|
||||
|
||||
@@ -28,6 +28,7 @@ ohos_shared_library("missionmanager_napi") {
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:mission_info",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
"${ability_runtime_napi_path}/inner/napi_common:napi_common",
|
||||
@@ -78,6 +79,7 @@ ohos_shared_library("distributedmissionmanager") {
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:mission_info",
|
||||
"${ability_runtime_innerkits_path}/app_manager:app_manager",
|
||||
"${ability_runtime_napi_path}/inner/napi_common:napi_common",
|
||||
|
||||
@@ -2066,6 +2066,7 @@ void UvWorkOnContinueDone(uv_work_t *work, int status)
|
||||
result = WrapInt32(continueAbilityCB->cbBase.cbInfo.env, continueAbilityCB->resultCode, "code");
|
||||
}
|
||||
if (continueAbilityCB->cbBase.deferred == nullptr) {
|
||||
std::lock_guard<std::mutex> autoLock(registrationLock_);
|
||||
napi_value callback = nullptr;
|
||||
napi_value undefined = nullptr;
|
||||
napi_get_undefined(continueAbilityCB->cbBase.cbInfo.env, &undefined);
|
||||
@@ -2075,6 +2076,7 @@ void UvWorkOnContinueDone(uv_work_t *work, int status)
|
||||
napi_call_function(continueAbilityCB->cbBase.cbInfo.env, undefined, callback, 1, &result, &callResult);
|
||||
if (continueAbilityCB->cbBase.cbInfo.callback != nullptr) {
|
||||
napi_delete_reference(continueAbilityCB->cbBase.cbInfo.env, continueAbilityCB->cbBase.cbInfo.callback);
|
||||
continueAbilityCB->cbBase.cbInfo.callback = nullptr;
|
||||
}
|
||||
} else {
|
||||
napi_value result[2] = { nullptr };
|
||||
|
||||
@@ -31,6 +31,7 @@ ohos_shared_library("particleability") {
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/dataobs_manager:dataobs_manager",
|
||||
"${ability_runtime_innerkits_path}/napi_base_context:napi_base_context",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
|
||||
@@ -175,7 +175,7 @@ private:
|
||||
|
||||
napi_value CreateJsUriPermMgr(napi_env env, napi_value exportObj)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::URIPERMMGR, "CreateJsUriPermMgr is called");
|
||||
TAG_LOGD(AAFwkTag::URIPERMMGR, "CreateJsUriPermMgr is called");
|
||||
if (env == nullptr || exportObj == nullptr) {
|
||||
TAG_LOGI(AAFwkTag::URIPERMMGR, "Invalid input parameters");
|
||||
return nullptr;
|
||||
|
||||
@@ -28,7 +28,7 @@ ohos_shared_library("wantagent") {
|
||||
]
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/error_utils:ability_runtime_error_util",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
"${ability_runtime_innerkits_path}/wantagent:wantagent_innerkits",
|
||||
|
||||
@@ -29,7 +29,7 @@ ohos_shared_library("wantagent_napi") {
|
||||
]
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/error_utils:ability_runtime_error_util",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
"${ability_runtime_innerkits_path}/wantagent:wantagent_innerkits",
|
||||
|
||||
@@ -60,6 +60,7 @@ ohos_shared_library("ability_context_native") {
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
"${ability_runtime_napi_path}/inner/napi_common:napi_common",
|
||||
|
||||
@@ -255,8 +255,7 @@ void ConnectionManager::DisconnectNonexistentService(
|
||||
for (auto &&abilityConnection : abilityConnections) {
|
||||
ConnectionInfo connectionInfo = abilityConnection.first;
|
||||
if (connectionInfo.abilityConnection == connection &&
|
||||
connectionInfo.connectReceiver.GetBundleName() == element.GetBundleName() &&
|
||||
connectionInfo.connectReceiver.GetAbilityName() == element.GetAbilityName()) {
|
||||
connectionInfo.connectReceiver.GetBundleName() == element.GetBundleName()) {
|
||||
HILOG_DEBUG("find connection.");
|
||||
exit = true;
|
||||
break;
|
||||
|
||||
@@ -229,6 +229,7 @@ ohos_shared_library("abilitykit_native") {
|
||||
":continuation_ipc",
|
||||
":extension_blocklist_config",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_setting",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:mission_info",
|
||||
"${ability_runtime_innerkits_path}/dataobs_manager:dataobs_manager",
|
||||
@@ -373,6 +374,7 @@ ohos_shared_library("extensionkit_native") {
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
"${ability_runtime_napi_path}/inner/napi_common:napi_common",
|
||||
"${ability_runtime_native_path}/ability:ability_context_native",
|
||||
@@ -426,6 +428,7 @@ ohos_shared_library("insight_intent_executor") {
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
"${ability_runtime_napi_path}/inner/napi_common:napi_common",
|
||||
"${ability_runtime_native_path}/ability/native:ability_business_error",
|
||||
@@ -500,6 +503,7 @@ ohos_shared_library("uiabilitykit_native") {
|
||||
":continuation_ipc",
|
||||
":ui_extension",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_setting",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:process_options",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
@@ -573,6 +577,7 @@ ohos_shared_library("ability_thread") {
|
||||
":extensionkit_native",
|
||||
":uiabilitykit_native",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/dataobs_manager:dataobs_manager",
|
||||
"${ability_runtime_native_path}/ability:ability_context_native",
|
||||
"${ability_runtime_native_path}/appkit:app_context",
|
||||
@@ -704,6 +709,7 @@ ohos_shared_library("service_extension") {
|
||||
deps = [
|
||||
":abilitykit_native",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
"${ability_runtime_napi_path}/inner/napi_common:napi_common",
|
||||
"${ability_runtime_native_path}/ability:ability_context_native",
|
||||
@@ -733,6 +739,7 @@ ohos_shared_library("service_extension") {
|
||||
external_deps += [
|
||||
"image_framework:image",
|
||||
"window_manager:libdm",
|
||||
"window_manager:libwm",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -768,6 +775,7 @@ ohos_shared_library("continuation_ipc") {
|
||||
deps = [
|
||||
":abilitykit_utils",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
@@ -981,6 +989,7 @@ ohos_shared_library("ui_extension") {
|
||||
deps = [
|
||||
":abilitykit_native",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
"${ability_runtime_napi_path}/inner/napi_common:napi_common",
|
||||
"${ability_runtime_native_path}/ability:ability_context_native",
|
||||
@@ -1070,6 +1079,7 @@ ohos_shared_library("share_extension") {
|
||||
":abilitykit_native",
|
||||
":ui_extension",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
"${ability_runtime_napi_path}/inner/napi_common:napi_common",
|
||||
"${ability_runtime_native_path}/ability:ability_context_native",
|
||||
@@ -1120,6 +1130,7 @@ ohos_shared_library("action_extension") {
|
||||
":abilitykit_native",
|
||||
":ui_extension",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
"${ability_runtime_napi_path}/inner/napi_common:napi_common",
|
||||
"${ability_runtime_native_path}/ability:ability_context_native",
|
||||
@@ -1321,6 +1332,7 @@ ohos_shared_library("embedded_ui_extension") {
|
||||
":abilitykit_native",
|
||||
":ui_extension",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
"${ability_runtime_napi_path}/inner/napi_common:napi_common",
|
||||
"${ability_runtime_native_path}/ability:ability_context_native",
|
||||
@@ -1414,6 +1426,7 @@ ohos_shared_library("auto_fill_extension") {
|
||||
":insight_intent_executor",
|
||||
":ui_extension",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
"${ability_runtime_napi_path}/inner/napi_common:napi_common",
|
||||
"${ability_runtime_native_path}/ability:ability_context_native",
|
||||
|
||||
@@ -1649,7 +1649,7 @@ std::string Ability::GetContentInfo()
|
||||
if (scene_ == nullptr) {
|
||||
return "";
|
||||
}
|
||||
return scene_->GetContentInfo();
|
||||
return scene_->GetContentInfo(Rosen::BackupAndRestoreType::CONTINUATION);
|
||||
}
|
||||
|
||||
void Ability::OnWindowFocusChanged(bool hasFocus)
|
||||
|
||||
@@ -78,7 +78,10 @@ constexpr const char* ERROR_MSG_TARGET_BUNDLE_NOT_EXIST = "The target bundle doe
|
||||
constexpr const char* ERROR_MSG_SET_SUPPORTED_PROCESS_CACHE_AGAIN = "Can not set process cache state more than once.";
|
||||
constexpr const char* ERROR_MSG_NO_RESIDENT_PERMISSION =
|
||||
"The caller application can only set the resident status of the configured process.";
|
||||
constexpr const char* ERROR_MSG_APP_TWIN_INDEX_INVALID = "The target app twin with the specified index does not exist.";
|
||||
constexpr const char* ERROR_MSG_MULTI_APP_NOT_SUPPORTED = "App clone or multi-instance is not supported.";
|
||||
constexpr const char* ERROR_MSG_APP_CLONE_INDEX_INVALID =
|
||||
"The target app clone with the specified index does not exist.";
|
||||
constexpr const char* ERROR_MSG_NOT_APP_CLONE = "The target app is not Clone.";
|
||||
|
||||
// follow ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST of appexecfwk_errors.h in bundle_framework
|
||||
constexpr int32_t ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST = 8521220;
|
||||
@@ -132,7 +135,9 @@ static std::unordered_map<AbilityErrorCode, const char*> ERR_CODE_MAP = {
|
||||
{ AbilityErrorCode::ERROR_CODE_TARGET_BUNDLE_NOT_EXIST, ERROR_MSG_TARGET_BUNDLE_NOT_EXIST },
|
||||
{ AbilityErrorCode::ERROR_CODE_SET_SUPPORTED_PROCESS_CACHE_AGAIN, ERROR_MSG_SET_SUPPORTED_PROCESS_CACHE_AGAIN },
|
||||
{ AbilityErrorCode::ERROR_CODE_NO_RESIDENT_PERMISSION, ERROR_MSG_NO_RESIDENT_PERMISSION },
|
||||
{ AbilityErrorCode::ERROR_APP_TWIN_INDEX_INVALID, ERROR_MSG_APP_TWIN_INDEX_INVALID },
|
||||
{ AbilityErrorCode::ERROR_CODE_MULTI_APP_NOT_SUPPORTED, ERROR_MSG_MULTI_APP_NOT_SUPPORTED },
|
||||
{ AbilityErrorCode::ERROR_APP_CLONE_INDEX_INVALID, ERROR_MSG_APP_CLONE_INDEX_INVALID },
|
||||
{ AbilityErrorCode::ERROR_NOT_APP_CLONE, ERROR_MSG_NOT_APP_CLONE },
|
||||
};
|
||||
|
||||
static std::unordered_map<int32_t, AbilityErrorCode> INNER_TO_JS_ERROR_CODE_MAP {
|
||||
@@ -189,7 +194,8 @@ static std::unordered_map<int32_t, AbilityErrorCode> INNER_TO_JS_ERROR_CODE_MAP
|
||||
{ERR_TARGET_BUNDLE_NOT_EXIST, AbilityErrorCode::ERROR_CODE_TARGET_BUNDLE_NOT_EXIST},
|
||||
{ERR_SET_SUPPORTED_PROCESS_CACHE_AGAIN, AbilityErrorCode::ERROR_CODE_SET_SUPPORTED_PROCESS_CACHE_AGAIN},
|
||||
{ERR_NO_RESIDENT_PERMISSION, AbilityErrorCode::ERROR_CODE_NO_RESIDENT_PERMISSION},
|
||||
{ERR_APP_TWIN_INDEX_INVALID, AbilityErrorCode::ERROR_APP_TWIN_INDEX_INVALID},
|
||||
{ERR_MULTI_APP_NOT_SUPPORTED, AbilityErrorCode::ERROR_CODE_MULTI_APP_NOT_SUPPORTED},
|
||||
{ERR_APP_CLONE_INDEX_INVALID, AbilityErrorCode::ERROR_APP_CLONE_INDEX_INVALID},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -609,7 +609,7 @@ void JsAbility::RestorePageStack(const Want &want)
|
||||
auto env = jsRuntime_.GetNapiEnv();
|
||||
if (abilityContext_->GetContentStorage()) {
|
||||
scene_->GetMainWindow()->NapiSetUIContent(pageStack, env,
|
||||
abilityContext_->GetContentStorage()->GetNapiValue(), true);
|
||||
abilityContext_->GetContentStorage()->GetNapiValue(), Rosen::BackupAndRestoreType::CONTINUATION);
|
||||
} else {
|
||||
TAG_LOGE(AAFwkTag::ABILITY, "restore: content storage is nullptr");
|
||||
}
|
||||
|
||||
@@ -1174,7 +1174,7 @@ napi_value JsAbilityContext::OnConnectAbility(napi_env env, NapiCallbackInfo& in
|
||||
// unwrap want
|
||||
AAFwk::Want want;
|
||||
OHOS::AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want);
|
||||
TAG_LOGI(AAFwkTag::CONTEXT, "ConnectAbility, callee:%{public}s.%{public}s",
|
||||
TAG_LOGD(AAFwkTag::CONTEXT, "ConnectAbility, callee:%{public}s.%{public}s",
|
||||
want.GetBundle().c_str(),
|
||||
want.GetElement().GetAbilityName().c_str());
|
||||
|
||||
@@ -1224,8 +1224,7 @@ napi_value JsAbilityContext::OnConnectAbilityWithAccount(napi_env env, NapiCallb
|
||||
AAFwk::Want want;
|
||||
OHOS::AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want);
|
||||
TAG_LOGI(AAFwkTag::CONTEXT, "ConnectAbilityWithAccount, bundlename:%{public}s abilityname:%{public}s",
|
||||
want.GetBundle().c_str(),
|
||||
want.GetElement().GetAbilityName().c_str());
|
||||
want.GetBundle().c_str(), want.GetElement().GetAbilityName().c_str());
|
||||
|
||||
int32_t accountId = 0;
|
||||
if (!OHOS::AppExecFwk::UnwrapInt32FromJS2(env, info.argv[INDEX_ONE], accountId)) {
|
||||
@@ -1685,7 +1684,7 @@ void JSAbilityConnection::SetConnectionId(int64_t id)
|
||||
void JSAbilityConnection::OnAbilityConnectDone(const AppExecFwk::ElementName &element,
|
||||
const sptr<IRemoteObject> &remoteObject, int resultCode)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::CONTEXT, "OnAbilityConnectDone, resultCode:%{public}d", resultCode);
|
||||
TAG_LOGD(AAFwkTag::CONTEXT, "OnAbilityConnectDone, resultCode:%{public}d", resultCode);
|
||||
wptr<JSAbilityConnection> connection = this;
|
||||
std::unique_ptr<NapiAsyncTask::CompleteCallback> complete = std::make_unique<NapiAsyncTask::CompleteCallback>
|
||||
([connection, element, remoteObject, resultCode](napi_env env, NapiAsyncTask &task, int32_t status) {
|
||||
@@ -1706,7 +1705,7 @@ void JSAbilityConnection::OnAbilityConnectDone(const AppExecFwk::ElementName &el
|
||||
void JSAbilityConnection::HandleOnAbilityConnectDone(const AppExecFwk::ElementName &element,
|
||||
const sptr<IRemoteObject> &remoteObject, int resultCode)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::CONTEXT, "HandleOnAbilityConnectDone, resultCode:%{public}d", resultCode);
|
||||
TAG_LOGD(AAFwkTag::CONTEXT, "HandleOnAbilityConnectDone, resultCode:%{public}d", resultCode);
|
||||
if (jsConnectionObject_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::CONTEXT, "jsConnectionObject_ nullptr");
|
||||
return;
|
||||
@@ -1732,7 +1731,7 @@ void JSAbilityConnection::HandleOnAbilityConnectDone(const AppExecFwk::ElementNa
|
||||
|
||||
void JSAbilityConnection::OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::CONTEXT, "OnAbilityDisconnectDone, resultCode:%{public}d", resultCode);
|
||||
TAG_LOGD(AAFwkTag::CONTEXT, "OnAbilityDisconnectDone, resultCode:%{public}d", resultCode);
|
||||
wptr<JSAbilityConnection> connection = this;
|
||||
std::unique_ptr<NapiAsyncTask::CompleteCallback> complete = std::make_unique<NapiAsyncTask::CompleteCallback>
|
||||
([connection, element, resultCode](napi_env env, NapiAsyncTask &task, int32_t status) {
|
||||
|
||||
@@ -706,7 +706,7 @@ void JsUIAbility::RestorePageStack(const Want &want)
|
||||
auto env = jsRuntime_.GetNapiEnv();
|
||||
if (abilityContext_->GetContentStorage()) {
|
||||
scene_->GetMainWindow()->NapiSetUIContent(pageStack, env,
|
||||
abilityContext_->GetContentStorage()->GetNapiValue(), true);
|
||||
abilityContext_->GetContentStorage()->GetNapiValue(), Rosen::BackupAndRestoreType::CONTINUATION);
|
||||
} else {
|
||||
TAG_LOGE(AAFwkTag::UIABILITY, "Content storage is nullptr.");
|
||||
}
|
||||
@@ -728,7 +728,8 @@ void JsUIAbility::AbilityContinuationOrRecover(const Want &want)
|
||||
auto env = jsRuntime_.GetNapiEnv();
|
||||
auto mainWindow = scene_->GetMainWindow();
|
||||
if (mainWindow != nullptr) {
|
||||
mainWindow->NapiSetUIContent(pageStack, env, abilityContext_->GetContentStorage()->GetNapiValue(), true);
|
||||
mainWindow->NapiSetUIContent(pageStack, env, abilityContext_->GetContentStorage()->GetNapiValue(),
|
||||
Rosen::BackupAndRestoreType::CONTINUATION);
|
||||
} else {
|
||||
TAG_LOGE(AAFwkTag::UIABILITY, "MainWindow is nullptr.");
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "bundle_info.h"
|
||||
#include "bundle_mgr_interface.h"
|
||||
#include "child_process.h"
|
||||
#include "native_child_ipc_process.h"
|
||||
#include "child_process_manager_error_utils.h"
|
||||
#include "child_process_start_info.h"
|
||||
#include "constants.h"
|
||||
@@ -115,6 +116,37 @@ ChildProcessManagerErrorCode ChildProcessManager::StartChildProcessByAppSpawnFor
|
||||
return ChildProcessManagerErrorCode::ERR_OK;
|
||||
}
|
||||
|
||||
ChildProcessManagerErrorCode ChildProcessManager::StartNativeChildProcessByAppSpawnFork(
|
||||
const std::string &libName, const sptr<IRemoteObject> &callbackStub)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::PROCESSMGR, "called, libName:%{private}s", libName.c_str());
|
||||
ChildProcessManagerErrorCode errorCode = PreCheckNativeProcess();
|
||||
if (errorCode != ChildProcessManagerErrorCode::ERR_OK) {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
sptr<AppExecFwk::IAppMgr> appMgr = GetAppMgr();
|
||||
if (appMgr == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "GetAppMgr for native child process failed.");
|
||||
return ChildProcessManagerErrorCode::ERR_GET_APP_MGR_FAILED;
|
||||
}
|
||||
|
||||
auto ret = appMgr->StartNativeChildProcess(libName, childProcessCount_, callbackStub);
|
||||
TAG_LOGD(AAFwkTag::PROCESSMGR, "AppMgr StartNativeChildProcess ret:%{public}d", ret);
|
||||
|
||||
if (ret != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "AppMgr StartNativeChildProcess failed, ret:%{public}d", ret);
|
||||
if (ret == ERR_OVERFLOW) {
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "Max native child processes readched");
|
||||
return ChildProcessManagerErrorCode::ERR_MAX_NATIVE_CHILD_PROCESSES;
|
||||
}
|
||||
return ChildProcessManagerErrorCode::ERR_GET_APP_MGR_START_PROCESS_FAILED;
|
||||
}
|
||||
|
||||
++childProcessCount_;
|
||||
return ChildProcessManagerErrorCode::ERR_OK;
|
||||
}
|
||||
|
||||
void ChildProcessManager::RegisterSignal()
|
||||
{
|
||||
if (!signalRegistered_) {
|
||||
@@ -144,6 +176,21 @@ ChildProcessManagerErrorCode ChildProcessManager::PreCheck()
|
||||
return ChildProcessManagerErrorCode::ERR_OK;
|
||||
}
|
||||
|
||||
ChildProcessManagerErrorCode ChildProcessManager::PreCheckNativeProcess()
|
||||
{
|
||||
ChildProcessManagerErrorCode errCode = PreCheck();
|
||||
if (errCode != ChildProcessManagerErrorCode::ERR_OK) {
|
||||
return errCode;
|
||||
}
|
||||
|
||||
if (!AAFwk::AppUtils::GetInstance().IsSupportNativeChildProcess()) {
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "Unsupport native child process");
|
||||
return ChildProcessManagerErrorCode::ERR_UNSUPPORT_NATIVE_CHILD_PROCESS;
|
||||
}
|
||||
|
||||
return ChildProcessManagerErrorCode::ERR_OK;
|
||||
}
|
||||
|
||||
bool ChildProcessManager::IsChildProcess()
|
||||
{
|
||||
return isChildProcessBySelfFork_ || hasChildProcessRecord();
|
||||
@@ -207,6 +254,28 @@ bool ChildProcessManager::LoadJsFile(const std::string &srcEntry, const AppExecF
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChildProcessManager::LoadNativeLib(const std::string &libPath, const sptr<IRemoteObject> &mainProcessCb)
|
||||
{
|
||||
auto childProcess = NativeChildIpcProcess::Create();
|
||||
if (childProcess == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "Failed create NativeChildIpcProcess");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<ChildProcessStartInfo> processStartInfo = std::make_shared<ChildProcessStartInfo>();
|
||||
processStartInfo->name = std::filesystem::path(libPath).stem();
|
||||
processStartInfo->srcEntry = libPath;
|
||||
processStartInfo->ipcObj = mainProcessCb;
|
||||
if (!childProcess->Init(processStartInfo)) {
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "NativeChildIpcProcess init failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
childProcess->OnStart();
|
||||
TAG_LOGD(AAFwkTag::PROCESSMGR, "LoadNativeLib end.");
|
||||
return true;
|
||||
}
|
||||
|
||||
std::unique_ptr<AbilityRuntime::Runtime> ChildProcessManager::CreateRuntime(const AppExecFwk::BundleInfo &bundleInfo,
|
||||
const AppExecFwk::HapModuleInfo &hapModuleInfo, const bool fromAppSpawn, const bool jitEnabled)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "native_child_ipc_process.h"
|
||||
#include <dlfcn.h>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "child_process_manager_error_utils.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
|
||||
std::shared_ptr<ChildProcess> NativeChildIpcProcess::Create()
|
||||
{
|
||||
return std::make_shared<NativeChildIpcProcess>();
|
||||
}
|
||||
|
||||
NativeChildIpcProcess::~NativeChildIpcProcess()
|
||||
{
|
||||
UnloadNativeLib();
|
||||
}
|
||||
|
||||
bool NativeChildIpcProcess::Init(const std::shared_ptr<ChildProcessStartInfo> &info)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::PROCESSMGR, "NativeChildIpcProcess init");
|
||||
if (info == nullptr || info->ipcObj == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "info or ipc callback is null");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!ChildProcess::Init(info)) {
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "Base class init failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
auto iNotify = iface_cast<OHOS::AppExecFwk::INativeChildNotify>(info->ipcObj);
|
||||
if (iNotify == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "Faild cvt interface to INativeChildNotify");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!LoadNativeLib(info)) {
|
||||
iNotify->OnError(static_cast<int32_t>(ChildProcessManagerErrorCode::ERR_NATIVE_CHILD_PROCESS_LOAD_LIB));
|
||||
return false;
|
||||
}
|
||||
|
||||
mainProcessCb_ = iNotify;
|
||||
return true;
|
||||
}
|
||||
|
||||
void NativeChildIpcProcess::OnStart()
|
||||
{
|
||||
if (funcNativeLibOnConnect_ == nullptr || funcNativeLibMainProc_ == nullptr || mainProcessCb_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "No init");
|
||||
return;
|
||||
}
|
||||
|
||||
ChildProcess::OnStart();
|
||||
OHIPCRemoteStub *ipcStub = funcNativeLibOnConnect_();
|
||||
if (ipcStub == nullptr || ipcStub->remote == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "Native lib OnConnect function return null stub");
|
||||
mainProcessCb_->OnError(static_cast<int32_t>(ChildProcessManagerErrorCode::ERR_NATIVE_CHILD_PROCESS_CONNECT));
|
||||
return;
|
||||
}
|
||||
|
||||
std::thread cbThread([this, childIpcStub = std::move(ipcStub->remote)] () -> void {
|
||||
// Wait MainProc run first
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
TAG_LOGI(AAFwkTag::PROCESSMGR, "Notify native child process started");
|
||||
mainProcessCb_->OnNativeChildStarted(childIpcStub);
|
||||
});
|
||||
|
||||
TAG_LOGI(AAFwkTag::PROCESSMGR, "Enter native lib MainProc");
|
||||
funcNativeLibMainProc_();
|
||||
TAG_LOGI(AAFwkTag::PROCESSMGR, "Native lib MainProc returned");
|
||||
|
||||
if (cbThread.joinable()) {
|
||||
cbThread.join();
|
||||
}
|
||||
}
|
||||
|
||||
bool NativeChildIpcProcess::LoadNativeLib(const std::shared_ptr<ChildProcessStartInfo> &info)
|
||||
{
|
||||
if (nativeLibHandle_ != nullptr) {
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "Native lib already loaded");
|
||||
return false;
|
||||
}
|
||||
|
||||
void *libHandle = dlopen(info->srcEntry.c_str(), RTLD_LAZY);
|
||||
if (libHandle == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "Load lib file %{private}s failed, err %{public}s",
|
||||
info->srcEntry.c_str(), dlerror());
|
||||
return false;
|
||||
}
|
||||
|
||||
do {
|
||||
NativeChildProcess_OnConnect funcOnConnect =
|
||||
reinterpret_cast<NativeChildProcess_OnConnect>(dlsym(libHandle, "NativeChildProcess_OnConnect"));
|
||||
if (funcOnConnect == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "Get OnConnect function address failed, err %{public}s", dlerror());
|
||||
break;
|
||||
}
|
||||
|
||||
NativeChildProcess_MainProc funcMainProc =
|
||||
reinterpret_cast<NativeChildProcess_MainProc>(dlsym(libHandle, "NativeChildProcess_MainProc"));
|
||||
if (funcMainProc == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "Get MainProc function address failed, err %{public}s", dlerror());
|
||||
break;
|
||||
}
|
||||
|
||||
funcNativeLibOnConnect_ = funcOnConnect;
|
||||
funcNativeLibMainProc_ = funcMainProc;
|
||||
nativeLibHandle_ = libHandle;
|
||||
return true;
|
||||
} while (false);
|
||||
|
||||
dlclose(libHandle);
|
||||
return false;
|
||||
}
|
||||
|
||||
void NativeChildIpcProcess::UnloadNativeLib()
|
||||
{
|
||||
if (nativeLibHandle_ != nullptr) {
|
||||
dlclose(nativeLibHandle_);
|
||||
nativeLibHandle_ = nullptr;
|
||||
funcNativeLibOnConnect_ = nullptr;
|
||||
funcNativeLibMainProc_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
@@ -41,6 +41,7 @@ void ConfigurationUtils::UpdateGlobalConfig(const Configuration &configuration,
|
||||
std::string colormode;
|
||||
std::string hasPointerDevice;
|
||||
GetGlobalConfig(configuration, language, colormode, hasPointerDevice);
|
||||
std::string colorModeIsSetByApp = configuration.GetItem(AAFwk::GlobalConfigurationKey::COLORMODE_IS_SET_BY_APP);
|
||||
std::unique_ptr<Global::Resource::ResConfig> resConfig(Global::Resource::CreateResConfig());
|
||||
if (resConfig == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITY, "Create resource config failed.");
|
||||
@@ -75,6 +76,11 @@ void ConfigurationUtils::UpdateGlobalConfig(const Configuration &configuration,
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "Update config, hasPointerDevice: %{public}d", resConfig->GetInputDevice());
|
||||
}
|
||||
|
||||
if (!colorModeIsSetByApp.empty()) {
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "set app true");
|
||||
resConfig->SetAppColorMode(true);
|
||||
}
|
||||
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, "resourceManager->UpdateResConfig");
|
||||
Global::Resource::RState ret = resourceManager->UpdateResConfig(*resConfig);
|
||||
if (ret != Global::Resource::RState::SUCCESS) {
|
||||
|
||||
@@ -351,8 +351,7 @@ bool DataAbilityOperation::Marshalling(Parcel &out) const
|
||||
}
|
||||
int referenceSize = (int)dataAbilityPredicatesBackReferences_.size();
|
||||
if (dataAbilityPredicatesBackReferences_.empty()) {
|
||||
TAG_LOGD(
|
||||
AAFwkTag::DATA_ABILITY, "DataAbilityOperation::Marshalling dataAbilityPredicatesBackReferences_ is empty");
|
||||
TAG_LOGD(AAFwkTag::DATA_ABILITY, "DataAbilityOperation::Marshalling dataAbilityPredicatesBackReferences_:null");
|
||||
if (!out.WriteInt32(referenceSize)) {
|
||||
TAG_LOGE(AAFwkTag::DATA_ABILITY, "DataAbilityOperation::Marshalling WriteInt32(VALUE_OBJECT) error");
|
||||
return false;
|
||||
|
||||
@@ -219,7 +219,13 @@ void JsServiceExtension::ListenWMS()
|
||||
return;
|
||||
}
|
||||
|
||||
auto listener = sptr<SystemAbilityStatusChangeListener>::MakeSptr(displayListener_);
|
||||
auto context = GetContext();
|
||||
if (context == nullptr || context->GetToken()) {
|
||||
TAG_LOGE(AAFwkTag::SERVICE_EXT, "Param invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
auto listener = sptr<SystemAbilityStatusChangeListener>::MakeSptr(displayListener_, context->GetToken());
|
||||
if (listener == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::SERVICE_EXT, "Failed to create status change listener.");
|
||||
return;
|
||||
@@ -237,7 +243,8 @@ void JsServiceExtension::SystemAbilityStatusChangeListener::OnAddSystemAbility(i
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::SERVICE_EXT, "systemAbilityId: %{public}d add", systemAbilityId);
|
||||
if (systemAbilityId == WINDOW_MANAGER_SERVICE_ID) {
|
||||
Rosen::DisplayManager::GetInstance().RegisterDisplayListener(tmpDisplayListener_);
|
||||
TAG_LOGI(AAFwkTag::SERVICE_EXT, "RegisterDisplayInfoChangedListener");
|
||||
Rosen::WindowManager::GetInstance().RegisterDisplayInfoChangedListener(token_, tmpDisplayListener_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,7 +322,14 @@ void JsServiceExtension::OnStop()
|
||||
ConnectionManager::GetInstance().ReportConnectionLeakEvent(getpid(), gettid());
|
||||
TAG_LOGD(AAFwkTag::SERVICE_EXT, "The service extension connection is not disconnected.");
|
||||
}
|
||||
Rosen::DisplayManager::GetInstance().UnregisterDisplayListener(displayListener_);
|
||||
TAG_LOGI(AAFwkTag::SERVICE_EXT, "UnregisterDisplayInfoChangedListener");
|
||||
auto context = GetContext();
|
||||
if (context == nullptr || context->GetToken()) {
|
||||
TAG_LOGE(AAFwkTag::SERVICE_EXT, "Param invalid.");
|
||||
return;
|
||||
}
|
||||
Rosen::WindowManager::GetInstance()
|
||||
.UnregisterDisplayInfoChangedListener(context->GetToken(), displayListener_);
|
||||
TAG_LOGD(AAFwkTag::SERVICE_EXT, "ok");
|
||||
}
|
||||
|
||||
@@ -451,8 +465,7 @@ bool JsServiceExtension::HandleInsightIntent(const AAFwk::Want &want)
|
||||
static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INVALID_PARAM));
|
||||
return false;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::SERVICE_EXT,
|
||||
"Insight intent bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s"
|
||||
TAG_LOGD(AAFwkTag::SERVICE_EXT, "Insight bundleName: %{public}s, moduleName: %{public}s, abilityName: %{public}s"
|
||||
"insightIntentName: %{public}s, executeMode: %{public}d, intentId: %{public}" PRIu64 "",
|
||||
executeParam->bundleName_.c_str(), executeParam->moduleName_.c_str(), executeParam->abilityName_.c_str(),
|
||||
executeParam->insightIntentName_.c_str(), executeParam->executeMode_, executeParam->insightIntentId_);
|
||||
@@ -799,6 +812,43 @@ void JsServiceExtension::OnDestroy(Rosen::DisplayId displayId)
|
||||
TAG_LOGD(AAFwkTag::SERVICE_EXT, "exit.");
|
||||
}
|
||||
|
||||
void JsServiceExtension::OnDisplayInfoChange(const sptr<IRemoteObject>& token, Rosen::DisplayId displayId,
|
||||
float density, Rosen::DisplayOrientation orientation)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::SERVICE_EXT, "displayId: %{public}" PRIu64, displayId);
|
||||
auto context = GetContext();
|
||||
if (context == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::SERVICE_EXT, "Context is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
auto contextConfig = context->GetConfiguration();
|
||||
if (contextConfig == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::SERVICE_EXT, "Configuration is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
TAG_LOGD(AAFwkTag::SERVICE_EXT, "Config dump: %{public}s", contextConfig->GetName().c_str());
|
||||
bool configChanged = false;
|
||||
auto configUtils = std::make_shared<ConfigurationUtils>();
|
||||
configUtils->UpdateDisplayConfig(displayId, contextConfig, context->GetResourceManager(), configChanged);
|
||||
TAG_LOGD(AAFwkTag::SERVICE_EXT, "Config dump after update: %{public}s", contextConfig->GetName().c_str());
|
||||
|
||||
if (configChanged) {
|
||||
auto jsServiceExtension = std::static_pointer_cast<JsServiceExtension>(shared_from_this());
|
||||
auto task = [jsServiceExtension]() {
|
||||
if (jsServiceExtension) {
|
||||
jsServiceExtension->ConfigurationUpdated();
|
||||
}
|
||||
};
|
||||
if (handler_ != nullptr) {
|
||||
handler_->PostTask(task, "JsServiceExtension:OnChange");
|
||||
}
|
||||
}
|
||||
|
||||
TAG_LOGD(AAFwkTag::SERVICE_EXT, "finished.");
|
||||
}
|
||||
|
||||
void JsServiceExtension::OnChange(Rosen::DisplayId displayId)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::SERVICE_EXT, "displayId: %{public}" PRIu64"", displayId);
|
||||
|
||||
@@ -210,7 +210,7 @@ private:
|
||||
napi_value OnStartAbility(napi_env env, NapiCallbackInfo& info, bool isStartRecent = false)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
TAG_LOGI(AAFwkTag::SERVICE_EXT, "StartAbility");
|
||||
TAG_LOGD(AAFwkTag::SERVICE_EXT, "StartAbility");
|
||||
if (info.argc < ARGC_ONE) {
|
||||
TAG_LOGE(AAFwkTag::SERVICE_EXT, "Start ability failed, not enough params.");
|
||||
ThrowTooFewParametersError(env);
|
||||
@@ -782,7 +782,7 @@ private:
|
||||
|
||||
napi_value OnDisconnectAbility(napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::SERVICE_EXT, "DisconnectAbility start");
|
||||
TAG_LOGD(AAFwkTag::SERVICE_EXT, "DisconnectAbility start");
|
||||
if (info.argc < ARGC_ONE) {
|
||||
TAG_LOGE(AAFwkTag::SERVICE_EXT, "Disconnect ability error, not enough params.");
|
||||
ThrowTooFewParametersError(env);
|
||||
@@ -1077,7 +1077,7 @@ private:
|
||||
return;
|
||||
}
|
||||
if (*retCode == 0) {
|
||||
TAG_LOGI(AAFwkTag::SERVICE_EXT, "StartAbility is success");
|
||||
TAG_LOGD(AAFwkTag::SERVICE_EXT, "StartAbility is success");
|
||||
task.Resolve(env, CreateJsUndefined(env));
|
||||
} else {
|
||||
task.Reject(env, CreateJsErrorByNativeErr(env, *retCode));
|
||||
@@ -1277,7 +1277,7 @@ void JSServiceExtensionConnection::OnAbilityDisconnectDone(const AppExecFwk::Ele
|
||||
void JSServiceExtensionConnection::HandleOnAbilityDisconnectDone(const AppExecFwk::ElementName &element,
|
||||
int resultCode)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::SERVICE_EXT, "HandleOnAbilityDisconnectDone, resultCode:%{public}d", resultCode);
|
||||
TAG_LOGD(AAFwkTag::SERVICE_EXT, "HandleOnAbilityDisconnectDone, resultCode:%{public}d", resultCode);
|
||||
napi_value napiElementName = OHOS::AppExecFwk::WrapElementName(env_, element);
|
||||
napi_value argv[] = {napiElementName};
|
||||
if (jsConnectionObject_ == nullptr) {
|
||||
|
||||
@@ -93,7 +93,8 @@ void UIAbility::Init(std::shared_ptr<AppExecFwk::AbilityLocalRecord> record,
|
||||
TAG_LOGE(AAFwkTag::UIABILITY, "abilityDisplayListener_ is nullptr.");
|
||||
return;
|
||||
}
|
||||
Rosen::DisplayManager::GetInstance().RegisterDisplayListener(abilityDisplayListener_);
|
||||
TAG_LOGI(AAFwkTag::UIABILITY, "RegisterDisplayInfoChangedListener.");
|
||||
Rosen::WindowManager::GetInstance().RegisterDisplayInfoChangedListener(token_, abilityDisplayListener_);
|
||||
#endif
|
||||
lifecycle_ = std::make_shared<AppExecFwk::LifeCycle>();
|
||||
abilityLifecycleExecutor_ = std::make_shared<AppExecFwk::AbilityLifecycleExecutor>();
|
||||
@@ -185,7 +186,8 @@ void UIAbility::OnStop()
|
||||
if (abilityRecovery_ != nullptr) {
|
||||
abilityRecovery_->ScheduleSaveAbilityState(AppExecFwk::StateReason::LIFECYCLE);
|
||||
}
|
||||
(void)Rosen::DisplayManager::GetInstance().UnregisterDisplayListener(abilityDisplayListener_);
|
||||
TAG_LOGI(AAFwkTag::UIABILITY, "UnregisterDisplayInfoChangedListener.");
|
||||
(void)Rosen::WindowManager::GetInstance().UnregisterDisplayInfoChangedListener(token_, abilityDisplayListener_);
|
||||
auto &&window = GetWindow();
|
||||
if (window != nullptr) {
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "Call UnregisterDisplayMoveListener.");
|
||||
@@ -240,10 +242,6 @@ bool UIAbility::IsRestoredInContinuation() const
|
||||
return false;
|
||||
}
|
||||
|
||||
if (abilityContext_->GetContentStorage() == nullptr) {
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "Get content failed.");
|
||||
return false;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "End.");
|
||||
return true;
|
||||
}
|
||||
@@ -293,6 +291,7 @@ void UIAbility::OnConfigurationUpdatedNotify(const AppExecFwk::Configuration &co
|
||||
std::string colormode;
|
||||
std::string hasPointerDevice;
|
||||
InitConfigurationProperties(configuration, language, colormode, hasPointerDevice);
|
||||
std::string colorModeIsSetByApp = configuration.GetItem(AAFwk::GlobalConfigurationKey::COLORMODE_IS_SET_BY_APP);
|
||||
// Notify ResourceManager
|
||||
std::unique_ptr<Global::Resource::ResConfig> resConfig(Global::Resource::CreateResConfig());
|
||||
if (resConfig == nullptr) {
|
||||
@@ -318,6 +317,10 @@ void UIAbility::OnConfigurationUpdatedNotify(const AppExecFwk::Configuration &co
|
||||
if (!hasPointerDevice.empty()) {
|
||||
resConfig->SetInputDevice(AppExecFwk::ConvertHasPointerDevice(hasPointerDevice));
|
||||
}
|
||||
if (!colorModeIsSetByApp.empty()) {
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "set app true");
|
||||
resConfig->SetAppColorMode(true);
|
||||
}
|
||||
resourceManager->UpdateResConfig(*resConfig);
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "Current colorMode: %{public}d, hasPointerDevice: %{public}d.",
|
||||
resConfig->GetColorMode(), resConfig->GetInputDevice());
|
||||
@@ -798,6 +801,49 @@ void UIAbility::OnDestroy(Rosen::DisplayId displayId)
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "Called.");
|
||||
}
|
||||
|
||||
void UIAbility::OnDisplayInfoChange(const sptr<IRemoteObject>& token, Rosen::DisplayId displayId, float density,
|
||||
Rosen::DisplayOrientation orientation)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::UIABILITY, "Begin displayId: %{public}" PRIu64, displayId);
|
||||
// Get display
|
||||
auto display = Rosen::DisplayManager::GetInstance().GetDisplayById(displayId);
|
||||
if (!display) {
|
||||
TAG_LOGE(AAFwkTag::UIABILITY, "Get display by displayId %{public}" PRIu64 " failed.", displayId);
|
||||
return;
|
||||
}
|
||||
|
||||
// Notify ResourceManager
|
||||
int32_t width = display->GetWidth();
|
||||
int32_t height = display->GetHeight();
|
||||
std::unique_ptr<Global::Resource::ResConfig> resConfig(Global::Resource::CreateResConfig());
|
||||
if (resConfig != nullptr) {
|
||||
auto resourceManager = GetResourceManager();
|
||||
if (resourceManager != nullptr) {
|
||||
resourceManager->GetResConfig(*resConfig);
|
||||
resConfig->SetScreenDensity(density);
|
||||
resConfig->SetDirection(AppExecFwk::ConvertDirection(height, width));
|
||||
resourceManager->UpdateResConfig(*resConfig);
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "Notify ResourceManager, Density: %{public}f, Direction: %{public}d",
|
||||
resConfig->GetScreenDensity(), resConfig->GetDirection());
|
||||
}
|
||||
}
|
||||
|
||||
// Notify ability
|
||||
Configuration newConfig;
|
||||
newConfig.AddItem(
|
||||
displayId, AppExecFwk::ConfigurationInner::APPLICATION_DIRECTION, AppExecFwk::GetDirectionStr(height, width));
|
||||
newConfig.AddItem(
|
||||
displayId, AppExecFwk::ConfigurationInner::APPLICATION_DENSITYDPI, AppExecFwk::GetDensityStr(density));
|
||||
|
||||
if (application_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::UIABILITY, "application_ is nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
OnChangeForUpdateConfiguration(newConfig);
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "End.");
|
||||
}
|
||||
|
||||
void UIAbility::OnChange(Rosen::DisplayId displayId)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "Begin displayId: %{public}" PRIu64 "", displayId);
|
||||
@@ -1021,11 +1067,6 @@ void UIAbility::OnChangeForUpdateConfiguration(const AppExecFwk::Configuration &
|
||||
ability->OnConfigurationUpdated(configuration);
|
||||
};
|
||||
handler_->PostTask(task);
|
||||
|
||||
auto diffConfiguration = std::make_shared<AppExecFwk::Configuration>(newConfig);
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "Update display config %{public}s for all windows.",
|
||||
diffConfiguration->GetName().c_str());
|
||||
Rosen::Window::UpdateConfigurationForAll(diffConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -368,7 +368,7 @@ void UIAbilityImpl::UpdateSilentForeground(const AAFwk::LifeCycleStateInfo &targ
|
||||
}
|
||||
if (lifecycleState_ == AAFwk::ABILITY_STATE_INITIAL &&
|
||||
sessionInfo && sessionInfo->processOptions &&
|
||||
AAFwk::ProcessOptions::IsNewProcessMode(sessionInfo->processOptions->processMode) &&
|
||||
AAFwk::ProcessOptions::IsValidProcessMode(sessionInfo->processOptions->processMode) &&
|
||||
sessionInfo->processOptions->startupVisibility == AAFwk::StartupVisibility::STARTUP_HIDE) {
|
||||
TAG_LOGI(AAFwkTag::UIABILITY, "Set IsSilentForeground to true.");
|
||||
ability_->SetIsSilentForeground(true);
|
||||
|
||||
@@ -782,7 +782,7 @@ void JsUIExtension::DestroyWindow(const sptr<AAFwk::SessionInfo> &sessionInfo)
|
||||
CallObjectMethod("onSessionDestroy", argv, ARGC_ONE);
|
||||
}
|
||||
}
|
||||
auto& uiWindow = uiWindowMap_[componentId];
|
||||
auto uiWindow = uiWindowMap_[componentId];
|
||||
if (uiWindow) {
|
||||
uiWindow->Destroy();
|
||||
}
|
||||
|
||||
+43
-27
@@ -564,26 +564,8 @@ napi_value JsUIExtensionContentSession::OnTerminateSelfWithResult(napi_env env,
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
NapiAsyncTask::CompleteCallback complete =
|
||||
[uiWindow = uiWindow_, sessionInfo = sessionInfo_, want, resultCode](napi_env env,
|
||||
NapiAsyncTask& task, int32_t status) {
|
||||
if (uiWindow == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "uiWindow is nullptr.");
|
||||
task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INNER));
|
||||
return;
|
||||
}
|
||||
auto ret = uiWindow->TransferAbilityResult(resultCode, want);
|
||||
if (ret != Rosen::WMError::WM_OK) {
|
||||
task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INNER));
|
||||
return;
|
||||
}
|
||||
auto errorCode = AAFwk::AbilityManagerClient::GetInstance()->TerminateUIExtensionAbility(sessionInfo);
|
||||
if (errorCode == 0) {
|
||||
task.ResolveWithNoError(env, CreateJsUndefined(env));
|
||||
} else {
|
||||
task.Reject(env, CreateJsErrorByNativeErr(env, errorCode));
|
||||
}
|
||||
};
|
||||
NapiAsyncTask::CompleteCallback complete;
|
||||
SetCallbackForTerminateWithResult(resultCode, want, complete);
|
||||
|
||||
napi_value lastParam = (info.argc > ARGC_ONE) ? info.argv[INDEX_ONE] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
@@ -633,7 +615,7 @@ napi_value JsUIExtensionContentSession::OnSetReceiveDataCallback(napi_env env, N
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
|
||||
if (!CheckTypeForNapiValue(env, info.argv[INDEX_ZERO], napi_function)) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "invalid param");
|
||||
ThrowInvalidParamError(env, "Parameter error: Callback must be a function.");
|
||||
@@ -681,7 +663,7 @@ napi_value JsUIExtensionContentSession::OnSetReceiveDataForResultCallback(napi_e
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
|
||||
if (!CheckTypeForNapiValue(env, info.argv[INDEX_ZERO], napi_function)) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "invalid param");
|
||||
ThrowInvalidParamError(env, "Parameter error: Callback must be a function.");
|
||||
@@ -733,7 +715,7 @@ napi_value JsUIExtensionContentSession::OnLoadContent(napi_env env, NapiCallback
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
|
||||
if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], contextPath)) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "invalid param");
|
||||
ThrowInvalidParamError(env, "Parameter error: Path must be a string.");
|
||||
@@ -761,7 +743,8 @@ napi_value JsUIExtensionContentSession::OnLoadContent(napi_env env, NapiCallback
|
||||
isFirstTriggerBindModal_ = false;
|
||||
}
|
||||
sptr<IRemoteObject> parentToken = sessionInfo_->parentToken;
|
||||
Rosen::WMError ret = uiWindow_->NapiSetUIContent(contextPath, env, storage, false, parentToken);
|
||||
Rosen::WMError ret = uiWindow_->NapiSetUIContent(contextPath, env, storage,
|
||||
Rosen::BackupAndRestoreType::NONE, parentToken);
|
||||
if (ret == Rosen::WMError::WM_OK) {
|
||||
TAG_LOGD(AAFwkTag::UI_EXT, "NapiSetUIContent success");
|
||||
} else {
|
||||
@@ -781,7 +764,7 @@ napi_value JsUIExtensionContentSession::OnSetWindowBackgroundColor(napi_env env,
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
|
||||
if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], color)) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "invalid param");
|
||||
ThrowInvalidParamError(env, "Parameter error: Parse color failed! Color must be a string.");
|
||||
@@ -812,7 +795,7 @@ napi_value JsUIExtensionContentSession::OnSetWindowPrivacyMode(napi_env env, Nap
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
|
||||
if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], isPrivacyMode)) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "invalid param");
|
||||
ThrowInvalidParamError(env, "Parameter error: Failed to parse isPrivacyMode! IsPrivacyMode must be a boolean.");
|
||||
@@ -849,7 +832,7 @@ napi_value JsUIExtensionContentSession::OnSetWindowPrivacyMode(napi_env env, Nap
|
||||
napi_value JsUIExtensionContentSession::OnStartAbilityByType(napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::UI_EXT, "called");
|
||||
|
||||
|
||||
std::string type;
|
||||
AAFwk::WantParams wantParam;
|
||||
|
||||
@@ -1084,5 +1067,38 @@ void JsUIExtensionContentSession::AddFreeInstallObserver(napi_env env,
|
||||
bundleName, abilityName, startTime, callback, result, isAbilityResult);
|
||||
}
|
||||
}
|
||||
|
||||
void JsUIExtensionContentSession::SetCallbackForTerminateWithResult(int32_t resultCode, AAFwk::Want& want,
|
||||
NapiAsyncTask::CompleteCallback& complete)
|
||||
{
|
||||
complete =
|
||||
[weak = context_, uiWindow = uiWindow_, sessionInfo = sessionInfo_, want, resultCode](napi_env env,
|
||||
NapiAsyncTask& task, int32_t status) {
|
||||
auto extensionContext = AbilityRuntime::Context::ConvertTo<AbilityRuntime::UIExtensionContext>(weak.lock());
|
||||
if (!extensionContext) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "extensionContext is nullptr");
|
||||
task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INVALID_CONTEXT));
|
||||
return;
|
||||
}
|
||||
auto token = extensionContext->GetToken();
|
||||
AAFwk::AbilityManagerClient::GetInstance()->TransferAbilityResultForExtension(token, resultCode, want);
|
||||
if (uiWindow == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "uiWindow is nullptr.");
|
||||
task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INNER));
|
||||
return;
|
||||
}
|
||||
auto ret = uiWindow->TransferAbilityResult(resultCode, want);
|
||||
if (ret != Rosen::WMError::WM_OK) {
|
||||
task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INNER));
|
||||
return;
|
||||
}
|
||||
auto errorCode = AAFwk::AbilityManagerClient::GetInstance()->TerminateUIExtensionAbility(sessionInfo);
|
||||
if (errorCode == 0) {
|
||||
task.ResolveWithNoError(env, CreateJsUndefined(env));
|
||||
} else {
|
||||
task.Reject(env, CreateJsErrorByNativeErr(env, errorCode));
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -428,33 +428,8 @@ napi_value JsUIExtensionContext::OnTerminateSelfWithResult(napi_env env, NapiCal
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
NapiAsyncTask::CompleteCallback complete =
|
||||
[weak = context_, want, resultCode](napi_env env, NapiAsyncTask& task, int32_t status) {
|
||||
auto context = weak.lock();
|
||||
if (!context) {
|
||||
TAG_LOGW(AAFwkTag::UI_EXT, "context is released");
|
||||
task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM));
|
||||
return;
|
||||
}
|
||||
sptr<Rosen::Window> uiWindow = context->GetWindow();
|
||||
if (uiWindow == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "uiWindow is nullptr");
|
||||
task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM));
|
||||
return;
|
||||
}
|
||||
auto ret = uiWindow->TransferAbilityResult(resultCode, want);
|
||||
if (ret != Rosen::WMError::WM_OK) {
|
||||
task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM));
|
||||
return;
|
||||
}
|
||||
auto errorCode = context->TerminateSelf();
|
||||
if (errorCode == 0) {
|
||||
task.ResolveWithNoError(env, CreateJsUndefined(env));
|
||||
} else {
|
||||
task.Reject(env, CreateJsErrorByNativeErr(env, errorCode));
|
||||
}
|
||||
};
|
||||
|
||||
NapiAsyncTask::CompleteCallback complete;
|
||||
SetCallbackForTerminateWithResult(resultCode, want, complete);
|
||||
napi_value lastParam = (info.argc > ARGC_ONE) ? info.argv[INDEX_ONE] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::ScheduleHighQos("JsUIExtensionContext::OnTerminateSelfWithResult",
|
||||
@@ -666,6 +641,45 @@ napi_value JsUIExtensionContext::OnOpenAtomicService(napi_env env, NapiCallbackI
|
||||
return OpenAtomicServiceInner(env, info, want, startOptions, unwrapArgc);
|
||||
}
|
||||
|
||||
void JsUIExtensionContext::SetCallbackForTerminateWithResult(int32_t resultCode, AAFwk::Want& want,
|
||||
NapiAsyncTask::CompleteCallback& complete)
|
||||
{
|
||||
complete =
|
||||
[weak = context_, want, resultCode](napi_env env, NapiAsyncTask& task, int32_t status) {
|
||||
auto context = weak.lock();
|
||||
if (!context) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "context is released");
|
||||
task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INVALID_CONTEXT));
|
||||
return;
|
||||
}
|
||||
auto extensionContext = AbilityRuntime::Context::ConvertTo<AbilityRuntime::UIExtensionContext>(context);
|
||||
if (!extensionContext) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "extensionContext is nullptr");
|
||||
task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM));
|
||||
return;
|
||||
}
|
||||
auto token = extensionContext->GetToken();
|
||||
AAFwk::AbilityManagerClient::GetInstance()->TransferAbilityResultForExtension(token, resultCode, want);
|
||||
sptr<Rosen::Window> uiWindow = context->GetWindow();
|
||||
if (!uiWindow) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "uiWindow is nullptr");
|
||||
task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM));
|
||||
return;
|
||||
}
|
||||
auto ret = uiWindow->TransferAbilityResult(resultCode, want);
|
||||
if (ret != Rosen::WMError::WM_OK) {
|
||||
task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM));
|
||||
return;
|
||||
}
|
||||
auto errorCode = context->TerminateSelf();
|
||||
if (errorCode == 0) {
|
||||
task.ResolveWithNoError(env, CreateJsUndefined(env));
|
||||
} else {
|
||||
task.Reject(env, CreateJsErrorByNativeErr(env, errorCode));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
napi_value JsUIExtensionContext::OpenAtomicServiceInner(napi_env env, NapiCallbackInfo& info, Want &want,
|
||||
const AAFwk::StartOptions &options, size_t unwrapArgc)
|
||||
{
|
||||
|
||||
@@ -48,7 +48,6 @@ config("appkit_config") {
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit/app",
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit/dfr",
|
||||
"${ability_runtime_path}/interfaces/kits/native/ability/native",
|
||||
"//third_party/json/include",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -150,6 +149,7 @@ ohos_shared_library("appkit_native") {
|
||||
":appkit_delegator",
|
||||
"${ability_runtime_abilitymgr_path}/:abilityms",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/app_manager:app_manager",
|
||||
"${ability_runtime_innerkits_path}/child_process_manager:child_process_manager",
|
||||
"${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper",
|
||||
@@ -187,6 +187,7 @@ ohos_shared_library("appkit_native") {
|
||||
"i18n:preferred_language",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
"json:nlohmann_json_static",
|
||||
"napi:ace_napi",
|
||||
"resource_management:global_resmgr",
|
||||
"safwk:system_ability_fwk",
|
||||
@@ -267,6 +268,7 @@ ohos_shared_library("app_context") {
|
||||
}
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/app_manager:app_manager",
|
||||
"${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
@@ -284,6 +286,7 @@ ohos_shared_library("app_context") {
|
||||
"hitrace:hitrace_meter",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
"json:nlohmann_json_static",
|
||||
"napi:ace_napi",
|
||||
"resource_management:global_resmgr",
|
||||
"samgr:samgr_proxy",
|
||||
@@ -325,6 +328,7 @@ ohos_shared_library("app_context_utils") {
|
||||
}
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/app_manager:app_manager",
|
||||
"${ability_runtime_innerkits_path}/error_utils:ability_runtime_error_util",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
@@ -344,6 +348,7 @@ ohos_shared_library("app_context_utils") {
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_core",
|
||||
"json:nlohmann_json_static",
|
||||
"napi:ace_napi",
|
||||
"resource_management:global_resmgr",
|
||||
"resource_management:resmgr_napi_core",
|
||||
@@ -397,6 +402,7 @@ ohos_shared_library("appkit_delegator") {
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
"${ability_runtime_native_path}/appkit:app_context",
|
||||
"${ability_runtime_native_path}/appkit:delegator_mgmt",
|
||||
@@ -410,6 +416,7 @@ ohos_shared_library("appkit_delegator") {
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"json:nlohmann_json_static",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
public_external_deps = [ "ability_base:configuration" ]
|
||||
@@ -464,6 +471,7 @@ ohos_shared_library("appkit_manager_helper") {
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_core",
|
||||
"json:nlohmann_json_static",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ ErrCode BundleMgrHelper::InstallSandboxApp(const std::string &bundleName, int32_
|
||||
ErrCode BundleMgrHelper::UninstallSandboxApp(const std::string &bundleName, int32_t appIndex, int32_t userId)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called.");
|
||||
if (bundleName.empty() || appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) {
|
||||
if (bundleName.empty() || appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) {
|
||||
TAG_LOGE(AAFwkTag::BUNDLEMGRHELPER, "The params are invalid.");
|
||||
return ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR;
|
||||
}
|
||||
@@ -113,7 +113,7 @@ ErrCode BundleMgrHelper::GetSandboxBundleInfo(
|
||||
const std::string &bundleName, int32_t appIndex, int32_t userId, BundleInfo &info)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called.");
|
||||
if (bundleName.empty() || appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) {
|
||||
if (bundleName.empty() || appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) {
|
||||
TAG_LOGE(AAFwkTag::BUNDLEMGRHELPER, "The params are invalid.");
|
||||
return ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR;
|
||||
}
|
||||
@@ -131,7 +131,7 @@ ErrCode BundleMgrHelper::GetSandboxAbilityInfo(const Want &want, int32_t appInde
|
||||
AbilityInfo &abilityInfo)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called.");
|
||||
if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) {
|
||||
if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) {
|
||||
TAG_LOGE(AAFwkTag::BUNDLEMGRHELPER, "The params are invalid.");
|
||||
return ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR;
|
||||
}
|
||||
@@ -152,7 +152,7 @@ ErrCode BundleMgrHelper::GetSandboxExtAbilityInfos(const Want &want, int32_t app
|
||||
int32_t userId, std::vector<ExtensionAbilityInfo> &extensionInfos)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called.");
|
||||
if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) {
|
||||
if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) {
|
||||
TAG_LOGE(AAFwkTag::BUNDLEMGRHELPER, "The params are invalid.");
|
||||
return ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR;
|
||||
}
|
||||
@@ -170,7 +170,7 @@ ErrCode BundleMgrHelper::GetSandboxHapModuleInfo(const AbilityInfo &abilityInfo,
|
||||
HapModuleInfo &hapModuleInfo)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called.");
|
||||
if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) {
|
||||
if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) {
|
||||
TAG_LOGE(AAFwkTag::BUNDLEMGRHELPER, "The params are invalid.");
|
||||
return ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR;
|
||||
}
|
||||
@@ -798,7 +798,7 @@ ErrCode BundleMgrHelper::GetLaunchWantForBundle(const std::string &bundleName, W
|
||||
return bundleMgr->GetLaunchWantForBundle(bundleName, want, userId);
|
||||
}
|
||||
|
||||
ErrCode BundleMgrHelper::QueryCloneAbilityInfo(const ElementName &element, int32_t flags, int32_t appTwinIndex,
|
||||
ErrCode BundleMgrHelper::QueryCloneAbilityInfo(const ElementName &element, int32_t flags, int32_t appCloneIndex,
|
||||
AbilityInfo &abilityInfo, int32_t userId)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called.");
|
||||
@@ -808,10 +808,10 @@ ErrCode BundleMgrHelper::QueryCloneAbilityInfo(const ElementName &element, int32
|
||||
return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
return bundleMgr->QueryCloneAbilityInfo(element, flags, appTwinIndex, abilityInfo, userId);
|
||||
return bundleMgr->QueryCloneAbilityInfo(element, flags, appCloneIndex, abilityInfo, userId);
|
||||
}
|
||||
|
||||
ErrCode BundleMgrHelper::GetCloneBundleInfo(const std::string &bundleName, int32_t flags, int32_t appTwinIndex,
|
||||
ErrCode BundleMgrHelper::GetCloneBundleInfo(const std::string &bundleName, int32_t flags, int32_t appCloneIndex,
|
||||
BundleInfo &bundleInfo, int32_t userId)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called.");
|
||||
@@ -821,7 +821,7 @@ ErrCode BundleMgrHelper::GetCloneBundleInfo(const std::string &bundleName, int32
|
||||
return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
return bundleMgr->GetCloneBundleInfo(bundleName, flags, appTwinIndex, bundleInfo, userId);
|
||||
return bundleMgr->GetCloneBundleInfo(bundleName, flags, appCloneIndex, bundleInfo, userId);
|
||||
}
|
||||
|
||||
} // namespace AppExecFwk
|
||||
|
||||
@@ -117,7 +117,8 @@ void AbilityStage::OnMemoryLevel(int level)
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "%{public}s called.", __func__);
|
||||
}
|
||||
|
||||
int32_t AbilityStage::RunAutoStartupTask(const std::function<void()> &callback, bool &isAsyncCallback)
|
||||
int32_t AbilityStage::RunAutoStartupTask(const std::function<void()> &callback, bool &isAsyncCallback,
|
||||
const std::shared_ptr<Context> &stageContext)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "called");
|
||||
isAsyncCallback = false;
|
||||
|
||||
@@ -169,39 +169,8 @@ void JsAbilityStage::Init(const std::shared_ptr<Context> &context,
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "stage is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
auto env = jsRuntime_.GetNapiEnv();
|
||||
|
||||
napi_value obj = jsAbilityStageObj_->GetNapiValue();
|
||||
if (!CheckTypeForNapiValue(env, obj, napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "Failed to get AbilityStage object");
|
||||
return;
|
||||
}
|
||||
|
||||
napi_value contextObj = CreateJsAbilityStageContext(env, context, nullptr, nullptr);
|
||||
shellContextRef_ = JsRuntime::LoadSystemModuleByEngine(env, "application.AbilityStageContext", &contextObj, 1);
|
||||
if (shellContextRef_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "Failed to get LoadSystemModuleByEngine");
|
||||
return;
|
||||
}
|
||||
contextObj = shellContextRef_->GetNapiValue();
|
||||
if (!CheckTypeForNapiValue(env, contextObj, napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "Failed to get context native object");
|
||||
return;
|
||||
}
|
||||
auto workContext = new (std::nothrow) std::weak_ptr<AbilityRuntime::Context>(context);
|
||||
napi_coerce_to_native_binding_object(
|
||||
env, contextObj, DetachCallbackFunc, AttachAbilityStageContext, workContext, nullptr);
|
||||
context->Bind(jsRuntime_, shellContextRef_.get());
|
||||
napi_set_named_property(env, obj, "context", contextObj);
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "Set ability stage context");
|
||||
napi_wrap(env, contextObj, workContext,
|
||||
[](napi_env, void* data, void*) {
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "Finalizer for weak_ptr ability stage context is called");
|
||||
delete static_cast<std::weak_ptr<AbilityRuntime::Context>*>(data);
|
||||
},
|
||||
nullptr, nullptr);
|
||||
|
||||
SetJsAbilityStage(context);
|
||||
}
|
||||
|
||||
void JsAbilityStage::OnCreate(const AAFwk::Want &want) const
|
||||
@@ -383,7 +352,8 @@ void JsAbilityStage::OnMemoryLevel(int32_t level)
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "end");
|
||||
}
|
||||
|
||||
int32_t JsAbilityStage::RunAutoStartupTask(const std::function<void()> &callback, bool &isAsyncCallback)
|
||||
int32_t JsAbilityStage::RunAutoStartupTask(const std::function<void()> &callback, bool &isAsyncCallback,
|
||||
const std::shared_ptr<Context> &stageContext)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "called");
|
||||
isAsyncCallback = false;
|
||||
@@ -397,12 +367,13 @@ int32_t JsAbilityStage::RunAutoStartupTask(const std::function<void()> &callback
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "hapModuleInfo invalid.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
if (hapModuleInfo->moduleType != AppExecFwk::ModuleType::ENTRY ||
|
||||
hapModuleInfo->appStartup.empty()) {
|
||||
if (hapModuleInfo->moduleType != AppExecFwk::ModuleType::ENTRY || hapModuleInfo->appStartup.empty()) {
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "not entry module or appStartup not exist.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
if (!shellContextRef_) {
|
||||
SetJsAbilityStage(stageContext);
|
||||
}
|
||||
std::vector<JsStartupTask> jsStartupTasks;
|
||||
int32_t result = RegisterStartupTaskFromProfile(jsStartupTasks);
|
||||
if (result != ERR_OK) {
|
||||
@@ -803,5 +774,52 @@ bool JsAbilityStage::GetResFromResMgr(
|
||||
profileInfo.emplace_back(profile);
|
||||
return true;
|
||||
}
|
||||
|
||||
void JsAbilityStage::SetJsAbilityStage(const std::shared_ptr<Context> &context)
|
||||
{
|
||||
if (!context) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "context is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
auto env = jsRuntime_.GetNapiEnv();
|
||||
|
||||
napi_value obj = nullptr;
|
||||
if (jsAbilityStageObj_) {
|
||||
obj = jsAbilityStageObj_->GetNapiValue();
|
||||
if (!CheckTypeForNapiValue(env, obj, napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "Failed to get AbilityStage object");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
napi_value contextObj = CreateJsAbilityStageContext(env, context, nullptr, nullptr);
|
||||
shellContextRef_ = JsRuntime::LoadSystemModuleByEngine(env, "application.AbilityStageContext", &contextObj, 1);
|
||||
if (shellContextRef_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "Failed to get LoadSystemModuleByEngine");
|
||||
return;
|
||||
}
|
||||
contextObj = shellContextRef_->GetNapiValue();
|
||||
if (!CheckTypeForNapiValue(env, contextObj, napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "Failed to get context native object");
|
||||
return;
|
||||
}
|
||||
auto workContext = new (std::nothrow) std::weak_ptr<AbilityRuntime::Context>(context);
|
||||
napi_coerce_to_native_binding_object(
|
||||
env, contextObj, DetachCallbackFunc, AttachAbilityStageContext, workContext, nullptr);
|
||||
context->Bind(jsRuntime_, shellContextRef_.get());
|
||||
|
||||
if (obj != nullptr) {
|
||||
napi_set_named_property(env, obj, "context", contextObj);
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "Set ability stage context");
|
||||
napi_wrap(env, contextObj, workContext,
|
||||
[](napi_env, void* data, void*) {
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "Finalizer for weak_ptr ability stage context is called");
|
||||
delete static_cast<std::weak_ptr<AbilityRuntime::Context>*>(data);
|
||||
},
|
||||
nullptr, nullptr);
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -544,6 +544,19 @@ std::string ApplicationContext::GetAppRunningUniqueId() const
|
||||
return appRunningUniqueId_;
|
||||
}
|
||||
|
||||
int32_t ApplicationContext::GetCurrentAppCloneIndex()
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "getCurrentAppCloneIndex is %{public}d.", appIndex_);
|
||||
return appIndex_;
|
||||
}
|
||||
|
||||
int32_t ApplicationContext::GetCurrentAppMode()
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "getCurrentMode is %{public}d.", appMode_);
|
||||
return appMode_;
|
||||
}
|
||||
|
||||
|
||||
void ApplicationContext::SetAppRunningUniqueId(const std::string &appRunningUniqueId)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "SetAppRunningUniqueId is %{public}s.", appRunningUniqueId.c_str());
|
||||
@@ -558,5 +571,17 @@ int32_t ApplicationContext::SetSupportedProcessCacheSelf(bool isSupport)
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "contextImpl_ is nullptr.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
void ApplicationContext::SetCurrentAppCloneIndex(int32_t appIndex)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "setCurrentAppCloneIndex is %{public}d.", appIndex);
|
||||
appIndex_ = appIndex;
|
||||
}
|
||||
|
||||
void ApplicationContext::SetCurrentAppMode(int32_t appMode)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "setCurrentAppMode is %{public}d.", appMode);
|
||||
appMode_ = appMode;
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "ability_manager_interface.h"
|
||||
#include "ability_runtime_error_util.h"
|
||||
#include "application_context.h"
|
||||
#include "application_info.h"
|
||||
#include "application_context_manager.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
@@ -801,6 +802,29 @@ napi_value JsApplicationContextUtils::OnGetRunningProcessInformation(napi_env en
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value JsApplicationContextUtils::GetCurrentAppCloneIndex(napi_env env, napi_callback_info info)
|
||||
{
|
||||
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsApplicationContextUtils,
|
||||
OnGetCurrentAppCloneIndex, APPLICATION_CONTEXT_NAME);
|
||||
}
|
||||
|
||||
napi_value JsApplicationContextUtils::OnGetCurrentAppCloneIndex(napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "Get App Index");
|
||||
auto context = applicationContext_.lock();
|
||||
if (context == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "context is nullptr.");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_CONTEXT);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
if (context->GetCurrentAppMode() != static_cast<int32_t>(AppExecFwk::MultiAppModeType::APP_CLONE)) {
|
||||
ThrowError(env, AbilityErrorCode::ERROR_NOT_APP_CLONE);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
int32_t appIndex = context->GetCurrentAppCloneIndex();
|
||||
return CreateJsValue(env, appIndex);
|
||||
}
|
||||
|
||||
void JsApplicationContextUtils::Finalizer(napi_env env, void *data, void *hint)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "called");
|
||||
@@ -1492,6 +1516,8 @@ void JsApplicationContextUtils::BindNativeApplicationContext(napi_env env, napi_
|
||||
JsApplicationContextUtils::GetRunningProcessInformation);
|
||||
BindNativeFunction(env, object, "getRunningProcessInformation", MD_NAME,
|
||||
JsApplicationContextUtils::GetRunningProcessInformation);
|
||||
BindNativeFunction(env, object, "getCurrentAppCloneIndex", MD_NAME,
|
||||
JsApplicationContextUtils::GetCurrentAppCloneIndex);
|
||||
BindNativeFunction(env, object, "getGroupDir", MD_NAME,
|
||||
JsApplicationContextUtils::GetGroupDir);
|
||||
BindNativeFunction(env, object, "restartApp", MD_NAME,
|
||||
|
||||
@@ -125,8 +125,12 @@ ErrCode ServiceExtensionContext::ConnectAbility(
|
||||
|
||||
ErrCode ServiceExtensionContext::StartAbilityWithAccount(const AAFwk::Want &want, int32_t accountId) const
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "%{public}s begin.", __func__);
|
||||
TAG_LOGI(AAFwkTag::APPKIT, "%{public}d accountId:", accountId);
|
||||
std::string callerName = "";
|
||||
if (GetAbilityInfo() != nullptr) {
|
||||
callerName = GetAbilityInfo()->name;
|
||||
}
|
||||
TAG_LOGI(AAFwkTag::APPKIT, "accountId: %{public}d, ability: %{public}s, caller: %{public}s",
|
||||
accountId, want.GetElement().GetURI().c_str(), callerName.c_str());
|
||||
(const_cast<Want &>(want)).SetParam(START_ABILITY_TYPE, true);
|
||||
ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartAbility(
|
||||
want, token_, ILLEGAL_REQUEST_CODE, accountId);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "child_main_thread.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include "bundle_mgr_proxy.h"
|
||||
#include "child_process_manager.h"
|
||||
#include "constants.h"
|
||||
@@ -172,7 +172,12 @@ void ChildMainThread::InitNativeLib(const BundleInfo &bundleInfo)
|
||||
GetNativeLibPath(bundleInfo, appLibPaths);
|
||||
bool isSystemApp = bundleInfo.applicationInfo.isSystemApp;
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "the application isSystemApp: %{public}d", isSystemApp);
|
||||
AbilityRuntime::JsRuntime::SetAppLibPath(appLibPaths, isSystemApp);
|
||||
|
||||
if (processInfo_->processType != CHILD_PROCESS_TYPE_NATIVE) {
|
||||
AbilityRuntime::JsRuntime::SetAppLibPath(appLibPaths, isSystemApp);
|
||||
} else {
|
||||
UpdateNativeChildLibPath(appLibPaths);
|
||||
}
|
||||
}
|
||||
|
||||
void ChildMainThread::ExitProcessSafely()
|
||||
@@ -222,6 +227,67 @@ void ChildMainThread::HandleExitProcessSafely()
|
||||
}
|
||||
}
|
||||
|
||||
bool ChildMainThread::ScheduleRunNativeProc(const sptr<IRemoteObject> &mainProcessCb)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "ScheduleRunNativeProc");
|
||||
if (mainProcessCb == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "Main process callback is null");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mainHandler_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "mainHandler_ is null");
|
||||
return false;
|
||||
}
|
||||
|
||||
auto task = [weak = wptr<ChildMainThread>(this), callback = sptr<IRemoteObject>(mainProcessCb)]() {
|
||||
auto childMainThread = weak.promote();
|
||||
if (childMainThread == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "childMainThread is nullptr, ScheduleRunNativeProc failed.");
|
||||
return;
|
||||
}
|
||||
childMainThread->HandleRunNativeProc(callback);
|
||||
};
|
||||
if (!mainHandler_->PostTask(task, "ChildMainThread::HandleRunNativeProc")) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "HandleRunNativeProc PostTask task failed.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ChildMainThread::HandleRunNativeProc(const sptr<IRemoteObject> &mainProcessCb)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "HandleRunNativeProc called start.");
|
||||
if (!processInfo_) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "processInfo is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
ChildProcessManager &childProcessMgr = ChildProcessManager::GetInstance();
|
||||
childProcessMgr.LoadNativeLib(processInfo_->srcEntry, mainProcessCb);
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "HandleRunNativeProc end.");
|
||||
ExitProcessSafely();
|
||||
}
|
||||
|
||||
void ChildMainThread::UpdateNativeChildLibPath(const AppLibPathMap &appLibPaths)
|
||||
{
|
||||
std::string nativeLibPath;
|
||||
for (const auto &libPathPair : appLibPaths) {
|
||||
for (const auto &libDir : libPathPair.second) {
|
||||
nativeLibPath = libDir;
|
||||
if (!nativeLibPath.empty() && nativeLibPath.back() != '/') {
|
||||
nativeLibPath += '/';
|
||||
}
|
||||
|
||||
nativeLibPath += processInfo_->srcEntry;
|
||||
if (access(nativeLibPath.c_str(), F_OK) == 0) {
|
||||
processInfo_->srcEntry = nativeLibPath;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ChildMainThread::GetNativeLibPath(const BundleInfo &bundleInfo, AppLibPathMap &appLibPaths)
|
||||
{
|
||||
std::string nativeLibraryPath = bundleInfo.applicationInfo.nativeLibraryPath;
|
||||
|
||||
@@ -26,7 +26,7 @@ int DumpFfrtHelper::DumpFfrt(std::string& result)
|
||||
{
|
||||
result.resize(MAX_BUF_SIZE);
|
||||
|
||||
int printNum = ffrt_dump(static_cast<uint32_t>(ffrt_dump_cmd_t::DUMP_INFO_ALL), &result[0], MAX_BUF_SIZE);
|
||||
int printNum = ffrt_dump(ffrt_dump_cmd_t::DUMP_INFO_ALL, &result[0], MAX_BUF_SIZE);
|
||||
if (printNum > 0) {
|
||||
result.resize(printNum);
|
||||
return 0;
|
||||
|
||||
@@ -640,7 +640,16 @@ void MainThread::ScheduleJsHeapMemory(OHOS::AppExecFwk::JsHeapDumpInfo &info)
|
||||
return;
|
||||
}
|
||||
if (info.needSnapshot == true) {
|
||||
runtime->DumpHeapSnapshot(info.tid, info.needGc);
|
||||
std::vector<uint32_t> fdVec;
|
||||
for (auto &fd : info.fdVec) {
|
||||
uint32_t newFd = dup(fd);
|
||||
if (newFd == -1) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "dup failed.");
|
||||
return;
|
||||
}
|
||||
fdVec.push_back(newFd);
|
||||
}
|
||||
runtime->DumpHeapSnapshot(info.tid, info.needGc, fdVec, info.tidVec);
|
||||
} else {
|
||||
if (info.needGc == true) {
|
||||
runtime->ForceFullGC(info.tid);
|
||||
@@ -1189,7 +1198,7 @@ bool GetBundleForLaunchApplication(std::shared_ptr<BundleMgrHelper> bundleMgrHel
|
||||
int32_t appIndex, BundleInfo &bundleInfo)
|
||||
{
|
||||
bool queryResult;
|
||||
if (appIndex > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) {
|
||||
if (appIndex > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) {
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "The bundleName = %{public}s.", bundleName.c_str());
|
||||
queryResult = (bundleMgrHelper->GetSandboxBundleInfo(bundleName,
|
||||
appIndex, UNSPECIFIED_USERID, bundleInfo) == 0);
|
||||
@@ -1319,6 +1328,9 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
|
||||
contextImpl->SetApplicationInfo(std::make_shared<ApplicationInfo>(appInfo));
|
||||
std::shared_ptr<AbilityRuntime::ApplicationContext> applicationContext =
|
||||
AbilityRuntime::ApplicationContext::GetInstance();
|
||||
int32_t appIndex = appLaunchData.GetAppIndex();
|
||||
applicationContext->SetCurrentAppCloneIndex(appIndex);
|
||||
applicationContext->SetCurrentAppMode(static_cast<int32_t>(appInfo.multiAppMode.multiAppModeType));
|
||||
applicationContext->AttachContextImpl(contextImpl);
|
||||
auto appRunningId = appLaunchData.GetAppRunningUniqueId();
|
||||
applicationContext->SetAppRunningUniqueId(appRunningId);
|
||||
@@ -3116,12 +3128,22 @@ void MainThread::AssertFaultPauseMainThreadDetection()
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "Called.");
|
||||
SetAppDebug(AbilityRuntime::AppFreezeState::AppFreezeFlag::ASSERT_DEBUG_MODE, true);
|
||||
if (appMgr_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "appMgr is nullptr.");
|
||||
return;
|
||||
}
|
||||
appMgr_->SetAppAssertionPauseState(true);
|
||||
}
|
||||
|
||||
void MainThread::AssertFaultResumeMainThreadDetection()
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "Called.");
|
||||
SetAppDebug(AbilityRuntime::AppFreezeState::AppFreezeFlag::ASSERT_DEBUG_MODE, false);
|
||||
if (appMgr_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "appMgr is nullptr.");
|
||||
return;
|
||||
}
|
||||
appMgr_->SetAppAssertionPauseState(false);
|
||||
}
|
||||
|
||||
void MainThread::HandleInitAssertFaultTask(bool isDebugModule, bool isDebugApp)
|
||||
|
||||
@@ -676,7 +676,7 @@ std::shared_ptr<AbilityRuntime::Context> OHOSApplication::AddAbilityStage(
|
||||
ohosApplication->AutoStartupDone(abilityRecord, abilityStage, moduleName);
|
||||
callback(abilityStage->GetContext());
|
||||
};
|
||||
abilityStage->RunAutoStartupTask(autoStartupCallback, isAsyncCallback);
|
||||
abilityStage->RunAutoStartupTask(autoStartupCallback, isAsyncCallback, stageContext);
|
||||
if (isAsyncCallback) {
|
||||
TAG_LOGI(AAFwkTag::APPKIT, "waiting for startup");
|
||||
return nullptr;
|
||||
|
||||
@@ -182,6 +182,7 @@ void JsStartupTaskExecutor::ReplyFailed(StartupTaskResultCallback *callback,
|
||||
std::shared_ptr<StartupTaskResult> result = std::make_shared<JsStartupTaskResult>(resultCode, resultMessage);
|
||||
callback->Call(result);
|
||||
delete callback;
|
||||
callback = nullptr;
|
||||
}
|
||||
|
||||
void JsStartupTaskExecutor::ReplyFailed(std::unique_ptr<StartupTaskResultCallback> callback,
|
||||
@@ -205,6 +206,7 @@ void JsStartupTaskExecutor::ReplySucceeded(StartupTaskResultCallback *callback,
|
||||
std::shared_ptr<StartupTaskResult> result = std::make_shared<JsStartupTaskResult>(resultRef);
|
||||
callback->Call(result);
|
||||
delete callback;
|
||||
callback = nullptr;
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -35,7 +35,7 @@ StartupTaskResult::ResultType JsStartupTaskResult::GetResultType() const
|
||||
return ResultType::JS;
|
||||
}
|
||||
|
||||
std::shared_ptr<NativeReference> JsStartupTaskResult::GetJsStartupResultRef() const
|
||||
const std::shared_ptr<NativeReference>& JsStartupTaskResult::GetJsStartupResultRef() const
|
||||
{
|
||||
return jsStartupResultRef_;
|
||||
}
|
||||
|
||||
@@ -36,12 +36,11 @@ int32_t StartupConfig::GetAwaitTimeoutMs() const
|
||||
return awaitTimeoutMs_;
|
||||
}
|
||||
|
||||
int32_t StartupConfig::ListenerOnCompleted(const std::shared_ptr<StartupTaskResult> &result)
|
||||
void StartupConfig::ListenerOnCompleted(const std::shared_ptr<StartupTaskResult> &result)
|
||||
{
|
||||
if (listener_ != nullptr) {
|
||||
listener_->OnCompleted(result);
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -128,7 +128,7 @@ void StartupManager::SetDefaultConfig(const std::shared_ptr<StartupConfig> &conf
|
||||
defaultConfig_ = config;
|
||||
}
|
||||
|
||||
std::shared_ptr<StartupConfig> StartupManager::GetDefaultConfig() const
|
||||
const std::shared_ptr<StartupConfig>& StartupManager::GetDefaultConfig() const
|
||||
{
|
||||
return defaultConfig_;
|
||||
}
|
||||
|
||||
@@ -13,22 +13,18 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#include "startup_task.h"
|
||||
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
StartupTask::StartupTask(const std::string &name) : name_(name)
|
||||
{
|
||||
state_ = State::CREATED;
|
||||
}
|
||||
StartupTask::StartupTask(const std::string &name) : name_(name), state_(State::CREATED)
|
||||
{}
|
||||
|
||||
StartupTask::~StartupTask() = default;
|
||||
|
||||
std::string StartupTask::GetName() const
|
||||
const std::string& StartupTask::GetName() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
@@ -100,7 +96,7 @@ int32_t StartupTask::RemoveResult()
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
std::shared_ptr<StartupTaskResult> StartupTask::GetResult() const
|
||||
const std::shared_ptr<StartupTaskResult>& StartupTask::GetResult() const
|
||||
{
|
||||
return result_;
|
||||
}
|
||||
@@ -117,7 +113,7 @@ std::string StartupTask::DumpDependencies() const
|
||||
}
|
||||
bool isFirst = true;
|
||||
std::string dumpResult;
|
||||
for (auto &iter : dependencies_) {
|
||||
for (const auto &iter : dependencies_) {
|
||||
if (isFirst) {
|
||||
dumpResult = iter;
|
||||
isFirst = false;
|
||||
|
||||
@@ -47,10 +47,9 @@ int32_t StartupTaskManager::AddTask(const std::shared_ptr<StartupTask> &task)
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t StartupTaskManager::SetConfig(const std::shared_ptr<StartupConfig> &config)
|
||||
void StartupTaskManager::SetConfig(const std::shared_ptr<StartupConfig> &config)
|
||||
{
|
||||
config_ = config;
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t StartupTaskManager::Prepare()
|
||||
|
||||
@@ -44,7 +44,7 @@ int32_t StartupTaskResult::GetResultCode() const
|
||||
return resultCode_;
|
||||
}
|
||||
|
||||
std::string StartupTaskResult::GetResultMessage() const
|
||||
const std::string& StartupTaskResult::GetResultMessage() const
|
||||
{
|
||||
return resultMessage_;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "ability_manager_client.h"
|
||||
#include "ability_state.h"
|
||||
#include "appfreeze_manager.h"
|
||||
#include "app_recovery.h"
|
||||
#include "exit_reason.h"
|
||||
#include "ffrt.h"
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
# Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("//foundation/ability/ability_runtime/ability_runtime.gni")
|
||||
|
||||
config("child_process_ndk_config") {
|
||||
include_dirs =
|
||||
[ "${ability_runtime_ndk_path}/ability/ability_runtime/child_process" ]
|
||||
|
||||
if (target_cpu == "arm") {
|
||||
cflags = [ "-DBINDER_IPC_32BIT" ]
|
||||
}
|
||||
}
|
||||
|
||||
ohos_shared_library("child_process") {
|
||||
sanitize = {
|
||||
integer_overflow = true
|
||||
ubsan = true
|
||||
boundary_sanitize = true
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcall_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
branch_protector_ret = "pac_ret"
|
||||
|
||||
include_dirs = [ "include" ]
|
||||
|
||||
configs = [ "${ability_runtime_services_path}/common:common_config" ]
|
||||
public_configs = [ ":child_process_ndk_config" ]
|
||||
|
||||
sources = [
|
||||
"${ability_runtime_native_path}/child_process/src/native_child_callback.cpp",
|
||||
"${ability_runtime_native_path}/child_process/src/native_child_process.cpp",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/app_manager:app_manager",
|
||||
"${ability_runtime_innerkits_path}/child_process_manager:child_process_manager",
|
||||
"${ability_runtime_native_path}/ability/native:ability_business_error",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_capi",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
|
||||
output_extension = "so"
|
||||
innerapi_tags = [ "ndk" ]
|
||||
install_images = [ "system" ]
|
||||
subsystem_name = "ability"
|
||||
part_name = "ability_runtime"
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ABILITY_RUNTIME_NATIVE_CHILD_CALLBACK_H
|
||||
#define OHOS_ABILITY_RUNTIME_NATIVE_CHILD_CALLBACK_H
|
||||
|
||||
#include "native_child_notify_stub.h"
|
||||
#include "native_child_process.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
|
||||
class NativeChildCallback : public OHOS::AppExecFwk::NativeChildNotifyStub {
|
||||
public:
|
||||
explicit NativeChildCallback(OH_Ability_OnNativeChildProcessStarted cb);
|
||||
~NativeChildCallback() = default;
|
||||
|
||||
void OnNativeChildStarted(const sptr<IRemoteObject> &nativeChild) override;
|
||||
void OnError(int32_t errCode) override;
|
||||
|
||||
private:
|
||||
OH_Ability_OnNativeChildProcessStarted callback_ = nullptr;
|
||||
};
|
||||
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // OHOS_ABILITY_RUNTIME_NATIVE_CHILD_CALLBACK_H
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "native_child_callback.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "ipc_inner_object.h"
|
||||
#include "child_process_manager_error_utils.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
|
||||
NativeChildCallback::NativeChildCallback(OH_Ability_OnNativeChildProcessStarted cb)
|
||||
: NativeChildNotifyStub(), callback_(cb)
|
||||
{
|
||||
}
|
||||
|
||||
void NativeChildCallback::OnNativeChildStarted(const sptr<IRemoteObject> &nativeChild)
|
||||
{
|
||||
if (callback_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "Native child process started, but callback is null?");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!nativeChild) {
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "Native child process ipc object is null");
|
||||
return;
|
||||
}
|
||||
|
||||
TAG_LOGI(AAFwkTag::PROCESSMGR, "Native child process started");
|
||||
sptr<IRemoteObject> ipcRemote = nativeChild;
|
||||
OHIPCRemoteProxy *ipcProxy = CreateIPCRemoteProxy(ipcRemote);
|
||||
if (ipcProxy == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "Convert inner ipc object to OHIPCRemoteProxy point failed");
|
||||
callback_(NCP_ERR_INTERNAL, nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
callback_(static_cast<int32_t>(ChildProcessManagerErrorCode::ERR_OK), ipcProxy);
|
||||
}
|
||||
|
||||
void NativeChildCallback::OnError(int32_t errCode)
|
||||
{
|
||||
if (callback_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "Native child process start failed, but callback is null?");
|
||||
return;
|
||||
}
|
||||
|
||||
TAG_LOGI(AAFwkTag::PROCESSMGR, "Native child process start failed, err %{public}d", errCode);
|
||||
callback_(errCode, nullptr);
|
||||
}
|
||||
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "native_child_process.h"
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "native_child_callback.h"
|
||||
#include "child_process_manager.h"
|
||||
|
||||
using namespace OHOS;
|
||||
using namespace OHOS::AbilityRuntime;
|
||||
|
||||
namespace {
|
||||
|
||||
std::mutex g_MutexCallBackObj;
|
||||
sptr<IRemoteObject> g_CallbackStub;
|
||||
OH_Ability_OnNativeChildProcessStarted g_Callback = nullptr;
|
||||
|
||||
const std::map<ChildProcessManagerErrorCode, Ability_NativeChildProcess_ErrCode> CPM_ERRCODE_MAP = {
|
||||
{ ChildProcessManagerErrorCode::ERR_OK, NCP_NOERROR },
|
||||
{ ChildProcessManagerErrorCode::ERR_MULTI_PROCESS_MODEL_DISABLED, NCP_ERR_MULTI_PROCESS_DISABLED },
|
||||
{ ChildProcessManagerErrorCode::ERR_ALREADY_IN_CHILD_PROCESS, NCP_ERR_ALREADY_IN_CHILD },
|
||||
{ ChildProcessManagerErrorCode::ERR_GET_APP_MGR_FAILED, NCP_ERR_SERVICE },
|
||||
{ ChildProcessManagerErrorCode::ERR_GET_APP_MGR_START_PROCESS_FAILED, NCP_ERR_SERVICE },
|
||||
{ ChildProcessManagerErrorCode::ERR_UNSUPPORT_NATIVE_CHILD_PROCESS, NCP_ERR_NOT_SUPPORTED },
|
||||
{ ChildProcessManagerErrorCode::ERR_MAX_NATIVE_CHILD_PROCESSES, NCP_ERR_MAX_CHILD_PROCESSES_REACHED },
|
||||
{ ChildProcessManagerErrorCode::ERR_NATIVE_CHILD_PROCESS_LOAD_LIB, NCP_ERR_CHILD_PROCESS_LOAD_LIB },
|
||||
{ ChildProcessManagerErrorCode::ERR_NATIVE_CHILD_PROCESS_CONNECT, NCP_ERR_CHILD_PROCESS_CONNECT },
|
||||
};
|
||||
|
||||
int CvtChildProcessManagerErrCode(ChildProcessManagerErrorCode cpmErr)
|
||||
{
|
||||
auto it = CPM_ERRCODE_MAP.find(cpmErr);
|
||||
if (it == CPM_ERRCODE_MAP.end()) {
|
||||
return NCP_ERR_INTERNAL;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
void OnNativeChildProcessStartedWapper(int errCode, OHIPCRemoteProxy *ipcProxy)
|
||||
{
|
||||
std::unique_lock autoLock(g_MutexCallBackObj);
|
||||
if (g_Callback != nullptr) {
|
||||
g_Callback(CvtChildProcessManagerErrCode(static_cast<ChildProcessManagerErrorCode>(errCode)), ipcProxy);
|
||||
g_Callback = nullptr;
|
||||
} else {
|
||||
TAG_LOGW(AAFwkTag::PROCESSMGR, "Remote call twice?");
|
||||
}
|
||||
|
||||
g_CallbackStub.clear();
|
||||
}
|
||||
|
||||
} // Anonymous namespace
|
||||
|
||||
int OH_Ability_CreateNativeChildProcess(const char* libName, OH_Ability_OnNativeChildProcessStarted onProcessStarted)
|
||||
{
|
||||
if (libName == nullptr || *libName == '\0' || onProcessStarted == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "Invalid libname or callback");
|
||||
return NCP_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
std::string strLibName(libName);
|
||||
if (strLibName.find("../") != std::string::npos) {
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "Do not allow use relative path");
|
||||
return NCP_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
std::unique_lock autoLock(g_MutexCallBackObj);
|
||||
if (g_Callback != nullptr || g_CallbackStub != nullptr) {
|
||||
TAG_LOGW(AAFwkTag::PROCESSMGR, "Another native process process starting, try again later");
|
||||
return NCP_ERR_BUSY;
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> callbackStub(new (std::nothrow) NativeChildCallback(OnNativeChildProcessStartedWapper));
|
||||
if (!callbackStub) {
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "Alloc callback ipc stub object faild.");
|
||||
return NCP_ERR_INTERNAL;
|
||||
}
|
||||
|
||||
ChildProcessManager &mgr = ChildProcessManager::GetInstance();
|
||||
auto cpmErr = mgr.StartNativeChildProcessByAppSpawnFork(strLibName, callbackStub);
|
||||
if (cpmErr != ChildProcessManagerErrorCode::ERR_OK) {
|
||||
return CvtChildProcessManagerErrCode(cpmErr);
|
||||
}
|
||||
|
||||
g_Callback = onProcessStarted;
|
||||
g_CallbackStub = callbackStub;
|
||||
return NCP_NOERROR;
|
||||
}
|
||||
@@ -34,6 +34,7 @@ ohos_shared_library("insightintentcontext") {
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
"${ability_runtime_napi_path}/inner/napi_common:napi_common",
|
||||
"${ability_runtime_native_path}/ability/native:ability_business_error",
|
||||
|
||||
@@ -626,7 +626,6 @@ void JsRuntime::FinishPreload()
|
||||
auto vm = GetEcmaVm();
|
||||
CHECK_POINTER(vm);
|
||||
panda::JSNApi::PreFork(vm);
|
||||
jsEnv_->StopMonitorJSHeapUsage();
|
||||
}
|
||||
|
||||
void JsRuntime::PostPreload(const Options& options)
|
||||
@@ -687,8 +686,6 @@ bool JsRuntime::Initialize(const Options& options)
|
||||
}
|
||||
NativeCreateEnv::RegCreateNapiEnvCallback(CreateNapiEnv);
|
||||
NativeCreateEnv::RegDestroyNapiEnvCallback(DestroyNapiEnv);
|
||||
} else {
|
||||
jsEnv_->StartMonitorJSHeapUsage();
|
||||
}
|
||||
apiTargetVersion_ = options.apiTargetVersion;
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Initialize: %{public}d.", apiTargetVersion_);
|
||||
@@ -1195,11 +1192,12 @@ void JsRuntime::DumpHeapSnapshot(bool isPrivate)
|
||||
nativeEngine->DumpHeapSnapshot(true, DumpFormat::JSON, isPrivate, false);
|
||||
}
|
||||
|
||||
void JsRuntime::DumpHeapSnapshot(uint32_t tid, bool isFullGC)
|
||||
void JsRuntime::DumpHeapSnapshot(uint32_t tid, bool isFullGC, std::vector<uint32_t> fdVec,
|
||||
std::vector<uint32_t> tidVec)
|
||||
{
|
||||
auto vm = GetEcmaVm();
|
||||
CHECK_POINTER(vm);
|
||||
DFXJSNApi::DumpHeapSnapshot(vm, 0, true, false, false, isFullGC, tid);
|
||||
DFXJSNApi::DumpHeapSnapshot(vm, 0, true, false, false, isFullGC, tid, fdVec, tidVec);
|
||||
}
|
||||
|
||||
void JsRuntime::ForceFullGC(uint32_t tid)
|
||||
|
||||
@@ -147,9 +147,6 @@ napi_status NativeRuntimeImpl::Init(const Options& options, napi_env env)
|
||||
}
|
||||
|
||||
if (!options.preload) {
|
||||
auto operatorObj = std::make_shared<JsEnv::SourceMapOperator>(options.bundleName, isModular,
|
||||
options.isDebugVersion);
|
||||
InitSourceMap(operatorObj, jsEnv);
|
||||
if (!options.isUnique) {
|
||||
InitTimerModule(jsEnv);
|
||||
}
|
||||
@@ -248,16 +245,6 @@ void NativeRuntimeImpl::InitConsoleModule(const std::shared_ptr<JsEnv::JsEnviron
|
||||
jsEnv->InitConsoleModule();
|
||||
}
|
||||
|
||||
void NativeRuntimeImpl::InitSourceMap(const std::shared_ptr<JsEnv::SourceMapOperator> operatorObj,
|
||||
const std::shared_ptr<JsEnv::JsEnvironment>& jsEnv)
|
||||
{
|
||||
if (jsEnv == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv is nullptr.");
|
||||
return;
|
||||
}
|
||||
jsEnv->InitSourceMap(operatorObj);
|
||||
}
|
||||
|
||||
void NativeRuntimeImpl::InitTimerModule(const std::shared_ptr<JsEnv::JsEnvironment>& jsEnv)
|
||||
{
|
||||
if (jsEnv == nullptr) {
|
||||
|
||||
@@ -299,21 +299,21 @@ std::unique_ptr<NapiAsyncTask> CreateAsyncTaskWithLastParam(napi_env env, napi_v
|
||||
}
|
||||
|
||||
std::unique_ptr<NapiAsyncTask> CreateAsyncTaskWithLastParam(napi_env env, napi_value lastParam,
|
||||
NapiAsyncTask::ExecuteCallback &&execute, nullptr_t, napi_value *result)
|
||||
NapiAsyncTask::ExecuteCallback &&execute, std::nullptr_t, napi_value *result)
|
||||
{
|
||||
return CreateAsyncTaskWithLastParam(
|
||||
env, lastParam, std::make_unique<NapiAsyncTask::ExecuteCallback>(std::move(execute)), nullptr, result);
|
||||
}
|
||||
|
||||
std::unique_ptr<NapiAsyncTask> CreateAsyncTaskWithLastParam(napi_env env, napi_value lastParam,
|
||||
nullptr_t, NapiAsyncTask::CompleteCallback &&complete, napi_value *result)
|
||||
std::nullptr_t, NapiAsyncTask::CompleteCallback &&complete, napi_value *result)
|
||||
{
|
||||
return CreateAsyncTaskWithLastParam(
|
||||
env, lastParam, nullptr, std::make_unique<NapiAsyncTask::CompleteCallback>(std::move(complete)), result);
|
||||
}
|
||||
|
||||
std::unique_ptr<NapiAsyncTask> CreateAsyncTaskWithLastParam(napi_env env, napi_value lastParam,
|
||||
nullptr_t, nullptr_t, napi_value *result)
|
||||
std::nullptr_t, std::nullptr_t, napi_value *result)
|
||||
{
|
||||
return CreateAsyncTaskWithLastParam(env, lastParam, std::unique_ptr<NapiAsyncTask::ExecuteCallback>(),
|
||||
std::unique_ptr<NapiAsyncTask::CompleteCallback>(), result);
|
||||
|
||||
@@ -352,3 +352,15 @@ START_STANDARD_ABILITIES:
|
||||
BUNDLE_NAME: {type: STRING, desc: bundle name}
|
||||
MODULE_NAME: {type: STRING, desc: module name}
|
||||
ABILITY_NAME: {type: STRING, desc: ability name}
|
||||
|
||||
PREVENT_START_ABILITY:
|
||||
__BASE: {type: BEHAVIOR, level: MINOR, desc: Process start control, preserve: true}
|
||||
CALLER_UID: {type: INT32, desc: caller uid}
|
||||
CALLER_PID: {type: INT32, desc: caller pid}
|
||||
CALLER_PROCESS_NAME: {type: STRING, desc: caller process name}
|
||||
CALLER_BUNDLE_NAME: {type: STRING, desc: caller bundle name}
|
||||
CALLEE_BUNDLE_NAME: {type: STRING, desc: callee bundle name}
|
||||
CALLEE_PROCESS_NAME: {type: STRING, desc: callee process name}
|
||||
EXTENSION_ABILITY_TYPE: {type: INT32, desc: extension ability type}
|
||||
ABILITY_NAME: {type: STRING, desc: caller ability name}
|
||||
|
||||
@@ -92,7 +92,6 @@ ohos_shared_library("ability_manager") {
|
||||
"${ability_runtime_services_path}/abilitymgr/src/remote_on_listener_proxy.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/remote_on_listener_stub.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/sender_info.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/start_options.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/system_ability_token_callback_stub.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/ui_extension_ability_connect_info.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/ui_extension_host_info.cpp",
|
||||
@@ -125,6 +124,7 @@ ohos_shared_library("ability_manager") {
|
||||
public_deps = [ ":ability_connect_callback_stub" ]
|
||||
|
||||
deps = [
|
||||
":ability_start_options",
|
||||
":ability_start_setting",
|
||||
":mission_info",
|
||||
":process_options",
|
||||
@@ -180,6 +180,44 @@ ohos_shared_library("ability_manager") {
|
||||
part_name = "ability_runtime"
|
||||
}
|
||||
|
||||
ohos_shared_library("ability_start_options") {
|
||||
sanitize = {
|
||||
integer_overflow = true
|
||||
ubsan = true
|
||||
boundary_sanitize = true
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcall_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
branch_protector_ret = "pac_ret"
|
||||
|
||||
include_dirs = [
|
||||
"include/",
|
||||
"${ability_runtime_services_path}/common/include",
|
||||
]
|
||||
|
||||
sources =
|
||||
[ "${ability_runtime_services_path}/abilitymgr/src/start_options.cpp" ]
|
||||
|
||||
deps = [ ":process_options" ]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"hisysevent:libhisysevent",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
|
||||
cflags_cc = []
|
||||
innerapi_tags = [
|
||||
"platformsdk",
|
||||
"sasdk",
|
||||
]
|
||||
subsystem_name = "ability"
|
||||
part_name = "ability_runtime"
|
||||
}
|
||||
|
||||
ohos_shared_library("mission_info") {
|
||||
sources = [
|
||||
"${ability_runtime_services_path}/abilitymgr/src/mission_info.cpp",
|
||||
|
||||
@@ -1479,6 +1479,17 @@ public:
|
||||
*/
|
||||
int32_t GetAbilityStateByPersistentId(int32_t persistentId, bool &state);
|
||||
|
||||
/**
|
||||
* Transfer resultCode & want to abms.
|
||||
*
|
||||
* @param callerToken caller ability token.
|
||||
* @param requestCode the resultCode of the ability to start.
|
||||
* @param want Indicates the ability to start.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
int32_t TransferAbilityResultForExtension(const sptr<IRemoteObject> &callerToken, int32_t resultCode,
|
||||
const Want &want);
|
||||
|
||||
private:
|
||||
AbilityManagerClient();
|
||||
DISALLOW_COPY_AND_MOVE(AbilityManagerClient);
|
||||
|
||||
@@ -506,12 +506,17 @@ enum {
|
||||
ERR_NO_RESIDENT_PERMISSION,
|
||||
|
||||
/**
|
||||
* Result(2097250) for app twin index does not exist.
|
||||
* Result(2097250) for app clone index does not exist.
|
||||
*/
|
||||
ERR_APP_TWIN_INDEX_INVALID,
|
||||
ERR_APP_CLONE_INDEX_INVALID,
|
||||
|
||||
/**
|
||||
* Result(2097251) for unlock screen failed in developer mode.
|
||||
* Result(2097251) not support twin.
|
||||
*/
|
||||
ERR_MULTI_APP_NOT_SUPPORTED,
|
||||
|
||||
/**
|
||||
* Result(2097252) for unlock screen failed in developer mode.
|
||||
*/
|
||||
ERR_UNLOCK_SCREEN_FAILED_IN_DEVELOPER_MODE,
|
||||
};
|
||||
|
||||
@@ -1592,6 +1592,19 @@ public:
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfer resultCode & want to ability manager service.
|
||||
*
|
||||
* @param resultCode, the resultCode of the ability to terminate.
|
||||
* @param resultWant, the Want of the ability to return.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int32_t TransferAbilityResultForExtension(const sptr<IRemoteObject> &callerToken, int32_t resultCode,
|
||||
const Want &want)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -439,6 +439,7 @@ enum class AbilityManagerInterfaceCode {
|
||||
UNREGISTER_ABILITY_FIRST_FRAME_STATE_OBSERVER = 1127,
|
||||
// ipc for get ability state by persistent id
|
||||
GET_ABILITY_STATE_BY_PERSISTENT_ID = 1128,
|
||||
TRANSFER_ABILITY_RESULT = 1129,
|
||||
|
||||
// ipc id 2001-3000 for tools
|
||||
// ipc id for dumping state (2001)
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
#ifndef OHOS_ABILITY_RUNTIME_ASSERT_FAULT_PROXY_H
|
||||
#define OHOS_ABILITY_RUNTIME_ASSERT_FAULT_PROXY_H
|
||||
|
||||
#include <chrono>
|
||||
#include <mutex>
|
||||
#include <queue>
|
||||
|
||||
#include "iremote_broker.h"
|
||||
@@ -23,6 +25,7 @@
|
||||
#include "iremote_proxy.h"
|
||||
#include "ability_connect_callback_stub.h"
|
||||
#include "assert_fault_interface.h"
|
||||
#include "singleton.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
@@ -52,34 +55,39 @@ private:
|
||||
RemoteDiedHandler handler_;
|
||||
};
|
||||
|
||||
class ModalSystemAssertUIExtension : public std::enable_shared_from_this<ModalSystemAssertUIExtension> {
|
||||
class ModalSystemAssertUIExtension {
|
||||
public:
|
||||
static ModalSystemAssertUIExtension &GetInstance();
|
||||
ModalSystemAssertUIExtension() = default;
|
||||
virtual ~ModalSystemAssertUIExtension();
|
||||
|
||||
bool CreateModalUIExtension(const AAFwk::Want &want);
|
||||
|
||||
friend class AssertFaultProxy;
|
||||
|
||||
private:
|
||||
class AssertDialogConnection : public OHOS::AAFwk::AbilityConnectionStub {
|
||||
public:
|
||||
AssertDialogConnection() = default;
|
||||
virtual ~AssertDialogConnection();
|
||||
|
||||
bool RequestShowDialog(const AAFwk::Want &want);
|
||||
void CleanUp();
|
||||
virtual ~AssertDialogConnection() = default;
|
||||
|
||||
void SetReqeustAssertDialogWant(const AAFwk::Want &want);
|
||||
void OnAbilityConnectDone(const AppExecFwk::ElementName &element, const sptr<IRemoteObject> &remoteObject,
|
||||
int resultCode) override;
|
||||
void OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode) override;
|
||||
|
||||
private:
|
||||
std::mutex mutex_;
|
||||
std::atomic_bool isDialogShow_ = false;
|
||||
std::queue<AAFwk::Want> consumptionList_;
|
||||
sptr<IRemoteObject> remoteObject_;
|
||||
sptr<IRemoteObject::DeathRecipient> deathRecipient_;
|
||||
AAFwk::Want want_;
|
||||
};
|
||||
|
||||
private:
|
||||
bool DisconnectSystemUI();
|
||||
void TryNotifyOneWaitingThread();
|
||||
void TryNotifyOneWaitingThreadInner();
|
||||
|
||||
std::mutex assertResultMutex_;
|
||||
std::condition_variable assertResultCV_;
|
||||
int32_t reqeustCount_ = 0;
|
||||
sptr<AssertDialogConnection> GetConnection();
|
||||
std::mutex dialogConnectionMutex_;
|
||||
sptr<AssertDialogConnection> dialogConnectionCallback_;
|
||||
|
||||
@@ -34,6 +34,7 @@ struct DialogAbilityInfo {
|
||||
int32_t bundleLabelId = 0;
|
||||
int32_t abilityIconId = 0;
|
||||
int32_t abilityLabelId = 0;
|
||||
bool visible = true;
|
||||
|
||||
std::string GetURI() const;
|
||||
bool ParseURI(const std::string &uri);
|
||||
|
||||
@@ -24,6 +24,7 @@ enum class ProcessMode {
|
||||
UNSPECIFIED = 0,
|
||||
NEW_PROCESS_ATTACH_TO_PARENT = 1,
|
||||
NEW_PROCESS_ATTACH_TO_STATUS_BAR_ITEM = 2,
|
||||
ATTACH_TO_STATUS_BAR_ITEM = 3,
|
||||
END
|
||||
};
|
||||
|
||||
@@ -46,9 +47,12 @@ public:
|
||||
static ProcessMode ConvertInt32ToProcessMode(int32_t value);
|
||||
static StartupVisibility ConvertInt32ToStartupVisibility(int32_t value);
|
||||
static bool IsNewProcessMode(ProcessMode value);
|
||||
static bool IsAttachToStatusBarMode(ProcessMode value);
|
||||
static bool IsValidProcessMode(ProcessMode value);
|
||||
|
||||
ProcessMode processMode = ProcessMode::UNSPECIFIED;
|
||||
StartupVisibility startupVisibility = StartupVisibility::UNSPECIFIED;
|
||||
std::string processName;
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -88,6 +88,8 @@ ohos_shared_library("app_manager") {
|
||||
"src/appmgr/configuration_observer_stub.cpp",
|
||||
"src/appmgr/fault_data.cpp",
|
||||
"src/appmgr/memory_level_info.cpp",
|
||||
"src/appmgr/native_child_notify_proxy.cpp",
|
||||
"src/appmgr/native_child_notify_stub.cpp",
|
||||
"src/appmgr/page_state_data.cpp",
|
||||
"src/appmgr/priority_object.cpp",
|
||||
"src/appmgr/process_data.cpp",
|
||||
@@ -101,6 +103,7 @@ ohos_shared_library("app_manager") {
|
||||
"src/appmgr/render_state_data.cpp",
|
||||
"src/appmgr/render_state_observer_proxy.cpp",
|
||||
"src/appmgr/render_state_observer_stub.cpp",
|
||||
"src/appmgr/running_multi_info.cpp",
|
||||
"src/appmgr/running_process_info.cpp",
|
||||
"src/appmgr/start_specified_ability_response_proxy.cpp",
|
||||
"src/appmgr/start_specified_ability_response_stub.cpp",
|
||||
|
||||
@@ -288,14 +288,6 @@ public:
|
||||
*/
|
||||
virtual bool IsAttachDebug(const std::string &bundleName) = 0;
|
||||
|
||||
/**
|
||||
* Set application assertion pause state.
|
||||
*
|
||||
* @param pid App process pid.
|
||||
* @param flag assertion pause state.
|
||||
*/
|
||||
virtual void SetAppAssertionPauseState(int32_t pid, bool flag) {}
|
||||
|
||||
/**
|
||||
* @brief Set resident process enable status.
|
||||
* @param bundleName The application bundle name.
|
||||
@@ -354,7 +346,6 @@ public:
|
||||
REGISTER_ABILITY_DEBUG_RESPONSE,
|
||||
IS_ATTACH_DEBUG,
|
||||
START_SPECIFIED_PROCESS,
|
||||
SET_APP_ASSERT_PAUSE_STATE,
|
||||
CLEAR_PROCESS_BY_TOKEN,
|
||||
REGISTER_ABILITY_MS_DELEGATE,
|
||||
KILL_PROCESSES_BY_PIDS,
|
||||
|
||||
@@ -257,14 +257,6 @@ public:
|
||||
*/
|
||||
bool IsAttachDebug(const std::string &bundleName) override;
|
||||
|
||||
/**
|
||||
* Set application assertion pause state.
|
||||
*
|
||||
* @param pid App process pid.
|
||||
* @param flag assertion pause state.
|
||||
*/
|
||||
void SetAppAssertionPauseState(int32_t pid, bool flag) override;
|
||||
|
||||
/**
|
||||
* @brief Set resident process enable status.
|
||||
* @param bundleName The application bundle name.
|
||||
|
||||
@@ -81,7 +81,6 @@ private:
|
||||
int32_t HandleClearNonPersistWaitingDebugFlag(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleRegisterAbilityDebugResponse(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleIsAttachDebug(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleSetAppAssertionPauseState(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleClearProcessByToken(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleIsMemorySizeSufficent(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleSetKeepAliveEnableState(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
@@ -16,16 +16,21 @@
|
||||
#ifndef OHOS_ABILITY_RUNTIME_APP_JSHEAP_MEM_INFO_H
|
||||
#define OHOS_ABILITY_RUNTIME_APP_JSHEAP_MEM_INFO_H
|
||||
|
||||
#include <vector>
|
||||
#include "parcel.h"
|
||||
#include "iremote_object.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
struct JsHeapDumpInfo : public Parcelable {
|
||||
~JsHeapDumpInfo();
|
||||
uint32_t pid;
|
||||
uint32_t tid;
|
||||
bool needGc;
|
||||
bool needSnapshot;
|
||||
std::vector<uint32_t> fdVec;
|
||||
std::vector<uint32_t> tidVec;
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
static JsHeapDumpInfo *Unmarshalling(Parcel &parcel);
|
||||
};
|
||||
|
||||
@@ -441,7 +441,7 @@ public:
|
||||
*/
|
||||
virtual int StartRenderProcess(const std::string &renderParam,
|
||||
int32_t ipcFd, int32_t sharedFd,
|
||||
int32_t crashFd, pid_t &renderPid);
|
||||
int32_t crashFd, pid_t &renderPid, bool isGPU = false);
|
||||
|
||||
/**
|
||||
* Render process call this to attach app manager service.
|
||||
@@ -612,14 +612,6 @@ public:
|
||||
*/
|
||||
void SetKeepAliveEnableState(const std::string &bundleName, bool enable);
|
||||
|
||||
/**
|
||||
* Set application assertion pause state.
|
||||
*
|
||||
* @param pid App process pid.
|
||||
* @param flag assertion pause state.
|
||||
*/
|
||||
void SetAppAssertionPauseState(int32_t pid, bool flag);
|
||||
|
||||
/**
|
||||
* Register application or process state observer.
|
||||
* @param observer, ability token.
|
||||
@@ -743,6 +735,8 @@ public:
|
||||
AppExecFwk::PreloadMode preloadMode, int32_t appIndex = 0);
|
||||
|
||||
int32_t SetSupportedProcessCacheSelf(bool isSupport);
|
||||
|
||||
void SaveBrowserChannel(sptr<IRemoteObject> browser);
|
||||
private:
|
||||
void SetServiceManager(std::unique_ptr<AppServiceManager> serviceMgr);
|
||||
/**
|
||||
|
||||
@@ -78,6 +78,7 @@ enum class ProcessType {
|
||||
NORMAL = 0,
|
||||
EXTENSION,
|
||||
RENDER,
|
||||
GPU,
|
||||
};
|
||||
|
||||
enum class AppStartType {
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include "system_memory_attr.h"
|
||||
#include "want.h"
|
||||
#include "app_jsheap_mem_info.h"
|
||||
#include "running_multi_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@@ -143,6 +144,17 @@ public:
|
||||
*/
|
||||
virtual int GetAllRunningProcesses(std::vector<RunningProcessInfo> &info) = 0;
|
||||
|
||||
/**
|
||||
* GetRunningMultiAppInfoByBundleName, call GetRunningMultiAppInfoByBundleName() through proxy project.
|
||||
* Obtains information about multiapp that are running on the device.
|
||||
*
|
||||
* @param bundlename, bundle name in Application record.
|
||||
* @param info, output multiapp information.
|
||||
* @return ERR_OK ,return back success,others fail.
|
||||
*/
|
||||
virtual int32_t GetRunningMultiAppInfoByBundleName(const std::string &bundleName,
|
||||
RunningMultiAppInfo &info) = 0;
|
||||
|
||||
/**
|
||||
* GetRunningProcessesByBundleType, call GetRunningProcessesByBundleType() through proxy project.
|
||||
* Obtains information about application processes by bundle type that are running on the device.
|
||||
@@ -334,11 +346,12 @@ public:
|
||||
* @param sharedFd, shared memory file descriptior.
|
||||
* @param crashFd, crash signal file descriptior.
|
||||
* @param renderPid, created render pid.
|
||||
* @param isGPU, is or not gpu process
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int StartRenderProcess(const std::string &renderParam,
|
||||
int32_t ipcFd, int32_t sharedFd,
|
||||
int32_t crashFd, pid_t &renderPid) = 0;
|
||||
int32_t crashFd, pid_t &renderPid, bool isGPU = false) = 0;
|
||||
|
||||
/**
|
||||
* Render process call this to attach app manager service.
|
||||
@@ -652,6 +665,25 @@ public:
|
||||
}
|
||||
|
||||
virtual int32_t SetSupportedProcessCacheSelf(bool isSupport) = 0;
|
||||
|
||||
/**
|
||||
* Set application assertion pause state.
|
||||
*
|
||||
* @param flag assertion pause state.
|
||||
*/
|
||||
virtual void SetAppAssertionPauseState(bool flag) {}
|
||||
|
||||
/**
|
||||
* Start native child process, callde by ChildProcessManager.
|
||||
* @param libName lib file name to be load in child process
|
||||
* @param childProcessCount current started child process count
|
||||
* @param callback callback for notify start result
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int32_t StartNativeChildProcess(const std::string &libName, int32_t childProcessCount,
|
||||
const sptr<IRemoteObject> &callback) = 0;
|
||||
|
||||
virtual void SaveBrowserChannel(sptr<IRemoteObject> browser) = 0;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -99,7 +99,11 @@ enum class AppMgrInterfaceCode {
|
||||
PRELOAD_APPLICATION = 73,
|
||||
SET_SUPPORTED_PROCESS_CACHE_SELF = 74,
|
||||
APP_GET_RUNNING_PROCESSES_BY_BUNDLE_TYPE = 75,
|
||||
START_NATIVE_CHILD_PROCESS = 76,
|
||||
SAVE_BROWSER_CHANNEL = 77,
|
||||
GET_RUNNING_MULTIAPP_INFO_BY_BUNDLENAME = 78,
|
||||
SET_APP_ASSERT_PAUSE_STATE_SELF = 79,
|
||||
};
|
||||
} // AppExecFwk
|
||||
} // OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_APP_MGR_IPC_INTERFACE_CODE_H
|
||||
#endif // OHOS_ABILITY_RUNTIME_APP_MGR_IPC_INTERFACE_CODE_H
|
||||
|
||||
@@ -122,6 +122,16 @@ public:
|
||||
*/
|
||||
virtual int32_t GetAllRunningProcesses(std::vector<RunningProcessInfo> &info) override;
|
||||
|
||||
/**
|
||||
* GetALLRunningMultiAppInfo, call GetALLRunningMultiAppInfo() through proxy project.
|
||||
* Obtains information about multiapp that are running on the device.
|
||||
*
|
||||
* @param info, app name in multiappinfo.
|
||||
* @return ERR_OK ,return back success,others fail.
|
||||
*/
|
||||
virtual int32_t GetRunningMultiAppInfoByBundleName(const std::string &bundleName,
|
||||
RunningMultiAppInfo &info) override;
|
||||
|
||||
/**
|
||||
* GetRunningProcessesByBundleType, call GetRunningProcessesByBundleType() through proxy project.
|
||||
* Obtains information about application processes by bundle type that are running on the device.
|
||||
@@ -306,11 +316,12 @@ public:
|
||||
* @param sharedFd, shared memory file descriptior.
|
||||
* @param crashFd, crash signal file descriptior.
|
||||
* @param renderPid, created render pid.
|
||||
* @param isGPU, is or not GPU process
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int StartRenderProcess(const std::string &renderParam,
|
||||
int32_t ipcFd, int32_t sharedFd,
|
||||
int32_t crashFd, pid_t &renderPid) override;
|
||||
int32_t crashFd, pid_t &renderPid, bool isGPU = false) override;
|
||||
|
||||
/**
|
||||
* Render process call this to attach app manager service.
|
||||
@@ -568,6 +579,26 @@ public:
|
||||
virtual int32_t NotifyMemorySizeStateChanged(bool isMemorySizeSufficent) override;
|
||||
|
||||
int32_t SetSupportedProcessCacheSelf(bool isSupport) override;
|
||||
|
||||
/**
|
||||
* Set application assertion pause state.
|
||||
*
|
||||
* @param flag assertion pause state.
|
||||
*/
|
||||
void SetAppAssertionPauseState(bool flag) override;
|
||||
|
||||
/**
|
||||
* Start native child process, callde by ChildProcessManager.
|
||||
* @param libName lib file name to be load in child process
|
||||
* @param childProcessCount current started child process count
|
||||
* @param callback callback for notify start result
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
int32_t StartNativeChildProcess(const std::string &libName, int32_t childProcessCount,
|
||||
const sptr<IRemoteObject> &callback) override;
|
||||
|
||||
virtual void SaveBrowserChannel(sptr<IRemoteObject> browser) override;
|
||||
|
||||
private:
|
||||
bool SendTransactCmd(AppMgrInterfaceCode code, MessageParcel &data, MessageParcel &reply);
|
||||
bool WriteInterfaceToken(MessageParcel &data);
|
||||
|
||||
@@ -94,6 +94,7 @@ private:
|
||||
int32_t HandleUnregisterConfigurationObserver(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleDumpHeapMemory(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleDumpJsHeapMemory(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleGetRunningMultiAppInfoByBundleName(MessageParcel &data, MessageParcel &reply);
|
||||
#ifdef ABILITY_COMMAND_FOR_TEST
|
||||
int32_t HandleBlockAppServiceDone(MessageParcel &data, MessageParcel &reply);
|
||||
#endif
|
||||
@@ -135,7 +136,9 @@ private:
|
||||
int32_t HandleGetAllUIExtensionProviderPid(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleNotifyMemorySizeStateChanged(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleSetSupportedProcessCacheSelf(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
int32_t HandleSetAppAssertionPauseState(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleStartNativeChildProcess(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleSaveBrowserChannel(MessageParcel &data, MessageParcel &reply);
|
||||
using AppMgrFunc = int32_t (AppMgrStub::*)(MessageParcel &data, MessageParcel &reply);
|
||||
std::map<uint32_t, AppMgrFunc> memberFuncMap_;
|
||||
|
||||
|
||||
@@ -22,10 +22,15 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
|
||||
constexpr int32_t CHILD_PROCESS_TYPE_JS = 0;
|
||||
constexpr int32_t CHILD_PROCESS_TYPE_NATIVE = 1;
|
||||
|
||||
struct ChildProcessInfo : public Parcelable {
|
||||
std::int32_t pid;
|
||||
std::int32_t hostPid;
|
||||
std::int32_t uid;
|
||||
std::int32_t processType;
|
||||
std::string bundleName;
|
||||
std::string processName;
|
||||
std::string srcEntry;
|
||||
|
||||
@@ -34,9 +34,16 @@ public:
|
||||
*/
|
||||
virtual bool ScheduleExitProcessSafely() = 0;
|
||||
|
||||
/**
|
||||
* Notify child process run main proc from shared lib.
|
||||
* @param mainProcessCb Main process callback ipc object
|
||||
*/
|
||||
virtual bool ScheduleRunNativeProc(const sptr<IRemoteObject> &mainProcessCb) = 0;
|
||||
|
||||
enum class Message {
|
||||
SCHEDULE_LOAD_JS = 0,
|
||||
SCHEDULE_EXIT_PROCESS_SAFELY = 1,
|
||||
SCHEDULE_RUN_NATIVE_PROC = 2,
|
||||
};
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
|
||||
@@ -29,6 +29,7 @@ public:
|
||||
|
||||
bool ScheduleLoadJs() override;
|
||||
bool ScheduleExitProcessSafely() override;
|
||||
bool ScheduleRunNativeProc(const sptr<IRemoteObject> &mainProcessCb) override;
|
||||
|
||||
private:
|
||||
bool WriteInterfaceToken(MessageParcel &data);
|
||||
|
||||
@@ -36,6 +36,7 @@ public:
|
||||
private:
|
||||
int32_t HandleScheduleLoadJs(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleScheduleExitProcessSafely(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleScheduleRunNativeProc(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
using ChildSchedulerFunc = int32_t (ChildSchedulerStub::*)(MessageParcel &data, MessageParcel &reply);
|
||||
std::map<uint32_t, ChildSchedulerFunc> memberFuncMap_;
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
* @param crashFd, crash signal file descriptior.
|
||||
*/
|
||||
virtual void NotifyBrowserFd(int32_t ipcFd, int32_t sharedFd,
|
||||
int32_t crashFd) = 0;
|
||||
int32_t crashFd, sptr<IRemoteObject> browser) = 0;
|
||||
|
||||
enum class Message {
|
||||
NOTIFY_BROWSER_FD = 1,
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ABILITY_RUNTIME_NATIVE_CHILD_NOTIFY_INTERFACE_H
|
||||
#define OHOS_ABILITY_RUNTIME_NATIVE_CHILD_NOTIFY_INTERFACE_H
|
||||
|
||||
#include "iremote_broker.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
|
||||
class INativeChildNotify : public IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.NativeChildNotify");
|
||||
|
||||
/**
|
||||
* Notify native child process started.
|
||||
*
|
||||
* @param nativeChild child process ipc object
|
||||
*/
|
||||
virtual void OnNativeChildStarted(const sptr<IRemoteObject> &nativeChild) = 0;
|
||||
|
||||
/**
|
||||
* Notify native child process start failed.
|
||||
*
|
||||
* @param errCode failed error code
|
||||
*/
|
||||
virtual void OnError(int32_t errCode) = 0;
|
||||
|
||||
protected:
|
||||
static constexpr uint32_t IPC_ID_ON_NATIVE_CHILD_STARTED = 0;
|
||||
static constexpr uint32_t IPC_ID_ON_ERROR = 1;
|
||||
};
|
||||
|
||||
} // OHOS
|
||||
} // AppExecFwk
|
||||
|
||||
#endif // OHOS_ABILITY_RUNTIME_NATIVE_CHILD_NOTIFY_INTERFACE_H
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user