mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-12-04 13:37:29 +00:00
log
Signed-off-by: sodanotgreen <limengzheng@huawei.com>
This commit is contained in:
parent
f5be29f135
commit
395268676d
@ -83,7 +83,7 @@ public:
|
||||
|
||||
static void Finalizer(napi_env env, void *data, void *hint)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::INTENT, "JsInsightIntentDriver::Finalizer is called");
|
||||
TAG_LOGI(AAFwkTag::INTENT, "called");
|
||||
std::unique_ptr<JsInsightIntentDriver>(static_cast<JsInsightIntentDriver*>(data));
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@ private:
|
||||
|
||||
napi_value JsInsightIntentDriverInit(napi_env env, napi_value exportObj)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::INTENT, "JsInsightIntentDriverInit is called");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
if (env == nullptr || exportObj == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Invalid input parameters");
|
||||
return nullptr;
|
||||
|
@ -38,7 +38,7 @@ bool InsightIntentExecutor::Init(const InsightIntentExecutorInfo& intentInfo)
|
||||
{
|
||||
auto executeParam = intentInfo.executeParam;
|
||||
if (executeParam == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Execute param invalid.");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Execute param invalid");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -34,10 +34,10 @@ InsightIntentExecutorMgr::~InsightIntentExecutorMgr()
|
||||
bool InsightIntentExecutorMgr::ExecuteInsightIntent(Runtime& runtime, const InsightIntentExecutorInfo& executeInfo,
|
||||
std::unique_ptr<InsightIntentExecutorAsyncCallback> callback)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called.");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
auto executeParam = executeInfo.executeParam;
|
||||
if (executeParam == nullptr || executeParam->insightIntentParam_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Execute param invalid.");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Execute param invalid");
|
||||
TriggerCallbackInner(std::move(callback), static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INVALID_PARAM));
|
||||
return false;
|
||||
}
|
||||
@ -45,10 +45,10 @@ bool InsightIntentExecutorMgr::ExecuteInsightIntent(Runtime& runtime, const Insi
|
||||
auto asyncCallback =
|
||||
[weak = weak_from_this(), intentId = executeParam->insightIntentId_](InsightIntentExecuteResult result) {
|
||||
// erase map when called
|
||||
TAG_LOGD(AAFwkTag::INTENT, "Begin remove executor.");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "Begin remove executor");
|
||||
auto executorMgr = weak.lock();
|
||||
if (executorMgr == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Executor manager invalid.");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Executor manager invalid");
|
||||
return;
|
||||
}
|
||||
executorMgr->RemoveInsightIntentExecutor(intentId);
|
||||
@ -58,17 +58,17 @@ bool InsightIntentExecutorMgr::ExecuteInsightIntent(Runtime& runtime, const Insi
|
||||
// Create insight intent executor
|
||||
auto intentExecutor = InsightIntentExecutor::Create(runtime);
|
||||
if (intentExecutor == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Create insight intent executor failed.");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Create insight intent executor failed");
|
||||
TriggerCallbackInner(std::move(callback), static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INVALID_PARAM));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!intentExecutor->Init(executeInfo)) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Init intent executor failed.");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Init intent executor failed");
|
||||
TriggerCallbackInner(std::move(callback), static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INVALID_PARAM));
|
||||
return false;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::INTENT, "AddInsightIntentExecutor.");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "AddInsightIntentExecutor");
|
||||
AddInsightIntentExecutor(executeParam->insightIntentId_, intentExecutor);
|
||||
|
||||
bool isAsync = false;
|
||||
@ -76,7 +76,7 @@ bool InsightIntentExecutorMgr::ExecuteInsightIntent(Runtime& runtime, const Insi
|
||||
executeParam->insightIntentName_, *executeParam->insightIntentParam_, executeInfo.pageLoader,
|
||||
std::move(callback), isAsync);
|
||||
if (!ret) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Execute intent failed.");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Execute intent failed");
|
||||
// callback has removed, if execute insight intent failed, call in sub function.
|
||||
return false;
|
||||
}
|
||||
@ -87,14 +87,14 @@ bool InsightIntentExecutorMgr::ExecuteInsightIntent(Runtime& runtime, const Insi
|
||||
void InsightIntentExecutorMgr::AddInsightIntentExecutor(uint64_t intentId,
|
||||
const std::shared_ptr<InsightIntentExecutor>& executor)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called.");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
insightIntentExecutors_[intentId] = executor;
|
||||
}
|
||||
|
||||
void InsightIntentExecutorMgr::RemoveInsightIntentExecutor(uint64_t intentId)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called.");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
insightIntentExecutors_.erase(intentId);
|
||||
}
|
||||
@ -102,7 +102,7 @@ void InsightIntentExecutorMgr::RemoveInsightIntentExecutor(uint64_t intentId)
|
||||
void InsightIntentExecutorMgr::TriggerCallbackInner(
|
||||
std::unique_ptr<InsightIntentExecutorAsyncCallback> callback, int32_t errCode)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called.");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
AppExecFwk::InsightIntentExecuteResult result;
|
||||
result.innerErr = errCode;
|
||||
callback->Call(result);
|
||||
|
@ -57,7 +57,7 @@ JsInsightIntentExecutor::~JsInsightIntentExecutor()
|
||||
|
||||
bool JsInsightIntentExecutor::Init(const InsightIntentExecutorInfo& insightIntentInfo)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::INTENT, "enter");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
STATE_PATTERN_NAIVE_ACCEPT(State::CREATED, false);
|
||||
state_ = State::INITIALIZED;
|
||||
InsightIntentExecutor::Init(insightIntentInfo);
|
||||
@ -65,26 +65,26 @@ bool JsInsightIntentExecutor::Init(const InsightIntentExecutorInfo& insightInten
|
||||
HandleScope handleScope(runtime_);
|
||||
jsObj_ = JsInsightIntentExecutor::LoadJsCode(insightIntentInfo, runtime_);
|
||||
if (jsObj_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "LoadJsCode failed.");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "LoadJsCode failed");
|
||||
STATE_PATTERN_NAIVE_STATE_SET_AND_RETURN(State::INVALID, false);
|
||||
}
|
||||
|
||||
auto env = runtime_.GetNapiEnv();
|
||||
if (env == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Napi env invalid.");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Napi env invalid");
|
||||
STATE_PATTERN_NAIVE_STATE_SET_AND_RETURN(State::INVALID, false);
|
||||
}
|
||||
|
||||
auto context = GetContext();
|
||||
if (context == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Context invalid.");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Context invalid");
|
||||
STATE_PATTERN_NAIVE_STATE_SET_AND_RETURN(State::INVALID, false);
|
||||
}
|
||||
|
||||
napi_value contextObj = CreateJsInsightIntentContext(env, context);
|
||||
contextObj_ = JsRuntime::LoadSystemModuleByEngine(env, "app.ability.InsightIntentContext", &contextObj, 1);
|
||||
if (contextObj_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Load system module failed.");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Load system module failed");
|
||||
STATE_PATTERN_NAIVE_STATE_SET_AND_RETURN(State::INVALID, false);
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ bool JsInsightIntentExecutor::Init(const InsightIntentExecutorInfo& insightInten
|
||||
if (!CheckTypeForNapiValue(env, executorNapiVal, napi_object) ||
|
||||
!CheckTypeForNapiValue(env, contextNapiVal, napi_object) ||
|
||||
napi_set_named_property(env, executorNapiVal, "context", contextNapiVal) != napi_ok) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Set property failed.");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Set property failed");
|
||||
STATE_PATTERN_NAIVE_STATE_SET_AND_RETURN(State::INVALID, false);
|
||||
}
|
||||
|
||||
@ -114,12 +114,12 @@ bool JsInsightIntentExecutor::HandleExecuteIntent(
|
||||
std::unique_ptr<InsightIntentExecutorAsyncCallback> callback,
|
||||
bool& isAsync)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::INTENT, "enter");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
STATE_PATTERN_NAIVE_ACCEPT(State::INITIALIZED, false);
|
||||
state_ = State::EXECUTING;
|
||||
|
||||
if (callback == nullptr || callback->IsEmpty()) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "HandleExecuteIntent invalid callback.");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "HandleExecuteIntent invalid callback");
|
||||
STATE_PATTERN_NAIVE_STATE_SET_AND_RETURN(State::INVALID, false);
|
||||
}
|
||||
callback_ = std::move(callback);
|
||||
@ -165,10 +165,10 @@ std::unique_ptr<NativeReference> JsInsightIntentExecutor::LoadJsCode(
|
||||
const InsightIntentExecutorInfo& info,
|
||||
JsRuntime& runtime)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::INTENT, "enter");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
auto executeParam = info.executeParam;
|
||||
if (executeParam == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Execute param invalid.");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Execute param invalid");
|
||||
return std::unique_ptr<NativeReference>();
|
||||
}
|
||||
|
||||
@ -194,7 +194,7 @@ bool JsInsightIntentExecutor::CallJsFunctionWithResult(
|
||||
const napi_value* argv,
|
||||
napi_value& result)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::INTENT, "enter");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
napi_value method = AppExecFwk::GetPropertyValueByPropertyName(
|
||||
env,
|
||||
obj,
|
||||
@ -220,7 +220,7 @@ bool JsInsightIntentExecutor::CallJsFunctionWithResultInner(
|
||||
const napi_value* argv,
|
||||
napi_value& result)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::INTENT, "enter");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
auto* env = runtime_.GetNapiEnv();
|
||||
napi_value obj = jsObj_->GetNapiValue();
|
||||
if (!CheckTypeForNapiValue(env, obj, napi_valuetype::napi_object)) {
|
||||
@ -239,7 +239,7 @@ bool JsInsightIntentExecutor::CallJsFunctionWithResultInner(
|
||||
std::shared_ptr<AppExecFwk::InsightIntentExecuteResult> JsInsightIntentExecutor::GetResultFromJs(
|
||||
napi_env env, napi_value resultJs)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::INTENT, "enter");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
auto resultCpp = std::make_shared<AppExecFwk::InsightIntentExecuteResult>();
|
||||
if (!UnwrapExecuteResult(env, resultJs, *resultCpp)) {
|
||||
return nullptr;
|
||||
@ -249,7 +249,7 @@ std::shared_ptr<AppExecFwk::InsightIntentExecuteResult> JsInsightIntentExecutor:
|
||||
|
||||
napi_value JsInsightIntentExecutor::ResolveCbCpp(napi_env env, napi_callback_info info)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::INTENT, "enter");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
constexpr size_t argc = 1;
|
||||
napi_value argv[argc] = {nullptr};
|
||||
size_t actualArgc = argc;
|
||||
@ -269,7 +269,7 @@ napi_value JsInsightIntentExecutor::ResolveCbCpp(napi_env env, napi_callback_inf
|
||||
|
||||
napi_value JsInsightIntentExecutor::RejectCbCpp(napi_env env, napi_callback_info info)
|
||||
{
|
||||
TAG_LOGW(AAFwkTag::INTENT, "Error or reject caught.");
|
||||
TAG_LOGW(AAFwkTag::INTENT, "Error or reject caught");
|
||||
void* data = nullptr;
|
||||
napi_get_cb_info(env, info, nullptr, nullptr, nullptr, &data);
|
||||
auto* callback = static_cast<InsightIntentExecutorAsyncCallback*>(data);
|
||||
@ -280,7 +280,7 @@ napi_value JsInsightIntentExecutor::RejectCbCpp(napi_env env, napi_callback_info
|
||||
void JsInsightIntentExecutor::ReplyFailed(InsightIntentExecutorAsyncCallback* callback,
|
||||
InsightIntentInnerErr innerErr)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::INTENT, "enter");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
if (callback == nullptr) {
|
||||
return;
|
||||
}
|
||||
@ -293,7 +293,7 @@ void JsInsightIntentExecutor::ReplyFailed(InsightIntentExecutorAsyncCallback* ca
|
||||
void JsInsightIntentExecutor::ReplySucceeded(InsightIntentExecutorAsyncCallback* callback,
|
||||
std::shared_ptr<AppExecFwk::InsightIntentExecuteResult> resultCpp)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::INTENT, "enter");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
if (callback == nullptr) {
|
||||
return;
|
||||
}
|
||||
@ -308,7 +308,7 @@ void JsInsightIntentExecutor::ReplySucceeded(InsightIntentExecutorAsyncCallback*
|
||||
|
||||
void JsInsightIntentExecutor::ReplyFailedInner(InsightIntentInnerErr innerErr)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::INTENT, "enter");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
state_ = JsInsightIntentExecutor::State::INVALID;
|
||||
auto* callback = callback_.release();
|
||||
JsInsightIntentExecutor::ReplyFailed(callback, innerErr);
|
||||
@ -316,7 +316,7 @@ void JsInsightIntentExecutor::ReplyFailedInner(InsightIntentInnerErr innerErr)
|
||||
|
||||
void JsInsightIntentExecutor::ReplySucceededInner(std::shared_ptr<AppExecFwk::InsightIntentExecuteResult> resultCpp)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::INTENT, "enter");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
state_ = JsInsightIntentExecutor::State::EXECUTATION_DONE;
|
||||
auto* callback = callback_.release();
|
||||
JsInsightIntentExecutor::ReplySucceeded(callback, resultCpp);
|
||||
@ -324,7 +324,7 @@ void JsInsightIntentExecutor::ReplySucceededInner(std::shared_ptr<AppExecFwk::In
|
||||
|
||||
bool JsInsightIntentExecutor::HandleResultReturnedFromJsFunc(napi_value resultJs)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::INTENT, "enter");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
auto* env = runtime_.GetNapiEnv();
|
||||
if (resultJs == nullptr) {
|
||||
ReplyFailedInner();
|
||||
@ -380,7 +380,7 @@ bool JsInsightIntentExecutor::ExecuteInsightIntentUIAbilityForeground(
|
||||
const AAFwk::WantParams& param,
|
||||
const std::shared_ptr<NativeReference>& windowStageJs)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::INTENT, "enter");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
HandleScope handleScope(runtime_);
|
||||
|
||||
constexpr auto intentMode = static_cast<size_t>(InsightIntentExecuteMode::UIABILITY_FOREGROUND);
|
||||
@ -410,7 +410,7 @@ bool JsInsightIntentExecutor::ExecuteInsightIntentUIAbilityBackground(
|
||||
const std::string& name,
|
||||
const AAFwk::WantParams& param)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::INTENT, "enter");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
HandleScope handleScope(runtime_);
|
||||
|
||||
constexpr auto intentMode = static_cast<size_t>(InsightIntentExecuteMode::UIABILITY_BACKGROUND);
|
||||
@ -442,7 +442,7 @@ bool JsInsightIntentExecutor::ExecuteInsightIntentUIExtension(
|
||||
const AAFwk::WantParams& param,
|
||||
const std::shared_ptr<NativeReference>& UIExtensionContentSession)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::INTENT, "enter");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
HandleScope handleScope(runtime_);
|
||||
|
||||
constexpr auto intentMode = static_cast<size_t>(InsightIntentExecuteMode::UIEXTENSION_ABILITY);
|
||||
@ -472,7 +472,7 @@ bool JsInsightIntentExecutor::ExecuteInsightIntentServiceExtension(
|
||||
const std::string& name,
|
||||
const AAFwk::WantParams& param)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::INTENT, "enter");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
HandleScope handleScope(runtime_);
|
||||
|
||||
constexpr auto intentMode = static_cast<size_t>(InsightIntentExecuteMode::SERVICE_EXTENSION_ABILITY);
|
||||
|
@ -28,7 +28,7 @@ sptr<InsightIntentHostClient> InsightIntentHostClient::GetInstance()
|
||||
if (instance_ == nullptr) {
|
||||
instance_ = new (std::nothrow) InsightIntentHostClient();
|
||||
if (instance_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "failed to create InsightIntentHostClient.");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "failed to create InsightIntentHostClient");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -38,7 +38,7 @@ sptr<InsightIntentHostClient> InsightIntentHostClient::GetInstance()
|
||||
uint64_t InsightIntentHostClient::AddInsightIntentExecute(
|
||||
const std::shared_ptr<InsightIntentExecuteCallbackInterface> &callback)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called.");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
std::lock_guard<std::mutex> lock(insightIntentExecutebackMutex_);
|
||||
callbackMap_.emplace(++key_, callback);
|
||||
return key_;
|
||||
@ -46,7 +46,7 @@ uint64_t InsightIntentHostClient::AddInsightIntentExecute(
|
||||
|
||||
void InsightIntentHostClient::RemoveInsightIntentExecute(uint64_t key)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called.");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
std::lock_guard<std::mutex> lock(insightIntentExecutebackMutex_);
|
||||
auto iter = callbackMap_.find(key);
|
||||
if (iter != callbackMap_.end()) {
|
||||
@ -57,7 +57,7 @@ void InsightIntentHostClient::RemoveInsightIntentExecute(uint64_t key)
|
||||
void InsightIntentHostClient::OnExecuteDone(uint64_t key, int32_t resultCode,
|
||||
const AppExecFwk::InsightIntentExecuteResult &executeResult)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called.");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
|
||||
std::shared_ptr<InsightIntentExecuteCallbackInterface> callback = nullptr;
|
||||
{
|
||||
|
@ -25,7 +25,7 @@ namespace AbilityRuntime {
|
||||
ErrCode InsightIntentContext::StartAbilityByInsightIntent(const AAFwk::Want &want)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
TAG_LOGD(AAFwkTag::INTENT, "enter");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartAbilityByInsightIntent(want, token_, intentId_);
|
||||
if (err != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "failed to startAbility. ret=%{public}d", err);
|
||||
|
@ -30,7 +30,7 @@ constexpr static char CONTEXT_MODULE_NAME[] = "InsightIntentContext";
|
||||
|
||||
void JsInsightIntentContext::Finalizer(napi_env env, void* data, void* hint)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::INTENT, "enter");
|
||||
TAG_LOGI(AAFwkTag::INTENT, "called");
|
||||
std::unique_ptr<JsInsightIntentContext>(static_cast<JsInsightIntentContext*>(data));
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ napi_value JsInsightIntentContext::StartAbiity(napi_env env, napi_callback_info
|
||||
|
||||
napi_value JsInsightIntentContext::OnStartAbility(napi_env env, NapiCallbackInfo& info)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::INTENT, "enter");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
|
||||
// unwrap want
|
||||
@ -89,7 +89,7 @@ napi_value JsInsightIntentContext::OnStartAbility(napi_env env, NapiCallbackInfo
|
||||
// create complete task
|
||||
NapiAsyncTask::CompleteCallback complete = [innerErrCode](napi_env env, NapiAsyncTask& task, int32_t status) {
|
||||
if (*innerErrCode == ERR_OK) {
|
||||
TAG_LOGD(AAFwkTag::INTENT, "StartAbility success.");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "StartAbility success");
|
||||
task.Resolve(env, CreateJsUndefined(env));
|
||||
} else {
|
||||
task.Reject(env, CreateJsErrorByNativeErr(env, *innerErrCode));
|
||||
@ -106,7 +106,7 @@ napi_value JsInsightIntentContext::OnStartAbility(napi_env env, NapiCallbackInfo
|
||||
|
||||
napi_value CreateJsInsightIntentContext(napi_env env, const std::shared_ptr<InsightIntentContext>& context)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::INTENT, "enter");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
napi_value contextObj;
|
||||
napi_create_object(env, &contextObj);
|
||||
|
||||
@ -129,7 +129,7 @@ bool CheckStartAbilityParam(napi_env env, NapiCallbackInfo& info, AAFwk::Want wa
|
||||
// unwrap want
|
||||
bool unwrapWantFlag = OHOS::AppExecFwk::UnwrapWant(env, info.argv[0], want);
|
||||
if (!unwrapWantFlag) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Failed to parse want.");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Failed to parse want");
|
||||
ThrowInvalidParamError(env, "Parameter error: Failed to parse want, must be a Want.");
|
||||
return false;
|
||||
}
|
||||
|
@ -25,27 +25,27 @@ namespace AAFwk {
|
||||
void InsightIntentExecuteCallbackProxy::OnExecuteDone(uint64_t key, int32_t resultCode,
|
||||
const AppExecFwk::InsightIntentExecuteResult &executeResult)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::INTENT, "call");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
MessageParcel data;
|
||||
if (!data.WriteInterfaceToken(IInsightIntentExecuteCallback::GetDescriptor())) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Write interface token failed.");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Write interface token failed");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteUint64(key)) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "key write failed.");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "key write failed");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteInt32(resultCode)) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "resultCode write failed.");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "resultCode write failed");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteParcelable(&executeResult)) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "executeResult write failed.");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "executeResult write failed");
|
||||
return;
|
||||
}
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Remote() is NULL");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "remote is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ InsightIntentExecuteCallbackStub::InsightIntentExecuteCallbackStub()
|
||||
|
||||
InsightIntentExecuteCallbackStub::~InsightIntentExecuteCallbackStub()
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::INTENT, "call");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
requestFuncMap_.clear();
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ int32_t InsightIntentExecuteCallbackStub::OnRemoteRequest(
|
||||
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
if (data.ReadInterfaceToken() != IInsightIntentExecuteCallback::GetDescriptor()) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "InterfaceToken not equal IInsightIntentExecuteCallback's descriptor.");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "InterfaceToken not equal IInsightIntentExecuteCallback's descriptor");
|
||||
return ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
@ -47,13 +47,13 @@ int32_t InsightIntentExecuteCallbackStub::OnRemoteRequest(
|
||||
return (this->*requestFunc)(data, reply);
|
||||
}
|
||||
}
|
||||
TAG_LOGW(AAFwkTag::INTENT, "default case, need check.");
|
||||
TAG_LOGW(AAFwkTag::INTENT, "default case, need check");
|
||||
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
|
||||
}
|
||||
|
||||
int32_t InsightIntentExecuteCallbackStub::OnExecuteDoneInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::INTENT, "call");
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
uint64_t key = data.ReadUint64();
|
||||
int32_t resultCode = data.ReadInt32();
|
||||
std::shared_ptr<AppExecFwk::InsightIntentExecuteResult> executeResult(
|
||||
|
@ -93,7 +93,7 @@ int32_t InsightIntentExecuteManager::CheckAndUpdateWant(Want &want, ExecuteMode
|
||||
auto srcEntry = AbilityRuntime::InsightIntentUtils::GetSrcEntry(elementName.GetBundleName(),
|
||||
elementName.GetModuleName(), want.GetStringParam(INSIGHT_INTENT_EXECUTE_PARAM_NAME));
|
||||
if (srcEntry.empty()) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Insight intent srcEntry invalid.");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Insight intent srcEntry invalid");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
want.SetParam(INSIGHT_INTENT_SRC_ENTRY, srcEntry);
|
||||
@ -225,7 +225,7 @@ int32_t InsightIntentExecuteManager::GenerateWant(
|
||||
auto srcEntry = AbilityRuntime::InsightIntentUtils::GetSrcEntry(param->bundleName_, param->moduleName_,
|
||||
param->insightIntentName_);
|
||||
if (srcEntry.empty()) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Insight intent srcEntry invalid.");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Insight intent srcEntry invalid");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
want.SetParam(INSIGHT_INTENT_SRC_ENTRY, srcEntry);
|
||||
|
@ -80,7 +80,7 @@ bool InsightIntentExecuteParam::GenerateFromWant(const AAFwk::Want &want,
|
||||
{
|
||||
const WantParams &wantParams = want.GetParams();
|
||||
if (!wantParams.HasParam(INSIGHT_INTENT_EXECUTE_PARAM_NAME)) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "The want does not contain insight intent name.");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "The want does not contain insight intent name");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -233,7 +233,7 @@ void from_json(const nlohmann::json &jsonObject, InsightIntentProfileInfoVec &in
|
||||
bool TransformToInsightIntentInfo(const InsightIntentProfileInfo &insightIntent, InsightIntentInfo &info)
|
||||
{
|
||||
if (insightIntent.intentName.empty()) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Intent name invalid.");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Intent name invalid");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -280,7 +280,7 @@ bool InsightIntentProfile::TransformTo(const std::string &profileStr, std::vecto
|
||||
TAG_LOGD(AAFwkTag::INTENT, "called");
|
||||
auto jsonObject = nlohmann::json::parse(profileStr, nullptr, false);
|
||||
if (jsonObject.is_discarded()) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Profile invalid.");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Profile invalid");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ std::string InsightIntentUtils::GetSrcEntry(const std::string &bundleName, const
|
||||
TAG_LOGD(AAFwkTag::INTENT, "Get srcEntry, bundleName: %{public}s, moduleName: %{public}s, intentName: %{public}s.",
|
||||
bundleName.c_str(), moduleName.c_str(), intentName.c_str());
|
||||
if (bundleName.empty() || moduleName.empty() || intentName.empty()) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Invalid param.");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Invalid param");
|
||||
return std::string("");
|
||||
}
|
||||
|
||||
@ -48,14 +48,14 @@ std::string InsightIntentUtils::GetSrcEntry(const std::string &bundleName, const
|
||||
auto ret = IN_PROCESS_CALL(bundleMgrHelper->GetJsonProfile(AppExecFwk::INTENT_PROFILE, bundleName, moduleName,
|
||||
profile, AppExecFwk::OsAccountManagerWrapper::GetCurrentActiveAccountId()));
|
||||
if (ret != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Get json profile failed, error code: %{public}d.", ret);
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Get json profile failed, error code: %{public}d", ret);
|
||||
return std::string("");
|
||||
}
|
||||
|
||||
// Transform json string
|
||||
std::vector<InsightIntentInfo> infos;
|
||||
if (!InsightIntentProfile::TransformTo(profile, infos)) {
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Transform profile failed.");
|
||||
TAG_LOGE(AAFwkTag::INTENT, "Transform profile failed");
|
||||
return std::string("");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user