mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 22:21:36 -04:00
merge conflict
Signed-off-by: donglin <donglin9@huawei.com> Change-Id: Icdc54072810dd5bf292e089f07052946bceedde8
This commit is contained in:
+2
-1
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
@@ -78,6 +78,7 @@ declare_args() {
|
||||
ability_runtime_resource = true
|
||||
ability_runtime_appspawn = true
|
||||
efficiency_manager = true
|
||||
ability_fault_and_exit_test = false
|
||||
ability_command_for_test = false
|
||||
ability_runtime_feature_coverage = false
|
||||
|
||||
|
||||
+19
-1
@@ -51,6 +51,7 @@
|
||||
"ets_runtime",
|
||||
"ets_utils",
|
||||
"faultloggerd",
|
||||
"ffrt",
|
||||
"form_fwk",
|
||||
"graphic_standard",
|
||||
"hichecker",
|
||||
@@ -60,7 +61,6 @@
|
||||
"hitrace",
|
||||
"hiview",
|
||||
"i18n",
|
||||
"icu",
|
||||
"init",
|
||||
"input",
|
||||
"ipc",
|
||||
@@ -329,6 +329,24 @@
|
||||
]
|
||||
},
|
||||
"name": "//foundation/ability/ability_runtime/tools/aa:tools_aa_source_set"
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"header_base": "//foundation/ability/ability_runtime/interfaces/inner_api/ability_manager/include",
|
||||
"header_files": [
|
||||
"ability_start_setting.h"
|
||||
]
|
||||
},
|
||||
"name": "//foundation/ability/ability_runtime/interfaces/inner_api/ability_manager:ability_start_setting"
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"header_base": "//foundation/ability/ability_runtime/interfaces/kits/native/ability/native/ui_extension_ability",
|
||||
"header_files": [
|
||||
"ui_extension_context.h"
|
||||
]
|
||||
},
|
||||
"name": "//foundation/ability/ability_runtime/frameworks/native/ability/native:ui_extension"
|
||||
}
|
||||
],
|
||||
"test": [
|
||||
|
||||
@@ -174,6 +174,10 @@ class AbilityContext extends Context {
|
||||
requestDialogService(want, resultCallback) {
|
||||
return this.__context_impl__.requestDialogService(want, resultCallback);
|
||||
}
|
||||
|
||||
reportDrawnCompleted(callback) {
|
||||
return this.__context_impl__.reportDrawnCompleted(callback);
|
||||
}
|
||||
}
|
||||
|
||||
export default AbilityContext;
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "event_runner.h"
|
||||
#include "napi_common_util.h"
|
||||
#include "js_app_state_observer.h"
|
||||
#include "ipc_skeleton.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
@@ -132,6 +133,18 @@ public:
|
||||
JsAppManager* me = CheckParamsAndGetThis<JsAppManager>(engine, info);
|
||||
return (me != nullptr) ? me->OnIsRamConstrainedDevice(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
static NativeValue* GetProcessMemoryByPid(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
JsAppManager* me = CheckParamsAndGetThis<JsAppManager>(engine, info);
|
||||
return (me != nullptr) ? me->OnGetProcessMemoryByPid(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
static NativeValue* GetRunningProcessInfoByBundleName(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
JsAppManager* me = CheckParamsAndGetThis<JsAppManager>(engine, info);
|
||||
return (me != nullptr) ? me->OnGetRunningProcessInfoByBundleName(*engine, *info) : nullptr;
|
||||
}
|
||||
private:
|
||||
sptr<OHOS::AppExecFwk::IAppMgr> appManager_ = nullptr;
|
||||
sptr<OHOS::AAFwk::IAbilityManager> abilityManager_ = nullptr;
|
||||
@@ -523,6 +536,98 @@ private:
|
||||
return result;
|
||||
}
|
||||
|
||||
NativeValue* OnGetProcessMemoryByPid(NativeEngine& engine, const NativeCallbackInfo& info)
|
||||
{
|
||||
HILOG_DEBUG("is called");
|
||||
if (info.argc < ARGC_ONE) {
|
||||
HILOG_ERROR("Params not match");
|
||||
ThrowTooFewParametersError(engine);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
int32_t pid;
|
||||
if (!ConvertFromJsValue(engine, info.argv[0], pid)) {
|
||||
HILOG_ERROR("get pid failed");
|
||||
ThrowError(engine, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[pid, appManager = appManager_](NativeEngine &engine, AsyncTask &task, int32_t status) {
|
||||
if (appManager == nullptr) {
|
||||
HILOG_WARN("appManager is nullptr");
|
||||
task.Reject(engine, CreateJsError(engine, AbilityErrorCode::ERROR_CODE_INNER));
|
||||
return;
|
||||
}
|
||||
int32_t memSize = 0;
|
||||
int32_t ret = appManager->GetProcessMemoryByPid(pid, memSize);
|
||||
if (ret == 0) {
|
||||
task.ResolveWithNoError(engine, CreateJsValue(engine, memSize));
|
||||
} else {
|
||||
task.Reject(engine, CreateJsErrorByNativeErr(engine, ret));
|
||||
}
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc == ARGC_TWO) ? info.argv[INDEX_ONE] : nullptr;
|
||||
NativeValue* result = nullptr;
|
||||
AsyncTask::Schedule("JSAppManager::OnGetProcessMemoryByPid",
|
||||
engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
NativeValue* OnGetRunningProcessInfoByBundleName(NativeEngine& engine, const NativeCallbackInfo& info)
|
||||
{
|
||||
if (info.argc < ARGC_ONE) {
|
||||
ThrowTooFewParametersError(engine);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
std::string bundleName;
|
||||
int userId = IPCSkeleton::GetCallingUid() / AppExecFwk::Constants::BASE_USER_RANGE;
|
||||
bool isPromiseType = false;
|
||||
if (!ConvertFromJsValue(engine, info.argv[0], bundleName)) {
|
||||
HILOG_ERROR("First parameter must be string");
|
||||
ThrowError(engine, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
if (info.argc == ARGC_ONE) {
|
||||
isPromiseType = true;
|
||||
} else if (info.argc == ARGC_TWO) {
|
||||
if (ConvertFromJsValue(engine, info.argv[1], userId)) {
|
||||
isPromiseType = true;
|
||||
}
|
||||
} else if (info.argc == ARGC_THREE) {
|
||||
if (!ConvertFromJsValue(engine, info.argv[1], userId)) {
|
||||
HILOG_WARN("Must input userid and use callback when argc is three.");
|
||||
ThrowError(engine, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
} else {
|
||||
ThrowError(engine, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[bundleName, userId, appManager = appManager_](NativeEngine &engine, AsyncTask &task, int32_t status) {
|
||||
if (appManager == nullptr) {
|
||||
task.Reject(engine, CreateJsError(engine, AbilityErrorCode::ERROR_CODE_INNER));
|
||||
return;
|
||||
}
|
||||
std::vector<AppExecFwk::RunningProcessInfo> infos;
|
||||
int32_t ret = appManager->GetRunningProcessInformation(bundleName, userId, infos);
|
||||
if (ret == 0) {
|
||||
task.ResolveWithNoError(engine, CreateJsRunningProcessInfoArray(engine, infos));
|
||||
} else {
|
||||
task.Reject(engine, CreateJsErrorByNativeErr(engine, ret));
|
||||
}
|
||||
};
|
||||
NativeValue* lastParam = isPromiseType ? nullptr : info.argv[info.argc - 1];
|
||||
NativeValue* result = nullptr;
|
||||
AsyncTask::Schedule("JSAppManager::OnGetRunningProcessInfoByBundleName",
|
||||
engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CheckOnOffType(NativeEngine& engine, const NativeCallbackInfo& info)
|
||||
{
|
||||
if (info.argc < ARGC_ONE) {
|
||||
@@ -610,6 +715,10 @@ NativeValue* JsAppManagerInit(NativeEngine* engine, NativeValue* exportObj)
|
||||
JsAppManager::IsRamConstrainedDevice);
|
||||
BindNativeFunction(*engine, *object, "isSharedBundleRunning", moduleName,
|
||||
JsAppManager::IsSharedBundleRunning);
|
||||
BindNativeFunction(*engine, *object, "getProcessMemoryByPid", moduleName,
|
||||
JsAppManager::GetProcessMemoryByPid);
|
||||
BindNativeFunction(*engine, *object, "getRunningProcessInfoByBundleName", moduleName,
|
||||
JsAppManager::GetRunningProcessInfoByBundleName);
|
||||
HILOG_INFO("JsAppManagerInit end");
|
||||
return engine->CreateUndefined();
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ ohos_shared_library("featureability") {
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${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",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
@@ -56,7 +57,7 @@ ohos_shared_library("featureability") {
|
||||
include_dirs += [
|
||||
"${windowmanager_path}/interfaces/kits/napi/window_runtime/window_napi",
|
||||
]
|
||||
deps += [ "${windowmanager_path}/interfaces/kits/napi/window_runtime:window_native_kit" ]
|
||||
external_deps += [ "window_manager:window_native_kit" ]
|
||||
defines = [ "SUPPORT_GRAPHICS" ]
|
||||
}
|
||||
|
||||
|
||||
@@ -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_setting",
|
||||
"${ability_runtime_innerkits_path}/napi_base_context:napi_base_context",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
"${ability_runtime_innerkits_path}/wantagent:wantagent_innerkits",
|
||||
|
||||
@@ -694,7 +694,7 @@ bool RegisterMissionWrapDeviceId(napi_env &env, napi_value &argc,
|
||||
std::to_string(VALUE_BUFFER_SIZE);
|
||||
return false;
|
||||
}
|
||||
registerMissionCB->deviceId = deviceId;
|
||||
registerMissionCB->deviceId = std::string(deviceId);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1445,7 +1445,7 @@ bool GetUnRegisterMissionDeviceId(napi_env &env, const napi_value &value,
|
||||
std::to_string(VALUE_BUFFER_SIZE);
|
||||
return false;
|
||||
}
|
||||
registerMissionCB->deviceId = deviceId;
|
||||
registerMissionCB->deviceId = std::string(deviceId);
|
||||
HILOG_INFO("%{public}s called end.", __func__);
|
||||
return true;
|
||||
}
|
||||
@@ -1579,6 +1579,7 @@ void ContinueAbilityExecuteCB(napi_env env, void *data)
|
||||
}
|
||||
|
||||
continueAbilityCB->result = -1;
|
||||
continueAbilityCB->abilityContinuation->SetContinueAbilityHasBundleName(continueAbilityCB->hasArgsWithBundleName);
|
||||
if (continueAbilityCB->hasArgsWithBundleName) {
|
||||
continueAbilityCB->result = AAFwk::AbilityManagerClient::GetInstance()->
|
||||
ContinueMission(continueAbilityCB->srcDeviceId, continueAbilityCB->dstDeviceId,
|
||||
@@ -1606,19 +1607,30 @@ void ContinueAbilityCallbackCompletedCB(napi_env env, napi_status status, void *
|
||||
int32_t errCode = ErrorCodeReturn(continueAbilityCB->result);
|
||||
result[0] = GenerateBusinessError(env, errCode, ErrorMessageReturn(errCode));
|
||||
}
|
||||
|
||||
if (continueAbilityCB->callbackRef == nullptr) { // promise
|
||||
if (continueAbilityCB->result == 0) {
|
||||
napi_resolve_deferred(env, continueAbilityCB->cbBase.deferred, result[1]);
|
||||
} else {
|
||||
napi_reject_deferred(env, continueAbilityCB->cbBase.deferred, result[0]);
|
||||
if (!continueAbilityCB->hasArgsWithBundleName) {
|
||||
if (continueAbilityCB->callbackRef == nullptr) { // promise
|
||||
if (continueAbilityCB->result == 0) {
|
||||
napi_resolve_deferred(env, continueAbilityCB->cbBase.deferred, result[1]);
|
||||
} else {
|
||||
napi_reject_deferred(env, continueAbilityCB->cbBase.deferred, result[0]);
|
||||
}
|
||||
} else { // AsyncCallback
|
||||
napi_value callback = nullptr;
|
||||
napi_get_reference_value(env, continueAbilityCB->callbackRef, &callback);
|
||||
napi_value callResult;
|
||||
napi_call_function(env, nullptr, callback, ARGS_TWO, &result[0], &callResult);
|
||||
napi_delete_reference(env, continueAbilityCB->callbackRef);
|
||||
}
|
||||
} else {
|
||||
if (continueAbilityCB->callbackRef == nullptr && continueAbilityCB->result != 0) { // promise
|
||||
napi_reject_deferred(env, continueAbilityCB->cbBase.deferred, result[0]);
|
||||
} else if (continueAbilityCB->callbackRef != nullptr && continueAbilityCB->result != 0) { // AsyncCallback
|
||||
napi_value callback = nullptr;
|
||||
napi_get_reference_value(env, continueAbilityCB->callbackRef, &callback);
|
||||
napi_value callResult;
|
||||
napi_call_function(env, nullptr, callback, ARGS_TWO, &result[0], &callResult);
|
||||
napi_delete_reference(env, continueAbilityCB->callbackRef);
|
||||
}
|
||||
} else { // AsyncCallback
|
||||
napi_value callback = nullptr;
|
||||
napi_get_reference_value(env, continueAbilityCB->callbackRef, &callback);
|
||||
napi_value callResult;
|
||||
napi_call_function(env, nullptr, callback, ARGS_TWO, &result[0], &callResult);
|
||||
napi_delete_reference(env, continueAbilityCB->callbackRef);
|
||||
}
|
||||
napi_delete_async_work(env, continueAbilityCB->cbBase.asyncWork);
|
||||
delete continueAbilityCB;
|
||||
@@ -1997,13 +2009,12 @@ void UvWorkOnContinueDone(uv_work_t *work, int status)
|
||||
delete work;
|
||||
return;
|
||||
}
|
||||
|
||||
napi_value result = nullptr;
|
||||
HILOG_INFO("UvWorkOnContinueDone, resultCode = %{public}d", continueAbilityCB->resultCode);
|
||||
result =
|
||||
WrapInt32(continueAbilityCB->cbBase.cbInfo.env, continueAbilityCB->resultCode, "resultCode");
|
||||
|
||||
if (continueAbilityCB->cbBase.cbInfo.callback != nullptr) {
|
||||
napi_value result = WrapInt32(continueAbilityCB->cbBase.cbInfo.env, continueAbilityCB->resultCode, "resultCode");
|
||||
if (continueAbilityCB->hasArgsWithBundleName) {
|
||||
result = WrapInt32(continueAbilityCB->cbBase.cbInfo.env, continueAbilityCB->resultCode, "code");
|
||||
}
|
||||
if (continueAbilityCB->cbBase.deferred == nullptr) {
|
||||
napi_value callback = nullptr;
|
||||
napi_value undefined = nullptr;
|
||||
napi_get_undefined(continueAbilityCB->cbBase.cbInfo.env, &undefined);
|
||||
@@ -2025,7 +2036,6 @@ void UvWorkOnContinueDone(uv_work_t *work, int status)
|
||||
napi_reject_deferred(continueAbilityCB->cbBase.cbInfo.env, continueAbilityCB->cbBase.deferred, result[0]);
|
||||
}
|
||||
}
|
||||
|
||||
napi_close_handle_scope(continueAbilityCB->cbBase.cbInfo.env, scope);
|
||||
delete continueAbilityCB;
|
||||
continueAbilityCB = nullptr;
|
||||
@@ -2053,6 +2063,7 @@ void NAPIMissionContinue::OnContinueDone(int32_t result)
|
||||
return;
|
||||
}
|
||||
continueAbilityCB->cbBase.cbInfo.env = env_;
|
||||
continueAbilityCB->hasArgsWithBundleName = onContinueDoneHasBundleName_;
|
||||
if (onContinueDoneRef_ != nullptr) {
|
||||
continueAbilityCB->cbBase.cbInfo.callback = onContinueDoneRef_;
|
||||
} else {
|
||||
@@ -2081,10 +2092,16 @@ void NAPIMissionContinue::SetContinueAbilityCBRef(const napi_ref &ref)
|
||||
onContinueDoneRef_ = ref;
|
||||
}
|
||||
|
||||
void NAPIMissionContinue::SetContinueAbilityHasBundleName(bool hasBundleName)
|
||||
{
|
||||
onContinueDoneHasBundleName_ = hasBundleName;
|
||||
}
|
||||
|
||||
void NAPIMissionContinue::SetContinueAbilityPromiseRef(const napi_deferred &promiseDeferred)
|
||||
{
|
||||
promiseDeferred_ = promiseDeferred;
|
||||
}
|
||||
|
||||
napi_value DistributedMissionManagerExport(napi_env env, napi_value exports)
|
||||
{
|
||||
HILOG_INFO("%{public}s,called", __func__);
|
||||
|
||||
@@ -47,12 +47,14 @@ public:
|
||||
void SetEnv(const napi_env &env);
|
||||
void SetContinueAbilityEnv(const napi_env &env);
|
||||
void SetContinueAbilityCBRef(const napi_ref &ref);
|
||||
void SetContinueAbilityHasBundleName(bool hasBundleName);
|
||||
void SetContinueAbilityPromiseRef(const napi_deferred &promiseDeferred);
|
||||
|
||||
private:
|
||||
bool onContinueDoneHasBundleName_ = false;
|
||||
napi_env env_ = nullptr;
|
||||
napi_ref onContinueDoneRef_ = nullptr;
|
||||
napi_deferred promiseDeferred_;
|
||||
napi_deferred promiseDeferred_ = nullptr;
|
||||
};
|
||||
|
||||
class NAPIRemoteMissionListener : public AAFwk::RemoteMissionListenerStub {
|
||||
@@ -96,8 +98,8 @@ struct CallbackInfo {
|
||||
|
||||
struct CBBase {
|
||||
CallbackInfo cbInfo;
|
||||
napi_async_work asyncWork;
|
||||
napi_deferred deferred;
|
||||
napi_async_work asyncWork = nullptr;
|
||||
napi_deferred deferred = nullptr;
|
||||
int errCode = 0;
|
||||
};
|
||||
|
||||
@@ -153,7 +155,7 @@ struct ContinueAbilityCB {
|
||||
int missionId = 0;
|
||||
std::string bundleName;
|
||||
bool hasArgsWithBundleName = false;
|
||||
napi_ref callbackRef;
|
||||
napi_ref callbackRef = nullptr;
|
||||
};
|
||||
|
||||
struct SyncRemoteMissionsContext {
|
||||
|
||||
@@ -585,6 +585,12 @@ ErrCode AbilityContextImpl::RequestDialogService(NativeEngine &engine,
|
||||
return err;
|
||||
}
|
||||
|
||||
ErrCode AbilityContextImpl::ReportDrawnCompleted()
|
||||
{
|
||||
HILOG_DEBUG("called.");
|
||||
return AAFwk::AbilityManagerClient::GetInstance()->ReportDrawnCompleted(token_);
|
||||
}
|
||||
|
||||
void AbilityContextImpl::RequestDialogResultJSThreadWorker(uv_work_t* work, int status)
|
||||
{
|
||||
HILOG_DEBUG("RequestDialogResultJSThreadWorker");
|
||||
|
||||
@@ -219,7 +219,6 @@ ohos_shared_library("abilitykit_native") {
|
||||
"${ability_runtime_native_path}/appkit/app/context_container.cpp",
|
||||
"${ability_runtime_native_path}/appkit/app/context_deal.cpp",
|
||||
"${ability_runtime_native_path}/appkit/app/sys_mgr_client.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/ability_start_setting.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/launch_param.cpp",
|
||||
]
|
||||
configs = [ ":ability_config" ]
|
||||
@@ -233,6 +232,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_setting",
|
||||
"${ability_runtime_innerkits_path}/dataobs_manager:dataobs_manager",
|
||||
"${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper",
|
||||
"${ability_runtime_innerkits_path}/napi_base_context:napi_base_context",
|
||||
@@ -308,12 +308,12 @@ ohos_shared_library("abilitykit_native") {
|
||||
"form_fwk:form_manager",
|
||||
"input:libmmi-client",
|
||||
"multimedia_image_framework:image",
|
||||
"window_manager:windowstage_kit",
|
||||
]
|
||||
|
||||
public_deps += [
|
||||
"${multimedia_path}/interfaces/innerkits:image_native",
|
||||
"${windowmanager_path}/dm:libdm",
|
||||
"${windowmanager_path}/interfaces/kits/napi/window_runtime:windowstage_kit",
|
||||
"${windowmanager_path}/wm:libwm",
|
||||
]
|
||||
}
|
||||
@@ -729,9 +729,12 @@ group("extension_module") {
|
||||
}
|
||||
}
|
||||
|
||||
ohos_shared_library("ui_extension") {
|
||||
config("ui_extension_public_config") {
|
||||
visibility = [ ":*" ]
|
||||
include_dirs = [ "${ability_runtime_path}/interfaces/kits/native/ability/native/ui_extension_ability" ]
|
||||
}
|
||||
|
||||
ohos_shared_library("ui_extension") {
|
||||
sources = [
|
||||
"${ability_runtime_native_path}/ability/native/ui_extension_ability/js_ui_extension.cpp",
|
||||
"${ability_runtime_native_path}/ability/native/ui_extension_ability/js_ui_extension_content_session.cpp",
|
||||
@@ -740,6 +743,8 @@ ohos_shared_library("ui_extension") {
|
||||
"${ability_runtime_native_path}/ability/native/ui_extension_ability/ui_extension_context.cpp",
|
||||
]
|
||||
|
||||
public_configs = [ ":ui_extension_public_config" ]
|
||||
|
||||
deps = [
|
||||
":abilitykit_native",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
|
||||
@@ -179,6 +179,12 @@ NativeValue* JsAbilityContext::RequestDialogService(NativeEngine* engine, Native
|
||||
return (me != nullptr) ? me->OnRequestDialogService(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
NativeValue* JsAbilityContext::ReportDrawnCompleted(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
JsAbilityContext* me = CheckParamsAndGetThis<JsAbilityContext>(engine, info);
|
||||
return (me != nullptr) ? me->OnReportDrawnCompleted(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
NativeValue* JsAbilityContext::IsTerminating(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
JsAbilityContext* me = CheckParamsAndGetThis<JsAbilityContext>(engine, info);
|
||||
@@ -1179,6 +1185,36 @@ NativeValue* JsAbilityContext::OnIsTerminating(NativeEngine& engine, NativeCallb
|
||||
return engine.CreateBoolean(context->IsTerminating());
|
||||
}
|
||||
|
||||
NativeValue* JsAbilityContext::OnReportDrawnCompleted(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
HILOG_DEBUG("called.");
|
||||
auto innerErrorCode = std::make_shared<int32_t>(ERR_OK);
|
||||
AsyncTask::ExecuteCallback execute = [weak = context_, innerErrorCode]() {
|
||||
auto context = weak.lock();
|
||||
if (!context) {
|
||||
HILOG_WARN("context is released");
|
||||
*innerErrorCode = static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INVALID_CONTEXT);
|
||||
return;
|
||||
}
|
||||
|
||||
*innerErrorCode = context->ReportDrawnCompleted();
|
||||
};
|
||||
|
||||
AsyncTask::CompleteCallback complete = [innerErrorCode](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
if (*innerErrorCode == ERR_OK) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(engine, CreateJsErrorByNativeErr(engine, *innerErrorCode));
|
||||
}
|
||||
};
|
||||
|
||||
NativeValue* lastParam = info.argv[ARGC_ZERO];
|
||||
NativeValue* result = nullptr;
|
||||
AsyncTask::Schedule("JsAbilityContext::OnReportDrawnCompleted",
|
||||
engine, CreateAsyncTaskWithLastParam(engine, lastParam, std::move(execute), std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
bool JsAbilityContext::UnWrapWant(NativeEngine& engine, NativeValue* argv, AAFwk::Want& want)
|
||||
{
|
||||
if (argv == nullptr) {
|
||||
@@ -1376,6 +1412,8 @@ NativeValue* CreateJsAbilityContext(NativeEngine& engine, std::shared_ptr<Abilit
|
||||
JsAbilityContext::StartRecentAbility);
|
||||
BindNativeFunction(engine, *object, "requestDialogService", moduleName,
|
||||
JsAbilityContext::RequestDialogService);
|
||||
BindNativeFunction(engine, *object, "reportDrawnCompleted", moduleName,
|
||||
JsAbilityContext::ReportDrawnCompleted);
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
BindNativeFunction(engine, *object, "setMissionLabel", moduleName, JsAbilityContext::SetMissionLabel);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -53,6 +53,7 @@ constexpr static char ACE_FORM_ABILITY_NAME[] = "AceFormAbility";
|
||||
constexpr static char FORM_EXTENSION[] = "FormExtension";
|
||||
constexpr static char UI_EXTENSION[] = "UIExtensionAbility";
|
||||
constexpr static char MEDIA_CONTROL_EXTENSION[] = "MediaControlExtensionAbility";
|
||||
constexpr static char USER_AUTH_EXTENSION[] = "UserAuthExtensionAbility";
|
||||
#endif
|
||||
constexpr static char BASE_SERVICE_EXTENSION[] = "ServiceExtension";
|
||||
constexpr static char BASE_DRIVER_EXTENSION[] = "DriverExtension";
|
||||
@@ -177,6 +178,9 @@ std::string AbilityThread::CreateAbilityName(const std::shared_ptr<AbilityLocalR
|
||||
if (abilityInfo->extensionAbilityType == ExtensionAbilityType::APP_ACCOUNT_AUTHORIZATION) {
|
||||
abilityName = APP_ACCOUNT_AUTHORIZATION_EXTENSION;
|
||||
}
|
||||
if (abilityInfo->extensionAbilityType == ExtensionAbilityType::SYSDIALOG_USERAUTH) {
|
||||
abilityName = USER_AUTH_EXTENSION;
|
||||
}
|
||||
HILOG_DEBUG("CreateAbilityName extension type, abilityName:%{public}s", abilityName.c_str());
|
||||
} else {
|
||||
abilityName = abilityInfo->name;
|
||||
|
||||
+116
-6
@@ -16,6 +16,7 @@
|
||||
#include "js_ui_extension_content_session.h"
|
||||
|
||||
#include "ability_manager_client.h"
|
||||
#include "event_handler.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "js_error_utils.h"
|
||||
#include "js_runtime_utils.h"
|
||||
@@ -33,8 +34,8 @@ constexpr size_t ARGC_ONE = 1;
|
||||
} // namespace
|
||||
|
||||
JsUIExtensionContentSession::JsUIExtensionContentSession(
|
||||
sptr<AAFwk::SessionInfo> sessionInfo, sptr<Rosen::Window> uiWindow)
|
||||
: sessionInfo_(sessionInfo), uiWindow_(uiWindow) {}
|
||||
NativeEngine& engine, sptr<AAFwk::SessionInfo> sessionInfo, sptr<Rosen::Window> uiWindow)
|
||||
: engine_(engine), sessionInfo_(sessionInfo), uiWindow_(uiWindow) {}
|
||||
|
||||
void JsUIExtensionContentSession::Finalizer(NativeEngine* engine, void* data, void* hint)
|
||||
{
|
||||
@@ -99,19 +100,105 @@ NativeValue *JsUIExtensionContentSession::OnTerminateSelf(NativeEngine& engine,
|
||||
NativeValue *JsUIExtensionContentSession::OnTerminateSelfWithResult(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
HILOG_DEBUG("called");
|
||||
return nullptr;
|
||||
if (info.argc < ARGC_ONE) {
|
||||
HILOG_ERROR("invalid param");
|
||||
ThrowError(engine, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
int resultCode = 0;
|
||||
AAFwk::Want want;
|
||||
if (!UnWrapAbilityResult(engine, info.argv[INDEX_ZERO], resultCode, want)) {
|
||||
HILOG_ERROR("OnTerminateSelfWithResult Failed to parse ability result!");
|
||||
ThrowError(engine, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[uiWindow = uiWindow_, sessionInfo = sessionInfo_, want, resultCode](NativeEngine& engine,
|
||||
AsyncTask& task, int32_t status) {
|
||||
if (uiWindow == nullptr) {
|
||||
HILOG_WARN("uiWindow is nullptr");
|
||||
task.Reject(engine, CreateJsError(engine, AbilityErrorCode::ERROR_CODE_INNER));
|
||||
return;
|
||||
}
|
||||
auto ret = uiWindow->TransferAbilityResult(resultCode, want);
|
||||
if (ret != Rosen::WMError::WM_OK) {
|
||||
task.Reject(engine, CreateJsError(engine, AbilityErrorCode::ERROR_CODE_INNER));
|
||||
return;
|
||||
}
|
||||
auto errorCode = AAFwk::AbilityManagerClient::GetInstance()->TerminateUIExtensionAbility(sessionInfo);
|
||||
if (errorCode == 0) {
|
||||
task.ResolveWithNoError(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(engine, CreateJsErrorByNativeErr(engine, errorCode));
|
||||
}
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc > ARGC_ONE) ? info.argv[INDEX_ONE] : nullptr;
|
||||
NativeValue* result = nullptr;
|
||||
AsyncTask::Schedule("JsUIExtensionContentSession::OnTerminateSelfWithResult",
|
||||
engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
NativeValue *JsUIExtensionContentSession::OnSendData(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
HILOG_DEBUG("called");
|
||||
return nullptr;
|
||||
if (info.argc < ARGC_ONE) {
|
||||
HILOG_ERROR("invalid param");
|
||||
ThrowError(engine, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
AAFwk::WantParams params;
|
||||
if (!AppExecFwk::UnwrapWantParams(reinterpret_cast<napi_env>(&engine),
|
||||
reinterpret_cast<napi_value>(info.argv[INDEX_ZERO]), params)) {
|
||||
HILOG_ERROR("OnSendData Failed to parse param!");
|
||||
ThrowError(engine, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
if (uiWindow_ == nullptr) {
|
||||
HILOG_ERROR("uiWindow_ is nullptr");
|
||||
return engine.CreateNumber(static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INNER));
|
||||
}
|
||||
|
||||
Rosen::WMError ret = uiWindow_->TransferExtensionData(params);
|
||||
if (ret == Rosen::WMError::WM_OK) {
|
||||
return engine.CreateNumber(static_cast<int32_t>(AbilityErrorCode::ERROR_OK));
|
||||
} else {
|
||||
return engine.CreateNumber(static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INNER));
|
||||
}
|
||||
}
|
||||
|
||||
NativeValue *JsUIExtensionContentSession::OnSetReceiveDataCallback(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
HILOG_DEBUG("called");
|
||||
return nullptr;
|
||||
if (info.argc < ARGC_ONE || info.argv[INDEX_ZERO]->TypeOf() != NATIVE_FUNCTION) {
|
||||
HILOG_ERROR("invalid param");
|
||||
ThrowError(engine, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
NativeValue* callback = info.argv[INDEX_ZERO];
|
||||
receiveDataCallback_.reset(engine.CreateReference(callback, 1));
|
||||
if (!isRegistered) {
|
||||
if (uiWindow_ == nullptr) {
|
||||
HILOG_ERROR("uiWindow_ is nullptr");
|
||||
return engine.CreateNumber(static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INNER));
|
||||
}
|
||||
std::weak_ptr<NativeReference> weakCallback(receiveDataCallback_);
|
||||
auto handler = std::make_shared<AppExecFwk::EventHandler>(AppExecFwk::EventRunner::GetMainEventRunner());
|
||||
uiWindow_->RegisterTransferComponentDataListener([&engine = engine_, handler, weakCallback](
|
||||
const AAFwk::WantParams& wantParams) {
|
||||
if (handler) {
|
||||
handler->PostTask([&engine, weakCallback, wantParams]() {
|
||||
JsUIExtensionContentSession::CallReceiveDataCallBack(engine, weakCallback, wantParams);
|
||||
});
|
||||
}
|
||||
});
|
||||
isRegistered = true;
|
||||
}
|
||||
return engine.CreateNumber(static_cast<int32_t>(AbilityErrorCode::ERROR_OK));
|
||||
}
|
||||
|
||||
NativeValue *JsUIExtensionContentSession::OnLoadContent(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
@@ -148,7 +235,7 @@ NativeValue *JsUIExtensionContentSession::CreateJsUIExtensionContentSession(Nati
|
||||
NativeObject* object = ConvertNativeValueTo<NativeObject>(objValue);
|
||||
|
||||
std::unique_ptr<JsUIExtensionContentSession> jsSession =
|
||||
std::make_unique<JsUIExtensionContentSession>(sessionInfo, uiWindow);
|
||||
std::make_unique<JsUIExtensionContentSession>(engine, sessionInfo, uiWindow);
|
||||
object->SetNativePointer(jsSession.release(), Finalizer, nullptr);
|
||||
|
||||
const char *moduleName = "JsUIExtensionContentSession";
|
||||
@@ -160,6 +247,29 @@ NativeValue *JsUIExtensionContentSession::CreateJsUIExtensionContentSession(Nati
|
||||
return objValue;
|
||||
}
|
||||
|
||||
void JsUIExtensionContentSession::CallReceiveDataCallBack(NativeEngine& engine,
|
||||
std::weak_ptr<NativeReference> weakCallback, const AAFwk::WantParams& wantParams)
|
||||
{
|
||||
auto callback = weakCallback.lock();
|
||||
if (callback == nullptr) {
|
||||
HILOG_WARN("callback is nullptr");
|
||||
return;
|
||||
}
|
||||
NativeValue* method = callback->Get();
|
||||
if (method == nullptr) {
|
||||
HILOG_WARN("method is nullptr");
|
||||
return;
|
||||
}
|
||||
HandleScope handleScope(engine);
|
||||
NativeValue* nativeWantParams = AppExecFwk::CreateJsWantParams(engine, wantParams);
|
||||
if (nativeWantParams == nullptr) {
|
||||
HILOG_ERROR("nativeWantParams is nullptr");
|
||||
return;
|
||||
}
|
||||
NativeValue* argv[] = {nativeWantParams};
|
||||
engine.CallFunction(engine.GetGlobal(), method, argv, ARGC_ONE);
|
||||
}
|
||||
|
||||
bool JsUIExtensionContentSession::UnWrapAbilityResult(NativeEngine& engine, NativeValue* argv, int& resultCode,
|
||||
AAFwk::Want& want)
|
||||
{
|
||||
|
||||
@@ -433,6 +433,7 @@ void ContextImpl::InitResourceManager(const AppExecFwk::BundleInfo &bundleInfo,
|
||||
EventFwk::MatchingSkills matchingSkills;
|
||||
matchingSkills.AddEvent(OVERLAY_STATE_CHANGED);
|
||||
EventFwk::CommonEventSubscribeInfo subscribeInfo(matchingSkills);
|
||||
subscribeInfo.SetThreadMode(EventFwk::CommonEventSubscribeInfo::COMMON);
|
||||
auto callback = [this, resourceManager, bundleName = bundleInfo.name, moduleName =
|
||||
hapModuleInfo.moduleName, loadPath](const EventFwk::CommonEventData &data) {
|
||||
HILOG_INFO("On overlay changed.");
|
||||
|
||||
@@ -960,6 +960,7 @@ bool MainThread::InitResourceManager(std::shared_ptr<Global::Resource::ResourceM
|
||||
EventFwk::MatchingSkills matchingSkills;
|
||||
matchingSkills.AddEvent(OVERLAY_STATE_CHANGED);
|
||||
EventFwk::CommonEventSubscribeInfo subscribeInfo(matchingSkills);
|
||||
subscribeInfo.SetThreadMode(EventFwk::CommonEventSubscribeInfo::COMMON);
|
||||
wptr<MainThread> weak = this;
|
||||
auto callback = [weak, resourceManager, bundleName, moduleName = entryHapModuleInfo.moduleName,
|
||||
loadPath](const EventFwk::CommonEventData &data) {
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace {
|
||||
constexpr int64_t ASSET_FILE_MAX_SIZE = 32 * 1024 * 1024;
|
||||
const std::string BUNDLE_NAME_FLAG = "@bundle:";
|
||||
const std::string CACHE_DIRECTORY = "el2";
|
||||
const int PATH_THREE = 3;
|
||||
#ifdef APP_USE_ARM
|
||||
constexpr char ARK_DEBUGGER_LIB_PATH[] = "/system/lib/libark_debugger.z.so";
|
||||
#else
|
||||
@@ -161,7 +162,7 @@ void AssetHelper::operator()(const std::string& uri, std::vector<uint8_t>& conte
|
||||
realPath = uri.substr(1);
|
||||
} else if (uri.find("../") == 0 && !workerInfo_->isStageModel) {
|
||||
HILOG_DEBUG("uri start with ../");
|
||||
realPath = uri.substr(3);
|
||||
realPath = uri.substr(PATH_THREE);
|
||||
} else {
|
||||
HILOG_DEBUG("uri start with modulename");
|
||||
realPath = uri;
|
||||
|
||||
+9
-1
@@ -251,4 +251,12 @@ PROCESS_EXIT:
|
||||
__BASE: {type: BEHAVIOR, level: MINOR, tag: app, desc: application process exit event reporting}
|
||||
EXIT_TIME: {type: INT64, desc: process exit time}
|
||||
EXIT_RESULT: {type: INT32, desc: process exit result}
|
||||
EXIT_PID: {type: INT32, desc: pid}
|
||||
EXIT_PID: {type: INT32, desc: pid}
|
||||
|
||||
DRAWN_COMPLETED:
|
||||
__BASE: {type: BEHAVIOR, level: MINOR, tag: app, desc: drawn completed event reporting}
|
||||
APP_UID: {type: INT32, desc: app uid}
|
||||
APP_PID: {type: INT32, desc: app pid}
|
||||
BUNDLE_NAME: {type: STRING, desc: bundle name}
|
||||
MODULE_NAME: {type: STRING, desc: module name}
|
||||
ABILITY_NAME: {type: STRING, desc: ability name}
|
||||
@@ -72,7 +72,6 @@ ohos_shared_library("ability_manager") {
|
||||
"${ability_runtime_services_path}/abilitymgr/src/ability_running_info.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/ability_scheduler_proxy.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/ability_scheduler_stub.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/ability_start_setting.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/acquire_share_data_callback_proxy.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/acquire_share_data_callback_stub.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/caller_info.cpp",
|
||||
@@ -110,6 +109,7 @@ ohos_shared_library("ability_manager") {
|
||||
]
|
||||
|
||||
deps = [
|
||||
":ability_start_setting",
|
||||
"${ability_runtime_innerkits_path}/app_manager:app_manager",
|
||||
"//third_party/jsoncpp:jsoncpp",
|
||||
]
|
||||
@@ -155,3 +155,18 @@ ohos_shared_library("ability_manager_c") {
|
||||
subsystem_name = "ability"
|
||||
part_name = "ability_runtime"
|
||||
}
|
||||
|
||||
ohos_shared_library("ability_start_setting") {
|
||||
sources = [
|
||||
"${ability_runtime_services_path}/abilitymgr/src/ability_start_setting.cpp",
|
||||
]
|
||||
|
||||
public_configs = [ ":ability_manager_public_config" ]
|
||||
|
||||
external_deps = [ "c_utils:utils" ]
|
||||
|
||||
cflags_cc = []
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
subsystem_name = "ability"
|
||||
part_name = "ability_runtime"
|
||||
}
|
||||
|
||||
@@ -198,19 +198,15 @@ public:
|
||||
AppExecFwk::ExtensionAbilityType extensionType = AppExecFwk::ExtensionAbilityType::UNSPECIFIED);
|
||||
|
||||
/**
|
||||
* Start ui extension ability with want, send want to ability manager service.
|
||||
* Start ui extension ability with extension session info, send extension session info to ability manager service.
|
||||
*
|
||||
* @param want, the want of the ability to start.
|
||||
* @param extensionSessionInfo the extension session info of the ability to start.
|
||||
* @param userId, Designation User ID.
|
||||
* @param extensionType If an ExtensionAbilityType is set, only extension of that type can be started.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
ErrCode StartUIExtensionAbility(
|
||||
const Want &want,
|
||||
const sptr<SessionInfo> &extensionSessionInfo,
|
||||
int32_t userId = DEFAULT_INVAL_VALUE,
|
||||
AppExecFwk::ExtensionAbilityType extensionType = AppExecFwk::ExtensionAbilityType::UNSPECIFIED);
|
||||
int32_t userId = DEFAULT_INVAL_VALUE);
|
||||
|
||||
/**
|
||||
* Start ui ability with want, send want to ability manager service.
|
||||
@@ -1100,6 +1096,8 @@ public:
|
||||
*/
|
||||
sptr<IRemoteObject> GetSessionManagerService();
|
||||
|
||||
ErrCode ReportDrawnCompleted(const sptr<IRemoteObject> &token);
|
||||
|
||||
private:
|
||||
class AbilityMgrDeathRecipient : public IRemoteObject::DeathRecipient {
|
||||
public:
|
||||
|
||||
@@ -187,19 +187,15 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* Start ui extension ability with want, send want to ability manager service.
|
||||
* Start ui extension ability with extension session info, send extension session info to ability manager service.
|
||||
*
|
||||
* @param want, the want of the ability to start.
|
||||
* @param extensionSessionInfo the extension session info of the ability to start.
|
||||
* @param userId, Designation User ID.
|
||||
* @param extensionType If an ExtensionAbilityType is set, only extension of that type can be started.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int StartUIExtensionAbility(
|
||||
const Want &want,
|
||||
const sptr<SessionInfo> &extensionSessionInfo,
|
||||
int32_t userId = DEFAULT_INVAL_VALUE,
|
||||
AppExecFwk::ExtensionAbilityType extensionType = AppExecFwk::ExtensionAbilityType::UNSPECIFIED)
|
||||
int32_t userId = DEFAULT_INVAL_VALUE)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -959,6 +955,13 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Report drawn completed.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int32_t ReportDrawnCompleted(const sptr<IRemoteObject> &callerToken) = 0;
|
||||
|
||||
/**
|
||||
* Acquire the shared data.
|
||||
* @param missionId The missionId of Target ability.
|
||||
@@ -1345,6 +1348,9 @@ public:
|
||||
// ipc id for set sessionManagerService
|
||||
SET_SESSIONMANAGERSERVICE,
|
||||
|
||||
// ipc id for report drawn completed
|
||||
REPORT_DRAWN_COMPLETED,
|
||||
|
||||
GET_SESSIONMANAGERSERVICE,
|
||||
|
||||
// ipc id for continue ability(1101)
|
||||
|
||||
@@ -322,6 +322,9 @@ enum class AbilityManagerInterfaceCode {
|
||||
// ipc id for set sessionManagerService
|
||||
SET_SESSIONMANAGERSERVICE,
|
||||
|
||||
// ipc id for report drawn completed
|
||||
REPORT_DRAWN_COMPLETED,
|
||||
|
||||
GET_SESSIONMANAGERSERVICE,
|
||||
|
||||
// ipc id for continue ability(1101)
|
||||
|
||||
@@ -34,6 +34,8 @@ enum class TransitionReason : uint32_t {
|
||||
CLOSE,
|
||||
ABILITY_TRANSITION,
|
||||
BACK_TRANSITION,
|
||||
CLOSE_BUTTON,
|
||||
BACKGROUND_TRANSITION,
|
||||
};
|
||||
|
||||
struct AbilityTransitionInfo : public Parcelable {
|
||||
|
||||
@@ -31,7 +31,8 @@ class IWindowManagerServiceHandler : public OHOS::IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.aafwk.WindowManagerServiceHandler");
|
||||
|
||||
virtual void NotifyWindowTransition(sptr<AbilityTransitionInfo> fromInfo, sptr<AbilityTransitionInfo> toInfo) = 0;
|
||||
virtual void NotifyWindowTransition(sptr<AbilityTransitionInfo> fromInfo, sptr<AbilityTransitionInfo> toInfo,
|
||||
bool& animaEnabled) = 0;
|
||||
|
||||
virtual int32_t GetFocusWindow(sptr<IRemoteObject>& abilityToken) = 0;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
virtual ~WindowManagerServiceHandlerProxy() = default;
|
||||
|
||||
virtual void NotifyWindowTransition(sptr<AbilityTransitionInfo> fromInfo,
|
||||
sptr<AbilityTransitionInfo> toInfo) override;
|
||||
sptr<AbilityTransitionInfo> toInfo, bool& animaEnabled) override;
|
||||
|
||||
virtual int32_t GetFocusWindow(sptr<IRemoteObject>& abilityToken) override;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ WindowManagerServiceHandlerProxy::WindowManagerServiceHandlerProxy(const sptr<IR
|
||||
: IRemoteProxy<IWindowManagerServiceHandler>(impl) {}
|
||||
|
||||
void WindowManagerServiceHandlerProxy::NotifyWindowTransition(sptr<AbilityTransitionInfo> fromInfo,
|
||||
sptr<AbilityTransitionInfo> toInfo)
|
||||
sptr<AbilityTransitionInfo> toInfo, bool& animaEnabled)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s is called.", __func__);
|
||||
MessageParcel data;
|
||||
@@ -42,12 +42,17 @@ void WindowManagerServiceHandlerProxy::NotifyWindowTransition(sptr<AbilityTransi
|
||||
HILOG_ERROR("Write toInfo failed.");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteBool(animaEnabled)) {
|
||||
HILOG_ERROR("Write animaEnabled failed.");
|
||||
return;
|
||||
}
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
int error = Remote()->SendRequest(WMSCmd::ON_NOTIFY_WINDOW_TRANSITION, data, reply, option);
|
||||
if (error != ERR_OK) {
|
||||
HILOG_ERROR("SendRequest fail, error: %{public}d", error);
|
||||
}
|
||||
animaEnabled = reply.ReadBool();
|
||||
}
|
||||
|
||||
int32_t WindowManagerServiceHandlerProxy::GetFocusWindow(sptr<IRemoteObject>& abilityToken)
|
||||
|
||||
@@ -76,7 +76,9 @@ int WindowManagerServiceHandlerStub::NotifyWindowTransitionInner(MessageParcel &
|
||||
HILOG_ERROR("To read toInfo failed.");
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
NotifyWindowTransition(fromInfo, toInfo);
|
||||
bool animaEnabled = data.ReadBool();
|
||||
NotifyWindowTransition(fromInfo, toInfo, animaEnabled);
|
||||
reply.WriteBool(animaEnabled);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -381,6 +381,26 @@ public:
|
||||
*/
|
||||
virtual int32_t GetBundleNameByPid(const int pid, std::string &bundleName, int32_t &uid) = 0;
|
||||
|
||||
/**
|
||||
* get memorySize by pid.
|
||||
*
|
||||
* @param pid process id.
|
||||
* @param memorySize Output parameters, return memorySize in KB.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int32_t GetProcessMemoryByPid(const int32_t pid, int32_t &memorySize) = 0;
|
||||
|
||||
/**
|
||||
* get application processes information list by bundleName.
|
||||
*
|
||||
* @param bundleName Bundle name.
|
||||
* @param userId user Id in Application record.
|
||||
* @param info Output parameters, return running process info list.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int32_t GetRunningProcessInformation(
|
||||
const std::string &bundleName, int32_t userId, std::vector<RunningProcessInfo> &info) = 0;
|
||||
|
||||
// please add new message item to the bottom in order to prevent some unexpected BUG
|
||||
enum class Message {
|
||||
APP_ATTACH_APPLICATION = 0,
|
||||
@@ -426,6 +446,8 @@ public:
|
||||
JUDGE_SANDBOX_BY_PID,
|
||||
GET_BUNDLE_NAME_BY_PID,
|
||||
APP_GET_ALL_RENDER_PROCESSES,
|
||||
GET_PROCESS_MEMORY_BY_PID,
|
||||
GET_PIDS_BY_BUNDLENAME,
|
||||
};
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
|
||||
@@ -334,6 +334,26 @@ public:
|
||||
*/
|
||||
virtual int32_t GetBundleNameByPid(const int pid, std::string &bundleName, int32_t &uid) override;
|
||||
|
||||
/**
|
||||
* get memorySize by pid.
|
||||
*
|
||||
* @param pid process id.
|
||||
* @param memorySize Output parameters, return memorySize in KB.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int32_t GetProcessMemoryByPid(const int32_t pid, int32_t &memorySize) override;
|
||||
|
||||
/**
|
||||
* get application processes information list by bundleName.
|
||||
*
|
||||
* @param bundleName Bundle name.
|
||||
* @param userId user Id in Application record.
|
||||
* @param info Output parameters, return running process info list.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int32_t GetRunningProcessInformation(
|
||||
const std::string &bundleName, int32_t userId, std::vector<RunningProcessInfo> &info) override;
|
||||
|
||||
private:
|
||||
bool SendTransactCmd(AppMgrInterfaceCode code, MessageParcel &data, MessageParcel &reply);
|
||||
bool WriteInterfaceToken(MessageParcel &data);
|
||||
|
||||
@@ -103,6 +103,8 @@ private:
|
||||
int32_t HandleNotifyFaultBySA(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleJudgeSandboxByPid(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleGetBundleNameByPid(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleGetProcessMemoryByPid(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleGetRunningProcessInformation(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
using AppMgrFunc = int32_t (AppMgrStub::*)(MessageParcel &data, MessageParcel &reply);
|
||||
std::map<uint32_t, AppMgrFunc> memberFuncMap_;
|
||||
|
||||
@@ -1295,5 +1295,81 @@ int32_t AppMgrProxy::NotifyAppFaultBySA(const AppFaultDataBySA &faultData)
|
||||
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t AppMgrProxy::GetProcessMemoryByPid(const int32_t pid, int32_t &memorySize)
|
||||
{
|
||||
HILOG_DEBUG("GetProcessMemoryByPid start");
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("Write interface token failed.");
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(pid)) {
|
||||
HILOG_ERROR("write pid failed.");
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
HILOG_ERROR("Remote is nullptr.");
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
|
||||
auto ret = remote->SendRequest(static_cast<uint32_t>(IAppMgr::Message::GET_PROCESS_MEMORY_BY_PID),
|
||||
data, reply, option);
|
||||
if (ret != NO_ERROR) {
|
||||
HILOG_ERROR("Send request failed with error code %{public}d.", ret);
|
||||
return ret;
|
||||
}
|
||||
memorySize = reply.ReadInt32();
|
||||
auto result = reply.ReadInt32();
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t AppMgrProxy::GetRunningProcessInformation(
|
||||
const std::string &bundleName, int32_t userId, std::vector<RunningProcessInfo> &info)
|
||||
{
|
||||
HILOG_DEBUG("GetRunningProcessInformation start");
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("Write interface token failed.");
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
|
||||
if (!data.WriteString(bundleName)) {
|
||||
HILOG_ERROR("write bundleName failed.");
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(userId)) {
|
||||
HILOG_ERROR("write userId failed.");
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
HILOG_ERROR("Remote is nullptr.");
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
|
||||
auto ret = remote->SendRequest(static_cast<uint32_t>(IAppMgr::Message::GET_PIDS_BY_BUNDLENAME),
|
||||
data, reply, option);
|
||||
if (ret != NO_ERROR) {
|
||||
HILOG_ERROR("Send request failed with error code %{public}d.", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto error = GetParcelableInfos<RunningProcessInfo>(reply, info);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("GetParcelableInfos fail, error: %{public}d", error);
|
||||
return error;
|
||||
}
|
||||
int result = reply.ReadInt32();
|
||||
return result;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -124,6 +124,10 @@ AppMgrStub::AppMgrStub()
|
||||
&AppMgrStub::HandleGetBundleNameByPid;
|
||||
memberFuncMap_[static_cast<uint32_t>(AppMgrInterfaceCode::APP_GET_ALL_RENDER_PROCESSES)] =
|
||||
&AppMgrStub::HandleGetAllRenderProcesses;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAppMgr::Message::GET_PROCESS_MEMORY_BY_PID)] =
|
||||
&AppMgrStub::HandleGetProcessMemoryByPid;
|
||||
memberFuncMap_[static_cast<uint32_t>(IAppMgr::Message::GET_PIDS_BY_BUNDLENAME)] =
|
||||
&AppMgrStub::HandleGetRunningProcessInformation;
|
||||
}
|
||||
|
||||
AppMgrStub::~AppMgrStub()
|
||||
@@ -736,5 +740,42 @@ int32_t AppMgrStub::HandleNotifyFaultBySA(MessageParcel &data, MessageParcel &re
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AppMgrStub::HandleGetProcessMemoryByPid(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
int32_t pid = data.ReadInt32();
|
||||
int32_t memorySize = 0;
|
||||
auto result = GetProcessMemoryByPid(pid, memorySize);
|
||||
if (!reply.WriteInt32(memorySize)) {
|
||||
HILOG_ERROR("Memory size write failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
if (!reply.WriteInt32(result)) {
|
||||
HILOG_ERROR("fail to write result.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AppMgrStub::HandleGetRunningProcessInformation(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HITRACE_METER(HITRACE_TAG_APP);
|
||||
std::string bundleName = data.ReadString();
|
||||
int32_t userId = data.ReadInt32();
|
||||
std::vector<RunningProcessInfo> info;
|
||||
auto result = GetRunningProcessInformation(bundleName, userId, info);
|
||||
reply.WriteInt32(info.size());
|
||||
for (auto &it : info) {
|
||||
if (!reply.WriteParcelable(&it)) {
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
}
|
||||
if (!reply.WriteInt32(result)) {
|
||||
HILOG_ERROR("fail to write result.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
* @param autoremove the uri is temperarily or not
|
||||
*/
|
||||
int GrantUriPermission(const Uri &uri, unsigned int flag,
|
||||
const std::string targetBundleName, int autoremove);
|
||||
const std::string targetBundleName, int autoremove, int32_t appIndex = 0);
|
||||
|
||||
/**
|
||||
* @brief Clear user's uri authorization record with auto remove flag.
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
* @return Returns true if the authorization is successful, otherwise returns false.
|
||||
*/
|
||||
virtual int GrantUriPermission(const Uri &uri, unsigned int flag,
|
||||
const std::string targetBundleName, int autoremove) = 0;
|
||||
const std::string targetBundleName, int autoremove, int32_t appIndex = 0) = 0;
|
||||
|
||||
/**
|
||||
* @brief Clear user's uri authorization record with autoremove flag.
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
virtual ~UriPermissionManagerProxy() = default;
|
||||
|
||||
virtual int GrantUriPermission(const Uri &uri, unsigned int flag,
|
||||
const std::string targetBundleName, int autoremove) override;
|
||||
const std::string targetBundleName, int autoremove, int32_t appIndex = 0) override;
|
||||
|
||||
virtual void RevokeUriPermission(const Security::AccessToken::AccessTokenID tokenId) override;
|
||||
virtual int RevokeUriPermissionManually(const Uri &uri, const std::string bundleName) override;
|
||||
|
||||
@@ -34,12 +34,12 @@ UriPermissionManagerClient& UriPermissionManagerClient::GetInstance()
|
||||
}
|
||||
|
||||
int UriPermissionManagerClient::GrantUriPermission(const Uri &uri, unsigned int flag,
|
||||
const std::string targetBundleName, int autoremove)
|
||||
const std::string targetBundleName, int autoremove, int32_t appIndex)
|
||||
{
|
||||
HILOG_DEBUG("targetBundleName :%{public}s", targetBundleName.c_str());
|
||||
auto uriPermMgr = ConnectUriPermService();
|
||||
if (uriPermMgr) {
|
||||
return uriPermMgr->GrantUriPermission(uri, flag, targetBundleName, autoremove);
|
||||
return uriPermMgr->GrantUriPermission(uri, flag, targetBundleName, autoremove, appIndex);
|
||||
}
|
||||
return INNER_ERR;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ UriPermissionManagerProxy::UriPermissionManagerProxy(const sptr<IRemoteObject> &
|
||||
: IRemoteProxy<IUriPermissionManager>(impl) {}
|
||||
|
||||
int UriPermissionManagerProxy::GrantUriPermission(const Uri &uri, unsigned int flag,
|
||||
const std::string targetBundleName, int autoremove)
|
||||
const std::string targetBundleName, int autoremove, int32_t appIndex)
|
||||
{
|
||||
HILOG_DEBUG("UriPermissionManagerProxy::GrantUriPermission is called.");
|
||||
MessageParcel data;
|
||||
@@ -49,6 +49,10 @@ int UriPermissionManagerProxy::GrantUriPermission(const Uri &uri, unsigned int f
|
||||
HILOG_ERROR("Write autoremove failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteInt32(appIndex)) {
|
||||
HILOG_ERROR("Write appIndex failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int error = Remote()->SendRequest(UriPermMgrCmd::ON_GRANT_URI_PERMISSION, data, reply, option);
|
||||
|
||||
@@ -38,7 +38,8 @@ int UriPermissionManagerStub::OnRemoteRequest(
|
||||
auto flag = data.ReadInt32();
|
||||
auto targetBundleName = data.ReadString();
|
||||
auto autoremove = data.ReadInt32();
|
||||
int result = GrantUriPermission(*uri, flag, targetBundleName, autoremove);
|
||||
auto appIndex = data.ReadInt32();
|
||||
int result = GrantUriPermission(*uri, flag, targetBundleName, autoremove, appIndex);
|
||||
reply.WriteInt32(result);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
#include "ability_runtime_error_util.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "pending_want_record.h"
|
||||
#include "want_agent_client.h"
|
||||
#include "want_agent_log_wrapper.h"
|
||||
#include "want_sender_info.h"
|
||||
|
||||
@@ -276,6 +276,13 @@ public:
|
||||
*/
|
||||
virtual ErrCode RequestDialogService(NativeEngine &engine, AAFwk::Want &want, RequestDialogResultTask &&task) = 0;
|
||||
|
||||
/**
|
||||
* @brief Report drawn completed.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual ErrCode ReportDrawnCompleted() = 0;
|
||||
|
||||
virtual ErrCode GetMissionId(int32_t &missionId) = 0;
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
|
||||
@@ -187,6 +187,8 @@ public:
|
||||
|
||||
ErrCode RequestDialogService(NativeEngine &engine, AAFwk::Want &want, RequestDialogResultTask &&task) override;
|
||||
|
||||
ErrCode ReportDrawnCompleted() override;
|
||||
|
||||
ErrCode GetMissionId(int32_t &missionId) override;
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
|
||||
@@ -58,6 +58,7 @@ public:
|
||||
static NativeValue* RestoreWindowStage(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* RequestDialogService(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* IsTerminating(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* ReportDrawnCompleted(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
|
||||
static void ConfigurationUpdated(NativeEngine* engine, std::shared_ptr<NativeReference> &jsContext,
|
||||
const std::shared_ptr<AppExecFwk::Configuration> &config);
|
||||
@@ -98,6 +99,7 @@ private:
|
||||
NativeValue* OnRestoreWindowStage(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnRequestDialogService(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnIsTerminating(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnReportDrawnCompleted(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
|
||||
static bool UnWrapWant(NativeEngine& engine, NativeValue* argv, AAFwk::Want& want);
|
||||
static NativeValue* WrapWant(NativeEngine& engine, const AAFwk::Want& want);
|
||||
|
||||
+7
-1
@@ -24,7 +24,8 @@ namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
class JsUIExtensionContentSession {
|
||||
public:
|
||||
JsUIExtensionContentSession(sptr<AAFwk::SessionInfo> sessionInfo, sptr<Rosen::Window> uiWindow);
|
||||
JsUIExtensionContentSession(NativeEngine& engine, sptr<AAFwk::SessionInfo> sessionInfo,
|
||||
sptr<Rosen::Window> uiWindow);
|
||||
virtual ~JsUIExtensionContentSession() = default;
|
||||
static void Finalizer(NativeEngine* engine, void* data, void* hint);
|
||||
static NativeValue* CreateJsUIExtensionContentSession(NativeEngine& engine,
|
||||
@@ -43,10 +44,15 @@ protected:
|
||||
NativeValue* OnSetReceiveDataCallback(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnLoadContent(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
|
||||
static void CallReceiveDataCallBack(NativeEngine& engine, std::weak_ptr<NativeReference> weakCallback,
|
||||
const AAFwk::WantParams& wantParams);
|
||||
static bool UnWrapAbilityResult(NativeEngine& engine, NativeValue* argv, int& resultCode, AAFwk::Want& want);
|
||||
private:
|
||||
NativeEngine& engine_;
|
||||
sptr<AAFwk::SessionInfo> sessionInfo_;
|
||||
sptr<Rosen::Window> uiWindow_;
|
||||
std::shared_ptr<NativeReference> receiveDataCallback_;
|
||||
bool isRegistered = false;
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -109,7 +109,6 @@ std::string SourceMap::TranslateBySourceMap(const std::string& stackStr)
|
||||
ExtractStackInfo(stackStr, res);
|
||||
|
||||
// collect error info first
|
||||
bool needGetErrorPos = false;
|
||||
uint32_t i = 0;
|
||||
std::string codeStart = "SourceCode (";
|
||||
std::string sourceCode = "";
|
||||
@@ -119,7 +118,6 @@ std::string SourceMap::TranslateBySourceMap(const std::string& stackStr)
|
||||
if (fristLine.substr(0, codeStartLen).compare(codeStart) == 0) {
|
||||
sourceCode = fristLine.substr(codeStartLen, fristLine.length() - codeStartLen - 1);
|
||||
i = 1; // 1 means Convert from the second line
|
||||
needGetErrorPos = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-5
@@ -61,16 +61,14 @@ public:
|
||||
std::vector<PurposeInfo> &purposeInfos) = 0;
|
||||
|
||||
/**
|
||||
* Start ui extension ability with want, send want to ability manager service.
|
||||
* Start ui extension ability with extension session info, send extension session info to ability manager service.
|
||||
*
|
||||
* @param want, the want of the ability to start.
|
||||
* @param sessionInfo the extension session info of the ability to start.
|
||||
* @param userId, Designation User ID.
|
||||
* @param extensionType If an ExtensionAbilityType is set, only extension of that type can be started.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int32_t StartUIExtensionAbility(const Want &want, const sptr<SessionInfo> &sessionInfo,
|
||||
int32_t userId = DEFAULT_INVAL_VALUE, ExtensionAbilityType extensionType = ExtensionAbilityType::UNSPECIFIED)
|
||||
virtual int32_t StartUIExtensionAbility(const sptr<SessionInfo> &sessionInfo,
|
||||
int32_t userId = DEFAULT_INVAL_VALUE)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -51,17 +51,14 @@ public:
|
||||
std::vector<PurposeInfo> &purposeInfos) override;
|
||||
|
||||
/**
|
||||
* Start ui extension ability with want, send want to ability manager service.
|
||||
* Start ui extension ability with extension session info, send extension session info to ability manager service.
|
||||
*
|
||||
* @param want, the want of the ability to start.
|
||||
* @param sessionInfo the extension session info of the ability to start.
|
||||
* @param userId, Designation User ID.
|
||||
* @param extensionType If an ExtensionAbilityType is set, only extension of that type can be started.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
int32_t StartUIExtensionAbility(const Want &want, const sptr<SessionInfo> &sessionInfo,
|
||||
int32_t userId = DEFAULT_INVAL_VALUE,
|
||||
ExtensionAbilityType extensionType = ExtensionAbilityType::UNSPECIFIED) override;
|
||||
int32_t StartUIExtensionAbility(const sptr<SessionInfo> &sessionInfo,
|
||||
int32_t userId = DEFAULT_INVAL_VALUE) override;
|
||||
|
||||
/**
|
||||
* Connect ui extension ability with want, connect session with service ability.
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
constexpr int32_t CYCLE_LIMIT = 1000;
|
||||
bool AppInfo::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
bundleName = Str16ToStr8(parcel.ReadString16());
|
||||
@@ -146,6 +147,10 @@ bool PurposeInfo::ReadFromParcel(Parcel &parcel)
|
||||
int32_t supportDimensionSize;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, supportDimensionSize);
|
||||
CONTAINER_SECURITY_VERIFY(parcel, supportDimensionSize, &supportDimensions);
|
||||
if (supportDimensionSize > CYCLE_LIMIT) {
|
||||
APP_LOGE("supportDimensionSize is too large.");
|
||||
return false;
|
||||
}
|
||||
for (int32_t i = 0; i < supportDimensionSize; i++) {
|
||||
supportDimensions.emplace_back(parcel.ReadInt32());
|
||||
}
|
||||
|
||||
@@ -79,8 +79,7 @@ int32_t ServiceRouterMgrProxy::QueryPurposeInfos(const Want &want, const std::st
|
||||
return res;
|
||||
}
|
||||
|
||||
int32_t ServiceRouterMgrProxy::StartUIExtensionAbility(const Want &want, const sptr<SessionInfo> &sessionInfo,
|
||||
int32_t userId, ExtensionAbilityType extensionType)
|
||||
int32_t ServiceRouterMgrProxy::StartUIExtensionAbility(const sptr<SessionInfo> &sessionInfo, int32_t userId)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
@@ -89,10 +88,6 @@ int32_t ServiceRouterMgrProxy::StartUIExtensionAbility(const Want &want, const s
|
||||
APP_LOGE("write interfaceToken failed");
|
||||
return ERR_APPEXECFWK_PARCEL_ERROR;
|
||||
}
|
||||
if (!data.WriteParcelable(&want)) {
|
||||
APP_LOGE("want write failed.");
|
||||
return ERR_APPEXECFWK_PARCEL_ERROR;
|
||||
}
|
||||
|
||||
if (sessionInfo) {
|
||||
if (!data.WriteBool(true) || !data.WriteParcelable(sessionInfo)) {
|
||||
@@ -110,10 +105,6 @@ int32_t ServiceRouterMgrProxy::StartUIExtensionAbility(const Want &want, const s
|
||||
APP_LOGE("StartExtensionAbility, userId write failed.");
|
||||
return ERR_APPEXECFWK_PARCEL_ERROR;
|
||||
}
|
||||
if (!data.WriteInt32(static_cast<int32_t>(extensionType))) {
|
||||
APP_LOGE("StartExtensionAbility, extensionType write failed.");
|
||||
return ERR_APPEXECFWK_PARCEL_ERROR;
|
||||
}
|
||||
if (!Remote()) {
|
||||
APP_LOGE("StartExtensionAbility, Remote error.");
|
||||
return ERR_APPEXECFWK_PARCEL_ERROR;
|
||||
|
||||
@@ -74,17 +74,14 @@ public:
|
||||
std::vector<PurposeInfo> &purposeInfos) override;
|
||||
|
||||
/**
|
||||
* Start ui extension ability with want, send want to ability manager service.
|
||||
* Start ui extension ability with extension session info, send extension session info to ability manager service.
|
||||
*
|
||||
* @param want, the want of the ability to start.
|
||||
* @param sessionInfo the extension session info of the ability to start.
|
||||
* @param userId, Designation User ID.
|
||||
* @param extensionType If an ExtensionAbilityType is set, only extension of that type can be started.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int32_t StartUIExtensionAbility(const Want &want, const sptr<SessionInfo> &sessionInfo,
|
||||
int32_t userId = DEFAULT_INVAL_VALUE,
|
||||
ExtensionAbilityType extensionType = ExtensionAbilityType::UNSPECIFIED) override;
|
||||
virtual int32_t StartUIExtensionAbility(const sptr<SessionInfo> &sessionInfo,
|
||||
int32_t userId = DEFAULT_INVAL_VALUE) override;
|
||||
|
||||
/**
|
||||
* Connect ui extension ability with want, connect session with service ability.
|
||||
|
||||
@@ -143,6 +143,7 @@ bool ServiceRouterMgrService::ServiceRouterMgrService::SubscribeCommonEvent()
|
||||
matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_REMOVED);
|
||||
matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_USER_SWITCHED);
|
||||
EventFwk::CommonEventSubscribeInfo subscribeInfo(matchingSkills);
|
||||
subscribeInfo.SetThreadMode(EventFwk::CommonEventSubscribeInfo::COMMON);
|
||||
|
||||
eventSubscriber_ = std::make_shared<SrCommonEventSubscriber>(subscribeInfo);
|
||||
eventSubscriber_->SetEventHandler(handler_);
|
||||
@@ -170,13 +171,11 @@ int32_t ServiceRouterMgrService::QueryPurposeInfos(const Want &want, const std::
|
||||
return ServiceRouterDataMgr::GetInstance().QueryPurposeInfos(want, purposeName, purposeInfos);
|
||||
}
|
||||
|
||||
int32_t ServiceRouterMgrService::StartUIExtensionAbility(const Want &want, const sptr<SessionInfo> &sessionInfo,
|
||||
int32_t userId, ExtensionAbilityType extensionType)
|
||||
int32_t ServiceRouterMgrService::StartUIExtensionAbility(const sptr<SessionInfo> &sessionInfo, int32_t userId)
|
||||
{
|
||||
APP_LOGD("StartUIExtensionAbility start:");
|
||||
DelayUnloadTask();
|
||||
return IN_PROCESS_CALL(AbilityManagerClient::GetInstance()->
|
||||
StartUIExtensionAbility(want, sessionInfo, userId, extensionType));
|
||||
return IN_PROCESS_CALL(AbilityManagerClient::GetInstance()->StartUIExtensionAbility(sessionInfo, userId));
|
||||
}
|
||||
|
||||
int32_t ServiceRouterMgrService::ConnectUIExtensionAbility(const Want &want, const sptr<IAbilityConnection> &connect,
|
||||
|
||||
@@ -126,23 +126,16 @@ int ServiceRouterMgrStub::HandleQueryPurposeInfos(MessageParcel &data, MessagePa
|
||||
int ServiceRouterMgrStub::HandleStartUIExtensionAbility(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
APP_LOGD("ServiceRouterMgrStub handle start ui extension ability");
|
||||
Want *want = data.ReadParcelable<Want>();
|
||||
if (want == nullptr) {
|
||||
APP_LOGE("ReadParcelable<want> failed");
|
||||
return ERR_APPEXECFWK_PARCEL_ERROR;
|
||||
}
|
||||
sptr<SessionInfo> sessionInfo = nullptr;
|
||||
if (data.ReadBool()) {
|
||||
sessionInfo = data.ReadParcelable<SessionInfo>();
|
||||
}
|
||||
int32_t userId = data.ReadInt32();
|
||||
ExtensionAbilityType type = static_cast<ExtensionAbilityType>(data.ReadInt32());
|
||||
int32_t result = StartUIExtensionAbility(*want, sessionInfo, userId, type);
|
||||
int32_t result = StartUIExtensionAbility(sessionInfo, userId);
|
||||
if (!reply.WriteInt32(result)) {
|
||||
APP_LOGE("write result failed");
|
||||
return ERR_APPEXECFWK_PARCEL_ERROR;
|
||||
}
|
||||
delete want;
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -73,6 +73,10 @@ config("abilityms_config") {
|
||||
defines += [ "ABILITY_COMMAND_FOR_TEST" ]
|
||||
}
|
||||
|
||||
if (ability_fault_and_exit_test) {
|
||||
defines += [ "ABILITY_FAULT_AND_EXIT_TEST" ]
|
||||
}
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
include_dirs += [
|
||||
"${graphic_path}/interfaces/inner_api",
|
||||
@@ -116,6 +120,7 @@ ohos_shared_library("abilityms") {
|
||||
]
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_setting",
|
||||
"${ability_runtime_innerkits_path}/app_manager:app_manager",
|
||||
"${ability_runtime_innerkits_path}/connectionobs_manager:connection_obs_manager",
|
||||
"${ability_runtime_innerkits_path}/deps_wrapper:ability_deps_wrapper",
|
||||
@@ -123,6 +128,7 @@ ohos_shared_library("abilityms") {
|
||||
"${ability_runtime_native_path}/ability/native:abilitykit_native",
|
||||
"${ability_runtime_services_path}/common:event_report",
|
||||
"${ability_runtime_services_path}/common:perm_verification",
|
||||
"${ability_runtime_services_path}/common:task_handler_wrap",
|
||||
"//third_party/icu/icu4c:shared_icuuc",
|
||||
]
|
||||
|
||||
@@ -138,7 +144,7 @@ ohos_shared_library("abilityms") {
|
||||
"common_event_service:cesfwk_core",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"dsoftbus:softbus_client",
|
||||
"eventhandler:libeventhandler",
|
||||
"ffrt:libffrt",
|
||||
"hicollie:libhicollie",
|
||||
"hilog:libhilog",
|
||||
"hisysevent:libhisysevent",
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#include "bundle_event_callback_host.h"
|
||||
#include "common_event_support.h"
|
||||
#include "ability_event_handler.h"
|
||||
#include "task_handler_wrap.h"
|
||||
#include "ability_event_util.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
@@ -31,8 +31,7 @@ namespace AAFwk {
|
||||
*/
|
||||
class AbilityBundleEventCallback : public AppExecFwk::BundleEventCallbackHost {
|
||||
public:
|
||||
AbilityBundleEventCallback();
|
||||
explicit AbilityBundleEventCallback(std::shared_ptr<AbilityEventHandler> eventHandler);
|
||||
explicit AbilityBundleEventCallback(std::shared_ptr<TaskHandlerWrap> taskHandler);
|
||||
|
||||
~AbilityBundleEventCallback() = default;
|
||||
|
||||
@@ -50,7 +49,7 @@ private:
|
||||
|
||||
DISALLOW_COPY_AND_MOVE(AbilityBundleEventCallback);
|
||||
AbilityEventUtil abilityEventHelper_;
|
||||
std::shared_ptr<AbilityEventHandler> eventHandler_ = nullptr;
|
||||
std::shared_ptr<TaskHandlerWrap> taskHandler_;
|
||||
};
|
||||
} // namespace OHOS
|
||||
} // namespace AAFwk
|
||||
|
||||
@@ -20,9 +20,11 @@
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include "cpp/mutex.h"
|
||||
|
||||
#include "ability_connect_callback_interface.h"
|
||||
#include "ability_event_handler.h"
|
||||
#include "task_handler_wrap.h"
|
||||
#include "event_handler_wrap.h"
|
||||
#include "ability_record.h"
|
||||
#include "ability_running_info.h"
|
||||
#include "extension_running_info.h"
|
||||
@@ -197,12 +199,19 @@ public:
|
||||
void GetExtensionRunningInfo(std::shared_ptr<AbilityRecord> &abilityRecord, const int32_t userId,
|
||||
std::vector<ExtensionRunningInfo> &info);
|
||||
|
||||
/**
|
||||
* set from ability manager service for sequenced task
|
||||
*/
|
||||
inline void SetTaskHandler(const std::shared_ptr<TaskHandlerWrap> &taskHandler)
|
||||
{
|
||||
taskHandler_ = taskHandler;
|
||||
}
|
||||
/**
|
||||
* SetEventHandler.
|
||||
*
|
||||
* @param handler,EventHandler
|
||||
*/
|
||||
inline void SetEventHandler(const std::shared_ptr<AppExecFwk::EventHandler> &handler)
|
||||
inline void SetEventHandler(const std::shared_ptr<EventHandlerWrap> &handler)
|
||||
{
|
||||
eventHandler_ = handler;
|
||||
}
|
||||
@@ -494,19 +503,20 @@ private:
|
||||
const std::string TASK_ON_CALLBACK_DIED = "OnCallbackDiedTask";
|
||||
const std::string TASK_ON_ABILITY_DIED = "OnAbilityDiedTask";
|
||||
|
||||
std::mutex Lock_;
|
||||
ffrt::mutex Lock_;
|
||||
ConnectMapType connectMap_;
|
||||
ServiceMapType serviceMap_;
|
||||
ServiceMapType terminatingExtensionMap_;
|
||||
RecipientMapType recipientMap_;
|
||||
RecipientMapType uiExtRecipientMap_;
|
||||
std::shared_ptr<AppExecFwk::EventHandler> eventHandler_;
|
||||
std::shared_ptr<TaskHandlerWrap> taskHandler_;
|
||||
std::shared_ptr<EventHandlerWrap> eventHandler_;
|
||||
int userId_;
|
||||
std::vector<AbilityRequest> restartResidentTaskList_;
|
||||
std::unordered_map<std::string, std::shared_ptr<std::list<AbilityRequest>>> startServiceReqList_;
|
||||
std::mutex startServiceReqListLock_;
|
||||
ffrt::mutex startServiceReqListLock_;
|
||||
UIExtensionMapType uiExtensionMap_;
|
||||
|
||||
|
||||
DISALLOW_COPY_AND_MOVE(AbilityConnectManager);
|
||||
};
|
||||
} // namespace AAFwk
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "event_handler.h"
|
||||
#include "event_runner.h"
|
||||
#include "event_handler_wrap.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
@@ -28,10 +27,10 @@ class AbilityManagerService;
|
||||
* @class AbilityEventHandler
|
||||
* AbilityEventHandler handling the ability event.
|
||||
*/
|
||||
class AbilityEventHandler : public AppExecFwk::EventHandler {
|
||||
class AbilityEventHandler : public EventHandlerWrap {
|
||||
public:
|
||||
AbilityEventHandler(
|
||||
const std::shared_ptr<AppExecFwk::EventRunner> &runner, const std::weak_ptr<AbilityManagerService> &server);
|
||||
const std::shared_ptr<TaskHandlerWrap> &taskHandler, const std::weak_ptr<AbilityManagerService> &server);
|
||||
virtual ~AbilityEventHandler() = default;
|
||||
|
||||
/**
|
||||
@@ -39,7 +38,7 @@ public:
|
||||
*
|
||||
* @param event, inner event loop.
|
||||
*/
|
||||
void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override;
|
||||
void ProcessEvent(const EventWrap &event) override;
|
||||
|
||||
private:
|
||||
void ProcessLoadTimeOut(int64_t abilityRecordId);
|
||||
|
||||
@@ -143,19 +143,15 @@ public:
|
||||
AppExecFwk::ExtensionAbilityType extensionType = AppExecFwk::ExtensionAbilityType::UNSPECIFIED) override;
|
||||
|
||||
/**
|
||||
* Start ui extension ability with want, send want to ability manager service.
|
||||
* Start ui extension ability with extension session info, send extension session info to ability manager service.
|
||||
*
|
||||
* @param want, the want of the ability to start.
|
||||
* @param extensionSessionInfo the extension session info of the ability to start.
|
||||
* @param userId, Designation User ID.
|
||||
* @param extensionType If an ExtensionAbilityType is set, only extension of that type can be started.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int StartUIExtensionAbility(
|
||||
const Want &want,
|
||||
const sptr<SessionInfo> &extensionSessionInfo,
|
||||
int32_t userId = DEFAULT_INVAL_VALUE,
|
||||
AppExecFwk::ExtensionAbilityType extensionType = AppExecFwk::ExtensionAbilityType::UNSPECIFIED) override;
|
||||
int32_t userId = DEFAULT_INVAL_VALUE) override;
|
||||
|
||||
/**
|
||||
* Start ui ability with want, send want to ability manager service.
|
||||
@@ -793,6 +789,8 @@ public:
|
||||
*/
|
||||
virtual int32_t RequestDialogService(const Want &want, const sptr<IRemoteObject> &callerToken) override;
|
||||
|
||||
int32_t ReportDrawnCompleted(const sptr<IRemoteObject> &callerToken) override;
|
||||
|
||||
virtual int32_t AcquireShareData(
|
||||
const int32_t &missionId, const sptr<IAcquireShareDataCallback> &shareData) override;
|
||||
virtual int32_t ShareDataDone(const sptr<IRemoteObject> &token,
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "ability_bundle_event_callback.h"
|
||||
#include "ability_connect_manager.h"
|
||||
#include "task_handler_wrap.h"
|
||||
#include "ability_event_handler.h"
|
||||
#include "ability_interceptor_executer.h"
|
||||
#include "ability_manager_stub.h"
|
||||
@@ -195,19 +196,15 @@ public:
|
||||
AppExecFwk::ExtensionAbilityType extensionType = AppExecFwk::ExtensionAbilityType::UNSPECIFIED) override;
|
||||
|
||||
/**
|
||||
* Start ui extension ability with want, send want to ability manager service.
|
||||
* Start ui extension ability with extension session info, send extension session info to ability manager service.
|
||||
*
|
||||
* @param want, the want of the ability to start.
|
||||
* @param extensionSessionInfo the extension session info of the ability to start.
|
||||
* @param userId, Designation User ID.
|
||||
* @param extensionType If an ExtensionAbilityType is set, only extension of that type can be started.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int StartUIExtensionAbility(
|
||||
const Want &want,
|
||||
const sptr<SessionInfo> &extensionSessionInfo,
|
||||
int32_t userId = DEFAULT_INVAL_VALUE,
|
||||
AppExecFwk::ExtensionAbilityType extensionType = AppExecFwk::ExtensionAbilityType::UNSPECIFIED) override;
|
||||
int32_t userId = DEFAULT_INVAL_VALUE) override;
|
||||
|
||||
/**
|
||||
* Start ui ability with want, send want to ability manager service.
|
||||
@@ -534,6 +531,11 @@ public:
|
||||
WindowCommand winCmd,
|
||||
AbilityCommand abilityCmd) override;
|
||||
|
||||
std::shared_ptr<TaskHandlerWrap> GetTaskHandler() const
|
||||
{
|
||||
return taskHandler_;
|
||||
}
|
||||
|
||||
/**
|
||||
* GetEventHandler, get the ability manager service's handler.
|
||||
*
|
||||
@@ -815,7 +817,7 @@ public:
|
||||
|
||||
virtual int PrepareTerminateAbility(const sptr<IRemoteObject> &token,
|
||||
sptr<IPrepareTerminateCallback> &callback) override;
|
||||
|
||||
|
||||
void HandleFocused(const sptr<OHOS::Rosen::FocusChangeInfo> &focusChangeInfo);
|
||||
|
||||
void HandleUnfocused(const sptr<OHOS::Rosen::FocusChangeInfo> &focusChangeInfo);
|
||||
@@ -1033,6 +1035,8 @@ public:
|
||||
|
||||
virtual int32_t RequestDialogService(const Want &want, const sptr<IRemoteObject> &callerToken) override;
|
||||
|
||||
int32_t ReportDrawnCompleted(const sptr<IRemoteObject> &callerToken) override;
|
||||
|
||||
virtual int32_t AcquireShareData(
|
||||
const int32_t &missionId, const sptr<IAcquireShareDataCallback> &shareData) override;
|
||||
virtual int32_t ShareDataDone(const sptr<IRemoteObject>& token,
|
||||
@@ -1330,7 +1334,7 @@ private:
|
||||
std::map<uint32_t, DumpSysFuncType> dumpsysFuncMap_;
|
||||
|
||||
int CheckStaticCfgPermission(AppExecFwk::AbilityInfo &abilityInfo, bool isStartAsCaller,
|
||||
uint32_t callerTokenId);
|
||||
uint32_t callerTokenId, bool isData = false, bool isSaCall = false);
|
||||
|
||||
bool GetValidDataAbilityUri(const std::string &abilityInfoUri, std::string &adjustUri);
|
||||
|
||||
@@ -1368,7 +1372,7 @@ private:
|
||||
* @param abilityRequest, abilityRequest.
|
||||
* @return Returns whether the caller is allowed to start DataAbility.
|
||||
*/
|
||||
int CheckCallDataAbilityPermission(AbilityRequest &abilityRequest);
|
||||
int CheckCallDataAbilityPermission(AbilityRequest &abilityRequest, bool isShell, bool IsSACall = false);
|
||||
|
||||
/**
|
||||
* Check if Caller is allowed to start ServiceExtension(Stage) or DataShareExtension(Stage).
|
||||
@@ -1419,7 +1423,7 @@ private:
|
||||
* FALSE: The Caller-Application is in focus or in foreground state.
|
||||
* @return Returns ERR_OK on check success, others on check failure.
|
||||
*/
|
||||
int IsCallFromBackground(const AbilityRequest &abilityRequest, bool &isBackgroundCall);
|
||||
int IsCallFromBackground(const AbilityRequest &abilityRequest, bool &isBackgroundCall, bool isData = false);
|
||||
|
||||
bool IsTargetPermission(const Want &want) const;
|
||||
|
||||
@@ -1432,7 +1436,7 @@ private:
|
||||
void UpdateFocusState(std::vector<AbilityRunningInfo> &info);
|
||||
|
||||
AAFwk::PermissionVerification::VerificationInfo CreateVerificationInfo(
|
||||
const AbilityRequest &abilityRequest);
|
||||
const AbilityRequest &abilityRequest, bool isData = false, bool isShell = false, bool isSA = false);
|
||||
|
||||
int AddStartControlParam(Want &want, const sptr<IRemoteObject> &callerToken);
|
||||
|
||||
@@ -1475,8 +1479,8 @@ private:
|
||||
constexpr static int REPOLL_TIME_MICRO_SECONDS = 1000000;
|
||||
constexpr static int WAITING_BOOT_ANIMATION_TIMER = 5;
|
||||
|
||||
std::shared_ptr<AppExecFwk::EventRunner> eventLoop_;
|
||||
std::shared_ptr<AbilityEventHandler> handler_;
|
||||
std::shared_ptr<TaskHandlerWrap> taskHandler_;
|
||||
std::shared_ptr<AbilityEventHandler> eventHandler_;
|
||||
ServiceRunningState state_;
|
||||
std::unordered_map<int, std::shared_ptr<AbilityConnectManager>> connectManagers_;
|
||||
std::shared_ptr<AbilityConnectManager> connectManager_;
|
||||
@@ -1501,10 +1505,10 @@ private:
|
||||
std::shared_ptr<UserController> userController_;
|
||||
sptr<AppExecFwk::IAbilityController> abilityController_ = nullptr;
|
||||
bool controllerIsAStabilityTest_ = false;
|
||||
std::mutex globalLock_;
|
||||
std::shared_mutex managersMutex_;
|
||||
std::shared_mutex bgtaskObserverMutex_;
|
||||
std::mutex abilityTokenLock_;
|
||||
ffrt::mutex globalLock_;
|
||||
ffrt::mutex managersMutex_;
|
||||
ffrt::mutex bgtaskObserverMutex_;
|
||||
ffrt::mutex abilityTokenLock_;
|
||||
sptr<AppExecFwk::IComponentInterception> componentInterception_ = nullptr;
|
||||
|
||||
std::multimap<std::string, std::string> timeoutMap_;
|
||||
|
||||
@@ -217,6 +217,7 @@ private:
|
||||
int VerifyPermissionInner(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
int HandleRequestDialogService(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleReportDrawnCompleted(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
int AcquireShareDataInner(MessageParcel &data, MessageParcel &reply);
|
||||
int ShareDataDoneInner(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "cpp/mutex.h"
|
||||
#include "cpp/condition_variable.h"
|
||||
|
||||
#include "ability_connect_callback_interface.h"
|
||||
#include "ability_info.h"
|
||||
@@ -467,8 +469,10 @@ public:
|
||||
std::shared_ptr<StartOptions> &startOptions, const std::shared_ptr<AbilityRecord> &callerAbility,
|
||||
uint32_t sceneFlag = 0);
|
||||
|
||||
void ProcessForegroundAbility(const std::shared_ptr<AbilityRecord> &callerAbility, uint32_t sceneFlag = 0);
|
||||
void ProcessForegroundAbility(const std::shared_ptr<AbilityRecord> &callerAbility, bool needExit = true,
|
||||
uint32_t sceneFlag = 0);
|
||||
void NotifyAnimationFromTerminatingAbility() const;
|
||||
void NotifyAnimationFromMinimizeAbility(bool& animaEnabled);
|
||||
|
||||
void SetCompleteFirstFrameDrawing(const bool flag);
|
||||
bool IsCompleteFirstFrameDrawing() const;
|
||||
@@ -926,7 +930,8 @@ private:
|
||||
const AbilityRequest &abilityRequest) const;
|
||||
void NotifyAnimationFromRecentTask(const std::shared_ptr<StartOptions> &startOptions,
|
||||
const std::shared_ptr<Want> &want) const;
|
||||
void NotifyAnimationFromTerminatingAbility(const std::shared_ptr<AbilityRecord> &callerAbility, bool flag);
|
||||
void NotifyAnimationFromTerminatingAbility(const std::shared_ptr<AbilityRecord> &callerAbility, bool needExit,
|
||||
bool flag);
|
||||
|
||||
void StartingWindowTask(bool isRecent, bool isCold, const AbilityRequest &abilityRequest,
|
||||
std::shared_ptr<StartOptions> &startOptions);
|
||||
@@ -1011,10 +1016,10 @@ private:
|
||||
int32_t restartCount_ = -1;
|
||||
int32_t restartMax_ = -1;
|
||||
std::string specifiedFlag_;
|
||||
std::mutex lock_;
|
||||
mutable std::mutex dumpInfoLock_;
|
||||
mutable std::mutex dumpLock_;
|
||||
mutable std::condition_variable dumpCondition_;
|
||||
ffrt::mutex lock_;
|
||||
mutable ffrt::mutex dumpInfoLock_;
|
||||
mutable ffrt::mutex dumpLock_;
|
||||
mutable ffrt::condition_variable dumpCondition_;
|
||||
mutable bool isDumpTimeout_ = false;
|
||||
std::vector<std::string> dumpInfos_;
|
||||
std::atomic<AbilityState> pendingState_ = AbilityState::INITIAL; // pending life state
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
#include "cpp/mutex.h"
|
||||
|
||||
#include "iconnection_observer.h"
|
||||
|
||||
@@ -102,7 +103,7 @@ private:
|
||||
};
|
||||
|
||||
private:
|
||||
std::mutex observerLock_;
|
||||
ffrt::mutex observerLock_;
|
||||
std::vector<sptr<AbilityRuntime::IConnectionObserver>> observers_;
|
||||
sptr<IRemoteObject::DeathRecipient> observerDeathRecipient_;
|
||||
};
|
||||
|
||||
@@ -18,8 +18,9 @@
|
||||
|
||||
#include <mutex>
|
||||
#include <unordered_map>
|
||||
#include "cpp/mutex.h"
|
||||
|
||||
#include "ability_event_handler.h"
|
||||
#include "task_handler_wrap.h"
|
||||
#include "application_state_observer_stub.h"
|
||||
#include "connection_state_item.h"
|
||||
#include "connection_observer_controller.h"
|
||||
@@ -47,7 +48,7 @@ public:
|
||||
* init manager.
|
||||
*
|
||||
*/
|
||||
void Init(const std::shared_ptr<AppExecFwk::EventHandler> &handler = nullptr);
|
||||
void Init(const std::shared_ptr<TaskHandlerWrap> &handler = nullptr);
|
||||
|
||||
/**
|
||||
* register connection state observer.
|
||||
@@ -200,14 +201,14 @@ private:
|
||||
private:
|
||||
std::shared_ptr<ConnectionObserverController> observerController_;
|
||||
|
||||
std::mutex stateLock_;
|
||||
ffrt::mutex stateLock_;
|
||||
std::unordered_map<int32_t, std::shared_ptr<ConnectionStateItem>> connectionStates_;
|
||||
|
||||
std::mutex dlpLock_;
|
||||
ffrt::mutex dlpLock_;
|
||||
std::unordered_map<int32_t, std::shared_ptr<DlpStateItem>> dlpItems_;
|
||||
|
||||
sptr<InnerAppStateObserver> appStateObserver_;
|
||||
std::shared_ptr<AppExecFwk::EventHandler> handler_;
|
||||
std::shared_ptr<TaskHandlerWrap> handler_;
|
||||
|
||||
int32_t retry_ = 0;
|
||||
};
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include "cpp/mutex.h"
|
||||
|
||||
#include "ability_record.h"
|
||||
#include "ability_running_info.h"
|
||||
@@ -65,7 +66,7 @@ private:
|
||||
std::shared_ptr<DataAbilityRecord> &record);
|
||||
|
||||
private:
|
||||
std::mutex mutex_;
|
||||
ffrt::mutex mutex_;
|
||||
DataAbilityRecordPtrMap dataAbilityRecordsLoaded_;
|
||||
DataAbilityRecordPtrMap dataAbilityRecordsLoading_;
|
||||
};
|
||||
|
||||
@@ -20,8 +20,9 @@
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
#include <chrono>
|
||||
#include "cpp/mutex.h"
|
||||
#include "cpp/condition_variable.h"
|
||||
|
||||
#include "ability_record.h"
|
||||
#include "data_ability_caller_recipient.h"
|
||||
@@ -35,7 +36,7 @@ public:
|
||||
|
||||
public:
|
||||
int StartLoading();
|
||||
int WaitForLoaded(std::mutex &mutex, const std::chrono::system_clock::duration &timeout);
|
||||
int WaitForLoaded(ffrt::mutex &mutex, const std::chrono::system_clock::duration &timeout);
|
||||
sptr<IAbilityScheduler> GetScheduler();
|
||||
int Attach(const sptr<IAbilityScheduler> &scheduler);
|
||||
int OnTransitionDone(int state);
|
||||
@@ -64,7 +65,7 @@ private:
|
||||
int32_t GetDiedCallerPid(const sptr<IRemoteObject> &remote);
|
||||
|
||||
private:
|
||||
std::condition_variable_any loadedCond_ {};
|
||||
ffrt::condition_variable loadedCond_ {};
|
||||
AbilityRequest request_ {};
|
||||
AbilityRecordPtr ability_ {};
|
||||
sptr<IAbilityScheduler> scheduler_ {};
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#define OHOS_ABILITY_RUNTIME_FREE_INSTALL_MANAGER_H
|
||||
|
||||
#include <future>
|
||||
#include "cpp/mutex.h"
|
||||
|
||||
#include <iremote_object.h>
|
||||
#include <iremote_stub.h>
|
||||
@@ -134,9 +135,9 @@ private:
|
||||
std::vector<FreeInstallInfo> freeInstallList_;
|
||||
std::vector<FreeInstallInfo> dmsFreeInstallCbs_;
|
||||
std::map<std::string, std::time_t> timeStampMap_;
|
||||
std::mutex distributedFreeInstallLock_;
|
||||
std::mutex freeInstallListLock_;
|
||||
std::mutex freeInstallObserverLock_;
|
||||
ffrt::mutex distributedFreeInstallLock_;
|
||||
ffrt::mutex freeInstallListLock_;
|
||||
ffrt::mutex freeInstallObserverLock_;
|
||||
/**
|
||||
* Start remote free install.
|
||||
*
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
#include "cpp/mutex.h"
|
||||
|
||||
#include "free_install_observer_interface.h"
|
||||
#include "singleton.h"
|
||||
@@ -44,7 +45,7 @@ private:
|
||||
void HandleOnInstallFinished(const std::string &bundleName, const std::string &abilityName,
|
||||
const std::string &startTime, const int &resultCode);
|
||||
|
||||
std::mutex observerLock_;
|
||||
ffrt::mutex observerLock_;
|
||||
sptr<IRemoteObject::DeathRecipient> deathRecipient_;
|
||||
std::vector<sptr<IFreeInstallObserver>> observerList_;
|
||||
};
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
#include <list>
|
||||
#include <mutex>
|
||||
#include <queue>
|
||||
#include "cpp/mutex.h"
|
||||
|
||||
#include "event_handler.h"
|
||||
#include "inner_mission_info.h"
|
||||
#include "mission_snapshot.h"
|
||||
|
||||
@@ -42,8 +42,6 @@ public:
|
||||
explicit MissionDataStorage(int userId);
|
||||
virtual ~MissionDataStorage();
|
||||
|
||||
void SetEventHandler(const std::shared_ptr<AppExecFwk::EventHandler> &handler);
|
||||
|
||||
/**
|
||||
* @brief GeT all mission info.
|
||||
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||
@@ -102,6 +100,7 @@ public:
|
||||
std::shared_ptr<Media::PixelMap> GetSnapshot(int missionId, bool isLowResolution = false) const;
|
||||
|
||||
std::unique_ptr<Media::PixelMap> GetPixelMap(int missionId, bool isLowResolution) const;
|
||||
std::unique_ptr<uint8_t[]> ReadFileToBuffer(const std::string &filePath, size_t &bufferSize) const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
@@ -137,8 +136,7 @@ private:
|
||||
#endif
|
||||
|
||||
int userId_ = 0;
|
||||
std::shared_ptr<AppExecFwk::EventHandler> handler_;
|
||||
std::mutex cachedPixelMapMutex_;
|
||||
ffrt::mutex cachedPixelMapMutex_;
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -16,10 +16,11 @@
|
||||
#ifndef OHOS_ABILITY_RUNTIME_MISSION_INFO_MGR_H
|
||||
#define OHOS_ABILITY_RUNTIME_MISSION_INFO_MGR_H
|
||||
|
||||
#include <condition_variable>
|
||||
#include <list>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include "cpp/mutex.h"
|
||||
#include "cpp/condition_variable.h"
|
||||
|
||||
#include "ability_state.h"
|
||||
#include "inner_mission_info.h"
|
||||
@@ -205,10 +206,10 @@ private:
|
||||
std::list<InnerMissionInfo> missionInfoList_;
|
||||
std::shared_ptr<TaskDataPersistenceMgr> taskDataPersistenceMgr_;
|
||||
sptr<ISnapshotHandler> snapshotHandler_;
|
||||
mutable std::mutex mutex_;
|
||||
mutable ffrt::mutex mutex_;
|
||||
std::unordered_map<int32_t, uint32_t> savingSnapshot_;
|
||||
std::mutex savingSnapshotLock_;
|
||||
std::condition_variable waitSavingCondition_;
|
||||
ffrt::mutex savingSnapshotLock_;
|
||||
ffrt::condition_variable waitSavingCondition_;
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <mutex>
|
||||
#include <queue>
|
||||
#include <memory>
|
||||
#include "cpp/mutex.h"
|
||||
|
||||
#include "ability_running_info.h"
|
||||
#include "foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp/include/device_manager.h"
|
||||
@@ -525,7 +526,7 @@ private:
|
||||
bool CheckPrepareTerminateEnable(const std::shared_ptr<Mission> &mission);
|
||||
|
||||
int userId_;
|
||||
mutable std::mutex managerLock_;
|
||||
mutable ffrt::mutex managerLock_;
|
||||
// launcher list is also in currentMissionLists_
|
||||
std::list<std::shared_ptr<MissionList>> currentMissionLists_;
|
||||
// only manager the ability of standard in the default list
|
||||
|
||||
@@ -18,8 +18,10 @@
|
||||
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include "cpp/mutex.h"
|
||||
|
||||
#include "event_handler.h"
|
||||
#include "task_handler_wrap.h"
|
||||
#include "mission_listener_interface.h"
|
||||
|
||||
namespace OHOS {
|
||||
@@ -128,7 +130,7 @@ private:
|
||||
template<typename F, typename... Args>
|
||||
void CallListeners(F func, Args&&... args)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(listenerLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(listenerLock_);
|
||||
for (auto listener : missionListeners_) {
|
||||
if (listener) {
|
||||
(listener->*func)(std::forward<Args>(args)...);
|
||||
@@ -148,8 +150,8 @@ private:
|
||||
};
|
||||
|
||||
private:
|
||||
std::mutex listenerLock_;
|
||||
std::shared_ptr<AppExecFwk::EventHandler> handler_;
|
||||
ffrt::mutex listenerLock_;
|
||||
std::shared_ptr<TaskHandlerWrap> handler_;
|
||||
std::vector<sptr<IMissionListener>> missionListeners_;
|
||||
sptr<IRemoteObject::DeathRecipient> listenerDeathRecipient_;
|
||||
};
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "cpp/mutex.h"
|
||||
|
||||
#include "ability_manager_errors.h"
|
||||
#include "ability_record.h"
|
||||
@@ -174,7 +175,7 @@ private:
|
||||
|
||||
private:
|
||||
std::map<std::shared_ptr<PendingWantKey>, sptr<PendingWantRecord>> wantRecords_;
|
||||
std::mutex mutex_;
|
||||
ffrt::mutex mutex_;
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <list>
|
||||
#include <mutex>
|
||||
#include "cpp/mutex.h"
|
||||
|
||||
#include "iremote_object.h"
|
||||
#include "pending_want_key.h"
|
||||
@@ -60,7 +61,7 @@ private:
|
||||
bool canceled_ = false;
|
||||
std::shared_ptr<PendingWantKey> key_ = {};
|
||||
std::list<sptr<IWantReceiver>> mCancelCallbacks_ = {};
|
||||
std::mutex lock_ = {};
|
||||
ffrt::mutex lock_ = {};
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#define OHOS_ABILITY_RUNTIME_UI_ABILITY_LIFECYCLE_MANAGER_H
|
||||
|
||||
#include <queue>
|
||||
#include "cpp/mutex.h"
|
||||
|
||||
#include "ability_record.h"
|
||||
#include "session/host/include/zidl/session_interface.h"
|
||||
@@ -235,7 +236,7 @@ private:
|
||||
std::shared_ptr<AbilityRecord> GetReusedSpecifiedAbility(const AAFwk::Want &want, const std::string &flag);
|
||||
void EraseSpecifiedAbilityRecord(const std::shared_ptr<AbilityRecord> &abilityRecord);
|
||||
|
||||
mutable std::mutex sessionLock_;
|
||||
mutable ffrt::mutex sessionLock_;
|
||||
std::map<uint64_t, std::shared_ptr<AbilityRecord>> sessionAbilityMap_;
|
||||
std::map<int64_t, std::shared_ptr<AbilityRecord>> tmpAbilityMap_;
|
||||
std::list<std::shared_ptr<AbilityRecord>> terminateAbilityList_;
|
||||
|
||||
@@ -18,9 +18,10 @@
|
||||
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include "cpp/mutex.h"
|
||||
|
||||
#include "singleton.h"
|
||||
#include "ability_event_handler.h"
|
||||
#include "task_handler_wrap.h"
|
||||
#include "mission_data_storage.h"
|
||||
|
||||
namespace OHOS {
|
||||
@@ -97,10 +98,9 @@ public:
|
||||
private:
|
||||
std::unordered_map<int, std::shared_ptr<MissionDataStorage>> missionDataStorageMgr_;
|
||||
std::shared_ptr<MissionDataStorage> currentMissionDataStorage_;
|
||||
std::shared_ptr<AppExecFwk::EventRunner> eventLoop_;
|
||||
std::shared_ptr<AppExecFwk::EventHandler> handler_;
|
||||
std::shared_ptr<TaskHandlerWrap> handler_;
|
||||
int32_t currentUserId_ = -1;
|
||||
std::mutex mutex_;
|
||||
ffrt::mutex mutex_;
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
#include "cpp/mutex.h"
|
||||
|
||||
#include "user_event_handler.h"
|
||||
|
||||
@@ -48,7 +49,9 @@ private:
|
||||
UserState lastState_ = STATE_BOOTING;
|
||||
};
|
||||
|
||||
struct UserEvent {
|
||||
class UserEvent : public EventDataBase {
|
||||
public:
|
||||
virtual ~UserEvent() = default;
|
||||
int32_t oldUserId;
|
||||
int32_t newUserId;
|
||||
std::shared_ptr<UserItem> userItem;
|
||||
@@ -82,7 +85,7 @@ public:
|
||||
|
||||
std::shared_ptr<UserItem> GetUserItem(int32_t userId);
|
||||
|
||||
void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event);
|
||||
void ProcessEvent(const EventWrap &event);
|
||||
|
||||
private:
|
||||
bool IsCurrentUser(int32_t userId);
|
||||
@@ -118,7 +121,7 @@ private:
|
||||
void HandleUserSwitchDone(int32_t userId);
|
||||
|
||||
private:
|
||||
std::mutex userLock_;
|
||||
ffrt::mutex userLock_;
|
||||
int32_t currentUserId_ = USER_ID_NO_HEAD;
|
||||
std::unordered_map<int32_t, std::shared_ptr<UserItem>> userItems_;
|
||||
std::shared_ptr<UserEventHandler> eventHandler_;
|
||||
|
||||
@@ -18,16 +18,15 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "event_handler.h"
|
||||
#include "event_runner.h"
|
||||
#include "event_handler_wrap.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
class UserController;
|
||||
class UserEventHandler : public AppExecFwk::EventHandler {
|
||||
class UserEventHandler : public EventHandlerWrap {
|
||||
public:
|
||||
UserEventHandler(
|
||||
const std::shared_ptr<AppExecFwk::EventRunner> &runner, const std::weak_ptr<UserController> &owner);
|
||||
const std::shared_ptr<TaskHandlerWrap> &taskHandler, const std::weak_ptr<UserController> &owner);
|
||||
virtual ~UserEventHandler() = default;
|
||||
|
||||
static constexpr uint32_t EVENT_SYSTEM_USER_START = 10;
|
||||
@@ -42,7 +41,7 @@ public:
|
||||
*
|
||||
* @param event, inner event loop.
|
||||
*/
|
||||
void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override;
|
||||
void ProcessEvent(const EventWrap &event) override;
|
||||
|
||||
private:
|
||||
std::weak_ptr<UserController> controller_;
|
||||
|
||||
@@ -18,15 +18,15 @@
|
||||
|
||||
|
||||
#include "window_manager.h"
|
||||
#include "task_handler_wrap.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
class AbilityManagerService;
|
||||
class AbilityEventHandler;
|
||||
class WindowFocusChangedListener : public OHOS::Rosen::IFocusChangedListener {
|
||||
public:
|
||||
WindowFocusChangedListener(const std::shared_ptr<AbilityManagerService>& owner,
|
||||
const std::shared_ptr<AbilityEventHandler>& handler) : owner_(owner), eventHandler_(handler) {}
|
||||
const std::shared_ptr<TaskHandlerWrap>& handler) : owner_(owner), taskHandler_(handler) {}
|
||||
virtual ~WindowFocusChangedListener() = default;
|
||||
|
||||
void OnFocused(const sptr<OHOS::Rosen::FocusChangeInfo> &focusChangeInfo) override;
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
|
||||
private:
|
||||
std::weak_ptr<AbilityManagerService> owner_;
|
||||
std::shared_ptr<AbilityEventHandler> eventHandler_;
|
||||
std::shared_ptr<TaskHandlerWrap> taskHandler_;
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -19,19 +19,14 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
AbilityBundleEventCallback::AbilityBundleEventCallback() : eventHandler_(nullptr) {}
|
||||
|
||||
AbilityBundleEventCallback::AbilityBundleEventCallback(std::shared_ptr<AbilityEventHandler> eventHandler)
|
||||
{
|
||||
eventHandler_ = eventHandler;
|
||||
}
|
||||
|
||||
AbilityBundleEventCallback::AbilityBundleEventCallback(std::shared_ptr<TaskHandlerWrap> taskHandler)
|
||||
: taskHandler_(taskHandler) {}
|
||||
|
||||
void AbilityBundleEventCallback::OnReceiveEvent(const EventFwk::CommonEventData eventData)
|
||||
{
|
||||
// env check
|
||||
if (eventHandler_ == nullptr) {
|
||||
HILOG_ERROR("OnReceiveEvent failed, eventHandler_ is nullptr");
|
||||
if (taskHandler_ == nullptr) {
|
||||
HILOG_ERROR("OnReceiveEvent failed, taskHandler is nullptr");
|
||||
return;
|
||||
}
|
||||
const Want& want = eventData.GetWant();
|
||||
@@ -67,7 +62,7 @@ void AbilityBundleEventCallback::HandleUpdatedModuleInfo(const std::string &bund
|
||||
}
|
||||
sharedThis->abilityEventHelper_.HandleModuleInfoUpdated(bundleName, uid);
|
||||
};
|
||||
eventHandler_->PostTask(task);
|
||||
taskHandler_->SubmitTask(task);
|
||||
}
|
||||
|
||||
void AbilityBundleEventCallback::HandleAppUpgradeCompleted(const std::string &bundleName, int32_t uid)
|
||||
@@ -87,7 +82,7 @@ void AbilityBundleEventCallback::HandleAppUpgradeCompleted(const std::string &bu
|
||||
}
|
||||
abilityMgr->AppUpgradeCompleted(bundleName, uid);
|
||||
};
|
||||
eventHandler_->PostTask(task);
|
||||
taskHandler_->SubmitTask(task);
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
@@ -183,6 +183,7 @@ void AbilityConnectManager::EnqueueStartServiceReq(const AbilityRequest &ability
|
||||
reqList->push_back(abilityRequest);
|
||||
startServiceReqList_.emplace(abilityUri, reqList);
|
||||
|
||||
CHECK_POINTER(taskHandler_);
|
||||
auto callback = [abilityUri, connectManager = shared_from_this()]() {
|
||||
std::lock_guard guard{connectManager->startServiceReqListLock_};
|
||||
auto exist = connectManager->startServiceReqList_.erase(abilityUri);
|
||||
@@ -193,7 +194,8 @@ void AbilityConnectManager::EnqueueStartServiceReq(const AbilityRequest &ability
|
||||
|
||||
int connectTimeout =
|
||||
AmsConfigurationParameter::GetInstance().GetAppStartTimeoutTime() * CONNECT_TIMEOUT_MULTIPLE;
|
||||
eventHandler_->PostTask(callback, std::string("start_service_timeout:") + abilityUri, connectTimeout);
|
||||
taskHandler_->SubmitTask(callback, std::string("start_service_timeout:") + abilityUri,
|
||||
connectTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,9 +357,9 @@ int AbilityConnectManager::ConnectAbilityLocked(const AbilityRequest &abilityReq
|
||||
// this service ability has connected already
|
||||
targetService->SetWant(abilityRequest.want);
|
||||
if (targetService->GetConnectRecordList().size() > 1) {
|
||||
if (eventHandler_ != nullptr && targetService->GetConnRemoteObject()) {
|
||||
if (taskHandler_ != nullptr && targetService->GetConnRemoteObject()) {
|
||||
auto task = [connectRecord]() { connectRecord->CompleteConnect(ERR_OK); };
|
||||
eventHandler_->PostTask(task);
|
||||
taskHandler_->SubmitTask(task);
|
||||
} else {
|
||||
HILOG_INFO("Target service is connecting, wait for callback");
|
||||
}
|
||||
@@ -480,11 +482,14 @@ int AbilityConnectManager::AttachAbilityThreadLocked(
|
||||
std::lock_guard guard(Lock_);
|
||||
auto abilityRecord = GetExtensionFromServiceMapInner(token);
|
||||
CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE);
|
||||
if (eventHandler_ != nullptr) {
|
||||
if (taskHandler_ != nullptr) {
|
||||
int recordId = abilityRecord->GetRecordId();
|
||||
std::string taskName = std::string("LoadTimeout_") + std::to_string(recordId);
|
||||
eventHandler_->RemoveTask(taskName);
|
||||
eventHandler_->RemoveEvent(AbilityManagerService::LOAD_TIMEOUT_MSG, abilityRecord->GetAbilityRecordId());
|
||||
taskHandler_->CancelTask(taskName);
|
||||
}
|
||||
if (eventHandler_) {
|
||||
eventHandler_->RemoveEvent(AbilityManagerService::LOAD_TIMEOUT_MSG,
|
||||
abilityRecord->GetAbilityRecordId());
|
||||
}
|
||||
std::string element = abilityRecord->GetWant().GetElement().GetURI();
|
||||
HILOG_DEBUG("Ability: %{public}s", element.c_str());
|
||||
@@ -566,8 +571,8 @@ int AbilityConnectManager::AbilityTransitionDone(const sptr<IRemoteObject> &toke
|
||||
}
|
||||
acm->ProcessPreload(abilityRecord);
|
||||
};
|
||||
if (eventHandler_ != nullptr) {
|
||||
eventHandler_->PostTask(preloadTask);
|
||||
if (taskHandler_ != nullptr) {
|
||||
taskHandler_->SubmitTask(preloadTask);
|
||||
}
|
||||
}
|
||||
return DispatchInactive(abilityRecord, state);
|
||||
@@ -719,11 +724,11 @@ int AbilityConnectManager::ScheduleCommandAbilityWindowDone(
|
||||
HILOG_DEBUG("Ability: %{public}s, persistentId: %{private}" PRIu64", winCmd: %{public}d, abilityCmd: %{public}d",
|
||||
element.c_str(), sessionInfo->persistentId, winCmd, abilityCmd);
|
||||
|
||||
if (eventHandler_) {
|
||||
if (taskHandler_) {
|
||||
int recordId = abilityRecord->GetRecordId();
|
||||
std::string taskName = std::string("CommandWindowTimeout_") + std::to_string(recordId) + std::string("_") +
|
||||
std::to_string(sessionInfo->persistentId) + std::string("_") + std::to_string(winCmd);
|
||||
eventHandler_->RemoveTask(taskName);
|
||||
taskHandler_->CancelTask(taskName);
|
||||
}
|
||||
|
||||
if (winCmd == WIN_CMD_DESTROY) {
|
||||
@@ -774,12 +779,11 @@ int AbilityConnectManager::ScheduleCommandAbilityWindowDone(
|
||||
void AbilityConnectManager::CompleteCommandAbility(std::shared_ptr<AbilityRecord> abilityRecord)
|
||||
{
|
||||
CHECK_POINTER(abilityRecord);
|
||||
|
||||
if (eventHandler_) {
|
||||
if (taskHandler_) {
|
||||
int recordId = abilityRecord->GetRecordId();
|
||||
std::string taskName = std::string("CommandTimeout_") + std::to_string(recordId) + std::string("_") +
|
||||
std::to_string(abilityRecord->GetStartId());
|
||||
eventHandler_->RemoveTask(taskName);
|
||||
taskHandler_->CancelTask(taskName);
|
||||
}
|
||||
|
||||
abilityRecord->SetAbilityState(AbilityState::ACTIVE);
|
||||
@@ -975,7 +979,7 @@ void AbilityConnectManager::LoadAbility(const std::shared_ptr<AbilityRecord> &ab
|
||||
void AbilityConnectManager::PostRestartResidentTask(const AbilityRequest &abilityRequest)
|
||||
{
|
||||
HILOG_INFO("PostRestartResidentTask start.");
|
||||
CHECK_POINTER(eventHandler_);
|
||||
CHECK_POINTER(taskHandler_);
|
||||
std::string taskName = std::string("RestartResident_") + std::string(abilityRequest.abilityInfo.name);
|
||||
auto task = [abilityRequest, connectManager = shared_from_this()]() {
|
||||
CHECK_POINTER(connectManager);
|
||||
@@ -987,7 +991,8 @@ void AbilityConnectManager::PostRestartResidentTask(const AbilityRequest &abilit
|
||||
restartIntervalTime = AmsConfigurationParameter::GetInstance().GetRestartIntervalTime();
|
||||
}
|
||||
HILOG_DEBUG("PostRestartResidentTask, time:%{public}d", restartIntervalTime);
|
||||
eventHandler_->PostTask(task, taskName, restartIntervalTime);
|
||||
taskHandler_->SubmitTask(task, taskName, restartIntervalTime);
|
||||
HILOG_INFO("PostRestartResidentTask end.");
|
||||
}
|
||||
|
||||
void AbilityConnectManager::HandleRestartResidentTask(const AbilityRequest &abilityRequest)
|
||||
@@ -1008,7 +1013,7 @@ void AbilityConnectManager::HandleRestartResidentTask(const AbilityRequest &abil
|
||||
void AbilityConnectManager::PostTimeOutTask(const std::shared_ptr<AbilityRecord> &abilityRecord, uint32_t messageId)
|
||||
{
|
||||
CHECK_POINTER(abilityRecord);
|
||||
CHECK_POINTER(eventHandler_);
|
||||
CHECK_POINTER(taskHandler_);
|
||||
if (messageId != AbilityConnectManager::LOAD_TIMEOUT_MSG &&
|
||||
messageId != AbilityConnectManager::CONNECT_TIMEOUT_MSG) {
|
||||
HILOG_ERROR("Timeout task messageId is error.");
|
||||
@@ -1048,8 +1053,7 @@ void AbilityConnectManager::PostTimeOutTask(const std::shared_ptr<AbilityRecord>
|
||||
HILOG_WARN("Connect or load ability timeout.");
|
||||
connectManager->HandleStartTimeoutTask(abilityRecord, resultCode);
|
||||
};
|
||||
|
||||
eventHandler_->PostTask(timeoutTask, taskName, delayTime);
|
||||
taskHandler_->SubmitTask(timeoutTask, taskName, delayTime);
|
||||
}
|
||||
|
||||
void AbilityConnectManager::HandleStartTimeoutTask(const std::shared_ptr<AbilityRecord> &abilityRecord, int resultCode)
|
||||
@@ -1195,13 +1199,13 @@ int AbilityConnectManager::DispatchInactive(const std::shared_ptr<AbilityRecord>
|
||||
int AbilityConnectManager::DispatchForeground(const std::shared_ptr<AbilityRecord> &abilityRecord)
|
||||
{
|
||||
CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE);
|
||||
CHECK_POINTER_AND_RETURN(eventHandler_, ERR_INVALID_VALUE);
|
||||
CHECK_POINTER_AND_RETURN(taskHandler_, ERR_INVALID_VALUE);
|
||||
// remove foreground timeout task.
|
||||
eventHandler_->RemoveTask("foreground_" + std::to_string(abilityRecord->GetAbilityRecordId()));
|
||||
taskHandler_->CancelTask("foreground_" + std::to_string(abilityRecord->GetAbilityRecordId()));
|
||||
|
||||
auto self(shared_from_this());
|
||||
auto task = [self, abilityRecord]() { self->CompleteForeground(abilityRecord); };
|
||||
eventHandler_->PostTask(task);
|
||||
taskHandler_->SubmitTask(task);
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
@@ -1209,13 +1213,13 @@ int AbilityConnectManager::DispatchForeground(const std::shared_ptr<AbilityRecor
|
||||
int AbilityConnectManager::DispatchBackground(const std::shared_ptr<AbilityRecord> &abilityRecord)
|
||||
{
|
||||
CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE);
|
||||
CHECK_POINTER_AND_RETURN(eventHandler_, ERR_INVALID_VALUE);
|
||||
CHECK_POINTER_AND_RETURN(taskHandler_, ERR_INVALID_VALUE);
|
||||
// remove background timeout task.
|
||||
eventHandler_->RemoveTask("background_" + std::to_string(abilityRecord->GetAbilityRecordId()));
|
||||
taskHandler_->CancelTask("background_" + std::to_string(abilityRecord->GetAbilityRecordId()));
|
||||
|
||||
auto self(shared_from_this());
|
||||
auto task = [self, abilityRecord]() { self->CompleteBackground(abilityRecord); };
|
||||
eventHandler_->PostTask(task);
|
||||
taskHandler_->SubmitTask(task);
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
@@ -1224,8 +1228,8 @@ int AbilityConnectManager::DispatchTerminate(const std::shared_ptr<AbilityRecord
|
||||
{
|
||||
CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE);
|
||||
// remove terminate timeout task
|
||||
if (eventHandler_ != nullptr) {
|
||||
eventHandler_->RemoveTask("terminate_" + std::to_string(abilityRecord->GetAbilityRecordId()));
|
||||
if (taskHandler_ != nullptr) {
|
||||
taskHandler_->CancelTask("terminate_" + std::to_string(abilityRecord->GetAbilityRecordId()));
|
||||
}
|
||||
// complete terminate
|
||||
TerminateDone(abilityRecord);
|
||||
@@ -1243,7 +1247,7 @@ void AbilityConnectManager::ConnectAbility(const std::shared_ptr<AbilityRecord>
|
||||
void AbilityConnectManager::CommandAbility(const std::shared_ptr<AbilityRecord> &abilityRecord)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
if (eventHandler_ != nullptr) {
|
||||
if (taskHandler_ != nullptr) {
|
||||
// first connect ability, There is at most one connect record.
|
||||
int recordId = abilityRecord->GetRecordId();
|
||||
abilityRecord->AddStartId();
|
||||
@@ -1255,7 +1259,7 @@ void AbilityConnectManager::CommandAbility(const std::shared_ptr<AbilityRecord>
|
||||
};
|
||||
int commandTimeout =
|
||||
AmsConfigurationParameter::GetInstance().GetAppStartTimeoutTime() * COMMAND_TIMEOUT_MULTIPLE;
|
||||
eventHandler_->PostTask(timeoutTask, taskName, commandTimeout);
|
||||
taskHandler_->SubmitTask(timeoutTask, taskName, commandTimeout);
|
||||
// scheduling command ability
|
||||
abilityRecord->CommandAbility();
|
||||
}
|
||||
@@ -1269,7 +1273,7 @@ void AbilityConnectManager::CommandAbilityWindow(const std::shared_ptr<AbilityRe
|
||||
CHECK_POINTER(sessionInfo);
|
||||
HILOG_DEBUG("ability: %{public}s, persistentId: %{private}" PRIu64", wincmd: %{public}d",
|
||||
abilityRecord->GetAbilityInfo().name.c_str(), sessionInfo->persistentId, winCmd);
|
||||
if (eventHandler_ != nullptr) {
|
||||
if (taskHandler_ != nullptr) {
|
||||
int recordId = abilityRecord->GetRecordId();
|
||||
std::string taskName = std::string("CommandWindowTimeout_") + std::to_string(recordId) + std::string("_") +
|
||||
std::to_string(sessionInfo->persistentId) + std::string("_") + std::to_string(winCmd);
|
||||
@@ -1279,7 +1283,7 @@ void AbilityConnectManager::CommandAbilityWindow(const std::shared_ptr<AbilityRe
|
||||
};
|
||||
int commandWindowTimeout =
|
||||
AmsConfigurationParameter::GetInstance().GetAppStartTimeoutTime() * COMMAND_WINDOW_TIMEOUT_MULTIPLE;
|
||||
eventHandler_->PostTask(timeoutTask, taskName, commandWindowTimeout);
|
||||
taskHandler_->SubmitTask(timeoutTask, taskName, commandWindowTimeout);
|
||||
// scheduling command ability
|
||||
abilityRecord->CommandAbilityWindow(sessionInfo, winCmd);
|
||||
}
|
||||
@@ -1384,9 +1388,9 @@ void AbilityConnectManager::OnCallBackDied(const wptr<IRemoteObject> &remote)
|
||||
{
|
||||
auto object = remote.promote();
|
||||
CHECK_POINTER(object);
|
||||
if (eventHandler_) {
|
||||
if (taskHandler_) {
|
||||
auto task = [object, connectManager = shared_from_this()]() { connectManager->HandleCallBackDiedTask(object); };
|
||||
eventHandler_->PostTask(task, TASK_ON_CALLBACK_DIED);
|
||||
taskHandler_->SubmitTask(task, TASK_ON_CALLBACK_DIED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1418,11 +1422,11 @@ void AbilityConnectManager::OnAbilityDied(const std::shared_ptr<AbilityRecord> &
|
||||
HILOG_DEBUG("Ability type is not service.");
|
||||
return;
|
||||
}
|
||||
if (eventHandler_) {
|
||||
if (taskHandler_) {
|
||||
auto task = [abilityRecord, connectManager = shared_from_this(), currentUserId]() {
|
||||
connectManager->HandleAbilityDiedTask(abilityRecord, currentUserId);
|
||||
};
|
||||
eventHandler_->PostTask(task, TASK_ON_ABILITY_DIED);
|
||||
taskHandler_->SubmitTask(task, TASK_ON_ABILITY_DIED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1949,11 +1953,11 @@ void AbilityConnectManager::OnUIExtWindowDied(const wptr<IRemoteObject> &remote)
|
||||
{
|
||||
auto object = remote.promote();
|
||||
CHECK_POINTER(object);
|
||||
if (eventHandler_) {
|
||||
if (taskHandler_) {
|
||||
auto task = [object, connectManager = shared_from_this()]() {
|
||||
connectManager->HandleUIExtWindowDiedTask(object);
|
||||
};
|
||||
eventHandler_->PostTask(task);
|
||||
taskHandler_->SubmitTask(task);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,16 +23,15 @@
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
AbilityEventHandler::AbilityEventHandler(
|
||||
const std::shared_ptr<AppExecFwk::EventRunner> &runner, const std::weak_ptr<AbilityManagerService> &server)
|
||||
: AppExecFwk::EventHandler(runner), server_(server)
|
||||
const std::shared_ptr<TaskHandlerWrap> &taskHandler, const std::weak_ptr<AbilityManagerService> &server)
|
||||
: EventHandlerWrap(taskHandler), server_(server)
|
||||
{
|
||||
HILOG_INFO("Constructors.");
|
||||
}
|
||||
|
||||
void AbilityEventHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
void AbilityEventHandler::ProcessEvent(const EventWrap &event)
|
||||
{
|
||||
CHECK_POINTER(event);
|
||||
HILOG_DEBUG("Event id obtained: %{public}u.", event->GetInnerEventId());
|
||||
HILOG_DEBUG("Event id obtained: %{public}u.", event.GetEventId());
|
||||
// check libc.hook_mode
|
||||
const int bufferLen = 128;
|
||||
char paramOutBuf[bufferLen] = {0};
|
||||
@@ -42,27 +41,27 @@ void AbilityEventHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &ev
|
||||
HILOG_DEBUG("Hook_mode: no process time out");
|
||||
return;
|
||||
}
|
||||
switch (event->GetInnerEventId()) {
|
||||
switch (event.GetEventId()) {
|
||||
case AbilityManagerService::LOAD_TIMEOUT_MSG: {
|
||||
ProcessLoadTimeOut(event->GetParam());
|
||||
ProcessLoadTimeOut(event.GetParam());
|
||||
break;
|
||||
}
|
||||
case AbilityManagerService::ACTIVE_TIMEOUT_MSG: {
|
||||
ProcessActiveTimeOut(event->GetParam());
|
||||
ProcessActiveTimeOut(event.GetParam());
|
||||
break;
|
||||
}
|
||||
case AbilityManagerService::INACTIVE_TIMEOUT_MSG: {
|
||||
HILOG_INFO("Inactive timeout.");
|
||||
// inactivate pre ability immediately in case blocking next ability start
|
||||
ProcessInactiveTimeOut(event->GetParam());
|
||||
ProcessInactiveTimeOut(event.GetParam());
|
||||
break;
|
||||
}
|
||||
case AbilityManagerService::FOREGROUND_TIMEOUT_MSG: {
|
||||
ProcessForegroundTimeOut(event->GetParam());
|
||||
ProcessForegroundTimeOut(event.GetParam());
|
||||
break;
|
||||
}
|
||||
case AbilityManagerService::SHAREDATA_TIMEOUT_MSG: {
|
||||
ProcessShareDataTimeOut(event->GetParam());
|
||||
ProcessShareDataTimeOut(event.GetParam());
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
||||
@@ -197,14 +197,14 @@ ErrCode AbilityManagerClient::StartExtensionAbility(const Want &want, const sptr
|
||||
return abms->StartExtensionAbility(want, callerToken, userId, extensionType);
|
||||
}
|
||||
|
||||
ErrCode AbilityManagerClient::StartUIExtensionAbility(const Want &want, const sptr<SessionInfo> &extensionSessionInfo,
|
||||
int32_t userId, AppExecFwk::ExtensionAbilityType extensionType)
|
||||
ErrCode AbilityManagerClient::StartUIExtensionAbility(const sptr<SessionInfo> &extensionSessionInfo, int32_t userId)
|
||||
{
|
||||
auto abms = GetAbilityManager();
|
||||
CHECK_POINTER_RETURN_NOT_CONNECTED(abms);
|
||||
HILOG_INFO("name:%{public}s %{public}s, userId:%{public}d.",
|
||||
want.GetElement().GetAbilityName().c_str(), want.GetElement().GetBundleName().c_str(), userId);
|
||||
return abms->StartUIExtensionAbility(want, extensionSessionInfo, userId, extensionType);
|
||||
extensionSessionInfo->want.GetElement().GetAbilityName().c_str(),
|
||||
extensionSessionInfo->want.GetElement().GetBundleName().c_str(), userId);
|
||||
return abms->StartUIExtensionAbility(extensionSessionInfo, userId);
|
||||
}
|
||||
|
||||
ErrCode AbilityManagerClient::StartUIAbilityBySCB(sptr<SessionInfo> sessionInfo)
|
||||
@@ -769,6 +769,14 @@ ErrCode AbilityManagerClient::RequestDialogService(
|
||||
return abms->RequestDialogService(want, callerToken);
|
||||
}
|
||||
|
||||
ErrCode AbilityManagerClient::ReportDrawnCompleted(const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
HILOG_DEBUG("called.");
|
||||
auto abilityMgr = GetAbilityManager();
|
||||
CHECK_POINTER_RETURN_NOT_CONNECTED(abilityMgr);
|
||||
return abilityMgr->ReportDrawnCompleted(callerToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start synchronizing remote device mission
|
||||
* @param devId, deviceId.
|
||||
|
||||
@@ -355,8 +355,7 @@ int AbilityManagerProxy::StartExtensionAbility(const Want &want, const sptr<IRem
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int AbilityManagerProxy::StartUIExtensionAbility(const Want &want, const sptr<SessionInfo> &extensionSessionInfo,
|
||||
int32_t userId, AppExecFwk::ExtensionAbilityType extensionType)
|
||||
int AbilityManagerProxy::StartUIExtensionAbility(const sptr<SessionInfo> &extensionSessionInfo, int32_t userId)
|
||||
{
|
||||
int error;
|
||||
MessageParcel data;
|
||||
@@ -365,10 +364,6 @@ int AbilityManagerProxy::StartUIExtensionAbility(const Want &want, const sptr<Se
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteParcelable(&want)) {
|
||||
HILOG_ERROR("want write failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
|
||||
CHECK_POINTER_AND_RETURN_LOG(extensionSessionInfo, ERR_INVALID_VALUE,
|
||||
"connect ability fail, extensionSessionInfo is nullptr");
|
||||
@@ -388,10 +383,6 @@ int AbilityManagerProxy::StartUIExtensionAbility(const Want &want, const sptr<Se
|
||||
HILOG_ERROR("StartExtensionAbility, userId write failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteInt32(static_cast<int32_t>(extensionType))) {
|
||||
HILOG_ERROR("StartExtensionAbility, extensionType write failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
|
||||
error = SendRequest(AbilityManagerInterfaceCode::START_UI_EXTENSION_ABILITY, data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
@@ -3532,6 +3523,39 @@ int32_t AbilityManagerProxy::RequestDialogService(const Want &want, const sptr<I
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t AbilityManagerProxy::ReportDrawnCompleted(const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
HILOG_DEBUG("called.");
|
||||
if (callerToken == nullptr) {
|
||||
HILOG_ERROR("callerToken is nullptr");
|
||||
return INNER_ERR;
|
||||
}
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return INNER_ERR;
|
||||
}
|
||||
|
||||
if (!data.WriteRemoteObject(callerToken)) {
|
||||
HILOG_ERROR("callerToken write failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
HILOG_ERROR("remote is nullptr.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
auto error = remote->SendRequest(IAbilityManager::REPORT_DRAWN_COMPLETED, data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("Send request error: %{public}d", error);
|
||||
return error;
|
||||
}
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t AbilityManagerProxy::AcquireShareData(
|
||||
const int32_t &missionId, const sptr<IAcquireShareDataCallback> &shareData)
|
||||
{
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <functional>
|
||||
#include <getopt.h>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
@@ -62,7 +63,6 @@
|
||||
#include "system_ability_definition.h"
|
||||
#include "system_ability_token_callback.h"
|
||||
#include "uri_permission_manager_client.h"
|
||||
#include "xcollie/watchdog.h"
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
|
||||
@@ -112,6 +112,8 @@ const std::string BUNDLE_NAME_SCENEBOARD = "com.ohos.sceneboard";
|
||||
// Support prepare terminate
|
||||
constexpr int32_t PREPARE_TERMINATE_ENABLE_SIZE = 6;
|
||||
const char* PREPARE_TERMINATE_ENABLE_PARAMETER = "persist.sys.prepare_terminate";
|
||||
// UIExtension type
|
||||
const std::string UIEXTENSION_TYPE_KEY = "ability.want.params.uiExtensionType";
|
||||
|
||||
const std::unordered_set<std::string> WHITE_LIST_ASS_WAKEUP_SET = { BUNDLE_NAME_SETTINGSDATA };
|
||||
|
||||
@@ -218,8 +220,6 @@ sptr<AbilityManagerService> AbilityManagerService::instance_;
|
||||
|
||||
AbilityManagerService::AbilityManagerService()
|
||||
: SystemAbility(ABILITY_MGR_SERVICE_ID, true),
|
||||
eventLoop_(nullptr),
|
||||
handler_(nullptr),
|
||||
state_(ServiceRunningState::STATE_NOT_START),
|
||||
iBundleManager_(nullptr)
|
||||
{
|
||||
@@ -242,7 +242,6 @@ void AbilityManagerService::OnStart()
|
||||
return;
|
||||
}
|
||||
state_ = ServiceRunningState::STATE_RUNNING;
|
||||
eventLoop_->Run();
|
||||
/* Publish service maybe failed, so we need call this function at the last,
|
||||
* so it can't affect the TDD test program */
|
||||
instance_ = DelayedSingleton<AbilityManagerService>::GetInstance().get();
|
||||
@@ -266,12 +265,8 @@ void AbilityManagerService::OnStart()
|
||||
|
||||
bool AbilityManagerService::Init()
|
||||
{
|
||||
eventLoop_ = AppExecFwk::EventRunner::Create(AbilityConfig::NAME_ABILITY_MGR_SERVICE);
|
||||
CHECK_POINTER_RETURN_BOOL(eventLoop_);
|
||||
|
||||
handler_ = std::make_shared<AbilityEventHandler>(eventLoop_, weak_from_this());
|
||||
CHECK_POINTER_RETURN_BOOL(handler_);
|
||||
|
||||
taskHandler_ = TaskHandlerWrap::CreateQueueHandler(AbilityConfig::NAME_ABILITY_MGR_SERVICE);
|
||||
eventHandler_ = std::make_shared<AbilityEventHandler>(taskHandler_, weak_from_this());
|
||||
freeInstallManager_ = std::make_shared<FreeInstallManager>(weak_from_this());
|
||||
CHECK_POINTER_RETURN_BOOL(freeInstallManager_);
|
||||
|
||||
@@ -294,18 +289,6 @@ bool AbilityManagerService::Init()
|
||||
SwitchManagers(U0_USER_ID, false);
|
||||
int amsTimeOut = AmsConfigurationParameter::GetInstance().GetAMSTimeOutTime();
|
||||
HILOG_INFO("amsTimeOut is %{public}d", amsTimeOut);
|
||||
std::string threadName = std::string(AbilityConfig::NAME_ABILITY_MGR_SERVICE) + "(" +
|
||||
std::to_string(eventLoop_->GetThreadId()) + ")";
|
||||
#ifdef SUPPORT_ASAN
|
||||
constexpr int32_t timeout = 5 * 60 * 1000; // 5 min
|
||||
if (HiviewDFX::Watchdog::GetInstance().AddThread(threadName, handler_, timeout) != 0) {
|
||||
HILOG_ERROR("HiviewDFX::Watchdog::GetInstance AddThread Fail");
|
||||
}
|
||||
#else
|
||||
if (HiviewDFX::Watchdog::GetInstance().AddThread(threadName, handler_) != 0) {
|
||||
HILOG_ERROR("HiviewDFX::Watchdog::GetInstance AddThread Fail");
|
||||
}
|
||||
#endif
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
DelayedSingleton<SystemDialogScheduler>::GetInstance()->SetDeviceType(OHOS::system::GetDeviceType());
|
||||
implicitStartProcessor_ = std::make_shared<ImplicitStartProcessor>();
|
||||
@@ -313,7 +296,7 @@ bool AbilityManagerService::Init()
|
||||
InitPrepareTerminateConfig();
|
||||
#endif
|
||||
|
||||
DelayedSingleton<ConnectionStateManager>::GetInstance()->Init(handler_);
|
||||
DelayedSingleton<ConnectionStateManager>::GetInstance()->Init(taskHandler_);
|
||||
|
||||
interceptorExecuter_ = std::make_shared<AbilityInterceptorExecuter>();
|
||||
interceptorExecuter_->AddInterceptor(std::make_shared<CrowdTestInterceptor>());
|
||||
@@ -330,10 +313,10 @@ bool AbilityManagerService::Init()
|
||||
}
|
||||
|
||||
auto startResidentAppsTask = [aams = shared_from_this()]() { aams->StartResidentApps(); };
|
||||
handler_->PostTask(startResidentAppsTask, "StartResidentApps");
|
||||
taskHandler_->SubmitTask(startResidentAppsTask, "StartResidentApps");
|
||||
|
||||
auto initStartupFlagTask = [aams = shared_from_this()]() { aams->InitStartupFlag(); };
|
||||
handler_->PostTask(initStartupFlagTask, "InitStartupFlag");
|
||||
taskHandler_->SubmitTask(initStartupFlagTask, "InitStartupFlag");
|
||||
HILOG_INFO("Init success.");
|
||||
return true;
|
||||
}
|
||||
@@ -350,7 +333,7 @@ void AbilityManagerService::OnStop()
|
||||
{
|
||||
HILOG_INFO("Stop AMS.");
|
||||
#ifdef BGTASKMGR_CONTINUOUS_TASK_ENABLE
|
||||
std::unique_lock<std::shared_mutex> lock(bgtaskObserverMutex_);
|
||||
std::unique_lock<ffrt::mutex> lock(bgtaskObserverMutex_);
|
||||
if (bgtaskObserver_) {
|
||||
int ret = BackgroundTaskMgrHelper::UnsubscribeBackgroundTask(*bgtaskObserver_);
|
||||
if (ret != ERR_OK) {
|
||||
@@ -368,8 +351,8 @@ void AbilityManagerService::OnStop()
|
||||
}
|
||||
}
|
||||
}
|
||||
eventLoop_.reset();
|
||||
handler_.reset();
|
||||
eventHandler_.reset();
|
||||
taskHandler_.reset();
|
||||
state_ = ServiceRunningState::STATE_NOT_START;
|
||||
}
|
||||
|
||||
@@ -590,12 +573,10 @@ int AbilityManagerService::StartAbilityInner(const Want &want, const sptr<IRemot
|
||||
}
|
||||
} else {
|
||||
HILOG_DEBUG("Check call ability permission, name is %{public}s.", abilityInfo.name.c_str());
|
||||
if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
result = CheckCallAbilityPermission(abilityRequest);
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Check permission failed");
|
||||
return result;
|
||||
}
|
||||
result = CheckCallAbilityPermission(abilityRequest);
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Check permission failed");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -740,14 +721,12 @@ int AbilityManagerService::StartAbility(const Want &want, const AbilityStartSett
|
||||
EventReport::SendAbilityEvent(EventName::START_ABILITY_ERROR, HiSysEventType::FAULT, eventInfo);
|
||||
return ERR_STATIC_CFG_PERMISSION;
|
||||
}
|
||||
if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
result = CheckCallAbilityPermission(abilityRequest);
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("%{public}s CheckCallAbilityPermission error.", __func__);
|
||||
eventInfo.errCode = result;
|
||||
EventReport::SendAbilityEvent(EventName::START_ABILITY_ERROR, HiSysEventType::FAULT, eventInfo);
|
||||
return result;
|
||||
}
|
||||
result = CheckCallAbilityPermission(abilityRequest);
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("%{public}s CheckCallAbilityPermission error.", __func__);
|
||||
eventInfo.errCode = result;
|
||||
EventReport::SendAbilityEvent(EventName::START_ABILITY_ERROR, HiSysEventType::FAULT, eventInfo);
|
||||
return result;
|
||||
}
|
||||
|
||||
abilityRequest.startSetting = std::make_shared<AbilityStartSetting>(abilityStartSetting);
|
||||
@@ -929,14 +908,12 @@ int AbilityManagerService::StartAbilityForOptionInner(const Want &want, const St
|
||||
EventReport::SendAbilityEvent(EventName::START_ABILITY_ERROR, HiSysEventType::FAULT, eventInfo);
|
||||
return ERR_STATIC_CFG_PERMISSION;
|
||||
}
|
||||
if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
result = CheckCallAbilityPermission(abilityRequest);
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("%{public}s CheckCallAbilityPermission error.", __func__);
|
||||
eventInfo.errCode = result;
|
||||
EventReport::SendAbilityEvent(EventName::START_ABILITY_ERROR, HiSysEventType::FAULT, eventInfo);
|
||||
return result;
|
||||
}
|
||||
result = CheckCallAbilityPermission(abilityRequest);
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("%{public}s CheckCallAbilityPermission error.", __func__);
|
||||
eventInfo.errCode = result;
|
||||
EventReport::SendAbilityEvent(EventName::START_ABILITY_ERROR, HiSysEventType::FAULT, eventInfo);
|
||||
return result;
|
||||
}
|
||||
|
||||
if (abilityInfo.type != AppExecFwk::AbilityType::PAGE) {
|
||||
@@ -1006,6 +983,31 @@ int32_t AbilityManagerService::RequestDialogService(const Want &want, const sptr
|
||||
return RequestDialogServiceInner(want, callerToken, -1, -1);
|
||||
}
|
||||
|
||||
int32_t AbilityManagerService::ReportDrawnCompleted(const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
HILOG_DEBUG("called.");
|
||||
if (callerToken == nullptr) {
|
||||
HILOG_ERROR("callerToken is nullptr");
|
||||
return INNER_ERR;
|
||||
}
|
||||
|
||||
auto abilityRecord = Token::GetAbilityRecordByToken(callerToken);
|
||||
if (abilityRecord == nullptr) {
|
||||
HILOG_ERROR("abilityRecord is nullptr");
|
||||
return INNER_ERR;
|
||||
}
|
||||
auto abilityInfo = abilityRecord->GetAbilityInfo();
|
||||
|
||||
EventInfo eventInfo;
|
||||
eventInfo.userId = IPCSkeleton::GetCallingUid() / BASE_USER_RANGE;
|
||||
eventInfo.pid = IPCSkeleton::GetCallingPid();
|
||||
eventInfo.bundleName = abilityInfo.bundleName;
|
||||
eventInfo.moduleName = abilityInfo.moduleName;
|
||||
eventInfo.abilityName = abilityInfo.name;
|
||||
EventReport::SendAppEvent(EventName::DRAWN_COMPLETED, HiSysEventType::BEHAVIOR, eventInfo);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int32_t AbilityManagerService::RequestDialogServiceInner(const Want &want, const sptr<IRemoteObject> &callerToken,
|
||||
int requestCode, int32_t userId)
|
||||
{
|
||||
@@ -1200,7 +1202,7 @@ bool AbilityManagerService::CheckCallingTokenId(const std::string &bundleName, i
|
||||
bool AbilityManagerService::IsBackgroundTaskUid(const int uid)
|
||||
{
|
||||
#ifdef BGTASKMGR_CONTINUOUS_TASK_ENABLE
|
||||
std::shared_lock<std::shared_mutex> lock(bgtaskObserverMutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(bgtaskObserverMutex_);
|
||||
if (bgtaskObserver_) {
|
||||
return bgtaskObserver_->IsBackgroundTaskUid(uid);
|
||||
}
|
||||
@@ -1301,7 +1303,7 @@ int32_t AbilityManagerService::ForceExitApp(const int32_t pid, Reason exitReason
|
||||
int32_t targetUserId = uid / BASE_USER_RANGE;
|
||||
std::vector<std::string> abilityLists;
|
||||
if (targetUserId == U0_USER_ID) {
|
||||
std::shared_lock<std::shared_mutex> lock(managersMutex_);
|
||||
std::lock_guard lock(managersMutex_);
|
||||
for (auto item: missionListManagers_) {
|
||||
if (item.second) {
|
||||
std::vector<std::string> abilityList;
|
||||
@@ -1437,7 +1439,7 @@ void AbilityManagerService::OnRemoveSystemAbility(int32_t systemAbilityId, const
|
||||
void AbilityManagerService::SubscribeBackgroundTask()
|
||||
{
|
||||
#ifdef BGTASKMGR_CONTINUOUS_TASK_ENABLE
|
||||
std::unique_lock<std::shared_mutex> lock(bgtaskObserverMutex_);
|
||||
std::unique_lock<ffrt::mutex> lock(bgtaskObserverMutex_);
|
||||
if (bgtaskObserver_) {
|
||||
return;
|
||||
}
|
||||
@@ -1456,7 +1458,7 @@ void AbilityManagerService::SubscribeBackgroundTask()
|
||||
void AbilityManagerService::UnSubscribeBackgroundTask()
|
||||
{
|
||||
#ifdef BGTASKMGR_CONTINUOUS_TASK_ENABLE
|
||||
std::unique_lock<std::shared_mutex> lock(bgtaskObserverMutex_);
|
||||
std::unique_lock<ffrt::mutex> lock(bgtaskObserverMutex_);
|
||||
if (!bgtaskObserver_) {
|
||||
return;
|
||||
}
|
||||
@@ -1473,7 +1475,7 @@ void AbilityManagerService::SubscribeBundleEventCallback()
|
||||
}
|
||||
|
||||
// Register abilityBundleEventCallback to receive hap updates
|
||||
abilityBundleEventCallback_ = new (std::nothrow) AbilityBundleEventCallback(handler_);
|
||||
abilityBundleEventCallback_ = new (std::nothrow) AbilityBundleEventCallback(taskHandler_);
|
||||
auto bms = GetBundleManager();
|
||||
if (bms) {
|
||||
bool ret = IN_PROCESS_CALL(bms->RegisterBundleEventCallback(abilityBundleEventCallback_));
|
||||
@@ -1630,21 +1632,22 @@ int AbilityManagerService::StartExtensionAbility(const Want &want, const sptr<IR
|
||||
return eventInfo.errCode;
|
||||
}
|
||||
|
||||
int AbilityManagerService::StartUIExtensionAbility(const Want &want, const sptr<SessionInfo> &extensionSessionInfo,
|
||||
int32_t userId, AppExecFwk::ExtensionAbilityType extensionType)
|
||||
int AbilityManagerService::StartUIExtensionAbility(const sptr<SessionInfo> &extensionSessionInfo, int32_t userId)
|
||||
{
|
||||
HILOG_INFO("Start ui extension ability come, bundlename: %{public}s, ability is %{public}s, userId is %{pravite}d",
|
||||
want.GetElement().GetBundleName().c_str(), want.GetElement().GetAbilityName().c_str(), userId);
|
||||
extensionSessionInfo->want.GetElement().GetBundleName().c_str(),
|
||||
extensionSessionInfo->want.GetElement().GetAbilityName().c_str(), userId);
|
||||
CHECK_POINTER_AND_RETURN(extensionSessionInfo, ERR_INVALID_VALUE);
|
||||
EventInfo eventInfo = BuildEventInfo(want, userId);
|
||||
AppExecFwk::ExtensionAbilityType extensionType = AppExecFwk::ExtensionAbilityType::UI;
|
||||
EventInfo eventInfo = BuildEventInfo(extensionSessionInfo->want, userId);
|
||||
eventInfo.extensionType = static_cast<int32_t>(extensionType);
|
||||
EventReport::SendExtensionEvent(EventName::START_SERVICE, HiSysEventType::BEHAVIOR, eventInfo);
|
||||
|
||||
sptr<IRemoteObject> callerToken = extensionSessionInfo->callerToken;
|
||||
|
||||
if (!DlpUtils::OtherAppsAccessDlpCheck(callerToken, want) ||
|
||||
if (!DlpUtils::OtherAppsAccessDlpCheck(callerToken, extensionSessionInfo->want) ||
|
||||
VerifyAccountPermission(userId) == CHECK_PERMISSION_FAILED ||
|
||||
!DlpUtils::DlpAccessOtherAppsCheck(callerToken, want)) {
|
||||
!DlpUtils::DlpAccessOtherAppsCheck(callerToken, extensionSessionInfo->want)) {
|
||||
HILOG_ERROR("StartUIExtensionAbility: Permission verification failed.");
|
||||
eventInfo.errCode = CHECK_PERMISSION_FAILED;
|
||||
EventReport::SendExtensionEvent(EventName::START_EXTENSION_ERROR, HiSysEventType::FAULT, eventInfo);
|
||||
@@ -1667,7 +1670,7 @@ int AbilityManagerService::StartUIExtensionAbility(const Want &want, const sptr<
|
||||
}
|
||||
|
||||
auto result = interceptorExecuter_ == nullptr ? ERR_INVALID_VALUE :
|
||||
interceptorExecuter_->DoProcess(want, 0, GetUserId(), false);
|
||||
interceptorExecuter_->DoProcess(extensionSessionInfo->want, 0, GetUserId(), false);
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("interceptorExecuter_ is nullptr or DoProcess return error.");
|
||||
eventInfo.errCode = result;
|
||||
@@ -1683,7 +1686,7 @@ int AbilityManagerService::StartUIExtensionAbility(const Want &want, const sptr<
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
if (ImplicitStartProcessor::IsImplicitStartAction(want)) {
|
||||
if (ImplicitStartProcessor::IsImplicitStartAction(extensionSessionInfo->want)) {
|
||||
HILOG_ERROR("UI extension ability donot support implicit start.");
|
||||
eventInfo.errCode = ERR_INVALID_VALUE;
|
||||
EventReport::SendExtensionEvent(EventName::START_EXTENSION_ERROR, HiSysEventType::FAULT, eventInfo);
|
||||
@@ -1691,11 +1694,11 @@ int AbilityManagerService::StartUIExtensionAbility(const Want &want, const sptr<
|
||||
}
|
||||
|
||||
AbilityRequest abilityRequest;
|
||||
abilityRequest.Voluation(want, DEFAULT_INVAL_VALUE, callerToken);
|
||||
abilityRequest.Voluation(extensionSessionInfo->want, DEFAULT_INVAL_VALUE, callerToken);
|
||||
abilityRequest.callType = AbilityCallType::START_EXTENSION_TYPE;
|
||||
abilityRequest.extensionType = extensionType;
|
||||
abilityRequest.sessionInfo = extensionSessionInfo;
|
||||
result = GenerateExtensionAbilityRequest(want, abilityRequest, callerToken, validUserId);
|
||||
result = GenerateExtensionAbilityRequest(extensionSessionInfo->want, abilityRequest, callerToken, validUserId);
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Generate ability request local error.");
|
||||
eventInfo.errCode = result;
|
||||
@@ -1708,7 +1711,7 @@ int AbilityManagerService::StartUIExtensionAbility(const Want &want, const sptr<
|
||||
HILOG_DEBUG("userId is : %{public}d, singleton is : %{public}d",
|
||||
validUserId, static_cast<int>(abilityInfo.applicationInfo.singleton));
|
||||
|
||||
result = CheckOptExtensionAbility(want, abilityRequest, validUserId, extensionType);
|
||||
result = CheckOptExtensionAbility(extensionSessionInfo->want, abilityRequest, validUserId, extensionType);
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("CheckOptExtensionAbility error.");
|
||||
eventInfo.errCode = result;
|
||||
@@ -3287,7 +3290,7 @@ sptr<IAbilityScheduler> AbilityManagerService::AcquireDataAbility(
|
||||
auto userId = GetValidUserId(INVALID_USER_ID);
|
||||
AbilityRequest abilityRequest;
|
||||
std::string dataAbilityUri = localUri.ToString();
|
||||
HILOG_INFO("%{public}s, called. userId %{public}d", __func__, userId);
|
||||
HILOG_INFO("called. userId %{public}d", userId);
|
||||
bool queryResult = IN_PROCESS_CALL(bms->QueryAbilityInfoByUri(dataAbilityUri, userId, abilityRequest.abilityInfo));
|
||||
if (!queryResult || abilityRequest.abilityInfo.name.empty() || abilityRequest.abilityInfo.bundleName.empty()) {
|
||||
HILOG_ERROR("Invalid ability info for data ability acquiring.");
|
||||
@@ -3295,7 +3298,9 @@ sptr<IAbilityScheduler> AbilityManagerService::AcquireDataAbility(
|
||||
}
|
||||
|
||||
abilityRequest.callerToken = callerToken;
|
||||
if (CheckCallDataAbilityPermission(abilityRequest) != ERR_OK) {
|
||||
auto isShellCall = AAFwk::PermissionVerification::GetInstance()->IsShellCall();
|
||||
auto isSaCall = AAFwk::PermissionVerification::GetInstance()->IsSACall();
|
||||
if (!isSaCall && CheckCallDataAbilityPermission(abilityRequest, isShellCall, isSaCall) != ERR_OK) {
|
||||
HILOG_ERROR("Invalid ability request info for data ability acquiring.");
|
||||
return nullptr;
|
||||
}
|
||||
@@ -3304,7 +3309,8 @@ sptr<IAbilityScheduler> AbilityManagerService::AcquireDataAbility(
|
||||
abilityRequest.appInfo.name.c_str(), abilityRequest.appInfo.bundleName.c_str(),
|
||||
abilityRequest.abilityInfo.name.c_str());
|
||||
|
||||
if (CheckStaticCfgPermission(abilityRequest.abilityInfo, false, -1) != AppExecFwk::Constants::PERMISSION_GRANTED) {
|
||||
if (CheckStaticCfgPermission(abilityRequest.abilityInfo, false, -1, true, isSaCall) !=
|
||||
AppExecFwk::Constants::PERMISSION_GRANTED) {
|
||||
if (!VerificationAllToken(callerToken)) {
|
||||
HILOG_INFO("VerificationAllToken fail");
|
||||
return nullptr;
|
||||
@@ -3318,8 +3324,6 @@ sptr<IAbilityScheduler> AbilityManagerService::AcquireDataAbility(
|
||||
std::shared_ptr<DataAbilityManager> dataAbilityManager = GetDataAbilityManagerByUserId(userId);
|
||||
CHECK_POINTER_AND_RETURN(dataAbilityManager, nullptr);
|
||||
ReportEventToSuspendManager(abilityRequest.abilityInfo);
|
||||
auto isSaCall = AAFwk::PermissionVerification::GetInstance()->IsSACall();
|
||||
auto isShellCall = AAFwk::PermissionVerification::GetInstance()->IsShellCall();
|
||||
bool isNotHap = isSaCall || isShellCall;
|
||||
UpdateCallerInfo(abilityRequest.want, callerToken);
|
||||
return dataAbilityManager->Acquire(abilityRequest, tryBind, callerToken, isNotHap);
|
||||
@@ -3441,7 +3445,7 @@ void AbilityManagerService::DumpSysMissionListInner(
|
||||
{
|
||||
std::shared_ptr<MissionListManager> targetManager;
|
||||
if (isUserID) {
|
||||
std::shared_lock<std::shared_mutex> lock(managersMutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(managersMutex_);
|
||||
auto it = missionListManagers_.find(userId);
|
||||
if (it == missionListManagers_.end()) {
|
||||
info.push_back("error: No user found.");
|
||||
@@ -3473,7 +3477,7 @@ void AbilityManagerService::DumpSysAbilityInner(
|
||||
{
|
||||
std::shared_ptr<MissionListManager> targetManager;
|
||||
if (isUserID) {
|
||||
std::shared_lock<std::shared_mutex> lock(managersMutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(managersMutex_);
|
||||
auto it = missionListManagers_.find(userId);
|
||||
if (it == missionListManagers_.end()) {
|
||||
info.push_back("error: No user found.");
|
||||
@@ -3513,7 +3517,7 @@ void AbilityManagerService::DumpSysStateInner(
|
||||
std::shared_ptr<AbilityConnectManager> targetManager;
|
||||
|
||||
if (isUserID) {
|
||||
std::shared_lock<std::shared_mutex> lock(managersMutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(managersMutex_);
|
||||
auto it = connectManagers_.find(userId);
|
||||
if (it == connectManagers_.end()) {
|
||||
info.push_back("error: No user found.");
|
||||
@@ -3548,7 +3552,7 @@ void AbilityManagerService::DumpSysPendingInner(
|
||||
{
|
||||
std::shared_ptr<PendingWantManager> targetManager;
|
||||
if (isUserID) {
|
||||
std::shared_lock<std::shared_mutex> lock(managersMutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(managersMutex_);
|
||||
auto it = pendingWantManagers_.find(userId);
|
||||
if (it == pendingWantManagers_.end()) {
|
||||
info.push_back("error: No user found.");
|
||||
@@ -3624,7 +3628,7 @@ void AbilityManagerService::DataDumpSysStateInner(
|
||||
{
|
||||
std::shared_ptr<DataAbilityManager> targetManager;
|
||||
if (isUserID) {
|
||||
std::shared_lock<std::shared_mutex> lock(managersMutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(managersMutex_);
|
||||
auto it = dataAbilityManagers_.find(userId);
|
||||
if (it == dataAbilityManagers_.end()) {
|
||||
info.push_back("error: No user found.");
|
||||
@@ -4006,14 +4010,14 @@ void AbilityManagerService::OnAppStateChanged(const AppInfo &info)
|
||||
|
||||
std::shared_ptr<AbilityEventHandler> AbilityManagerService::GetEventHandler()
|
||||
{
|
||||
return handler_;
|
||||
return eventHandler_;
|
||||
}
|
||||
|
||||
void AbilityManagerService::InitMissionListManager(int userId, bool switchUser)
|
||||
{
|
||||
bool find = false;
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(managersMutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(managersMutex_);
|
||||
auto iterator = missionListManagers_.find(userId);
|
||||
find = (iterator != missionListManagers_.end());
|
||||
if (find) {
|
||||
@@ -4026,7 +4030,7 @@ void AbilityManagerService::InitMissionListManager(int userId, bool switchUser)
|
||||
if (!find) {
|
||||
auto manager = std::make_shared<MissionListManager>(userId);
|
||||
manager->Init();
|
||||
std::unique_lock<std::shared_mutex> lock(managersMutex_);
|
||||
std::unique_lock<ffrt::mutex> lock(managersMutex_);
|
||||
missionListManagers_.emplace(userId, manager);
|
||||
if (switchUser) {
|
||||
currentMissionListManager_ = manager;
|
||||
@@ -4289,7 +4293,8 @@ int AbilityManagerService::StopServiceAbility(const Want &want, int32_t userId,
|
||||
HILOG_DEBUG("call.");
|
||||
|
||||
auto isSaCall = AAFwk::PermissionVerification::GetInstance()->IsSACall();
|
||||
if (!isSaCall) {
|
||||
auto isShellCall = AAFwk::PermissionVerification::GetInstance()->IsShellCall();
|
||||
if (!isSaCall && !isShellCall) {
|
||||
auto abilityRecord = Token::GetAbilityRecordByToken(token);
|
||||
if (abilityRecord == nullptr) {
|
||||
HILOG_ERROR("callerRecord is nullptr");
|
||||
@@ -4372,7 +4377,7 @@ void AbilityManagerService::OnCallConnectDied(std::shared_ptr<CallRecord> callRe
|
||||
|
||||
void AbilityManagerService::ReleaseAbilityTokenMap(const sptr<IRemoteObject> &token)
|
||||
{
|
||||
std::lock_guard<std::mutex> autoLock(abilityTokenLock_);
|
||||
std::lock_guard<ffrt::mutex> autoLock(abilityTokenLock_);
|
||||
for (auto iter = callStubTokenMap_.begin(); iter != callStubTokenMap_.end(); iter++) {
|
||||
if (iter->second == token) {
|
||||
callStubTokenMap_.erase(iter);
|
||||
@@ -4430,7 +4435,7 @@ int AbilityManagerService::UninstallApp(const std::string &bundleName, int32_t u
|
||||
|
||||
int32_t targetUserId = uid / BASE_USER_RANGE;
|
||||
if (targetUserId == U0_USER_ID) {
|
||||
std::shared_lock<std::shared_mutex> lock(managersMutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(managersMutex_);
|
||||
for (auto item: missionListManagers_) {
|
||||
if (item.second) {
|
||||
item.second->UninstallApp(bundleName, uid);
|
||||
@@ -4537,7 +4542,7 @@ bool AbilityManagerService::IsSystemUI(const std::string &bundleName) const
|
||||
void AbilityManagerService::HandleLoadTimeOut(int64_t abilityRecordId)
|
||||
{
|
||||
HILOG_DEBUG("Handle load timeout.");
|
||||
std::shared_lock<std::shared_mutex> lock(managersMutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(managersMutex_);
|
||||
if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
uiAbilityLifecycleManager_->OnTimeOut(AbilityManagerService::LOAD_TIMEOUT_MSG, abilityRecordId);
|
||||
return;
|
||||
@@ -4552,7 +4557,7 @@ void AbilityManagerService::HandleLoadTimeOut(int64_t abilityRecordId)
|
||||
void AbilityManagerService::HandleActiveTimeOut(int64_t abilityRecordId)
|
||||
{
|
||||
HILOG_DEBUG("Handle active timeout.");
|
||||
std::shared_lock<std::shared_mutex> lock(managersMutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(managersMutex_);
|
||||
for (auto& item : missionListManagers_) {
|
||||
if (item.second) {
|
||||
item.second->OnTimeOut(AbilityManagerService::ACTIVE_TIMEOUT_MSG, abilityRecordId);
|
||||
@@ -4563,7 +4568,7 @@ void AbilityManagerService::HandleActiveTimeOut(int64_t abilityRecordId)
|
||||
void AbilityManagerService::HandleInactiveTimeOut(int64_t abilityRecordId)
|
||||
{
|
||||
HILOG_DEBUG("Handle inactive timeout.");
|
||||
std::shared_lock<std::shared_mutex> lock(managersMutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(managersMutex_);
|
||||
for (auto& item : missionListManagers_) {
|
||||
if (item.second) {
|
||||
item.second->OnTimeOut(AbilityManagerService::INACTIVE_TIMEOUT_MSG, abilityRecordId);
|
||||
@@ -4580,7 +4585,7 @@ void AbilityManagerService::HandleInactiveTimeOut(int64_t abilityRecordId)
|
||||
void AbilityManagerService::HandleForegroundTimeOut(int64_t abilityRecordId)
|
||||
{
|
||||
HILOG_DEBUG("Handle foreground timeout.");
|
||||
std::shared_lock<std::shared_mutex> lock(managersMutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(managersMutex_);
|
||||
if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
uiAbilityLifecycleManager_->OnTimeOut(AbilityManagerService::FOREGROUND_TIMEOUT_MSG, abilityRecordId);
|
||||
return;
|
||||
@@ -4663,7 +4668,7 @@ bool AbilityManagerService::VerificationAllToken(const sptr<IRemoteObject> &toke
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("VerificationAllToken.");
|
||||
std::shared_lock<std::shared_mutex> lock(managersMutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(managersMutex_);
|
||||
if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
if (uiAbilityLifecycleManager_ != nullptr && uiAbilityLifecycleManager_->IsContainsAbility(token)) {
|
||||
return true;
|
||||
@@ -4713,7 +4718,7 @@ std::shared_ptr<DataAbilityManager> AbilityManagerService::GetDataAbilityManager
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_lock<std::shared_mutex> lock(managersMutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(managersMutex_);
|
||||
for (auto& item: dataAbilityManagers_) {
|
||||
if (item.second && item.second->ContainsDataAbility(scheduler)) {
|
||||
return item.second;
|
||||
@@ -4725,7 +4730,7 @@ std::shared_ptr<DataAbilityManager> AbilityManagerService::GetDataAbilityManager
|
||||
|
||||
std::shared_ptr<MissionListManager> AbilityManagerService::GetListManagerByUserId(int32_t userId)
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(managersMutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(managersMutex_);
|
||||
auto it = missionListManagers_.find(userId);
|
||||
if (it != missionListManagers_.end()) {
|
||||
return it->second;
|
||||
@@ -4736,7 +4741,7 @@ std::shared_ptr<MissionListManager> AbilityManagerService::GetListManagerByUserI
|
||||
|
||||
std::shared_ptr<AbilityConnectManager> AbilityManagerService::GetConnectManagerByUserId(int32_t userId)
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(managersMutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(managersMutex_);
|
||||
auto it = connectManagers_.find(userId);
|
||||
if (it != connectManagers_.end()) {
|
||||
return it->second;
|
||||
@@ -4747,7 +4752,7 @@ std::shared_ptr<AbilityConnectManager> AbilityManagerService::GetConnectManagerB
|
||||
|
||||
std::shared_ptr<DataAbilityManager> AbilityManagerService::GetDataAbilityManagerByUserId(int32_t userId)
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(managersMutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(managersMutex_);
|
||||
auto it = dataAbilityManagers_.find(userId);
|
||||
if (it != dataAbilityManagers_.end()) {
|
||||
return it->second;
|
||||
@@ -4759,7 +4764,7 @@ std::shared_ptr<DataAbilityManager> AbilityManagerService::GetDataAbilityManager
|
||||
std::shared_ptr<AbilityConnectManager> AbilityManagerService::GetConnectManagerByToken(
|
||||
const sptr<IRemoteObject> &token)
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(managersMutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(managersMutex_);
|
||||
for (auto item: connectManagers_) {
|
||||
if (item.second && item.second->GetExtensionByTokenFromServiceMap(token)) {
|
||||
return item.second;
|
||||
@@ -4775,7 +4780,7 @@ std::shared_ptr<AbilityConnectManager> AbilityManagerService::GetConnectManagerB
|
||||
std::shared_ptr<DataAbilityManager> AbilityManagerService::GetDataAbilityManagerByToken(
|
||||
const sptr<IRemoteObject> &token)
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(managersMutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(managersMutex_);
|
||||
for (auto item: dataAbilityManagers_) {
|
||||
if (item.second && item.second->GetAbilityRecordByToken(token)) {
|
||||
return item.second;
|
||||
@@ -5211,7 +5216,7 @@ int AbilityManagerService::GetProcessRunningInfosByUserId(
|
||||
void AbilityManagerService::ClearUserData(int32_t userId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s", __func__);
|
||||
std::unique_lock<std::shared_mutex> lock(managersMutex_);
|
||||
std::unique_lock<ffrt::mutex> lock(managersMutex_);
|
||||
missionListManagers_.erase(userId);
|
||||
connectManagers_.erase(userId);
|
||||
dataAbilityManagers_.erase(userId);
|
||||
@@ -5305,7 +5310,7 @@ void AbilityManagerService::EnableRecoverAbility(const sptr<IRemoteObject>& toke
|
||||
}
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(globalLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(globalLock_);
|
||||
auto it = appRecoveryHistory_.find(record->GetUid());
|
||||
if (it == appRecoveryHistory_.end()) {
|
||||
appRecoveryHistory_.emplace(record->GetUid(), 0);
|
||||
@@ -5368,7 +5373,7 @@ void AbilityManagerService::ScheduleRecoverAbility(const sptr<IRemoteObject>& to
|
||||
|
||||
AAFwk::Want curWant;
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(globalLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(globalLock_);
|
||||
auto type = record->GetAbilityInfo().type;
|
||||
if (type != AppExecFwk::AbilityType::PAGE) {
|
||||
HILOG_ERROR("%{public}s AppRecovery::only do recover for page ability.", __func__);
|
||||
@@ -5446,7 +5451,7 @@ void AbilityManagerService::ScheduleRecoverAbility(const sptr<IRemoteObject>& to
|
||||
std::string taskName = "AppRecovery_kill:" + std::to_string(record->GetPid());
|
||||
auto task = std::bind(&AbilityManagerService::RecoverAbilityRestart, this, curWant);
|
||||
HILOG_INFO("AppRecovery RecoverAbilityRestart task begin");
|
||||
handler_->PostTask(task, taskName, delaytime);
|
||||
taskHandler_->SubmitTask(task, taskName, delaytime);
|
||||
}
|
||||
|
||||
int32_t AbilityManagerService::GetRemoteMissionSnapshotInfo(const std::string& deviceId, int32_t missionId,
|
||||
@@ -5486,7 +5491,9 @@ void AbilityManagerService::UserStarted(int32_t userId)
|
||||
{
|
||||
HILOG_INFO("%{public}s", __func__);
|
||||
InitConnectManager(userId, false);
|
||||
InitMissionListManager(userId, false);
|
||||
if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
InitMissionListManager(userId, false);
|
||||
}
|
||||
InitDataAbilityManager(userId, false);
|
||||
InitPendWantManager(userId, false);
|
||||
}
|
||||
@@ -5495,13 +5502,15 @@ void AbilityManagerService::SwitchToUser(int32_t oldUserId, int32_t userId)
|
||||
{
|
||||
HILOG_INFO("%{public}s, oldUserId:%{public}d, newUserId:%{public}d", __func__, oldUserId, userId);
|
||||
SwitchManagers(userId);
|
||||
PauseOldUser(oldUserId);
|
||||
bool isBoot = false;
|
||||
if (oldUserId == U0_USER_ID) {
|
||||
isBoot = true;
|
||||
if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
PauseOldUser(oldUserId);
|
||||
bool isBoot = false;
|
||||
if (oldUserId == U0_USER_ID) {
|
||||
isBoot = true;
|
||||
}
|
||||
ConnectBmsService();
|
||||
StartUserApps(userId, isBoot);
|
||||
}
|
||||
ConnectBmsService();
|
||||
StartUserApps(userId, isBoot);
|
||||
PauseOldConnectManager(oldUserId);
|
||||
}
|
||||
|
||||
@@ -5509,7 +5518,7 @@ void AbilityManagerService::SwitchManagers(int32_t userId, bool switchUser)
|
||||
{
|
||||
HILOG_INFO("%{public}s, SwitchManagers:%{public}d-----begin", __func__, userId);
|
||||
InitConnectManager(userId, switchUser);
|
||||
if (userId != U0_USER_ID) {
|
||||
if (userId != U0_USER_ID && !Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
InitMissionListManager(userId, switchUser);
|
||||
}
|
||||
InitDataAbilityManager(userId, switchUser);
|
||||
@@ -5527,7 +5536,7 @@ void AbilityManagerService::PauseOldUser(int32_t userId)
|
||||
void AbilityManagerService::PauseOldMissionListManager(int32_t userId)
|
||||
{
|
||||
HILOG_INFO("%{public}s, PauseOldMissionListManager:%{public}d-----begin", __func__, userId);
|
||||
std::shared_lock<std::shared_mutex> lock(managersMutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(managersMutex_);
|
||||
auto it = missionListManagers_.find(userId);
|
||||
if (it == missionListManagers_.end()) {
|
||||
HILOG_INFO("%{public}s, PauseOldMissionListManager:%{public}d-----end1", __func__, userId);
|
||||
@@ -5550,7 +5559,7 @@ void AbilityManagerService::PauseOldConnectManager(int32_t userId)
|
||||
return;
|
||||
}
|
||||
|
||||
std::shared_lock<std::shared_mutex> lock(managersMutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(managersMutex_);
|
||||
auto it = connectManagers_.find(userId);
|
||||
if (it == connectManagers_.end()) {
|
||||
HILOG_INFO("%{public}s, PauseOldConnectManager:%{public}d-----no user", __func__, userId);
|
||||
@@ -5579,7 +5588,7 @@ void AbilityManagerService::InitConnectManager(int32_t userId, bool switchUser)
|
||||
{
|
||||
bool find = false;
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(managersMutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(managersMutex_);
|
||||
auto it = connectManagers_.find(userId);
|
||||
find = (it != connectManagers_.end());
|
||||
if (find) {
|
||||
@@ -5590,8 +5599,9 @@ void AbilityManagerService::InitConnectManager(int32_t userId, bool switchUser)
|
||||
}
|
||||
if (!find) {
|
||||
auto manager = std::make_shared<AbilityConnectManager>(userId);
|
||||
manager->SetEventHandler(handler_);
|
||||
std::unique_lock<std::shared_mutex> lock(managersMutex_);
|
||||
manager->SetTaskHandler(taskHandler_);
|
||||
manager->SetEventHandler(eventHandler_);
|
||||
std::unique_lock<ffrt::mutex> lock(managersMutex_);
|
||||
connectManagers_.emplace(userId, manager);
|
||||
if (switchUser) {
|
||||
connectManager_ = manager;
|
||||
@@ -5603,7 +5613,7 @@ void AbilityManagerService::InitDataAbilityManager(int32_t userId, bool switchUs
|
||||
{
|
||||
bool find = false;
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(managersMutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(managersMutex_);
|
||||
auto it = dataAbilityManagers_.find(userId);
|
||||
find = (it != dataAbilityManagers_.end());
|
||||
if (find) {
|
||||
@@ -5614,7 +5624,7 @@ void AbilityManagerService::InitDataAbilityManager(int32_t userId, bool switchUs
|
||||
}
|
||||
if (!find) {
|
||||
auto manager = std::make_shared<DataAbilityManager>();
|
||||
std::unique_lock<std::shared_mutex> lock(managersMutex_);
|
||||
std::unique_lock<ffrt::mutex> lock(managersMutex_);
|
||||
dataAbilityManagers_.emplace(userId, manager);
|
||||
if (switchUser) {
|
||||
dataAbilityManager_ = manager;
|
||||
@@ -5626,7 +5636,7 @@ void AbilityManagerService::InitPendWantManager(int32_t userId, bool switchUser)
|
||||
{
|
||||
bool find = false;
|
||||
{
|
||||
std::shared_lock<std::shared_mutex> lock(managersMutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(managersMutex_);
|
||||
auto it = pendingWantManagers_.find(userId);
|
||||
find = (it != pendingWantManagers_.end());
|
||||
if (find) {
|
||||
@@ -5637,7 +5647,7 @@ void AbilityManagerService::InitPendWantManager(int32_t userId, bool switchUser)
|
||||
}
|
||||
if (!find) {
|
||||
auto manager = std::make_shared<PendingWantManager>();
|
||||
std::unique_lock<std::shared_mutex> lock(managersMutex_);
|
||||
std::unique_lock<ffrt::mutex> lock(managersMutex_);
|
||||
pendingWantManagers_.emplace(userId, manager);
|
||||
if (switchUser) {
|
||||
pendingWantManager_ = manager;
|
||||
@@ -5671,7 +5681,7 @@ int AbilityManagerService::SetAbilityController(const sptr<IAbilityController> &
|
||||
return CHECK_PERMISSION_FAILED;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> guard(globalLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(globalLock_);
|
||||
abilityController_ = abilityController;
|
||||
controllerIsAStabilityTest_ = imAStabilityTest;
|
||||
HILOG_DEBUG("%{public}s, end", __func__);
|
||||
@@ -5692,7 +5702,7 @@ int AbilityManagerService::SendANRProcessID(int pid)
|
||||
bool debug;
|
||||
auto appScheduler = DelayedSingleton<AppScheduler>::GetInstance();
|
||||
if (appScheduler->GetApplicationInfoByProcessID(pid, appInfo, debug) == ERR_OK) {
|
||||
std::lock_guard<std::mutex> guard(globalLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(globalLock_);
|
||||
auto it = appRecoveryHistory_.find(appInfo.uid);
|
||||
if (it != appRecoveryHistory_.end()) {
|
||||
return ERR_OK;
|
||||
@@ -5720,7 +5730,7 @@ int AbilityManagerService::SendANRProcessID(int pid)
|
||||
|
||||
bool AbilityManagerService::IsRunningInStabilityTest()
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(globalLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(globalLock_);
|
||||
bool ret = abilityController_ != nullptr && controllerIsAStabilityTest_;
|
||||
HILOG_DEBUG("%{public}s, IsRunningInStabilityTest: %{public}d", __func__, ret);
|
||||
return ret;
|
||||
@@ -5896,7 +5906,7 @@ int AbilityManagerService::DoAbilityForeground(const sptr<IRemoteObject> &token,
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> guard(globalLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(globalLock_);
|
||||
auto abilityRecord = Token::GetAbilityRecordByToken(token);
|
||||
CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE);
|
||||
if (!JudgeSelfCalled(abilityRecord)) {
|
||||
@@ -6015,10 +6025,12 @@ int AbilityManagerService::ForceTimeoutForTest(const std::string &abilityName, c
|
||||
#endif
|
||||
|
||||
int AbilityManagerService::CheckStaticCfgPermission(AppExecFwk::AbilityInfo &abilityInfo, bool isStartAsCaller,
|
||||
uint32_t callerTokenId)
|
||||
uint32_t callerTokenId, bool isData, bool isSaCall)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
auto isSaCall = AAFwk::PermissionVerification::GetInstance()->IsSACall();
|
||||
if (!isData) {
|
||||
isSaCall = AAFwk::PermissionVerification::GetInstance()->IsSACall();
|
||||
}
|
||||
if (isSaCall) {
|
||||
// do not need check static config permission when start ability by SA
|
||||
return AppExecFwk::Constants::PERMISSION_GRANTED;
|
||||
@@ -6158,7 +6170,7 @@ int AbilityManagerService::BlockAmsService()
|
||||
HILOG_ERROR("Not shell call");
|
||||
return ERR_PERMISSION_DENIED;
|
||||
}
|
||||
if (handler_) {
|
||||
if (taskHandler_) {
|
||||
HILOG_DEBUG("%{public}s begin post block ams service task", __func__);
|
||||
auto BlockAmsServiceTask = [aams = shared_from_this()]() {
|
||||
while (1) {
|
||||
@@ -6166,7 +6178,7 @@ int AbilityManagerService::BlockAmsService()
|
||||
std::this_thread::sleep_for(BLOCK_AMS_SERVICE_TIME*1s);
|
||||
}
|
||||
};
|
||||
handler_->PostTask(BlockAmsServiceTask, "blockamsservice");
|
||||
taskHandler_->SubmitTask(BlockAmsServiceTask, "blockamsservice");
|
||||
return ERR_OK;
|
||||
}
|
||||
return ERR_NO_INIT;
|
||||
@@ -6444,7 +6456,7 @@ sptr<IWindowManagerServiceHandler> AbilityManagerService::GetWMSHandler() const
|
||||
void AbilityManagerService::CompleteFirstFrameDrawing(const sptr<IRemoteObject> &abilityToken)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s is called.", __func__);
|
||||
std::shared_lock<std::shared_mutex> lock(managersMutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(managersMutex_);
|
||||
for (auto& item : missionListManagers_) {
|
||||
if (item.second) {
|
||||
item.second->CompleteFirstFrameDrawing(abilityToken);
|
||||
@@ -6523,8 +6535,8 @@ int AbilityManagerService::PrepareTerminateAbility(const sptr<IRemoteObject> &to
|
||||
};
|
||||
int prepareTerminateTimeout =
|
||||
AmsConfigurationParameter::GetInstance().GetAppStartTimeoutTime() * PREPARE_TERMINATE_TIMEOUT_MULTIPLE;
|
||||
if (handler_) {
|
||||
handler_->PostTask(timeoutTask, "PrepareTermiante_" + std::to_string(abilityRecord->GetAbilityRecordId()),
|
||||
if (taskHandler_) {
|
||||
taskHandler_->SubmitTask(timeoutTask, "PrepareTermiante_" + std::to_string(abilityRecord->GetAbilityRecordId()),
|
||||
prepareTerminateTimeout);
|
||||
}
|
||||
|
||||
@@ -6532,7 +6544,7 @@ int AbilityManagerService::PrepareTerminateAbility(const sptr<IRemoteObject> &to
|
||||
if (!res) {
|
||||
callback->DoPrepareTerminate();
|
||||
}
|
||||
handler_->RemoveTask("PrepareTermiante_" + std::to_string(abilityRecord->GetAbilityRecordId()));
|
||||
taskHandler_->CancelTask("PrepareTermiante_" + std::to_string(abilityRecord->GetAbilityRecordId()));
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
@@ -6567,15 +6579,15 @@ void AbilityManagerService::InitFocusListener()
|
||||
return;
|
||||
}
|
||||
|
||||
focusListener_ = new WindowFocusChangedListener(shared_from_this(), handler_);
|
||||
focusListener_ = new WindowFocusChangedListener(shared_from_this(), taskHandler_);
|
||||
auto registerTask = [innerService = shared_from_this()]() {
|
||||
if (innerService) {
|
||||
HILOG_INFO("RegisterFocusListener task");
|
||||
innerService->RegisterFocusListener();
|
||||
}
|
||||
};
|
||||
if (handler_) {
|
||||
handler_->PostTask(registerTask, "RegisterFocusListenerTask", REGISTER_FOCUS_DELAY);
|
||||
if (taskHandler_) {
|
||||
taskHandler_->SubmitTask(registerTask, "RegisterFocusListenerTask", REGISTER_FOCUS_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6618,9 +6630,8 @@ int AbilityManagerService::CheckCallServicePermission(const AbilityRequest &abil
|
||||
}
|
||||
}
|
||||
|
||||
int AbilityManagerService::CheckCallDataAbilityPermission(AbilityRequest &abilityRequest)
|
||||
int AbilityManagerService::CheckCallDataAbilityPermission(AbilityRequest &abilityRequest, bool isShell, bool isSACall)
|
||||
{
|
||||
HILOG_INFO("%{public}s begin", __func__);
|
||||
abilityRequest.appInfo = abilityRequest.abilityInfo.applicationInfo;
|
||||
abilityRequest.uid = abilityRequest.appInfo.uid;
|
||||
if (abilityRequest.appInfo.name.empty() || abilityRequest.appInfo.bundleName.empty()) {
|
||||
@@ -6632,11 +6643,16 @@ int AbilityManagerService::CheckCallDataAbilityPermission(AbilityRequest &abilit
|
||||
return ERR_WRONG_INTERFACE_CALL;
|
||||
}
|
||||
|
||||
AAFwk::PermissionVerification::VerificationInfo verificationInfo = CreateVerificationInfo(abilityRequest);
|
||||
if (IsCallFromBackground(abilityRequest, verificationInfo.isBackgroundCall) != ERR_OK) {
|
||||
AAFwk::PermissionVerification::VerificationInfo verificationInfo = CreateVerificationInfo(abilityRequest,
|
||||
true, isShell, isSACall);
|
||||
if (isShell) {
|
||||
verificationInfo.isBackgroundCall = true;
|
||||
}
|
||||
if (!isShell && IsCallFromBackground(abilityRequest, verificationInfo.isBackgroundCall, true) != ERR_OK) {
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
int result = AAFwk::PermissionVerification::GetInstance()->CheckCallDataAbilityPermission(verificationInfo);
|
||||
int result = AAFwk::PermissionVerification::GetInstance()->CheckCallDataAbilityPermission(verificationInfo,
|
||||
isShell);
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Do not have permission to start DataAbility");
|
||||
return result;
|
||||
@@ -6646,7 +6662,7 @@ int AbilityManagerService::CheckCallDataAbilityPermission(AbilityRequest &abilit
|
||||
}
|
||||
|
||||
AAFwk::PermissionVerification::VerificationInfo AbilityManagerService::CreateVerificationInfo(
|
||||
const AbilityRequest &abilityRequest)
|
||||
const AbilityRequest &abilityRequest, bool isData, bool isShell, bool isSA)
|
||||
{
|
||||
AAFwk::PermissionVerification::VerificationInfo verificationInfo;
|
||||
verificationInfo.accessTokenId = abilityRequest.appInfo.accessTokenId;
|
||||
@@ -6661,9 +6677,11 @@ AAFwk::PermissionVerification::VerificationInfo AbilityManagerService::CreateVer
|
||||
} else {
|
||||
verificationInfo.associatedWakeUp = abilityRequest.appInfo.associatedWakeUp;
|
||||
}
|
||||
if (AAFwk::PermissionVerification::GetInstance()->IsSACall() ||
|
||||
AAFwk::PermissionVerification::GetInstance()->IsShellCall()) {
|
||||
HILOG_INFO("Caller is not an application.");
|
||||
if (!isData) {
|
||||
isSA = AAFwk::PermissionVerification::GetInstance()->IsSACall();
|
||||
isShell = AAFwk::PermissionVerification::GetInstance()->IsShellCall();
|
||||
}
|
||||
if (isSA || isShell) {
|
||||
return verificationInfo;
|
||||
}
|
||||
std::shared_ptr<AbilityRecord> callerAbility = Token::GetAbilityRecordByToken(abilityRequest.callerToken);
|
||||
@@ -6783,16 +6801,17 @@ int AbilityManagerService::CheckStartByCallPermission(const AbilityRequest &abil
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int AbilityManagerService::IsCallFromBackground(const AbilityRequest &abilityRequest, bool &isBackgroundCall)
|
||||
int AbilityManagerService::IsCallFromBackground(const AbilityRequest &abilityRequest, bool &isBackgroundCall,
|
||||
bool isData)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
if (AAFwk::PermissionVerification::GetInstance()->IsShellCall()) {
|
||||
if (!isData && AAFwk::PermissionVerification::GetInstance()->IsShellCall()) {
|
||||
isBackgroundCall = true;
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
if (AAFwk::PermissionVerification::GetInstance()->IsSACall() ||
|
||||
AbilityUtil::IsStartFreeInstall(abilityRequest.want)) {
|
||||
if (!isData && (AAFwk::PermissionVerification::GetInstance()->IsSACall() ||
|
||||
AbilityUtil::IsStartFreeInstall(abilityRequest.want))) {
|
||||
isBackgroundCall = false;
|
||||
return ERR_OK;
|
||||
}
|
||||
@@ -6908,7 +6927,7 @@ bool AbilityManagerService::GetStartUpNewRuleFlag() const
|
||||
void AbilityManagerService::CallRequestDone(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &callStub)
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::mutex> autoLock(abilityTokenLock_);
|
||||
std::lock_guard<ffrt::mutex> autoLock(abilityTokenLock_);
|
||||
callStubTokenMap_[callStub] = token;
|
||||
}
|
||||
auto abilityRecord = Token::GetAbilityRecordByToken(token);
|
||||
@@ -6931,7 +6950,7 @@ void AbilityManagerService::CallRequestDone(const sptr<IRemoteObject> &token, co
|
||||
|
||||
void AbilityManagerService::GetAbilityTokenByCalleeObj(const sptr<IRemoteObject> &callStub, sptr<IRemoteObject> &token)
|
||||
{
|
||||
std::lock_guard<std::mutex> autoLock(abilityTokenLock_);
|
||||
std::lock_guard<ffrt::mutex> autoLock(abilityTokenLock_);
|
||||
auto it = callStubTokenMap_.find(callStub);
|
||||
if (it == callStubTokenMap_.end()) {
|
||||
token = nullptr;
|
||||
@@ -7005,7 +7024,7 @@ int AbilityManagerService::SetComponentInterception(
|
||||
return CHECK_PERMISSION_FAILED;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> guard(globalLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(globalLock_);
|
||||
componentInterception_ = componentInterception;
|
||||
HILOG_DEBUG("%{public}s, end", __func__);
|
||||
return ERR_OK;
|
||||
@@ -7243,8 +7262,8 @@ int32_t AbilityManagerService::ShareDataDone(
|
||||
if (!JudgeSelfCalled(abilityRecord)) {
|
||||
return CHECK_PERMISSION_FAILED;
|
||||
}
|
||||
CHECK_POINTER_AND_RETURN_LOG(handler_, ERR_INVALID_VALUE, "fail to get abilityEventHandler.");
|
||||
handler_->RemoveEvent(SHAREDATA_TIMEOUT_MSG, uniqueId);
|
||||
CHECK_POINTER_AND_RETURN_LOG(eventHandler_, ERR_INVALID_VALUE, "fail to get abilityEventHandler.");
|
||||
eventHandler_->RemoveEvent(SHAREDATA_TIMEOUT_MSG, uniqueId);
|
||||
return GetShareDataPairAndReturnData(abilityRecord, resultCode, uniqueId, wantParam);
|
||||
}
|
||||
|
||||
|
||||
@@ -297,6 +297,8 @@ void AbilityManagerStub::ThirdStepInit()
|
||||
#endif
|
||||
requestFuncMap_[static_cast<uint32_t>(AbilityManagerInterfaceCode::REQUEST_DIALOG_SERVICE)] =
|
||||
&AbilityManagerStub::HandleRequestDialogService;
|
||||
requestFuncMap_[static_cast<uint32_t>(AbilityManagerInterfaceCode::REPORT_DRAWN_COMPLETED)] =
|
||||
&AbilityManagerStub::HandleReportDrawnCompleted;
|
||||
requestFuncMap_[static_cast<uint32_t>(AbilityManagerInterfaceCode::SET_COMPONENT_INTERCEPTION)] =
|
||||
&AbilityManagerStub::SetComponentInterceptionInner;
|
||||
requestFuncMap_[static_cast<uint32_t>(AbilityManagerInterfaceCode::SEND_ABILITY_RESULT_BY_TOKEN)] =
|
||||
@@ -633,24 +635,15 @@ int AbilityManagerStub::StartExtensionAbilityInner(MessageParcel &data, MessageP
|
||||
|
||||
int AbilityManagerStub::StartUIExtensionAbilityInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
Want *want = data.ReadParcelable<Want>();
|
||||
if (want == nullptr) {
|
||||
HILOG_ERROR("want is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
sptr<SessionInfo> extensionSessionInfo = nullptr;
|
||||
if (data.ReadBool()) {
|
||||
extensionSessionInfo = data.ReadParcelable<SessionInfo>();
|
||||
}
|
||||
|
||||
int32_t userId = data.ReadInt32();
|
||||
int32_t extensionType = data.ReadInt32();
|
||||
|
||||
int32_t result = StartUIExtensionAbility(*want, extensionSessionInfo, userId,
|
||||
static_cast<AppExecFwk::ExtensionAbilityType>(extensionType));
|
||||
int32_t result = StartUIExtensionAbility(extensionSessionInfo, userId);
|
||||
reply.WriteInt32(result);
|
||||
delete want;
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
@@ -2007,6 +2000,23 @@ int AbilityManagerStub::HandleRequestDialogService(MessageParcel &data, MessageP
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AbilityManagerStub::HandleReportDrawnCompleted(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("called.");
|
||||
sptr<IRemoteObject> callerToken = data.ReadRemoteObject();
|
||||
if (callerToken == nullptr) {
|
||||
HILOG_ERROR("callerToken is invalid.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
auto result = ReportDrawnCompleted(callerToken);
|
||||
if (!reply.WriteInt32(result)) {
|
||||
HILOG_ERROR("reply write failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int AbilityManagerStub::AcquireShareDataInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int32_t missionId = data.ReadInt32();
|
||||
|
||||
@@ -360,12 +360,12 @@ void AbilityRecord::ForegroundAbility(const Closure &task, uint32_t sceneFlag)
|
||||
HILOG_INFO("name:%{public}s.", abilityInfo_.name.c_str());
|
||||
CHECK_POINTER(lifecycleDeal_);
|
||||
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
if (handler && task) {
|
||||
if (!want_.GetBoolParam(DEBUG_APP, false) && !want_.GetBoolParam(NATIVE_DEBUG, false)) {
|
||||
int foregroundTimeout =
|
||||
AmsConfigurationParameter::GetInstance().GetAppStartTimeoutTime() * FOREGROUND_TIMEOUT_MULTIPLE;
|
||||
handler->PostTask(task, "foreground_" + std::to_string(recordId_), foregroundTimeout);
|
||||
handler->SubmitTask(task, "foreground_" + std::to_string(recordId_), foregroundTimeout);
|
||||
} else {
|
||||
HILOG_INFO("Is debug mode, no need to handle time out.");
|
||||
}
|
||||
@@ -446,7 +446,8 @@ std::string AbilityRecord::GetLabel()
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
void AbilityRecord::ProcessForegroundAbility(const std::shared_ptr<AbilityRecord> &callerAbility, uint32_t sceneFlag)
|
||||
void AbilityRecord::ProcessForegroundAbility(const std::shared_ptr<AbilityRecord> &callerAbility, bool needExit,
|
||||
uint32_t sceneFlag)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
std::string element = GetWant().GetElement().GetURI();
|
||||
@@ -454,7 +455,7 @@ void AbilityRecord::ProcessForegroundAbility(const std::shared_ptr<AbilityRecord
|
||||
|
||||
StartingWindowHot();
|
||||
auto flag = !IsForeground();
|
||||
NotifyAnimationFromTerminatingAbility(callerAbility, flag);
|
||||
NotifyAnimationFromTerminatingAbility(callerAbility, needExit, flag);
|
||||
PostCancelStartingWindowHotTask();
|
||||
|
||||
if (IsAbilityState(AbilityState::FOREGROUND)) {
|
||||
@@ -469,7 +470,7 @@ void AbilityRecord::ProcessForegroundAbility(const std::shared_ptr<AbilityRecord
|
||||
}
|
||||
|
||||
void AbilityRecord::NotifyAnimationFromTerminatingAbility(const std::shared_ptr<AbilityRecord>& callerAbility,
|
||||
bool flag)
|
||||
bool needExit, bool flag)
|
||||
{
|
||||
auto windowHandler = GetWMSHandler();
|
||||
if (!windowHandler) {
|
||||
@@ -484,16 +485,18 @@ void AbilityRecord::NotifyAnimationFromTerminatingAbility(const std::shared_ptr<
|
||||
fromInfo->abilityToken_ = callerAbility->GetToken();
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
if (flag && needExit) {
|
||||
fromInfo->reason_ = TransitionReason::BACK_TRANSITION;
|
||||
} else if (flag && !needExit) {
|
||||
fromInfo->reason_ = TransitionReason::BACKGROUND_TRANSITION;
|
||||
} else {
|
||||
fromInfo->reason_ = TransitionReason::CLOSE;
|
||||
}
|
||||
|
||||
auto toInfo = CreateAbilityTransitionInfo();
|
||||
SetAbilityTransitionInfo(abilityInfo_, toInfo);
|
||||
|
||||
windowHandler->NotifyWindowTransition(fromInfo, toInfo);
|
||||
bool animaEnabled = false;
|
||||
windowHandler->NotifyWindowTransition(fromInfo, toInfo, animaEnabled);
|
||||
}
|
||||
|
||||
void AbilityRecord::NotifyAnimationFromTerminatingAbility() const
|
||||
@@ -507,7 +510,22 @@ void AbilityRecord::NotifyAnimationFromTerminatingAbility() const
|
||||
sptr<AbilityTransitionInfo> fromInfo = new AbilityTransitionInfo();
|
||||
SetAbilityTransitionInfo(fromInfo);
|
||||
fromInfo->reason_ = TransitionReason::CLOSE;
|
||||
windowHandler->NotifyWindowTransition(fromInfo, nullptr);
|
||||
bool animaEnabled = false;
|
||||
windowHandler->NotifyWindowTransition(fromInfo, nullptr, animaEnabled);
|
||||
}
|
||||
|
||||
void AbilityRecord::NotifyAnimationFromMinimizeAbility(bool& animaEnabled)
|
||||
{
|
||||
auto windowHandler = GetWMSHandler();
|
||||
if (!windowHandler) {
|
||||
HILOG_WARN("Get WMS handler failed.");
|
||||
return;
|
||||
}
|
||||
HILOG_INFO("Notify Animation From MinimizeAbility");
|
||||
sptr<AbilityTransitionInfo> fromInfo = new AbilityTransitionInfo();
|
||||
SetAbilityTransitionInfo(fromInfo);
|
||||
fromInfo->reason_ = TransitionReason::MINIMIZE;
|
||||
windowHandler->NotifyWindowTransition(fromInfo, nullptr, animaEnabled);
|
||||
}
|
||||
|
||||
void AbilityRecord::SetAbilityTransitionInfo(sptr<AbilityTransitionInfo>& info) const
|
||||
@@ -565,13 +583,13 @@ void AbilityRecord::ProcessForegroundAbility(bool isRecent, const AbilityRequest
|
||||
GrantUriPermission(want_, GetCurrentAccountId(), applicationInfo_.bundleName);
|
||||
|
||||
if (isReady_) {
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
if (!handler) {
|
||||
HILOG_ERROR("Fail to get AbilityEventHandler.");
|
||||
return;
|
||||
}
|
||||
auto taskName = std::to_string(missionId_) + "_hot";
|
||||
handler->RemoveTask(taskName);
|
||||
handler->CancelTask(taskName);
|
||||
StartingWindowTask(isRecent, false, abilityRequest, startOptions);
|
||||
AnimationTask(isRecent, abilityRequest, startOptions, callerAbility);
|
||||
PostCancelStartingWindowHotTask();
|
||||
@@ -664,7 +682,8 @@ void AbilityRecord::NotifyAnimationFromRecentTask(const std::shared_ptr<StartOpt
|
||||
SetAbilityTransitionInfo(abilityInfo_, toInfo);
|
||||
sptr<AbilityTransitionInfo> fromInfo = new AbilityTransitionInfo();
|
||||
fromInfo->isRecent_ = true;
|
||||
windowHandler->NotifyWindowTransition(fromInfo, toInfo);
|
||||
bool animaEnabled = false;
|
||||
windowHandler->NotifyWindowTransition(fromInfo, toInfo, animaEnabled);
|
||||
}
|
||||
|
||||
void AbilityRecord::NotifyAnimationFromStartingAbility(const std::shared_ptr<AbilityRecord> &callerAbility,
|
||||
@@ -689,8 +708,8 @@ void AbilityRecord::NotifyAnimationFromStartingAbility(const std::shared_ptr<Abi
|
||||
toInfo->abilityToken_ = token_;
|
||||
toInfo->missionId_ = missionId_;
|
||||
SetAbilityTransitionInfo(abilityInfo_, toInfo);
|
||||
|
||||
windowHandler->NotifyWindowTransition(fromInfo, toInfo);
|
||||
bool animaEnabled = false;
|
||||
windowHandler->NotifyWindowTransition(fromInfo, toInfo, animaEnabled);
|
||||
}
|
||||
|
||||
void AbilityRecord::StartingWindowTask(bool isRecent, bool isCold, const AbilityRequest &abilityRequest,
|
||||
@@ -723,9 +742,9 @@ void AbilityRecord::PostCancelStartingWindowHotTask()
|
||||
HILOG_INFO("PostCancelStartingWindowHotTask was called, debug mode, just return.");
|
||||
return;
|
||||
}
|
||||
HILOG_INFO("call");
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
CHECK_POINTER_LOG(handler, "Fail to get AbilityEventHandler.");
|
||||
HILOG_INFO("PostCancelStartingWindowHotTask was called.");
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
CHECK_POINTER_LOG(handler, "Fail to get TaskHandler.");
|
||||
|
||||
auto windowHandler = GetWMSHandler();
|
||||
CHECK_POINTER_LOG(windowHandler, "PostCancelStartingWindowColdTask, Get WMS handler failed.");
|
||||
@@ -742,7 +761,7 @@ void AbilityRecord::PostCancelStartingWindowHotTask()
|
||||
auto taskName = std::to_string(missionId_) + "_hot";
|
||||
int foregroundTimeout =
|
||||
AmsConfigurationParameter::GetInstance().GetAppStartTimeoutTime() * FOREGROUND_TIMEOUT_MULTIPLE;
|
||||
handler->PostTask(delayTask, taskName, foregroundTimeout);
|
||||
handler->SubmitTask(delayTask, taskName, foregroundTimeout);
|
||||
}
|
||||
|
||||
void AbilityRecord::PostCancelStartingWindowColdTask()
|
||||
@@ -753,9 +772,9 @@ void AbilityRecord::PostCancelStartingWindowColdTask()
|
||||
HILOG_INFO("PostCancelStartingWindowColdTask was called, debug mode, just return.");
|
||||
return;
|
||||
}
|
||||
HILOG_DEBUG("call");
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
CHECK_POINTER_LOG(handler, "Fail to get AbilityEventHandler.");
|
||||
HILOG_DEBUG("PostCancelStartingWindowColdTask was called.");
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
CHECK_POINTER_LOG(handler, "Fail to get TaskHandler.");
|
||||
|
||||
auto windowHandler = GetWMSHandler();
|
||||
CHECK_POINTER_LOG(windowHandler, "PostCancelStartingWindowColdTask, Get WMS handler failed.");
|
||||
@@ -772,7 +791,7 @@ void AbilityRecord::PostCancelStartingWindowColdTask()
|
||||
};
|
||||
auto taskName = std::to_string(missionId_) + "_cold";
|
||||
int loadTimeout = AmsConfigurationParameter::GetInstance().GetAppStartTimeoutTime() * LOAD_TIMEOUT_MULTIPLE;
|
||||
handler->PostTask(delayTask, taskName, loadTimeout);
|
||||
handler->SubmitTask(delayTask, taskName, loadTimeout);
|
||||
}
|
||||
|
||||
sptr<IWindowManagerServiceHandler> AbilityRecord::GetWMSHandler() const
|
||||
@@ -1018,7 +1037,7 @@ void AbilityRecord::InitColdStartingWindowResource(
|
||||
bgColor_ = 0xdfffffff;
|
||||
}
|
||||
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
if (startingWindowBg_ && handler) {
|
||||
auto delayTask = [me = weak_from_this()] {
|
||||
auto self = me.lock();
|
||||
@@ -1027,7 +1046,7 @@ void AbilityRecord::InitColdStartingWindowResource(
|
||||
}
|
||||
self->startingWindowBg_.reset();
|
||||
};
|
||||
handler->PostTask(delayTask, "release_bg", RELEASE_STARTING_BG_TIMEOUT);
|
||||
handler->SubmitTask(delayTask, "release_bg", RELEASE_STARTING_BG_TIMEOUT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1050,14 +1069,14 @@ void AbilityRecord::BackgroundAbility(const Closure &task)
|
||||
HILOG_ERROR("Move the ability to background fail, lifecycleDeal_ is null.");
|
||||
return;
|
||||
}
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
if (handler && task) {
|
||||
if (!want_.GetBoolParam(DEBUG_APP, false) &&
|
||||
!want_.GetBoolParam(NATIVE_DEBUG, false) &&
|
||||
want_.GetStringParam(PERF_CMD).empty()) {
|
||||
int backgroundTimeout =
|
||||
AmsConfigurationParameter::GetInstance().GetAppStartTimeoutTime() * BACKGROUND_TIMEOUT_MULTIPLE;
|
||||
handler->PostTask(task, "background_" + std::to_string(recordId_), backgroundTimeout);
|
||||
handler->SubmitTask(task, "background_" + std::to_string(recordId_), backgroundTimeout);
|
||||
} else {
|
||||
HILOG_INFO("Is debug mode, no need to handle time out.");
|
||||
}
|
||||
@@ -1309,18 +1328,18 @@ void AbilityRecord::Terminate(const Closure &task)
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_INFO("ability:%{public}s.", abilityInfo_.name.c_str());
|
||||
CHECK_POINTER(lifecycleDeal_);
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
if (handler && task) {
|
||||
if (!want_.GetBoolParam(DEBUG_APP, false) &&
|
||||
!want_.GetBoolParam(NATIVE_DEBUG, false) &&
|
||||
want_.GetStringParam(PERF_CMD).empty()) {
|
||||
int terminateTimeout =
|
||||
AmsConfigurationParameter::GetInstance().GetAppStartTimeoutTime() * TERMINATE_TIMEOUT_MULTIPLE;
|
||||
handler->PostTask(task, "terminate_" + std::to_string(recordId_), terminateTimeout);
|
||||
handler->SubmitTask(task, "terminate_" + std::to_string(recordId_), terminateTimeout);
|
||||
} else if (applicationInfo_.asanEnabled) {
|
||||
int terminateTimeout =
|
||||
AmsConfigurationParameter::GetInstance().GetAppStartTimeoutTime() * TERMINATE_TIMEOUT_ASANENABLED;
|
||||
handler->PostTask(task, "terminate_" + std::to_string(recordId_), terminateTimeout);
|
||||
handler->SubmitTask(task, "terminate_" + std::to_string(recordId_), terminateTimeout);
|
||||
} else {
|
||||
HILOG_INFO("Is debug mode, no need to handle time out.");
|
||||
}
|
||||
@@ -1419,7 +1438,7 @@ std::shared_ptr<AbilityResult> AbilityRecord::GetResult() const
|
||||
void AbilityRecord::SendResult(bool isSandboxApp)
|
||||
{
|
||||
HILOG_INFO("ability:%{public}s.", abilityInfo_.name.c_str());
|
||||
std::lock_guard<std::mutex> guard(lock_);
|
||||
std::lock_guard<ffrt::mutex> guard(lock_);
|
||||
CHECK_POINTER(scheduler_);
|
||||
CHECK_POINTER(result_);
|
||||
GrantUriPermission(result_->resultWant_, GetCurrentAccountId(), applicationInfo_.bundleName, isSandboxApp);
|
||||
@@ -1923,7 +1942,7 @@ void AbilityRecord::OnSchedulerDied(const wptr<IRemoteObject> &remote)
|
||||
if (mission) {
|
||||
HILOG_WARN("On scheduler died. Is app not response Reason:%{public}d", mission->IsANRState());
|
||||
}
|
||||
std::lock_guard<std::mutex> guard(lock_);
|
||||
std::lock_guard<ffrt::mutex> guard(lock_);
|
||||
CHECK_POINTER(scheduler_);
|
||||
|
||||
auto object = remote.promote();
|
||||
@@ -1948,19 +1967,19 @@ void AbilityRecord::OnSchedulerDied(const wptr<IRemoteObject> &remote)
|
||||
auto abilityManagerService = DelayedSingleton<AbilityManagerService>::GetInstance();
|
||||
CHECK_POINTER(abilityManagerService);
|
||||
|
||||
auto handler = abilityManagerService->GetEventHandler();
|
||||
auto handler = abilityManagerService->GetTaskHandler();
|
||||
CHECK_POINTER(handler);
|
||||
|
||||
HILOG_INFO("Ability on scheduler died: '%{public}s'", abilityInfo_.name.c_str());
|
||||
auto task = [abilityManagerService, ability = shared_from_this()]() {
|
||||
abilityManagerService->OnAbilityDied(ability);
|
||||
};
|
||||
handler->PostTask(task);
|
||||
handler->SubmitTask(task);
|
||||
auto uriTask = [want = want_, ability = shared_from_this()]() {
|
||||
ability->SaveResultToCallers(-1, &want);
|
||||
ability->SendResultToCallers(true);
|
||||
};
|
||||
handler->PostTask(uriTask);
|
||||
handler->SubmitTask(uriTask);
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
// notify winddow manager service the ability died
|
||||
if (missionId_ != -1) {
|
||||
@@ -2037,7 +2056,7 @@ void AbilityRecord::SendEvent(uint32_t msg, uint32_t timeOut, int32_t param)
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
CHECK_POINTER(handler);
|
||||
param = (param == -1) ? recordId_ : param;
|
||||
handler->SendEvent(msg, param, timeOut);
|
||||
handler->SendEvent(EventWrap(msg, param), timeOut);
|
||||
}
|
||||
|
||||
void AbilityRecord::SetStartSetting(const std::shared_ptr<AbilityStartSetting> &setting)
|
||||
@@ -2358,19 +2377,19 @@ void AbilityRecord::DumpClientInfo(std::vector<std::string> &info, const std::ve
|
||||
HILOG_ERROR("something nullptr.");
|
||||
return;
|
||||
}
|
||||
std::unique_lock<std::mutex> lock(dumpLock_);
|
||||
std::unique_lock<ffrt::mutex> lock(dumpLock_);
|
||||
scheduler_->DumpAbilityInfo(params, info);
|
||||
|
||||
HILOG_INFO("Dump begin wait.");
|
||||
isDumpTimeout_ = false;
|
||||
int dumpTimeout = AmsConfigurationParameter::GetInstance().GetAppStartTimeoutTime() * DUMP_TIMEOUT_MULTIPLE;
|
||||
std::chrono::milliseconds timeout { dumpTimeout };
|
||||
if (dumpCondition_.wait_for(lock, timeout) == std::cv_status::timeout) {
|
||||
if (dumpCondition_.wait_for(lock, timeout) == ffrt::cv_status::timeout) {
|
||||
isDumpTimeout_ = true;
|
||||
}
|
||||
HILOG_INFO("Dump done and begin parse.");
|
||||
if (!isDumpTimeout_) {
|
||||
std::lock_guard<std::mutex> infoLock(dumpInfoLock_);
|
||||
std::lock_guard<ffrt::mutex> infoLock(dumpInfoLock_);
|
||||
for (auto one : dumpInfos_) {
|
||||
info.emplace_back(one);
|
||||
}
|
||||
@@ -2394,7 +2413,7 @@ void AbilityRecord::DumpAbilityInfoDone(std::vector<std::string> &infos)
|
||||
return;
|
||||
}
|
||||
{
|
||||
std::lock_guard<std::mutex> infoLock(dumpInfoLock_);
|
||||
std::lock_guard<ffrt::mutex> infoLock(dumpInfoLock_);
|
||||
dumpInfos_.clear();
|
||||
for (auto info : infos) {
|
||||
dumpInfos_.emplace_back(info);
|
||||
@@ -2460,7 +2479,7 @@ void AbilityRecord::GrantUriPermission(Want &want, int32_t userId, std::string t
|
||||
int autoremove = 1;
|
||||
auto ret = IN_PROCESS_CALL(
|
||||
AAFwk::UriPermissionManagerClient::GetInstance().GrantUriPermission(uri, want.GetFlags(),
|
||||
targetBundleName, autoremove));
|
||||
targetBundleName, autoremove, appIndex_));
|
||||
if (ret == 0) {
|
||||
isGrantedUriPermission_ = true;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#include "ability_manager_errors.h"
|
||||
#include "ability_connect_callback_stub.h"
|
||||
#include "ability_util.h"
|
||||
#include "ability_event_handler.h"
|
||||
#include "ability_manager_service.h"
|
||||
|
||||
namespace OHOS {
|
||||
@@ -114,12 +113,12 @@ void CallContainer::OnConnectionDied(const wptr<IRemoteObject> &remote)
|
||||
|
||||
auto abilityManagerService = DelayedSingleton<AbilityManagerService>::GetInstance();
|
||||
CHECK_POINTER(abilityManagerService);
|
||||
auto handler = abilityManagerService->GetEventHandler();
|
||||
auto handler = abilityManagerService->GetTaskHandler();
|
||||
CHECK_POINTER(handler);
|
||||
auto task = [abilityManagerService, callRecord]() {
|
||||
abilityManagerService->OnCallConnectDied(callRecord);
|
||||
};
|
||||
handler->PostTask(task);
|
||||
handler->SubmitTask(task);
|
||||
}
|
||||
|
||||
bool CallContainer::CallRequestDone(const sptr<IRemoteObject> &callStub)
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
#include "hilog_wrapper.h"
|
||||
#include "ability_util.h"
|
||||
#include "ability_event_handler.h"
|
||||
#include "ability_manager_service.h"
|
||||
#include "ability_record.h"
|
||||
#include "element_name.h"
|
||||
@@ -161,12 +160,12 @@ void CallRecord::OnCallStubDied(const wptr<IRemoteObject> &remote)
|
||||
|
||||
auto abilityManagerService = DelayedSingleton<AbilityManagerService>::GetInstance();
|
||||
CHECK_POINTER(abilityManagerService);
|
||||
auto handler = abilityManagerService->GetEventHandler();
|
||||
auto handler = abilityManagerService->GetTaskHandler();
|
||||
CHECK_POINTER(handler);
|
||||
auto task = [abilityManagerService, callRecord = shared_from_this()]() {
|
||||
abilityManagerService->OnCallConnectDied(callRecord);
|
||||
};
|
||||
handler->PostTask(task);
|
||||
handler->SubmitTask(task);
|
||||
HILOG_DEBUG("callstub is died. id:%{public}d, end", recordId_);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ int ConnectionObserverController::AddObserver(const sptr<AbilityRuntime::IConnec
|
||||
return AbilityRuntime::ERR_INVALID_OBSERVER;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> guard(observerLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(observerLock_);
|
||||
auto it = std::find_if(observers_.begin(), observers_.end(), [&observer](const sptr<IConnectionObserver> &item) {
|
||||
return (item && item->AsObject() == observer->AsObject());
|
||||
});
|
||||
@@ -63,7 +63,7 @@ void ConnectionObserverController::RemoveObserver(const sptr<AbilityRuntime::ICo
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> guard(observerLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(observerLock_);
|
||||
auto it = std::find_if(observers_.begin(), observers_.end(), [&observer](const sptr<IConnectionObserver> item) {
|
||||
return (item && item->AsObject() == observer->AsObject());
|
||||
});
|
||||
@@ -94,7 +94,7 @@ void ConnectionObserverController::NotifyDlpAbilityClosed(const AbilityRuntime::
|
||||
|
||||
std::vector<sptr<AbilityRuntime::IConnectionObserver>> ConnectionObserverController::GetObservers()
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(observerLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(observerLock_);
|
||||
return observers_;
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ void ConnectionObserverController::HandleRemoteDied(const wptr<IRemoteObject> &r
|
||||
}
|
||||
remoteObj->RemoveDeathRecipient(observerDeathRecipient_);
|
||||
|
||||
std::lock_guard<std::mutex> guard(observerLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(observerLock_);
|
||||
auto it = std::find_if(observers_.begin(), observers_.end(), [&remoteObj](const sptr<IConnectionObserver> item) {
|
||||
return (item && item->AsObject() == remoteObj);
|
||||
});
|
||||
|
||||
@@ -97,10 +97,10 @@ int ConnectionRecord::DisconnectAbility()
|
||||
CHECK_POINTER_AND_RETURN(targetService_, ERR_INVALID_VALUE);
|
||||
std::size_t connectNums = targetService_->GetConnectRecordList().size();
|
||||
if (connectNums == 1) {
|
||||
/* post timeout task to eventhandler */
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
/* post timeout task to taskhandler */
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
if (handler == nullptr) {
|
||||
HILOG_ERROR("fail to get AbilityEventHandler");
|
||||
HILOG_ERROR("fail to get TaskHandler");
|
||||
} else {
|
||||
std::string taskName("DisconnectTimeout_");
|
||||
taskName += std::to_string(recordId_);
|
||||
@@ -110,7 +110,7 @@ int ConnectionRecord::DisconnectAbility()
|
||||
};
|
||||
int disconnectTimeout =
|
||||
AmsConfigurationParameter::GetInstance().GetAppStartTimeoutTime() * DISCONNECT_TIMEOUT_MULTIPLE;
|
||||
handler->PostTask(disconnectTask, taskName, disconnectTimeout);
|
||||
handler->SubmitTask(disconnectTask, taskName, disconnectTimeout);
|
||||
}
|
||||
/* schedule disconnect to target ability */
|
||||
targetService_->DisconnectAbility();
|
||||
@@ -161,12 +161,12 @@ void ConnectionRecord::CompleteDisconnect(int resultCode, bool isDied)
|
||||
}
|
||||
connCallback->OnAbilityDisconnectDone(element, code);
|
||||
};
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
if (handler == nullptr) {
|
||||
HILOG_ERROR("handler is nullptr.");
|
||||
return;
|
||||
}
|
||||
handler->PostTask(onDisconnectDoneTask);
|
||||
handler->SubmitTask(onDisconnectDoneTask);
|
||||
DelayedSingleton<ConnectionStateManager>::GetInstance()->RemoveConnection(shared_from_this(), isDied);
|
||||
HILOG_INFO("result: %{public}d. connectState:%{public}d.", resultCode, state_);
|
||||
}
|
||||
@@ -178,12 +178,12 @@ void ConnectionRecord::ScheduleDisconnectAbilityDone()
|
||||
return;
|
||||
}
|
||||
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
if (handler == nullptr) {
|
||||
HILOG_ERROR("fail to get AbilityEventHandler");
|
||||
HILOG_ERROR("fail to get AbilityTaskHandler");
|
||||
} else {
|
||||
std::string taskName = std::string("DisconnectTimeout_") + std::to_string(recordId_);
|
||||
handler->RemoveTask(taskName);
|
||||
handler->CancelTask(taskName);
|
||||
}
|
||||
|
||||
CompleteDisconnect(ERR_OK, false);
|
||||
@@ -195,12 +195,12 @@ void ConnectionRecord::ScheduleConnectAbilityDone()
|
||||
HILOG_ERROR("fail to schedule connect ability done, current state is not connecting.");
|
||||
return;
|
||||
}
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
if (handler == nullptr) {
|
||||
HILOG_ERROR("fail to get AbilityEventHandler");
|
||||
HILOG_ERROR("fail to get AbilityTaskHandler");
|
||||
} else {
|
||||
std::string taskName = std::string("ConnectTimeout_") + std::to_string(recordId_);
|
||||
handler->RemoveTask(taskName);
|
||||
handler->CancelTask(taskName);
|
||||
}
|
||||
|
||||
CompleteConnect(ERR_OK);
|
||||
|
||||
@@ -59,7 +59,7 @@ std::string ConnectionStateManager::GetProcessNameByPid(int32_t pid)
|
||||
return name;
|
||||
}
|
||||
|
||||
void ConnectionStateManager::Init(const std::shared_ptr<AppExecFwk::EventHandler> &handler)
|
||||
void ConnectionStateManager::Init(const std::shared_ptr<TaskHandlerWrap> &handler)
|
||||
{
|
||||
if (!observerController_) {
|
||||
observerController_ = std::make_shared<ConnectionObserverController>();
|
||||
@@ -78,7 +78,7 @@ void ConnectionStateManager::Init(const std::shared_ptr<AppExecFwk::EventHandler
|
||||
}
|
||||
self->InitAppStateObserver();
|
||||
};
|
||||
handler->PostTask(initConnectionStateManagerTask, "InitConnectionStateManager");
|
||||
handler->SubmitTask(initConnectionStateManagerTask, "InitConnectionStateManager");
|
||||
}
|
||||
|
||||
int ConnectionStateManager::RegisterObserver(const sptr<AbilityRuntime::IConnectionObserver> &observer)
|
||||
@@ -244,7 +244,7 @@ void ConnectionStateManager::AddDlpManager(const std::shared_ptr<AbilityRecord>
|
||||
}
|
||||
|
||||
auto userId = dlpManger->GetOwnerMissionUserId();
|
||||
std::lock_guard<std::mutex> guard(dlpLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(dlpLock_);
|
||||
auto it = dlpItems_.find(userId);
|
||||
if (it == dlpItems_.end()) {
|
||||
dlpItems_[userId] = std::make_shared<DlpStateItem>(dlpManger->GetUid(), dlpManger->GetPid());
|
||||
@@ -257,7 +257,7 @@ void ConnectionStateManager::RemoveDlpManager(const std::shared_ptr<AbilityRecor
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> guard(dlpLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(dlpLock_);
|
||||
dlpItems_.erase(dlpManger->GetOwnerMissionUserId());
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ void ConnectionStateManager::HandleAppDied(int32_t pid)
|
||||
|
||||
void ConnectionStateManager::GetDlpConnectionInfos(std::vector<AbilityRuntime::DlpConnectionInfo> &infos)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(dlpLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(dlpLock_);
|
||||
for (auto it = dlpItems_.begin(); it != dlpItems_.end(); it++) {
|
||||
auto item = it->second;
|
||||
if (!item) {
|
||||
@@ -317,7 +317,7 @@ bool ConnectionStateManager::AddConnectionInner(const std::shared_ptr<Connection
|
||||
{
|
||||
std::shared_ptr<ConnectionStateItem> targetItem = nullptr;
|
||||
auto callerPid = connectionRecord->GetCallerPid();
|
||||
std::lock_guard<std::mutex> guard(stateLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(stateLock_);
|
||||
auto it = connectionStates_.find(callerPid);
|
||||
if (it == connectionStates_.end()) {
|
||||
targetItem = ConnectionStateItem::CreateConnectionStateItem(connectionRecord);
|
||||
@@ -340,7 +340,7 @@ bool ConnectionStateManager::RemoveConnectionInner(const std::shared_ptr<Connect
|
||||
AbilityRuntime::ConnectionData &data)
|
||||
{
|
||||
auto callerPid = connectionRecord->GetCallerPid();
|
||||
std::lock_guard<std::mutex> guard(stateLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(stateLock_);
|
||||
auto it = connectionStates_.find(callerPid);
|
||||
if (it == connectionStates_.end()) {
|
||||
HILOG_WARN("can not find target item, connection caller pid:%{public}d.", callerPid);
|
||||
@@ -387,7 +387,7 @@ void ConnectionStateManager::HandleCallerDied(int32_t callerPid)
|
||||
|
||||
std::shared_ptr<ConnectionStateItem> ConnectionStateManager::RemoveDiedCaller(int32_t callerPid)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(stateLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(stateLock_);
|
||||
auto it = connectionStates_.find(callerPid);
|
||||
if (it == connectionStates_.end()) {
|
||||
HILOG_WARN("connection caller pid:%{public}d.", callerPid);
|
||||
@@ -403,7 +403,7 @@ bool ConnectionStateManager::AddDataAbilityConnectionInner(const DataAbilityCall
|
||||
const std::shared_ptr<DataAbilityRecord> &record, ConnectionData &data)
|
||||
{
|
||||
std::shared_ptr<ConnectionStateItem> targetItem = nullptr;
|
||||
std::lock_guard<std::mutex> guard(stateLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(stateLock_);
|
||||
auto it = connectionStates_.find(caller.callerPid);
|
||||
if (it == connectionStates_.end()) {
|
||||
targetItem = ConnectionStateItem::CreateConnectionStateItem(caller);
|
||||
@@ -425,7 +425,7 @@ bool ConnectionStateManager::AddDataAbilityConnectionInner(const DataAbilityCall
|
||||
bool ConnectionStateManager::RemoveDataAbilityConnectionInner(const DataAbilityCaller &caller,
|
||||
const std::shared_ptr<DataAbilityRecord> &record, AbilityRuntime::ConnectionData &data)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(stateLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(stateLock_);
|
||||
auto it = connectionStates_.find(caller.callerPid);
|
||||
if (it == connectionStates_.end()) {
|
||||
HILOG_WARN("can not find target item, connection caller pid:%{public}d.", caller.callerPid);
|
||||
@@ -448,7 +448,7 @@ bool ConnectionStateManager::RemoveDataAbilityConnectionInner(const DataAbilityC
|
||||
void ConnectionStateManager::HandleDataAbilityDiedInner(const sptr<IRemoteObject> &abilityToken,
|
||||
std::vector<AbilityRuntime::ConnectionData> &allData)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(stateLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(stateLock_);
|
||||
for (auto it = connectionStates_.begin(); it != connectionStates_.end();) {
|
||||
auto item = it->second;
|
||||
if (!item) {
|
||||
@@ -482,7 +482,7 @@ bool ConnectionStateManager::HandleDlpAbilityInner(const std::shared_ptr<Ability
|
||||
return false;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> guard(dlpLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(dlpLock_);
|
||||
auto it = dlpItems_.find(dlpAbility->GetOwnerMissionUserId());
|
||||
if (it == dlpItems_.end()) {
|
||||
HILOG_WARN("no dlp manager, invalid state.");
|
||||
@@ -520,7 +520,7 @@ void ConnectionStateManager::InitAppStateObserver()
|
||||
}
|
||||
self->InitAppStateObserver();
|
||||
};
|
||||
handler_->PostTask(initConnectionStateManagerTask, "InitConnectionStateManager", DELAY_TIME);
|
||||
handler_->SubmitTask(initConnectionStateManagerTask, "InitConnectionStateManager", DELAY_TIME);
|
||||
retry_++;
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -73,7 +73,7 @@ sptr<IAbilityScheduler> DataAbilityManager::Acquire(
|
||||
HILOG_INFO("Loading data ability '%{public}s'...", dataAbilityName.c_str());
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> locker(mutex_);
|
||||
std::lock_guard<ffrt::mutex> locker(mutex_);
|
||||
|
||||
if (DEBUG_ENABLED) {
|
||||
DumpLocked(__func__, __LINE__);
|
||||
@@ -128,7 +128,7 @@ int DataAbilityManager::Release(
|
||||
CHECK_POINTER_AND_RETURN(scheduler, ERR_NULL_OBJECT);
|
||||
CHECK_POINTER_AND_RETURN(client, ERR_NULL_OBJECT);
|
||||
|
||||
std::lock_guard<std::mutex> locker(mutex_);
|
||||
std::lock_guard<ffrt::mutex> locker(mutex_);
|
||||
|
||||
if (DEBUG_ENABLED) {
|
||||
DumpLocked(__func__, __LINE__);
|
||||
@@ -182,7 +182,7 @@ bool DataAbilityManager::ContainsDataAbility(const sptr<IAbilityScheduler> &sche
|
||||
|
||||
CHECK_POINTER_AND_RETURN(scheduler, ERR_NULL_OBJECT);
|
||||
|
||||
std::lock_guard<std::mutex> locker(mutex_);
|
||||
std::lock_guard<ffrt::mutex> locker(mutex_);
|
||||
for (auto it = dataAbilityRecordsLoaded_.begin(); it != dataAbilityRecordsLoaded_.end(); ++it) {
|
||||
if (it->second && it->second->GetScheduler() &&
|
||||
it->second->GetScheduler()->AsObject() == scheduler->AsObject()) {
|
||||
@@ -200,7 +200,7 @@ int DataAbilityManager::AttachAbilityThread(const sptr<IAbilityScheduler> &sched
|
||||
CHECK_POINTER_AND_RETURN(scheduler, ERR_NULL_OBJECT);
|
||||
CHECK_POINTER_AND_RETURN(token, ERR_NULL_OBJECT);
|
||||
|
||||
std::lock_guard<std::mutex> locker(mutex_);
|
||||
std::lock_guard<ffrt::mutex> locker(mutex_);
|
||||
|
||||
if (DEBUG_ENABLED) {
|
||||
DumpLocked(__func__, __LINE__);
|
||||
@@ -249,7 +249,7 @@ int DataAbilityManager::AbilityTransitionDone(const sptr<IRemoteObject> &token,
|
||||
|
||||
CHECK_POINTER_AND_RETURN(token, ERR_NULL_OBJECT);
|
||||
|
||||
std::lock_guard<std::mutex> locker(mutex_);
|
||||
std::lock_guard<ffrt::mutex> locker(mutex_);
|
||||
|
||||
if (DEBUG_ENABLED) {
|
||||
DumpLocked(__func__, __LINE__);
|
||||
@@ -295,7 +295,7 @@ void DataAbilityManager::OnAbilityDied(const std::shared_ptr<AbilityRecord> &abi
|
||||
CHECK_POINTER(abilityRecord);
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> locker(mutex_);
|
||||
std::lock_guard<ffrt::mutex> locker(mutex_);
|
||||
if (DEBUG_ENABLED) {
|
||||
DumpLocked(__func__, __LINE__);
|
||||
}
|
||||
@@ -332,7 +332,7 @@ void DataAbilityManager::OnAbilityDied(const std::shared_ptr<AbilityRecord> &abi
|
||||
|
||||
void DataAbilityManager::OnAppStateChanged(const AppInfo &info)
|
||||
{
|
||||
std::lock_guard<std::mutex> locker(mutex_);
|
||||
std::lock_guard<ffrt::mutex> locker(mutex_);
|
||||
|
||||
for (auto it = dataAbilityRecordsLoaded_.begin(); it != dataAbilityRecordsLoaded_.end(); ++it) {
|
||||
if (!it->second) {
|
||||
@@ -375,7 +375,7 @@ std::shared_ptr<AbilityRecord> DataAbilityManager::GetAbilityRecordById(int64_t
|
||||
{
|
||||
HILOG_DEBUG("Call.");
|
||||
|
||||
std::lock_guard<std::mutex> locker(mutex_);
|
||||
std::lock_guard<ffrt::mutex> locker(mutex_);
|
||||
|
||||
for (auto it = dataAbilityRecordsLoaded_.begin(); it != dataAbilityRecordsLoaded_.end(); ++it) {
|
||||
if (!it->second) {
|
||||
@@ -396,7 +396,7 @@ std::shared_ptr<AbilityRecord> DataAbilityManager::GetAbilityRecordByToken(const
|
||||
|
||||
CHECK_POINTER_AND_RETURN(token, nullptr);
|
||||
|
||||
std::lock_guard<std::mutex> locker(mutex_);
|
||||
std::lock_guard<ffrt::mutex> locker(mutex_);
|
||||
for (auto it = dataAbilityRecordsLoaded_.begin(); it != dataAbilityRecordsLoaded_.end(); ++it) {
|
||||
if (!it->second) {
|
||||
continue;
|
||||
@@ -424,7 +424,7 @@ std::shared_ptr<AbilityRecord> DataAbilityManager::GetAbilityRecordByScheduler(c
|
||||
|
||||
CHECK_POINTER_AND_RETURN(scheduler, nullptr);
|
||||
|
||||
std::lock_guard<std::mutex> locker(mutex_);
|
||||
std::lock_guard<ffrt::mutex> locker(mutex_);
|
||||
|
||||
for (auto it = dataAbilityRecordsLoaded_.begin(); it != dataAbilityRecordsLoaded_.end(); ++it) {
|
||||
if (it->second && it->second->GetScheduler() &&
|
||||
@@ -440,7 +440,7 @@ void DataAbilityManager::Dump(const char *func, int line)
|
||||
{
|
||||
HILOG_DEBUG("Call.");
|
||||
|
||||
std::lock_guard<std::mutex> locker(mutex_);
|
||||
std::lock_guard<ffrt::mutex> locker(mutex_);
|
||||
|
||||
DumpLocked(func, line);
|
||||
}
|
||||
@@ -599,7 +599,7 @@ void DataAbilityManager::DumpSysState(std::vector<std::string> &info, bool isCli
|
||||
void DataAbilityManager::GetAbilityRunningInfos(std::vector<AbilityRunningInfo> &info, bool isPerm)
|
||||
{
|
||||
HILOG_INFO("Get ability running infos");
|
||||
std::lock_guard<std::mutex> locker(mutex_);
|
||||
std::lock_guard<ffrt::mutex> locker(mutex_);
|
||||
|
||||
auto queryInfo = [&info, isPerm](DataAbilityRecordPtrMap::reference data) {
|
||||
auto dataAbilityRecord = data.second;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "data_ability_record.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <mutex>
|
||||
|
||||
#include "ability_util.h"
|
||||
#include "app_scheduler.h"
|
||||
@@ -71,7 +72,7 @@ int DataAbilityRecord::StartLoading()
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int DataAbilityRecord::WaitForLoaded(std::mutex &mutex, const std::chrono::system_clock::duration &timeout)
|
||||
int DataAbilityRecord::WaitForLoaded(ffrt::mutex &mutex, const std::chrono::system_clock::duration &timeout)
|
||||
{
|
||||
CHECK_POINTER_AND_RETURN(ability_, ERR_INVALID_STATE);
|
||||
|
||||
@@ -80,7 +81,8 @@ int DataAbilityRecord::WaitForLoaded(std::mutex &mutex, const std::chrono::syste
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
auto ret = loadedCond_.wait_for(mutex, timeout, [this] { return ability_->GetAbilityState() == ACTIVE; });
|
||||
std::unique_lock<ffrt::mutex> lock(mutex, std::adopt_lock);
|
||||
auto ret = loadedCond_.wait_for(lock, timeout, [this] { return ability_->GetAbilityState() == ACTIVE; });
|
||||
if (!ret) {
|
||||
return ERR_TIMED_OUT;
|
||||
}
|
||||
@@ -226,16 +228,6 @@ int DataAbilityRecord::AddClient(const sptr<IRemoteObject> &client, bool tryBind
|
||||
clientInfo.tryBind = tryBind;
|
||||
clientInfo.isNotHap = isNotHap;
|
||||
clientInfo.clientPid = IPCSkeleton::GetCallingPid();
|
||||
if (!isNotHap) {
|
||||
auto clientAbilityRecord = Token::GetAbilityRecordByToken(client);
|
||||
CHECK_POINTER_AND_RETURN(clientAbilityRecord, ERR_UNKNOWN_OBJECT);
|
||||
appScheduler->AbilityBehaviorAnalysis(ability_->GetToken(), clientAbilityRecord->GetToken(), 0, 0, 1);
|
||||
HILOG_INFO("Ability '%{public}s|%{public}s'.", clientAbilityRecord->GetApplicationInfo().bundleName.c_str(),
|
||||
clientAbilityRecord->GetAbilityInfo().name.c_str());
|
||||
}
|
||||
|
||||
HILOG_INFO("Data ability '%{public}s|%{public}s'.", ability_->GetApplicationInfo().bundleName.c_str(),
|
||||
ability_->GetAbilityInfo().name.c_str());
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ int FreeInstallManager::StartFreeInstall(const Want &want, int32_t userId, int r
|
||||
}
|
||||
FreeInstallInfo info = BuildFreeInstallInfo(want, userId, requestCode, callerToken, isAsync);
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(freeInstallListLock_);
|
||||
std::lock_guard<ffrt::mutex> lock(freeInstallListLock_);
|
||||
freeInstallList_.push_back(info);
|
||||
}
|
||||
sptr<AtomicServiceStatusCallback> callback = new AtomicServiceStatusCallback(weak_from_this(), isAsync);
|
||||
@@ -142,7 +142,7 @@ int FreeInstallManager::RemoteFreeInstall(const Want &want, int32_t userId, int
|
||||
}
|
||||
FreeInstallInfo info = BuildFreeInstallInfo(want, userId, requestCode, callerToken, false);
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(freeInstallListLock_);
|
||||
std::lock_guard<ffrt::mutex> lock(freeInstallListLock_);
|
||||
freeInstallList_.push_back(info);
|
||||
}
|
||||
sptr<AtomicServiceStatusCallback> callback = new AtomicServiceStatusCallback(weak_from_this(), false);
|
||||
@@ -203,7 +203,7 @@ int FreeInstallManager::StartRemoteFreeInstall(const Want &want, int requestCode
|
||||
int FreeInstallManager::NotifyDmsCallback(const Want &want, int resultCode)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
std::lock_guard<std::mutex> autoLock(distributedFreeInstallLock_);
|
||||
std::lock_guard<ffrt::mutex> autoLock(distributedFreeInstallLock_);
|
||||
if (dmsFreeInstallCbs_.empty()) {
|
||||
HILOG_ERROR("Has no dms callback.");
|
||||
return ERR_INVALID_VALUE;
|
||||
@@ -250,7 +250,7 @@ int FreeInstallManager::NotifyDmsCallback(const Want &want, int resultCode)
|
||||
void FreeInstallManager::NotifyFreeInstallResult(const Want &want, int resultCode, bool isAsync)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
std::lock_guard<std::mutex> lock(freeInstallListLock_);
|
||||
std::lock_guard<ffrt::mutex> lock(freeInstallListLock_);
|
||||
if (freeInstallList_.empty()) {
|
||||
HILOG_INFO("Has no app callback.");
|
||||
return;
|
||||
@@ -321,7 +321,7 @@ int FreeInstallManager::FreeInstallAbilityFromRemote(const Want &want, const spt
|
||||
};
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> autoLock(distributedFreeInstallLock_);
|
||||
std::lock_guard<ffrt::mutex> autoLock(distributedFreeInstallLock_);
|
||||
dmsFreeInstallCbs_.push_back(info);
|
||||
}
|
||||
|
||||
@@ -421,10 +421,9 @@ void FreeInstallManager::PostUpgradeAtomicServiceTask(int resultCode, const Want
|
||||
}
|
||||
};
|
||||
|
||||
std::shared_ptr<AbilityEventHandler> handler =
|
||||
DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
CHECK_POINTER_LOG(handler, "Fail to get AbilityEventHandler.");
|
||||
handler->PostTask(updateAtmoicServiceTask, "UpdateAtmoicServiceTask");
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
CHECK_POINTER_LOG(handler, "Fail to get Ability task handler.");
|
||||
handler->SubmitTask(updateAtmoicServiceTask, "UpdateAtmoicServiceTask");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -458,10 +457,9 @@ void FreeInstallManager::PostTimeoutTask(const Want &want)
|
||||
};
|
||||
std::string taskName = std::string("FreeInstallTimeout_") + bundleName + std::string("_") +
|
||||
abilityName + std::string("_") + startTime;
|
||||
std::shared_ptr<AbilityEventHandler> handler =
|
||||
DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
CHECK_POINTER_LOG(handler, "Fail to get AbilityEventHandler.");
|
||||
handler->PostTask(task, taskName, DELAY_LOCAL_FREE_INSTALL_TIMEOUT);
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
CHECK_POINTER_LOG(handler, "Fail to get AbilityTaskHandler.");
|
||||
handler->SubmitTask(task, taskName, DELAY_LOCAL_FREE_INSTALL_TIMEOUT);
|
||||
}
|
||||
|
||||
void FreeInstallManager::RemoveTimeoutTask(const std::string &bundleName, const std::string &abilityName,
|
||||
@@ -471,10 +469,9 @@ void FreeInstallManager::RemoveTimeoutTask(const std::string &bundleName, const
|
||||
std::string taskName = std::string("FreeInstallTimeout_") + bundleName + std::string("_") +
|
||||
abilityName + std::string("_") + startTime;
|
||||
HILOG_INFO("RemoveTimeoutTask task name:%{public}s", taskName.c_str());
|
||||
std::shared_ptr<AbilityEventHandler> handler =
|
||||
DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
CHECK_POINTER_LOG(handler, "Fail to get AbilityEventHandler.");
|
||||
handler->RemoveTask(taskName);
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
CHECK_POINTER_LOG(handler, "Fail to get AbilityTaskHandler.");
|
||||
handler->CancelTask(taskName);
|
||||
}
|
||||
|
||||
void FreeInstallManager::OnRemoveTimeoutTask(const Want &want)
|
||||
@@ -499,7 +496,7 @@ void FreeInstallManager::OnRemoveTimeoutTask(const Want &want)
|
||||
void FreeInstallManager::RemoveFreeInstallInfo(const std::string &bundleName, const std::string &abilityName,
|
||||
const std::string &startTime)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(freeInstallListLock_);
|
||||
std::lock_guard<ffrt::mutex> lock(freeInstallListLock_);
|
||||
for (auto it = freeInstallList_.begin(); it != freeInstallList_.end();) {
|
||||
if ((*it).want.GetElement().GetBundleName() == bundleName &&
|
||||
(*it).want.GetElement().GetAbilityName() == abilityName &&
|
||||
|
||||
@@ -12,14 +12,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "free_install_observer_manager.h"
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include "ability_event_handler.h"
|
||||
#include "ability_manager_service.h"
|
||||
#include "ability_manager_errors.h"
|
||||
#include "free_install_observer_manager.h"
|
||||
#include "free_install_observer_interface.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
@@ -37,7 +36,7 @@ int32_t FreeInstallObserverManager::AddObserver(const sptr<IFreeInstallObserver>
|
||||
HILOG_ERROR("the observer is nullptr.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
std::lock_guard<std::mutex> lock(observerLock_);
|
||||
std::lock_guard<ffrt::mutex> lock(observerLock_);
|
||||
if (ObserverExistLocked(observer)) {
|
||||
HILOG_ERROR("Observer exist.");
|
||||
return ERR_INVALID_VALUE;
|
||||
@@ -72,7 +71,7 @@ int32_t FreeInstallObserverManager::RemoveObserver(const sptr<IFreeInstallObserv
|
||||
HILOG_ERROR("the observer is nullptr.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
std::lock_guard<std::mutex> lock(observerLock_);
|
||||
std::lock_guard<ffrt::mutex> lock(observerLock_);
|
||||
auto it = std::find_if(observerList_.begin(), observerList_.end(),
|
||||
[&observer](const sptr<IFreeInstallObserver> &item) {
|
||||
return (item && item->AsObject() == observer->AsObject());
|
||||
@@ -99,10 +98,9 @@ void FreeInstallObserverManager::OnInstallFinished(const std::string &bundleName
|
||||
self->HandleOnInstallFinished(bundleName, abilityName, startTime, resultCode);
|
||||
};
|
||||
|
||||
std::shared_ptr<AbilityEventHandler> handler =
|
||||
DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
CHECK_POINTER_LOG(handler, "Fail to get AbilityEventHandler.");
|
||||
handler->PostTask(task);
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
CHECK_POINTER_LOG(handler, "Fail to get Ability task handler.");
|
||||
handler->SubmitTask(task);
|
||||
}
|
||||
|
||||
void FreeInstallObserverManager::HandleOnInstallFinished(const std::string &bundleName, const std::string &abilityName,
|
||||
@@ -141,7 +139,7 @@ void FreeInstallObserverManager::OnObserverDied(const wptr<IRemoteObject> &remot
|
||||
}
|
||||
remoteObj->RemoveDeathRecipient(deathRecipient_);
|
||||
|
||||
std::lock_guard<std::mutex> lock(observerLock_);
|
||||
std::lock_guard<ffrt::mutex> lock(observerLock_);
|
||||
auto it = std::find_if(observerList_.begin(), observerList_.end(), [&remoteObj]
|
||||
(const sptr<IFreeInstallObserver> item) {
|
||||
return (item && item->AsObject() == remoteObj);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "mission_data_storage.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include "directory_ex.h"
|
||||
#include "file_ex.h"
|
||||
#include "hilog_wrapper.h"
|
||||
@@ -77,11 +77,6 @@ MissionDataStorage::MissionDataStorage(int userId)
|
||||
MissionDataStorage::~MissionDataStorage()
|
||||
{}
|
||||
|
||||
void MissionDataStorage::SetEventHandler(const std::shared_ptr<AppExecFwk::EventHandler> &handler)
|
||||
{
|
||||
handler_ = handler;
|
||||
}
|
||||
|
||||
bool MissionDataStorage::LoadAllMissionInfo(std::list<InnerMissionInfo> &missionInfoList)
|
||||
{
|
||||
std::vector<std::string> fileNameVec;
|
||||
@@ -308,7 +303,7 @@ std::shared_ptr<OHOS::Media::PixelMap> MissionDataStorage::GetReducedPixelMap(
|
||||
|
||||
bool MissionDataStorage::GetCachedSnapshot(int32_t missionId, MissionSnapshot& missionSnapshot)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(cachedPixelMapMutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(cachedPixelMapMutex_);
|
||||
auto pixelMap = cachedPixelMap_.find(missionId);
|
||||
if (pixelMap != cachedPixelMap_.end()) {
|
||||
missionSnapshot.snapshot = pixelMap->second;
|
||||
@@ -319,7 +314,7 @@ bool MissionDataStorage::GetCachedSnapshot(int32_t missionId, MissionSnapshot& m
|
||||
|
||||
bool MissionDataStorage::SaveCachedSnapshot(int32_t missionId, const MissionSnapshot& missionSnapshot)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(cachedPixelMapMutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(cachedPixelMapMutex_);
|
||||
auto result = cachedPixelMap_.insert_or_assign(missionId, missionSnapshot.snapshot);
|
||||
if (!result.second) {
|
||||
HILOG_ERROR("snapshot: save snapshot cache failed, missionId = %{public}d", missionId);
|
||||
@@ -330,7 +325,7 @@ bool MissionDataStorage::SaveCachedSnapshot(int32_t missionId, const MissionSnap
|
||||
|
||||
bool MissionDataStorage::DeleteCachedSnapshot(int32_t missionId)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(cachedPixelMapMutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(cachedPixelMapMutex_);
|
||||
auto result = cachedPixelMap_.erase(missionId);
|
||||
if (result != 1) {
|
||||
HILOG_ERROR("snapshot: delete snapshot cache failed, missionId = %{public}d", missionId);
|
||||
@@ -363,6 +358,51 @@ std::shared_ptr<Media::PixelMap> MissionDataStorage::GetSnapshot(int missionId,
|
||||
return std::shared_ptr<Media::PixelMap>(pixelMapPtr.release());
|
||||
}
|
||||
|
||||
std::unique_ptr<uint8_t[]> MissionDataStorage::ReadFileToBuffer(const std::string &filePath, size_t &bufferSize) const
|
||||
{
|
||||
struct stat statbuf;
|
||||
int ret = stat(filePath.c_str(), &statbuf);
|
||||
if (ret != 0) {
|
||||
HILOG_ERROR("GetPixelMap: get the file size failed, ret:%{public}d.", ret);
|
||||
return nullptr;
|
||||
}
|
||||
bufferSize = statbuf.st_size;
|
||||
std::string realPath;
|
||||
if (!OHOS::PathToRealPath(filePath, realPath)) {
|
||||
HILOG_ERROR("ReadFileToBuffer:file path to real path failed, file path=%{public}s.", filePath.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<uint8_t[]> buffer = std::make_unique<uint8_t[]>(bufferSize);
|
||||
if (buffer == nullptr) {
|
||||
HILOG_ERROR("ReadFileToBuffer:buffer is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FILE *fp = fopen(realPath.c_str(), "rb");
|
||||
if (fp == nullptr) {
|
||||
HILOG_ERROR("ReadFileToBuffer:open file failed, real path=%{public}s.", realPath.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
fseek(fp, 0, SEEK_END);
|
||||
size_t fileSize = ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
if (bufferSize < fileSize) {
|
||||
HILOG_ERROR("ReadFileToBuffer:buffer size:(%{public}zu) is smaller than file size:(%{public}zu).", bufferSize,
|
||||
fileSize);
|
||||
fclose(fp);
|
||||
return nullptr;
|
||||
}
|
||||
size_t retSize = std::fread(buffer.get(), 1, fileSize, fp);
|
||||
if (retSize != fileSize) {
|
||||
HILOG_ERROR("ReadFileToBuffer:read file result size = %{public}zu, size = %{public}zu.", retSize, fileSize);
|
||||
fclose(fp);
|
||||
return nullptr;
|
||||
}
|
||||
fclose(fp);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
std::unique_ptr<Media::PixelMap> MissionDataStorage::GetPixelMap(int missionId, bool isLowResolution) const
|
||||
{
|
||||
std::string filePath = GetMissionSnapshotPath(missionId, isLowResolution);
|
||||
@@ -371,8 +411,16 @@ std::unique_ptr<Media::PixelMap> MissionDataStorage::GetPixelMap(int missionId,
|
||||
return nullptr;
|
||||
}
|
||||
uint32_t errCode = 0;
|
||||
|
||||
size_t bufferSize = 0;
|
||||
const std::string fileName = filePath;
|
||||
std::unique_ptr<uint8_t[]> buffer = MissionDataStorage::ReadFileToBuffer(fileName, bufferSize);
|
||||
if (buffer == nullptr) {
|
||||
HILOG_ERROR("GetPixelMap: get buffer error buffer == nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
Media::SourceOptions sourceOptions;
|
||||
auto imageSource = Media::ImageSource::CreateImageSource(filePath, sourceOptions, errCode);
|
||||
auto imageSource = Media::ImageSource::CreateImageSource(buffer.get(), bufferSize, sourceOptions, errCode);
|
||||
if (errCode != OHOS::Media::SUCCESS) {
|
||||
HILOG_ERROR("snapshot: CreateImageSource failed, errCode = %{public}d", errCode);
|
||||
return nullptr;
|
||||
|
||||
@@ -38,7 +38,7 @@ MissionInfoMgr::~MissionInfoMgr()
|
||||
|
||||
bool MissionInfoMgr::GenerateMissionId(int32_t &missionId)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(mutex_);
|
||||
if (currentMissionId_ == MAX_MISSION_ID) {
|
||||
currentMissionId_ = MIN_MISSION_ID;
|
||||
}
|
||||
@@ -58,7 +58,7 @@ bool MissionInfoMgr::GenerateMissionId(int32_t &missionId)
|
||||
|
||||
bool MissionInfoMgr::Init(int userId)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(mutex_);
|
||||
if (!taskDataPersistenceMgr_) {
|
||||
taskDataPersistenceMgr_ = DelayedSingleton<TaskDataPersistenceMgr>::GetInstance();
|
||||
if (!taskDataPersistenceMgr_) {
|
||||
@@ -82,7 +82,7 @@ bool MissionInfoMgr::Init(int userId)
|
||||
|
||||
bool MissionInfoMgr::AddMissionInfo(const InnerMissionInfo &missionInfo)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(mutex_);
|
||||
return AddMissionInfoInner(missionInfo);
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ bool MissionInfoMgr::AddMissionInfoInner(const InnerMissionInfo &missionInfo)
|
||||
|
||||
bool MissionInfoMgr::UpdateMissionInfo(const InnerMissionInfo &missionInfo)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(mutex_);
|
||||
auto id = missionInfo.missionInfo.id;
|
||||
if (missionIdMap_.find(id) == missionIdMap_.end() || !missionIdMap_[id]) {
|
||||
HILOG_ERROR("update mission info failed, missionId %{public}d not exists", id);
|
||||
@@ -149,7 +149,7 @@ bool MissionInfoMgr::UpdateMissionInfo(const InnerMissionInfo &missionInfo)
|
||||
|
||||
bool MissionInfoMgr::DeleteMissionInfo(int missionId)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(mutex_);
|
||||
if (missionIdMap_.find(missionId) == missionIdMap_.end()) {
|
||||
HILOG_WARN("missionId %{public}d not exists, no need delete", missionId);
|
||||
return true;
|
||||
@@ -184,7 +184,7 @@ bool MissionInfoMgr::DeleteMissionInfo(int missionId)
|
||||
|
||||
bool MissionInfoMgr::DeleteAllMissionInfos(const std::shared_ptr<MissionListenerController> &listenerController)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(mutex_);
|
||||
if (!taskDataPersistenceMgr_) {
|
||||
HILOG_ERROR("taskDataPersistenceMgr_ is nullptr");
|
||||
return false;
|
||||
@@ -228,7 +228,7 @@ int MissionInfoMgr::GetMissionInfos(int32_t numMax, std::vector<MissionInfo> &mi
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(mutex_);
|
||||
for (auto &mission : missionInfoList_) {
|
||||
if (static_cast<int>(missionInfos.size()) >= numMax) {
|
||||
break;
|
||||
@@ -248,7 +248,7 @@ int MissionInfoMgr::GetMissionInfos(int32_t numMax, std::vector<MissionInfo> &mi
|
||||
int MissionInfoMgr::GetMissionInfoById(int32_t missionId, MissionInfo &missionInfo)
|
||||
{
|
||||
HILOG_INFO("missionId:%{public}d", missionId);
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(mutex_);
|
||||
if (missionIdMap_.find(missionId) == missionIdMap_.end()) {
|
||||
HILOG_ERROR("missionId %{public}d not exists, get mission info failed", missionId);
|
||||
return -1;
|
||||
@@ -276,7 +276,7 @@ int MissionInfoMgr::GetMissionInfoById(int32_t missionId, MissionInfo &missionIn
|
||||
|
||||
int MissionInfoMgr::GetInnerMissionInfoById(int32_t missionId, InnerMissionInfo &innerMissionInfo)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(mutex_);
|
||||
if (missionIdMap_.find(missionId) == missionIdMap_.end()) {
|
||||
HILOG_ERROR("missionId %{public}d not exists, get inner mission info failed", missionId);
|
||||
return MISSION_NOT_FOUND;
|
||||
@@ -302,7 +302,7 @@ bool MissionInfoMgr::FindReusedMissionInfo(const std::string &missionName,
|
||||
return false;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(mutex_);
|
||||
auto it = std::find_if(missionInfoList_.begin(), missionInfoList_.end(),
|
||||
[&missionName, &flag, &isFindRecentStandard](const InnerMissionInfo item) {
|
||||
if (missionName != item.missionName) {
|
||||
@@ -334,7 +334,7 @@ bool MissionInfoMgr::FindReusedMissionInfo(const std::string &missionName,
|
||||
|
||||
int MissionInfoMgr::UpdateMissionLabel(int32_t missionId, const std::string& label)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(mutex_);
|
||||
if (!taskDataPersistenceMgr_) {
|
||||
HILOG_ERROR("task data persist not init.");
|
||||
return -1;
|
||||
@@ -360,7 +360,7 @@ void MissionInfoMgr::SetMissionAbilityState(int32_t missionId, AbilityState stat
|
||||
if (missionId <= 0) {
|
||||
return;
|
||||
}
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(mutex_);
|
||||
auto it = find_if(missionInfoList_.begin(), missionInfoList_.end(), [missionId](const InnerMissionInfo &info) {
|
||||
return missionId == info.missionInfo.id;
|
||||
});
|
||||
@@ -410,7 +410,7 @@ void MissionInfoMgr::HandleUnInstallApp(const std::string &bundleName, int32_t u
|
||||
|
||||
void MissionInfoMgr::GetMatchedMission(const std::string &bundleName, int32_t uid, std::list<int32_t> &missions)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(mutex_);
|
||||
for (const auto& innerMissionInfo : missionInfoList_) {
|
||||
if (innerMissionInfo.bundleName == bundleName && innerMissionInfo.uid == uid) {
|
||||
missions.push_back(innerMissionInfo.missionInfo.id);
|
||||
@@ -420,7 +420,7 @@ void MissionInfoMgr::GetMatchedMission(const std::string &bundleName, int32_t ui
|
||||
|
||||
void MissionInfoMgr::Dump(std::vector<std::string> &info)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(mutex_);
|
||||
for (const auto& innerMissionInfo : missionInfoList_) {
|
||||
innerMissionInfo.Dump(info);
|
||||
}
|
||||
@@ -428,7 +428,7 @@ void MissionInfoMgr::Dump(std::vector<std::string> &info)
|
||||
|
||||
void MissionInfoMgr::RegisterSnapshotHandler(const sptr<ISnapshotHandler>& handler)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(mutex_);
|
||||
snapshotHandler_ = handler;
|
||||
}
|
||||
|
||||
@@ -440,7 +440,7 @@ void MissionInfoMgr::UpdateMissionSnapshot(int32_t missionId, const std::shared_
|
||||
MissionSnapshot savedSnapshot;
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, "FindTargetMissionSnapshot");
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(mutex_);
|
||||
auto it = find_if(missionInfoList_.begin(), missionInfoList_.end(), [missionId](const InnerMissionInfo &info) {
|
||||
return missionId == info.missionInfo.id;
|
||||
});
|
||||
@@ -478,7 +478,7 @@ bool MissionInfoMgr::UpdateMissionSnapshot(int32_t missionId, const sptr<IRemote
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, "FindTargetMissionSnapshot");
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(mutex_);
|
||||
auto it = find_if(missionInfoList_.begin(), missionInfoList_.end(), [missionId](const InnerMissionInfo &info) {
|
||||
return missionId == info.missionInfo.id;
|
||||
});
|
||||
@@ -516,7 +516,7 @@ bool MissionInfoMgr::UpdateMissionSnapshot(int32_t missionId, const sptr<IRemote
|
||||
savedSnapshot.snapshot = snapshot.GetPixelMap();
|
||||
#endif
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(savingSnapshotLock_);
|
||||
std::lock_guard<ffrt::mutex> lock(savingSnapshotLock_);
|
||||
auto search = savingSnapshot_.find(missionId);
|
||||
if (search == savingSnapshot_.end()) {
|
||||
savingSnapshot_[missionId] = 1;
|
||||
@@ -536,7 +536,7 @@ bool MissionInfoMgr::UpdateMissionSnapshot(int32_t missionId, const sptr<IRemote
|
||||
|
||||
void MissionInfoMgr::CompleteSaveSnapshot(int32_t missionId)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(savingSnapshotLock_);
|
||||
std::unique_lock<ffrt::mutex> lock(savingSnapshotLock_);
|
||||
auto search = savingSnapshot_.find(missionId);
|
||||
if (search != savingSnapshot_.end()) {
|
||||
auto savingCount = search->second - 1;
|
||||
@@ -554,7 +554,7 @@ std::shared_ptr<Media::PixelMap> MissionInfoMgr::GetSnapshot(int32_t missionId)
|
||||
{
|
||||
HILOG_INFO("missionId:%{public}d", missionId);
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(mutex_);
|
||||
auto it = find_if(missionInfoList_.begin(), missionInfoList_.end(), [missionId](const InnerMissionInfo &info) {
|
||||
return missionId == info.missionInfo.id;
|
||||
});
|
||||
@@ -578,7 +578,7 @@ bool MissionInfoMgr::GetMissionSnapshot(int32_t missionId, const sptr<IRemoteObj
|
||||
HILOG_INFO("missionId:%{public}d, force:%{public}d", missionId, force);
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(mutex_);
|
||||
auto it = find_if(missionInfoList_.begin(), missionInfoList_.end(), [missionId](const InnerMissionInfo &info) {
|
||||
return missionId == info.missionInfo.id;
|
||||
});
|
||||
@@ -598,14 +598,14 @@ bool MissionInfoMgr::GetMissionSnapshot(int32_t missionId, const sptr<IRemoteObj
|
||||
return UpdateMissionSnapshot(missionId, abilityToken, missionSnapshot, isLowResolution);
|
||||
}
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(savingSnapshotLock_);
|
||||
std::unique_lock<ffrt::mutex> lock(savingSnapshotLock_);
|
||||
auto search = savingSnapshot_.find(missionId);
|
||||
if (search != savingSnapshot_.end()) {
|
||||
auto savingSnapshotTimeout = 100; // ms
|
||||
std::chrono::milliseconds timeout { savingSnapshotTimeout };
|
||||
auto waitingCount = 5;
|
||||
auto waitingNum = 0;
|
||||
while (waitSavingCondition_.wait_for(lock, timeout) == std::cv_status::no_timeout) {
|
||||
while (waitSavingCondition_.wait_for(lock, timeout) == ffrt::cv_status::no_timeout) {
|
||||
++waitingNum;
|
||||
auto iter = savingSnapshot_.find(missionId);
|
||||
if (iter == savingSnapshot_.end() || waitingNum == waitingCount) {
|
||||
|
||||
@@ -920,10 +920,9 @@ int MissionListManager::AttachAbilityThread(const sptr<IAbilityScheduler> &sched
|
||||
|
||||
HILOG_DEBUG("AbilityMS attach abilityThread, name is %{public}s.", abilityRecord->GetAbilityInfo().name.c_str());
|
||||
|
||||
std::shared_ptr<AbilityEventHandler> handler =
|
||||
DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
CHECK_POINTER_AND_RETURN_LOG(handler, ERR_INVALID_VALUE, "Fail to get AbilityEventHandler.");
|
||||
handler->RemoveEvent(AbilityManagerService::LOAD_TIMEOUT_MSG, abilityRecord->GetAbilityRecordId());
|
||||
auto eventHandler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
CHECK_POINTER_AND_RETURN_LOG(eventHandler, ERR_INVALID_VALUE, "Fail to get AbilityEventHandler.");
|
||||
eventHandler->RemoveEvent(AbilityManagerService::LOAD_TIMEOUT_MSG, abilityRecord->GetAbilityRecordId());
|
||||
|
||||
abilityRecord->SetScheduler(scheduler);
|
||||
|
||||
@@ -942,8 +941,10 @@ int MissionListManager::AttachAbilityThread(const sptr<IAbilityScheduler> &sched
|
||||
abilityRecord->CallRequest();
|
||||
}
|
||||
|
||||
auto taskHandler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
CHECK_POINTER_AND_RETURN_LOG(taskHandler, ERR_INVALID_VALUE, "Fail to get AbilityTaskHandler.");
|
||||
auto taskName = std::to_string(abilityRecord->GetMissionId()) + "_cold";
|
||||
handler->RemoveTask(taskName);
|
||||
taskHandler->CancelTask(taskName);
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
abilityRecord->PostCancelStartingWindowHotTask();
|
||||
#endif
|
||||
@@ -1139,8 +1140,6 @@ int MissionListManager::DispatchState(const std::shared_ptr<AbilityRecord> &abil
|
||||
int MissionListManager::DispatchForeground(const std::shared_ptr<AbilityRecord> &abilityRecord, bool success,
|
||||
AbilityState state)
|
||||
{
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
CHECK_POINTER_AND_RETURN_LOG(handler, ERR_INVALID_VALUE, "Fail to get AbilityEventHandler.");
|
||||
CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE);
|
||||
|
||||
if (!abilityRecord->IsAbilityState(AbilityState::FOREGROUNDING)) {
|
||||
@@ -1150,15 +1149,18 @@ int MissionListManager::DispatchForeground(const std::shared_ptr<AbilityRecord>
|
||||
abilityRecord->GetAbilityState());
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
handler->RemoveEvent(AbilityManagerService::FOREGROUND_TIMEOUT_MSG, abilityRecord->GetAbilityRecordId());
|
||||
auto eventHandler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
CHECK_POINTER_AND_RETURN_LOG(eventHandler, ERR_INVALID_VALUE, "Fail to get AbilityEventHandler.");
|
||||
eventHandler->RemoveEvent(AbilityManagerService::FOREGROUND_TIMEOUT_MSG, abilityRecord->GetAbilityRecordId());
|
||||
auto self(weak_from_this());
|
||||
auto taskHandler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
CHECK_POINTER_AND_RETURN_LOG(taskHandler, ERR_INVALID_VALUE, "Fail to get AbilityTaskHandler.");
|
||||
if (success) {
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
HILOG_INFO("ok");
|
||||
abilityRecord->SetStartingWindow(false);
|
||||
auto taskName = std::to_string(abilityRecord->GetMissionId()) + "_hot";
|
||||
handler->RemoveTask(taskName);
|
||||
taskHandler->CancelTask(taskName);
|
||||
#endif
|
||||
auto task = [self, abilityRecord]() {
|
||||
auto selfObj = self.lock();
|
||||
@@ -1168,7 +1170,7 @@ int MissionListManager::DispatchForeground(const std::shared_ptr<AbilityRecord>
|
||||
}
|
||||
selfObj->CompleteForegroundSuccess(abilityRecord);
|
||||
};
|
||||
handler->PostTask(task);
|
||||
taskHandler->SubmitTask(task);
|
||||
} else {
|
||||
auto task = [self, abilityRecord, state]() {
|
||||
auto selfObj = self.lock();
|
||||
@@ -1178,7 +1180,7 @@ int MissionListManager::DispatchForeground(const std::shared_ptr<AbilityRecord>
|
||||
}
|
||||
selfObj->CompleteForegroundFailed(abilityRecord, state);
|
||||
};
|
||||
handler->PostTask(task);
|
||||
taskHandler->SubmitTask(task);
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
@@ -1269,8 +1271,8 @@ void MissionListManager::TerminatePreviousAbility(const std::shared_ptr<AbilityR
|
||||
|
||||
int MissionListManager::DispatchBackground(const std::shared_ptr<AbilityRecord> &abilityRecord)
|
||||
{
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
CHECK_POINTER_AND_RETURN_LOG(handler, ERR_INVALID_VALUE, "Fail to get AbilityEventHandler.");
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
CHECK_POINTER_AND_RETURN_LOG(handler, ERR_INVALID_VALUE, "Fail to get AbilityTasktHandler.");
|
||||
CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE);
|
||||
|
||||
if (!abilityRecord->IsAbilityState(AbilityState::BACKGROUNDING)) {
|
||||
@@ -1279,10 +1281,10 @@ int MissionListManager::DispatchBackground(const std::shared_ptr<AbilityRecord>
|
||||
}
|
||||
|
||||
// remove background timeout task.
|
||||
handler->RemoveTask("background_" + std::to_string(abilityRecord->GetAbilityRecordId()));
|
||||
handler->CancelTask("background_" + std::to_string(abilityRecord->GetAbilityRecordId()));
|
||||
auto self(shared_from_this());
|
||||
auto task = [self, abilityRecord]() { self->CompleteBackground(abilityRecord); };
|
||||
handler->PostTask(task);
|
||||
handler->SubmitTask(task);
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
@@ -1357,8 +1359,15 @@ int MissionListManager::MoveAbilityToBackgroundLocked(const std::shared_ptr<Abil
|
||||
nextAbilityRecord->SetPreAbilityRecord(abilityRecord);
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
nextAbilityRecord->SetPendingState(AbilityState::FOREGROUND);
|
||||
nextAbilityRecord->ProcessForegroundAbility(abilityRecord);
|
||||
nextAbilityRecord->ProcessForegroundAbility(abilityRecord, false);
|
||||
} else {
|
||||
bool animaEnabled = false;
|
||||
if (!abilityRecord->IsClearMissionFlag()) {
|
||||
abilityRecord->NotifyAnimationFromMinimizeAbility(animaEnabled);
|
||||
}
|
||||
if (animaEnabled) {
|
||||
return ERR_OK;
|
||||
}
|
||||
#else
|
||||
nextAbilityRecord->ProcessForegroundAbility();
|
||||
} else {
|
||||
@@ -1386,7 +1395,7 @@ void MissionListManager::RemoveBackgroundingAbility(const std::shared_ptr<Abilit
|
||||
}
|
||||
|
||||
if (missionList->IsEmpty()) {
|
||||
HILOG_DEBUG("Remove terminating ability, missionList is empty, remove.");
|
||||
HILOG_DEBUG("Remove backgrounding ability, missionList is empty, remove.");
|
||||
RemoveMissionList(missionList);
|
||||
}
|
||||
|
||||
@@ -1650,19 +1659,19 @@ int MissionListManager::DispatchTerminate(const std::shared_ptr<AbilityRecord> &
|
||||
}
|
||||
|
||||
// remove terminate timeout task.
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
CHECK_POINTER_AND_RETURN_LOG(handler, ERR_INVALID_VALUE, "Fail to get AbilityEventHandler.");
|
||||
handler->RemoveTask("terminate_" + std::to_string(abilityRecord->GetAbilityRecordId()));
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
CHECK_POINTER_AND_RETURN_LOG(handler, ERR_INVALID_VALUE, "Fail to get AbilityTasktHandler.");
|
||||
handler->CancelTask("terminate_" + std::to_string(abilityRecord->GetAbilityRecordId()));
|
||||
auto self(shared_from_this());
|
||||
auto task = [self, abilityRecord]() { self->CompleteTerminate(abilityRecord); };
|
||||
handler->PostTask(task);
|
||||
handler->SubmitTask(task);
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
void MissionListManager::DelayCompleteTerminate(const std::shared_ptr<AbilityRecord> &abilityRecord)
|
||||
{
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
CHECK_POINTER(handler);
|
||||
|
||||
PrintTimeOutLog(abilityRecord, AbilityManagerService::TERMINATE_TIMEOUT_MSG);
|
||||
@@ -1672,7 +1681,7 @@ void MissionListManager::DelayCompleteTerminate(const std::shared_ptr<AbilityRec
|
||||
self->CompleteTerminate(abilityRecord);
|
||||
};
|
||||
int killTimeout = AmsConfigurationParameter::GetInstance().GetAppStartTimeoutTime() * KILL_TIMEOUT_MULTIPLE;
|
||||
handler->PostTask(timeoutTask, "DELAY_KILL_PROCESS", killTimeout);
|
||||
handler->SubmitTask(timeoutTask, "DELAY_KILL_PROCESS", killTimeout);
|
||||
}
|
||||
|
||||
void MissionListManager::CompleteTerminate(const std::shared_ptr<AbilityRecord> &abilityRecord)
|
||||
@@ -1981,7 +1990,7 @@ void MissionListManager::NotifyMissionCreated(const std::shared_ptr<AbilityReco
|
||||
|
||||
void MissionListManager::PostMissionLabelUpdateTask(int missionId) const
|
||||
{
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
if (handler == nullptr) {
|
||||
HILOG_ERROR("Fail to get EventHandler, do not post mission label update message.");
|
||||
return;
|
||||
@@ -1996,7 +2005,7 @@ void MissionListManager::PostMissionLabelUpdateTask(int missionId) const
|
||||
}
|
||||
controller->NotifyMissionLabelUpdated(missionId);
|
||||
};
|
||||
handler->PostTask(task, "NotifyMissionLabelUpdated.", DELAY_NOTIFY_LABEL_TIME);
|
||||
handler->SubmitTask(task, "NotifyMissionLabelUpdated.", DELAY_NOTIFY_LABEL_TIME);
|
||||
}
|
||||
|
||||
void MissionListManager::PrintTimeOutLog(const std::shared_ptr<AbilityRecord> &ability, uint32_t msgId)
|
||||
@@ -2227,7 +2236,7 @@ void MissionListManager::DelayedResumeTimeout(const std::shared_ptr<AbilityRecor
|
||||
{
|
||||
auto abilityManagerService = DelayedSingleton<AbilityManagerService>::GetInstance();
|
||||
CHECK_POINTER(abilityManagerService);
|
||||
auto handler = abilityManagerService->GetEventHandler();
|
||||
auto handler = abilityManagerService->GetTaskHandler();
|
||||
CHECK_POINTER(handler);
|
||||
std::weak_ptr<MissionListManager> wpListMgr = shared_from_this();
|
||||
auto timeoutTask = [wpListMgr, callerAbility]() {
|
||||
@@ -2237,7 +2246,7 @@ void MissionListManager::DelayedResumeTimeout(const std::shared_ptr<AbilityRecor
|
||||
listMgr->BackToCaller(callerAbility);
|
||||
}
|
||||
};
|
||||
handler->PostTask(timeoutTask, "Caller_Restart");
|
||||
handler->SubmitTask(timeoutTask, "Caller_Restart");
|
||||
}
|
||||
|
||||
void MissionListManager::BackToCaller(const std::shared_ptr<AbilityRecord> &callerAbility)
|
||||
@@ -2484,11 +2493,11 @@ void MissionListManager::PostStartWaitingAbility()
|
||||
auto self(shared_from_this());
|
||||
auto startWaitingAbilityTask = [self]() { self->StartWaitingAbility(); };
|
||||
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
CHECK_POINTER_LOG(handler, "Fail to get AbilityEventHandler.");
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
CHECK_POINTER_LOG(handler, "Fail to get AbilityTaskHandler.");
|
||||
|
||||
/* PostTask to trigger start Ability from waiting queue */
|
||||
handler->PostTask(startWaitingAbilityTask, "startWaitingAbility");
|
||||
handler->SubmitTask(startWaitingAbilityTask, "startWaitingAbility");
|
||||
}
|
||||
|
||||
void MissionListManager::HandleAbilityDied(std::shared_ptr<AbilityRecord> abilityRecord)
|
||||
@@ -2591,7 +2600,7 @@ void MissionListManager::DelayedStartLauncher()
|
||||
{
|
||||
auto abilityManagerService = DelayedSingleton<AbilityManagerService>::GetInstance();
|
||||
CHECK_POINTER(abilityManagerService);
|
||||
auto handler = abilityManagerService->GetEventHandler();
|
||||
auto handler = abilityManagerService->GetTaskHandler();
|
||||
CHECK_POINTER(handler);
|
||||
std::weak_ptr<MissionListManager> wpListMgr = shared_from_this();
|
||||
auto timeoutTask = [wpListMgr]() {
|
||||
@@ -2601,7 +2610,7 @@ void MissionListManager::DelayedStartLauncher()
|
||||
listMgr->BackToLauncher();
|
||||
}
|
||||
};
|
||||
handler->PostTask(timeoutTask, "Launcher_Restart");
|
||||
handler->SubmitTask(timeoutTask, "Launcher_Restart");
|
||||
}
|
||||
|
||||
void MissionListManager::BackToLauncher()
|
||||
@@ -2713,9 +2722,9 @@ void MissionListManager::CompleteFirstFrameDrawing(const sptr<IRemoteObject> &ab
|
||||
}
|
||||
abilityRecord->SetCompleteFirstFrameDrawing(true);
|
||||
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
if (handler == nullptr) {
|
||||
HILOG_ERROR("Fail to get AbilityEventHandler.");
|
||||
HILOG_ERROR("Fail to get Ability task handler.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2730,7 +2739,7 @@ void MissionListManager::CompleteFirstFrameDrawing(const sptr<IRemoteObject> &ab
|
||||
mgr->UpdateMissionSnapshot(abilityRecord);
|
||||
}
|
||||
};
|
||||
handler->PostTask(task, "FirstFrameDrawing");
|
||||
handler->SubmitTask(task, "FirstFrameDrawing");
|
||||
auto preloadTask = [owner = weak_from_this(), abilityRecord] {
|
||||
auto mgr = owner.lock();
|
||||
if (mgr == nullptr) {
|
||||
@@ -2739,7 +2748,7 @@ void MissionListManager::CompleteFirstFrameDrawing(const sptr<IRemoteObject> &ab
|
||||
}
|
||||
mgr->ProcessPreload(abilityRecord);
|
||||
};
|
||||
handler->PostTask(preloadTask);
|
||||
handler->SubmitTask(preloadTask);
|
||||
}
|
||||
|
||||
void MissionListManager::ProcessPreload(const std::shared_ptr<AbilityRecord> &record) const
|
||||
@@ -2774,9 +2783,9 @@ Closure MissionListManager::GetCancelStartingWindowTask(const std::shared_ptr<Ab
|
||||
void MissionListManager::PostCancelStartingWindowTask(const std::shared_ptr<AbilityRecord> &abilityRecord) const
|
||||
{
|
||||
HILOG_INFO("call");
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
if (!handler) {
|
||||
HILOG_ERROR("Fail to get AbilityEventHandler.");
|
||||
HILOG_ERROR("Fail to get AbilityTaskHandler.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2785,7 +2794,7 @@ void MissionListManager::PostCancelStartingWindowTask(const std::shared_ptr<Abil
|
||||
HILOG_ERROR("Fail to get CancelStartingWindow task.");
|
||||
return;
|
||||
}
|
||||
handler->PostTask(task, AppExecFwk::EventQueue::Priority::IMMEDIATE);
|
||||
handler->SubmitTask(task, TaskQoS::USER_INTERACTIVE);
|
||||
}
|
||||
|
||||
void MissionListManager::InitPrepareTerminateConfig()
|
||||
@@ -3429,7 +3438,7 @@ void MissionListManager::UninstallApp(const std::string &bundleName, int32_t uid
|
||||
HILOG_INFO("Uninstall app, bundleName: %{public}s, uid:%{public}d", bundleName.c_str(), uid);
|
||||
auto abilityManagerService = DelayedSingleton<AbilityManagerService>::GetInstance();
|
||||
CHECK_POINTER(abilityManagerService);
|
||||
auto handler = abilityManagerService->GetEventHandler();
|
||||
auto handler = abilityManagerService->GetTaskHandler();
|
||||
CHECK_POINTER(handler);
|
||||
std::weak_ptr<MissionListManager> wpMgr = shared_from_this();
|
||||
auto task = [wpMgr, bundleName, uid]() {
|
||||
@@ -3439,7 +3448,7 @@ void MissionListManager::UninstallApp(const std::string &bundleName, int32_t uid
|
||||
mgr->AddUninstallTags(bundleName, uid);
|
||||
}
|
||||
};
|
||||
handler->PostTask(task);
|
||||
handler->SubmitTask(task);
|
||||
}
|
||||
|
||||
void MissionListManager::AddUninstallTags(const std::string &bundleName, int32_t uid)
|
||||
@@ -3866,22 +3875,21 @@ int MissionListManager::PrepareClearMissionLocked(int missionId, const std::shar
|
||||
mgr->ClearMissionLocking(missionId, mission);
|
||||
}
|
||||
};
|
||||
std::shared_ptr<AbilityEventHandler> handler =
|
||||
DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
int prepareTerminateTimeout =
|
||||
AmsConfigurationParameter::GetInstance().GetAppStartTimeoutTime() * PREPARE_TERMINATE_TIMEOUT_MULTIPLE;
|
||||
if (handler) {
|
||||
handler->PostTask(terminateTask, "PrepareTermiante_" + std::to_string(abilityRecord->GetAbilityRecordId()),
|
||||
handler->SubmitTask(terminateTask, "PrepareTermiante_" + std::to_string(abilityRecord->GetAbilityRecordId()),
|
||||
prepareTerminateTimeout);
|
||||
}
|
||||
|
||||
bool res = abilityRecord->PrepareTerminateAbility();
|
||||
if (res) {
|
||||
HILOG_INFO("stop terminating.");
|
||||
handler->RemoveTask("PrepareTermiante_" + std::to_string(abilityRecord->GetAbilityRecordId()));
|
||||
handler->CancelTask("PrepareTermiante_" + std::to_string(abilityRecord->GetAbilityRecordId()));
|
||||
return ERR_OK;
|
||||
}
|
||||
handler->RemoveTask("PrepareTermiante_" + std::to_string(abilityRecord->GetAbilityRecordId()));
|
||||
handler->CancelTask("PrepareTermiante_" + std::to_string(abilityRecord->GetAbilityRecordId()));
|
||||
return ClearMissionLocked(missionId, mission);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
using namespace OHOS::AppExecFwk;
|
||||
namespace {
|
||||
const std::string THREAD_NAME = "MissionListener";
|
||||
}
|
||||
@@ -35,7 +34,7 @@ MissionListenerController::~MissionListenerController()
|
||||
void MissionListenerController::Init()
|
||||
{
|
||||
if (!handler_) {
|
||||
handler_ = std::make_shared<EventHandler>(EventRunner::Create(THREAD_NAME));
|
||||
handler_ = TaskHandlerWrap::CreateQueueHandler("mission_listener_task_queue");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +45,7 @@ int MissionListenerController::AddMissionListener(const sptr<IMissionListener> &
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> guard(listenerLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(listenerLock_);
|
||||
auto it = std::find_if(missionListeners_.begin(), missionListeners_.end(),
|
||||
[&listener](const sptr<IMissionListener> &item) {
|
||||
return (item && item->AsObject() == listener->AsObject());
|
||||
@@ -83,7 +82,7 @@ void MissionListenerController::DelMissionListener(const sptr<IMissionListener>
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> guard(listenerLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(listenerLock_);
|
||||
auto it = std::find_if(missionListeners_.begin(), missionListeners_.end(),
|
||||
[&listener](const sptr<IMissionListener> item) {
|
||||
return (item && item->AsObject() == listener->AsObject());
|
||||
@@ -109,7 +108,7 @@ void MissionListenerController::NotifyMissionCreated(int32_t missionId)
|
||||
HILOG_INFO("notify listeners mission is created, missionId:%{public}d.", missionId);
|
||||
self->CallListeners(&IMissionListener::OnMissionCreated, missionId);
|
||||
};
|
||||
handler_->PostTask(task);
|
||||
handler_->SubmitTask(task);
|
||||
}
|
||||
|
||||
void MissionListenerController::NotifyMissionDestroyed(int32_t missionId)
|
||||
@@ -127,7 +126,7 @@ void MissionListenerController::NotifyMissionDestroyed(int32_t missionId)
|
||||
HILOG_INFO("notify listeners mission is destroyed, missionId:%{public}d.", missionId);
|
||||
self->CallListeners(&IMissionListener::OnMissionDestroyed, missionId);
|
||||
};
|
||||
handler_->PostTask(task);
|
||||
handler_->SubmitTask(task);
|
||||
}
|
||||
|
||||
void MissionListenerController::HandleUnInstallApp(const std::list<int32_t> &missions)
|
||||
@@ -151,7 +150,7 @@ void MissionListenerController::HandleUnInstallApp(const std::list<int32_t> &mis
|
||||
self->CallListeners(&IMissionListener::OnMissionDestroyed, id);
|
||||
}
|
||||
};
|
||||
handler_->PostTask(task);
|
||||
handler_->SubmitTask(task);
|
||||
}
|
||||
|
||||
void MissionListenerController::NotifyMissionSnapshotChanged(int32_t missionId)
|
||||
@@ -170,7 +169,7 @@ void MissionListenerController::NotifyMissionSnapshotChanged(int32_t missionId)
|
||||
HILOG_INFO("notify listeners mission snapshot changed, missionId:%{public}d.", missionId);
|
||||
self->CallListeners(&IMissionListener::OnMissionSnapshotChanged, missionId);
|
||||
};
|
||||
handler_->PostTask(task);
|
||||
handler_->SubmitTask(task);
|
||||
}
|
||||
|
||||
void MissionListenerController::NotifyMissionMovedToFront(int32_t missionId)
|
||||
@@ -189,7 +188,7 @@ void MissionListenerController::NotifyMissionMovedToFront(int32_t missionId)
|
||||
HILOG_INFO("notify listeners mission is moved to front, missionId:%{public}d.", missionId);
|
||||
self->CallListeners(&IMissionListener::OnMissionMovedToFront, missionId);
|
||||
};
|
||||
handler_->PostTask(task);
|
||||
handler_->SubmitTask(task);
|
||||
}
|
||||
|
||||
void MissionListenerController::NotifyMissionFocused(int32_t missionId)
|
||||
@@ -211,7 +210,7 @@ void MissionListenerController::NotifyMissionFocused(int32_t missionId)
|
||||
HILOG_INFO("NotifyMissionFocused, missionId:%{public}d.", missionId);
|
||||
self->CallListeners(&IMissionListener::OnMissionFocused, missionId);
|
||||
};
|
||||
handler_->PostTask(task);
|
||||
handler_->SubmitTask(task);
|
||||
}
|
||||
|
||||
void MissionListenerController::NotifyMissionUnfocused(int32_t missionId)
|
||||
@@ -233,7 +232,7 @@ void MissionListenerController::NotifyMissionUnfocused(int32_t missionId)
|
||||
HILOG_INFO("NotifyMissionUnfocused, missionId:%{public}d.", missionId);
|
||||
self->CallListeners(&IMissionListener::OnMissionUnfocused, missionId);
|
||||
};
|
||||
handler_->PostTask(task);
|
||||
handler_->SubmitTask(task);
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
@@ -254,7 +253,7 @@ void MissionListenerController::NotifyMissionIconChanged(int32_t missionId,
|
||||
HILOG_INFO("notify listeners mission icon has changed, missionId:%{public}d.", missionId);
|
||||
self->CallListeners(&IMissionListener::OnMissionIconUpdated, missionId, icon);
|
||||
};
|
||||
handler_->PostTask(task);
|
||||
handler_->SubmitTask(task);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -273,7 +272,7 @@ void MissionListenerController::NotifyMissionClosed(int32_t missionId)
|
||||
HILOG_INFO("NotifyMissionClosed, missionId:%{public}d.", missionId);
|
||||
self->CallListeners(&IMissionListener::OnMissionClosed, missionId);
|
||||
};
|
||||
handler_->PostTask(task);
|
||||
handler_->SubmitTask(task);
|
||||
}
|
||||
|
||||
void MissionListenerController::NotifyMissionLabelUpdated(int32_t missionId)
|
||||
@@ -291,7 +290,7 @@ void MissionListenerController::NotifyMissionLabelUpdated(int32_t missionId)
|
||||
HILOG_INFO("notify listeners mission label has updated, missionId:%{public}d.", missionId);
|
||||
self->CallListeners(&IMissionListener::OnMissionLabelUpdated, missionId);
|
||||
};
|
||||
handler_->PostTask(task);
|
||||
handler_->SubmitTask(task);
|
||||
}
|
||||
|
||||
void MissionListenerController::OnListenerDied(const wptr<IRemoteObject> &remote)
|
||||
@@ -304,7 +303,7 @@ void MissionListenerController::OnListenerDied(const wptr<IRemoteObject> &remote
|
||||
}
|
||||
remoteObj->RemoveDeathRecipient(listenerDeathRecipient_);
|
||||
|
||||
std::lock_guard<std::mutex> guard(listenerLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(listenerLock_);
|
||||
auto it = std::find_if(missionListeners_.begin(), missionListeners_.end(),
|
||||
[&remoteObj](const sptr<IMissionListener> item) {
|
||||
return (item && item->AsObject() == remoteObj);
|
||||
|
||||
@@ -84,7 +84,7 @@ sptr<IWantSender> PendingWantManager::GetWantSenderLocked(const int32_t callingU
|
||||
pendingKey->SetRequestResolvedType(wantSenderInfo.allWants.back().resolvedTypes);
|
||||
pendingKey->SetAllWantsInfos(wantSenderInfo.allWants);
|
||||
}
|
||||
std::lock_guard<std::mutex> locker(mutex_);
|
||||
std::lock_guard<ffrt::mutex> locker(mutex_);
|
||||
auto ref = GetPendingWantRecordByKey(pendingKey);
|
||||
if (ref != nullptr) {
|
||||
if (!needCancel) {
|
||||
@@ -194,7 +194,7 @@ void PendingWantManager::CancelWantSender(std::string &apl, const sptr<IWantSend
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> locker(mutex_);
|
||||
std::lock_guard<ffrt::mutex> locker(mutex_);
|
||||
auto isSaCall = AAFwk::PermissionVerification::GetInstance()->IsSACall();
|
||||
if (!isSaCall && apl != AbilityUtil::SYSTEM_BASIC && apl != AbilityUtil::SYSTEM_CORE) {
|
||||
HILOG_ERROR("is not allowed to send");
|
||||
@@ -317,7 +317,7 @@ sptr<PendingWantRecord> PendingWantManager::GetPendingWantRecordByCode(int32_t c
|
||||
{
|
||||
HILOG_INFO("begin. wantRecords_ size = %{public}zu", wantRecords_.size());
|
||||
|
||||
std::lock_guard<std::mutex> locker(mutex_);
|
||||
std::lock_guard<ffrt::mutex> locker(mutex_);
|
||||
auto iter = std::find_if(wantRecords_.begin(), wantRecords_.end(), [&code](const auto &pair) {
|
||||
return pair.second->GetKey()->GetCode() == code;
|
||||
});
|
||||
@@ -413,7 +413,7 @@ void PendingWantManager::RegisterCancelListener(const sptr<IWantSender> &sender,
|
||||
return;
|
||||
}
|
||||
bool cancel = record->GetCanceled();
|
||||
std::lock_guard<std::mutex> locker(mutex_);
|
||||
std::lock_guard<ffrt::mutex> locker(mutex_);
|
||||
if (!cancel) {
|
||||
record->RegisterCancelListener(recevier);
|
||||
}
|
||||
@@ -434,7 +434,7 @@ void PendingWantManager::UnregisterCancelListener(const sptr<IWantSender> &sende
|
||||
HILOG_ERROR("%{public}s:record is nullptr.", __func__);
|
||||
return;
|
||||
}
|
||||
std::lock_guard<std::mutex> locker(mutex_);
|
||||
std::lock_guard<ffrt::mutex> locker(mutex_);
|
||||
record->UnregisterCancelListener(recevier);
|
||||
}
|
||||
|
||||
@@ -498,16 +498,16 @@ void PendingWantManager::ClearPendingWantRecord(const std::string &bundleName, i
|
||||
HILOG_INFO("bundleName: %{public}s", bundleName.c_str());
|
||||
auto abilityManagerService = DelayedSingleton<AbilityManagerService>::GetInstance();
|
||||
CHECK_POINTER(abilityManagerService);
|
||||
auto handler = abilityManagerService->GetEventHandler();
|
||||
auto handler = abilityManagerService->GetTaskHandler();
|
||||
CHECK_POINTER(handler);
|
||||
auto task = [bundleName, uid, self = shared_from_this()]() { self->ClearPendingWantRecordTask(bundleName, uid); };
|
||||
handler->PostTask(task);
|
||||
handler->SubmitTask(task);
|
||||
}
|
||||
|
||||
void PendingWantManager::ClearPendingWantRecordTask(const std::string &bundleName, int32_t uid)
|
||||
{
|
||||
HILOG_INFO("bundleName: %{public}s", bundleName.c_str());
|
||||
std::lock_guard<std::mutex> locker(mutex_);
|
||||
std::lock_guard<ffrt::mutex> locker(mutex_);
|
||||
auto iter = wantRecords_.begin();
|
||||
while (iter != wantRecords_.end()) {
|
||||
bool hasBundle = false;
|
||||
|
||||
@@ -62,7 +62,7 @@ void PendingWantRecord::UnregisterCancelListener(const sptr<IWantReceiver> &rece
|
||||
int32_t PendingWantRecord::SenderInner(SenderInfo &senderInfo)
|
||||
{
|
||||
HILOG_INFO("%{public}s:begin.", __func__);
|
||||
std::lock_guard<std::mutex> locker(lock_);
|
||||
std::lock_guard<ffrt::mutex> locker(lock_);
|
||||
if (canceled_) {
|
||||
return START_CANCELED;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ const int KILL_TIMEOUT_MULTIPLE = 3;
|
||||
int UIAbilityLifecycleManager::StartUIAbility(AbilityRequest &abilityRequest, sptr<SessionInfo> sessionInfo)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
std::lock_guard<std::mutex> guard(sessionLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(sessionLock_);
|
||||
HILOG_DEBUG("Call.");
|
||||
if (sessionInfo == nullptr || sessionInfo->sessionToken == nullptr) {
|
||||
HILOG_ERROR("sessionInfo is invalid.");
|
||||
@@ -62,6 +62,10 @@ int UIAbilityLifecycleManager::StartUIAbility(AbilityRequest &abilityRequest, sp
|
||||
uiAbilityRecord->SetWant(abilityRequest.want);
|
||||
uiAbilityRecord->SetIsNewWant(true);
|
||||
} else {
|
||||
if (sessionInfo->startSetting != nullptr) {
|
||||
HILOG_DEBUG("startSetting is valid.");
|
||||
abilityRequest.startSetting = sessionInfo->startSetting;
|
||||
}
|
||||
uiAbilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
}
|
||||
CHECK_POINTER_AND_RETURN(uiAbilityRecord, ERR_INVALID_VALUE);
|
||||
@@ -97,7 +101,7 @@ int UIAbilityLifecycleManager::AttachAbilityThread(const sptr<IAbilityScheduler>
|
||||
const sptr<IRemoteObject> &token)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
std::lock_guard<std::mutex> guard(sessionLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(sessionLock_);
|
||||
if (!IsContainsAbilityInner(token)) {
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
@@ -132,7 +136,7 @@ int UIAbilityLifecycleManager::AttachAbilityThread(const sptr<IAbilityScheduler>
|
||||
void UIAbilityLifecycleManager::OnAbilityRequestDone(const sptr<IRemoteObject> &token, int32_t state) const
|
||||
{
|
||||
HILOG_DEBUG("Ability request state %{public}d done.", state);
|
||||
std::lock_guard<std::mutex> guard(sessionLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(sessionLock_);
|
||||
AppAbilityState abilityState = DelayedSingleton<AppScheduler>::GetInstance()->ConvertToAppAbilityState(state);
|
||||
if (abilityState == AppAbilityState::ABILITY_STATE_FOREGROUND) {
|
||||
auto&& abilityRecord = Token::GetAbilityRecordByToken(token);
|
||||
@@ -151,7 +155,7 @@ int UIAbilityLifecycleManager::AbilityTransactionDone(const sptr<IRemoteObject>
|
||||
std::string abilityState = AbilityRecord::ConvertAbilityState(static_cast<AbilityState>(targetState));
|
||||
HILOG_INFO("AbilityTransactionDone, state: %{public}s.", abilityState.c_str());
|
||||
|
||||
std::lock_guard<std::mutex> guard(sessionLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(sessionLock_);
|
||||
auto abilityRecord = GetAbilityRecordByToken(token);
|
||||
CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE);
|
||||
|
||||
@@ -169,7 +173,7 @@ int UIAbilityLifecycleManager::NotifySCBToStartUIAbility(const AbilityRequest &a
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("Call.");
|
||||
std::lock_guard<std::mutex> guard(sessionLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(sessionLock_);
|
||||
auto isSpecified = (abilityRequest.abilityInfo.launchMode == AppExecFwk::LaunchMode::SPECIFIED);
|
||||
if (isSpecified) {
|
||||
EnqueueAbilityToFront(abilityRequest);
|
||||
@@ -212,6 +216,8 @@ int UIAbilityLifecycleManager::DispatchForeground(const std::shared_ptr<AbilityR
|
||||
{
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
CHECK_POINTER_AND_RETURN_LOG(handler, ERR_INVALID_VALUE, "Fail to get AbilityEventHandler.");
|
||||
auto taskHandler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
CHECK_POINTER_AND_RETURN_LOG(taskHandler, ERR_INVALID_VALUE, "Fail to get AbilityTaskHandler.");
|
||||
CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE);
|
||||
|
||||
if (!abilityRecord->IsAbilityState(AbilityState::FOREGROUNDING)) {
|
||||
@@ -233,7 +239,7 @@ int UIAbilityLifecycleManager::DispatchForeground(const std::shared_ptr<AbilityR
|
||||
}
|
||||
selfObj->CompleteForegroundSuccess(abilityRecord);
|
||||
};
|
||||
handler->PostTask(task);
|
||||
taskHandler->SubmitTask(task);
|
||||
} else {
|
||||
auto task = [self, abilityRecord, state]() {
|
||||
auto selfObj = self.lock();
|
||||
@@ -251,15 +257,15 @@ int UIAbilityLifecycleManager::DispatchForeground(const std::shared_ptr<AbilityR
|
||||
}
|
||||
selfObj->HandleForegroundFailed(abilityRecord, state);
|
||||
};
|
||||
handler->PostTask(task);
|
||||
taskHandler->SubmitTask(task);
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int UIAbilityLifecycleManager::DispatchBackground(const std::shared_ptr<AbilityRecord> &abilityRecord)
|
||||
{
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
CHECK_POINTER_AND_RETURN_LOG(handler, ERR_INVALID_VALUE, "Fail to get AbilityEventHandler.");
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
CHECK_POINTER_AND_RETURN_LOG(handler, ERR_INVALID_VALUE, "Fail to get AbilityTaskHandler.");
|
||||
CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE);
|
||||
|
||||
if (!abilityRecord->IsAbilityState(AbilityState::BACKGROUNDING)) {
|
||||
@@ -268,10 +274,10 @@ int UIAbilityLifecycleManager::DispatchBackground(const std::shared_ptr<AbilityR
|
||||
}
|
||||
|
||||
// remove background timeout task.
|
||||
handler->RemoveTask("background_" + std::to_string(abilityRecord->GetAbilityRecordId()));
|
||||
handler->CancelTask("background_" + std::to_string(abilityRecord->GetAbilityRecordId()));
|
||||
auto self(shared_from_this());
|
||||
auto task = [self, abilityRecord]() { self->CompleteBackground(abilityRecord); };
|
||||
handler->PostTask(task);
|
||||
handler->SubmitTask(task);
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
@@ -285,12 +291,12 @@ int UIAbilityLifecycleManager::DispatchTerminate(const std::shared_ptr<AbilityRe
|
||||
}
|
||||
|
||||
// remove terminate timeout task.
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
CHECK_POINTER_AND_RETURN_LOG(handler, ERR_INVALID_VALUE, "Fail to get AbilityEventHandler.");
|
||||
handler->RemoveTask("terminate_" + std::to_string(abilityRecord->GetAbilityRecordId()));
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
CHECK_POINTER_AND_RETURN_LOG(handler, ERR_INVALID_VALUE, "Fail to get AbilityTaskHandler.");
|
||||
handler->CancelTask("terminate_" + std::to_string(abilityRecord->GetAbilityRecordId()));
|
||||
auto self(shared_from_this());
|
||||
auto task = [self, abilityRecord]() { self->CompleteTerminate(abilityRecord); };
|
||||
handler->PostTask(task);
|
||||
handler->SubmitTask(task);
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
@@ -298,7 +304,7 @@ int UIAbilityLifecycleManager::DispatchTerminate(const std::shared_ptr<AbilityRe
|
||||
void UIAbilityLifecycleManager::CompleteForegroundSuccess(const std::shared_ptr<AbilityRecord> &abilityRecord)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
std::lock_guard<std::mutex> guard(sessionLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(sessionLock_);
|
||||
|
||||
CHECK_POINTER(abilityRecord);
|
||||
// ability do not save window mode
|
||||
@@ -327,7 +333,7 @@ void UIAbilityLifecycleManager::HandleForegroundFailed(const std::shared_ptr<Abi
|
||||
AbilityState state)
|
||||
{
|
||||
HILOG_DEBUG("state: %{public}d.", static_cast<int32_t>(state));
|
||||
std::lock_guard<std::mutex> guard(sessionLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(sessionLock_);
|
||||
if (ability == nullptr) {
|
||||
HILOG_ERROR("ability record is nullptr.");
|
||||
return;
|
||||
@@ -367,7 +373,7 @@ std::shared_ptr<AbilityRecord> UIAbilityLifecycleManager::GetAbilityRecordByToke
|
||||
|
||||
bool UIAbilityLifecycleManager::IsContainsAbility(const sptr<IRemoteObject> &token) const
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(sessionLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(sessionLock_);
|
||||
return IsContainsAbilityInner(token);
|
||||
}
|
||||
|
||||
@@ -433,7 +439,7 @@ void UIAbilityLifecycleManager::UpdateAbilityRecordLaunchReason(
|
||||
std::shared_ptr<AbilityRecord> UIAbilityLifecycleManager::GetUIAbilityRecordBySessionInfo(
|
||||
const sptr<SessionInfo> &sessionInfo)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(sessionLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(sessionLock_);
|
||||
CHECK_POINTER_AND_RETURN(sessionInfo, nullptr);
|
||||
CHECK_POINTER_AND_RETURN(sessionInfo->sessionToken, nullptr);
|
||||
auto sessionToken = iface_cast<Rosen::ISession>(sessionInfo->sessionToken);
|
||||
@@ -454,7 +460,7 @@ std::shared_ptr<AbilityRecord> UIAbilityLifecycleManager::GetUIAbilityRecordBySe
|
||||
int UIAbilityLifecycleManager::MinimizeUIAbility(const std::shared_ptr<AbilityRecord> &abilityRecord)
|
||||
{
|
||||
HILOG_DEBUG("call");
|
||||
std::lock_guard<std::mutex> guard(sessionLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(sessionLock_);
|
||||
if (abilityRecord == nullptr) {
|
||||
HILOG_ERROR("ability record is null");
|
||||
return ERR_INVALID_VALUE;
|
||||
@@ -506,7 +512,7 @@ int UIAbilityLifecycleManager::ResolveLocked(const AbilityRequest &abilityReques
|
||||
int UIAbilityLifecycleManager::CallAbilityLocked(const AbilityRequest &abilityRequest)
|
||||
{
|
||||
HILOG_DEBUG("Call.");
|
||||
std::lock_guard<std::mutex> guard(sessionLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(sessionLock_);
|
||||
|
||||
// Get target uiAbility record.
|
||||
std::shared_ptr<AbilityRecord> uiAbilityRecord;
|
||||
@@ -554,7 +560,7 @@ int UIAbilityLifecycleManager::CallAbilityLocked(const AbilityRequest &abilityRe
|
||||
void UIAbilityLifecycleManager::CallUIAbilityBySCB(const sptr<SessionInfo> &sessionInfo)
|
||||
{
|
||||
HILOG_DEBUG("Call.");
|
||||
std::lock_guard<std::mutex> guard(sessionLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(sessionLock_);
|
||||
if (sessionInfo == nullptr || sessionInfo->sessionToken == nullptr) {
|
||||
HILOG_ERROR("sessionInfo is invalid.");
|
||||
return;
|
||||
@@ -595,6 +601,9 @@ sptr<SessionInfo> UIAbilityLifecycleManager::CreateSessionInfo(const AbilityRequ
|
||||
sptr<SessionInfo> sessionInfo = new SessionInfo();
|
||||
sessionInfo->callerToken = abilityRequest.callerToken;
|
||||
sessionInfo->want = abilityRequest.want;
|
||||
if (abilityRequest.startSetting != nullptr) {
|
||||
sessionInfo->startSetting = abilityRequest.startSetting;
|
||||
}
|
||||
return sessionInfo;
|
||||
}
|
||||
|
||||
@@ -697,7 +706,7 @@ void UIAbilityLifecycleManager::PrintTimeOutLog(const std::shared_ptr<AbilityRec
|
||||
|
||||
void UIAbilityLifecycleManager::CompleteBackground(const std::shared_ptr<AbilityRecord> &abilityRecord)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(sessionLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(sessionLock_);
|
||||
if (abilityRecord->GetAbilityState() != AbilityState::BACKGROUNDING) {
|
||||
HILOG_ERROR("failed, ability state is %{public}d, it can't complete background.",
|
||||
abilityRecord->GetAbilityState());
|
||||
@@ -738,7 +747,7 @@ int UIAbilityLifecycleManager::CloseUIAbility(const std::shared_ptr<AbilityRecor
|
||||
int resultCode, const Want *resultWant)
|
||||
{
|
||||
HILOG_DEBUG("call");
|
||||
std::lock_guard<std::mutex> guard(sessionLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(sessionLock_);
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE);
|
||||
std::string element = abilityRecord->GetWant().GetElement().GetURI();
|
||||
@@ -782,7 +791,7 @@ int UIAbilityLifecycleManager::CloseUIAbility(const std::shared_ptr<AbilityRecor
|
||||
|
||||
void UIAbilityLifecycleManager::DelayCompleteTerminate(const std::shared_ptr<AbilityRecord> &abilityRecord)
|
||||
{
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
|
||||
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetTaskHandler();
|
||||
CHECK_POINTER(handler);
|
||||
|
||||
PrintTimeOutLog(abilityRecord, AbilityManagerService::TERMINATE_TIMEOUT_MSG);
|
||||
@@ -792,13 +801,13 @@ void UIAbilityLifecycleManager::DelayCompleteTerminate(const std::shared_ptr<Abi
|
||||
self->CompleteTerminate(abilityRecord);
|
||||
};
|
||||
int killTimeout = AmsConfigurationParameter::GetInstance().GetAppStartTimeoutTime() * KILL_TIMEOUT_MULTIPLE;
|
||||
handler->PostTask(timeoutTask, "DELAY_KILL_PROCESS", killTimeout);
|
||||
handler->SubmitTask(timeoutTask, "DELAY_KILL_PROCESS", killTimeout);
|
||||
}
|
||||
|
||||
void UIAbilityLifecycleManager::CompleteTerminate(const std::shared_ptr<AbilityRecord> &abilityRecord)
|
||||
{
|
||||
CHECK_POINTER(abilityRecord);
|
||||
std::lock_guard<std::mutex> guard(sessionLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(sessionLock_);
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
|
||||
if (abilityRecord->GetAbilityState() != AbilityState::TERMINATING) {
|
||||
@@ -903,7 +912,7 @@ void UIAbilityLifecycleManager::ReportEventToSuspendManager(const AppExecFwk::Ab
|
||||
void UIAbilityLifecycleManager::OnTimeOut(uint32_t msgId, int64_t abilityRecordId)
|
||||
{
|
||||
HILOG_DEBUG("call, msgId is %{public}d", msgId);
|
||||
std::lock_guard<std::mutex> guard(sessionLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(sessionLock_);
|
||||
std::shared_ptr<AbilityRecord> abilityRecord;
|
||||
for (auto iter = sessionAbilityMap_.begin(); iter != sessionAbilityMap_.end(); iter++) {
|
||||
if (iter->second != nullptr && iter->second->GetAbilityRecordId() == abilityRecordId) {
|
||||
@@ -998,7 +1007,7 @@ void UIAbilityLifecycleManager::HandleForegroundTimeout(const std::shared_ptr<Ab
|
||||
void UIAbilityLifecycleManager::OnAbilityDied(std::shared_ptr<AbilityRecord> abilityRecord)
|
||||
{
|
||||
HILOG_DEBUG("call");
|
||||
std::lock_guard<std::mutex> guard(sessionLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(sessionLock_);
|
||||
if (abilityRecord == nullptr) {
|
||||
HILOG_ERROR("failed, ability record is nullptr");
|
||||
return;
|
||||
@@ -1015,7 +1024,7 @@ void UIAbilityLifecycleManager::OnAbilityDied(std::shared_ptr<AbilityRecord> abi
|
||||
void UIAbilityLifecycleManager::OnAcceptWantResponse(const AAFwk::Want &want, const std::string &flag)
|
||||
{
|
||||
HILOG_DEBUG("call");
|
||||
std::lock_guard<std::mutex> guard(sessionLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(sessionLock_);
|
||||
if (abilityQueue_.empty()) {
|
||||
return;
|
||||
}
|
||||
@@ -1060,7 +1069,7 @@ void UIAbilityLifecycleManager::StartSpecifiedAbilityBySCB(const Want &want, int
|
||||
return;
|
||||
}
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(sessionLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(sessionLock_);
|
||||
EnqueueAbilityToFront(abilityRequest);
|
||||
}
|
||||
DelayedSingleton<AppScheduler>::GetInstance()->StartSpecifiedAbility(
|
||||
@@ -1174,7 +1183,7 @@ int UIAbilityLifecycleManager::StartAbilityBySpecifed(const AbilityRequest &abil
|
||||
sessionInfo->requestCode = abilityRequest.requestCode;
|
||||
SpecifiedInfo specifiedInfo;
|
||||
specifiedInfo.abilityName = abilityRequest.abilityInfo.name;
|
||||
specifiedInfo.abilityName = abilityRequest.abilityInfo.bundleName;
|
||||
specifiedInfo.bundleName = abilityRequest.abilityInfo.bundleName;
|
||||
specifiedInfo.flag = abilityRequest.specifiedFlag;
|
||||
specifiedInfoQueue_.push(specifiedInfo);
|
||||
|
||||
@@ -1185,7 +1194,7 @@ int UIAbilityLifecycleManager::StartAbilityBySpecifed(const AbilityRequest &abil
|
||||
void UIAbilityLifecycleManager::CallRequestDone(const std::shared_ptr<AbilityRecord> &abilityRecord,
|
||||
const sptr<IRemoteObject> &callStub)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(sessionLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(sessionLock_);
|
||||
if (abilityRecord == nullptr) {
|
||||
HILOG_ERROR("ability record is null.");
|
||||
return;
|
||||
@@ -1205,7 +1214,7 @@ int UIAbilityLifecycleManager::ReleaseCallLocked(
|
||||
CHECK_POINTER_AND_RETURN(connect, ERR_INVALID_VALUE);
|
||||
CHECK_POINTER_AND_RETURN(connect->AsObject(), ERR_INVALID_VALUE);
|
||||
|
||||
std::lock_guard<std::mutex> guard(sessionLock_);
|
||||
std::lock_guard<ffrt::mutex> guard(sessionLock_);
|
||||
|
||||
auto abilityRecords = GetAbilityRecordsByName(element);
|
||||
auto isExist = [connect] (const std::shared_ptr<AbilityRecord> &abilityRecord) {
|
||||
|
||||
@@ -27,24 +27,17 @@ TaskDataPersistenceMgr::TaskDataPersistenceMgr()
|
||||
|
||||
TaskDataPersistenceMgr::~TaskDataPersistenceMgr()
|
||||
{
|
||||
eventLoop_.reset();
|
||||
handler_.reset();
|
||||
HILOG_INFO("TaskDataPersistenceMgr instance is destroyed");
|
||||
}
|
||||
|
||||
bool TaskDataPersistenceMgr::Init(int userId)
|
||||
{
|
||||
if (!eventLoop_) {
|
||||
eventLoop_ = AppExecFwk::EventRunner::Create(THREAD_NAME);
|
||||
CHECK_POINTER_RETURN_BOOL(eventLoop_);
|
||||
}
|
||||
|
||||
if (!handler_) {
|
||||
handler_ = std::make_shared<AppExecFwk::EventHandler>(eventLoop_);
|
||||
handler_ = TaskHandlerWrap::GetFfrtHandler();
|
||||
CHECK_POINTER_RETURN_BOOL(handler_);
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(mutex_);
|
||||
if (missionDataStorageMgr_.find(userId) == missionDataStorageMgr_.end()) {
|
||||
currentMissionDataStorage_ = std::make_shared<MissionDataStorage>(userId);
|
||||
missionDataStorageMgr_.insert(std::make_pair(userId, currentMissionDataStorage_));
|
||||
@@ -60,7 +53,7 @@ bool TaskDataPersistenceMgr::Init(int userId)
|
||||
|
||||
bool TaskDataPersistenceMgr::LoadAllMissionInfo(std::list<InnerMissionInfo> &missionInfoList)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(mutex_);
|
||||
if (!currentMissionDataStorage_) {
|
||||
HILOG_ERROR("currentMissionDataStorage_ is nullptr");
|
||||
return false;
|
||||
@@ -71,7 +64,7 @@ bool TaskDataPersistenceMgr::LoadAllMissionInfo(std::list<InnerMissionInfo> &mis
|
||||
|
||||
bool TaskDataPersistenceMgr::SaveMissionInfo(const InnerMissionInfo &missionInfo)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(mutex_);
|
||||
if (!handler_ || !currentMissionDataStorage_) {
|
||||
HILOG_ERROR("handler_ or currentMissionDataStorage_ is nullptr");
|
||||
return false;
|
||||
@@ -84,12 +77,13 @@ bool TaskDataPersistenceMgr::SaveMissionInfo(const InnerMissionInfo &missionInfo
|
||||
missionDataStorage->SaveMissionInfo(missionInfo);
|
||||
}
|
||||
};
|
||||
return handler_->PostTask(SaveMissionInfoFunc, SAVE_MISSION_INFO);
|
||||
handler_->SubmitTask(SaveMissionInfoFunc, SAVE_MISSION_INFO);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TaskDataPersistenceMgr::DeleteMissionInfo(int missionId)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(mutex_);
|
||||
if (!handler_ || !currentMissionDataStorage_) {
|
||||
HILOG_ERROR("handler_ or currentMissionDataStorage_ is nullptr");
|
||||
return false;
|
||||
@@ -102,12 +96,13 @@ bool TaskDataPersistenceMgr::DeleteMissionInfo(int missionId)
|
||||
missionDataStorage->DeleteMissionInfo(missionId);
|
||||
}
|
||||
};
|
||||
return handler_->PostTask(DeleteMissionInfoFunc, DELETE_MISSION_INFO);
|
||||
handler_->SubmitTask(DeleteMissionInfoFunc, DELETE_MISSION_INFO);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TaskDataPersistenceMgr::RemoveUserDir(int32_t userId)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(mutex_);
|
||||
if (currentUserId_ == userId) {
|
||||
HILOG_ERROR("can not removed current user dir");
|
||||
return false;
|
||||
@@ -123,7 +118,7 @@ bool TaskDataPersistenceMgr::RemoveUserDir(int32_t userId)
|
||||
|
||||
bool TaskDataPersistenceMgr::SaveMissionSnapshot(int missionId, const MissionSnapshot& snapshot)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(mutex_);
|
||||
if (!handler_ || !currentMissionDataStorage_) {
|
||||
HILOG_ERROR("snapshot: handler_ or currentMissionDataStorage_ is nullptr");
|
||||
return false;
|
||||
@@ -136,7 +131,8 @@ bool TaskDataPersistenceMgr::SaveMissionSnapshot(int missionId, const MissionSna
|
||||
missionDataStorage->SaveMissionSnapshot(missionId, snapshot);
|
||||
}
|
||||
};
|
||||
return handler_->PostTask(SaveMissionSnapshotFunc, SAVE_MISSION_SNAPSHOT);
|
||||
handler_->SubmitTask(SaveMissionSnapshotFunc, SAVE_MISSION_SNAPSHOT);
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
@@ -152,7 +148,7 @@ std::shared_ptr<Media::PixelMap> TaskDataPersistenceMgr::GetSnapshot(int mission
|
||||
|
||||
bool TaskDataPersistenceMgr::GetMissionSnapshot(int missionId, MissionSnapshot& snapshot, bool isLowResolution)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
std::lock_guard<ffrt::mutex> lock(mutex_);
|
||||
if (!currentMissionDataStorage_) {
|
||||
HILOG_ERROR("snapshot: currentMissionDataStorage_ is nullptr");
|
||||
return false;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user