hilog整改

Signed-off-by: xinking129 <xinxin13@huawei.com>
This commit is contained in:
xinking129 2024-03-28 10:27:18 +08:00
parent f3f775ffa7
commit 2af4b55967
51 changed files with 782 additions and 696 deletions

View File

@ -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
@ -14,6 +14,7 @@
*/
#include "authorization_result.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
namespace OHOS {
@ -21,9 +22,9 @@ namespace AbilityRuntime {
void AuthorizationResult::GrantResultsCallback(const std::vector<std::string>& permissions,
const std::vector<int>& grantResults)
{
HILOG_INFO("%{public}s called.", __func__);
TAG_LOGI(AAFwkTag::DEFAULT, "%{public}s called.", __func__);
if (task_) {
HILOG_DEBUG("%{public}s callback client function.", __func__);
TAG_LOGD(AAFwkTag::DEFAULT, "%{public}s callback client function.", __func__);
task_(permissions, grantResults);
}
}

View File

@ -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 "local_call_container.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "ability_manager_client.h"
#include "os_account_manager_wrapper.h"
@ -25,17 +26,17 @@ int LocalCallContainer::StartAbilityByCallInner(const Want& want, std::shared_pt
sptr<IRemoteObject> callerToken, int32_t accountId)
{
AppExecFwk::ElementName element = want.GetElement();
HILOG_DEBUG("start ability by call, element:%{public}s", element.GetURI().c_str());
TAG_LOGD(AAFwkTag::LOCAL_CALL, "start ability by call, element:%{public}s", element.GetURI().c_str());
if (callback == nullptr) {
HILOG_ERROR("callback is nullptr.");
TAG_LOGE(AAFwkTag::LOCAL_CALL, "callback is nullptr.");
return ERR_INVALID_VALUE;
}
if (element.GetBundleName().empty() || element.GetAbilityName().empty()) {
HILOG_ERROR("the element of want is empty.");
TAG_LOGE(AAFwkTag::LOCAL_CALL, "the element of want is empty.");
return ERR_INVALID_VALUE;
}
if (element.GetDeviceID().empty()) {
HILOG_DEBUG("start ability by call, element:DeviceID is empty");
TAG_LOGD(AAFwkTag::LOCAL_CALL, "start ability by call, element:DeviceID is empty");
}
int32_t oriValidUserId = GetValidUserId(accountId);
@ -43,27 +44,28 @@ int LocalCallContainer::StartAbilityByCallInner(const Want& want, std::shared_pt
if (!GetCallLocalRecord(element, localCallRecord, oriValidUserId)) {
localCallRecord = std::make_shared<LocalCallRecord>(element);
localCallRecord->SetUserId(oriValidUserId);
HILOG_DEBUG("create local call record and set user id[%{public}d] to record", oriValidUserId);
TAG_LOGD(
AAFwkTag::LOCAL_CALL, "create local call record and set user id[%{public}d] to record", oriValidUserId);
}
localCallRecord->AddCaller(callback);
auto remote = localCallRecord->GetRemoteObject();
// already finish call request.
if (remote) {
HILOG_DEBUG("start ability by call, callback->InvokeCallBack(remote) begin");
TAG_LOGD(AAFwkTag::LOCAL_CALL, "start ability by call, callback->InvokeCallBack(remote) begin");
callback->InvokeCallBack(remote);
HILOG_DEBUG("start ability by call, callback->InvokeCallBack(remote) end");
TAG_LOGD(AAFwkTag::LOCAL_CALL, "start ability by call, callback->InvokeCallBack(remote) end");
if (!want.GetBoolParam(Want::PARAM_RESV_CALL_TO_FOREGROUND, false)) {
return ERR_OK;
}
}
sptr<CallerConnection> connect = new (std::nothrow) CallerConnection();
if (connect == nullptr) {
HILOG_ERROR("StartAbilityByCallInner Create local call connection failed");
TAG_LOGE(AAFwkTag::LOCAL_CALL, "StartAbilityByCallInner Create local call connection failed");
return ERR_INVALID_VALUE;
}
connections_.emplace(connect);
connect->SetRecordAndContainer(localCallRecord, shared_from_this());
HILOG_DEBUG("StartAbilityByCallInner connections_.size is %{public}zu", connections_.size());
TAG_LOGD(AAFwkTag::LOCAL_CALL, "StartAbilityByCallInner connections_.size is %{public}zu", connections_.size());
auto retval = AAFwk::AbilityManagerClient::GetInstance()->StartAbilityByCall(want, connect,
callerToken, oriValidUserId);
if (retval != ERR_OK) {
@ -74,30 +76,31 @@ int LocalCallContainer::StartAbilityByCallInner(const Want& want, std::shared_pt
int LocalCallContainer::ReleaseCall(const std::shared_ptr<CallerCallBack>& callback)
{
HILOG_DEBUG("LocalCallContainer::ReleaseCall begin.");
TAG_LOGD(AAFwkTag::LOCAL_CALL, "LocalCallContainer::ReleaseCall begin.");
if (callback == nullptr) {
HILOG_ERROR("LocalCallContainer::ReleaseCall input params is nullptr");
TAG_LOGE(AAFwkTag::LOCAL_CALL, "LocalCallContainer::ReleaseCall input params is nullptr");
return ERR_INVALID_VALUE;
}
auto abilityClient = AAFwk::AbilityManagerClient::GetInstance();
if (abilityClient == nullptr) {
HILOG_ERROR("LocalCallContainer::ReleaseCall abilityClient is nullptr");
TAG_LOGE(AAFwkTag::LOCAL_CALL, "LocalCallContainer::ReleaseCall abilityClient is nullptr");
return ERR_INVALID_VALUE;
}
auto localCallRecord = callback->GetRecord();
if (localCallRecord == nullptr) {
HILOG_ERROR("LocalCallContainer::ReleaseCall localCallRecord is nullptr");
TAG_LOGE(AAFwkTag::LOCAL_CALL, "LocalCallContainer::ReleaseCall localCallRecord is nullptr");
return ERR_INVALID_VALUE;
}
localCallRecord->RemoveCaller(callback);
if (localCallRecord->IsExistCallBack()) {
// just release callback.
HILOG_DEBUG("LocalCallContainer::ReleaseCall, The callee has onther callers, just release this callback.");
TAG_LOGD(AAFwkTag::LOCAL_CALL,
"LocalCallContainer::ReleaseCall, The callee has onther callers, just release this callback.");
return ERR_OK;
}
auto connect = iface_cast<CallerConnection>(localCallRecord->GetConnection());
if (connect == nullptr) {
HILOG_ERROR("LocalCallContainer::ReleaseCall connection conversion failed.");
TAG_LOGE(AAFwkTag::LOCAL_CALL, "LocalCallContainer::ReleaseCall connection conversion failed.");
return ERR_INVALID_VALUE;
}
int32_t retval = ERR_OK;
@ -108,36 +111,36 @@ int LocalCallContainer::ReleaseCall(const std::shared_ptr<CallerCallBack>& callb
}
if (retval != ERR_OK) {
HILOG_ERROR("Remove call local record failed");
TAG_LOGE(AAFwkTag::LOCAL_CALL, "Remove call local record failed");
return retval;
}
connections_.erase(connect);
if (abilityClient->ReleaseCall(connect, localCallRecord->GetElementName()) != ERR_OK) {
HILOG_ERROR("ReleaseCall failed.");
TAG_LOGE(AAFwkTag::LOCAL_CALL, "ReleaseCall failed.");
return ERR_INVALID_VALUE;
}
HILOG_DEBUG("LocalCallContainer::ReleaseCall end.");
TAG_LOGD(AAFwkTag::LOCAL_CALL, "LocalCallContainer::ReleaseCall end.");
return ERR_OK;
}
void LocalCallContainer::ClearFailedCallConnection(const std::shared_ptr<CallerCallBack> &callback)
{
HILOG_DEBUG("LocalCallContainer::ClearFailedCallConnection called");
TAG_LOGD(AAFwkTag::LOCAL_CALL, "LocalCallContainer::ClearFailedCallConnection called");
if (callback == nullptr) {
HILOG_ERROR("LocalCallContainer::ClearFailedCallConnection callback is nullptr");
TAG_LOGE(AAFwkTag::LOCAL_CALL, "LocalCallContainer::ClearFailedCallConnection callback is nullptr");
return;
}
auto localCallRecord = callback->GetRecord();
if (localCallRecord == nullptr) {
HILOG_ERROR("LocalCallContainer::ClearFailedCallConnection localCallRecord is nullptr");
TAG_LOGE(AAFwkTag::LOCAL_CALL, "LocalCallContainer::ClearFailedCallConnection localCallRecord is nullptr");
return;
}
auto connect = iface_cast<CallerConnection>(localCallRecord->GetConnection());
if (connect == nullptr) {
HILOG_ERROR("LocalCallContainer::ClearFailedCallConnection connection conversion failed.");
TAG_LOGE(AAFwkTag::LOCAL_CALL, "LocalCallContainer::ClearFailedCallConnection connection conversion failed.");
return;
}
@ -148,13 +151,13 @@ int32_t LocalCallContainer::RemoveSingletonCallLocalRecord(const std::shared_ptr
{
std::lock_guard<std::mutex> lock(mutex_);
if (record == nullptr) {
HILOG_ERROR("input params invalid value");
TAG_LOGE(AAFwkTag::LOCAL_CALL, "input params invalid value");
return ERR_INVALID_VALUE;
}
auto iterRecord = callProxyRecords_.find(record->GetElementName().GetURI());
if (iterRecord == callProxyRecords_.end()) {
HILOG_ERROR("release record in singleton not found.");
TAG_LOGE(AAFwkTag::LOCAL_CALL, "release record in singleton not found.");
return ERR_INVALID_VALUE;
}
@ -169,14 +172,14 @@ int32_t LocalCallContainer::RemoveSingletonCallLocalRecord(const std::shared_ptr
int32_t LocalCallContainer::RemoveMultipleCallLocalRecord(const std::shared_ptr<LocalCallRecord> &record)
{
if (record == nullptr) {
HILOG_ERROR("input params invalid value");
TAG_LOGE(AAFwkTag::LOCAL_CALL, "input params invalid value");
return ERR_INVALID_VALUE;
}
std::lock_guard<std::mutex> lock(multipleMutex_);
auto iterRecord = multipleCallProxyRecords_.find(record->GetElementName().GetURI());
if (iterRecord == multipleCallProxyRecords_.end()) {
HILOG_ERROR("release record in multiple not found.");
TAG_LOGE(AAFwkTag::LOCAL_CALL, "release record in multiple not found.");
return ERR_INVALID_VALUE;
}
@ -192,7 +195,7 @@ bool LocalCallContainer::IsCallBackCalled(const std::vector<std::shared_ptr<Call
{
for (auto& callBack : callers) {
if (callBack != nullptr && !callBack->IsCallBack()) {
HILOG_INFO("%{public}s call back is not called.", __func__);
TAG_LOGI(AAFwkTag::LOCAL_CALL, "%{public}s call back is not called.", __func__);
return false;
}
}
@ -202,7 +205,7 @@ bool LocalCallContainer::IsCallBackCalled(const std::vector<std::shared_ptr<Call
void LocalCallContainer::DumpCalls(std::vector<std::string>& info)
{
HILOG_DEBUG("LocalCallContainer::DumpCalls called.");
TAG_LOGD(AAFwkTag::LOCAL_CALL, "LocalCallContainer::DumpCalls called.");
info.emplace_back(" caller connections:");
std::lock_guard<std::mutex> lock(mutex_);
for (auto &item : callProxyRecords_) {
@ -213,10 +216,10 @@ void LocalCallContainer::DumpCalls(std::vector<std::string>& info)
tempstr += " uri[" + item.first + "]" + "\n";
tempstr += " callers #" + std::to_string(itemCall->GetCallers().size());
if (IsCallBackCalled(itemCall->GetCallers())) {
HILOG_INFO("%{public}s state is REQUESTEND.", __func__);
TAG_LOGI(AAFwkTag::LOCAL_CALL, "%{public}s state is REQUESTEND.", __func__);
tempstr += " state #REQUESTEND";
} else {
HILOG_INFO("%{public}s state is REQUESTING.", __func__);
TAG_LOGI(AAFwkTag::LOCAL_CALL, "%{public}s state is REQUESTING.", __func__);
tempstr += " state #REQUESTING";
}
info.emplace_back(tempstr);
@ -229,11 +232,13 @@ bool LocalCallContainer::GetCallLocalRecord(
const AppExecFwk::ElementName& elementName, std::shared_ptr<LocalCallRecord>& localCallRecord, int32_t accountId)
{
std::lock_guard<std::mutex> lock(mutex_);
HILOG_DEBUG("Get call local record by %{public}s and id %{public}d", elementName.GetURI().c_str(), accountId);
TAG_LOGD(AAFwkTag::LOCAL_CALL, "Get call local record by %{public}s and id %{public}d",
elementName.GetURI().c_str(), accountId);
for (auto pair : callProxyRecords_) {
AppExecFwk::ElementName callElement;
if (!callElement.ParseURI(pair.first)) {
HILOG_ERROR("Parse uri to elementName failed, elementName uri: %{private}s", pair.first.c_str());
TAG_LOGE(AAFwkTag::LOCAL_CALL,
"Parse uri to elementName failed, elementName uri: %{private}s", pair.first.c_str());
continue;
}
// elementName in callProxyRecords_ has moduleName (sometimes not empty),
@ -267,12 +272,13 @@ void LocalCallContainer::OnCallStubDied(const wptr<IRemoteObject>& remote)
if (iter == item.second.end()) {
continue;
}
HILOG_DEBUG("LocalCallContainer::OnCallStubDied singleton key[%{public}s]. notify died event",
item.first.c_str());
TAG_LOGD(AAFwkTag::LOCAL_CALL,
"LocalCallContainer::OnCallStubDied singleton key[%{public}s]. notify died event", item.first.c_str());
(*iter)->OnCallStubDied(remote);
item.second.erase(iter);
if (item.second.empty()) {
HILOG_DEBUG("LocalCallContainer::OnCallStubDied singleton key[%{public}s] empty.", item.first.c_str());
TAG_LOGD(AAFwkTag::LOCAL_CALL,
"LocalCallContainer::OnCallStubDied singleton key[%{public}s] empty.", item.first.c_str());
callProxyRecords_.erase(item.first);
break;
}
@ -281,28 +287,31 @@ void LocalCallContainer::OnCallStubDied(const wptr<IRemoteObject>& remote)
std::lock_guard<std::mutex> lock(multipleMutex_);
for (auto &item : multipleCallProxyRecords_) {
HILOG_DEBUG("LocalCallContainer::OnCallStubDied multiple key[%{public}s].", item.first.c_str());
TAG_LOGD(
AAFwkTag::LOCAL_CALL, "LocalCallContainer::OnCallStubDied multiple key[%{public}s].", item.first.c_str());
auto iterMultiple = find_if(item.second.begin(), item.second.end(), isExist);
if (iterMultiple == item.second.end()) {
continue;
}
HILOG_DEBUG("LocalCallContainer::OnCallStubDied multiple key[%{public}s]. notify died event",
TAG_LOGD(AAFwkTag::LOCAL_CALL, "LocalCallContainer::OnCallStubDied multiple key[%{public}s]. notify died event",
item.first.c_str());
(*iterMultiple)->OnCallStubDied(remote);
item.second.erase(iterMultiple);
if (item.second.empty()) {
HILOG_DEBUG("LocalCallContainer::OnCallStubDied multiple key[%{public}s] empty.", item.first.c_str());
TAG_LOGD(AAFwkTag::LOCAL_CALL,
"LocalCallContainer::OnCallStubDied multiple key[%{public}s] empty.", item.first.c_str());
multipleCallProxyRecords_.erase(item.first);
break;
}
}
HILOG_DEBUG("LocalCallContainer::OnCallStubDied end.");
TAG_LOGD(AAFwkTag::LOCAL_CALL, "LocalCallContainer::OnCallStubDied end.");
}
void LocalCallContainer::SetCallLocalRecord(
const AppExecFwk::ElementName& element, const std::shared_ptr<LocalCallRecord> &localCallRecord)
{
HILOG_DEBUG("LocalCallContainer::SetCallLocalRecord called uri is %{private}s.", element.GetURI().c_str());
TAG_LOGD(AAFwkTag::LOCAL_CALL,
"LocalCallContainer::SetCallLocalRecord called uri is %{private}s.", element.GetURI().c_str());
const std::string strKey = element.GetURI();
std::lock_guard<std::mutex> lock(mutex_);
auto iter = callProxyRecords_.find(strKey);
@ -318,7 +327,8 @@ void LocalCallContainer::SetCallLocalRecord(
void LocalCallContainer::SetMultipleCallLocalRecord(
const AppExecFwk::ElementName& element, const std::shared_ptr<LocalCallRecord> &localCallRecord)
{
HILOG_DEBUG("LocalCallContainer::SetMultipleCallLocalRecord called uri is %{private}s.", element.GetURI().c_str());
TAG_LOGD(AAFwkTag::LOCAL_CALL,
"LocalCallContainer::SetMultipleCallLocalRecord called uri is %{private}s.", element.GetURI().c_str());
const std::string strKey = element.GetURI();
std::lock_guard<std::mutex> lock(multipleMutex_);
auto iter = multipleCallProxyRecords_.find(strKey);
@ -335,7 +345,7 @@ void CallerConnection::SetRecordAndContainer(const std::shared_ptr<LocalCallReco
const std::weak_ptr<LocalCallContainer> &container)
{
if (localCallRecord == nullptr) {
HILOG_DEBUG("CallerConnection::SetRecordAndContainer input param is nullptr.");
TAG_LOGD(AAFwkTag::LOCAL_CALL, "CallerConnection::SetRecordAndContainer input param is nullptr.");
return;
}
localCallRecord_ = localCallRecord;
@ -346,10 +356,11 @@ void CallerConnection::SetRecordAndContainer(const std::shared_ptr<LocalCallReco
void CallerConnection::OnAbilityConnectDone(
const AppExecFwk::ElementName &element, const sptr<IRemoteObject> &remoteObject, int code)
{
HILOG_DEBUG("CallerConnection::OnAbilityConnectDone start %{public}s .", element.GetURI().c_str());
TAG_LOGD(AAFwkTag::LOCAL_CALL,
"CallerConnection::OnAbilityConnectDone start %{public}s .", element.GetURI().c_str());
auto container = container_.lock();
if (container == nullptr || localCallRecord_ == nullptr) {
HILOG_ERROR("CallerConnection::OnAbilityConnectDone container or record is nullptr.");
TAG_LOGE(AAFwkTag::LOCAL_CALL, "CallerConnection::OnAbilityConnectDone container or record is nullptr.");
return;
}
@ -367,27 +378,29 @@ void CallerConnection::OnAbilityConnectDone(
}
localCallRecord_->InvokeCallBack();
HILOG_DEBUG("CallerConnection::OnAbilityConnectDone end. code:%{public}d.", code);
TAG_LOGD(AAFwkTag::LOCAL_CALL, "CallerConnection::OnAbilityConnectDone end. code:%{public}d.", code);
return;
}
void CallerConnection::OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int code)
{
HILOG_DEBUG("CallerConnection::OnAbilityDisconnectDone start %{public}s %{public}d.",
TAG_LOGD(AAFwkTag::LOCAL_CALL, "CallerConnection::OnAbilityDisconnectDone start %{public}s %{public}d.",
element.GetURI().c_str(), code);
}
void CallerConnection::OnRemoteStateChanged(const AppExecFwk::ElementName &element, int32_t abilityState)
{
HILOG_DEBUG("CallerConnection::OnRemoteStateChanged start %{public}s .", element.GetURI().c_str());
TAG_LOGD(
AAFwkTag::LOCAL_CALL, "CallerConnection::OnRemoteStateChanged start %{public}s .", element.GetURI().c_str());
if (localCallRecord_ == nullptr) {
HILOG_DEBUG("local call record is nullptr.");
TAG_LOGD(AAFwkTag::LOCAL_CALL, "local call record is nullptr.");
return;
}
localCallRecord_->NotifyRemoteStateChanged(abilityState);
HILOG_DEBUG("CallerConnection::OnRemoteStateChanged end. abilityState:%{public}d.", abilityState);
TAG_LOGD(
AAFwkTag::LOCAL_CALL, "CallerConnection::OnRemoteStateChanged end. abilityState:%{public}d.", abilityState);
return;
}
@ -396,12 +409,12 @@ int32_t LocalCallContainer::GetCurrentUserId()
if (currentUserId_ == DEFAULT_INVAL_VALUE) {
auto osAccount = DelayedSingleton<AppExecFwk::OsAccountManagerWrapper>::GetInstance();
if (osAccount == nullptr) {
HILOG_ERROR("LocalCallContainer::GetCurrentUserId get osAccount is nullptr.");
TAG_LOGE(AAFwkTag::LOCAL_CALL, "LocalCallContainer::GetCurrentUserId get osAccount is nullptr.");
return DEFAULT_INVAL_VALUE;
}
osAccount->GetOsAccountLocalIdFromProcess(currentUserId_);
HILOG_DEBUG("LocalCallContainer::GetCurrentUserId called. %{public}d", currentUserId_);
TAG_LOGD(AAFwkTag::LOCAL_CALL, "LocalCallContainer::GetCurrentUserId called. %{public}d", currentUserId_);
}
return currentUserId_;
@ -409,7 +422,7 @@ int32_t LocalCallContainer::GetCurrentUserId()
int32_t LocalCallContainer::GetValidUserId(int32_t accountId)
{
HILOG_DEBUG("LocalCallContainer::GetValidUserId is %{public}d", accountId);
TAG_LOGD(AAFwkTag::LOCAL_CALL, "LocalCallContainer::GetValidUserId is %{public}d", accountId);
if (accountId > 0 && accountId != GetCurrentUserId()) {
return accountId;
}

View File

@ -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
@ -14,6 +14,7 @@
*/
#include "local_call_record.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
namespace OHOS {
@ -39,7 +40,7 @@ LocalCallRecord::~LocalCallRecord()
void LocalCallRecord::SetRemoteObject(const sptr<IRemoteObject>& call)
{
if (call == nullptr) {
HILOG_ERROR("remote object is nullptr");
TAG_LOGE(AAFwkTag::LOCAL_CALL, "remote object is nullptr");
return;
}
@ -49,7 +50,7 @@ void LocalCallRecord::SetRemoteObject(const sptr<IRemoteObject>& call)
auto diedTask = [self](const wptr<IRemoteObject>& remote) {
auto record = self.lock();
if (record == nullptr) {
HILOG_ERROR("LocalCallRecord is null, OnCallStubDied failed.");
TAG_LOGE(AAFwkTag::LOCAL_CALL, "LocalCallRecord is null, OnCallStubDied failed.");
return;
}
record->OnCallStubDied(remote);
@ -57,14 +58,14 @@ void LocalCallRecord::SetRemoteObject(const sptr<IRemoteObject>& call)
callRecipient_ = new CallRecipient(diedTask);
}
remoteObject_->AddDeathRecipient(callRecipient_);
HILOG_DEBUG("SetRemoteObject complete.");
TAG_LOGD(AAFwkTag::LOCAL_CALL, "SetRemoteObject complete.");
}
void LocalCallRecord::SetRemoteObject(const sptr<IRemoteObject>& call,
sptr<IRemoteObject::DeathRecipient> callRecipient)
{
if (call == nullptr) {
HILOG_ERROR("remote object is nullptr");
TAG_LOGE(AAFwkTag::LOCAL_CALL, "remote object is nullptr");
return;
}
@ -72,13 +73,13 @@ void LocalCallRecord::SetRemoteObject(const sptr<IRemoteObject>& call,
callRecipient_ = callRecipient;
remoteObject_->AddDeathRecipient(callRecipient_);
HILOG_DEBUG("SetRemoteObject2 complete.");
TAG_LOGD(AAFwkTag::LOCAL_CALL, "SetRemoteObject2 complete.");
}
void LocalCallRecord::AddCaller(const std::shared_ptr<CallerCallBack>& callback)
{
if (callback == nullptr) {
HILOG_ERROR("input param is nullptr");
TAG_LOGE(AAFwkTag::LOCAL_CALL, "input param is nullptr");
return;
}
@ -89,7 +90,7 @@ void LocalCallRecord::AddCaller(const std::shared_ptr<CallerCallBack>& callback)
bool LocalCallRecord::RemoveCaller(const std::shared_ptr<CallerCallBack>& callback)
{
if (callers_.empty()) {
HILOG_ERROR("this caller vector is empty.");
TAG_LOGE(AAFwkTag::LOCAL_CALL, "this caller vector is empty.");
return false;
}
@ -100,16 +101,16 @@ bool LocalCallRecord::RemoveCaller(const std::shared_ptr<CallerCallBack>& callba
return true;
}
HILOG_ERROR("this caller callback can't find.");
TAG_LOGE(AAFwkTag::LOCAL_CALL, "this caller callback can't find.");
return false;
}
void LocalCallRecord::OnCallStubDied(const wptr<IRemoteObject>& remote)
{
HILOG_DEBUG("OnCallStubDied.");
TAG_LOGD(AAFwkTag::LOCAL_CALL, "OnCallStubDied.");
for (auto& callBack : callers_) {
if (callBack != nullptr) {
HILOG_ERROR("invoke caller's OnRelease.");
TAG_LOGE(AAFwkTag::LOCAL_CALL, "invoke caller's OnRelease.");
callBack->InvokeOnRelease(ON_DIED);
}
}
@ -118,7 +119,7 @@ void LocalCallRecord::OnCallStubDied(const wptr<IRemoteObject>& remote)
void LocalCallRecord::InvokeCallBack() const
{
if (remoteObject_ == nullptr) {
HILOG_ERROR("remote object is nullptr, can't callback.");
TAG_LOGE(AAFwkTag::LOCAL_CALL, "remote object is nullptr, can't callback.");
return;
}
@ -127,13 +128,13 @@ void LocalCallRecord::InvokeCallBack() const
callBack->InvokeCallBack(remoteObject_);
}
}
HILOG_DEBUG("finish callback with remote object.");
TAG_LOGD(AAFwkTag::LOCAL_CALL, "finish callback with remote object.");
}
void LocalCallRecord::NotifyRemoteStateChanged(int32_t abilityState)
{
if (remoteObject_ == nullptr) {
HILOG_ERROR("remote object is nullptr, can't notify.");
TAG_LOGE(AAFwkTag::LOCAL_CALL, "remote object is nullptr, can't notify.");
return;
}
std::string state = "";
@ -142,15 +143,15 @@ void LocalCallRecord::NotifyRemoteStateChanged(int32_t abilityState)
} else if (abilityState == BACKGROUND) {
state = "background";
}
HILOG_DEBUG("NotifyRemoteStateChanged, state = %{public}s.", state.c_str());
TAG_LOGD(AAFwkTag::LOCAL_CALL, "NotifyRemoteStateChanged, state = %{public}s.", state.c_str());
for (auto& callBack : callers_) {
if (callBack != nullptr && callBack->IsCallBack()) {
HILOG_INFO("callback is not nullptr, and is callbcak ");
TAG_LOGI(AAFwkTag::LOCAL_CALL, "callback is not nullptr, and is callbcak ");
callBack->InvokeOnNotify(state);
}
}
HILOG_DEBUG("finish notify remote state changed.");
TAG_LOGD(AAFwkTag::LOCAL_CALL, "finish notify remote state changed.");
}
sptr<IRemoteObject> LocalCallRecord::GetRemoteObject() const
@ -181,12 +182,12 @@ std::vector<std::shared_ptr<CallerCallBack>> LocalCallRecord::GetCallers() const
bool LocalCallRecord::IsSameObject(const sptr<IRemoteObject>& remote) const
{
if (remote == nullptr) {
HILOG_ERROR("input remote object is nullptr");
TAG_LOGE(AAFwkTag::LOCAL_CALL, "input remote object is nullptr");
return false;
}
bool retVal = (remoteObject_ == remote);
HILOG_DEBUG("LocalCallRecord::%{public}s the input object same as local object is %{public}s.",
TAG_LOGD(AAFwkTag::LOCAL_CALL, "LocalCallRecord::%{public}s the input object same as local object is %{public}s.",
__func__, retVal ? "true" : "false");
return retVal;
}

View File

@ -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 <set>
#include "event_handler.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "js_context_utils.h"
#include "js_data_struct_converter.h"
@ -67,21 +68,21 @@ public:
static bool ReleaseObject(JsCallerComplex* data)
{
HILOG_DEBUG("ReleaseObject begin");
TAG_LOGD(AAFwkTag::DEFAULT, "ReleaseObject begin");
if (data == nullptr) {
HILOG_ERROR("ReleaseObject begin, but input parameters is nullptr");
TAG_LOGE(AAFwkTag::DEFAULT, "ReleaseObject begin, but input parameters is nullptr");
return false;
}
if (!data->ChangeCurrentState(OBJSTATE::OBJ_RELEASE)) {
auto handler = data->GetEventHandler();
if (handler == nullptr) {
HILOG_ERROR("ReleaseObject error end, Get eventHandler failed");
TAG_LOGE(AAFwkTag::DEFAULT, "ReleaseObject error end, Get eventHandler failed");
return false;
}
auto releaseObjTask = [pdata = data] () {
if (!FindJsCallerComplex(pdata)) {
HILOG_ERROR("ReleaseObject error end, but input parameters does not found");
TAG_LOGE(AAFwkTag::DEFAULT, "ReleaseObject error end, but input parameters does not found");
return;
}
ReleaseObject(pdata);
@ -93,33 +94,35 @@ public:
// when the object is about to be destroyed, does not reset state
std::unique_ptr<JsCallerComplex> delObj(data);
}
HILOG_DEBUG("ReleaseObject success end");
TAG_LOGD(AAFwkTag::DEFAULT, "ReleaseObject success end");
return true;
}
static void Finalizer(napi_env env, void* data, void* hint)
{
HILOG_DEBUG("JsCallerComplex::%{public}s begin.", __func__);
TAG_LOGD(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s begin.", __func__);
if (data == nullptr) {
HILOG_ERROR("JsCallerComplex::%{public}s is called, but input parameters is nullptr", __func__);
TAG_LOGE(
AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s is called, but input parameters is nullptr", __func__);
return;
}
auto ptr = static_cast<JsCallerComplex*>(data);
if (!FindJsCallerComplex(ptr)) {
HILOG_ERROR("JsCallerComplex::%{public}s is called, but input parameters does not found", __func__);
TAG_LOGE(AAFwkTag::DEFAULT,
"JsCallerComplex::%{public}s is called, but input parameters does not found", __func__);
return;
}
ReleaseObject(ptr);
HILOG_DEBUG("JsCallerComplex::%{public}s end.", __func__);
TAG_LOGD(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s end.", __func__);
}
static napi_value JsReleaseCall(napi_env env, napi_callback_info info)
{
if (env == nullptr || info == nullptr) {
HILOG_ERROR("JsCallerComplex::%{public}s is called, but input parameters %{public}s is nullptr",
__func__,
TAG_LOGE(AAFwkTag::DEFAULT,
"JsCallerComplex::%{public}s is called, but input parameters %{public}s is nullptr", __func__,
((env == nullptr) ? "env" : "info"));
return nullptr;
}
@ -129,8 +132,8 @@ public:
static napi_value JsSetOnReleaseCallBack(napi_env env, napi_callback_info info)
{
if (env == nullptr || info == nullptr) {
HILOG_ERROR("JsCallerComplex::%{public}s is called, but input parameters %{public}s is nullptr",
__func__,
TAG_LOGE(AAFwkTag::DEFAULT,
"JsCallerComplex::%{public}s is called, but input parameters %{public}s is nullptr", __func__,
((env == nullptr) ? "env" : "info"));
return nullptr;
}
@ -140,8 +143,8 @@ public:
static napi_value JsSetOnRemoteStateChanged(napi_env env, napi_callback_info info)
{
if (env == nullptr || info == nullptr) {
HILOG_ERROR("JsCallerComplex::%{public}s is called, but input parameters %{public}s is nullptr",
__func__,
TAG_LOGE(AAFwkTag::DEFAULT,
"JsCallerComplex::%{public}s is called, but input parameters %{public}s is nullptr", __func__,
((env == nullptr) ? "env" : "info"));
return nullptr;
}
@ -151,46 +154,46 @@ public:
static bool AddJsCallerComplex(JsCallerComplex* ptr)
{
if (ptr == nullptr) {
HILOG_ERROR("JsAbilityContext::%{public}s, input parameters is nullptr", __func__);
TAG_LOGE(AAFwkTag::DEFAULT, "JsAbilityContext::%{public}s, input parameters is nullptr", __func__);
return false;
}
std::lock_guard<std::mutex> lck (jsCallerComplexMutex);
auto iter = jsCallerComplexManagerList.find(ptr);
if (iter != jsCallerComplexManagerList.end()) {
HILOG_ERROR("JsAbilityContext::%{public}s, address exists", __func__);
TAG_LOGE(AAFwkTag::DEFAULT, "JsAbilityContext::%{public}s, address exists", __func__);
return false;
}
auto iterRet = jsCallerComplexManagerList.emplace(ptr);
HILOG_DEBUG("JsAbilityContext::%{public}s, execution ends and retval is %{public}s",
__func__, iterRet.second ? "true" : "false");
TAG_LOGD(AAFwkTag::DEFAULT, "JsAbilityContext::%{public}s, execution ends and retval is %{public}s", __func__,
iterRet.second ? "true" : "false");
return iterRet.second;
}
static bool RemoveJsCallerComplex(JsCallerComplex* ptr)
{
if (ptr == nullptr) {
HILOG_ERROR("JsAbilityContext::%{public}s, input parameters is nullptr", __func__);
TAG_LOGE(AAFwkTag::DEFAULT, "JsAbilityContext::%{public}s, input parameters is nullptr", __func__);
return false;
}
std::lock_guard<std::mutex> lck (jsCallerComplexMutex);
auto iter = jsCallerComplexManagerList.find(ptr);
if (iter == jsCallerComplexManagerList.end()) {
HILOG_ERROR("JsAbilityContext::%{public}s, input parameters not found", __func__);
TAG_LOGE(AAFwkTag::DEFAULT, "JsAbilityContext::%{public}s, input parameters not found", __func__);
return false;
}
jsCallerComplexManagerList.erase(ptr);
HILOG_DEBUG("JsAbilityContext::%{public}s, called", __func__);
TAG_LOGD(AAFwkTag::DEFAULT, "JsAbilityContext::%{public}s, called", __func__);
return true;
}
static bool FindJsCallerComplex(JsCallerComplex* ptr)
{
if (ptr == nullptr) {
HILOG_ERROR("JsAbilityContext::%{public}s, input parameters is nullptr", __func__);
TAG_LOGE(AAFwkTag::DEFAULT, "JsAbilityContext::%{public}s, input parameters is nullptr", __func__);
return false;
}
auto ret = true;
@ -199,28 +202,29 @@ public:
if (iter == jsCallerComplexManagerList.end()) {
ret = false;
}
HILOG_DEBUG("JsAbilityContext::%{public}s, execution ends and retval is %{public}s",
__func__, ret ? "true" : "false");
TAG_LOGD(AAFwkTag::DEFAULT, "JsAbilityContext::%{public}s, execution ends and retval is %{public}s", __func__,
ret ? "true" : "false");
return ret;
}
static bool FindJsCallerComplexAndChangeState(JsCallerComplex* ptr, OBJSTATE state)
{
if (ptr == nullptr) {
HILOG_ERROR("JsAbilityContext::%{public}s, input parameters is nullptr", __func__);
TAG_LOGE(AAFwkTag::DEFAULT, "JsAbilityContext::%{public}s, input parameters is nullptr", __func__);
return false;
}
std::lock_guard<std::mutex> lck (jsCallerComplexMutex);
auto iter = jsCallerComplexManagerList.find(ptr);
if (iter == jsCallerComplexManagerList.end()) {
HILOG_ERROR("JsAbilityContext::%{public}s, execution end, but not found", __func__);
TAG_LOGE(AAFwkTag::DEFAULT, "JsAbilityContext::%{public}s, execution end, but not found", __func__);
return false;
}
auto ret = ptr->ChangeCurrentState(state);
HILOG_DEBUG("JsAbilityContext::%{public}s, execution ends and ChangeCurrentState retval is %{public}s",
__func__, ret ? "true" : "false");
TAG_LOGD(AAFwkTag::DEFAULT,
"JsAbilityContext::%{public}s, execution ends and ChangeCurrentState retval is %{public}s", __func__,
ret ? "true" : "false");
return ret;
}
@ -239,20 +243,20 @@ public:
{
auto ret = false;
if (stateMechanismMutex_.try_lock() == false) {
HILOG_ERROR("mutex try_lock false");
TAG_LOGE(AAFwkTag::DEFAULT, "mutex try_lock false");
return ret;
}
if (currentState_ == OBJSTATE::OBJ_NORMAL) {
currentState_ = state;
ret = true;
HILOG_DEBUG("currentState_ == OBJSTATE::OBJ_NORMAL");
TAG_LOGD(AAFwkTag::DEFAULT, "currentState_ == OBJSTATE::OBJ_NORMAL");
} else if (currentState_ == state) {
ret = true;
HILOG_DEBUG("currentState_ == state");
TAG_LOGD(AAFwkTag::DEFAULT, "currentState_ == state");
} else {
ret = false;
HILOG_DEBUG("ret = false");
TAG_LOGD(AAFwkTag::DEFAULT, "ret = false");
}
stateMechanismMutex_.unlock();
@ -273,28 +277,28 @@ private:
void OnReleaseNotify(const std::string &str)
{
HILOG_DEBUG("OnReleaseNotify begin");
TAG_LOGD(AAFwkTag::DEFAULT, "OnReleaseNotify begin");
if (handler_ == nullptr) {
HILOG_ERROR("handler parameters error");
TAG_LOGE(AAFwkTag::DEFAULT, "handler parameters error");
return;
}
auto task = [notify = this, &str] () {
if (!FindJsCallerComplex(notify)) {
HILOG_ERROR("ptr not found, address error");
TAG_LOGE(AAFwkTag::DEFAULT, "ptr not found, address error");
return;
}
notify->OnReleaseNotifyTask(str);
};
handler_->PostSyncTask(task, "OnReleaseNotify");
HILOG_DEBUG("OnReleaseNotify end");
TAG_LOGD(AAFwkTag::DEFAULT, "OnReleaseNotify end");
}
void OnReleaseNotifyTask(const std::string &str)
{
HILOG_DEBUG("OnReleaseNotifyTask begin");
TAG_LOGD(AAFwkTag::DEFAULT, "OnReleaseNotifyTask begin");
if (jsReleaseCallBackObj_ == nullptr) {
HILOG_ERROR("JsCallerComplex::%{public}s, jsreleaseObj is nullptr", __func__);
TAG_LOGE(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, jsreleaseObj is nullptr", __func__);
return;
}
@ -302,36 +306,36 @@ private:
napi_value callback = jsReleaseCallBackObj_->GetNapiValue();
napi_value args[] = { CreateJsValue(releaseCallBackEngine_, str) };
napi_call_function(releaseCallBackEngine_, value, callback, 1, args, nullptr);
HILOG_DEBUG("OnReleaseNotifyTask CallFunction call done");
TAG_LOGD(AAFwkTag::DEFAULT, "OnReleaseNotifyTask CallFunction call done");
callee_ = nullptr;
StateReset();
HILOG_DEBUG("OnReleaseNotifyTask end");
TAG_LOGD(AAFwkTag::DEFAULT, "OnReleaseNotifyTask end");
}
void OnRemoteStateChangedNotify(const std::string &str)
{
HILOG_DEBUG("OnRemoteStateChangedNotify begin");
TAG_LOGD(AAFwkTag::DEFAULT, "OnRemoteStateChangedNotify begin");
if (handler_ == nullptr) {
HILOG_ERROR("handler parameters error");
TAG_LOGE(AAFwkTag::DEFAULT, "handler parameters error");
return;
}
auto task = [notify = this, &str] () {
if (!FindJsCallerComplex(notify)) {
HILOG_ERROR("ptr not found, address error");
TAG_LOGE(AAFwkTag::DEFAULT, "ptr not found, address error");
return;
}
notify->OnRemoteStateChangedNotifyTask(str);
};
handler_->PostSyncTask(task, "OnRemoteStateChangedNotify");
HILOG_DEBUG("OnRemoteStateChangedNotify end");
TAG_LOGD(AAFwkTag::DEFAULT, "OnRemoteStateChangedNotify end");
}
void OnRemoteStateChangedNotifyTask(const std::string &str)
{
HILOG_DEBUG("OnRemoteStateChangedNotifyTask begin");
TAG_LOGD(AAFwkTag::DEFAULT, "OnRemoteStateChangedNotifyTask begin");
if (jsRemoteStateChangedObj_ == nullptr) {
HILOG_ERROR("JsCallerComplex::%{public}s, jsRemoteStateChangedObj is nullptr", __func__);
TAG_LOGE(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, jsRemoteStateChangedObj is nullptr", __func__);
return;
}
@ -339,26 +343,26 @@ private:
napi_value callback = jsRemoteStateChangedObj_->GetNapiValue();
napi_value args[] = { CreateJsValue(remoteStateChanegdEngine_, str) };
napi_call_function(remoteStateChanegdEngine_, value, callback, 1, args, nullptr);
HILOG_DEBUG("OnRemoteStateChangedNotifyTask CallFunction call done");
TAG_LOGD(AAFwkTag::DEFAULT, "OnRemoteStateChangedNotifyTask CallFunction call done");
StateReset();
HILOG_DEBUG("OnRemoteStateChangedNotifyTask end");
TAG_LOGD(AAFwkTag::DEFAULT, "OnRemoteStateChangedNotifyTask end");
}
napi_value ReleaseCallInner(napi_env env, NapiCallbackInfo& info)
{
HILOG_DEBUG("JsCallerComplex::%{public}s, called", __func__);
TAG_LOGD(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, called", __func__);
if (callerCallBackObj_ == nullptr) {
HILOG_ERROR("JsCallerComplex::%{public}s, CallBacker is nullptr", __func__);
TAG_LOGE(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, CallBacker is nullptr", __func__);
ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER);
}
if (!releaseCallFunc_) {
HILOG_ERROR("JsCallerComplex::%{public}s, releaseFunc is nullptr", __func__);
TAG_LOGE(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, releaseFunc is nullptr", __func__);
ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER);
}
int32_t innerErrorCode = releaseCallFunc_(callerCallBackObj_);
if (innerErrorCode != ERR_OK) {
HILOG_ERROR("JsCallerComplex::%{public}s, ReleaseAbility failed %{public}d",
TAG_LOGE(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, ReleaseAbility failed %{public}d",
__func__, static_cast<int>(innerErrorCode));
ThrowError(env, innerErrorCode);
}
@ -368,28 +372,28 @@ private:
napi_value SetOnReleaseCallBackInner(napi_env env, NapiCallbackInfo& info)
{
HILOG_DEBUG("JsCallerComplex::%{public}s, start", __func__);
TAG_LOGD(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, start", __func__);
constexpr size_t argcOne = 1;
if (info.argc < argcOne) {
HILOG_ERROR("JsCallerComplex::%{public}s, Invalid input parameters", __func__);
TAG_LOGE(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, Invalid input parameters", __func__);
ThrowTooFewParametersError(env);
}
bool isCallable = false;
napi_is_callable(env, info.argv[0], &isCallable);
if (!isCallable) {
HILOG_ERROR("JsCallerComplex::%{public}s, IsCallable is %{public}s.",
TAG_LOGE(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, IsCallable is %{public}s.",
__func__, isCallable ? "true" : "false");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
}
if (callerCallBackObj_ == nullptr) {
HILOG_ERROR("JsCallerComplex::%{public}s, CallBacker is null", __func__);
TAG_LOGE(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, CallBacker is null", __func__);
ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER);
}
auto param1 = info.argv[0];
if (param1 == nullptr) {
HILOG_ERROR("JsCallerComplex::%{public}s, param1 is null", __func__);
TAG_LOGE(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, param1 is null", __func__);
ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER);
}
@ -398,40 +402,40 @@ private:
jsReleaseCallBackObj_.reset(reinterpret_cast<NativeReference*>(ref));
auto task = [notify = this] (const std::string &str) {
if (!FindJsCallerComplexAndChangeState(notify, OBJSTATE::OBJ_EXECUTION)) {
HILOG_ERROR("ptr not found, address error");
TAG_LOGE(AAFwkTag::DEFAULT, "ptr not found, address error");
return;
}
notify->OnReleaseNotify(str);
};
callerCallBackObj_->SetOnRelease(task);
HILOG_DEBUG("JsCallerComplex::%{public}s, end", __func__);
TAG_LOGD(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, end", __func__);
return CreateJsUndefined(env);
}
napi_value SetOnRemoteStateChangedInner(napi_env env, NapiCallbackInfo& info)
{
HILOG_DEBUG("JsCallerComplex::%{public}s, begin", __func__);
TAG_LOGD(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, begin", __func__);
constexpr size_t argcOne = 1;
if (info.argc < argcOne) {
HILOG_ERROR("JsCallerComplex::%{public}s, Invalid input params", __func__);
TAG_LOGE(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, Invalid input params", __func__);
ThrowTooFewParametersError(env);
}
bool isCallable = false;
napi_is_callable(env, info.argv[0], &isCallable);
if (!isCallable) {
HILOG_ERROR("JsCallerComplex::%{public}s, IsCallable is %{public}s.",
TAG_LOGE(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, IsCallable is %{public}s.",
__func__, isCallable ? "true" : "false");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
}
if (callerCallBackObj_ == nullptr) {
HILOG_ERROR("JsCallerComplex::%{public}s, CallBacker is nullptr", __func__);
TAG_LOGE(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, CallBacker is nullptr", __func__);
ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER);
}
auto param1 = info.argv[0];
if (param1 == nullptr) {
HILOG_ERROR("JsCallerComplex::%{public}s, param1 is nullptr", __func__);
TAG_LOGE(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, param1 is nullptr", __func__);
ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER);
}
@ -439,15 +443,15 @@ private:
napi_create_reference(remoteStateChanegdEngine_, param1, 1, &ref);
jsRemoteStateChangedObj_.reset(reinterpret_cast<NativeReference*>(ref));
auto task = [notify = this] (const std::string &str) {
HILOG_INFO("state changed");
TAG_LOGI(AAFwkTag::DEFAULT, "state changed");
if (!FindJsCallerComplexAndChangeState(notify, OBJSTATE::OBJ_EXECUTION)) {
HILOG_ERROR("ptr not found, address error");
TAG_LOGE(AAFwkTag::DEFAULT, "ptr not found, address error");
return;
}
notify->OnRemoteStateChangedNotify(str);
};
callerCallBackObj_->SetOnRemoteStateChanged(task);
HILOG_DEBUG("JsCallerComplex::%{public}s, end", __func__);
TAG_LOGD(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, end", __func__);
return CreateJsUndefined(env);
}
@ -475,9 +479,9 @@ napi_value CreateJsCallerComplex(
napi_env env, ReleaseCallFunc releaseCallFunc, sptr<IRemoteObject> callee,
std::shared_ptr<CallerCallBack> callerCallBack)
{
HILOG_DEBUG("JsCallerComplex::%{public}s, begin", __func__);
TAG_LOGD(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, begin", __func__);
if (callee == nullptr || callerCallBack == nullptr || releaseCallFunc == nullptr) {
HILOG_ERROR("%{public}s is called, input params error. %{public}s is nullptr", __func__,
TAG_LOGE(AAFwkTag::DEFAULT, "%{public}s is called, input params error. %{public}s is nullptr", __func__,
(callee == nullptr) ? ("callee") :
((releaseCallFunc == nullptr) ? ("releaseCallFunc") : ("callerCallBack")));
return CreateJsUndefined(env);
@ -488,7 +492,7 @@ napi_value CreateJsCallerComplex(
auto jsCaller = std::make_unique<JsCallerComplex>(env, releaseCallFunc, callee, callerCallBack);
auto remoteObj = jsCaller->GetRemoteObject();
if (remoteObj == nullptr) {
HILOG_ERROR("%{public}s is called,remoteObj is nullptr", __func__);
TAG_LOGE(AAFwkTag::DEFAULT, "%{public}s is called,remoteObj is nullptr", __func__);
return CreateJsUndefined(env);
}
@ -499,19 +503,19 @@ napi_value CreateJsCallerComplex(
BindNativeFunction(env, object, "onRelease", moduleName, JsCallerComplex::JsSetOnReleaseCallBack);
BindNativeFunction(env, object, "onRemoteStateChange", moduleName, JsCallerComplex::JsSetOnRemoteStateChanged);
HILOG_DEBUG("JsCallerComplex::%{public}s, end", __func__);
TAG_LOGD(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s, end", __func__);
return object;
}
napi_value CreateJsCalleeRemoteObject(napi_env env, sptr<IRemoteObject> callee)
{
if (callee == nullptr) {
HILOG_ERROR("%{public}s is called, input params is nullptr", __func__);
TAG_LOGE(AAFwkTag::DEFAULT, "%{public}s is called, input params is nullptr", __func__);
return CreateJsUndefined(env);
}
napi_value napiRemoteObject = NAPI_ohos_rpc_CreateJsRemoteObject(env, callee);
if (napiRemoteObject == nullptr) {
HILOG_ERROR("%{public}s is called, but remoteObj is nullptr", __func__);
TAG_LOGE(AAFwkTag::DEFAULT, "%{public}s is called, but remoteObj is nullptr", __func__);
}
return napiRemoteObject;
}

View File

@ -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
@ -14,6 +14,7 @@
*/
#include "dummy_values_bucket.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "string_ex.h"
@ -43,7 +44,7 @@ ValuesBucket ValuesBucket::Unmarshalling(Parcel &parcel)
{
ValuesBucket valuesBucket;
if (!valuesBucket.ReadFromParcel(parcel)) {
HILOG_ERROR("ValuesBucket::Unmarshalling ReadFromParcel failed");
TAG_LOGE(AAFwkTag::DEFAULT, "ValuesBucket::Unmarshalling ReadFromParcel failed");
}
return valuesBucket;
}
@ -56,7 +57,7 @@ ValuesBucket ValuesBucket::Unmarshalling(Parcel &parcel)
bool ValuesBucket::Marshalling(Parcel &parcel) const
{
if (!parcel.WriteString16(Str8ToStr16(testInf_))) {
HILOG_ERROR("valuesBucket::Marshalling WriteString16 failed");
TAG_LOGE(AAFwkTag::DEFAULT, "valuesBucket::Marshalling WriteString16 failed");
return false;
}
return true;

View File

@ -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
@ -20,11 +20,11 @@
#include "js_env_logger.h"
#ifndef ENV_LOG_DOMAIN
#define ENV_LOG_DOMAIN 0xD001300
#define ENV_LOG_DOMAIN 0xD001320
#endif
#ifndef ENV_LOG_TAG
#define ENV_LOG_TAG "JsEnv"
#define ENV_LOG_TAG "AAFwkJsEnv"
#endif
namespace OHOS {

View File

@ -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
@ -20,6 +20,7 @@
#include "appexecfwk_errors.h"
#include "bundle_constants.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "json_serializer.h"
@ -57,7 +58,7 @@ void CheckArrayType(
case ArrayType::STRING:
for (const auto &array : arrays) {
if (!array.is_string()) {
HILOG_DEBUG("array %{public}s is not string type", key.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "array %{public}s is not string type", key.c_str());
parseResult = ERR_APPEXECFWK_PARSE_PROFILE_PROP_TYPE_ERROR;
}
}
@ -68,7 +69,7 @@ void CheckArrayType(
case ArrayType::OBJECT:
for (const auto &array : arrays) {
if (!array.is_object()) {
HILOG_DEBUG("array %{public}s is not object type", key.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "array %{public}s is not object type", key.c_str());
parseResult = ERR_APPEXECFWK_PARSE_PROFILE_PROP_TYPE_ERROR;
break;
}
@ -80,7 +81,7 @@ void CheckArrayType(
case ArrayType::NUMBER:
for (const auto &array : arrays) {
if (!array.is_number()) {
HILOG_DEBUG("array %{public}s is not number type", key.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "array %{public}s is not number type", key.c_str());
parseResult = ERR_APPEXECFWK_PARSE_PROFILE_PROP_TYPE_ERROR;
}
}
@ -89,10 +90,10 @@ void CheckArrayType(
}
break;
case ArrayType::NOT_ARRAY:
HILOG_DEBUG("array %{public}s is not string type", key.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "array %{public}s is not string type", key.c_str());
break;
default:
HILOG_DEBUG("array %{public}s type error", key.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "array %{public}s type error", key.c_str());
break;
}
}
@ -109,7 +110,7 @@ void GetValueIfFindKey(const nlohmann::json &jsonObject, const nlohmann::detail:
switch (jsonType) {
case JsonType::BOOLEAN:
if (!jsonObject.at(key).is_boolean()) {
HILOG_DEBUG("type is error %{public}s is not boolean", key.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "type is error %{public}s is not boolean", key.c_str());
parseResult = ERR_APPEXECFWK_PARSE_PROFILE_PROP_TYPE_ERROR;
break;
}
@ -117,7 +118,7 @@ void GetValueIfFindKey(const nlohmann::json &jsonObject, const nlohmann::detail:
break;
case JsonType::NUMBER:
if (!jsonObject.at(key).is_number()) {
HILOG_DEBUG("type is error %{public}s is not number", key.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "type is error %{public}s is not number", key.c_str());
parseResult = ERR_APPEXECFWK_PARSE_PROFILE_PROP_TYPE_ERROR;
break;
}
@ -125,7 +126,7 @@ void GetValueIfFindKey(const nlohmann::json &jsonObject, const nlohmann::detail:
break;
case JsonType::OBJECT:
if (!jsonObject.at(key).is_object()) {
HILOG_DEBUG("type is error %{public}s is not object", key.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "type is error %{public}s is not object", key.c_str());
parseResult = ERR_APPEXECFWK_PARSE_PROFILE_PROP_TYPE_ERROR;
break;
}
@ -133,7 +134,7 @@ void GetValueIfFindKey(const nlohmann::json &jsonObject, const nlohmann::detail:
break;
case JsonType::ARRAY:
if (!jsonObject.at(key).is_array()) {
HILOG_DEBUG("type is error %{public}s is not array", key.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "type is error %{public}s is not array", key.c_str());
parseResult = ERR_APPEXECFWK_PARSE_PROFILE_PROP_TYPE_ERROR;
break;
}
@ -141,7 +142,7 @@ void GetValueIfFindKey(const nlohmann::json &jsonObject, const nlohmann::detail:
break;
case JsonType::STRING:
if (!jsonObject.at(key).is_string()) {
HILOG_DEBUG("type is error %{public}s is not string", key.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "type is error %{public}s is not string", key.c_str());
parseResult = ERR_APPEXECFWK_PARSE_PROFILE_PROP_TYPE_ERROR;
break;
}
@ -151,16 +152,16 @@ void GetValueIfFindKey(const nlohmann::json &jsonObject, const nlohmann::detail:
}
break;
case JsonType::NULLABLE:
HILOG_DEBUG("type is error %{public}s is nullable", key.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "type is error %{public}s is nullable", key.c_str());
break;
default:
HILOG_DEBUG("type is error %{public}s is not jsonType", key.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "type is error %{public}s is not jsonType", key.c_str());
parseResult = ERR_APPEXECFWK_PARSE_PROFILE_PROP_TYPE_ERROR;
}
return;
}
if (isNecessary) {
HILOG_DEBUG("profile prop %{public}s is mission", key.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "profile prop %{public}s is mission", key.c_str());
parseResult = ERR_APPEXECFWK_PARSE_PROFILE_MISSING_PROP;
}
}
@ -176,13 +177,13 @@ template<typename T>
bool ParseInfoFromJsonStr(const char *data, T &t)
{
if (data == nullptr) {
HILOG_DEBUG("%{public}s failed due to data is nullptr", __func__);
TAG_LOGD(AAFwkTag::ABILITY_SIM, "%{public}s failed due to data is nullptr", __func__);
return false;
}
nlohmann::json jsonObject = nlohmann::json::parse(data, nullptr, false);
if (jsonObject.is_discarded()) {
HILOG_DEBUG("%{public}s failed due to data is discarded", __func__);
TAG_LOGD(AAFwkTag::ABILITY_SIM, "%{public}s failed due to data is discarded", __func__);
return false;
}

View File

@ -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_context.h"
#include <cstring>
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
namespace OHOS {
@ -54,31 +55,31 @@ void AbilityContext::SetOptions(const Options &options)
{
options_ = options;
HILOG_DEBUG("Options.bundleName: %{public}s", options.bundleName.c_str());
HILOG_DEBUG("Options.moduleName: %{public}s", options.moduleName.c_str());
HILOG_DEBUG("Options.modulePath: %{public}s", options.modulePath.c_str());
HILOG_DEBUG("Options.resourcePath: %{public}s", options.resourcePath.c_str());
HILOG_DEBUG("Options.debugPort: %{public}d", options.debugPort);
HILOG_DEBUG("Options.assetPath: %{public}s", options.assetPath.c_str());
HILOG_DEBUG("Options.systemResourcePath: %{public}s", options.systemResourcePath.c_str());
HILOG_DEBUG("Options.appResourcePath: %{public}s", options.appResourcePath.c_str());
HILOG_DEBUG("Options.containerSdkPath: %{public}s", options.containerSdkPath.c_str());
HILOG_DEBUG("Options.url: %{public}s", options.url.c_str());
HILOG_DEBUG("Options.language: %{public}s", options.language.c_str());
HILOG_DEBUG("Options.region: %{public}s", options.region.c_str());
HILOG_DEBUG("Options.script: %{public}s", options.script.c_str());
HILOG_DEBUG("Options.themeId: %{public}d", options.themeId);
HILOG_DEBUG("Options.deviceWidth: %{public}d", options.deviceWidth);
HILOG_DEBUG("Options.deviceHeight: %{public}d", options.deviceHeight);
HILOG_DEBUG("Options.isRound: %{public}d", options.themeId);
HILOG_DEBUG("Options.compatibleVersion: %{public}d", options.compatibleVersion);
HILOG_DEBUG("Options.installationFree: %{public}d", options.installationFree);
HILOG_DEBUG("Options.labelId: %{public}d", options.labelId);
HILOG_DEBUG("Options.compileMode: %{public}s", options.compileMode.c_str());
HILOG_DEBUG("Options.pageProfile: %{public}s", options.pageProfile.c_str());
HILOG_DEBUG("Options.targetVersion: %{public}d", options.targetVersion);
HILOG_DEBUG("Options.releaseType: %{public}s", options.releaseType.c_str());
HILOG_DEBUG("Options.enablePartialUpdate: %{public}d", options.enablePartialUpdate);
TAG_LOGD(AAFwkTag::ABILITY_SIM, "Options.bundleName: %{public}s", options.bundleName.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "Options.moduleName: %{public}s", options.moduleName.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "Options.modulePath: %{public}s", options.modulePath.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "Options.resourcePath: %{public}s", options.resourcePath.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "Options.debugPort: %{public}d", options.debugPort);
TAG_LOGD(AAFwkTag::ABILITY_SIM, "Options.assetPath: %{public}s", options.assetPath.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "Options.systemResourcePath: %{public}s", options.systemResourcePath.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "Options.appResourcePath: %{public}s", options.appResourcePath.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "Options.containerSdkPath: %{public}s", options.containerSdkPath.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "Options.url: %{public}s", options.url.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "Options.language: %{public}s", options.language.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "Options.region: %{public}s", options.region.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "Options.script: %{public}s", options.script.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "Options.themeId: %{public}d", options.themeId);
TAG_LOGD(AAFwkTag::ABILITY_SIM, "Options.deviceWidth: %{public}d", options.deviceWidth);
TAG_LOGD(AAFwkTag::ABILITY_SIM, "Options.deviceHeight: %{public}d", options.deviceHeight);
TAG_LOGD(AAFwkTag::ABILITY_SIM, "Options.isRound: %{public}d", options.themeId);
TAG_LOGD(AAFwkTag::ABILITY_SIM, "Options.compatibleVersion: %{public}d", options.compatibleVersion);
TAG_LOGD(AAFwkTag::ABILITY_SIM, "Options.installationFree: %{public}d", options.installationFree);
TAG_LOGD(AAFwkTag::ABILITY_SIM, "Options.labelId: %{public}d", options.labelId);
TAG_LOGD(AAFwkTag::ABILITY_SIM, "Options.compileMode: %{public}s", options.compileMode.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "Options.pageProfile: %{public}s", options.pageProfile.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "Options.targetVersion: %{public}d", options.targetVersion);
TAG_LOGD(AAFwkTag::ABILITY_SIM, "Options.releaseType: %{public}s", options.releaseType.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "Options.enablePartialUpdate: %{public}d", options.enablePartialUpdate);
}
std::string AbilityContext::GetBundleName()

View File

@ -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_stage_context.h"
#include <cstring>
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
namespace OHOS {
@ -187,9 +188,9 @@ std::string AbilityStageContext::GetDistributedFilesDir()
void AbilityStageContext::SwitchArea(int mode)
{
HILOG_DEBUG("called, mode:%{public}d.", mode);
TAG_LOGD(AAFwkTag::ABILITY_SIM, "called, mode:%{public}d.", mode);
if (mode < 0 || mode >= static_cast<int>(sizeof(CONTEXT_ELS) / sizeof(CONTEXT_ELS[0]))) {
HILOG_ERROR("mode is invalid.");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "mode is invalid.");
return;
}
currArea_ = CONTEXT_ELS[mode];
@ -197,7 +198,7 @@ void AbilityStageContext::SwitchArea(int mode)
int AbilityStageContext::GetArea()
{
HILOG_DEBUG("called");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "called");
int mode = -1;
for (int i = 0; i < static_cast<int>(sizeof(CONTEXT_ELS) / sizeof(CONTEXT_ELS[0])); i++) {
if (currArea_ == CONTEXT_ELS[i]) {
@ -206,7 +207,7 @@ int AbilityStageContext::GetArea()
}
}
if (mode == -1) {
HILOG_ERROR("Not find mode.");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Not find mode.");
return EL_DEFAULT;
}
return mode;
@ -230,11 +231,11 @@ std::string AbilityStageContext::GetPreviewPath()
bool AbilityStageContext::Access(const std::string &path)
{
HILOG_DEBUG("Access: dir: %{public}s", path.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "Access: dir: %{public}s", path.c_str());
std::unique_ptr<uv_fs_t, decltype(AbilityStageContext::FsReqCleanup)*> access_req = {
new uv_fs_t, AbilityStageContext::FsReqCleanup };
if (!access_req) {
HILOG_ERROR("Failed to request heap memory.");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Failed to request heap memory.");
return false;
}
@ -243,29 +244,29 @@ bool AbilityStageContext::Access(const std::string &path)
void AbilityStageContext::Mkdir(const std::string &path)
{
HILOG_DEBUG("Mkdir: dir: %{public}s", path.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "Mkdir: dir: %{public}s", path.c_str());
std::unique_ptr<uv_fs_t, decltype(AbilityStageContext::FsReqCleanup)*> mkdir_req = {
new uv_fs_t, AbilityStageContext::FsReqCleanup };
if (!mkdir_req) {
HILOG_ERROR("Failed to request heap memory.");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Failed to request heap memory.");
return;
}
int ret = uv_fs_mkdir(nullptr, mkdir_req.get(), path.c_str(), DIR_DEFAULT_PERM, nullptr);
if (ret < 0) {
HILOG_ERROR("Failed to create directory");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Failed to create directory");
}
}
bool AbilityStageContext::CreateMultiDir(const std::string &path)
{
if (path.empty()) {
HILOG_DEBUG("path is empty");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "path is empty");
return false;
}
if (Access(path)) {
HILOG_DEBUG("path is already exist");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "path is already exist");
return true;
}

View File

@ -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
@ -21,6 +21,7 @@
#include <unistd.h>
#include "bundle_constants.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "json_util.h"
#include "nlohmann/json.hpp"
@ -130,7 +131,7 @@ void to_json(nlohmann::json &jsonObject, const Metadata &metadata)
void to_json(nlohmann::json &jsonObject, const AbilityInfo &abilityInfo)
{
HILOG_DEBUG("AbilityInfo to_json begin");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "AbilityInfo to_json begin");
jsonObject = nlohmann::json {
{JSON_KEY_NAME, abilityInfo.name},
{JSON_KEY_LABEL, abilityInfo.label},
@ -287,13 +288,14 @@ void from_json(const nlohmann::json &jsonObject, Metadata &metadata)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
HILOG_DEBUG("read Ability Metadata from database error, error code : %{public}d", parseResult);
TAG_LOGD(
AAFwkTag::ABILITY_SIM, "read Ability Metadata from database error, error code : %{public}d", parseResult);
}
}
void from_json(const nlohmann::json &jsonObject, AbilityInfo &abilityInfo)
{
HILOG_DEBUG("AbilityInfo from_json begin");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "AbilityInfo from_json begin");
const auto &jsonObjectEnd = jsonObject.end();
int32_t parseResult = ERR_OK;
GetValueIfFindKey<std::string>(jsonObject,

View File

@ -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
@ -22,6 +22,7 @@
#include <unistd.h>
#include "bundle_constants.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "json_serializer.h"
#include "json_util.h"
@ -148,7 +149,7 @@ void from_json(const nlohmann::json &jsonObject, Resource &resource)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
HILOG_DEBUG("read Resource from database error, error code : %{public}d", parseResult);
TAG_LOGD(AAFwkTag::ABILITY_SIM, "read Resource from database error, error code : %{public}d", parseResult);
}
}
@ -865,7 +866,7 @@ void from_json(const nlohmann::json &jsonObject, ApplicationInfo &applicationInf
parseResult,
ArrayType::NUMBER);
if (parseResult != ERR_OK) {
HILOG_ERROR("from_json error, error code : %{public}d", parseResult);
TAG_LOGE(AAFwkTag::ABILITY_SIM, "from_json error, error code : %{public}d", parseResult);
}
}
} // namespace AppExecFwk

View File

@ -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 <nlohmann/json.hpp>
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "json_serializer.h"
#include "module_profile.h"
@ -33,7 +34,7 @@ void BundleContainer::LoadBundleInfos(const std::vector<uint8_t> &buffer)
{
bundleInfo_ = std::make_shared<InnerBundleInfo>();
if (!bundleInfo_) {
HILOG_DEBUG("bundleInfo_ is nullptr");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "bundleInfo_ is nullptr");
return;
}
@ -56,7 +57,8 @@ std::shared_ptr<HapModuleInfo> BundleContainer::GetHapModuleInfo(const std::stri
{
if (bundleInfo_ != nullptr) {
auto uid = Constants::UNSPECIFIED_USERID;
HILOG_INFO("BundleContainer GetHapModuleInfo by modulePackage %{public}s", modulePackage.c_str());
TAG_LOGI(AAFwkTag::ABILITY_SIM,
"BundleContainer GetHapModuleInfo by modulePackage %{public}s", modulePackage.c_str());
std::optional<HapModuleInfo> hapMouduleInfo = bundleInfo_->FindHapModuleInfo(modulePackage, uid);
if (hapMouduleInfo) {
auto hapInfo = std::make_shared<HapModuleInfo>();

View File

@ -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
@ -20,6 +20,7 @@
#include <unistd.h>
#include "bundle_constants.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "json_util.h"
#include "nlohmann/json.hpp"
@ -52,7 +53,7 @@ const std::string UID = "uid";
}; // namespace
void to_json(nlohmann::json &jsonObject, const ExtensionAbilityInfo &extensionInfo)
{
HILOG_DEBUG("ExtensionAbilityInfo to_json begin");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "ExtensionAbilityInfo to_json begin");
jsonObject = nlohmann::json {
{Constants::BUNDLE_NAME, extensionInfo.bundleName},
{Constants::MODULE_NAME, extensionInfo.moduleName},
@ -83,7 +84,7 @@ void to_json(nlohmann::json &jsonObject, const ExtensionAbilityInfo &extensionIn
void from_json(const nlohmann::json &jsonObject, ExtensionAbilityInfo &extensionInfo)
{
HILOG_DEBUG("ExtensionAbilityInfo from_json begin");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "ExtensionAbilityInfo from_json begin");
const auto &jsonObjectEnd = jsonObject.end();
int32_t parseResult = ERR_OK;
GetValueIfFindKey<std::string>(jsonObject,
@ -279,7 +280,7 @@ void from_json(const nlohmann::json &jsonObject, ExtensionAbilityInfo &extension
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
HILOG_ERROR("ExtensionAbilityInfo from_json error, error code : %{public}d", parseResult);
TAG_LOGE(AAFwkTag::ABILITY_SIM, "ExtensionAbilityInfo from_json error, error code : %{public}d", parseResult);
}
}
} // namespace AppExecFwk

View File

@ -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 "hap_module_info.h"
#include "bundle_constants.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "json_util.h"
#include "nlohmann/json.hpp"
@ -99,7 +100,7 @@ void from_json(const nlohmann::json &jsonObject, PreloadItem &preloadItem)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
HILOG_ERROR("read PreloadItem from database error, error code : %{public}d", parseResult);
TAG_LOGE(AAFwkTag::ABILITY_SIM, "read PreloadItem from database error, error code : %{public}d", parseResult);
}
}
@ -150,7 +151,7 @@ void from_json(const nlohmann::json &jsonObject, ProxyData &proxyData)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
HILOG_ERROR("read ProxyData from database error, error code : %{public}d", parseResult);
TAG_LOGE(AAFwkTag::ABILITY_SIM, "read ProxyData from database error, error code : %{public}d", parseResult);
}
}
@ -606,7 +607,7 @@ void from_json(const nlohmann::json &jsonObject, HapModuleInfo &hapModuleInfo)
parseResult,
ArrayType::STRING);
if (parseResult != ERR_OK) {
HILOG_ERROR("HapModuleInfo from_json error, error code : %{public}d", parseResult);
TAG_LOGE(AAFwkTag::ABILITY_SIM, "HapModuleInfo from_json error, error code : %{public}d", parseResult);
}
}
} // namespace AppExecFwk

View File

@ -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
@ -21,6 +21,7 @@
#include <unistd.h>
#include "common_profile.h"
#include "hilog_tag_wrapper.h"
#include "string_ex.h"
namespace OHOS {
@ -132,9 +133,9 @@ InnerBundleInfo::InnerBundleInfo()
{
baseApplicationInfo_ = std::make_shared<ApplicationInfo>();
if (baseApplicationInfo_ == nullptr) {
HILOG_ERROR("baseApplicationInfo_ is nullptr, create failed");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "baseApplicationInfo_ is nullptr, create failed");
}
HILOG_DEBUG("inner bundle info instance is created");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "inner bundle info instance is created");
}
InnerBundleInfo &InnerBundleInfo::operator=(const InnerBundleInfo &info)
@ -165,7 +166,7 @@ InnerBundleInfo &InnerBundleInfo::operator=(const InnerBundleInfo &info)
InnerBundleInfo::~InnerBundleInfo()
{
HILOG_DEBUG("inner bundle info instance is destroyed");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "inner bundle info instance is destroyed");
}
void to_json(nlohmann::json &jsonObject, const Distro &distro)
@ -701,7 +702,8 @@ void from_json(const nlohmann::json &jsonObject, InnerModuleInfo &info)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
HILOG_ERROR("read InnerModuleInfo from database error, error code : %{public}d", parseResult);
TAG_LOGE(
AAFwkTag::ABILITY_SIM, "read InnerModuleInfo from database error, error code : %{public}d", parseResult);
}
}
@ -734,13 +736,13 @@ void from_json(const nlohmann::json &jsonObject, Dependency &dependency)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
HILOG_ERROR("Dependency from_json error, error code : %{public}d", parseResult);
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Dependency from_json error, error code : %{public}d", parseResult);
}
}
void from_json(const nlohmann::json &jsonObject, Distro &distro)
{
HILOG_DEBUG("from_json start.");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "from_json start.");
const auto &jsonObjectEnd = jsonObject.end();
int32_t parseResult = ERR_OK;
GetValueIfFindKey<bool>(jsonObject,
@ -777,7 +779,7 @@ void from_json(const nlohmann::json &jsonObject, Distro &distro)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
HILOG_ERROR("Distro from_json error, error code : %{public}d", parseResult);
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Distro from_json error, error code : %{public}d", parseResult);
}
}
@ -882,7 +884,8 @@ int32_t InnerBundleInfo::FromJson(const nlohmann::json &jsonObject)
parseResult,
ArrayType::NOT_ARRAY);
if (parseResult != ERR_OK) {
HILOG_ERROR("read InnerBundleInfo from database error, error code : %{public}d", parseResult);
TAG_LOGE(
AAFwkTag::ABILITY_SIM, "read InnerBundleInfo from database error, error code : %{public}d", parseResult);
}
return parseResult;
}
@ -891,7 +894,7 @@ std::optional<HapModuleInfo> InnerBundleInfo::FindHapModuleInfo(const std::strin
{
auto it = innerModuleInfos_.find(modulePackage);
if (it == innerModuleInfos_.end()) {
HILOG_ERROR("can not find module %{public}s", modulePackage.c_str());
TAG_LOGE(AAFwkTag::ABILITY_SIM, "can not find module %{public}s", modulePackage.c_str());
return std::nullopt;
}
HapModuleInfo hapInfo;
@ -1014,7 +1017,8 @@ ErrCode InnerBundleInfo::FindAbilityInfo(
}
}
}
HILOG_ERROR("bundleName:%{public}s not find moduleName:%{public}s, abilityName:%{public}s, isModuleFind:%{public}d",
TAG_LOGE(AAFwkTag::ABILITY_SIM,
"bundleName:%{public}s not find moduleName:%{public}s, abilityName:%{public}s, isModuleFind:%{public}d",
GetBundleName().c_str(), moduleName.c_str(), abilityName.c_str(), isModuleFind);
if (isModuleFind) {
return ERR_BUNDLE_MANAGER_ABILITY_NOT_EXIST;

View File

@ -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 "module_info.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "json_util.h"
#include "nlohmann/json.hpp"
@ -64,7 +65,8 @@ void from_json(const nlohmann::json &jsonObject, ModuleInfo &moduleInfo)
parseResult,
ArrayType::STRING);
if (parseResult != ERR_OK) {
HILOG_ERROR("read module moduleInfo from jsonObject error, error code : %{public}d", parseResult);
TAG_LOGE(AAFwkTag::ABILITY_SIM,
"read module moduleInfo from jsonObject error, error code : %{public}d", parseResult);
}
}
} // namespace AppExecFwk

View File

@ -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
@ -21,6 +21,7 @@
#include <sstream>
#include "bundle_constants.h"
#include "common_profile.h"
#include "hilog_tag_wrapper.h"
#include "string_ex.h"
namespace OHOS {
@ -56,7 +57,7 @@ const std::unordered_map<std::string, ExtensionAbilityType> EXTENSION_TYPE_MAP =
ExtensionAbilityType ConvertToExtensionAbilityType(const std::string &type)
{
HILOG_DEBUG("ConvertToExtensionAbilityType start");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "ConvertToExtensionAbilityType start");
if (EXTENSION_TYPE_MAP.find(type) != EXTENSION_TYPE_MAP.end()) {
return EXTENSION_TYPE_MAP.at(type);
}
@ -66,7 +67,7 @@ ExtensionAbilityType ConvertToExtensionAbilityType(const std::string &type)
std::string ConvertToExtensionTypeName(ExtensionAbilityType type)
{
HILOG_DEBUG("ConvertToExtensionTypeName start");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "ConvertToExtensionTypeName start");
for (const auto &[key, val] : EXTENSION_TYPE_MAP) {
if (val == type) {
return key;
@ -284,7 +285,7 @@ struct ModuleJson {
void from_json(const nlohmann::json &jsonObject, Metadata &metadata)
{
HILOG_DEBUG("read metadata tag from module.json");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "read metadata tag from module.json");
const auto &jsonObjectEnd = jsonObject.end();
GetValueIfFindKey<std::string>(jsonObject,
jsonObjectEnd,
@ -314,7 +315,7 @@ void from_json(const nlohmann::json &jsonObject, Metadata &metadata)
void from_json(const nlohmann::json &jsonObject, Ability &ability)
{
HILOG_DEBUG("read ability tag from module.json");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "read ability tag from module.json");
const auto &jsonObjectEnd = jsonObject.end();
GetValueIfFindKey<std::string>(jsonObject,
jsonObjectEnd,
@ -589,7 +590,7 @@ void from_json(const nlohmann::json &jsonObject, Ability &ability)
void from_json(const nlohmann::json &jsonObject, Extension &extension)
{
HILOG_DEBUG("read extension tag from module.json");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "read extension tag from module.json");
const auto &jsonObjectEnd = jsonObject.end();
GetValueIfFindKey<std::string>(jsonObject,
jsonObjectEnd,
@ -815,7 +816,7 @@ void from_json(const nlohmann::json &jsonObject, DeviceConfig &deviceConfig)
void from_json(const nlohmann::json &jsonObject, App &app)
{
HILOG_DEBUG("read app tag from module.json");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "read app tag from module.json");
const auto &jsonObjectEnd = jsonObject.end();
GetValueIfFindKey<std::string>(jsonObject,
jsonObjectEnd,
@ -1144,7 +1145,7 @@ void from_json(const nlohmann::json &jsonObject, App &app)
void from_json(const nlohmann::json &jsonObject, Module &module)
{
HILOG_DEBUG("read module tag from module.json");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "read module tag from module.json");
const auto &jsonObjectEnd = jsonObject.end();
GetValueIfFindKey<std::string>(jsonObject,
jsonObjectEnd,
@ -1423,7 +1424,7 @@ bool CheckModuleNameIsValid(const std::string &moduleName)
return false;
}
if (moduleName.find(Constants::MODULE_NAME_SEPARATOR) != std::string::npos) {
HILOG_ERROR("module name should not contain ,");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "module name should not contain ,");
return false;
}
return true;
@ -1443,7 +1444,7 @@ bool ToApplicationInfo(
const TransformParam &transformParam,
ApplicationInfo &applicationInfo)
{
HILOG_DEBUG("transform ModuleJson to ApplicationInfo");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "transform ModuleJson to ApplicationInfo");
auto app = moduleJson.app;
applicationInfo.name = app.bundleName;
applicationInfo.bundleName = app.bundleName;
@ -1554,7 +1555,7 @@ bool ToAbilityInfo(
const TransformParam &transformParam,
AbilityInfo &abilityInfo)
{
HILOG_DEBUG("transform ModuleJson to AbilityInfo");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "transform ModuleJson to AbilityInfo");
abilityInfo.name = ability.name;
abilityInfo.srcEntrance = ability.srcEntrance;
abilityInfo.description = ability.description;
@ -1619,7 +1620,7 @@ bool ToExtensionInfo(
const TransformParam &transformParam,
ExtensionAbilityInfo &extensionInfo)
{
HILOG_DEBUG("transform ModuleJson to ExtensionAbilityInfo");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "transform ModuleJson to ExtensionAbilityInfo");
extensionInfo.type = ConvertToExtensionAbilityType(extension.type);
extensionInfo.name = extension.name;
extensionInfo.srcEntrance = extension.srcEntrance;
@ -1658,7 +1659,7 @@ bool ToInnerModuleInfo(
const TransformParam &transformParam,
InnerModuleInfo &innerModuleInfo)
{
HILOG_DEBUG("transform ModuleJson to InnerModuleInfo");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "transform ModuleJson to InnerModuleInfo");
innerModuleInfo.name = moduleJson.module.name;
innerModuleInfo.modulePackage = moduleJson.module.name;
innerModuleInfo.moduleName = moduleJson.module.name;
@ -1724,7 +1725,7 @@ bool ParseExtensionInfo(const Profile::ModuleJson &moduleJson, InnerBundleInfo &
for (const Profile::Extension &extension : moduleJson.module.extensionAbilities) {
ExtensionAbilityInfo extensionInfo;
if (!ToExtensionInfo(moduleJson, extension, transformParam, extensionInfo)) {
HILOG_ERROR("To extensionInfo failed");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "To extensionInfo failed");
return false;
}
@ -1795,18 +1796,18 @@ bool ToInnerBundleInfo(const Profile::ModuleJson &moduleJson, InnerBundleInfo &i
ErrCode ModuleProfile::TransformTo(const std::vector<uint8_t> &buf, InnerBundleInfo &innerBundleInfo) const
{
HILOG_DEBUG("transform module.json stream to InnerBundleInfo");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "transform module.json stream to InnerBundleInfo");
std::vector<uint8_t> buffer = buf;
buffer.push_back('\0');
nlohmann::json jsonObject = nlohmann::json::parse(buffer.data(), nullptr, false);
if (jsonObject.is_discarded()) {
HILOG_ERROR("bad profile");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "bad profile");
return ERR_APPEXECFWK_PARSE_BAD_PROFILE;
}
Profile::ModuleJson moduleJson = jsonObject.get<Profile::ModuleJson>();
if (Profile::g_parseResult != ERR_OK) {
HILOG_ERROR("g_parseResult is %{public}d", Profile::g_parseResult);
TAG_LOGE(AAFwkTag::ABILITY_SIM, "g_parseResult is %{public}d", Profile::g_parseResult);
int32_t ret = Profile::g_parseResult;
// need recover parse result to ERR_OK
Profile::g_parseResult = ERR_OK;

View File

@ -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 "common_func.h"
#include <vector>
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "napi/native_api.h"
#include "napi/native_common.h"
@ -58,13 +59,13 @@ bool CommonFunc::ParsePropertyArray(napi_env env, napi_value args, const std::st
bool hasKey = false;
napi_has_named_property(env, args, propertyName.c_str(), &hasKey);
if (!hasKey) {
HILOG_ERROR("%{public}s is not existed", propertyName.c_str());
TAG_LOGE(AAFwkTag::ABILITY_SIM, "%{public}s is not existed", propertyName.c_str());
return true;
}
napi_value property = nullptr;
napi_status status = napi_get_named_property(env, args, propertyName.c_str(), &property);
if (status != napi_ok) {
HILOG_ERROR("get name property failed, propertyName: %{public}s", propertyName.c_str());
TAG_LOGE(AAFwkTag::ABILITY_SIM, "get name property failed, propertyName: %{public}s", propertyName.c_str());
return false;
}
bool isArray = false;

View File

@ -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_ability_context.h"
#include "ability_business_error.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "js_context_utils.h"
#include "js_data_converter.h"
@ -30,7 +31,7 @@ constexpr size_t ARGC_ONE = 1;
}
void JsAbilityContext::Finalizer(napi_env env, void *data, void *hint)
{
HILOG_DEBUG("called");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "called");
std::unique_ptr<JsAbilityContext>(static_cast<JsAbilityContext*>(data));
}
@ -111,7 +112,7 @@ napi_value JsAbilityContext::TerminateSelf(napi_env env, napi_callback_info info
napi_value JsAbilityContext::OnTerminateSelf(napi_env env, NapiCallbackInfo &info)
{
HILOG_DEBUG("TerminateSelf");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "TerminateSelf");
auto abilityContext = context_.lock();
if (abilityContext == nullptr) {
return nullptr;
@ -142,7 +143,7 @@ napi_value JsAbilityContext::TerminateSelfWithResult(napi_env env, napi_callback
napi_value JsAbilityContext::OnTerminateSelfWithResult(napi_env env, NapiCallbackInfo &info)
{
HILOG_DEBUG("called.");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "called.");
auto abilityContext = context_.lock();
if (abilityContext == nullptr) {
return nullptr;
@ -183,10 +184,10 @@ napi_value JsAbilityContext::IsTerminating(napi_env env, napi_callback_info info
napi_value JsAbilityContext::OnIsTerminating(napi_env env, NapiCallbackInfo &info)
{
HILOG_DEBUG("IsTerminating");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "IsTerminating");
auto context = context_.lock();
if (context == nullptr) {
HILOG_ERROR("OnIsTerminating context is nullptr");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "OnIsTerminating context is nullptr");
return CreateJsUndefined(env);
}
return CreateJsValue(env, context->IsTerminating());
@ -203,22 +204,22 @@ napi_value CreateJsErrorByNativeErr(napi_env env, int32_t err, const std::string
void JsAbilityContext::ConfigurationUpdated(napi_env env, std::shared_ptr<NativeReference> &jsContext,
const std::shared_ptr<AppExecFwk::Configuration> &config)
{
HILOG_DEBUG("called.");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "called.");
if (jsContext == nullptr || config == nullptr) {
HILOG_ERROR("jsContext is nullptr.");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "jsContext is nullptr.");
return;
}
napi_value value = jsContext->GetNapiValue();
if (value == nullptr) {
HILOG_ERROR("value is nullptr.");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "value is nullptr.");
return;
}
napi_value method = nullptr;
napi_get_named_property(env, value, "onUpdateConfiguration", &method);
if (method == nullptr) {
HILOG_ERROR("Failed to get onUpdateConfiguration from object");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Failed to get onUpdateConfiguration from object");
return;
}

View File

@ -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 "js_ability_stage_context.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "js_context_utils.h"
#include "js_data_converter.h"
@ -24,7 +25,7 @@ namespace OHOS {
namespace AbilityRuntime {
napi_value CreateJsAbilityStageContext(napi_env env, const std::shared_ptr<AbilityRuntime::Context> &context)
{
HILOG_DEBUG("called.");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "called.");
napi_value objValue = CreateJsBaseContext(env, context);
if (context == nullptr) {
return objValue;
@ -40,26 +41,26 @@ napi_value CreateJsAbilityStageContext(napi_env env, const std::shared_ptr<Abili
void JsAbilityStageContext::ConfigurationUpdated(napi_env env, std::shared_ptr<NativeReference> &jsContext,
const std::shared_ptr<AppExecFwk::Configuration> &config)
{
HILOG_DEBUG("called.");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "called.");
if (!jsContext || !config) {
HILOG_ERROR("jsContext or config is nullptr.");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "jsContext or config is nullptr.");
return;
}
napi_value value = jsContext->GetNapiValue();
if (value == nullptr) {
HILOG_ERROR("value is nullptr.");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "value is nullptr.");
return;
}
napi_value method = nullptr;
napi_get_named_property(env, value, "onUpdateConfiguration", &method);
if (!method) {
HILOG_ERROR("Failed to get onUpdateConfiguration from object");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Failed to get onUpdateConfiguration from object");
return;
}
HILOG_DEBUG("JsAbilityStageContext call onUpdateConfiguration.");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "JsAbilityStageContext call onUpdateConfiguration.");
napi_value argv[] = { CreateJsConfiguration(env, *config) };
napi_value callResult = nullptr;
napi_call_function(env, value, method, 1, argv, &callResult);

View File

@ -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_application_context_utils.h"
#include <map>
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "js_context_utils.h"
#include "js_data_converter.h"
@ -43,7 +44,7 @@ napi_value JsApplicationContextUtils::OnSwitchArea(napi_env env, NapiCallbackInf
{
napi_value object = info.thisVar;
if (object == nullptr) {
HILOG_ERROR("object is null");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "object is null");
return CreateJsUndefined(env);
}
BindNativeProperty(env, object, "cacheDir", GetCacheDir);
@ -77,7 +78,7 @@ napi_value JsApplicationContextUtils::OnGetTempDir(napi_env env, NapiCallbackInf
{
auto context = context_.lock();
if (!context) {
HILOG_WARN("context is already released");
TAG_LOGW(AAFwkTag::ABILITY_SIM, "context is already released");
return CreateJsUndefined(env);
}
std::string path = context->GetTempDir();
@ -93,7 +94,7 @@ napi_value JsApplicationContextUtils::OnGetResourceDir(napi_env env, NapiCallbac
{
auto context = context_.lock();
if (!context) {
HILOG_WARN("context is already released");
TAG_LOGW(AAFwkTag::ABILITY_SIM, "context is already released");
return CreateJsUndefined(env);
}
std::string path = context->GetResourceDir();
@ -109,7 +110,7 @@ napi_value JsApplicationContextUtils::OnGetArea(napi_env env, NapiCallbackInfo &
{
auto context = context_.lock();
if (!context) {
HILOG_WARN("context is already released");
TAG_LOGW(AAFwkTag::ABILITY_SIM, "context is already released");
return CreateJsUndefined(env);
}
int area = context->GetArea();
@ -125,7 +126,7 @@ napi_value JsApplicationContextUtils::OnGetCacheDir(napi_env env, NapiCallbackIn
{
auto context = context_.lock();
if (!context) {
HILOG_WARN("context is already released");
TAG_LOGW(AAFwkTag::ABILITY_SIM, "context is already released");
return CreateJsUndefined(env);
}
std::string path = context->GetCacheDir();
@ -141,7 +142,7 @@ napi_value JsApplicationContextUtils::OnGetFilesDir(napi_env env, NapiCallbackIn
{
auto context = context_.lock();
if (!context) {
HILOG_WARN("context is already released");
TAG_LOGW(AAFwkTag::ABILITY_SIM, "context is already released");
return CreateJsUndefined(env);
}
std::string path = context->GetFilesDir();
@ -158,7 +159,7 @@ napi_value JsApplicationContextUtils::OnGetDistributedFilesDir(napi_env env, Nap
{
auto context = context_.lock();
if (!context) {
HILOG_WARN("context is already released");
TAG_LOGW(AAFwkTag::ABILITY_SIM, "context is already released");
return CreateJsUndefined(env);
}
std::string path = context->GetDistributedFilesDir();
@ -174,7 +175,7 @@ napi_value JsApplicationContextUtils::OnGetDatabaseDir(napi_env env, NapiCallbac
{
auto context = context_.lock();
if (!context) {
HILOG_WARN("context is already released");
TAG_LOGW(AAFwkTag::ABILITY_SIM, "context is already released");
return CreateJsUndefined(env);
}
std::string path = context->GetDatabaseDir();
@ -191,7 +192,7 @@ napi_value JsApplicationContextUtils::OnGetPreferencesDir(napi_env env, NapiCall
{
auto context = context_.lock();
if (!context) {
HILOG_WARN("context is already released");
TAG_LOGW(AAFwkTag::ABILITY_SIM, "context is already released");
return CreateJsUndefined(env);
}
std::string path = context->GetPreferencesDir();
@ -208,7 +209,7 @@ napi_value JsApplicationContextUtils::OnGetBundleCodeDir(napi_env env, NapiCallb
{
auto context = context_.lock();
if (!context) {
HILOG_WARN("context is already released");
TAG_LOGW(AAFwkTag::ABILITY_SIM, "context is already released");
return CreateJsUndefined(env);
}
std::string path = context->GetBundleCodeDir();
@ -273,7 +274,7 @@ napi_value JsApplicationContextUtils::OnGetApplicationContext(napi_env env, Napi
napi_value value = CreateJsApplicationContext(env, context_.lock());
auto systemModule = JsRuntime::LoadSystemModuleByEngine(env, "application.ApplicationContext", &value, 1);
if (systemModule == nullptr) {
HILOG_WARN("OnGetApplicationContext, invalid systemModule.");
TAG_LOGW(AAFwkTag::ABILITY_SIM, "OnGetApplicationContext, invalid systemModule.");
return CreateJsUndefined(env);
}
return systemModule->GetNapiValue();
@ -282,7 +283,7 @@ napi_value JsApplicationContextUtils::OnGetApplicationContext(napi_env env, Napi
napi_value JsApplicationContextUtils::CreateJsApplicationContext(
napi_env env, const std::shared_ptr<Context> &context)
{
HILOG_DEBUG("called");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "called");
napi_value object = nullptr;
napi_create_object(env, &object);
if (object == nullptr) {

View File

@ -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 <string>
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "js_runtime_utils.h"
@ -43,20 +44,20 @@ std::string MakeLogContent(napi_env env, napi_callback_info info)
}
if (value == nullptr) {
HILOG_ERROR("Failed to convert to string object");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Failed to convert to string object");
continue;
}
size_t bufferLen = 0;
napi_status status = napi_get_value_string_utf8(env, value, nullptr, 0, &bufferLen);
if (status != napi_ok || bufferLen == 0 || bufferLen >= JS_CONSOLE_LOG_MAX_LOG_LEN) {
HILOG_DEBUG("Log length exceeds maximum");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "Log length exceeds maximum");
return content;
}
auto buff = new (std::nothrow) char[bufferLen + 1];
if (buff == nullptr) {
HILOG_ERROR("Failed to allocate buffer, size = %zu", bufferLen + 1);
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Failed to allocate buffer, size = %zu", bufferLen + 1);
break;
}
@ -76,7 +77,7 @@ template<LogLevel LEVEL>
napi_value ConsoleLog(napi_env env, napi_callback_info info)
{
if (env == nullptr || info == nullptr) {
HILOG_ERROR("env or callback info is nullptr");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "env or callback info is nullptr");
return nullptr;
}
@ -92,7 +93,7 @@ void InitConsoleLogModule(napi_env env, napi_value globalObject)
napi_value consoleObj = nullptr;
napi_create_object(env, &consoleObj);
if (consoleObj == nullptr) {
HILOG_ERROR("Failed to create console object");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Failed to create console object");
return;
}
const char *moduleName = "console";

View File

@ -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_context_utils.h"
#include <iostream>
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "js_application_context_utils.h"
#include "js_data_converter.h"
@ -66,7 +67,7 @@ protected:
void JsBaseContext::Finalizer(napi_env env, void *data, void *hint)
{
HILOG_DEBUG("called");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "called");
std::unique_ptr<JsBaseContext>(static_cast<JsBaseContext*>(data));
}
@ -88,19 +89,19 @@ napi_value JsBaseContext::SwitchArea(napi_env env, napi_callback_info info)
napi_value JsBaseContext::OnSwitchArea(napi_env env, NapiCallbackInfo &info)
{
if (info.argc == 0) {
HILOG_ERROR("Not enough params");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Not enough params");
return CreateJsUndefined(env);
}
auto context = context_.lock();
if (!context) {
HILOG_WARN("context is already released");
TAG_LOGW(AAFwkTag::ABILITY_SIM, "context is already released");
return CreateJsUndefined(env);
}
int mode = 0;
if (!ConvertFromJsValue(env, info.argv[0], mode)) {
HILOG_ERROR("Parse mode failed");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Parse mode failed");
return CreateJsUndefined(env);
}
@ -108,7 +109,7 @@ napi_value JsBaseContext::OnSwitchArea(napi_env env, NapiCallbackInfo &info)
napi_value object = info.thisVar;
if (object == nullptr) {
HILOG_ERROR("object is nullptr");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "object is nullptr");
return CreateJsUndefined(env);
}
BindNativeProperty(env, object, "cacheDir", GetCacheDir);
@ -141,7 +142,7 @@ napi_value JsBaseContext::OnGetArea(napi_env env, NapiCallbackInfo &info)
{
auto context = context_.lock();
if (!context) {
HILOG_WARN("context is already released");
TAG_LOGW(AAFwkTag::ABILITY_SIM, "context is already released");
return CreateJsUndefined(env);
}
int area = context->GetArea();
@ -157,7 +158,7 @@ napi_value JsBaseContext::OnGetCacheDir(napi_env env, NapiCallbackInfo &info)
{
auto context = context_.lock();
if (!context) {
HILOG_WARN("context is already released");
TAG_LOGW(AAFwkTag::ABILITY_SIM, "context is already released");
return CreateJsUndefined(env);
}
std::string path = context->GetCacheDir();
@ -173,7 +174,7 @@ napi_value JsBaseContext::OnGetTempDir(napi_env env, NapiCallbackInfo &info)
{
auto context = context_.lock();
if (!context) {
HILOG_WARN("context is already released");
TAG_LOGW(AAFwkTag::ABILITY_SIM, "context is already released");
return CreateJsUndefined(env);
}
std::string path = context->GetTempDir();
@ -189,7 +190,7 @@ napi_value JsBaseContext::OnGetResourceDir(napi_env env, NapiCallbackInfo &info)
{
auto context = context_.lock();
if (!context) {
HILOG_WARN("context is already released");
TAG_LOGW(AAFwkTag::ABILITY_SIM, "context is already released");
return CreateJsUndefined(env);
}
std::string path = context->GetResourceDir();
@ -205,7 +206,7 @@ napi_value JsBaseContext::OnGetFilesDir(napi_env env, NapiCallbackInfo &info)
{
auto context = context_.lock();
if (!context) {
HILOG_WARN("context is already released");
TAG_LOGW(AAFwkTag::ABILITY_SIM, "context is already released");
return CreateJsUndefined(env);
}
std::string path = context->GetFilesDir();
@ -221,7 +222,7 @@ napi_value JsBaseContext::OnGetDistributedFilesDir(napi_env env, NapiCallbackInf
{
auto context = context_.lock();
if (!context) {
HILOG_WARN("context is already released");
TAG_LOGW(AAFwkTag::ABILITY_SIM, "context is already released");
return CreateJsUndefined(env);
}
std::string path = context->GetDistributedFilesDir();
@ -237,7 +238,7 @@ napi_value JsBaseContext::OnGetDatabaseDir(napi_env env, NapiCallbackInfo &info)
{
auto context = context_.lock();
if (!context) {
HILOG_WARN("context is already released");
TAG_LOGW(AAFwkTag::ABILITY_SIM, "context is already released");
return CreateJsUndefined(env);
}
std::string path = context->GetDatabaseDir();
@ -253,7 +254,7 @@ napi_value JsBaseContext::OnGetPreferencesDir(napi_env env, NapiCallbackInfo &in
{
auto context = context_.lock();
if (!context) {
HILOG_WARN("context is already released");
TAG_LOGW(AAFwkTag::ABILITY_SIM, "context is already released");
return CreateJsUndefined(env);
}
std::string path = context->GetPreferencesDir();
@ -269,7 +270,7 @@ napi_value JsBaseContext::OnGetBundleCodeDir(napi_env env, NapiCallbackInfo &inf
{
auto context = context_.lock();
if (!context) {
HILOG_WARN("context is already released");
TAG_LOGW(AAFwkTag::ABILITY_SIM, "context is already released");
return CreateJsUndefined(env);
}
std::string path = context->GetBundleCodeDir();
@ -278,7 +279,7 @@ napi_value JsBaseContext::OnGetBundleCodeDir(napi_env env, NapiCallbackInfo &inf
napi_value JsBaseContext::OnGetApplicationContext(napi_env env, NapiCallbackInfo &info)
{
HILOG_DEBUG("called");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "called");
napi_value value = JsApplicationContextUtils::CreateJsApplicationContext(env, context_.lock());
auto systemModule = JsRuntime::LoadSystemModuleByEngine(env, "application.ApplicationContext", &value, 1);
if (systemModule == nullptr) {
@ -294,7 +295,7 @@ napi_value CreateJsBaseContext(napi_env env, std::shared_ptr<Context> context, b
napi_value object = nullptr;
napi_create_object(env, &object);
if (object == nullptr) {
HILOG_WARN("invalid object.");
TAG_LOGW(AAFwkTag::ABILITY_SIM, "invalid object.");
return object;
}

View File

@ -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_data_converter.h"
#include "common_func.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "js_runtime.h"
#include "js_runtime_utils.h"
@ -52,7 +53,7 @@ int32_t ConvertDisplayId(const std::string &displayId)
Global::Resource::ScreenDensity ConvertDensity(const std::string &density)
{
HILOG_DEBUG("ConvertDensity is called");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "ConvertDensity is called");
auto resolution = Global::Resource::ScreenDensity::SCREEN_DENSITY_NOT_SET;
static const std::vector<std::pair<std::string, Global::Resource::ScreenDensity>> resolutions = {
@ -98,7 +99,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::ABILITY_SIM, "Native object is nullptr.");
return object;
}
@ -129,7 +130,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::ABILITY_SIM, "Create object failed.");
return nullptr;
}
@ -142,7 +143,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::ABILITY_SIM, "Create object failed.");
return nullptr;
}
@ -155,7 +156,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::ABILITY_SIM, "Create object failed.");
return nullptr;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2023 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"
@ -149,7 +150,7 @@ void NapiAsyncTask::Schedule(const std::string &name, napi_env env, std::unique_
void NapiAsyncTask::Resolve(napi_env env, napi_value value)
{
HILOG_DEBUG("NapiAsyncTask::Resolve is called");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "NapiAsyncTask::Resolve is called");
if (deferred_) {
napi_resolve_deferred(env, deferred_, value);
deferred_ = nullptr;
@ -165,12 +166,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::ABILITY_SIM, "NapiAsyncTask::Resolve is called end.");
}
void NapiAsyncTask::ResolveWithNoError(napi_env env, napi_value value)
{
HILOG_DEBUG("NapiAsyncTask::Resolve is called");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "NapiAsyncTask::Resolve is called");
if (deferred_) {
napi_resolve_deferred(env, deferred_, value);
deferred_ = nullptr;
@ -186,7 +187,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::ABILITY_SIM, "NapiAsyncTask::Resolve is called end.");
}
void NapiAsyncTask::Reject(napi_env env, napi_value error)
@ -210,7 +211,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::ABILITY_SIM, "NapiAsyncTask::ResolveWithCustomize is called");
if (deferred_) {
napi_resolve_deferred(env, deferred_, value);
deferred_ = nullptr;
@ -226,12 +227,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::ABILITY_SIM, "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::ABILITY_SIM, "NapiAsyncTask::RejectWithCustomize is called");
if (deferred_) {
napi_reject_deferred(env, deferred_, error);
deferred_ = nullptr;
@ -247,7 +248,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::ABILITY_SIM, "NapiAsyncTask::RejectWithCustomize is called end.");
}
void NapiAsyncTask::Execute(napi_env env, void *data)
@ -321,9 +322,9 @@ std::unique_ptr<NapiAsyncTask> CreateAsyncTaskWithLastParam(napi_env env, napi_v
std::unique_ptr<NativeReference> JsRuntime::LoadSystemModuleByEngine(napi_env env,
const std::string &moduleName, napi_value const *argv, size_t argc)
{
HILOG_DEBUG("JsRuntime::LoadSystemModule(%{public}s)", moduleName.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "JsRuntime::LoadSystemModule(%{public}s)", moduleName.c_str());
if (env == nullptr) {
HILOG_DEBUG("JsRuntime::LoadSystemModule: invalid env.");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "JsRuntime::LoadSystemModule: invalid env.");
return std::unique_ptr<NativeReference>();
}
@ -336,7 +337,7 @@ std::unique_ptr<NativeReference> JsRuntime::LoadSystemModuleByEngine(napi_env en
napi_create_reference(env, ref, 1, &methodRequireNapiRef);
methodRequireNapiRef_.reset(reinterpret_cast<NativeReference *>(methodRequireNapiRef));
if (!methodRequireNapiRef_) {
HILOG_ERROR("Failed to create reference for global.requireNapi");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Failed to create reference for global.requireNapi");
return nullptr;
}
napi_value className = nullptr;
@ -347,7 +348,7 @@ std::unique_ptr<NativeReference> JsRuntime::LoadSystemModuleByEngine(napi_env en
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::ABILITY_SIM, "Failed to create object instance");
return std::unique_ptr<NativeReference>();
}

View File

@ -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
@ -22,6 +22,7 @@
#include <vector>
#include <unordered_map>
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "js_runtime.h"
#include "js_runtime_utils.h"
@ -43,7 +44,7 @@ public:
uv_loop_s* loop = nullptr;
napi_get_uv_event_loop(env_, &loop);
if (loop == nullptr) {
HILOG_ERROR("loop == nullptr.");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "loop == nullptr.");
return;
}
uv_timer_init(loop, &timerReq_);
@ -96,7 +97,7 @@ private:
napi_value StartTimeoutOrInterval(napi_env env, napi_callback_info info, bool isInterval)
{
if (env == nullptr || info == nullptr) {
HILOG_ERROR("Start timeout or interval failed with env or callback info is nullptr.");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Start timeout or interval failed with env or callback info is nullptr.");
return nullptr;
}
size_t argc = ARGC_MAX_COUNT;
@ -107,7 +108,7 @@ napi_value StartTimeoutOrInterval(napi_env env, napi_callback_info info, bool is
// parameter check, must have at least 2 params
if (argc < 2 ||!CheckTypeForNapiValue(env, argv[0], napi_function)
|| !CheckTypeForNapiValue(env, argv[1], napi_number)) {
HILOG_ERROR("Set callback timer failed with invalid parameter.");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Set callback timer failed with invalid parameter.");
return CreateJsUndefined(env);
}
@ -154,7 +155,7 @@ napi_value StartInterval(napi_env env, napi_callback_info info)
napi_value StopTimeoutOrInterval(napi_env env, napi_callback_info info)
{
if (env == nullptr || info == nullptr) {
HILOG_ERROR("Stop timeout or interval failed with env or callback info is nullptr.");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Stop timeout or interval failed with env or callback info is nullptr.");
return nullptr;
}
size_t argc = ARGC_MAX_COUNT;
@ -164,7 +165,7 @@ napi_value StopTimeoutOrInterval(napi_env env, napi_callback_info info)
// parameter check, must have at least 1 param
if (argc < 1 || !CheckTypeForNapiValue(env, argv[0], napi_number)) {
HILOG_ERROR("Clear callback timer failed with invalid parameter.");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Clear callback timer failed with invalid parameter.");
return CreateJsUndefined(env);
}
uint32_t callbackId = 0;

View File

@ -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
@ -27,6 +27,7 @@
#include "bundle_container.h"
#include "commonlibrary/ets_utils/js_sys_module/timer/timer.h"
#include "commonlibrary/ets_utils/js_sys_module/console/console.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "js_ability_context.h"
#include "js_ability_stage_context.h"
@ -66,7 +67,7 @@ constexpr char ARK_DEBUGGER_LIB_PATH[] = "libark_debugger.dylib";
int32_t PrintVmLog(int32_t, int32_t, const char*, const char*, const char *message)
{
HILOG_DEBUG("ArkLog: %{public}s", message);
TAG_LOGD(AAFwkTag::ABILITY_SIM, "ArkLog: %{public}s", message);
return 0;
}
@ -143,7 +144,7 @@ void DebuggerTask::HandleTask(const uv_async_t *req)
{
auto *debuggerTask = reinterpret_cast<DebuggerTask*>(req->data);
if (debuggerTask == nullptr) {
HILOG_ERROR("HandleTask debuggerTask is null");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "HandleTask debuggerTask is null");
return;
}
debuggerTask->func();
@ -167,7 +168,7 @@ SimulatorImpl::~SimulatorImpl()
if (uvLoop != nullptr) {
uv_work_t work;
uv_queue_work(uvLoop, &work, [](uv_work_t*) {}, [](uv_work_t *work, int32_t status) {
HILOG_ERROR("Simulator stop uv loop");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Simulator stop uv loop");
uv_stop(work->loop);
});
}
@ -184,7 +185,7 @@ SimulatorImpl::~SimulatorImpl()
bool SimulatorImpl::Initialize(const Options &options)
{
if (nativeEngine_) {
HILOG_ERROR("Simulator is already initialized");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Simulator is already initialized");
return true;
}
@ -210,18 +211,18 @@ bool SimulatorImpl::Initialize(const Options &options)
void CallObjectMethod(napi_env env, napi_value obj, const char *name, napi_value const *argv, size_t argc)
{
if (obj == nullptr) {
HILOG_ERROR("%{public}s, Failed to get Ability object", __func__);
TAG_LOGE(AAFwkTag::ABILITY_SIM, "%{public}s, Failed to get Ability object", __func__);
return;
}
napi_value methodOnCreate = nullptr;
napi_get_named_property(env, obj, name, &methodOnCreate);
if (methodOnCreate == nullptr) {
HILOG_ERROR("Failed to get '%{public}s' from Ability object", name);
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Failed to get '%{public}s' from Ability object", name);
return;
}
napi_status status = napi_call_function(env, obj, methodOnCreate, argc, argv, nullptr);
if (status != napi_ok) {
HILOG_ERROR("Failed to napi call function");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Failed to napi call function");
}
}
@ -229,7 +230,7 @@ napi_value SimulatorImpl::LoadScript(const std::string &srcPath)
{
panda::Local<panda::ObjectRef> objRef = panda::JSNApi::GetExportObject(vm_, srcPath, "default");
if (objRef->IsNull()) {
HILOG_ERROR("Get export object failed");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Get export object failed");
return nullptr;
}
@ -244,7 +245,7 @@ bool SimulatorImpl::ParseBundleAndModuleInfo()
AppExecFwk::BundleContainer::GetInstance().LoadBundleInfos(options_.moduleJsonBuffer);
appInfo_ = AppExecFwk::BundleContainer::GetInstance().GetApplicationInfo();
if (appInfo_ == nullptr) {
HILOG_ERROR("appinfo parse failed.");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "appinfo parse failed.");
return false;
}
nlohmann::json appInfoJson;
@ -259,7 +260,7 @@ bool SimulatorImpl::ParseBundleAndModuleInfo()
options_.compileMode = "esmodule";
if (appInfo_->moduleInfos.empty()) {
HILOG_ERROR("module name is not exist");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "module name is not exist");
return false;
}
options_.moduleName = appInfo_->moduleInfos[0].moduleName;
@ -267,7 +268,7 @@ bool SimulatorImpl::ParseBundleAndModuleInfo()
moduleInfo_ = AppExecFwk::BundleContainer::GetInstance().GetHapModuleInfo(options_.moduleName);
if (moduleInfo_ == nullptr) {
HILOG_ERROR("module info parse failed.");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "module info parse failed.");
return false;
}
nlohmann::json moduleInfoJson;
@ -298,7 +299,7 @@ bool SimulatorImpl::ParseAbilityInfo(const std::string &abilitySrcPath, const st
}
if (abilityInfo_ == nullptr) {
HILOG_ERROR("ability info parse failed.");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "ability info parse failed.");
return false;
}
nlohmann::json json;
@ -326,7 +327,7 @@ int64_t SimulatorImpl::StartAbility(
std::ifstream stream(options_.modulePath, std::ios::ate | std::ios::binary);
if (!stream.is_open()) {
HILOG_ERROR("Failed to open: %{public}s", options_.modulePath.c_str());
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Failed to open: %{public}s", options_.modulePath.c_str());
return -1;
}
@ -338,19 +339,19 @@ int64_t SimulatorImpl::StartAbility(
auto buf = buffer.release();
if (!LoadAbilityStage(buf, len)) {
HILOG_ERROR("Load ability stage failed.");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Load ability stage failed.");
return -1;
}
abilityPath_ = BUNDLE_INSTALL_PATH + options_.moduleName + "/" + abilitySrcPath;
if (!reinterpret_cast<NativeEngine*>(nativeEngine_)->RunScriptBuffer(abilityPath_, buf, len, false)) {
HILOG_ERROR("Failed to run script: %{public}s", abilityPath_.c_str());
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Failed to run script: %{public}s", abilityPath_.c_str());
return -1;
}
napi_value instanceValue = LoadScript(abilityPath_);
if (instanceValue == nullptr) {
HILOG_ERROR("Failed to create object instance");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Failed to create object instance");
return -1;
}
@ -367,17 +368,17 @@ int64_t SimulatorImpl::StartAbility(
bool SimulatorImpl::LoadAbilityStage(uint8_t *buffer, size_t len)
{
if (moduleInfo_ == nullptr) {
HILOG_ERROR("moduleInfo is nullptr");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "moduleInfo is nullptr");
return false;
}
if (moduleInfo_->srcEntrance.empty()) {
HILOG_DEBUG("module src path is empty.");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "module src path is empty.");
return true;
}
if (nativeEngine_ == nullptr) {
HILOG_ERROR("nativeEngine_ is nullptr");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "nativeEngine_ is nullptr");
return false;
}
std::string srcEntrance = moduleInfo_->srcEntrance;
@ -386,15 +387,15 @@ bool SimulatorImpl::LoadAbilityStage(uint8_t *buffer, size_t len)
srcEntrance = srcEntrance.substr(srcEntrance.find('/') + 1, srcEntrance.length());
auto moduleSrcPath = BUNDLE_INSTALL_PATH + options_.moduleName + "/" + srcEntrance;
HILOG_DEBUG("moduleSrcPath is %{public}s", moduleSrcPath.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "moduleSrcPath is %{public}s", moduleSrcPath.c_str());
if (!reinterpret_cast<NativeEngine*>(nativeEngine_)->RunScriptBuffer(moduleSrcPath, buffer, len, false)) {
HILOG_ERROR("Failed to run ability stage script: %{public}s", moduleSrcPath.c_str());
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Failed to run ability stage script: %{public}s", moduleSrcPath.c_str());
return false;
}
napi_value instanceValue = LoadScript(moduleSrcPath);
if (instanceValue == nullptr) {
HILOG_ERROR("Failed to create ability stage instance");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Failed to create ability stage instance");
return false;
}
@ -415,25 +416,25 @@ void SimulatorImpl::InitJsAbilityStageContext(napi_value obj)
{
napi_value contextObj = CreateJsAbilityStageContext(nativeEngine_, stageContext_);
if (contextObj == nullptr) {
HILOG_ERROR("contextObj is nullptr");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "contextObj is nullptr");
return;
}
jsStageContext_ = std::shared_ptr<NativeReference>(
JsRuntime::LoadSystemModuleByEngine(nativeEngine_, "application.AbilityStageContext", &contextObj, 1));
if (jsStageContext_ == nullptr) {
HILOG_ERROR("Failed to get LoadSystemModuleByEngine");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Failed to get LoadSystemModuleByEngine");
return;
}
contextObj = jsStageContext_->GetNapiValue();
if (contextObj == nullptr) {
HILOG_ERROR("contextObj is nullptr.");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "contextObj is nullptr.");
return;
}
if (obj == nullptr) {
HILOG_ERROR("obj is nullptr");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "obj is nullptr");
return;
}
napi_set_named_property(nativeEngine_, obj, "context", contextObj);
@ -481,9 +482,9 @@ void SimulatorImpl::TerminateAbility(int64_t abilityId)
void SimulatorImpl::UpdateConfiguration(const AppExecFwk::Configuration &config)
{
HILOG_DEBUG("called.");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "called.");
if (abilityStage_ == nullptr) {
HILOG_ERROR("abilityStage_ is nullptr");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "abilityStage_ is nullptr");
return;
}
@ -502,7 +503,7 @@ void SimulatorImpl::UpdateConfiguration(const AppExecFwk::Configuration &config)
auto abilityStage = abilityStage_->GetNapiValue();
if (abilityStage == nullptr) {
HILOG_ERROR("abilityStage is nullptr");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "abilityStage is nullptr");
return;
}
CallObjectMethod(nativeEngine_, abilityStage, "onConfigurationUpdated", configArgv, ArraySize(configArgv));
@ -512,7 +513,7 @@ void SimulatorImpl::UpdateConfiguration(const AppExecFwk::Configuration &config)
for (auto iter = abilities_.begin(); iter != abilities_.end(); iter++) {
auto ability = iter->second->GetNapiValue();
if (ability == nullptr) {
HILOG_ERROR("ability is nullptr");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "ability is nullptr");
continue;
}
@ -524,23 +525,23 @@ void SimulatorImpl::UpdateConfiguration(const AppExecFwk::Configuration &config)
void SimulatorImpl::SetMockList(const std::map<std::string, std::string> &mockList)
{
HILOG_DEBUG("called. mockList size: %{public}zu", mockList.size());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "called. mockList size: %{public}zu", mockList.size());
panda::JSNApi::SetMockModuleList(vm_, mockList);
}
void SimulatorImpl::InitResourceMgr()
{
HILOG_DEBUG("called.");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "called.");
resourceMgr_ = std::shared_ptr<Global::Resource::ResourceManager>(Global::Resource::CreateResourceManager());
if (resourceMgr_ == nullptr) {
HILOG_ERROR("resourceMgr is nullptr");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "resourceMgr is nullptr");
return;
}
if (!resourceMgr_->AddResource(options_.resourcePath.c_str())) {
HILOG_ERROR("Add resource failed.");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Add resource failed.");
}
HILOG_DEBUG("Add resource success.");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "Add resource success.");
}
void SimulatorImpl::InitJsAbilityContext(napi_env env, napi_value obj)
@ -557,17 +558,17 @@ void SimulatorImpl::InitJsAbilityContext(napi_env env, napi_value obj)
auto systemModule = std::shared_ptr<NativeReference>(
JsRuntime::LoadSystemModuleByEngine(nativeEngine_, "application.AbilityContext", &contextObj, 1));
if (systemModule == nullptr) {
HILOG_ERROR("systemModule is nullptr.");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "systemModule is nullptr.");
return;
}
contextObj = systemModule->GetNapiValue();
if (contextObj == nullptr) {
HILOG_ERROR("contextObj is nullptr.");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "contextObj is nullptr.");
return;
}
if (obj == nullptr) {
HILOG_ERROR("obj is nullptr");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "obj is nullptr");
return;
}
napi_set_named_property(env, obj, "context", contextObj);
@ -639,7 +640,7 @@ std::unique_ptr<NativeReference> SimulatorImpl::CreateJsWindowStage(
{
napi_value jsWindowStage = Rosen::CreateJsWindowStage(nativeEngine_, windowScene);
if (jsWindowStage == nullptr) {
HILOG_ERROR("Failed to create jsWindowSatge object");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Failed to create jsWindowSatge object");
return nullptr;
}
return JsRuntime::LoadSystemModuleByEngine(nativeEngine_, "application.WindowStage", &jsWindowStage, 1);
@ -663,7 +664,7 @@ panda::ecmascript::EcmaVM *SimulatorImpl::CreateJSVM()
bool SimulatorImpl::OnInit()
{
if (!ParseBundleAndModuleInfo()) {
HILOG_ERROR("parse bundle and module info failed.");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "parse bundle and module info failed.");
return false;
}
@ -678,7 +679,7 @@ bool SimulatorImpl::OnInit()
auto nativeEngine = new (std::nothrow) ArkNativeEngine(vm_, nullptr);
if (nativeEngine == nullptr) {
HILOG_ERROR("nativeEngine is nullptr");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "nativeEngine is nullptr");
return false;
}
napi_env env = reinterpret_cast<napi_env>(nativeEngine);
@ -687,13 +688,13 @@ bool SimulatorImpl::OnInit()
napi_get_global(env, &globalObj);
if (globalObj == nullptr) {
delete nativeEngine;
HILOG_ERROR("Failed to get global object");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Failed to get global object");
return false;
}
if (!LoadRuntimeEnv(env, globalObj)) {
delete nativeEngine;
HILOG_ERROR("Load runtime env failed.");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Load runtime env failed.");
return false;
}
@ -731,7 +732,7 @@ bool SimulatorImpl::LoadRuntimeEnv(napi_env env, napi_value globalObj)
JsSysModule::Console::InitConsoleModule(env);
auto ret = JsSysModule::Timer::RegisterTime(env);
if (!ret) {
HILOG_ERROR("Register timer failed");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Register timer failed");
}
napi_value object = nullptr;
napi_create_object(env, &object);
@ -748,7 +749,8 @@ bool SimulatorImpl::LoadRuntimeEnv(napi_env env, napi_value globalObj)
napi_set_named_property(env, globalObj, "mockRequireNapi", mockRequireNapi);
auto* moduleManager = reinterpret_cast<NativeEngine*>(env)->GetModuleManager();
if (moduleManager != nullptr) {
HILOG_ERROR("moduleManager SetPreviewSearchPath: %{public}s", options_.containerSdkPath.c_str());
TAG_LOGE(
AAFwkTag::ABILITY_SIM, "moduleManager SetPreviewSearchPath: %{public}s", options_.containerSdkPath.c_str());
moduleManager->SetPreviewSearchPath(options_.containerSdkPath);
}
@ -759,7 +761,7 @@ bool SimulatorImpl::LoadRuntimeEnv(napi_env env, napi_value globalObj)
}
std::string fileName = options_.containerSdkPath + fileSeparator + "apiMock" + fileSeparator + "jsMockHmos.abc";
HILOG_DEBUG("file name: %{public}s", fileName.c_str());
TAG_LOGD(AAFwkTag::ABILITY_SIM, "file name: %{public}s", fileName.c_str());
if (!fileName.empty() && AbilityStageContext::Access(fileName)) {
panda::JSNApi::Execute(vm_, fileName, "_GLOBAL::func_main_0");
}
@ -795,7 +797,7 @@ std::unique_ptr<Simulator> Simulator::Create(const Options &options)
void SimulatorImpl::SetHostResolveBufferTracker(ResolveBufferTrackerCallback cb)
{
if (vm_ == nullptr || cb == nullptr) {
HILOG_ERROR("Params invalid.");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "Params invalid.");
return;
}
panda::JSNApi::SetHostResolveBufferTracker(vm_, cb);

View File

@ -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
@ -14,6 +14,7 @@
*/
#include "ability_window_configuration.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "launch_param.h"
#include "napi/native_api.h"
@ -30,7 +31,7 @@ enum class MemoryLevel {
static napi_status SetEnumItem(napi_env env, napi_value object, const char* name, int32_t value)
{
HILOG_DEBUG("SetEnumItem start");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "SetEnumItem start");
napi_status status;
napi_value itemName;
napi_value itemValue;
@ -40,7 +41,7 @@ static napi_status SetEnumItem(napi_env env, napi_value object, const char* name
NAPI_CALL_BASE(env, status = napi_set_property(env, object, itemName, itemValue), status);
NAPI_CALL_BASE(env, status = napi_set_property(env, object, itemValue, itemName), status);
HILOG_DEBUG("SetEnumItem end");
TAG_LOGD(AAFwkTag::ABILITY_SIM, "SetEnumItem end");
return napi_ok;
}
@ -151,43 +152,43 @@ static napi_value AbilityConstantInit(napi_env env, napi_value exports)
{
napi_value launchReason = InitLaunchReasonObject(env);
if (launchReason == nullptr) {
HILOG_ERROR("failed to create launch reason object");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "failed to create launch reason object");
return nullptr;
}
napi_value lastExitReason = InitLastExitReasonObject(env);
if (lastExitReason == nullptr) {
HILOG_ERROR("failed to create last exit reason object");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "failed to create last exit reason object");
return nullptr;
}
napi_value onContinueResult = InitOnContinueResultObject(env);
if (onContinueResult == nullptr) {
HILOG_ERROR("failed to create onContinue result object");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "failed to create onContinue result object");
return nullptr;
}
napi_value windowMode = InitWindowModeObject(env);
if (windowMode == nullptr) {
HILOG_ERROR("failed to create window mode object");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "failed to create window mode object");
return nullptr;
}
napi_value memoryLevel = InitMemoryLevelObject(env);
if (memoryLevel == nullptr) {
HILOG_ERROR("failed to create memory level object");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "failed to create memory level object");
return nullptr;
}
napi_value stateType = InitStateTypeEnum(env);
if (stateType == nullptr) {
HILOG_ERROR("failed to create state type object");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "failed to create state type object");
return nullptr;
}
napi_value saveResult = InitOnSaveResultEnum(env);
if (saveResult == nullptr) {
HILOG_ERROR("failed to create save result object");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "failed to create save result object");
return nullptr;
}
@ -202,7 +203,7 @@ static napi_value AbilityConstantInit(napi_env env, napi_value exports)
};
napi_status status = napi_define_properties(env, exports, sizeof(exportObjs) / sizeof(exportObjs[0]), exportObjs);
if (status != napi_ok) {
HILOG_ERROR("failed to define properties for exports");
TAG_LOGE(AAFwkTag::ABILITY_SIM, "failed to define properties for exports");
return nullptr;
}

View File

@ -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 "os_account_manager_wrapper.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#ifdef OS_ACCOUNT_PART_ENABLED
#include "os_account_manager.h"
@ -33,11 +34,11 @@ const int32_t UID_TRANSFORM_DIVISOR = 200000;
ErrCode OsAccountManagerWrapper::QueryActiveOsAccountIds(std::vector<int32_t>& ids)
{
#ifndef OS_ACCOUNT_PART_ENABLED
HILOG_DEBUG("execute %{public}s without os account subsystem.", __func__);
TAG_LOGD(AAFwkTag::DEFAULT, "execute %{public}s without os account subsystem.", __func__);
ids.emplace_back(DEFAULT_OS_ACCOUNT_ID);
return ERR_OK;
#else
HILOG_DEBUG("execute %{public}s with os account subsystem.", __func__);
TAG_LOGD(AAFwkTag::DEFAULT, "execute %{public}s with os account subsystem.", __func__);
return AccountSA::OsAccountManager::QueryActiveOsAccountIds(ids);
#endif // OS_ACCOUNT_PART_ENABLED
}
@ -45,11 +46,11 @@ ErrCode OsAccountManagerWrapper::QueryActiveOsAccountIds(std::vector<int32_t>& i
ErrCode OsAccountManagerWrapper::GetOsAccountLocalIdFromUid(const int32_t uid, int32_t &id)
{
#ifndef OS_ACCOUNT_PART_ENABLED
HILOG_DEBUG("execute %{public}s without os account subsystem.", __func__);
TAG_LOGD(AAFwkTag::DEFAULT, "execute %{public}s without os account subsystem.", __func__);
id = uid / UID_TRANSFORM_DIVISOR;
return ERR_OK;
#else
HILOG_DEBUG("execute %{public}s with os account subsystem.", __func__);
TAG_LOGD(AAFwkTag::DEFAULT, "execute %{public}s with os account subsystem.", __func__);
return AccountSA::OsAccountManager::GetOsAccountLocalIdFromUid(uid, id);
#endif // OS_ACCOUNT_PART_ENABLED
}
@ -57,11 +58,11 @@ ErrCode OsAccountManagerWrapper::GetOsAccountLocalIdFromUid(const int32_t uid, i
ErrCode OsAccountManagerWrapper::GetOsAccountLocalIdFromProcess(int &id)
{
#ifndef OS_ACCOUNT_PART_ENABLED
HILOG_DEBUG("execute %{public}s without os account subsystem.", __func__);
TAG_LOGD(AAFwkTag::DEFAULT, "execute %{public}s without os account subsystem.", __func__);
id = DEFAULT_OS_ACCOUNT_ID;
return ERR_OK;
#else
HILOG_DEBUG("execute %{public}s with os account subsystem.", __func__);
TAG_LOGD(AAFwkTag::DEFAULT, "execute %{public}s with os account subsystem.", __func__);
return AccountSA::OsAccountManager::GetOsAccountLocalIdFromProcess(id);
#endif // OS_ACCOUNT_PART_ENABLED
}
@ -69,11 +70,11 @@ ErrCode OsAccountManagerWrapper::GetOsAccountLocalIdFromProcess(int &id)
ErrCode OsAccountManagerWrapper::IsOsAccountExists(const int id, bool &isOsAccountExists)
{
#ifndef OS_ACCOUNT_PART_ENABLED
HILOG_DEBUG("execute %{public}s without os account subsystem.", __func__);
TAG_LOGD(AAFwkTag::DEFAULT, "execute %{public}s without os account subsystem.", __func__);
isOsAccountExists = (id == DEFAULT_OS_ACCOUNT_ID);
return ERR_OK;
#else // OS_ACCOUNT_PART_ENABLED
HILOG_DEBUG("execute %{public}s with os account subsystem.", __func__);
TAG_LOGD(AAFwkTag::DEFAULT, "execute %{public}s with os account subsystem.", __func__);
return AccountSA::OsAccountManager::IsOsAccountExists(id, isOsAccountExists);
#endif // OS_ACCOUNT_PART_ENABLED
}
@ -81,11 +82,11 @@ ErrCode OsAccountManagerWrapper::IsOsAccountExists(const int id, bool &isOsAccou
ErrCode OsAccountManagerWrapper::CreateOsAccount(const std::string &name, int32_t &osAccountUserId)
{
#ifndef OS_ACCOUNT_PART_ENABLED
HILOG_INFO("execute %{public}s without os account subsystem.", __func__);
TAG_LOGI(AAFwkTag::DEFAULT, "execute %{public}s without os account subsystem.", __func__);
osAccountUserId = USER_ID_U100;
return ERR_OK;
#else // OS_ACCOUNT_PART_ENABLED
HILOG_INFO("execute %{public}s with os account subsystem.", __func__);
TAG_LOGI(AAFwkTag::DEFAULT, "execute %{public}s with os account subsystem.", __func__);
AccountSA::OsAccountInfo osAccountInfo;
ErrCode errCode = AccountSA::OsAccountManager::CreateOsAccount(name,
AccountSA::OsAccountType::NORMAL, osAccountInfo);
@ -97,10 +98,10 @@ ErrCode OsAccountManagerWrapper::CreateOsAccount(const std::string &name, int32_
ErrCode OsAccountManagerWrapper::RemoveOsAccount(const int id)
{
#ifndef OS_ACCOUNT_PART_ENABLED
HILOG_INFO("execute %{public}s without os account subsystem.", __func__);
TAG_LOGI(AAFwkTag::DEFAULT, "execute %{public}s without os account subsystem.", __func__);
return ERR_OK;
#else // OS_ACCOUNT_PART_ENABLED
HILOG_INFO("execute %{public}s with os account subsystem.", __func__);
TAG_LOGI(AAFwkTag::DEFAULT, "execute %{public}s with os account subsystem.", __func__);
return AccountSA::OsAccountManager::RemoveOsAccount(id);
#endif // OS_ACCOUNT_PART_ENABLED
}
@ -110,18 +111,18 @@ int32_t OsAccountManagerWrapper::GetCurrentActiveAccountId()
std::vector<int32_t> accountIds;
auto instance = DelayedSingleton<AppExecFwk::OsAccountManagerWrapper>::GetInstance();
if (instance == nullptr) {
HILOG_ERROR("Failed to get OsAccountManager instance.");
TAG_LOGE(AAFwkTag::DEFAULT, "Failed to get OsAccountManager instance.");
return 0;
}
ErrCode ret = instance->QueryActiveOsAccountIds(accountIds);
if (ret != ERR_OK) {
HILOG_ERROR("Query active account id failed.");
TAG_LOGE(AAFwkTag::DEFAULT, "Query active account id failed.");
return 0;
}
if (accountIds.empty()) {
HILOG_ERROR("No active account.");
TAG_LOGE(AAFwkTag::DEFAULT, "No active account.");
return 0;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 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 "sa_mgr_client.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "if_system_ability_manager.h"
#include "ipc_skeleton.h"
@ -37,7 +38,7 @@ sptr<IRemoteObject> SaMgrClient::GetSystemAbility(const int32_t systemAbilityId)
if (saMgr_ == nullptr) {
saMgr_ = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
if (saMgr_ == nullptr) {
HILOG_ERROR("Failed to get registry.");
TAG_LOGE(AAFwkTag::DEFAULT, "Failed to get registry.");
return nullptr;
}
}
@ -53,7 +54,7 @@ sptr<IRemoteObject> SaMgrClient::CheckSystemAbility(const int32_t systemAbilityI
if (saMgr_ == nullptr) {
saMgr_ = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
if (saMgr_ == nullptr) {
HILOG_ERROR("Fail to get registry.");
TAG_LOGE(AAFwkTag::DEFAULT, "Fail to get registry.");
return nullptr;
}
}

View File

@ -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
@ -14,6 +14,7 @@
*/
#include "session_handler_proxy.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "message_parcel.h"
@ -25,21 +26,21 @@ void SessionHandlerProxy::OnSessionMovedToFront(int32_t sessionId)
MessageParcel reply;
MessageOption option(MessageOption::TF_ASYNC);
if (!data.WriteInterfaceToken(ISessionHandler::GetDescriptor())) {
HILOG_ERROR("write interface token failed.");
TAG_LOGE(AAFwkTag::DEFAULT, "write interface token failed.");
return;
}
if (!data.WriteInt32(sessionId)) {
HILOG_ERROR("sessionId write failed.");
TAG_LOGE(AAFwkTag::DEFAULT, "sessionId write failed.");
return;
}
auto remote = Remote();
if (!remote) {
HILOG_ERROR("remote object is nullptr.");
TAG_LOGE(AAFwkTag::DEFAULT, "remote object is nullptr.");
return;
}
int32_t ret = remote->SendRequest(ISessionHandler::ON_SESSION_MOVED_TO_FRONT, data, reply, option);
if (ret != NO_ERROR) {
HILOG_ERROR("OnSessionMovedToFront fail to Send request, err: %{public}d.", ret);
TAG_LOGE(AAFwkTag::DEFAULT, "OnSessionMovedToFront fail to Send request, err: %{public}d.", ret);
}
}
}

View File

@ -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
@ -14,6 +14,7 @@
*/
#include "session_handler_stub.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "message_parcel.h"
@ -31,7 +32,7 @@ int32_t SessionHandlerStub::OnRemoteRequest(
std::u16string descriptor = SessionHandlerStub::GetDescriptor();
std::u16string remoteDescriptor = data.ReadInterfaceToken();
if (descriptor != remoteDescriptor) {
HILOG_ERROR("local descriptor is not equal to remote.");
TAG_LOGE(AAFwkTag::DEFAULT, "local descriptor is not equal to remote.");
return ERR_INVALID_STATE;
}
@ -51,7 +52,7 @@ int32_t SessionHandlerStub::OnSessionMovedToFrontInner(MessageParcel &data, Mess
void SessionHandlerStub::OnSessionMovedToFront(int32_t sessionId)
{
HILOG_INFO("call, sessionId:%{public}d", sessionId);
TAG_LOGI(AAFwkTag::DEFAULT, "call, sessionId:%{public}d", sessionId);
}
}
}

View File

@ -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
@ -16,6 +16,7 @@
#include "pending_want.h"
#include "ability_runtime_error_util.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "want_agent_client.h"
#include "want_agent_log_wrapper.h"
@ -59,9 +60,9 @@ ErrCode PendingWant::GetAbility(
const std::shared_ptr<AAFwk::WantParams> &options,
std::shared_ptr<PendingWant> &pendingWant)
{
WANT_AGENT_LOGI("call");
TAG_LOGI(AAFwkTag::WANTAGENT, "call");
if (context == nullptr) {
WANT_AGENT_LOGE("PendingWant::GetAbility invalid input param.");
TAG_LOGE(AAFwkTag::WANTAGENT, "PendingWant::GetAbility invalid input param.");
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
}
@ -82,7 +83,7 @@ ErrCode PendingWant::GetAbility(
sptr<IWantSender> target = nullptr;
ErrCode result = WantAgentClient::GetInstance().GetWantSender(wantSenderInfo, nullptr, target);
if (result != ERR_OK) {
WANT_AGENT_LOGI("PendingWant::GetWantSender failed.");
TAG_LOGI(AAFwkTag::WANTAGENT, "PendingWant::GetWantSender failed.");
return result;
}
pendingWant = std::make_shared<PendingWant>(target);
@ -103,9 +104,9 @@ ErrCode PendingWant::GetAbilities(
std::vector<std::shared_ptr<Want>> &wants, unsigned int flags, const std::shared_ptr<WantParams> &options,
std::shared_ptr<PendingWant> &pendingWant)
{
WANT_AGENT_LOGI("call");
TAG_LOGI(AAFwkTag::WANTAGENT, "call");
if (context == nullptr) {
WANT_AGENT_LOGE("PendingWant::GetAbilities invalid input param.");
TAG_LOGE(AAFwkTag::WANTAGENT, "PendingWant::GetAbilities invalid input param.");
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
}
@ -129,7 +130,7 @@ ErrCode PendingWant::GetAbilities(
sptr<IWantSender> target = nullptr;
ErrCode result = WantAgentClient::GetInstance().GetWantSender(wantSenderInfo, nullptr, target);
if (result != ERR_OK) {
WANT_AGENT_LOGI("PendingWant::GetWantSender failed.");
TAG_LOGI(AAFwkTag::WANTAGENT, "PendingWant::GetWantSender failed.");
return result;
}
pendingWant = std::make_shared<PendingWant>(target);
@ -150,7 +151,7 @@ ErrCode PendingWant::GetCommonEventAsUser(
std::shared_ptr<PendingWant> &pendingWant)
{
if (context == nullptr) {
WANT_AGENT_LOGE("PendingWant::GetCommonEventAsUser invalid input param.");
TAG_LOGE(AAFwkTag::WANTAGENT, "PendingWant::GetCommonEventAsUser invalid input param.");
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
}
@ -170,7 +171,7 @@ ErrCode PendingWant::GetCommonEventAsUser(
sptr<IWantSender> target = nullptr;
ErrCode result = WantAgentClient::GetInstance().GetWantSender(wantSenderInfo, nullptr, target);
if (result != ERR_OK) {
WANT_AGENT_LOGI("PendingWant::GetWantSender failed.");
TAG_LOGI(AAFwkTag::WANTAGENT, "PendingWant::GetWantSender failed.");
return result;
}
pendingWant = std::make_shared<PendingWant>(target);
@ -203,7 +204,7 @@ ErrCode PendingWant::BuildServicePendingWant(
std::shared_ptr<PendingWant> &pendingWant)
{
if (context == nullptr) {
WANT_AGENT_LOGE("PendingWant::BuildServicePendingWant invalid input param.");
TAG_LOGE(AAFwkTag::WANTAGENT, "PendingWant::BuildServicePendingWant invalid input param.");
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
}
@ -273,10 +274,10 @@ ErrCode PendingWant::Send(int resultCode, const std::shared_ptr<Want> &want,
const sptr<CompletedDispatcher> &onCompleted, const std::string &requiredPermission,
const std::shared_ptr<WantParams> &options, const sptr<AAFwk::IWantSender> &target)
{
HILOG_INFO("call");
TAG_LOGI(AAFwkTag::WANTAGENT, "call");
int result = SendAndReturnResult(resultCode, want, onCompleted, requiredPermission, options, target);
if (result != 0) {
WANT_AGENT_LOGE("PendingWant::SendAndReturnResult failed.");
TAG_LOGE(AAFwkTag::WANTAGENT, "PendingWant::SendAndReturnResult failed.");
return ERR_ABILITY_RUNTIME_EXTERNAL_SERVICE_BUSY;
}
return result;
@ -286,7 +287,7 @@ int PendingWant::SendAndReturnResult(int resultCode, const std::shared_ptr<Want>
const sptr<CompletedDispatcher> &onCompleted, const std::string &requiredPermission,
const std::shared_ptr<WantParams> &options, const sptr<AAFwk::IWantSender> &target)
{
HILOG_INFO("call");
TAG_LOGI(AAFwkTag::WANTAGENT, "call");
SenderInfo senderInfo;
senderInfo.resolvedType = want != nullptr ? want->GetType() : "";
if (want != nullptr) {
@ -343,7 +344,7 @@ void PendingWant::CancelReceiver::PerformReceive(const AAFwk::Want &want, int re
void PendingWant::CancelReceiver::Send(const int32_t resultCode)
{
HILOG_INFO("call");
TAG_LOGI(AAFwkTag::WANTAGENT, "call");
if (outerInstance_.lock() != nullptr) {
outerInstance_.lock()->NotifyCancelListeners(resultCode);
@ -353,10 +354,10 @@ void PendingWant::CancelReceiver::Send(const int32_t resultCode)
void PendingWant::RegisterCancelListener(
const std::shared_ptr<CancelListener> &cancelListener, const sptr<AAFwk::IWantSender> &target)
{
HILOG_INFO("call");
TAG_LOGI(AAFwkTag::WANTAGENT, "call");
if (cancelListener == nullptr) {
WANT_AGENT_LOGE("PendingWant::RegisterCancelListener invalid input param.");
TAG_LOGE(AAFwkTag::WANTAGENT, "PendingWant::RegisterCancelListener invalid input param.");
return;
}
std::scoped_lock<std::mutex> lock(lock_object);
@ -372,7 +373,7 @@ void PendingWant::RegisterCancelListener(
void PendingWant::NotifyCancelListeners(int32_t resultCode)
{
HILOG_INFO("call");
TAG_LOGI(AAFwkTag::WANTAGENT, "call");
std::vector<std::shared_ptr<CancelListener>> cancelListeners;
{
@ -389,10 +390,10 @@ void PendingWant::NotifyCancelListeners(int32_t resultCode)
void PendingWant::UnregisterCancelListener(
const std::shared_ptr<CancelListener> &cancelListener, const sptr<AAFwk::IWantSender> &target)
{
HILOG_INFO("call");
TAG_LOGI(AAFwkTag::WANTAGENT, "call");
if (cancelListener == nullptr) {
WANT_AGENT_LOGE("PendingWant::UnregisterCancelListener invalid input param.");
TAG_LOGE(AAFwkTag::WANTAGENT, "PendingWant::UnregisterCancelListener invalid input param.");
return;
}
@ -432,7 +433,7 @@ std::shared_ptr<Want> PendingWant::GetWant(const sptr<AAFwk::IWantSender> &targe
bool PendingWant::Marshalling(Parcel &parcel) const
{
if (target_ == nullptr || !(static_cast<MessageParcel*>(&parcel))->WriteRemoteObject(target_->AsObject())) {
WANT_AGENT_LOGE("parcel WriteString failed");
TAG_LOGE(AAFwkTag::WANTAGENT, "parcel WriteString failed");
return false;
}
@ -443,7 +444,7 @@ PendingWant *PendingWant::Unmarshalling(Parcel &parcel)
{
PendingWant *pendingWant = new (std::nothrow) PendingWant();
if (pendingWant == nullptr) {
WANT_AGENT_LOGE("read from parcel failed");
TAG_LOGE(AAFwkTag::WANTAGENT, "read from parcel failed");
return nullptr;
}
sptr<AAFwk::IWantSender> target =

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 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
@ -13,6 +13,7 @@
* limitations under the License.
*/
#include "hilog_tag_wrapper.h"
#include "want_agent.h"
#include "want_agent_log_wrapper.h"
@ -35,7 +36,7 @@ void WantAgent::SetPendingWant(const std::shared_ptr<PendingWant> &pendingWant)
bool WantAgent::Marshalling(Parcel &parcel) const
{
if (!parcel.WriteParcelable(pendingWant_.get())) {
WANT_AGENT_LOGE("parcel WriteString failed");
TAG_LOGE(AAFwkTag::WANTAGENT, "parcel WriteString failed");
return false;
}
@ -46,7 +47,7 @@ WantAgent *WantAgent::Unmarshalling(Parcel &parcel)
{
WantAgent *agent = new (std::nothrow) WantAgent();
if (agent == nullptr) {
WANT_AGENT_LOGE("read from parcel failed");
TAG_LOGE(AAFwkTag::WANTAGENT, "read from parcel failed");
return nullptr;
}
std::shared_ptr<PendingWant> pendingWant(parcel.ReadParcelable<PendingWant>());

View File

@ -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
@ -19,6 +19,7 @@
#include "ability_manager_errors.h"
#include "ability_manager_interface.h"
#include "ability_util.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "if_system_ability_manager.h"
#include "iservice_registry.h"
@ -49,17 +50,17 @@ ErrCode WantAgentClient::GetWantSender(
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
}
if (!data.WriteParcelable(&wantSenderInfo)) {
HILOG_ERROR("wantSenderInfo write failed.");
TAG_LOGE(AAFwkTag::WANTAGENT, "wantSenderInfo write failed.");
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
}
if (callerToken) {
if (!data.WriteBool(true) || !data.WriteRemoteObject(callerToken)) {
HILOG_ERROR("flag and callerToken write failed.");
TAG_LOGE(AAFwkTag::WANTAGENT, "flag and callerToken write failed.");
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
}
} else {
if (!data.WriteBool(false)) {
HILOG_ERROR("flag write failed.");
TAG_LOGE(AAFwkTag::WANTAGENT, "flag write failed.");
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
}
}
@ -67,7 +68,7 @@ ErrCode WantAgentClient::GetWantSender(
auto error = abms->SendRequest(static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_PENDING_WANT_SENDER),
data, reply, option);
if (error != NO_ERROR) {
HILOG_ERROR("Send request error: %{public}d", error);
TAG_LOGE(AAFwkTag::WANTAGENT, "Send request error: %{public}d", error);
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_WANTAGENT;
}
wantSender = iface_cast<IWantSender>(reply.ReadRemoteObject());
@ -86,18 +87,18 @@ ErrCode WantAgentClient::SendWantSender(sptr<IWantSender> target, const SenderIn
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
}
if (target == nullptr || !data.WriteRemoteObject(target->AsObject())) {
HILOG_ERROR("SendWantSender, target write failed.");
TAG_LOGE(AAFwkTag::WANTAGENT, "SendWantSender, target write failed.");
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_WANTAGENT;
}
if (!data.WriteParcelable(&senderInfo)) {
HILOG_ERROR("SendWantSender, senderInfo write failed.");
TAG_LOGE(AAFwkTag::WANTAGENT, "SendWantSender, senderInfo write failed.");
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
}
auto error = abms->SendRequest(static_cast<uint32_t>(AbilityManagerInterfaceCode::SEND_PENDING_WANT_SENDER),
data, reply, option);
if (error != NO_ERROR) {
HILOG_ERROR("SendWantSender, Send request error: %{public}d", error);
TAG_LOGE(AAFwkTag::WANTAGENT, "SendWantSender, Send request error: %{public}d", error);
return ERR_ABILITY_RUNTIME_EXTERNAL_SERVICE_TIMEOUT;
}
return reply.ReadInt32();
@ -200,7 +201,7 @@ void WantAgentClient::RegisterCancelListener(const sptr<IWantSender> &sender, co
}
auto abms = GetAbilityManager();
if (!abms) {
HILOG_ERROR("RegisterCancelListener, ability proxy is nullptr.");
TAG_LOGE(AAFwkTag::WANTAGENT, "RegisterCancelListener, ability proxy is nullptr.");
return;
}
MessageParcel data;
@ -210,17 +211,17 @@ void WantAgentClient::RegisterCancelListener(const sptr<IWantSender> &sender, co
return;
}
if (!data.WriteRemoteObject(sender->AsObject())) {
HILOG_ERROR("RegisterCancelListener, sender write failed.");
TAG_LOGE(AAFwkTag::WANTAGENT, "RegisterCancelListener, sender write failed.");
return;
}
if (!data.WriteRemoteObject(receiver->AsObject())) {
HILOG_ERROR("RegisterCancelListener, receiver write failed.");
TAG_LOGE(AAFwkTag::WANTAGENT, "RegisterCancelListener, receiver write failed.");
return;
}
auto error = abms->SendRequest(static_cast<uint32_t>(AbilityManagerInterfaceCode::REGISTER_CANCEL_LISTENER),
data, reply, option);
if (error != NO_ERROR) {
HILOG_ERROR("RegisterCancelListener, Send request error: %{public}d", error);
TAG_LOGE(AAFwkTag::WANTAGENT, "RegisterCancelListener, Send request error: %{public}d", error);
return;
}
}
@ -233,7 +234,7 @@ void WantAgentClient::UnregisterCancelListener(
}
auto abms = GetAbilityManager();
if (!abms) {
HILOG_ERROR("UnregisterCancelListener, ability proxy is nullptr.");
TAG_LOGE(AAFwkTag::WANTAGENT, "UnregisterCancelListener, ability proxy is nullptr.");
return;
}
MessageParcel data;
@ -243,17 +244,17 @@ void WantAgentClient::UnregisterCancelListener(
return;
}
if (!data.WriteRemoteObject(sender->AsObject())) {
HILOG_ERROR("UnregisterCancelListener, sender write failed.");
TAG_LOGE(AAFwkTag::WANTAGENT, "UnregisterCancelListener, sender write failed.");
return;
}
if (!data.WriteRemoteObject(receiver->AsObject())) {
HILOG_ERROR("UnregisterCancelListener, receiver write failed.");
TAG_LOGE(AAFwkTag::WANTAGENT, "UnregisterCancelListener, receiver write failed.");
return;
}
auto error = abms->SendRequest(static_cast<uint32_t>(AbilityManagerInterfaceCode::UNREGISTER_CANCEL_LISTENER),
data, reply, option);
if (error != NO_ERROR) {
HILOG_ERROR("UnregisterCancelListener, Send request error: %{public}d", error);
TAG_LOGE(AAFwkTag::WANTAGENT, "UnregisterCancelListener, Send request error: %{public}d", error);
return;
}
}
@ -271,22 +272,22 @@ ErrCode WantAgentClient::GetPendingRequestWant(const sptr<IWantSender> &target,
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
}
if (!data.WriteRemoteObject(target->AsObject())) {
HILOG_ERROR("GetPendingRequestWant, target write failed.");
TAG_LOGE(AAFwkTag::WANTAGENT, "GetPendingRequestWant, target write failed.");
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
}
if (!data.WriteParcelable(want.get())) {
HILOG_ERROR("GetPendingRequestWant, want write failed.");
TAG_LOGE(AAFwkTag::WANTAGENT, "GetPendingRequestWant, want write failed.");
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
}
auto error = abms->SendRequest(static_cast<int32_t>(AbilityManagerInterfaceCode::GET_PENDING_REQUEST_WANT),
data, reply, option);
if (error != NO_ERROR) {
HILOG_ERROR("GetPendingRequestWant, Send request error: %{public}d", error);
TAG_LOGE(AAFwkTag::WANTAGENT, "GetPendingRequestWant, Send request error: %{public}d", error);
return ERR_ABILITY_RUNTIME_EXTERNAL_SERVICE_TIMEOUT;
}
std::unique_ptr<Want> wantInfo(reply.ReadParcelable<Want>());
if (!wantInfo) {
HILOG_ERROR("GetPendingRequestWant, readParcelableInfo failed");
TAG_LOGE(AAFwkTag::WANTAGENT, "GetPendingRequestWant, readParcelableInfo failed");
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
}
want = std::move(wantInfo);
@ -307,22 +308,22 @@ ErrCode WantAgentClient::GetWantSenderInfo(const sptr<IWantSender> &target, std:
return INNER_ERR;
}
if (!data.WriteRemoteObject(target->AsObject())) {
HILOG_ERROR("GetWantSenderInfo, target write failed.");
TAG_LOGE(AAFwkTag::WANTAGENT, "GetWantSenderInfo, target write failed.");
return INNER_ERR;
}
if (!data.WriteParcelable(info.get())) {
HILOG_ERROR("GetWantSenderInfo, info write failed.");
TAG_LOGE(AAFwkTag::WANTAGENT, "GetWantSenderInfo, info write failed.");
return INNER_ERR;
}
auto error = abms->SendRequest(static_cast<uint32_t>(AbilityManagerInterfaceCode::GET_PENDING_WANT_SENDER_INFO),
data, reply, option);
if (error != NO_ERROR) {
HILOG_ERROR("GetWantSenderInfo, Send request error: %{public}d", error);
TAG_LOGE(AAFwkTag::WANTAGENT, "GetWantSenderInfo, Send request error: %{public}d", error);
return error;
}
std::unique_ptr<WantSenderInfo> wantSenderInfo(reply.ReadParcelable<WantSenderInfo>());
if (!wantSenderInfo) {
HILOG_ERROR("GetWantSenderInfo, readParcelable Info failed");
TAG_LOGE(AAFwkTag::WANTAGENT, "GetWantSenderInfo, readParcelable Info failed");
return INNER_ERR;
}
info = std::move(wantSenderInfo);
@ -336,22 +337,22 @@ sptr<IRemoteObject> WantAgentClient::GetAbilityManager()
if (proxy_ == nullptr) {
auto systemManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
if (systemManager == nullptr) {
HILOG_ERROR("Fail to get registry.");
TAG_LOGE(AAFwkTag::WANTAGENT, "Fail to get registry.");
return nullptr;
}
auto remoteObj = systemManager->GetSystemAbility(ABILITY_MGR_SERVICE_ID);
if (remoteObj == nullptr) {
HILOG_ERROR("Fail to connect ability manager service.");
TAG_LOGE(AAFwkTag::WANTAGENT, "Fail to connect ability manager service.");
return nullptr;
}
deathRecipient_ = sptr<IRemoteObject::DeathRecipient>(new (std::nothrow) WantAgentDeathRecipient());
if (deathRecipient_ == nullptr) {
HILOG_ERROR("%{public}s :Failed to create WantAgentDeathRecipient!", __func__);
TAG_LOGE(AAFwkTag::WANTAGENT, "%{public}s :Failed to create WantAgentDeathRecipient!", __func__);
return nullptr;
}
if (!remoteObj->AddDeathRecipient(deathRecipient_)) {
HILOG_INFO("%{public}s :Add death recipient to failed, maybe already add.", __func__);
TAG_LOGI(AAFwkTag::WANTAGENT, "%{public}s :Add death recipient to failed, maybe already add.", __func__);
}
proxy_ = remoteObj;
}
@ -361,7 +362,7 @@ sptr<IRemoteObject> WantAgentClient::GetAbilityManager()
void WantAgentClient::WantAgentDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& remote)
{
HILOG_INFO("WantAgentDeathRecipient handle remote died.");
TAG_LOGI(AAFwkTag::WANTAGENT, "WantAgentDeathRecipient handle remote died.");
WantAgentClient::GetInstance().ResetProxy(remote);
}
@ -380,7 +381,7 @@ void WantAgentClient::ResetProxy(const wptr<IRemoteObject>& remote)
bool WantAgentClient::WriteInterfaceToken(MessageParcel &data)
{
if (!data.WriteInterfaceToken(IAbilityManager::GetDescriptor())) {
HILOG_ERROR("write interface token failed.");
TAG_LOGE(AAFwkTag::WANTAGENT, "write interface token failed.");
return false;
}
return true;
@ -389,11 +390,11 @@ bool WantAgentClient::WriteInterfaceToken(MessageParcel &data)
bool WantAgentClient::CheckSenderAndRecevier(const sptr<IWantSender> &sender, const sptr<IWantReceiver> &receiver)
{
if (sender == nullptr) {
HILOG_ERROR("sender is nullptr.");
TAG_LOGE(AAFwkTag::WANTAGENT, "sender is nullptr.");
return false;
}
if (receiver == nullptr) {
HILOG_ERROR("receiver is nullptr.");
TAG_LOGE(AAFwkTag::WANTAGENT, "receiver is nullptr.");
return false;
}
@ -410,13 +411,13 @@ bool WantAgentClient::SendRequest(int32_t operation, const sptr<IRemoteObject> &
return false;
}
if (!data.WriteRemoteObject(remoteObject)) {
HILOG_ERROR("write failed.");
TAG_LOGE(AAFwkTag::WANTAGENT, "write failed.");
error = ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
return false;
}
error = abms->SendRequest(operation, data, reply, option);
if (error != NO_ERROR) {
HILOG_ERROR("Send request error: %{public}d", error);
TAG_LOGE(AAFwkTag::WANTAGENT, "Send request error: %{public}d", error);
error = ERR_ABILITY_RUNTIME_EXTERNAL_SERVICE_BUSY;
return false;
}

View File

@ -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
@ -16,6 +16,7 @@
#include "want_agent_helper.h"
#include "ability_runtime_error_util.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "want_params_wrapper.h"
#include "pending_want.h"
@ -58,26 +59,26 @@ unsigned int WantAgentHelper::FlagsTransformer(const std::vector<WantAgentConsta
break;
case WantAgentConstant::Flags::REPLACE_ELEMENT:
wantFlags |= static_cast<unsigned int>(FLAG_UPDATE_CURRENT);
WANT_AGENT_LOGE("Invalid flag:REPLACE_ELEMENT.");
TAG_LOGE(AAFwkTag::WANTAGENT, "Invalid flag:REPLACE_ELEMENT.");
break;
case WantAgentConstant::Flags::REPLACE_ACTION:
wantFlags |= static_cast<unsigned int>(FLAG_UPDATE_CURRENT);
WANT_AGENT_LOGE("Invalid flag:REPLACE_ACTION.");
TAG_LOGE(AAFwkTag::WANTAGENT, "Invalid flag:REPLACE_ACTION.");
break;
case WantAgentConstant::Flags::REPLACE_URI:
wantFlags |= static_cast<unsigned int>(FLAG_UPDATE_CURRENT);
WANT_AGENT_LOGE("Invalid flag:REPLACE_URI.");
TAG_LOGE(AAFwkTag::WANTAGENT, "Invalid flag:REPLACE_URI.");
break;
case WantAgentConstant::Flags::REPLACE_ENTITIES:
wantFlags |= static_cast<unsigned int>(FLAG_UPDATE_CURRENT);
WANT_AGENT_LOGE("Invalid flag:REPLACE_ENTITIES.");
TAG_LOGE(AAFwkTag::WANTAGENT, "Invalid flag:REPLACE_ENTITIES.");
break;
case WantAgentConstant::Flags::REPLACE_BUNDLE:
wantFlags |= static_cast<unsigned int>(FLAG_UPDATE_CURRENT);
WANT_AGENT_LOGE("Invalid flag:REPLACE_BUNDLE.");
TAG_LOGE(AAFwkTag::WANTAGENT, "Invalid flag:REPLACE_BUNDLE.");
break;
default:
WANT_AGENT_LOGE("WantAgentHelper::flags is error.");
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgentHelper::flags is error.");
break;
}
}
@ -89,23 +90,23 @@ ErrCode WantAgentHelper::GetWantAgent(
const WantAgentInfo &paramsInfo, std::shared_ptr<WantAgent> &wantAgent)
{
if (context == nullptr) {
WANT_AGENT_LOGE("WantAgentHelper::GetWantAgent invalid input param.");
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgentHelper::GetWantAgent invalid input param.");
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
}
std::vector<std::shared_ptr<Want>> wants = paramsInfo.GetWants();
if (wants.empty()) {
WANT_AGENT_LOGE("WantAgentHelper::GetWantAgent invalid input param.");
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgentHelper::GetWantAgent invalid input param.");
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
}
HILOG_DEBUG("bundle:%{public}s; ability:%{public}s",
TAG_LOGD(AAFwkTag::WANTAGENT, "bundle:%{public}s; ability:%{public}s",
wants[0]->GetElement().GetBundleName().c_str(),
wants[0]->GetElement().GetAbilityName().c_str());
unsigned int flags = FlagsTransformer(paramsInfo.GetFlags());
if (flags == 0) {
WANT_AGENT_LOGE("WantAgentHelper::flags invalid.");
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgentHelper::flags invalid.");
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
}
@ -131,13 +132,13 @@ ErrCode WantAgentHelper::GetWantAgent(
result = PendingWant::GetCommonEvent(context, requestCode, wants[0], flags, pendingWant);
break;
default:
WANT_AGENT_LOGE("WantAgentHelper::GetWantAgent operation type is error.");
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgentHelper::GetWantAgent operation type is error.");
result = ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
break;
}
if (pendingWant == nullptr) {
WANT_AGENT_LOGE("WantAgentHelper::GetWantAgent the wants does not meet the requirements.");
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgentHelper::GetWantAgent the wants does not meet the requirements.");
return result;
}
wantAgent = std::make_shared<WantAgent>(pendingWant);
@ -148,13 +149,13 @@ std::shared_ptr<WantAgent> WantAgentHelper::GetWantAgent(const WantAgentInfo &pa
{
std::vector<std::shared_ptr<Want>> wants = paramsInfo.GetWants();
if (wants.empty()) {
WANT_AGENT_LOGE("WantAgentHelper::GetWantAgent invalid input param.");
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgentHelper::GetWantAgent invalid input param.");
return nullptr;
}
std::shared_ptr<Want> want = wants[0];
if (want == nullptr) {
WANT_AGENT_LOGE("WantAgentHelper::GetWantAgent invalid input param.");
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgentHelper::GetWantAgent invalid input param.");
return nullptr;
}
@ -165,7 +166,7 @@ std::shared_ptr<WantAgent> WantAgentHelper::GetWantAgent(const WantAgentInfo &pa
wantsInfo.want.SetParams(*paramsInfo.GetExtraInfo());
}
HILOG_INFO("bundle:%{public}s; ability:%{public}s",
TAG_LOGI(AAFwkTag::WANTAGENT, "bundle:%{public}s; ability:%{public}s",
wantsInfo.want.GetElement().GetBundleName().c_str(),
wantsInfo.want.GetElement().GetAbilityName().c_str());
@ -178,7 +179,7 @@ std::shared_ptr<WantAgent> WantAgentHelper::GetWantAgent(const WantAgentInfo &pa
sptr<IWantSender> target = nullptr;
WantAgentClient::GetInstance().GetWantSender(wantSenderInfo, nullptr, target);
if (target == nullptr) {
WANT_AGENT_LOGE("WantAgentHelper::GetWantAgent target is nullptr.");
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgentHelper::GetWantAgent target is nullptr.");
return nullptr;
}
std::shared_ptr<WantAgent> agent = std::make_shared<WantAgent>(std::make_shared<PendingWant>(target));
@ -198,9 +199,9 @@ WantAgentConstant::OperationType WantAgentHelper::GetType(std::shared_ptr<WantAg
ErrCode WantAgentHelper::TriggerWantAgent(std::shared_ptr<WantAgent> agent,
const std::shared_ptr<CompletedCallback> &callback, const TriggerInfo &paramsInfo)
{
HILOG_INFO("call");
TAG_LOGI(AAFwkTag::WANTAGENT, "call");
if (agent == nullptr) {
WANT_AGENT_LOGE("WantAgentHelper::TriggerWantAgent invalid input param.");
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgentHelper::TriggerWantAgent invalid input param.");
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
}
std::shared_ptr<PendingWant> pendingWant = agent->GetPendingWant();
@ -215,9 +216,9 @@ ErrCode WantAgentHelper::TriggerWantAgent(std::shared_ptr<WantAgent> agent,
ErrCode WantAgentHelper::Send(const std::shared_ptr<PendingWant> &pendingWant,
WantAgentConstant::OperationType type, const sptr<CompletedDispatcher> &callBack, const TriggerInfo &paramsInfo)
{
HILOG_INFO("call");
TAG_LOGI(AAFwkTag::WANTAGENT, "call");
if (pendingWant == nullptr) {
WANT_AGENT_LOGE("WantAgentHelper::Send invalid input param.");
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgentHelper::Send invalid input param.");
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
}
@ -232,13 +233,13 @@ ErrCode WantAgentHelper::Send(const std::shared_ptr<PendingWant> &pendingWant,
ErrCode WantAgentHelper::Cancel(const std::shared_ptr<WantAgent> &agent)
{
if (agent == nullptr) {
WANT_AGENT_LOGE("WantAgentHelper::Cancel WantAgent invalid input param.");
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgentHelper::Cancel WantAgent invalid input param.");
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
}
std::shared_ptr<PendingWant> pendingWant = agent->GetPendingWant();
if (pendingWant == nullptr) {
WANT_AGENT_LOGE("WantAgentHelper::Cancel PendingWant invalid input param.");
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgentHelper::Cancel PendingWant invalid input param.");
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
}
@ -260,15 +261,15 @@ ErrCode WantAgentHelper::IsEquals(
ErrCode WantAgentHelper::GetBundleName(const std::shared_ptr<WantAgent> &agent, std::string &bundleName)
{
WANT_AGENT_LOGD("WantAgentHelper::GetBundleName");
TAG_LOGD(AAFwkTag::WANTAGENT, "WantAgentHelper::GetBundleName");
if (agent == nullptr) {
WANT_AGENT_LOGE("WantAgentHelper::GetBundleName WantAgent invalid input param.");
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgentHelper::GetBundleName WantAgent invalid input param.");
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
}
std::shared_ptr<PendingWant> pendingWant = agent->GetPendingWant();
if (pendingWant == nullptr) {
WANT_AGENT_LOGE("WantAgentHelper::GetBundleName PendingWant invalid input param.");
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgentHelper::GetBundleName PendingWant invalid input param.");
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
}
@ -278,13 +279,13 @@ ErrCode WantAgentHelper::GetBundleName(const std::shared_ptr<WantAgent> &agent,
ErrCode WantAgentHelper::GetUid(const std::shared_ptr<WantAgent> &agent, int32_t &uid)
{
if (agent == nullptr) {
WANT_AGENT_LOGE("WantAgentHelper::GetUid WantAgent invalid input param.");
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgentHelper::GetUid WantAgent invalid input param.");
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
}
std::shared_ptr<PendingWant> pendingWant = agent->GetPendingWant();
if (pendingWant == nullptr) {
WANT_AGENT_LOGE("WantAgentHelper::GetUid PendingWant invalid input param.");
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgentHelper::GetUid PendingWant invalid input param.");
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
}
@ -294,13 +295,13 @@ ErrCode WantAgentHelper::GetUid(const std::shared_ptr<WantAgent> &agent, int32_t
std::shared_ptr<Want> WantAgentHelper::GetWant(const std::shared_ptr<WantAgent> &agent)
{
if (agent == nullptr) {
WANT_AGENT_LOGE("WantAgentHelper::GetWant WantAgent invalid input param.");
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgentHelper::GetWant WantAgent invalid input param.");
return nullptr;
}
std::shared_ptr<PendingWant> pendingWant = agent->GetPendingWant();
if (pendingWant == nullptr) {
WANT_AGENT_LOGE("WantAgentHelper::GetWant PendingWant invalid input param.");
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgentHelper::GetWant PendingWant invalid input param.");
return nullptr;
}
@ -311,13 +312,13 @@ void WantAgentHelper::RegisterCancelListener(
const std::shared_ptr<CancelListener> &cancelListener, const std::shared_ptr<WantAgent> &agent)
{
if (agent == nullptr) {
WANT_AGENT_LOGE("WantAgentHelper::RegisterCancelListener WantAgent invalid input param.");
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgentHelper::RegisterCancelListener WantAgent invalid input param.");
return;
}
std::shared_ptr<PendingWant> pendingWant = agent->GetPendingWant();
if (pendingWant == nullptr) {
WANT_AGENT_LOGE("WantAgentHelper::RegisterCancelListener PendingWant invalid input param.");
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgentHelper::RegisterCancelListener PendingWant invalid input param.");
return;
}
@ -328,13 +329,13 @@ void WantAgentHelper::UnregisterCancelListener(
const std::shared_ptr<CancelListener> &cancelListener, const std::shared_ptr<WantAgent> &agent)
{
if (agent == nullptr) {
WANT_AGENT_LOGE("WantAgentHelper::UnregisterCancelListener WantAgent invalid input param.");
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgentHelper::UnregisterCancelListener WantAgent invalid input param.");
return;
}
std::shared_ptr<PendingWant> pendingWant = agent->GetPendingWant();
if (pendingWant == nullptr) {
WANT_AGENT_LOGE("WantAgentHelper::UnregisterCancelListener PendingWant invalid input param.");
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgentHelper::UnregisterCancelListener PendingWant invalid input param.");
return;
}
@ -344,19 +345,19 @@ void WantAgentHelper::UnregisterCancelListener(
std::string WantAgentHelper::ToString(const std::shared_ptr<WantAgent> &agent)
{
if (agent == nullptr) {
WANT_AGENT_LOGE("WantAgentHelper::ToString WantAgent invalid input param.");
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgentHelper::ToString WantAgent invalid input param.");
return "";
}
std::shared_ptr<PendingWant> pendingWant = agent->GetPendingWant();
if (pendingWant == nullptr) {
WANT_AGENT_LOGE("WantAgentHelper::ToString PendingWant invalid input param.");
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgentHelper::ToString PendingWant invalid input param.");
return "";
}
std::shared_ptr<WantSenderInfo> info = pendingWant->GetWantSenderInfo(pendingWant->GetTarget());
if (info == nullptr) {
WANT_AGENT_LOGE("WantAgentHelper::ToString WantSenderInfo invalid input param.");
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgentHelper::ToString WantSenderInfo invalid input param.");
return "";
}
nlohmann::json jsonObject;
@ -459,7 +460,7 @@ std::vector<WantAgentConstant::Flags> WantAgentHelper::ParseFlags(nlohmann::json
ErrCode WantAgentHelper::GetType(const std::shared_ptr<WantAgent> &agent, int32_t &operType)
{
if ((agent == nullptr) || (agent->GetPendingWant() == nullptr)) {
WANT_AGENT_LOGE("WantAgent or PendingWant invalid input param.");
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgent or PendingWant invalid input param.");
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_WANTAGENT;
}
@ -469,7 +470,7 @@ ErrCode WantAgentHelper::GetType(const std::shared_ptr<WantAgent> &agent, int32_
ErrCode WantAgentHelper::GetWant(const std::shared_ptr<WantAgent> &agent, std::shared_ptr<AAFwk::Want> &want)
{
if ((agent == nullptr) || (agent->GetPendingWant() == nullptr)) {
WANT_AGENT_LOGE("WantAgent or PendingWant invalid input param.");
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgent or PendingWant invalid input param.");
return ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_WANTAGENT;
}

View File

@ -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 "service_info.h"
#include "hilog_tag_wrapper.h"
#include "parcel_macro.h"
#include "string_ex.h"
@ -43,7 +44,7 @@ AppInfo *AppInfo::Unmarshalling(Parcel &parcel)
{
AppInfo *info = new (std::nothrow) AppInfo();
if (info && !info->ReadFromParcel(parcel)) {
APP_LOGW("read from parcel failed");
TAG_LOGW(AAFwkTag::SER_ROUTER, "read from parcel failed");
delete info;
info = nullptr;
}
@ -70,7 +71,7 @@ BusinessAbilityFilter *BusinessAbilityFilter::Unmarshalling(Parcel &parcel)
{
BusinessAbilityFilter *filter = new (std::nothrow) BusinessAbilityFilter();
if (filter && !filter->ReadFromParcel(parcel)) {
APP_LOGW("read from parcel failed");
TAG_LOGW(AAFwkTag::SER_ROUTER, "read from parcel failed");
delete filter;
filter = nullptr;
}
@ -81,7 +82,7 @@ bool BusinessAbilityInfo::ReadFromParcel(Parcel &parcel)
{
std::unique_ptr<AppInfo> app(parcel.ReadParcelable<AppInfo>());
if (!app) {
APP_LOGE("ReadParcelable<AppInfo> failed");
TAG_LOGE(AAFwkTag::SER_ROUTER, "ReadParcelable<AppInfo> failed");
return false;
}
appInfo = *app;
@ -97,7 +98,7 @@ bool BusinessAbilityInfo::ReadFromParcel(Parcel &parcel)
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, size);
CONTAINER_SECURITY_VERIFY(parcel, size, &permissions);
if (size > CYCLE_LIMIT) {
APP_LOGE("size is too large.");
TAG_LOGE(AAFwkTag::SER_ROUTER, "size is too large.");
return false;
}
for (int32_t i = 0; i < size; i++) {
@ -128,7 +129,7 @@ BusinessAbilityInfo *BusinessAbilityInfo::Unmarshalling(Parcel &parcel)
{
BusinessAbilityInfo *info = new (std::nothrow) BusinessAbilityInfo();
if (info && !info->ReadFromParcel(parcel)) {
APP_LOGW("read from parcel failed");
TAG_LOGW(AAFwkTag::SER_ROUTER, "read from parcel failed");
delete info;
info = nullptr;
}
@ -139,7 +140,7 @@ bool PurposeInfo::ReadFromParcel(Parcel &parcel)
{
std::unique_ptr<AppInfo> app(parcel.ReadParcelable<AppInfo>());
if (!app) {
APP_LOGE("ReadParcelable<AppInfo> failed");
TAG_LOGE(AAFwkTag::SER_ROUTER, "ReadParcelable<AppInfo> failed");
return false;
}
appInfo = *app;
@ -152,7 +153,7 @@ bool PurposeInfo::ReadFromParcel(Parcel &parcel)
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, supportDimensionSize);
CONTAINER_SECURITY_VERIFY(parcel, supportDimensionSize, &supportDimensions);
if (supportDimensionSize > CYCLE_LIMIT) {
APP_LOGE("supportDimensionSize is too large.");
TAG_LOGE(AAFwkTag::SER_ROUTER, "supportDimensionSize is too large.");
return false;
}
for (int32_t i = 0; i < supportDimensionSize; i++) {
@ -183,7 +184,7 @@ PurposeInfo *PurposeInfo::Unmarshalling(Parcel &parcel)
{
PurposeInfo *info = new (std::nothrow) PurposeInfo();
if (info && !info->ReadFromParcel(parcel)) {
APP_LOGW("read from parcel failed");
TAG_LOGW(AAFwkTag::SER_ROUTER, "read from parcel failed");
delete info;
info = nullptr;
}

View File

@ -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,13 +15,14 @@
#include "service_router_death_recipient.h"
#include "app_log_wrapper.h"
#include "hilog_tag_wrapper.h"
#include "service_router_mgr_helper.h"
namespace OHOS {
namespace AbilityRuntime {
void ServiceRouterDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &object)
{
APP_LOGI("OnRemoteDied.");
TAG_LOGI(AAFwkTag::SER_ROUTER, "OnRemoteDied.");
ServiceRouterMgrHelper::GetInstance().OnRemoteDiedHandle();
}
} // namespace AbilityRuntime

View File

@ -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 "service_router_load_callback.h"
#include "app_log_wrapper.h"
#include "hilog_tag_wrapper.h"
#include "service_router_mgr_helper.h"
#include "system_ability_definition.h"
@ -24,20 +25,22 @@ void ServiceRouterLoadCallback::OnLoadSystemAbilitySuccess(int32_t systemAbility
const sptr<IRemoteObject> &remoteObject)
{
if (systemAbilityId != OHOS::SERVICE_ROUTER_MGR_SERVICE_ID) {
APP_LOGE("OnLoadSystemAbilitySuccess, not matched systemAbilityId: %{public}d", systemAbilityId);
TAG_LOGE(AAFwkTag::SER_ROUTER,
"OnLoadSystemAbilitySuccess, not matched systemAbilityId: %{public}d", systemAbilityId);
return;
}
if (remoteObject == nullptr) {
APP_LOGE("OnLoadSystemAbilitySuccess, remoteObject is null, systemAbilityId: %{public}d", systemAbilityId);
TAG_LOGE(AAFwkTag::SER_ROUTER,
"OnLoadSystemAbilitySuccess, remoteObject is null, systemAbilityId: %{public}d", systemAbilityId);
return;
}
APP_LOGI("OnLoadSystemAbilitySuccess, systemAbilityId: %{public}d", systemAbilityId);
TAG_LOGI(AAFwkTag::SER_ROUTER, "OnLoadSystemAbilitySuccess, systemAbilityId: %{public}d", systemAbilityId);
ServiceRouterMgrHelper::GetInstance().FinishStartSASuccess(remoteObject);
}
void ServiceRouterLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId)
{
APP_LOGE("OnLoadSystemAbilitySuccess systemAbilityId: %{public}d", systemAbilityId);
TAG_LOGE(AAFwkTag::SER_ROUTER, "OnLoadSystemAbilitySuccess systemAbilityId: %{public}d", systemAbilityId);
ServiceRouterMgrHelper::GetInstance().FinishStartSAFail();
}
} // namespace AbilityRuntime

View File

@ -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 "app_log_wrapper.h"
#include "bundle_constants.h"
#include "hilog_tag_wrapper.h"
#include "iservice_registry.h"
#include "service_router_load_callback.h"
#include "system_ability_definition.h"
@ -35,7 +36,7 @@ ServiceRouterMgrHelper::~ServiceRouterMgrHelper()
void ServiceRouterMgrHelper::OnRemoteDiedHandle()
{
APP_LOGE("Remove service died.");
TAG_LOGE(AAFwkTag::SER_ROUTER, "Remove service died.");
SetServiceRouterMgr(nullptr);
std::unique_lock<std::mutex> lock(cvLock_);
isReady = false;
@ -61,25 +62,25 @@ void ServiceRouterMgrHelper::LoadSA()
}
sptr<ISystemAbilityManager> saManager = OHOS::SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
if (saManager == nullptr) {
APP_LOGE("LoadSA, GetSystemAbilityManager is null.");
TAG_LOGE(AAFwkTag::SER_ROUTER, "LoadSA, GetSystemAbilityManager is null.");
return;
}
sptr<ServiceRouterLoadCallback> loadCallback = new (std::nothrow) ServiceRouterLoadCallback();
if (loadCallback == nullptr) {
APP_LOGE("LoadSA, new ServiceRouterLoadCallback return null.");
TAG_LOGE(AAFwkTag::SER_ROUTER, "LoadSA, new ServiceRouterLoadCallback return null.");
return;
}
int32_t result = saManager->LoadSystemAbility(OHOS::SERVICE_ROUTER_MGR_SERVICE_ID, loadCallback);
if (result != ERR_OK) {
APP_LOGE("LoadSA, LoadSystemAbility result: %{public}d", result);
TAG_LOGE(AAFwkTag::SER_ROUTER, "LoadSA, LoadSystemAbility result: %{public}d", result);
return;
}
}
void ServiceRouterMgrHelper::FinishStartSASuccess(const sptr<IRemoteObject> &remoteObject)
{
APP_LOGI("FinishStartSASuccess.");
TAG_LOGI(AAFwkTag::SER_ROUTER, "FinishStartSASuccess.");
SetServiceRouterMgr(OHOS::iface_cast<IServiceRouterManager>(remoteObject));
{
@ -96,7 +97,7 @@ void ServiceRouterMgrHelper::FinishStartSASuccess(const sptr<IRemoteObject> &rem
void ServiceRouterMgrHelper::FinishStartSAFail()
{
APP_LOGI("FinishStartSAFail.");
TAG_LOGI(AAFwkTag::SER_ROUTER, "FinishStartSAFail.");
SetServiceRouterMgr(nullptr);
{
@ -128,7 +129,7 @@ sptr<IServiceRouterManager> ServiceRouterMgrHelper::GetServiceRouterMgr()
routerMgr = InnerGetServiceRouterMgr();
if (routerMgr == nullptr) {
APP_LOGE("GetServiceRouterMgr, after load routerMgr_ is null");
TAG_LOGE(AAFwkTag::SER_ROUTER, "GetServiceRouterMgr, after load routerMgr_ is null");
}
return routerMgr;
}

View File

@ -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 "app_log_wrapper.h"
#include "appexecfwk_errors.h"
#include "hilog_tag_wrapper.h"
#include "parcel_macro.h"
#include "service_router_mgr_interface.h"
@ -25,31 +26,31 @@ namespace AbilityRuntime {
ServiceRouterMgrProxy::ServiceRouterMgrProxy(const sptr<IRemoteObject> &object)
: IRemoteProxy<IServiceRouterManager>(object)
{
APP_LOGD("ServiceRouterMgrProxy instance is created");
TAG_LOGD(AAFwkTag::SER_ROUTER, "ServiceRouterMgrProxy instance is created");
}
ServiceRouterMgrProxy::~ServiceRouterMgrProxy()
{
APP_LOGD("ServiceRouterMgrProxy instance is destroyed");
TAG_LOGD(AAFwkTag::SER_ROUTER, "ServiceRouterMgrProxy instance is destroyed");
}
int32_t ServiceRouterMgrProxy::QueryBusinessAbilityInfos(const BusinessAbilityFilter &filter,
std::vector<BusinessAbilityInfo> &abilityInfos)
{
APP_LOGD("ServiceRouterMgrProxy QueryBusinessAbilityInfos");
TAG_LOGD(AAFwkTag::SER_ROUTER, "ServiceRouterMgrProxy QueryBusinessAbilityInfos");
MessageParcel data;
if (!data.WriteInterfaceToken(GetDescriptor())) {
APP_LOGE("write interfaceToken failed");
TAG_LOGE(AAFwkTag::SER_ROUTER, "write interfaceToken failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteParcelable(&filter)) {
APP_LOGE("write filter failed");
TAG_LOGE(AAFwkTag::SER_ROUTER, "write filter failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
int32_t res = GetParcelableInfos<BusinessAbilityInfo>(ServiceRouterMgrProxy::Message::QUERY_BUSINESS_ABILITY_INFOS,
data, abilityInfos);
if (res != OHOS::NO_ERROR) {
APP_LOGE("fail to QueryBusinessAbilityInfos from server, error code: %{public}d", res);
TAG_LOGE(AAFwkTag::SER_ROUTER, "fail to QueryBusinessAbilityInfos from server, error code: %{public}d", res);
}
return res;
}
@ -57,24 +58,24 @@ int32_t ServiceRouterMgrProxy::QueryBusinessAbilityInfos(const BusinessAbilityFi
int32_t ServiceRouterMgrProxy::QueryPurposeInfos(const Want &want, const std::string purposeName,
std::vector<PurposeInfo> &purposeInfos)
{
APP_LOGD("ServiceRouterMgrProxy QueryPurposeInfos");
TAG_LOGD(AAFwkTag::SER_ROUTER, "ServiceRouterMgrProxy QueryPurposeInfos");
MessageParcel data;
if (!data.WriteInterfaceToken(GetDescriptor())) {
APP_LOGE("write interfaceToken failed");
TAG_LOGE(AAFwkTag::SER_ROUTER, "write interfaceToken failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteParcelable(&want)) {
APP_LOGE("write want failed");
TAG_LOGE(AAFwkTag::SER_ROUTER, "write want failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteString(purposeName)) {
APP_LOGE("write purposeName fail");
TAG_LOGE(AAFwkTag::SER_ROUTER, "write purposeName fail");
return false;
}
int32_t res = GetParcelableInfos<PurposeInfo>(ServiceRouterMgrProxy::Message::QUERY_PURPOSE_INFOS, data,
purposeInfos);
if (res != OHOS::NO_ERROR) {
APP_LOGE("fail to QueryPurposeInfos from server, error code: %{public}d", res);
TAG_LOGE(AAFwkTag::SER_ROUTER, "fail to QueryPurposeInfos from server, error code: %{public}d", res);
}
return res;
}
@ -85,30 +86,30 @@ int32_t ServiceRouterMgrProxy::StartUIExtensionAbility(const sptr<SessionInfo> &
MessageParcel reply;
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor())) {
APP_LOGE("write interfaceToken failed");
TAG_LOGE(AAFwkTag::SER_ROUTER, "write interfaceToken failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (sessionInfo) {
if (!data.WriteBool(true) || !data.WriteParcelable(sessionInfo)) {
APP_LOGE("flag and sessionInfo write failed.");
TAG_LOGE(AAFwkTag::SER_ROUTER, "flag and sessionInfo write failed.");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
} else {
if (!data.WriteBool(false)) {
APP_LOGE("flag write failed.");
TAG_LOGE(AAFwkTag::SER_ROUTER, "flag write failed.");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
}
if (!data.WriteInt32(userId)) {
APP_LOGE("StartExtensionAbility, userId write failed.");
TAG_LOGE(AAFwkTag::SER_ROUTER, "StartExtensionAbility, userId write failed.");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
int32_t error = SendRequest(ServiceRouterMgrProxy::Message::START_UI_EXTENSION, data, reply, option);
if (error != NO_ERROR) {
APP_LOGE("StartExtensionAbility, Send request error: %{public}d", error);
TAG_LOGE(AAFwkTag::SER_ROUTER, "StartExtensionAbility, Send request error: %{public}d", error);
return error;
}
return reply.ReadInt32();
@ -122,44 +123,44 @@ int32_t ServiceRouterMgrProxy::ConnectUIExtensionAbility(const Want &want, const
MessageOption option;
if (!data.WriteInterfaceToken(GetDescriptor()) || !data.WriteParcelable(&want)) {
APP_LOGE("write interfaceToken or want failed");
TAG_LOGE(AAFwkTag::SER_ROUTER, "write interfaceToken or want failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!connect) {
APP_LOGE("connect ability fail, connect is nullptr");
TAG_LOGE(AAFwkTag::SER_ROUTER, "connect ability fail, connect is nullptr");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (connect->AsObject()) {
if (!data.WriteBool(true) || !data.WriteRemoteObject(connect->AsObject())) {
APP_LOGE("flag and connect write failed.");
TAG_LOGE(AAFwkTag::SER_ROUTER, "flag and connect write failed.");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
} else {
if (!data.WriteBool(false)) {
APP_LOGE("flag write failed.");
TAG_LOGE(AAFwkTag::SER_ROUTER, "flag write failed.");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
}
if (sessionInfo) {
if (!data.WriteBool(true) || !data.WriteParcelable(sessionInfo)) {
APP_LOGE("flag and sessionInfo write failed.");
TAG_LOGE(AAFwkTag::SER_ROUTER, "flag and sessionInfo write failed.");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
} else {
if (!data.WriteBool(false)) {
APP_LOGE("flag write failed.");
TAG_LOGE(AAFwkTag::SER_ROUTER, "flag write failed.");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
}
if (!data.WriteInt32(userId)) {
APP_LOGE("%{public}s, userId write failed.", __func__);
TAG_LOGE(AAFwkTag::SER_ROUTER, "%{public}s, userId write failed.", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
int32_t error = SendRequest(ServiceRouterMgrProxy::Message::CONNECT_UI_EXTENSION, data, reply, option);
if (error != NO_ERROR) {
APP_LOGE("%{public}s, Send request error: %{public}d", __func__, error);
TAG_LOGE(AAFwkTag::SER_ROUTER, "%{public}s, Send request error: %{public}d", __func__, error);
return error;
}
return reply.ReadInt32();
@ -168,15 +169,16 @@ int32_t ServiceRouterMgrProxy::ConnectUIExtensionAbility(const Want &want, const
int32_t ServiceRouterMgrProxy::SendRequest(ServiceRouterMgrProxy::Message code, MessageParcel &data,
MessageParcel &reply, MessageOption &option)
{
APP_LOGI("ServiceRouterMgrProxy SendRequest");
TAG_LOGI(AAFwkTag::SER_ROUTER, "ServiceRouterMgrProxy SendRequest");
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
APP_LOGE("fail to send %{public}d cmd to service, remote object is null", code);
TAG_LOGE(AAFwkTag::SER_ROUTER, "fail to send %{public}d cmd to service, remote object is null", code);
return ERR_APPEXECFWK_FAILED_GET_REMOTE_PROXY;
}
int32_t result = remote->SendRequest(static_cast<uint32_t>(code), data, reply, option);
if (result != NO_ERROR) {
APP_LOGE("fail to send %{public}d cmd to service, transact error:%{public}d", code, result);
TAG_LOGE(
AAFwkTag::SER_ROUTER, "fail to send %{public}d cmd to service, transact error:%{public}d", code, result);
}
return result;
}
@ -189,13 +191,13 @@ int32_t ServiceRouterMgrProxy::GetParcelableInfos(
MessageOption option(MessageOption::TF_SYNC);
int32_t result = SendRequest(code, data, reply, option);
if (result != OHOS::NO_ERROR) {
APP_LOGE("SendRequest result false");
TAG_LOGE(AAFwkTag::SER_ROUTER, "SendRequest result false");
return result;
}
int32_t res = reply.ReadInt32();
if (res != ERR_OK) {
APP_LOGE("reply's result is %{public}d", res);
TAG_LOGE(AAFwkTag::SER_ROUTER, "reply's result is %{public}d", res);
return res;
}
@ -203,12 +205,12 @@ int32_t ServiceRouterMgrProxy::GetParcelableInfos(
for (int32_t j = 0; j < infosSize; j++) {
std::unique_ptr<T> info(reply.ReadParcelable<T>());
if (!info) {
APP_LOGE("Read parcelableInfos failed");
TAG_LOGE(AAFwkTag::SER_ROUTER, "Read parcelableInfos failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
parcelableInfos.emplace_back(*info);
}
APP_LOGI("get parcelableInfos success");
TAG_LOGI(AAFwkTag::SER_ROUTER, "get parcelableInfos success");
return OHOS::NO_ERROR;
}
} // namespace AbilityRuntime

View File

@ -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
@ -19,6 +19,7 @@
#include <unistd.h>
#include "app_log_wrapper.h"
#include "hilog_tag_wrapper.h"
#include "napi/native_api.h"
#include "napi/native_common.h"
#include "service_info.h"
@ -53,7 +54,7 @@ static napi_value BusinessAbilityRouterExport(napi_env env, napi_value exports)
{
napi_value businessType = InitBusinessTypeObject(env);
if (businessType == nullptr) {
APP_LOGE("failed to create business type object");
TAG_LOGE(AAFwkTag::SER_ROUTER, "failed to create business type object");
return nullptr;
}

View File

@ -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
@ -21,6 +21,7 @@
#include "common_func.h"
#include "bundle_errors.h"
#include "business_error.h"
#include "hilog_tag_wrapper.h"
#include "ipc_skeleton.h"
#include "iservice_registry.h"
#include "napi_arg.h"
@ -132,17 +133,17 @@ static void ConvertBusinessAbilityInfos(napi_env env, const std::vector<Business
static ErrCode InnerQueryBusinessAbilityInfos(AbilityInfosCallbackInfo *info)
{
if (info == nullptr) {
APP_LOGE("CallbackInfo is null");
TAG_LOGE(AAFwkTag::SER_ROUTER, "CallbackInfo is null");
return ERROR_BUNDLE_SERVICE_EXCEPTION;
}
auto serviceRouterMgr = ServiceRouterMgrHelper::GetInstance().GetServiceRouterMgr();
if (serviceRouterMgr == nullptr) {
APP_LOGE("can not get serviceRouterMgr");
TAG_LOGE(AAFwkTag::SER_ROUTER, "can not get serviceRouterMgr");
return ERROR_BUNDLE_SERVICE_EXCEPTION;
}
auto ret = serviceRouterMgr->QueryBusinessAbilityInfos(info->filter, info->businessAbilityInfos);
APP_LOGI("InnerQueryBusinessAbilityInfos ErrCode : %{public}d", ret);
TAG_LOGI(AAFwkTag::SER_ROUTER, "InnerQueryBusinessAbilityInfos ErrCode : %{public}d", ret);
return CommonFunc::ConvertErrCode(ret);
}
@ -181,10 +182,10 @@ static bool ParseBusinessAbilityInfo(napi_env env, napi_value args, BusinessAbil
void QueryBusinessAbilityInfosExec(napi_env env, void *data)
{
APP_LOGD("QueryServiceInfosExec start");
TAG_LOGD(AAFwkTag::SER_ROUTER, "QueryServiceInfosExec start");
AbilityInfosCallbackInfo *asyncCallbackInfo = reinterpret_cast<AbilityInfosCallbackInfo*>(data);
if (asyncCallbackInfo == nullptr) {
APP_LOGE("%{public}s, asyncCallbackInfo == nullptr.", __func__);
TAG_LOGE(AAFwkTag::SER_ROUTER, "%{public}s, asyncCallbackInfo == nullptr.", __func__);
return;
}
asyncCallbackInfo->err = InnerQueryBusinessAbilityInfos(asyncCallbackInfo);
@ -192,10 +193,10 @@ void QueryBusinessAbilityInfosExec(napi_env env, void *data)
void QueryBusinessAbilityInfosComplete(napi_env env, napi_status status, void *data)
{
APP_LOGD("QueryBusinessAbilityInfosComplete start");
TAG_LOGD(AAFwkTag::SER_ROUTER, "QueryBusinessAbilityInfosComplete start");
AbilityInfosCallbackInfo *asyncCallbackInfo = reinterpret_cast<AbilityInfosCallbackInfo*>(data);
if (asyncCallbackInfo == nullptr) {
APP_LOGE("asyncCallbackInfo is null in %{public}s", __func__);
TAG_LOGE(AAFwkTag::SER_ROUTER, "asyncCallbackInfo is null in %{public}s", __func__);
return;
}
napi_value result[2] = {0};
@ -224,7 +225,7 @@ void QueryBusinessAbilityInfosComplete(napi_env env, napi_status status, void *d
napi_value QueryBusinessAbilityInfos(napi_env env, napi_callback_info info)
{
APP_LOGI("NAPI_QueryBusinessAbilityInfos start");
TAG_LOGI(AAFwkTag::SER_ROUTER, "NAPI_QueryBusinessAbilityInfos start");
NapiArg args(env, info);
if (!args.Init(ARGS_SIZE_ONE, ARGS_SIZE_TWO)) {
BusinessError::ThrowTooFewParametersError(env, ERROR_PARAM_CHECK_ERROR);
@ -250,7 +251,7 @@ napi_value QueryBusinessAbilityInfos(napi_env env, napi_callback_info info)
}
}
} else {
APP_LOGE("parameters error");
TAG_LOGE(AAFwkTag::SER_ROUTER, "parameters error");
BusinessError::ThrowTooFewParametersError(env, ERROR_PARAM_CHECK_ERROR);
return nullptr;
}

View File

@ -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
@ -21,6 +21,7 @@
#include "bundle_constants.h"
#include "bundle_info.h"
#include "hilog_tag_wrapper.h"
#include "inner_service_info.h"
#include "service_info.h"
#include "sr_constants.h"
@ -38,13 +39,14 @@ public:
std::vector<BusinessAbilityInfo> &businessAbilityInfos, const AppInfo &appInfo)
{
if (bundleInfo.name.empty()) {
APP_LOGE("ConvertBundleInfo, bundleInfo invalid");
TAG_LOGE(AAFwkTag::SER_ROUTER, "ConvertBundleInfo, bundleInfo invalid");
return false;
}
ResolveAbilityInfos(bundleInfo.abilityInfos, purposeInfos, appInfo);
ResolveExtAbilityInfos(bundleInfo.extensionInfos, purposeInfos, businessAbilityInfos, appInfo);
if (purposeInfos.empty() && businessAbilityInfos.empty()) {
APP_LOGI("ResolveBundleInfo, not support, bundleName: %{public}s", bundleInfo.name.c_str());
TAG_LOGI(AAFwkTag::SER_ROUTER,
"ResolveBundleInfo, not support, bundleName: %{public}s", bundleInfo.name.c_str());
return false;
}
return true;
@ -112,7 +114,8 @@ private:
purposeInfo.componentType = ComponentType::UI_ABILITY;
purposeInfo.appInfo = appInfo;
purposeInfos.emplace_back(purposeInfo);
APP_LOGI("AbilityToPurposes, bundle: %{public}s ,ability: %{public}s, purposeName: %{public}s",
TAG_LOGI(AAFwkTag::SER_ROUTER,
"AbilityToPurposes, bundle: %{public}s ,ability: %{public}s, purposeName: %{public}s",
abilityInfo.bundleName.c_str(), abilityInfo.name.c_str(), name.c_str());
}
}
@ -140,7 +143,8 @@ private:
purposeInfo.purposeName = purposeAndCard;
purposeInfo.componentType = ComponentType::UI_EXTENSION;
purposeInfos.emplace_back(purposeInfo);
APP_LOGI("UIExtToPurposes, bundle: %{public}s, abilityName: %{public}s, purposeName: %{public}s",
TAG_LOGI(AAFwkTag::SER_ROUTER,
"UIExtToPurposes, bundle: %{public}s, abilityName: %{public}s, purposeName: %{public}s",
extAbilityInfo.bundleName.c_str(), extAbilityInfo.name.c_str(), purposeAndCard.c_str());
} else {
std::vector<std::string> purposeNameAndCardName;
@ -150,11 +154,12 @@ private:
purposeInfo.cardName = purposeNameAndCardName[1];
purposeInfo.componentType = ComponentType::FORM;
purposeInfos.emplace_back(purposeInfo);
APP_LOGI("FormToPurposes, bundle: %{public}s, abilityName: %{public}s, purposeName: %{public}s",
TAG_LOGI(AAFwkTag::SER_ROUTER,
"FormToPurposes, bundle: %{public}s, abilityName: %{public}s, purposeName: %{public}s",
extAbilityInfo.bundleName.c_str(), extAbilityInfo.name.c_str(),
purposeInfo.purposeName.c_str());
} else {
APP_LOGW("FormToPurposes invalid supportPurpose");
TAG_LOGW(AAFwkTag::SER_ROUTER, "FormToPurposes invalid supportPurpose");
}
}
}
@ -167,7 +172,7 @@ private:
return;
}
BusinessType type = GetBusinessType(extAbilityInfo.metadata);
APP_LOGI("ToService, abilityName: %{public}s, businessType: %{public}d",
TAG_LOGI(AAFwkTag::SER_ROUTER, "ToService, abilityName: %{public}s, businessType: %{public}d",
extAbilityInfo.name.c_str(), static_cast<int>(type));
if (type != BusinessType::UNSPECIFIED) {
BusinessAbilityInfo businessAbilityInfo;

View File

@ -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
@ -19,6 +19,7 @@
#include "app_log_wrapper.h"
#include "application_info.h"
#include "bundle_info.h"
#include "hilog_tag_wrapper.h"
#include "service_info.h"
#include "want.h"
@ -81,7 +82,7 @@ public:
void UpdateBusinessAbilityInfos(const std::vector<BusinessAbilityInfo> &businessAbilityInfos)
{
if (businessAbilityInfos.size() == 0) {
APP_LOGW("UpdateBusinessAbilityInfos, serviceInfos.size is 0");
TAG_LOGW(AAFwkTag::SER_ROUTER, "UpdateBusinessAbilityInfos, serviceInfos.size is 0");
businessAbilityInfos_.clear();
return;
}
@ -96,7 +97,7 @@ public:
void UpdatePurposeInfos(const std::vector<PurposeInfo> &purposeInfos)
{
if (purposeInfos.size() == 0) {
APP_LOGW("updatePurposeInfos, purposeInfos.size is 0");
TAG_LOGW(AAFwkTag::SER_ROUTER, "updatePurposeInfos, purposeInfos.size is 0");
purposeInfos_.clear();
return;
}

View File

@ -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 "app_log_wrapper.h"
#include "bundle_info_resolve_util.h"
#include "bundle_mgr_helper.h"
#include "hilog_tag_wrapper.h"
#include "iservice_registry.h"
#include "sr_constants.h"
#include "sr_samgr_helper.h"
@ -32,17 +33,17 @@ const std::string SCHEME_SERVICE_ROUTER = "servicerouter";
bool ServiceRouterDataMgr::LoadAllBundleInfos()
{
APP_LOGD("SRDM LoadAllBundleInfos");
TAG_LOGD(AAFwkTag::SER_ROUTER, "SRDM LoadAllBundleInfos");
ClearAllBundleInfos();
auto bundleMgrHelper = DelayedSingleton<AppExecFwk::BundleMgrHelper>::GetInstance();
if (bundleMgrHelper == nullptr) {
APP_LOGE("The bundleMgrHelper is nullptr.");
TAG_LOGE(AAFwkTag::SER_ROUTER, "The bundleMgrHelper is nullptr.");
return false;
}
auto flags = (BundleFlag::GET_BUNDLE_WITH_ABILITIES | BundleFlag::GET_BUNDLE_WITH_EXTENSION_INFO);
std::vector<BundleInfo> bundleInfos;
if (!bundleMgrHelper->GetBundleInfos(flags, bundleInfos, SrSamgrHelper::GetCurrentActiveUserId())) {
APP_LOGE("Return false.");
TAG_LOGE(AAFwkTag::SER_ROUTER, "Return false.");
return false;
}
@ -55,16 +56,16 @@ bool ServiceRouterDataMgr::LoadAllBundleInfos()
bool ServiceRouterDataMgr::LoadBundleInfo(const std::string &bundleName)
{
APP_LOGD("SRDM LoadBundleInfo");
TAG_LOGD(AAFwkTag::SER_ROUTER, "SRDM LoadBundleInfo");
auto bundleMgrHelper = DelayedSingleton<AppExecFwk::BundleMgrHelper>::GetInstance();
if (bundleMgrHelper == nullptr) {
APP_LOGI("The bundleMgrHelper is nullptr.");
TAG_LOGI(AAFwkTag::SER_ROUTER, "The bundleMgrHelper is nullptr.");
return false;
}
BundleInfo bundleInfo;
auto flags = (BundleFlag::GET_BUNDLE_WITH_ABILITIES | BundleFlag::GET_BUNDLE_WITH_EXTENSION_INFO);
if (!bundleMgrHelper->GetBundleInfo(bundleName, flags, bundleInfo, SrSamgrHelper::GetCurrentActiveUserId())) {
APP_LOGE("Return false.");
TAG_LOGE(AAFwkTag::SER_ROUTER, "Return false.");
return false;
}
@ -75,7 +76,7 @@ bool ServiceRouterDataMgr::LoadBundleInfo(const std::string &bundleName)
void ServiceRouterDataMgr::UpdateBundleInfoLocked(const BundleInfo &bundleInfo)
{
APP_LOGD("SRDM UpdateBundleInfo");
TAG_LOGD(AAFwkTag::SER_ROUTER, "SRDM UpdateBundleInfo");
InnerServiceInfo innerServiceInfo;
auto infoItem = innerServiceInfos_.find(bundleInfo.name);
if (infoItem != innerServiceInfos_.end()) {
@ -94,11 +95,11 @@ void ServiceRouterDataMgr::UpdateBundleInfoLocked(const BundleInfo &bundleInfo)
void ServiceRouterDataMgr::DeleteBundleInfo(const std::string &bundleName)
{
APP_LOGD("SRDM DeleteBundleInfo");
TAG_LOGD(AAFwkTag::SER_ROUTER, "SRDM DeleteBundleInfo");
std::lock_guard<std::mutex> lock(bundleInfoMutex_);
auto infoItem = innerServiceInfos_.find(bundleName);
if (infoItem == innerServiceInfos_.end()) {
APP_LOGE("SRDM inner service info not found by bundleName");
TAG_LOGE(AAFwkTag::SER_ROUTER, "SRDM inner service info not found by bundleName");
return;
}
innerServiceInfos_.erase(bundleName);
@ -107,10 +108,10 @@ void ServiceRouterDataMgr::DeleteBundleInfo(const std::string &bundleName)
int32_t ServiceRouterDataMgr::QueryBusinessAbilityInfos(const BusinessAbilityFilter &filter,
std::vector<BusinessAbilityInfo> &businessAbilityInfos) const
{
APP_LOGD("SRDM QueryBusinessAbilityInfos");
TAG_LOGD(AAFwkTag::SER_ROUTER, "SRDM QueryBusinessAbilityInfos");
BusinessType validType = GetBusinessType(filter);
if (validType == BusinessType::UNSPECIFIED) {
APP_LOGE("SRDM QueryBusinessAbilityInfos, businessType is empty");
TAG_LOGE(AAFwkTag::SER_ROUTER, "SRDM QueryBusinessAbilityInfos, businessType is empty");
return ERR_BUNDLE_MANAGER_PARAM_ERROR;
}
@ -124,9 +125,9 @@ int32_t ServiceRouterDataMgr::QueryBusinessAbilityInfos(const BusinessAbilityFil
int32_t ServiceRouterDataMgr::QueryPurposeInfos(const Want &want, const std::string purposeName,
std::vector<PurposeInfo> &purposeInfos) const
{
APP_LOGD("SRDM QueryPurposeInfos");
TAG_LOGD(AAFwkTag::SER_ROUTER, "SRDM QueryPurposeInfos");
if (purposeName.empty()) {
APP_LOGE("SRDM QueryPurposeInfos, purposeName is empty");
TAG_LOGE(AAFwkTag::SER_ROUTER, "SRDM QueryPurposeInfos, purposeName is empty");
return ERR_BUNDLE_MANAGER_PARAM_ERROR;
}
@ -140,7 +141,7 @@ int32_t ServiceRouterDataMgr::QueryPurposeInfos(const Want &want, const std::str
} else {
auto infoItem = innerServiceInfos_.find(bundleName);
if (infoItem == innerServiceInfos_.end()) {
APP_LOGE("SRDM QueryPurposeInfos, not found by bundleName.");
TAG_LOGE(AAFwkTag::SER_ROUTER, "SRDM QueryPurposeInfos, not found by bundleName.");
return ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST;
}
infoItem->second.FindPurposeInfos(purposeName, purposeInfos);
@ -160,7 +161,7 @@ BusinessType ServiceRouterDataMgr::GetBusinessType(const BusinessAbilityFilter &
OHOS::Uri uri = OHOS::Uri(filter.uri);
if (uri.GetScheme().empty() || uri.GetHost().empty() || uri.GetScheme() != SCHEME_SERVICE_ROUTER) {
APP_LOGE("GetExtensionServiceType, invalid uri: %{public}s", filter.uri.c_str());
TAG_LOGE(AAFwkTag::SER_ROUTER, "GetExtensionServiceType, invalid uri: %{public}s", filter.uri.c_str());
return BusinessType::UNSPECIFIED;
}
return BundleInfoResolveUtil::findBusinessType(uri.GetHost());

View File

@ -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
@ -24,6 +24,7 @@
#include "bundle_constants.h"
#include "common_event_manager.h"
#include "common_event_support.h"
#include "hilog_tag_wrapper.h"
#include "if_system_ability_manager.h"
#include "in_process_call_wrapper.h"
#include "ipc_skeleton.h"
@ -47,30 +48,30 @@ const bool REGISTER_RESULT =
ServiceRouterMgrService::ServiceRouterMgrService() : SystemAbility(SERVICE_ROUTER_MGR_SERVICE_ID, true)
{
APP_LOGD("SRMS instance create");
TAG_LOGD(AAFwkTag::SER_ROUTER, "SRMS instance create");
}
ServiceRouterMgrService::~ServiceRouterMgrService()
{
APP_LOGD("SRMS instance destroy");
TAG_LOGD(AAFwkTag::SER_ROUTER, "SRMS instance destroy");
}
void ServiceRouterMgrService::OnStart()
{
APP_LOGI("SRMS starting...");
TAG_LOGI(AAFwkTag::SER_ROUTER, "SRMS starting...");
Init();
bool ret = Publish(this);
if (!ret) {
APP_LOGE("Publish SRMS failed!");
TAG_LOGE(AAFwkTag::SER_ROUTER, "Publish SRMS failed!");
return;
}
DelayUnloadTask();
APP_LOGI("SRMS start success.");
TAG_LOGI(AAFwkTag::SER_ROUTER, "SRMS start success.");
}
void ServiceRouterMgrService::OnStop()
{
APP_LOGI("Stop SRMS.");
TAG_LOGI(AAFwkTag::SER_ROUTER, "Stop SRMS.");
}
void ServiceRouterMgrService::Init()
@ -83,35 +84,35 @@ void ServiceRouterMgrService::Init()
void ServiceRouterMgrService::DelayUnloadTask()
{
if (handler_ == nullptr) {
APP_LOGI("DelayUnloadTask, handler_ is nullptr");
TAG_LOGI(AAFwkTag::SER_ROUTER, "DelayUnloadTask, handler_ is nullptr");
return;
}
std::lock_guard<std::mutex> lock(delayTaskMutex_);
handler_->RemoveTask(TASK_NAME);
auto task = [this]() {
APP_LOGI("UnloadSA start.");
TAG_LOGI(AAFwkTag::SER_ROUTER, "UnloadSA start.");
sptr<ISystemAbilityManager> saManager =
OHOS::SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
if (saManager == nullptr) {
APP_LOGE("UnloadSA, GetSystemAbilityManager is null.");
TAG_LOGE(AAFwkTag::SER_ROUTER, "UnloadSA, GetSystemAbilityManager is null.");
return;
}
int32_t result = saManager->UnloadSystemAbility(OHOS::SERVICE_ROUTER_MGR_SERVICE_ID);
if (result != ERR_OK) {
APP_LOGE("UnloadSA, UnloadSystemAbility result: %{public}d", result);
TAG_LOGE(AAFwkTag::SER_ROUTER, "UnloadSA, UnloadSystemAbility result: %{public}d", result);
return;
}
APP_LOGI("UnloadSA success.");
TAG_LOGI(AAFwkTag::SER_ROUTER, "UnloadSA success.");
};
handler_->PostTask(task, TASK_NAME, UNLOAD_DELAY_TIME);
}
bool ServiceRouterMgrService::LoadAllBundleInfos()
{
APP_LOGD("LoadAllBundleInfos start");
TAG_LOGD(AAFwkTag::SER_ROUTER, "LoadAllBundleInfos start");
bool ret = ServiceRouterDataMgr::GetInstance().LoadAllBundleInfos();
APP_LOGD("LoadAllBundleInfos end");
TAG_LOGD(AAFwkTag::SER_ROUTER, "LoadAllBundleInfos end");
return ret;
}
@ -120,12 +121,12 @@ bool ServiceRouterMgrService::InitEventRunnerAndHandler()
std::lock_guard<std::mutex> lock(mutex_);
runner_ = EventRunner::Create(NAME_SERVICE_ROUTER_MGR_SERVICE);
if (runner_ == nullptr) {
APP_LOGE("%{public}s fail, Failed to init due to create runner error", __func__);
TAG_LOGE(AAFwkTag::SER_ROUTER, "%{public}s fail, Failed to init due to create runner error", __func__);
return false;
}
handler_ = std::make_shared<EventHandler>(runner_);
if (handler_ == nullptr) {
APP_LOGE("%{public}s fail, Failed to init due to create handler error", __func__);
TAG_LOGE(AAFwkTag::SER_ROUTER, "%{public}s fail, Failed to init due to create handler error", __func__);
return false;
}
return true;
@ -134,7 +135,7 @@ bool ServiceRouterMgrService::InitEventRunnerAndHandler()
bool ServiceRouterMgrService::ServiceRouterMgrService::SubscribeCommonEvent()
{
if (eventSubscriber_ != nullptr) {
APP_LOGI("subscribeCommonEvent already subscribed.");
TAG_LOGI(AAFwkTag::SER_ROUTER, "subscribeCommonEvent already subscribed.");
return true;
}
EventFwk::MatchingSkills matchingSkills;
@ -148,17 +149,17 @@ bool ServiceRouterMgrService::ServiceRouterMgrService::SubscribeCommonEvent()
eventSubscriber_ = std::make_shared<SrCommonEventSubscriber>(subscribeInfo);
eventSubscriber_->SetEventHandler(handler_);
if (!EventFwk::CommonEventManager::SubscribeCommonEvent(eventSubscriber_)) {
APP_LOGE("subscribeCommonEvent subscribed failure.");
TAG_LOGE(AAFwkTag::SER_ROUTER, "subscribeCommonEvent subscribed failure.");
return false;
};
APP_LOGI("subscribeCommonEvent subscribed success.");
TAG_LOGI(AAFwkTag::SER_ROUTER, "subscribeCommonEvent subscribed success.");
return true;
}
int32_t ServiceRouterMgrService::QueryBusinessAbilityInfos(const BusinessAbilityFilter &filter,
std::vector< BusinessAbilityInfo> &businessAbilityInfos)
{
APP_LOGD("coldStart:");
TAG_LOGD(AAFwkTag::SER_ROUTER, "coldStart:");
DelayUnloadTask();
return ServiceRouterDataMgr::GetInstance().QueryBusinessAbilityInfos(filter, businessAbilityInfos);
}
@ -166,14 +167,14 @@ int32_t ServiceRouterMgrService::QueryBusinessAbilityInfos(const BusinessAbility
int32_t ServiceRouterMgrService::QueryPurposeInfos(const Want &want, const std::string purposeName,
std::vector<PurposeInfo> &purposeInfos)
{
APP_LOGD("coldStart:");
TAG_LOGD(AAFwkTag::SER_ROUTER, "coldStart:");
DelayUnloadTask();
return ServiceRouterDataMgr::GetInstance().QueryPurposeInfos(want, purposeName, purposeInfos);
}
int32_t ServiceRouterMgrService::StartUIExtensionAbility(const sptr<SessionInfo> &sessionInfo, int32_t userId)
{
APP_LOGD("StartUIExtensionAbility start:");
TAG_LOGD(AAFwkTag::SER_ROUTER, "StartUIExtensionAbility start:");
DelayUnloadTask();
return IN_PROCESS_CALL(AbilityManagerClient::GetInstance()->StartUIExtensionAbility(sessionInfo, userId));
}
@ -181,7 +182,7 @@ int32_t ServiceRouterMgrService::StartUIExtensionAbility(const sptr<SessionInfo>
int32_t ServiceRouterMgrService::ConnectUIExtensionAbility(const Want &want, const sptr<IAbilityConnection> &connect,
const sptr<SessionInfo> &sessionInfo, int32_t userId)
{
APP_LOGD("ConnectUIExtensionAbility start:");
TAG_LOGD(AAFwkTag::SER_ROUTER, "ConnectUIExtensionAbility start:");
DelayUnloadTask();
return IN_PROCESS_CALL(AbilityManagerClient::GetInstance()->
ConnectUIExtensionAbility(want, connect, sessionInfo, userId));

View File

@ -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
@ -21,6 +21,7 @@
#include "appexecfwk_errors.h"
#include "app_log_wrapper.h"
#include "bundle_constants.h"
#include "hilog_tag_wrapper.h"
#include "ipc_skeleton.h"
#include "service_info.h"
#include "tokenid_kit.h"
@ -29,12 +30,12 @@ namespace OHOS {
namespace AbilityRuntime {
ServiceRouterMgrStub::ServiceRouterMgrStub()
{
APP_LOGD("ServiceRouterMgrStub instance is created");
TAG_LOGD(AAFwkTag::SER_ROUTER, "ServiceRouterMgrStub instance is created");
}
ServiceRouterMgrStub::~ServiceRouterMgrStub()
{
APP_LOGD("ServiceRouterMgrStub instance is destroyed");
TAG_LOGD(AAFwkTag::SER_ROUTER, "ServiceRouterMgrStub instance is destroyed");
}
int ServiceRouterMgrStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
@ -43,7 +44,7 @@ int ServiceRouterMgrStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Me
std::u16string descriptor = ServiceRouterMgrStub::GetDescriptor();
std::u16string remoteDescriptor = data.ReadInterfaceToken();
if (descriptor != remoteDescriptor) {
APP_LOGE("local descriptor is not equal to remote");
TAG_LOGE(AAFwkTag::SER_ROUTER, "local descriptor is not equal to remote");
return ERR_INVALID_STATE;
}
@ -53,37 +54,37 @@ int ServiceRouterMgrStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Me
case static_cast<uint32_t>(IServiceRouterManager::Message::QUERY_PURPOSE_INFOS):
return HandleQueryPurposeInfos(data, reply);
default:
APP_LOGW("ServiceRouterMgrStub receives unknown code, code = %{public}d", code);
TAG_LOGW(AAFwkTag::SER_ROUTER, "ServiceRouterMgrStub receives unknown code, code = %{public}d", code);
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
}
}
int ServiceRouterMgrStub::HandleQueryBusinessAbilityInfos(MessageParcel &data, MessageParcel &reply)
{
APP_LOGD("ServiceRouterMgrStub handle query service infos");
TAG_LOGD(AAFwkTag::SER_ROUTER, "ServiceRouterMgrStub handle query service infos");
if (!VerifySystemApp()) {
APP_LOGE("verify system app failed");
TAG_LOGE(AAFwkTag::SER_ROUTER, "verify system app failed");
return ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED;
}
if (!VerifyCallingPermission(Constants::PERMISSION_GET_BUNDLE_INFO_PRIVILEGED)) {
APP_LOGE("verify GET_BUNDLE_INFO_PRIVILEGED failed");
TAG_LOGE(AAFwkTag::SER_ROUTER, "verify GET_BUNDLE_INFO_PRIVILEGED failed");
return ERR_BUNDLE_MANAGER_PERMISSION_DENIED;
}
std::unique_ptr<BusinessAbilityFilter> filter(data.ReadParcelable<BusinessAbilityFilter>());
if (filter == nullptr) {
APP_LOGE("ReadParcelable<filter> failed");
TAG_LOGE(AAFwkTag::SER_ROUTER, "ReadParcelable<filter> failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
std::vector<BusinessAbilityInfo> infos;
int ret = QueryBusinessAbilityInfos(*filter, infos);
if (!reply.WriteInt32(ret)) {
APP_LOGE("write ret failed");
TAG_LOGE(AAFwkTag::SER_ROUTER, "write ret failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (ret == ERR_OK) {
if (!WriteParcelableVector<BusinessAbilityInfo>(infos, reply)) {
APP_LOGE("QueryBusinessAbilityInfos write failed");
TAG_LOGE(AAFwkTag::SER_ROUTER, "QueryBusinessAbilityInfos write failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
}
@ -92,26 +93,26 @@ int ServiceRouterMgrStub::HandleQueryBusinessAbilityInfos(MessageParcel &data, M
int ServiceRouterMgrStub::HandleQueryPurposeInfos(MessageParcel &data, MessageParcel &reply)
{
APP_LOGD("ServiceRouterMgrStub handle query purpose infos");
TAG_LOGD(AAFwkTag::SER_ROUTER, "ServiceRouterMgrStub handle query purpose infos");
if (!VerifyCallingPermission(Constants::PERMISSION_GET_BUNDLE_INFO_PRIVILEGED)) {
APP_LOGE("verify GET_BUNDLE_INFO_PRIVILEGED failed");
TAG_LOGE(AAFwkTag::SER_ROUTER, "verify GET_BUNDLE_INFO_PRIVILEGED failed");
return ERR_BUNDLE_MANAGER_PERMISSION_DENIED;
}
std::unique_ptr<Want> want(data.ReadParcelable<Want>());
if (want == nullptr) {
APP_LOGE("ReadParcelable<want> failed");
TAG_LOGE(AAFwkTag::SER_ROUTER, "ReadParcelable<want> failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
std::string purposeName = data.ReadString();
std::vector<PurposeInfo> infos;
int ret = QueryPurposeInfos(*want, purposeName, infos);
if (!reply.WriteInt32(ret)) {
APP_LOGE("write ret failed");
TAG_LOGE(AAFwkTag::SER_ROUTER, "write ret failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (ret == ERR_OK) {
if (!WriteParcelableVector<PurposeInfo>(infos, reply)) {
APP_LOGE("QueryPurposeInfos write failed");
TAG_LOGE(AAFwkTag::SER_ROUTER, "QueryPurposeInfos write failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
}
@ -120,7 +121,7 @@ int ServiceRouterMgrStub::HandleQueryPurposeInfos(MessageParcel &data, MessagePa
int ServiceRouterMgrStub::HandleStartUIExtensionAbility(MessageParcel &data, MessageParcel &reply)
{
APP_LOGD("ServiceRouterMgrStub handle start ui extension ability");
TAG_LOGD(AAFwkTag::SER_ROUTER, "ServiceRouterMgrStub handle start ui extension ability");
sptr<SessionInfo> sessionInfo = nullptr;
if (data.ReadBool()) {
sessionInfo = data.ReadParcelable<SessionInfo>();
@ -128,7 +129,7 @@ int ServiceRouterMgrStub::HandleStartUIExtensionAbility(MessageParcel &data, Mes
int32_t userId = data.ReadInt32();
int32_t result = StartUIExtensionAbility(sessionInfo, userId);
if (!reply.WriteInt32(result)) {
APP_LOGE("write result failed");
TAG_LOGE(AAFwkTag::SER_ROUTER, "write result failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
return ERR_OK;
@ -136,10 +137,10 @@ int ServiceRouterMgrStub::HandleStartUIExtensionAbility(MessageParcel &data, Mes
int ServiceRouterMgrStub::HandleConnectUIExtensionAbility(MessageParcel &data, MessageParcel &reply)
{
APP_LOGD("ServiceRouterMgrStub handle connect ui extension ability");
TAG_LOGD(AAFwkTag::SER_ROUTER, "ServiceRouterMgrStub handle connect ui extension ability");
std::unique_ptr<Want> want(data.ReadParcelable<Want>());
if (want == nullptr) {
APP_LOGE("ReadParcelable<want> failed");
TAG_LOGE(AAFwkTag::SER_ROUTER, "ReadParcelable<want> failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
sptr<IAbilityConnection> callback = nullptr;
@ -153,7 +154,7 @@ int ServiceRouterMgrStub::HandleConnectUIExtensionAbility(MessageParcel &data, M
int32_t userId = data.ReadInt32();
int32_t result = ConnectUIExtensionAbility(*want, callback, sessionInfo, userId);
if (!reply.WriteInt32(result)) {
APP_LOGE("write result failed");
TAG_LOGE(AAFwkTag::SER_ROUTER, "write result failed");
return ERR_APPEXECFWK_PARCEL_ERROR;
}
return ERR_OK;
@ -161,7 +162,7 @@ int ServiceRouterMgrStub::HandleConnectUIExtensionAbility(MessageParcel &data, M
bool ServiceRouterMgrStub::VerifyCallingPermission(const std::string &permissionName)
{
APP_LOGD("VerifyCallingPermission permission %{public}s", permissionName.c_str());
TAG_LOGD(AAFwkTag::SER_ROUTER, "VerifyCallingPermission permission %{public}s", permissionName.c_str());
OHOS::Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID();
OHOS::Security::AccessToken::ATokenTypeEnum tokenType =
OHOS::Security::AccessToken::AccessTokenKit::GetTokenTypeFlag(callerToken);
@ -170,7 +171,7 @@ bool ServiceRouterMgrStub::VerifyCallingPermission(const std::string &permission
}
int32_t ret = OHOS::Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, permissionName);
if (ret == OHOS::Security::AccessToken::PermissionState::PERMISSION_DENIED) {
APP_LOGE("PERMISSION_DENIED: %{public}s", permissionName.c_str());
TAG_LOGE(AAFwkTag::SER_ROUTER, "PERMISSION_DENIED: %{public}s", permissionName.c_str());
return false;
}
return true;
@ -178,7 +179,7 @@ bool ServiceRouterMgrStub::VerifyCallingPermission(const std::string &permission
bool ServiceRouterMgrStub::VerifySystemApp()
{
APP_LOGD("verifying systemApp");
TAG_LOGD(AAFwkTag::SER_ROUTER, "verifying systemApp");
Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID();
Security::AccessToken::ATokenTypeEnum tokenType =
Security::AccessToken::AccessTokenKit::GetTokenTypeFlag(callerToken);
@ -188,7 +189,7 @@ bool ServiceRouterMgrStub::VerifySystemApp()
}
uint64_t accessTokenIdEx = IPCSkeleton::GetCallingFullTokenID();
if (!Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(accessTokenIdEx)) {
APP_LOGE("non-system app calling system api");
TAG_LOGE(AAFwkTag::SER_ROUTER, "non-system app calling system api");
return false;
}
return true;
@ -198,13 +199,13 @@ template <typename T>
bool ServiceRouterMgrStub::WriteParcelableVector(std::vector<T> &parcelableVector, Parcel &reply)
{
if (!reply.WriteInt32(parcelableVector.size())) {
APP_LOGE("write ParcelableVector size failed");
TAG_LOGE(AAFwkTag::SER_ROUTER, "write ParcelableVector size failed");
return false;
}
for (auto &parcelable : parcelableVector) {
if (!reply.WriteParcelable(&parcelable)) {
APP_LOGE("write ParcelableVector failed");
TAG_LOGE(AAFwkTag::SER_ROUTER, "write ParcelableVector failed");
return false;
}
}

View File

@ -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 "app_log_wrapper.h"
#include "common_event_support.h"
#include "hilog_tag_wrapper.h"
#include "service_router_data_mgr.h"
#include "want.h"
@ -25,12 +26,12 @@ namespace AbilityRuntime {
SrCommonEventSubscriber::SrCommonEventSubscriber(const EventFwk::CommonEventSubscribeInfo &subscribeInfo)
: EventFwk::CommonEventSubscriber(subscribeInfo)
{
APP_LOGD("SrCommonEventSubscriber created");
TAG_LOGD(AAFwkTag::SER_ROUTER, "SrCommonEventSubscriber created");
}
SrCommonEventSubscriber::~SrCommonEventSubscriber()
{
APP_LOGD("SrCommonEventSubscriber destroyed");
TAG_LOGD(AAFwkTag::SER_ROUTER, "SrCommonEventSubscriber destroyed");
}
void SrCommonEventSubscriber::OnReceiveEvent(const EventFwk::CommonEventData &eventData)
@ -39,22 +40,22 @@ void SrCommonEventSubscriber::OnReceiveEvent(const EventFwk::CommonEventData &ev
std::string action = want.GetAction();
std::string bundleName = want.GetElement().GetBundleName();
if (action.empty() || eventHandler_ == nullptr) {
APP_LOGE("failed, empty action: %{public}s, or invalid event handler", action.c_str());
TAG_LOGE(AAFwkTag::SER_ROUTER, "failed, empty action: %{public}s, or invalid event handler", action.c_str());
return;
}
if (bundleName.empty() && action != EventFwk::CommonEventSupport::COMMON_EVENT_USER_SWITCHED) {
APP_LOGE("failed, invalid param, action: %{public}s, bundleName: %{public}s",
TAG_LOGE(AAFwkTag::SER_ROUTER, "failed, invalid param, action: %{public}s, bundleName: %{public}s",
action.c_str(), bundleName.c_str());
return;
}
APP_LOGI("action:%{public}s.", action.c_str());
TAG_LOGI(AAFwkTag::SER_ROUTER, "action:%{public}s.", action.c_str());
std::weak_ptr<SrCommonEventSubscriber> weakThis = shared_from_this();
if (action == EventFwk::CommonEventSupport::COMMON_EVENT_USER_SWITCHED) {
int32_t userId = eventData.GetCode();
auto task = [weakThis, userId]() {
std::shared_ptr<SrCommonEventSubscriber> sharedThis = weakThis.lock();
if (sharedThis) {
APP_LOGI("%{public}d COMMON_EVENT_USER_SWITCHED", userId);
TAG_LOGI(AAFwkTag::SER_ROUTER, "%{public}d COMMON_EVENT_USER_SWITCHED", userId);
ServiceRouterDataMgr::GetInstance().LoadAllBundleInfos();
}
};
@ -62,7 +63,7 @@ void SrCommonEventSubscriber::OnReceiveEvent(const EventFwk::CommonEventData &ev
} else if (action == EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_ADDED ||
action == EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_CHANGED) {
auto task = [weakThis, bundleName]() {
APP_LOGI("bundle changed, bundleName: %{public}s", bundleName.c_str());
TAG_LOGI(AAFwkTag::SER_ROUTER, "bundle changed, bundleName: %{public}s", bundleName.c_str());
std::shared_ptr<SrCommonEventSubscriber> sharedThis = weakThis.lock();
if (sharedThis) {
ServiceRouterDataMgr::GetInstance().LoadBundleInfo(bundleName);
@ -71,7 +72,7 @@ void SrCommonEventSubscriber::OnReceiveEvent(const EventFwk::CommonEventData &ev
eventHandler_->PostTask(task, "SrCommonEventSubscriber:LoadBundleInfo");
} else if (action == EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_REMOVED) {
auto task = [weakThis, bundleName]() {
APP_LOGI("bundle remove, bundleName: %{public}s", bundleName.c_str());
TAG_LOGI(AAFwkTag::SER_ROUTER, "bundle remove, bundleName: %{public}s", bundleName.c_str());
std::shared_ptr<SrCommonEventSubscriber> sharedThis = weakThis.lock();
if (sharedThis) {
ServiceRouterDataMgr::GetInstance().DeleteBundleInfo(bundleName);
@ -79,7 +80,7 @@ void SrCommonEventSubscriber::OnReceiveEvent(const EventFwk::CommonEventData &ev
};
eventHandler_->PostTask(task, "SrCommonEventSubscriber:DeleteBundleInfo");
} else {
APP_LOGW("invalid action.");
TAG_LOGW(AAFwkTag::SER_ROUTER, "invalid action.");
}
}
} // AbilityRuntime

View File

@ -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 "app_log_wrapper.h"
#include "bundle_constants.h"
#include "bundle_mgr_proxy.h"
#include "hilog_tag_wrapper.h"
#include "if_system_ability_manager.h"
#include "ipc_skeleton.h"
#include "iservice_registry.h"
@ -36,7 +37,7 @@ SrSamgrHelper::~SrSamgrHelper()
sptr<IBundleMgr> SrSamgrHelper::GetBundleMgr()
{
APP_LOGI("GetBundleMgr called.");
TAG_LOGI(AAFwkTag::SER_ROUTER, "GetBundleMgr called.");
std::lock_guard<std::mutex> lock(bundleMgrMutex_);
if (iBundleMgr_ == nullptr) {
ConnectBundleMgrLocked();
@ -50,17 +51,17 @@ int32_t SrSamgrHelper::GetCurrentActiveUserId()
std::vector<int32_t> activeIds;
int ret = AccountSA::OsAccountManager::QueryActiveOsAccountIds(activeIds);
if (ret != 0) {
APP_LOGE("QueryActiveOsAccountIds failed ret:%{public}d", ret);
TAG_LOGE(AAFwkTag::SER_ROUTER, "QueryActiveOsAccountIds failed ret:%{public}d", ret);
return Constants::INVALID_USERID;
}
if (activeIds.empty()) {
APP_LOGE("QueryActiveOsAccountIds activeIds empty");
TAG_LOGE(AAFwkTag::SER_ROUTER, "QueryActiveOsAccountIds activeIds empty");
return Constants::INVALID_USERID;
}
APP_LOGE("QueryActiveOsAccountIds activeIds ret:%{public}d", activeIds[0]);
TAG_LOGE(AAFwkTag::SER_ROUTER, "QueryActiveOsAccountIds activeIds ret:%{public}d", activeIds[0]);
return activeIds[0];
#else
APP_LOGI("ACCOUNT_ENABLE is false");
TAG_LOGI(AAFwkTag::SER_ROUTER, "ACCOUNT_ENABLE is false");
return 0;
#endif
}
@ -72,28 +73,28 @@ void SrSamgrHelper::ConnectBundleMgrLocked()
}
sptr<ISystemAbilityManager> saManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
if (saManager == nullptr) {
APP_LOGE("failed to get bms saManager.");
TAG_LOGE(AAFwkTag::SER_ROUTER, "failed to get bms saManager.");
return;
}
sptr<IRemoteObject> remoteObj = saManager->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID);
if (remoteObj == nullptr) {
APP_LOGE("failed to get bms remoteObj.");
TAG_LOGE(AAFwkTag::SER_ROUTER, "failed to get bms remoteObj.");
return;
}
deathRecipient_ = sptr<IRemoteObject::DeathRecipient>(new (std::nothrow) BmsDeathRecipient());
if (deathRecipient_ == nullptr) {
APP_LOGE("Failed to create BmsDeathRecipient!");
TAG_LOGE(AAFwkTag::SER_ROUTER, "Failed to create BmsDeathRecipient!");
return;
}
if ((remoteObj->IsProxyObject()) && (!remoteObj->AddDeathRecipient(deathRecipient_))) {
APP_LOGE("Add death recipient to bms failed.");
TAG_LOGE(AAFwkTag::SER_ROUTER, "Add death recipient to bms failed.");
return;
}
iBundleMgr_ = iface_cast<IBundleMgr>(remoteObj);
if (iBundleMgr_ == nullptr) {
APP_LOGE("iface_cast failed, failed to get bms");
TAG_LOGE(AAFwkTag::SER_ROUTER, "iface_cast failed, failed to get bms");
}
}
@ -106,7 +107,7 @@ void SrSamgrHelper::ResetProxy(const wptr<IRemoteObject> &remote)
auto serviceRemote = iBundleMgr_->AsObject();
if ((serviceRemote != nullptr) && (serviceRemote == remote.promote())) {
APP_LOGD("To remove death recipient.");
TAG_LOGD(AAFwkTag::SER_ROUTER, "To remove death recipient.");
serviceRemote->RemoveDeathRecipient(deathRecipient_);
iBundleMgr_ = nullptr;
}
@ -114,7 +115,7 @@ void SrSamgrHelper::ResetProxy(const wptr<IRemoteObject> &remote)
void SrSamgrHelper::BmsDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &remote)
{
APP_LOGI("BmsDeathRecipient handle remote abilityms died.");
TAG_LOGI(AAFwkTag::SER_ROUTER, "BmsDeathRecipient handle remote abilityms died.");
SrSamgrHelper::GetInstance().ResetProxy(remote);
}
} // namespace AbilityRuntime

View File

@ -48,6 +48,8 @@ enum class AAFwkLogTag : uint32_t {
DIALOG,
QUICKFIX,
URIPERMMGR,
BUNDLEMGRHELPER,
APPKIT,
JSENV = DEFAULT + 0x20, // 0xD001320
JSRUNTIME,
@ -86,6 +88,8 @@ enum class AAFwkLogTag : uint32_t {
DISTRIBUTED,
FREE_INSTALL,
LOCAL_CALL = DEFAULT + 0x60, // 0xD001360
END = 256, // N.B. never use it
};
@ -96,12 +100,14 @@ const std::map<AAFwkLogTag, const char*> DOMAIN_MAP = {
{ AAFwkLogTag::AA_TOOL, "AAFwkAATool" },
{ AAFwkLogTag::ABILITY_SIM, "AAFwkAbilitySimulator" },
{ AAFwkLogTag::APPDFR, "AAFwkAppDfr"},
{ AAFwkLogTag::APPMGR, "AAFwkAppMgr" },
{ AAFwkLogTag::DBOBSMGR, "AAFwkDbObsMgr" },
{ AAFwkLogTag::DIALOG, "AAFwkDialog" },
{ AAFwkLogTag::QUICKFIX, "AAFwkQuickfix" },
{ AAFwkLogTag::URIPERMMGR, "AAFwkUriPermMgr" },
{ AAFwkLogTag::APPDFR, "AAFwkAppDfr"},
{ AAFwkLogTag::APPMGR, "AAFwkAppMgr" },
{ AAFwkLogTag::DBOBSMGR, "AAFwkDbObsMgr" },
{ AAFwkLogTag::DIALOG, "AAFwkDialog" },
{ AAFwkLogTag::QUICKFIX, "AAFwkQuickfix" },
{ AAFwkLogTag::URIPERMMGR, "AAFwkUriPermMgr" },
{ AAFwkLogTag::BUNDLEMGRHELPER, "AAFwkBundleMgrHelper" },
{ AAFwkLogTag::APPKIT, "AAFwkAppKit" },
{ AAFwkLogTag::JSENV, "AAFwkJsEnv" },
{ AAFwkLogTag::JSRUNTIME, "AAFwkJsRuntime" },
@ -139,6 +145,8 @@ const std::map<AAFwkLogTag, const char*> DOMAIN_MAP = {
{ AAFwkLogTag::CONTINUATION, "AAFwkContinuation" },
{ AAFwkLogTag::DISTRIBUTED, "AAFwkDistributed" },
{ AAFwkLogTag::FREE_INSTALL, "AAFwkFreeInstall" },
{ AAFwkLogTag::LOCAL_CALL, "AAFwkLocalCall" },
};
static inline const char* GetTagInfoFromDomainId(AAFwkLogTag tag)