mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-12-04 05:22:25 +00:00
log
Signed-off-by: sodanotgreen <limengzheng@huawei.com>
This commit is contained in:
parent
f5be29f135
commit
d9d938633f
@ -1491,7 +1491,7 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
|
||||
options.lang = isCJApp ? AbilityRuntime::Runtime::Language::CJ : AbilityRuntime::Runtime::Language::JS;
|
||||
#endif
|
||||
if (applicationInfo_->appProvisionType == Constants::APP_PROVISION_TYPE_DEBUG) {
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Start Multi-Thread Mode: %{public}d.", appLaunchData.GetMultiThread());
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "Start Multi-Thread Mode: %{public}d", appLaunchData.GetMultiThread());
|
||||
options.isMultiThread = appLaunchData.GetMultiThread();
|
||||
}
|
||||
options.jitEnabled = appLaunchData.IsJITEnabled();
|
||||
|
@ -81,7 +81,7 @@ void ConnectServerManager::LoadConnectServerDebuggerSo()
|
||||
if (handlerConnectServerSo_ == nullptr) {
|
||||
handlerConnectServerSo_ = dlopen("libconnectserver_debugger.z.so", RTLD_LAZY);
|
||||
if (handlerConnectServerSo_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::StartConnectServer failed to open register library");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "failed to open register library");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -89,14 +89,14 @@ void ConnectServerManager::LoadConnectServerDebuggerSo()
|
||||
|
||||
void ConnectServerManager::StartConnectServer(const std::string& bundleName, int socketFd, bool isLocalAbstract)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "ConnectServerManager::StartConnectServer Start connect server");
|
||||
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
|
||||
LoadConnectServerDebuggerSo();
|
||||
bundleName_ = bundleName;
|
||||
if (isLocalAbstract) {
|
||||
auto startServer = reinterpret_cast<StartServer>(dlsym(handlerConnectServerSo_, "StartServer"));
|
||||
if (startServer == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::StartServer failed to find symbol 'StartServer'");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "failed to find symbol 'StartServer'");
|
||||
return;
|
||||
}
|
||||
startServer(bundleName_);
|
||||
@ -106,7 +106,7 @@ void ConnectServerManager::StartConnectServer(const std::string& bundleName, int
|
||||
reinterpret_cast<StartServerForSocketPair>(dlsym(handlerConnectServerSo_, "StartServerForSocketPair"));
|
||||
if (startServerForSocketPair == nullptr) {
|
||||
TAG_LOGE(
|
||||
AAFwkTag::JSRUNTIME, "ConnectServerManager::StartServerForSocketPair failed to find symbol 'StartServer'");
|
||||
AAFwkTag::JSRUNTIME, "failed to find symbol 'StartServer'");
|
||||
return;
|
||||
}
|
||||
startServerForSocketPair(socketFd);
|
||||
@ -114,16 +114,16 @@ void ConnectServerManager::StartConnectServer(const std::string& bundleName, int
|
||||
|
||||
void ConnectServerManager::StopConnectServer(bool isCloseSo)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "ConnectServerManager::StopConnectServer Stop connect server");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
if (handlerConnectServerSo_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::StopConnectServer handlerConnectServerSo_ is nullptr");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "handlerConnectServerSo_ is nullptr");
|
||||
return;
|
||||
}
|
||||
auto stopServer = reinterpret_cast<StopServer>(dlsym(handlerConnectServerSo_, "StopServer"));
|
||||
if (stopServer != nullptr) {
|
||||
stopServer(bundleName_);
|
||||
} else {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::StopConnectServer failed to find symbol 'StopServer'");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "failed to find symbol 'StopServer'");
|
||||
}
|
||||
if (isCloseSo) {
|
||||
dlclose(handlerConnectServerSo_);
|
||||
@ -139,7 +139,7 @@ bool ConnectServerManager::StoreInstanceMessage(int32_t tid, int32_t instanceId,
|
||||
auto result = instanceMap_.try_emplace(instanceId, std::make_pair(instanceName, tid));
|
||||
if (!result.second) {
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME,
|
||||
"ConnectServerManager::StoreInstanceMessage Instance %{public}d already added", instanceId);
|
||||
"Instance %{public}d already added", instanceId);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -155,7 +155,7 @@ void ConnectServerManager::StoreDebuggerInfo(int32_t tid, void* vm, const panda:
|
||||
}
|
||||
|
||||
if (!isConnected_) {
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME, "ConnectServerManager::StoreDebuggerInfo not Connected");
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME, "not Connected");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -195,7 +195,7 @@ void ConnectServerManager::SetConnectedCallback()
|
||||
dlsym(handlerConnectServerSo_, "SetConnectCallback"));
|
||||
if (setConnectCallBack == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME,
|
||||
"ConnectServerManager::SetConnectedCallback failed to find symbol 'SetConnectCallBack'");
|
||||
"failed to find symbol 'SetConnectCallBack'");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -206,20 +206,20 @@ void ConnectServerManager::SetConnectedCallback()
|
||||
|
||||
bool ConnectServerManager::SendInstanceMessage(int32_t tid, int32_t instanceId, const std::string& instanceName)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "ConnectServerManager::SendInstanceMessage Add instance to connect server");
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "called");
|
||||
LoadConnectServerDebuggerSo();
|
||||
|
||||
auto setSwitchCallBack = reinterpret_cast<SetSwitchCallBack>(
|
||||
dlsym(handlerConnectServerSo_, "SetSwitchCallBack"));
|
||||
if (setSwitchCallBack == nullptr) {
|
||||
TAG_LOGI(
|
||||
AAFwkTag::JSRUNTIME, "ConnectServerManager::SendInstanceMessage failed to find symbol 'setSwitchCallBack'");
|
||||
AAFwkTag::JSRUNTIME, "failed to find symbol 'setSwitchCallBack'");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
auto storeMessage = reinterpret_cast<StoreMessage>(dlsym(handlerConnectServerSo_, "StoreMessage"));
|
||||
if (storeMessage == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::SendInstanceMessage failed to find symbol 'StoreMessage'");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "failed to find symbol 'StoreMessage'");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -227,7 +227,7 @@ bool ConnectServerManager::SendInstanceMessage(int32_t tid, int32_t instanceId,
|
||||
dlsym(handlerConnectServerSo_, "SetProfilerCallback"));
|
||||
if (setProfilerCallback == nullptr) {
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME,
|
||||
"ConnectServerManager::SendInstanceMessage failed to find symbol 'setProfilerCallback'");
|
||||
"failed to find symbol 'setProfilerCallback'");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -236,32 +236,32 @@ bool ConnectServerManager::SendInstanceMessage(int32_t tid, int32_t instanceId,
|
||||
if (setStatus_ != nullptr) {
|
||||
setStatus_(status);
|
||||
} else {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::setStatus_ is nullptr");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "setStatus_ is nullptr");
|
||||
}
|
||||
},
|
||||
[this](int32_t containerId) {
|
||||
if (createLayoutInfo_ != nullptr) {
|
||||
createLayoutInfo_(containerId);
|
||||
} else {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::createLayoutInfo_ is nullptr");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "createLayoutInfo_ is nullptr");
|
||||
}
|
||||
}, instanceId);
|
||||
|
||||
|
||||
setProfilerCallback([this](bool status) {
|
||||
if (setArkUIStateProfilerStatus_ != nullptr) {
|
||||
setArkUIStateProfilerStatus_(status);
|
||||
} else {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::setArkUIStateProfilerStatus_ is nullptr");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "setArkUIStateProfilerStatus_ is nullptr");
|
||||
}
|
||||
});
|
||||
|
||||
std::string message = GetInstanceMapMessage("addInstance", instanceId, instanceName, tid);
|
||||
storeMessage(instanceId, message);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool ConnectServerManager::AddInstance(int32_t tid, int32_t instanceId, const std::string& instanceName)
|
||||
{
|
||||
{
|
||||
@ -269,23 +269,23 @@ bool ConnectServerManager::AddInstance(int32_t tid, int32_t instanceId, const st
|
||||
auto result = instanceMap_.try_emplace(instanceId, std::make_pair(instanceName, tid));
|
||||
if (!result.second) {
|
||||
TAG_LOGW(
|
||||
AAFwkTag::JSRUNTIME, "ConnectServerManager::AddInstance Instance %{public}d already added", instanceId);
|
||||
AAFwkTag::JSRUNTIME, "Instance %{public}d already added", instanceId);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isConnected_) {
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME, "ConnectServerManager::AddInstance not Connected");
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME, "not Connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "ConnectServerManager::AddInstance Add instance to connect server");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Add instance to connect server");
|
||||
LoadConnectServerDebuggerSo();
|
||||
|
||||
auto setSwitchCallBack = reinterpret_cast<SetSwitchCallBack>(
|
||||
dlsym(handlerConnectServerSo_, "SetSwitchCallBack"));
|
||||
if (setSwitchCallBack == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::AddInstance failed to find symbol 'setSwitchCallBack'");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "failed to find symbol 'setSwitchCallBack'");
|
||||
return false;
|
||||
}
|
||||
setSwitchCallBack(
|
||||
@ -293,14 +293,14 @@ bool ConnectServerManager::AddInstance(int32_t tid, int32_t instanceId, const st
|
||||
if (setStatus_ != nullptr) {
|
||||
setStatus_(status);
|
||||
} else {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::setStatus_ is nullptr");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "setStatus_ is nullptr");
|
||||
}
|
||||
},
|
||||
[this](int32_t containerId) {
|
||||
if (createLayoutInfo_ != nullptr) {
|
||||
createLayoutInfo_(containerId);
|
||||
} else {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::createLayoutInfo_ is nullptr");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "createLayoutInfo_ is nullptr");
|
||||
}
|
||||
}, instanceId);
|
||||
|
||||
@ -308,7 +308,7 @@ bool ConnectServerManager::AddInstance(int32_t tid, int32_t instanceId, const st
|
||||
dlsym(handlerConnectServerSo_, "SetProfilerCallback"));
|
||||
if (setProfilerCallback == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME,
|
||||
"ConnectServerManager::AddInstance failed to find symbol 'setProfilerCallback'");
|
||||
"failed to find symbol 'setProfilerCallback'");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -316,7 +316,7 @@ bool ConnectServerManager::AddInstance(int32_t tid, int32_t instanceId, const st
|
||||
if (setArkUIStateProfilerStatus_ != nullptr) {
|
||||
setArkUIStateProfilerStatus_(status);
|
||||
} else {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::setArkUIStateProfilerStatus_ is nullptr");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "setArkUIStateProfilerStatus_ is nullptr");
|
||||
}
|
||||
});
|
||||
|
||||
@ -325,7 +325,7 @@ bool ConnectServerManager::AddInstance(int32_t tid, int32_t instanceId, const st
|
||||
|
||||
auto storeMessage = reinterpret_cast<StoreMessage>(dlsym(handlerConnectServerSo_, "StoreMessage"));
|
||||
if (storeMessage == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::AddInstance failed to find symbol 'StoreMessage'");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "failed to find symbol 'StoreMessage'");
|
||||
return false;
|
||||
}
|
||||
storeMessage(instanceId, message);
|
||||
@ -333,7 +333,7 @@ bool ConnectServerManager::AddInstance(int32_t tid, int32_t instanceId, const st
|
||||
// WaitForConnection() means the connection state of the connect server
|
||||
auto sendMessage = reinterpret_cast<SendMessage>(dlsym(handlerConnectServerSo_, "SendMessage"));
|
||||
if (sendMessage == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::AddInstance failed to find symbol 'SendMessage'");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "failed to find symbol 'SendMessage'");
|
||||
return false;
|
||||
}
|
||||
// if connected, message will be sent immediately.
|
||||
@ -343,7 +343,7 @@ bool ConnectServerManager::AddInstance(int32_t tid, int32_t instanceId, const st
|
||||
|
||||
void ConnectServerManager::RemoveInstance(int32_t instanceId)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "ConnectServerManager::RemoveInstance Remove instance to connect server");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
std::string instanceName;
|
||||
int32_t tid;
|
||||
|
||||
@ -351,7 +351,7 @@ void ConnectServerManager::RemoveInstance(int32_t instanceId)
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
auto it = instanceMap_.find(instanceId);
|
||||
if (it == instanceMap_.end()) {
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME, "ConnectServerManager::RemoveInstance Instance %{public}d is not found",
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME, "Instance %{public}d is not found",
|
||||
instanceId);
|
||||
return;
|
||||
}
|
||||
@ -362,14 +362,14 @@ void ConnectServerManager::RemoveInstance(int32_t instanceId)
|
||||
}
|
||||
|
||||
if (!isConnected_) {
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME, "ConnectServerManager::RemoveInstance not Connected");
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME, "not Connected");
|
||||
return;
|
||||
}
|
||||
|
||||
LoadConnectServerDebuggerSo();
|
||||
auto waitForConnection = reinterpret_cast<WaitForConnection>(dlsym(handlerConnectServerSo_, "WaitForConnection"));
|
||||
if (waitForConnection == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::RemoveInstance failed to find symbol 'WaitForConnection'");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "failed to find symbol 'WaitForConnection'");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -378,7 +378,7 @@ void ConnectServerManager::RemoveInstance(int32_t instanceId)
|
||||
|
||||
auto removeMessage = reinterpret_cast<RemoveMessage>(dlsym(handlerConnectServerSo_, "RemoveMessage"));
|
||||
if (removeMessage == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::RemoveInstance failed to find symbol 'RemoveMessage'");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "failed to find symbol 'RemoveMessage'");
|
||||
return;
|
||||
}
|
||||
removeMessage(instanceId);
|
||||
@ -389,7 +389,7 @@ void ConnectServerManager::RemoveInstance(int32_t instanceId)
|
||||
|
||||
auto sendMessage = reinterpret_cast<SendMessage>(dlsym(handlerConnectServerSo_, "SendMessage"));
|
||||
if (sendMessage == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::RemoveInstance failed to find symbol 'SendMessage'");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "failed to find symbol 'SendMessage'");
|
||||
return;
|
||||
}
|
||||
sendMessage(message);
|
||||
@ -397,10 +397,10 @@ void ConnectServerManager::RemoveInstance(int32_t instanceId)
|
||||
|
||||
void ConnectServerManager::SendInspector(const std::string& jsonTreeStr, const std::string& jsonSnapshotStr)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "ConnectServerManager SendInspector Start");
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "called");
|
||||
auto sendLayoutMessage = reinterpret_cast<SendMessage>(dlsym(handlerConnectServerSo_, "SendLayoutMessage"));
|
||||
if (sendLayoutMessage == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::AddInstance failed to find symbol 'sendLayoutMessage'");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "failed to find symbol 'sendLayoutMessage'");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -409,7 +409,7 @@ void ConnectServerManager::SendInspector(const std::string& jsonTreeStr, const s
|
||||
auto storeInspectorInfo = reinterpret_cast<StoreInspectorInfo>(
|
||||
dlsym(handlerConnectServerSo_, "StoreInspectorInfo"));
|
||||
if (storeInspectorInfo == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "ConnectServerManager::AddInstance failed to find symbol 'StoreInspectorInfo'");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "failed to find symbol 'StoreInspectorInfo'");
|
||||
return;
|
||||
}
|
||||
storeInspectorInfo(jsonTreeStr, jsonSnapshotStr);
|
||||
@ -434,11 +434,11 @@ void ConnectServerManager::SetStateProfilerCallback(const std::function<void(boo
|
||||
|
||||
void ConnectServerManager::SendArkUIStateProfilerMessage(const std::string &message)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "ConnectServerManager SendArkUIStateProfilerMessage Start");
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "called");
|
||||
auto sendProfilerMessage = reinterpret_cast<SendMessage>(dlsym(handlerConnectServerSo_, "SendProfilerMessage"));
|
||||
if (sendProfilerMessage == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME,
|
||||
"ConnectServerManager::SendArkUIStateProfilerMessage failed to find symbol 'sendProfilerMessage'");
|
||||
"failed to find symbol 'sendProfilerMessage'");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -449,7 +449,7 @@ DebuggerPostTask ConnectServerManager::GetDebuggerPostTask(int32_t tid)
|
||||
{
|
||||
auto it = g_debuggerInfo.find(tid);
|
||||
if (it == g_debuggerInfo.end()) {
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME, "ConnectServerManager::GetDebuggerPostTask tid %{public}d is not found: ", tid);
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME, "tid %{public}d is not found: ", tid);
|
||||
return nullptr;
|
||||
}
|
||||
return it->second.second;
|
||||
|
@ -40,38 +40,38 @@ HdcRegister& HdcRegister::Get()
|
||||
void HdcRegister::StartHdcRegister(const std::string& bundleName, const std::string& processName, bool debugApp,
|
||||
HdcRegisterCallback callback)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "HdcRegister::StartHdcRegister begin");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "begin");
|
||||
|
||||
registerHandler_ = dlopen("libhdc_register.z.so", RTLD_LAZY);
|
||||
if (registerHandler_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "HdcRegister::StartHdcRegister failed to open register library");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "failed to open register library");
|
||||
return;
|
||||
}
|
||||
auto startRegister = reinterpret_cast<StartRegister>(dlsym(registerHandler_, "StartConnect"));
|
||||
if (startRegister == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "HdcRegister::StartHdcRegister failed to find symbol 'StartConnect'");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "failed to find symbol 'StartConnect'");
|
||||
return;
|
||||
}
|
||||
startRegister(processName, bundleName, debugApp, callback);
|
||||
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "HdcRegister::StartHdcRegister end");
|
||||
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "end");
|
||||
}
|
||||
|
||||
void HdcRegister::StopHdcRegister()
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "HdcRegister::StopHdcRegister begin");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "begin");
|
||||
if (registerHandler_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "HdcRegister::StopHdcRegister registerHandler_ is nullptr");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "registerHandler_ is nullptr");
|
||||
return;
|
||||
}
|
||||
auto stopRegister = reinterpret_cast<StopRegister>(dlsym(registerHandler_, "StopConnect"));
|
||||
if (stopRegister != nullptr) {
|
||||
stopRegister();
|
||||
} else {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "HdcRegister::StopHdcRegister failed to find symbol 'StopConnect'");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "failed to find symbol 'StopConnect'");
|
||||
}
|
||||
dlclose(registerHandler_);
|
||||
registerHandler_ = nullptr;
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "HdcRegister::StopHdcRegister end");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "end");
|
||||
}
|
||||
} // namespace OHOS::AbilityRuntime
|
||||
|
@ -30,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) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "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()));
|
||||
@ -49,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) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Create object failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Create object failed");
|
||||
return nullptr;
|
||||
}
|
||||
AppExecFwk::CommonFunc::ConvertAbilityInfo(env, abilityInfo, object);
|
||||
@ -61,7 +61,7 @@ napi_value CreateJsApplicationInfo(napi_env env, const AppExecFwk::ApplicationIn
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
if (object == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Create object failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Create object failed");
|
||||
return nullptr;
|
||||
}
|
||||
AppExecFwk::CommonFunc::ConvertApplicationInfo(env, object, applicationInfo);
|
||||
@ -73,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) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "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));
|
||||
@ -87,7 +87,7 @@ napi_value CreateJsConfiguration(napi_env env, const AppExecFwk::Configuration&
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
if (object == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Native object is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Native object is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ napi_value CreateJsConfiguration(napi_env env, const AppExecFwk::Configuration&
|
||||
configuration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE)));
|
||||
napi_set_named_property(env, object, "colorMode", CreateJsValue(env,
|
||||
ConvertColorMode(configuration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE))));
|
||||
|
||||
|
||||
napi_set_named_property(env, object, "time24", CreateJsValue(env,
|
||||
ConvertTimeFormat(configuration.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_HOUR))));
|
||||
|
||||
@ -123,11 +123,11 @@ napi_value CreateJsConfiguration(napi_env env, const AppExecFwk::Configuration&
|
||||
|
||||
napi_value CreateJsExtensionAbilityInfo(napi_env env, const AppExecFwk::ExtensionAbilityInfo& info)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "CreateJsExtensionAbilityInfo begin");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
if (object == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Create object failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Create object failed");
|
||||
return nullptr;
|
||||
}
|
||||
AppExecFwk::CommonFunc::ConvertExtensionInfo(env, info, object);
|
||||
@ -139,7 +139,7 @@ napi_value CreateJsHapModuleInfo(napi_env env, const AppExecFwk::HapModuleInfo&
|
||||
napi_value object = nullptr;
|
||||
napi_create_object(env, &object);
|
||||
if (object == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Create object failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Create object failed");
|
||||
return nullptr;
|
||||
}
|
||||
AppExecFwk::CommonFunc::ConvertHapModuleInfo(env, hapModuleInfo, object);
|
||||
|
@ -135,13 +135,13 @@ std::string JsModuleReader::GetOtherHspPath(const std::string& bundleName, const
|
||||
|
||||
auto bundleMgrHelper = DelayedSingleton<AppExecFwk::BundleMgrHelper>::GetInstance();
|
||||
if (bundleMgrHelper == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "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) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "GetBaseSharedBundleInfos failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "GetBaseSharedBundleInfos failed");
|
||||
return presetAppHapPath;
|
||||
}
|
||||
std::string tmpPath = inputPath.substr(inputPath.find_first_of("/") + 1);
|
||||
@ -156,7 +156,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) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "GetDependentBundleInfo failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "GetDependentBundleInfo failed");
|
||||
return presetAppHapPath;
|
||||
}
|
||||
for (const auto &info : bundleInfo.hapModuleInfos) {
|
||||
@ -173,12 +173,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()) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Failed to obtain moduleName.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Failed to obtain moduleName");
|
||||
return presetAppHapPath;
|
||||
}
|
||||
auto bundleMgrHelper = DelayedSingleton<AppExecFwk::BundleMgrHelper>::GetInstance();
|
||||
if (bundleMgrHelper == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "The bundleMgrHelper is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "The bundleMgrHelper is nullptr");
|
||||
return presetAppHapPath;
|
||||
}
|
||||
if (inputPath.find_first_of("/") == inputPath.find_last_of("/")) {
|
||||
@ -186,7 +186,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()) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "GetBundleInfoForSelf failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "GetBundleInfoForSelf failed");
|
||||
return presetAppHapPath;
|
||||
}
|
||||
for (auto hapModuleInfo : bundleInfo.hapModuleInfos) {
|
||||
@ -205,12 +205,12 @@ void JsModuleReader::GetHapPathList(const std::string &bundleName, std::vector<s
|
||||
{
|
||||
auto systemAbilityManagerClient = OHOS::SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (!systemAbilityManagerClient) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "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) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "fail to get bundle manager proxy.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "fail to get bundle manager proxy");
|
||||
return;
|
||||
}
|
||||
auto bundleMgrProxy = iface_cast<IBundleMgr>(remoteObject);
|
||||
@ -218,7 +218,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()) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "GetBundleInfoForSelf failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "GetBundleInfoForSelf failed");
|
||||
return;
|
||||
}
|
||||
for (auto hapModuleInfo : bundleInfo.hapModuleInfos) {
|
||||
|
@ -33,7 +33,7 @@ bool JsQuickfixCallback::operator()(std::string baseFileName, std::string &patch
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "baseFileName: %{private}s", baseFileName.c_str());
|
||||
auto position = baseFileName.find(".abc");
|
||||
if (position == std::string::npos) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "invalid baseFileName!");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "invalid baseFileName position is npos");
|
||||
return false;
|
||||
}
|
||||
int baseFileNameLen = static_cast<int>(baseFileName.length());
|
||||
@ -41,7 +41,7 @@ bool JsQuickfixCallback::operator()(std::string baseFileName, std::string &patch
|
||||
int suffixLen = strlen(MERGE_ABC_PATH);
|
||||
int moduleLen = baseFileNameLen - prefixLen - suffixLen;
|
||||
if (moduleLen < 0) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "invalid baseFileName!");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "invalid baseFileName moduleLen < 0");
|
||||
return false;
|
||||
}
|
||||
std::string moduleName = baseFileName.substr(prefixLen, moduleLen);
|
||||
|
@ -119,7 +119,7 @@ static auto PermissionCheckFunc = []() {
|
||||
napi_value CanIUse(napi_env env, napi_callback_info info)
|
||||
{
|
||||
if (env == nullptr || info == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "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);
|
||||
@ -128,14 +128,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) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "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) {
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "%{public}s called. Params is invalid.", __func__);
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "Params is invalid");
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@ -169,7 +169,7 @@ napi_status CreateNapiEnv(napi_env *env)
|
||||
}
|
||||
auto options = JsRuntime::GetChildOptions();
|
||||
if (options == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "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;
|
||||
@ -207,7 +207,7 @@ std::shared_ptr<Runtime::Options> JsRuntime::childOptions_ = nullptr;
|
||||
std::mutex childOptionsMutex_;
|
||||
JsRuntime::JsRuntime()
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "JsRuntime costructor.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "JsRuntime costructor");
|
||||
}
|
||||
|
||||
JsRuntime::~JsRuntime()
|
||||
@ -267,7 +267,7 @@ void JsRuntime::StartDebugMode(const DebugOption dOption)
|
||||
std::string inputProcessName = bundleName_ != dOption.processName ? dOption.processName : "";
|
||||
HdcRegister::Get().StartHdcRegister(bundleName_, inputProcessName, isDebugApp, [bundleName,
|
||||
isStartWithDebug, instanceId, weak, isDebugApp] (int socketFd, std::string option) {
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "HdcRegister msg, fd= %{public}d, option= %{public}s.",
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "HdcRegister msg, fd= %{public}d, option= %{public}s",
|
||||
socketFd, option.c_str());
|
||||
if (weak == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv is nullptr in hdc register callback");
|
||||
@ -317,7 +317,7 @@ void JsRuntime::InitConsoleModule()
|
||||
|
||||
bool JsRuntime::StartDebugger(bool needBreakPoint, uint32_t instanceId)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "StartDebugger called.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -367,7 +367,7 @@ int32_t JsRuntime::JsperfProfilerCommandParse(const std::string &command, int32_
|
||||
std::string interval;
|
||||
constexpr size_t matchNumResultIndex = 1;
|
||||
if (jsperfMatchResults.size() < PARAM_TWO) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "no results need to be matched");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "no jsperfMatchResults need to be matched");
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@ -396,7 +396,7 @@ void JsRuntime::StartProfiler(const DebugOption dOption)
|
||||
std::string inputProcessName = bundleName_ != dOption.processName ? dOption.processName : "";
|
||||
HdcRegister::Get().StartHdcRegister(bundleName_, inputProcessName, isDebugApp,
|
||||
[bundleName, isStartWithDebug, instanceId, weak, isDebugApp](int socketFd, std::string option) {
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "HdcRegister msg, fd= %{public}d, option= %{public}s.", socketFd, option.c_str());
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "HdcRegister msg, fd= %{public}d, option= %{public}s", socketFd, option.c_str());
|
||||
if (weak == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv is nullptr in hdc register callback");
|
||||
return;
|
||||
@ -431,7 +431,7 @@ void JsRuntime::StartProfiler(const DebugOption dOption)
|
||||
auto dTask = jsEnv_->GetDebuggerPostTask();
|
||||
panda::JSNApi::DebugOption option = {ARK_DEBUGGER_LIB_PATH, isDebugApp ? isStartWithDebug : false};
|
||||
ConnectServerManager::Get().StoreDebuggerInfo(getproctid(), reinterpret_cast<void*>(vm), option, dTask, isDebugApp);
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "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, getproctid(), isDebugApp);
|
||||
}
|
||||
|
||||
@ -440,7 +440,7 @@ bool JsRuntime::GetFileBuffer(const std::string& filePath, std::string& fileFull
|
||||
{
|
||||
Extractor extractor(filePath);
|
||||
if (!extractor.Init()) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "GetFileBuffer, Extractor of %{private}s init failed.", filePath.c_str());
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Extractor of %{private}s init failed", filePath.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -452,7 +452,7 @@ bool JsRuntime::GetFileBuffer(const std::string& filePath, std::string& fileFull
|
||||
}
|
||||
if (fileNames.empty()) {
|
||||
TAG_LOGW(
|
||||
AAFwkTag::JSRUNTIME, "GetFileBuffer, There's no abc file in hap or hqf %{private}s.", filePath.c_str());
|
||||
AAFwkTag::JSRUNTIME, "There's no abc file in hap or hqf %{private}s", filePath.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -460,7 +460,7 @@ bool JsRuntime::GetFileBuffer(const std::string& filePath, std::string& fileFull
|
||||
fileFullName = filePath + "/" + fileName;
|
||||
std::ostringstream outStream;
|
||||
if (!extractor.ExtractByName(fileName, outStream)) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "GetFileBuffer, Extract %{public}s failed.", fileFullName.c_str());
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Extract %{public}s failed", fileFullName.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -471,7 +471,7 @@ bool JsRuntime::GetFileBuffer(const std::string& filePath, std::string& fileFull
|
||||
|
||||
bool JsRuntime::LoadRepairPatch(const std::string& hqfFile, const std::string& hapPath)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "LoadRepairPatch function called.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
auto vm = GetEcmaVm();
|
||||
CHECK_POINTER_AND_RETURN(vm, false);
|
||||
|
||||
@ -480,14 +480,14 @@ bool JsRuntime::LoadRepairPatch(const std::string& hqfFile, const std::string& h
|
||||
std::string patchFile;
|
||||
std::vector<uint8_t> patchBuffer;
|
||||
if (!GetFileBuffer(hqfFile, patchFile, patchBuffer)) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "LoadRepairPatch, get patch file buffer failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "get patch file buffer failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string baseFile;
|
||||
std::vector<uint8_t> baseBuffer;
|
||||
if (!GetFileBuffer(hapPath, baseFile, baseBuffer)) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "LoadRepairPatch, get base file buffer failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "get base file buffer failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -502,46 +502,46 @@ bool JsRuntime::LoadRepairPatch(const std::string& hqfFile, const std::string& h
|
||||
resolvedHapPath = hapPath.substr(0, hspPosition) + MERGE_ABC_PATH;
|
||||
}
|
||||
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "LoadRepairPatch, LoadPatch, patchFile: %{private}s, baseFile: %{private}s.",
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "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) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "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;
|
||||
}
|
||||
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "LoadRepairPatch, Load patch %{private}s succeed.", patchFile.c_str());
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Load patch %{private}s succeed", patchFile.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JsRuntime::UnLoadRepairPatch(const std::string& hqfFile)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "UnLoadRepairPatch function called.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
auto vm = GetEcmaVm();
|
||||
CHECK_POINTER_AND_RETURN(vm, false);
|
||||
|
||||
Extractor extractor(hqfFile);
|
||||
if (!extractor.Init()) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "UnLoadRepairPatch, Extractor of %{private}s init failed.", hqfFile.c_str());
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Extractor of %{private}s init failed", hqfFile.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string> fileNames;
|
||||
extractor.GetSpecifiedTypeFiles(fileNames, ".abc");
|
||||
if (fileNames.empty()) {
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME, "UnLoadRepairPatch, There's no abc file in hqf %{private}s.", hqfFile.c_str());
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME, "There's no abc file in hqf %{private}s", hqfFile.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
for (const auto &fileName : fileNames) {
|
||||
std::string patchFile = hqfFile + "/" + fileName;
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "UnLoadRepairPatch, UnloadPatch, patchFile: %{private}s.", patchFile.c_str());
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "UnloadPatch, patchFile: %{private}s", patchFile.c_str());
|
||||
auto ret = panda::JSNApi::UnloadPatch(vm, patchFile);
|
||||
if (ret != panda::JSNApi::PatchErrorCode::SUCCESS) {
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME, "UnLoadPatch failed with %{public}d.", static_cast<int32_t>(ret));
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME, "UnLoadPatch failed with %{public}d", static_cast<int32_t>(ret));
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "UnLoadRepairPatch, UnLoad patch %{private}s succeed.", patchFile.c_str());
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "UnLoad patch %{private}s succeed", patchFile.c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -549,7 +549,7 @@ bool JsRuntime::UnLoadRepairPatch(const std::string& hqfFile)
|
||||
|
||||
bool JsRuntime::NotifyHotReloadPage()
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "function called.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
#ifdef SUPPORT_SCREEN
|
||||
Ace::HotReloader::HotReload();
|
||||
#endif // SUPPORT_SCREEN
|
||||
@ -558,14 +558,14 @@ bool JsRuntime::NotifyHotReloadPage()
|
||||
|
||||
bool JsRuntime::LoadScript(const std::string& path, std::vector<uint8_t>* buffer, bool isBundle)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Load script, path: %{private}s.", path.c_str());
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "path: %{private}s", path.c_str());
|
||||
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)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Load script, path: %{private}s.", path.c_str());
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "path: %{private}s", path.c_str());
|
||||
CHECK_POINTER_AND_RETURN(jsEnv_, false);
|
||||
return jsEnv_->LoadScript(path, buffer, len, isBundle);
|
||||
}
|
||||
@ -573,9 +573,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)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "JsRuntime::LoadSystemModule(%{public}s)", moduleName.c_str());
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "ModuleName %{public}s", moduleName.c_str());
|
||||
if (env == nullptr) {
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "JsRuntime::LoadSystemModule: invalid engine.");
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "invalid engine");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -631,7 +631,7 @@ void JsRuntime::PostPreload(const Options& options)
|
||||
postOption.SetAnDir(sandBoxAnFilePath);
|
||||
}
|
||||
if (options.isMultiThread) {
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Start Multi-Thread Mode: %{public}d.", options.isMultiThread);
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Start Multi-Thread Mode: %{public}d", options.isMultiThread);
|
||||
panda::JSNApi::SetMultiThreadCheck();
|
||||
}
|
||||
bool profileEnabled = OHOS::system::GetBoolParameter("ark.profile", false);
|
||||
@ -671,14 +671,14 @@ bool JsRuntime::Initialize(const Options& options)
|
||||
#endif
|
||||
if (!preloaded_) {
|
||||
if (!CreateJsEnv(options)) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Create js environment failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Create js environment failed");
|
||||
return false;
|
||||
}
|
||||
NativeCreateEnv::RegCreateNapiEnvCallback(CreateNapiEnv);
|
||||
NativeCreateEnv::RegDestroyNapiEnvCallback(DestroyNapiEnv);
|
||||
}
|
||||
apiTargetVersion_ = options.apiTargetVersion;
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Initialize: %{public}d.", apiTargetVersion_);
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Initialize: %{public}d", apiTargetVersion_);
|
||||
bool isModular = false;
|
||||
if (IsUseAbilityRuntime(options)) {
|
||||
auto env = GetNapiEnv();
|
||||
@ -715,9 +715,9 @@ bool JsRuntime::Initialize(const Options& options)
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Failed to create reference for global.requireNapi");
|
||||
return false;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "PreloadAce start.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "PreloadAce start");
|
||||
PreloadAce(options);
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "PreloadAce end.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "PreloadAce end");
|
||||
nativeEngine->RegisterPermissionCheck(PermissionCheckFunc);
|
||||
}
|
||||
|
||||
@ -773,7 +773,7 @@ bool JsRuntime::Initialize(const Options& options)
|
||||
SetRequestAotCallback();
|
||||
|
||||
if (!InitLoop(options.isStageModel)) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Initialize loop failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Initialize loop failed");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -795,7 +795,7 @@ bool JsRuntime::CreateJsEnv(const Options& options)
|
||||
pandaOption.SetMemConfigProperty(memConfigProperty);
|
||||
pandaOption.SetGcThreadNum(gcThreadNum);
|
||||
pandaOption.SetLongPauseTime(longPauseTime);
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "JSRuntime::Initialize ark properties = %{public}d bundlename = %{public}s",
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "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);
|
||||
@ -810,7 +810,7 @@ bool JsRuntime::CreateJsEnv(const Options& options)
|
||||
pandaOption.SetEnableJIT(options.jitEnabled);
|
||||
|
||||
if (options.isMultiThread) {
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Start Multi Thread Mode: %{public}d.", options.isMultiThread);
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Start Multi Thread Mode: %{public}d", options.isMultiThread);
|
||||
panda::JSNApi::SetMultiThreadCheck();
|
||||
}
|
||||
|
||||
@ -824,7 +824,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))) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Initialize js environment failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Initialize js environment failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -851,7 +851,7 @@ void JsRuntime::PreloadAce(const Options& options)
|
||||
|
||||
void JsRuntime::ReloadFormComponent()
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Call.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
auto nativeEngine = GetNativeEnginePointer();
|
||||
CHECK_POINTER(nativeEngine);
|
||||
// ArkTsCard update condition, need to reload new component
|
||||
@ -863,7 +863,7 @@ void JsRuntime::ReloadFormComponent()
|
||||
void JsRuntime::DoCleanWorkAfterStageCleaned()
|
||||
{
|
||||
// Force gc. If the jsRuntime is destroyed, this task should not be executed.
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "DoCleanWorkAfterStageCleaned begin");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
RemoveTask("ability_destruct_gc");
|
||||
auto gcTask = [this]() {
|
||||
panda::JSNApi::TriggerGC(GetEcmaVm(), panda::JSNApi::TRIGGER_GC_TYPE::FULL_GC);
|
||||
@ -879,16 +879,16 @@ bool JsRuntime::InitLoop(bool isStage)
|
||||
|
||||
void JsRuntime::SetAppLibPath(const AppLibPathMap& appLibPaths, const bool& isSystemApp)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Set library path.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Set library path");
|
||||
|
||||
if (appLibPaths.size() == 0) {
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME, "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) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Get module manager failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Get module manager failed");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -910,7 +910,7 @@ void JsRuntime::InitSourceMap(const std::string hqfFilePath)
|
||||
std::string patchSoureMapFile;
|
||||
std::vector<uint8_t> soureMapBuffer;
|
||||
if (!GetFileBuffer(hqfFilePath, patchSoureMapFile, soureMapBuffer, false)) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "InitSourceMap, get patchSoureMap file buffer failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "get patchSoureMap file buffer failed");
|
||||
return;
|
||||
}
|
||||
std::string str(soureMapBuffer.begin(), soureMapBuffer.end());
|
||||
@ -925,7 +925,7 @@ void JsRuntime::InitSourceMap(const std::string hqfFilePath)
|
||||
|
||||
void JsRuntime::Deinitialize()
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "JsRuntime deinitialize.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
for (auto it = modules_.begin(); it != modules_.end(); it = modules_.erase(it)) {
|
||||
delete it->second;
|
||||
it->second = nullptr;
|
||||
@ -1055,7 +1055,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)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "JsRuntime::LoadSystemModule(%{public}s)", moduleName.c_str());
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "SystemModule %{public}s", moduleName.c_str());
|
||||
napi_env env = GetNapiEnv();
|
||||
CHECK_POINTER_AND_RETURN(env, std::unique_ptr<NativeReference>());
|
||||
|
||||
@ -1116,14 +1116,14 @@ bool JsRuntime::RunScript(const std::string& srcPath, const std::string& hapPath
|
||||
if (!extractor->IsHapCompress(modulePath) && useSafeMempry) {
|
||||
auto safeData = extractor->GetSafeData(modulePath);
|
||||
if (!safeData) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Get abc file failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Get safeData abc file failed");
|
||||
return false;
|
||||
}
|
||||
return LoadScript(abcPath, safeData->GetDataPtr(), safeData->GetDataLen(), isBundle_);
|
||||
} else {
|
||||
std::ostringstream outStream;
|
||||
if (!extractor->GetFileBuffer(modulePath, outStream)) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Get abc file failed");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Get File Buffer abc file failed");
|
||||
return false;
|
||||
}
|
||||
const auto& outStr = outStream.str();
|
||||
@ -1250,7 +1250,7 @@ void JsRuntime::NotifyApplicationState(bool isBackground)
|
||||
auto nativeEngine = GetNativeEnginePointer();
|
||||
CHECK_POINTER(nativeEngine);
|
||||
nativeEngine->NotifyApplicationState(isBackground);
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "NotifyApplicationState, isBackground %{public}d.", isBackground);
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "isBackground %{public}d", isBackground);
|
||||
}
|
||||
|
||||
bool JsRuntime::SuspendVM(uint32_t tid)
|
||||
@ -1360,7 +1360,7 @@ bool JsRuntime::ReadSourceMapData(const std::string& hapPath, const std::string&
|
||||
std::unique_ptr<uint8_t[]> dataPtr = nullptr;
|
||||
size_t len = 0;
|
||||
if (!extractor->ExtractToBufByName(sourceMapPath, dataPtr, len)) {
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "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)) {
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "get mergeSourceMapData fileBuffer failed, map path: %{private}s",
|
||||
@ -1391,7 +1391,7 @@ void JsRuntime::FreeNativeReference(std::unique_ptr<NativeReference> uniqueNativ
|
||||
std::shared_ptr<NativeReference>&& sharedNativeRef)
|
||||
{
|
||||
if (uniqueNativeRef == nullptr && sharedNativeRef == nullptr) {
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME, "native reference is invalid.");
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME, "native reference is invalid");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1402,13 +1402,13 @@ void JsRuntime::FreeNativeReference(std::unique_ptr<NativeReference> uniqueNativ
|
||||
|
||||
auto work = new (std::nothrow) uv_work_t;
|
||||
if (work == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "new uv work failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "new uv work failed");
|
||||
return;
|
||||
}
|
||||
|
||||
auto cb = new (std::nothrow) JsNativeReferenceDeleterObject();
|
||||
if (cb == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "new deleter object failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "new deleter object failed");
|
||||
delete work;
|
||||
work = nullptr;
|
||||
return;
|
||||
@ -1483,24 +1483,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) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "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) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "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) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Failed to get bundle manager.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Failed to get bundle manager");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME,
|
||||
"Reset compile status, bundleName: %{public}s, moduleName: %{public}s, triggerMode: %{public}d.",
|
||||
"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);
|
||||
};
|
||||
@ -1510,7 +1510,7 @@ void JsRuntime::SetRequestAotCallback()
|
||||
|
||||
void JsRuntime::SetDeviceDisconnectCallback(const std::function<bool()> &cb)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Start.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
CHECK_POINTER(jsEnv_);
|
||||
jsEnv_->SetDeviceDisconnectCallback(cb);
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ bool NapiAsyncTask::StartWithDefaultQos(const std::string &name, napi_env env)
|
||||
|
||||
void NapiAsyncTask::Resolve(napi_env env, napi_value value)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "NapiAsyncTask::Resolve is called");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
if (deferred_) {
|
||||
napi_resolve_deferred(env, deferred_, value);
|
||||
deferred_ = nullptr;
|
||||
@ -263,12 +263,12 @@ void NapiAsyncTask::Resolve(napi_env env, napi_value value)
|
||||
napi_delete_reference(env, callbackRef_);
|
||||
callbackRef_ = nullptr;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "NapiAsyncTask::Resolve is called end.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "end");
|
||||
}
|
||||
|
||||
void NapiAsyncTask::ResolveWithNoError(napi_env env, napi_value value)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "NapiAsyncTask::Resolve is called");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
if (deferred_) {
|
||||
napi_resolve_deferred(env, deferred_, value);
|
||||
deferred_ = nullptr;
|
||||
@ -284,7 +284,7 @@ void NapiAsyncTask::ResolveWithNoError(napi_env env, napi_value value)
|
||||
napi_delete_reference(env, callbackRef_);
|
||||
callbackRef_ = nullptr;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "NapiAsyncTask::Resolve is called end.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "end");
|
||||
}
|
||||
|
||||
void NapiAsyncTask::Reject(napi_env env, napi_value error)
|
||||
@ -308,7 +308,7 @@ void NapiAsyncTask::Reject(napi_env env, napi_value error)
|
||||
|
||||
void NapiAsyncTask::ResolveWithCustomize(napi_env env, napi_value error, napi_value value)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "NapiAsyncTask::ResolveWithCustomize is called");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
if (deferred_) {
|
||||
napi_resolve_deferred(env, deferred_, value);
|
||||
deferred_ = nullptr;
|
||||
@ -324,12 +324,12 @@ void NapiAsyncTask::ResolveWithCustomize(napi_env env, napi_value error, napi_va
|
||||
napi_delete_reference(env, callbackRef_);
|
||||
callbackRef_ = nullptr;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "NapiAsyncTask::ResolveWithCustomize is called end.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "end");
|
||||
}
|
||||
|
||||
void NapiAsyncTask::RejectWithCustomize(napi_env env, napi_value error, napi_value value)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "NapiAsyncTask::RejectWithCustomize is called");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
if (deferred_) {
|
||||
napi_reject_deferred(env, deferred_, error);
|
||||
deferred_ = nullptr;
|
||||
@ -345,7 +345,7 @@ void NapiAsyncTask::RejectWithCustomize(napi_env env, napi_value error, napi_val
|
||||
napi_delete_reference(env, callbackRef_);
|
||||
callbackRef_ = nullptr;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "NapiAsyncTask::RejectWithCustomize is called end.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "end");
|
||||
}
|
||||
|
||||
void NapiAsyncTask::Execute(napi_env env, void* data)
|
||||
@ -361,7 +361,7 @@ void NapiAsyncTask::Execute(napi_env env, void* data)
|
||||
|
||||
void NapiAsyncTask::Complete(napi_env env, napi_status status, void* data)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
if (data == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ void InitWorkerFunc(NativeEngine* nativeEngine)
|
||||
auto arkNativeEngine = static_cast<ArkNativeEngine*>(nativeEngine);
|
||||
// load jsfwk
|
||||
if (g_jsFramework && !arkNativeEngine->ExecuteJsBin("/system/etc/strip.native.min.abc")) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Failed to load js framework!");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Failed to load js framework");
|
||||
}
|
||||
|
||||
if (g_debugMode) {
|
||||
@ -121,7 +121,7 @@ void InitWorkerFunc(NativeEngine* nativeEngine)
|
||||
|
||||
void OffWorkerFunc(NativeEngine* nativeEngine)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "OffWorkerFunc called");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
if (nativeEngine == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Input nativeEngine is nullptr");
|
||||
return;
|
||||
@ -162,7 +162,7 @@ std::string AssetHelper::NormalizedFileName(const std::string& fileName) const
|
||||
|
||||
AssetHelper::~AssetHelper()
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "destroyed.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "destroyed");
|
||||
if (fd_ != -1) {
|
||||
close(fd_);
|
||||
fd_ = -1;
|
||||
@ -173,7 +173,7 @@ void AssetHelper::operator()(const std::string& uri, uint8_t** buff, size_t* buf
|
||||
std::string& ami, bool& useSecureMem, bool isRestricted)
|
||||
{
|
||||
if (uri.empty() || buff == nullptr || buffSize == nullptr || workerInfo_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Input params invalid.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Input params invalid");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -217,17 +217,17 @@ void AssetHelper::operator()(const std::string& uri, uint8_t** buff, size_t* buf
|
||||
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, content, useSecureMem, isRestricted)) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Get buffer by ami failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Get buffer by ami failed");
|
||||
}
|
||||
} else if (!ReadFilePathData(filePath, buff, buffSize, content, useSecureMem, isRestricted)) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "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
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "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) {
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "uri start with @bundle:");
|
||||
size_t fileNamePos = uri.find_last_of("/");
|
||||
@ -259,34 +259,34 @@ void AssetHelper::operator()(const std::string& uri, uint8_t** buff, size_t* buf
|
||||
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, content, useSecureMem, isRestricted)) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Get buffer by ami failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Get buffer by ami failed");
|
||||
}
|
||||
} else if (!ReadFilePathData(filePath, buff, buffSize, content, useSecureMem, isRestricted)) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "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)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Get secure mem.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Get secure mem");
|
||||
std::string resolvedPath;
|
||||
resolvedPath.reserve(PATH_MAX);
|
||||
resolvedPath.resize(PATH_MAX - 1);
|
||||
if (realpath(ami.c_str(), &(resolvedPath[0])) == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "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) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "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) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Get fstat of file %{private}s caught error: %{public}d.", resolvedPath.c_str(),
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Get fstat of file %{private}s caught error: %{public}d", resolvedPath.c_str(),
|
||||
errno);
|
||||
close(fd);
|
||||
return false;
|
||||
@ -294,14 +294,14 @@ bool AssetHelper::GetSafeData(const std::string& ami, uint8_t** buff, size_t* bu
|
||||
|
||||
std::unique_ptr<FileMapper> fileMapper = std::make_unique<FileMapper>();
|
||||
if (fileMapper == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "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) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "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;
|
||||
}
|
||||
@ -326,30 +326,30 @@ bool AssetHelper::ReadAmiData(const std::string& ami, uint8_t** buff, size_t* bu
|
||||
return true;
|
||||
} else {
|
||||
// If api version less than 12 and get secure mem failed, try get normal mem.
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME, "Get secure mem failed, file %{private}s.", ami.c_str());
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME, "Get secure mem failed, file %{private}s", ami.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
char path[PATH_MAX];
|
||||
if (realpath(ami.c_str(), path) == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "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()) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "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) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "File is too large.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "File is too large");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fileLen <= 0) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Invalid file length.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Invalid file length");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -364,7 +364,7 @@ bool AssetHelper::ReadFilePathData(const std::string& filePath, uint8_t** buff,
|
||||
{
|
||||
auto bundleMgrHelper = DelayedSingleton<AppExecFwk::BundleMgrHelper>::GetInstance();
|
||||
if (bundleMgrHelper == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "The bundleMgrHelper is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "The bundleMgrHelper is nullptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -372,11 +372,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) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "GetBundleInfoForSelf failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "GetBundleInfoForSelf failed");
|
||||
return false;
|
||||
}
|
||||
if (bundleInfo.hapModuleInfos.size() == 0) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Get hapModuleInfo of bundleInfo failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Get hapModuleInfo of bundleInfo failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -422,12 +422,12 @@ bool AssetHelper::ReadFilePathData(const std::string& filePath, uint8_t** buff,
|
||||
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)) {
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Use secure mem.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Use secure mem");
|
||||
auto safeData = extractor->GetSafeData(realfilePath);
|
||||
if (workerInfo_->apiTargetVersion >= API12) {
|
||||
useSecureMem = true;
|
||||
if (safeData == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Get secure mem failed, file %{private}s.", filePath.c_str());
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Get secure mem failed, file %{private}s", filePath.c_str());
|
||||
return false;
|
||||
}
|
||||
*buff = safeData->GetDataPtr();
|
||||
@ -440,7 +440,7 @@ bool AssetHelper::ReadFilePathData(const std::string& filePath, uint8_t** buff,
|
||||
return true;
|
||||
} else {
|
||||
// If api version less than 12 and get secure mem failed, try get normal mem.
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME, "Get secure mem failed, file %{private}s.", filePath.c_str());
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME, "Get secure mem failed, file %{private}s", filePath.c_str());
|
||||
}
|
||||
}
|
||||
if (!extractor->ExtractToBufByName(realfilePath, dataPtr, fileLen)) {
|
||||
@ -501,7 +501,7 @@ void AssetHelper::GetAmi(std::string& ami, const std::string& filePath)
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "targetFilePath %{public}s", targetFilePath.c_str());
|
||||
|
||||
if (!flag) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "get targetFilePath failed!");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "get targetFilePath failed");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ napi_status NativeRuntimeImpl::CreateJsEnv(const Options& options, std::shared_p
|
||||
pandaOption.SetMemConfigProperty(memConfigProperty);
|
||||
pandaOption.SetGcThreadNum(gcThreadNum);
|
||||
pandaOption.SetLongPauseTime(longPauseTime);
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "NativeRuntimeImpl::Initialize ark properties = %{public}d bundlename = %{public}s",
|
||||
TAG_LOGI(AAFwkTag::JSRUNTIME, "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);
|
||||
@ -103,7 +103,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) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Initialize js environment failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Initialize js environment failed");
|
||||
return napi_status::napi_ok;
|
||||
}
|
||||
jsEnv->GetNativeEngine()->MarkNativeThread();
|
||||
@ -114,13 +114,13 @@ napi_status NativeRuntimeImpl::Init(const Options& options, napi_env env)
|
||||
{
|
||||
auto jsEnv = GetJsEnv(env);
|
||||
if (jsEnv == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv is nullptr");
|
||||
return napi_status::napi_generic_failure;
|
||||
}
|
||||
|
||||
auto vm = GetEcmaVm(jsEnv);
|
||||
if (!vm) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "vm is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "vm is nullptr");
|
||||
return napi_status::napi_generic_failure;
|
||||
}
|
||||
|
||||
@ -155,7 +155,7 @@ napi_status NativeRuntimeImpl::Init(const Options& options, napi_env env)
|
||||
SetRequestAotCallback(jsEnv);
|
||||
|
||||
if (!InitLoop(jsEnv)) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Initialize loop failed.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Initialize loop failed");
|
||||
return napi_status::napi_generic_failure;
|
||||
}
|
||||
}
|
||||
@ -169,11 +169,11 @@ 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()) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "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) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "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);
|
||||
@ -205,7 +205,7 @@ napi_status NativeRuntimeImpl::RemoveJsEnv(napi_env env)
|
||||
panda::ecmascript::EcmaVM* NativeRuntimeImpl::GetEcmaVm(const std::shared_ptr<JsEnv::JsEnvironment>& jsEnv) const
|
||||
{
|
||||
if (jsEnv == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
return jsEnv->GetVM();
|
||||
@ -239,7 +239,7 @@ void NativeRuntimeImpl::LoadAotFile(const Options& options, const std::shared_pt
|
||||
void NativeRuntimeImpl::InitConsoleModule(const std::shared_ptr<JsEnv::JsEnvironment>& jsEnv)
|
||||
{
|
||||
if (jsEnv == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv is nullptr");
|
||||
return;
|
||||
}
|
||||
jsEnv->InitConsoleModule();
|
||||
@ -248,7 +248,7 @@ void NativeRuntimeImpl::InitConsoleModule(const std::shared_ptr<JsEnv::JsEnviron
|
||||
void NativeRuntimeImpl::InitTimerModule(const std::shared_ptr<JsEnv::JsEnvironment>& jsEnv)
|
||||
{
|
||||
if (jsEnv == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv is nullptr");
|
||||
return;
|
||||
}
|
||||
jsEnv->InitTimerModule();
|
||||
@ -258,7 +258,7 @@ void NativeRuntimeImpl::SetModuleLoadChecker(const std::shared_ptr<ModuleChecker
|
||||
const std::shared_ptr<JsEnv::JsEnvironment>& jsEnv)
|
||||
{
|
||||
if (jsEnv == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv is nullptr");
|
||||
return;
|
||||
}
|
||||
jsEnv->SetModuleLoadChecker(moduleCheckerDelegate);
|
||||
@ -267,30 +267,30 @@ void NativeRuntimeImpl::SetModuleLoadChecker(const std::shared_ptr<ModuleChecker
|
||||
void NativeRuntimeImpl::SetRequestAotCallback(const std::shared_ptr<JsEnv::JsEnvironment>& jsEnv)
|
||||
{
|
||||
if (jsEnv == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "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) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "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) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "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) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Failed to get bundle manager.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Failed to get bundle manager");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME,
|
||||
"Reset compile status, bundleName: %{public}s, moduleName: %{public}s, triggerMode: %{public}d.",
|
||||
"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);
|
||||
};
|
||||
@ -301,7 +301,7 @@ void NativeRuntimeImpl::SetRequestAotCallback(const std::shared_ptr<JsEnv::JsEnv
|
||||
bool NativeRuntimeImpl::InitLoop(const std::shared_ptr<JsEnv::JsEnvironment>& jsEnv)
|
||||
{
|
||||
if (jsEnv == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv is nullptr");
|
||||
return false;
|
||||
}
|
||||
return jsEnv->InitLoop();
|
||||
@ -310,7 +310,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) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv is nullptr.");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -30,16 +30,16 @@ namespace {
|
||||
}
|
||||
void OHOSJsEnvironmentImpl::PostTaskToHandler(void* handler, uv_io_cb func, void* work, int status, int priority)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Enter.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Enter");
|
||||
if (!func || !work) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Invalid parameters!");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Invalid parameters");
|
||||
return;
|
||||
}
|
||||
|
||||
auto task = [func, work, status]() {
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Do uv work.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Do uv work");
|
||||
func(work, status);
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Do uv work end.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Do uv work end");
|
||||
};
|
||||
|
||||
AppExecFwk::EventQueue::Priority prio = AppExecFwk::EventQueue::Priority::IMMEDIATE;
|
||||
@ -59,12 +59,12 @@ void OHOSJsEnvironmentImpl::PostTaskToHandler(void* handler, uv_io_cb func, void
|
||||
}
|
||||
|
||||
if (g_eventHandler == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Invalid parameters!");
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Invalid parameters");
|
||||
return;
|
||||
}
|
||||
g_eventHandler->PostTask(task, prio);
|
||||
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "PostTask end.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "end");
|
||||
}
|
||||
OHOSJsEnvironmentImpl::OHOSJsEnvironmentImpl()
|
||||
{
|
||||
@ -75,7 +75,7 @@ OHOSJsEnvironmentImpl::OHOSJsEnvironmentImpl(const std::shared_ptr<AppExecFwk::E
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
if (eventRunner != nullptr) {
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Create event handler.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Create event handler");
|
||||
eventHandler_ = std::make_shared<AppExecFwk::EventHandler>(eventRunner);
|
||||
if (eventRunner.get() == AppExecFwk::EventRunner::GetMainEventRunner().get()) {
|
||||
g_eventHandler = std::make_shared<AppExecFwk::EventHandler>(eventRunner);
|
||||
@ -98,7 +98,7 @@ void OHOSJsEnvironmentImpl::PostTask(const std::function<void()>& task, const st
|
||||
|
||||
void OHOSJsEnvironmentImpl::PostSyncTask(const std::function<void()>& task, const std::string& name)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Post sync task");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
if (eventHandler_ != nullptr) {
|
||||
eventHandler_->PostSyncTask(task, name);
|
||||
}
|
||||
@ -114,7 +114,7 @@ void OHOSJsEnvironmentImpl::RemoveTask(const std::string& name)
|
||||
|
||||
void OHOSJsEnvironmentImpl::InitTimerModule(NativeEngine* engine)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Init timer.");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "called");
|
||||
CHECK_POINTER(engine);
|
||||
auto ret = JsSysModule::Timer::RegisterTime(reinterpret_cast<napi_env>(engine));
|
||||
if (!ret) {
|
||||
|
@ -20,19 +20,19 @@ namespace AbilityRuntime {
|
||||
|
||||
void OHOSLoopHandler::OnReadable(int32_t)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "OHOSLoopHandler::OnReadable is triggered");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "triggered");
|
||||
OnTriggered();
|
||||
}
|
||||
|
||||
void OHOSLoopHandler::OnWritable(int32_t)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "OHOSLoopHandler::OnWritable is triggered");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "triggered");
|
||||
OnTriggered();
|
||||
}
|
||||
|
||||
void OHOSLoopHandler::OnTriggered()
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "OHOSLoopHandler::OnTriggered is triggered");
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "triggered");
|
||||
|
||||
uv_run(uvLoop_, UV_RUN_NOWAIT);
|
||||
|
||||
|
@ -24,7 +24,7 @@ namespace AbilityRuntime {
|
||||
#define CHECK_POINTER(object) \
|
||||
do { \
|
||||
if ((object) == nullptr) { \
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "pointer is nullptr."); \
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "pointer is nullptr"); \
|
||||
return; \
|
||||
} \
|
||||
} while (0)
|
||||
@ -32,7 +32,7 @@ namespace AbilityRuntime {
|
||||
#define CHECK_POINTER_AND_RETURN(object, value) \
|
||||
do { \
|
||||
if ((object) == nullptr) { \
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "pointer is nullptr."); \
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "pointer is nullptr"); \
|
||||
return value; \
|
||||
} \
|
||||
} while (0)
|
||||
|
Loading…
Reference in New Issue
Block a user