mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-11-23 07:10:19 +00:00
Merge branch 'master' into DuLiBianYi_20241014
Signed-off-by: zhubingwei <zhubingwei@huawei.com>
This commit is contained in:
commit
cbb3b09324
@ -109,6 +109,7 @@ declare_args() {
|
||||
ability_runtime_app_no_response_dialog = false
|
||||
ability_runtime_app_no_response_bundlename = "com.ohos.taskmanager"
|
||||
include_app_domain_verify = true
|
||||
ability_runtime_start_window_options_with_pixelmap = false
|
||||
|
||||
if (!defined(global_parts_info) ||
|
||||
defined(global_parts_info.account_os_account)) {
|
||||
|
12
bundle.json
12
bundle.json
@ -27,7 +27,8 @@
|
||||
"ability_runtime_graphics",
|
||||
"ability_runtime_power",
|
||||
"ability_runtime_app_no_response_dialog",
|
||||
"ability_runtime_app_no_response_bundlename"
|
||||
"ability_runtime_app_no_response_bundlename",
|
||||
"ability_runtime_start_window_options_with_pixelmap"
|
||||
],
|
||||
"adapted_system_type": [
|
||||
"standard"
|
||||
@ -495,6 +496,15 @@
|
||||
]
|
||||
},
|
||||
"name": "//foundation/ability/ability_runtime/frameworks/native/ability/native:dialog_request_callback"
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"header_base": "//foundation/ability/ability_runtime/interfaces/inner_api/ability_manager/include",
|
||||
"header_files": [
|
||||
"start_window_option.h"
|
||||
]
|
||||
},
|
||||
"name": "//foundation/ability/ability_runtime/interfaces/inner_api/ability_manager:start_window_option"
|
||||
}
|
||||
],
|
||||
"test": [
|
||||
|
@ -46,11 +46,13 @@ ohos_shared_library("cj_ability_ffi") {
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"napi:cj_bind_ffi",
|
||||
"napi:cj_bind_native",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"cj_ability_delegator.cpp",
|
||||
"cj_ability_delegator_args.cpp",
|
||||
"cj_application_context.cpp",
|
||||
"cj_element_name_ffi.cpp",
|
||||
"cj_utils_ffi.cpp",
|
||||
|
135
frameworks/cj/ffi/cj_ability_delegator_args.cpp
Normal file
135
frameworks/cj/ffi/cj_ability_delegator_args.cpp
Normal file
@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "cj_ability_delegator_args.h"
|
||||
#include "ability_delegator_registry.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "cj_utils_ffi.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityDelegatorArgsCJ {
|
||||
using namespace OHOS::FFI;
|
||||
using namespace OHOS::AbilityRuntime;
|
||||
|
||||
const int32_t INVALID_ARG = -1;
|
||||
|
||||
std::string CJAbilityDelegatorArgs::GetTestBundleName()
|
||||
{
|
||||
return delegatorArgs_->GetTestBundleName();
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> CJAbilityDelegatorArgs::GetTestParam()
|
||||
{
|
||||
return delegatorArgs_->GetTestParam();
|
||||
}
|
||||
|
||||
std::string CJAbilityDelegatorArgs::GetTestCaseName()
|
||||
{
|
||||
return delegatorArgs_->GetTestCaseName();
|
||||
}
|
||||
|
||||
std::string CJAbilityDelegatorArgs::GetTestRunnerClassName()
|
||||
{
|
||||
return delegatorArgs_->GetTestRunnerClassName();
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
int64_t FfiAbilityDelegatorRegistryGetArguments()
|
||||
{
|
||||
auto delegatorArgs = OHOS::AppExecFwk::AbilityDelegatorRegistry::GetArguments();
|
||||
if (delegatorArgs == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DELEGATOR, "null cj delegatorArgs");
|
||||
return INVALID_ARG;
|
||||
}
|
||||
auto cjDelegatorArgs = FFI::FFIData::Create<CJAbilityDelegatorArgs>(delegatorArgs);
|
||||
if (cjDelegatorArgs == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::CONTEXT, "cj delegatorArgs is null.");
|
||||
return INVALID_ARG;
|
||||
}
|
||||
return cjDelegatorArgs->GetID();
|
||||
}
|
||||
|
||||
char* FfiAbilityDelegatorArgsGetTestBundleName(int64_t id, int32_t *errCode)
|
||||
{
|
||||
auto cjDelegatorArgs = FFI::FFIData::GetData<CJAbilityDelegatorArgs>(id);
|
||||
if (cjDelegatorArgs == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DELEGATOR, "null cj delegatorArgs");
|
||||
*errCode = INVALID_ARG;
|
||||
return nullptr;
|
||||
}
|
||||
std::string bundleName = cjDelegatorArgs->GetTestBundleName();
|
||||
return CreateCStringFromString(bundleName);
|
||||
}
|
||||
|
||||
CRecord FfiAbilityDelegatorArgsGetTestParam(int64_t id, int32_t *errCode)
|
||||
{
|
||||
CRecord ret = { .keys = { .head = nullptr, .size = 0}, .values = { .head = nullptr, .size = 0}};
|
||||
auto cjDelegatorArgs = FFI::FFIData::GetData<CJAbilityDelegatorArgs>(id);
|
||||
if (cjDelegatorArgs == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DELEGATOR, "null cj delegatorArgs");
|
||||
*errCode = INVALID_ARG;
|
||||
return ret;
|
||||
}
|
||||
std::map<std::string, std::string> params = cjDelegatorArgs->GetTestParam();
|
||||
char** keysHead = static_cast<char**>(malloc(sizeof(char*) * params.size()));
|
||||
if (keysHead == nullptr) {
|
||||
*errCode = INVALID_ARG;
|
||||
return ret;
|
||||
}
|
||||
char** valuesHead = static_cast<char**>(malloc(sizeof(char*) * params.size()));
|
||||
if (valuesHead == nullptr) {
|
||||
*errCode = INVALID_ARG;
|
||||
free(keysHead);
|
||||
return ret;
|
||||
}
|
||||
int64_t i = 0;
|
||||
for (auto ¶m : params) {
|
||||
keysHead[i] = CreateCStringFromString(param.first);
|
||||
valuesHead[i] = CreateCStringFromString(param.second);
|
||||
i++;
|
||||
}
|
||||
ret.keys.size = params.size();
|
||||
ret.keys.head = keysHead;
|
||||
ret.values.size = params.size();
|
||||
ret.values.head = valuesHead;
|
||||
return ret;
|
||||
}
|
||||
|
||||
char* FfiAbilityDelegatorArgsGetTestCaseName(int64_t id, int32_t *errCode)
|
||||
{
|
||||
auto cjDelegatorArgs = FFI::FFIData::GetData<CJAbilityDelegatorArgs>(id);
|
||||
if (cjDelegatorArgs == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DELEGATOR, "null cj delegatorArgs");
|
||||
*errCode = INVALID_ARG;
|
||||
return nullptr;
|
||||
}
|
||||
std::string testCaseName = cjDelegatorArgs->GetTestCaseName();
|
||||
return CreateCStringFromString(testCaseName);
|
||||
}
|
||||
|
||||
char* FfiAbilityDelegatorArgsGetTestRunnerClassName(int64_t id, int32_t *errCode)
|
||||
{
|
||||
auto cjDelegatorArgs = FFI::FFIData::GetData<CJAbilityDelegatorArgs>(id);
|
||||
if (cjDelegatorArgs == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::DELEGATOR, "null cj delegatorArgs");
|
||||
*errCode = INVALID_ARG;
|
||||
return nullptr;
|
||||
}
|
||||
std::string testRunnerClassName = cjDelegatorArgs->GetTestRunnerClassName();
|
||||
return CreateCStringFromString(testRunnerClassName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
57
frameworks/cj/ffi/cj_ability_delegator_args.h
Normal file
57
frameworks/cj/ffi/cj_ability_delegator_args.h
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ABILITY_RUNTIME_CJ_ABILITY_DELEGATOR_ARGS_FFI_H
|
||||
#define OHOS_ABILITY_RUNTIME_CJ_ABILITY_DELEGATOR_ARGS_FFI_H
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "want.h"
|
||||
#include "ability_delegator_registry.h"
|
||||
#include "cj_macro.h"
|
||||
#include "cj_common_ffi.h"
|
||||
#include "ffi_remote_data.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityDelegatorArgsCJ {
|
||||
|
||||
class CJAbilityDelegatorArgs : public FFI::FFIData {
|
||||
public:
|
||||
explicit CJAbilityDelegatorArgs(const std::shared_ptr<AppExecFwk::AbilityDelegatorArgs>& abilityDelegatorArgs)
|
||||
: delegatorArgs_(abilityDelegatorArgs) {};
|
||||
std::string GetTestBundleName();
|
||||
std::map<std::string, std::string> GetTestParam();
|
||||
std::string GetTestCaseName();
|
||||
std::string GetTestRunnerClassName();
|
||||
private:
|
||||
std::shared_ptr<AppExecFwk::AbilityDelegatorArgs> delegatorArgs_;
|
||||
};
|
||||
|
||||
struct CRecord {
|
||||
CArrString keys;
|
||||
CArrString values;
|
||||
};
|
||||
|
||||
extern "C" {
|
||||
CJ_EXPORT int64_t FfiAbilityDelegatorRegistryGetArguments();
|
||||
CJ_EXPORT char* FfiAbilityDelegatorArgsGetTestBundleName(int64_t id, int32_t *errCode);
|
||||
CJ_EXPORT CRecord FfiAbilityDelegatorArgsGetTestParam(int64_t id, int32_t *errCode);
|
||||
CJ_EXPORT char* FfiAbilityDelegatorArgsGetTestCaseName(int64_t id, int32_t *errCode);
|
||||
CJ_EXPORT char* FfiAbilityDelegatorArgsGetTestRunnerClassName(int64_t id, int32_t *errCode);
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // OHOS_ABILITY_RUNTIME_CJ_ABILITY_DELEGATOR_ARGS_FFI_H
|
@ -267,7 +267,7 @@ napi_value JSAbilityDelegator::OnAddAbilityMonitor(napi_env env, NapiCallbackInf
|
||||
TAG_LOGI(AAFwkTag::DELEGATOR, "complete called");
|
||||
auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator();
|
||||
if (!delegator) {
|
||||
task.Reject(env, CreateJsError(env, COMMON_FAILED, "addAbilityMonitor failed."));
|
||||
task.Reject(env, CreateJsError(env, COMMON_FAILED, "Calling AddAbilityMonitor failed."));
|
||||
return;
|
||||
}
|
||||
delegator->AddAbilityMonitor(monitor);
|
||||
@ -295,7 +295,7 @@ napi_value JSAbilityDelegator::OnAddAbilityMonitorSync(napi_env env, NapiCallbac
|
||||
if (delegator) {
|
||||
delegator->AddAbilityMonitor(monitor);
|
||||
} else {
|
||||
ThrowError(env, COMMON_FAILED, "addAbilityMonitor failed.");
|
||||
ThrowError(env, COMMON_FAILED, "Calling AddAbilityMonitorSync failed.");
|
||||
}
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
@ -316,7 +316,7 @@ napi_value JSAbilityDelegator::OnAddAbilityStageMonitor(napi_env env, NapiCallba
|
||||
TAG_LOGI(AAFwkTag::DELEGATOR, "complete called");
|
||||
auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator();
|
||||
if (!delegator) {
|
||||
task.Reject(env, CreateJsError(env, COMMON_FAILED, "addAbilityStageMonitor failed."));
|
||||
task.Reject(env, CreateJsError(env, COMMON_FAILED, "Calling AddAbilityStageMonitor failed."));
|
||||
return;
|
||||
}
|
||||
delegator->AddAbilityStageMonitor(monitor);
|
||||
@ -347,7 +347,7 @@ napi_value JSAbilityDelegator::OnAddAbilityStageMonitorSync(napi_env env, NapiCa
|
||||
}
|
||||
auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator();
|
||||
if (!delegator) {
|
||||
ThrowError(env, COMMON_FAILED, "addAbilityStageMonitor failed.");
|
||||
ThrowError(env, COMMON_FAILED, "Calling AddAbilityStageMonitorSync failed.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
delegator->AddAbilityStageMonitor(monitor);
|
||||
@ -373,7 +373,7 @@ napi_value JSAbilityDelegator::OnRemoveAbilityMonitor(napi_env env, NapiCallback
|
||||
TAG_LOGI(AAFwkTag::DELEGATOR, "complete called");
|
||||
auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator();
|
||||
if (!delegator) {
|
||||
task.Reject(env, CreateJsError(env, COMMON_FAILED, "removeAbilityMonitor failed."));
|
||||
task.Reject(env, CreateJsError(env, COMMON_FAILED, "Calling RemoveAbilityMonitor failed."));
|
||||
return;
|
||||
}
|
||||
delegator->RemoveAbilityMonitor(monitor);
|
||||
@ -413,7 +413,7 @@ napi_value JSAbilityDelegator::OnRemoveAbilityMonitorSync(napi_env env, NapiCall
|
||||
}
|
||||
auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator();
|
||||
if (!delegator) {
|
||||
ThrowError(env, COMMON_FAILED, "removeAbilityMonitor failed.");
|
||||
ThrowError(env, COMMON_FAILED, "Calling RemoveAbilityMonitorSync failed.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
delegator->RemoveAbilityMonitor(monitor);
|
||||
@ -447,7 +447,7 @@ napi_value JSAbilityDelegator::OnRemoveAbilityStageMonitor(napi_env env, NapiCal
|
||||
|
||||
auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator();
|
||||
if (!delegator) {
|
||||
task.Reject(env, CreateJsError(env, COMMON_FAILED, "removeAbilityStageMonitor failed."));
|
||||
task.Reject(env, CreateJsError(env, COMMON_FAILED, "Calling RemoveAbilityStageMonitor failed."));
|
||||
return;
|
||||
}
|
||||
delegator->RemoveAbilityStageMonitor(monitor);
|
||||
@ -479,7 +479,7 @@ napi_value JSAbilityDelegator::OnRemoveAbilityStageMonitorSync(napi_env env, Nap
|
||||
|
||||
auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator();
|
||||
if (!delegator) {
|
||||
ThrowError(env, COMMON_FAILED, "removeAbilityStageMonitor failed.");
|
||||
ThrowError(env, COMMON_FAILED, "Calling RemoveAbilityStageMonitorSync failed.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
delegator->RemoveAbilityStageMonitor(monitor);
|
||||
@ -534,7 +534,7 @@ napi_value JSAbilityDelegator::OnWaitAbilityMonitor(napi_env env, NapiCallbackIn
|
||||
if (abilityObjectBox && !abilityObjectBox->object_.expired()) {
|
||||
ResolveWithNoError(env, task, abilityObjectBox->object_.lock()->GetNapiValue());
|
||||
} else {
|
||||
task.Reject(env, CreateJsError(env, COMMON_FAILED, "waitAbilityMonitor failed."));
|
||||
task.Reject(env, CreateJsError(env, COMMON_FAILED, "Calling WaitAbilityMonitor failed."));
|
||||
}
|
||||
};
|
||||
|
||||
@ -589,7 +589,7 @@ napi_value JSAbilityDelegator::OnWaitAbilityStageMonitor(napi_env env, NapiCallb
|
||||
if (abilityStageObjBox && !abilityStageObjBox->object_.expired()) {
|
||||
ResolveWithNoError(env, task, abilityStageObjBox->object_.lock()->GetNapiValue());
|
||||
} else {
|
||||
task.Reject(env, CreateJsError(env, COMMON_FAILED, "waitAbilityStageMonitor failed."));
|
||||
task.Reject(env, CreateJsError(env, COMMON_FAILED, "Calling WaitAbilityStageMonitor failed."));
|
||||
}
|
||||
};
|
||||
napi_value lastParam = nullptr;
|
||||
@ -778,14 +778,14 @@ napi_value JSAbilityDelegator::OnGetCurrentTopAbility(napi_env env, NapiCallback
|
||||
auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator();
|
||||
if (!delegator) {
|
||||
TAG_LOGE(AAFwkTag::DELEGATOR, "null delegator");
|
||||
task.Reject(env, CreateJsError(env, COMMON_FAILED, "getCurrentTopAbility failed."));
|
||||
task.Reject(env, CreateJsError(env, COMMON_FAILED, "Calling GetCurrentTopAbility failed."));
|
||||
return;
|
||||
}
|
||||
|
||||
auto property = delegator->GetCurrentTopAbility();
|
||||
if (!property || property->object_.expired()) {
|
||||
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid property");
|
||||
task.Reject(env, CreateJsError(env, COMMON_FAILED, "getCurrentTopAbility failed."));
|
||||
task.Reject(env, CreateJsError(env, COMMON_FAILED, "Calling GetCurrentTopAbility failed."));
|
||||
} else {
|
||||
{
|
||||
std::unique_lock<std::mutex> lck(g_mutexAbilityRecord);
|
||||
@ -850,13 +850,13 @@ napi_value JSAbilityDelegator::OnDoAbilityForeground(napi_env env, NapiCallbackI
|
||||
TAG_LOGI(AAFwkTag::DELEGATOR, "complete called");
|
||||
auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator();
|
||||
if (!delegator) {
|
||||
task.Reject(env, CreateJsError(env, COMMON_FAILED, "doAbilityForeground failed."));
|
||||
task.Reject(env, CreateJsError(env, COMMON_FAILED, "Calling DoAbilityForeground failed."));
|
||||
return;
|
||||
}
|
||||
if (delegator->DoAbilityForeground(remoteObject)) {
|
||||
ResolveWithNoError(env, task, CreateJsNull(env));
|
||||
} else {
|
||||
task.Reject(env, CreateJsError(env, COMMON_FAILED, "doAbilityForeground failed."));
|
||||
task.Reject(env, CreateJsError(env, COMMON_FAILED, "Calling DoAbilityForeground failed."));
|
||||
}
|
||||
};
|
||||
|
||||
@ -882,13 +882,13 @@ napi_value JSAbilityDelegator::OnDoAbilityBackground(napi_env env, NapiCallbackI
|
||||
TAG_LOGI(AAFwkTag::DELEGATOR, "complete called");
|
||||
auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator();
|
||||
if (!delegator) {
|
||||
task.Reject(env, CreateJsError(env, COMMON_FAILED, "doAbilityBackground failed."));
|
||||
task.Reject(env, CreateJsError(env, COMMON_FAILED, "Calling DoAbilityBackground failed."));
|
||||
return;
|
||||
}
|
||||
if (delegator->DoAbilityBackground(remoteObject)) {
|
||||
ResolveWithNoError(env, task, CreateJsNull(env));
|
||||
} else {
|
||||
task.Reject(env, CreateJsError(env, COMMON_FAILED, "doAbilityBackground failed."));
|
||||
task.Reject(env, CreateJsError(env, COMMON_FAILED, "Calling DoAbilityBackground failed."));
|
||||
}
|
||||
};
|
||||
|
||||
@ -915,7 +915,7 @@ napi_value JSAbilityDelegator::OnFinishTest(napi_env env, NapiCallbackInfo& info
|
||||
TAG_LOGI(AAFwkTag::DELEGATOR, "complete called");
|
||||
auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator();
|
||||
if (!delegator) {
|
||||
task.Reject(env, CreateJsError(env, COMMON_FAILED, "finishTest failed."));
|
||||
task.Reject(env, CreateJsError(env, COMMON_FAILED, "Calling FinishTest failed."));
|
||||
return;
|
||||
}
|
||||
delegator->FinishUserTest(msg, code);
|
||||
|
@ -27,7 +27,7 @@ const ERROR_CODE_INNER_ERROR = 16000050;
|
||||
|
||||
const ERROR_MSG_INVALID_PARAM = 'Invalid input parameter.';
|
||||
const ERROR_MSG_FUNC_REGISTERED = 'Method registered. The method has registered.';
|
||||
const ERROR_MSG_FUNC_NOT_EXIST = 'Method not registered. The method has not registered.';
|
||||
const ERROR_MSG_FUNC_NOT_EXIST = 'The method has not been registered.';
|
||||
const ERROR_MSG_INNER_ERROR = 'Inner Error.';
|
||||
|
||||
let errMap = new Map();
|
||||
|
@ -24,7 +24,7 @@ const ERROR_CODE_INNER_ERROR = 16000050;
|
||||
|
||||
const ERROR_MSG_INVALID_PARAM = 'Invalid input parameter.';
|
||||
const ERROR_MSG_CALLER_RELEASED = 'Caller released. The caller has been released.';
|
||||
const ERROR_MSG_CLAAEE_INVALID = 'Callee invalid. The callee does not exist.';
|
||||
const ERROR_MSG_CLAAEE_INVALID = 'The callee does not exist.';
|
||||
const ERROR_MSG_INNER_ERROR = 'Inner Error.';
|
||||
|
||||
let errMap = new Map();
|
||||
|
@ -69,6 +69,7 @@ ohos_shared_library("featureability") {
|
||||
if (ability_runtime_relational) {
|
||||
include_dirs += [ "data_ability/include" ]
|
||||
sources += [
|
||||
"data_ability/js_df_manager.cpp",
|
||||
"data_ability/js_utils.cpp",
|
||||
"data_ability/napi_data_ability_predicates.cpp",
|
||||
"data_ability/napi_rdb_js_utils.cpp",
|
||||
|
@ -44,6 +44,7 @@ ohos_shared_library("napi_common") {
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:process_options",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:start_window_option",
|
||||
"${ability_runtime_innerkits_path}/app_manager:app_manager",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
]
|
||||
@ -82,6 +83,12 @@ ohos_shared_library("napi_common") {
|
||||
]
|
||||
}
|
||||
|
||||
if (ability_runtime_graphics &&
|
||||
ability_runtime_start_window_options_with_pixelmap) {
|
||||
defines += [ "START_WINDOW_OPTIONS_WITH_PIXELMAP" ]
|
||||
external_deps += [ "image_framework:image" ]
|
||||
}
|
||||
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
subsystem_name = "ability"
|
||||
part_name = "ability_runtime"
|
||||
|
@ -20,6 +20,10 @@
|
||||
#include "napi_common_want.h"
|
||||
#include "int_wrapper.h"
|
||||
#include "process_options.h"
|
||||
#include "start_window_option.h"
|
||||
#ifdef START_WINDOW_OPTIONS_WITH_PIXELMAP
|
||||
#include "pixel_map_napi.h"
|
||||
#endif
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@ -59,6 +63,63 @@ bool UnwrapProcessOptions(napi_env env, napi_value param, std::shared_ptr<AAFwk:
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef START_WINDOW_OPTIONS_WITH_PIXELMAP
|
||||
bool UnwrapPixelMapFromJS(napi_env env, napi_value param, std::shared_ptr<Media::PixelMap> &value)
|
||||
{
|
||||
auto pixelMap = OHOS::Media::PixelMapNapi::GetPixelMap(env, param);
|
||||
if (!pixelMap) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "Unwrap pixelMap failed");
|
||||
return false;
|
||||
}
|
||||
value = pixelMap;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UnwrapPixelMapByPropertyName(
|
||||
napi_env env, napi_value jsObject, const char *propertyName, std::shared_ptr<Media::PixelMap> &value)
|
||||
{
|
||||
napi_value jsValue = GetPropertyValueByPropertyName(env, jsObject, propertyName, napi_object);
|
||||
if (jsValue == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return UnwrapPixelMapFromJS(env, jsValue, value);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool UnwrapStartWindowOption(napi_env env, napi_value param,
|
||||
std::shared_ptr<AAFwk::StartWindowOption> &startWindowOption)
|
||||
{
|
||||
auto option = std::make_shared<AAFwk::StartWindowOption>();
|
||||
std::string startWindowBackgroundColor;
|
||||
if (IsExistsByPropertyName(env, param, "startWindowBackgroundColor")) {
|
||||
if (!UnwrapStringByPropertyName(env, param, "startWindowBackgroundColor", startWindowBackgroundColor)) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "Unwrap startWindowBackgroundColor failed");
|
||||
return false;
|
||||
}
|
||||
option->startWindowBackgroundColor = startWindowBackgroundColor;
|
||||
}
|
||||
if (!startWindowBackgroundColor.empty()) {
|
||||
option->hasStartWindow = true;
|
||||
}
|
||||
|
||||
#ifdef START_WINDOW_OPTIONS_WITH_PIXELMAP
|
||||
std::shared_ptr<Media::PixelMap> startWindowIcon = nullptr;
|
||||
if (IsExistsByPropertyName(env, param, "startWindowIcon")) {
|
||||
if (!UnwrapPixelMapByPropertyName(env, param, "startWindowIcon", startWindowIcon)) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "Unwrap startWindowIcon failed");
|
||||
return false;
|
||||
}
|
||||
option->startWindowIcon = startWindowIcon;
|
||||
}
|
||||
if (startWindowIcon != nullptr) {
|
||||
option->hasStartWindow = true;
|
||||
}
|
||||
#endif
|
||||
startWindowOption = option;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UnwrapStartOptionsWithProcessOption(napi_env env, napi_value param, AAFwk::StartOptions &startOptions)
|
||||
{
|
||||
UnwrapStartOptions(env, param, startOptions);
|
||||
@ -66,6 +127,10 @@ bool UnwrapStartOptionsWithProcessOption(napi_env env, napi_value param, AAFwk::
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "Unwrap processOptions failed");
|
||||
return false;
|
||||
}
|
||||
if (!UnwrapStartWindowOption(env, param, startOptions.startWindowOption)) {
|
||||
TAG_LOGE(AAFwkTag::JSNAPI, "Unwrap startWindowOption failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,16 @@ bool UnwrapStartOptions(napi_env env, napi_value param, AAFwk::StartOptions &sta
|
||||
|
||||
bool UnwrapStartOptionsAndWant(napi_env env, napi_value param, AAFwk::StartOptions &startOptions, AAFwk::Want &want);
|
||||
|
||||
#ifdef START_WINDOW_OPTIONS_WITH_PIXELMAP
|
||||
bool UnwrapPixelMapByPropertyName(
|
||||
napi_env env, napi_value jsObject, const char *propertyName, std::shared_ptr<Media::PixelMap> &value);
|
||||
|
||||
bool UnwrapPixelMapFromJS(napi_env env, napi_value param, std::shared_ptr<Media::PixelMap> &value);
|
||||
#endif
|
||||
|
||||
bool UnwrapStartWindowOption(napi_env env, napi_value param,
|
||||
std::shared_ptr<AAFwk::StartWindowOption> &startWindowOption);
|
||||
|
||||
EXTERN_C_END
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -86,7 +86,7 @@ private:
|
||||
OHOS::AAFwk::Want want;
|
||||
if (!OHOS::AppExecFwk::UnwrapWant(env, info.argv[0], want)) {
|
||||
TAG_LOGE(AAFwkTag::DIALOG, "UnwrapWant failed");
|
||||
ThrowInvalidParamError(env, "Parse param want failed, must be a Want");
|
||||
ThrowInvalidParamError(env, "Parse param want failed, must be a Want.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
@ -124,14 +124,14 @@ private:
|
||||
OHOS::AAFwk::Want want;
|
||||
if (!OHOS::AppExecFwk::UnwrapWant(env, info.argv[0], want)) {
|
||||
TAG_LOGE(AAFwkTag::DIALOG, "The input want is invalid");
|
||||
ThrowInvalidParamError(env, "Parse param want failed, must be a Want");
|
||||
ThrowInvalidParamError(env, "Parse param want failed, must be a Want.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> remoteObj = want.GetRemoteObject(RequestConstants::REQUEST_CALLBACK_KEY);
|
||||
if (!remoteObj) {
|
||||
TAG_LOGE(AAFwkTag::DIALOG, "Wrap Param requestCallback failed, must be a RequestCallback");
|
||||
ThrowInvalidParamError(env, "Wrap Param requestCallback failed, must be a RequestCallback");
|
||||
ThrowInvalidParamError(env, "Wrap Param requestCallback failed, must be a RequestCallback.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
|
@ -91,19 +91,19 @@ private:
|
||||
std::string dialogSessionId = "";
|
||||
if (!ConvertFromJsValue(env, info.argv[0], dialogSessionId)) {
|
||||
TAG_LOGE(AAFwkTag::DIALOG, "Failed unwrap dialogSessionId");
|
||||
ThrowInvalidParamError(env, "Parameter error: dialogSessionId must be a valid string");
|
||||
ThrowInvalidParamError(env, "Parameter error: dialogSessionId must be a valid string.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
AAFwk::Want want;
|
||||
if (!AppExecFwk::UnwrapWant(env, info.argv[1], want)) {
|
||||
TAG_LOGE(AAFwkTag::DIALOG, "Failed unwrap want");
|
||||
ThrowInvalidParamError(env, "Parameter error: want must be a Want");
|
||||
ThrowInvalidParamError(env, "Parameter error: want must be a Want.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
bool isAllow = false;
|
||||
if (!ConvertFromJsValue(env, info.argv[ARGC_TWO], isAllow)) {
|
||||
TAG_LOGE(AAFwkTag::DIALOG, "Failed unwrap isAllow");
|
||||
ThrowInvalidParamError(env, "Parameter error: isAllow must be a Boolean");
|
||||
ThrowInvalidParamError(env, "Parameter error: isAllow must be a Boolean.");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
NapiAsyncTask::CompleteCallback complete =
|
||||
|
@ -681,8 +681,7 @@ private:
|
||||
|
||||
NapiAsyncTask::CompleteCallback complete =
|
||||
[missionIds, topMissionId](napi_env env, NapiAsyncTask &task, int32_t status) {
|
||||
auto ret =
|
||||
AAFwk::AbilityManagerClient::GetInstance()->MoveMissionsToForeground(missionIds, topMissionId);
|
||||
auto ret = AbilityManagerClient::GetInstance()->MoveMissionsToForeground(missionIds, topMissionId);
|
||||
if (ret == 0) {
|
||||
task.ResolveWithNoError(env, CreateJsUndefined(env));
|
||||
} else {
|
||||
@ -690,7 +689,6 @@ private:
|
||||
CreateJsErrorByNativeErr(env, ret, PermissionConstants::PERMISSION_MANAGE_MISSION));
|
||||
}
|
||||
};
|
||||
|
||||
napi_value lastParam = (argc > unwrapArgc) ? argv[unwrapArgc] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::ScheduleHighQos("MissionManager::OnMoveMissionsToForeground", env,
|
||||
|
@ -64,6 +64,7 @@ ohos_shared_library("particleability") {
|
||||
if (ability_runtime_relational) {
|
||||
include_dirs += [ "../featureAbility/data_ability/include" ]
|
||||
sources += [
|
||||
"../featureAbility/data_ability/js_df_manager.cpp",
|
||||
"../featureAbility/data_ability/js_utils.cpp",
|
||||
"../featureAbility/data_ability/napi_data_ability_predicates.cpp",
|
||||
"../featureAbility/data_ability/napi_rdb_js_utils.cpp",
|
||||
|
@ -107,7 +107,7 @@ private:
|
||||
"Only support file URI."));
|
||||
} else if (errCode == AAFwk::ERR_CODE_GRANT_URI_PERMISSION) {
|
||||
task.Reject(env, CreateJsError(env, ERR_ABILITY_RUNTIME_EXTERNAL_GRANT_URI_PERMISSION,
|
||||
"Sandbox application can not grant URI permission."));
|
||||
"A sandbox application cannot grant URI permission."));
|
||||
} else {
|
||||
task.Reject(env, CreateJsError(env, ERR_ABILITY_RUNTIME_EXTERNAL_INTERNAL_ERROR,
|
||||
"Internal Error."));
|
||||
|
@ -34,7 +34,7 @@ void AbilityConnection::OnAbilityConnectDone(
|
||||
element.GetBundleName().c_str(), element.GetAbilityName().c_str(), resultCode);
|
||||
mutex_.lock();
|
||||
if (abilityConnectCallbackList_.empty()) {
|
||||
TAG_LOGD(AAFwkTag::CONNECTION, "empty abilityConnectCallbackList");
|
||||
TAG_LOGW(AAFwkTag::CONNECTION, "empty callbackList");
|
||||
mutex_.unlock();
|
||||
return;
|
||||
}
|
||||
|
@ -694,6 +694,10 @@ ErrCode AbilityContextImpl::RequestDialogService(napi_env env, AAFwk::Want &want
|
||||
auto resultTask =
|
||||
[env, outTask = std::move(task)](int32_t resultCode, const AAFwk::Want &resultWant) {
|
||||
auto retData = new (std::nothrow) RequestResult();
|
||||
if (retData == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::CONTEXT, "null retData");
|
||||
return;
|
||||
}
|
||||
retData->resultCode = resultCode;
|
||||
retData->resultWant = resultWant;
|
||||
retData->task = std::move(outTask);
|
||||
@ -705,6 +709,10 @@ ErrCode AbilityContextImpl::RequestDialogService(napi_env env, AAFwk::Want &want
|
||||
return;
|
||||
}
|
||||
auto work = new (std::nothrow) uv_work_t;
|
||||
if (work == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::CONTEXT, "null work");
|
||||
return;
|
||||
}
|
||||
work->data = static_cast<void*>(retData);
|
||||
int rev = uv_queue_work_with_qos(
|
||||
loop,
|
||||
|
@ -1621,8 +1621,8 @@ ohos_shared_library("auto_startup_callback") {
|
||||
include_dirs = [ "${ability_runtime_path}/interfaces/kits/native/ability/native/ability_business_error" ]
|
||||
|
||||
sources = [
|
||||
"${ability_runtime_native_path}/ability/native/auto_startup_callback_proxy.cpp",
|
||||
"${ability_runtime_native_path}/ability/native/auto_startup_callback_stub.cpp",
|
||||
"${ability_runtime_native_path}/ability/native/auto_startup_callback/auto_startup_callback_proxy.cpp",
|
||||
"${ability_runtime_native_path}/ability/native/auto_startup_callback/auto_startup_callback_stub.cpp",
|
||||
]
|
||||
|
||||
deps = [ "${ability_runtime_innerkits_path}/ability_manager:ability_manager" ]
|
||||
|
@ -32,11 +32,11 @@ constexpr const char* ERROR_MSG_CAPABILITY_NOT_SUPPORT = "Capability not support
|
||||
constexpr const char* ERROR_MSG_INNER = "Internal error.";
|
||||
constexpr const char* ERROR_MSG_RESOLVE_ABILITY = "The specified ability does not exist.";
|
||||
constexpr const char* ERROR_MSG_INVALID_ABILITY_TYPE = "Incorrect ability type.";
|
||||
constexpr const char* ERROR_MSG_INVALID_ID = "Input error. The specified ID does not exist.";
|
||||
constexpr const char* ERROR_MSG_INVISIBLE = "Can not start invisible component.";
|
||||
constexpr const char* ERROR_MSG_INVALID_ID = "The specified ID does not exist.";
|
||||
constexpr const char* ERROR_MSG_INVISIBLE = "Failed to start the invisible ability.";
|
||||
constexpr const char* ERROR_MSG_STATIC_CFG_PERMISSION = "The specified process does not have the permission.";
|
||||
constexpr const char* ERROR_MSG_CROSS_USER = "Cross-user operations are not allowed.";
|
||||
constexpr const char* ERROR_MSG_SERVICE_BUSY = "Service busy.Try again later.";
|
||||
constexpr const char* ERROR_MSG_SERVICE_BUSY = "Service busy. There are concurrent tasks. Try again later.";
|
||||
constexpr const char* ERROR_MSG_CROWDTEST_EXPIRED = "The crowdtesting application expires.";
|
||||
constexpr const char* ERROR_MSG_WUKONG_MODE = "An ability cannot be started or stopped in Wukong mode.";
|
||||
constexpr const char* ERROR_MSG_CONTINUATION_FLAG = "The call with the continuation flag is forbidden.";
|
||||
@ -53,28 +53,29 @@ constexpr const char* ERROR_MSG_FREE_INSTALL_OTHERS = "Installation-free is not
|
||||
constexpr const char* ERROR_MSG_FREE_INSTALL_CROSS_DEVICE = "Cross-device installation-free is not supported.";
|
||||
constexpr const char* ERROR_MSG_INVALID_URI_FLAG = "Invalid URI flag.";
|
||||
constexpr const char* ERROR_MSG_INVALID_URI_TYPE = "Invalid URI type, only support file Uri.";
|
||||
constexpr const char* ERROR_MSG_GRANT_URI_PERMISSION = "Sandbox application can not grant URI permission.";
|
||||
constexpr const char* ERROR_MSG_GRANT_URI_PERMISSION = "A sandbox application cannot grant URI permission.";
|
||||
constexpr const char* ERROR_MSG_OPERATION_NOT_SUPPORTED = "Operation not supported.";
|
||||
constexpr const char* ERROR_MSG_CHILD_PROCESS_NUMBER_EXCEEDS_UPPER_BOUND =
|
||||
"The number of child process exceeds upper bound.";
|
||||
"The number of child processes exceeds the upper limit.";
|
||||
constexpr const char* ERROR_MSG_RESTART_APP_INCORRECT_ABILITY =
|
||||
"The target to restart does not belong to the current app or is not a UIAbility.";
|
||||
"The target to restart does not belong to the current application or is not a UIAbility.";
|
||||
constexpr const char* ERROR_MSG_RESTART_APP_FREQUENT = "Restart too frequently. Try again at least 10s later.";
|
||||
constexpr const char* ERROR_MSG_INVALID_CALLER = "The caller has been released.";
|
||||
constexpr const char* ERROR_MSG_NO_MISSION_ID = "The specified mission does not exist.";
|
||||
constexpr const char* ERROR_MSG_NO_MISSION_LISTENER = "Input error. The specified mission listener does not exist.";
|
||||
constexpr const char* ERROR_MSG_START_ABILITY_WAITTING = "The previous ability is starting, wait start later.";
|
||||
constexpr const char* ERROR_MSG_NOT_SELF_APPLICATION = "The target application is not self application.";
|
||||
constexpr const char* ERROR_MSG_NO_MISSION_LISTENER = "The specified mission listener does not exist.";
|
||||
constexpr const char* ERROR_MSG_START_ABILITY_WAITTING =
|
||||
"Another ability is being started. Wait until it finishes starting.";
|
||||
constexpr const char* ERROR_MSG_NOT_SELF_APPLICATION = "The target application is not the current application.";
|
||||
constexpr const char* ERROR_MSG_ABILITY_NOT_FOREGROUND =
|
||||
"The interface can be called only when ability is foreground.";
|
||||
"The API can be called only when the ability is running in the foreground.";
|
||||
constexpr const char* ERROR_MSG_WUKONG_MODE_CANT_MOVE_STATE =
|
||||
"An ability cannot move to foreground or background in Wukong mode.";
|
||||
constexpr const char* ERROR_MSG_START_OPTIONS_CHECK_FAILED = "Start options check failed.";
|
||||
constexpr const char* ERROR_MSG_ABILITY_ALREADY_RUNNING = "Ability already running.";
|
||||
"An ability cannot switch to the foreground or background in Wukong mode.";
|
||||
constexpr const char* ERROR_MSG_START_OPTIONS_CHECK_FAILED = "The StartOptions check failed.";
|
||||
constexpr const char* ERROR_MSG_ABILITY_ALREADY_RUNNING = "The ability is already running.";
|
||||
constexpr const char* ERROR_MSG_NOT_SUPPORT_CROSS_APP_START =
|
||||
"The application is not allow jumping to other applications when api version is above 11.";
|
||||
constexpr const char* ERROR_MSG_CANNOT_MATCH_ANY_COMPONENT = "Can not match any component.";
|
||||
constexpr const char* ERROR_MSG_TARGET_BUNDLE_NOT_EXIST = "The target bundle does not exist.";
|
||||
"Redirection to a third-party application is not allowed in API version 11 or later.";
|
||||
constexpr const char* ERROR_MSG_CANNOT_MATCH_ANY_COMPONENT = "No matching ability is found.";
|
||||
constexpr const char* ERROR_MSG_TARGET_BUNDLE_NOT_EXIST = "The bundle does not exist or no patch has been applied.";
|
||||
constexpr const char* ERROR_MSG_NO_RESIDENT_PERMISSION =
|
||||
"The caller application can only set the resident status of the configured process.";
|
||||
constexpr const char* ERROR_MSG_MULTI_APP_NOT_SUPPORTED = "App clone or multi-instance is not supported.";
|
||||
|
@ -554,7 +554,7 @@ bool JsAbility::OnBackPress()
|
||||
bool JsAbility::OnPrepareTerminate()
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
TAG_LOGI(AAFwkTag::ABILITY, "prepare terminate call, ability: %{public}s", GetAbilityName().c_str());
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "call, ability: %{public}s", GetAbilityName().c_str());
|
||||
Ability::OnPrepareTerminate();
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
auto env = jsRuntime_.GetNapiEnv();
|
||||
|
@ -377,19 +377,14 @@ napi_value JsAbilityContext::HideAbility(napi_env env, napi_callback_info info)
|
||||
GET_NAPI_INFO_AND_CALL(env, info, JsAbilityContext, OnHideAbility);
|
||||
}
|
||||
|
||||
napi_value JsAbilityContext::OpenAtomicService(napi_env env, napi_callback_info info)
|
||||
{
|
||||
GET_NAPI_INFO_AND_CALL(env, info, JsAbilityContext, OnOpenAtomicService);
|
||||
}
|
||||
|
||||
napi_value JsAbilityContext::MoveAbilityToBackground(napi_env env, napi_callback_info info)
|
||||
{
|
||||
GET_NAPI_INFO_AND_CALL(env, info, JsAbilityContext, OnMoveAbilityToBackground);
|
||||
}
|
||||
|
||||
napi_value JsAbilityContext::SetRestoreEnabled(napi_env env, napi_callback_info info)
|
||||
napi_value JsAbilityContext::OpenAtomicService(napi_env env, napi_callback_info info)
|
||||
{
|
||||
GET_NAPI_INFO_AND_CALL(env, info, JsAbilityContext, OnSetRestoreEnabled);
|
||||
GET_NAPI_INFO_AND_CALL(env, info, JsAbilityContext, OnOpenAtomicService);
|
||||
}
|
||||
|
||||
napi_value JsAbilityContext::StartUIServiceExtension(napi_env env, napi_callback_info info)
|
||||
@ -407,6 +402,11 @@ napi_value JsAbilityContext::DisconnectUIServiceExtension(napi_env env, napi_cal
|
||||
GET_NAPI_INFO_AND_CALL(env, info, JsAbilityContext, OnDisconnectUIServiceExtension);
|
||||
}
|
||||
|
||||
napi_value JsAbilityContext::SetRestoreEnabled(napi_env env, napi_callback_info info)
|
||||
{
|
||||
GET_NAPI_INFO_AND_CALL(env, info, JsAbilityContext, OnSetRestoreEnabled);
|
||||
}
|
||||
|
||||
void JsAbilityContext::ClearFailedCallConnection(
|
||||
const std::weak_ptr<AbilityContext>& abilityContext, const std::shared_ptr<CallerCallBack> &callback)
|
||||
{
|
||||
@ -2029,16 +2029,16 @@ napi_value CreateJsAbilityContext(napi_env env, std::shared_ptr<AbilityContext>
|
||||
JsAbilityContext::ShowAbility);
|
||||
BindNativeFunction(env, object, "hideAbility", moduleName,
|
||||
JsAbilityContext::HideAbility);
|
||||
BindNativeFunction(env, object, "openAtomicService", moduleName,
|
||||
JsAbilityContext::OpenAtomicService);
|
||||
BindNativeFunction(env, object, "moveAbilityToBackground", moduleName, JsAbilityContext::MoveAbilityToBackground);
|
||||
BindNativeFunction(env, object, "setRestoreEnabled", moduleName, JsAbilityContext::SetRestoreEnabled);
|
||||
BindNativeFunction(env, object, "openAtomicService", moduleName, JsAbilityContext::OpenAtomicService);
|
||||
BindNativeFunction(env, object, "startUIServiceExtensionAbility", moduleName,
|
||||
JsAbilityContext::StartUIServiceExtension);
|
||||
BindNativeFunction(env, object, "connectUIServiceExtensionAbility", moduleName,
|
||||
JsAbilityContext::ConnectUIServiceExtension);
|
||||
BindNativeFunction(env, object, "disconnectUIServiceExtensionAbility", moduleName,
|
||||
JsAbilityContext::DisconnectUIServiceExtension);
|
||||
BindNativeFunction(env, object, "setRestoreEnabled", moduleName, JsAbilityContext::SetRestoreEnabled);
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
BindNativeFunction(env, object, "setMissionLabel", moduleName, JsAbilityContext::SetMissionLabel);
|
||||
BindNativeFunction(env, object, "setMissionIcon", moduleName, JsAbilityContext::SetMissionIcon);
|
||||
@ -2149,7 +2149,11 @@ void JSAbilityConnection::HandleOnAbilityConnectDone(const AppExecFwk::ElementNa
|
||||
// wrap RemoteObject
|
||||
napi_value napiRemoteObject = NAPI_ohos_rpc_CreateJsRemoteObject(env_, remoteObject);
|
||||
napi_value argv[] = { ConvertElement(element), napiRemoteObject };
|
||||
napi_call_function(env_, obj, methodOnConnect, ARGC_TWO, argv, nullptr);
|
||||
TAG_LOGI(AAFwkTag::CONTEXT, "Call onConnect");
|
||||
napi_status status = napi_call_function(env_, obj, methodOnConnect, ARGC_TWO, argv, nullptr);
|
||||
if (status != napi_ok) {
|
||||
TAG_LOGE(AAFwkTag::CONTEXT, "call js func failed %{public}d", status);
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::CONTEXT, "end");
|
||||
}
|
||||
|
||||
@ -2213,8 +2217,11 @@ void JSAbilityConnection::HandleOnAbilityDisconnectDone(const AppExecFwk::Elemen
|
||||
}
|
||||
|
||||
napi_value argv[] = { ConvertElement(element) };
|
||||
TAG_LOGD(AAFwkTag::CONTEXT, "success");
|
||||
napi_call_function(env_, obj, method, ARGC_ONE, argv, nullptr);
|
||||
TAG_LOGI(AAFwkTag::CONTEXT, "Call onDisconnect");
|
||||
napi_status status = napi_call_function(env_, obj, method, ARGC_ONE, argv, nullptr);
|
||||
if (status != napi_ok) {
|
||||
TAG_LOGE(AAFwkTag::CONTEXT, "call js func failed %{public}d", status);
|
||||
}
|
||||
}
|
||||
|
||||
void JSAbilityConnection::CallJsFailed(int32_t errorCode)
|
||||
@ -2601,6 +2608,36 @@ napi_value JsAbilityContext::ChangeAbilityVisibility(napi_env env, NapiCallbackI
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value JsAbilityContext::OnMoveAbilityToBackground(napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::CONTEXT, "start");
|
||||
auto abilityContext = context_.lock();
|
||||
|
||||
NapiAsyncTask::CompleteCallback complete =
|
||||
[weak = context_](napi_env env, NapiAsyncTask& task, int32_t status) {
|
||||
TAG_LOGD(AAFwkTag::CONTEXT, "start task");
|
||||
auto context = weak.lock();
|
||||
if (!context) {
|
||||
TAG_LOGW(AAFwkTag::CONTEXT, "released context");
|
||||
task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INVALID_CONTEXT));
|
||||
return;
|
||||
}
|
||||
|
||||
auto errcode = context->MoveUIAbilityToBackground();
|
||||
if (errcode == 0) {
|
||||
task.ResolveWithNoError(env, CreateJsUndefined(env));
|
||||
} else {
|
||||
task.Reject(env, CreateJsErrorByNativeErr(env, errcode));
|
||||
}
|
||||
};
|
||||
|
||||
napi_value lastParam = (info.argc > ARGC_ZERO) ? info.argv[INDEX_ZERO] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::ScheduleHighQos("JsAbilityContext::OnMoveAbilityToBackground",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value JsAbilityContext::OnOpenAtomicService(napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
if (info.argc == ARGC_ZERO) {
|
||||
@ -2675,39 +2712,6 @@ napi_value JsAbilityContext::OpenAtomicServiceInner(napi_env env, NapiCallbackIn
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value JsAbilityContext::OnMoveAbilityToBackground(napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::CONTEXT, "start");
|
||||
auto abilityContext = context_.lock();
|
||||
auto innerErrCode = std::make_shared<ErrCode>(ERR_OK);
|
||||
NapiAsyncTask::ExecuteCallback execute =
|
||||
[weak = context_, innerErrCode]() {
|
||||
auto context = weak.lock();
|
||||
if (!context) {
|
||||
TAG_LOGW(AAFwkTag::CONTEXT, "released context");
|
||||
*innerErrCode = static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INVALID_CONTEXT);
|
||||
return;
|
||||
}
|
||||
*innerErrCode = context->MoveUIAbilityToBackground();
|
||||
};
|
||||
NapiAsyncTask::CompleteCallback complete =
|
||||
[innerErrCode](napi_env env, NapiAsyncTask& task, int32_t status) {
|
||||
if (*innerErrCode == ERR_OK) {
|
||||
task.ResolveWithNoError(env, CreateJsUndefined(env));
|
||||
} else if (*innerErrCode == static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INVALID_CONTEXT)) {
|
||||
task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INVALID_CONTEXT));
|
||||
} else {
|
||||
task.Reject(env, CreateJsErrorByNativeErr(env, *innerErrCode));
|
||||
}
|
||||
};
|
||||
|
||||
napi_value lastParam = (info.argc > ARGC_ZERO) ? info.argv[INDEX_ZERO] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::ScheduleHighQos("JsAbilityContext::OnMoveAbilityToBackground",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, std::move(execute), std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value JsAbilityContext::OnSetRestoreEnabled(napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::CONTEXT, "called");
|
||||
|
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -151,7 +151,7 @@ JsUIAbility::JsUIAbility(JsRuntime &jsRuntime) : jsRuntime_(jsRuntime)
|
||||
|
||||
JsUIAbility::~JsUIAbility()
|
||||
{
|
||||
//"maintenance log
|
||||
//maintenance log
|
||||
TAG_LOGI(AAFwkTag::UIABILITY, "called");
|
||||
if (abilityContext_ != nullptr) {
|
||||
abilityContext_->Unbind();
|
||||
@ -231,10 +231,7 @@ void JsUIAbility::SetAbilityContext(std::shared_ptr<AbilityInfo> abilityInfo,
|
||||
napi_value contextObj = nullptr;
|
||||
int32_t screenMode = want->GetIntParam(AAFwk::SCREEN_MODE_KEY, AAFwk::ScreenMode::IDLE_SCREEN_MODE);
|
||||
CreateJSContext(env, contextObj, screenMode);
|
||||
if (shellContextRef_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::UIABILITY, "null shellContextRef_");
|
||||
return;
|
||||
}
|
||||
CHECK_POINTER(shellContextRef_);
|
||||
contextObj = shellContextRef_->GetNapiValue();
|
||||
if (!CheckTypeForNapiValue(env, contextObj, napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::UIABILITY, "get ability native object failed");
|
||||
@ -244,7 +241,11 @@ void JsUIAbility::SetAbilityContext(std::shared_ptr<AbilityInfo> abilityInfo,
|
||||
CHECK_POINTER(workContext);
|
||||
screenModePtr_ = std::make_shared<int32_t>(screenMode);
|
||||
auto workScreenMode = new (std::nothrow) std::weak_ptr<int32_t>(screenModePtr_);
|
||||
CHECK_POINTER(workScreenMode);
|
||||
if (workScreenMode == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::UIABILITY, "workScreenMode nullptr");
|
||||
delete workContext;
|
||||
return;
|
||||
}
|
||||
napi_coerce_to_native_binding_object(
|
||||
env, contextObj, DetachCallbackFunc, AttachJsAbilityContext, workContext, workScreenMode);
|
||||
abilityContext_->Bind(jsRuntime_, shellContextRef_.get());
|
||||
|
@ -111,8 +111,13 @@ private:
|
||||
|
||||
std::string strFormId;
|
||||
ConvertFromJsValue(env, info.argv[0], strFormId);
|
||||
int64_t formId = strFormId.empty() ? -1 : std::stoll(strFormId);
|
||||
|
||||
int64_t formId = 0;
|
||||
try {
|
||||
formId = strFormId.empty() ? -1 : std::stoll(strFormId);
|
||||
}catch (...) {
|
||||
TAG_LOGE(AAFwkTag::FORM_EXT, "stoll error strFormId:%{public}s", strFormId.c_str());
|
||||
}
|
||||
|
||||
AppExecFwk::FormProviderData formProviderData;
|
||||
std::string formDataStr = "{}";
|
||||
if (CheckTypeForNapiValue(env, info.argv[1], napi_object)) {
|
||||
|
@ -224,7 +224,7 @@ void JsServiceExtension::ListenWMS()
|
||||
return;
|
||||
}
|
||||
|
||||
auto saStatusChangeListener_ =
|
||||
saStatusChangeListener_ =
|
||||
sptr<SystemAbilityStatusChangeListener>::MakeSptr(displayListener_, context->GetToken());
|
||||
if (saStatusChangeListener_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::SERVICE_EXT, "create status change listener failed");
|
||||
@ -635,7 +635,11 @@ napi_value JsServiceExtension::CallOnConnect(const AAFwk::Want &want)
|
||||
return nullptr;
|
||||
}
|
||||
napi_value remoteNative = nullptr;
|
||||
napi_call_function(env, obj, method, ARGC_ONE, argv, &remoteNative);
|
||||
TAG_LOGI(AAFwkTag::SERVICE_EXT, "Call onConnect");
|
||||
napi_status status = napi_call_function(env, obj, method, ARGC_ONE, argv, &remoteNative);
|
||||
if (status != napi_ok) {
|
||||
TAG_LOGE(AAFwkTag::SERVICE_EXT, "call js func failed %{public}d", status);
|
||||
}
|
||||
if (remoteNative == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::SERVICE_EXT, "null remoteNative");
|
||||
}
|
||||
@ -666,13 +670,19 @@ napi_value JsServiceExtension::CallOnDisconnect(const AAFwk::Want &want, bool wi
|
||||
TAG_LOGE(AAFwkTag::SERVICE_EXT, "get onDisconnect from ServiceExtension obj failed");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
TAG_LOGI(AAFwkTag::SERVICE_EXT, "Call onDisconnect");
|
||||
if (withResult) {
|
||||
napi_value result = nullptr;
|
||||
napi_call_function(env, obj, method, ARGC_ONE, argv, &result);
|
||||
napi_status status = napi_call_function(env, obj, method, ARGC_ONE, argv, &result);
|
||||
if (status != napi_ok) {
|
||||
TAG_LOGE(AAFwkTag::SERVICE_EXT, "call js func failed %{public}d", status);
|
||||
}
|
||||
return handleEscape.Escape(result);
|
||||
} else {
|
||||
napi_call_function(env, obj, method, ARGC_ONE, argv, nullptr);
|
||||
napi_status status = napi_call_function(env, obj, method, ARGC_ONE, argv, nullptr);
|
||||
if (status != napi_ok) {
|
||||
TAG_LOGE(AAFwkTag::SERVICE_EXT, "call js func failed %{public}d", status);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -1426,7 +1426,11 @@ void JSServiceExtensionConnection::HandleOnAbilityConnectDone(const AppExecFwk::
|
||||
TAG_LOGE(AAFwkTag::SERVICE_EXT, "null methodOnConnect");
|
||||
return;
|
||||
}
|
||||
napi_call_function(env_, obj, methodOnConnect, ARGC_TWO, argv, nullptr);
|
||||
TAG_LOGI(AAFwkTag::SERVICE_EXT, "Call onConnect");
|
||||
napi_status status = napi_call_function(env_, obj, methodOnConnect, ARGC_TWO, argv, nullptr);
|
||||
if (status != napi_ok) {
|
||||
TAG_LOGE(AAFwkTag::SERVICE_EXT, "call js func failed %{public}d", status);
|
||||
}
|
||||
}
|
||||
|
||||
void JSServiceExtensionConnection::OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode)
|
||||
@ -1492,7 +1496,11 @@ void JSServiceExtensionConnection::HandleOnAbilityDisconnectDone(const AppExecFw
|
||||
AAFwkTag::SERVICE_EXT, "OnAbilityDisconnectDone erase g_connects.size:%{public}zu", g_connects.size());
|
||||
}
|
||||
}
|
||||
napi_call_function(env_, obj, method, ARGC_ONE, argv, nullptr);
|
||||
TAG_LOGI(AAFwkTag::SERVICE_EXT, "Call onDisconnect");
|
||||
napi_status status = napi_call_function(env_, obj, method, ARGC_ONE, argv, nullptr);
|
||||
if (status != napi_ok) {
|
||||
TAG_LOGE(AAFwkTag::SERVICE_EXT, "call js func failed %{public}d", status);
|
||||
}
|
||||
}
|
||||
|
||||
void JSServiceExtensionConnection::SetJsConnectionObject(napi_value jsConnectionObject)
|
||||
|
@ -426,21 +426,21 @@ void AppRecovery::DeleteInValidMissionFiles()
|
||||
return;
|
||||
}
|
||||
if (missionIds.empty()) {
|
||||
TAG_LOGD(AAFwkTag::RECOVERY, "AppRecovery no mission file, no need delete it.");
|
||||
TAG_LOGD(AAFwkTag::RECOVERY, "missionIds empty");
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<AAFwk::AbilityManagerClient> abilityMgr = AAFwk::AbilityManagerClient::GetInstance();
|
||||
if (abilityMgr == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::RECOVERY, "AppRecovery DeleteInValidMissionFiles. abilityMgr client is not exist.");
|
||||
TAG_LOGE(AAFwkTag::RECOVERY, "bilityMgr client is not exist");
|
||||
return;
|
||||
}
|
||||
abilityMgr->IsValidMissionIds(missionIds, results);
|
||||
if (results.empty()) {
|
||||
TAG_LOGE(AAFwkTag::RECOVERY, "AppRecovery DeleteInValidMissionFiles. results is empty.");
|
||||
TAG_LOGE(AAFwkTag::RECOVERY, "results is empty");
|
||||
return;
|
||||
}
|
||||
for (auto& item : results) {
|
||||
TAG_LOGI(AAFwkTag::RECOVERY, "AppRecovery missionResult: missionId: %{public}d, isValid: %{public}d",
|
||||
TAG_LOGI(AAFwkTag::RECOVERY, "missionId: %{public}d, isValid: %{public}d",
|
||||
item.missionId, item.isValid);
|
||||
if (!item.isValid) {
|
||||
DeleteInValidMissionFileById(fileDir, item.missionId);
|
||||
|
@ -496,7 +496,7 @@ void UIAbilityImpl::WindowLifeCycleImpl::AfterUnfocused()
|
||||
|
||||
void UIAbilityImpl::WindowLifeCycleImpl::ForegroundFailed(int32_t type)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "called");
|
||||
TAG_LOGE(AAFwkTag::UIABILITY, "scb call, ForegroundFailed");
|
||||
AppExecFwk::PacMap restoreData;
|
||||
switch (type) {
|
||||
case static_cast<int32_t>(OHOS::Rosen::WMError::WM_ERROR_INVALID_OPERATION): {
|
||||
|
@ -95,6 +95,11 @@ napi_value JsEmbeddableUIAbilityContext::TerminateSelfWithResult(napi_env env, n
|
||||
GET_NAPI_INFO_AND_CALL(env, info, JsEmbeddableUIAbilityContext, OnTerminateSelfWithResult);
|
||||
}
|
||||
|
||||
napi_value JsEmbeddableUIAbilityContext::BackToCallerAbilityWithResult(napi_env env, napi_callback_info info)
|
||||
{
|
||||
GET_NAPI_INFO_AND_CALL(env, info, JsEmbeddableUIAbilityContext, OnBackToCallerAbilityWithResult);
|
||||
}
|
||||
|
||||
napi_value JsEmbeddableUIAbilityContext::StartAbilityAsCaller(napi_env env, napi_callback_info info)
|
||||
{
|
||||
GET_NAPI_INFO_AND_CALL(env, info, JsEmbeddableUIAbilityContext, OnStartAbilityAsCaller);
|
||||
@ -282,6 +287,17 @@ napi_value JsEmbeddableUIAbilityContext::OnTerminateSelfWithResult(napi_env env,
|
||||
return jsAbilityContext_->OnTerminateSelfWithResult(env, info);
|
||||
}
|
||||
|
||||
napi_value JsEmbeddableUIAbilityContext::OnBackToCallerAbilityWithResult(napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
if (screenMode_ == AAFwk::EMBEDDED_FULL_SCREEN_MODE) {
|
||||
TAG_LOGE(AAFwkTag::UI_EXT, "BackToCallerAbilityWithResult in embedded screen mode");
|
||||
ThrowError(env, static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INNER), ERR_MSG_NOT_SUPPORT);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
CHECK_POINTER_RETURN(env, jsAbilityContext_);
|
||||
return jsAbilityContext_->OnBackToCallerAbilityWithResult(env, info);
|
||||
}
|
||||
|
||||
napi_value JsEmbeddableUIAbilityContext::OnStartAbilityAsCaller(napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
if (screenMode_ == AAFwk::EMBEDDED_FULL_SCREEN_MODE) {
|
||||
@ -609,7 +625,7 @@ void JsEmbeddableUIAbilityContext::WrapJsUIExtensionContext(napi_env env,
|
||||
napi_value JsEmbeddableUIAbilityContext::CreateJsEmbeddableUIAbilityContext(napi_env env,
|
||||
std::shared_ptr<AbilityContext> uiAbiContext, std::shared_ptr<UIExtensionContext> uiExtContext, int32_t screenMode)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::UI_EXT, "Create JS embeddable UIAbility context begin");
|
||||
TAG_LOGD(AAFwkTag::UI_EXT, "begin");
|
||||
napi_value objValue = nullptr;
|
||||
if (screenMode == AAFwk::JUMP_SCREEN_MODE) {
|
||||
WrapJsUIAbilityContext(env, uiAbiContext, objValue, screenMode);
|
||||
@ -625,6 +641,7 @@ napi_value JsEmbeddableUIAbilityContext::CreateJsEmbeddableUIAbilityContext(napi
|
||||
BindNativeFunction(env, objValue, "disconnectServiceExtensionAbility", moduleName, DisconnectAbility);
|
||||
BindNativeFunction(env, objValue, "terminateSelf", moduleName, TerminateSelf);
|
||||
BindNativeFunction(env, objValue, "terminateSelfWithResult", moduleName, TerminateSelfWithResult);
|
||||
BindNativeFunction(env, objValue, "backToCallerAbilityWithResult", moduleName, BackToCallerAbilityWithResult);
|
||||
BindNativeFunction(env, objValue, "startAbilityAsCaller", moduleName, StartAbilityAsCaller);
|
||||
BindNativeFunction(env, objValue, "startAbilityWithAccount", moduleName, StartAbilityWithAccount);
|
||||
BindNativeFunction(env, objValue, "startAbilityByCall", moduleName, StartAbilityByCall);
|
||||
|
@ -33,6 +33,11 @@ BundleMgrHelper::~BundleMgrHelper()
|
||||
}
|
||||
}
|
||||
|
||||
void BundleMgrHelper::PreConnect()
|
||||
{
|
||||
Connect();
|
||||
}
|
||||
|
||||
ErrCode BundleMgrHelper::GetNameForUid(const int32_t uid, std::string &name)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "called");
|
||||
@ -204,11 +209,19 @@ std::string BundleMgrHelper::GetAppIdByBundleName(const std::string &bundleName,
|
||||
TAG_LOGE(AAFwkTag::BUNDLEMGRHELPER, "Failed to connect.");
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
return bundleMgr->GetAppIdByBundleName(bundleName, userId);
|
||||
}
|
||||
|
||||
void BundleMgrHelper::ConnectTillSuccess()
|
||||
{
|
||||
while (Connect() == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::BUNDLEMGRHELPER, "connect failed, now retry");
|
||||
usleep(REPOLL_TIME_MICRO_SECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
sptr<IBundleMgr> BundleMgrHelper::Connect()
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
|
@ -598,10 +598,9 @@ int32_t ApplicationContext::GetProcessRunningInformation(AppExecFwk::RunningProc
|
||||
return (contextImpl_ != nullptr) ? contextImpl_->GetProcessRunningInformation(info) : -1;
|
||||
}
|
||||
|
||||
int32_t ApplicationContext::GetAllRunningInstanceKeys(const std::string& bundleName,
|
||||
std::vector<std::string> &instanceKeys)
|
||||
int32_t ApplicationContext::GetAllRunningInstanceKeys(std::vector<std::string> &instanceKeys)
|
||||
{
|
||||
return (contextImpl_ != nullptr) ? contextImpl_->GetAllRunningInstanceKeys(bundleName, instanceKeys) : -1;
|
||||
return (contextImpl_ != nullptr) ? contextImpl_->GetAllRunningInstanceKeys(instanceKeys) : -1;
|
||||
}
|
||||
|
||||
bool ApplicationContext::IsUpdatingConfigurations()
|
||||
|
@ -696,12 +696,6 @@ int ContextImpl::GetCurrentActiveAccountId() const
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "no accounts");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (accountIds.size() > 1) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "no current now");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return accountIds[0];
|
||||
}
|
||||
|
||||
@ -1239,11 +1233,10 @@ int32_t ContextImpl::GetProcessRunningInformation(AppExecFwk::RunningProcessInfo
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t ContextImpl::GetAllRunningInstanceKeys(const std::string& bundleName,
|
||||
std::vector<std::string> &instanceKeys)
|
||||
int32_t ContextImpl::GetAllRunningInstanceKeys(std::vector<std::string> &instanceKeys)
|
||||
{
|
||||
auto appMgrClient = DelayedSingleton<AppExecFwk::AppMgrClient>::GetInstance();
|
||||
auto result = appMgrClient->GetAllRunningInstanceKeysByBundleName(bundleName, instanceKeys);
|
||||
auto result = appMgrClient->GetAllRunningInstanceKeysBySelf(instanceKeys);
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "result is %{public}d", result);
|
||||
return result;
|
||||
}
|
||||
@ -1421,14 +1414,20 @@ void ContextImpl::OnOverlayChanged(const EventFwk::CommonEventData &data,
|
||||
}
|
||||
}
|
||||
|
||||
void ContextImpl::ChangeToLocalPath(const std::string &bundleName,
|
||||
const std::string &sourceDir, std::string &localPath)
|
||||
void ContextImpl::ChangeToLocalPath(const std::string& bundleName, const std::string& sourceDir, std::string& localPath)
|
||||
{
|
||||
std::regex pattern(std::string(ABS_CODE_PATH) + std::string(FILE_SEPARATOR) + bundleName);
|
||||
if (sourceDir.empty()) {
|
||||
return;
|
||||
}
|
||||
if (std::regex_search(localPath, std::regex(bundleName))) {
|
||||
bool isExist = false;
|
||||
try {
|
||||
isExist = std::regex_search(localPath, std::regex(bundleName));
|
||||
} catch (...) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "ChangeToLocalPath error localPath:%{public}s bundleName:%{public}s",
|
||||
localPath.c_str(), bundleName.c_str());
|
||||
}
|
||||
if (isExist) {
|
||||
localPath = std::regex_replace(localPath, pattern, std::string(LOCAL_CODE_PATH));
|
||||
} else {
|
||||
localPath = std::regex_replace(localPath, std::regex(ABS_CODE_PATH), LOCAL_BUNDLES);
|
||||
|
@ -971,7 +971,7 @@ napi_value JsApplicationContextUtils::OnGetAllRunningInstanceKeys(napi_env env,
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "Get all running instance keys");
|
||||
auto innerErrCode = std::make_shared<ErrCode>(ERR_OK);
|
||||
std::shared_ptr<std::vector<std::string>> instanceKeys;
|
||||
std::shared_ptr<std::vector<std::string>> instanceKeys = std::make_shared<std::vector<std::string>>();
|
||||
NapiAsyncTask::ExecuteCallback execute =
|
||||
[applicationContext = applicationContext_, innerErrCode, instanceKeys]() {
|
||||
auto context = applicationContext.lock();
|
||||
@ -981,23 +981,24 @@ napi_value JsApplicationContextUtils::OnGetAllRunningInstanceKeys(napi_env env,
|
||||
return;
|
||||
}
|
||||
if (context->GetCurrentAppMode() != static_cast<int32_t>(AppExecFwk::MultiAppModeType::MULTI_INSTANCE)) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "multi-instance not supported");
|
||||
*innerErrCode = static_cast<int>(AbilityErrorCode::ERROR_MULTI_INSTANCE_NOT_SUPPORTED);
|
||||
return;
|
||||
}
|
||||
std::string bundleName = context->GetBundleName();
|
||||
*innerErrCode = context->GetAllRunningInstanceKeys(bundleName, *instanceKeys);
|
||||
*innerErrCode = context->GetAllRunningInstanceKeys(*instanceKeys);
|
||||
};
|
||||
auto complete = [applicationContext = applicationContext_, innerErrCode, instanceKeys](
|
||||
napi_env env, NapiAsyncTask& task, int32_t status) {
|
||||
if (*innerErrCode != ERR_OK) {
|
||||
task.Reject(env, CreateJsError(env, *innerErrCode, "failed to get instance keys."));
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "failed to get instance keys,innerErrCode=%{public}d", *innerErrCode);
|
||||
task.Reject(env, CreateJsErrorByNativeErr(env, *innerErrCode));
|
||||
return;
|
||||
}
|
||||
task.ResolveWithNoError(env, CreateNativeArray(env, *instanceKeys));
|
||||
};
|
||||
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::Schedule("JsApplicationContextUtils::OnGetRunningProcessInformation",
|
||||
NapiAsyncTask::Schedule("JsApplicationContextUtils::OnGetAllRunningInstanceKeys",
|
||||
env, CreateAsyncTaskWithLastParam(env, nullptr, std::move(execute), std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
|
@ -364,6 +364,13 @@ void MainThread::Attach()
|
||||
return;
|
||||
}
|
||||
mainThreadState_ = MainThreadState::ATTACH;
|
||||
isDeveloperMode_ = system::GetBoolParameter(DEVELOPER_MODE_STATE, false);
|
||||
auto bundleMgrHelper = DelayedSingleton<BundleMgrHelper>::GetInstance();
|
||||
if (bundleMgrHelper == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "The bundleMgrHelper is nullptr");
|
||||
return;
|
||||
}
|
||||
bundleMgrHelper->PreConnect();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1042,10 +1049,6 @@ void MainThread::OnStartAbility(const std::string &bundleName,
|
||||
loadPath = std::regex_replace(loadPath, pattern, std::string(LOCAL_CODE_PATH));
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "ModuleResPath: %{public}s", loadPath.c_str());
|
||||
// getOverlayPath
|
||||
auto res = GetOverlayModuleInfos(bundleName, entryHapModuleInfo.moduleName, overlayModuleInfos_);
|
||||
if (res != ERR_OK) {
|
||||
TAG_LOGW(AAFwkTag::APPKIT, "getOverlayPath failed");
|
||||
}
|
||||
if (overlayModuleInfos_.size() == 0) {
|
||||
if (!resourceManager->AddResource(loadPath.c_str())) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "AddResource failed");
|
||||
@ -1527,7 +1530,9 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
|
||||
debugOption.perfCmd = perfCmd;
|
||||
runtime->StartProfiler(debugOption);
|
||||
} else {
|
||||
runtime->StartDebugMode(debugOption);
|
||||
if (isDeveloperMode_) {
|
||||
runtime->StartDebugMode(debugOption);
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<HqfInfo> hqfInfos = appInfo.appQuickFix.deployedAppqfInfo.hqfInfos;
|
||||
@ -1676,11 +1681,10 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
|
||||
entryHapModuleInfo.hapPath.empty() ? entryHapModuleInfo.resourcePath : entryHapModuleInfo.hapPath;
|
||||
std::regex inner_pattern(std::string(ABS_CODE_PATH) + std::string(FILE_SEPARATOR) + bundleInfo.name);
|
||||
loadPath = std::regex_replace(loadPath, inner_pattern, LOCAL_CODE_PATH);
|
||||
std::vector<OverlayModuleInfo> overlayModuleInfos;
|
||||
auto res = GetOverlayModuleInfos(bundleInfo.name, moduleName, overlayModuleInfos);
|
||||
auto res = GetOverlayModuleInfos(bundleInfo.name, moduleName, overlayModuleInfos_);
|
||||
std::vector<std::string> overlayPaths;
|
||||
if (res == ERR_OK) {
|
||||
overlayPaths = GetAddOverlayPaths(overlayModuleInfos);
|
||||
overlayPaths = GetAddOverlayPaths(overlayModuleInfos_);
|
||||
}
|
||||
std::unique_ptr<Global::Resource::ResConfig> resConfig(Global::Resource::CreateResConfig());
|
||||
int32_t appType;
|
||||
@ -1872,7 +1876,14 @@ void MainThread::ChangeToLocalPath(const std::string &bundleName,
|
||||
if (sourceDir.empty()) {
|
||||
return;
|
||||
}
|
||||
if (std::regex_search(localPath, std::regex(bundleName))) {
|
||||
bool isExist = false;
|
||||
try {
|
||||
isExist = std::regex_search(localPath, std::regex(bundleName));
|
||||
} catch (...) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "ChangeToLocalPath error localPath:%{public}s bundleName:%{public}s",
|
||||
localPath.c_str(), bundleName.c_str());
|
||||
}
|
||||
if (isExist) {
|
||||
localPath = std::regex_replace(localPath, pattern, std::string(LOCAL_CODE_PATH));
|
||||
} else {
|
||||
localPath = std::regex_replace(localPath, std::regex(ABS_CODE_PATH), LOCAL_BUNDLES);
|
||||
@ -1897,7 +1908,20 @@ void MainThread::HandleAbilityStage(const HapModuleInfo &abilityStage)
|
||||
return;
|
||||
}
|
||||
|
||||
application_->AddAbilityStage(abilityStage);
|
||||
wptr<MainThread> weak = this;
|
||||
auto callback = [weak]() {
|
||||
auto appThread = weak.promote();
|
||||
if (!appThread->appMgr_ || !appThread->applicationImpl_) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "appMgr_ is nullptr");
|
||||
return;
|
||||
}
|
||||
appThread->appMgr_->AddAbilityStageDone(appThread->applicationImpl_->GetRecordId());
|
||||
};
|
||||
bool isAsyncCallback = false;
|
||||
application_->AddAbilityStage(abilityStage, callback, isAsyncCallback);
|
||||
if (isAsyncCallback) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!appMgr_ || !applicationImpl_) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "appMgr_ is nullptr");
|
||||
@ -2055,7 +2079,8 @@ void MainThread::HandleLaunchAbility(const std::shared_ptr<AbilityLocalRecord> &
|
||||
Rosen::DisplayId defaultDisplayId = Rosen::DisplayManager::GetInstance().GetDefaultDisplayId();
|
||||
Rosen::DisplayId displayId = defaultDisplayId;
|
||||
if (abilityRecord->GetWant() != nullptr) {
|
||||
displayId = abilityRecord->GetWant()->GetIntParam(AAFwk::Want::PARAM_RESV_DISPLAY_ID, defaultDisplayId);
|
||||
displayId = static_cast<uint64_t>(abilityRecord->GetWant()->GetIntParam(
|
||||
AAFwk::Want::PARAM_RESV_DISPLAY_ID, defaultDisplayId));
|
||||
}
|
||||
Rosen::DisplayManager::GetInstance().AddDisplayIdFromAms(displayId, abilityRecord->GetToken());
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "add displayId: %{public}" PRIu64, displayId);
|
||||
@ -3243,12 +3268,12 @@ void MainThread::AssertFaultResumeMainThreadDetection()
|
||||
|
||||
void MainThread::HandleInitAssertFaultTask(bool isDebugModule, bool isDebugApp)
|
||||
{
|
||||
if (!system::GetBoolParameter(PRODUCT_ASSERT_FAULT_DIALOG_ENABLED, false)) {
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "Unsupport assert fault dialog");
|
||||
if (!isDeveloperMode_) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "Developer Mode is false");
|
||||
return;
|
||||
}
|
||||
if (!system::GetBoolParameter(DEVELOPER_MODE_STATE, false)) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "Developer Mode is false");
|
||||
if (!system::GetBoolParameter(PRODUCT_ASSERT_FAULT_DIALOG_ENABLED, false)) {
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "Unsupport assert fault dialog");
|
||||
return;
|
||||
}
|
||||
if (!isDebugApp) {
|
||||
|
@ -23,7 +23,6 @@
|
||||
|
||||
#include "ability.h"
|
||||
#include "ability_record_mgr.h"
|
||||
#include "ability_stage_context.h"
|
||||
#include "ability_thread.h"
|
||||
#include "app_loader.h"
|
||||
#include "application_context.h"
|
||||
@ -402,7 +401,6 @@ std::shared_ptr<AbilityRuntime::Context> OHOSApplication::AddAbilityStage(
|
||||
auto application = std::static_pointer_cast<OHOSApplication>(shared_from_this());
|
||||
std::weak_ptr<OHOSApplication> weak = application;
|
||||
abilityStage->Init(stageContext, weak);
|
||||
|
||||
auto autoStartupCallback = CreateAutoStartupCallback(abilityStage, abilityRecord, callback);
|
||||
if (autoStartupCallback != nullptr) {
|
||||
abilityStage->RunAutoStartupTask(autoStartupCallback, isAsyncCallback, stageContext);
|
||||
@ -460,6 +458,35 @@ const std::function<void()> OHOSApplication::CreateAutoStartupCallback(
|
||||
return autoStartupCallback;
|
||||
}
|
||||
|
||||
const std::function<void()> OHOSApplication::CreateAutoStartupCallback(
|
||||
const std::shared_ptr<AbilityRuntime::AbilityStage> &abilityStage,
|
||||
const AppExecFwk::HapModuleInfo &hapModuleInfo,
|
||||
const std::function<void()>& callback)
|
||||
{
|
||||
auto applicationInfo = abilityRuntimeContext_->GetApplicationInfo();
|
||||
if (!IsMainProcess(hapModuleInfo.bundleName, applicationInfo->process)) {
|
||||
return nullptr;
|
||||
}
|
||||
auto application = std::static_pointer_cast<OHOSApplication>(shared_from_this());
|
||||
std::weak_ptr<OHOSApplication> weak = application;
|
||||
|
||||
auto autoStartupCallback = [weak, abilityStage, hapModuleInfo, callback]() {
|
||||
auto ohosApplication = weak.lock();
|
||||
if (ohosApplication == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "null ohosApplication");
|
||||
return;
|
||||
}
|
||||
ohosApplication->AutoStartupDone(abilityStage, hapModuleInfo);
|
||||
if (callback == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "null callback");
|
||||
return;
|
||||
}
|
||||
callback();
|
||||
};
|
||||
|
||||
return autoStartupCallback;
|
||||
}
|
||||
|
||||
void OHOSApplication::AutoStartupDone(const std::shared_ptr<AbilityLocalRecord> &abilityRecord,
|
||||
const std::shared_ptr<AbilityRuntime::AbilityStage> &abilityStage, const std::string &moduleName)
|
||||
{
|
||||
@ -484,6 +511,22 @@ void OHOSApplication::AutoStartupDone(const std::shared_ptr<AbilityLocalRecord>
|
||||
abilityStage->AddAbility(token, abilityRecord);
|
||||
}
|
||||
|
||||
void OHOSApplication::AutoStartupDone(
|
||||
const std::shared_ptr<AbilityRuntime::AbilityStage> &abilityStage,
|
||||
const AppExecFwk::HapModuleInfo &hapModuleInfo)
|
||||
{
|
||||
if (abilityStage == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "abilityStage is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
Want want;
|
||||
abilityStage->OnCreate(want);
|
||||
abilityStages_[hapModuleInfo.moduleName] = abilityStage;
|
||||
TAG_LOGI(AAFwkTag::APPKIT, "abilityStage insert and initialization");
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief update the application info after new module installed.
|
||||
@ -503,7 +546,9 @@ void OHOSApplication::UpdateApplicationInfoInstalled(const AppExecFwk::Applicati
|
||||
abilityRuntimeContext_->SetApplicationInfo(std::make_shared<AppExecFwk::ApplicationInfo>(appInfo));
|
||||
}
|
||||
|
||||
bool OHOSApplication::AddAbilityStage(const AppExecFwk::HapModuleInfo &hapModuleInfo)
|
||||
bool OHOSApplication::AddAbilityStage(
|
||||
const AppExecFwk::HapModuleInfo &hapModuleInfo,
|
||||
const std::function<void()> &callback, bool &isAsyncCallback)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "called");
|
||||
if (abilityRuntimeContext_ == nullptr) {
|
||||
@ -544,10 +589,18 @@ bool OHOSApplication::AddAbilityStage(const AppExecFwk::HapModuleInfo &hapModule
|
||||
auto application = std::static_pointer_cast<OHOSApplication>(shared_from_this());
|
||||
std::weak_ptr<OHOSApplication> weak = application;
|
||||
abilityStage->Init(stageContext, weak);
|
||||
auto autoStartupCallback = CreateAutoStartupCallback(abilityStage, hapModuleInfo, callback);
|
||||
if (autoStartupCallback != nullptr) {
|
||||
abilityStage->RunAutoStartupTask(autoStartupCallback, isAsyncCallback, stageContext);
|
||||
if (isAsyncCallback) {
|
||||
TAG_LOGI(AAFwkTag::APPKIT, "waiting for startup");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Want want;
|
||||
abilityStage->OnCreate(want);
|
||||
abilityStages_[hapModuleInfo.moduleName] = abilityStage;
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "abilityStage insert and initialization");
|
||||
TAG_LOGI(AAFwkTag::APPKIT, "abilityStage insert and initialization");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -81,19 +81,19 @@ int OH_Ability_CreateNativeChildProcess(const char* libName, OH_Ability_OnNative
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "relative path not allow");
|
||||
return NCP_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
|
||||
std::unique_lock autoLock(g_mutexCallBackObj);
|
||||
if (g_Callback != nullptr || g_CallbackStub != nullptr) {
|
||||
TAG_LOGW(AAFwkTag::PROCESSMGR, "Another native process starting");
|
||||
return NCP_ERR_BUSY;
|
||||
}
|
||||
|
||||
|
||||
sptr<IRemoteObject> callbackStub(new (std::nothrow) NativeChildCallback(OnNativeChildProcessStartedWapper));
|
||||
if (!callbackStub) {
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "Alloc callbackStub obj faild");
|
||||
return NCP_ERR_INTERNAL;
|
||||
}
|
||||
|
||||
|
||||
ChildProcessManager &mgr = ChildProcessManager::GetInstance();
|
||||
auto cpmErr = mgr.StartNativeChildProcessByAppSpawnFork(strLibName, callbackStub);
|
||||
if (cpmErr != ChildProcessManagerErrorCode::ERR_OK) {
|
||||
@ -118,13 +118,17 @@ Ability_NativeChildProcess_ErrCode OH_Ability_StartNativeChildProcess(const char
|
||||
return NCP_ERR_INVALID_PARAM;
|
||||
}
|
||||
if (pid == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "pid null.");
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "pid null");
|
||||
return NCP_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
std::map<std::string, int32_t> fds;
|
||||
NativeChildProcess_Fd* cur = args.fdList.head;
|
||||
while (cur != nullptr) {
|
||||
if (!cur->fdName) {
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "fdName null");
|
||||
return NCP_ERR_INVALID_PARAM;
|
||||
}
|
||||
std::string key(cur->fdName);
|
||||
if (key.size() > MAX_KEY_SIZE) {
|
||||
TAG_LOGE(AAFwkTag::PROCESSMGR, "fd name too long");
|
||||
@ -143,10 +147,8 @@ Ability_NativeChildProcess_ErrCode OH_Ability_StartNativeChildProcess(const char
|
||||
std::string entryParams(args.entryParams);
|
||||
childArgs.entryParams = entryParams;
|
||||
}
|
||||
|
||||
AppExecFwk::ChildProcessOptions childProcessOptions;
|
||||
childProcessOptions.isolationMode = options.isolationMode == NCP_ISOLATION_MODE_ISOLATED;
|
||||
|
||||
int32_t childProcessType = AppExecFwk::CHILD_PROCESS_TYPE_NATIVE_ARGS;
|
||||
|
||||
ChildProcessManager &mgr = ChildProcessManager::GetInstance();
|
||||
@ -154,6 +156,5 @@ Ability_NativeChildProcess_ErrCode OH_Ability_StartNativeChildProcess(const char
|
||||
if (cpmErr != ChildProcessManagerErrorCode::ERR_OK) {
|
||||
return CvtChildProcessManagerErrCode(cpmErr);
|
||||
}
|
||||
|
||||
return NCP_NO_ERROR;
|
||||
}
|
@ -44,7 +44,7 @@ std::string GetInstanceMapMessage(
|
||||
}
|
||||
|
||||
using StartServer = void (*)(const std::string&);
|
||||
using StartServerForSocketPair = void (*)(int);
|
||||
using StartServerForSocketPair = bool (*)(int);
|
||||
using SendMessage = void (*)(const std::string&);
|
||||
using SendLayoutMessage = void (*)(const std::string&);
|
||||
using StopServer = void (*)(const std::string&);
|
||||
|
@ -58,7 +58,6 @@
|
||||
#include "parameters.h"
|
||||
#include "extractor.h"
|
||||
#include "system_ability_definition.h"
|
||||
#include "systemcapability.h"
|
||||
#include "source_map.h"
|
||||
#include "source_map_operator.h"
|
||||
|
||||
@ -68,6 +67,7 @@
|
||||
#include "declarative_module_preloader.h"
|
||||
#endif //SUPPORT_SCREEN
|
||||
|
||||
#include "syscap_ts.h"
|
||||
|
||||
using namespace OHOS::AbilityBase;
|
||||
using Extractor = OHOS::AbilityBase::Extractor;
|
||||
@ -108,45 +108,6 @@ static auto PermissionCheckFunc = []() {
|
||||
}
|
||||
};
|
||||
|
||||
napi_value CanIUse(napi_env env, napi_callback_info info)
|
||||
{
|
||||
if (env == nullptr || info == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "null env or info");
|
||||
return nullptr;
|
||||
}
|
||||
napi_value undefined = CreateJsUndefined(env);
|
||||
|
||||
size_t argc = 1;
|
||||
napi_value argv[1] = { nullptr };
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
if (argc != 1) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "invalid argc");
|
||||
return undefined;
|
||||
}
|
||||
|
||||
napi_valuetype valueType = napi_undefined;
|
||||
napi_typeof(env, argv[0], &valueType);
|
||||
if (valueType != napi_string) {
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "invalid type");
|
||||
return undefined;
|
||||
}
|
||||
|
||||
char syscap[SYSCAP_MAX_SIZE] = { 0 };
|
||||
|
||||
size_t strLen = 0;
|
||||
napi_get_value_string_utf8(env, argv[0], syscap, sizeof(syscap), &strLen);
|
||||
|
||||
bool ret = HasSystemCapability(syscap);
|
||||
return CreateJsValue(env, ret);
|
||||
}
|
||||
|
||||
void InitSyscapModule(napi_env env, napi_value globalObject)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
const char *moduleName = "JsRuntime";
|
||||
BindNativeFunction(env, globalObject, "canIUse", moduleName, CanIUse);
|
||||
}
|
||||
|
||||
int32_t PrintVmLog(int32_t, int32_t, const char*, const char*, const char* message)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "ArkLog: %{public}s", message);
|
||||
@ -701,7 +662,7 @@ bool JsRuntime::Initialize(const Options& options)
|
||||
CHECK_POINTER_AND_RETURN(globalObj, false);
|
||||
|
||||
if (!preloaded_) {
|
||||
InitSyscapModule(env, globalObj);
|
||||
InitSyscapModule(env);
|
||||
|
||||
// Simple hook function 'isSystemplugin'
|
||||
const char* moduleName = "JsRuntime";
|
||||
|
@ -57,7 +57,7 @@ void OHOSJsEnvironmentImpl::PostTaskToHandler(void* handler, uv_io_cb func, void
|
||||
break;
|
||||
}
|
||||
|
||||
if (g_eventHandler == nullptr) {
|
||||
if (g_eventHandler == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Invalid parameters");
|
||||
return;
|
||||
}
|
||||
|
@ -127,6 +127,7 @@ ohos_shared_library("ability_manager") {
|
||||
":ability_start_setting",
|
||||
":mission_info",
|
||||
":process_options",
|
||||
":start_window_option",
|
||||
"${ability_runtime_innerkits_path}/app_manager:app_manager",
|
||||
"${ability_runtime_services_path}/abilitymgr:wantagent_manager",
|
||||
]
|
||||
@ -210,7 +211,10 @@ ohos_shared_library("ability_start_options") {
|
||||
sources =
|
||||
[ "${ability_runtime_services_path}/abilitymgr/src/start_options.cpp" ]
|
||||
|
||||
deps = [ ":process_options" ]
|
||||
deps = [
|
||||
":process_options",
|
||||
":start_window_option",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
@ -338,6 +342,45 @@ ohos_shared_library("process_options") {
|
||||
part_name = "ability_runtime"
|
||||
}
|
||||
|
||||
ohos_shared_library("start_window_option") {
|
||||
sanitize = {
|
||||
integer_overflow = true
|
||||
ubsan = true
|
||||
boundary_sanitize = true
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcall_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
branch_protector_ret = "pac_ret"
|
||||
|
||||
include_dirs = [
|
||||
"include/",
|
||||
"${ability_runtime_services_path}/common/include",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"${ability_runtime_services_path}/abilitymgr/src/start_window_option.cpp",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
if (ability_runtime_graphics &&
|
||||
ability_runtime_start_window_options_with_pixelmap) {
|
||||
defines = [ "START_WINDOW_OPTIONS_WITH_PIXELMAP" ]
|
||||
external_deps += [ "image_framework:image_native" ]
|
||||
}
|
||||
|
||||
cflags_cc = []
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
subsystem_name = "ability"
|
||||
part_name = "ability_runtime"
|
||||
}
|
||||
|
||||
ohos_shared_library("ability_connect_callback_stub") {
|
||||
branch_protector_ret = "pac_ret"
|
||||
|
||||
|
@ -814,7 +814,7 @@ public:
|
||||
}
|
||||
|
||||
virtual sptr<IWantSender> GetWantSender(
|
||||
const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken) = 0;
|
||||
const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken, int32_t uid = -1) = 0;
|
||||
|
||||
virtual int SendWantSender(sptr<IWantSender> target, const SenderInfo &senderInfo) = 0;
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
class Configuration;
|
||||
class Configuration;
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,12 +129,6 @@ public:
|
||||
*/
|
||||
virtual int32_t NotifyRemoveShellProcess(int32_t pid, int32_t type, const std::string &reason) = 0;
|
||||
|
||||
/**
|
||||
* @brief Update mission info to real element by broker.
|
||||
* @param info info of mission.
|
||||
*/
|
||||
virtual void UpdateMissionInfo(InnerMissionInfoDto &info) = 0;
|
||||
|
||||
/**
|
||||
* @brief Update mission info to real element by broker.
|
||||
* @param sessionInfo sessionInfo.
|
||||
@ -191,8 +185,7 @@ public:
|
||||
NOTIFY_TERMINATE_MISSION,
|
||||
NOTIFY_CLEAR_MISSION,
|
||||
NOTIFY_REMOVE_SHELL_PROCESS,
|
||||
UPDATE_MISSION_INFO,
|
||||
NOTIFY_MISSION_CREATED_BY_SCB,
|
||||
NOTIFY_MISSION_CREATED_BY_SCB = 10,
|
||||
NOTIFY_LOAD_ABILITY_BY_SCB,
|
||||
UPDATE_MISSION_INFO_BY_SCB,
|
||||
NOTIFY_PRELOAD_ABILITY,
|
||||
|
@ -65,28 +65,6 @@ struct MissionValidResult : public Parcelable {
|
||||
int32_t missionId = -1;
|
||||
bool isValid = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* @struct InnerMissionInfoDto
|
||||
* The Dto of InnerMissionInfo
|
||||
*/
|
||||
struct InnerMissionInfoDto : public Parcelable {
|
||||
MissionInfo missionInfo;
|
||||
std::string missionName;
|
||||
std::string missionAffinity;
|
||||
int32_t launchMode;
|
||||
int32_t startMethod;
|
||||
std::string bundleName;
|
||||
int32_t uid;
|
||||
bool isTemporary;
|
||||
std::string specifiedFlag;
|
||||
bool hasRecoverInfo;
|
||||
int32_t collaboratorType;
|
||||
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
static InnerMissionInfoDto *Unmarshalling(Parcel &parcel);
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_MISSION_INFO_H
|
||||
|
@ -24,6 +24,7 @@
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
class ProcessOptions;
|
||||
class StartWindowOption;
|
||||
|
||||
class StartOptions final : public Parcelable, public std::enable_shared_from_this<StartOptions> {
|
||||
public:
|
||||
@ -33,6 +34,7 @@ public:
|
||||
bool windowWidthUsed_ = false;
|
||||
bool windowHeightUsed_ = false;
|
||||
std::shared_ptr<ProcessOptions> processOptions = nullptr;
|
||||
std::shared_ptr<StartWindowOption> startWindowOption = nullptr;
|
||||
|
||||
StartOptions() = default;
|
||||
~StartOptions() = default;
|
||||
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ABILITY_RUNTIME_START_WINDOW_OPTION_H
|
||||
#define OHOS_ABILITY_RUNTIME_START_WINDOW_OPTION_H
|
||||
|
||||
#include "parcel.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Media {
|
||||
class PixelMap;
|
||||
}
|
||||
namespace AAFwk {
|
||||
class StartWindowOption final : public Parcelable {
|
||||
public:
|
||||
StartWindowOption() = default;
|
||||
~StartWindowOption() = default;
|
||||
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
static StartWindowOption *Unmarshalling(Parcel &parcel);
|
||||
|
||||
bool hasStartWindow = false;
|
||||
std::string startWindowBackgroundColor;
|
||||
std::shared_ptr<Media::PixelMap> startWindowIcon = nullptr;
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_START_WINDOW_OPTION_H
|
@ -399,17 +399,6 @@ public:
|
||||
*/
|
||||
virtual void BlockProcessCacheByPids(const std::vector<int32_t> &pids) {}
|
||||
|
||||
/**
|
||||
* Request to clean uiability from user.
|
||||
*
|
||||
* @param token the token of ability.
|
||||
* @return Returns true if clean success, others return false.
|
||||
*/
|
||||
virtual bool CleanAbilityByUserRequest(const sptr<IRemoteObject> &token)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* whether killed for upgrade web.
|
||||
*
|
||||
@ -421,6 +410,17 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to clean uiability from user.
|
||||
*
|
||||
* @param token the token of ability.
|
||||
* @return Returns true if clean success, others return false.
|
||||
*/
|
||||
virtual bool CleanAbilityByUserRequest(const sptr<IRemoteObject> &token)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* whether the abilities of process specified by pid type only UIAbility.
|
||||
* @return Returns true is only UIAbility, otherwise return false
|
||||
|
@ -361,14 +361,6 @@ public:
|
||||
*/
|
||||
virtual void BlockProcessCacheByPids(const std::vector<int32_t> &pids) override;
|
||||
|
||||
/**
|
||||
* Request to clean uiability from user.
|
||||
*
|
||||
* @param token the token of ability.
|
||||
* @return Returns true if clean success, others return false.
|
||||
*/
|
||||
virtual bool CleanAbilityByUserRequest(const sptr<IRemoteObject> &token) override;
|
||||
|
||||
/**
|
||||
* whether killed for upgrade web.
|
||||
*
|
||||
@ -377,6 +369,14 @@ public:
|
||||
*/
|
||||
virtual bool IsKilledForUpgradeWeb(const std::string &bundleName) override;
|
||||
|
||||
/**
|
||||
* Request to clean uiability from user.
|
||||
*
|
||||
* @param token the token of ability.
|
||||
* @return Returns true if clean success, others return false.
|
||||
*/
|
||||
virtual bool CleanAbilityByUserRequest(const sptr<IRemoteObject> &token) override;
|
||||
|
||||
/**
|
||||
* whether the abilities of process specified by pid type only UIAbility.
|
||||
* @return Returns true is only UIAbility, otherwise return false
|
||||
|
@ -97,8 +97,8 @@ private:
|
||||
int32_t OnRemoteRequestInnerFourth(uint32_t code, MessageParcel &data,
|
||||
MessageParcel &reply, MessageOption &option);
|
||||
int32_t HandleBlockProcessCacheByPids(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleCleanAbilityByUserRequest(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleIsKilledForUpgradeWeb(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleCleanAbilityByUserRequest(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleIsProcessContainsOnlyUIAbility(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleIsProcessAttached(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleIsAppKilling(MessageParcel &data, MessageParcel &reply);
|
||||
|
@ -245,16 +245,26 @@ public:
|
||||
*/
|
||||
virtual AppMgrResultCode GetProcessRunningInformation(RunningProcessInfo &info);
|
||||
|
||||
/**
|
||||
* GetAllRunningInstanceKeysBySelf, call GetAllRunningInstanceKeysBySelf() through proxy project.
|
||||
* Obtains running instance keys of multi-instance app that are running on the device.
|
||||
*
|
||||
* @param instanceKeys, output instance keys of the multi-instance app.
|
||||
* @return ERR_OK ,return back success,others fail.
|
||||
*/
|
||||
virtual AppMgrResultCode GetAllRunningInstanceKeysBySelf(std::vector<std::string> &instanceKeys);
|
||||
|
||||
/**
|
||||
* GetAllRunningInstanceKeysByBundleName, call GetAllRunningInstanceKeysByBundleName() through proxy project.
|
||||
* Obtains running instance keys of multi-instance app that are running on the device.
|
||||
*
|
||||
* @param bundlename, bundle name in Application record.
|
||||
* @param instanceKeys, output instance keys of the multi-instance app.
|
||||
* @param userId, user id.
|
||||
* @return ERR_OK ,return back success,others fail.
|
||||
*/
|
||||
virtual AppMgrResultCode GetAllRunningInstanceKeysByBundleName(const std::string &bundleName,
|
||||
std::vector<std::string> &instanceKeys);
|
||||
std::vector<std::string> &instanceKeys, int32_t userId = -1);
|
||||
|
||||
/**
|
||||
* GetAllRenderProcesses, call GetAllRenderProcesses() through proxy project.
|
||||
|
@ -158,16 +158,26 @@ public:
|
||||
virtual int32_t GetRunningMultiAppInfoByBundleName(const std::string &bundleName,
|
||||
RunningMultiAppInfo &info) = 0;
|
||||
|
||||
/**
|
||||
* GetAllRunningInstanceKeysBySelf, call GetAllRunningInstanceKeysBySelf() through proxy project.
|
||||
* Obtains running instance keys of multi-instance app that are running on the device.
|
||||
*
|
||||
* @param instanceKeys, output instance keys of the multi-instance app.
|
||||
* @return ERR_OK ,return back success,others fail.
|
||||
*/
|
||||
virtual int32_t GetAllRunningInstanceKeysBySelf(std::vector<std::string> &instanceKeys) = 0;
|
||||
|
||||
/**
|
||||
* GetAllRunningInstanceKeysByBundleName, call GetAllRunningInstanceKeysByBundleName() through proxy project.
|
||||
* Obtains running instance keys of multi-instance app that are running on the device.
|
||||
*
|
||||
* @param bundlename, bundle name in Application record.
|
||||
* @param instanceKeys, output instance keys of the multi-instance app.
|
||||
* @param userId, user id.
|
||||
* @return ERR_OK ,return back success,others fail.
|
||||
*/
|
||||
virtual int32_t GetAllRunningInstanceKeysByBundleName(const std::string &bundleName,
|
||||
std::vector<std::string> &instanceKeys) = 0;
|
||||
std::vector<std::string> &instanceKeys, int32_t userId = -1) = 0;
|
||||
|
||||
/**
|
||||
* GetRunningProcessesByBundleType, call GetRunningProcessesByBundleType() through proxy project.
|
||||
|
@ -116,6 +116,7 @@ enum class AppMgrInterfaceCode {
|
||||
REGISTER_KIA_INTERCEPTOR = 90,
|
||||
CHECK_IS_KIA_PROCESS = 91,
|
||||
GET_All_RUNNING_INSTANCE_KEYS_BY_BUNDLENAME = 92,
|
||||
GET_All_RUNNING_INSTANCE_KEYS_BY_SELF = 93,
|
||||
};
|
||||
} // AppExecFwk
|
||||
} // OHOS
|
||||
|
@ -135,16 +135,26 @@ public:
|
||||
virtual int32_t GetRunningMultiAppInfoByBundleName(const std::string &bundleName,
|
||||
RunningMultiAppInfo &info) override;
|
||||
|
||||
/**
|
||||
* GetAllRunningInstanceKeysBySelf, call GetAllRunningInstanceKeysBySelf() through proxy project.
|
||||
* Obtains running instance keys of multi-instance app that are running on the device.
|
||||
*
|
||||
* @param instanceKeys, output instance keys of the multi-instance app.
|
||||
* @return ERR_OK ,return back success,others fail.
|
||||
*/
|
||||
virtual int32_t GetAllRunningInstanceKeysBySelf(std::vector<std::string> &instanceKeys) override;
|
||||
|
||||
/**
|
||||
* GetAllRunningInstanceKeysByBundleName, call GetAllRunningInstanceKeysByBundleName() through proxy project.
|
||||
* Obtains running instance keys of multi-instance app that are running on the device.
|
||||
*
|
||||
* @param bundlename, bundle name in Application record.
|
||||
* @param instanceKeys, output instance keys of the multi-instance app.
|
||||
* @param userId, user id.
|
||||
* @return ERR_OK ,return back success,others fail.
|
||||
*/
|
||||
virtual int32_t GetAllRunningInstanceKeysByBundleName(const std::string &bundleName,
|
||||
std::vector<std::string> &instanceKeys) override;
|
||||
std::vector<std::string> &instanceKeys, int32_t userId = -1) override;
|
||||
|
||||
/**
|
||||
* GetRunningProcessesByBundleType, call GetRunningProcessesByBundleType() through proxy project.
|
||||
|
@ -105,6 +105,7 @@ private:
|
||||
int32_t HandleDumpHeapMemory(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleDumpJsHeapMemory(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleGetRunningMultiAppInfoByBundleName(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleGetAllRunningInstanceKeysBySelf(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleGetAllRunningInstanceKeysByBundleName(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleIsAppRunning(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t HandleGetAppRunningStateByBundleName(MessageParcel &data, MessageParcel &reply);
|
||||
|
@ -69,6 +69,7 @@ private:
|
||||
if (remote_ == remote.promote()) {
|
||||
remote_->RemoveDeathRecipient(deathRecipient_);
|
||||
remote_ = nullptr;
|
||||
deathRecipient_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,6 +78,10 @@ private:
|
||||
if (!serviceManager_) {
|
||||
return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
|
||||
}
|
||||
if (remote_) {
|
||||
return AppMgrResultCode::RESULT_OK;
|
||||
}
|
||||
TAG_LOGI(AAFwkTag::APPMGR, "get AppMgrRemote object");
|
||||
remote_ = serviceManager_->GetAppMgrService();
|
||||
if (!remote_) {
|
||||
return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
|
||||
@ -416,17 +421,34 @@ AppMgrResultCode AppMgrClient::GetProcessRunningInformation(AppExecFwk::RunningP
|
||||
return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
AppMgrResultCode AppMgrClient::GetAllRunningInstanceKeysByBundleName(const std::string &bundleName,
|
||||
std::vector<std::string> &instanceKeys)
|
||||
AppMgrResultCode AppMgrClient::GetAllRunningInstanceKeysBySelf(std::vector<std::string> &instanceKeys)
|
||||
{
|
||||
sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
|
||||
if (service != nullptr) {
|
||||
int32_t result = service->GetAllRunningInstanceKeysByBundleName(bundleName, instanceKeys);
|
||||
int32_t result = service->GetAllRunningInstanceKeysBySelf(instanceKeys);
|
||||
if (result == ERR_OK) {
|
||||
return AppMgrResultCode::RESULT_OK;
|
||||
}
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "GetAllRunningInstanceKeysBySelf returns result=%{public}d", result);
|
||||
return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
|
||||
}
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "service is nullptr");
|
||||
return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
AppMgrResultCode AppMgrClient::GetAllRunningInstanceKeysByBundleName(const std::string &bundleName,
|
||||
std::vector<std::string> &instanceKeys, int32_t userId)
|
||||
{
|
||||
sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
|
||||
if (service != nullptr) {
|
||||
int32_t result = service->GetAllRunningInstanceKeysByBundleName(bundleName, instanceKeys, userId);
|
||||
if (result == ERR_OK) {
|
||||
return AppMgrResultCode::RESULT_OK;
|
||||
}
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "GetAllRunningInstanceKeysByBundleName returns result=%{public}d", result);
|
||||
return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
|
||||
}
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "service is nullptr");
|
||||
return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
|
@ -219,8 +219,25 @@ int32_t AppMgrProxy::GetRunningMultiAppInfoByBundleName(const std::string &bundl
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t AppMgrProxy::GetAllRunningInstanceKeysBySelf(std::vector<std::string> &instanceKeys)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_SYNC);
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
|
||||
PARCEL_UTIL_SENDREQ_RET_INT(AppMgrInterfaceCode::GET_All_RUNNING_INSTANCE_KEYS_BY_SELF, data, reply, option);
|
||||
if (!reply.ReadStringVector(&instanceKeys)) {
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
int32_t result = reply.ReadInt32();
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t AppMgrProxy::GetAllRunningInstanceKeysByBundleName(const std::string &bundleName,
|
||||
std::vector<std::string> &instanceKeys)
|
||||
std::vector<std::string> &instanceKeys, int32_t userId)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
@ -229,6 +246,7 @@ int32_t AppMgrProxy::GetAllRunningInstanceKeysByBundleName(const std::string &bu
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
PARCEL_UTIL_WRITE_RET_INT(data, String, bundleName);
|
||||
PARCEL_UTIL_WRITE_RET_INT(data, Int32, userId);
|
||||
|
||||
PARCEL_UTIL_SENDREQ_RET_INT(AppMgrInterfaceCode::GET_All_RUNNING_INSTANCE_KEYS_BY_BUNDLENAME, data, reply, option);
|
||||
if (!reply.ReadStringVector(&instanceKeys)) {
|
||||
|
@ -37,22 +37,6 @@
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
constexpr int32_t CYCLE_LIMIT = 1000;
|
||||
namespace {
|
||||
#ifdef __aarch64__
|
||||
constexpr uint32_t OBJECT_MASK = 0xffffffff;
|
||||
#else
|
||||
constexpr uint32_t OBJECT_MASK = 0xffffff;
|
||||
#endif
|
||||
|
||||
uint32_t ConvertAddr(const void *ptr)
|
||||
{
|
||||
if (ptr == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "ptr is null");
|
||||
return 0;
|
||||
}
|
||||
return static_cast<uint32_t>((reinterpret_cast<uintptr_t>(ptr)) & OBJECT_MASK);
|
||||
}
|
||||
}
|
||||
|
||||
AppMgrStub::AppMgrStub() {}
|
||||
|
||||
@ -215,6 +199,8 @@ int32_t AppMgrStub::OnRemoteRequestInnerThird(uint32_t code, MessageParcel &data
|
||||
return HandleNotifyFault(data, reply);
|
||||
case static_cast<uint32_t>(AppMgrInterfaceCode::GET_All_RUNNING_INSTANCE_KEYS_BY_BUNDLENAME):
|
||||
return HandleGetAllRunningInstanceKeysByBundleName(data, reply);
|
||||
case static_cast<uint32_t>(AppMgrInterfaceCode::GET_All_RUNNING_INSTANCE_KEYS_BY_SELF):
|
||||
return HandleGetAllRunningInstanceKeysBySelf(data, reply);
|
||||
}
|
||||
return INVALID_FD;
|
||||
}
|
||||
@ -370,12 +356,6 @@ int32_t AppMgrStub::HandleAttachApplication(MessageParcel &data, MessageParcel &
|
||||
if (client == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "remote object null");
|
||||
}
|
||||
TAG_LOGI(AAFwkTag::APPMGR, "remote: %{public}u", ConvertAddr(client.GetRefPtr()));
|
||||
IPCObjectProxy *proxy = reinterpret_cast<IPCObjectProxy *>(client.GetRefPtr());
|
||||
if (proxy != nullptr) {
|
||||
int32_t pid = static_cast<int32_t>(IPCSkeleton::GetCallingPid());
|
||||
TAG_LOGI(AAFwkTag::APPMGR, "handle:%{public}u, callingPid:%{public}d", proxy->GetHandle(), pid);
|
||||
}
|
||||
AttachApplication(client);
|
||||
return NO_ERROR;
|
||||
}
|
||||
@ -495,11 +475,27 @@ int32_t AppMgrStub::HandleGetRunningMultiAppInfoByBundleName(MessageParcel &data
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AppMgrStub::HandleGetAllRunningInstanceKeysBySelf(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
std::vector<std::string> instanceKeys;
|
||||
int32_t result = GetAllRunningInstanceKeysBySelf(instanceKeys);
|
||||
if (!reply.WriteStringVector(instanceKeys)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "failed to write isntanceKeys");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
if (!reply.WriteInt32(result)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "fail to write result.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t AppMgrStub::HandleGetAllRunningInstanceKeysByBundleName(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
std::string bundleName = data.ReadString();
|
||||
int32_t userId = data.ReadInt32();
|
||||
std::vector<std::string> instanceKeys;
|
||||
int32_t result = GetAllRunningInstanceKeysByBundleName(bundleName, instanceKeys);
|
||||
int32_t result = GetAllRunningInstanceKeysByBundleName(bundleName, instanceKeys, userId);
|
||||
if (!reply.WriteStringVector(instanceKeys)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "failed to write isntanceKeys");
|
||||
return ERR_INVALID_VALUE;
|
||||
|
@ -39,6 +39,7 @@ int AppSchedulerHost::OnRemoteRequest(uint32_t code, MessageParcel &data, Messag
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "AppSchedulerHost::OnReceived, code = %{public}u, flags= %{public}d.", code,
|
||||
option.GetFlags());
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
std::u16string descriptor = AppSchedulerHost::GetDescriptor();
|
||||
std::u16string remoteDescriptor = data.ReadInterfaceToken();
|
||||
if (descriptor != remoteDescriptor) {
|
||||
|
@ -34,15 +34,15 @@ const std::map<int32_t, std::string> ERROR_MSG_MAP = {
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_NO_SUCH_ABILITY_NAME,
|
||||
"Input error. The specified ability name not exsit." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_NOT_SUPPORT_OPERATION,
|
||||
"Ability type error. The specified ability type is wrong." },
|
||||
"Incorrect ability type." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_NO_SUCH_ID,
|
||||
"Input error. The specified id not exsit." },
|
||||
"The specified ID does not exist." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_VISIBILITY_VERIFICATION_FAILED,
|
||||
"Visibility verification failed." },
|
||||
"Failed to start the invisible ability." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_CROSS_USER_OPERATION,
|
||||
"Cannot cross user operations." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_SERVICE_BUSY,
|
||||
"Service busyness. There are concurrent tasks, waiting for retry." },
|
||||
"Service busy. There are concurrent tasks. Try again later." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_CROWDTEST_APP_EXPIRATION,
|
||||
"Crowdtest App Expiration." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_WUKONG_MODE,
|
||||
@ -70,7 +70,7 @@ const std::map<int32_t, std::string> ERROR_MSG_MAP = {
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_NOT_TOP_ABILITY,
|
||||
"Not top ability. The application is not top ability." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_FREE_INSTALL_BUSY,
|
||||
"Free install busyness. There are concurrent tasks, waiting for retry." },
|
||||
"The installation-free service is busy. Try again later." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_FREE_INSTALL_TIMEOUT,
|
||||
"Free install timeout." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_CANNOT_FREE_INSTALL_OTHER_ABILITY,
|
||||
@ -82,9 +82,9 @@ const std::map<int32_t, std::string> ERROR_MSG_MAP = {
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_WANTAGENT,
|
||||
"Invalid wantagent object." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_WANTAGENT_NOT_FOUND,
|
||||
"WantAgent object not found." },
|
||||
"The wantAgent object does not exist." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_WANTAGENT_CANCELED,
|
||||
"WantAgent object canceled" },
|
||||
"The wantAgent object has been canceled." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_NO_SUCH_URI_ABILITY,
|
||||
"Input error. The specified uri does not exist." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_FA_NOT_SUPPORT_OPERATION,
|
||||
@ -92,19 +92,19 @@ const std::map<int32_t, std::string> ERROR_MSG_MAP = {
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_CALLER_RELEASED,
|
||||
"Caller released. The caller has been released." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_CALLEE_INVALID,
|
||||
"Callee invalid. The callee does not exist." },
|
||||
"The callee does not exist." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_RELEASE_ERROR,
|
||||
"Release error. The caller does not call any callee." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_METHOED_REGISTERED,
|
||||
"Method registered. The method has registered." },
|
||||
"The method has been registered." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_METHOED_NOT_REGISTERED,
|
||||
"Method not registered. The method has not registered." },
|
||||
"The method has not been registered." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_NO_SUCH_MISSION,
|
||||
"Mission id error. The specified mission id does not exist." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_NO_SUCH_MISSION_LISTENER,
|
||||
"Input error. The specified mission listener id does not exist." },
|
||||
"The specified mission listener does not exist." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_NO_SUCH_BUNDLENAME,
|
||||
"The specified bundleName is invalid." },
|
||||
"The bundle does not exist or no patch has been applied." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_NO_SUCH_HQF,
|
||||
"The specified hqf is invalid. Hqf may not exist or inaccessible." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_DEPLOY_HQF_FAILED,
|
||||
@ -112,7 +112,7 @@ const std::map<int32_t, std::string> ERROR_MSG_MAP = {
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_SWITCH_HQF_FAILED,
|
||||
"Switch hqf failed." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_DELETE_HQF_FAILED,
|
||||
"Delete hqf failed." },
|
||||
"Failed to remove the patch package." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_LOAD_PATCH_FAILED,
|
||||
"Load patch failed." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_UNLOAD_PATCH_FAILED,
|
||||
@ -128,11 +128,11 @@ const std::map<int32_t, std::string> ERROR_MSG_MAP = {
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_NO_SUCH_SYSCAP,
|
||||
"The specified SystemCapability name was not found." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_START_ABILITY_WAITTING,
|
||||
"The previous ability is starting, wait start later." },
|
||||
"Another ability is being started. Wait until it finishes starting." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_NOT_SUPPORT_CROSS_APP_START,
|
||||
"The application is not allow jumping to other applications." },
|
||||
"Redirection to a third-party application is not allowed in API version 11 or later." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_CANNOT_MATCH_ANY_COMPONENT,
|
||||
"Can not match any component." },
|
||||
"No matching ability is found." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_URI_FLAG,
|
||||
"Invalid URI flag." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_URI_TYPE,
|
||||
@ -142,9 +142,9 @@ const std::map<int32_t, std::string> ERROR_MSG_MAP = {
|
||||
{ ERR_ABILITY_RUNTIME_OPERATION_NOT_SUPPORTED,
|
||||
"Operation not supported." },
|
||||
{ ERR_ABILITY_RUNTIME_CHILD_PROCESS_NUMBER_EXCEEDS_UPPER_BOUND,
|
||||
"The number of child process exceeds upper bound." },
|
||||
"The number of child processes exceeds the upper limit." },
|
||||
{ ERR_ABILITY_RUNTIME_RESTART_APP_INCORRECT_ABILITY,
|
||||
"The target to restart does not belong to the current app or is not a UIAbility." },
|
||||
"The target to restart does not belong to the current application or is not a UIAbility." },
|
||||
{ ERR_ABILITY_RUNTIME_RESTART_APP_FREQUENT,
|
||||
"Restart too frequently. Try again at least 10s later." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_NOT_SYSTEM_HSP,
|
||||
|
@ -63,15 +63,15 @@ const std::map<int32_t, std::string> EXTERNAL_ERR_MSG_MAP = {
|
||||
{ ERR_QUICKFIX_PERMISSION_DENIED, "The application does not have permission to call the interface." },
|
||||
{ ERR_QUICKFIX_NOT_SYSTEM_APP, "The application is not system-app, can not use system-api." },
|
||||
{ ERR_QUICKFIX_PARAM_INVALID, "Invalid input parameter." },
|
||||
{ ERR_QUICKFIX_BUNDLE_NAME_INVALID, "The specified bundleName is invalid." },
|
||||
{ ERR_QUICKFIX_BUNDLE_NAME_INVALID, "The bundle does not exist or no patch has been applied." },
|
||||
{ ERR_QUICKFIX_HQF_INVALID, "The specified hqf is invalid. Hqf may not exist or inaccessible." },
|
||||
{ ERR_QUICKFIX_HQF_DEPLOY_FAILED, "Deploy hqf failed." },
|
||||
{ ERR_QUICKFIX_HQF_SWITCH_FAILED, "Switch hqf failed." },
|
||||
{ ERR_QUICKFIX_HQF_DELETE_FAILED, "Delete hqf failed." },
|
||||
{ ERR_QUICKFIX_HQF_DELETE_FAILED, "Failed to remove the patch package." },
|
||||
{ ERR_QUICKFIX_LOAD_PATCH_FAILED, "Load patch failed." },
|
||||
{ ERR_QUICKFIX_UNLOAD_PATCH_FAILED, "Unload patch failed." },
|
||||
{ ERR_QUICKFIX_INTERNAL_ERROR, "Internal error." },
|
||||
{ ERR_QUICKFIX_DEPLOYING_TASK, "The application has a apply quick fix task that is being processed." },
|
||||
{ ERR_QUICKFIX_DEPLOYING_TASK, "The application has an ongoing quick fix task." },
|
||||
};
|
||||
} // namespace
|
||||
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
static WantAgentClient &GetInstance();
|
||||
|
||||
ErrCode GetWantSender(const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken,
|
||||
sptr<IWantSender> &wantSender);
|
||||
sptr<IWantSender> &wantSender, int32_t uid = -1);
|
||||
|
||||
ErrCode SendWantSender(sptr<IWantSender> target, const SenderInfo &senderInfo);
|
||||
|
||||
|
@ -71,7 +71,7 @@ public:
|
||||
* @return Returns the created WantAgent object.
|
||||
*/
|
||||
static std::shared_ptr<WantAgent> GetWantAgent(const WantAgentInfo ¶msInfo,
|
||||
int32_t userId = INVLID_WANT_AGENT_USER_ID);
|
||||
int32_t userId = INVLID_WANT_AGENT_USER_ID, int32_t uid = -1);
|
||||
|
||||
/**
|
||||
* Obtains an WantAgent object operation type.
|
||||
@ -178,7 +178,7 @@ public:
|
||||
* @param jsonString Json string.
|
||||
* @return WantAgentInfo object.
|
||||
*/
|
||||
static std::shared_ptr<WantAgent> FromString(const std::string &jsonString);
|
||||
static std::shared_ptr<WantAgent> FromString(const std::string &jsonString, int32_t uid = -1);
|
||||
|
||||
private:
|
||||
WantAgentHelper();
|
||||
|
@ -39,7 +39,8 @@ WantAgentClient::WantAgentClient() {}
|
||||
WantAgentClient::~WantAgentClient() {}
|
||||
|
||||
ErrCode WantAgentClient::GetWantSender(
|
||||
const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken, sptr<IWantSender> &wantSender)
|
||||
const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken, sptr<IWantSender> &wantSender,
|
||||
int32_t uid)
|
||||
{
|
||||
auto abms = GetAbilityManager();
|
||||
CHECK_POINTER_AND_RETURN(abms, ERR_ABILITY_RUNTIME_EXTERNAL_SERVICE_BUSY);
|
||||
@ -65,6 +66,11 @@ ErrCode WantAgentClient::GetWantSender(
|
||||
}
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(uid)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "uid write fail");
|
||||
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
auto error = abms->SendRequest(static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_PENDING_WANT_SENDER),
|
||||
data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
|
@ -142,7 +142,7 @@ ErrCode WantAgentHelper::GetWantAgent(
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
std::shared_ptr<WantAgent> WantAgentHelper::GetWantAgent(const WantAgentInfo ¶msInfo, int32_t userId)
|
||||
std::shared_ptr<WantAgent> WantAgentHelper::GetWantAgent(const WantAgentInfo ¶msInfo, int32_t userId, int32_t uid)
|
||||
{
|
||||
std::vector<std::shared_ptr<Want>> wants = paramsInfo.GetWants();
|
||||
if (wants.empty()) {
|
||||
@ -170,7 +170,7 @@ std::shared_ptr<WantAgent> WantAgentHelper::GetWantAgent(const WantAgentInfo &pa
|
||||
wantSenderInfo.type = static_cast<int32_t>(paramsInfo.GetOperationType());
|
||||
wantSenderInfo.userId = userId;
|
||||
sptr<IWantSender> target = nullptr;
|
||||
WantAgentClient::GetInstance().GetWantSender(wantSenderInfo, nullptr, target);
|
||||
WantAgentClient::GetInstance().GetWantSender(wantSenderInfo, nullptr, target, uid);
|
||||
if (target == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -375,7 +375,7 @@ std::string WantAgentHelper::ToString(const std::shared_ptr<WantAgent> &agent)
|
||||
return jsonObject.dump();
|
||||
}
|
||||
|
||||
std::shared_ptr<WantAgent> WantAgentHelper::FromString(const std::string &jsonString)
|
||||
std::shared_ptr<WantAgent> WantAgentHelper::FromString(const std::string &jsonString, int32_t uid)
|
||||
{
|
||||
if (jsonString.empty()) {
|
||||
return nullptr;
|
||||
@ -420,7 +420,7 @@ std::shared_ptr<WantAgent> WantAgentHelper::FromString(const std::string &jsonSt
|
||||
}
|
||||
WantAgentInfo info(requestCode, operationType, flagsVec, wants, extraInfo);
|
||||
|
||||
return GetWantAgent(info);
|
||||
return GetWantAgent(info, INVLID_WANT_AGENT_USER_ID, uid);
|
||||
}
|
||||
|
||||
std::vector<WantAgentConstant::Flags> WantAgentHelper::ParseFlags(nlohmann::json jsonObject)
|
||||
|
@ -43,6 +43,7 @@ public:
|
||||
static napi_value DisconnectAbility(napi_env env, napi_callback_info info);
|
||||
static napi_value TerminateSelf(napi_env env, napi_callback_info info);
|
||||
static napi_value TerminateSelfWithResult(napi_env env, napi_callback_info info);
|
||||
static napi_value BackToCallerAbilityWithResult(napi_env env, napi_callback_info info);
|
||||
static napi_value CreateJsEmbeddableUIAbilityContext(napi_env env, std::shared_ptr<AbilityContext> uiAbiContext,
|
||||
std::shared_ptr<UIExtensionContext> uiExtContext, int32_t screenMode);
|
||||
static napi_value StartAbilityAsCaller(napi_env env, napi_callback_info info);
|
||||
@ -80,6 +81,7 @@ private:
|
||||
napi_value OnDisconnectAbility(napi_env env, NapiCallbackInfo& info);
|
||||
napi_value OnTerminateSelf(napi_env env, NapiCallbackInfo& info);
|
||||
napi_value OnTerminateSelfWithResult(napi_env env, NapiCallbackInfo& info);
|
||||
napi_value OnBackToCallerAbilityWithResult(napi_env env, NapiCallbackInfo& info);
|
||||
napi_value OnStartAbilityAsCaller(napi_env env, NapiCallbackInfo& info);
|
||||
napi_value OnStartAbilityWithAccount(napi_env env, NapiCallbackInfo& info);
|
||||
napi_value OnStartAbilityByCall(napi_env env, NapiCallbackInfo& info);
|
||||
|
@ -21,12 +21,16 @@
|
||||
#include "bundle_mgr_interface.h"
|
||||
|
||||
namespace OHOS {
|
||||
constexpr static int REPOLL_TIME_MICRO_SECONDS = 1000000;
|
||||
|
||||
namespace AppExecFwk {
|
||||
using Want = OHOS::AAFwk::Want;
|
||||
|
||||
class BundleMgrHelper : public std::enable_shared_from_this<BundleMgrHelper> {
|
||||
public:
|
||||
DISALLOW_COPY_AND_MOVE(BundleMgrHelper);
|
||||
void PreConnect();
|
||||
void ConnectTillSuccess();
|
||||
ErrCode GetNameForUid(const int32_t uid, std::string &name);
|
||||
ErrCode GetNameAndIndexForUid(const int32_t uid, std::string &bundleName, int32_t &appIndex);
|
||||
bool GetBundleInfo(const std::string &bundleName, const BundleFlag flag, BundleInfo &bundleInfo, int32_t userId);
|
||||
@ -109,7 +113,7 @@ private:
|
||||
sptr<IBundleInstaller> ConnectBundleInstaller();
|
||||
void OnDeath();
|
||||
std::string ParseBundleNameByAppId(const std::string &appId) const;
|
||||
|
||||
|
||||
private:
|
||||
DECLARE_DELAYED_SINGLETON(BundleMgrHelper)
|
||||
std::mutex mutex_;
|
||||
|
@ -145,8 +145,7 @@ public:
|
||||
void SetCurrentAppCloneIndex(int32_t appIndex);
|
||||
std::string GetCurrentInstanceKey();
|
||||
void SetCurrentInstanceKey(const std::string& instanceKey);
|
||||
int32_t GetAllRunningInstanceKeys(const std::string& bundleName,
|
||||
std::vector<std::string> &instanceKeys);
|
||||
int32_t GetAllRunningInstanceKeys(std::vector<std::string> &instanceKeys);
|
||||
int32_t GetCurrentAppMode();
|
||||
void SetCurrentAppMode(int32_t appIndex);
|
||||
void ProcessSecurityExit(const AAFwk::ExitReason &exitReason);
|
||||
|
@ -356,8 +356,7 @@ public:
|
||||
*
|
||||
* @return error code
|
||||
*/
|
||||
int32_t GetAllRunningInstanceKeys(const std::string& bundleName,
|
||||
std::vector<std::string> &instanceKeys);
|
||||
int32_t GetAllRunningInstanceKeys(std::vector<std::string> &instanceKeys);
|
||||
|
||||
/**
|
||||
* @brief Restart app
|
||||
|
@ -661,6 +661,7 @@ private:
|
||||
std::string pathSeparator_ = "/";
|
||||
std::string abilityLibraryType_ = ".so";
|
||||
static std::weak_ptr<OHOSApplication> applicationForDump_;
|
||||
bool isDeveloperMode_ = false;
|
||||
|
||||
#ifdef ABILITY_LIBRARY_LOADER
|
||||
/**
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "ability_stage.h"
|
||||
#include "app_context.h"
|
||||
#include "context.h"
|
||||
#include "ability_stage_context.h"
|
||||
#include "application_configuration_manager.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -147,7 +148,9 @@ public:
|
||||
* @param hapModuleInfo
|
||||
* @return Returns true on success, false on failure
|
||||
*/
|
||||
bool AddAbilityStage(const AppExecFwk::HapModuleInfo &hapModuleInfo);
|
||||
bool AddAbilityStage(
|
||||
const AppExecFwk::HapModuleInfo &hapModuleInfo,
|
||||
const std::function<void()> &callback, bool &isAsyncCallback);
|
||||
|
||||
/**
|
||||
* @brief remove the ability stage when all of the abilities in the hap have been removed
|
||||
@ -214,6 +217,9 @@ public:
|
||||
|
||||
void AutoStartupDone(const std::shared_ptr<AbilityLocalRecord> &abilityRecord,
|
||||
const std::shared_ptr<AbilityRuntime::AbilityStage> &abilityStage, const std::string &moduleName);
|
||||
|
||||
void AutoStartupDone(const std::shared_ptr<AbilityRuntime::AbilityStage> &abilityStage,
|
||||
const AppExecFwk::HapModuleInfo &hapModuleInfo);
|
||||
|
||||
void CleanEmptyAbilityStage();
|
||||
|
||||
@ -226,6 +232,10 @@ private:
|
||||
const std::shared_ptr<AbilityRuntime::AbilityStage> abilityStage,
|
||||
const std::shared_ptr<AbilityLocalRecord> abilityRecord,
|
||||
const std::function<void(const std::shared_ptr<AbilityRuntime::Context>&)>& callback);
|
||||
const std::function<void()> CreateAutoStartupCallback(
|
||||
const std::shared_ptr<AbilityRuntime::AbilityStage> &abilityStage,
|
||||
const AppExecFwk::HapModuleInfo &hapModuleInfo,
|
||||
const std::function<void()>& callback);
|
||||
bool IsMainProcess(const std::string &bundleName, const std::string &process);
|
||||
|
||||
private:
|
||||
|
@ -121,6 +121,7 @@ ohos_shared_library("abilityms") {
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_setting",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:mission_info",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:process_options",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:start_window_option",
|
||||
"${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",
|
||||
@ -229,6 +230,12 @@ ohos_shared_library("abilityms") {
|
||||
external_deps += [ "power_manager:powermgr_client" ]
|
||||
}
|
||||
|
||||
if (ability_runtime_graphics &&
|
||||
ability_runtime_start_window_options_with_pixelmap) {
|
||||
defines += [ "START_WINDOW_OPTIONS_WITH_PIXELMAP" ]
|
||||
external_deps += [ "image_framework:image_native" ]
|
||||
}
|
||||
|
||||
version_script = "libabilityms.map"
|
||||
subsystem_name = "ability"
|
||||
innerapi_tags = [ "platformsdk_indirect" ]
|
||||
|
@ -33,8 +33,8 @@ abilityms_files = [
|
||||
"src/assert_fault_callback_death_mgr.cpp",
|
||||
"src/assert_fault_proxy.cpp",
|
||||
"src/connection_record.cpp",
|
||||
"src/data_ability_caller_recipient.cpp",
|
||||
"src/data_ability_manager.cpp",
|
||||
"src/data_ability/data_ability_caller_recipient.cpp",
|
||||
"src/data_ability/data_ability_manager.cpp",
|
||||
"src/data_ability/data_ability_record.cpp",
|
||||
"src/dialog_session/dialog_session_manager.cpp",
|
||||
"src/lifecycle_deal.cpp",
|
||||
@ -137,7 +137,9 @@ abilityms_files = [
|
||||
"src/utils/dump_utils.cpp",
|
||||
"src/utils/ability_permission_util.cpp",
|
||||
"src/utils/modal_system_dialog_util.cpp",
|
||||
"src/utils/multi_app_utils.cpp",
|
||||
"src/utils/multi_instance_utils.cpp",
|
||||
"src/utils/update_caller_info_util.cpp",
|
||||
]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
|
@ -116,12 +116,6 @@ public:
|
||||
*/
|
||||
virtual int32_t NotifyRemoveShellProcess(int32_t pid, int32_t type, const std::string &reason) override;
|
||||
|
||||
/**
|
||||
* @brief Update mission info to real element by broker.
|
||||
* @param info info of mission.
|
||||
*/
|
||||
virtual void UpdateMissionInfo(InnerMissionInfoDto &info) override;
|
||||
|
||||
/**
|
||||
* @brief Update mission info to real element by broker.
|
||||
* @param sessionInfo sessionInfo.
|
||||
|
@ -643,7 +643,7 @@ public:
|
||||
int32_t appIndex = 0) override;
|
||||
|
||||
virtual sptr<IWantSender> GetWantSender(
|
||||
const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken) override;
|
||||
const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken, int32_t uid = -1) override;
|
||||
|
||||
virtual int SendWantSender(sptr<IWantSender> target, const SenderInfo &senderInfo) override;
|
||||
|
||||
|
@ -880,7 +880,7 @@ public:
|
||||
int32_t appIndex = 0) override;
|
||||
|
||||
virtual sptr<IWantSender> GetWantSender(
|
||||
const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken) override;
|
||||
const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken, int32_t uid = -1) override;
|
||||
|
||||
virtual int SendWantSender(sptr<IWantSender> target, const SenderInfo &senderInfo) override;
|
||||
|
||||
@ -1791,6 +1791,8 @@ public:
|
||||
|
||||
int32_t BlockAllAppStart(bool flag) override;
|
||||
|
||||
int SetWantForSessionInfo(sptr<SessionInfo> sessionInfo);
|
||||
|
||||
int32_t StartUIAbilityBySCBDefaultCommon(AbilityRequest &abilityRequest, sptr<SessionInfo> sessionInfo,
|
||||
uint32_t sceneFlag, bool &isColdStart);
|
||||
|
||||
@ -1807,6 +1809,8 @@ public:
|
||||
*/
|
||||
int IsCallFromBackground(const AbilityRequest &abilityRequest, bool &isBackgroundCall, bool isData = false);
|
||||
|
||||
void EnableListForSCBRecovery(int32_t userId) const;
|
||||
|
||||
// MSG 0 - 20 represents timeout message
|
||||
static constexpr uint32_t LOAD_TIMEOUT_MSG = 0;
|
||||
static constexpr uint32_t ACTIVE_TIMEOUT_MSG = 1;
|
||||
@ -1876,7 +1880,7 @@ private:
|
||||
* connect bms.
|
||||
*
|
||||
*/
|
||||
void ConnectBmsService();
|
||||
void ConnectServices();
|
||||
|
||||
/**
|
||||
* Determine whether it is a system APP
|
||||
@ -1889,8 +1893,6 @@ private:
|
||||
*/
|
||||
void InitGlobalConfiguration();
|
||||
|
||||
sptr<OHOS::AppExecFwk::IAppMgr> GetAppMgr();
|
||||
|
||||
int StartRemoteAbility(const Want &want, int requestCode, int32_t validUserId,
|
||||
const sptr<IRemoteObject> &callerToken);
|
||||
int StartUIAbilityBySCBDefault(sptr<SessionInfo> sessionInfo, uint32_t sceneFlag, bool &isColdStart);
|
||||
@ -1913,13 +1915,6 @@ private:
|
||||
int DisconnectRemoteAbility(const sptr<IRemoteObject> &connect);
|
||||
int PreLoadAppDataAbilities(const std::string &bundleName, const int32_t userId);
|
||||
void PreLoadAppDataAbilitiesTask(const std::string &bundleName, const int32_t userId);
|
||||
void UpdateAsCallerSourceInfo(Want& want, sptr<IRemoteObject> asCallerSourceToken, sptr<IRemoteObject> callerToken);
|
||||
void UpdateAsCallerInfoFromToken(Want& want, sptr<IRemoteObject> asCallerSourceToken);
|
||||
void UpdateAsCallerInfoFromCallerRecord(Want& want, sptr<IRemoteObject> callerToken);
|
||||
bool UpdateAsCallerInfoFromDialog(Want& want);
|
||||
void UpdateCallerInfo(Want& want, const sptr<IRemoteObject> &callerToken);
|
||||
void UpdateSignatureInfo(std::string bundleName, Want& want);
|
||||
void UpdateCallerInfoFromToken(Want& want, const sptr<IRemoteObject> &token);
|
||||
int StartAbilityPublicPrechainCheck(StartAbilityParams ¶ms);
|
||||
int StartAbilityPrechainInterceptor(StartAbilityParams ¶ms);
|
||||
bool StartAbilityInChain(StartAbilityParams ¶ms, int &result);
|
||||
@ -2007,7 +2002,7 @@ private:
|
||||
std::shared_ptr<MissionListManagerInterface> GetCurrentMissionListManager();
|
||||
std::unordered_map<int, std::shared_ptr<UIAbilityLifecycleManager>> GetUIAbilityManagers();
|
||||
std::shared_ptr<UIAbilityLifecycleManager> GetCurrentUIAbilityManager();
|
||||
std::shared_ptr<UIAbilityLifecycleManager> GetUIAbilityManagerByUserId(int32_t userId);
|
||||
std::shared_ptr<UIAbilityLifecycleManager> GetUIAbilityManagerByUserId(int32_t userId) const;
|
||||
std::shared_ptr<UIAbilityLifecycleManager> GetUIAbilityManagerByUid(int32_t uid);
|
||||
bool JudgeSelfCalled(const std::shared_ptr<AbilityRecord> &abilityRecord);
|
||||
bool IsAppSelfCalled(const std::shared_ptr<AbilityRecord> &abilityRecord);
|
||||
@ -2259,9 +2254,6 @@ private:
|
||||
int32_t SetBackgroundCall(const AppExecFwk::RunningProcessInfo &processInfo,
|
||||
const AbilityRequest &abilityRequest, bool &isBackgroundCall) const;
|
||||
|
||||
void GetRunningMultiAppIndex(const std::string &bundleName, int32_t uid, int32_t &appIndex);
|
||||
ErrCode ConvertToExplicitWant(Want& want);
|
||||
|
||||
int CheckUIExtensionUsage(AppExecFwk::UIExtensionUsage uiExtensionUsage,
|
||||
AppExecFwk::ExtensionAbilityType extensionType);
|
||||
|
||||
@ -2315,13 +2307,11 @@ private:
|
||||
*/
|
||||
void ShowDeveloperModeDialog(const std::string &bundleName, const std::string &abilityName);
|
||||
|
||||
constexpr static int REPOLL_TIME_MICRO_SECONDS = 1000000;
|
||||
bool CheckWorkSchedulerPermission(const sptr<IRemoteObject> &callerToken, const uint32_t uid);
|
||||
|
||||
std::shared_ptr<TaskHandlerWrap> taskHandler_;
|
||||
std::shared_ptr<AbilityEventHandler> eventHandler_;
|
||||
ServiceRunningState state_;
|
||||
sptr<AppExecFwk::IBundleMgr> iBundleManager_;
|
||||
sptr<OHOS::AppExecFwk::IAppMgr> appMgr_ { nullptr };
|
||||
|
||||
std::shared_ptr<FreeInstallManager> freeInstallManager_;
|
||||
|
||||
@ -2399,8 +2389,6 @@ private:
|
||||
void ReportPreventStartAbilityResult(const AppExecFwk::AbilityInfo &callerAbilityInfo,
|
||||
const AppExecFwk::AbilityInfo &abilityInfo);
|
||||
|
||||
void UpdateBackToCallerFlag(const sptr<IRemoteObject> &callerToken, Want &want, int32_t requestCode, bool backFlag);
|
||||
|
||||
void SetAbilityRequestSessionInfo(AbilityRequest &abilityRequest, AppExecFwk::ExtensionAbilityType extensionType);
|
||||
|
||||
bool ShouldBlockAllAppStart();
|
||||
|
@ -263,6 +263,7 @@ struct AbilityRequest {
|
||||
|
||||
std::shared_ptr<AbilityStartSetting> startSetting = nullptr;
|
||||
std::shared_ptr<ProcessOptions> processOptions = nullptr;
|
||||
std::shared_ptr<StartWindowOption> startWindowOption = nullptr;
|
||||
std::string specifiedFlag;
|
||||
int32_t userId = -1;
|
||||
bool callSpecifiedFlagTimeout = false;
|
||||
@ -275,6 +276,7 @@ struct AbilityRequest {
|
||||
uint32_t specifyTokenId = 0;
|
||||
bool uriReservedFlag = false;
|
||||
std::string reservedBundleName;
|
||||
bool isFromIcon = false;
|
||||
std::pair<bool, LaunchReason> IsContinuation() const
|
||||
{
|
||||
auto flags = want.GetFlags();
|
||||
@ -1094,6 +1096,8 @@ public:
|
||||
|
||||
void RemoveConnectWant();
|
||||
|
||||
void UpdateDmsCallerInfo(Want &want);
|
||||
|
||||
inline std::string GetInstanceKey() const
|
||||
{
|
||||
return instanceKey_;
|
||||
@ -1104,6 +1108,16 @@ public:
|
||||
instanceKey_ = key;
|
||||
}
|
||||
|
||||
void SetSecurityFlag(bool securityFlag)
|
||||
{
|
||||
securityFlag_ = securityFlag;
|
||||
}
|
||||
|
||||
bool GetSecurityFlag() const
|
||||
{
|
||||
return securityFlag_;
|
||||
}
|
||||
|
||||
protected:
|
||||
void SendEvent(uint32_t msg, uint32_t timeOut, int32_t param = -1, bool isExtension = false);
|
||||
|
||||
@ -1328,6 +1342,7 @@ private:
|
||||
bool isLaunching_ = true;
|
||||
LaunchDebugInfo launchDebugInfo_;
|
||||
std::string instanceKey_ = "";
|
||||
bool securityFlag_ = false;
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
@ -30,21 +30,37 @@ public:
|
||||
BackgroundTaskObserver();
|
||||
virtual ~BackgroundTaskObserver();
|
||||
bool IsBackgroundTaskUid(const int uid);
|
||||
bool IsEfficiencyResourcesTaskUid(const int uid);
|
||||
|
||||
void GetContinuousTaskApps();
|
||||
void GetEfficiencyResourcesTaskApps();
|
||||
|
||||
private:
|
||||
void OnContinuousTaskStart(const std::shared_ptr<BackgroundTaskMgr::ContinuousTaskCallbackInfo>
|
||||
&continuousTaskCallbackInfo);
|
||||
&continuousTaskCallbackInfo) override;
|
||||
|
||||
void OnContinuousTaskStop(const std::shared_ptr<BackgroundTaskMgr::ContinuousTaskCallbackInfo>
|
||||
&continuousTaskCallbackInfo);
|
||||
&continuousTaskCallbackInfo) override;
|
||||
|
||||
void OnAppEfficiencyResourcesApply(
|
||||
const std::shared_ptr<BackgroundTaskMgr::ResourceCallbackInfo> &resourceInfo) override;
|
||||
|
||||
void OnAppEfficiencyResourcesReset(
|
||||
const std::shared_ptr<BackgroundTaskMgr::ResourceCallbackInfo> &resourceInfo) override;
|
||||
|
||||
void OnProcEfficiencyResourcesApply(
|
||||
const std::shared_ptr<BackgroundTaskMgr::ResourceCallbackInfo> &resourceInfo) override;
|
||||
|
||||
void OnProcEfficiencyResourcesReset(
|
||||
const std::shared_ptr<BackgroundTaskMgr::ResourceCallbackInfo> &resourceInfo) override;
|
||||
|
||||
sptr<AppExecFwk::IAppMgr> GetAppManager();
|
||||
|
||||
private:
|
||||
std::list<int> bgTaskUids_;
|
||||
std::mutex bgTaskMutex_;
|
||||
std::list<int> efficiencyUids_;
|
||||
std::mutex efficiencyMutex_;
|
||||
sptr<OHOS::AppExecFwk::IAppMgr> appManager_ = nullptr;
|
||||
};
|
||||
} // namespace AAFwk
|
||||
|
@ -234,7 +234,6 @@ private:
|
||||
void HandleFreeInstallResult(int32_t recordId, FreeInstallInfo &freeInstallInfo, int resultCode, bool isAsync);
|
||||
void HandleOnFreeInstallSuccess(int32_t recordId, FreeInstallInfo &freeInstallInfo, bool isAsync);
|
||||
void HandleOnFreeInstallFail(int32_t recordId, FreeInstallInfo &freeInstallInfo, int resultCode, bool isAsync);
|
||||
void NotifySCBToHandleException(const FreeInstallInfo &info, int resultCode);
|
||||
void StartAbilityByConvertedWant(FreeInstallInfo &info, const std::string &startTime);
|
||||
void StartAbilityByOriginalWant(FreeInstallInfo &info, const std::string &startTime);
|
||||
bool VerifyStartFreeInstallPermission(const sptr<IRemoteObject> &callerToken);
|
||||
|
@ -68,7 +68,8 @@ public:
|
||||
|
||||
private:
|
||||
int GenerateAbilityRequestByAction(int32_t userId, AbilityRequest &request,
|
||||
std::vector<DialogAppInfo> &dialogAppInfos, bool isMoreHapList, bool &findDefaultApp);
|
||||
std::vector<DialogAppInfo> &dialogAppInfos, bool isMoreHapList, bool &findDefaultApp,
|
||||
bool &isAppCloneSelector);
|
||||
|
||||
int GenerateAbilityRequestByAppIndexes(int32_t userId, AbilityRequest &request,
|
||||
std::vector<DialogAppInfo> &dialogAppInfos);
|
||||
@ -111,6 +112,12 @@ private:
|
||||
|
||||
int CheckImplicitCallPermission(const AbilityRequest& abilityRequest);
|
||||
|
||||
int32_t FindAppClone(std::vector<AppExecFwk::AbilityInfo> &abilityInfos,
|
||||
std::vector<AppExecFwk::ExtensionAbilityInfo> extensionInfos, bool &isAppCloneSelector);
|
||||
|
||||
bool FindAbilityAppClone(std::vector<AppExecFwk::AbilityInfo> &abilityInfos);
|
||||
bool FindExtensionAppClone(std::vector<AppExecFwk::ExtensionAbilityInfo> &extensionInfos);
|
||||
|
||||
private:
|
||||
bool IsExtensionInWhiteList(AppExecFwk::ExtensionAbilityType type);
|
||||
std::shared_ptr<AppExecFwk::BundleMgrHelper> iBundleManagerHelper_;
|
||||
|
@ -56,9 +56,6 @@ struct InnerMissionInfo {
|
||||
bool FromJsonStr(const std::string &jsonStr);
|
||||
void Dump(std::vector<std::string> &info) const;
|
||||
bool CheckJsonNode(nlohmann::json &value, const std::string &node, JsonType jsonType);
|
||||
|
||||
void UpdateMissionInfo(const InnerMissionInfoDto &info);
|
||||
InnerMissionInfoDto ConvertInnerMissionInfoDto();
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
@ -56,7 +56,7 @@ private:
|
||||
void BuildSendWant(SenderInfo &senderInfo, Want &want);
|
||||
int32_t ExecuteOperation(
|
||||
std::shared_ptr<PendingWantManager> pendingWantManager, SenderInfo &senderInfo, Want &want);
|
||||
void CheckAppInstanceKey(WantParams &wantParams);
|
||||
void CheckAppInstanceKey(const std::string& bundleName, WantParams &wantParams);
|
||||
|
||||
private:
|
||||
std::weak_ptr<PendingWantManager> pendingWantManager_ = {};
|
||||
|
@ -29,6 +29,7 @@ class PreLoadUIExtStateObserver final : public AppExecFwk::ApplicationStateObser
|
||||
public:
|
||||
PreLoadUIExtStateObserver(std::weak_ptr<AbilityRuntime::ExtensionRecord> extensionRecord);
|
||||
void OnProcessDied(const AppExecFwk::ProcessData &processData) override;
|
||||
void OnAppCacheStateChanged(const AppExecFwk::AppStateData &appStateData) override;
|
||||
|
||||
private:
|
||||
std::weak_ptr<AbilityRuntime::ExtensionRecord> extensionRecord_ = std::weak_ptr<AbilityRuntime::ExtensionRecord>();
|
||||
|
@ -31,6 +31,7 @@ public:
|
||||
int32_t RegisterStatusBarDelegate(sptr<AbilityRuntime::IStatusBarDelegate> delegate);
|
||||
bool IsCallerInStatusBar();
|
||||
int32_t DoProcessAttachment(std::shared_ptr<AbilityRecord> abilityRecord);
|
||||
int32_t DoCallerProcessAttachment(std::shared_ptr<AbilityRecord> abilityRecord);
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_MOVE(StatusBarDelegateManager);
|
||||
|
@ -369,6 +369,8 @@ public:
|
||||
|
||||
int32_t CleanUIAbility(const std::shared_ptr<AbilityRecord> &abilityRecord, bool forceKill);
|
||||
|
||||
void EnableListForSCBRecovery();
|
||||
|
||||
private:
|
||||
int32_t GetPersistentIdByAbilityRequest(const AbilityRequest &abilityRequest, bool &reuse) const;
|
||||
int32_t GetReusedSpecifiedPersistentId(const AbilityRequest &abilityRequest, bool &reuse) const;
|
||||
@ -442,6 +444,9 @@ private:
|
||||
void TerminateSession(std::shared_ptr<AbilityRecord> abilityRecord);
|
||||
int StartWithPersistentIdByDistributed(const AbilityRequest &abilityRequest, int32_t persistentId);
|
||||
void CheckCallerFromBackground(std::shared_ptr<AbilityRecord> callerAbility, sptr<SessionInfo> &sessionInfo);
|
||||
int32_t DoCallerProcessAttachment(std::shared_ptr<AbilityRecord> abilityRecord);
|
||||
std::shared_ptr<AbilityRecord> GenerateAbilityRecord(AbilityRequest &abilityRequest, sptr<SessionInfo> sessionInfo,
|
||||
bool &isColdStart);
|
||||
|
||||
int32_t userId_ = -1;
|
||||
mutable ffrt::mutex sessionLock_;
|
||||
@ -456,6 +461,8 @@ private:
|
||||
sptr<ISessionHandler> handler_;
|
||||
ffrt::mutex statusBarDelegateManagerLock_;
|
||||
std::shared_ptr<StatusBarDelegateManager> statusBarDelegateManager_;
|
||||
bool isSCBRecovery_ = false;
|
||||
std::unordered_set<int32_t> codeStartInSCBRecovery_;
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
@ -49,6 +49,7 @@ public:
|
||||
|
||||
std::shared_ptr<DataAbilityManager> GetCurrentDataAbilityManager();
|
||||
std::shared_ptr<DataAbilityManager> GetDataAbilityManager(const sptr<IAbilityScheduler> &scheduler);
|
||||
std::unordered_map<int, std::shared_ptr<DataAbilityManager>> GetDataAbilityManagers();
|
||||
std::shared_ptr<DataAbilityManager> GetDataAbilityManagerByUserId(int32_t userId);
|
||||
std::shared_ptr<DataAbilityManager> GetDataAbilityManagerByToken(const sptr<IRemoteObject> &token);
|
||||
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
|
||||
void FilterUriWithPermissionDms(Want &want, uint32_t tokenId);
|
||||
|
||||
bool CheckNonImplicitShareFileUri(const AbilityRequest &abilityRequest);
|
||||
int32_t CheckNonImplicitShareFileUri(const Want &want, int32_t userId, uint32_t specifyTokenId);
|
||||
|
||||
std::vector<Uri> GetPermissionedUriList(const std::vector<std::string> &uriVec,
|
||||
const std::vector<bool> &checkResults, Want &want);
|
||||
|
29
services/abilitymgr/include/utils/multi_app_utils.h
Normal file
29
services/abilitymgr/include/utils/multi_app_utils.h
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ABILITY_RUNTIME_MULTI_APP_UTILS_H
|
||||
#define OHOS_ABILITY_RUNTIME_MULTI_APP_UTILS_H
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
class MultiAppUtils {
|
||||
public:
|
||||
static void GetRunningMultiAppIndex(const std::string &bundleName, int32_t uid, int32_t &appIndex);
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_MULTI_APP_UTILS_H
|
46
services/abilitymgr/include/utils/update_caller_info_util.h
Normal file
46
services/abilitymgr/include/utils/update_caller_info_util.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ABILITY_RUNTIME_UPDATE_CALLER_INFO_UTIL_H
|
||||
#define OHOS_ABILITY_RUNTIME_UPDATE_CALLER_INFO_UTIL_H
|
||||
|
||||
#include <string>
|
||||
#include "want.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
class UpdateCallerInfoUtil {
|
||||
public:
|
||||
static UpdateCallerInfoUtil &GetInstance();
|
||||
~UpdateCallerInfoUtil() = default;
|
||||
|
||||
void UpdateAsCallerSourceInfo(Want& want, sptr<IRemoteObject> asCallerSourceToken, sptr<IRemoteObject> callerToken);
|
||||
void UpdateCallerInfo(Want& want, const sptr<IRemoteObject> &callerToken);
|
||||
void UpdateBackToCallerFlag(const sptr<IRemoteObject> &callerToken, Want &want, int32_t requestCode, bool backFlag);
|
||||
void UpdateCallerInfoFromToken(Want& want, const sptr<IRemoteObject> &token);
|
||||
void UpdateDmsCallerInfo(Want& want, const sptr<IRemoteObject> &callerToken);
|
||||
|
||||
private:
|
||||
UpdateCallerInfoUtil() = default;
|
||||
void UpdateSignatureInfo(std::string bundleName, Want& want, bool isRemote = false);
|
||||
void UpdateAsCallerInfoFromToken(Want& want, sptr<IRemoteObject> asCallerSourceToken);
|
||||
void UpdateAsCallerInfoFromCallerRecord(Want& want, sptr<IRemoteObject> callerToken);
|
||||
bool UpdateAsCallerInfoFromDialog(Want& want);
|
||||
|
||||
DISALLOW_COPY_AND_MOVE(UpdateCallerInfoUtil);
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_DIALOG_SESSION_MANAGEER_H
|
@ -17,8 +17,10 @@
|
||||
#define OHOS_ABILITY_RUNTIME_WINDOW_OPTIONS_UTILS_H
|
||||
|
||||
#include "ability_info.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "iremote_object.h"
|
||||
#include "start_options.h"
|
||||
#include "string_wrapper.h"
|
||||
#include "want.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -28,6 +30,9 @@ public:
|
||||
static void SetWindowPositionAndSize(Want& want,
|
||||
const sptr<IRemoteObject>& callerToken, const StartOptions& startOptions);
|
||||
static std::pair<bool, AppExecFwk::SupportWindowMode> WindowModeMap(int32_t windowMode);
|
||||
static void UpdateWantToSetDisplayID(Want &want, const sptr<IRemoteObject> &callerToken);
|
||||
static void UpdateStartOptionsToSetDisplayID(StartOptions &startOptions,
|
||||
const sptr<IRemoteObject> &callerToken);
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
@ -55,7 +55,6 @@ void AbilityCacheManager::RemoveAbilityRecInDevList(std::shared_ptr<AbilityRecor
|
||||
|
||||
void AbilityCacheManager::RemoveAbilityRecInProcList(std::shared_ptr<AbilityRecord> abilityRecord)
|
||||
{
|
||||
const Want want = abilityRecord->GetWant();
|
||||
uint32_t accessTokenId = abilityRecord->GetApplicationInfo().accessTokenId;
|
||||
auto findProcInfo = procLruMap_.find(accessTokenId);
|
||||
if (findProcInfo == procLruMap_.end()) {
|
||||
|
@ -139,13 +139,14 @@ int AbilityConnectionStub::OnRemoteRequest(
|
||||
auto resultCode = data.ReadInt32();
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "AbilityConnectionStub ON_ABILITY_CONNECT_DONE");
|
||||
OnAbilityConnectDone(*element, remoteObject, resultCode);
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "AbilityConnectionStub ON_ABILITY_CONNECT_DONE end");
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "AbilityConnectionStub ON_ABILITY_CONNECT_DONE end");
|
||||
return NO_ERROR;
|
||||
}
|
||||
case IAbilityConnection::ON_ABILITY_DISCONNECT_DONE: {
|
||||
auto resultCode = data.ReadInt32();
|
||||
OnAbilityDisconnectDone(*element, resultCode);
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "AbilityConnectionStub ON_ABILITY_DISCONNECT_DONE");
|
||||
OnAbilityDisconnectDone(*element, resultCode);
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "AbilityConnectionStub ON_ABILITY_DISCONNECT_DONE end");
|
||||
return NO_ERROR;
|
||||
}
|
||||
case IAbilityConnection::ON_REMOTE_STATE_CHANGED: {
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "appfreeze_manager.h"
|
||||
#include "app_exit_reason_data_manager.h"
|
||||
#include "assert_fault_callback_death_mgr.h"
|
||||
#include "global_constant.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "int_wrapper.h"
|
||||
#include "multi_instance_utils.h"
|
||||
@ -120,7 +121,8 @@ int AbilityConnectManager::TerminateAbilityInner(const sptr<IRemoteObject> &toke
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "exist connection, don't terminate");
|
||||
return ERR_OK;
|
||||
} else if (abilityRecord->IsAbilityState(AbilityState::FOREGROUND) ||
|
||||
abilityRecord->IsAbilityState(AbilityState::FOREGROUNDING)) {
|
||||
abilityRecord->IsAbilityState(AbilityState::FOREGROUNDING) ||
|
||||
abilityRecord->IsAbilityState(AbilityState::BACKGROUNDING)) {
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "current ability is active");
|
||||
DoBackgroundAbilityWindow(abilityRecord, abilityRecord->GetSessionInfo());
|
||||
MoveToTerminatingMap(abilityRecord);
|
||||
@ -145,7 +147,8 @@ int AbilityConnectManager::StartAbilityLocked(const AbilityRequest &abilityReque
|
||||
|
||||
int32_t ret = AbilityPermissionUtil::GetInstance().CheckMultiInstanceKeyForExtension(abilityRequest);
|
||||
if (ret != ERR_OK) {
|
||||
return ret;
|
||||
// Do not distinguishing specific error codes
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
std::shared_ptr<AbilityRecord> targetService;
|
||||
@ -495,7 +498,8 @@ int AbilityConnectManager::PreloadUIExtensionAbilityInner(const AbilityRequest &
|
||||
}
|
||||
int32_t ret = AbilityPermissionUtil::GetInstance().CheckMultiInstanceKeyForExtension(abilityRequest);
|
||||
if (ret != ERR_OK) {
|
||||
return ret;
|
||||
// Do not distinguishing specific error codes
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
std::shared_ptr<ExtensionRecord> extensionRecord = nullptr;
|
||||
CHECK_POINTER_AND_RETURN(uiExtensionAbilityRecordMgr_, ERR_NULL_OBJECT);
|
||||
@ -552,7 +556,8 @@ int AbilityConnectManager::ConnectAbilityLocked(const AbilityRequest &abilityReq
|
||||
// 1. get target service ability record, and check whether it has been loaded.
|
||||
int32_t ret = AbilityPermissionUtil::GetInstance().CheckMultiInstanceKeyForExtension(abilityRequest);
|
||||
if (ret != ERR_OK) {
|
||||
return ret;
|
||||
// Do not distinguishing specific error codes
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
std::shared_ptr<AbilityRecord> targetService;
|
||||
bool isLoadedAbility = false;
|
||||
@ -566,7 +571,7 @@ int AbilityConnectManager::ConnectAbilityLocked(const AbilityRequest &abilityReq
|
||||
bool isCallbackConnected = !connectRecordList.empty();
|
||||
// 3. If this service ability and callback has been connected, There is no need to connect repeatedly
|
||||
if (isLoadedAbility && (isCallbackConnected) && IsAbilityConnected(targetService, connectRecordList)) {
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "Service/callback connected");
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "Service/callback connected");
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
@ -603,7 +608,7 @@ int AbilityConnectManager::ConnectAbilityLocked(const AbilityRequest &abilityReq
|
||||
targetService->SetWant(abilityRequest.want);
|
||||
HandleActiveAbility(targetService, connectRecord);
|
||||
} else {
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "TargetService active");
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "TargetService activing");
|
||||
targetService->SaveConnectWant(abilityRequest.want);
|
||||
}
|
||||
return ret;
|
||||
@ -1818,7 +1823,7 @@ void AbilityConnectManager::DoBackgroundAbilityWindow(const std::shared_ptr<Abil
|
||||
abilityRecord->IsAbilityState(AbilityState::FOREGROUNDING)) {
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "exist initial or foregrounding task");
|
||||
abilityRecord->DoBackgroundAbilityWindowDelayed(true);
|
||||
} else {
|
||||
} else if (!abilityRecord->IsAbilityState(AbilityState::BACKGROUNDING)) {
|
||||
TAG_LOGW(AAFwkTag::ABILITYMGR, "invalid ability state");
|
||||
}
|
||||
}
|
||||
@ -2349,7 +2354,10 @@ void AbilityConnectManager::RestartAbility(const std::shared_ptr<AbilityRecord>
|
||||
TAG_LOGW(AAFwkTag::ABILITYMGR, "delay restart root launcher until switch user");
|
||||
return;
|
||||
}
|
||||
requestInfo.want.SetParam("ohos.app.recovery", true);
|
||||
if (abilityRecord->IsSceneBoard()) {
|
||||
requestInfo.want.SetParam("ohos.app.recovery", true);
|
||||
DelayedSingleton<AbilityManagerService>::GetInstance()->EnableListForSCBRecovery(userId_);
|
||||
}
|
||||
requestInfo.restartCount = abilityRecord->GetRestartCount();
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "restart root launcher, number:%{public}d", requestInfo.restartCount);
|
||||
StartAbilityLocked(requestInfo);
|
||||
|
@ -422,6 +422,7 @@ ErrCode AbilityManagerClient::MoveAbilityToBackground(sptr<IRemoteObject> token)
|
||||
|
||||
ErrCode AbilityManagerClient::MoveUIAbilityToBackground(const sptr<IRemoteObject> token)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "MoveUIAbilityToBackground call");
|
||||
auto abms = GetAbilityManager();
|
||||
CHECK_POINTER_RETURN_NOT_CONNECTED(abms);
|
||||
return abms->MoveUIAbilityToBackground(token);
|
||||
|
@ -337,37 +337,6 @@ int32_t AbilityManagerCollaboratorProxy::NotifyRemoveShellProcess(int32_t pid, i
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
void AbilityManagerCollaboratorProxy::UpdateMissionInfo(InnerMissionInfoDto &info)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!data.WriteInterfaceToken(AbilityManagerCollaboratorProxy::GetDescriptor())) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "write token fail");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&info)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "write info fail");
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t ret = SendTransactCmd(IAbilityManagerCollaborator::UPDATE_MISSION_INFO, data, reply, option);
|
||||
if (ret != NO_ERROR) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
std::unique_ptr<InnerMissionInfoDto> innerInfo(reply.ReadParcelable<InnerMissionInfoDto>());
|
||||
if (!innerInfo) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "get error");
|
||||
return;
|
||||
}
|
||||
info = *innerInfo;
|
||||
return;
|
||||
}
|
||||
|
||||
void AbilityManagerCollaboratorProxy::UpdateMissionInfo(sptr<SessionInfo> &sessionInfo)
|
||||
{
|
||||
MessageParcel data;
|
||||
|
@ -2004,7 +2004,7 @@ int32_t AbilityManagerProxy::UpgradeApp(const std::string &bundleName, const int
|
||||
}
|
||||
|
||||
sptr<IWantSender> AbilityManagerProxy::GetWantSender(
|
||||
const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken)
|
||||
const WantSenderInfo &wantSenderInfo, const sptr<IRemoteObject> &callerToken, int32_t uid)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
@ -2027,6 +2027,12 @@ sptr<IWantSender> AbilityManagerProxy::GetWantSender(
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(uid)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "uid write fail");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto error = SendRequest(AbilityManagerInterfaceCode::GET_PENDING_WANT_SENDER, data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "request error:%{public}d", error);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1751,7 +1751,9 @@ int AbilityManagerStub::GetWantSenderInner(MessageParcel &data, MessageParcel &r
|
||||
if (data.ReadBool()) {
|
||||
callerToken = data.ReadRemoteObject();
|
||||
}
|
||||
sptr<IWantSender> wantSender = GetWantSender(*wantSenderInfo, callerToken);
|
||||
|
||||
int32_t uid = data.ReadInt32();
|
||||
sptr<IWantSender> wantSender = GetWantSender(*wantSenderInfo, callerToken, uid);
|
||||
if (!reply.WriteRemoteObject(((wantSender == nullptr) ? nullptr : wantSender->AsObject()))) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "failed reply wantSender to client, for write parcel error");
|
||||
return ERR_INVALID_VALUE;
|
||||
|
@ -84,9 +84,15 @@ const std::string UIEXTENSION_ABILITY_ID = "ability.want.params.uiExtensionAbili
|
||||
const std::string UIEXTENSION_ROOT_HOST_PID = "ability.want.params.uiExtensionRootHostPid";
|
||||
constexpr const char* PARAM_SEND_RESULT_CALLER_BUNDLENAME = "ohos.anco.param.sendResultCallderBundleName";
|
||||
constexpr const char* PARAM_SEND_RESULT_CALLER_TOKENID = "ohos.anco.param.sendResultCallerTokenId";
|
||||
constexpr const char* DLP_PARAMS_SECURITY_FLAG = "ohos.dlp.params.securityFlag";
|
||||
// Developer mode param
|
||||
constexpr const char* DEVELOPER_MODE_STATE = "const.security.developermode.state";
|
||||
constexpr const char* APP_PROVISION_TYPE_DEBUG = "debug";
|
||||
constexpr const char* DMS_CALLER_BUNDLE_NAME = "ohos.dms.param.sourceCallerBundleName";
|
||||
constexpr const char* DMS_CALLER_ABILITY_NAME = "ohos.dms.param.sourceCallerAbilityName";
|
||||
constexpr const char* DMS_CALLER_NATIVE_NAME = "ohos.dms.param.sourceCallerNativeName";
|
||||
constexpr const char* DMS_CALLER_APP_ID = "ohos.dms.param.sourceCallerAppId";
|
||||
constexpr const char* DMS_CALLER_APP_IDENTIFIER = "ohos.dms.param.sourceCallerAppIdentifier";
|
||||
const int32_t SHELL_ASSISTANT_DIETYPE = 0;
|
||||
int64_t AbilityRecord::abilityRecordId = 0;
|
||||
const int32_t DEFAULT_USER_ID = 0;
|
||||
@ -97,6 +103,7 @@ const int TERMINATE_TIMEOUT_ASANENABLED = 150;
|
||||
const int HALF_TIMEOUT = 2;
|
||||
const int MAX_URI_COUNT = 500;
|
||||
const int RESTART_SCENEBOARD_DELAY = 500;
|
||||
constexpr int32_t DMS_UID = 5522;
|
||||
|
||||
auto g_addLifecycleEventTask = [](sptr<Token> token, FreezeUtil::TimeoutState state, std::string &methodName) {
|
||||
CHECK_POINTER_LOG(token, "token is nullptr");
|
||||
@ -217,6 +224,7 @@ std::shared_ptr<AbilityRecord> AbilityRecord::CreateAbilityRecord(const AbilityR
|
||||
int32_t appIndex = 0;
|
||||
(void)AbilityRuntime::StartupUtil::GetAppIndex(abilityRequest.want, appIndex);
|
||||
abilityRecord->SetAppIndex(appIndex);
|
||||
abilityRecord->SetSecurityFlag(abilityRequest.want.GetBoolParam(DLP_PARAMS_SECURITY_FLAG, false));
|
||||
abilityRecord->SetCallerAccessTokenId(abilityRequest.callerAccessTokenId);
|
||||
abilityRecord->sessionInfo_ = abilityRequest.sessionInfo;
|
||||
if (abilityRequest.sessionInfo != nullptr) {
|
||||
@ -283,16 +291,14 @@ void AbilityRecord::LoadUIAbility()
|
||||
int loadTimeout = AmsConfigurationParameter::GetInstance().GetAppStartTimeoutTime() * LOAD_TIMEOUT_MULTIPLE;
|
||||
if (abilityInfo_.applicationInfo.asanEnabled || abilityInfo_.applicationInfo.tsanEnabled) {
|
||||
loadTimeout = AmsConfigurationParameter::GetInstance().GetAppStartTimeoutTime() * LOAD_TIMEOUT_ASANENABLED;
|
||||
SendEvent(AbilityManagerService::LOAD_HALF_TIMEOUT_MSG, loadTimeout / HALF_TIMEOUT);
|
||||
SendEvent(AbilityManagerService::LOAD_TIMEOUT_MSG, loadTimeout);
|
||||
} else {
|
||||
int coldStartTimeout =
|
||||
AmsConfigurationParameter::GetInstance().GetAppStartTimeoutTime() * COLDSTART_TIMEOUT_MULTIPLE;
|
||||
std::lock_guard guard(wantLock_);
|
||||
auto delayTime = want_.GetBoolParam("coldStart", false) ? coldStartTimeout : loadTimeout;
|
||||
SendEvent(AbilityManagerService::LOAD_HALF_TIMEOUT_MSG, delayTime / HALF_TIMEOUT);
|
||||
SendEvent(AbilityManagerService::LOAD_TIMEOUT_MSG, delayTime);
|
||||
loadTimeout = want_.GetBoolParam("coldStart", false) ? coldStartTimeout : loadTimeout;
|
||||
}
|
||||
SendEvent(AbilityManagerService::LOAD_HALF_TIMEOUT_MSG, loadTimeout / HALF_TIMEOUT);
|
||||
SendEvent(AbilityManagerService::LOAD_TIMEOUT_MSG, loadTimeout);
|
||||
std::string methodName = "LoadAbility";
|
||||
g_addLifecycleEventTask(token_, FreezeUtil::TimeoutState::LOAD, methodName);
|
||||
}
|
||||
@ -390,7 +396,9 @@ void AbilityRecord::ForegroundAbility(uint32_t sceneFlag)
|
||||
SetAbilityStateInner(AbilityState::FOREGROUNDING);
|
||||
#endif // SUPPORT_SCREEN
|
||||
lifeCycleStateInfo_.sceneFlag = sceneFlag;
|
||||
lifecycleDeal_->ForegroundNew(GetWant(), lifeCycleStateInfo_, GetSessionInfo());
|
||||
Want want = GetWant();
|
||||
UpdateDmsCallerInfo(want);
|
||||
lifecycleDeal_->ForegroundNew(want, lifeCycleStateInfo_, GetSessionInfo());
|
||||
lifeCycleStateInfo_.sceneFlag = 0;
|
||||
lifeCycleStateInfo_.sceneFlagBak = 0;
|
||||
{
|
||||
@ -1602,7 +1610,9 @@ void AbilityRecord::Inactivate()
|
||||
#ifdef SUPPORT_SCREEN
|
||||
SetAbilityStateInner(AbilityState::INACTIVATING);
|
||||
#endif // SUPPORT_SCREEN
|
||||
lifecycleDeal_->Inactivate(GetWant(), lifeCycleStateInfo_, GetSessionInfo());
|
||||
Want want = GetWant();
|
||||
UpdateDmsCallerInfo(want);
|
||||
lifecycleDeal_->Inactivate(want, lifeCycleStateInfo_, GetSessionInfo());
|
||||
}
|
||||
|
||||
void AbilityRecord::Terminate(const Closure &task)
|
||||
@ -1653,7 +1663,9 @@ void AbilityRecord::ShareData(const int32_t &uniqueId)
|
||||
void AbilityRecord::ConnectAbility()
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "%{public}s called.", __func__);
|
||||
ConnectAbilityWithWant(GetWant());
|
||||
Want want = GetWant();
|
||||
UpdateDmsCallerInfo(want);
|
||||
ConnectAbilityWithWant(want);
|
||||
}
|
||||
|
||||
void AbilityRecord::ConnectAbilityWithWant(const Want &want)
|
||||
@ -1713,8 +1725,10 @@ bool AbilityRecord::GrantUriPermissionForServiceExtension()
|
||||
void AbilityRecord::CommandAbility()
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "startId_:%{public}d.", startId_);
|
||||
Want want = GetWant();
|
||||
UpdateDmsCallerInfo(want);
|
||||
CHECK_POINTER(lifecycleDeal_);
|
||||
lifecycleDeal_->CommandAbility(GetWant(), false, startId_);
|
||||
lifecycleDeal_->CommandAbility(want, false, startId_);
|
||||
}
|
||||
|
||||
void AbilityRecord::CommandAbilityWindow(const sptr<SessionInfo> &sessionInfo, WindowCommand winCmd)
|
||||
@ -3698,5 +3712,26 @@ void AbilityRecord::RemoveConnectWant()
|
||||
std::lock_guard guard(connectWantLock_);
|
||||
connectWant_.reset();
|
||||
}
|
||||
|
||||
void AbilityRecord::UpdateDmsCallerInfo(Want &want)
|
||||
{
|
||||
if (want.GetIntParam(Want::PARAM_RESV_CALLER_UID, 0) != DMS_UID) {
|
||||
return;
|
||||
}
|
||||
want.SetParam(Want::PARAM_RESV_CALLER_TOKEN, -1);
|
||||
want.SetParam(Want::PARAM_RESV_CALLER_UID, -1);
|
||||
want.SetParam(Want::PARAM_RESV_CALLER_PID, -1);
|
||||
|
||||
want.SetParam(Want::PARAM_RESV_CALLER_BUNDLE_NAME, want.GetStringParam(DMS_CALLER_BUNDLE_NAME));
|
||||
want.RemoveParam(DMS_CALLER_BUNDLE_NAME);
|
||||
want.SetParam(Want::PARAM_RESV_CALLER_ABILITY_NAME, want.GetStringParam(DMS_CALLER_ABILITY_NAME));
|
||||
want.RemoveParam(DMS_CALLER_ABILITY_NAME);
|
||||
want.SetParam(Want::PARAM_RESV_CALLER_NATIVE_NAME, want.GetStringParam(DMS_CALLER_NATIVE_NAME));
|
||||
want.RemoveParam(DMS_CALLER_NATIVE_NAME);
|
||||
want.SetParam(Want::PARAM_RESV_CALLER_APP_ID, want.GetStringParam(DMS_CALLER_APP_ID));
|
||||
want.RemoveParam(DMS_CALLER_APP_ID);
|
||||
want.SetParam(Want::PARAM_RESV_CALLER_APP_IDENTIFIER, want.GetStringParam(DMS_CALLER_APP_IDENTIFIER));
|
||||
want.RemoveParam(DMS_CALLER_APP_IDENTIFIER);
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user