update: 更新文件 ecological_rule_mgr_service_proxy.cpp

Signed-off-by: xxj_masterxiexiaojian1@h-partners.com

Signed-off-by: xxj_codeHub <xiexiaojian1@h-partners.com>
This commit is contained in:
xxj_codeHub
2026-02-11 11:21:05 +08:00
parent c579a42dba
commit 9ee163eb60
@@ -30,154 +30,24 @@ EcologicalRuleMgrServiceProxy::EcologicalRuleMgrServiceProxy(const sptr<IRemoteO
int32_t EcologicalRuleMgrServiceProxy::QueryFreeInstallExperience(const Want &want, const CallerInfo &callerInfo,
ExperienceRule &rule)
{
LOG_INFO("QueryFreeInstallExperience called");
MessageParcel data;
if (!data.WriteInterfaceToken(ERMS_INTERFACE_TOKEN)) {
LOG_ERROR("write token failed");
return ERR_FAILED;
}
bool res = data.WriteParcelable(&want) && data.WriteParcelable(&callerInfo);
if (!res) {
LOG_ERROR("write data failed");
return ERR_FAILED;
}
MessageOption option = { MessageOption::TF_SYNC };
MessageParcel reply;
auto remote = Remote();
if (remote == nullptr) {
LOG_ERROR("get Remote failed");
return ERR_FAILED;
}
int32_t ret = remote->SendRequest(QUERY_FREE_INSTALL_EXPERIENCE_CMD, data, reply, option);
if (ret != ERR_NONE) {
LOG_ERROR("SendRequest error, ret = %{public}d", ret);
return ERR_FAILED;
}
sptr<BmsExperienceRule> sptrRule = reply.ReadParcelable<BmsExperienceRule>();
if (sptrRule == nullptr) {
LOG_ERROR("readParcelable sptrRule error");
return ERR_FAILED;
}
rule.replaceWant = sptrRule->replaceWant;
LOG_INFO("QueryFreeInstallExperience end");
return ERR_OK;
}
int32_t EcologicalRuleMgrServiceProxy::EvaluateResolveInfos(const Want &want, const CallerInfo &callerInfo,
int32_t type, std::vector<AbilityInfo> &abilityInfos)
{
LOG_INFO("EvaluateResolveInfos called");
MessageParcel data;
if (!data.WriteInterfaceToken(ERMS_INTERFACE_TOKEN)) {
LOG_ERROR("write token failed");
return ERR_FAILED;
}
bool res = data.WriteParcelable(&want) && data.WriteInt32(type) &&
data.WriteInt32(abilityInfos.size());
if (!res) {
LOG_ERROR("write data failed");
return ERR_FAILED;
}
for (auto &abilityInfo : abilityInfos) {
if (!data.WriteParcelable(&abilityInfo)) {
LOG_ERROR("write abilityInfo failed");
return ERR_FAILED;
}
}
if (!data.WriteParcelable(&callerInfo)) {
LOG_ERROR("write callerInfo failed");
return ERR_FAILED;
}
MessageOption option = { MessageOption::TF_SYNC };
MessageParcel reply;
auto remote = Remote();
if (remote == nullptr) {
LOG_ERROR("get Remote failed.");
return ERR_FAILED;
}
int32_t ret = remote->SendRequest(EVALUATE_RESOLVE_INFO_CMD, data, reply, option);
if (ret != ERR_NONE) {
LOG_ERROR("SendRequest error, ret = %{public}d", ret);
return ERR_FAILED;
}
LOG_INFO("EvaluateResolveInfos end");
return ERR_OK;
}
int32_t EcologicalRuleMgrServiceProxy::QueryStartExperience(const Want &want, const CallerInfo &callerInfo,
ExperienceRule &rule)
{
LOG_INFO("QueryStartExperience called");
MessageParcel data;
if (!data.WriteInterfaceToken(ERMS_INTERFACE_TOKEN)) {
LOG_ERROR("write token failed");
return ERR_FAILED;
}
bool res = data.WriteParcelable(&want) && data.WriteParcelable(&callerInfo);
if (!res) {
LOG_ERROR("write data failed");
return ERR_FAILED;
}
MessageOption option = { MessageOption::TF_SYNC };
MessageParcel reply;
auto remote = Remote();
if (remote == nullptr) {
LOG_ERROR("get Remote failed");
return ERR_FAILED;
}
int32_t ret = remote->SendRequest(QUERY_START_EXPERIENCE_CMD, data, reply, option);
if (ret != ERR_NONE) {
LOG_ERROR("SendRequest error, ret = %{public}d", ret);
return ERR_FAILED;
}
sptr<AmsExperienceRule> sptrRule = reply.ReadParcelable<AmsExperienceRule>();
if (sptrRule == nullptr) {
LOG_ERROR("ReadParcelable sptrRule error");
return ERR_FAILED;
}
rule.resultCode = sptrRule->resultCode;
rule.replaceWant = sptrRule->replaceWant;
LOG_INFO("QueryStartExperience end");
return ERR_OK;
}
int32_t EcologicalRuleMgrServiceProxy::IsSupportPublishForm(const std::vector<Want> &wants,
const CallerInfo &callerInfo, bool &bSupport)
{
LOG_INFO("IsSupportPublishForm called");
MessageParcel data;
if (!data.WriteInterfaceToken(ERMS_INTERFACE_TOKEN)) {
LOG_ERROR("write token failed");
return ERR_FAILED;
}
if (!data.WriteInt32(wants.size())) {
LOG_ERROR("write wants size failed");
return ERR_FAILED;
}
for (auto &want : wants) {
if (!data.WriteParcelable(&want)) {
LOG_ERROR("write want failed");
return ERR_FAILED;
}
}
if (!data.WriteParcelable(&callerInfo)) {
LOG_ERROR("write callerInfo failed");
return ERR_FAILED;
}
MessageOption option = { MessageOption::TF_SYNC };
MessageParcel reply;
auto remote = Remote();
if (remote == nullptr) {
LOG_ERROR("get Remote failed");
return ERR_FAILED;
}
int32_t ret = remote->SendRequest(IS_SUPPORT_PUBLISH_FORM_CMD, data, reply, option);
if (ret != ERR_NONE) {
LOG_ERROR("SendRequest error, ret = %{public}d", ret);
return ERR_FAILED;
}
bSupport = reply.ReadBool();
LOG_INFO("IsSupportPublishForm end, bSupport=%{public}d", bSupport);
return ERR_OK;
}