mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 22:21:36 -04:00
Merge branch 'master' of gitee.com:openharmony/ability_ability_runtime into second_commit
Signed-off-by: xinking129 <xinxin13@huawei.com>
This commit is contained in:
@@ -18,8 +18,8 @@
|
||||
|
||||
static napi_module _module = {
|
||||
.nm_version = 0,
|
||||
.nm_modname = "app.ability.autoFillManager",
|
||||
.nm_register_func = OHOS::AbilityRuntime::JsAutoFillManagerInit,
|
||||
.nm_modname = "app.ability.autoFillManager",
|
||||
};
|
||||
|
||||
extern "C" __attribute__((constructor)) void NAPI_app_ability_autofillmanager_AutoRegister(void)
|
||||
|
||||
@@ -19,14 +19,15 @@
|
||||
#include <cstdint>
|
||||
|
||||
#include "ability_manager_client.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "event_handler.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "ability_runtime/js_caller_complex.h"
|
||||
#include "js_context_utils.h"
|
||||
#include "js_data_struct_converter.h"
|
||||
#include "js_error_utils.h"
|
||||
#include "js_runtime_utils.h"
|
||||
#include "ability_runtime/js_caller_complex.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "mission_info.h"
|
||||
#include "napi_common_ability.h"
|
||||
#include "napi_common_start_options.h"
|
||||
@@ -34,10 +35,8 @@
|
||||
#include "napi_common_want.h"
|
||||
#include "napi_remote_object.h"
|
||||
#include "start_options.h"
|
||||
#include "want.h"
|
||||
#include "event_handler.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "tokenid_kit.h"
|
||||
#include "want.h"
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#include "pixel_map_napi.h"
|
||||
@@ -227,14 +226,14 @@ napi_value JsAbilityContext::OnStartAbility(napi_env env, NapiCallbackInfo& info
|
||||
}
|
||||
|
||||
AAFwk::Want want;
|
||||
OHOS::AppExecFwk::UnwrapWant(env, info.argv[0], want);
|
||||
OHOS::AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want);
|
||||
InheritWindowMode(want);
|
||||
decltype(info.argc) unwrapArgc = 1;
|
||||
decltype(info.argc) unwrapArgc = ARGC_ONE;
|
||||
HILOG_INFO("StartAbility, ability:%{public}s.", want.GetElement().GetAbilityName().c_str());
|
||||
AAFwk::StartOptions startOptions;
|
||||
if (info.argc > ARGC_ONE && CheckTypeForNapiValue(env, info.argv[1], napi_object)) {
|
||||
if (info.argc > ARGC_ONE && CheckTypeForNapiValue(env, info.argv[INDEX_ONE], napi_object)) {
|
||||
HILOG_DEBUG("OnStartAbility start options is used.");
|
||||
AppExecFwk::UnwrapStartOptions(env, info.argv[1], startOptions);
|
||||
AppExecFwk::UnwrapStartOptions(env, info.argv[INDEX_ONE], startOptions);
|
||||
unwrapArgc++;
|
||||
}
|
||||
|
||||
@@ -259,7 +258,7 @@ napi_value JsAbilityContext::OnStartAbility(napi_env env, NapiCallbackInfo& info
|
||||
return;
|
||||
}
|
||||
|
||||
*innerErrorCode = (unwrapArgc == 1) ?
|
||||
*innerErrorCode = (unwrapArgc == ARGC_ONE) ?
|
||||
context->StartAbility(want, -1) : context->StartAbility(want, startOptions, -1);
|
||||
if ((want.GetFlags() & Want::FLAG_INSTALL_ON_DEMAND) == Want::FLAG_INSTALL_ON_DEMAND &&
|
||||
*innerErrorCode != 0 && observer != nullptr) {
|
||||
@@ -303,14 +302,14 @@ napi_value JsAbilityContext::OnStartAbilityAsCaller(napi_env env, NapiCallbackIn
|
||||
}
|
||||
|
||||
AAFwk::Want want;
|
||||
OHOS::AppExecFwk::UnwrapWant(env, info.argv[0], want);
|
||||
OHOS::AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want);
|
||||
InheritWindowMode(want);
|
||||
decltype(info.argc) unwrapArgc = 1;
|
||||
decltype(info.argc) unwrapArgc = ARGC_ONE;
|
||||
HILOG_INFO("StartAbilityAsCaller, ability:%{public}s.", want.GetElement().GetAbilityName().c_str());
|
||||
AAFwk::StartOptions startOptions;
|
||||
if (info.argc > ARGC_ONE && CheckTypeForNapiValue(env, info.argv[1], napi_object)) {
|
||||
if (info.argc > ARGC_ONE && CheckTypeForNapiValue(env, info.argv[INDEX_ONE], napi_object)) {
|
||||
HILOG_DEBUG("OnStartAbilityAsCaller start options is used.");
|
||||
AppExecFwk::UnwrapStartOptions(env, info.argv[1], startOptions);
|
||||
AppExecFwk::UnwrapStartOptions(env, info.argv[INDEX_ONE], startOptions);
|
||||
unwrapArgc++;
|
||||
}
|
||||
NapiAsyncTask::CompleteCallback complete =
|
||||
@@ -321,7 +320,7 @@ napi_value JsAbilityContext::OnStartAbilityAsCaller(napi_env env, NapiCallbackIn
|
||||
task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INVALID_CONTEXT));
|
||||
return;
|
||||
}
|
||||
auto innerErrorCode = (unwrapArgc == 1) ?
|
||||
auto innerErrorCode = (unwrapArgc == ARGC_ONE) ?
|
||||
context->StartAbilityAsCaller(want, -1) : context->StartAbilityAsCaller(want, startOptions, -1);
|
||||
if (innerErrorCode == 0) {
|
||||
task.Resolve(env, CreateJsUndefined(env));
|
||||
@@ -349,12 +348,12 @@ napi_value JsAbilityContext::OnStartAbilityWithAccount(napi_env env, NapiCallbac
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
AAFwk::Want want;
|
||||
OHOS::AppExecFwk::UnwrapWant(env, info.argv[0], want);
|
||||
OHOS::AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want);
|
||||
InheritWindowMode(want);
|
||||
decltype(info.argc) unwrapArgc = 1;
|
||||
decltype(info.argc) unwrapArgc = ARGC_ONE;
|
||||
HILOG_INFO("StartAbilityWithAccount, ability:%{public}s", want.GetElement().GetAbilityName().c_str());
|
||||
int32_t accountId = 0;
|
||||
if (!OHOS::AppExecFwk::UnwrapInt32FromJS2(env, info.argv[1], accountId)) {
|
||||
if (!OHOS::AppExecFwk::UnwrapInt32FromJS2(env, info.argv[INDEX_ONE], accountId)) {
|
||||
HILOG_DEBUG("the second parameter is invalid.");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return CreateJsUndefined(env);
|
||||
@@ -363,7 +362,7 @@ napi_value JsAbilityContext::OnStartAbilityWithAccount(napi_env env, NapiCallbac
|
||||
AAFwk::StartOptions startOptions;
|
||||
if (info.argc > ARGC_TWO && CheckTypeForNapiValue(env, info.argv[INDEX_TWO], napi_object)) {
|
||||
HILOG_DEBUG("OnStartAbilityWithAccount start options is used.");
|
||||
AppExecFwk::UnwrapStartOptions(env, info.argv[ARGC_TWO], startOptions);
|
||||
AppExecFwk::UnwrapStartOptions(env, info.argv[INDEX_TWO], startOptions);
|
||||
unwrapArgc++;
|
||||
}
|
||||
|
||||
@@ -426,7 +425,8 @@ napi_value JsAbilityContext::OnStartAbilityByCall(napi_env env, NapiCallbackInfo
|
||||
}
|
||||
|
||||
AAFwk::Want want;
|
||||
if (!CheckTypeForNapiValue(env, info.argv[0], napi_object) || !AppExecFwk::UnwrapWant(env, info.argv[0], want)) {
|
||||
if (!CheckTypeForNapiValue(env, info.argv[INDEX_ZERO], napi_object) ||
|
||||
!AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want)) {
|
||||
HILOG_ERROR("Failed to parse want!");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return CreateJsUndefined(env);
|
||||
@@ -438,14 +438,14 @@ napi_value JsAbilityContext::OnStartAbilityByCall(napi_env env, NapiCallbackInfo
|
||||
napi_value retsult = nullptr;
|
||||
int32_t userId = DEFAULT_INVAL_VALUE;
|
||||
if (info.argc > ARGC_ONE) {
|
||||
if (CheckTypeForNapiValue(env, info.argv[ARGC_ONE], napi_number)) {
|
||||
if (!ConvertFromJsValue(env, info.argv[ARGC_ONE], userId)) {
|
||||
if (CheckTypeForNapiValue(env, info.argv[INDEX_ONE], napi_number)) {
|
||||
if (!ConvertFromJsValue(env, info.argv[INDEX_ONE], userId)) {
|
||||
HILOG_ERROR("Failed to parse accountId!");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
} else if (CheckTypeForNapiValue(env, info.argv[ARGC_ONE], napi_function)) {
|
||||
lastParam = info.argv[ARGC_ONE];
|
||||
} else if (CheckTypeForNapiValue(env, info.argv[INDEX_ONE], napi_function)) {
|
||||
lastParam = info.argv[INDEX_ONE];
|
||||
} else {
|
||||
HILOG_ERROR("Failed, input param type invalid");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
@@ -453,8 +453,8 @@ napi_value JsAbilityContext::OnStartAbilityByCall(napi_env env, NapiCallbackInfo
|
||||
}
|
||||
}
|
||||
|
||||
if (info.argc > ARGC_TWO && CheckTypeForNapiValue(env, info.argv[ARGC_TWO], napi_function)) {
|
||||
lastParam = info.argv[ARGC_TWO];
|
||||
if (info.argc > ARGC_TWO && CheckTypeForNapiValue(env, info.argv[INDEX_TWO], napi_function)) {
|
||||
lastParam = info.argv[INDEX_TWO];
|
||||
}
|
||||
|
||||
auto callBackDone = [calldata = calls] (const sptr<IRemoteObject> &obj) {
|
||||
@@ -560,17 +560,17 @@ napi_value JsAbilityContext::OnStartAbilityForResult(napi_env env, NapiCallbackI
|
||||
}
|
||||
|
||||
AAFwk::Want want;
|
||||
if (!AppExecFwk::UnwrapWant(env, info.argv[0], want)) {
|
||||
if (!AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want)) {
|
||||
HILOG_ERROR("Failed to parse want!");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
InheritWindowMode(want);
|
||||
decltype(info.argc) unwrapArgc = 1;
|
||||
decltype(info.argc) unwrapArgc = ARGC_ONE;
|
||||
AAFwk::StartOptions startOptions;
|
||||
if (info.argc > ARGC_ONE && CheckTypeForNapiValue(env, info.argv[1], napi_object)) {
|
||||
if (info.argc > ARGC_ONE && CheckTypeForNapiValue(env, info.argv[INDEX_ONE], napi_object)) {
|
||||
HILOG_DEBUG("OnStartAbilityForResult begin options is used.");
|
||||
AppExecFwk::UnwrapStartOptions(env, info.argv[1], startOptions);
|
||||
AppExecFwk::UnwrapStartOptions(env, info.argv[INDEX_ONE], startOptions);
|
||||
unwrapArgc++;
|
||||
}
|
||||
|
||||
@@ -615,7 +615,7 @@ napi_value JsAbilityContext::OnStartAbilityForResult(napi_env env, NapiCallbackI
|
||||
} else {
|
||||
want.SetParam(Want::PARAM_RESV_FOR_RESULT, true);
|
||||
curRequestCode_ = (curRequestCode_ == INT_MAX) ? 0 : (curRequestCode_ + 1);
|
||||
(unwrapArgc == 1) ? context->StartAbilityForResult(want, curRequestCode_, std::move(task)) :
|
||||
(unwrapArgc == ARGC_ONE) ? context->StartAbilityForResult(want, curRequestCode_, std::move(task)) :
|
||||
context->StartAbilityForResult(want, startOptions, curRequestCode_, std::move(task));
|
||||
}
|
||||
HILOG_DEBUG("OnStartAbilityForResult is called end");
|
||||
@@ -637,15 +637,15 @@ napi_value JsAbilityContext::OnStartAbilityForResultWithAccount(napi_env env, Na
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
AAFwk::Want want;
|
||||
if (!AppExecFwk::UnwrapWant(env, info.argv[0], want)) {
|
||||
if (!AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want)) {
|
||||
HILOG_ERROR("Failed to parse want!");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
InheritWindowMode(want);
|
||||
decltype(info.argc) unwrapArgc = 1;
|
||||
decltype(info.argc) unwrapArgc = ARGC_ONE;
|
||||
int32_t accountId = 0;
|
||||
if (!OHOS::AppExecFwk::UnwrapInt32FromJS2(env, info.argv[1], accountId)) {
|
||||
if (!OHOS::AppExecFwk::UnwrapInt32FromJS2(env, info.argv[INDEX_ONE], accountId)) {
|
||||
HILOG_ERROR("the second parameter is invalid.");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return CreateJsUndefined(env);
|
||||
@@ -715,7 +715,7 @@ napi_value JsAbilityContext::OnStartExtensionAbility(napi_env env, NapiCallbackI
|
||||
}
|
||||
|
||||
AAFwk::Want want;
|
||||
if (!AppExecFwk::UnwrapWant(env, info.argv[0], want)) {
|
||||
if (!AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want)) {
|
||||
HILOG_ERROR("Failed to parse want!");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return CreateJsUndefined(env);
|
||||
@@ -737,7 +737,7 @@ napi_value JsAbilityContext::OnStartExtensionAbility(napi_env env, NapiCallbackI
|
||||
}
|
||||
};
|
||||
|
||||
napi_value lastParam = (info.argc > ARGC_ONE) ? info.argv[ARGC_ONE] : nullptr;
|
||||
napi_value lastParam = (info.argc > ARGC_ONE) ? info.argv[INDEX_ONE] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::ScheduleHighQos("JsAbilityContext::OnStartExtensionAbility",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
@@ -755,8 +755,8 @@ napi_value JsAbilityContext::OnStartExtensionAbilityWithAccount(napi_env env, Na
|
||||
|
||||
AAFwk::Want want;
|
||||
int32_t accountId = -1;
|
||||
if (!AppExecFwk::UnwrapWant(env, info.argv[0], want) ||
|
||||
!OHOS::AppExecFwk::UnwrapInt32FromJS2(env, info.argv[1], accountId)) {
|
||||
if (!AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want) ||
|
||||
!OHOS::AppExecFwk::UnwrapInt32FromJS2(env, info.argv[INDEX_ONE], accountId)) {
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
@@ -777,7 +777,7 @@ napi_value JsAbilityContext::OnStartExtensionAbilityWithAccount(napi_env env, Na
|
||||
}
|
||||
};
|
||||
|
||||
napi_value lastParam = (info.argc > ARGC_TWO) ? info.argv[ARGC_TWO] : nullptr;
|
||||
napi_value lastParam = (info.argc > ARGC_TWO) ? info.argv[INDEX_TWO] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::ScheduleHighQos("JsAbilityContext::OnStartExtensionAbilityWithAccount",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
@@ -794,7 +794,7 @@ napi_value JsAbilityContext::OnStopExtensionAbility(napi_env env, NapiCallbackIn
|
||||
}
|
||||
|
||||
AAFwk::Want want;
|
||||
if (!AppExecFwk::UnwrapWant(env, info.argv[0], want)) {
|
||||
if (!AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want)) {
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
@@ -815,7 +815,7 @@ napi_value JsAbilityContext::OnStopExtensionAbility(napi_env env, NapiCallbackIn
|
||||
}
|
||||
};
|
||||
|
||||
napi_value lastParam = (info.argc > ARGC_ONE) ? info.argv[ARGC_ONE] : nullptr;
|
||||
napi_value lastParam = (info.argc > ARGC_ONE) ? info.argv[INDEX_ONE] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::Schedule("JsAbilityContext::OnStopExtensionAbility",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
@@ -833,8 +833,8 @@ napi_value JsAbilityContext::OnStopExtensionAbilityWithAccount(napi_env env, Nap
|
||||
|
||||
int32_t accountId = -1;
|
||||
AAFwk::Want want;
|
||||
if (!AppExecFwk::UnwrapWant(env, info.argv[0], want) ||
|
||||
!AppExecFwk::UnwrapInt32FromJS2(env, info.argv[1], accountId)) {
|
||||
if (!AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want) ||
|
||||
!AppExecFwk::UnwrapInt32FromJS2(env, info.argv[INDEX_ONE], accountId)) {
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
@@ -855,7 +855,7 @@ napi_value JsAbilityContext::OnStopExtensionAbilityWithAccount(napi_env env, Nap
|
||||
}
|
||||
};
|
||||
|
||||
napi_value lastParam = (info.argc > ARGC_TWO) ? info.argv[ARGC_TWO] : nullptr;
|
||||
napi_value lastParam = (info.argc > ARGC_TWO) ? info.argv[INDEX_TWO] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::Schedule("JsAbilityContext::OnStopExtensionAbilityWithAccount",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
@@ -866,7 +866,7 @@ napi_value JsAbilityContext::OnTerminateSelfWithResult(napi_env env, NapiCallbac
|
||||
{
|
||||
HILOG_INFO("TerminateSelfWithResult");
|
||||
|
||||
if (info.argc == 0) {
|
||||
if (info.argc == ARGC_ZERO) {
|
||||
HILOG_ERROR("Not enough params");
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
@@ -874,7 +874,7 @@ napi_value JsAbilityContext::OnTerminateSelfWithResult(napi_env env, NapiCallbac
|
||||
|
||||
int resultCode = 0;
|
||||
AAFwk::Want want;
|
||||
if (!AppExecFwk::UnWrapAbilityResult(env, info.argv[0], resultCode, want)) {
|
||||
if (!AppExecFwk::UnWrapAbilityResult(env, info.argv[INDEX_ZERO], resultCode, want)) {
|
||||
HILOG_ERROR("%s Failed to parse ability result!", __func__);
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return CreateJsUndefined(env);
|
||||
@@ -902,7 +902,7 @@ napi_value JsAbilityContext::OnTerminateSelfWithResult(napi_env env, NapiCallbac
|
||||
}
|
||||
};
|
||||
|
||||
napi_value lastParam = (info.argc > ARGC_ONE) ? info.argv[1] : nullptr;
|
||||
napi_value lastParam = (info.argc > ARGC_ONE) ? info.argv[INDEX_ONE] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::ScheduleHighQos("JsAbilityContext::OnTerminateSelfWithResult",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
@@ -922,14 +922,14 @@ napi_value JsAbilityContext::OnConnectAbility(napi_env env, NapiCallbackInfo& in
|
||||
|
||||
// unwrap want
|
||||
AAFwk::Want want;
|
||||
OHOS::AppExecFwk::UnwrapWant(env, info.argv[0], want);
|
||||
OHOS::AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want);
|
||||
HILOG_INFO("ConnectAbility, callee:%{public}s.%{public}s",
|
||||
want.GetBundle().c_str(),
|
||||
want.GetElement().GetAbilityName().c_str());
|
||||
|
||||
// unwarp connection
|
||||
sptr<JSAbilityConnection> connection = new JSAbilityConnection(env);
|
||||
connection->SetJsConnectionObject(info.argv[1]);
|
||||
connection->SetJsConnectionObject(info.argv[INDEX_ONE]);
|
||||
int64_t connectId = g_serialNumber;
|
||||
ConnectionKey key;
|
||||
key.id = g_serialNumber;
|
||||
@@ -977,13 +977,13 @@ napi_value JsAbilityContext::OnConnectAbilityWithAccount(napi_env env, NapiCallb
|
||||
|
||||
// unwrap want
|
||||
AAFwk::Want want;
|
||||
OHOS::AppExecFwk::UnwrapWant(env, info.argv[0], want);
|
||||
OHOS::AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want);
|
||||
HILOG_INFO("ConnectAbilityWithAccount, bundlename:%{public}s abilityname:%{public}s",
|
||||
want.GetBundle().c_str(),
|
||||
want.GetElement().GetAbilityName().c_str());
|
||||
|
||||
int32_t accountId = 0;
|
||||
if (!OHOS::AppExecFwk::UnwrapInt32FromJS2(env, info.argv[1], accountId)) {
|
||||
if (!OHOS::AppExecFwk::UnwrapInt32FromJS2(env, info.argv[INDEX_ONE], accountId)) {
|
||||
HILOG_ERROR("the second parameter is invalid.");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return CreateJsUndefined(env);
|
||||
@@ -1042,7 +1042,7 @@ napi_value JsAbilityContext::OnDisconnectAbility(napi_env env, NapiCallbackInfo&
|
||||
// unwrap connectId
|
||||
int64_t connectId = -1;
|
||||
sptr<JSAbilityConnection> connection = nullptr;
|
||||
napi_get_value_int64(env, info.argv[0], &connectId);
|
||||
napi_get_value_int64(env, info.argv[INDEX_ZERO], &connectId);
|
||||
HILOG_INFO("DisconnectAbility, connection:%{public}d.", static_cast<int32_t>(connectId));
|
||||
auto item = std::find_if(g_connects.begin(),
|
||||
g_connects.end(),
|
||||
@@ -1076,7 +1076,7 @@ napi_value JsAbilityContext::OnDisconnectAbility(napi_env env, NapiCallbackInfo&
|
||||
task.Resolve(env, CreateJsUndefined(env));
|
||||
};
|
||||
|
||||
napi_value lastParam = (info.argc > ARGC_ONE) ? info.argv[1] : nullptr;
|
||||
napi_value lastParam = (info.argc > ARGC_ONE) ? info.argv[INDEX_ONE] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::Schedule("JsAbilityContext::OnDisconnectAbility",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
@@ -1108,7 +1108,7 @@ napi_value JsAbilityContext::OnTerminateSelf(napi_env env, NapiCallbackInfo& inf
|
||||
}
|
||||
};
|
||||
|
||||
napi_value lastParam = (info.argc > ARGC_ZERO) ? info.argv[ARGC_ZERO] : nullptr;
|
||||
napi_value lastParam = (info.argc > ARGC_ZERO) ? info.argv[INDEX_ZERO] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::ScheduleHighQos("JsAbilityContext::OnTerminateSelf",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
@@ -1129,7 +1129,7 @@ napi_value JsAbilityContext::OnRestoreWindowStage(napi_env env, NapiCallbackInfo
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_CONTEXT);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
auto errcode = context->RestoreWindowStage(env, info.argv[0]);
|
||||
auto errcode = context->RestoreWindowStage(env, info.argv[INDEX_ZERO]);
|
||||
if (errcode != 0) {
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER);
|
||||
return CreateJsError(env, errcode, "RestoreWindowStage failed.");
|
||||
@@ -1146,11 +1146,11 @@ napi_value JsAbilityContext::OnRequestDialogService(napi_env env, NapiCallbackIn
|
||||
}
|
||||
|
||||
AAFwk::Want want;
|
||||
AppExecFwk::UnwrapWant(env, info.argv[0], want);
|
||||
AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want);
|
||||
HILOG_INFO("RequestDialogService, target:%{public}s.%{public}s.", want.GetBundle().c_str(),
|
||||
want.GetElement().GetAbilityName().c_str());
|
||||
|
||||
napi_value lastParam = (info.argc > ARGC_ONE) ? info.argv[ARGC_ONE] : nullptr;
|
||||
napi_value lastParam = (info.argc > ARGC_ONE) ? info.argv[INDEX_ONE] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
auto uasyncTask = CreateAsyncTaskWithLastParam(env, lastParam, nullptr, nullptr, &result);
|
||||
std::shared_ptr<NapiAsyncTask> asyncTask = std::move(uasyncTask);
|
||||
@@ -1215,7 +1215,7 @@ napi_value JsAbilityContext::OnReportDrawnCompleted(napi_env env, NapiCallbackIn
|
||||
}
|
||||
};
|
||||
|
||||
napi_value lastParam = info.argv[ARGC_ZERO];
|
||||
napi_value lastParam = info.argv[INDEX_ZERO];
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::ScheduleHighQos("JsAbilityContext::OnReportDrawnCompleted",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, std::move(execute), std::move(complete), &result));
|
||||
@@ -1248,8 +1248,10 @@ void JsAbilityContext::InheritWindowMode(AAFwk::Want &want)
|
||||
return;
|
||||
}
|
||||
auto windowMode = context->GetCurrentWindowMode();
|
||||
if (windowMode == AAFwk::AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_PRIMARY ||
|
||||
windowMode == AAFwk::AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_SECONDARY) {
|
||||
auto deviceType = context->GetDeviceType();
|
||||
if (deviceType != Global::Resource::DeviceType::DEVICE_TWOINONE &&
|
||||
(windowMode == AAFwk::AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_PRIMARY ||
|
||||
windowMode == AAFwk::AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_SECONDARY)) {
|
||||
want.SetParam(Want::PARAM_RESV_WINDOW_MODE, windowMode);
|
||||
}
|
||||
HILOG_DEBUG("window mode is %{public}d", windowMode);
|
||||
@@ -1601,7 +1603,7 @@ napi_value JsAbilityContext::OnSetMissionContinueState(napi_env env, NapiCallbac
|
||||
}
|
||||
|
||||
AAFwk::ContinueState state;
|
||||
if (!ConvertFromJsValue(env, info.argv[0], state)) {
|
||||
if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], state)) {
|
||||
HILOG_ERROR("OnSetMissionContinueState, parse state failed.");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return CreateJsUndefined(env);
|
||||
@@ -1630,7 +1632,7 @@ napi_value JsAbilityContext::OnSetMissionContinueState(napi_env env, NapiCallbac
|
||||
}
|
||||
};
|
||||
|
||||
napi_value lastParam = (info.argc > ARGC_ONE) ? info.argv[ARGC_ONE] : nullptr;
|
||||
napi_value lastParam = (info.argc > ARGC_ONE) ? info.argv[INDEX_ONE] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::ScheduleHighQos("JsAbilityContext::SetMissionContinueState",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
@@ -1658,7 +1660,7 @@ napi_value JsAbilityContext::OnSetMissionLabel(napi_env env, NapiCallbackInfo& i
|
||||
}
|
||||
|
||||
std::string label;
|
||||
if (!ConvertFromJsValue(env, info.argv[0], label)) {
|
||||
if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], label)) {
|
||||
HILOG_ERROR("OnSetMissionLabel, parse label failed.");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return CreateJsUndefined(env);
|
||||
@@ -1681,7 +1683,7 @@ napi_value JsAbilityContext::OnSetMissionLabel(napi_env env, NapiCallbackInfo& i
|
||||
}
|
||||
};
|
||||
|
||||
napi_value lastParam = (info.argc > ARGC_ONE) ? info.argv[ARGC_ONE] : nullptr;
|
||||
napi_value lastParam = (info.argc > ARGC_ONE) ? info.argv[INDEX_ONE] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::ScheduleHighQos("JsAbilityContext::OnSetMissionLabel",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
@@ -1697,7 +1699,7 @@ napi_value JsAbilityContext::OnSetMissionIcon(napi_env env, NapiCallbackInfo& in
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
auto icon = OHOS::Media::PixelMapNapi::GetPixelMap(env, info.argv[0]);
|
||||
auto icon = OHOS::Media::PixelMapNapi::GetPixelMap(env, info.argv[INDEX_ZERO]);
|
||||
if (!icon) {
|
||||
HILOG_ERROR("OnSetMissionIcon, parse icon failed.");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
@@ -1721,7 +1723,7 @@ napi_value JsAbilityContext::OnSetMissionIcon(napi_env env, NapiCallbackInfo& in
|
||||
}
|
||||
};
|
||||
|
||||
napi_value lastParam = (info.argc > ARGC_ONE) ? info.argv[1] : nullptr;
|
||||
napi_value lastParam = (info.argc > ARGC_ONE) ? info.argv[INDEX_ONE] : nullptr;
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::ScheduleHighQos("JsAbilityContext::OnSetMissionIcon",
|
||||
env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
|
||||
|
||||
@@ -57,12 +57,14 @@ public:
|
||||
std::condition_variable condition;
|
||||
};
|
||||
|
||||
static std::mutex g_connectsMutex;
|
||||
static std::map<ConnectionKey, sptr<JSServiceExtensionConnection>, key_compare> g_connects;
|
||||
static int64_t g_serialNumber = 0;
|
||||
|
||||
void RemoveConnection(int64_t connectId)
|
||||
{
|
||||
HILOG_DEBUG("enter");
|
||||
std::lock_guard guard(g_connectsMutex);
|
||||
auto item = std::find_if(g_connects.begin(), g_connects.end(),
|
||||
[&connectId](const auto &obj) {
|
||||
return connectId == obj.first.id;
|
||||
@@ -701,14 +703,17 @@ private:
|
||||
}
|
||||
connection->SetJsConnectionObject(value);
|
||||
ConnectionKey key;
|
||||
key.id = g_serialNumber;
|
||||
key.want = want;
|
||||
connection->SetConnectionId(key.id);
|
||||
g_connects.emplace(key, connection);
|
||||
if (g_serialNumber < INT32_MAX) {
|
||||
g_serialNumber++;
|
||||
} else {
|
||||
g_serialNumber = 0;
|
||||
{
|
||||
std::lock_guard guard(g_connectsMutex);
|
||||
key.id = g_serialNumber;
|
||||
key.want = want;
|
||||
connection->SetConnectionId(key.id);
|
||||
g_connects.emplace(key, connection);
|
||||
if (g_serialNumber < INT32_MAX) {
|
||||
g_serialNumber++;
|
||||
} else {
|
||||
g_serialNumber = 0;
|
||||
}
|
||||
}
|
||||
HILOG_DEBUG("Unable to find connection, make new one");
|
||||
return true;
|
||||
@@ -765,6 +770,7 @@ private:
|
||||
void FindConnection(AAFwk::Want& want, sptr<JSServiceExtensionConnection>& connection, int64_t& connectId) const
|
||||
{
|
||||
HILOG_INFO("Disconnect ability begin, connection:%{public}d.", static_cast<int32_t>(connectId));
|
||||
std::lock_guard guard(g_connectsMutex);
|
||||
auto item = std::find_if(g_connects.begin(),
|
||||
g_connects.end(),
|
||||
[&connectId](const auto &obj) {
|
||||
@@ -1125,21 +1131,24 @@ void JSServiceExtensionConnection::HandleOnAbilityDisconnectDone(const AppExecFw
|
||||
}
|
||||
|
||||
// release connect
|
||||
HILOG_DEBUG("OnAbilityDisconnectDone g_connects.size:%{public}zu", g_connects.size());
|
||||
std::string bundleName = element.GetBundleName();
|
||||
std::string abilityName = element.GetAbilityName();
|
||||
auto item = std::find_if(g_connects.begin(),
|
||||
g_connects.end(),
|
||||
[bundleName, abilityName, connectionId = connectionId_](
|
||||
const auto &obj) {
|
||||
return (bundleName == obj.first.want.GetBundle()) &&
|
||||
(abilityName == obj.first.want.GetElement().GetAbilityName()) &&
|
||||
connectionId == obj.first.id;
|
||||
});
|
||||
if (item != g_connects.end()) {
|
||||
// match bundlename && abilityname
|
||||
g_connects.erase(item);
|
||||
HILOG_DEBUG("OnAbilityDisconnectDone erase g_connects.size:%{public}zu", g_connects.size());
|
||||
{
|
||||
std::lock_guard guard(g_connectsMutex);
|
||||
HILOG_DEBUG("OnAbilityDisconnectDone g_connects.size:%{public}zu", g_connects.size());
|
||||
std::string bundleName = element.GetBundleName();
|
||||
std::string abilityName = element.GetAbilityName();
|
||||
auto item = std::find_if(g_connects.begin(),
|
||||
g_connects.end(),
|
||||
[bundleName, abilityName, connectionId = connectionId_](
|
||||
const auto &obj) {
|
||||
return (bundleName == obj.first.want.GetBundle()) &&
|
||||
(abilityName == obj.first.want.GetElement().GetAbilityName()) &&
|
||||
connectionId == obj.first.id;
|
||||
});
|
||||
if (item != g_connects.end()) {
|
||||
// match bundlename && abilityname
|
||||
g_connects.erase(item);
|
||||
HILOG_DEBUG("OnAbilityDisconnectDone erase g_connects.size:%{public}zu", g_connects.size());
|
||||
}
|
||||
}
|
||||
napi_call_function(env_, obj, method, ARGC_ONE, argv, nullptr);
|
||||
}
|
||||
|
||||
@@ -428,8 +428,11 @@ bool JsUIExtension::ForegroundWindowWithInsightIntent(const AAFwk::Want &want,
|
||||
|
||||
auto context = GetContext();
|
||||
InsightIntentExecutorInfo executorInfo;
|
||||
executorInfo.hapPath = context->GetAbilityInfo()->hapPath;
|
||||
executorInfo.windowMode = context->GetAbilityInfo()->compileMode == AppExecFwk::CompileMode::ES_MODULE;
|
||||
std::shared_ptr<AppExecFwk::AbilityInfo> abilityInfo = context->GetAbilityInfo();
|
||||
if (abilityInfo != nullptr) {
|
||||
executorInfo.hapPath = abilityInfo->hapPath;
|
||||
executorInfo.windowMode = abilityInfo->compileMode == AppExecFwk::CompileMode::ES_MODULE;
|
||||
}
|
||||
executorInfo.token = context->GetToken();
|
||||
executorInfo.pageLoader = contentSessions_[sessionInfo->uiExtensionComponentId];
|
||||
executorInfo.executeParam = std::make_shared<InsightIntentExecuteParam>();
|
||||
|
||||
@@ -259,8 +259,11 @@ bool JsUIExtensionBase::ForegroundWindowWithInsightIntent(const AAFwk::Want &wan
|
||||
});
|
||||
|
||||
InsightIntentExecutorInfo executorInfo;
|
||||
executorInfo.hapPath = context_->GetAbilityInfo()->hapPath;
|
||||
executorInfo.windowMode = context_->GetAbilityInfo()->compileMode == AppExecFwk::CompileMode::ES_MODULE;
|
||||
std::shared_ptr<AppExecFwk::AbilityInfo> abilityInfo = context_->GetAbilityInfo();
|
||||
if (abilityInfo != nullptr) {
|
||||
executorInfo.hapPath = abilityInfo->hapPath;
|
||||
executorInfo.windowMode = abilityInfo->compileMode == AppExecFwk::CompileMode::ES_MODULE;
|
||||
}
|
||||
executorInfo.token = context_->GetToken();
|
||||
executorInfo.pageLoader = contentSessions_[sessionInfo->uiExtensionComponentId];
|
||||
executorInfo.executeParam = std::make_shared<InsightIntentExecuteParam>();
|
||||
|
||||
@@ -120,10 +120,7 @@ bool AppfreezeInner::IsExitApp(const std::string& name)
|
||||
int AppfreezeInner::AcquireStack(const FaultData& info, bool onlyMainThread)
|
||||
{
|
||||
HITRACE_METER_FMT(HITRACE_TAG_APP, "AppfreezeInner::AcquireStack name:%s", info.errorObject.name.c_str());
|
||||
StartTrace(HITRACE_TAG_APP, "dumper MixStack");
|
||||
std::string stack = MixStackDumper::GetMixStack(onlyMainThread);
|
||||
FinishTrace(HITRACE_TAG_APP);
|
||||
|
||||
std::string stack = "";
|
||||
std::string msgContent;
|
||||
|
||||
auto mainHandler = appMainHandler_.lock();
|
||||
|
||||
@@ -520,9 +520,10 @@ public:
|
||||
* clear the application data.
|
||||
*
|
||||
* @param bundleName, bundle name in Application record.
|
||||
* @param userId User ID.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
ErrCode ClearUpApplicationData(const std::string &bundleName);
|
||||
ErrCode ClearUpApplicationData(const std::string &bundleName, const int32_t userId = DEFAULT_INVAL_VALUE);
|
||||
|
||||
/**
|
||||
* ContinueMission, continue ability from mission center.
|
||||
|
||||
@@ -607,7 +607,7 @@ public:
|
||||
* @param bundleName, bundle name in Application record.
|
||||
* @return
|
||||
*/
|
||||
virtual int ClearUpApplicationData(const std::string &bundleName) = 0;
|
||||
virtual int ClearUpApplicationData(const std::string &bundleName, const int32_t userId = DEFAULT_INVAL_VALUE) = 0;
|
||||
|
||||
/**
|
||||
* Uninstall app
|
||||
|
||||
@@ -175,9 +175,11 @@ public:
|
||||
* clear the application data.
|
||||
*
|
||||
* @param bundleName, bundle name in Application record.
|
||||
* @param userId, the user id.
|
||||
* @return
|
||||
*/
|
||||
virtual AppMgrResultCode ClearUpApplicationData(const std::string &bundleName);
|
||||
virtual AppMgrResultCode ClearUpApplicationData(const std::string &bundleName,
|
||||
const int32_t userId = -1);
|
||||
|
||||
/**
|
||||
* GetAllRunningProcesses, call GetAllRunningProcesses() through proxy project.
|
||||
|
||||
@@ -109,9 +109,11 @@ public:
|
||||
* clear the application data.
|
||||
*
|
||||
* @param bundleName, bundle name in Application record.
|
||||
* @param userId the user id.
|
||||
* @return
|
||||
*/
|
||||
virtual int32_t ClearUpApplicationData(const std::string &bundleName) = 0;
|
||||
virtual int32_t ClearUpApplicationData(const std::string &bundleName,
|
||||
const int32_t userId = -1) = 0;
|
||||
|
||||
/**
|
||||
* GetAllRunningProcesses, call GetAllRunningProcesses() through proxy project.
|
||||
|
||||
@@ -96,7 +96,8 @@ public:
|
||||
* @param bundleName, bundle name in Application record.
|
||||
* @return
|
||||
*/
|
||||
virtual int32_t ClearUpApplicationData(const std::string &bundleName) override;
|
||||
virtual int32_t ClearUpApplicationData(const std::string &bundleName,
|
||||
const int32_t userId = -1) override;
|
||||
|
||||
/**
|
||||
* GetAllRunningProcesses, call GetAllRunningProcesses() through proxy project.
|
||||
|
||||
@@ -302,11 +302,11 @@ AppMgrResultCode AppMgrClient::KillApplicationSelf()
|
||||
return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
AppMgrResultCode AppMgrClient::ClearUpApplicationData(const std::string &bundleName)
|
||||
AppMgrResultCode AppMgrClient::ClearUpApplicationData(const std::string &bundleName, const int32_t userId)
|
||||
{
|
||||
sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
|
||||
if (service != nullptr) {
|
||||
int32_t result = service->ClearUpApplicationData(bundleName);
|
||||
int32_t result = service->ClearUpApplicationData(bundleName, userId);
|
||||
if (result == ERR_OK) {
|
||||
return AppMgrResultCode::RESULT_OK;
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ sptr<IAmsMgr> AppMgrProxy::GetAmsMgr()
|
||||
return amsMgr;
|
||||
}
|
||||
|
||||
int32_t AppMgrProxy::ClearUpApplicationData(const std::string &bundleName)
|
||||
int32_t AppMgrProxy::ClearUpApplicationData(const std::string &bundleName, const int32_t userId)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
@@ -166,6 +166,10 @@ int32_t AppMgrProxy::ClearUpApplicationData(const std::string &bundleName)
|
||||
HILOG_ERROR("parcel WriteString failed");
|
||||
return ERR_FLATTEN_OBJECT;
|
||||
}
|
||||
if (!data.WriteInt32(userId)) {
|
||||
HILOG_ERROR("userId write failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
int32_t ret = SendRequest(AppMgrInterfaceCode::APP_CLEAR_UP_APPLICATION_DATA, data, reply, option);
|
||||
if (ret != NO_ERROR) {
|
||||
HILOG_WARN("SendRequest is failed, error code: %{public}d", ret);
|
||||
|
||||
@@ -246,7 +246,8 @@ int32_t AppMgrStub::HandleClearUpApplicationData(MessageParcel &data, MessagePar
|
||||
{
|
||||
HITRACE_METER(HITRACE_TAG_APP);
|
||||
std::string bundleName = data.ReadString();
|
||||
int32_t result = ClearUpApplicationData(bundleName);
|
||||
int32_t userId = data.ReadInt32();
|
||||
int32_t result = ClearUpApplicationData(bundleName, userId);
|
||||
reply.WriteInt32(result);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ ErrCode ExtensionManagerClient::ConnectServiceExtensionAbility(const Want &want,
|
||||
HILOG_INFO("name:%{public}s %{public}s, userId:%{public}d.",
|
||||
want.GetElement().GetBundleName().c_str(), want.GetElement().GetAbilityName().c_str(), userId);
|
||||
return abms->ConnectAbilityCommon(want, connect, nullptr, AppExecFwk::ExtensionAbilityType::SERVICE,
|
||||
userId, true);
|
||||
userId, false);
|
||||
}
|
||||
|
||||
ErrCode ExtensionManagerClient::ConnectServiceExtensionAbility(const Want &want,
|
||||
@@ -120,7 +120,7 @@ ErrCode ExtensionManagerClient::ConnectServiceExtensionAbility(const Want &want,
|
||||
HILOG_INFO("name:%{public}s %{public}s, userId:%{public}d.",
|
||||
want.GetElement().GetBundleName().c_str(), want.GetElement().GetAbilityName().c_str(), userId);
|
||||
return abms->ConnectAbilityCommon(
|
||||
want, connect, callerToken, AppExecFwk::ExtensionAbilityType::SERVICE, userId, true);
|
||||
want, connect, callerToken, AppExecFwk::ExtensionAbilityType::SERVICE, userId, false);
|
||||
}
|
||||
|
||||
ErrCode ExtensionManagerClient::ConnectEnterpriseAdminExtensionAbility(const Want &want,
|
||||
|
||||
@@ -63,7 +63,9 @@ abilityms_files = [
|
||||
|
||||
# new ability manager service here
|
||||
"src/task_data_persistence_mgr.cpp",
|
||||
"src/ui_extension_ability_connect_manager.cpp",
|
||||
"src/extension_record_manager.cpp",
|
||||
"src/extension_record.cpp",
|
||||
"src/ui_extension_record.cpp",
|
||||
"src/start_options.cpp",
|
||||
"src/stop_user_callback_proxy.cpp",
|
||||
"src/stop_user_callback_stub.cpp",
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include "connection_record.h"
|
||||
#include "element_name.h"
|
||||
#include "ui_extension_ability_connect_info.h"
|
||||
#include "ui_extension_ability_connect_manager.h"
|
||||
#include "extension_record_manager.h"
|
||||
#include "want.h"
|
||||
#include "iremote_object.h"
|
||||
#include "nocopyable.h"
|
||||
@@ -41,7 +41,7 @@ namespace OHOS {
|
||||
namespace AAFwk {
|
||||
using OHOS::AppExecFwk::AbilityType;
|
||||
using UIExtensionAbilityConnectInfo = AbilityRuntime::UIExtensionAbilityConnectInfo;
|
||||
using UIExtensionAbilityConnectManager = AbilityRuntime::UIExtensionAbilityConnectManager;
|
||||
using UIExtensionAbilityConnectManager = AbilityRuntime::ExtensionRecordManager;
|
||||
|
||||
/**
|
||||
* @class AbilityConnectManager
|
||||
@@ -502,12 +502,12 @@ private:
|
||||
bool IsLauncher(std::shared_ptr<AbilityRecord> serviceExtension) const;
|
||||
bool IsSceneBoard(std::shared_ptr<AbilityRecord> serviceExtension) const;
|
||||
void KillProcessesByUserId() const;
|
||||
inline bool IsUIExtensionAbility(const std::shared_ptr<AbilityRecord> abilityRecord);
|
||||
inline bool IsUIExtensionAbility(const std::shared_ptr<AbilityRecord> &abilityRecord);
|
||||
inline bool CheckUIExtensionAbilityLoaded(const AbilityRequest &abilityRequest);
|
||||
inline bool CheckUIExtensionAbilitySessionExistLocked(const std::shared_ptr<AbilityRecord> abilityRecord);
|
||||
inline int32_t AddUIExtensionAbilityRecord(const std::shared_ptr<AAFwk::AbilityRecord> abilityRecord,
|
||||
const std::string hostBundleName, const int32_t inputId) const;
|
||||
inline void RemoveUIExtensionAbilityRecord(const std::shared_ptr<AbilityRecord> abilityRecord);
|
||||
inline bool CheckUIExtensionAbilitySessionExistLocked(const std::shared_ptr<AbilityRecord> &abilityRecord);
|
||||
inline int32_t AddUIExtensionAbilityRecord(const std::shared_ptr<AAFwk::AbilityRecord> &abilityRecord,
|
||||
const std::string &hostBundleName, const int32_t inputId) const;
|
||||
inline void RemoveUIExtensionAbilityRecord(const std::shared_ptr<AbilityRecord> &abilityRecord);
|
||||
|
||||
private:
|
||||
const std::string TASK_ON_CALLBACK_DIED = "OnCallbackDiedTask";
|
||||
|
||||
@@ -497,7 +497,8 @@ public:
|
||||
* @param bundleName, bundle name in Application record.
|
||||
* @return
|
||||
*/
|
||||
virtual int ClearUpApplicationData(const std::string &bundleName) override;
|
||||
virtual int ClearUpApplicationData(const std::string &bundleName,
|
||||
const int32_t userId = -1) override;
|
||||
|
||||
/**
|
||||
* Uninstall app
|
||||
|
||||
@@ -644,7 +644,8 @@ public:
|
||||
* @param bundleName, bundle name in Application record.
|
||||
* @return ERR_OK, return back success, others fail.
|
||||
*/
|
||||
virtual int ClearUpApplicationData(const std::string &bundleName) override;
|
||||
virtual int ClearUpApplicationData(const std::string &bundleName,
|
||||
const int32_t userId = -1) override;
|
||||
|
||||
/**
|
||||
* Uninstall app
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ABILITY_APP_GALLERY_ENABLE_UTIL_H
|
||||
#define OHOS_ABILITY_APP_GALLERY_ENABLE_UTIL_H
|
||||
|
||||
#include <string>
|
||||
#include "hilog_wrapper.h"
|
||||
#include "parameters.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
namespace AppGalleryEnableUtil {
|
||||
const std::string ENABLE_APP_GALLERY_SELECTOR_UTIL = "abilitymanagerservice.support.appgallery.selector";
|
||||
|
||||
inline bool IsEnableAppGallerySelector()
|
||||
{
|
||||
HILOG_DEBUG("call");
|
||||
std::string ret = OHOS::system::GetParameter(ENABLE_APP_GALLERY_SELECTOR_UTIL, "false");
|
||||
if (ret == "true") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} // namespace AppGalleryEnableUtil
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_APP_GALLERY_ENABLE_UTIL_H
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "ability_debug_response_interface.h"
|
||||
#include "ability_info.h"
|
||||
#include "ability_manager_client.h"
|
||||
#include "app_debug_listener_interface.h"
|
||||
#include "application_info.h"
|
||||
#include "appmgr/app_mgr_client.h"
|
||||
@@ -243,7 +244,7 @@ public:
|
||||
*
|
||||
* @param bundleName.
|
||||
*/
|
||||
int ClearUpApplicationData(const std::string &bundleName);
|
||||
int ClearUpApplicationData(const std::string &bundleName, const int32_t userId = -1);
|
||||
|
||||
void AttachTimeOut(const sptr<IRemoteObject> &token);
|
||||
|
||||
|
||||
+20
-11
@@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ABILITY_RUNTIME_UI_EXTENSION_ABILITY_RECORD_H
|
||||
#define OHOS_ABILITY_RUNTIME_UI_EXTENSION_ABILITY_RECORD_H
|
||||
#ifndef OHOS_ABILITY_RUNTIME_EXTENSION_RECORD_H
|
||||
#define OHOS_ABILITY_RUNTIME_EXTENSION_RECORD_H
|
||||
|
||||
#include <atomic>
|
||||
#include <map>
|
||||
@@ -25,19 +25,28 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
class UIExtensionAbilityRecord : public std::enable_shared_from_this<UIExtensionAbilityRecord> {
|
||||
class ExtensionRecord : public std::enable_shared_from_this<ExtensionRecord> {
|
||||
public:
|
||||
UIExtensionAbilityRecord(const std::shared_ptr<AAFwk::AbilityRecord> abilityRecord, std::string hostBundleName,
|
||||
int32_t uiExtensionAbilityId)
|
||||
: abilityRecord_(abilityRecord), hostBundleName_(hostBundleName), uiExtensionAbilityId_(uiExtensionAbilityId)
|
||||
{}
|
||||
ExtensionRecord(const std::shared_ptr<AAFwk::AbilityRecord> &abilityRecord,
|
||||
const std::string &hostBundleName, int32_t extensionRecordId);
|
||||
|
||||
virtual ~UIExtensionAbilityRecord() = default;
|
||||
virtual ~ExtensionRecord();
|
||||
|
||||
sptr<IRemoteObject> GetCallToken() const;
|
||||
|
||||
sptr<IRemoteObject> GetRootCallerToken() const;
|
||||
|
||||
void SetRootCallerToken(sptr<IRemoteObject> &rootCallerToken);
|
||||
|
||||
virtual bool ContinueToGetCallerToken();
|
||||
|
||||
std::shared_ptr<AAFwk::AbilityRecord> abilityRecord_ = nullptr;
|
||||
std::string hostBundleName_ = "";
|
||||
int32_t uiExtensionAbilityId_ = 0;
|
||||
std::string hostBundleName_;
|
||||
int32_t extensionRecordId_ = 0;
|
||||
|
||||
private:
|
||||
sptr<IRemoteObject> rootCallerToken_ = nullptr;
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_UI_EXTENSION_ABILITY_RECORD_H
|
||||
#endif // OHOS_ABILITY_RUNTIME_EXTENSION_RECORD_H
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ABILITY_RUNTIME_EXTENSION_RECORD_MANAGER_H
|
||||
#define OHOS_ABILITY_RUNTIME_EXTENSION_RECORD_MANAGER_H
|
||||
|
||||
#include <atomic>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
|
||||
#include "extension_record.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
constexpr int32_t INVALID_EXTENSION_RECORD_ID = 0;
|
||||
|
||||
class ExtensionRecordManager : public std::enable_shared_from_this<ExtensionRecordManager> {
|
||||
public:
|
||||
using ExtensionAbilityRecordMap = std::map<int32_t, std::shared_ptr<ExtensionRecord>>;
|
||||
|
||||
explicit ExtensionRecordManager(const int32_t userId);
|
||||
virtual ~ExtensionRecordManager();
|
||||
|
||||
/**
|
||||
* @brief Generate extension record id, if input id didn't exist, return it, else assign one.
|
||||
*
|
||||
* @param extensionRecordId Input extension record id.
|
||||
* @return int32_t Generated extension record id.
|
||||
*/
|
||||
int32_t GenerateExtensionRecordId(const int32_t extensionRecordId);
|
||||
|
||||
/**
|
||||
* @brief Add extension record by id, if record exist, replace it.
|
||||
*
|
||||
* @param extensionRecordId extension record id.
|
||||
* @param record extension record.
|
||||
*/
|
||||
void AddExtensionRecord(const int32_t extensionRecordId, const std::shared_ptr<ExtensionRecord> &record);
|
||||
|
||||
/**
|
||||
* @brief Remove extension record by id
|
||||
*
|
||||
* @param extensionRecordId extension record id.
|
||||
*/
|
||||
void RemoveExtensionRecord(const int32_t extensionRecordId);
|
||||
|
||||
/**
|
||||
* @brief Check if host bundleName matched to stored record by specified id.
|
||||
*
|
||||
* @param extensionRecordId extension record id.
|
||||
* @param hostBundleName bundleName of target extension.
|
||||
* @return true Matched.
|
||||
* @return false Not Match.
|
||||
*/
|
||||
bool CheckExtensionLoaded(const int32_t extensionRecordId, const std::string &hostBundleName);
|
||||
|
||||
static bool IsBelongToManager(const AppExecFwk::AbilityInfo &abilityInfo);
|
||||
|
||||
bool IsFocused(int32_t extensionRecordId, const sptr<IRemoteObject>& focusToken);
|
||||
|
||||
int32_t CreateExtensionRecord(const std::shared_ptr<AAFwk::AbilityRecord> &abilityRecord,
|
||||
const std::string &hostBundleName, int32_t &extensionRecordId);
|
||||
|
||||
private:
|
||||
int32_t userId_;
|
||||
static std::atomic_int32_t extensionRecordId_;
|
||||
std::mutex mutex_;
|
||||
std::set<int32_t> extensionRecordIdSet_;
|
||||
ExtensionAbilityRecordMap extensionRecords_;
|
||||
|
||||
sptr<IRemoteObject> GetRootCallerTokenLocked(int32_t extensionRecordId);
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_EXTENSION_RECORD_MANAGER_H
|
||||
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ABILITY_RUNTIME_UI_EXTENSION_ABILITY_CONNECT_MANAGER_H
|
||||
#define OHOS_ABILITY_RUNTIME_UI_EXTENSION_ABILITY_CONNECT_MANAGER_H
|
||||
|
||||
#include <atomic>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
|
||||
#include "ui_extension_ability_record.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
constexpr int32_t INVALID_UI_EXTENSION_ABILITY_ID = 0;
|
||||
|
||||
class UIExtensionAbilityConnectManager : public std::enable_shared_from_this<UIExtensionAbilityConnectManager> {
|
||||
public:
|
||||
using UIExtensionAbilityRecordMap = std::map<int32_t, std::shared_ptr<UIExtensionAbilityRecord>>;
|
||||
|
||||
explicit UIExtensionAbilityConnectManager(const int32_t userId);
|
||||
virtual ~UIExtensionAbilityConnectManager();
|
||||
|
||||
/**
|
||||
* @brief Generate uiextensionability id, if input id didn't exist, return it, else assign one.
|
||||
*
|
||||
* @param uiExtensionAbilityId Input uiextensionability id.
|
||||
* @return int32_t Generated uiextensionability id.
|
||||
*/
|
||||
int32_t GenerateUIExtensionAbilityId(const int32_t uiExtensionAbilityId);
|
||||
|
||||
/**
|
||||
* @brief Add uiextensionability record by id, if record exist, replace it.
|
||||
*
|
||||
* @param uiExtensionAbilityId uiextensionability id.
|
||||
* @param record uiextensionability record.
|
||||
*/
|
||||
void AddUIExtensionAbilityRecord(const int32_t uiExtensionAbilityId,
|
||||
const std::shared_ptr<UIExtensionAbilityRecord> record);
|
||||
|
||||
/**
|
||||
* @brief Remove uiextensionability record by id
|
||||
*
|
||||
* @param uiExtensionAbilityId uiextensionability id.
|
||||
*/
|
||||
void RemoveUIExtensionAbilityRecord(const int32_t uiExtensionAbilityId);
|
||||
|
||||
/**
|
||||
* @brief Check if host bundleName matched to stored record by specified id.
|
||||
*
|
||||
* @param uiExtensionAbilityId uiextensionability id.
|
||||
* @param hostBundleName bundleName of target uiextensionability.
|
||||
* @return true Matched.
|
||||
* @return false Not Match.
|
||||
*/
|
||||
bool CheckUIExtensionAbilityLoaded(const int32_t uiExtensionAbilityId, const std::string hostBundleName);
|
||||
|
||||
private:
|
||||
int32_t userId_;
|
||||
static std::atomic_int32_t uiExtensionAbilityId_;
|
||||
std::mutex mutex_;
|
||||
std::set<int32_t> uiExtensionAbilityIdSet_;
|
||||
UIExtensionAbilityRecordMap uiExtensionAbilityRecords_;
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_UI_EXTENSION_ABILITY_CONNECT_MANAGER_H
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ABILITY_RUNTIME_UI_EXTENSION_RECORD_H
|
||||
#define OHOS_ABILITY_RUNTIME_UI_EXTENSION_RECORD_H
|
||||
|
||||
#include <atomic>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "extension_record.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
class UIExtensionRecord : public ExtensionRecord {
|
||||
public:
|
||||
UIExtensionRecord(const std::shared_ptr<AAFwk::AbilityRecord> &abilityRecord,
|
||||
const std::string &hostBundleName, int32_t extensionRecordId);
|
||||
|
||||
~UIExtensionRecord() override;
|
||||
|
||||
bool ContinueToGetCallerToken() override;
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_UI_EXTENSION_RECORD_H
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "mock_session_manager_service.h"
|
||||
#include "parameter.h"
|
||||
#include "session/host/include/zidl/session_interface.h"
|
||||
#include "ui_extension_ability_record.h"
|
||||
#include "extension_record.h"
|
||||
#include "ui_extension_utils.h"
|
||||
|
||||
namespace OHOS {
|
||||
@@ -69,7 +69,7 @@ const std::unordered_set<std::string> FROZEN_WHITE_LIST {
|
||||
|
||||
AbilityConnectManager::AbilityConnectManager(int userId) : userId_(userId)
|
||||
{
|
||||
uiExtensionAbilityRecordMgr_ = std::make_unique<AbilityRuntime::UIExtensionAbilityConnectManager>(userId);
|
||||
uiExtensionAbilityRecordMgr_ = std::make_unique<AbilityRuntime::ExtensionRecordManager>(userId);
|
||||
}
|
||||
|
||||
AbilityConnectManager::~AbilityConnectManager()
|
||||
@@ -114,6 +114,12 @@ int AbilityConnectManager::StartAbilityLocked(const AbilityRequest &abilityReque
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_INFO("ability_name:%{public}s", abilityRequest.want.GetElement().GetURI().c_str());
|
||||
|
||||
if (UIExtensionUtils::IsUIExtension(abilityRequest.abilityInfo.extensionAbilityType) &&
|
||||
!CheckUIExtensionAbilityLoaded(abilityRequest)) {
|
||||
HILOG_WARN("Start uiextensionability with invalid id.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
std::shared_ptr<AbilityRecord> targetService;
|
||||
bool isLoadedAbility = false;
|
||||
GetOrCreateServiceRecord(abilityRequest, false, targetService, isLoadedAbility);
|
||||
@@ -136,7 +142,7 @@ int AbilityConnectManager::StartAbilityLocked(const AbilityRequest &abilityReque
|
||||
if (IsUIExtensionAbility(targetService) && abilityRequest.sessionInfo != nullptr) {
|
||||
std::string hostBundleName = abilityRequest.abilityInfo.bundleName;
|
||||
int32_t inputId = abilityRequest.sessionInfo->want.GetIntParam(UIEXTENSION_ABILITY_ID,
|
||||
INVALID_UI_EXTENSION_ABILITY_ID);
|
||||
INVALID_EXTENSION_RECORD_ID);
|
||||
auto uiExtensionAbilityId = AddUIExtensionAbilityRecord(targetService, hostBundleName, inputId);
|
||||
HILOG_DEBUG("UIExtensionAbility id %{public}d.", uiExtensionAbilityId);
|
||||
}
|
||||
@@ -147,8 +153,7 @@ int AbilityConnectManager::StartAbilityLocked(const AbilityRequest &abilityReque
|
||||
} else if (IsUIExtensionAbility(targetService) &&
|
||||
targetService->IsReady() && !targetService->IsAbilityState(AbilityState::INACTIVATING) &&
|
||||
!targetService->IsAbilityState(AbilityState::BACKGROUNDING) &&
|
||||
targetService->IsAbilityWindowReady() &&
|
||||
CheckUIExtensionAbilityLoaded(abilityRequest)) {
|
||||
targetService->IsAbilityWindowReady()) {
|
||||
targetService->SetWant(abilityRequest.want);
|
||||
CommandAbilityWindow(targetService, abilityRequest.sessionInfo, WIN_CMD_FOREGROUND);
|
||||
} else {
|
||||
@@ -723,7 +728,7 @@ int AbilityConnectManager::ScheduleDisconnectAbilityDoneLocked(const sptr<IRemot
|
||||
abilityRecord->RemoveConnectRecordFromList(connect);
|
||||
if (abilityRecord->IsConnectListEmpty() && abilityRecord->GetStartId() == 0) {
|
||||
if (IsUIExtensionAbility(abilityRecord) && CheckUIExtensionAbilitySessionExistLocked(abilityRecord)) {
|
||||
HILOG_INFO("There exist ui extension component, don't terminate when disconnet.");
|
||||
HILOG_INFO("There exist ui extension component, don't terminate when disconnect.");
|
||||
} else {
|
||||
HILOG_INFO("Service ability has no any connection, and not started, need terminate.");
|
||||
TerminateRecord(abilityRecord);
|
||||
@@ -2192,12 +2197,15 @@ void AbilityConnectManager::HandleUIExtWindowDiedTask(const sptr<IRemoteObject>
|
||||
|
||||
bool AbilityConnectManager::IsUIExtensionFocused(uint32_t uiExtensionTokenId, const sptr<IRemoteObject>& focusToken)
|
||||
{
|
||||
HILOG_DEBUG("called, id: %{public}u", uiExtensionTokenId);
|
||||
CHECK_POINTER_AND_RETURN(uiExtensionAbilityRecordMgr_, false);
|
||||
std::lock_guard guard(Lock_);
|
||||
for (auto& item: uiExtensionMap_) {
|
||||
auto uiExtension = item.second.first.lock();
|
||||
auto sessionInfo = item.second.second;
|
||||
if (uiExtension && uiExtension->GetApplicationInfo().accessTokenId == uiExtensionTokenId
|
||||
&& sessionInfo && sessionInfo->callerToken == focusToken) {
|
||||
&& uiExtensionAbilityRecordMgr_->IsFocused(uiExtension->GetUIExtensionAbilityId(), focusToken)) {
|
||||
HILOG_INFO("id: %{public}u, isFocused.", uiExtensionTokenId);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -2304,7 +2312,7 @@ void AbilityConnectManager::HandleExtensionDisconnectTask(const std::shared_ptr<
|
||||
}
|
||||
}
|
||||
|
||||
bool AbilityConnectManager::IsUIExtensionAbility(const std::shared_ptr<AbilityRecord> abilityRecord)
|
||||
bool AbilityConnectManager::IsUIExtensionAbility(const std::shared_ptr<AbilityRecord> &abilityRecord)
|
||||
{
|
||||
CHECK_POINTER_AND_RETURN(abilityRecord, false);
|
||||
return UIExtensionUtils::IsUIExtension(abilityRecord->GetAbilityInfo().extensionAbilityType);
|
||||
@@ -2316,20 +2324,21 @@ bool AbilityConnectManager::CheckUIExtensionAbilityLoaded(const AbilityRequest &
|
||||
CHECK_POINTER_AND_RETURN(uiExtensionAbilityRecordMgr_, false);
|
||||
|
||||
int32_t uiExtensionAbilityId = abilityRequest.sessionInfo->want.GetIntParam(UIEXTENSION_ABILITY_ID,
|
||||
INVALID_UI_EXTENSION_ABILITY_ID);
|
||||
if (uiExtensionAbilityId == INVALID_UI_EXTENSION_ABILITY_ID) {
|
||||
INVALID_EXTENSION_RECORD_ID);
|
||||
if (uiExtensionAbilityId == INVALID_EXTENSION_RECORD_ID) {
|
||||
HILOG_DEBUG("Didn't carry uiextension ability id when start.");
|
||||
return true;
|
||||
}
|
||||
|
||||
auto ret = uiExtensionAbilityRecordMgr_->CheckUIExtensionAbilityLoaded(
|
||||
HILOG_INFO("UIExtensionAbility id: %{public}d.", uiExtensionAbilityId);
|
||||
auto ret = uiExtensionAbilityRecordMgr_->CheckExtensionLoaded(
|
||||
uiExtensionAbilityId, abilityRequest.abilityInfo.bundleName);
|
||||
HILOG_DEBUG("UIExtensionAbility loaded status: %{public}s.", ret ? "true" : "false");
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool AbilityConnectManager::CheckUIExtensionAbilitySessionExistLocked(
|
||||
const std::shared_ptr<AbilityRecord> abilityRecord)
|
||||
const std::shared_ptr<AbilityRecord> &abilityRecord)
|
||||
{
|
||||
CHECK_POINTER_AND_RETURN(abilityRecord, false);
|
||||
|
||||
@@ -2344,26 +2353,21 @@ bool AbilityConnectManager::CheckUIExtensionAbilitySessionExistLocked(
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t AbilityConnectManager::AddUIExtensionAbilityRecord(const std::shared_ptr<AAFwk::AbilityRecord> abilityRecord,
|
||||
const std::string hostBundleName, const int32_t inputId) const
|
||||
int32_t AbilityConnectManager::AddUIExtensionAbilityRecord(const std::shared_ptr<AAFwk::AbilityRecord> &abilityRecord,
|
||||
const std::string &hostBundleName, const int32_t inputId) const
|
||||
{
|
||||
CHECK_POINTER_AND_RETURN(abilityRecord, INVALID_UI_EXTENSION_ABILITY_ID);
|
||||
CHECK_POINTER_AND_RETURN(uiExtensionAbilityRecordMgr_, INVALID_UI_EXTENSION_ABILITY_ID);
|
||||
|
||||
auto uiExtensionAbilityId = uiExtensionAbilityRecordMgr_->GenerateUIExtensionAbilityId(inputId);
|
||||
HILOG_DEBUG("Generated id is %{public}d.", uiExtensionAbilityId);
|
||||
abilityRecord->SetUIExtensionAbilityId(uiExtensionAbilityId);
|
||||
auto uiExtensionAbilityRecord = std::make_shared<UIExtensionAbilityRecord>(abilityRecord,
|
||||
hostBundleName, uiExtensionAbilityId);
|
||||
uiExtensionAbilityRecordMgr_->AddUIExtensionAbilityRecord(uiExtensionAbilityId, uiExtensionAbilityRecord);
|
||||
CHECK_POINTER_AND_RETURN(abilityRecord, INVALID_EXTENSION_RECORD_ID);
|
||||
CHECK_POINTER_AND_RETURN(uiExtensionAbilityRecordMgr_, INVALID_EXTENSION_RECORD_ID);
|
||||
int32_t uiExtensionAbilityId = inputId;
|
||||
uiExtensionAbilityRecordMgr_->CreateExtensionRecord(abilityRecord, hostBundleName, uiExtensionAbilityId);
|
||||
return uiExtensionAbilityId;
|
||||
}
|
||||
|
||||
void AbilityConnectManager::RemoveUIExtensionAbilityRecord(const std::shared_ptr<AbilityRecord> abilityRecord)
|
||||
void AbilityConnectManager::RemoveUIExtensionAbilityRecord(const std::shared_ptr<AbilityRecord> &abilityRecord)
|
||||
{
|
||||
CHECK_POINTER(abilityRecord);
|
||||
CHECK_POINTER(uiExtensionAbilityRecordMgr_);
|
||||
uiExtensionAbilityRecordMgr_->RemoveUIExtensionAbilityRecord(abilityRecord->GetUIExtensionAbilityId());
|
||||
uiExtensionAbilityRecordMgr_->RemoveExtensionRecord(abilityRecord->GetUIExtensionAbilityId());
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "permission_verification.h"
|
||||
#include "system_dialog_scheduler.h"
|
||||
#include "want.h"
|
||||
#include "want_params_wrapper.h"
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
#ifdef SUPPORT_ERMS
|
||||
@@ -59,6 +60,11 @@ const std::string JUMP_DIALOG_TARGET_MODULE_NAME = "interceptor_targetModuleName
|
||||
const std::string JUMP_DIALOG_TARGET_LABEL_ID = "interceptor_targetLabelId";
|
||||
const std::string UNREGISTER_EVENT_TASK = "unregister event task";
|
||||
const std::string ABILITY_SUPPORT_ECOLOGICAL_RULEMGRSERVICE = "abilitymanagerservice.support.ecologicalrulemgrservice";
|
||||
const std::string IS_FROM_PARENTCONTROL = "ohos.ability.isFromParentControl";
|
||||
const std::string INTERCEPT_PARAMETERS = "intercept_parammeters";
|
||||
const std::string INTERCEPT_BUNDLE_NAME = "intercept_bundleName";
|
||||
const std::string INTERCEPT_ABILITY_NAME = "intercept_abilityName";
|
||||
const std::string INTERCEPT_MODULE_NAME = "intercept_moduleName";
|
||||
constexpr int KILL_PROCESS_DELAYTIME_MICRO_SECONDS = 5000;
|
||||
|
||||
ErrCode CrowdTestInterceptor::DoProcess(const Want &want, int requestCode, int32_t userId, bool isForeground)
|
||||
@@ -119,13 +125,28 @@ ErrCode ControlInterceptor::DoProcess(const Want &want, int requestCode, int32_t
|
||||
if (CheckControl(want, userId, controlRule)) {
|
||||
HILOG_INFO("The target application is intercpted. %{public}s", controlRule.controlMessage.c_str());
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
if (isForeground && controlRule.controlWant != nullptr) {
|
||||
int ret = IN_PROCESS_CALL(AbilityManagerClient::GetInstance()->StartAbility(*controlRule.controlWant,
|
||||
requestCode, userId));
|
||||
if (ret != ERR_OK) {
|
||||
HILOG_ERROR("Control implicit start appgallery failed.");
|
||||
return ret;
|
||||
if (!isForeground || controlRule.controlWant == nullptr) {
|
||||
HILOG_ERROR("Can not start control want");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
if (controlRule.controlWant->GetBoolParam(IS_FROM_PARENTCONTROL, false)) {
|
||||
auto controlWant = controlRule.controlWant;
|
||||
auto controlParam = controlWant->GetParams();
|
||||
sptr<AAFwk::IWantParams> interceptParam = WantParamWrapper::Box(want.GetParams());
|
||||
if (interceptParam != nullptr) {
|
||||
controlParam.SetParam(INTERCEPT_PARAMETERS, interceptParam);
|
||||
}
|
||||
controlWant->SetParams(controlParam);
|
||||
controlWant->SetParam(INTERCEPT_BUNDLE_NAME, want.GetElement().GetBundleName());
|
||||
controlWant->SetParam(INTERCEPT_ABILITY_NAME, want.GetElement().GetAbilityName());
|
||||
controlWant->SetParam(INTERCEPT_MODULE_NAME, want.GetElement().GetModuleName());
|
||||
controlRule.controlWant = controlWant;
|
||||
}
|
||||
int ret = IN_PROCESS_CALL(AbilityManagerClient::GetInstance()->StartAbility(*controlRule.controlWant,
|
||||
requestCode, userId));
|
||||
if (ret != ERR_OK) {
|
||||
HILOG_ERROR("Control implicit start appgallery failed.");
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
if (controlRule.isEdm) {
|
||||
|
||||
@@ -552,12 +552,12 @@ ErrCode AbilityManagerClient::ForceTimeoutForTest(const std::string &abilityName
|
||||
}
|
||||
#endif
|
||||
|
||||
ErrCode AbilityManagerClient::ClearUpApplicationData(const std::string &bundleName)
|
||||
ErrCode AbilityManagerClient::ClearUpApplicationData(const std::string &bundleName, const int32_t userId)
|
||||
{
|
||||
HILOG_INFO("call");
|
||||
auto abms = GetAbilityManager();
|
||||
CHECK_POINTER_RETURN_NOT_CONNECTED(abms);
|
||||
return abms->ClearUpApplicationData(bundleName);
|
||||
return abms->ClearUpApplicationData(bundleName, userId);
|
||||
}
|
||||
|
||||
ErrCode AbilityManagerClient::ContinueMission(const std::string &srcDeviceId, const std::string &dstDeviceId,
|
||||
|
||||
@@ -1617,7 +1617,7 @@ int AbilityManagerProxy::ForceTimeoutForTest(const std::string &abilityName, con
|
||||
}
|
||||
#endif
|
||||
|
||||
int AbilityManagerProxy::ClearUpApplicationData(const std::string &bundleName)
|
||||
int AbilityManagerProxy::ClearUpApplicationData(const std::string &bundleName, const int32_t userId)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
@@ -1630,6 +1630,10 @@ int AbilityManagerProxy::ClearUpApplicationData(const std::string &bundleName)
|
||||
HILOG_ERROR("bundleName write failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
if (!data.WriteInt32(userId)) {
|
||||
HILOG_ERROR("userId write failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
int error = SendRequest(AbilityManagerInterfaceCode::CLEAR_UP_APPLICATION_DATA, data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("Send request error: %{public}d", error);
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
#include "string_wrapper.h"
|
||||
#include "system_ability_definition.h"
|
||||
#include "system_ability_token_callback.h"
|
||||
#include "ui_extension_ability_connect_manager.h"
|
||||
#include "extension_record_manager.h"
|
||||
#include "ui_extension_utils.h"
|
||||
#include "uri_permission_manager_client.h"
|
||||
#include "view_data.h"
|
||||
@@ -208,6 +208,7 @@ const int32_t BROKER_UID = 5557;
|
||||
const int32_t BROKER_RESERVE_UID = 5005;
|
||||
const int32_t DMS_UID = 5522;
|
||||
const int32_t PREPARE_TERMINATE_TIMEOUT_MULTIPLE = 10;
|
||||
const int32_t BOOTEVENT_COMPLETED_DELAY_TIME = 1000;
|
||||
const std::string BUNDLE_NAME_KEY = "bundleName";
|
||||
const std::string DM_PKG_NAME = "ohos.distributedhardware.devicemanager";
|
||||
const std::string ACTION_CHOOSE = "ohos.want.action.select";
|
||||
@@ -417,9 +418,12 @@ bool AbilityManagerService::Init()
|
||||
};
|
||||
taskHandler_->SubmitTask(initExtensionConfigTask, "InitExtensionConfigTask");
|
||||
|
||||
auto bootCompletedTask = []() {
|
||||
auto bootCompletedTask = [handler = taskHandler_]() {
|
||||
if (ApplicationUtil::IsBootCompleted()) {
|
||||
ApplicationUtil::AppFwkBootEventCallback(BOOTEVENT_BOOT_COMPLETED.c_str(), "true", nullptr);
|
||||
auto task = []() {
|
||||
ApplicationUtil::AppFwkBootEventCallback(BOOTEVENT_BOOT_COMPLETED.c_str(), "true", nullptr);
|
||||
};
|
||||
handler->SubmitTask(task, "BootCompletedDelayTask", BOOTEVENT_COMPLETED_DELAY_TIME);
|
||||
} else {
|
||||
WatchParameter(BOOTEVENT_BOOT_COMPLETED.c_str(), ApplicationUtil::AppFwkBootEventCallback, nullptr);
|
||||
}
|
||||
@@ -5304,11 +5308,11 @@ int AbilityManagerService::KillProcess(const std::string &bundleName)
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int AbilityManagerService::ClearUpApplicationData(const std::string &bundleName)
|
||||
int AbilityManagerService::ClearUpApplicationData(const std::string &bundleName, const int32_t userId)
|
||||
{
|
||||
HILOG_DEBUG("ClearUpApplicationData, bundleName: %{public}s", bundleName.c_str());
|
||||
CHECK_CALLER_IS_SYSTEM_APP;
|
||||
int ret = DelayedSingleton<AppScheduler>::GetInstance()->ClearUpApplicationData(bundleName);
|
||||
int ret = DelayedSingleton<AppScheduler>::GetInstance()->ClearUpApplicationData(bundleName, userId);
|
||||
if (ret != ERR_OK) {
|
||||
return CLEAR_APPLICATION_DATA_FAIL;
|
||||
}
|
||||
|
||||
@@ -653,7 +653,8 @@ int AbilityManagerStub::KillProcessInner(MessageParcel &data, MessageParcel &rep
|
||||
int AbilityManagerStub::ClearUpApplicationDataInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
std::string bundleName = Str16ToStr8(data.ReadString16());
|
||||
int result = ClearUpApplicationData(bundleName);
|
||||
int32_t userId = data.ReadInt32();
|
||||
int result = ClearUpApplicationData(bundleName, userId);
|
||||
if (!reply.WriteInt32(result)) {
|
||||
HILOG_ERROR("ClearUpApplicationData error");
|
||||
return ERR_INVALID_VALUE;
|
||||
|
||||
@@ -242,10 +242,10 @@ int AppScheduler::KillApplicationByUid(const std::string &bundleName, int32_t ui
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int AppScheduler::ClearUpApplicationData(const std::string &bundleName)
|
||||
int AppScheduler::ClearUpApplicationData(const std::string &bundleName, const int32_t userId)
|
||||
{
|
||||
CHECK_POINTER_AND_RETURN(appMgrClient_, INNER_ERR);
|
||||
int ret = (int)appMgrClient_->ClearUpApplicationData(bundleName);
|
||||
int ret = (int)appMgrClient_->ClearUpApplicationData(bundleName, userId);
|
||||
if (ret != ERR_OK) {
|
||||
HILOG_ERROR("Fail to clear application data.");
|
||||
return INNER_ERR;
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "extension_record.h"
|
||||
#include "ability_util.h"
|
||||
#include "errors.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
ExtensionRecord::ExtensionRecord(const std::shared_ptr<AAFwk::AbilityRecord> &abilityRecord,
|
||||
const std::string &hostBundleName, int32_t extensionRecordId)
|
||||
: abilityRecord_(abilityRecord), hostBundleName_(hostBundleName), extensionRecordId_(extensionRecordId)
|
||||
{}
|
||||
|
||||
ExtensionRecord::~ExtensionRecord() = default;
|
||||
|
||||
sptr<IRemoteObject> ExtensionRecord::GetCallToken() const
|
||||
{
|
||||
CHECK_POINTER_AND_RETURN(abilityRecord_, nullptr);
|
||||
auto sessionInfo = abilityRecord_->GetSessionInfo();
|
||||
CHECK_POINTER_AND_RETURN(sessionInfo, nullptr);
|
||||
return sessionInfo->callerToken;
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> ExtensionRecord::GetRootCallerToken() const
|
||||
{
|
||||
return rootCallerToken_;
|
||||
}
|
||||
|
||||
void ExtensionRecord::SetRootCallerToken(sptr<IRemoteObject> &rootCallerToken)
|
||||
{
|
||||
rootCallerToken_ = rootCallerToken;
|
||||
}
|
||||
|
||||
bool ExtensionRecord::ContinueToGetCallerToken()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "extension_record_manager.h"
|
||||
|
||||
#include "ability_util.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "ui_extension_utils.h"
|
||||
#include "ui_extension_record.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
std::atomic_int32_t ExtensionRecordManager::extensionRecordId_ = INVALID_EXTENSION_RECORD_ID;
|
||||
|
||||
ExtensionRecordManager::ExtensionRecordManager(const int32_t userId) : userId_(userId)
|
||||
{
|
||||
HILOG_DEBUG("constructor.");
|
||||
}
|
||||
|
||||
ExtensionRecordManager::~ExtensionRecordManager()
|
||||
{
|
||||
HILOG_INFO("deconstructor.");
|
||||
}
|
||||
|
||||
int32_t ExtensionRecordManager::GenerateExtensionRecordId(const int32_t extensionRecordId)
|
||||
{
|
||||
HILOG_DEBUG("Input id is %{public}d.", extensionRecordId);
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (extensionRecordId != INVALID_EXTENSION_RECORD_ID &&
|
||||
!extensionRecordIdSet_.count(extensionRecordId)) {
|
||||
extensionRecordIdSet_.insert(extensionRecordId);
|
||||
extensionRecordId_ = extensionRecordId;
|
||||
return extensionRecordId_;
|
||||
}
|
||||
|
||||
if (extensionRecordId == INVALID_EXTENSION_RECORD_ID) {
|
||||
++extensionRecordId_;
|
||||
}
|
||||
|
||||
while (extensionRecordIdSet_.count(extensionRecordId_)) {
|
||||
extensionRecordId_++;
|
||||
}
|
||||
|
||||
return extensionRecordId_;
|
||||
}
|
||||
|
||||
void ExtensionRecordManager::AddExtensionRecord(const int32_t extensionRecordId,
|
||||
const std::shared_ptr<ExtensionRecord> &record)
|
||||
{
|
||||
HILOG_DEBUG("extensionRecordId %{public}d.", extensionRecordId);
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
extensionRecords_.emplace(extensionRecordId, record);
|
||||
}
|
||||
|
||||
void ExtensionRecordManager::RemoveExtensionRecord(const int32_t extensionRecordId)
|
||||
{
|
||||
HILOG_DEBUG("extensionRecordId %{public}d.", extensionRecordId);
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
extensionRecords_.erase(extensionRecordId);
|
||||
}
|
||||
|
||||
bool ExtensionRecordManager::CheckExtensionLoaded(const int32_t extensionRecordId,
|
||||
const std::string &hostBundleName)
|
||||
{
|
||||
HILOG_DEBUG("extensionRecordId %{public}d.", extensionRecordId);
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
// find target record firstly
|
||||
auto it = extensionRecords_.find(extensionRecordId);
|
||||
if (it != extensionRecords_.end() && it->second != nullptr) {
|
||||
// check bundleName
|
||||
HILOG_DEBUG("Stored host bundleName: %{public}s, input bundleName is %{public}s.",
|
||||
it->second->hostBundleName_.c_str(), hostBundleName.c_str());
|
||||
if (it->second->hostBundleName_ == hostBundleName) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
HILOG_DEBUG("Not found stored id %{public}d.", extensionRecordId);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ExtensionRecordManager::IsBelongToManager(const AppExecFwk::AbilityInfo &abilityInfo)
|
||||
{
|
||||
// only support UIExtension now
|
||||
return AAFwk::UIExtensionUtils::IsUIExtension(abilityInfo.extensionAbilityType);
|
||||
}
|
||||
|
||||
bool ExtensionRecordManager::IsFocused(int32_t extensionRecordId, const sptr<IRemoteObject>& focusToken)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
sptr<IRemoteObject> rootCallerToken = GetRootCallerTokenLocked(extensionRecordId);
|
||||
bool isFocused = rootCallerToken == focusToken;
|
||||
HILOG_DEBUG("id: %{public}d isFocused: %{public}d.", extensionRecordId, isFocused);
|
||||
return isFocused;
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> ExtensionRecordManager::GetRootCallerTokenLocked(int32_t extensionRecordId)
|
||||
{
|
||||
auto it = extensionRecords_.find(extensionRecordId);
|
||||
if (it != extensionRecords_.end() && it->second != nullptr) {
|
||||
sptr<IRemoteObject> rootCallerToken = it->second->GetRootCallerToken();
|
||||
if (rootCallerToken != nullptr) {
|
||||
return rootCallerToken;
|
||||
}
|
||||
if (!it->second->ContinueToGetCallerToken()) {
|
||||
return it->second->GetCallToken();
|
||||
}
|
||||
auto callerToken = it->second->GetCallToken();
|
||||
if (callerToken == nullptr) {
|
||||
HILOG_ERROR("callerToken is null, id: %{public}d.", extensionRecordId);
|
||||
return nullptr;
|
||||
}
|
||||
auto callerAbilityRecord = AAFwk::Token::GetAbilityRecordByToken(callerToken);
|
||||
if (callerAbilityRecord == nullptr) {
|
||||
HILOG_ERROR("callerAbilityRecord is null, id: %{public}d.", extensionRecordId);
|
||||
return nullptr;
|
||||
}
|
||||
if (callerAbilityRecord->GetUIExtensionAbilityId() == INVALID_EXTENSION_RECORD_ID) {
|
||||
HILOG_DEBUG("update rootCallerToken, id: %{public}d.", extensionRecordId);
|
||||
it->second->SetRootCallerToken(callerToken);
|
||||
return callerToken;
|
||||
}
|
||||
rootCallerToken = GetRootCallerTokenLocked(callerAbilityRecord->GetUIExtensionAbilityId());
|
||||
HILOG_DEBUG("update rootCallerToken, id: %{public}d.", extensionRecordId);
|
||||
it->second->SetRootCallerToken(rootCallerToken);
|
||||
return rootCallerToken;
|
||||
}
|
||||
HILOG_ERROR("Not found id %{public}d.", extensionRecordId);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int32_t ExtensionRecordManager::CreateExtensionRecord(const std::shared_ptr<AAFwk::AbilityRecord> &abilityRecord,
|
||||
const std::string &hostBundleName, int32_t &extensionRecordId)
|
||||
{
|
||||
// factory pattern with ability request
|
||||
if (abilityRecord == nullptr) {
|
||||
HILOG_ERROR("abilityRecord is null");
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
extensionRecordId = GenerateExtensionRecordId(extensionRecordId);
|
||||
if (AAFwk::UIExtensionUtils::IsUIExtension(abilityRecord->GetAbilityInfo().extensionAbilityType)) {
|
||||
std::shared_ptr<ExtensionRecord> extensionRecord = std::make_shared<UIExtensionRecord>(abilityRecord,
|
||||
hostBundleName, extensionRecordId);
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
HILOG_DEBUG("add UIExtension, id %{public}d.", extensionRecordId);
|
||||
extensionRecords_[extensionRecordId] = extensionRecord;
|
||||
abilityRecord->SetUIExtensionAbilityId(extensionRecordId);
|
||||
return ERR_OK;
|
||||
}
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "ability_manager_service.h"
|
||||
#include "ability_util.h"
|
||||
#include "app_gallery_enable_util.h"
|
||||
#include "default_app_interface.h"
|
||||
#include "errors.h"
|
||||
#include "event_report.h"
|
||||
@@ -116,7 +117,7 @@ int ImplicitStartProcessor::ImplicitStartAbility(AbilityRequest &request, int32_
|
||||
HILOG_INFO("hint dialog doesn't generate.");
|
||||
return ERR_IMPLICIT_START_ABILITY_FAIL;
|
||||
}
|
||||
if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
if (AppGalleryEnableUtil::IsEnableAppGallerySelector() && Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
want = sysDialogScheduler->GetSelectorDialogWant(dialogAppInfos, request.want, request.callerToken);
|
||||
return NotifyCreateModalDialog(request, want, userId, dialogAppInfos);
|
||||
}
|
||||
@@ -125,7 +126,7 @@ int ImplicitStartProcessor::ImplicitStartAbility(AbilityRequest &request, int32_
|
||||
abilityMgr->StartAbility(want);
|
||||
return ERR_IMPLICIT_START_ABILITY_FAIL;
|
||||
} else if (dialogAppInfos.size() == 0 && deviceType != STR_PHONE && deviceType != STR_DEFAULT) {
|
||||
if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
if (AppGalleryEnableUtil::IsEnableAppGallerySelector() && Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
std::string type = MatchTypeAndUri(request.want);
|
||||
want = sysDialogScheduler->GetPcSelectorDialogWant(dialogAppInfos, request.want, type,
|
||||
userId, request.callerToken);
|
||||
@@ -167,7 +168,7 @@ int ImplicitStartProcessor::ImplicitStartAbility(AbilityRequest &request, int32_
|
||||
if (deviceType == STR_PHONE || deviceType == STR_DEFAULT) {
|
||||
HILOG_INFO("ImplicitQueryInfos success, Multiple apps to choose.");
|
||||
want = sysDialogScheduler->GetSelectorDialogWant(dialogAppInfos, request.want, request.callerToken);
|
||||
if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
if (AppGalleryEnableUtil::IsEnableAppGallerySelector() && Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
return NotifyCreateModalDialog(request, want, userId, dialogAppInfos);
|
||||
}
|
||||
ret = abilityMgr->StartAbilityAsCaller(want, request.callerToken, nullptr);
|
||||
@@ -183,7 +184,7 @@ int ImplicitStartProcessor::ImplicitStartAbility(AbilityRequest &request, int32_
|
||||
std::string type = MatchTypeAndUri(request.want);
|
||||
|
||||
want = sysDialogScheduler->GetPcSelectorDialogWant(dialogAppInfos, request.want, type, userId, request.callerToken);
|
||||
if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
if (AppGalleryEnableUtil::IsEnableAppGallerySelector() && Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
return NotifyCreateModalDialog(request, want, userId, dialogAppInfos);
|
||||
}
|
||||
ret = abilityMgr->StartAbilityAsCaller(want, request.callerToken, nullptr);
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ui_extension_ability_connect_manager.h"
|
||||
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
std::atomic_int32_t UIExtensionAbilityConnectManager::uiExtensionAbilityId_ = INVALID_UI_EXTENSION_ABILITY_ID;
|
||||
|
||||
UIExtensionAbilityConnectManager::UIExtensionAbilityConnectManager(const int userId) : userId_(userId)
|
||||
{
|
||||
HILOG_DEBUG("constructor.");
|
||||
}
|
||||
|
||||
UIExtensionAbilityConnectManager::~UIExtensionAbilityConnectManager()
|
||||
{
|
||||
HILOG_INFO("deconstructor.");
|
||||
}
|
||||
|
||||
int32_t UIExtensionAbilityConnectManager::GenerateUIExtensionAbilityId(const int32_t uiExtensionAbilityId)
|
||||
{
|
||||
HILOG_DEBUG("Input id is %{public}d.", uiExtensionAbilityId);
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (uiExtensionAbilityId != INVALID_UI_EXTENSION_ABILITY_ID &&
|
||||
!uiExtensionAbilityIdSet_.count(uiExtensionAbilityId)) {
|
||||
uiExtensionAbilityIdSet_.insert(uiExtensionAbilityId);
|
||||
uiExtensionAbilityId_ = uiExtensionAbilityId;
|
||||
return uiExtensionAbilityId_;
|
||||
}
|
||||
|
||||
if (uiExtensionAbilityId == INVALID_UI_EXTENSION_ABILITY_ID) {
|
||||
++uiExtensionAbilityId_;
|
||||
}
|
||||
|
||||
while (uiExtensionAbilityIdSet_.count(uiExtensionAbilityId_)) {
|
||||
uiExtensionAbilityId_++;
|
||||
}
|
||||
|
||||
return uiExtensionAbilityId_;
|
||||
}
|
||||
|
||||
void UIExtensionAbilityConnectManager::AddUIExtensionAbilityRecord(const int32_t uiExtensionAbilityId,
|
||||
const std::shared_ptr<UIExtensionAbilityRecord> record)
|
||||
{
|
||||
HILOG_DEBUG("UIExtensionAbilityId %{public}d.", uiExtensionAbilityId);
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
uiExtensionAbilityRecords_.emplace(uiExtensionAbilityId, record);
|
||||
}
|
||||
|
||||
void UIExtensionAbilityConnectManager::RemoveUIExtensionAbilityRecord(const int32_t uiExtensionAbilityId)
|
||||
{
|
||||
HILOG_DEBUG("UIExtensionAbilityId %{public}d.", uiExtensionAbilityId);
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
uiExtensionAbilityRecords_.erase(uiExtensionAbilityId);
|
||||
}
|
||||
|
||||
bool UIExtensionAbilityConnectManager::CheckUIExtensionAbilityLoaded(const int32_t uiExtensionAbilityId,
|
||||
const std::string hostBundleName)
|
||||
{
|
||||
HILOG_DEBUG("UIExtensionAbilityId %{public}d.", uiExtensionAbilityId);
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
// find target record firstly
|
||||
auto it = uiExtensionAbilityRecords_.find(uiExtensionAbilityId);
|
||||
if (it != uiExtensionAbilityRecords_.end() && it->second != nullptr) {
|
||||
// check bundlename
|
||||
HILOG_DEBUG("Stored host bundleName: %{public}s, input bundleName is %{public}s.",
|
||||
it->second->hostBundleName_.c_str(), hostBundleName.c_str());
|
||||
if (it->second->hostBundleName_ == hostBundleName) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
HILOG_DEBUG("Not found stored id %{public}d.", uiExtensionAbilityId);
|
||||
return false;
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ui_extension_record.h"
|
||||
#include "ability_util.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
UIExtensionRecord::UIExtensionRecord(const std::shared_ptr<AAFwk::AbilityRecord> &abilityRecord,
|
||||
const std::string &hostBundleName, int32_t extensionRecordId)
|
||||
: ExtensionRecord(abilityRecord, hostBundleName, extensionRecordId)
|
||||
{}
|
||||
|
||||
UIExtensionRecord::~UIExtensionRecord() = default;
|
||||
|
||||
bool UIExtensionRecord::ContinueToGetCallerToken()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
@@ -317,7 +317,8 @@ std::string AppfreezeManager::CatcherStacktrace(int pid) const
|
||||
HiviewDFX::DfxDumpCatcher dumplog;
|
||||
std::string ret;
|
||||
std::string msg;
|
||||
if (!dumplog.DumpCatch(pid, 0, msg)) {
|
||||
size_t defaultMaxFaultNum = 256;
|
||||
if (!dumplog.DumpCatch(pid, 0, msg, defaultMaxFaultNum, true)) {
|
||||
ret = "Failed to dump stacktrace for " + std::to_string(pid) + "\n" + msg;
|
||||
} else {
|
||||
ret = msg;
|
||||
|
||||
@@ -113,7 +113,8 @@ public:
|
||||
* @param bundleName, bundle name in Application record.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int32_t ClearUpApplicationData(const std::string &bundleName) override;
|
||||
virtual int32_t ClearUpApplicationData(const std::string &bundleName,
|
||||
const int32_t userId = -1) override;
|
||||
|
||||
/**
|
||||
* GetAllRunningProcesses, call GetAllRunningProcesses() through proxy project.
|
||||
|
||||
@@ -261,7 +261,8 @@ public:
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
virtual void ClearUpApplicationData(const std::string &bundleName, const int32_t callerUid, const pid_t callerPid);
|
||||
virtual void ClearUpApplicationData(const std::string &bundleName,
|
||||
const int32_t callerUid, const pid_t callerPid, const int32_t userId = -1);
|
||||
|
||||
/**
|
||||
* GetAllRunningProcesses, Obtains information about application processes that are running on the device.
|
||||
|
||||
@@ -295,7 +295,7 @@ sptr<IAmsMgr> AppMgrService::GetAmsMgr()
|
||||
return amsMgrScheduler_;
|
||||
}
|
||||
|
||||
int32_t AppMgrService::ClearUpApplicationData(const std::string &bundleName)
|
||||
int32_t AppMgrService::ClearUpApplicationData(const std::string &bundleName, const int32_t userId)
|
||||
{
|
||||
std::shared_ptr<RemoteClientManager> remoteClientManager = std::make_shared<RemoteClientManager>();
|
||||
if(remoteClientManager == nullptr) {
|
||||
@@ -308,19 +308,21 @@ int32_t AppMgrService::ClearUpApplicationData(const std::string &bundleName)
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
int32_t callingUid = IPCSkeleton::GetCallingUid();
|
||||
std::string callerBundleName;
|
||||
auto result = IN_PROCESS_CALL(bundleMgrHelper->GetNameForUid(callingUid, callerBundleName));
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("GetBundleName failed: %{public}d", result);
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
auto isSaCall = AAFwk::PermissionVerification::GetInstance()->IsSACall();
|
||||
if (!isSaCall && bundleName != callerBundleName) {
|
||||
auto isCallingPerm = AAFwk::PermissionVerification::GetInstance()->VerifyCallingPermission(
|
||||
AAFwk::PermissionConstants::PERMISSION_CLEAN_APPLICATION_DATA);
|
||||
if (!isCallingPerm) {
|
||||
HILOG_ERROR("Permission verification failed.");
|
||||
return ERR_PERMISSION_DENIED;
|
||||
if (callingUid != 0 || userId < 0) {
|
||||
std::string callerBundleName;
|
||||
auto result = IN_PROCESS_CALL(bundleMgrHelper->GetNameForUid(callingUid, callerBundleName));
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("GetBundleName failed: %{public}d.", result);
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
auto isSaCall = AAFwk::PermissionVerification::GetInstance()->IsSACall();
|
||||
if (!isSaCall && bundleName != callerBundleName) {
|
||||
auto isCallingPerm = AAFwk::PermissionVerification::GetInstance()->VerifyCallingPermission(
|
||||
AAFwk::PermissionConstants::PERMISSION_CLEAN_APPLICATION_DATA);
|
||||
if (!isCallingPerm) {
|
||||
HILOG_ERROR("Permission verification failed");
|
||||
return ERR_PERMISSION_DENIED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,7 +332,7 @@ int32_t AppMgrService::ClearUpApplicationData(const std::string &bundleName)
|
||||
int32_t uid = IPCSkeleton::GetCallingUid();
|
||||
pid_t pid = IPCSkeleton::GetCallingPid();
|
||||
std::function<void()> clearUpApplicationDataFunc =
|
||||
std::bind(&AppMgrServiceInner::ClearUpApplicationData, appMgrServiceInner_, bundleName, uid, pid);
|
||||
std::bind(&AppMgrServiceInner::ClearUpApplicationData, appMgrServiceInner_, bundleName, uid, pid, userId);
|
||||
taskHandler_->SubmitTask(clearUpApplicationDataFunc, TASK_CLEAR_UP_APPLICATION_DATA);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
@@ -170,6 +170,8 @@ constexpr int32_t BLUETOOTH_GROUPID = 1002;
|
||||
constexpr int32_t NETSYS_SOCKET_GROUPID = 1097;
|
||||
#endif
|
||||
|
||||
constexpr int32_t DEFAULT_INVAL_VALUE = -1;
|
||||
|
||||
int32_t GetUserIdByUid(int32_t uid)
|
||||
{
|
||||
return uid / BASE_USER_RANGE;
|
||||
@@ -1037,12 +1039,16 @@ int32_t AppMgrServiceInner::KillApplicationByUserIdLocked(const std::string &bun
|
||||
return result;
|
||||
}
|
||||
|
||||
void AppMgrServiceInner::ClearUpApplicationData(const std::string &bundleName, int32_t callerUid, pid_t callerPid)
|
||||
void AppMgrServiceInner::ClearUpApplicationData(const std::string &bundleName,
|
||||
int32_t callerUid, pid_t callerPid, const int32_t userId)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
auto userId = GetUserIdByUid(callerUid);
|
||||
int32_t newUserId = userId;
|
||||
if (userId == DEFAULT_INVAL_VALUE) {
|
||||
newUserId = GetUserIdByUid(callerUid);
|
||||
}
|
||||
HILOG_INFO("userId:%{public}d", userId);
|
||||
ClearUpApplicationDataByUserId(bundleName, callerUid, callerPid, userId);
|
||||
ClearUpApplicationDataByUserId(bundleName, callerUid, callerPid, newUserId);
|
||||
}
|
||||
|
||||
void AppMgrServiceInner::ClearUpApplicationDataByUserId(
|
||||
@@ -1052,7 +1058,7 @@ void AppMgrServiceInner::ClearUpApplicationDataByUserId(
|
||||
HILOG_ERROR("invalid callerPid:%{public}d", callerPid);
|
||||
return;
|
||||
}
|
||||
if (callerUid <= 0) {
|
||||
if (callerUid < 0) {
|
||||
HILOG_ERROR("invalid callerUid:%{public}d", callerUid);
|
||||
return;
|
||||
}
|
||||
@@ -4318,7 +4324,7 @@ int32_t AppMgrServiceInner::NotifyAppFault(const FaultData &faultData)
|
||||
.bundleName = bundleName,
|
||||
.processName = bundleName,
|
||||
};
|
||||
AppExecFwk::AppfreezeManager::GetInstance()->AppfreezeHandle(faultData, info);
|
||||
AppExecFwk::AppfreezeManager::GetInstance()->AppfreezeHandleWithStack(faultData, info);
|
||||
}
|
||||
|
||||
HILOG_WARN("FaultData is: name: %{public}s, faultType: %{public}d, uid: %{public}d, pid: %{public}d,"
|
||||
|
||||
+1
-1
@@ -188,7 +188,7 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ClearUpApplicationData(const std::string& bundleName) override
|
||||
int ClearUpApplicationData(const std::string& bundleName, const int32_t userId = DEFAULT_INVAL_VALUE) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -177,7 +177,7 @@ public:
|
||||
|
||||
int UninstallApp(const std::string& bundleName, int32_t uid) override;
|
||||
|
||||
int ClearUpApplicationData(const std::string& bundleName) override
|
||||
int ClearUpApplicationData(const std::string& bundleName, const int32_t userId = DEFAULT_INVAL_VALUE) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
+2
-2
@@ -116,7 +116,7 @@ public:
|
||||
MOCK_METHOD2(MoveMissionToFront, int(int32_t missionId, const StartOptions& startOptions));
|
||||
MOCK_METHOD2(MoveMissionsToForeground, int(const std::vector<int32_t>& missionIds, int32_t topMissionId));
|
||||
MOCK_METHOD2(MoveMissionsToBackground, int(const std::vector<int32_t>& missionIds, std::vector<int32_t>& result));
|
||||
MOCK_METHOD1(ClearUpApplicationData, int(const std::string&));
|
||||
MOCK_METHOD2(ClearUpApplicationData, int(const std::string&, int32_t userId));
|
||||
MOCK_METHOD1(GetAbilityRunningInfos, int(std::vector<AbilityRunningInfo>& info));
|
||||
MOCK_METHOD2(GetExtensionRunningInfos, int(int upperLimit, std::vector<ExtensionRunningInfo>& info));
|
||||
MOCK_METHOD1(GetProcessRunningInfos, int(std::vector<AppExecFwk::RunningProcessInfo>& info));
|
||||
@@ -296,7 +296,7 @@ public:
|
||||
MOCK_METHOD2(MoveMissionToFront, int(int32_t missionId, const StartOptions& startOptions));
|
||||
MOCK_METHOD2(MoveMissionsToForeground, int(const std::vector<int32_t>& missionIds, int32_t topMissionId));
|
||||
MOCK_METHOD2(MoveMissionsToBackground, int(const std::vector<int32_t>& missionIds, std::vector<int32_t>& result));
|
||||
MOCK_METHOD1(ClearUpApplicationData, int(const std::string&));
|
||||
MOCK_METHOD2(ClearUpApplicationData, int(const std::string&, int32_t userId));
|
||||
MOCK_METHOD1(GetAbilityRunningInfos, int(std::vector<AbilityRunningInfo>& info));
|
||||
MOCK_METHOD2(GetExtensionRunningInfos, int(int upperLimit, std::vector<ExtensionRunningInfo>& info));
|
||||
MOCK_METHOD1(GetProcessRunningInfos, int(std::vector<AppExecFwk::RunningProcessInfo>& info));
|
||||
|
||||
@@ -169,7 +169,7 @@ public:
|
||||
MOCK_METHOD1(BlockAbility, int(int32_t abilityRecordId));
|
||||
#endif
|
||||
|
||||
int ClearUpApplicationData(const std::string& bundleName) override
|
||||
int ClearUpApplicationData(const std::string& bundleName, const int32_t userId = DEFAULT_INVAL_VALUE) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ClearUpApplicationData(const std::string& bundleName) override
|
||||
int ClearUpApplicationData(const std::string& bundleName, const int32_t userId = DEFAULT_INVAL_VALUE) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ AppMgrResultCode AppMgrClient::KillApplication(const std::string& bundleName)
|
||||
return AppMgrResultCode::RESULT_OK;
|
||||
}
|
||||
|
||||
AppMgrResultCode AppMgrClient::ClearUpApplicationData(const std::string& bundleName)
|
||||
AppMgrResultCode AppMgrClient::ClearUpApplicationData(const std::string& bundleName, const int32_t userId)
|
||||
{
|
||||
return AppMgrResultCode::RESULT_OK;
|
||||
}
|
||||
|
||||
+1
-1
@@ -130,7 +130,7 @@ void AppScheduler::OnAppStateChanged(const AppExecFwk::AppProcessData& appData)
|
||||
HILOG_INFO("Test AppScheduler::OnAppStateChanged()");
|
||||
}
|
||||
|
||||
int AppScheduler::ClearUpApplicationData(const std::string& bundleName)
|
||||
int AppScheduler::ClearUpApplicationData(const std::string& bundleName, const int32_t userId)
|
||||
{
|
||||
HILOG_INFO("Test AppScheduler::ClearUpApplicationData()");
|
||||
return ERR_OK;
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
MOCK_METHOD0(GetAmsMgr, sptr<IAmsMgr>());
|
||||
MOCK_METHOD1(GetAppFreezingTime, void(int& time));
|
||||
MOCK_METHOD1(SetAppFreezingTime, void(int time));
|
||||
MOCK_METHOD1(ClearUpApplicationData, int32_t(const std::string& bundleName));
|
||||
MOCK_METHOD2(ClearUpApplicationData, int32_t(const std::string& bundleName, int32_t userId));
|
||||
MOCK_METHOD1(StartupResidentProcess, void(const std::vector<AppExecFwk::BundleInfo>& bundleInfos));
|
||||
MOCK_METHOD1(AddAbilityStageDone, void(const int32_t recordId));
|
||||
MOCK_METHOD0(PreStartNWebSpawnProcess, int());
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
MOCK_METHOD1(KillApplication, int32_t(const std::string& bundleName));
|
||||
MOCK_METHOD2(KillApplicationByUid, int(const std::string&, const int uid));
|
||||
MOCK_METHOD1(AbilityTerminated, void(const sptr<IRemoteObject>& token));
|
||||
MOCK_METHOD3(ClearUpApplicationData, void(const std::string&, const int32_t, const pid_t));
|
||||
MOCK_METHOD4(ClearUpApplicationData, void(const std::string&, const int32_t, const pid_t, int32_t userId));
|
||||
MOCK_METHOD1(IsBackgroundRunningRestricted, int32_t(const std::string&));
|
||||
MOCK_METHOD1(GetAllRunningProcesses, int32_t(std::vector<RunningProcessInfo>&));
|
||||
MOCK_METHOD1(GetAllRenderProcesses, int32_t(std::vector<RenderProcessInfo>&));
|
||||
|
||||
@@ -75,7 +75,7 @@ protected:
|
||||
class MockMockAppMgrService : public MockAppMgrService {
|
||||
public:
|
||||
MOCK_METHOD0(GetAmsMgr, sptr<IAmsMgr>());
|
||||
MOCK_METHOD1(ClearUpApplicationData, int32_t(const std::string&));
|
||||
MOCK_METHOD2(ClearUpApplicationData, int32_t(const std::string&, int32_t userId));
|
||||
MOCK_METHOD1(IsBackgroundRunningRestricted, int(const std::string& appName));
|
||||
MOCK_METHOD1(GetAllRunningProcesses, int(std::vector<RunningProcessInfo>&));
|
||||
};
|
||||
|
||||
@@ -58,7 +58,7 @@ void AmsIpcAppmgrModuleTest::TearDown()
|
||||
class MockMockAppMgrService : public MockAppMgrService {
|
||||
public:
|
||||
MOCK_METHOD0(GetAmsMgr, sptr<IAmsMgr>());
|
||||
MOCK_METHOD1(ClearUpApplicationData, int32_t(const std::string&));
|
||||
MOCK_METHOD2(ClearUpApplicationData, int32_t(const std::string&, int32_t userId));
|
||||
MOCK_METHOD1(IsBackgroundRunningRestricted, int(const std::string& bundleName));
|
||||
MOCK_METHOD1(GetAllRunningProcesses, int(std::vector<RunningProcessInfo>&));
|
||||
};
|
||||
@@ -216,13 +216,13 @@ HWTEST_F(AmsIpcAppmgrModuleTest, ExcuteAppmgrIPCInterface_007, TestSize.Level3)
|
||||
std::string testBundleName("testApp");
|
||||
bool testResult = false;
|
||||
|
||||
auto mockHandler = [&](const std::string& name) {
|
||||
auto mockHandler = [&](const std::string& name, const int32_t userId) {
|
||||
testResult = (name == testBundleName);
|
||||
mockMockAppMgr->Post();
|
||||
return 0;
|
||||
};
|
||||
|
||||
EXPECT_CALL(*mockMockAppMgr, ClearUpApplicationData(_)).WillOnce(Invoke(mockHandler));
|
||||
EXPECT_CALL(*mockMockAppMgr, ClearUpApplicationData(_, _)).WillOnce(Invoke(mockHandler));
|
||||
|
||||
appMgrClient->ClearUpApplicationData(testBundleName);
|
||||
mockMockAppMgr->Wait();
|
||||
|
||||
@@ -213,7 +213,7 @@ public:
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int ClearUpApplicationData(const std::string& bundleName) override
|
||||
int ClearUpApplicationData(const std::string& bundleName, const int32_t userId = DEFAULT_INVAL_VALUE) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public:
|
||||
MOCK_METHOD2(SetMissionLabel, int(const sptr<IRemoteObject>& token, const std::string& label));
|
||||
MOCK_METHOD2(SetMissionIcon, int(const sptr<IRemoteObject>& token,
|
||||
const std::shared_ptr<OHOS::Media::PixelMap>& icon));
|
||||
MOCK_METHOD1(ClearUpApplicationData, int(const std::string&));
|
||||
MOCK_METHOD2(ClearUpApplicationData, int(const std::string&, int32_t userId));
|
||||
|
||||
MOCK_METHOD2(GetWantSenderInfo, int(const sptr<IWantSender>& target, std::shared_ptr<WantSenderInfo>& info));
|
||||
|
||||
|
||||
@@ -139,6 +139,8 @@ ohos_source_set("abilityms_test_source") {
|
||||
"${ability_runtime_services_path}/abilitymgr/src/data_ability_record.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/dialog_session_record.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/dlp_state_item.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/extension_record_manager.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/free_install_manager.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/insight_intent_execute_manager.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/insight_intent_profile.cpp",
|
||||
@@ -154,6 +156,7 @@ ohos_source_set("abilityms_test_source") {
|
||||
"${ability_runtime_services_path}/abilitymgr/src/start_ability_handler.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/start_ability_handler/start_ability_sandbox_savefile.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/task_data_persistence_mgr.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/ui_extension_record.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/user_controller.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/user_event_handler.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/want_receiver_proxy.cpp",
|
||||
|
||||
@@ -3082,14 +3082,71 @@ HWTEST_F(AbilityConnectManagerTest, IsUIExtensionFocused_001, TestSize.Level1)
|
||||
bool isFocused = connectManager->IsUIExtensionFocused(
|
||||
serviceRecord_->GetApplicationInfo().accessTokenId, serviceRecord1_->GetToken());
|
||||
EXPECT_EQ(isFocused, false);
|
||||
connectManager.reset();
|
||||
}
|
||||
|
||||
sptr<SessionInfo> sessionInfo = new (std::nothrow) SessionInfo();
|
||||
sessionInfo->callerToken = serviceRecord1_->GetToken();
|
||||
/*
|
||||
* Feature: AbilityConnectManager
|
||||
* Function: IsUIExtensionFocused
|
||||
* SubFunction: IsUIExtensionFocused
|
||||
* FunctionPoints: NA
|
||||
* EnvConditions: NA
|
||||
* CaseDescription: Verify AbilityConnectManager IsUIExtensionFocused
|
||||
*/
|
||||
HWTEST_F(AbilityConnectManagerTest, IsUIExtensionFocused_002, TestSize.Level1)
|
||||
{
|
||||
std::shared_ptr<AbilityConnectManager> connectManager = std::make_shared<AbilityConnectManager>(3);
|
||||
ASSERT_NE(connectManager, nullptr);
|
||||
connectManager->uiExtensionMap_.clear();
|
||||
|
||||
std::string device = "device";
|
||||
std::string abilityName = "uiExtensionUserAbility";
|
||||
std::string appName = "uiExtensionUser";
|
||||
std::string bundleName = "com.ix.uiExtensionUser";
|
||||
std::string moduleName = "entry";
|
||||
auto request = GenerateAbilityRequest(device, abilityName, appName, bundleName, moduleName);
|
||||
auto uiExtensionUser = AbilityRecord::CreateAbilityRecord(request);
|
||||
EXPECT_NE(uiExtensionUser, nullptr);
|
||||
|
||||
std::string abilityName1 = "uiExtensionAbility1";
|
||||
std::string appName1 = "uiExtensionProvider1";
|
||||
std::string bundleName1 = "com.ix.uiExtensionProvider1";
|
||||
std::string moduleName1 = "entry";
|
||||
auto request1 = GenerateAbilityRequest(device, abilityName1, appName1, bundleName1, moduleName1);
|
||||
auto uiExtension1 = AbilityRecord::CreateAbilityRecord(request1);
|
||||
EXPECT_NE(uiExtension1, nullptr);
|
||||
uiExtension1->abilityInfo_.extensionAbilityType = ExtensionAbilityType::SYS_COMMON_UI;
|
||||
sptr<SessionInfo> sessionInfo1 = new (std::nothrow) SessionInfo();
|
||||
sessionInfo1->callerToken = uiExtensionUser->GetToken();
|
||||
uiExtension1->sessionInfo_ = sessionInfo1;
|
||||
connectManager->uiExtensionMap_.emplace(
|
||||
callbackA_->AsObject(), AbilityConnectManager::UIExtWindowMapValType(serviceRecord_, sessionInfo));
|
||||
isFocused = connectManager->IsUIExtensionFocused(
|
||||
serviceRecord_->GetApplicationInfo().accessTokenId, serviceRecord1_->GetToken());
|
||||
EXPECT_EQ(isFocused, true);
|
||||
callbackA_->AsObject(), AbilityConnectManager::UIExtWindowMapValType(uiExtension1, sessionInfo1));
|
||||
int32_t extensionId1 = 1;
|
||||
int32_t ret = connectManager->uiExtensionAbilityRecordMgr_->CreateExtensionRecord(uiExtension1, "", extensionId1);
|
||||
EXPECT_EQ(ret, ERR_OK);
|
||||
bool isFocused1 = connectManager->IsUIExtensionFocused(
|
||||
uiExtension1->GetApplicationInfo().accessTokenId, uiExtensionUser->GetToken());
|
||||
EXPECT_EQ(isFocused1, true);
|
||||
|
||||
std::string abilityName2 = "uiExtensionAbility2";
|
||||
std::string appName2 = "uiExtensionProvider2";
|
||||
std::string bundleName2 = "com.ix.uiExtensionProvider2";
|
||||
std::string moduleName2 = "entry";
|
||||
auto request2 = GenerateAbilityRequest(device, abilityName2, appName2, bundleName2, moduleName2);
|
||||
auto uiExtension2 = AbilityRecord::CreateAbilityRecord(request2);
|
||||
EXPECT_NE(uiExtension2, nullptr);
|
||||
uiExtension2->abilityInfo_.extensionAbilityType = ExtensionAbilityType::SYS_COMMON_UI;
|
||||
sptr<SessionInfo> sessionInfo2 = new (std::nothrow) SessionInfo();
|
||||
sessionInfo2->callerToken = uiExtension1->GetToken();
|
||||
uiExtension2->sessionInfo_ = sessionInfo2;
|
||||
connectManager->uiExtensionMap_.emplace(
|
||||
callbackA_->AsObject(), AbilityConnectManager::UIExtWindowMapValType(uiExtension2, sessionInfo2));
|
||||
int32_t extensionId2 = 2;
|
||||
ret = connectManager->uiExtensionAbilityRecordMgr_->CreateExtensionRecord(uiExtension2, "", extensionId2);
|
||||
EXPECT_EQ(ret, ERR_OK);
|
||||
bool isFocused2 = connectManager->IsUIExtensionFocused(
|
||||
uiExtension2->GetApplicationInfo().accessTokenId, uiExtensionUser->GetToken());
|
||||
EXPECT_EQ(isFocused2, true);
|
||||
connectManager.reset();
|
||||
}
|
||||
|
||||
|
||||
@@ -220,7 +220,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
int ClearUpApplicationData(const std::string& bundleName) override
|
||||
int ClearUpApplicationData(const std::string& bundleName, const int32_t userId = DEFAULT_INVAL_VALUE) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
int ClearUpApplicationData(const std::string& bundleName) override
|
||||
int ClearUpApplicationData(const std::string& bundleName, const int32_t userId = DEFAULT_INVAL_VALUE) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ClearUpApplicationData(const std::string& bundleName) override
|
||||
int ClearUpApplicationData(const std::string& bundleName, const int32_t userId = DEFAULT_INVAL_VALUE) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
int ClearUpApplicationData(const std::string& bundleName) override
|
||||
int ClearUpApplicationData(const std::string& bundleName, const int32_t userId = DEFAULT_INVAL_VALUE) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -424,7 +424,7 @@ HWTEST_F(AmsAppMgrClientTest, AppMgrClient_014, TestSize.Level1)
|
||||
sptr<IRemoteObject> token;
|
||||
EXPECT_EQ(AppMgrResultCode::RESULT_OK, client_->ConnectAppMgrService());
|
||||
EXPECT_CALL(*(static_cast<MockAppMgrService*>((iface_cast<IAppMgr>(client_->GetRemoteObject())).GetRefPtr())),
|
||||
ClearUpApplicationData(_))
|
||||
ClearUpApplicationData(_, _))
|
||||
.Times(1)
|
||||
.WillOnce(Return(ERR_NO_MEMORY));
|
||||
EXPECT_EQ(AppMgrResultCode::ERROR_SERVICE_NOT_READY, client_->ClearUpApplicationData("com.test"));
|
||||
@@ -444,7 +444,7 @@ HWTEST_F(AmsAppMgrClientTest, AppMgrClient_015, TestSize.Level1)
|
||||
EXPECT_EQ(AppMgrResultCode::RESULT_OK, client_->ConnectAppMgrService());
|
||||
sptr<IAppMgr> appMgr(new MockAppMgrService());
|
||||
EXPECT_CALL(*(static_cast<MockAppMgrService*>((iface_cast<IAppMgr>(client_->GetRemoteObject())).GetRefPtr())),
|
||||
ClearUpApplicationData(_))
|
||||
ClearUpApplicationData(_, _))
|
||||
.Times(1)
|
||||
.WillOnce(Return(ERR_OK));
|
||||
EXPECT_EQ(AppMgrResultCode::RESULT_OK, client_->ClearUpApplicationData("com.test"));
|
||||
|
||||
@@ -206,7 +206,7 @@ HWTEST_F(AmsIpcAppMgrInterfaceTest, ClearUpApplicationData_008, TestSize.Level1)
|
||||
sptr<MockAppMgrService> mockAppMgr(new MockAppMgrService());
|
||||
sptr<IAppMgr> appMgrClient = iface_cast<IAppMgr>(mockAppMgr);
|
||||
|
||||
EXPECT_CALL(*mockAppMgr, ClearUpApplicationData(_)).Times(1);
|
||||
EXPECT_CALL(*mockAppMgr, ClearUpApplicationData(_, _)).Times(1);
|
||||
|
||||
appMgrClient->ClearUpApplicationData("PROCESS");
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
MOCK_METHOD0(UpdateApplicationInfoInstalledDone, AppMgrResultCode());
|
||||
MOCK_METHOD1(KillApplication, AppMgrResultCode(const std::string&));
|
||||
MOCK_METHOD2(KillApplicationByUid, AppMgrResultCode(const std::string &bundleName, const int uid));
|
||||
MOCK_METHOD1(ClearUpApplicationData, AppMgrResultCode(const std::string&));
|
||||
MOCK_METHOD2(ClearUpApplicationData, AppMgrResultCode(const std::string&, int32_t userId));
|
||||
MOCK_METHOD1(StartupResidentProcess, void(const std::vector<AppExecFwk::BundleInfo> &bundleInfos));
|
||||
MOCK_METHOD2(StartSpecifiedAbility, void(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo));
|
||||
MOCK_METHOD1(GetAllRunningProcesses, AppMgrResultCode(std::vector<RunningProcessInfo> &info));
|
||||
|
||||
@@ -724,7 +724,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_KillApplicationByUid_002, TestSize.Level
|
||||
*/
|
||||
HWTEST_F(AppSchedulerTest, AppScheduler_ClearUpApplicationData_001, TestSize.Level1)
|
||||
{
|
||||
EXPECT_CALL(*clientMock_, ClearUpApplicationData(_)).Times(1)
|
||||
EXPECT_CALL(*clientMock_, ClearUpApplicationData(_, _)).Times(1)
|
||||
.WillOnce(Return(AppMgrResultCode::ERROR_SERVICE_NOT_READY));
|
||||
DelayedSingleton<AppScheduler>::GetInstance()->appMgrClient_ = std::move(clientMock_);
|
||||
std::string bundleName = "bundleName";
|
||||
@@ -742,7 +742,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_ClearUpApplicationData_001, TestSize.Lev
|
||||
*/
|
||||
HWTEST_F(AppSchedulerTest, AppScheduler_ClearUpApplicationData_002, TestSize.Level1)
|
||||
{
|
||||
EXPECT_CALL(*clientMock_, ClearUpApplicationData(_)).Times(1)
|
||||
EXPECT_CALL(*clientMock_, ClearUpApplicationData(_, _)).Times(1)
|
||||
.WillOnce(Return(AppMgrResultCode::RESULT_OK));
|
||||
DelayedSingleton<AppScheduler>::GetInstance()->appMgrClient_ = std::move(clientMock_);
|
||||
std::string bundleName = "bundleName";
|
||||
|
||||
@@ -128,7 +128,7 @@ class MockAppMgrStub : public AppMgrStub {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int32_t ClearUpApplicationData(const std::string &bundleName) override
|
||||
int32_t ClearUpApplicationData(const std::string &bundleName, const int32_t userId) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
int ClearUpApplicationData(const std::string& bundleName) override
|
||||
int ClearUpApplicationData(const std::string& bundleName, const int32_t userId = DEFAULT_INVAL_VALUE) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ public:
|
||||
MOCK_METHOD1(BlockAbility, int(int32_t abilityRecordId));
|
||||
#endif
|
||||
|
||||
int ClearUpApplicationData(const std::string& bundleName) override
|
||||
int ClearUpApplicationData(const std::string& bundleName, const int32_t userId = DEFAULT_INVAL_VALUE) override
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ public:
|
||||
MOCK_METHOD2(SetMissionLabel, int(const sptr<IRemoteObject>& token, const std::string& label));
|
||||
MOCK_METHOD2(SetMissionIcon, int(const sptr<IRemoteObject>& token,
|
||||
const std::shared_ptr<OHOS::Media::PixelMap>& icon));
|
||||
MOCK_METHOD1(ClearUpApplicationData, int(const std::string&));
|
||||
MOCK_METHOD2(ClearUpApplicationData, int(const std::string&, int32_t userId));
|
||||
MOCK_METHOD1(GetAbilityRunningInfos, int(std::vector<AbilityRunningInfo>& info));
|
||||
MOCK_METHOD2(GetExtensionRunningInfos, int(int upperLimit, std::vector<ExtensionRunningInfo>& info));
|
||||
MOCK_METHOD1(GetProcessRunningInfos, int(std::vector<AppExecFwk::RunningProcessInfo>& info));
|
||||
|
||||
Reference in New Issue
Block a user