mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 22:21:36 -04:00
!7972 Hilog日志规范化整改interfaces/inner_api hilog
Merge pull request !7972 from xinking129/0322_hilog
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "insight_intent_context.h"
|
||||
|
||||
#include "ability_manager_client.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
|
||||
@@ -24,12 +25,12 @@ namespace AbilityRuntime {
|
||||
ErrCode InsightIntentContext::StartAbilityByInsightIntent(const AAFwk::Want &want)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("enter");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "enter");
|
||||
ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartAbilityByInsightIntent(want, token_, intentId_);
|
||||
if (err != ERR_OK) {
|
||||
HILOG_ERROR("failed to startAbility. ret=%{public}d", err);
|
||||
TAG_LOGE(AAFwkTag::INTENT, "failed to startAbility. ret=%{public}d", err);
|
||||
}
|
||||
HILOG_DEBUG("end");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "end");
|
||||
return err;
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
|
||||
+12
-11
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "js_insight_intent_context.h"
|
||||
|
||||
#include "ability_window_configuration.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "js_error_utils.h"
|
||||
@@ -29,7 +30,7 @@ constexpr static char CONTEXT_MODULE_NAME[] = "InsightIntentContext";
|
||||
|
||||
void JsInsightIntentContext::Finalizer(napi_env env, void* data, void* hint)
|
||||
{
|
||||
HILOG_INFO("enter");
|
||||
TAG_LOGI(AAFwkTag::INTENT, "enter");
|
||||
std::unique_ptr<JsInsightIntentContext>(static_cast<JsInsightIntentContext*>(data));
|
||||
}
|
||||
|
||||
@@ -41,10 +42,10 @@ napi_value JsInsightIntentContext::StartAbiity(napi_env env, napi_callback_info
|
||||
|
||||
napi_value JsInsightIntentContext::OnStartAbility(napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
HILOG_DEBUG("enter");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "enter");
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
if (info.argc == 0) {
|
||||
HILOG_ERROR("not enough args");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "not enough args");
|
||||
ThrowTooFewParametersError(env);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
@@ -54,7 +55,7 @@ napi_value JsInsightIntentContext::OnStartAbility(napi_env env, NapiCallbackInfo
|
||||
|
||||
auto context = context_.lock();
|
||||
if (context == nullptr) {
|
||||
HILOG_ERROR("invalid context");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "invalid context");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
@@ -62,7 +63,7 @@ napi_value JsInsightIntentContext::OnStartAbility(napi_env env, NapiCallbackInfo
|
||||
// verify if bundleName is empty or invalid
|
||||
auto bundleNameFromWant = want.GetElement().GetBundleName();
|
||||
if (bundleNameFromWant.empty() || bundleNameFromWant != context->GetBundleName()) {
|
||||
HILOG_ERROR("bundleName is empty or invalid");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "bundleName is empty or invalid");
|
||||
ThrowError(env, AbilityErrorCode::ERROR_CODE_OPERATION_NOT_SUPPORTED);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
@@ -78,7 +79,7 @@ napi_value JsInsightIntentContext::OnStartAbility(napi_env env, NapiCallbackInfo
|
||||
NapiAsyncTask::ExecuteCallback execute = [weak = context_, want, innerErrCode]() {
|
||||
auto context = weak.lock();
|
||||
if (!context) {
|
||||
HILOG_ERROR("context is released");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "context is released");
|
||||
*innerErrCode = static_cast<int>(AbilityErrorCode::ERROR_CODE_INVALID_CONTEXT);
|
||||
return;
|
||||
}
|
||||
@@ -87,7 +88,7 @@ napi_value JsInsightIntentContext::OnStartAbility(napi_env env, NapiCallbackInfo
|
||||
// create complete task
|
||||
NapiAsyncTask::CompleteCallback complete = [innerErrCode](napi_env env, NapiAsyncTask& task, int32_t status) {
|
||||
if (*innerErrCode == ERR_OK) {
|
||||
HILOG_DEBUG("StartAbility success.");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "StartAbility success.");
|
||||
task.Resolve(env, CreateJsUndefined(env));
|
||||
} else {
|
||||
task.Reject(env, CreateJsErrorByNativeErr(env, *innerErrCode));
|
||||
@@ -98,13 +99,13 @@ napi_value JsInsightIntentContext::OnStartAbility(napi_env env, NapiCallbackInfo
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::ScheduleHighQos("JsInsightIntentContext::OnStartAbility", env,
|
||||
CreateAsyncTaskWithLastParam(env, lastParam, std::move(execute), std::move(complete), &result));
|
||||
HILOG_DEBUG("end");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "end");
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value CreateJsInsightIntentContext(napi_env env, const std::shared_ptr<InsightIntentContext>& context)
|
||||
{
|
||||
HILOG_DEBUG("enter");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "enter");
|
||||
napi_value contextObj;
|
||||
napi_create_object(env, &contextObj);
|
||||
|
||||
@@ -112,7 +113,7 @@ napi_value CreateJsInsightIntentContext(napi_env env, const std::shared_ptr<Insi
|
||||
napi_wrap(env, contextObj, jsInsightIntentContext.release(), JsInsightIntentContext::Finalizer, nullptr, nullptr);
|
||||
|
||||
BindNativeFunction(env, contextObj, "startAbility", CONTEXT_MODULE_NAME, JsInsightIntentContext::StartAbiity);
|
||||
HILOG_DEBUG("end");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "end");
|
||||
return contextObj;
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <dlfcn.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS::AbilityRuntime {
|
||||
@@ -79,7 +80,7 @@ void ConnectServerManager::LoadConnectServerDebuggerSo()
|
||||
if (handlerConnectServerSo_ == nullptr) {
|
||||
handlerConnectServerSo_ = dlopen("libconnectserver_debugger.z.so", RTLD_LAZY);
|
||||
if (handlerConnectServerSo_ == nullptr) {
|
||||
HILOG_ERROR("ConnectServerManager::StartConnectServer failed to open register library");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::StartConnectServer failed to open register library");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -87,14 +88,14 @@ void ConnectServerManager::LoadConnectServerDebuggerSo()
|
||||
|
||||
void ConnectServerManager::StartConnectServer(const std::string& bundleName, int socketFd, bool isLocalAbstract)
|
||||
{
|
||||
HILOG_DEBUG("ConnectServerManager::StartConnectServer Start connect server");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "ConnectServerManager::StartConnectServer Start connect server");
|
||||
|
||||
LoadConnectServerDebuggerSo();
|
||||
bundleName_ = bundleName;
|
||||
if (isLocalAbstract) {
|
||||
auto startServer = reinterpret_cast<StartServer>(dlsym(handlerConnectServerSo_, "StartServer"));
|
||||
if (startServer == nullptr) {
|
||||
HILOG_ERROR("ConnectServerManager::StartServer failed to find symbol 'StartServer'");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::StartServer failed to find symbol 'StartServer'");
|
||||
return;
|
||||
}
|
||||
startServer(bundleName_);
|
||||
@@ -103,7 +104,8 @@ void ConnectServerManager::StartConnectServer(const std::string& bundleName, int
|
||||
auto startServerForSocketPair =
|
||||
reinterpret_cast<StartServerForSocketPair>(dlsym(handlerConnectServerSo_, "StartServerForSocketPair"));
|
||||
if (startServerForSocketPair == nullptr) {
|
||||
HILOG_ERROR("ConnectServerManager::StartServerForSocketPair failed to find symbol 'StartServer'");
|
||||
TAG_LOGE(
|
||||
AAFwkTag::JSRUNTIME, "ConnectServerManager::StartServerForSocketPair failed to find symbol 'StartServer'");
|
||||
return;
|
||||
}
|
||||
startServerForSocketPair(socketFd);
|
||||
@@ -111,16 +113,16 @@ void ConnectServerManager::StartConnectServer(const std::string& bundleName, int
|
||||
|
||||
void ConnectServerManager::StopConnectServer(bool isCloseSo)
|
||||
{
|
||||
HILOG_DEBUG("ConnectServerManager::StopConnectServer Stop connect server");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "ConnectServerManager::StopConnectServer Stop connect server");
|
||||
if (handlerConnectServerSo_ == nullptr) {
|
||||
HILOG_ERROR("ConnectServerManager::StopConnectServer handlerConnectServerSo_ is nullptr");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::StopConnectServer handlerConnectServerSo_ is nullptr");
|
||||
return;
|
||||
}
|
||||
auto stopServer = reinterpret_cast<StopServer>(dlsym(handlerConnectServerSo_, "StopServer"));
|
||||
if (stopServer != nullptr) {
|
||||
stopServer(bundleName_);
|
||||
} else {
|
||||
HILOG_ERROR("ConnectServerManager::StopConnectServer failed to find symbol 'StopServer'");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::StopConnectServer failed to find symbol 'StopServer'");
|
||||
}
|
||||
if (isCloseSo) {
|
||||
dlclose(handlerConnectServerSo_);
|
||||
@@ -135,7 +137,8 @@ bool ConnectServerManager::StoreInstanceMessage(int tid, int32_t instanceId, con
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
auto result = instanceMap_.try_emplace(instanceId, std::make_pair(instanceName, tid));
|
||||
if (!result.second) {
|
||||
HILOG_WARN("ConnectServerManager::StoreInstanceMessage Instance %{public}d already added", instanceId);
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME,
|
||||
"ConnectServerManager::StoreInstanceMessage Instance %{public}d already added", instanceId);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -151,7 +154,7 @@ void ConnectServerManager::StoreDebuggerInfo(int tid, void* vm, const panda::JSN
|
||||
}
|
||||
|
||||
if (!isConnected_) {
|
||||
HILOG_WARN("ConnectServerManager::StoreDebuggerInfo not Connected");
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME, "ConnectServerManager::StoreDebuggerInfo not Connected");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -190,7 +193,8 @@ void ConnectServerManager::SetConnectedCallback()
|
||||
auto setConnectCallBack = reinterpret_cast<SetConnectCallback>(
|
||||
dlsym(handlerConnectServerSo_, "SetConnectCallback"));
|
||||
if (setConnectCallBack == nullptr) {
|
||||
HILOG_ERROR("ConnectServerManager::SetConnectedCallback failed to find symbol 'SetConnectCallBack'");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME,
|
||||
"ConnectServerManager::SetConnectedCallback failed to find symbol 'SetConnectCallBack'");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -201,19 +205,20 @@ void ConnectServerManager::SetConnectedCallback()
|
||||
|
||||
bool ConnectServerManager::SendInstanceMessage(int tid, int32_t instanceId, const std::string& instanceName)
|
||||
{
|
||||
HILOG_INFO("ConnectServerManager::SendInstanceMessage Add instance to connect server");
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "ConnectServerManager::SendInstanceMessage Add instance to connect server");
|
||||
LoadConnectServerDebuggerSo();
|
||||
|
||||
auto setSwitchCallBack = reinterpret_cast<SetSwitchCallBack>(
|
||||
dlsym(handlerConnectServerSo_, "SetSwitchCallBack"));
|
||||
if (setSwitchCallBack == nullptr) {
|
||||
HILOG_INFO("ConnectServerManager::SendInstanceMessage failed to find symbol 'setSwitchCallBack'");
|
||||
TAG_LOGI(
|
||||
AAFwkTag::JSRUNTIME, "ConnectServerManager::SendInstanceMessage failed to find symbol 'setSwitchCallBack'");
|
||||
return false;
|
||||
}
|
||||
|
||||
auto storeMessage = reinterpret_cast<StoreMessage>(dlsym(handlerConnectServerSo_, "StoreMessage"));
|
||||
if (storeMessage == nullptr) {
|
||||
HILOG_ERROR("ConnectServerManager::SendInstanceMessage failed to find symbol 'StoreMessage'");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::SendInstanceMessage failed to find symbol 'StoreMessage'");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -233,23 +238,24 @@ bool ConnectServerManager::AddInstance(int tid, int32_t instanceId, const std::s
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
auto result = instanceMap_.try_emplace(instanceId, std::make_pair(instanceName, tid));
|
||||
if (!result.second) {
|
||||
HILOG_WARN("ConnectServerManager::AddInstance Instance %{public}d already added", instanceId);
|
||||
TAG_LOGW(
|
||||
AAFwkTag::JSRUNTIME, "ConnectServerManager::AddInstance Instance %{public}d already added", instanceId);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isConnected_) {
|
||||
HILOG_WARN("ConnectServerManager::AddInstance not Connected");
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME, "ConnectServerManager::AddInstance not Connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("ConnectServerManager::AddInstance Add instance to connect server");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "ConnectServerManager::AddInstance Add instance to connect server");
|
||||
LoadConnectServerDebuggerSo();
|
||||
|
||||
auto setSwitchCallBack = reinterpret_cast<SetSwitchCallBack>(
|
||||
dlsym(handlerConnectServerSo_, "SetSwitchCallBack"));
|
||||
if (setSwitchCallBack == nullptr) {
|
||||
HILOG_ERROR("ConnectServerManager::AddInstance failed to find symbol 'setSwitchCallBack'");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::AddInstance failed to find symbol 'setSwitchCallBack'");
|
||||
return false;
|
||||
}
|
||||
setSwitchCallBack([this](bool status) { setStatus_(status); },
|
||||
@@ -260,7 +266,7 @@ bool ConnectServerManager::AddInstance(int tid, int32_t instanceId, const std::s
|
||||
|
||||
auto storeMessage = reinterpret_cast<StoreMessage>(dlsym(handlerConnectServerSo_, "StoreMessage"));
|
||||
if (storeMessage == nullptr) {
|
||||
HILOG_ERROR("ConnectServerManager::AddInstance failed to find symbol 'StoreMessage'");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::AddInstance failed to find symbol 'StoreMessage'");
|
||||
return false;
|
||||
}
|
||||
storeMessage(instanceId, message);
|
||||
@@ -268,7 +274,7 @@ bool ConnectServerManager::AddInstance(int tid, int32_t instanceId, const std::s
|
||||
// WaitForConnection() means the connection state of the connect server
|
||||
auto sendMessage = reinterpret_cast<SendMessage>(dlsym(handlerConnectServerSo_, "SendMessage"));
|
||||
if (sendMessage == nullptr) {
|
||||
HILOG_ERROR("ConnectServerManager::AddInstance failed to find symbol 'SendMessage'");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::AddInstance failed to find symbol 'SendMessage'");
|
||||
return false;
|
||||
}
|
||||
// if connected, message will be sent immediately.
|
||||
@@ -278,9 +284,9 @@ bool ConnectServerManager::AddInstance(int tid, int32_t instanceId, const std::s
|
||||
|
||||
void ConnectServerManager::RemoveInstance(int32_t instanceId)
|
||||
{
|
||||
HILOG_DEBUG("ConnectServerManager::RemoveInstance Remove instance to connect server");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "ConnectServerManager::RemoveInstance Remove instance to connect server");
|
||||
if (handlerConnectServerSo_ == nullptr) {
|
||||
HILOG_ERROR("ConnectServerManager::RemoveInstance handlerConnectServerSo_ is nullptr");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::RemoveInstance handlerConnectServerSo_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -291,7 +297,8 @@ void ConnectServerManager::RemoveInstance(int32_t instanceId)
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
auto it = instanceMap_.find(instanceId);
|
||||
if (it == instanceMap_.end()) {
|
||||
HILOG_WARN("ConnectServerManager::RemoveInstance Instance %{public}d is not found", instanceId);
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME, "ConnectServerManager::RemoveInstance Instance %{public}d is not found",
|
||||
instanceId);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -302,7 +309,7 @@ void ConnectServerManager::RemoveInstance(int32_t instanceId)
|
||||
|
||||
auto waitForConnection = reinterpret_cast<WaitForConnection>(dlsym(handlerConnectServerSo_, "WaitForConnection"));
|
||||
if (waitForConnection == nullptr) {
|
||||
HILOG_ERROR("ConnectServerManager::RemoveInstance failed to find symbol 'WaitForConnection'");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::RemoveInstance failed to find symbol 'WaitForConnection'");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -311,7 +318,7 @@ void ConnectServerManager::RemoveInstance(int32_t instanceId)
|
||||
|
||||
auto removeMessage = reinterpret_cast<RemoveMessage>(dlsym(handlerConnectServerSo_, "RemoveMessage"));
|
||||
if (removeMessage == nullptr) {
|
||||
HILOG_ERROR("ConnectServerManager::RemoveInstance failed to find symbol 'RemoveMessage'");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::RemoveInstance failed to find symbol 'RemoveMessage'");
|
||||
return;
|
||||
}
|
||||
removeMessage(instanceId);
|
||||
@@ -322,7 +329,7 @@ void ConnectServerManager::RemoveInstance(int32_t instanceId)
|
||||
|
||||
auto sendMessage = reinterpret_cast<SendMessage>(dlsym(handlerConnectServerSo_, "SendMessage"));
|
||||
if (sendMessage == nullptr) {
|
||||
HILOG_ERROR("ConnectServerManager::RemoveInstance failed to find symbol 'SendMessage'");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::RemoveInstance failed to find symbol 'SendMessage'");
|
||||
return;
|
||||
}
|
||||
sendMessage(message);
|
||||
@@ -330,10 +337,10 @@ void ConnectServerManager::RemoveInstance(int32_t instanceId)
|
||||
|
||||
void ConnectServerManager::SendInspector(const std::string& jsonTreeStr, const std::string& jsonSnapshotStr)
|
||||
{
|
||||
HILOG_INFO("ConnectServerManager SendInspector Start");
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "ConnectServerManager SendInspector Start");
|
||||
auto sendLayoutMessage = reinterpret_cast<SendMessage>(dlsym(handlerConnectServerSo_, "SendLayoutMessage"));
|
||||
if (sendLayoutMessage == nullptr) {
|
||||
HILOG_ERROR("ConnectServerManager::AddInstance failed to find symbol 'sendLayoutMessage'");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::AddInstance failed to find symbol 'sendLayoutMessage'");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -342,7 +349,7 @@ void ConnectServerManager::SendInspector(const std::string& jsonTreeStr, const s
|
||||
auto storeInspectorInfo = reinterpret_cast<StoreInspectorInfo>(
|
||||
dlsym(handlerConnectServerSo_, "StoreInspectorInfo"));
|
||||
if (storeInspectorInfo == nullptr) {
|
||||
HILOG_ERROR("ConnectServerManager::AddInstance failed to find symbol 'StoreInspectorInfo'");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::AddInstance failed to find symbol 'StoreInspectorInfo'");
|
||||
return;
|
||||
}
|
||||
storeInspectorInfo(jsonTreeStr, jsonSnapshotStr);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <dlfcn.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS::AbilityRuntime {
|
||||
@@ -39,38 +40,38 @@ HdcRegister& HdcRegister::Get()
|
||||
void HdcRegister::StartHdcRegister(const std::string& bundleName, const std::string& processName, bool debugApp,
|
||||
HdcRegisterCallback callback)
|
||||
{
|
||||
HILOG_DEBUG("HdcRegister::StartHdcRegister begin");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "HdcRegister::StartHdcRegister begin");
|
||||
|
||||
registerHandler_ = dlopen("libhdc_register.z.so", RTLD_LAZY);
|
||||
if (registerHandler_ == nullptr) {
|
||||
HILOG_ERROR("HdcRegister::StartHdcRegister failed to open register library");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "HdcRegister::StartHdcRegister failed to open register library");
|
||||
return;
|
||||
}
|
||||
auto startRegister = reinterpret_cast<StartRegister>(dlsym(registerHandler_, "StartConnect"));
|
||||
if (startRegister == nullptr) {
|
||||
HILOG_ERROR("HdcRegister::StartHdcRegister failed to find symbol 'StartConnect'");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "HdcRegister::StartHdcRegister failed to find symbol 'StartConnect'");
|
||||
return;
|
||||
}
|
||||
startRegister(processName, bundleName, debugApp, callback);
|
||||
|
||||
HILOG_DEBUG("HdcRegister::StartHdcRegister end");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "HdcRegister::StartHdcRegister end");
|
||||
}
|
||||
|
||||
void HdcRegister::StopHdcRegister()
|
||||
{
|
||||
HILOG_DEBUG("HdcRegister::StopHdcRegister begin");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "HdcRegister::StopHdcRegister begin");
|
||||
if (registerHandler_ == nullptr) {
|
||||
HILOG_ERROR("HdcRegister::StopHdcRegister registerHandler_ is nullptr");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "HdcRegister::StopHdcRegister registerHandler_ is nullptr");
|
||||
return;
|
||||
}
|
||||
auto stopRegister = reinterpret_cast<StopRegister>(dlsym(registerHandler_, "StopConnect"));
|
||||
if (stopRegister != nullptr) {
|
||||
stopRegister();
|
||||
} else {
|
||||
HILOG_ERROR("HdcRegister::StopHdcRegister failed to find symbol 'StopConnect'");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "HdcRegister::StopHdcRegister failed to find symbol 'StopConnect'");
|
||||
}
|
||||
dlclose(registerHandler_);
|
||||
registerHandler_ = nullptr;
|
||||
HILOG_DEBUG("HdcRegister::StopHdcRegister end");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "HdcRegister::StopHdcRegister end");
|
||||
}
|
||||
} // namespace OHOS::AbilityRuntime
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "common_func.h"
|
||||
#include "configuration_convertor.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "js_runtime.h"
|
||||
#include "js_runtime_utils.h"
|
||||
@@ -29,7 +30,7 @@ napi_value CreateJsWantObject(napi_env env, const AAFwk::Want& want)
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
if (object == nullptr) {
|
||||
HILOG_ERROR("Native object is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Native object is nullptr.");
|
||||
return nullptr;
|
||||
}
|
||||
napi_set_named_property(env, object, "deviceId", CreateJsValue(env, want.GetOperation().GetDeviceId()));
|
||||
@@ -48,7 +49,7 @@ napi_value CreateJsAbilityInfo(napi_env env, const AppExecFwk::AbilityInfo& abil
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
if (object == nullptr) {
|
||||
HILOG_ERROR("Create object failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Create object failed.");
|
||||
return nullptr;
|
||||
}
|
||||
AppExecFwk::CommonFunc::ConvertAbilityInfo(env, abilityInfo, object);
|
||||
@@ -60,7 +61,7 @@ napi_value CreateJsApplicationInfo(napi_env env, const AppExecFwk::ApplicationIn
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
if (object == nullptr) {
|
||||
HILOG_ERROR("Create object failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Create object failed.");
|
||||
return nullptr;
|
||||
}
|
||||
AppExecFwk::CommonFunc::ConvertApplicationInfo(env, object, applicationInfo);
|
||||
@@ -72,7 +73,7 @@ napi_value CreateJsLaunchParam(napi_env env, const AAFwk::LaunchParam& launchPar
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
if (object == nullptr) {
|
||||
HILOG_ERROR("Native object is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Native object is nullptr.");
|
||||
return nullptr;
|
||||
}
|
||||
napi_set_named_property(env, object, "launchReason", CreateJsValue(env, launchParam.launchReason));
|
||||
@@ -86,7 +87,7 @@ napi_value CreateJsConfiguration(napi_env env, const AppExecFwk::Configuration&
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
if (object == nullptr) {
|
||||
HILOG_ERROR("Native object is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Native object is nullptr.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -114,11 +115,11 @@ napi_value CreateJsConfiguration(napi_env env, const AppExecFwk::Configuration&
|
||||
|
||||
napi_value CreateJsExtensionAbilityInfo(napi_env env, const AppExecFwk::ExtensionAbilityInfo& info)
|
||||
{
|
||||
HILOG_DEBUG("CreateJsExtensionAbilityInfo begin");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "CreateJsExtensionAbilityInfo begin");
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
if (object == nullptr) {
|
||||
HILOG_ERROR("Create object failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Create object failed.");
|
||||
return nullptr;
|
||||
}
|
||||
AppExecFwk::CommonFunc::ConvertExtensionInfo(env, info, object);
|
||||
@@ -130,7 +131,7 @@ napi_value CreateJsHapModuleInfo(napi_env env, const AppExecFwk::HapModuleInfo&
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
if (object == nullptr) {
|
||||
HILOG_ERROR("Create object failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Create object failed.");
|
||||
return nullptr;
|
||||
}
|
||||
AppExecFwk::CommonFunc::ConvertHapModuleInfo(env, hapModuleInfo, object);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "bundle_mgr_helper.h"
|
||||
#include "bundle_mgr_proxy.h"
|
||||
#include "file_path_utils.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "iservice_registry.h"
|
||||
@@ -44,29 +45,29 @@ JsModuleReader::JsModuleReader(const std::string& bundleName, const std::string&
|
||||
|
||||
bool JsModuleReader::operator()(const std::string& inputPath, uint8_t **buff, size_t *buffSize) const
|
||||
{
|
||||
HILOG_DEBUG("JsModuleReader operator start: %{private}s", inputPath.c_str());
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "JsModuleReader operator start: %{private}s", inputPath.c_str());
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
if (inputPath.empty() || buff == nullptr || buffSize == nullptr) {
|
||||
HILOG_ERROR("Invalid param");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Invalid param");
|
||||
return false;
|
||||
}
|
||||
|
||||
auto realHapPath = GetAppHspPath(inputPath);
|
||||
if (realHapPath.empty()) {
|
||||
HILOG_ERROR("realHapPath is empty");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "realHapPath is empty");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool newCreate = false;
|
||||
std::shared_ptr<Extractor> extractor = ExtractorUtil::GetExtractor(realHapPath, newCreate);
|
||||
if (extractor == nullptr) {
|
||||
HILOG_ERROR("realHapPath %{private}s GetExtractor failed", realHapPath.c_str());
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "realHapPath %{private}s GetExtractor failed", realHapPath.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
auto data = extractor->GetSafeData(MERGE_ABC_PATH);
|
||||
if (!data) {
|
||||
HILOG_ERROR("get mergeAbc fileBuffer failed");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "get mergeAbc fileBuffer failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -92,11 +93,11 @@ std::string JsModuleReader::GetFormAppHspPath(const std::string& inputPath) cons
|
||||
.append(GetModuleName(inputPath))
|
||||
.append(SHARED_FILE_SUFFIX);
|
||||
|
||||
HILOG_INFO("realHapPath: %{private}s", realHapPath.c_str());
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "realHapPath: %{private}s", realHapPath.c_str());
|
||||
if (realHapPath.empty() ||
|
||||
realHapPath.length() < suffix.length() ||
|
||||
realHapPath.compare(realHapPath.length() - suffix.length(), suffix.length(), suffix) != 0) {
|
||||
HILOG_ERROR("failed to obtain realHapPath");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "failed to obtain realHapPath");
|
||||
return realHapPath;
|
||||
}
|
||||
return realHapPath;
|
||||
@@ -115,11 +116,11 @@ std::string JsModuleReader::GetCommonAppHspPath(const std::string& inputPath) co
|
||||
realHapPath = std::string(ABS_CODE_PATH) + inputPath + suffix;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("realHapPath: %{private}s", realHapPath.c_str());
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "realHapPath: %{private}s", realHapPath.c_str());
|
||||
if (realHapPath.empty() ||
|
||||
realHapPath.length() < suffix.length() ||
|
||||
realHapPath.compare(realHapPath.length() - suffix.length(), suffix.length(), suffix) != 0) {
|
||||
HILOG_ERROR("failed to obtain realHapPath");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "failed to obtain realHapPath");
|
||||
return realHapPath;
|
||||
}
|
||||
return realHapPath;
|
||||
@@ -132,13 +133,13 @@ std::string JsModuleReader::GetOtherHspPath(const std::string& bundleName, const
|
||||
|
||||
auto bundleMgrHelper = DelayedSingleton<AppExecFwk::BundleMgrHelper>::GetInstance();
|
||||
if (bundleMgrHelper == nullptr) {
|
||||
HILOG_ERROR("The bundleMgrHelper is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "The bundleMgrHelper is nullptr.");
|
||||
return presetAppHapPath;
|
||||
}
|
||||
|
||||
std::vector<AppExecFwk::BaseSharedBundleInfo> baseSharedBundleInfos;
|
||||
if (bundleMgrHelper->GetBaseSharedBundleInfos(bundleName, baseSharedBundleInfos) != 0) {
|
||||
HILOG_ERROR("GetBaseSharedBundleInfos failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "GetBaseSharedBundleInfos failed.");
|
||||
return presetAppHapPath;
|
||||
}
|
||||
std::string tmpPath = inputPath.substr(inputPath.find_first_of("/") + 1);
|
||||
@@ -153,7 +154,7 @@ std::string JsModuleReader::GetOtherHspPath(const std::string& bundleName, const
|
||||
int32_t ret = bundleMgrHelper->GetDependentBundleInfo(sharedBundleName, bundleInfo,
|
||||
AppExecFwk::GetDependentBundleInfoFlag::GET_APP_SERVICE_HSP_BUNDLE_INFO);
|
||||
if (ret != ERR_OK) {
|
||||
HILOG_ERROR("GetDependentBundleInfo failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "GetDependentBundleInfo failed.");
|
||||
return presetAppHapPath;
|
||||
}
|
||||
for (const auto &info : bundleInfo.hapModuleInfos) {
|
||||
@@ -170,12 +171,12 @@ std::string JsModuleReader::GetPresetAppHapPath(const std::string& inputPath, co
|
||||
std::string presetAppHapPath = inputPath;
|
||||
std::string moduleName = inputPath.substr(inputPath.find_last_of("/") + 1);
|
||||
if (moduleName.empty()) {
|
||||
HILOG_ERROR("Failed to obtain moduleName.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Failed to obtain moduleName.");
|
||||
return presetAppHapPath;
|
||||
}
|
||||
auto bundleMgrHelper = DelayedSingleton<AppExecFwk::BundleMgrHelper>::GetInstance();
|
||||
if (bundleMgrHelper == nullptr) {
|
||||
HILOG_ERROR("The bundleMgrHelper is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "The bundleMgrHelper is nullptr.");
|
||||
return presetAppHapPath;
|
||||
}
|
||||
if (inputPath.find_first_of("/") == inputPath.find_last_of("/")) {
|
||||
@@ -183,7 +184,7 @@ std::string JsModuleReader::GetPresetAppHapPath(const std::string& inputPath, co
|
||||
auto getInfoResult = bundleMgrHelper->GetBundleInfoForSelf(static_cast<int32_t>(AppExecFwk::GetBundleInfoFlag::
|
||||
GET_BUNDLE_INFO_WITH_HAP_MODULE), bundleInfo);
|
||||
if (getInfoResult != 0 || bundleInfo.hapModuleInfos.empty()) {
|
||||
HILOG_ERROR("GetBundleInfoForSelf failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "GetBundleInfoForSelf failed.");
|
||||
return presetAppHapPath;
|
||||
}
|
||||
for (auto hapModuleInfo : bundleInfo.hapModuleInfos) {
|
||||
@@ -202,12 +203,12 @@ void JsModuleReader::GetHapPathList(const std::string &bundleName, std::vector<s
|
||||
{
|
||||
auto systemAbilityManagerClient = OHOS::SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (!systemAbilityManagerClient) {
|
||||
HILOG_ERROR("fail to get system ability mgr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "fail to get system ability mgr.");
|
||||
return;
|
||||
}
|
||||
auto remoteObject = systemAbilityManagerClient->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID);
|
||||
if (!remoteObject) {
|
||||
HILOG_ERROR("fail to get bundle manager proxy.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "fail to get bundle manager proxy.");
|
||||
return;
|
||||
}
|
||||
auto bundleMgrProxy = iface_cast<IBundleMgr>(remoteObject);
|
||||
@@ -215,7 +216,7 @@ void JsModuleReader::GetHapPathList(const std::string &bundleName, std::vector<s
|
||||
auto getInfoResult = bundleMgrProxy->GetBundleInfoForSelf(static_cast<int32_t>(AppExecFwk::GetBundleInfoFlag::
|
||||
GET_BUNDLE_INFO_WITH_HAP_MODULE), bundleInfo);
|
||||
if (getInfoResult != 0 || bundleInfo.hapModuleInfos.empty()) {
|
||||
HILOG_ERROR("GetBundleInfoForSelf failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "GetBundleInfoForSelf failed.");
|
||||
return;
|
||||
}
|
||||
for (auto hapModuleInfo : bundleInfo.hapModuleInfos) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "js_quickfix_callback.h"
|
||||
|
||||
#include "file_path_utils.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "js_runtime.h"
|
||||
|
||||
@@ -29,10 +30,10 @@ namespace {
|
||||
bool JsQuickfixCallback::operator()(std::string baseFileName, std::string &patchFileName,
|
||||
void **patchBuffer, size_t &patchSize)
|
||||
{
|
||||
HILOG_DEBUG("baseFileName: %{private}s", baseFileName.c_str());
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "baseFileName: %{private}s", baseFileName.c_str());
|
||||
auto position = baseFileName.find(".abc");
|
||||
if (position == std::string::npos) {
|
||||
HILOG_ERROR("invalid baseFileName!");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "invalid baseFileName!");
|
||||
return false;
|
||||
}
|
||||
int baseFileNameLen = static_cast<int>(baseFileName.length());
|
||||
@@ -40,11 +41,11 @@ bool JsQuickfixCallback::operator()(std::string baseFileName, std::string &patch
|
||||
int suffixLen = strlen(MERGE_ABC_PATH);
|
||||
int moduleLen = baseFileNameLen - prefixLen - suffixLen;
|
||||
if (moduleLen < 0) {
|
||||
HILOG_ERROR("invalid baseFileName!");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "invalid baseFileName!");
|
||||
return false;
|
||||
}
|
||||
std::string moduleName = baseFileName.substr(prefixLen, moduleLen);
|
||||
HILOG_DEBUG("moduleName: %{private}s", moduleName.c_str());
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "moduleName: %{private}s", moduleName.c_str());
|
||||
|
||||
auto it = moduleAndHqfPath_.find(moduleName);
|
||||
if (it == moduleAndHqfPath_.end()) {
|
||||
@@ -53,14 +54,15 @@ bool JsQuickfixCallback::operator()(std::string baseFileName, std::string &patch
|
||||
|
||||
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());
|
||||
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "hqfFile: %{private}s, resolvedHqfFile: %{private}s", hqfFile.c_str(),
|
||||
resolvedHqfFile.c_str());
|
||||
|
||||
if (!JsRuntime::GetFileBuffer(resolvedHqfFile, patchFileName, newpatchBuffer_)) {
|
||||
HILOG_ERROR("GetFileBuffer failed");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "GetFileBuffer failed");
|
||||
return false;
|
||||
}
|
||||
*patchBuffer = newpatchBuffer_.data();
|
||||
HILOG_DEBUG("patchFileName: %{private}s", patchFileName.c_str());
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "patchFileName: %{private}s", patchFileName.c_str());
|
||||
patchSize = newpatchBuffer_.size();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ static auto PermissionCheckFunc = []() {
|
||||
napi_value CanIUse(napi_env env, napi_callback_info info)
|
||||
{
|
||||
if (env == nullptr || info == nullptr) {
|
||||
HILOG_ERROR("get syscap failed since env or callback info is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "get syscap failed since env or callback info is nullptr.");
|
||||
return nullptr;
|
||||
}
|
||||
napi_value undefined = CreateJsUndefined(env);
|
||||
@@ -115,14 +115,14 @@ napi_value CanIUse(napi_env env, napi_callback_info info)
|
||||
napi_value argv[1] = { nullptr };
|
||||
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
|
||||
if (argc != 1) {
|
||||
HILOG_ERROR("Get syscap failed with invalid parameter.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Get syscap failed with invalid parameter.");
|
||||
return undefined;
|
||||
}
|
||||
|
||||
napi_valuetype valueType = napi_undefined;
|
||||
napi_typeof(env, argv[0], &valueType);
|
||||
if (valueType != napi_string) {
|
||||
HILOG_INFO("%{public}s called. Params is invalid.", __func__);
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "%{public}s called. Params is invalid.", __func__);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -143,31 +143,31 @@ void InitSyscapModule(napi_env env, napi_value globalObject)
|
||||
|
||||
int32_t PrintVmLog(int32_t, int32_t, const char*, const char*, const char* message)
|
||||
{
|
||||
HILOG_INFO("ArkLog: %{public}s", message);
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "ArkLog: %{public}s", message);
|
||||
return 0;
|
||||
}
|
||||
|
||||
napi_status CreateNapiEnv(napi_env *env)
|
||||
{
|
||||
HILOG_DEBUG("Called");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Called");
|
||||
if (env == nullptr) {
|
||||
HILOG_ERROR("Invalid arg");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Invalid arg");
|
||||
return napi_status::napi_invalid_arg;
|
||||
}
|
||||
auto options = JsRuntime::GetChildOptions();
|
||||
if (options == nullptr) {
|
||||
HILOG_ERROR("options is null, it maybe application startup failed!");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "options is null, it maybe application startup failed!");
|
||||
return napi_status::napi_generic_failure;
|
||||
}
|
||||
std::shared_ptr<OHOS::JsEnv::JsEnvironment> jsEnv = nullptr;
|
||||
auto errCode = NativeRuntimeImpl::GetNativeRuntimeImpl().CreateJsEnv(*options, jsEnv);
|
||||
if (errCode != napi_status::napi_ok) {
|
||||
HILOG_ERROR("CreateJsEnv failed");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "CreateJsEnv failed");
|
||||
return errCode;
|
||||
}
|
||||
*env = reinterpret_cast<napi_env>(jsEnv->GetNativeEngine());
|
||||
if (env == nullptr) {
|
||||
HILOG_ERROR("CreateJsEnv failed");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "CreateJsEnv failed");
|
||||
return napi_status::napi_generic_failure;
|
||||
}
|
||||
return NativeRuntimeImpl::GetNativeRuntimeImpl().Init(*options, *env);
|
||||
@@ -175,9 +175,9 @@ napi_status CreateNapiEnv(napi_env *env)
|
||||
|
||||
napi_status DestroyNapiEnv(napi_env *env)
|
||||
{
|
||||
HILOG_DEBUG("Called");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Called");
|
||||
if (env == nullptr) {
|
||||
HILOG_ERROR("Invalid arg");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Invalid arg");
|
||||
return napi_status::napi_invalid_arg;
|
||||
}
|
||||
auto errCode = NativeRuntimeImpl::GetNativeRuntimeImpl().RemoveJsEnv(*env);
|
||||
@@ -193,12 +193,12 @@ std::atomic<bool> JsRuntime::hasInstance(false);
|
||||
std::shared_ptr<Runtime::Options> JsRuntime::childOptions_ = nullptr;
|
||||
JsRuntime::JsRuntime()
|
||||
{
|
||||
HILOG_DEBUG("JsRuntime costructor.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "JsRuntime costructor.");
|
||||
}
|
||||
|
||||
JsRuntime::~JsRuntime()
|
||||
{
|
||||
HILOG_DEBUG("called");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
Deinitialize();
|
||||
StopDebugMode();
|
||||
}
|
||||
@@ -235,7 +235,7 @@ void JsRuntime::StartDebugMode(bool needBreakPoint, const std::string &processNa
|
||||
{
|
||||
CHECK_POINTER(jsEnv_);
|
||||
if (jsEnv_->GetDebugMode()) {
|
||||
HILOG_INFO("Already in debug mode");
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "Already in debug mode");
|
||||
return;
|
||||
}
|
||||
// Set instance id to tid after the first instance.
|
||||
@@ -243,7 +243,7 @@ void JsRuntime::StartDebugMode(bool needBreakPoint, const std::string &processNa
|
||||
instanceId_ = static_cast<uint32_t>(gettid());
|
||||
}
|
||||
|
||||
HILOG_DEBUG("Ark VM is starting debug mode [%{public}s]", needBreakPoint ? "break" : "normal");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Ark VM is starting debug mode [%{public}s]", needBreakPoint ? "break" : "normal");
|
||||
StartDebuggerInWorkerModule();
|
||||
SetDebuggerApp(isDebugApp);
|
||||
const std::string bundleName = bundleName_;
|
||||
@@ -255,10 +255,11 @@ void JsRuntime::StartDebugMode(bool needBreakPoint, const std::string &processNa
|
||||
}
|
||||
HdcRegister::Get().StartHdcRegister(bundleName_, inputProcessName, isDebugApp,
|
||||
[bundleName, needBreakPoint, instanceId, weak, isDebugApp](int socketFd, std::string option) {
|
||||
HILOG_INFO("HdcRegister callback is call, socket fd is %{public}d, option is %{public}s.",
|
||||
socketFd, option.c_str());
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME,
|
||||
"HdcRegister callback is call, socket fd is %{public}d, option is %{public}s.", socketFd,
|
||||
option.c_str());
|
||||
if (weak == nullptr) {
|
||||
HILOG_ERROR("jsEnv is nullptr in hdc register callback");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv is nullptr in hdc register callback");
|
||||
return;
|
||||
}
|
||||
if (option.find(DEBUGGER) == std::string::npos) {
|
||||
@@ -304,7 +305,7 @@ void JsRuntime::InitConsoleModule()
|
||||
|
||||
bool JsRuntime::StartDebugger(bool needBreakPoint, uint32_t instanceId)
|
||||
{
|
||||
HILOG_DEBUG("StartDebugger called.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "StartDebugger called.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -316,11 +317,11 @@ void JsRuntime::StopDebugger()
|
||||
|
||||
int32_t JsRuntime::JsperfProfilerCommandParse(const std::string &command, int32_t defaultValue)
|
||||
{
|
||||
HILOG_DEBUG("profiler command parse %{public}s", command.c_str());
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "profiler command parse %{public}s", command.c_str());
|
||||
auto findPos = command.find("jsperf");
|
||||
if (findPos == std::string::npos) {
|
||||
// jsperf command not found, so not to do, return zero.
|
||||
HILOG_DEBUG("jsperf command not found");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "jsperf command not found");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -329,7 +330,7 @@ int32_t JsRuntime::JsperfProfilerCommandParse(const std::string &command, int32_
|
||||
const std::regex regexJsperf(R"(^jsperf($|\s+($|\d*\s*($|nativeperf.*))))");
|
||||
std::match_results<std::string::const_iterator> matchResults;
|
||||
if (!std::regex_match(jsPerfStr, matchResults, regexJsperf)) {
|
||||
HILOG_DEBUG("the order not match");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "the order not match");
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@@ -337,7 +338,7 @@ int32_t JsRuntime::JsperfProfilerCommandParse(const std::string &command, int32_
|
||||
std::string jsperfResuflt;
|
||||
constexpr size_t matchResultIndex = 1;
|
||||
if (matchResults.size() < PARAM_TWO) {
|
||||
HILOG_ERROR("no results need to be matched");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "no results need to be matched");
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@@ -346,7 +347,7 @@ int32_t JsRuntime::JsperfProfilerCommandParse(const std::string &command, int32_
|
||||
const std::regex regexJsperfNum(R"(^\s*(\d+).*)");
|
||||
std::match_results<std::string::const_iterator> jsperfMatchResults;
|
||||
if (!std::regex_match(jsperfResuflt, jsperfMatchResults, regexJsperfNum)) {
|
||||
HILOG_DEBUG("the jsperf results not match");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "the jsperf results not match");
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@@ -354,13 +355,13 @@ int32_t JsRuntime::JsperfProfilerCommandParse(const std::string &command, int32_
|
||||
std::string interval;
|
||||
constexpr size_t matchNumResultIndex = 1;
|
||||
if (jsperfMatchResults.size() < PARAM_TWO) {
|
||||
HILOG_ERROR("no results need to be matched");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "no results need to be matched");
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
interval = jsperfMatchResults[matchNumResultIndex].str();
|
||||
if (interval.empty()) {
|
||||
HILOG_DEBUG("match order result error");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "match order result error");
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@@ -386,10 +387,10 @@ void JsRuntime::StartProfiler(
|
||||
}
|
||||
HdcRegister::Get().StartHdcRegister(bundleName_, inputProcessName, isDebugApp,
|
||||
[bundleName, needBreakPoint, instanceId, weak, isDebugApp](int socketFd, std::string option) {
|
||||
HILOG_INFO("HdcRegister callback is call, socket fd is %{public}d, option is %{public}s.",
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "HdcRegister callback is call, socket fd is %{public}d, option is %{public}s.",
|
||||
socketFd, option.c_str());
|
||||
if (weak == nullptr) {
|
||||
HILOG_ERROR("jsEnv is nullptr in hdc register callback");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv is nullptr in hdc register callback");
|
||||
return;
|
||||
}
|
||||
if (option.find(DEBUGGER) == std::string::npos) {
|
||||
@@ -421,7 +422,7 @@ void JsRuntime::StartProfiler(
|
||||
panda::JSNApi::DebugOption debugOption = {ARK_DEBUGGER_LIB_PATH, isDebugApp ? needBreakPoint : false};
|
||||
ConnectServerManager::Get().StoreDebuggerInfo(
|
||||
instanceId_, reinterpret_cast<void*>(vm), debugOption, debuggerPostTask, isDebugApp);
|
||||
HILOG_DEBUG("profiler:%{public}d interval:%{public}d.", profiler, interval);
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "profiler:%{public}d interval:%{public}d.", profiler, interval);
|
||||
jsEnv_->StartProfiler(ARK_DEBUGGER_LIB_PATH, instanceId_, profiler, interval, gettid(), isDebugApp);
|
||||
}
|
||||
|
||||
@@ -429,14 +430,15 @@ bool JsRuntime::GetFileBuffer(const std::string& filePath, std::string& fileFull
|
||||
{
|
||||
Extractor extractor(filePath);
|
||||
if (!extractor.Init()) {
|
||||
HILOG_ERROR("GetFileBuffer, Extractor of %{private}s init failed.", filePath.c_str());
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "GetFileBuffer, Extractor of %{private}s init failed.", filePath.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string> fileNames;
|
||||
extractor.GetSpecifiedTypeFiles(fileNames, ".abc");
|
||||
if (fileNames.empty()) {
|
||||
HILOG_WARN("GetFileBuffer, There's no abc file in hap or hqf %{private}s.", filePath.c_str());
|
||||
TAG_LOGW(
|
||||
AAFwkTag::JSRUNTIME, "GetFileBuffer, There's no abc file in hap or hqf %{private}s.", filePath.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -444,7 +446,7 @@ bool JsRuntime::GetFileBuffer(const std::string& filePath, std::string& fileFull
|
||||
fileFullName = filePath + "/" + fileName;
|
||||
std::ostringstream outStream;
|
||||
if (!extractor.ExtractByName(fileName, outStream)) {
|
||||
HILOG_ERROR("GetFileBuffer, Extract %{public}s failed.", fileFullName.c_str());
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "GetFileBuffer, Extract %{public}s failed.", fileFullName.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -455,21 +457,21 @@ bool JsRuntime::GetFileBuffer(const std::string& filePath, std::string& fileFull
|
||||
|
||||
bool JsRuntime::LoadRepairPatch(const std::string& hqfFile, const std::string& hapPath)
|
||||
{
|
||||
HILOG_DEBUG("LoadRepairPatch function called.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "LoadRepairPatch function called.");
|
||||
auto vm = GetEcmaVm();
|
||||
CHECK_POINTER_AND_RETURN(vm, false);
|
||||
|
||||
std::string patchFile;
|
||||
std::vector<uint8_t> patchBuffer;
|
||||
if (!GetFileBuffer(hqfFile, patchFile, patchBuffer)) {
|
||||
HILOG_ERROR("LoadRepairPatch, get patch file buffer failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "LoadRepairPatch, get patch file buffer failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string baseFile;
|
||||
std::vector<uint8_t> baseBuffer;
|
||||
if (!GetFileBuffer(hapPath, baseFile, baseBuffer)) {
|
||||
HILOG_ERROR("LoadRepairPatch, get base file buffer failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "LoadRepairPatch, get base file buffer failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -484,46 +486,46 @@ bool JsRuntime::LoadRepairPatch(const std::string& hqfFile, const std::string& h
|
||||
resolvedHapPath = hapPath.substr(0, hspPosition) + MERGE_ABC_PATH;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("LoadRepairPatch, LoadPatch, patchFile: %{private}s, baseFile: %{private}s.",
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "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(),
|
||||
resolvedHapPath, baseBuffer.data(), baseBuffer.size());
|
||||
if (ret != panda::JSNApi::PatchErrorCode::SUCCESS) {
|
||||
HILOG_ERROR("LoadPatch failed with %{public}d.", static_cast<int32_t>(ret));
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "LoadPatch failed with %{public}d.", static_cast<int32_t>(ret));
|
||||
return false;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("LoadRepairPatch, Load patch %{private}s succeed.", patchFile.c_str());
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "LoadRepairPatch, Load patch %{private}s succeed.", patchFile.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JsRuntime::UnLoadRepairPatch(const std::string& hqfFile)
|
||||
{
|
||||
HILOG_DEBUG("UnLoadRepairPatch function called.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "UnLoadRepairPatch function called.");
|
||||
auto vm = GetEcmaVm();
|
||||
CHECK_POINTER_AND_RETURN(vm, false);
|
||||
|
||||
Extractor extractor(hqfFile);
|
||||
if (!extractor.Init()) {
|
||||
HILOG_ERROR("UnLoadRepairPatch, Extractor of %{private}s init failed.", hqfFile.c_str());
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "UnLoadRepairPatch, Extractor of %{private}s init failed.", hqfFile.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string> fileNames;
|
||||
extractor.GetSpecifiedTypeFiles(fileNames, ".abc");
|
||||
if (fileNames.empty()) {
|
||||
HILOG_WARN("UnLoadRepairPatch, There's no abc file in hqf %{private}s.", hqfFile.c_str());
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME, "UnLoadRepairPatch, There's no abc file in hqf %{private}s.", hqfFile.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
for (const auto &fileName : fileNames) {
|
||||
std::string patchFile = hqfFile + "/" + fileName;
|
||||
HILOG_DEBUG("UnLoadRepairPatch, UnloadPatch, patchFile: %{private}s.", patchFile.c_str());
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "UnLoadRepairPatch, UnloadPatch, patchFile: %{private}s.", patchFile.c_str());
|
||||
auto ret = panda::JSNApi::UnloadPatch(vm, patchFile);
|
||||
if (ret != panda::JSNApi::PatchErrorCode::SUCCESS) {
|
||||
HILOG_WARN("UnLoadPatch failed with %{public}d.", static_cast<int32_t>(ret));
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME, "UnLoadPatch failed with %{public}d.", static_cast<int32_t>(ret));
|
||||
}
|
||||
HILOG_DEBUG("UnLoadRepairPatch, UnLoad patch %{private}s succeed.", patchFile.c_str());
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "UnLoadRepairPatch, UnLoad patch %{private}s succeed.", patchFile.c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -531,21 +533,21 @@ bool JsRuntime::UnLoadRepairPatch(const std::string& hqfFile)
|
||||
|
||||
bool JsRuntime::NotifyHotReloadPage()
|
||||
{
|
||||
HILOG_DEBUG("function called.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "function called.");
|
||||
Ace::HotReloader::HotReload();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JsRuntime::LoadScript(const std::string& path, std::vector<uint8_t>* buffer, bool isBundle)
|
||||
{
|
||||
HILOG_DEBUG("function called.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "function called.");
|
||||
CHECK_POINTER_AND_RETURN(jsEnv_, false);
|
||||
return jsEnv_->LoadScript(path, buffer, isBundle);
|
||||
}
|
||||
|
||||
bool JsRuntime::LoadScript(const std::string& path, uint8_t* buffer, size_t len, bool isBundle)
|
||||
{
|
||||
HILOG_DEBUG("function called.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "function called.");
|
||||
CHECK_POINTER_AND_RETURN(jsEnv_, false);
|
||||
return jsEnv_->LoadScript(path, buffer, len, isBundle);
|
||||
}
|
||||
@@ -553,9 +555,9 @@ bool JsRuntime::LoadScript(const std::string& path, uint8_t* buffer, size_t len,
|
||||
std::unique_ptr<NativeReference> JsRuntime::LoadSystemModuleByEngine(
|
||||
napi_env env, const std::string& moduleName, const napi_value* argv, size_t argc)
|
||||
{
|
||||
HILOG_DEBUG("JsRuntime::LoadSystemModule(%{public}s)", moduleName.c_str());
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "JsRuntime::LoadSystemModule(%{public}s)", moduleName.c_str());
|
||||
if (env == nullptr) {
|
||||
HILOG_INFO("JsRuntime::LoadSystemModule: invalid engine.");
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "JsRuntime::LoadSystemModule: invalid engine.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -569,7 +571,7 @@ std::unique_ptr<NativeReference> JsRuntime::LoadSystemModuleByEngine(
|
||||
napi_create_reference(env, propertyValue, 1, &tmpRef);
|
||||
methodRequireNapiRef_.reset(reinterpret_cast<NativeReference*>(tmpRef));
|
||||
if (!methodRequireNapiRef_) {
|
||||
HILOG_ERROR("Failed to create reference for global.requireNapi");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Failed to create reference for global.requireNapi");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -582,7 +584,7 @@ std::unique_ptr<NativeReference> JsRuntime::LoadSystemModuleByEngine(
|
||||
napi_value instanceValue = nullptr;
|
||||
napi_new_instance(env, classValue, argc, argv, &instanceValue);
|
||||
if (instanceValue == nullptr) {
|
||||
HILOG_ERROR("Failed to create object instance");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Failed to create object instance");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -648,7 +650,7 @@ bool JsRuntime::Initialize(const Options& options)
|
||||
#endif
|
||||
if (!preloaded_) {
|
||||
if (!CreateJsEnv(options)) {
|
||||
HILOG_ERROR("Create js environment failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Create js environment failed.");
|
||||
return false;
|
||||
}
|
||||
NativeCreateEnv::RegCreateNapiEnvCallback(CreateNapiEnv);
|
||||
@@ -657,7 +659,7 @@ bool JsRuntime::Initialize(const Options& options)
|
||||
jsEnv_->StartMonitorJSHeapUsage();
|
||||
}
|
||||
apiTargetVersion_ = options.apiTargetVersion;
|
||||
HILOG_DEBUG("Initialize: %{public}d.", apiTargetVersion_);
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Initialize: %{public}d.", apiTargetVersion_);
|
||||
bool isModular = false;
|
||||
if (IsUseAbilityRuntime(options)) {
|
||||
auto env = GetNapiEnv();
|
||||
@@ -691,12 +693,12 @@ bool JsRuntime::Initialize(const Options& options)
|
||||
napi_create_reference(env, propertyValue, 1, &tmpRef);
|
||||
methodRequireNapiRef_.reset(reinterpret_cast<NativeReference*>(tmpRef));
|
||||
if (!methodRequireNapiRef_) {
|
||||
HILOG_ERROR("Failed to create reference for global.requireNapi");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Failed to create reference for global.requireNapi");
|
||||
return false;
|
||||
}
|
||||
HILOG_DEBUG("PreloadAce start.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "PreloadAce start.");
|
||||
PreloadAce(options);
|
||||
HILOG_DEBUG("PreloadAce end.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "PreloadAce end.");
|
||||
nativeEngine->RegisterPermissionCheck(PermissionCheckFunc);
|
||||
}
|
||||
|
||||
@@ -734,7 +736,7 @@ bool JsRuntime::Initialize(const Options& options)
|
||||
InitSourceMap(operatorObj);
|
||||
|
||||
if (options.isUnique) {
|
||||
HILOG_DEBUG("Not supported TimerModule when form render");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Not supported TimerModule when form render");
|
||||
} else {
|
||||
InitTimerModule();
|
||||
}
|
||||
@@ -744,7 +746,7 @@ bool JsRuntime::Initialize(const Options& options)
|
||||
SetRequestAotCallback();
|
||||
|
||||
if (!InitLoop()) {
|
||||
HILOG_ERROR("Initialize loop failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Initialize loop failed.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -764,7 +766,7 @@ bool JsRuntime::CreateJsEnv(const Options& options)
|
||||
pandaOption.SetArkBundleName(bundleName);
|
||||
pandaOption.SetGcThreadNum(gcThreadNum);
|
||||
pandaOption.SetLongPauseTime(longPauseTime);
|
||||
HILOG_DEBUG("JSRuntime::Initialize ark properties = %{public}d bundlename = %{public}s",
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "JSRuntime::Initialize ark properties = %{public}d bundlename = %{public}s",
|
||||
arkProperties, bundleName.c_str());
|
||||
pandaOption.SetGcType(panda::RuntimeOption::GC_TYPE::GEN_GC);
|
||||
pandaOption.SetGcPoolSize(DEFAULT_GC_POOL_SIZE);
|
||||
@@ -788,7 +790,7 @@ bool JsRuntime::CreateJsEnv(const Options& options)
|
||||
OHOSJsEnvLogger::RegisterJsEnvLogger();
|
||||
jsEnv_ = std::make_shared<JsEnv::JsEnvironment>(std::make_unique<OHOSJsEnvironmentImpl>(options.eventRunner));
|
||||
if (jsEnv_ == nullptr || !jsEnv_->Initialize(pandaOption, static_cast<void*>(this))) {
|
||||
HILOG_ERROR("Initialize js environment failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Initialize js environment failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -814,7 +816,7 @@ void JsRuntime::PreloadAce(const Options& options)
|
||||
|
||||
void JsRuntime::ReloadFormComponent()
|
||||
{
|
||||
HILOG_DEBUG("Call.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Call.");
|
||||
auto nativeEngine = GetNativeEnginePointer();
|
||||
CHECK_POINTER(nativeEngine);
|
||||
// ArkTsCard update condition, need to reload new component
|
||||
@@ -824,7 +826,7 @@ void JsRuntime::ReloadFormComponent()
|
||||
void JsRuntime::DoCleanWorkAfterStageCleaned()
|
||||
{
|
||||
// Force gc. If the jsRuntime is destroyed, this task should not be executed.
|
||||
HILOG_DEBUG("DoCleanWorkAfterStageCleaned begin");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "DoCleanWorkAfterStageCleaned begin");
|
||||
RemoveTask("ability_destruct_gc");
|
||||
auto gcTask = [this]() {
|
||||
panda::JSNApi::TriggerGC(GetEcmaVm(), panda::JSNApi::TRIGGER_GC_TYPE::FULL_GC);
|
||||
@@ -840,16 +842,16 @@ bool JsRuntime::InitLoop()
|
||||
|
||||
void JsRuntime::SetAppLibPath(const AppLibPathMap& appLibPaths, const bool& isSystemApp)
|
||||
{
|
||||
HILOG_DEBUG("Set library path.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Set library path.");
|
||||
|
||||
if (appLibPaths.size() == 0) {
|
||||
HILOG_WARN("There's no library path need to set.");
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME, "There's no library path need to set.");
|
||||
return;
|
||||
}
|
||||
|
||||
auto moduleManager = NativeModuleManager::GetInstance();
|
||||
if (moduleManager == nullptr) {
|
||||
HILOG_ERROR("Get module manager failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Get module manager failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -868,7 +870,7 @@ void JsRuntime::InitSourceMap(const std::shared_ptr<JsEnv::SourceMapOperator> op
|
||||
|
||||
void JsRuntime::Deinitialize()
|
||||
{
|
||||
HILOG_DEBUG("JsRuntime deinitialize.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "JsRuntime deinitialize.");
|
||||
for (auto it = modules_.begin(); it != modules_.end(); it = modules_.erase(it)) {
|
||||
delete it->second;
|
||||
it->second = nullptr;
|
||||
@@ -892,21 +894,21 @@ napi_value JsRuntime::LoadJsBundle(const std::string& path, const std::string& h
|
||||
napi_set_named_property(env, globalObj, "exports", exports);
|
||||
|
||||
if (!RunScript(path, hapPath, useCommonChunk)) {
|
||||
HILOG_ERROR("Failed to run script: %{private}s", path.c_str());
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Failed to run script: %{private}s", path.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
napi_value exportsObj = nullptr;
|
||||
napi_get_named_property(env, globalObj, "exports", &exportsObj);
|
||||
if (exportsObj == nullptr) {
|
||||
HILOG_ERROR("Failed to get exports objcect: %{private}s", path.c_str());
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Failed to get exports objcect: %{private}s", path.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
napi_value exportObj = nullptr;
|
||||
napi_get_named_property(env, exportsObj, "default", &exportObj);
|
||||
if (exportObj == nullptr) {
|
||||
HILOG_ERROR("Failed to get default objcect: %{private}s", path.c_str());
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Failed to get default objcect: %{private}s", path.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -917,7 +919,7 @@ napi_value JsRuntime::LoadJsModule(const std::string& path, const std::string& h
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
if (!RunScript(path, hapPath, false)) {
|
||||
HILOG_ERROR("Failed to run script: %{private}s", path.c_str());
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Failed to run script: %{private}s", path.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -925,7 +927,7 @@ napi_value JsRuntime::LoadJsModule(const std::string& path, const std::string& h
|
||||
CHECK_POINTER_AND_RETURN(vm, nullptr);
|
||||
panda::Local<panda::ObjectRef> exportObj = panda::JSNApi::GetExportObject(vm, path, "default");
|
||||
if (exportObj->IsNull()) {
|
||||
HILOG_ERROR("Get export object failed");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Get export object failed");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -938,7 +940,7 @@ std::unique_ptr<NativeReference> JsRuntime::LoadModule(const std::string& module
|
||||
const std::string& hapPath, bool esmodule, bool useCommonChunk)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("Load module(%{public}s, %{private}s, %{private}s, %{public}s)",
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Load module(%{public}s, %{private}s, %{private}s, %{public}s)",
|
||||
moduleName.c_str(), modulePath.c_str(), hapPath.c_str(), esmodule ? "true" : "false");
|
||||
auto vm = GetEcmaVm();
|
||||
CHECK_POINTER_AND_RETURN(vm, std::unique_ptr<NativeReference>());
|
||||
@@ -969,7 +971,7 @@ std::unique_ptr<NativeReference> JsRuntime::LoadModule(const std::string& module
|
||||
fileName = std::regex_replace(fileName, pattern, "");
|
||||
} else {
|
||||
if (!MakeFilePath(codePath_, modulePath, fileName)) {
|
||||
HILOG_ERROR("Failed to make module file path: %{private}s", modulePath.c_str());
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Failed to make module file path: %{private}s", modulePath.c_str());
|
||||
return std::unique_ptr<NativeReference>();
|
||||
}
|
||||
}
|
||||
@@ -986,7 +988,7 @@ std::unique_ptr<NativeReference> JsRuntime::LoadModule(const std::string& module
|
||||
napi_value instanceValue = nullptr;
|
||||
napi_new_instance(env, classValue, 0, nullptr, &instanceValue);
|
||||
if (instanceValue == nullptr) {
|
||||
HILOG_ERROR("Failed to create object instance");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Failed to create object instance");
|
||||
return std::unique_ptr<NativeReference>();
|
||||
}
|
||||
|
||||
@@ -998,7 +1000,7 @@ std::unique_ptr<NativeReference> JsRuntime::LoadModule(const std::string& module
|
||||
std::unique_ptr<NativeReference> JsRuntime::LoadSystemModule(
|
||||
const std::string& moduleName, const napi_value* argv, size_t argc)
|
||||
{
|
||||
HILOG_DEBUG("JsRuntime::LoadSystemModule(%{public}s)", moduleName.c_str());
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "JsRuntime::LoadSystemModule(%{public}s)", moduleName.c_str());
|
||||
napi_env env = GetNapiEnv();
|
||||
CHECK_POINTER_AND_RETURN(env, std::unique_ptr<NativeReference>());
|
||||
|
||||
@@ -1015,7 +1017,7 @@ std::unique_ptr<NativeReference> JsRuntime::LoadSystemModule(
|
||||
napi_value instanceValue = nullptr;
|
||||
napi_new_instance(env, classValue, argc, argv, &instanceValue);
|
||||
if (instanceValue == nullptr) {
|
||||
HILOG_ERROR("Failed to create object instance");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Failed to create object instance");
|
||||
return std::unique_ptr<NativeReference>();
|
||||
}
|
||||
|
||||
@@ -1044,7 +1046,7 @@ bool JsRuntime::RunScript(const std::string& srcPath, const std::string& hapPath
|
||||
std::string loadPath = ExtractorUtil::GetLoadFilePath(hapPath);
|
||||
std::shared_ptr<Extractor> extractor = ExtractorUtil::GetExtractor(loadPath, newCreate, true);
|
||||
if (!extractor) {
|
||||
HILOG_ERROR("Get extractor failed. hapPath[%{private}s]", hapPath.c_str());
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Get extractor failed. hapPath[%{private}s]", hapPath.c_str());
|
||||
return false;
|
||||
}
|
||||
if (newCreate) {
|
||||
@@ -1060,14 +1062,14 @@ bool JsRuntime::RunScript(const std::string& srcPath, const std::string& hapPath
|
||||
if (!extractor->IsHapCompress(modulePath) && useSafeMempry) {
|
||||
auto safeData = extractor->GetSafeData(modulePath);
|
||||
if (!safeData) {
|
||||
HILOG_ERROR("Get abc file failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Get abc file failed.");
|
||||
return false;
|
||||
}
|
||||
return LoadScript(abcPath, safeData->GetDataPtr(), safeData->GetDataLen(), isBundle_);
|
||||
} else {
|
||||
std::ostringstream outStream;
|
||||
if (!extractor->GetFileBuffer(modulePath, outStream)) {
|
||||
HILOG_ERROR("Get abc file failed");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Get abc file failed");
|
||||
return false;
|
||||
}
|
||||
const auto& outStr = outStream.str();
|
||||
@@ -1086,7 +1088,7 @@ bool JsRuntime::RunScript(const std::string& srcPath, const std::string& hapPath
|
||||
std::string path = srcPath;
|
||||
if (!isBundle_) {
|
||||
if (moduleName_.empty()) {
|
||||
HILOG_ERROR("moduleName is hole");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "moduleName is hole");
|
||||
return false;
|
||||
}
|
||||
path = BUNDLE_INSTALL_PATH + moduleName_ + MERGE_ABC_PATH;
|
||||
@@ -1105,13 +1107,13 @@ bool JsRuntime::RunSandboxScript(const std::string& path, const std::string& hap
|
||||
fileName = std::regex_replace(fileName, pattern, "");
|
||||
} else {
|
||||
if (!MakeFilePath(codePath_, path, fileName)) {
|
||||
HILOG_ERROR("Failed to make module file path: %{private}s", path.c_str());
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Failed to make module file path: %{private}s", path.c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!RunScript(fileName, hapPath)) {
|
||||
HILOG_ERROR("Failed to run script: %{public}s", fileName.c_str());
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Failed to run script: %{public}s", fileName.c_str());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -1214,7 +1216,7 @@ void JsRuntime::NotifyApplicationState(bool isBackground)
|
||||
auto nativeEngine = GetNativeEnginePointer();
|
||||
CHECK_POINTER(nativeEngine);
|
||||
nativeEngine->NotifyApplicationState(isBackground);
|
||||
HILOG_DEBUG("NotifyApplicationState, isBackground %{public}d.", isBackground);
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "NotifyApplicationState, isBackground %{public}d.", isBackground);
|
||||
}
|
||||
|
||||
bool JsRuntime::SuspendVM(uint32_t tid)
|
||||
@@ -1280,7 +1282,7 @@ void JsRuntime::UpdateModuleNameAndAssetPath(const std::string& moduleName)
|
||||
|
||||
auto vm = GetEcmaVm();
|
||||
if (!vm || moduleName.empty()) {
|
||||
HILOG_ERROR("vm is nullptr or moduleName is empty");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "vm is nullptr or moduleName is empty");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1307,23 +1309,24 @@ bool JsRuntime::ReadSourceMapData(const std::string& hapPath, const std::string&
|
||||
{
|
||||
// Source map relative path, FA: "/assets/js", Stage: "/ets"
|
||||
if (hapPath.empty()) {
|
||||
HILOG_ERROR("hapPath is empty");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "hapPath is empty");
|
||||
return false;
|
||||
}
|
||||
bool newCreate = false;
|
||||
std::shared_ptr<Extractor> extractor = ExtractorUtil::GetExtractor(
|
||||
ExtractorUtil::GetLoadFilePath(hapPath), newCreate);
|
||||
if (extractor == nullptr) {
|
||||
HILOG_ERROR("hap's path: %{public}s, get extractor failed", hapPath.c_str());
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "hap's path: %{public}s, get extractor failed", hapPath.c_str());
|
||||
return false;
|
||||
}
|
||||
std::unique_ptr<uint8_t[]> dataPtr = nullptr;
|
||||
size_t len = 0;
|
||||
if (!extractor->ExtractToBufByName(sourceMapPath, dataPtr, len)) {
|
||||
HILOG_DEBUG("can't find source map, and switch to stage model.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "can't find source map, and switch to stage model.");
|
||||
std::string tempPath = std::regex_replace(sourceMapPath, std::regex("ets"), "assets/js");
|
||||
if (!extractor->ExtractToBufByName(tempPath, dataPtr, len)) {
|
||||
HILOG_DEBUG("get mergeSourceMapData fileBuffer failed, map path: %{private}s", tempPath.c_str());
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "get mergeSourceMapData fileBuffer failed, map path: %{private}s",
|
||||
tempPath.c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1350,7 +1353,7 @@ void JsRuntime::FreeNativeReference(std::unique_ptr<NativeReference> uniqueNativ
|
||||
std::shared_ptr<NativeReference>&& sharedNativeRef)
|
||||
{
|
||||
if (uniqueNativeRef == nullptr && sharedNativeRef == nullptr) {
|
||||
HILOG_WARN("native reference is invalid.");
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME, "native reference is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1361,13 +1364,13 @@ void JsRuntime::FreeNativeReference(std::unique_ptr<NativeReference> uniqueNativ
|
||||
|
||||
auto work = new (std::nothrow) uv_work_t;
|
||||
if (work == nullptr) {
|
||||
HILOG_ERROR("new uv work failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "new uv work failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
auto cb = new (std::nothrow) JsNativeReferenceDeleterObject();
|
||||
if (cb == nullptr) {
|
||||
HILOG_ERROR("new deleter object failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "new deleter object failed.");
|
||||
delete work;
|
||||
work = nullptr;
|
||||
return;
|
||||
@@ -1442,23 +1445,24 @@ void JsRuntime::SetRequestAotCallback()
|
||||
auto callback = [](const std::string& bundleName, const std::string& moduleName, int32_t triggerMode) -> int32_t {
|
||||
auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (systemAbilityMgr == nullptr) {
|
||||
HILOG_ERROR("Failed to get system ability manager.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Failed to get system ability manager.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
auto remoteObj = systemAbilityMgr->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID);
|
||||
if (remoteObj == nullptr) {
|
||||
HILOG_ERROR("Remote object is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Remote object is nullptr.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
auto bundleMgr = iface_cast<AppExecFwk::IBundleMgr>(remoteObj);
|
||||
if (bundleMgr == nullptr) {
|
||||
HILOG_ERROR("Failed to get bundle manager.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Failed to get bundle manager.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("Reset compile status, bundleName: %{public}s, moduleName: %{public}s, triggerMode: %{public}d.",
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME,
|
||||
"Reset compile status, bundleName: %{public}s, moduleName: %{public}s, triggerMode: %{public}d.",
|
||||
bundleName.c_str(), moduleName.c_str(), triggerMode);
|
||||
return bundleMgr->ResetAOTCompileStatus(bundleName, moduleName, triggerMode);
|
||||
};
|
||||
@@ -1468,7 +1472,7 @@ void JsRuntime::SetRequestAotCallback()
|
||||
|
||||
void JsRuntime::SetDeviceDisconnectCallback(const std::function<bool()> &cb)
|
||||
{
|
||||
HILOG_DEBUG("Start.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Start.");
|
||||
CHECK_POINTER(jsEnv_);
|
||||
jsEnv_->SetDeviceDisconnectCallback(cb);
|
||||
}
|
||||
@@ -1524,7 +1528,7 @@ std::vector<panda::HmsMap> JsRuntime::GetSystemKitsMap(uint32_t version)
|
||||
systemKitsMap.emplace_back(hmsMap);
|
||||
}
|
||||
}
|
||||
HILOG_DEBUG("The size of the map is %{public}zu", systemKitsMap.size());
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "The size of the map is %{public}zu", systemKitsMap.size());
|
||||
return systemKitsMap;
|
||||
}
|
||||
|
||||
@@ -1559,7 +1563,7 @@ void JsRuntime::SetChildOptions(const Options& options)
|
||||
|
||||
std::shared_ptr<Runtime::Options> JsRuntime::GetChildOptions()
|
||||
{
|
||||
HILOG_DEBUG("called");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
return childOptions_;
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "js_runtime_utils.h"
|
||||
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "js_runtime.h"
|
||||
#include "napi/native_api.h"
|
||||
@@ -246,7 +247,7 @@ bool NapiAsyncTask::StartWithDefaultQos(const std::string &name, napi_env env)
|
||||
|
||||
void NapiAsyncTask::Resolve(napi_env env, napi_value value)
|
||||
{
|
||||
HILOG_DEBUG("NapiAsyncTask::Resolve is called");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "NapiAsyncTask::Resolve is called");
|
||||
if (deferred_) {
|
||||
napi_resolve_deferred(env, deferred_, value);
|
||||
deferred_ = nullptr;
|
||||
@@ -262,12 +263,12 @@ void NapiAsyncTask::Resolve(napi_env env, napi_value value)
|
||||
napi_delete_reference(env, callbackRef_);
|
||||
callbackRef_ = nullptr;
|
||||
}
|
||||
HILOG_DEBUG("NapiAsyncTask::Resolve is called end.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "NapiAsyncTask::Resolve is called end.");
|
||||
}
|
||||
|
||||
void NapiAsyncTask::ResolveWithNoError(napi_env env, napi_value value)
|
||||
{
|
||||
HILOG_DEBUG("NapiAsyncTask::Resolve is called");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "NapiAsyncTask::Resolve is called");
|
||||
if (deferred_) {
|
||||
napi_resolve_deferred(env, deferred_, value);
|
||||
deferred_ = nullptr;
|
||||
@@ -283,7 +284,7 @@ void NapiAsyncTask::ResolveWithNoError(napi_env env, napi_value value)
|
||||
napi_delete_reference(env, callbackRef_);
|
||||
callbackRef_ = nullptr;
|
||||
}
|
||||
HILOG_DEBUG("NapiAsyncTask::Resolve is called end.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "NapiAsyncTask::Resolve is called end.");
|
||||
}
|
||||
|
||||
void NapiAsyncTask::Reject(napi_env env, napi_value error)
|
||||
@@ -307,7 +308,7 @@ void NapiAsyncTask::Reject(napi_env env, napi_value error)
|
||||
|
||||
void NapiAsyncTask::ResolveWithCustomize(napi_env env, napi_value error, napi_value value)
|
||||
{
|
||||
HILOG_DEBUG("NapiAsyncTask::ResolveWithCustomize is called");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "NapiAsyncTask::ResolveWithCustomize is called");
|
||||
if (deferred_) {
|
||||
napi_resolve_deferred(env, deferred_, value);
|
||||
deferred_ = nullptr;
|
||||
@@ -323,12 +324,12 @@ void NapiAsyncTask::ResolveWithCustomize(napi_env env, napi_value error, napi_va
|
||||
napi_delete_reference(env, callbackRef_);
|
||||
callbackRef_ = nullptr;
|
||||
}
|
||||
HILOG_DEBUG("NapiAsyncTask::ResolveWithCustomize is called end.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "NapiAsyncTask::ResolveWithCustomize is called end.");
|
||||
}
|
||||
|
||||
void NapiAsyncTask::RejectWithCustomize(napi_env env, napi_value error, napi_value value)
|
||||
{
|
||||
HILOG_DEBUG("NapiAsyncTask::RejectWithCustomize is called");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "NapiAsyncTask::RejectWithCustomize is called");
|
||||
if (deferred_) {
|
||||
napi_reject_deferred(env, deferred_, error);
|
||||
deferred_ = nullptr;
|
||||
@@ -344,7 +345,7 @@ void NapiAsyncTask::RejectWithCustomize(napi_env env, napi_value error, napi_val
|
||||
napi_delete_reference(env, callbackRef_);
|
||||
callbackRef_ = nullptr;
|
||||
}
|
||||
HILOG_DEBUG("NapiAsyncTask::RejectWithCustomize is called end.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "NapiAsyncTask::RejectWithCustomize is called end.");
|
||||
}
|
||||
|
||||
void NapiAsyncTask::Execute(napi_env env, void* data)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "foundation/communication/ipc/interfaces/innerkits/ipc_core/include/iremote_object.h"
|
||||
#include "singleton.h"
|
||||
#include "system_ability_definition.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "js_runtime_utils.h"
|
||||
#include "native_engine/impl/ark/ark_native_engine.h"
|
||||
@@ -69,16 +70,16 @@ std::mutex g_mutex;
|
||||
|
||||
void InitWorkerFunc(NativeEngine* nativeEngine)
|
||||
{
|
||||
HILOG_DEBUG("called");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
if (nativeEngine == nullptr) {
|
||||
HILOG_ERROR("Input nativeEngine is nullptr");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Input nativeEngine is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
napi_value globalObj = nullptr;
|
||||
napi_get_global(reinterpret_cast<napi_env>(nativeEngine), &globalObj);
|
||||
if (globalObj == nullptr) {
|
||||
HILOG_ERROR("Failed to get global object");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Failed to get global object");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -88,7 +89,7 @@ void InitWorkerFunc(NativeEngine* nativeEngine)
|
||||
auto arkNativeEngine = static_cast<ArkNativeEngine*>(nativeEngine);
|
||||
// load jsfwk
|
||||
if (g_jsFramework && !arkNativeEngine->ExecuteJsBin("/system/etc/strip.native.min.abc")) {
|
||||
HILOG_ERROR("Failed to load js framework!");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Failed to load js framework!");
|
||||
}
|
||||
|
||||
if (g_debugMode) {
|
||||
@@ -109,9 +110,9 @@ void InitWorkerFunc(NativeEngine* nativeEngine)
|
||||
|
||||
void OffWorkerFunc(NativeEngine* nativeEngine)
|
||||
{
|
||||
HILOG_DEBUG("OffWorkerFunc called");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "OffWorkerFunc called");
|
||||
if (nativeEngine == nullptr) {
|
||||
HILOG_ERROR("Input nativeEngine is nullptr");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Input nativeEngine is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -139,10 +140,10 @@ std::string AssetHelper::NormalizedFileName(const std::string& fileName) const
|
||||
// 1.1 end with file name
|
||||
// 1.2 end with file name and file type
|
||||
if (index == std::string::npos) {
|
||||
HILOG_DEBUG("uri end without file type");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "uri end without file type");
|
||||
normalizedFilePath = fileName + ".abc";
|
||||
} else {
|
||||
HILOG_DEBUG("uri end with file type");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "uri end with file type");
|
||||
normalizedFilePath = fileName.substr(0, index) + ".abc";
|
||||
}
|
||||
return normalizedFilePath;
|
||||
@@ -150,7 +151,7 @@ std::string AssetHelper::NormalizedFileName(const std::string& fileName) const
|
||||
|
||||
AssetHelper::~AssetHelper()
|
||||
{
|
||||
HILOG_DEBUG("destroyed.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "destroyed.");
|
||||
if (fd_ != -1) {
|
||||
close(fd_);
|
||||
fd_ = -1;
|
||||
@@ -161,11 +162,11 @@ void AssetHelper::operator()(const std::string& uri, uint8_t** buff, size_t* buf
|
||||
bool& useSecureMem, bool isRestricted)
|
||||
{
|
||||
if (uri.empty() || buff == nullptr || buffSize == nullptr || workerInfo_ == nullptr) {
|
||||
HILOG_ERROR("Input params invalid.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Input params invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("RegisterAssetFunc called, uri: %{private}s", uri.c_str());
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "RegisterAssetFunc called, uri: %{private}s", uri.c_str());
|
||||
std::string realPath;
|
||||
std::string filePath;
|
||||
useSecureMem = false;
|
||||
@@ -178,23 +179,23 @@ void AssetHelper::operator()(const std::string& uri, uint8_t** buff, size_t* buf
|
||||
// 1.2 start with ../
|
||||
// 1.3 start with @namespace [not support]
|
||||
// 1.4 start with modulename
|
||||
HILOG_DEBUG("The application is packaged using jsbundle mode.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "The application is packaged using jsbundle mode.");
|
||||
if (uri.find_first_of("/") == 0) {
|
||||
HILOG_DEBUG("uri start with /modulename");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "uri start with /modulename");
|
||||
realPath = uri.substr(1);
|
||||
} else if (uri.find("../") == 0 && !workerInfo_->isStageModel) {
|
||||
HILOG_DEBUG("uri start with ../");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "uri start with ../");
|
||||
realPath = uri.substr(PATH_THREE);
|
||||
} else if (uri.find_first_of("@") == 0) {
|
||||
HILOG_DEBUG("uri start with @namespace");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "uri start with @namespace");
|
||||
realPath = uri.substr(uri.find_first_of("/") + 1);
|
||||
} else {
|
||||
HILOG_DEBUG("uri start with modulename");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "uri start with modulename");
|
||||
realPath = uri;
|
||||
}
|
||||
|
||||
filePath = NormalizedFileName(realPath);
|
||||
HILOG_INFO("filePath %{private}s", filePath.c_str());
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "filePath %{private}s", filePath.c_str());
|
||||
|
||||
if (!workerInfo_->isStageModel) {
|
||||
GetAmi(ami, filePath);
|
||||
@@ -202,22 +203,22 @@ void AssetHelper::operator()(const std::string& uri, uint8_t** buff, size_t* buf
|
||||
ami = workerInfo_->codePath + filePath;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("Get asset, ami: %{private}s", ami.c_str());
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Get asset, ami: %{private}s", ami.c_str());
|
||||
if (ami.find(CACHE_DIRECTORY) != std::string::npos) {
|
||||
if (!ReadAmiData(ami, buff, buffSize, useSecureMem, isRestricted)) {
|
||||
HILOG_ERROR("Get buffer by ami failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Get buffer by ami failed.");
|
||||
}
|
||||
} else if (!ReadFilePathData(filePath, buff, buffSize, useSecureMem, isRestricted)) {
|
||||
HILOG_ERROR("Get buffer by filepath failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Get buffer by filepath failed.");
|
||||
}
|
||||
} else {
|
||||
// 2.1 start with @bundle:bundlename/modulename
|
||||
// 2.2 start with /modulename
|
||||
// 2.3 start with @namespace
|
||||
// 2.4 start with modulename
|
||||
HILOG_DEBUG("The application is packaged using esmodule mode.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "The application is packaged using esmodule mode.");
|
||||
if (uri.find(BUNDLE_NAME_FLAG) == 0) {
|
||||
HILOG_DEBUG("uri start with @bundle:");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "uri start with @bundle:");
|
||||
size_t fileNamePos = uri.find_last_of("/");
|
||||
realPath = uri.substr(fileNamePos + 1);
|
||||
if (realPath.find_last_of(".") != std::string::npos) {
|
||||
@@ -225,66 +226,67 @@ void AssetHelper::operator()(const std::string& uri, uint8_t** buff, size_t* buf
|
||||
} else {
|
||||
ami = uri;
|
||||
}
|
||||
HILOG_DEBUG("Get asset, ami: %{private}s", ami.c_str());
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Get asset, ami: %{private}s", ami.c_str());
|
||||
return;
|
||||
} else if (uri.find_first_of("/") == 0) {
|
||||
HILOG_DEBUG("uri start with /modulename");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "uri start with /modulename");
|
||||
realPath = uri.substr(1);
|
||||
} else if (uri.find_first_of("@") == 0) {
|
||||
HILOG_DEBUG("uri start with @namespace");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "uri start with @namespace");
|
||||
realPath = workerInfo_->moduleName + uri;
|
||||
} else {
|
||||
HILOG_DEBUG("uri start with modulename");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "uri start with modulename");
|
||||
realPath = uri;
|
||||
}
|
||||
|
||||
filePath = NormalizedFileName(realPath);
|
||||
ami = workerInfo_->codePath + filePath;
|
||||
HILOG_DEBUG("Get asset, ami: %{private}s", ami.c_str());
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Get asset, ami: %{private}s", ami.c_str());
|
||||
if (ami.find(CACHE_DIRECTORY) != std::string::npos) {
|
||||
if (!ReadAmiData(ami, buff, buffSize, useSecureMem, isRestricted)) {
|
||||
HILOG_ERROR("Get buffer by ami failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Get buffer by ami failed.");
|
||||
}
|
||||
} else if (!ReadFilePathData(filePath, buff, buffSize, useSecureMem, isRestricted)) {
|
||||
HILOG_ERROR("Get buffer by filepath failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Get buffer by filepath failed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool AssetHelper::GetSafeData(const std::string& ami, uint8_t** buff, size_t* buffSize)
|
||||
{
|
||||
HILOG_DEBUG("Use secure mem.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Use secure mem.");
|
||||
std::string resolvedPath;
|
||||
resolvedPath.reserve(PATH_MAX);
|
||||
resolvedPath.resize(PATH_MAX - 1);
|
||||
if (realpath(ami.c_str(), &(resolvedPath[0])) == nullptr) {
|
||||
HILOG_ERROR("Realpath file %{private}s caught error: %{public}d.", ami.c_str(), errno);
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Realpath file %{private}s caught error: %{public}d.", ami.c_str(), errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
int fd = open(resolvedPath.c_str(), O_RDONLY);
|
||||
if (fd < 0) {
|
||||
HILOG_ERROR("Open file %{private}s caught error: %{public}d.", resolvedPath.c_str(), errno);
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Open file %{private}s caught error: %{public}d.", resolvedPath.c_str(), errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
struct stat statbuf;
|
||||
if (fstat(fd, &statbuf) < 0) {
|
||||
HILOG_ERROR("Get fstat of file %{private}s caught error: %{public}d.", resolvedPath.c_str(), errno);
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Get fstat of file %{private}s caught error: %{public}d.", resolvedPath.c_str(),
|
||||
errno);
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::unique_ptr<FileMapper> fileMapper = std::make_unique<FileMapper>();
|
||||
if (fileMapper == nullptr) {
|
||||
HILOG_ERROR("Create file mapper failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Create file mapper failed.");
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
||||
auto result = fileMapper->CreateFileMapper(resolvedPath, false, fd, 0, statbuf.st_size, FileMapperType::SAFE_ABC);
|
||||
if (!result) {
|
||||
HILOG_ERROR("Create file %{private}s mapper failed.", resolvedPath.c_str());
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Create file %{private}s mapper failed.", resolvedPath.c_str());
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
@@ -307,30 +309,30 @@ bool AssetHelper::ReadAmiData(const std::string& ami, uint8_t** buff, size_t* bu
|
||||
|
||||
char path[PATH_MAX];
|
||||
if (realpath(ami.c_str(), path) == nullptr) {
|
||||
HILOG_ERROR("Realpath file %{private}s caught error: %{public}d.", ami.c_str(), errno);
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Realpath file %{private}s caught error: %{public}d.", ami.c_str(), errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::ifstream stream(path, std::ios::binary | std::ios::ate);
|
||||
if (!stream.is_open()) {
|
||||
HILOG_ERROR("Failed to open file %{private}s.", ami.c_str());
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Failed to open file %{private}s.", ami.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
auto fileLen = stream.tellg();
|
||||
if (!workerInfo_->isDebugVersion && fileLen > ASSET_FILE_MAX_SIZE) {
|
||||
HILOG_ERROR("File is too large.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "File is too large.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fileLen <= 0) {
|
||||
HILOG_ERROR("Invalid file length.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Invalid file length.");
|
||||
return false;
|
||||
}
|
||||
|
||||
auto temp = std::make_unique<uint8_t[]>(fileLen);
|
||||
if (temp == nullptr) {
|
||||
HILOG_ERROR("Alloc mem failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Alloc mem failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -347,7 +349,7 @@ bool AssetHelper::ReadFilePathData(const std::string& filePath, uint8_t** buff,
|
||||
{
|
||||
auto bundleMgrHelper = DelayedSingleton<AppExecFwk::BundleMgrHelper>::GetInstance();
|
||||
if (bundleMgrHelper == nullptr) {
|
||||
HILOG_ERROR("The bundleMgrHelper is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "The bundleMgrHelper is nullptr.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -355,11 +357,11 @@ bool AssetHelper::ReadFilePathData(const std::string& filePath, uint8_t** buff,
|
||||
auto getInfoResult = bundleMgrHelper->GetBundleInfoForSelf(
|
||||
static_cast<int32_t>(AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE), bundleInfo);
|
||||
if (getInfoResult != 0) {
|
||||
HILOG_ERROR("GetBundleInfoForSelf failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "GetBundleInfoForSelf failed.");
|
||||
return false;
|
||||
}
|
||||
if (bundleInfo.hapModuleInfos.size() == 0) {
|
||||
HILOG_ERROR("Get hapModuleInfo of bundleInfo failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Get hapModuleInfo of bundleInfo failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -375,12 +377,12 @@ bool AssetHelper::ReadFilePathData(const std::string& filePath, uint8_t** buff,
|
||||
}
|
||||
}
|
||||
}
|
||||
HILOG_DEBUG("HapPath: %{private}s", newHapPath.c_str());
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "HapPath: %{private}s", newHapPath.c_str());
|
||||
bool newCreate = false;
|
||||
std::string loadPath = ExtractorUtil::GetLoadFilePath(newHapPath);
|
||||
std::shared_ptr<Extractor> extractor = ExtractorUtil::GetExtractor(loadPath, newCreate);
|
||||
if (extractor == nullptr) {
|
||||
HILOG_ERROR("LoadPath %{private}s GetExtractor failed", loadPath.c_str());
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "LoadPath %{private}s GetExtractor failed", loadPath.c_str());
|
||||
return false;
|
||||
}
|
||||
std::unique_ptr<uint8_t[]> dataPtr = nullptr;
|
||||
@@ -390,22 +392,22 @@ bool AssetHelper::ReadFilePathData(const std::string& filePath, uint8_t** buff,
|
||||
bool flag = false;
|
||||
for (const auto& basePath : workerInfo_->assetBasePathStr) {
|
||||
realfilePath = basePath + filePath;
|
||||
HILOG_DEBUG("realfilePath: %{private}s", realfilePath.c_str());
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "realfilePath: %{private}s", realfilePath.c_str());
|
||||
if (extractor->ExtractToBufByName(realfilePath, dataPtr, fileLen)) {
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag) {
|
||||
HILOG_ERROR("ExtractToBufByName error");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ExtractToBufByName error");
|
||||
return flag;
|
||||
}
|
||||
} else {
|
||||
realfilePath = filePath.substr(pos + 1);
|
||||
HILOG_DEBUG("realfilePath: %{private}s", realfilePath.c_str());
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "realfilePath: %{private}s", realfilePath.c_str());
|
||||
bool apiSatisfy = workerInfo_->apiTargetVersion == 0 || workerInfo_->apiTargetVersion > API8;
|
||||
if (workerInfo_->isStageModel && !isRestricted && apiSatisfy && !extractor->IsHapCompress(realfilePath)) {
|
||||
HILOG_DEBUG("Use secure mem.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Use secure mem.");
|
||||
auto safeData = extractor->GetSafeData(realfilePath);
|
||||
if (safeData != nullptr) {
|
||||
*buff = safeData->GetDataPtr();
|
||||
@@ -415,13 +417,13 @@ bool AssetHelper::ReadFilePathData(const std::string& filePath, uint8_t** buff,
|
||||
}
|
||||
}
|
||||
if (!extractor->ExtractToBufByName(realfilePath, dataPtr, fileLen)) {
|
||||
HILOG_ERROR("get mergeAbc fileBuffer failed");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "get mergeAbc fileBuffer failed");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!workerInfo_->isDebugVersion && fileLen > ASSET_FILE_MAX_SIZE) {
|
||||
HILOG_ERROR("ReadFilePathData failed, file is too large");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ReadFilePathData failed, file is too large");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -440,13 +442,13 @@ void AssetHelper::GetAmi(std::string& ami, const std::string& filePath)
|
||||
bool newCreate = false;
|
||||
std::shared_ptr<Extractor> extractor = ExtractorUtil::GetExtractor(loadPath, newCreate);
|
||||
if (extractor == nullptr) {
|
||||
HILOG_ERROR("loadPath %{private}s GetExtractor failed", loadPath.c_str());
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "loadPath %{private}s GetExtractor failed", loadPath.c_str());
|
||||
return;
|
||||
}
|
||||
std::vector<std::string> files;
|
||||
for (const auto& basePath : workerInfo_->assetBasePathStr) {
|
||||
std::string assetPath = basePath + path;
|
||||
HILOG_INFO("assetPath: %{private}s", assetPath.c_str());
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "assetPath: %{private}s", assetPath.c_str());
|
||||
bool res = extractor->IsDirExist(assetPath);
|
||||
if (!res) {
|
||||
continue;
|
||||
@@ -470,10 +472,10 @@ void AssetHelper::GetAmi(std::string& ami, const std::string& filePath)
|
||||
}
|
||||
}
|
||||
|
||||
HILOG_INFO("targetFilePath %{public}s", targetFilePath.c_str());
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "targetFilePath %{public}s", targetFilePath.c_str());
|
||||
|
||||
if (!flag) {
|
||||
HILOG_ERROR("get targetFilePath failed!");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "get targetFilePath failed!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <regex>
|
||||
|
||||
#include "bundle_mgr_interface.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "js_environment.h"
|
||||
@@ -39,7 +40,7 @@ constexpr size_t MAX_ENV_COUNT = 16;
|
||||
const std::string SANDBOX_ARK_PROIFILE_PATH = "/data/storage/ark-profile";
|
||||
int32_t PrintVmLog(int32_t, int32_t, const char*, const char*, const char* message)
|
||||
{
|
||||
HILOG_INFO("ArkLog: %{public}s", message);
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "ArkLog: %{public}s", message);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -65,7 +66,7 @@ NativeRuntimeImpl& NativeRuntimeImpl::GetNativeRuntimeImpl()
|
||||
|
||||
napi_status NativeRuntimeImpl::CreateJsEnv(const Options& options, std::shared_ptr<JsEnv::JsEnvironment>& jsEnv)
|
||||
{
|
||||
HILOG_DEBUG("called");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
panda::RuntimeOption pandaOption;
|
||||
int arkProperties = OHOS::system::GetIntParameter<int>("persist.ark.properties", -1);
|
||||
std::string bundleName = OHOS::system::GetParameter("persist.ark.arkbundlename", "");
|
||||
@@ -75,7 +76,7 @@ napi_status NativeRuntimeImpl::CreateJsEnv(const Options& options, std::shared_p
|
||||
pandaOption.SetArkBundleName(bundleName);
|
||||
pandaOption.SetGcThreadNum(gcThreadNum);
|
||||
pandaOption.SetLongPauseTime(longPauseTime);
|
||||
HILOG_INFO("NativeRuntimeImpl::Initialize ark properties = %{public}d bundlename = %{public}s",
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "NativeRuntimeImpl::Initialize ark properties = %{public}d bundlename = %{public}s",
|
||||
arkProperties, bundleName.c_str());
|
||||
pandaOption.SetGcType(panda::RuntimeOption::GC_TYPE::GEN_GC);
|
||||
pandaOption.SetGcPoolSize(DEFAULT_GC_POOL_SIZE);
|
||||
@@ -100,7 +101,7 @@ napi_status NativeRuntimeImpl::CreateJsEnv(const Options& options, std::shared_p
|
||||
jsEnv = std::make_shared<JsEnv::JsEnvironment>(std::make_unique<OHOSJsEnvironmentImpl>(options.eventRunner));
|
||||
if (jsEnv == nullptr || !jsEnv->Initialize(pandaOption, static_cast<void*>(this))
|
||||
|| jsEnv->GetNativeEngine() == nullptr) {
|
||||
HILOG_ERROR("Initialize js environment failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Initialize js environment failed.");
|
||||
return napi_status::napi_ok;
|
||||
}
|
||||
jsEnv->GetNativeEngine()->MarkNativeThread();
|
||||
@@ -111,13 +112,13 @@ napi_status NativeRuntimeImpl::Init(const Options& options, napi_env env)
|
||||
{
|
||||
auto jsEnv = GetJsEnv(env);
|
||||
if (jsEnv == nullptr) {
|
||||
HILOG_ERROR("jsEnv is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv is nullptr.");
|
||||
return napi_status::napi_generic_failure;
|
||||
}
|
||||
|
||||
auto vm = GetEcmaVm(jsEnv);
|
||||
if (!vm) {
|
||||
HILOG_ERROR("vm is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "vm is nullptr.");
|
||||
return napi_status::napi_generic_failure;
|
||||
}
|
||||
|
||||
@@ -155,7 +156,7 @@ napi_status NativeRuntimeImpl::Init(const Options& options, napi_env env)
|
||||
SetRequestAotCallback(jsEnv);
|
||||
|
||||
if (!InitLoop(jsEnv)) {
|
||||
HILOG_ERROR("Initialize loop failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Initialize loop failed.");
|
||||
return napi_status::napi_generic_failure;
|
||||
}
|
||||
}
|
||||
@@ -169,15 +170,15 @@ napi_status NativeRuntimeImpl::AddEnv(napi_env env, std::shared_ptr<JsEnv::JsEnv
|
||||
std::lock_guard<std::mutex> lock(envMutex_);
|
||||
pid_t threadId = gettid();
|
||||
if (threadIds_.find(threadId) != threadIds_.end()) {
|
||||
HILOG_ERROR("already created!");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "already created!");
|
||||
return napi_status::napi_create_ark_runtime_only_one_env_per_thread;
|
||||
}
|
||||
if (envMap_.size() >= MAX_ENV_COUNT) {
|
||||
HILOG_ERROR("the maximum number of runtime environments that can be created is 16!");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "the maximum number of runtime environments that can be created is 16!");
|
||||
return napi_status::napi_create_ark_runtime_too_many_envs;
|
||||
}
|
||||
threadIds_.insert(threadId);
|
||||
HILOG_DEBUG("add threadId %{public}zu", threadId);
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "add threadId %{public}zu", threadId);
|
||||
auto it = envMap_.find(env);
|
||||
if (it == envMap_.end()) {
|
||||
envMap_[env] = jsEnv;
|
||||
@@ -190,7 +191,7 @@ napi_status NativeRuntimeImpl::RemoveJsEnv(napi_env env)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(envMutex_);
|
||||
pid_t threadId = gettid();
|
||||
HILOG_DEBUG("remove threadId %{public}zu", threadId);
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "remove threadId %{public}zu", threadId);
|
||||
threadIds_.erase(threadId);
|
||||
auto it = envMap_.find(env);
|
||||
if (it != envMap_.end()) {
|
||||
@@ -205,7 +206,7 @@ napi_status NativeRuntimeImpl::RemoveJsEnv(napi_env env)
|
||||
panda::ecmascript::EcmaVM* NativeRuntimeImpl::GetEcmaVm(const std::shared_ptr<JsEnv::JsEnvironment>& jsEnv) const
|
||||
{
|
||||
if (jsEnv == nullptr) {
|
||||
HILOG_ERROR("jsEnv is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv is nullptr.");
|
||||
return nullptr;
|
||||
}
|
||||
return jsEnv->GetVM();
|
||||
@@ -239,7 +240,7 @@ void NativeRuntimeImpl::LoadAotFile(const Options& options, const std::shared_pt
|
||||
void NativeRuntimeImpl::InitConsoleModule(const std::shared_ptr<JsEnv::JsEnvironment>& jsEnv)
|
||||
{
|
||||
if (jsEnv == nullptr) {
|
||||
HILOG_ERROR("jsEnv is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv is nullptr.");
|
||||
return;
|
||||
}
|
||||
jsEnv->InitConsoleModule();
|
||||
@@ -249,7 +250,7 @@ void NativeRuntimeImpl::InitSourceMap(const std::shared_ptr<JsEnv::SourceMapOper
|
||||
const std::shared_ptr<JsEnv::JsEnvironment>& jsEnv)
|
||||
{
|
||||
if (jsEnv == nullptr) {
|
||||
HILOG_ERROR("jsEnv is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv is nullptr.");
|
||||
return;
|
||||
}
|
||||
jsEnv->InitSourceMap(operatorObj);
|
||||
@@ -258,7 +259,7 @@ void NativeRuntimeImpl::InitSourceMap(const std::shared_ptr<JsEnv::SourceMapOper
|
||||
void NativeRuntimeImpl::InitTimerModule(const std::shared_ptr<JsEnv::JsEnvironment>& jsEnv)
|
||||
{
|
||||
if (jsEnv == nullptr) {
|
||||
HILOG_ERROR("jsEnv is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv is nullptr.");
|
||||
return;
|
||||
}
|
||||
jsEnv->InitTimerModule();
|
||||
@@ -268,7 +269,7 @@ void NativeRuntimeImpl::SetModuleLoadChecker(const std::shared_ptr<ModuleChecker
|
||||
const std::shared_ptr<JsEnv::JsEnvironment>& jsEnv)
|
||||
{
|
||||
if (jsEnv == nullptr) {
|
||||
HILOG_ERROR("jsEnv is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv is nullptr.");
|
||||
return;
|
||||
}
|
||||
jsEnv->SetModuleLoadChecker(moduleCheckerDelegate);
|
||||
@@ -277,29 +278,30 @@ void NativeRuntimeImpl::SetModuleLoadChecker(const std::shared_ptr<ModuleChecker
|
||||
void NativeRuntimeImpl::SetRequestAotCallback(const std::shared_ptr<JsEnv::JsEnvironment>& jsEnv)
|
||||
{
|
||||
if (jsEnv == nullptr) {
|
||||
HILOG_ERROR("jsEnv is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv is nullptr.");
|
||||
return;
|
||||
}
|
||||
auto callback = [](const std::string& bundleName, const std::string& moduleName, int32_t triggerMode) -> int32_t {
|
||||
auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (systemAbilityMgr == nullptr) {
|
||||
HILOG_ERROR("Failed to get system ability manager.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Failed to get system ability manager.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
auto remoteObj = systemAbilityMgr->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID);
|
||||
if (remoteObj == nullptr) {
|
||||
HILOG_ERROR("Remote object is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Remote object is nullptr.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
auto bundleMgr = iface_cast<AppExecFwk::IBundleMgr>(remoteObj);
|
||||
if (bundleMgr == nullptr) {
|
||||
HILOG_ERROR("Failed to get bundle manager.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Failed to get bundle manager.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("Reset compile status, bundleName: %{public}s, moduleName: %{public}s, triggerMode: %{public}d.",
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME,
|
||||
"Reset compile status, bundleName: %{public}s, moduleName: %{public}s, triggerMode: %{public}d.",
|
||||
bundleName.c_str(), moduleName.c_str(), triggerMode);
|
||||
return bundleMgr->ResetAOTCompileStatus(bundleName, moduleName, triggerMode);
|
||||
};
|
||||
@@ -310,7 +312,7 @@ void NativeRuntimeImpl::SetRequestAotCallback(const std::shared_ptr<JsEnv::JsEnv
|
||||
bool NativeRuntimeImpl::InitLoop(const std::shared_ptr<JsEnv::JsEnvironment>& jsEnv)
|
||||
{
|
||||
if (jsEnv == nullptr) {
|
||||
HILOG_ERROR("jsEnv is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv is nullptr.");
|
||||
return false;
|
||||
}
|
||||
return jsEnv->InitLoop();
|
||||
@@ -319,7 +321,7 @@ bool NativeRuntimeImpl::InitLoop(const std::shared_ptr<JsEnv::JsEnvironment>& js
|
||||
void NativeRuntimeImpl::InitWorkerModule(const Options& options, const std::shared_ptr<JsEnv::JsEnvironment>& jsEnv)
|
||||
{
|
||||
if (jsEnv == nullptr) {
|
||||
HILOG_ERROR("jsEnv is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv is nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "commonlibrary/ets_utils/js_sys_module/console/console.h"
|
||||
#include "commonlibrary/ets_utils/js_sys_module/timer/timer.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "js_utils.h"
|
||||
#include "js_worker.h"
|
||||
@@ -26,26 +27,26 @@ namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
OHOSJsEnvironmentImpl::OHOSJsEnvironmentImpl()
|
||||
{
|
||||
HILOG_DEBUG("called");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
}
|
||||
|
||||
OHOSJsEnvironmentImpl::OHOSJsEnvironmentImpl(const std::shared_ptr<AppExecFwk::EventRunner>& eventRunner)
|
||||
{
|
||||
HILOG_DEBUG("called");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
if (eventRunner != nullptr) {
|
||||
HILOG_DEBUG("Create event handler.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Create event handler.");
|
||||
eventHandler_ = std::make_shared<AppExecFwk::EventHandler>(eventRunner);
|
||||
}
|
||||
}
|
||||
|
||||
OHOSJsEnvironmentImpl::~OHOSJsEnvironmentImpl()
|
||||
{
|
||||
HILOG_DEBUG("called");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
}
|
||||
|
||||
void OHOSJsEnvironmentImpl::PostTask(const std::function<void()>& task, const std::string& name, int64_t delayTime)
|
||||
{
|
||||
HILOG_DEBUG("called");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
if (eventHandler_ != nullptr) {
|
||||
eventHandler_->PostTask(task, name, delayTime);
|
||||
}
|
||||
@@ -53,7 +54,7 @@ void OHOSJsEnvironmentImpl::PostTask(const std::function<void()>& task, const st
|
||||
|
||||
void OHOSJsEnvironmentImpl::PostSyncTask(const std::function<void()>& task, const std::string& name)
|
||||
{
|
||||
HILOG_DEBUG("Post sync task");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Post sync task");
|
||||
if (eventHandler_ != nullptr) {
|
||||
eventHandler_->PostSyncTask(task, name);
|
||||
}
|
||||
@@ -61,7 +62,7 @@ void OHOSJsEnvironmentImpl::PostSyncTask(const std::function<void()>& task, cons
|
||||
|
||||
void OHOSJsEnvironmentImpl::RemoveTask(const std::string& name)
|
||||
{
|
||||
HILOG_DEBUG("called");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
if (eventHandler_ != nullptr) {
|
||||
eventHandler_->RemoveTask(name);
|
||||
}
|
||||
@@ -69,28 +70,28 @@ void OHOSJsEnvironmentImpl::RemoveTask(const std::string& name)
|
||||
|
||||
void OHOSJsEnvironmentImpl::InitTimerModule(NativeEngine* engine)
|
||||
{
|
||||
HILOG_DEBUG("Init timer.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Init timer.");
|
||||
CHECK_POINTER(engine);
|
||||
auto ret = JsSysModule::Timer::RegisterTime(reinterpret_cast<napi_env>(engine));
|
||||
if (!ret) {
|
||||
HILOG_ERROR("Register timer failed");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Register timer failed");
|
||||
}
|
||||
}
|
||||
|
||||
void OHOSJsEnvironmentImpl::InitConsoleModule(NativeEngine* engine)
|
||||
{
|
||||
HILOG_DEBUG("called");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
JsSysModule::Console::InitConsoleModule(reinterpret_cast<napi_env>(engine));
|
||||
}
|
||||
|
||||
bool OHOSJsEnvironmentImpl::InitLoop(NativeEngine* engine)
|
||||
{
|
||||
HILOG_DEBUG("called");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
CHECK_POINTER_AND_RETURN(engine, false);
|
||||
auto uvLoop = engine->GetUVLoop();
|
||||
auto fd = uvLoop != nullptr ? uv_backend_fd(uvLoop) : -1;
|
||||
if (fd < 0) {
|
||||
HILOG_ERROR("Failed to get backend fd from uv loop");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Failed to get backend fd from uv loop");
|
||||
return false;
|
||||
}
|
||||
uv_run(uvLoop, UV_RUN_NOWAIT);
|
||||
@@ -116,7 +117,7 @@ void OHOSJsEnvironmentImpl::DeInitLoop(NativeEngine* engine)
|
||||
|
||||
void OHOSJsEnvironmentImpl::InitWorkerModule(NativeEngine* engine, std::shared_ptr<JsEnv::WorkerInfo> workerInfo)
|
||||
{
|
||||
HILOG_DEBUG("called");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
CHECK_POINTER(engine);
|
||||
engine->SetInitWorkerFunc(InitWorkerFunc);
|
||||
engine->SetOffWorkerFunc(OffWorkerFunc);
|
||||
@@ -129,7 +130,7 @@ void OHOSJsEnvironmentImpl::InitWorkerModule(NativeEngine* engine, std::shared_p
|
||||
|
||||
void OHOSJsEnvironmentImpl::InitSyscapModule()
|
||||
{
|
||||
HILOG_DEBUG("called");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -12,6 +12,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "ohos_loop_handler.h"
|
||||
|
||||
namespace OHOS {
|
||||
@@ -19,19 +20,19 @@ namespace AbilityRuntime {
|
||||
|
||||
void OHOSLoopHandler::OnReadable(int32_t)
|
||||
{
|
||||
HILOG_DEBUG("OHOSLoopHandler::OnReadable is triggered");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "OHOSLoopHandler::OnReadable is triggered");
|
||||
OnTriggered();
|
||||
}
|
||||
|
||||
void OHOSLoopHandler::OnWritable(int32_t)
|
||||
{
|
||||
HILOG_DEBUG("OHOSLoopHandler::OnWritable is triggered");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "OHOSLoopHandler::OnWritable is triggered");
|
||||
OnTriggered();
|
||||
}
|
||||
|
||||
void OHOSLoopHandler::OnTriggered()
|
||||
{
|
||||
HILOG_DEBUG("OHOSLoopHandler::OnTriggered is triggered");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "OHOSLoopHandler::OnTriggered is triggered");
|
||||
|
||||
uv_run(uvLoop_, UV_RUN_NOWAIT);
|
||||
|
||||
|
||||
+7
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "ability_foreground_state_observer_proxy.h"
|
||||
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "ipc_types.h"
|
||||
|
||||
@@ -27,7 +28,7 @@ AbilityForegroundStateObserverProxy::AbilityForegroundStateObserverProxy(const s
|
||||
bool AbilityForegroundStateObserverProxy::WriteInterfaceToken(MessageParcel &data)
|
||||
{
|
||||
if (!data.WriteInterfaceToken(AbilityForegroundStateObserverProxy::GetDescriptor())) {
|
||||
HILOG_ERROR("Write interface token failed.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Write interface token failed.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -37,16 +38,16 @@ void AbilityForegroundStateObserverProxy::OnAbilityStateChanged(const AbilitySta
|
||||
{
|
||||
MessageParcel data;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("Write Token failed.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Write Token failed.");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteParcelable(&abilityStateData)) {
|
||||
HILOG_ERROR("Fail to write abilityStateData.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Fail to write abilityStateData.");
|
||||
return;
|
||||
}
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
HILOG_ERROR("Remote is NULL.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Remote is NULL.");
|
||||
return;
|
||||
}
|
||||
MessageParcel reply;
|
||||
@@ -54,7 +55,7 @@ void AbilityForegroundStateObserverProxy::OnAbilityStateChanged(const AbilitySta
|
||||
int32_t ret = remote->SendRequest(
|
||||
static_cast<uint32_t>(IAbilityForegroundStateObserver::Message::ON_ABILITY_STATE_CHANGED), data, reply, option);
|
||||
if (ret != NO_ERROR) {
|
||||
HILOG_ERROR("SendRequest is failed, error code: %{public}d.", ret);
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "SendRequest is failed, error code: %{public}d.", ret);
|
||||
}
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "ability_foreground_state_observer_stub.h"
|
||||
|
||||
#include "appexecfwk_errors.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "ipc_types.h"
|
||||
#include "iremote_object.h"
|
||||
@@ -36,11 +37,11 @@ AbilityForegroundStateObserverStub::~AbilityForegroundStateObserverStub()
|
||||
int32_t AbilityForegroundStateObserverStub::OnRemoteRequest(
|
||||
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
HILOG_DEBUG("Called.");
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "Called.");
|
||||
std::u16string descriptor = AbilityForegroundStateObserverStub::GetDescriptor();
|
||||
std::u16string remoteDescriptor = data.ReadInterfaceToken();
|
||||
if (descriptor != remoteDescriptor) {
|
||||
HILOG_ERROR("Local descriptor is not equal to remote.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Local descriptor is not equal to remote.");
|
||||
return ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
@@ -58,7 +59,7 @@ int32_t AbilityForegroundStateObserverStub::HandleOnAbilityStateChanged(MessageP
|
||||
{
|
||||
std::unique_ptr<AbilityStateData> abilityStateData(data.ReadParcelable<AbilityStateData>());
|
||||
if (abilityStateData == nullptr) {
|
||||
HILOG_ERROR("abilityStateData is null.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "abilityStateData is null.");
|
||||
return ERR_APPEXECFWK_PARCEL_ERROR;
|
||||
}
|
||||
|
||||
@@ -72,7 +73,7 @@ AbilityForegroundStateObserverRecipient::AbilityForegroundStateObserverRecipient
|
||||
|
||||
void AbilityForegroundStateObserverRecipient::OnRemoteDied(const wptr<IRemoteObject> &__attribute__((unused)) remote)
|
||||
{
|
||||
HILOG_ERROR("Remote died.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Remote died.");
|
||||
if (handler_) {
|
||||
handler_(remote);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "window_manager_service_handler_proxy.h"
|
||||
|
||||
#include "ability_manager_errors.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "parcel.h"
|
||||
|
||||
@@ -28,39 +29,39 @@ WindowManagerServiceHandlerProxy::WindowManagerServiceHandlerProxy(const sptr<IR
|
||||
void WindowManagerServiceHandlerProxy::NotifyWindowTransition(sptr<AbilityTransitionInfo> fromInfo,
|
||||
sptr<AbilityTransitionInfo> toInfo, bool& animaEnabled)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s is called.", __func__);
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "%{public}s is called.", __func__);
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(IWindowManagerServiceHandler::GetDescriptor())) {
|
||||
HILOG_ERROR("Write interface token failed.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Write interface token failed.");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteParcelable(fromInfo.GetRefPtr())) {
|
||||
HILOG_ERROR("Write fromInfo failed.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Write fromInfo failed.");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteParcelable(toInfo.GetRefPtr())) {
|
||||
HILOG_ERROR("Write toInfo failed.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Write toInfo failed.");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteBool(animaEnabled)) {
|
||||
HILOG_ERROR("Write animaEnabled failed.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Write animaEnabled failed.");
|
||||
return;
|
||||
}
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
int error = SendTransactCmd(WMSCmd::ON_NOTIFY_WINDOW_TRANSITION, data, reply, option);
|
||||
if (error != ERR_OK) {
|
||||
HILOG_ERROR("SendRequest fail, error: %{public}d", error);
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "SendRequest fail, error: %{public}d", error);
|
||||
}
|
||||
animaEnabled = reply.ReadBool();
|
||||
}
|
||||
|
||||
int32_t WindowManagerServiceHandlerProxy::GetFocusWindow(sptr<IRemoteObject>& abilityToken)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s is called.", __func__);
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "%{public}s is called.", __func__);
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(IWindowManagerServiceHandler::GetDescriptor())) {
|
||||
HILOG_ERROR("Write interface token failed.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Write interface token failed.");
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
|
||||
@@ -68,91 +69,91 @@ int32_t WindowManagerServiceHandlerProxy::GetFocusWindow(sptr<IRemoteObject>& ab
|
||||
MessageOption option;
|
||||
int error = SendTransactCmd(WMSCmd::ON_GET_FOCUS_ABILITY, data, reply, option);
|
||||
if (error != ERR_OK) {
|
||||
HILOG_ERROR("SendRequest fail, error: %{public}d", error);
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "SendRequest fail, error: %{public}d", error);
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
auto ret = reply.ReadInt32();
|
||||
if (ret == 0 && reply.ReadBool()) {
|
||||
abilityToken = reply.ReadRemoteObject();
|
||||
}
|
||||
HILOG_DEBUG("ending");
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "ending");
|
||||
return ret;
|
||||
}
|
||||
|
||||
void WindowManagerServiceHandlerProxy::StartingWindow(sptr<AbilityTransitionInfo> info,
|
||||
std::shared_ptr<Media::PixelMap> pixelMap, uint32_t bgColor)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s is called.", __func__);
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "%{public}s is called.", __func__);
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(IWindowManagerServiceHandler::GetDescriptor())) {
|
||||
HILOG_ERROR("Failed to write interface token.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Failed to write interface token.");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteParcelable(info.GetRefPtr())) {
|
||||
HILOG_ERROR("Write info failed.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Write info failed.");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteParcelable(pixelMap.get())) {
|
||||
HILOG_ERROR("Write pixelMap failed.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Write pixelMap failed.");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteUint32(bgColor)) {
|
||||
HILOG_ERROR("Failed to write bgColor.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Failed to write bgColor.");
|
||||
return;
|
||||
}
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
int error = SendTransactCmd(WMSCmd::ON_COLD_STARTING_WINDOW, data, reply, option);
|
||||
if (error != ERR_OK) {
|
||||
HILOG_ERROR("SendRequest fail, error: %{public}d", error);
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "SendRequest fail, error: %{public}d", error);
|
||||
}
|
||||
}
|
||||
|
||||
void WindowManagerServiceHandlerProxy::StartingWindow(sptr<AbilityTransitionInfo> info,
|
||||
std::shared_ptr<Media::PixelMap> pixelMap)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s is called.", __func__);
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "%{public}s is called.", __func__);
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(IWindowManagerServiceHandler::GetDescriptor())) {
|
||||
HILOG_ERROR("Write interface token failed.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Write interface token failed.");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteParcelable(info.GetRefPtr())) {
|
||||
HILOG_ERROR("Write info failed.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Write info failed.");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteParcelable(pixelMap.get())) {
|
||||
HILOG_ERROR("Failed to write pixelMap.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Failed to write pixelMap.");
|
||||
return;
|
||||
}
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
int error = SendTransactCmd(WMSCmd::ON_HOT_STARTING_WINDOW, data, reply, option);
|
||||
if (error != ERR_OK) {
|
||||
HILOG_ERROR("SendRequest fail, error: %{public}d", error);
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "SendRequest fail, error: %{public}d", error);
|
||||
}
|
||||
}
|
||||
|
||||
void WindowManagerServiceHandlerProxy::CancelStartingWindow(sptr<IRemoteObject> abilityToken)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s is called.", __func__);
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "%{public}s is called.", __func__);
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(IWindowManagerServiceHandler::GetDescriptor())) {
|
||||
HILOG_ERROR("Write interface token failed.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Write interface token failed.");
|
||||
return;
|
||||
}
|
||||
if (!abilityToken) {
|
||||
if (!data.WriteBool(false)) {
|
||||
HILOG_ERROR("Failed to write false.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Failed to write false.");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (!data.WriteBool(true)) {
|
||||
HILOG_ERROR("Write true failed.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Write true failed.");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteRemoteObject(abilityToken)) {
|
||||
HILOG_ERROR("Write abilityToken failed.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Write abilityToken failed.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -160,56 +161,56 @@ void WindowManagerServiceHandlerProxy::CancelStartingWindow(sptr<IRemoteObject>
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
int error = SendTransactCmd(WMSCmd::ON_CANCEL_STARTING_WINDOW, data, reply, option);
|
||||
if (error != ERR_OK) {
|
||||
HILOG_ERROR("SendRequest fail, error: %{public}d", error);
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "SendRequest fail, error: %{public}d", error);
|
||||
}
|
||||
}
|
||||
|
||||
void WindowManagerServiceHandlerProxy::NotifyAnimationAbilityDied(sptr<AbilityTransitionInfo> info)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s is called.", __func__);
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "%{public}s is called.", __func__);
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(IWindowManagerServiceHandler::GetDescriptor())) {
|
||||
HILOG_ERROR("Write interface token failed.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Write interface token failed.");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteParcelable(info.GetRefPtr())) {
|
||||
HILOG_ERROR("Failed to write info.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Failed to write info.");
|
||||
return;
|
||||
}
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
int error = SendTransactCmd(WMSCmd::ON_NOTIFY_ANIMATION_ABILITY_DIED, data, reply, option);
|
||||
if (error != ERR_OK) {
|
||||
HILOG_ERROR("SendRequest fail, error: %{public}d", error);
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "SendRequest fail, error: %{public}d", error);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t WindowManagerServiceHandlerProxy::MoveMissionsToForeground(const std::vector<int32_t>& missionIds,
|
||||
int32_t topMissionId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s is called.", __func__);
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "%{public}s is called.", __func__);
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!data.WriteInterfaceToken(IWindowManagerServiceHandler::GetDescriptor())) {
|
||||
HILOG_ERROR("WriteInterfaceToken failed");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "WriteInterfaceToken failed");
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32Vector(missionIds)) {
|
||||
HILOG_ERROR("Write missionIds failed");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Write missionIds failed");
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(topMissionId)) {
|
||||
HILOG_ERROR("Failed to write TopMissionId");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Failed to write TopMissionId");
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
|
||||
int error = SendTransactCmd(WMSCmd::ON_MOVE_MISSINONS_TO_FOREGROUND, data, reply, option);
|
||||
if (error != ERR_NONE) {
|
||||
HILOG_ERROR("SendoRequest failed, error: %{public}d", error);
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "SendoRequest failed, error: %{public}d", error);
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
return reply.ReadInt32();
|
||||
@@ -218,28 +219,28 @@ int32_t WindowManagerServiceHandlerProxy::MoveMissionsToForeground(const std::ve
|
||||
int32_t WindowManagerServiceHandlerProxy::MoveMissionsToBackground(const std::vector<int32_t>& missionIds,
|
||||
std::vector<int32_t>& result)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s is called.", __func__);
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "%{public}s is called.", __func__);
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!data.WriteInterfaceToken(IWindowManagerServiceHandler::GetDescriptor())) {
|
||||
HILOG_ERROR("WriteInterfaceToken failed");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "WriteInterfaceToken failed");
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32Vector(missionIds)) {
|
||||
HILOG_ERROR("Write missionIds failed");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Write missionIds failed");
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
|
||||
int error = SendTransactCmd(WMSCmd::ON_MOVE_MISSIONS_TO_BACKGROUND, data, reply, option);
|
||||
if (error != ERR_NONE) {
|
||||
HILOG_ERROR("SendoRequest failed, error: %{public}d", error);
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "SendoRequest failed, error: %{public}d", error);
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
if (!reply.ReadInt32Vector(&result)) {
|
||||
HILOG_ERROR("Read hide result failed");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Read hide result failed");
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
};
|
||||
return reply.ReadInt32();
|
||||
@@ -250,13 +251,13 @@ int32_t WindowManagerServiceHandlerProxy::SendTransactCmd(uint32_t code, Message
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
HILOG_ERROR("remote object is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "remote object is nullptr.");
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
|
||||
int32_t ret = remote->SendRequest(code, data, reply, option);
|
||||
if (ret != ERR_OK) {
|
||||
HILOG_ERROR("SendRequest failed. code is %{public}d, ret is %{public}d.", code, ret);
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "SendRequest failed. code is %{public}d, ret is %{public}d.", code, ret);
|
||||
return ret;
|
||||
}
|
||||
return ERR_OK;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "window_manager_service_handler_stub.h"
|
||||
|
||||
#include "ability_manager_errors.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
@@ -48,7 +49,7 @@ int WindowManagerServiceHandlerStub::OnRemoteRequest(
|
||||
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
if (data.ReadInterfaceToken() != IWindowManagerServiceHandler::GetDescriptor()) {
|
||||
HILOG_ERROR("InterfaceToken not equal IWindowManagerServiceHandler's descriptor.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "InterfaceToken not equal IWindowManagerServiceHandler's descriptor.");
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
|
||||
@@ -59,21 +60,21 @@ int WindowManagerServiceHandlerStub::OnRemoteRequest(
|
||||
return (this->*requestFunc)(data, reply);
|
||||
}
|
||||
}
|
||||
HILOG_WARN("default case, it needs to be checked.");
|
||||
TAG_LOGW(AAFwkTag::ABILITYMGR, "default case, it needs to be checked.");
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
|
||||
int WindowManagerServiceHandlerStub::NotifyWindowTransitionInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s is called.", __func__);
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "%{public}s is called.", __func__);
|
||||
sptr<AbilityTransitionInfo> fromInfo(data.ReadParcelable<AbilityTransitionInfo>());
|
||||
if (!fromInfo) {
|
||||
HILOG_ERROR("To read fromInfo failed.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "To read fromInfo failed.");
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
sptr<AbilityTransitionInfo> toInfo(data.ReadParcelable<AbilityTransitionInfo>());
|
||||
if (!toInfo) {
|
||||
HILOG_ERROR("To read toInfo failed.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "To read toInfo failed.");
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
bool animaEnabled = data.ReadBool();
|
||||
@@ -84,25 +85,25 @@ int WindowManagerServiceHandlerStub::NotifyWindowTransitionInner(MessageParcel &
|
||||
|
||||
int WindowManagerServiceHandlerStub::GetFocusWindowInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s is called.", __func__);
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "%{public}s is called.", __func__);
|
||||
sptr<IRemoteObject> abilityToken = nullptr;
|
||||
int32_t ret = GetFocusWindow(abilityToken);
|
||||
if (!reply.WriteInt32(ret)) {
|
||||
HILOG_ERROR("To write result failed.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "To write result failed.");
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
if (abilityToken) {
|
||||
if (!reply.WriteBool(true)) {
|
||||
HILOG_ERROR("To write true failed.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "To write true failed.");
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
if (!reply.WriteRemoteObject(abilityToken)) {
|
||||
HILOG_ERROR("To write abilityToken failed.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "To write abilityToken failed.");
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
} else {
|
||||
if (!reply.WriteBool(false)) {
|
||||
HILOG_ERROR("To write false failed.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "To write false failed.");
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
}
|
||||
@@ -111,16 +112,16 @@ int WindowManagerServiceHandlerStub::GetFocusWindowInner(MessageParcel &data, Me
|
||||
|
||||
int WindowManagerServiceHandlerStub::StartingWindowCold(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s is called.", __func__);
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "%{public}s is called.", __func__);
|
||||
sptr<AbilityTransitionInfo> info(data.ReadParcelable<AbilityTransitionInfo>());
|
||||
if (!info) {
|
||||
HILOG_ERROR("To read info failed!");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "To read info failed!");
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
std::shared_ptr<Media::PixelMap> pixelMap
|
||||
= std::shared_ptr<Media::PixelMap>(data.ReadParcelable<Media::PixelMap>());
|
||||
if (pixelMap == nullptr) {
|
||||
HILOG_ERROR("To read pixelMap failed!");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "To read pixelMap failed!");
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
auto bgColor = data.ReadUint32();
|
||||
@@ -130,16 +131,16 @@ int WindowManagerServiceHandlerStub::StartingWindowCold(MessageParcel &data, Mes
|
||||
|
||||
int WindowManagerServiceHandlerStub::StartingWindowHot(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s is called.", __func__);
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "%{public}s is called.", __func__);
|
||||
sptr<AbilityTransitionInfo> info(data.ReadParcelable<AbilityTransitionInfo>());
|
||||
if (!info) {
|
||||
HILOG_ERROR("To read info failed.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "To read info failed.");
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
std::shared_ptr<Media::PixelMap> pixelMap
|
||||
= std::shared_ptr<Media::PixelMap>(data.ReadParcelable<Media::PixelMap>());
|
||||
if (pixelMap == nullptr) {
|
||||
HILOG_ERROR("Failed to read pixelMap.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Failed to read pixelMap.");
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
StartingWindow(info, pixelMap);
|
||||
@@ -148,10 +149,10 @@ int WindowManagerServiceHandlerStub::StartingWindowHot(MessageParcel &data, Mess
|
||||
|
||||
int WindowManagerServiceHandlerStub::CancelStartingWindowInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s is called.", __func__);
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "%{public}s is called.", __func__);
|
||||
sptr<IRemoteObject> abilityToken = nullptr;
|
||||
if (data.ReadBool()) {
|
||||
HILOG_DEBUG("abilityToken is valid.");
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "abilityToken is valid.");
|
||||
abilityToken = data.ReadRemoteObject();
|
||||
}
|
||||
CancelStartingWindow(abilityToken);
|
||||
@@ -160,10 +161,10 @@ int WindowManagerServiceHandlerStub::CancelStartingWindowInner(MessageParcel &da
|
||||
|
||||
int WindowManagerServiceHandlerStub::NotifyAnimationAbilityDiedInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s is called.", __func__);
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "%{public}s is called.", __func__);
|
||||
sptr<AbilityTransitionInfo> info(data.ReadParcelable<AbilityTransitionInfo>());
|
||||
if (!info) {
|
||||
HILOG_ERROR("To read info failed.");
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "To read info failed.");
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
NotifyAnimationAbilityDied(info);
|
||||
@@ -172,7 +173,7 @@ int WindowManagerServiceHandlerStub::NotifyAnimationAbilityDiedInner(MessageParc
|
||||
|
||||
int WindowManagerServiceHandlerStub::MoveMissionsToForegroundInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s is called.", __func__);
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "%{public}s is called.", __func__);
|
||||
std::vector<int32_t> missionIds;
|
||||
data.ReadInt32Vector(&missionIds);
|
||||
int32_t topMissionId = data.ReadInt32();
|
||||
@@ -183,7 +184,7 @@ int WindowManagerServiceHandlerStub::MoveMissionsToForegroundInner(MessageParcel
|
||||
|
||||
int WindowManagerServiceHandlerStub::MoveMissionsToBackgroundInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s is called.", __func__);
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "%{public}s is called.", __func__);
|
||||
std::vector<int32_t> missionIds;
|
||||
std::vector<int32_t> result;
|
||||
data.ReadInt32Vector(&missionIds);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "auto_fill_event_handler.h"
|
||||
|
||||
#include "auto_fill_manager.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
@@ -26,9 +27,9 @@ AutoFillEventHandler::AutoFillEventHandler(const std::shared_ptr<AppExecFwk::Eve
|
||||
|
||||
void AutoFillEventHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event)
|
||||
{
|
||||
HILOG_DEBUG("Called.");
|
||||
TAG_LOGD(AAFwkTag::AUTOFILLMGR, "Called.");
|
||||
if (event == nullptr) {
|
||||
HILOG_ERROR("Event is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::AUTOFILLMGR, "Event is nullptr.");
|
||||
return;
|
||||
}
|
||||
AutoFillManager::GetInstance().HandleTimeOut(event->GetInnerEventId());
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include "auto_fill_error.h"
|
||||
#include "auto_fill_manager.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "view_data.h"
|
||||
|
||||
@@ -27,7 +28,7 @@ constexpr static char WANT_PARAMS_AUTO_FILL_EVENT_KEY[] = "ability.want.params.A
|
||||
} // namespace
|
||||
void AutoFillExtensionCallback::OnResult(int32_t errCode, const AAFwk::Want &want)
|
||||
{
|
||||
HILOG_DEBUG("Called, result code is %{public}d.", errCode);
|
||||
TAG_LOGD(AAFwkTag::AUTOFILLMGR, "Called, result code is %{public}d.", errCode);
|
||||
AutoFillManager::GetInstance().RemoveEvent(eventId_);
|
||||
CloseModalUIExtension();
|
||||
|
||||
@@ -42,7 +43,7 @@ void AutoFillExtensionCallback::OnResult(int32_t errCode, const AAFwk::Want &wan
|
||||
|
||||
void AutoFillExtensionCallback::OnRelease(int32_t errCode)
|
||||
{
|
||||
HILOG_DEBUG("Called, result code is %{public}d.", errCode);
|
||||
TAG_LOGD(AAFwkTag::AUTOFILLMGR, "Called, result code is %{public}d.", errCode);
|
||||
AutoFillManager::GetInstance().RemoveEvent(eventId_);
|
||||
CloseModalUIExtension();
|
||||
|
||||
@@ -53,7 +54,7 @@ void AutoFillExtensionCallback::OnRelease(int32_t errCode)
|
||||
|
||||
void AutoFillExtensionCallback::OnError(int32_t errCode, const std::string &name, const std::string &message)
|
||||
{
|
||||
HILOG_DEBUG("Called, errcode is %{public}d, name is %{public}s, message is %{public}s",
|
||||
TAG_LOGD(AAFwkTag::AUTOFILLMGR, "Called, errcode is %{public}d, name is %{public}s, message is %{public}s",
|
||||
errCode, name.c_str(), message.c_str());
|
||||
AutoFillManager::GetInstance().RemoveEvent(eventId_);
|
||||
CloseModalUIExtension();
|
||||
@@ -65,9 +66,9 @@ void AutoFillExtensionCallback::OnError(int32_t errCode, const std::string &name
|
||||
|
||||
void AutoFillExtensionCallback::OnReceive(const AAFwk::WantParams &wantParams)
|
||||
{
|
||||
HILOG_DEBUG("Called.");
|
||||
TAG_LOGD(AAFwkTag::AUTOFILLMGR, "Called.");
|
||||
if (wantParams.GetIntParam(WANT_PARAMS_AUTO_FILL_EVENT_KEY, 0) != AutoFill::AUTO_FILL_CANCEL_TIME_OUT) {
|
||||
HILOG_ERROR("Event is invalid.");
|
||||
TAG_LOGE(AAFwkTag::AUTOFILLMGR, "Event is invalid.");
|
||||
return;
|
||||
}
|
||||
AutoFillManager::GetInstance().RemoveEvent(eventId_);
|
||||
@@ -75,9 +76,9 @@ void AutoFillExtensionCallback::OnReceive(const AAFwk::WantParams &wantParams)
|
||||
|
||||
void AutoFillExtensionCallback::onRemoteReady(const std::shared_ptr<Ace::ModalUIExtensionProxy> &modalUIExtensionProxy)
|
||||
{
|
||||
HILOG_DEBUG("Called.");
|
||||
TAG_LOGD(AAFwkTag::AUTOFILLMGR, "Called.");
|
||||
if (modalUIExtensionProxy == nullptr || uiContent_ == nullptr) {
|
||||
HILOG_ERROR("Proxy or uiContent_ is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::AUTOFILLMGR, "Proxy or uiContent_ is nullptr.");
|
||||
return;
|
||||
}
|
||||
AutoFillManager::GetInstance().SetAutoFillExtensionProxy(uiContent_, modalUIExtensionProxy);
|
||||
@@ -85,7 +86,7 @@ void AutoFillExtensionCallback::onRemoteReady(const std::shared_ptr<Ace::ModalUI
|
||||
|
||||
void AutoFillExtensionCallback::onDestroy()
|
||||
{
|
||||
HILOG_DEBUG("Called.");
|
||||
TAG_LOGD(AAFwkTag::AUTOFILLMGR, "Called.");
|
||||
AutoFillManager::GetInstance().RemoveEvent(eventId_);
|
||||
if (uiContent_ != nullptr && autoFillWindowType_ == AutoFill::AutoFillWindowType::POPUP_WINDOW) {
|
||||
AutoFillManager::GetInstance().RemoveAutoFillExtensionProxy(uiContent_);
|
||||
@@ -162,7 +163,7 @@ void AutoFillExtensionCallback::SendAutoFillFailed(int32_t errCode)
|
||||
void AutoFillExtensionCallback::CloseModalUIExtension()
|
||||
{
|
||||
if (uiContent_ == nullptr) {
|
||||
HILOG_DEBUG("uiContent_ is nullptr.");
|
||||
TAG_LOGD(AAFwkTag::AUTOFILLMGR, "uiContent_ is nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "auto_fill_error.h"
|
||||
#include "auto_fill_manager_util.h"
|
||||
#include "extension_ability_info.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "int_wrapper.h"
|
||||
#include "parameters.h"
|
||||
@@ -45,7 +46,7 @@ AutoFillManager &AutoFillManager::GetInstance()
|
||||
|
||||
AutoFillManager::~AutoFillManager()
|
||||
{
|
||||
HILOG_DEBUG("Called.");
|
||||
TAG_LOGD(AAFwkTag::AUTOFILLMGR, "Called.");
|
||||
if (eventHandler_ != nullptr) {
|
||||
eventHandler_.reset();
|
||||
}
|
||||
@@ -56,14 +57,14 @@ int32_t AutoFillManager::RequestAutoFill(
|
||||
const AutoFill::AutoFillRequest &request,
|
||||
const std::shared_ptr<IFillRequestCallback> &fillCallback, bool &isPopup)
|
||||
{
|
||||
HILOG_DEBUG("Called.");
|
||||
TAG_LOGD(AAFwkTag::AUTOFILLMGR, "Called.");
|
||||
if (uiContent == nullptr || fillCallback == nullptr) {
|
||||
HILOG_ERROR("UIContent or fillCallback is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::AUTOFILLMGR, "UIContent or fillCallback is nullptr.");
|
||||
return AutoFill::AUTO_FILL_OBJECT_IS_NULL;
|
||||
}
|
||||
|
||||
if (request.autoFillType == AbilityBase::AutoFillType::UNSPECIFIED) {
|
||||
HILOG_ERROR("Auto fill type is invalid.");
|
||||
TAG_LOGE(AAFwkTag::AUTOFILLMGR, "Auto fill type is invalid.");
|
||||
return AutoFill::AUTO_FILL_TYPE_INVALID;
|
||||
}
|
||||
return HandleRequestExecuteInner(uiContent, request, fillCallback, nullptr, isPopup);
|
||||
@@ -74,9 +75,9 @@ int32_t AutoFillManager::RequestAutoSave(
|
||||
const AutoFill::AutoFillRequest &request,
|
||||
const std::shared_ptr<ISaveRequestCallback> &saveCallback)
|
||||
{
|
||||
HILOG_DEBUG("Called.");
|
||||
TAG_LOGD(AAFwkTag::AUTOFILLMGR, "Called.");
|
||||
if (uiContent == nullptr || saveCallback == nullptr) {
|
||||
HILOG_ERROR("UIContent or saveCallback is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::AUTOFILLMGR, "UIContent or save callback is nullptr.");
|
||||
return AutoFill::AUTO_FILL_OBJECT_IS_NULL;
|
||||
}
|
||||
bool isPopup = false;
|
||||
@@ -90,7 +91,7 @@ int32_t AutoFillManager::HandleRequestExecuteInner(
|
||||
const std::shared_ptr<ISaveRequestCallback> &saveCallback, bool &isPopup)
|
||||
{
|
||||
if (uiContent == nullptr || (fillCallback == nullptr && saveCallback == nullptr)) {
|
||||
HILOG_ERROR("UIContent or fillCallback&saveCallback is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::AUTOFILLMGR, "UIContent or fillCallback&saveCallback is nullptr.");
|
||||
return AutoFill::AUTO_FILL_OBJECT_IS_NULL;
|
||||
}
|
||||
{
|
||||
@@ -121,7 +122,7 @@ int32_t AutoFillManager::HandleRequestExecuteInner(
|
||||
isPopup = autoFillWindowType == AutoFill::AutoFillWindowType::POPUP_WINDOW ? true : false;
|
||||
auto sessionId = CreateAutoFillExtension(uiContent, request, callback, autoFillWindowType, isSmartAutoFill);
|
||||
if (sessionId == AUTO_FILL_UI_EXTENSION_SESSION_ID_INVALID) {
|
||||
HILOG_ERROR("Create ui extension is failed.");
|
||||
TAG_LOGE(AAFwkTag::AUTOFILLMGR, "Create ui extension is failed.");
|
||||
RemoveEvent(eventId_);
|
||||
return AutoFill::AUTO_FILL_CREATE_MODULE_UI_EXTENSION_FAILED;
|
||||
}
|
||||
@@ -136,9 +137,9 @@ int32_t AutoFillManager::HandleRequestExecuteInner(
|
||||
|
||||
void AutoFillManager::UpdateCustomPopupUIExtension(Ace::UIContent *uiContent, const AbilityBase::ViewData &viewData)
|
||||
{
|
||||
HILOG_DEBUG("Called.");
|
||||
TAG_LOGD(AAFwkTag::AUTOFILLMGR, "Called.");
|
||||
if (uiContent == nullptr) {
|
||||
HILOG_ERROR("UIContent is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::AUTOFILLMGR, "UIContent is nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -147,7 +148,7 @@ void AutoFillManager::UpdateCustomPopupUIExtension(Ace::UIContent *uiContent, co
|
||||
std::lock_guard<std::mutex> lock(modalProxyMapMutex_);
|
||||
auto it = modalUIExtensionProxyMap_.find(uiContent);
|
||||
if (it == modalUIExtensionProxyMap_.end()) {
|
||||
HILOG_ERROR("Content is not in map.");
|
||||
TAG_LOGE(AAFwkTag::AUTOFILLMGR, "Content is not in map.");
|
||||
return;
|
||||
}
|
||||
modalUIExtensionProxy = it->second;
|
||||
@@ -165,9 +166,9 @@ void AutoFillManager::UpdateCustomPopupUIExtension(Ace::UIContent *uiContent, co
|
||||
void AutoFillManager::SetAutoFillExtensionProxy(Ace::UIContent *uiContent,
|
||||
const std::shared_ptr<Ace::ModalUIExtensionProxy> &modalUIExtensionProxy)
|
||||
{
|
||||
HILOG_DEBUG("Called.");
|
||||
TAG_LOGD(AAFwkTag::AUTOFILLMGR, "Called.");
|
||||
if (uiContent == nullptr || modalUIExtensionProxy == nullptr) {
|
||||
HILOG_ERROR("UIContent or proxy is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::AUTOFILLMGR, "UIContent or proxy is nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -181,9 +182,9 @@ void AutoFillManager::SetAutoFillExtensionProxy(Ace::UIContent *uiContent,
|
||||
|
||||
void AutoFillManager::RemoveAutoFillExtensionProxy(Ace::UIContent *uiContent)
|
||||
{
|
||||
HILOG_DEBUG("Called.");
|
||||
TAG_LOGD(AAFwkTag::AUTOFILLMGR, "Called.");
|
||||
if (uiContent == nullptr) {
|
||||
HILOG_ERROR("Content is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::AUTOFILLMGR, "Content is nullptr.");
|
||||
return;
|
||||
}
|
||||
std::lock_guard<std::mutex> lock(modalProxyMapMutex_);
|
||||
@@ -201,7 +202,7 @@ int32_t AutoFillManager::CreateAutoFillExtension(Ace::UIContent *uiContent,
|
||||
{
|
||||
int32_t sessionId = AUTO_FILL_UI_EXTENSION_SESSION_ID_INVALID;
|
||||
if (uiContent == nullptr) {
|
||||
HILOG_ERROR("Content is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::AUTOFILLMGR, "Content is nullptr.");
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
@@ -249,10 +250,10 @@ AutoFill::AutoFillWindowType AutoFillManager::ConvertAutoFillWindowType(const Au
|
||||
|
||||
void AutoFillManager::SetTimeOutEvent(uint32_t eventId)
|
||||
{
|
||||
HILOG_DEBUG("Called.");
|
||||
TAG_LOGD(AAFwkTag::AUTOFILLMGR, "Called.");
|
||||
auto runner = AppExecFwk::EventRunner::Create(AUTO_FILL_MANAGER_THREAD);
|
||||
if (eventHandler_ == nullptr) {
|
||||
HILOG_DEBUG("Eventhandler is nullptr.");
|
||||
TAG_LOGD(AAFwkTag::AUTOFILLMGR, "Eventhandler is nullptr.");
|
||||
eventHandler_ = std::make_shared<AutoFillEventHandler>(runner);
|
||||
}
|
||||
eventHandler_->SendEvent(eventId, AUTO_FILL_REQUEST_TIME_OUT_VALUE);
|
||||
@@ -260,9 +261,9 @@ void AutoFillManager::SetTimeOutEvent(uint32_t eventId)
|
||||
|
||||
void AutoFillManager::RemoveEvent(uint32_t eventId)
|
||||
{
|
||||
HILOG_DEBUG("Called.");
|
||||
TAG_LOGD(AAFwkTag::AUTOFILLMGR, "Called.");
|
||||
if (eventHandler_ == nullptr) {
|
||||
HILOG_ERROR("Eventhandler is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::AUTOFILLMGR, "Eventhandler is nullptr.");
|
||||
return;
|
||||
}
|
||||
eventHandler_->RemoveEvent(eventId);
|
||||
@@ -276,16 +277,16 @@ void AutoFillManager::RemoveEvent(uint32_t eventId)
|
||||
|
||||
void AutoFillManager::HandleTimeOut(uint32_t eventId)
|
||||
{
|
||||
HILOG_DEBUG("Called.");
|
||||
TAG_LOGD(AAFwkTag::AUTOFILLMGR, "Called.");
|
||||
std::lock_guard<std::mutex> lock(extensionCallbacksMutex_);
|
||||
auto ret = extensionCallbacks_.find(eventId);
|
||||
if (ret == extensionCallbacks_.end()) {
|
||||
HILOG_WARN("Event id is not find.");
|
||||
TAG_LOGW(AAFwkTag::AUTOFILLMGR, "Event id is not find.");
|
||||
return;
|
||||
}
|
||||
auto extensionCallback = ret->second.lock();
|
||||
if (extensionCallback == nullptr) {
|
||||
HILOG_ERROR("Extension callback is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::AUTOFILLMGR, "Extension callback is nullptr.");
|
||||
return;
|
||||
}
|
||||
extensionCallback->HandleTimeOut();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "connection_data.h"
|
||||
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "string_ex.h"
|
||||
|
||||
@@ -95,17 +96,17 @@ bool ConnectionData::ReadFromParcel(Parcel &parcel)
|
||||
extensionType = static_cast<ExtensionAbilityType>(type);
|
||||
|
||||
if (!parcel.ReadInt32(callerUid)) {
|
||||
HILOG_WARN("ConnectionData::ReadFromParcel read callerUid failed");
|
||||
TAG_LOGW(AAFwkTag::CONNECTION, "ConnectionData::ReadFromParcel read callerUid failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!parcel.ReadInt32(callerPid)) {
|
||||
HILOG_WARN("ConnectionData::ReadFromParcel read callerPid failed");
|
||||
TAG_LOGW(AAFwkTag::CONNECTION, "ConnectionData::ReadFromParcel read callerPid failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!parcel.ReadString16(strValue)) {
|
||||
HILOG_WARN("ConnectionData::ReadFromParcel read strValue failed");
|
||||
TAG_LOGW(AAFwkTag::CONNECTION, "ConnectionData::ReadFromParcel read strValue failed");
|
||||
return false;
|
||||
}
|
||||
callerName = Str16ToStr8(strValue);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "connection_observer_client_impl.h"
|
||||
#include "connection_observer_errors.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
@@ -35,7 +36,7 @@ ConnectionObserverClient& ConnectionObserverClient::GetInstance()
|
||||
int32_t ConnectionObserverClient::RegisterObserver(const std::shared_ptr<ConnectionObserver> &observer)
|
||||
{
|
||||
if (!clientImpl_) {
|
||||
HILOG_ERROR("ConnectionObserverClient::RegisterObserver impl is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "ConnectionObserverClient::RegisterObserver impl is nullptr.");
|
||||
return ERR_NO_CLIENT_IMPL;
|
||||
}
|
||||
|
||||
@@ -45,7 +46,7 @@ int32_t ConnectionObserverClient::RegisterObserver(const std::shared_ptr<Connect
|
||||
int32_t ConnectionObserverClient::UnregisterObserver(const std::shared_ptr<ConnectionObserver> &observer)
|
||||
{
|
||||
if (!clientImpl_) {
|
||||
HILOG_ERROR("ConnectionObserverClient::UnregisterObserver impl is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "ConnectionObserverClient::UnregisterObserver impl is nullptr.");
|
||||
return ERR_NO_CLIENT_IMPL;
|
||||
}
|
||||
|
||||
@@ -55,7 +56,7 @@ int32_t ConnectionObserverClient::UnregisterObserver(const std::shared_ptr<Conne
|
||||
int32_t ConnectionObserverClient::GetDlpConnectionInfos(std::vector<DlpConnectionInfo> &infos)
|
||||
{
|
||||
if (!clientImpl_) {
|
||||
HILOG_ERROR("ConnectionObserverClient::GetDlpConnectionInfos impl is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "ConnectionObserverClient::GetDlpConnectionInfos impl is nullptr.");
|
||||
return ERR_NO_CLIENT_IMPL;
|
||||
}
|
||||
|
||||
@@ -65,7 +66,7 @@ int32_t ConnectionObserverClient::GetDlpConnectionInfos(std::vector<DlpConnectio
|
||||
int32_t ConnectionObserverClient::GetConnectionData(std::vector<ConnectionData> &connectionData)
|
||||
{
|
||||
if (!clientImpl_) {
|
||||
HILOG_ERROR("ConnectionObserverClient::GetConnectionData impl is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "ConnectionObserverClient::GetConnectionData impl is nullptr.");
|
||||
return ERR_NO_CLIENT_IMPL;
|
||||
}
|
||||
|
||||
|
||||
+19
-18
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "connection_observer_errors.h"
|
||||
#include "connection_observer_stub_impl.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "system_ability_definition.h"
|
||||
@@ -26,7 +27,7 @@ namespace AbilityRuntime {
|
||||
int32_t ConnectionObserverClientImpl::RegisterObserver(const std::shared_ptr<ConnectionObserver> &observer)
|
||||
{
|
||||
if (!observer) {
|
||||
HILOG_ERROR("ConnectionObserverClientImpl::RegisterObserver invalid observer.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "ConnectionObserverClientImpl::RegisterObserver invalid observer.");
|
||||
return ERR_INVALID_OBSERVER;
|
||||
}
|
||||
|
||||
@@ -34,7 +35,7 @@ int32_t ConnectionObserverClientImpl::RegisterObserver(const std::shared_ptr<Con
|
||||
|
||||
std::lock_guard<std::mutex> guard(observerLock_);
|
||||
if (!RegisterObserverToServiceLocked(proxy)) {
|
||||
HILOG_ERROR("register to service failed.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "register to service failed.");
|
||||
return ERR_REGISTER_FAILED;
|
||||
}
|
||||
|
||||
@@ -44,7 +45,7 @@ int32_t ConnectionObserverClientImpl::RegisterObserver(const std::shared_ptr<Con
|
||||
int32_t ConnectionObserverClientImpl::UnregisterObserver(const std::shared_ptr<ConnectionObserver> &observer)
|
||||
{
|
||||
if (!observer) {
|
||||
HILOG_ERROR("unregister, observer is invalid.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "unregister, observer is invalid.");
|
||||
return ERR_INVALID_OBSERVER;
|
||||
}
|
||||
|
||||
@@ -63,7 +64,7 @@ int32_t ConnectionObserverClientImpl::GetDlpConnectionInfos(std::vector<DlpConne
|
||||
{
|
||||
auto proxy = GetServiceProxy();
|
||||
if (!proxy) {
|
||||
HILOG_ERROR("GetDlpConnectionInfos, observer is invalid.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "GetDlpConnectionInfos, observer is invalid.");
|
||||
return ERR_NO_PROXY;
|
||||
}
|
||||
|
||||
@@ -74,7 +75,7 @@ int32_t ConnectionObserverClientImpl::GetConnectionData(std::vector<ConnectionDa
|
||||
{
|
||||
auto proxy = GetServiceProxy();
|
||||
if (!proxy) {
|
||||
HILOG_ERROR("GetConnectionData, observer is invalid.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "GetConnectionData, observer is invalid.");
|
||||
return ERR_NO_PROXY;
|
||||
}
|
||||
|
||||
@@ -132,7 +133,7 @@ bool ConnectionObserverClientImpl::RegisterObserverToServiceLocked(const std::sh
|
||||
}
|
||||
|
||||
if (!proxy) {
|
||||
HILOG_ERROR("fail to get service.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "fail to get service.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -141,7 +142,7 @@ bool ConnectionObserverClientImpl::RegisterObserverToServiceLocked(const std::sh
|
||||
}
|
||||
|
||||
if (proxy->RegisterObserver(observer_) != ERR_OK) {
|
||||
HILOG_ERROR("register connection observer failed.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "register connection observer failed.");
|
||||
return false;
|
||||
}
|
||||
isRegistered_ = true;
|
||||
@@ -159,7 +160,7 @@ void ConnectionObserverClientImpl::UnregisterFromServiceLocked(const std::shared
|
||||
}
|
||||
|
||||
if (proxy->UnregisterObserver(observer_) != ERR_OK) {
|
||||
HILOG_ERROR("unregister connection observer failed.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "unregister connection observer failed.");
|
||||
return;
|
||||
}
|
||||
isRegistered_ = false;
|
||||
@@ -168,7 +169,7 @@ void ConnectionObserverClientImpl::UnregisterFromServiceLocked(const std::shared
|
||||
int32_t ConnectionObserverClientImpl::AddObserversLocked(const std::shared_ptr<ConnectionObserver> &observer)
|
||||
{
|
||||
if (userObservers_.find(observer) != userObservers_.end()) {
|
||||
HILOG_ERROR("observer was already registered.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "observer was already registered.");
|
||||
return ERR_OBSERVER_ALREADY_REGISTERED;
|
||||
}
|
||||
userObservers_.emplace(observer);
|
||||
@@ -178,7 +179,7 @@ int32_t ConnectionObserverClientImpl::AddObserversLocked(const std::shared_ptr<C
|
||||
int32_t ConnectionObserverClientImpl::RemoveObserversLocked(const std::shared_ptr<ConnectionObserver> &observer)
|
||||
{
|
||||
if (userObservers_.find(observer) == userObservers_.end()) {
|
||||
HILOG_ERROR("unregister no such observer.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "unregister no such observer.");
|
||||
return ERR_OBSERVER_NOT_REGISTERED;
|
||||
}
|
||||
userObservers_.erase(observer);
|
||||
@@ -201,28 +202,28 @@ void ConnectionObserverClientImpl::ConnectLocked()
|
||||
}
|
||||
sptr<ISystemAbilityManager> systemManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (systemManager == nullptr) {
|
||||
HILOG_ERROR("Fail to get system ability registry.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "Fail to get system ability registry.");
|
||||
return;
|
||||
}
|
||||
sptr<IRemoteObject> remoteObj = systemManager->GetSystemAbility(ABILITY_MGR_SERVICE_ID);
|
||||
if (remoteObj == nullptr) {
|
||||
HILOG_ERROR("Fail to connect ability manager service.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "Fail to connect ability manager service.");
|
||||
return;
|
||||
}
|
||||
|
||||
deathRecipient_ = sptr<IRemoteObject::DeathRecipient>(
|
||||
new (std::nothrow) ServiceDeathRecipient(shared_from_this()));
|
||||
if (deathRecipient_ == nullptr) {
|
||||
HILOG_ERROR("Failed to create AbilityMgrDeathRecipient!");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "Failed to create AbilityMgrDeathRecipient!");
|
||||
return;
|
||||
}
|
||||
if ((remoteObj->IsProxyObject()) && (!remoteObj->AddDeathRecipient(deathRecipient_))) {
|
||||
HILOG_ERROR("Add death recipient to AbilityManagerService failed.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "Add death recipient to AbilityManagerService failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
serviceAdapter_ = std::make_shared<ServiceProxyAdapter>(remoteObj);
|
||||
HILOG_INFO("Connect ability manager service success.");
|
||||
TAG_LOGI(AAFwkTag::CONNECTION, "Connect ability manager service success.");
|
||||
}
|
||||
|
||||
void ConnectionObserverClientImpl::HandleRemoteDied(const wptr<IRemoteObject> &remote)
|
||||
@@ -277,10 +278,10 @@ std::unordered_set<std::shared_ptr<ConnectionObserver>> ConnectionObserverClient
|
||||
|
||||
void ConnectionObserverClientImpl::ServiceDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote)
|
||||
{
|
||||
HILOG_INFO("ServiceDeathRecipient handle remote abilityms died.");
|
||||
TAG_LOGI(AAFwkTag::CONNECTION, "ServiceDeathRecipient handle remote abilityms died.");
|
||||
auto owner = owner_.lock();
|
||||
if (!owner) {
|
||||
HILOG_ERROR("ServiceDeathRecipient handle remote abilityms died.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "ServiceDeathRecipient handle remote abilityms died.");
|
||||
return;
|
||||
}
|
||||
owner->HandleRemoteDied(remote);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "connection_observer_proxy.h"
|
||||
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "ipc_types.h"
|
||||
#include "message_parcel.h"
|
||||
@@ -27,20 +28,20 @@ void ConnectionObserverProxy::OnExtensionConnected(const ConnectionData& connect
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
|
||||
HILOG_DEBUG("called");
|
||||
TAG_LOGD(AAFwkTag::CONNECTION, "called");
|
||||
if (!data.WriteInterfaceToken(IConnectionObserver::GetDescriptor())) {
|
||||
HILOG_ERROR("Write interface token failed.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "Write interface token failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&connectionData)) {
|
||||
HILOG_ERROR("Write ConnectionData error.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "Write ConnectionData error.");
|
||||
return;
|
||||
}
|
||||
|
||||
int error = SendTransactCmd(IConnectionObserver::ON_EXTENSION_CONNECTED, data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("OnExtensionConnected sned request fail, error: %{public}d", error);
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "OnExtensionConnected sned request fail, error: %{public}d", error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -51,20 +52,20 @@ void ConnectionObserverProxy::OnExtensionDisconnected(const ConnectionData& conn
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
|
||||
HILOG_DEBUG("called.");
|
||||
TAG_LOGD(AAFwkTag::CONNECTION, "called.");
|
||||
if (!data.WriteInterfaceToken(IConnectionObserver::GetDescriptor())) {
|
||||
HILOG_ERROR("Write interface token failed.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "Write interface token failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&connectionData)) {
|
||||
HILOG_ERROR("Write ConnectionData error.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "Write ConnectionData error.");
|
||||
return;
|
||||
}
|
||||
|
||||
int error = SendTransactCmd(IConnectionObserver::ON_EXTENSION_DISCONNECTED, data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("OnExtensionDisconnected send request fail, error: %{public}d", error);
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "OnExtensionDisconnected send request fail, error: %{public}d", error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -75,20 +76,20 @@ void ConnectionObserverProxy::OnDlpAbilityOpened(const DlpStateData& dlpData)
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
|
||||
HILOG_INFO("ConnectionObserverProxy OnDlpAbilityOpened.");
|
||||
TAG_LOGI(AAFwkTag::CONNECTION, "ConnectionObserverProxy OnDlpAbilityOpened.");
|
||||
if (!data.WriteInterfaceToken(IConnectionObserver::GetDescriptor())) {
|
||||
HILOG_ERROR("Write interface token failed.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "Write interface token failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&dlpData)) {
|
||||
HILOG_ERROR("Write DlpStateData error.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "Write DlpStateData error.");
|
||||
return;
|
||||
}
|
||||
|
||||
int error = SendTransactCmd(IConnectionObserver::ON_DLP_ABILITY_OPENED, data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("OnDlpAbilityOpened send request fail, error: %{public}d", error);
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "OnDlpAbilityOpened send request fail, error: %{public}d", error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -99,20 +100,20 @@ void ConnectionObserverProxy::OnDlpAbilityClosed(const DlpStateData& dlpData)
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
|
||||
HILOG_INFO("ConnectionObserverProxy OnDlpAbilityClosed.");
|
||||
TAG_LOGI(AAFwkTag::CONNECTION, "ConnectionObserverProxy OnDlpAbilityClosed.");
|
||||
if (!data.WriteInterfaceToken(IConnectionObserver::GetDescriptor())) {
|
||||
HILOG_ERROR("Write interface token failed.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "Write interface token failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&dlpData)) {
|
||||
HILOG_ERROR("Write DlpStateData error.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "Write DlpStateData error.");
|
||||
return;
|
||||
}
|
||||
|
||||
int error = SendTransactCmd(IConnectionObserver::ON_DLP_ABILITY_CLOSED, data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("OnDlpAbilityClosed send request fail, error: %{public}d", error);
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "OnDlpAbilityClosed send request fail, error: %{public}d", error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -122,13 +123,13 @@ int32_t ConnectionObserverProxy::SendTransactCmd(uint32_t code, MessageParcel &d
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
HILOG_ERROR("remote object is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "remote object is nullptr.");
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
|
||||
int32_t ret = remote->SendRequest(code, data, reply, option);
|
||||
if (ret != NO_ERROR) {
|
||||
HILOG_ERROR("SendRequest failed. code is %{public}d, ret is %{public}d.", code, ret);
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "SendRequest failed. code is %{public}d, ret is %{public}d.", code, ret);
|
||||
return ret;
|
||||
}
|
||||
return NO_ERROR;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "connection_observer_stub.h"
|
||||
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "ipc_types.h"
|
||||
#include "message_parcel.h"
|
||||
@@ -36,7 +37,7 @@ int ConnectionObserverStub::OnRemoteRequest(
|
||||
std::u16string descriptor = ConnectionObserverStub::GetDescriptor();
|
||||
std::u16string remoteDescriptor = data.ReadInterfaceToken();
|
||||
if (descriptor != remoteDescriptor) {
|
||||
HILOG_INFO("ConnectionObserverStub Local descriptor is not equal to remote.");
|
||||
TAG_LOGI(AAFwkTag::CONNECTION, "ConnectionObserverStub Local descriptor is not equal to remote.");
|
||||
return ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
@@ -52,7 +53,7 @@ int ConnectionObserverStub::OnExtensionConnectedInner(MessageParcel &data, Messa
|
||||
{
|
||||
std::unique_ptr<ConnectionData> connectionData(data.ReadParcelable<ConnectionData>());
|
||||
if (!connectionData) {
|
||||
HILOG_ERROR("OnExensionConnected ReadParcelable<ConnectionData> failed");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "OnExensionConnected ReadParcelable<ConnectionData> failed");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
@@ -64,7 +65,7 @@ int ConnectionObserverStub::OnExtensionDisconnectedInner(MessageParcel &data, Me
|
||||
{
|
||||
std::unique_ptr<ConnectionData> connectionData(data.ReadParcelable<ConnectionData>());
|
||||
if (!connectionData) {
|
||||
HILOG_ERROR("OnExtensionDisconnected ReadParcelable<ConnectionData> failed");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "OnExtensionDisconnected ReadParcelable<ConnectionData> failed");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
@@ -76,7 +77,7 @@ int ConnectionObserverStub::OnDlpAbilityOpenedInner(MessageParcel &data, Message
|
||||
{
|
||||
std::unique_ptr<DlpStateData> dlpData(data.ReadParcelable<DlpStateData>());
|
||||
if (!dlpData) {
|
||||
HILOG_ERROR("OnDlpAbilityOpened ReadParcelable<DlpStateData> failed");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "OnDlpAbilityOpened ReadParcelable<DlpStateData> failed");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
@@ -88,7 +89,7 @@ int ConnectionObserverStub::OnDlpAbilityClosedInner(MessageParcel &data, Message
|
||||
{
|
||||
std::unique_ptr<DlpStateData> dlpData(data.ReadParcelable<DlpStateData>());
|
||||
if (!dlpData) {
|
||||
HILOG_ERROR("OnDlpAbilityClosed ReadParcelable<DlpStateData> failed");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "OnDlpAbilityClosed ReadParcelable<DlpStateData> failed");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "dlp_state_data.h"
|
||||
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "string_ex.h"
|
||||
|
||||
@@ -54,7 +55,7 @@ bool DlpStateData::Marshalling(Parcel &parcel) const
|
||||
return false;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("end");
|
||||
TAG_LOGD(AAFwkTag::CONNECTION, "end");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -85,17 +86,17 @@ bool DlpStateData::ReadFromParcel(Parcel &parcel)
|
||||
targetAbilityName = Str16ToStr8(strValue);
|
||||
|
||||
if (!parcel.ReadInt32(callerUid)) {
|
||||
HILOG_WARN("DlpStateData::ReadFromParcel read callerUid failed");
|
||||
TAG_LOGW(AAFwkTag::CONNECTION, "DlpStateData::ReadFromParcel read callerUid failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!parcel.ReadInt32(callerPid)) {
|
||||
HILOG_WARN("DlpStateData::ReadFromParcel read callerPid failed");
|
||||
TAG_LOGW(AAFwkTag::CONNECTION, "DlpStateData::ReadFromParcel read callerPid failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!parcel.ReadString16(strValue)) {
|
||||
HILOG_WARN("DlpStateData::ReadFromParcel read strValue failed");
|
||||
TAG_LOGW(AAFwkTag::CONNECTION, "DlpStateData::ReadFromParcel read strValue failed");
|
||||
return false;
|
||||
}
|
||||
callerName = Str16ToStr8(strValue);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "service_proxy_adapter.h"
|
||||
|
||||
#include "connection_observer_errors.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
@@ -31,12 +32,12 @@ constexpr int32_t CYCLE_LIMIT = 1000;
|
||||
int32_t ServiceProxyAdapter::RegisterObserver(const sptr<IConnectionObserver> &observer)
|
||||
{
|
||||
if (!observer) {
|
||||
HILOG_ERROR("IConnectObserver is invalid.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "IConnectObserver is invalid.");
|
||||
return ERR_INVALID_OBSERVER;
|
||||
}
|
||||
|
||||
if (!remoteObj_) {
|
||||
HILOG_ERROR("no abilityms proxy.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "no abilityms proxy.");
|
||||
return ERR_NO_PROXY;
|
||||
}
|
||||
|
||||
@@ -45,18 +46,18 @@ int32_t ServiceProxyAdapter::RegisterObserver(const sptr<IConnectionObserver> &o
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(ABILITY_MGR_DESCRIPTOR)) {
|
||||
HILOG_ERROR("register observer write interface token failed.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "register observer write interface token failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
if (!data.WriteRemoteObject(observer->AsObject())) {
|
||||
HILOG_ERROR("register observer write observer remote obj failed.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "register observer write observer remote obj failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
error = remoteObj_->SendRequest(REGISTER_CONNECTION_OBSERVER, data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("register observer Send request error: %{public}d", error);
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "register observer Send request error: %{public}d", error);
|
||||
return error;
|
||||
}
|
||||
return reply.ReadInt32();
|
||||
@@ -65,12 +66,12 @@ int32_t ServiceProxyAdapter::RegisterObserver(const sptr<IConnectionObserver> &o
|
||||
int32_t ServiceProxyAdapter::UnregisterObserver(const sptr<IConnectionObserver> &observer)
|
||||
{
|
||||
if (!observer) {
|
||||
HILOG_ERROR("unregister observer, IConnectObserver is invalid.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "unregister observer, IConnectObserver is invalid.");
|
||||
return ERR_INVALID_OBSERVER;
|
||||
}
|
||||
|
||||
if (!remoteObj_) {
|
||||
HILOG_ERROR("unregister observer, no abilityms proxy.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "unregister observer, no abilityms proxy.");
|
||||
return ERR_NO_PROXY;
|
||||
}
|
||||
|
||||
@@ -79,18 +80,18 @@ int32_t ServiceProxyAdapter::UnregisterObserver(const sptr<IConnectionObserver>
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(ABILITY_MGR_DESCRIPTOR)) {
|
||||
HILOG_ERROR("unregister observer, write interface token failed.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "unregister observer, write interface token failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
if (!data.WriteRemoteObject(observer->AsObject())) {
|
||||
HILOG_ERROR("unregister observer, write observer remote obj failed.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "unregister observer, write observer remote obj failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
error = remoteObj_->SendRequest(UNREGISTER_CONNECTION_OBSERVER, data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("unregister observer, Send request error: %{public}d", error);
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "unregister observer, Send request error: %{public}d", error);
|
||||
return error;
|
||||
}
|
||||
return reply.ReadInt32();
|
||||
@@ -99,7 +100,7 @@ int32_t ServiceProxyAdapter::UnregisterObserver(const sptr<IConnectionObserver>
|
||||
int32_t ServiceProxyAdapter::GetDlpConnectionInfos(std::vector<DlpConnectionInfo> &infos)
|
||||
{
|
||||
if (!remoteObj_) {
|
||||
HILOG_ERROR("GetDlpConnectionInfos, no abilityms proxy.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "GetDlpConnectionInfos, no abilityms proxy.");
|
||||
return ERR_NO_PROXY;
|
||||
}
|
||||
|
||||
@@ -108,32 +109,32 @@ int32_t ServiceProxyAdapter::GetDlpConnectionInfos(std::vector<DlpConnectionInfo
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(ABILITY_MGR_DESCRIPTOR)) {
|
||||
HILOG_ERROR("GetDlpConnectionInfos, write interface token failed.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "GetDlpConnectionInfos, write interface token failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
error = remoteObj_->SendRequest(GET_DLP_CONNECTION_INFOS, data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("GetDlpConnectionInfos, Send request error: %{public}d", error);
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "GetDlpConnectionInfos, Send request error: %{public}d", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
auto result = reply.ReadInt32();
|
||||
if (result != 0) {
|
||||
HILOG_ERROR("GetDlpConnectionInfos fail, result: %{public}d", result);
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "GetDlpConnectionInfos fail, result: %{public}d", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t infoSize = reply.ReadInt32();
|
||||
if (infoSize > CYCLE_LIMIT) {
|
||||
HILOG_ERROR("infoSize is too large");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "infoSize is too large");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < infoSize; i++) {
|
||||
std::unique_ptr<DlpConnectionInfo> info(reply.ReadParcelable<DlpConnectionInfo>());
|
||||
if (info == nullptr) {
|
||||
HILOG_ERROR("Read GetDlpConnectionInfo infos failed");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "Read GetDlpConnectionInfo infos failed");
|
||||
return ERR_READ_INFO_FAILED;
|
||||
}
|
||||
infos.emplace_back(*info);
|
||||
@@ -145,7 +146,7 @@ int32_t ServiceProxyAdapter::GetDlpConnectionInfos(std::vector<DlpConnectionInfo
|
||||
int32_t ServiceProxyAdapter::GetConnectionData(std::vector<ConnectionData> &connectionData)
|
||||
{
|
||||
if (!remoteObj_) {
|
||||
HILOG_ERROR("GetConnectionData, no abilityms proxy.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "GetConnectionData, no abilityms proxy.");
|
||||
return ERR_NO_PROXY;
|
||||
}
|
||||
|
||||
@@ -154,32 +155,32 @@ int32_t ServiceProxyAdapter::GetConnectionData(std::vector<ConnectionData> &conn
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(ABILITY_MGR_DESCRIPTOR)) {
|
||||
HILOG_ERROR("GetConnectionData, write interface token failed.");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "GetConnectionData, write interface token failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
error = remoteObj_->SendRequest(GET_CONNECTION_DATA, data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("GetConnectionData, Send request error: %{public}d", error);
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "GetConnectionData, Send request error: %{public}d", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
auto result = reply.ReadInt32();
|
||||
if (result != 0) {
|
||||
HILOG_ERROR("GetConnectionData fail, result: %{public}d", result);
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "GetConnectionData fail, result: %{public}d", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t infoSize = reply.ReadInt32();
|
||||
if (infoSize > CYCLE_LIMIT) {
|
||||
HILOG_ERROR("infoSize is too large");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "infoSize is too large");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < infoSize; i++) {
|
||||
std::unique_ptr<ConnectionData> item(reply.ReadParcelable<ConnectionData>());
|
||||
if (item == nullptr) {
|
||||
HILOG_ERROR("Read GetConnectionData infos failed");
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "Read GetConnectionData infos failed");
|
||||
return ERR_READ_INFO_FAILED;
|
||||
}
|
||||
connectionData.emplace_back(*item);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include <map>
|
||||
#include "errors.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "napi/native_api.h"
|
||||
#include "runtime.h"
|
||||
@@ -163,7 +164,7 @@ bool AbilityRuntimeErrorUtil::Throw(napi_env env, int32_t errCode, const std::st
|
||||
napi_value error = nullptr;
|
||||
napi_create_error(env, CreateJsValue(env, errCode), CreateJsValue(env, eMes), &error);
|
||||
if (error == nullptr) {
|
||||
HILOG_ERROR("Failed to create error.");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Failed to create error.");
|
||||
return false;
|
||||
}
|
||||
napi_throw(env, error);
|
||||
@@ -173,7 +174,7 @@ bool AbilityRuntimeErrorUtil::Throw(napi_env env, int32_t errCode, const std::st
|
||||
bool AbilityRuntimeErrorUtil::ThrowByInternalErrCode(napi_env env, int32_t errCode)
|
||||
{
|
||||
if (ERROR_CODE_MAP.find(errCode) == ERROR_CODE_MAP.end()) {
|
||||
HILOG_ERROR("Invalid inner errCode, check ERROR_CODE_MAP");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Invalid inner errCode, check ERROR_CODE_MAP");
|
||||
return false;
|
||||
}
|
||||
return Throw(env, ERROR_CODE_MAP.at(errCode));
|
||||
@@ -182,7 +183,7 @@ bool AbilityRuntimeErrorUtil::ThrowByInternalErrCode(napi_env env, int32_t errCo
|
||||
napi_value AbilityRuntimeErrorUtil::CreateErrorByInternalErrCode(napi_env env, int32_t errCode)
|
||||
{
|
||||
if (ERROR_CODE_MAP.find(errCode) == ERROR_CODE_MAP.end()) {
|
||||
HILOG_ERROR("Invalid inner errCode, check ERROR_CODE_MAP");
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Invalid inner errCode, check ERROR_CODE_MAP");
|
||||
return nullptr;
|
||||
}
|
||||
int32_t externalErrCode = ERROR_CODE_MAP.at(errCode);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "ability_manager_errors.h"
|
||||
#include "extension_ability_info.h"
|
||||
#include "extension_manager_proxy.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "iservice_registry.h"
|
||||
@@ -28,7 +29,7 @@ namespace OHOS {
|
||||
namespace AAFwk {
|
||||
#define CHECK_POINTER_RETURN_NOT_CONNECTED(object) \
|
||||
if (!object) { \
|
||||
HILOG_ERROR("proxy is nullptr."); \
|
||||
TAG_LOGE(AAFwkTag::EXTMGR, "proxy is nullptr."); \
|
||||
return ABILITY_SERVICE_NOT_CONNECTED; \
|
||||
}
|
||||
|
||||
@@ -52,30 +53,30 @@ void ExtensionManagerClient::Connect()
|
||||
{
|
||||
auto systemManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (systemManager == nullptr) {
|
||||
HILOG_ERROR("Fail to get SAMgr.");
|
||||
TAG_LOGE(AAFwkTag::EXTMGR, "Fail to get SAMgr.");
|
||||
return;
|
||||
}
|
||||
auto remoteObj = systemManager->GetSystemAbility(ABILITY_MGR_SERVICE_ID);
|
||||
if (remoteObj == nullptr) {
|
||||
HILOG_ERROR("Fail to connect ability manager service.");
|
||||
TAG_LOGE(AAFwkTag::EXTMGR, "Fail to connect ability manager service.");
|
||||
return;
|
||||
}
|
||||
|
||||
deathRecipient_ = new ExtensionMgrDeathRecipient();
|
||||
if (remoteObj->IsProxyObject() && !remoteObj->AddDeathRecipient(deathRecipient_)) {
|
||||
HILOG_ERROR("Add death recipient to AbilityManagerService failed.");
|
||||
TAG_LOGE(AAFwkTag::EXTMGR, "Add death recipient to AbilityManagerService failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
proxy_ = sptr<IExtensionManager>(new ExtensionManagerProxy(remoteObj));
|
||||
HILOG_DEBUG("Connect ability manager service success.");
|
||||
TAG_LOGD(AAFwkTag::EXTMGR, "Connect ability manager service success.");
|
||||
}
|
||||
|
||||
void ExtensionManagerClient::ResetProxy(const wptr<IRemoteObject>& remote)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (proxy_ == nullptr) {
|
||||
HILOG_INFO("proxy_ is nullptr, no need reset.");
|
||||
TAG_LOGI(AAFwkTag::EXTMGR, "proxy_ is nullptr, no need reset.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -88,7 +89,7 @@ void ExtensionManagerClient::ResetProxy(const wptr<IRemoteObject>& remote)
|
||||
|
||||
void ExtensionManagerClient::ExtensionMgrDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& remote)
|
||||
{
|
||||
HILOG_INFO("ExtensionMgrDeathRecipient handle remote died.");
|
||||
TAG_LOGI(AAFwkTag::EXTMGR, "ExtensionMgrDeathRecipient handle remote died.");
|
||||
ExtensionManagerClient::GetInstance().ResetProxy(remote);
|
||||
}
|
||||
|
||||
@@ -98,11 +99,11 @@ ErrCode ExtensionManagerClient::ConnectServiceExtensionAbility(const Want &want,
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
auto abms = GetExtensionManager();
|
||||
if (abms == nullptr) {
|
||||
HILOG_ERROR("Connect service failed, bundleName:%{public}s, abilityName:%{public}s.",
|
||||
TAG_LOGE(AAFwkTag::EXTMGR, "Connect service failed, bundleName:%{public}s, abilityName:%{public}s.",
|
||||
want.GetElement().GetBundleName().c_str(), want.GetElement().GetAbilityName().c_str());
|
||||
return ABILITY_SERVICE_NOT_CONNECTED;
|
||||
}
|
||||
HILOG_DEBUG("name:%{public}s %{public}s, userId:%{public}d.",
|
||||
TAG_LOGD(AAFwkTag::EXTMGR, "name:%{public}s %{public}s, userId:%{public}d.",
|
||||
want.GetElement().GetBundleName().c_str(), want.GetElement().GetAbilityName().c_str(), userId);
|
||||
return abms->ConnectAbilityCommon(want, connect, nullptr, AppExecFwk::ExtensionAbilityType::SERVICE,
|
||||
userId, false);
|
||||
@@ -114,11 +115,11 @@ ErrCode ExtensionManagerClient::ConnectServiceExtensionAbility(const Want &want,
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
auto abms = GetExtensionManager();
|
||||
if (abms == nullptr) {
|
||||
HILOG_ERROR("Connect service failed, bundleName:%{public}s, abilityName:%{public}s.",
|
||||
TAG_LOGE(AAFwkTag::EXTMGR, "Connect service failed, bundleName:%{public}s, abilityName:%{public}s.",
|
||||
want.GetElement().GetBundleName().c_str(), want.GetElement().GetAbilityName().c_str());
|
||||
return ABILITY_SERVICE_NOT_CONNECTED;
|
||||
}
|
||||
HILOG_INFO("name:%{public}s %{public}s, userId:%{public}d.",
|
||||
TAG_LOGI(AAFwkTag::EXTMGR, "name:%{public}s %{public}s, userId:%{public}d.",
|
||||
want.GetElement().GetBundleName().c_str(), want.GetElement().GetAbilityName().c_str(), userId);
|
||||
return abms->ConnectAbilityCommon(
|
||||
want, connect, callerToken, AppExecFwk::ExtensionAbilityType::SERVICE, userId, false);
|
||||
@@ -130,11 +131,11 @@ ErrCode ExtensionManagerClient::ConnectEnterpriseAdminExtensionAbility(const Wan
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
auto abms = GetExtensionManager();
|
||||
if (abms == nullptr) {
|
||||
HILOG_ERROR("Connect service failed, bundleName:%{public}s, abilityName:%{public}s.",
|
||||
TAG_LOGE(AAFwkTag::EXTMGR, "Connect service failed, bundleName:%{public}s, abilityName:%{public}s.",
|
||||
want.GetElement().GetBundleName().c_str(), want.GetElement().GetAbilityName().c_str());
|
||||
return ABILITY_SERVICE_NOT_CONNECTED;
|
||||
}
|
||||
HILOG_INFO("name:%{public}s %{public}s, userId:%{public}d.",
|
||||
TAG_LOGI(AAFwkTag::EXTMGR, "name:%{public}s %{public}s, userId:%{public}d.",
|
||||
want.GetElement().GetBundleName().c_str(), want.GetElement().GetAbilityName().c_str(), userId);
|
||||
return abms->ConnectAbilityCommon(
|
||||
want, connect, callerToken, AppExecFwk::ExtensionAbilityType::ENTERPRISE_ADMIN, userId, true);
|
||||
@@ -146,12 +147,12 @@ ErrCode ExtensionManagerClient::ConnectExtensionAbility(const Want &want, const
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
auto abms = GetExtensionManager();
|
||||
if (abms == nullptr) {
|
||||
HILOG_ERROR("Connect failed, bundleName:%{public}s, abilityName:%{public}s",
|
||||
TAG_LOGE(AAFwkTag::EXTMGR, "Connect failed, bundleName:%{public}s, abilityName:%{public}s",
|
||||
want.GetElement().GetBundleName().c_str(), want.GetElement().GetAbilityName().c_str());
|
||||
return ABILITY_SERVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
HILOG_INFO("bundleName: %{public}s, abilityName: %{public}s, userId: %{public}d.",
|
||||
TAG_LOGI(AAFwkTag::EXTMGR, "bundleName: %{public}s, abilityName: %{public}s, userId: %{public}d.",
|
||||
want.GetElement().GetBundleName().c_str(), want.GetElement().GetAbilityName().c_str(), userId);
|
||||
return abms->ConnectAbilityCommon(want, connect, nullptr, AppExecFwk::ExtensionAbilityType::UNSPECIFIED, userId);
|
||||
}
|
||||
@@ -161,7 +162,7 @@ ErrCode ExtensionManagerClient::DisconnectAbility(const sptr<IRemoteObject> &con
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
auto abms = GetExtensionManager();
|
||||
CHECK_POINTER_RETURN_NOT_CONNECTED(abms);
|
||||
HILOG_INFO("call");
|
||||
TAG_LOGI(AAFwkTag::EXTMGR, "call");
|
||||
return abms->DisconnectAbility(connect);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "ability_manager_errors.h"
|
||||
#include "ability_manager_ipc_interface_code.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "message_parcel.h"
|
||||
#include "want.h"
|
||||
@@ -25,7 +26,7 @@ namespace OHOS::AAFwk {
|
||||
bool ExtensionManagerProxy::WriteInterfaceToken(MessageParcel &data)
|
||||
{
|
||||
if (!data.WriteInterfaceToken(ExtensionManagerProxy::GetDescriptor())) {
|
||||
HILOG_ERROR("write interface token failed.");
|
||||
TAG_LOGE(AAFwkTag::EXTMGR, "write interface token failed.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -36,7 +37,7 @@ int ExtensionManagerProxy::ConnectAbilityCommon(const Want &want, const sptr<IRe
|
||||
bool isQueryExtensionOnly)
|
||||
{
|
||||
if (connect == nullptr) {
|
||||
HILOG_ERROR("connect is nullptr");
|
||||
TAG_LOGE(AAFwkTag::EXTMGR, "connect is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
@@ -45,34 +46,34 @@ int ExtensionManagerProxy::ConnectAbilityCommon(const Want &want, const sptr<IRe
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteParcelable(&want)) {
|
||||
HILOG_ERROR("want write failed.");
|
||||
TAG_LOGE(AAFwkTag::EXTMGR, "want write failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
if (!data.WriteBool(true) || !data.WriteRemoteObject(connect)) {
|
||||
HILOG_ERROR("flag and connect write failed.");
|
||||
TAG_LOGE(AAFwkTag::EXTMGR, "flag and connect write failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
if (callerToken) {
|
||||
if (!data.WriteBool(true) || !data.WriteRemoteObject(callerToken)) {
|
||||
HILOG_ERROR("flag and callerToken write failed.");
|
||||
TAG_LOGE(AAFwkTag::EXTMGR, "flag and callerToken write failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
} else {
|
||||
if (!data.WriteBool(false)) {
|
||||
HILOG_ERROR("flag write failed.");
|
||||
TAG_LOGE(AAFwkTag::EXTMGR, "flag write failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
}
|
||||
if (!data.WriteInt32(userId)) {
|
||||
HILOG_ERROR("%{public}s, userId write failed.", __func__);
|
||||
TAG_LOGE(AAFwkTag::EXTMGR, "%{public}s, userId write failed.", __func__);
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteInt32(static_cast<int32_t>(extensionType))) {
|
||||
HILOG_ERROR("%{public}s, extensionType write failed.", __func__);
|
||||
TAG_LOGE(AAFwkTag::EXTMGR, "%{public}s, extensionType write failed.", __func__);
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteBool(isQueryExtensionOnly)) {
|
||||
HILOG_ERROR("isQueryExtensionOnly write failed.");
|
||||
TAG_LOGE(AAFwkTag::EXTMGR, "isQueryExtensionOnly write failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
|
||||
@@ -80,7 +81,7 @@ int ExtensionManagerProxy::ConnectAbilityCommon(const Want &want, const sptr<IRe
|
||||
MessageOption option;
|
||||
int error = SendRequest(AbilityManagerInterfaceCode::CONNECT_ABILITY_WITH_TYPE, data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("%{public}s, Send request error: %{public}d", __func__, error);
|
||||
TAG_LOGE(AAFwkTag::EXTMGR, "%{public}s, Send request error: %{public}d", __func__, error);
|
||||
return error;
|
||||
}
|
||||
return reply.ReadInt32();
|
||||
@@ -89,7 +90,7 @@ int ExtensionManagerProxy::ConnectAbilityCommon(const Want &want, const sptr<IRe
|
||||
int ExtensionManagerProxy::DisconnectAbility(const sptr<IRemoteObject> &connect)
|
||||
{
|
||||
if (connect == nullptr) {
|
||||
HILOG_ERROR("disconnect ability fail, connect is nullptr");
|
||||
TAG_LOGE(AAFwkTag::EXTMGR, "disconnect ability fail, connect is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
@@ -98,7 +99,7 @@ int ExtensionManagerProxy::DisconnectAbility(const sptr<IRemoteObject> &connect)
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteRemoteObject(connect)) {
|
||||
HILOG_ERROR("connect write failed.");
|
||||
TAG_LOGE(AAFwkTag::EXTMGR, "connect write failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
@@ -106,7 +107,7 @@ int ExtensionManagerProxy::DisconnectAbility(const sptr<IRemoteObject> &connect)
|
||||
MessageOption option;
|
||||
auto error = SendRequest(AbilityManagerInterfaceCode::DISCONNECT_ABILITY, data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("Send request error: %{public}d", error);
|
||||
TAG_LOGE(AAFwkTag::EXTMGR, "Send request error: %{public}d", error);
|
||||
return error;
|
||||
}
|
||||
return reply.ReadInt32();
|
||||
@@ -117,7 +118,7 @@ ErrCode ExtensionManagerProxy::SendRequest(AbilityManagerInterfaceCode code, Mes
|
||||
{
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
HILOG_ERROR("Remote() is NULL");
|
||||
TAG_LOGE(AAFwkTag::EXTMGR, "Remote() is NULL");
|
||||
return INNER_ERR;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "quick_fix_info.h"
|
||||
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
@@ -26,7 +27,7 @@ bool ApplicationQuickFixInfo::ReadFromParcel(Parcel &parcel)
|
||||
bundleVersionName = parcel.ReadString();
|
||||
std::unique_ptr<AppExecFwk::AppqfInfo> qfInfo(parcel.ReadParcelable<AppExecFwk::AppqfInfo>());
|
||||
if (qfInfo == nullptr) {
|
||||
HILOG_ERROR("ReadParcelable<AppqfInfo> failed.");
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "ReadParcelable<AppqfInfo> failed.");
|
||||
return false;
|
||||
}
|
||||
appqfInfo = *qfInfo;
|
||||
@@ -36,19 +37,19 @@ bool ApplicationQuickFixInfo::ReadFromParcel(Parcel &parcel)
|
||||
bool ApplicationQuickFixInfo::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
if (!parcel.WriteString(bundleName)) {
|
||||
HILOG_ERROR("Write bundleName failed.");
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "Write bundleName failed.");
|
||||
return false;
|
||||
}
|
||||
if (!parcel.WriteUint32(bundleVersionCode)) {
|
||||
HILOG_ERROR("Write bundleVersionCode failed.");
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "Write bundleVersionCode failed.");
|
||||
return false;
|
||||
}
|
||||
if (!parcel.WriteString(bundleVersionName)) {
|
||||
HILOG_ERROR("Write bundleVersionName failed.");
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "Write bundleVersionName failed.");
|
||||
return false;
|
||||
}
|
||||
if (!parcel.WriteParcelable(&appqfInfo)) {
|
||||
HILOG_ERROR("Write appQfInfo failed.");
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "Write appQfInfo failed.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -58,12 +59,12 @@ ApplicationQuickFixInfo *ApplicationQuickFixInfo::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
ApplicationQuickFixInfo *info = new (std::nothrow) ApplicationQuickFixInfo();
|
||||
if (info == nullptr) {
|
||||
HILOG_ERROR("Create failed.");
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "Create failed.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!info->ReadFromParcel(parcel)) {
|
||||
HILOG_ERROR("Read from parcel failed.");
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "Read from parcel failed.");
|
||||
delete info;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -13,6 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "quick_fix_load_callback.h"
|
||||
#include "quick_fix_manager_client.h"
|
||||
@@ -23,27 +24,27 @@ namespace AAFwk {
|
||||
void QuickFixLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbilityId, const sptr<IRemoteObject> &remoteObject)
|
||||
{
|
||||
if (systemAbilityId != QUICK_FIX_MGR_SERVICE_ID) {
|
||||
HILOG_ERROR("System ability id %{public}d mismatch.", systemAbilityId);
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "System ability id %{public}d mismatch.", systemAbilityId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (remoteObject == nullptr) {
|
||||
HILOG_ERROR("Object is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "Object is nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("Load system ability %{public}d succeed.", systemAbilityId);
|
||||
TAG_LOGD(AAFwkTag::QUICKFIX, "Load system ability %{public}d succeed.", systemAbilityId);
|
||||
QuickFixManagerClient::GetInstance()->OnLoadSystemAbilitySuccess(remoteObject);
|
||||
}
|
||||
|
||||
void QuickFixLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId)
|
||||
{
|
||||
if (systemAbilityId != QUICK_FIX_MGR_SERVICE_ID) {
|
||||
HILOG_ERROR("System ability id %{public}d mismatch.", systemAbilityId);
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "System ability id %{public}d mismatch.", systemAbilityId);
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("Load system ability %{public}d failed.", systemAbilityId);
|
||||
TAG_LOGD(AAFwkTag::QUICKFIX, "Load system ability %{public}d failed.", systemAbilityId);
|
||||
QuickFixManagerClient::GetInstance()->OnLoadSystemAbilityFail();
|
||||
}
|
||||
} // namespace AAFwk
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "quick_fix_manager_client.h"
|
||||
|
||||
#include "appexecfwk_errors.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "if_system_ability_manager.h"
|
||||
@@ -35,11 +36,11 @@ const int LOAD_SA_TIMEOUT_MS = 4 * 1000;
|
||||
int32_t QuickFixManagerClient::ApplyQuickFix(const std::vector<std::string> &quickFixFiles, bool isDebug)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("function called.");
|
||||
TAG_LOGD(AAFwkTag::QUICKFIX, "function called.");
|
||||
|
||||
auto quickFixMgr = GetQuickFixMgrProxy();
|
||||
if (quickFixMgr == nullptr) {
|
||||
HILOG_ERROR("Get quick fix manager service failed.");
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "Get quick fix manager service failed.");
|
||||
return QUICK_FIX_CONNECT_FAILED;
|
||||
}
|
||||
|
||||
@@ -48,11 +49,11 @@ int32_t QuickFixManagerClient::ApplyQuickFix(const std::vector<std::string> &qui
|
||||
return QUICK_FIX_CONNECT_FAILED;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("hqf file number need to apply: %{public}zu.", quickFixFiles.size());
|
||||
TAG_LOGD(AAFwkTag::QUICKFIX, "hqf file number need to apply: %{public}zu.", quickFixFiles.size());
|
||||
std::vector<std::string> destFiles;
|
||||
auto copyRet = bundleQuickFixMgr->CopyFiles(quickFixFiles, destFiles);
|
||||
if (copyRet != 0) {
|
||||
HILOG_ERROR("Copy files failed.");
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "Copy files failed.");
|
||||
return (copyRet == ERR_BUNDLEMANAGER_QUICK_FIX_PERMISSION_DENIED) ? QUICK_FIX_VERIFY_PERMISSION_FAILED :
|
||||
QUICK_FIX_COPY_FILES_FAILED;
|
||||
}
|
||||
@@ -64,11 +65,11 @@ int32_t QuickFixManagerClient::GetApplyedQuickFixInfo(const std::string &bundleN
|
||||
ApplicationQuickFixInfo &quickFixInfo)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("function called.");
|
||||
TAG_LOGD(AAFwkTag::QUICKFIX, "function called.");
|
||||
|
||||
auto quickFixMgr = GetQuickFixMgrProxy();
|
||||
if (quickFixMgr == nullptr) {
|
||||
HILOG_ERROR("Get quick fix manager service failed.");
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "Get quick fix manager service failed.");
|
||||
return QUICK_FIX_CONNECT_FAILED;
|
||||
}
|
||||
|
||||
@@ -77,21 +78,21 @@ int32_t QuickFixManagerClient::GetApplyedQuickFixInfo(const std::string &bundleN
|
||||
|
||||
sptr<IQuickFixManager> QuickFixManagerClient::GetQuickFixMgrProxy()
|
||||
{
|
||||
HILOG_DEBUG("function called.");
|
||||
TAG_LOGD(AAFwkTag::QUICKFIX, "function called.");
|
||||
auto quickFixMgr = GetQuickFixMgr();
|
||||
if (quickFixMgr != nullptr) {
|
||||
HILOG_DEBUG("Quick fix manager has been started.");
|
||||
TAG_LOGD(AAFwkTag::QUICKFIX, "Quick fix manager has been started.");
|
||||
return quickFixMgr;
|
||||
}
|
||||
|
||||
if (!LoadQuickFixMgrService()) {
|
||||
HILOG_ERROR("Load quick fix manager service failed.");
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "Load quick fix manager service failed.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
quickFixMgr = GetQuickFixMgr();
|
||||
if (quickFixMgr == nullptr || quickFixMgr->AsObject() == nullptr) {
|
||||
HILOG_ERROR("Failed to get quick fix manager.");
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "Failed to get quick fix manager.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -106,28 +107,28 @@ sptr<IQuickFixManager> QuickFixManagerClient::GetQuickFixMgrProxy()
|
||||
sptr<QfmsDeathRecipient> recipient(new (std::nothrow) QfmsDeathRecipient(onClearProxyCallback));
|
||||
quickFixMgr->AsObject()->AddDeathRecipient(recipient);
|
||||
|
||||
HILOG_DEBUG("function finished.");
|
||||
TAG_LOGD(AAFwkTag::QUICKFIX, "function finished.");
|
||||
return quickFixMgr;
|
||||
}
|
||||
|
||||
int32_t QuickFixManagerClient::RevokeQuickFix(const std::string &bundleName)
|
||||
{
|
||||
HILOG_DEBUG("Function called.");
|
||||
TAG_LOGD(AAFwkTag::QUICKFIX, "Function called.");
|
||||
|
||||
auto quickFixMgr = GetQuickFixMgrProxy();
|
||||
if (quickFixMgr == nullptr) {
|
||||
HILOG_ERROR("Get quick fix manager service failed.");
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "Get quick fix manager service failed.");
|
||||
return QUICK_FIX_CONNECT_FAILED;
|
||||
}
|
||||
|
||||
auto retval = quickFixMgr->RevokeQuickFix(bundleName);
|
||||
HILOG_DEBUG("Function call end, retval is %{public}d.", retval);
|
||||
TAG_LOGD(AAFwkTag::QUICKFIX, "Function call end, retval is %{public}d.", retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
void QuickFixManagerClient::ClearProxy()
|
||||
{
|
||||
HILOG_DEBUG("function called.");
|
||||
TAG_LOGD(AAFwkTag::QUICKFIX, "function called.");
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
quickFixMgr_ = nullptr;
|
||||
}
|
||||
@@ -135,7 +136,7 @@ void QuickFixManagerClient::ClearProxy()
|
||||
void QuickFixManagerClient::QfmsDeathRecipient::OnRemoteDied([[maybe_unused]] const wptr<IRemoteObject> &remote)
|
||||
{
|
||||
if (proxy_ != nullptr) {
|
||||
HILOG_ERROR("quick fix manager service died.");
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "quick fix manager service died.");
|
||||
proxy_(remote);
|
||||
}
|
||||
}
|
||||
@@ -149,19 +150,20 @@ bool QuickFixManagerClient::LoadQuickFixMgrService()
|
||||
|
||||
auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (systemAbilityMgr == nullptr) {
|
||||
HILOG_ERROR("Failed to get SystemAbilityManager.");
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "Failed to get SystemAbilityManager.");
|
||||
return false;
|
||||
}
|
||||
|
||||
sptr<QuickFixLoadCallback> loadCallback = new (std::nothrow) QuickFixLoadCallback();
|
||||
if (loadCallback == nullptr) {
|
||||
HILOG_ERROR("Create load callback failed.");
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "Create load callback failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
auto ret = systemAbilityMgr->LoadSystemAbility(QUICK_FIX_MGR_SERVICE_ID, loadCallback);
|
||||
if (ret != 0) {
|
||||
HILOG_ERROR("Load system ability %{public}d failed with %{public}d.", QUICK_FIX_MGR_SERVICE_ID, ret);
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "Load system ability %{public}d failed with %{public}d.", QUICK_FIX_MGR_SERVICE_ID,
|
||||
ret);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -172,7 +174,7 @@ bool QuickFixManagerClient::LoadQuickFixMgrService()
|
||||
return loadSaFinished_;
|
||||
});
|
||||
if (!waitStatus) {
|
||||
HILOG_ERROR("Wait for load sa timeout.");
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "Wait for load sa timeout.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "quick_fix_utils.h"
|
||||
|
||||
#include "bundle_mgr_helper.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "iservice_registry.h"
|
||||
@@ -28,13 +29,13 @@ sptr<IRemoteObject> QuickFixUtil::GetRemoteObjectOfSystemAbility(const int32_t s
|
||||
{
|
||||
auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (systemAbilityMgr == nullptr) {
|
||||
HILOG_ERROR("Failed to get SystemAbilityManager.");
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "Failed to get SystemAbilityManager.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto remoteObj = systemAbilityMgr->GetSystemAbility(systemAbilityId);
|
||||
if (remoteObj == nullptr) {
|
||||
HILOG_ERROR("Remote object is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "Remote object is nullptr.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -48,20 +49,20 @@ sptr<AppExecFwk::IAppMgr> QuickFixUtil::GetAppManagerProxy()
|
||||
|
||||
sptr<AppExecFwk::IQuickFixManager> QuickFixUtil::GetBundleQuickFixMgrProxy()
|
||||
{
|
||||
HILOG_DEBUG("Function called.");
|
||||
TAG_LOGD(AAFwkTag::QUICKFIX, "Function called.");
|
||||
auto bundleMgrHelper = DelayedSingleton<AppExecFwk::BundleMgrHelper>::GetInstance();
|
||||
if (bundleMgrHelper == nullptr) {
|
||||
HILOG_ERROR("The bundleMgrHelper is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "The bundleMgrHelper is nullptr.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto bundleQuickFixMgr = bundleMgrHelper->GetQuickFixManagerProxy();
|
||||
if (bundleQuickFixMgr == nullptr) {
|
||||
HILOG_ERROR("The bundleQuickFixMgr is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::QUICKFIX, "The bundleQuickFixMgr is nullptr.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("Function finished.");
|
||||
TAG_LOGD(AAFwkTag::QUICKFIX, "Function finished.");
|
||||
return bundleQuickFixMgr;
|
||||
}
|
||||
} // namespace AAFwk
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -13,6 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "uri_permission_load_callback.h"
|
||||
#include "uri_permission_manager_client.h"
|
||||
@@ -24,27 +25,27 @@ 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);
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "System ability id %{public}d mismatch.", systemAbilityId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (remoteObject == nullptr) {
|
||||
HILOG_ERROR("Object is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Object is nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("Load system ability %{public}d succeed.", systemAbilityId);
|
||||
TAG_LOGD(AAFwkTag::URIPERMMGR, "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);
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "System ability id %{public}d mismatch.", systemAbilityId);
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("Load system ability %{public}d failed.", systemAbilityId);
|
||||
TAG_LOGD(AAFwkTag::URIPERMMGR, "Load system ability %{public}d failed.", systemAbilityId);
|
||||
UriPermissionManagerClient::GetInstance().OnLoadSystemAbilityFail();
|
||||
}
|
||||
} // namespace AAFwk
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "uri_permission_manager_client.h"
|
||||
|
||||
#include "ability_manager_errors.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "iservice_registry.h"
|
||||
@@ -37,7 +38,7 @@ UriPermissionManagerClient& UriPermissionManagerClient::GetInstance()
|
||||
int UriPermissionManagerClient::GrantUriPermission(const Uri &uri, unsigned int flag,
|
||||
const std::string targetBundleName, int32_t appIndex, uint32_t initiatorTokenId)
|
||||
{
|
||||
HILOG_DEBUG("targetBundleName :%{public}s", targetBundleName.c_str());
|
||||
TAG_LOGD(AAFwkTag::URIPERMMGR, "targetBundleName :%{public}s", targetBundleName.c_str());
|
||||
auto uriPermMgr = ConnectUriPermService();
|
||||
if (uriPermMgr) {
|
||||
return uriPermMgr->GrantUriPermission(uri, flag, targetBundleName, appIndex, initiatorTokenId);
|
||||
@@ -48,9 +49,10 @@ int UriPermissionManagerClient::GrantUriPermission(const Uri &uri, unsigned int
|
||||
int UriPermissionManagerClient::GrantUriPermission(const std::vector<Uri> &uriVec, unsigned int flag,
|
||||
const std::string targetBundleName, int32_t appIndex, uint32_t initiatorTokenId)
|
||||
{
|
||||
HILOG_DEBUG("targetBundleName: %{public}s, uriVec size: %{public}zu", targetBundleName.c_str(), uriVec.size());
|
||||
TAG_LOGD(AAFwkTag::URIPERMMGR, "targetBundleName: %{public}s, uriVec size: %{public}zu", targetBundleName.c_str(),
|
||||
uriVec.size());
|
||||
if (uriVec.size() == 0 || uriVec.size() > MAX_URI_COUNT) {
|
||||
HILOG_ERROR("The size of uriVec should be between 1 and %{public}i.", MAX_URI_COUNT);
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "The size of uriVec should be between 1 and %{public}i.", MAX_URI_COUNT);
|
||||
return INNER_ERR;
|
||||
}
|
||||
auto uriPermMgr = ConnectUriPermService();
|
||||
@@ -63,9 +65,10 @@ int UriPermissionManagerClient::GrantUriPermission(const std::vector<Uri> &uriVe
|
||||
int UriPermissionManagerClient::GrantUriPermissionFor2In1(const std::vector<Uri> &uriVec, unsigned int flag,
|
||||
const std::string &targetBundleName, int32_t appIndex, bool isSystemAppCall)
|
||||
{
|
||||
HILOG_DEBUG("targetBundleName: %{public}s, uriVec size: %{public}zu", targetBundleName.c_str(), uriVec.size());
|
||||
TAG_LOGD(AAFwkTag::URIPERMMGR, "targetBundleName: %{public}s, uriVec size: %{public}zu", targetBundleName.c_str(),
|
||||
uriVec.size());
|
||||
if (uriVec.size() == 0 || uriVec.size() > MAX_URI_COUNT) {
|
||||
HILOG_ERROR("The size of uriVec should be between 1 and %{public}i.", MAX_URI_COUNT);
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "The size of uriVec should be between 1 and %{public}i.", MAX_URI_COUNT);
|
||||
return INNER_ERR;
|
||||
}
|
||||
auto uriPermMgr = ConnectUriPermService();
|
||||
@@ -77,7 +80,7 @@ int UriPermissionManagerClient::GrantUriPermissionFor2In1(const std::vector<Uri>
|
||||
|
||||
void UriPermissionManagerClient::RevokeUriPermission(const Security::AccessToken::AccessTokenID tokenId)
|
||||
{
|
||||
HILOG_DEBUG("UriPermissionManagerClient::RevokeUriPermission is called.");
|
||||
TAG_LOGD(AAFwkTag::URIPERMMGR, "UriPermissionManagerClient::RevokeUriPermission is called.");
|
||||
auto uriPermMgr = ConnectUriPermService();
|
||||
if (uriPermMgr) {
|
||||
return uriPermMgr->RevokeUriPermission(tokenId);
|
||||
@@ -86,7 +89,7 @@ void UriPermissionManagerClient::RevokeUriPermission(const Security::AccessToken
|
||||
|
||||
int UriPermissionManagerClient::RevokeAllUriPermissions(const Security::AccessToken::AccessTokenID tokenId)
|
||||
{
|
||||
HILOG_DEBUG("UriPermissionManagerClient::RevokeAllUriPermissions is called.");
|
||||
TAG_LOGD(AAFwkTag::URIPERMMGR, "UriPermissionManagerClient::RevokeAllUriPermissions is called.");
|
||||
auto uriPermMgr = ConnectUriPermService();
|
||||
if (uriPermMgr) {
|
||||
return uriPermMgr->RevokeAllUriPermissions(tokenId);
|
||||
@@ -96,7 +99,7 @@ int UriPermissionManagerClient::RevokeAllUriPermissions(const Security::AccessTo
|
||||
|
||||
int UriPermissionManagerClient::RevokeUriPermissionManually(const Uri &uri, const std::string bundleName)
|
||||
{
|
||||
HILOG_DEBUG("UriPermissionManagerClient::RevokeUriPermissionManually is called.");
|
||||
TAG_LOGD(AAFwkTag::URIPERMMGR, "UriPermissionManagerClient::RevokeUriPermissionManually is called.");
|
||||
auto uriPermMgr = ConnectUriPermService();
|
||||
if (uriPermMgr) {
|
||||
return uriPermMgr->RevokeUriPermissionManually(uri, bundleName);
|
||||
@@ -124,16 +127,16 @@ bool UriPermissionManagerClient::IsAuthorizationUriAllowed(uint32_t fromTokenId)
|
||||
|
||||
sptr<IUriPermissionManager> UriPermissionManagerClient::ConnectUriPermService()
|
||||
{
|
||||
HILOG_DEBUG("UriPermissionManagerClient::ConnectUriPermService is called.");
|
||||
TAG_LOGD(AAFwkTag::URIPERMMGR, "UriPermissionManagerClient::ConnectUriPermService is called.");
|
||||
auto uriPermMgr = GetUriPermMgr();
|
||||
if (uriPermMgr == nullptr) {
|
||||
if (!LoadUriPermService()) {
|
||||
HILOG_ERROR("Load uri permission manager service failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Load uri permission manager service failed.");
|
||||
return nullptr;
|
||||
}
|
||||
uriPermMgr = GetUriPermMgr();
|
||||
if (uriPermMgr == nullptr || uriPermMgr->AsObject() == nullptr) {
|
||||
HILOG_ERROR("Failed to get uri permission manager.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Failed to get uri permission manager.");
|
||||
return nullptr;
|
||||
}
|
||||
const auto& onClearProxyCallback = [] {
|
||||
@@ -142,28 +145,29 @@ sptr<IUriPermissionManager> UriPermissionManagerClient::ConnectUriPermService()
|
||||
sptr<UpmsDeathRecipient> recipient(new UpmsDeathRecipient(onClearProxyCallback));
|
||||
uriPermMgr->AsObject()->AddDeathRecipient(recipient);
|
||||
}
|
||||
HILOG_DEBUG("End UriPermissionManagerClient::ConnectUriPermService.");
|
||||
TAG_LOGD(AAFwkTag::URIPERMMGR, "End UriPermissionManagerClient::ConnectUriPermService.");
|
||||
return uriPermMgr;
|
||||
}
|
||||
|
||||
bool UriPermissionManagerClient::LoadUriPermService()
|
||||
{
|
||||
HILOG_DEBUG("UriPermissionManagerClient::LoadUriPermService is called.");
|
||||
TAG_LOGD(AAFwkTag::URIPERMMGR, "UriPermissionManagerClient::LoadUriPermService is called.");
|
||||
auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (systemAbilityMgr == nullptr) {
|
||||
HILOG_ERROR("Failed to get SystemAbilityManager.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Failed to get SystemAbilityManager.");
|
||||
return false;
|
||||
}
|
||||
|
||||
sptr<UriPermissionLoadCallback> loadCallback = new (std::nothrow) UriPermissionLoadCallback();
|
||||
if (loadCallback == nullptr) {
|
||||
HILOG_ERROR("Create load callback failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "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);
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Load system ability %{public}d failed with %{public}d.",
|
||||
URI_PERMISSION_MGR_SERVICE_ID, ret);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -174,7 +178,7 @@ bool UriPermissionManagerClient::LoadUriPermService()
|
||||
return saLoadFinished_;
|
||||
});
|
||||
if (!waitStatus) {
|
||||
HILOG_ERROR("Wait for load sa timeout.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Wait for load sa timeout.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -189,14 +193,14 @@ sptr<IUriPermissionManager> UriPermissionManagerClient::GetUriPermMgr()
|
||||
|
||||
void UriPermissionManagerClient::SetUriPermMgr(const sptr<IRemoteObject> &remoteObject)
|
||||
{
|
||||
HILOG_DEBUG("UriPermissionManagerClient::SetUriPermMgr is called.");
|
||||
TAG_LOGD(AAFwkTag::URIPERMMGR, "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.");
|
||||
TAG_LOGD(AAFwkTag::URIPERMMGR, "UriPermissionManagerClient::OnLoadSystemAbilitySuccess is called.");
|
||||
SetUriPermMgr(remoteObject);
|
||||
std::unique_lock<std::mutex> lock(saLoadMutex_);
|
||||
saLoadFinished_ = true;
|
||||
@@ -205,7 +209,7 @@ void UriPermissionManagerClient::OnLoadSystemAbilitySuccess(const sptr<IRemoteOb
|
||||
|
||||
void UriPermissionManagerClient::OnLoadSystemAbilityFail()
|
||||
{
|
||||
HILOG_DEBUG("UriPermissionManagerClient::OnLoadSystemAbilityFail is called.");
|
||||
TAG_LOGD(AAFwkTag::URIPERMMGR, "UriPermissionManagerClient::OnLoadSystemAbilityFail is called.");
|
||||
SetUriPermMgr(nullptr);
|
||||
std::unique_lock<std::mutex> lock(saLoadMutex_);
|
||||
saLoadFinished_ = true;
|
||||
@@ -214,7 +218,7 @@ void UriPermissionManagerClient::OnLoadSystemAbilityFail()
|
||||
|
||||
void UriPermissionManagerClient::ClearProxy()
|
||||
{
|
||||
HILOG_DEBUG("UriPermissionManagerClient::ClearProxy is called.");
|
||||
TAG_LOGD(AAFwkTag::URIPERMMGR, "UriPermissionManagerClient::ClearProxy is called.");
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
uriPermMgr_ = nullptr;
|
||||
@@ -225,7 +229,7 @@ void UriPermissionManagerClient::ClearProxy()
|
||||
|
||||
void UriPermissionManagerClient::UpmsDeathRecipient::OnRemoteDied([[maybe_unused]] const wptr<IRemoteObject>& remote)
|
||||
{
|
||||
HILOG_ERROR("upms stub died.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "upms stub died.");
|
||||
proxy_();
|
||||
}
|
||||
} // namespace AAFwk
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "uri_permission_manager_proxy.h"
|
||||
|
||||
#include "ability_manager_errors.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "parcel.h"
|
||||
|
||||
@@ -30,37 +31,37 @@ UriPermissionManagerProxy::UriPermissionManagerProxy(const sptr<IRemoteObject> &
|
||||
int UriPermissionManagerProxy::GrantUriPermission(const Uri &uri, unsigned int flag,
|
||||
const std::string targetBundleName, int32_t appIndex, uint32_t initiatorTokenId)
|
||||
{
|
||||
HILOG_DEBUG("UriPermissionManagerProxy::GrantUriPermission is called.");
|
||||
TAG_LOGD(AAFwkTag::URIPERMMGR, "UriPermissionManagerProxy::GrantUriPermission is called.");
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(IUriPermissionManager::GetDescriptor())) {
|
||||
HILOG_ERROR("Write interface token failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write interface token failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteParcelable(&uri)) {
|
||||
HILOG_ERROR("Write uri failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write uri failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteInt32(flag)) {
|
||||
HILOG_ERROR("Write flag failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write flag failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteString(targetBundleName)) {
|
||||
HILOG_ERROR("Write targetBundleName failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write targetBundleName failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteInt32(appIndex)) {
|
||||
HILOG_ERROR("Write appIndex failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write appIndex failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteUint32(initiatorTokenId)) {
|
||||
HILOG_ERROR("Write initiatorTokenId failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write initiatorTokenId failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int error = SendTransactCmd(UriPermMgrCmd::ON_GRANT_URI_PERMISSION, data, reply, option);
|
||||
if (error != ERR_OK) {
|
||||
HILOG_ERROR("SendRequest fial, error: %{public}d", error);
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "SendRequest fial, error: %{public}d", error);
|
||||
return INNER_ERR;
|
||||
}
|
||||
return reply.ReadInt32();
|
||||
@@ -69,43 +70,43 @@ int UriPermissionManagerProxy::GrantUriPermission(const Uri &uri, unsigned int f
|
||||
int UriPermissionManagerProxy::GrantUriPermission(const std::vector<Uri> &uriVec, unsigned int flag,
|
||||
const std::string targetBundleName, int32_t appIndex, uint32_t initiatorTokenId)
|
||||
{
|
||||
HILOG_DEBUG("UriPermissionManagerProxy::GrantUriPermission is called.");
|
||||
TAG_LOGD(AAFwkTag::URIPERMMGR, "UriPermissionManagerProxy::GrantUriPermission is called.");
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(IUriPermissionManager::GetDescriptor())) {
|
||||
HILOG_ERROR("Write interface token failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write interface token failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteUint32(uriVec.size())) {
|
||||
HILOG_ERROR("Write size of uriVec failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write size of uriVec failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
for (const auto &uri : uriVec) {
|
||||
if (!data.WriteParcelable(&uri)) {
|
||||
HILOG_ERROR("Write uri failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write uri failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
}
|
||||
if (!data.WriteInt32(flag)) {
|
||||
HILOG_ERROR("Write flag failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write flag failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteString(targetBundleName)) {
|
||||
HILOG_ERROR("Write targetBundleName failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write targetBundleName failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteInt32(appIndex)) {
|
||||
HILOG_ERROR("Write appIndex failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write appIndex failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteUint32(initiatorTokenId)) {
|
||||
HILOG_ERROR("Write initiatorTokenId failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write initiatorTokenId failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int error = SendTransactCmd(UriPermMgrCmd::ON_BATCH_GRANT_URI_PERMISSION, data, reply, option);
|
||||
if (error != ERR_OK) {
|
||||
HILOG_ERROR("SendRequest fial, error: %{public}d", error);
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "SendRequest fial, error: %{public}d", error);
|
||||
return INNER_ERR;
|
||||
}
|
||||
return reply.ReadInt32();
|
||||
@@ -114,47 +115,47 @@ int UriPermissionManagerProxy::GrantUriPermission(const std::vector<Uri> &uriVec
|
||||
int UriPermissionManagerProxy::GrantUriPermissionFor2In1(const std::vector<Uri> &uriVec, unsigned int flag,
|
||||
const std::string &targetBundleName, int32_t appIndex, bool isSystemAppCall)
|
||||
{
|
||||
HILOG_DEBUG("Called.");
|
||||
TAG_LOGD(AAFwkTag::URIPERMMGR, "Called.");
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(IUriPermissionManager::GetDescriptor())) {
|
||||
HILOG_ERROR("Write interface token failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write interface token failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (uriVec.size() > MAX_URI_COUNT) {
|
||||
HILOG_ERROR("Exceeded maximum uri count.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Exceeded maximum uri count.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteUint32(uriVec.size())) {
|
||||
HILOG_ERROR("Write size of uriVec failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write size of uriVec failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
for (const auto &uri : uriVec) {
|
||||
if (!data.WriteParcelable(&uri)) {
|
||||
HILOG_ERROR("Write uri failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write uri failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
}
|
||||
if (!data.WriteInt32(flag)) {
|
||||
HILOG_ERROR("Write flag failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write flag failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteString(targetBundleName)) {
|
||||
HILOG_ERROR("Write targetBundleName failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write targetBundleName failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteInt32(appIndex)) {
|
||||
HILOG_ERROR("Write appIndex failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write appIndex failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteBool(isSystemAppCall)) {
|
||||
HILOG_ERROR("Write isSystemAppCall failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write isSystemAppCall failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int error = SendTransactCmd(UriPermMgrCmd::ON_BATCH_GRANT_URI_PERMISSION_FOR_2_IN_1, data, reply, option);
|
||||
if (error != ERR_OK) {
|
||||
HILOG_ERROR("SendRequest fial, error: %{public}d", error);
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "SendRequest fial, error: %{public}d", error);
|
||||
return INNER_ERR;
|
||||
}
|
||||
return reply.ReadInt32();
|
||||
@@ -162,41 +163,41 @@ int UriPermissionManagerProxy::GrantUriPermissionFor2In1(const std::vector<Uri>
|
||||
|
||||
void UriPermissionManagerProxy::RevokeUriPermission(const Security::AccessToken::AccessTokenID tokenId)
|
||||
{
|
||||
HILOG_DEBUG("UriPermissionManagerProxy::RevokeUriPermission is called.");
|
||||
TAG_LOGD(AAFwkTag::URIPERMMGR, "UriPermissionManagerProxy::RevokeUriPermission is called.");
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(IUriPermissionManager::GetDescriptor())) {
|
||||
HILOG_ERROR("Write interface token failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write interface token failed.");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteInt32(tokenId)) {
|
||||
HILOG_ERROR("Write AccessTokenID failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write AccessTokenID failed.");
|
||||
return;
|
||||
}
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int error = SendTransactCmd(UriPermMgrCmd::ON_REVOKE_URI_PERMISSION, data, reply, option);
|
||||
if (error != ERR_OK) {
|
||||
HILOG_ERROR("SendRequest fail, error: %{public}d", error);
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "SendRequest fail, error: %{public}d", error);
|
||||
}
|
||||
}
|
||||
|
||||
int UriPermissionManagerProxy::RevokeAllUriPermissions(const Security::AccessToken::AccessTokenID tokenId)
|
||||
{
|
||||
HILOG_DEBUG("UriPermissionManagerProxy::RevokeAllUriPermissions is called.");
|
||||
TAG_LOGD(AAFwkTag::URIPERMMGR, "UriPermissionManagerProxy::RevokeAllUriPermissions is called.");
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(IUriPermissionManager::GetDescriptor())) {
|
||||
HILOG_ERROR("Write interface token failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write interface token failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteInt32(tokenId)) {
|
||||
HILOG_ERROR("Write AccessTokenID failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write AccessTokenID failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int error = SendTransactCmd(UriPermMgrCmd::ON_REVOKE_ALL_URI_PERMISSION, data, reply, option);
|
||||
if (error != ERR_OK) {
|
||||
HILOG_ERROR("SendRequest fail, error: %{public}d", error);
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "SendRequest fail, error: %{public}d", error);
|
||||
return INNER_ERR;
|
||||
}
|
||||
return ERR_OK;
|
||||
@@ -204,25 +205,25 @@ int UriPermissionManagerProxy::RevokeAllUriPermissions(const Security::AccessTok
|
||||
|
||||
int UriPermissionManagerProxy::RevokeUriPermissionManually(const Uri &uri, const std::string bundleName)
|
||||
{
|
||||
HILOG_DEBUG("UriPermissionManagerProxy::RevokeUriPermissionManually is called.");
|
||||
TAG_LOGD(AAFwkTag::URIPERMMGR, "UriPermissionManagerProxy::RevokeUriPermissionManually is called.");
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(IUriPermissionManager::GetDescriptor())) {
|
||||
HILOG_ERROR("Write interface token failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write interface token failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteParcelable(&uri)) {
|
||||
HILOG_ERROR("Write uri failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write uri failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteString(bundleName)) {
|
||||
HILOG_ERROR("Write bundleName failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write bundleName failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int error = SendTransactCmd(UriPermMgrCmd::ON_REVOKE_URI_PERMISSION_MANUALLY, data, reply, option);
|
||||
if (error != ERR_OK) {
|
||||
HILOG_ERROR("SendRequest fail, error: %{public}d", error);
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "SendRequest fail, error: %{public}d", error);
|
||||
return INNER_ERR;
|
||||
}
|
||||
return reply.ReadInt32();
|
||||
@@ -230,29 +231,29 @@ int UriPermissionManagerProxy::RevokeUriPermissionManually(const Uri &uri, const
|
||||
|
||||
bool UriPermissionManagerProxy::VerifyUriPermission(const Uri& uri, uint32_t flag, uint32_t tokenId)
|
||||
{
|
||||
HILOG_DEBUG("UriPermissionManagerProxy::VerifyUriPermission is called.");
|
||||
TAG_LOGD(AAFwkTag::URIPERMMGR, "UriPermissionManagerProxy::VerifyUriPermission is called.");
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(IUriPermissionManager::GetDescriptor())) {
|
||||
HILOG_ERROR("Write interface token failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write interface token failed.");
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteParcelable(&uri)) {
|
||||
HILOG_ERROR("Write uri failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write uri failed.");
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(flag)) {
|
||||
HILOG_ERROR("Write flag failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write flag failed.");
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(tokenId)) {
|
||||
HILOG_ERROR("Write tokenId failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write tokenId failed.");
|
||||
return false;
|
||||
}
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int error = SendTransactCmd(UriPermMgrCmd::ON_VERIFY_URI_PERMISSION, data, reply, option);
|
||||
if (error != ERR_OK) {
|
||||
HILOG_ERROR("SendRequest fail, error: %{public}d", error);
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "SendRequest fail, error: %{public}d", error);
|
||||
return false;
|
||||
}
|
||||
return reply.ReadBool();
|
||||
@@ -260,21 +261,21 @@ bool UriPermissionManagerProxy::VerifyUriPermission(const Uri& uri, uint32_t fla
|
||||
|
||||
bool UriPermissionManagerProxy::IsAuthorizationUriAllowed(uint32_t fromTokenId)
|
||||
{
|
||||
HILOG_DEBUG("UriPermissionManagerProxy::IsAuthorizationUriAllowed is called.");
|
||||
TAG_LOGD(AAFwkTag::URIPERMMGR, "UriPermissionManagerProxy::IsAuthorizationUriAllowed is called.");
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(IUriPermissionManager::GetDescriptor())) {
|
||||
HILOG_ERROR("Write interface token failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write interface token failed.");
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(fromTokenId)) {
|
||||
HILOG_ERROR("Write fromTokenId failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Write fromTokenId failed.");
|
||||
return false;
|
||||
}
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
int error = SendTransactCmd(UriPermMgrCmd::ON_IS_Authorization_URI_ALLOWED, data, reply, option);
|
||||
if (error != ERR_OK) {
|
||||
HILOG_ERROR("SendRequest fail, error: %{public}d", error);
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "SendRequest fail, error: %{public}d", error);
|
||||
return false;
|
||||
}
|
||||
return reply.ReadBool();
|
||||
@@ -285,13 +286,13 @@ int32_t UriPermissionManagerProxy::SendTransactCmd(uint32_t code, MessageParcel
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
HILOG_ERROR("remote object is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "remote object is nullptr.");
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
|
||||
int32_t ret = remote->SendRequest(code, data, reply, option);
|
||||
if (ret != NO_ERROR) {
|
||||
HILOG_ERROR("SendRequest failed. code is %{public}d, ret is %{public}d.", code, ret);
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "SendRequest failed. code is %{public}d, ret is %{public}d.", code, ret);
|
||||
return ret;
|
||||
}
|
||||
return NO_ERROR;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "uri_permission_manager_stub.h"
|
||||
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
@@ -26,7 +27,7 @@ int UriPermissionManagerStub::OnRemoteRequest(
|
||||
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
if (data.ReadInterfaceToken() != IUriPermissionManager::GetDescriptor()) {
|
||||
HILOG_ERROR("InterfaceToken not equal IUriPermissionManager's descriptor.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "InterfaceToken not equal IUriPermissionManager's descriptor.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
ErrCode errCode = ERR_OK;
|
||||
@@ -80,7 +81,7 @@ int UriPermissionManagerStub::HandleGrantUriPermission(MessageParcel &data, Mess
|
||||
{
|
||||
std::unique_ptr<Uri> uri(data.ReadParcelable<Uri>());
|
||||
if (!uri) {
|
||||
HILOG_ERROR("To read uri failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "To read uri failed.");
|
||||
return ERR_DEAD_OBJECT;
|
||||
}
|
||||
auto flag = data.ReadInt32();
|
||||
@@ -96,14 +97,14 @@ int UriPermissionManagerStub::HandleBatchGrantUriPermission(MessageParcel &data,
|
||||
{
|
||||
auto size = data.ReadUint32();
|
||||
if (size <= 0 || size > MAX_URI_COUNT) {
|
||||
HILOG_ERROR("size is invalid.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "size is invalid.");
|
||||
return ERR_DEAD_OBJECT;
|
||||
}
|
||||
std::vector<Uri> uriVec;
|
||||
for (uint32_t i = 0; i < size; i++) {
|
||||
std::unique_ptr<Uri> uri(data.ReadParcelable<Uri>());
|
||||
if (!uri) {
|
||||
HILOG_ERROR("To read uri failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "To read uri failed.");
|
||||
return ERR_DEAD_OBJECT;
|
||||
}
|
||||
uriVec.emplace_back(*uri);
|
||||
@@ -121,7 +122,7 @@ int UriPermissionManagerStub::HandleRevokeUriPermissionManually(MessageParcel &d
|
||||
{
|
||||
std::unique_ptr<Uri> uri(data.ReadParcelable<Uri>());
|
||||
if (!uri) {
|
||||
HILOG_ERROR("To read uri failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "To read uri failed.");
|
||||
return ERR_DEAD_OBJECT;
|
||||
}
|
||||
auto bundleName = data.ReadString();
|
||||
@@ -134,7 +135,7 @@ int UriPermissionManagerStub::HandleVerifyUriPermission(MessageParcel &data, Mes
|
||||
{
|
||||
std::unique_ptr<Uri> uri(data.ReadParcelable<Uri>());
|
||||
if (!uri) {
|
||||
HILOG_ERROR("To read uri failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "To read uri failed.");
|
||||
return ERR_DEAD_OBJECT;
|
||||
}
|
||||
auto flag = data.ReadInt32();
|
||||
@@ -148,14 +149,14 @@ int UriPermissionManagerStub::HandleBatchGrantUriPermissionFor2In1(MessageParcel
|
||||
{
|
||||
auto size = data.ReadUint32();
|
||||
if (size == 0 || size > MAX_URI_COUNT) {
|
||||
HILOG_ERROR("size is invalid.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "size is invalid.");
|
||||
return ERR_DEAD_OBJECT;
|
||||
}
|
||||
std::vector<Uri> uriVec;
|
||||
for (uint32_t i = 0; i < size; i++) {
|
||||
std::unique_ptr<Uri> uri(data.ReadParcelable<Uri>());
|
||||
if (uri == nullptr) {
|
||||
HILOG_ERROR("To read uri failed.");
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "To read uri failed.");
|
||||
return ERR_DEAD_OBJECT;
|
||||
}
|
||||
uriVec.emplace_back(*uri);
|
||||
|
||||
@@ -20,6 +20,7 @@ ohos_unittest("ability_foreground_state_observer_stub_test") {
|
||||
module_out_path = module_output_path
|
||||
|
||||
include_dirs = [
|
||||
"${ability_runtime_services_path}/common/include",
|
||||
"${ability_runtime_innerkits_path}/app_manager/include/appmgr/",
|
||||
"${ability_runtime_test_path}/unittest/ability_foreground_state_observer_stub_test/",
|
||||
"//foundation/filemanagement/user_file_service/utils/",
|
||||
|
||||
Reference in New Issue
Block a user