diff --git a/frameworks/ans/src/reminder_request.cpp b/frameworks/ans/src/reminder_request.cpp index 1f7f10979f96fed6fd14b9392bd2918d660e2cbe..371d8ade3db703030b7a7f451b118d644d434af5 100644 --- a/frameworks/ans/src/reminder_request.cpp +++ b/frameworks/ans/src/reminder_request.cpp @@ -646,6 +646,7 @@ void ReminderRequest::RecoverWantAgent(const std::string &wantAgentInfo, const u auto wai = std::make_shared(); wai->pkgName = info.at(0); wai->abilityName = info.at(1); + wai->uri = info.at(2); SetWantAgentInfo(wai); break; } @@ -992,6 +993,10 @@ bool ReminderRequest::Marshalling(Parcel &parcel) const ANSR_LOGE("Failed to write wantAgentInfo`s pkgName"); return false; } + if (!parcel.WriteString(wantAgentInfo_->uri)) { + ANSR_LOGE("Failed to write wantAgentInfo`s uri"); + return false; + } if (!parcel.WriteString(maxScreenWantAgentInfo_->abilityName)) { ANSR_LOGE("Failed to write maxScreenWantAgentInfo`s abilityName"); return false; @@ -1142,6 +1147,10 @@ bool ReminderRequest::ReadFromParcel(Parcel &parcel) ANSR_LOGE("Failed to read wantAgentInfo`s pkgName"); return false; } + if (!parcel.ReadString(wantAgentInfo_->uri)) { + ANSR_LOGE("Failed to read wantAgentInfo`s uri"); + return false; + } if (!parcel.ReadString(maxScreenWantAgentInfo_->abilityName)) { ANSR_LOGE("Failed to read maxScreenWantAgentInfo`s abilityName"); return false; @@ -1488,14 +1497,16 @@ void ReminderRequest::AddRemovalWantAgent() } std::shared_ptr ReminderRequest::CreateWantAgent( - AppExecFwk::ElementName &element) const + AppExecFwk::ElementName &element, bool isWantAgent) const { int32_t requestCode = 10; std::vector flags; flags.push_back(AbilityRuntime::WantAgent::WantAgentConstant::Flags::UPDATE_PRESENT_FLAG); auto want = std::make_shared(); want->SetElement(element); - want->SetUri(customButtonUri_); + if (isWantAgent) { + want->SetUri(wantAgentInfo_->uri); + } std::vector> wants; wants.push_back(want); AbilityRuntime::WantAgent::WantAgentInfo wantAgentInfo( @@ -1513,13 +1524,13 @@ std::shared_ptr ReminderRequest::CreateWan void ReminderRequest::SetMaxScreenWantAgent(AppExecFwk::ElementName &element) { - std::shared_ptr wantAgent = CreateWantAgent(element); + std::shared_ptr wantAgent = CreateWantAgent(element, false); notificationRequest_->SetMaxScreenWantAgent(wantAgent); } void ReminderRequest::SetWantAgent(AppExecFwk::ElementName &element) { - std::shared_ptr wantAgent = CreateWantAgent(element); + std::shared_ptr wantAgent = CreateWantAgent(element, true); notificationRequest_->SetWantAgent(wantAgent); } @@ -1761,11 +1772,12 @@ void ReminderRequest::AppendValuesBucket(const sptr &reminder, values.PutString(EXPIRED_CONTENT, reminder->GetExpiredContent()); auto wantAgentInfo = reminder->GetWantAgentInfo(); if (wantAgentInfo == nullptr) { - std::string info = "null" + ReminderRequest::SEP_WANT_AGENT + "null"; + std::string info = "null" + ReminderRequest::SEP_WANT_AGENT + "null" + ReminderRequest::SEP_WANT_AGENT + "null"; values.PutString(AGENT, info); } else { - values.PutString(AGENT, wantAgentInfo->pkgName - + ReminderRequest::SEP_WANT_AGENT + wantAgentInfo->abilityName); + std::string info = wantAgentInfo->pkgName + ReminderRequest::SEP_WANT_AGENT + + wantAgentInfo->abilityName + ReminderRequest::SEP_WANT_AGENT + wantAgentInfo->uri; + values.PutString(AGENT, info); } auto maxScreenWantAgentInfo = reminder->GetMaxScreenWantAgentInfo(); if (maxScreenWantAgentInfo == nullptr) { diff --git a/frameworks/js/napi/include/reminder/reminder_common.h b/frameworks/js/napi/include/reminder/reminder_common.h index 2efcf4f4bd949d50c53c9603870cea6e77568b24..77f3c3fa9fbcddb789e84ff1481d55fd0bf22b19 100644 --- a/frameworks/js/napi/include/reminder/reminder_common.h +++ b/frameworks/js/napi/include/reminder/reminder_common.h @@ -59,6 +59,7 @@ const char* TIMER_COUNT_DOWN_TIME = "triggerTimeInSeconds"; const char* WANT_AGENT = "wantAgent"; const char* WANT_AGENT_PKG = "pkgName"; const char* WANT_AGENT_ABILITY = "abilityName"; +const char* WANT_AGENT_URI = "uri"; const char* BUTTON_WANT_AGENT = "wantAgent"; const char* BUTTON_WANT_AGENT_PKG = "pkgName"; const char* BUTTON_WANT_AGENT_ABILITY = "abilityName"; @@ -135,7 +136,7 @@ private: const char* propertyName, napi_value& propertyVal); static void GenWantAgent( - const napi_env &env, const napi_value &value, std::shared_ptr& reminder); + const napi_env &env, const napi_value &value, std::shared_ptr& reminder, bool isSysApp); static void GenMaxScreenWantAgent( const napi_env &env, const napi_value &value, std::shared_ptr& reminder); diff --git a/frameworks/js/napi/src/reminder/publish.cpp b/frameworks/js/napi/src/reminder/publish.cpp index 849d63316a8ae2b4b10b3327c5a97565626adf0f..f75cd24f9f717e252ba6a2569d8c412961689b0a 100644 --- a/frameworks/js/napi/src/reminder/publish.cpp +++ b/frameworks/js/napi/src/reminder/publish.cpp @@ -559,8 +559,8 @@ void ParseWantAgent(const napi_env &env, ReminderRequest &reminder, napi_value & napi_create_string_utf8(env, (reminder.GetWantAgentInfo()->abilityName).c_str(), NAPI_AUTO_LENGTH, &info); napi_set_named_property(env, wantAgentInfo, WANT_AGENT_ABILITY, info); - napi_create_string_utf8(env, (reminder.GetCustomButtonUri()).c_str(), NAPI_AUTO_LENGTH, &info); - napi_set_named_property(env, wantAgentInfo, BUTTON_WANT_AGENT_URI, info); + napi_create_string_utf8(env, (reminder.GetWantAgentInfo()->uri).c_str(), NAPI_AUTO_LENGTH, &info); + napi_set_named_property(env, wantAgentInfo, WANT_AGENT_URI, info); } void ParseMaxScreenWantAgent(const napi_env &env, ReminderRequest &reminder, napi_value &result) diff --git a/frameworks/js/napi/src/reminder/reminder_common.cpp b/frameworks/js/napi/src/reminder/reminder_common.cpp index 2df3e89fcb6a6712b83a1240774ab1e10d796b5f..31becf28d030ca0c6ec716fdc8410ca2e91644ed 100644 --- a/frameworks/js/napi/src/reminder/reminder_common.cpp +++ b/frameworks/js/napi/src/reminder/reminder_common.cpp @@ -132,7 +132,7 @@ void ReminderCommon::GetButtonWantAgent(const napi_env &env, const napi_value &v } void ReminderCommon::GenWantAgent( - const napi_env &env, const napi_value &value, std::shared_ptr& reminder) + const napi_env &env, const napi_value &value, std::shared_ptr& reminder, bool isSysApp) { char str[NotificationNapi::STR_MAX_SIZE] = {0}; napi_value wantAgent = nullptr; @@ -146,11 +146,16 @@ void ReminderCommon::GenWantAgent( wantAgentInfo->abilityName = str; } if (GetStringUtf8(env, wantAgent, - ReminderAgentNapi::BUTTON_WANT_AGENT_URI, str, NotificationNapi::STR_MAX_SIZE)) { - reminder->SetCustomButtonUri(str); + ReminderAgentNapi::WANT_AGENT_URI, str, NotificationNapi::STR_MAX_SIZE)) { + if (!isSysApp) { + ANSR_LOGW("not system app, want uri is not support.") + return false; + } + wantAgentInfo->uri = str; } reminder->SetWantAgentInfo(wantAgentInfo); } + return true; } void ReminderCommon::GenMaxScreenWantAgent( @@ -300,7 +305,9 @@ napi_value ReminderCommon::GenReminder( } // wantAgent - GenWantAgent(env, value, reminder); + if (!GenWantAgent(env, value, reminder, isSysApp)) { + return nullptr; + } // maxScreenWantAgent GenMaxScreenWantAgent(env, value, reminder); diff --git a/interfaces/inner_api/reminder_request.h b/interfaces/inner_api/reminder_request.h index ce0e224e26046940b63cc7aac6300c42d47cf9db..3cec37b152b93d13868789a0df449f4bf30dc50a 100644 --- a/interfaces/inner_api/reminder_request.h +++ b/interfaces/inner_api/reminder_request.h @@ -136,6 +136,7 @@ public: struct WantAgentInfo { std::string pkgName = ""; std::string abilityName = ""; + std::string uri = ""; }; struct MaxScreenAgentInfo { @@ -748,7 +749,7 @@ protected: private: void AddActionButtons(const bool includeSnooze); void AddRemovalWantAgent(); - std::shared_ptr CreateWantAgent(AppExecFwk::ElementName &element) const; + std::shared_ptr CreateWantAgent(AppExecFwk::ElementName &element, bool isWantAgent) const; std::string GetButtonInfo() const; uint64_t GetNowInstantMilli() const; std::string GetShowTime(const uint64_t showTime) const;