mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-11-27 09:21:28 +00:00
Merge branch 'master1' into FA
Change-Id: I2151b59cfb2257f31266ce8dbba4ce9b5c66230f
This commit is contained in:
commit
8426913511
@ -47,6 +47,7 @@ template("abilitymanager") {
|
||||
"ability_runtime:runtime",
|
||||
"access_token:libtokenid_sdk",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
|
@ -52,6 +52,7 @@ template("delegator") {
|
||||
"ability_runtime:abilitykit_native",
|
||||
"ability_runtime:runtime",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
@ -38,6 +38,7 @@ ohos_shared_library("appmanager_napi") {
|
||||
"ability_runtime:app_manager",
|
||||
"ability_runtime:runtime",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"napi:ace_napi",
|
||||
|
@ -42,6 +42,7 @@ ohos_shared_library("appmanager") {
|
||||
"ability_runtime:app_manager",
|
||||
"ability_runtime:runtime",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"napi:ace_napi",
|
||||
|
@ -43,6 +43,7 @@ ohos_shared_library("apprecovery_napi") {
|
||||
"ability_runtime:app_manager",
|
||||
"ability_runtime:runtime",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
@ -53,6 +53,7 @@ ohos_shared_library("featureability") {
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
|
@ -33,6 +33,7 @@ ohos_shared_library("featureability_napi") {
|
||||
"ability_runtime:abilitykit_native",
|
||||
"ability_runtime:runtime",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
@ -43,6 +43,7 @@ ohos_shared_library("napi_ability_common") {
|
||||
"access_token:libtokenid_sdk",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi_common",
|
||||
|
@ -126,10 +126,9 @@ public:
|
||||
bool GetPermissionOptions(NativeEngine &engine, NativeValue *object, JsPermissionOptions &options);
|
||||
std::string ConvertErrorCode(int32_t errCode);
|
||||
void AddFreeInstallObserver(NativeEngine& engine, const AAFwk::Want &want, NativeValue* callback);
|
||||
void GenerateCallback(const napi_env &env, const napi_value &arg1, ConnectionCallback &callback);
|
||||
sptr<NAPIAbilityConnection> FindConnectionLocked(const Want &want, int64_t &id);
|
||||
bool CreateConnectionAndConnectAbilityLocked(
|
||||
const ConnectionCallback &callback, const Want &want, int64_t &id);
|
||||
std::shared_ptr<ConnectionCallback> callback, const Want &want, int64_t &id);
|
||||
void RemoveConnectionLocked(const Want &want);
|
||||
Ability *ability_;
|
||||
sptr<AbilityRuntime::JsFreeInstallObserver> freeInstallObserver_ = nullptr;
|
||||
|
@ -3254,7 +3254,7 @@ napi_value NAPI_StopAbilityCommon(napi_env env, napi_callback_info info, Ability
|
||||
return ret;
|
||||
}
|
||||
|
||||
void NAPIAbilityConnection::AddConnectionCallback(const ConnectionCallback &callback)
|
||||
void NAPIAbilityConnection::AddConnectionCallback(std::shared_ptr<ConnectionCallback> callback)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(lock_);
|
||||
callbacks_.emplace_back(callback);
|
||||
@ -3281,46 +3281,47 @@ size_t NAPIAbilityConnection::GetCallbackSize()
|
||||
void UvWorkOnAbilityConnectDone(uv_work_t *work, int status)
|
||||
{
|
||||
HILOG_INFO("UvWorkOnAbilityConnectDone, uv_queue_work");
|
||||
std::unique_ptr<uv_work_t> managedWork(work);
|
||||
if (work == nullptr) {
|
||||
HILOG_ERROR("UvWorkOnAbilityConnectDone, work is null");
|
||||
return;
|
||||
}
|
||||
// JS Thread
|
||||
ConnectAbilityCB *connectAbilityCB = static_cast<ConnectAbilityCB *>(work->data);
|
||||
std::unique_ptr<ConnectAbilityCB> connectAbilityCB(static_cast<ConnectAbilityCB *>(work->data));
|
||||
if (connectAbilityCB == nullptr) {
|
||||
HILOG_ERROR("UvWorkOnAbilityConnectDone, connectAbilityCB is null");
|
||||
return;
|
||||
}
|
||||
CallbackInfo &cbInfo = connectAbilityCB->cbBase.cbInfo;
|
||||
napi_handle_scope scope = nullptr;
|
||||
napi_open_handle_scope(cbInfo.env, &scope);
|
||||
if (scope == nullptr) {
|
||||
HILOG_ERROR("napi_open_handle_scope failed");
|
||||
return;
|
||||
}
|
||||
napi_value result[ARGS_TWO] = {nullptr};
|
||||
result[PARAM0] =
|
||||
WrapElementName(connectAbilityCB->cbBase.cbInfo.env, connectAbilityCB->abilityConnectionCB.elementName);
|
||||
WrapElementName(cbInfo.env, connectAbilityCB->abilityConnectionCB.elementName);
|
||||
napi_value jsRemoteObject = NAPI_ohos_rpc_CreateJsRemoteObject(
|
||||
connectAbilityCB->cbBase.cbInfo.env, connectAbilityCB->abilityConnectionCB.connection);
|
||||
cbInfo.env, connectAbilityCB->abilityConnectionCB.connection);
|
||||
result[PARAM1] = jsRemoteObject;
|
||||
|
||||
napi_value callback = nullptr;
|
||||
napi_value undefined = nullptr;
|
||||
napi_get_undefined(connectAbilityCB->cbBase.cbInfo.env, &undefined);
|
||||
napi_get_undefined(cbInfo.env, &undefined);
|
||||
napi_value callResult = nullptr;
|
||||
napi_get_reference_value(connectAbilityCB->cbBase.cbInfo.env, connectAbilityCB->cbBase.cbInfo.callback, &callback);
|
||||
napi_get_reference_value(cbInfo.env, cbInfo.callback, &callback);
|
||||
|
||||
napi_call_function(
|
||||
connectAbilityCB->cbBase.cbInfo.env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult);
|
||||
if (connectAbilityCB->cbBase.cbInfo.callback != nullptr) {
|
||||
napi_delete_reference(connectAbilityCB->cbBase.cbInfo.env, connectAbilityCB->cbBase.cbInfo.callback);
|
||||
}
|
||||
if (connectAbilityCB != nullptr) {
|
||||
delete connectAbilityCB;
|
||||
connectAbilityCB = nullptr;
|
||||
}
|
||||
if (work != nullptr) {
|
||||
delete work;
|
||||
work = nullptr;
|
||||
cbInfo.env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult);
|
||||
if (cbInfo.callback != nullptr) {
|
||||
napi_delete_reference(cbInfo.env, cbInfo.callback);
|
||||
}
|
||||
napi_close_handle_scope(cbInfo.env, scope);
|
||||
HILOG_INFO("UvWorkOnAbilityConnectDone, uv_queue_work end");
|
||||
}
|
||||
|
||||
void NAPIAbilityConnection::HandleOnAbilityConnectDone(const ConnectionCallback &callback, int resultCode)
|
||||
void NAPIAbilityConnection::HandleOnAbilityConnectDone(ConnectionCallback &callback, int resultCode)
|
||||
{
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
uv_loop_s *loop = nullptr;
|
||||
@ -3347,6 +3348,7 @@ void NAPIAbilityConnection::HandleOnAbilityConnectDone(const ConnectionCallback
|
||||
}
|
||||
connectAbilityCB->cbBase.cbInfo.env = callback.env;
|
||||
connectAbilityCB->cbBase.cbInfo.callback = callback.connectCallbackRef;
|
||||
callback.connectCallbackRef = nullptr;
|
||||
connectAbilityCB->abilityConnectionCB.elementName = element_;
|
||||
connectAbilityCB->abilityConnectionCB.resultCode = resultCode;
|
||||
connectAbilityCB->abilityConnectionCB.connection = serviceRemoteObject_;
|
||||
@ -3379,7 +3381,7 @@ void NAPIAbilityConnection::OnAbilityConnectDone(
|
||||
element_ = element;
|
||||
serviceRemoteObject_ = remoteObject;
|
||||
for (const auto &callback : callbacks_) {
|
||||
HandleOnAbilityConnectDone(callback, resultCode);
|
||||
HandleOnAbilityConnectDone(*callback, resultCode);
|
||||
}
|
||||
connectionState_ = CONNECTION_STATE_CONNECTED;
|
||||
HILOG_INFO("%{public}s, end.", __func__);
|
||||
@ -3388,17 +3390,24 @@ void NAPIAbilityConnection::OnAbilityConnectDone(
|
||||
void UvWorkOnAbilityDisconnectDone(uv_work_t *work, int status)
|
||||
{
|
||||
HILOG_INFO("UvWorkOnAbilityDisconnectDone, uv_queue_work");
|
||||
std::unique_ptr<uv_work_t> managedWork(work);
|
||||
if (work == nullptr) {
|
||||
HILOG_ERROR("UvWorkOnAbilityDisconnectDone, work is null");
|
||||
return;
|
||||
}
|
||||
// JS Thread
|
||||
ConnectAbilityCB *connectAbilityCB = static_cast<ConnectAbilityCB *>(work->data);
|
||||
std::unique_ptr<ConnectAbilityCB> connectAbilityCB(static_cast<ConnectAbilityCB *>(work->data));
|
||||
if (connectAbilityCB == nullptr) {
|
||||
HILOG_ERROR("UvWorkOnAbilityDisconnectDone, connectAbilityCB is null");
|
||||
return;
|
||||
}
|
||||
CallbackInfo &cbInfo = connectAbilityCB->cbBase.cbInfo;
|
||||
napi_handle_scope scope = nullptr;
|
||||
napi_open_handle_scope(cbInfo.env, &scope);
|
||||
if (scope == nullptr) {
|
||||
HILOG_ERROR("napi_open_handle_scope failed");
|
||||
return;
|
||||
}
|
||||
napi_value result = WrapElementName(cbInfo.env, connectAbilityCB->abilityConnectionCB.elementName);
|
||||
if (cbInfo.callback != nullptr) {
|
||||
napi_value callback = nullptr;
|
||||
@ -3410,6 +3419,7 @@ void UvWorkOnAbilityDisconnectDone(uv_work_t *work, int status)
|
||||
napi_delete_reference(cbInfo.env, cbInfo.callback);
|
||||
cbInfo.callback = nullptr;
|
||||
}
|
||||
napi_close_handle_scope(cbInfo.env, scope);
|
||||
|
||||
// release connect
|
||||
std::lock_guard<std::recursive_mutex> lock(connectionsLock_);
|
||||
@ -3429,19 +3439,10 @@ void UvWorkOnAbilityDisconnectDone(uv_work_t *work, int status)
|
||||
connects_.erase(item);
|
||||
HILOG_INFO("UvWorkOnAbilityDisconnectDone erase connects_.size:%{public}zu", connects_.size());
|
||||
}
|
||||
|
||||
if (connectAbilityCB != nullptr) {
|
||||
delete connectAbilityCB;
|
||||
connectAbilityCB = nullptr;
|
||||
}
|
||||
if (work != nullptr) {
|
||||
delete work;
|
||||
work = nullptr;
|
||||
}
|
||||
HILOG_INFO("UvWorkOnAbilityDisconnectDone, uv_queue_work end");
|
||||
}
|
||||
|
||||
void NAPIAbilityConnection::HandleOnAbilityDisconnectDone(const ConnectionCallback &callback, int resultCode)
|
||||
void NAPIAbilityConnection::HandleOnAbilityDisconnectDone(ConnectionCallback &callback, int resultCode)
|
||||
{
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
uv_loop_s *loop = nullptr;
|
||||
@ -3469,6 +3470,7 @@ void NAPIAbilityConnection::HandleOnAbilityDisconnectDone(const ConnectionCallba
|
||||
|
||||
connectAbilityCB->cbBase.cbInfo.env = callback.env;
|
||||
connectAbilityCB->cbBase.cbInfo.callback = callback.disconnectCallbackRef;
|
||||
callback.disconnectCallbackRef = nullptr;
|
||||
connectAbilityCB->abilityConnectionCB.elementName = element_;
|
||||
connectAbilityCB->abilityConnectionCB.resultCode = resultCode;
|
||||
work->data = static_cast<void *>(connectAbilityCB);
|
||||
@ -3494,7 +3496,7 @@ void NAPIAbilityConnection::OnAbilityDisconnectDone(const AppExecFwk::ElementNam
|
||||
std::lock_guard<std::mutex> guard(lock_);
|
||||
element_ = element;
|
||||
for (const auto &callback : callbacks_) {
|
||||
HandleOnAbilityDisconnectDone(callback, resultCode);
|
||||
HandleOnAbilityDisconnectDone(*callback, resultCode);
|
||||
}
|
||||
connectionState_ = CONNECTION_STATE_DISCONNECTED;
|
||||
HILOG_INFO("%{public}s, end.", __func__);
|
||||
@ -3969,13 +3971,11 @@ NativeValue* JsNapiCommon::JsConnectAbility(
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
ConnectionCallback connectionCallback;
|
||||
GenerateCallback(env, secondParam, connectionCallback);
|
||||
auto connectionCallback = std::make_shared<ConnectionCallback>(env, secondParam);
|
||||
bool result = false;
|
||||
int32_t errorVal = static_cast<int32_t>(NAPI_ERR_NO_ERROR);
|
||||
int64_t id = 0;
|
||||
sptr<NAPIAbilityConnection> abilityConnection = nullptr;
|
||||
|
||||
if (CheckAbilityType(abilityType)) {
|
||||
abilityConnection = FindConnectionLocked(want, id);
|
||||
if (abilityConnection) {
|
||||
@ -3987,7 +3987,7 @@ NativeValue* JsNapiCommon::JsConnectAbility(
|
||||
auto connectionState = abilityConnection->GetConnectionState();
|
||||
if (connectionState == CONNECTION_STATE_CONNECTED) {
|
||||
HILOG_INFO("Ability is connected, callback to client.");
|
||||
abilityConnection->HandleOnAbilityConnectDone(connectionCallback, ERR_OK);
|
||||
abilityConnection->HandleOnAbilityConnectDone(*connectionCallback, ERR_OK);
|
||||
return CreateJsValue(engine, id);
|
||||
} else if (connectionState == CONNECTION_STATE_CONNECTING) {
|
||||
HILOG_INFO("Ability is connecting, just wait callback.");
|
||||
@ -4024,10 +4024,11 @@ NativeValue* JsNapiCommon::JsConnectAbility(
|
||||
}
|
||||
NAPI_CALL_BASE(env, napi_create_int32(env, errorCode, &resultVal), engine.CreateUndefined());
|
||||
NAPI_CALL_BASE(
|
||||
env, napi_get_reference_value(env, connectionCallback.failedCallbackRef, &callback),
|
||||
env, napi_get_reference_value(env, connectionCallback->failedCallbackRef, &callback),
|
||||
engine.CreateUndefined());
|
||||
NAPI_CALL_BASE(env, napi_call_function(env, undefined, callback, ARGS_ONE, &resultVal, &callResult),
|
||||
engine.CreateUndefined());
|
||||
RemoveConnectionLocked(want);
|
||||
}
|
||||
return CreateJsValue(engine, id);
|
||||
}
|
||||
@ -4087,7 +4088,7 @@ NativeValue* JsNapiCommon::JsDisConnectAbility(
|
||||
}
|
||||
|
||||
bool JsNapiCommon::CreateConnectionAndConnectAbilityLocked(
|
||||
const ConnectionCallback &callback, const Want &want, int64_t &id)
|
||||
std::shared_ptr<ConnectionCallback> callback, const Want &want, int64_t &id)
|
||||
{
|
||||
HILOG_DEBUG("Create new connection");
|
||||
// Create connection
|
||||
@ -4156,18 +4157,6 @@ void JsNapiCommon::RemoveConnectionLocked(const Want &want)
|
||||
connects_.erase(iter);
|
||||
}
|
||||
|
||||
void JsNapiCommon::GenerateCallback(const napi_env &env, const napi_value &arg1, ConnectionCallback &callback)
|
||||
{
|
||||
callback.env = env;
|
||||
napi_value jsMethod = nullptr;
|
||||
napi_get_named_property(env, arg1, "onConnect", &jsMethod);
|
||||
napi_create_reference(env, jsMethod, 1, &callback.connectCallbackRef);
|
||||
napi_get_named_property(env, arg1, "onDisconnect", &jsMethod);
|
||||
napi_create_reference(env, jsMethod, 1, &callback.disconnectCallbackRef);
|
||||
napi_get_named_property(env, arg1, "onFailed", &jsMethod);
|
||||
napi_create_reference(env, jsMethod, 1, &callback.failedCallbackRef);
|
||||
}
|
||||
|
||||
NativeValue* JsNapiCommon::JsGetContext(
|
||||
NativeEngine &engine, const NativeCallbackInfo &info, const AbilityType abilityType)
|
||||
{
|
||||
|
@ -16,6 +16,7 @@
|
||||
#ifndef OHOS_ABILITY_RUNTIME_NAPI_COMMON_ABILITY_H
|
||||
#define OHOS_ABILITY_RUNTIME_NAPI_COMMON_ABILITY_H
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <list>
|
||||
|
||||
@ -219,10 +220,68 @@ enum {
|
||||
};
|
||||
|
||||
struct ConnectionCallback {
|
||||
napi_env env;
|
||||
napi_ref connectCallbackRef;
|
||||
napi_ref disconnectCallbackRef;
|
||||
napi_ref failedCallbackRef;
|
||||
ConnectionCallback(napi_env env, napi_value cbInfo)
|
||||
{
|
||||
this->env = env;
|
||||
napi_value jsMethod = nullptr;
|
||||
napi_get_named_property(env, cbInfo, "onConnect", &jsMethod);
|
||||
napi_create_reference(env, jsMethod, 1, &connectCallbackRef);
|
||||
napi_get_named_property(env, cbInfo, "onDisconnect", &jsMethod);
|
||||
napi_create_reference(env, jsMethod, 1, &disconnectCallbackRef);
|
||||
napi_get_named_property(env, cbInfo, "onFailed", &jsMethod);
|
||||
napi_create_reference(env, jsMethod, 1, &failedCallbackRef);
|
||||
}
|
||||
ConnectionCallback(ConnectionCallback &) = delete;
|
||||
ConnectionCallback(ConnectionCallback &&other)
|
||||
: env(other.env), connectCallbackRef(other.connectCallbackRef),
|
||||
disconnectCallbackRef(other.disconnectCallbackRef), failedCallbackRef(other.failedCallbackRef)
|
||||
{
|
||||
other.env = nullptr;
|
||||
other.connectCallbackRef = nullptr;
|
||||
other.disconnectCallbackRef = nullptr;
|
||||
other.failedCallbackRef = nullptr;
|
||||
}
|
||||
const ConnectionCallback &operator=(ConnectionCallback &) = delete;
|
||||
const ConnectionCallback &operator=(ConnectionCallback &&other)
|
||||
{
|
||||
Reset();
|
||||
env = other.env;
|
||||
connectCallbackRef = other.connectCallbackRef;
|
||||
disconnectCallbackRef = other.disconnectCallbackRef;
|
||||
failedCallbackRef = other.failedCallbackRef;
|
||||
other.env = nullptr;
|
||||
other.connectCallbackRef = nullptr;
|
||||
other.disconnectCallbackRef = nullptr;
|
||||
other.failedCallbackRef = nullptr;
|
||||
return *this;
|
||||
}
|
||||
~ConnectionCallback()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
void Reset()
|
||||
{
|
||||
if (env) {
|
||||
if (connectCallbackRef) {
|
||||
napi_delete_reference(env, connectCallbackRef);
|
||||
connectCallbackRef = nullptr;
|
||||
}
|
||||
if (disconnectCallbackRef) {
|
||||
napi_delete_reference(env, disconnectCallbackRef);
|
||||
disconnectCallbackRef = nullptr;
|
||||
}
|
||||
if (failedCallbackRef) {
|
||||
napi_delete_reference(env, failedCallbackRef);
|
||||
failedCallbackRef = nullptr;
|
||||
}
|
||||
env = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
napi_env env = nullptr;
|
||||
napi_ref connectCallbackRef = nullptr;
|
||||
napi_ref disconnectCallbackRef = nullptr;
|
||||
napi_ref failedCallbackRef = nullptr;
|
||||
};
|
||||
|
||||
class NAPIAbilityConnection : public AAFwk::AbilityConnectionStub {
|
||||
@ -230,15 +289,15 @@ public:
|
||||
void OnAbilityConnectDone(
|
||||
const AppExecFwk::ElementName &element, const sptr<IRemoteObject> &remoteObject, int resultCode) override;
|
||||
void OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode) override;
|
||||
void AddConnectionCallback(const ConnectionCallback &callback);
|
||||
void HandleOnAbilityConnectDone(const ConnectionCallback &callback, int resultCode);
|
||||
void HandleOnAbilityDisconnectDone(const ConnectionCallback &callback, int resultCode);
|
||||
void AddConnectionCallback(std::shared_ptr<ConnectionCallback> callback);
|
||||
void HandleOnAbilityConnectDone(ConnectionCallback &callback, int resultCode);
|
||||
void HandleOnAbilityDisconnectDone(ConnectionCallback &callback, int resultCode);
|
||||
int GetConnectionState() const;
|
||||
void SetConnectionState(int connectionState);
|
||||
size_t GetCallbackSize();
|
||||
|
||||
private:
|
||||
std::list<ConnectionCallback> callbacks_;
|
||||
std::list<std::shared_ptr<ConnectionCallback>> callbacks_;
|
||||
AppExecFwk::ElementName element_;
|
||||
sptr<IRemoteObject> serviceRemoteObject_ = nullptr;
|
||||
int connectionState_ = CONNECTION_STATE_DISCONNECTED;
|
||||
|
@ -47,6 +47,7 @@ ohos_shared_library("napi_common") {
|
||||
"ability_runtime:runtime",
|
||||
"access_token:libtokenid_sdk",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi_common",
|
||||
|
@ -42,6 +42,7 @@ ohos_shared_library("dialogrequest_napi") {
|
||||
"ability_runtime:runtime",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"napi:ace_napi",
|
||||
|
@ -38,6 +38,7 @@ ohos_shared_library("missionmanager") {
|
||||
"ability_runtime:abilitykit_native",
|
||||
"ability_runtime:runtime",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
|
@ -35,6 +35,7 @@ ohos_shared_library("missionmanager_napi") {
|
||||
"ability_runtime:abilitykit_native",
|
||||
"ability_runtime:runtime",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
@ -79,6 +80,7 @@ ohos_shared_library("distributedmissionmanager") {
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
|
@ -60,6 +60,7 @@ ohos_shared_library("particleability") {
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
|
@ -34,6 +34,7 @@ ohos_shared_library("quickfixmanager_napi") {
|
||||
"ability_runtime:runtime",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
@ -36,6 +36,7 @@ ohos_shared_library("uripermissionmanager_napi") {
|
||||
"ability_runtime:runtime",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
@ -42,6 +42,7 @@ ohos_shared_library("wantagent") {
|
||||
"ability_runtime:wantagent_innerkits",
|
||||
"access_token:libtokenid_sdk",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"napi:ace_napi",
|
||||
|
@ -43,6 +43,7 @@ ohos_shared_library("wantagent_napi") {
|
||||
"ability_runtime:wantagent_innerkits",
|
||||
"access_token:libtokenid_sdk",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"napi:ace_napi",
|
||||
|
@ -60,6 +60,7 @@ ohos_shared_library("ability_context_native") {
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"access_token:libtoken_callback_sdk",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"faultloggerd:libdfx_dumpcatcher",
|
||||
"hichecker_native:libhichecker",
|
||||
"hitrace_native:hitrace_meter",
|
||||
|
@ -265,6 +265,7 @@ ohos_shared_library("abilitykit_native") {
|
||||
"access_token:libtokenid_sdk",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"hisysevent_native:libhisysevent",
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
@ -379,6 +380,7 @@ ohos_shared_library("extensionkit_native") {
|
||||
"ability_runtime:napi_common",
|
||||
"ability_runtime:runtime",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
@ -420,6 +422,7 @@ ohos_shared_library("ability_thread") {
|
||||
"ability_runtime:ability_context_native",
|
||||
"ability_runtime:ability_manager",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
@ -457,6 +460,7 @@ ohos_shared_library("form_extension") {
|
||||
"ability_runtime:ability_context_native",
|
||||
"ability_runtime:runtime",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"form_fwk:fmskit_native",
|
||||
"form_fwk:form_manager",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
@ -521,6 +525,7 @@ ohos_shared_library("service_extension") {
|
||||
"ability_runtime:ability_manager",
|
||||
"ability_runtime:runtime",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
@ -628,6 +633,7 @@ ohos_shared_library("continuation_ipc") {
|
||||
"ability_base:want",
|
||||
"ability_runtime:ability_manager",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
@ -663,6 +669,7 @@ ohos_shared_library("data_ability_helper") {
|
||||
external_deps = [
|
||||
"ability_base:zuri",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"data_share:datashare_common",
|
||||
"data_share:datashare_consumer",
|
||||
"hitrace_native:hitrace_meter",
|
||||
@ -806,6 +813,7 @@ ohos_shared_library("ui_extension") {
|
||||
"ability_runtime:ability_manager",
|
||||
"ability_runtime:runtime",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
|
@ -16,7 +16,55 @@
|
||||
"StaticSubscriberExtension": [],
|
||||
"AccessibilityExtension": [],
|
||||
"InputMethodExtension": [],
|
||||
"WorkSchedulerExtension": [],
|
||||
"DataShareExtension": []
|
||||
"WorkSchedulerExtension": [
|
||||
"backgroundTaskManager",
|
||||
"resourceschedule.backgroundTaskManager",
|
||||
"multimedia.camera",
|
||||
"multimedia.audio",
|
||||
"multimedia.media"
|
||||
],
|
||||
"DataShareExtension": [
|
||||
"UIAbilityContext",
|
||||
"ability.featureAbility",
|
||||
"ability.particleAbility",
|
||||
"account.osAccount",
|
||||
"backgroundTaskManager",
|
||||
"bluetooth",
|
||||
"bluetoothManager",
|
||||
"connectedTag",
|
||||
"continuation.continuationManager",
|
||||
"mutilmedia.audio",
|
||||
"multimedia.carema",
|
||||
"nfc.cardEmulation",
|
||||
"nfc.controller",
|
||||
"nfc.tag",
|
||||
"request",
|
||||
"resourceschedule.backgroundTaskManager",
|
||||
"telephony.call",
|
||||
"telephony.data",
|
||||
"telephony.observer",
|
||||
"telephony.radio",
|
||||
"telephony.sim",
|
||||
"telephony.sms",
|
||||
"vibrator",
|
||||
"wallpaper",
|
||||
"wifi",
|
||||
"wifiext",
|
||||
"wifiManager",
|
||||
"wifiManagerExt",
|
||||
"window"],
|
||||
"PushExtension": [
|
||||
"notification",
|
||||
"notificationManager",
|
||||
"app.form.formProvider",
|
||||
"app.form.formInfo",
|
||||
"app.form.formHost",
|
||||
"app.form.formBindingData",
|
||||
"app.form.FormExtensionAbility",
|
||||
"application.formBindingData",
|
||||
"application.formHost",
|
||||
"application.formInfo",
|
||||
"application.formProvider"
|
||||
]
|
||||
}
|
||||
}
|
@ -32,14 +32,19 @@ void PageAbilityImpl::HandleAbilityTransaction(const Want &want, const AAFwk::Li
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_INFO("Handle ability transaction start, sourceState:%{public}d, targetState:%{public}d, "
|
||||
"isNewWant:%{public}d, sceneFlag:%{public}d.",
|
||||
lifecycleState_,
|
||||
targetState.state,
|
||||
targetState.isNewWant,
|
||||
targetState.sceneFlag);
|
||||
lifecycleState_, targetState.state, targetState.isNewWant, targetState.sceneFlag);
|
||||
if (ability_ == nullptr) {
|
||||
HILOG_ERROR("Handle ability transaction error, ability_ is null.");
|
||||
return;
|
||||
}
|
||||
|
||||
auto abilityContext = ability_->GetAbilityContext();
|
||||
if (abilityContext != nullptr && abilityContext->IsTerminating()
|
||||
&& targetState.state == AAFwk::ABILITY_STATE_INACTIVE) {
|
||||
HILOG_ERROR("Invalid translate state.");
|
||||
return;
|
||||
}
|
||||
|
||||
ability_->sceneFlag_ = targetState.sceneFlag;
|
||||
if ((lifecycleState_ == targetState.state) && !targetState.isNewWant) {
|
||||
if (targetState.state == AAFwk::ABILITY_STATE_FOREGROUND_NEW) {
|
||||
|
@ -733,8 +733,8 @@ void ContextImpl::OnOverlayChanged(const EventFwk::CommonEventData &data, const
|
||||
HILOG_DEBUG("Not this subscribe, action: %{public}s.", action.c_str());
|
||||
return;
|
||||
}
|
||||
if (want.GetElement().GetBundleName() != bundleName || GetBundleName() != bundleName) {
|
||||
HILOG_DEBUG("Not this app, bundleName: %{public}s.", want.GetElement().GetBundleName().c_str());
|
||||
if (GetBundleName() != bundleName) {
|
||||
HILOG_DEBUG("Not this app, bundleName: %{public}s.", bundleName.c_str());
|
||||
return;
|
||||
}
|
||||
bool isEnable = data.GetWant().GetBoolParam(AppExecFwk::Constants::OVERLAY_STATE, false);
|
||||
|
@ -72,7 +72,6 @@
|
||||
#include <dirent.h>
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
using namespace OHOS::AbilityBase::Constants;
|
||||
@ -82,10 +81,10 @@ std::shared_ptr<EventHandler> MainThread::signalHandler_ = nullptr;
|
||||
std::shared_ptr<MainThread::MainHandler> MainThread::mainHandler_ = nullptr;
|
||||
static std::shared_ptr<MixStackDumper> mixStackDumper_ = nullptr;
|
||||
namespace {
|
||||
#ifdef APP_USE_ARM64
|
||||
constexpr char FORM_RENDER_LIB_PATH[] = "/system/lib64/libformrender.z.so";
|
||||
#else
|
||||
#ifdef APP_USE_ARM
|
||||
constexpr char FORM_RENDER_LIB_PATH[] = "/system/lib/libformrender.z.so";
|
||||
#else
|
||||
constexpr char FORM_RENDER_LIB_PATH[] = "/system/lib64/libformrender.z.so";
|
||||
#endif
|
||||
|
||||
constexpr int32_t DELIVERY_TIME = 200;
|
||||
@ -1011,10 +1010,6 @@ void MainThread::HandleOnOverlayChanged(const EventFwk::CommonEventData &data,
|
||||
HILOG_DEBUG("Not this subscribe, action: %{public}s.", action.c_str());
|
||||
return;
|
||||
}
|
||||
if (want.GetElement().GetBundleName() != bundleName) {
|
||||
HILOG_DEBUG("Not this app, bundleName: %{public}s.", want.GetElement().GetBundleName().c_str());
|
||||
return;
|
||||
}
|
||||
bool isEnable = data.GetWant().GetBoolParam(Constants::OVERLAY_STATE, false);
|
||||
// 1.get overlay hapPath
|
||||
if (resourceManager == nullptr) {
|
||||
@ -1654,14 +1649,15 @@ void MainThread::HandleLaunchAbility(const std::shared_ptr<AbilityLocalRecord> &
|
||||
AbilityThread::AbilityThreadMain(application_, abilityRecord, mainHandler_->GetEventRunner(), stageContext);
|
||||
#endif
|
||||
|
||||
if (runtime) {
|
||||
std::vector<std::pair<std::string, std::string>> hqfFilePair;
|
||||
if (GetHqfFileAndHapPath(appInfo->bundleName, hqfFilePair)) {
|
||||
for (auto it = hqfFilePair.begin(); it != hqfFilePair.end(); it++) {
|
||||
HILOG_INFO("hqfFile: %{private}s, hapPath: %{private}s.", it->first.c_str(), it->second.c_str());
|
||||
runtime->LoadRepairPatch(it->first, it->second);
|
||||
}
|
||||
std::vector<HqfInfo> hqfInfos = appInfo->appQuickFix.deployedAppqfInfo.hqfInfos;
|
||||
std::map<std::string, std::string> modulePaths;
|
||||
if (runtime && !hqfInfos.empty()) {
|
||||
for (auto it = hqfInfos.begin(); it != hqfInfos.end(); it++) {
|
||||
HILOG_INFO("moudelName: %{private}s, hqfFilePath: %{private}s.",
|
||||
it->moduleName.c_str(), it->hqfFilePath.c_str());
|
||||
modulePaths.insert(std::make_pair(it->moduleName, it->hqfFilePath));
|
||||
}
|
||||
runtime->RegisterQuickFixQueryFunc(modulePaths);
|
||||
}
|
||||
}
|
||||
|
||||
|
68
frameworks/native/runtime/js_quickfix_callback.cpp
Normal file
68
frameworks/native/runtime/js_quickfix_callback.cpp
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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 "js_quickfix_callback.h"
|
||||
|
||||
#include "file_path_utils.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "js_runtime.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
namespace {
|
||||
constexpr char MERGE_ABC_PATH[] = "/ets/modules.abc";
|
||||
constexpr char BUNDLE_INSTALL_PATH[] = "/data/storage/el1/bundle/";
|
||||
}
|
||||
|
||||
bool JsQuickfixCallback::operator()(std::string baseFileName, std::string &patchFileName,
|
||||
void **patchBuffer, size_t &patchSize)
|
||||
{
|
||||
HILOG_DEBUG("baseFileName: %{private}s", baseFileName.c_str());
|
||||
auto position = baseFileName.find(".abc");
|
||||
if (position == std::string::npos) {
|
||||
HILOG_ERROR("invalid baseFileName!");
|
||||
return false;
|
||||
}
|
||||
int baseFileNameLen = baseFileName.length();
|
||||
int prefixLen = strlen(BUNDLE_INSTALL_PATH);
|
||||
int suffixLen = strlen(MERGE_ABC_PATH);
|
||||
int moduleLen = baseFileNameLen - prefixLen - suffixLen;
|
||||
if (moduleLen < 0) {
|
||||
HILOG_ERROR("invalid baseFileName!");
|
||||
return false;
|
||||
}
|
||||
std::string moduleName = baseFileName.substr(prefixLen, moduleLen);
|
||||
HILOG_DEBUG("moduleName: %{private}s", moduleName.c_str());
|
||||
|
||||
auto it = moduleAndHqfPath_.find(moduleName);
|
||||
if (it == moduleAndHqfPath_.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string hqfFile = it->second;
|
||||
std::string resolvedHqfFile(AbilityBase::GetLoadPath(hqfFile));
|
||||
HILOG_DEBUG("hqfFile: %{private}s, resolvedHqfFile: %{private}s", hqfFile.c_str(), resolvedHqfFile.c_str());
|
||||
|
||||
if (!JsRuntime::GetFileBuffer(resolvedHqfFile, patchFileName, newpatchBuffer_)) {
|
||||
HILOG_ERROR("GetFileBuffer failed");
|
||||
return false;
|
||||
}
|
||||
*patchBuffer = newpatchBuffer_.data();
|
||||
HILOG_DEBUG("patchFileName: %{private}s", patchFileName.c_str());
|
||||
patchSize = newpatchBuffer_.size();
|
||||
return true;
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
44
frameworks/native/runtime/js_quickfix_callback.h
Normal file
44
frameworks/native/runtime/js_quickfix_callback.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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_JS_QUICKFIX_CALLBACK_H
|
||||
#define OHOS_ABILITY_RUNTIME_JS_QUICKFIX_CALLBACK_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
class JsRuntime;
|
||||
class JsQuickfixCallback final {
|
||||
public:
|
||||
explicit JsQuickfixCallback(std::map<std::string, std::string> moduleAndHqfPath) :
|
||||
moduleAndHqfPath_(moduleAndHqfPath) {};
|
||||
~JsQuickfixCallback() = default;
|
||||
|
||||
bool operator()(std::string baseFileName,
|
||||
std::string &patchFileName,
|
||||
void **patchBuffer,
|
||||
size_t &patchSize);
|
||||
|
||||
private:
|
||||
std::vector<uint8_t> newpatchBuffer_;
|
||||
std::map<std::string, std::string> moduleAndHqfPath_;
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // OHOS_ABILITY_RUNTIME_JS_QUICKFIX_CALLBACK_H
|
@ -39,6 +39,7 @@
|
||||
#include "js_environment.h"
|
||||
#include "js_module_reader.h"
|
||||
#include "js_module_searcher.h"
|
||||
#include "js_quickfix_callback.h"
|
||||
#include "js_runtime_utils.h"
|
||||
#include "js_source_map_operator.h"
|
||||
#include "js_timer.h"
|
||||
@ -50,6 +51,8 @@
|
||||
#include "parameters.h"
|
||||
#include "extractor.h"
|
||||
#include "systemcapability.h"
|
||||
#include "commonlibrary/ets_utils/js_sys_module/timer/timer.h"
|
||||
#include "commonlibrary/ets_utils/js_sys_module/console/console.h"
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#include "declarative_module_preloader.h"
|
||||
@ -320,6 +323,11 @@ bool JsRuntime::LoadRepairPatch(const std::string& hqfFile, const std::string& h
|
||||
resolvedHapPath = hapPath.substr(0, position) + MERGE_ABC_PATH;
|
||||
}
|
||||
|
||||
auto hspPosition = hapPath.find(".hsp");
|
||||
if (hspPosition != std::string::npos) {
|
||||
resolvedHapPath = hapPath.substr(0, hspPosition) + MERGE_ABC_PATH;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("LoadRepairPatch, LoadPatch, patchFile: %{private}s, baseFile: %{private}s.",
|
||||
patchFile.c_str(), resolvedHapPath.c_str());
|
||||
auto ret = panda::JSNApi::LoadPatch(vm, patchFile, patchBuffer.data(), patchBuffer.size(),
|
||||
@ -449,7 +457,7 @@ bool JsRuntime::Initialize(const Options& options)
|
||||
CHECK_POINTER_AND_RETURN(globalObj, false);
|
||||
|
||||
if (!preloaded_) {
|
||||
InitConsoleLogModule(*nativeEngine, *globalObj);
|
||||
JsSysModule::Console::InitConsoleModule(reinterpret_cast<napi_env>(nativeEngine));
|
||||
InitSyscapModule(*nativeEngine, *globalObj);
|
||||
|
||||
// Simple hook function 'isSystemplugin'
|
||||
@ -505,7 +513,7 @@ bool JsRuntime::Initialize(const Options& options)
|
||||
if (options.isUnique) {
|
||||
HILOG_INFO("Not supported TimerModule when form render");
|
||||
} else {
|
||||
InitTimerModule(*nativeEngine, *globalObj);
|
||||
JsSysModule::Timer::RegisterTime(reinterpret_cast<napi_env>(nativeEngine));
|
||||
}
|
||||
|
||||
InitWorkerModule(*nativeEngine, codePath_, options.isDebugVersion, options.isBundle);
|
||||
@ -963,5 +971,13 @@ void JsRuntime::RegisterUncaughtExceptionHandler(JsEnv::UncaughtExceptionInfo un
|
||||
CHECK_POINTER(jsEnv_);
|
||||
jsEnv_->RegisterUncaughtExceptionHandler(uncaughtExceptionInfo);
|
||||
}
|
||||
|
||||
void JsRuntime::RegisterQuickFixQueryFunc(const std::map<std::string, std::string>& moduleAndPath)
|
||||
{
|
||||
auto vm = GetEcmaVm();
|
||||
if (vm != nullptr) {
|
||||
panda::JSNApi::RegisterQuickFixQueryFunc(vm, JsQuickfixCallback(moduleAndPath));
|
||||
}
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
@ -21,6 +21,5 @@ std::string JsSourceMapOperatorImpl::TranslateBySourceMap(const std::string& sta
|
||||
{
|
||||
return AbilityRuntime::ModSourceMap::TranslateBySourceMap(stackStr, *bindSourceMaps_, hapPath_);
|
||||
}
|
||||
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
@ -21,11 +21,11 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
|
||||
class JsSourceMapOperatorImpl : public JsEnv::SourceMapOperatorImpl {
|
||||
public:
|
||||
JsSourceMapOperatorImpl(const std::string hapPath, std::shared_ptr<AbilityRuntime::ModSourceMap> bindSourceMaps) :
|
||||
hapPath_(hapPath), bindSourceMaps_(bindSourceMaps)
|
||||
JsSourceMapOperatorImpl(const std::string hapPath,
|
||||
std::shared_ptr<AbilityRuntime::ModSourceMap> bindSourceMaps)
|
||||
: hapPath_(hapPath), bindSourceMaps_(bindSourceMaps)
|
||||
{}
|
||||
|
||||
~JsSourceMapOperatorImpl() = default;
|
||||
@ -39,4 +39,4 @@ private:
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // OHOS_ABILITY_RUNTIME_JS_SOURCE_MAP_OPERATOR_H
|
||||
#endif // OHOS_ABILITY_RUNTIME_JS_SOURCE_MAP_OPERATOR_H
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "js_console_log.h"
|
||||
#include "js_runtime_utils.h"
|
||||
#include "native_engine/impl/ark/ark_native_engine.h"
|
||||
#include "commonlibrary/ets_utils/js_sys_module/console/console.h"
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
using OHOS::Ace::ContainerScope;
|
||||
@ -70,7 +71,7 @@ void InitWorkerFunc(NativeEngine* nativeEngine)
|
||||
return;
|
||||
}
|
||||
|
||||
InitConsoleLogModule(*nativeEngine, *globalObj);
|
||||
OHOS::JsSysModule::Console::InitConsoleModule(reinterpret_cast<napi_env>(nativeEngine));
|
||||
|
||||
if (g_debugMode) {
|
||||
auto instanceId = gettid();
|
||||
|
@ -104,6 +104,7 @@ ohos_shared_library("ability_manager") {
|
||||
"ability_base:zuri",
|
||||
"ability_runtime:app_manager",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
|
@ -54,6 +54,7 @@ struct AbilityTransitionInfo : public Parcelable {
|
||||
int32_t missionId_;
|
||||
TransitionReason reason_ = TransitionReason::ABILITY_TRANSITION;
|
||||
AppExecFwk::DisplayOrientation orientation_ = AppExecFwk::DisplayOrientation::UNSPECIFIED;
|
||||
uint32_t apiCompatibleVersion_ = 0;
|
||||
|
||||
virtual bool Marshalling(Parcel& parcel) const override
|
||||
{
|
||||
@ -108,6 +109,10 @@ struct AbilityTransitionInfo : public Parcelable {
|
||||
if (!parcel.WriteUint32(static_cast<uint32_t>(orientation_))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!parcel.WriteUint32(static_cast<uint32_t>(apiCompatibleVersion_))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -163,6 +168,7 @@ struct AbilityTransitionInfo : public Parcelable {
|
||||
info->missionId_ = parcel.ReadInt32();
|
||||
info->reason_ = static_cast<TransitionReason>(parcel.ReadUint32());
|
||||
info->orientation_ = static_cast<AppExecFwk::DisplayOrientation>(parcel.ReadUint32());
|
||||
info->apiCompatibleVersion_ = parcel.ReadUint32();
|
||||
return info;
|
||||
}
|
||||
};
|
||||
|
@ -79,12 +79,12 @@ bool RunningProcessInfo::Marshalling(Parcel &parcel) const
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isKeepAlive);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isFocused);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isTestProcess);
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(processType_));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(extensionType_));
|
||||
if (!parcel.WriteStringVector(bundleNames)) {
|
||||
HILOG_ERROR("write bundleNames failed.");
|
||||
return false;
|
||||
}
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(processType_));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(extensionType_));
|
||||
return true;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
|
@ -55,6 +55,7 @@ ohos_shared_library("runtime") {
|
||||
"${ability_runtime_native_path}/runtime/js_error_utils.cpp",
|
||||
"${ability_runtime_native_path}/runtime/js_module_reader.cpp",
|
||||
"${ability_runtime_native_path}/runtime/js_module_searcher.cpp",
|
||||
"${ability_runtime_native_path}/runtime/js_quickfix_callback.cpp",
|
||||
"${ability_runtime_native_path}/runtime/js_runtime.cpp",
|
||||
"${ability_runtime_native_path}/runtime/js_runtime_utils.cpp",
|
||||
"${ability_runtime_native_path}/runtime/js_source_map_operator.cpp",
|
||||
@ -93,6 +94,8 @@ ohos_shared_library("runtime") {
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"ets_runtime:libark_jsruntime",
|
||||
"ets_utils:console",
|
||||
"ets_utils:timer",
|
||||
"eventhandler:libeventhandler",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "native_engine/native_engine.h"
|
||||
#include "runtime.h"
|
||||
#include "source_map.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
class EventHandler;
|
||||
@ -103,6 +102,8 @@ public:
|
||||
panda::ecmascript::EcmaVM* GetEcmaVm() const;
|
||||
|
||||
void UpdateModuleNameAndAssetPath(const std::string& moduleName);
|
||||
void RegisterQuickFixQueryFunc(const std::map<std::string, std::string>& moduleAndPath) override;
|
||||
static bool GetFileBuffer(const std::string& filePath, std::string& fileFullName, std::vector<uint8_t>& buffer);
|
||||
|
||||
void InitSourceMap(const std::shared_ptr<JsEnv::SourceMapOperatorImpl> operatorImpl);
|
||||
|
||||
@ -132,7 +133,6 @@ private:
|
||||
static std::atomic<bool> hasInstance;
|
||||
|
||||
private:
|
||||
bool GetFileBuffer(const std::string& filePath, std::string& fileFullName, std::vector<uint8_t>& buffer);
|
||||
bool CreateJsEnv(const Options& options);
|
||||
void PreloadAce(const Options& options);
|
||||
bool InitLoop(const std::shared_ptr<AppExecFwk::EventRunner>& eventRunner);
|
||||
|
@ -77,6 +77,7 @@ public:
|
||||
virtual bool NotifyHotReloadPage() = 0;
|
||||
virtual bool UnLoadRepairPatch(const std::string& patchFile) = 0;
|
||||
virtual void UpdateExtensionType(int32_t extensionType) = 0;
|
||||
virtual void RegisterQuickFixQueryFunc(const std::map<std::string, std::string>& moduleAndPath) = 0;
|
||||
|
||||
Runtime(const Runtime&) = delete;
|
||||
Runtime(Runtime&&) = delete;
|
||||
|
@ -29,6 +29,7 @@ ohos_shared_library("uri_permission_mgr") {
|
||||
public_configs = [ ":uripermkit_public_config" ]
|
||||
|
||||
sources = [
|
||||
"src/uri_permission_load_callback.cpp",
|
||||
"src/uri_permission_manager_client.cpp",
|
||||
"src/uri_permission_manager_proxy.cpp",
|
||||
"src/uri_permission_manager_stub.cpp",
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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_URI_PERMISSION_LOAD_CALLBACK_H
|
||||
#define OHOS_ABILITY_RUNTIME_URI_PERMISSION_LOAD_CALLBACK_H
|
||||
|
||||
#include "iremote_object.h"
|
||||
#include "system_ability_load_callback_stub.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
class UriPermissionLoadCallback : public SystemAbilityLoadCallbackStub {
|
||||
public:
|
||||
UriPermissionLoadCallback() = default;
|
||||
virtual ~UriPermissionLoadCallback() = default;
|
||||
|
||||
void OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr<IRemoteObject> &remoteObject) override;
|
||||
void OnLoadSystemAbilityFail(int32_t systemAbilityId) override;
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_URI_PERMISSION_LOAD_CALLBACK_H
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-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
|
||||
@ -18,16 +18,15 @@
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "singleton.h"
|
||||
#include "uri.h"
|
||||
#include "uri_permission_manager_interface.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
using ClearProxyCallback = std::function<void()>;
|
||||
class UriPermissionManagerClient : public DelayedSingleton<UriPermissionManagerClient>,
|
||||
public std::enable_shared_from_this<UriPermissionManagerClient> {
|
||||
class UriPermissionManagerClient : public std::enable_shared_from_this<UriPermissionManagerClient> {
|
||||
public:
|
||||
static std::shared_ptr<UriPermissionManagerClient> GetInstance();
|
||||
UriPermissionManagerClient() = default;
|
||||
~UriPermissionManagerClient() = default;
|
||||
|
||||
@ -57,9 +56,14 @@ public:
|
||||
*/
|
||||
int RevokeUriPermissionManually(const Uri &uri, const std::string bundleName);
|
||||
|
||||
void OnLoadSystemAbilitySuccess(const sptr<IRemoteObject> &remoteObject);
|
||||
void OnLoadSystemAbilityFail();
|
||||
private:
|
||||
sptr<IUriPermissionManager> ConnectUriPermService();
|
||||
void ClearProxy();
|
||||
bool LoadUriPermService();
|
||||
void SetUriPermMgr(const sptr<IRemoteObject> &remoteObject);
|
||||
sptr<IUriPermissionManager> GetUriPermMgr();
|
||||
DISALLOW_COPY_AND_MOVE(UriPermissionManagerClient);
|
||||
|
||||
class UpmsDeathRecipient : public IRemoteObject::DeathRecipient {
|
||||
@ -73,7 +77,12 @@ private:
|
||||
};
|
||||
|
||||
private:
|
||||
static std::recursive_mutex recursiveMutex_;
|
||||
static std::shared_ptr<UriPermissionManagerClient> instance_;
|
||||
std::mutex mutex_;
|
||||
std::mutex saLoadMutex_;
|
||||
std::condition_variable loadSaVariable_;
|
||||
bool saLoadFinished_ = false;
|
||||
sptr<IUriPermissionManager> uriPermMgr_ = nullptr;
|
||||
};
|
||||
} // namespace AAFwk
|
||||
|
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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 "hilog_wrapper.h"
|
||||
#include "uri_permission_load_callback.h"
|
||||
#include "uri_permission_manager_client.h"
|
||||
#include "system_ability_definition.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
void UriPermissionLoadCallback::OnLoadSystemAbilitySuccess(
|
||||
int32_t systemAbilityId, const sptr<IRemoteObject> &remoteObject)
|
||||
{
|
||||
if (systemAbilityId != URI_PERMISSION_MGR_SERVICE_ID) {
|
||||
HILOG_ERROR("System ability id %{public}d mismatch.", systemAbilityId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (remoteObject == nullptr) {
|
||||
HILOG_ERROR("Object is nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("Load system ability %{public}d succeed.", systemAbilityId);
|
||||
UriPermissionManagerClient::GetInstance()->OnLoadSystemAbilitySuccess(remoteObject);
|
||||
}
|
||||
|
||||
void UriPermissionLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId)
|
||||
{
|
||||
if (systemAbilityId != URI_PERMISSION_MGR_SERVICE_ID) {
|
||||
HILOG_ERROR("System ability id %{public}d mismatch.", systemAbilityId);
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("Load system ability %{public}d failed.", systemAbilityId);
|
||||
UriPermissionManagerClient::GetInstance()->OnLoadSystemAbilityFail();
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-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
|
||||
@ -20,13 +20,29 @@
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "system_ability_definition.h"
|
||||
#include "uri_permission_load_callback.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
namespace {
|
||||
const int LOAD_SA_TIMEOUT_MS = 4 * 1000;
|
||||
} // namespace
|
||||
std::shared_ptr<UriPermissionManagerClient> UriPermissionManagerClient::instance_ = nullptr;
|
||||
std::recursive_mutex UriPermissionManagerClient::recursiveMutex_;
|
||||
std::shared_ptr<UriPermissionManagerClient> UriPermissionManagerClient::GetInstance()
|
||||
{
|
||||
if (instance_ == nullptr) {
|
||||
std::lock_guard<std::recursive_mutex> lock_l(recursiveMutex_);
|
||||
if (instance_ == nullptr) {
|
||||
instance_ = std::make_shared<UriPermissionManagerClient>();
|
||||
}
|
||||
}
|
||||
return instance_;
|
||||
}
|
||||
|
||||
int UriPermissionManagerClient::GrantUriPermission(const Uri &uri, unsigned int flag,
|
||||
const std::string targetBundleName, int autoremove)
|
||||
{
|
||||
HILOG_DEBUG("UriPermissionManagerClient::GrantUriPermission is called.");
|
||||
HILOG_DEBUG("targetBundleName :%{public}s", targetBundleName.c_str());
|
||||
auto uriPermMgr = ConnectUriPermService();
|
||||
if (uriPermMgr) {
|
||||
@ -57,17 +73,15 @@ int UriPermissionManagerClient::RevokeUriPermissionManually(const Uri &uri, cons
|
||||
sptr<IUriPermissionManager> UriPermissionManagerClient::ConnectUriPermService()
|
||||
{
|
||||
HILOG_DEBUG("UriPermissionManagerClient::ConnectUriPermService is called.");
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (uriPermMgr_ == nullptr) {
|
||||
auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (!systemAbilityMgr) {
|
||||
HILOG_ERROR("Failed to get SystemAbilityManager.");
|
||||
auto uriPermMgr = GetUriPermMgr();
|
||||
if (uriPermMgr == nullptr) {
|
||||
if (!LoadUriPermService()) {
|
||||
HILOG_ERROR("Load uri permission manager service failed.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto remoteObj = systemAbilityMgr->GetSystemAbility(URI_PERMISSION_MGR_SERVICE_ID);
|
||||
if (!remoteObj || (uriPermMgr_ = iface_cast<IUriPermissionManager>(remoteObj)) == nullptr) {
|
||||
HILOG_ERROR("Failed to get UriPermService.");
|
||||
uriPermMgr = GetUriPermMgr();
|
||||
if (uriPermMgr == nullptr || uriPermMgr->AsObject() == nullptr) {
|
||||
HILOG_ERROR("Failed to get uri permission manager.");
|
||||
return nullptr;
|
||||
}
|
||||
auto self = shared_from_this();
|
||||
@ -77,12 +91,78 @@ sptr<IUriPermissionManager> UriPermissionManagerClient::ConnectUriPermService()
|
||||
}
|
||||
};
|
||||
sptr<UpmsDeathRecipient> recipient(new UpmsDeathRecipient(onClearProxyCallback));
|
||||
uriPermMgr_->AsObject()->AddDeathRecipient(recipient);
|
||||
uriPermMgr->AsObject()->AddDeathRecipient(recipient);
|
||||
}
|
||||
HILOG_DEBUG("End UriPermissionManagerClient::ConnectUriPermService.");
|
||||
return uriPermMgr;
|
||||
}
|
||||
|
||||
bool UriPermissionManagerClient::LoadUriPermService()
|
||||
{
|
||||
HILOG_DEBUG("UriPermissionManagerClient::LoadUriPermService is called.");
|
||||
auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (systemAbilityMgr == nullptr) {
|
||||
HILOG_ERROR("Failed to get SystemAbilityManager.");
|
||||
return false;
|
||||
}
|
||||
|
||||
sptr<UriPermissionLoadCallback> loadCallback = new (std::nothrow) UriPermissionLoadCallback();
|
||||
if (loadCallback == nullptr) {
|
||||
HILOG_ERROR("Create load callback failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
auto ret = systemAbilityMgr->LoadSystemAbility(URI_PERMISSION_MGR_SERVICE_ID, loadCallback);
|
||||
if (ret != 0) {
|
||||
HILOG_ERROR("Load system ability %{public}d failed with %{public}d.", URI_PERMISSION_MGR_SERVICE_ID, ret);
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(saLoadMutex_);
|
||||
auto waitStatus = loadSaVariable_.wait_for(lock, std::chrono::milliseconds(LOAD_SA_TIMEOUT_MS),
|
||||
[this]() {
|
||||
return saLoadFinished_;
|
||||
});
|
||||
if (!waitStatus) {
|
||||
HILOG_ERROR("Wait for load sa timeout.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
sptr<IUriPermissionManager> UriPermissionManagerClient::GetUriPermMgr()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
return uriPermMgr_;
|
||||
}
|
||||
|
||||
void UriPermissionManagerClient::SetUriPermMgr(const sptr<IRemoteObject> &remoteObject)
|
||||
{
|
||||
HILOG_DEBUG("UriPermissionManagerClient::SetUriPermMgr is called.");
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
uriPermMgr_ = iface_cast<IUriPermissionManager>(remoteObject);
|
||||
}
|
||||
|
||||
void UriPermissionManagerClient::OnLoadSystemAbilitySuccess(const sptr<IRemoteObject> &remoteObject)
|
||||
{
|
||||
HILOG_DEBUG("UriPermissionManagerClient::OnLoadSystemAbilitySuccess is called.");
|
||||
SetUriPermMgr(remoteObject);
|
||||
std::unique_lock<std::mutex> lock(saLoadMutex_);
|
||||
saLoadFinished_ = true;
|
||||
loadSaVariable_.notify_one();
|
||||
}
|
||||
|
||||
void UriPermissionManagerClient::OnLoadSystemAbilityFail()
|
||||
{
|
||||
HILOG_DEBUG("UriPermissionManagerClient::OnLoadSystemAbilityFail is called.");
|
||||
SetUriPermMgr(nullptr);
|
||||
std::unique_lock<std::mutex> lock(saLoadMutex_);
|
||||
saLoadFinished_ = true;
|
||||
loadSaVariable_.notify_one();
|
||||
}
|
||||
|
||||
void UriPermissionManagerClient::ClearProxy()
|
||||
{
|
||||
HILOG_DEBUG("UriPermissionManagerClient::ClearProxy is called.");
|
||||
|
@ -39,7 +39,6 @@ public:
|
||||
if (impl_ == nullptr) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return impl_->TranslateBySourceMap(stackStr);
|
||||
}
|
||||
|
||||
@ -48,4 +47,4 @@ private:
|
||||
};
|
||||
} // namespace JsEnv
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_JS_ENVIRONMENT_SOURCE_MAP_OPERATOR_H
|
||||
#endif // OHOS_ABILITY_JS_ENVIRONMENT_SOURCE_MAP_OPERATOR_H
|
||||
|
@ -16,15 +16,18 @@
|
||||
#include "js_environment.h"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <gtest/hwext/gtest-multithread.h>
|
||||
#include <cstdarg>
|
||||
#include <string>
|
||||
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
#include "js_env_logger.h"
|
||||
#include "ohos_js_env_logger.h"
|
||||
#include "ohos_js_environment_impl.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
using namespace testing::mt;
|
||||
|
||||
namespace OHOS {
|
||||
namespace JsEnv {
|
||||
@ -60,6 +63,8 @@ HWTEST_F(JsEnvironmentTest, JsEnvInitialize_0100, TestSize.Level0)
|
||||
{
|
||||
auto jsEnv = std::make_shared<JsEnvironment>(std::make_unique<AbilityRuntime::OHOSJsEnvironmentImpl>());
|
||||
ASSERT_NE(jsEnv, nullptr);
|
||||
ASSERT_EQ(jsEnv->GetVM(), nullptr);
|
||||
ASSERT_EQ(jsEnv->GetNativeEngine(), nullptr);
|
||||
|
||||
panda::RuntimeOption pandaOption;
|
||||
auto ret = jsEnv->Initialize(pandaOption, static_cast<void*>(this));
|
||||
@ -72,6 +77,30 @@ HWTEST_F(JsEnvironmentTest, JsEnvInitialize_0100, TestSize.Level0)
|
||||
EXPECT_NE(nativeEngine, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: JsEnvInitialize_0200
|
||||
* @tc.desc: Initialize js environment in multi thread.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI6KODF
|
||||
*/
|
||||
HWTEST_F(JsEnvironmentTest, JsEnvInitialize_0200, TestSize.Level0)
|
||||
{
|
||||
JSENV_LOG_I("Running in multi-thread, using default thread number.");
|
||||
|
||||
auto task = []() {
|
||||
JSENV_LOG_I("Running in thread %{public}" PRIu64 "", gettid());
|
||||
auto jsEnv = std::make_shared<JsEnvironment>(std::make_unique<AbilityRuntime::OHOSJsEnvironmentImpl>());
|
||||
ASSERT_NE(jsEnv, nullptr);
|
||||
|
||||
panda::RuntimeOption pandaOption;
|
||||
ASSERT_EQ(jsEnv->Initialize(pandaOption, nullptr), true);
|
||||
EXPECT_NE(jsEnv->GetVM(), nullptr);
|
||||
EXPECT_NE(jsEnv->GetNativeEngine(), nullptr);
|
||||
};
|
||||
|
||||
GTEST_RUN_TASK(task);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: LoadScript_0100
|
||||
* @tc.desc: load script with invalid engine.
|
||||
|
@ -15,5 +15,4 @@ bootevent.appfwk.ready=false
|
||||
component.startup.newRules=true
|
||||
component.startup.newRules.except.LauncherSystemUI=true
|
||||
component.startup.backgroundJudge.flag=true
|
||||
component.startup.whitelist.normal=true
|
||||
component.startup.whitelist.associatedWakeUp=true
|
||||
|
@ -15,5 +15,4 @@ bootevent.appfwk.ready = foundation:foundation:0775
|
||||
component.startup.newRules = foundation:foundation:0775
|
||||
component.startup.newRules.except.LauncherSystemUI = foundation:foundation:0775
|
||||
component.startup.backgroundJudge.flag = foundation:foundation:0775
|
||||
component.startup.whitelist.normal = foundation:foundation:0775
|
||||
component.startup.whitelist.associatedWakeUp = foundation:foundation:0775
|
||||
|
@ -1330,7 +1330,7 @@ private:
|
||||
|
||||
static sptr<AbilityManagerService> instance_;
|
||||
int32_t uniqueId_ = 0;
|
||||
std::map<int32_t, std::pair<int64_t, const sptr<IAcquireShareDataCallback>&>> iAcquireShareDataMap_;
|
||||
std::map<int32_t, std::pair<int64_t, const sptr<IAcquireShareDataCallback>>> iAcquireShareDataMap_;
|
||||
|
||||
// Component StartUp rule switch
|
||||
bool startUpNewRule_ = true;
|
||||
@ -1344,11 +1344,6 @@ private:
|
||||
* FALSE: Determine the state by AppExecFwk::AppProcessState::APP_STATE_FOCUS.
|
||||
*/
|
||||
bool backgroundJudgeFlag_ = true;
|
||||
/** The applications in white list use old rule
|
||||
* TRUE: white list enable.
|
||||
* FALSE: white list unable.
|
||||
*/
|
||||
bool whiteListNormalFlag_ = true;
|
||||
/** The applications in white list can associatedWakeUp
|
||||
* TRUE: white list enable.
|
||||
* FALSE: white list unable.
|
||||
|
@ -831,6 +831,11 @@ public:
|
||||
return recordId_;
|
||||
}
|
||||
|
||||
inline int64_t GetForegroundingTime() const
|
||||
{
|
||||
return foregroundingTime_;
|
||||
}
|
||||
|
||||
void SetPendingState(AbilityState state);
|
||||
AbilityState GetPendingState() const;
|
||||
|
||||
@ -839,6 +844,7 @@ public:
|
||||
std::shared_ptr<AbilityRecord> GetOtherMissionStackAbilityRecord() const;
|
||||
void SetOtherMissionStackAbilityRecord(const std::shared_ptr<AbilityRecord> &abilityRecord);
|
||||
void RevokeUriPermission();
|
||||
void RemoveAbilityDeathRecipient() const;
|
||||
|
||||
protected:
|
||||
void SendEvent(uint32_t msg, uint32_t timeOut, int32_t param = -1);
|
||||
@ -855,7 +861,9 @@ private:
|
||||
*/
|
||||
void GetAbilityTypeString(std::string &typeStr);
|
||||
void OnSchedulerDied(const wptr<IRemoteObject> &remote);
|
||||
void GrantUriPermission(const Want &want, int32_t userId, std::string targetBundleName);
|
||||
void GrantUriPermission(Want &want, int32_t userId, std::string targetBundleName);
|
||||
void GrantDmsUriPermission(Want &want, std::string targetBundleName);
|
||||
bool IsDmsCall();
|
||||
int32_t GetCurrentAccountId() const;
|
||||
|
||||
/**
|
||||
@ -922,6 +930,7 @@ private:
|
||||
std::weak_ptr<AbilityRecord> nextAbilityRecord_ = {}; // ability that started by this ability
|
||||
int64_t startTime_ = 0; // records first time of ability start
|
||||
int64_t restartTime_ = 0; // the time of last trying restart
|
||||
int64_t foregroundingTime_ = 0; // the time of foregrounding to do
|
||||
bool isReady_ = false; // is ability thread attached?
|
||||
bool isWindowAttached_ = false; // Is window of this ability attached?
|
||||
bool isLauncherAbility_ = false; // is launcher?
|
||||
|
@ -229,7 +229,7 @@ static constexpr int64_t MICROSECONDS = 1000000; // MICROSECONDS mean 10^6 mi
|
||||
return false;
|
||||
}
|
||||
|
||||
[[maybe_unused]] static bool IsStartIncludeAtomicService(const Want &want, const int32_t callerUid)
|
||||
[[maybe_unused]] static bool IsStartIncludeAtomicService(const Want &want, const int32_t callerUid)
|
||||
{
|
||||
auto bms = GetBundleManager();
|
||||
if (!bms) {
|
||||
@ -239,9 +239,9 @@ static constexpr int64_t MICROSECONDS = 1000000; // MICROSECONDS mean 10^6 mi
|
||||
|
||||
std::string targetBundleName = want.GetBundle();
|
||||
AppExecFwk::ApplicationInfo targetAppInfo;
|
||||
bool result = IN_PROCESS_CALL(bms->GetApplicationInfo(targetBundleName,
|
||||
bool getTargetResult = IN_PROCESS_CALL(bms->GetApplicationInfo(targetBundleName,
|
||||
AppExecFwk::ApplicationFlag::GET_BASIC_APPLICATION_INFO, callerUid, targetAppInfo));
|
||||
if (!result) {
|
||||
if (!getTargetResult) {
|
||||
HILOG_ERROR("Get targetAppInfo failed in check atomic service.");
|
||||
return false;
|
||||
}
|
||||
@ -251,15 +251,15 @@ static constexpr int64_t MICROSECONDS = 1000000; // MICROSECONDS mean 10^6 mi
|
||||
}
|
||||
|
||||
std::string callerBundleName;
|
||||
result = IN_PROCESS_CALL(bms->GetBundleNameForUid(callerUid, callerBundleName));
|
||||
if (!result) {
|
||||
ErrCode err = IN_PROCESS_CALL(bms->GetNameForUid(callerUid, callerBundleName));
|
||||
if (err != ERR_OK) {
|
||||
HILOG_ERROR("Get bms failed in check atomic service.");
|
||||
return false;
|
||||
}
|
||||
AppExecFwk::ApplicationInfo callerAppInfo;
|
||||
result = IN_PROCESS_CALL(bms->GetApplicationInfo(callerBundleName,
|
||||
bool getCallerResult = IN_PROCESS_CALL(bms->GetApplicationInfo(callerBundleName,
|
||||
AppExecFwk::ApplicationFlag::GET_BASIC_APPLICATION_INFO, callerUid, callerAppInfo));
|
||||
if (!result) {
|
||||
if (!getCallerResult) {
|
||||
HILOG_ERROR("Get callerAppInfo failed in check atomic service.");
|
||||
return false;
|
||||
}
|
||||
|
@ -842,7 +842,6 @@ void AbilityConnectManager::PostTimeOutTask(const std::shared_ptr<AbilityRecord>
|
||||
std::string taskName;
|
||||
int resultCode;
|
||||
uint32_t delayTime;
|
||||
auto abilityMgr = DelayedSingleton<AbilityManagerService>::GetInstance();
|
||||
if (messageId == AbilityManagerService::LOAD_TIMEOUT_MSG) {
|
||||
// first load ability, There is at most one connect record.
|
||||
recordId = abilityRecord->GetRecordId();
|
||||
|
@ -99,20 +99,12 @@ const std::string IS_DELEGATOR_CALL = "isDelegatorCall";
|
||||
const std::string COMPONENT_STARTUP_NEW_RULES = "component.startup.newRules";
|
||||
const std::string NEW_RULES_EXCEPT_LAUNCHER_SYSTEMUI = "component.startup.newRules.except.LauncherSystemUI";
|
||||
const std::string BACKGROUND_JUDGE_FLAG = "component.startup.backgroundJudge.flag";
|
||||
const std::string WHITE_LIST_NORMAL_FLAG = "component.startup.whitelist.normal";
|
||||
const std::string WHITE_LIST_ASS_WAKEUP_FLAG = "component.startup.whitelist.associatedWakeUp";
|
||||
// White list app
|
||||
const std::string BUNDLE_NAME_LAUNCHER = "com.ohos.launcher";
|
||||
const std::string BUNDLE_NAME_SYSTEMUI = "com.ohos.systemui";
|
||||
const std::string BUNDLE_NAME_SETTINGSDATA = "com.ohos.settingsdata";
|
||||
const std::string BUNDLE_NAME_SERVICE_TEST = "com.amsst.stserviceabilityclient";
|
||||
const std::string BUNDLE_NAME_SERVICE_SERVER_TEST = "com.amsst.stserviceabilityserver";
|
||||
const std::string BUNDLE_NAME_SERVICE_SERVER2_TEST = "com.amsst.stserviceabilityserversecond";
|
||||
|
||||
// White list
|
||||
const std::unordered_set<std::string> WHITE_LIST_NORMAL_SET = { BUNDLE_NAME_SERVICE_TEST,
|
||||
BUNDLE_NAME_SERVICE_SERVER_TEST,
|
||||
BUNDLE_NAME_SERVICE_SERVER2_TEST };
|
||||
const std::unordered_set<std::string> WHITE_LIST_ASS_WAKEUP_SET = { BUNDLE_NAME_SETTINGSDATA };
|
||||
} // namespace
|
||||
|
||||
@ -344,7 +336,6 @@ void AbilityManagerService::InitStartupFlag()
|
||||
startUpNewRule_ = CheckNewRuleSwitchState(COMPONENT_STARTUP_NEW_RULES);
|
||||
newRuleExceptLauncherSystemUI_ = CheckNewRuleSwitchState(NEW_RULES_EXCEPT_LAUNCHER_SYSTEMUI);
|
||||
backgroundJudgeFlag_ = CheckNewRuleSwitchState(BACKGROUND_JUDGE_FLAG);
|
||||
whiteListNormalFlag_ = CheckNewRuleSwitchState(WHITE_LIST_NORMAL_FLAG);
|
||||
whiteListassociatedWakeUpFlag_ = CheckNewRuleSwitchState(WHITE_LIST_ASS_WAKEUP_FLAG);
|
||||
}
|
||||
|
||||
@ -3857,7 +3848,7 @@ int32_t AbilityManagerService::GetShareDataPairAndReturnData(std::shared_ptr<Abi
|
||||
auto it = iAcquireShareDataMap_.find(uniqueId);
|
||||
if (it != iAcquireShareDataMap_.end()) {
|
||||
auto shareDataPair = it->second;
|
||||
if (!abilityRecord || shareDataPair.first != abilityRecord->GetAbilityRecordId()) {
|
||||
if (abilityRecord && shareDataPair.first != abilityRecord->GetAbilityRecordId()) {
|
||||
HILOG_ERROR("abilityRecord is not the abilityRecord from request.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
@ -6073,9 +6064,6 @@ bool AbilityManagerService::IsUseNewStartUpRule(const AbilityRequest &abilityReq
|
||||
if (callerAbility) {
|
||||
const std::string bundleName = callerAbility->GetApplicationInfo().bundleName;
|
||||
HILOG_DEBUG("IsUseNewStartUpRule, caller bundleName is %{public}s.", bundleName.c_str());
|
||||
if (whiteListNormalFlag_ && WHITE_LIST_NORMAL_SET.find(bundleName) != WHITE_LIST_NORMAL_SET.end()) {
|
||||
return false;
|
||||
}
|
||||
if (newRuleExceptLauncherSystemUI_ &&
|
||||
(bundleName == BUNDLE_NAME_LAUNCHER || bundleName == BUNDLE_NAME_SYSTEMUI)) {
|
||||
return false;
|
||||
@ -6370,7 +6358,7 @@ int32_t AbilityManagerService::AcquireShareData(
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
uniqueId_ = (uniqueId_ == INT_MAX) ? 0 : (uniqueId_ + 1);
|
||||
std::pair<int64_t, const sptr<IAcquireShareDataCallback>&> shareDataPair =
|
||||
std::pair<int64_t, const sptr<IAcquireShareDataCallback>> shareDataPair =
|
||||
std::make_pair(abilityRecord->GetAbilityRecordId(), shareData);
|
||||
iAcquireShareDataMap_.emplace(uniqueId_, shareDataPair);
|
||||
abilityRecord->ShareData(uniqueId_);
|
||||
|
@ -60,6 +60,7 @@ const std::string DLP_INDEX = "ohos.dlp.params.index";
|
||||
const std::string DLP_BUNDLE_NAME = "com.ohos.dlpmanager";
|
||||
const std::string COMPONENT_STARTUP_NEW_RULES = "component.startup.newRules";
|
||||
const std::string NEED_STARTINGWINDOW = "ohos.ability.NeedStartingWindow";
|
||||
const std::string PARAMS_URI = "ability.verify.uri";
|
||||
const uint32_t RELEASE_STARTING_BG_TIMEOUT = 15000; // release starting window resource timeout.
|
||||
int64_t AbilityRecord::abilityRecordId = 0;
|
||||
const int32_t DEFAULT_USER_ID = 0;
|
||||
@ -328,6 +329,7 @@ void AbilityRecord::ForegroundAbility(uint32_t sceneFlag)
|
||||
// schedule active after updating AbilityState and sending timeout message to avoid ability async callback
|
||||
// earlier than above actions.
|
||||
currentState_ = AbilityState::FOREGROUNDING;
|
||||
foregroundingTime_ = AbilityUtil::SystemTimeMillis();
|
||||
lifeCycleStateInfo_.sceneFlag = sceneFlag;
|
||||
lifecycleDeal_->ForegroundNew(want_, lifeCycleStateInfo_, sessionInfo_);
|
||||
lifeCycleStateInfo_.sceneFlag = 0;
|
||||
@ -478,6 +480,7 @@ void AbilityRecord::SetAbilityTransitionInfo(sptr<AbilityTransitionInfo>& info)
|
||||
info->maxWindowHeight_ = abilityInfo_.maxWindowHeight;
|
||||
info->minWindowHeight_ = abilityInfo_.minWindowHeight;
|
||||
info->orientation_ = abilityInfo_.orientation;
|
||||
info->apiCompatibleVersion_ = abilityInfo_.applicationInfo.apiCompatibleVersion;
|
||||
}
|
||||
|
||||
sptr<AbilityTransitionInfo> AbilityRecord::CreateAbilityTransitionInfo()
|
||||
@ -598,6 +601,7 @@ void AbilityRecord::SetAbilityTransitionInfo(const AppExecFwk::AbilityInfo &abil
|
||||
info->bundleName_ = abilityInfo.bundleName;
|
||||
info->windowModes_ = abilityInfo.windowModes;
|
||||
info->orientation_ = abilityInfo.orientation;
|
||||
info->apiCompatibleVersion_ = abilityInfo.applicationInfo.apiCompatibleVersion;
|
||||
SetShowWhenLocked(abilityInfo, info);
|
||||
}
|
||||
|
||||
@ -1779,6 +1783,25 @@ void AbilityRecord::DumpService(std::vector<std::string> &info, std::vector<std:
|
||||
DumpClientInfo(info, params, isClient);
|
||||
}
|
||||
|
||||
void AbilityRecord::RemoveAbilityDeathRecipient() const
|
||||
{
|
||||
if (scheduler_ == nullptr) {
|
||||
HILOG_WARN("scheduler_ is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (schedulerDeathRecipient_ == nullptr) {
|
||||
HILOG_WARN("schedulerDeathRecipient_ is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
auto schedulerObject = scheduler_->AsObject();
|
||||
if (schedulerObject != nullptr) {
|
||||
HILOG_INFO("RemoveDeathRecipient");
|
||||
schedulerObject->RemoveDeathRecipient(schedulerDeathRecipient_);
|
||||
}
|
||||
}
|
||||
|
||||
void AbilityRecord::OnSchedulerDied(const wptr<IRemoteObject> &remote)
|
||||
{
|
||||
HILOG_WARN("On scheduler died.");
|
||||
@ -1804,7 +1827,6 @@ void AbilityRecord::OnSchedulerDied(const wptr<IRemoteObject> &remote)
|
||||
schedulerObject->RemoveDeathRecipient(schedulerDeathRecipient_);
|
||||
}
|
||||
}
|
||||
scheduler_.clear();
|
||||
CHECK_POINTER(lifecycleDeal_);
|
||||
lifecycleDeal_->SetScheduler(nullptr);
|
||||
isWindowAttached_ = false;
|
||||
@ -1828,19 +1850,12 @@ void AbilityRecord::OnSchedulerDied(const wptr<IRemoteObject> &remote)
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
// notify winddow manager service the ability died
|
||||
if (missionId_ != -1) {
|
||||
auto task = [me = weak_from_this()]() {
|
||||
auto self = me.lock();
|
||||
if (self == nullptr) {
|
||||
HILOG_ERROR("Ability is invalid.");
|
||||
return;
|
||||
}
|
||||
if (self->GetWMSHandler()) {
|
||||
sptr<AbilityTransitionInfo> info = new AbilityTransitionInfo();
|
||||
self->SetAbilityTransitionInfo(info);
|
||||
self->GetWMSHandler()->NotifyAnimationAbilityDied(info);
|
||||
}
|
||||
};
|
||||
handler->PostTask(task);
|
||||
if (GetWMSHandler()) {
|
||||
sptr<AbilityTransitionInfo> info = new AbilityTransitionInfo();
|
||||
SetAbilityTransitionInfo(info);
|
||||
HILOG_INFO("Notification window manager UIAbiltiy abnormal death.");
|
||||
GetWMSHandler()->NotifyAnimationAbilityDied(info);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
HandleDlpClosed();
|
||||
@ -2265,17 +2280,21 @@ void AbilityRecord::DumpAbilityInfoDone(std::vector<std::string> &infos)
|
||||
dumpCondition_.notify_all();
|
||||
}
|
||||
|
||||
void AbilityRecord::GrantUriPermission(const Want &want, int32_t userId, std::string targetBundleName)
|
||||
void AbilityRecord::GrantUriPermission(Want &want, int32_t userId, std::string targetBundleName)
|
||||
{
|
||||
if ((want.GetFlags() & (Want::FLAG_AUTH_READ_URI_PERMISSION | Want::FLAG_AUTH_WRITE_URI_PERMISSION)) == 0) {
|
||||
HILOG_WARN("Do not call uriPermissionMgr.");
|
||||
return;
|
||||
}
|
||||
|
||||
auto bms = AbilityUtil::GetBundleManager();
|
||||
CHECK_POINTER_IS_NULLPTR(bms);
|
||||
auto&& uriStr = want.GetUri().ToString();
|
||||
auto&& uriVec = want.GetStringArrayParam(AbilityConfig::PARAMS_STREAM);
|
||||
if (IsDmsCall()) {
|
||||
GrantDmsUriPermission(want, targetBundleName);
|
||||
return;
|
||||
}
|
||||
std::vector<std::string> uriVec;
|
||||
std::string uriStr = want.GetUri().ToString();
|
||||
uriVec = want.GetStringArrayParam(AbilityConfig::PARAMS_STREAM);
|
||||
uriVec.emplace_back(uriStr);
|
||||
HILOG_DEBUG("GrantUriPermission uriVec size: %{public}zu", uriVec.size());
|
||||
auto upmClient = AAFwk::UriPermissionManagerClient::GetInstance();
|
||||
@ -2311,6 +2330,49 @@ void AbilityRecord::GrantUriPermission(const Want &want, int32_t userId, std::st
|
||||
}
|
||||
}
|
||||
|
||||
bool AbilityRecord::IsDmsCall()
|
||||
{
|
||||
auto fromTokenId = IPCSkeleton::GetCallingTokenID();
|
||||
auto tokenType = Security::AccessToken::AccessTokenKit::GetTokenTypeFlag(fromTokenId);
|
||||
bool isNativeCall = tokenType == Security::AccessToken::ATokenTypeEnum::TOKEN_NATIVE;
|
||||
if (!isNativeCall) {
|
||||
HILOG_INFO("Is not native call.");
|
||||
return false;
|
||||
}
|
||||
AccessToken::NativeTokenInfo nativeTokenInfo;
|
||||
int32_t result = AccessToken::AccessTokenKit::GetNativeTokenInfo(fromTokenId, nativeTokenInfo);
|
||||
if (result == ERR_OK && nativeTokenInfo.processName == DMS_PROCESS_NAME) {
|
||||
HILOG_INFO("Is dms ability call.");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void AbilityRecord::GrantDmsUriPermission(Want &want, std::string targetBundleName)
|
||||
{
|
||||
std::vector<std::string> uriVec = want.GetStringArrayParam(PARAMS_URI);
|
||||
HILOG_DEBUG("GrantDmsUriPermission uriVec size: %{public}zu", uriVec.size());
|
||||
auto upmClient = AAFwk::UriPermissionManagerClient::GetInstance();
|
||||
for (auto&& str : uriVec) {
|
||||
Uri uri(str);
|
||||
auto&& scheme = uri.GetScheme();
|
||||
HILOG_INFO("uri scheme is %{public}s.", scheme.c_str());
|
||||
// only support file scheme
|
||||
if (scheme != "file") {
|
||||
HILOG_WARN("only support file uri.");
|
||||
continue;
|
||||
}
|
||||
int autoremove = 1;
|
||||
auto ret = IN_PROCESS_CALL(upmClient->GrantUriPermission(uri, want.GetFlags(),
|
||||
targetBundleName, autoremove));
|
||||
if (ret) {
|
||||
isGrantedUriPermission_ = true;
|
||||
}
|
||||
}
|
||||
uriVec.clear();
|
||||
want.SetParam(PARAMS_URI, uriVec);
|
||||
}
|
||||
|
||||
void AbilityRecord::RevokeUriPermission()
|
||||
{
|
||||
if (isGrantedUriPermission_) {
|
||||
|
@ -39,6 +39,7 @@ constexpr char EVENT_KEY_PACKAGE_NAME[] = "PACKAGE_NAME";
|
||||
constexpr char EVENT_KEY_PROCESS_NAME[] = "PROCESS_NAME";
|
||||
constexpr int32_t MAX_INSTANCE_COUNT = 512;
|
||||
constexpr uint64_t NANO_SECOND_PER_SEC = 1000000000; // ns
|
||||
constexpr int64_t MAX_FOREGROUNDING_TIME = 60 * 1000; // 1 minute
|
||||
const std::string DMS_SRC_NETWORK_ID = "dmsSrcNetworkId";
|
||||
const std::string DMS_MISSION_ID = "dmsMissionId";
|
||||
const int DEFAULT_DMS_MISSION_ID = -1;
|
||||
@ -135,9 +136,16 @@ int MissionListManager::StartAbility(AbilityRequest &abilityRequest)
|
||||
HILOG_DEBUG("current top: %{public}s, state: %{public}s",
|
||||
element.c_str(), AbilityRecord::ConvertAbilityState(state).c_str());
|
||||
if (state == FOREGROUNDING) {
|
||||
HILOG_INFO("Top ability:%{public}s is foregrounding, so enqueue ability for waiting.", element.c_str());
|
||||
EnqueueWaitingAbility(abilityRequest);
|
||||
return START_ABILITY_WAITING;
|
||||
auto foregroundingTime = currentTopAbility->GetForegroundingTime();
|
||||
auto currentTime = AbilityUtil::SystemTimeMillis();
|
||||
if (currentTime - foregroundingTime > MAX_FOREGROUNDING_TIME) {
|
||||
HILOG_INFO("Top ability:%{public}s is foregrounding and more than one minute.", element.c_str());
|
||||
OnTimeOut(AbilityManagerService::FOREGROUND_TIMEOUT_MSG, currentTopAbility->GetAbilityRecordId());
|
||||
} else {
|
||||
HILOG_INFO("Top ability:%{public}s is foregrounding, so enqueue ability for waiting.", element.c_str());
|
||||
EnqueueWaitingAbility(abilityRequest);
|
||||
return START_ABILITY_WAITING;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1538,6 +1546,7 @@ void MissionListManager::CompleteTerminate(const std::shared_ptr<AbilityRecord>
|
||||
HILOG_ERROR("%{public}s, ability is not terminating.", __func__);
|
||||
return;
|
||||
}
|
||||
abilityRecord->RemoveAbilityDeathRecipient();
|
||||
|
||||
// notify AppMS terminate
|
||||
if (abilityRecord->TerminateAbility() != ERR_OK) {
|
||||
@ -1647,6 +1656,8 @@ int MissionListManager::ClearMissionLocked(int missionId, const std::shared_ptr<
|
||||
|
||||
abilityRecord->SetTerminatingState();
|
||||
abilityRecord->SetClearMissionFlag(true);
|
||||
Want want;
|
||||
abilityRecord->SaveResultToCallers(-1, &want);
|
||||
auto ret = TerminateAbilityLocked(abilityRecord, false);
|
||||
if (ret != ERR_OK) {
|
||||
HILOG_ERROR("clear mission error: %{public}d.", ret);
|
||||
@ -1872,14 +1883,14 @@ void MissionListManager::UpdateMissionSnapshot(const std::shared_ptr<AbilityReco
|
||||
|
||||
void MissionListManager::OnTimeOut(uint32_t msgId, int64_t abilityRecordId)
|
||||
{
|
||||
HILOG_DEBUG("On timeout, msgId is %{public}d", msgId);
|
||||
HILOG_INFO("On timeout, msgId is %{public}d", msgId);
|
||||
std::lock_guard<std::recursive_mutex> guard(managerLock_);
|
||||
auto abilityRecord = GetAbilityRecordById(abilityRecordId);
|
||||
if (abilityRecord == nullptr) {
|
||||
HILOG_ERROR("MissionListManager on time out event: ability record is nullptr.");
|
||||
return;
|
||||
}
|
||||
HILOG_DEBUG("Ability timeout,msg:%{public}d,name:%{public}s", msgId, abilityRecord->GetAbilityInfo().name.c_str());
|
||||
HILOG_INFO("Ability timeout, name:%{public}s", abilityRecord->GetAbilityInfo().name.c_str());
|
||||
abilityRecord->RevokeUriPermission();
|
||||
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
@ -1934,6 +1945,11 @@ void MissionListManager::HandleForegroundTimeout(const std::shared_ptr<AbilityRe
|
||||
ability->GetMission()->SetMovingState(false);
|
||||
}
|
||||
|
||||
if (!ability->IsAbilityState(AbilityState::FOREGROUNDING)) {
|
||||
HILOG_ERROR("this ability is not foregrounding state.");
|
||||
return;
|
||||
}
|
||||
|
||||
// root launcher load timeout, notify appMs force terminate the ability and restart immediately.
|
||||
if (ability->IsLauncherAbility() && ability->IsLauncherRoot()) {
|
||||
DelayedSingleton<AppScheduler>::GetInstance()->AttachTimeOut(ability->GetToken());
|
||||
|
@ -193,7 +193,7 @@ void AppMgrServiceInner::LoadAbility(const sptr<IRemoteObject> &token, const spt
|
||||
StartProcess(abilityInfo->applicationName, processName, startFlags, appRecord,
|
||||
appInfo->uid, appInfo->bundleName, bundleIndex, appExistFlag);
|
||||
std::string perfCmd = (want == nullptr) ? "" : want->GetStringParam(PERF_CMD);
|
||||
bool isSanboxApp = want->GetBoolParam(ENTER_SANBOX, false);
|
||||
bool isSanboxApp = (want == nullptr) ? false : want->GetBoolParam(ENTER_SANBOX, false);
|
||||
(void)StartPerfProcess(appRecord, perfCmd, "", isSanboxApp);
|
||||
} else {
|
||||
int32_t requestProcCode = (want == nullptr) ? 0 : want->GetIntParam(Want::PARAM_RESV_REQUEST_PROC_CODE, 0);
|
||||
|
@ -20,7 +20,7 @@
|
||||
<libpath>libupms.z.so</libpath>
|
||||
<!--<depend></depend> --> <!-- Declare the name of system abilities which the system ability depends on. Note that one dependency uses 1 line. If there are dependencies, it needs to check if all those dependencies are available in service manager before starting the system ability. -->
|
||||
<!--<depend-time-out></depend-time-out> --> <!-- Check all dependencies are available before the timeout period ended. The MAX_DEPENDENCY_TIMEOUT is 60s. -->
|
||||
<run-on-create>true</run-on-create>
|
||||
<run-on-create>false</run-on-create>
|
||||
<distributed>false</distributed>
|
||||
<dump-level>1</dump-level>
|
||||
</systemability>
|
||||
|
@ -38,6 +38,7 @@ using TokenId = Security::AccessToken::AccessTokenID;
|
||||
int UriPermissionManagerStubImpl::GrantUriPermission(const Uri &uri, unsigned int flag,
|
||||
const std::string targetBundleName, int autoremove)
|
||||
{
|
||||
HILOG_DEBUG("UriPermissionManagerStubImpl::GrantUriPermission is called.");
|
||||
if ((flag & (Want::FLAG_AUTH_READ_URI_PERMISSION | Want::FLAG_AUTH_WRITE_URI_PERMISSION)) == 0) {
|
||||
HILOG_WARN("UriPermissionManagerStubImpl::GrantUriPermission: The param flag is invalid.");
|
||||
return INNER_ERR;
|
||||
|
@ -41,6 +41,7 @@ ohos_fuzztest("WantAgentHelperStringFuzzTest") {
|
||||
"ability_base:want",
|
||||
"ability_runtime:wantagent_innerkits",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ ohos_fuzztest("WantAgentHelperTriggerFuzzTest") {
|
||||
"ability_base:want",
|
||||
"ability_runtime:wantagent_innerkits",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
}
|
||||
|
@ -88,6 +88,10 @@ public:
|
||||
{
|
||||
return true;
|
||||
}
|
||||
void RegisterQuickFixQueryFunc(const std::map<std::string, std::string>& moduleAndPath) override
|
||||
{
|
||||
return;
|
||||
}
|
||||
public:
|
||||
Language language;
|
||||
};
|
||||
|
@ -400,6 +400,7 @@ group("unittest") {
|
||||
"task_data_persistence_mgr_test:unittest",
|
||||
"trigger_Info_test:unittest",
|
||||
"uri_permission_impl_test:unittest",
|
||||
"uri_permission_manager_test:unittest",
|
||||
"uri_permission_test:unittest",
|
||||
"user_controller_test:unittest",
|
||||
"user_event_handler_test:unittest",
|
||||
|
@ -1903,6 +1903,7 @@ HWTEST_F(AbilityRecordTest, AbilityRecord_AddSystemAbilityCallerRecord_002, Test
|
||||
HWTEST_F(AbilityRecordTest, AbilityRecord_GetConnectingRecordList_001, TestSize.Level1)
|
||||
{
|
||||
std::shared_ptr<AbilityRecord> abilityRecord = GetAbilityRecord();
|
||||
EXPECT_NE(abilityRecord, nullptr);
|
||||
OHOS::sptr<IAbilityConnection> callback = new AbilityConnectCallback();
|
||||
std::shared_ptr<ConnectionRecord> connection1 =
|
||||
std::make_shared<ConnectionRecord>(abilityRecord->GetToken(), abilityRecord, callback);
|
||||
|
@ -51,6 +51,7 @@ void AmsAppStateCallBackTest::TearDown()
|
||||
HWTEST_F(AmsAppStateCallBackTest, OnRemoteRequest_001, TestSize.Level1)
|
||||
{
|
||||
sptr<AppStateCallbackHost> host(new AppStateCallbackHost());
|
||||
EXPECT_NE(host, nullptr);
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option{ MessageOption::TF_ASYNC };
|
||||
@ -63,8 +64,6 @@ HWTEST_F(AmsAppStateCallBackTest, OnRemoteRequest_001, TestSize.Level1)
|
||||
processData.pid = 1;
|
||||
processData.appState = ApplicationState::APP_STATE_FOREGROUND;
|
||||
data.WriteParcelable(&processData);
|
||||
int32_t ret = 0;
|
||||
EXPECT_EQ(0, ret);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -78,6 +77,7 @@ HWTEST_F(AmsAppStateCallBackTest, OnRemoteRequest_001, TestSize.Level1)
|
||||
HWTEST_F(AmsAppStateCallBackTest, OnRemoteRequest_002, TestSize.Level1)
|
||||
{
|
||||
sptr<AppStateCallbackHost> host(new AppStateCallbackHost());
|
||||
EXPECT_NE(host, nullptr);
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option{ MessageOption::TF_ASYNC };
|
||||
@ -86,8 +86,6 @@ HWTEST_F(AmsAppStateCallBackTest, OnRemoteRequest_002, TestSize.Level1)
|
||||
data.WriteParcelable(token.GetRefPtr());
|
||||
int32_t abilityState = static_cast<int32_t>(AbilityState::ABILITY_STATE_FOREGROUND);
|
||||
data.WriteInt32(abilityState);
|
||||
int32_t ret = 0;
|
||||
EXPECT_EQ(0, ret);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -103,10 +101,8 @@ HWTEST_F(AmsAppStateCallBackTest, OnAbilityRequestDone_001, TestSize.Level1)
|
||||
sptr<IRemoteObject> token = nullptr;
|
||||
AbilityState state = AbilityState::ABILITY_STATE_CREATE;
|
||||
sptr<AppStateCallbackHost> host(new AppStateCallbackHost());
|
||||
EXPECT_NE(host, nullptr);
|
||||
host->OnAbilityRequestDone(token, state);
|
||||
|
||||
int32_t ret = 0;
|
||||
EXPECT_EQ(0, ret);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -121,10 +117,8 @@ HWTEST_F(AmsAppStateCallBackTest, OnAppStateChanged_001, TestSize.Level1)
|
||||
{
|
||||
AppProcessData data;
|
||||
sptr<AppStateCallbackHost> host(new AppStateCallbackHost());
|
||||
EXPECT_NE(host, nullptr);
|
||||
host->OnAppStateChanged(data);
|
||||
|
||||
int32_t ret = 0;
|
||||
EXPECT_EQ(0, ret);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -334,7 +334,6 @@ HWTEST_F(AppMgrClientTest, AppMgrClient_AbilityAttachTimeOut_001, TestSize.Level
|
||||
HWTEST_F(AppMgrClientTest, AppMgrClient_PrepareTerminate_001, TestSize.Level0)
|
||||
{
|
||||
sptr<IRemoteObject> token = nullptr;
|
||||
int32_t ret = 0;
|
||||
auto appMgrClient = std::make_unique<AppMgrClient>();
|
||||
EXPECT_NE(appMgrClient, nullptr);
|
||||
|
||||
@ -342,7 +341,6 @@ HWTEST_F(AppMgrClientTest, AppMgrClient_PrepareTerminate_001, TestSize.Level0)
|
||||
EXPECT_EQ(result, AppMgrResultCode::RESULT_OK);
|
||||
|
||||
appMgrClient->PrepareTerminate(token);
|
||||
EXPECT_EQ(0, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -353,7 +351,6 @@ HWTEST_F(AppMgrClientTest, AppMgrClient_PrepareTerminate_001, TestSize.Level0)
|
||||
HWTEST_F(AppMgrClientTest, AppMgrClient_AddAbilityStageDone_001, TestSize.Level0)
|
||||
{
|
||||
int32_t recordId = INIT_VALUE;
|
||||
int32_t ret = 0;
|
||||
auto appMgrClient = std::make_unique<AppMgrClient>();
|
||||
EXPECT_NE(appMgrClient, nullptr);
|
||||
|
||||
@ -361,7 +358,6 @@ HWTEST_F(AppMgrClientTest, AppMgrClient_AddAbilityStageDone_001, TestSize.Level0
|
||||
EXPECT_EQ(result, AppMgrResultCode::RESULT_OK);
|
||||
|
||||
appMgrClient->AddAbilityStageDone(recordId);
|
||||
EXPECT_EQ(0, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -372,7 +368,6 @@ HWTEST_F(AppMgrClientTest, AppMgrClient_AddAbilityStageDone_001, TestSize.Level0
|
||||
HWTEST_F(AppMgrClientTest, AppMgrClient_StartupResidentProcess_001, TestSize.Level0)
|
||||
{
|
||||
std::vector<AppExecFwk::BundleInfo> bundleInfos;
|
||||
int32_t ret = 0;
|
||||
auto appMgrClient = std::make_unique<AppMgrClient>();
|
||||
EXPECT_NE(appMgrClient, nullptr);
|
||||
|
||||
@ -380,7 +375,6 @@ HWTEST_F(AppMgrClientTest, AppMgrClient_StartupResidentProcess_001, TestSize.Lev
|
||||
EXPECT_EQ(result, AppMgrResultCode::RESULT_OK);
|
||||
|
||||
appMgrClient->StartupResidentProcess(bundleInfos);
|
||||
EXPECT_EQ(0, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -392,7 +386,6 @@ HWTEST_F(AppMgrClientTest, AppMgrClient_StartSpecifiedAbility_001, TestSize.Leve
|
||||
{
|
||||
AAFwk::Want want;
|
||||
AppExecFwk::AbilityInfo abilityInfo;
|
||||
int32_t ret = 0;
|
||||
auto appMgrClient = std::make_unique<AppMgrClient>();
|
||||
EXPECT_NE(appMgrClient, nullptr);
|
||||
|
||||
@ -400,7 +393,6 @@ HWTEST_F(AppMgrClientTest, AppMgrClient_StartSpecifiedAbility_001, TestSize.Leve
|
||||
EXPECT_EQ(result, AppMgrResultCode::RESULT_OK);
|
||||
|
||||
appMgrClient->StartSpecifiedAbility(want, abilityInfo);
|
||||
EXPECT_EQ(0, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -411,7 +403,6 @@ HWTEST_F(AppMgrClientTest, AppMgrClient_StartSpecifiedAbility_001, TestSize.Leve
|
||||
HWTEST_F(AppMgrClientTest, AppMgrClient_RegisterStartSpecifiedAbilityResponse_001, TestSize.Level0)
|
||||
{
|
||||
sptr<IStartSpecifiedAbilityResponse> response = nullptr;
|
||||
int32_t ret = 0;
|
||||
auto appMgrClient = std::make_unique<AppMgrClient>();
|
||||
EXPECT_NE(appMgrClient, nullptr);
|
||||
|
||||
@ -419,7 +410,6 @@ HWTEST_F(AppMgrClientTest, AppMgrClient_RegisterStartSpecifiedAbilityResponse_00
|
||||
EXPECT_EQ(result, AppMgrResultCode::RESULT_OK);
|
||||
|
||||
appMgrClient->RegisterStartSpecifiedAbilityResponse(response);
|
||||
EXPECT_EQ(0, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -432,7 +422,6 @@ HWTEST_F(AppMgrClientTest, AppMgrClient_ScheduleAcceptWantDone_001, TestSize.Lev
|
||||
int32_t recordId = INIT_VALUE;
|
||||
AAFwk::Want want;
|
||||
std::string flag = EMPTY_STRING;
|
||||
int32_t ret = 0;
|
||||
auto appMgrClient = std::make_unique<AppMgrClient>();
|
||||
EXPECT_NE(appMgrClient, nullptr);
|
||||
|
||||
@ -440,7 +429,6 @@ HWTEST_F(AppMgrClientTest, AppMgrClient_ScheduleAcceptWantDone_001, TestSize.Lev
|
||||
EXPECT_EQ(result, AppMgrResultCode::RESULT_OK);
|
||||
|
||||
appMgrClient->ScheduleAcceptWantDone(recordId, want, flag);
|
||||
EXPECT_EQ(0, ret);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -393,14 +393,11 @@ HWTEST_F(AppMgrServiceInnerTest, SendProcessExitEvent_001, TestSize.Level1)
|
||||
HWTEST_F(AppMgrServiceInnerTest, UpDateStartupType_001, TestSize.Level1)
|
||||
{
|
||||
HILOG_INFO("UpDateStartupType_001 start");
|
||||
constexpr int32_t defaultVal = -1;
|
||||
auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
|
||||
EXPECT_NE(appMgrServiceInner, nullptr);
|
||||
int32_t abilityType = -1;
|
||||
int32_t extensionType = -1;
|
||||
appMgrServiceInner->UpDateStartupType(nullptr, abilityType, extensionType);
|
||||
EXPECT_EQ(defaultVal, abilityType);
|
||||
EXPECT_EQ(defaultVal, extensionType);
|
||||
HILOG_INFO("UpDateStartupType_001 end");
|
||||
}
|
||||
|
||||
@ -413,7 +410,6 @@ HWTEST_F(AppMgrServiceInnerTest, UpDateStartupType_002, TestSize.Level1)
|
||||
{
|
||||
HILOG_INFO("UpDateStartupType_002 start");
|
||||
constexpr int32_t expectedVal = 3;
|
||||
constexpr int32_t defaultVal = -1;
|
||||
auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
|
||||
EXPECT_NE(appMgrServiceInner, nullptr);
|
||||
auto info = std::make_shared<AbilityInfo>();
|
||||
@ -422,7 +418,6 @@ HWTEST_F(AppMgrServiceInnerTest, UpDateStartupType_002, TestSize.Level1)
|
||||
int32_t extensionType = -1;
|
||||
appMgrServiceInner->UpDateStartupType(info, abilityType, extensionType);
|
||||
EXPECT_EQ(expectedVal, abilityType);
|
||||
EXPECT_EQ(defaultVal, extensionType);
|
||||
HILOG_INFO("UpDateStartupType_002 end");
|
||||
}
|
||||
|
||||
|
@ -281,6 +281,18 @@ RState GetDrawableInfoByName(const char *name, std::string &type, size_t &len,
|
||||
{
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
RState GetStringFormatById(uint32_t id, std::string &outValue,
|
||||
std::vector<std::tuple<ResourceManager::NapiValueType, std::string>> &jsParams)
|
||||
{
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
RState GetStringFormatByName(const char *name, std::string &outValue,
|
||||
std::vector<std::tuple<ResourceManager::NapiValueType, std::string>> &jsParams)
|
||||
{
|
||||
return SUCCESS;
|
||||
}
|
||||
};
|
||||
} // namespace Resource
|
||||
} // namespace Global
|
||||
|
@ -5282,6 +5282,7 @@ HWTEST_F(MissionListManagerTest, EraseWaitingAbility_001, TestSize.Level1)
|
||||
{
|
||||
int userId = 3;
|
||||
auto missionListManager = std::make_shared<MissionListManager>(userId);
|
||||
EXPECT_NE(missionListManager, nullptr);
|
||||
std::shared_ptr<MissionList> missionList = std::make_shared<MissionList>();
|
||||
std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
|
||||
std::shared_ptr<Mission> mission = std::make_shared<Mission>(1, abilityRecord);
|
||||
@ -5407,6 +5408,7 @@ HWTEST_F(MissionListManagerTest, GetAllForegroundAbilities_001, TestSize.Level1)
|
||||
{
|
||||
int userId = 3;
|
||||
auto missionListManager = std::make_shared<MissionListManager>(userId);
|
||||
EXPECT_NE(missionListManager, nullptr);
|
||||
std::shared_ptr<MissionList> missionList = std::make_shared<MissionList>();
|
||||
std::list<std::shared_ptr<AbilityRecord>> foregroundList;
|
||||
missionList->missions_.clear();
|
||||
@ -5429,6 +5431,7 @@ HWTEST_F(MissionListManagerTest, GetForegroundAbilities_001, TestSize.Level1)
|
||||
{
|
||||
int userId = 3;
|
||||
auto missionListManager = std::make_shared<MissionListManager>(userId);
|
||||
EXPECT_NE(missionListManager, nullptr);
|
||||
std::shared_ptr<MissionList> missionList = std::make_shared<MissionList>();
|
||||
std::list<std::shared_ptr<AbilityRecord>> foregroundList;
|
||||
missionList->missions_.clear();
|
||||
@ -5611,6 +5614,7 @@ HWTEST_F(MissionListManagerTest, SetMissionANRStateByTokens_003, TestSize.Level1
|
||||
{
|
||||
int userId = 3;
|
||||
auto missionListManager = std::make_shared<MissionListManager>(userId);
|
||||
EXPECT_NE(missionListManager, nullptr);
|
||||
std::shared_ptr<MissionList> missionList = std::make_shared<MissionList>();
|
||||
std::shared_ptr<AbilityRecord> abilityRecord = InitAbilityRecord();
|
||||
std::vector<sptr<IRemoteObject>> tokens;
|
||||
|
@ -115,6 +115,7 @@ HWTEST_F(QuickFixManagerServiceTest, GetApplyedQuickFixInfo_0100, TestSize.Level
|
||||
HWTEST_F(QuickFixManagerServiceTest, ApplyAndRemoveTask_0100, TestSize.Level1)
|
||||
{
|
||||
HILOG_INFO("%{public}s start.", __func__);
|
||||
EXPECT_NE(quickFixMs_, nullptr);
|
||||
quickFixMs_->RemoveApplyTask(nullptr);
|
||||
quickFixMs_->AddApplyTask(nullptr);
|
||||
|
||||
|
@ -21,6 +21,25 @@ config("coverage_flags") {
|
||||
ldflags = [ "--coverage" ]
|
||||
}
|
||||
|
||||
ohos_unittest("quickfix_callback_test") {
|
||||
module_out_path = module_output_path
|
||||
|
||||
include_dirs = [
|
||||
"${ability_runtime_native_path}/runtime",
|
||||
"${ability_runtime_native_path}/runtime/utils/include",
|
||||
]
|
||||
|
||||
sources = [ "js_quickfix_callback_test.cpp" ]
|
||||
|
||||
configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ]
|
||||
deps = []
|
||||
|
||||
external_deps = [
|
||||
"ability_runtime:runtime",
|
||||
"c_utils:utils",
|
||||
]
|
||||
}
|
||||
|
||||
ohos_unittest("runtime_test") {
|
||||
module_out_path = module_output_path
|
||||
|
||||
|
134
test/unittest/runtime_test/js_quickfix_callback_test.cpp
Normal file
134
test/unittest/runtime_test/js_quickfix_callback_test.cpp
Normal file
@ -0,0 +1,134 @@
|
||||
/*
|
||||
* 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 <gtest/gtest.h>
|
||||
|
||||
#include "js_quickfix_callback.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
class JsQuickfixCallbackTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
};
|
||||
|
||||
void JsQuickfixCallbackTest::SetUpTestCase()
|
||||
{}
|
||||
|
||||
void JsQuickfixCallbackTest::TearDownTestCase()
|
||||
{}
|
||||
|
||||
void JsQuickfixCallbackTest::SetUp()
|
||||
{}
|
||||
|
||||
void JsQuickfixCallbackTest::TearDown()
|
||||
{}
|
||||
|
||||
/**
|
||||
* @tc.name: JsQuickfixCallbackTest_0100
|
||||
* @tc.desc: JsQuickfixCallbackTest Test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(JsQuickfixCallbackTest, JsQuickfixCallbackTest_0100, TestSize.Level0)
|
||||
{
|
||||
std::string moudel = "<moudelName>";
|
||||
std::string hqfFile = "<hqfFile>";
|
||||
std::map<std::string, std::string> moduleAndPath;
|
||||
moduleAndPath.insert(std::make_pair(moudel, hqfFile));
|
||||
AbilityRuntime::JsQuickfixCallback jsQuickfixCallback(moduleAndPath);
|
||||
|
||||
std::string baseFileName = "<baseFileName>";
|
||||
std::string patchFileName;
|
||||
void* patchBuffer = nullptr;
|
||||
size_t patchSize = 0;
|
||||
bool res = jsQuickfixCallback(baseFileName, patchFileName, &patchBuffer, patchSize);
|
||||
EXPECT_FALSE(res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: JsQuickfixCallbackTest_0200
|
||||
* @tc.desc: JsQuickfixCallbackTest Test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(JsQuickfixCallbackTest, JsQuickfixCallbackTest_0200, TestSize.Level0)
|
||||
{
|
||||
std::string moudel = "<moudelName>";
|
||||
std::string hqfFile = "<hqfFile>";
|
||||
std::map<std::string, std::string> moduleAndPath;
|
||||
moduleAndPath.insert(std::make_pair(moudel, hqfFile));
|
||||
AbilityRuntime::JsQuickfixCallback jsQuickfixCallback(moduleAndPath);
|
||||
|
||||
std::string baseFileName = "baseFileName.abc";
|
||||
std::string patchFileName;
|
||||
void* patchBuffer = nullptr;
|
||||
size_t patchSize = 0;
|
||||
bool res = jsQuickfixCallback(baseFileName, patchFileName, &patchBuffer, patchSize);
|
||||
EXPECT_FALSE(res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: JsQuickfixCallbackTest_0300
|
||||
* @tc.desc: JsQuickfixCallbackTest Test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(JsQuickfixCallbackTest, JsQuickfixCallbackTest_0300, TestSize.Level0)
|
||||
{
|
||||
std::string moudel = "<moudelName>";
|
||||
std::string hqfFile = "<hqfFile>";
|
||||
std::map<std::string, std::string> moduleAndPath;
|
||||
moduleAndPath.insert(std::make_pair(moudel, hqfFile));
|
||||
AbilityRuntime::JsQuickfixCallback jsQuickfixCallback(moduleAndPath);
|
||||
|
||||
std::string baseFileName = "/data/storage/el1/bundle/entry/ets/modules.abc";
|
||||
std::string patchFileName;
|
||||
void* patchBuffer = nullptr;
|
||||
size_t patchSize = 0;
|
||||
bool res = jsQuickfixCallback(baseFileName, patchFileName, &patchBuffer, patchSize);
|
||||
EXPECT_FALSE(res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: JsQuickfixCallbackTest_0400
|
||||
* @tc.desc: JsQuickfixCallbackTest Test
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:
|
||||
*/
|
||||
HWTEST_F(JsQuickfixCallbackTest, JsQuickfixCallbackTest_0400, TestSize.Level0)
|
||||
{
|
||||
std::string moudel = "bundle";
|
||||
std::string hqfFile = "<hqfFile>";
|
||||
std::map<std::string, std::string> moduleAndPath;
|
||||
moduleAndPath.insert(std::make_pair(moudel, hqfFile));
|
||||
AbilityRuntime::JsQuickfixCallback jsQuickfixCallback(moduleAndPath);
|
||||
|
||||
std::string baseFileName = "/data/storage/el1/bundle/bundle/ets/modules.abc";
|
||||
std::string patchFileName;
|
||||
void* patchBuffer = nullptr;
|
||||
size_t patchSize = 0;
|
||||
bool res = jsQuickfixCallback(baseFileName, patchFileName, &patchBuffer, patchSize);
|
||||
EXPECT_FALSE(res);
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
@ -14,6 +14,7 @@
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <gtest/hwext/gtest-multithread.h>
|
||||
|
||||
#define private public
|
||||
#define protected public
|
||||
@ -29,6 +30,7 @@
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
using namespace testing::mt;
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
@ -580,5 +582,74 @@ HWTEST_F(JsRuntimeTest, JsRuntimeUpdateModuleNameAndAssetPathTest_0100, TestSize
|
||||
|
||||
HILOG_INFO("UpdateModuleNameAndAssetPath end");
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: JsRuntimeInitialize_0100
|
||||
* @tc.desc: Initialize js runtime in multi thread.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI6KODF
|
||||
*/
|
||||
HWTEST_F(JsRuntimeTest, JsRuntimeInitialize_0100, TestSize.Level0)
|
||||
{
|
||||
HILOG_INFO("Running in multi-thread, using default thread number.");
|
||||
|
||||
auto task = []() {
|
||||
HILOG_INFO("Running in thread %{public}d", gettid());
|
||||
AbilityRuntime::Runtime::Options options;
|
||||
options.loadAce = false;
|
||||
options.preload = false;
|
||||
options.isStageModel = false;
|
||||
|
||||
auto jsRuntime = AbilityRuntime::JsRuntime::Create(options);
|
||||
ASSERT_NE(jsRuntime, nullptr);
|
||||
EXPECT_NE(jsRuntime->GetEcmaVm(), nullptr);
|
||||
EXPECT_NE(jsRuntime->GetNativeEnginePointer(), nullptr);
|
||||
};
|
||||
|
||||
GTEST_RUN_TASK(task);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: JsRuntimeInitialize_0200
|
||||
* @tc.desc: preload js runtime.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI6KODF
|
||||
*/
|
||||
HWTEST_F(JsRuntimeTest, JsRuntimeInitialize_0200, TestSize.Level0)
|
||||
{
|
||||
AbilityRuntime::Runtime::Options options;
|
||||
options.preload = true;
|
||||
|
||||
auto jsRuntime = AbilityRuntime::JsRuntime::Create(options);
|
||||
ASSERT_NE(jsRuntime, nullptr);
|
||||
EXPECT_NE(jsRuntime->GetEcmaVm(), nullptr);
|
||||
EXPECT_NE(jsRuntime->GetNativeEnginePointer(), nullptr);
|
||||
|
||||
options.preload = false;
|
||||
jsRuntime = AbilityRuntime::JsRuntime::Create(options);
|
||||
ASSERT_NE(jsRuntime, nullptr);
|
||||
EXPECT_NE(jsRuntime->GetEcmaVm(), nullptr);
|
||||
EXPECT_NE(jsRuntime->GetNativeEnginePointer(), nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: RegisterQuickFixQueryFunc_0100
|
||||
* @tc.desc: JsRuntime test for RegisterQuickFixQueryFunc.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(JsRuntimeTest, RegisterQuickFixQueryFunc_0100, TestSize.Level0)
|
||||
{
|
||||
HILOG_INFO("RegisterQuickFixQueryFunc start");
|
||||
|
||||
auto jsRuntime = std::make_unique<JsRuntime>();
|
||||
EXPECT_TRUE(jsRuntime != nullptr);
|
||||
std::string moudel = "<moudelName>";
|
||||
std::string hqfFile = "<hqfFile>";
|
||||
std::map<std::string, std::string> moduleAndPath;
|
||||
moduleAndPath.insert(std::make_pair(moudel, hqfFile));
|
||||
jsRuntime->RegisterQuickFixQueryFunc(moduleAndPath);
|
||||
|
||||
HILOG_INFO("RegisterQuickFixQueryFunc end");
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
@ -84,6 +84,11 @@ public:
|
||||
GTEST_LOG_(INFO) << "MockJsRuntime::LoadSystemModule called";
|
||||
return nullptr;
|
||||
}
|
||||
bool GetFileBuffer(const std::string& filePath, std::string& fileFullName, std::vector<uint8_t>& buffer)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "MockJsRuntime::GetFileBuffer called";
|
||||
return true;
|
||||
}
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
@ -29,6 +29,7 @@ ohos_unittest("ability_util_test") {
|
||||
"ability_base:want",
|
||||
"ability_runtime:ability_manager",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ ohos_unittest("static_subscriber_stub_test") {
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
]
|
||||
|
45
test/unittest/uri_permission_manager_test/BUILD.gn
Normal file
45
test/unittest/uri_permission_manager_test/BUILD.gn
Normal file
@ -0,0 +1,45 @@
|
||||
# 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.
|
||||
|
||||
import("//build/test.gni")
|
||||
import("//foundation/ability/ability_runtime/ability_runtime.gni")
|
||||
|
||||
module_output_path = "ability_runtime/abilitymgr"
|
||||
|
||||
ohos_unittest("uri_permission_manager_test") {
|
||||
module_out_path = module_output_path
|
||||
|
||||
sources = [ "uri_permission_manager_test.cpp" ]
|
||||
|
||||
configs = [
|
||||
"${ability_runtime_services_path}/uripermmgr:upms_config",
|
||||
"${ability_runtime_innerkits_path}/uri_permission:uripermkit_public_config",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr",
|
||||
"${ability_runtime_services_path}/uripermmgr:libupms_static",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:zuri",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"storage_service:storage_manager_sa_proxy",
|
||||
]
|
||||
}
|
||||
|
||||
group("unittest") {
|
||||
testonly = true
|
||||
|
||||
deps = [ ":uri_permission_manager_test" ]
|
||||
}
|
@ -0,0 +1,112 @@
|
||||
/*
|
||||
* 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 <gtest/gtest.h>
|
||||
|
||||
#define private public
|
||||
#include "uri_permission_manager_client.h"
|
||||
#include "uri_permission_load_callback.h"
|
||||
#undef private
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
class UriPermissionManagerTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
static void TearDownTestCase();
|
||||
void SetUp() override;
|
||||
void TearDown() override;
|
||||
};
|
||||
|
||||
void UriPermissionManagerTest::SetUpTestCase() {}
|
||||
|
||||
void UriPermissionManagerTest::TearDownTestCase() {}
|
||||
|
||||
void UriPermissionManagerTest::SetUp() {}
|
||||
|
||||
void UriPermissionManagerTest::TearDown() {}
|
||||
|
||||
/*
|
||||
* Feature: UriPermissionManagerClient
|
||||
* Function: ConnectUriPermService
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: UriPermissionManagerClient ConnectUriPermService
|
||||
*/
|
||||
HWTEST_F(UriPermissionManagerTest, ConnectUriPermService_001, TestSize.Level1)
|
||||
{
|
||||
auto upmc = std::make_shared<UriPermissionManagerClient>();
|
||||
upmc->saLoadFinished_ = true;
|
||||
auto ret = upmc->ConnectUriPermService();
|
||||
EXPECT_TRUE(ret == nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: UriPermissionManagerClient
|
||||
* Function: ConnectUriPermService
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: UriPermissionManagerClient ConnectUriPermService
|
||||
*/
|
||||
HWTEST_F(UriPermissionManagerTest, ConnectUriPermService_002, TestSize.Level1)
|
||||
{
|
||||
auto upmc = std::make_shared<UriPermissionManagerClient>();
|
||||
sptr<IRemoteObject> remoteObject = new (std::nothrow) UriPermissionLoadCallback();
|
||||
upmc->SetUriPermMgr(remoteObject);
|
||||
auto ret = upmc->ConnectUriPermService();
|
||||
EXPECT_TRUE(ret != nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: UriPermissionManagerClient
|
||||
* Function: ConnectUriPermService
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: UriPermissionManagerClient ConnectUriPermService
|
||||
*/
|
||||
HWTEST_F(UriPermissionManagerTest, ConnectUriPermService_003, TestSize.Level1)
|
||||
{
|
||||
auto upmc = std::make_shared<UriPermissionManagerClient>();
|
||||
sptr<IRemoteObject> remoteObject = nullptr;
|
||||
upmc->SetUriPermMgr(remoteObject);
|
||||
auto ret = upmc->ConnectUriPermService();
|
||||
EXPECT_TRUE(ret == nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: UriPermissionManagerClient
|
||||
* Function: LoadUriPermService
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: UriPermissionManagerClient LoadUriPermService
|
||||
*/
|
||||
HWTEST_F(UriPermissionManagerTest, LoadUriPermService_001, TestSize.Level1)
|
||||
{
|
||||
auto upmc = std::make_shared<UriPermissionManagerClient>();
|
||||
auto ret = upmc->LoadUriPermService();
|
||||
EXPECT_FALSE(ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature: UriPermissionManagerClient
|
||||
* Function: LoadUriPermService
|
||||
* SubFunction: NA
|
||||
* FunctionPoints: UriPermissionManagerClient LoadUriPermService
|
||||
*/
|
||||
HWTEST_F(UriPermissionManagerTest, LoadUriPermService_002, TestSize.Level1)
|
||||
{
|
||||
auto upmc = std::make_shared<UriPermissionManagerClient>();
|
||||
upmc->saLoadFinished_ = true;
|
||||
auto ret = upmc->LoadUriPermService();
|
||||
EXPECT_TRUE(ret);
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
Loading…
Reference in New Issue
Block a user