!2876 应用内卡片删除

Merge pull request !2876 from 李伟峰/master
This commit is contained in:
openharmony_ci 2022-09-02 00:39:00 +00:00 committed by Gitee
commit d07fbc1757
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 24 additions and 8 deletions

View File

@ -38,7 +38,7 @@ int FormProviderClient::AcquireProviderFormInfo(
Want newWant(want);
newWant.SetParam(Constants::ACQUIRE_TYPE, want.GetIntParam(Constants::ACQUIRE_TYPE, 0));
newWant.SetParam(Constants::FORM_CONNECT_ID, want.GetLongParam(Constants::FORM_CONNECT_ID, 0));
newWant.SetParam(Constants::FORM_CONNECT_ID, want.GetIntParam(Constants::FORM_CONNECT_ID, 0));
newWant.SetParam(Constants::FORM_SUPPLY_INFO, want.GetStringParam(Constants::FORM_SUPPLY_INFO));
newWant.SetParam(Constants::PROVIDER_FLAG, true);
newWant.SetParam(Constants::PARAM_FORM_IDENTITY_KEY, std::to_string(formJsInfo.formId));
@ -88,6 +88,12 @@ int FormProviderClient::NotifyFormDelete(const int64_t formId, const Want &want,
int errorCode = ERR_OK;
do {
HILOG_INFO("%{public}s called.", __func__);
auto hostToken = want.GetRemoteObject(Constants::PARAM_FORM_HOST_TOKEN);
if (hostToken != nullptr) {
FormCallerMgr::GetInstance().RemoveFormProviderCaller(formId, hostToken);
break;
}
std::shared_ptr<Ability> ownerAbility = GetOwner();
if (ownerAbility == nullptr) {
HILOG_ERROR("%{public}s error, ownerAbility is nullptr.", __func__);
@ -493,8 +499,8 @@ int FormProviderClient::HandleDisconnect(const Want &want, const sptr<IRemoteOb
return ERR_APPEXECFWK_FORM_BIND_PROVIDER_FAILED;
}
HILOG_DEBUG("%{public}s come, connectId: %{public}ld.", __func__,
want.GetLongParam(Constants::FORM_CONNECT_ID, 0L));
HILOG_DEBUG("%{public}s come, connectId: %{public}d.", __func__,
want.GetIntParam(Constants::FORM_CONNECT_ID, 0L));
formSupplyClient->OnEventHandle(want);
return ERR_OK;
@ -555,8 +561,11 @@ void FormProviderClient::HandleRemoteAcquire(const FormJsInfo &formJsInfo, const
const Want &want, const sptr<IRemoteObject> &token)
{
HILOG_INFO("%{public}s called", __func__);
auto callerToken = want.GetRemoteObject(Constants::PARAM_FORM_HOST_TOKEN);
FormCallerMgr::GetInstance().SetFormProviderCaller(formJsInfo, callerToken);
auto hostToken = want.GetRemoteObject(Constants::PARAM_FORM_HOST_TOKEN);
if (hostToken == nullptr) {
return;
}
FormCallerMgr::GetInstance().AddFormProviderCaller(formJsInfo, hostToken);
std::vector<std::shared_ptr<FormProviderCaller>> formProviderCallers;
FormCallerMgr::GetInstance().GetFormProviderCaller(formJsInfo.formId, formProviderCallers);

View File

@ -20,6 +20,7 @@
#include "appexecfwk_errors.h"
#include "event_handler.h"
#include "event_runner.h"
#include "form_caller_mgr.h"
#include "form_extension.h"
#include "form_mgr_errors.h"
#include "form_supply_proxy.h"
@ -42,7 +43,7 @@ int FormExtensionProviderClient::AcquireProviderFormInfo(const AppExecFwk::FormJ
Want connectWant(want);
connectWant.SetParam(Constants::ACQUIRE_TYPE, want.GetIntParam(Constants::ACQUIRE_TYPE, 0));
connectWant.SetParam(Constants::FORM_CONNECT_ID, want.GetLongParam(Constants::FORM_CONNECT_ID, 0));
connectWant.SetParam(Constants::FORM_CONNECT_ID, want.GetIntParam(Constants::FORM_CONNECT_ID, 0));
connectWant.SetParam(Constants::FORM_SUPPLY_INFO, want.GetStringParam(Constants::FORM_SUPPLY_INFO));
connectWant.SetParam(Constants::PROVIDER_FLAG, true);
connectWant.SetParam(Constants::PARAM_FORM_IDENTITY_KEY, std::to_string(formJsInfo.formId));
@ -69,7 +70,7 @@ void FormExtensionProviderClient::AcquireFormExtensionProviderInfo(const AppExec
HILOG_INFO("%{public}s called.", __func__);
Want connectWant(want);
connectWant.SetParam(Constants::ACQUIRE_TYPE, want.GetIntParam(Constants::ACQUIRE_TYPE, 0));
connectWant.SetParam(Constants::FORM_CONNECT_ID, want.GetLongParam(Constants::FORM_CONNECT_ID, 0));
connectWant.SetParam(Constants::FORM_CONNECT_ID, want.GetIntParam(Constants::FORM_CONNECT_ID, 0));
connectWant.SetParam(Constants::FORM_SUPPLY_INFO, want.GetStringParam(Constants::FORM_SUPPLY_INFO));
connectWant.SetParam(Constants::PROVIDER_FLAG, true);
connectWant.SetParam(Constants::PARAM_FORM_IDENTITY_KEY, std::to_string(formJsInfo.formId));
@ -136,6 +137,13 @@ void FormExtensionProviderClient::NotifyFormExtensionDelete(const int64_t formId
{
HILOG_INFO("%{public}s called.", __func__);
int errorCode = ERR_OK;
auto hostToken = want.GetRemoteObject(Constants::PARAM_FORM_HOST_TOKEN);
if (hostToken != nullptr) {
HILOG_DEBUG("remove provider caller.");
FormCallerMgr::GetInstance().RemoveFormProviderCaller(formId, hostToken);
HandleResultCode(errorCode, want, callerToken);
return;
}
std::shared_ptr<FormExtension> ownerFormExtension = GetOwner();
if (ownerFormExtension == nullptr) {
HILOG_ERROR("%{public}s error, ownerFormExtension is nullptr.", __func__);

View File

@ -162,7 +162,6 @@ public:
* @return none.
*/
void ClearOwner(const std::shared_ptr<Ability> ability);
protected:
bool CheckIsSystemApp() const;
int HandleDisconnect(const Want &want, const sptr<IRemoteObject> &callerToken);