!1369 [CVSS-Fix]use WriteRemoteObject&ReadRemoteObject

Merge pull request !1369 from 张亚菲/zyf1
This commit is contained in:
openharmony_ci 2022-03-26 04:05:28 +00:00 committed by Gitee
commit 196cc1e1b6
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
19 changed files with 131 additions and 75 deletions

View File

@ -39,10 +39,19 @@ void ReverseContinuationSchedulerReplicaProxy::PassPrimary(const sptr<IRemoteObj
HILOG_ERROR("ReverseContinuationSchedulerReplicaProxy::PassPrimary write interface token failed");
return;
}
if (!data.WriteRemoteObject(primary)) {
HILOG_ERROR("ReverseContinuationSchedulerReplicaProxy::PassPrimary write parcel callback failed");
return;
if (primary) {
if (!data.WriteBool(true) || !data.WriteRemoteObject(primary)) {
HILOG_ERROR("Failed to write flag and primary");
return;
}
} else {
HILOG_DEBUG("primary is nullptr");
if (!data.WriteBool(false)) {
HILOG_ERROR("Failed to write flag");
return;
}
}
sptr<IRemoteObject> remoteObject = Remote();
if (remoteObject == nullptr) {
HILOG_ERROR("ReverseContinuationSchedulerReplicaProxy::PassPrimary Remote() is NULL");

View File

@ -34,7 +34,10 @@ ReverseContinuationSchedulerReplicaStub::~ReverseContinuationSchedulerReplicaStu
int32_t ReverseContinuationSchedulerReplicaStub::PassPrimaryInner(MessageParcel &data, MessageParcel &reply)
{
HILOG_INFO("%{public}s called begin", __func__);
const sptr<IRemoteObject> primary = data.ReadParcelable<IRemoteObject>();
sptr<IRemoteObject> primary = nullptr;
if (data.ReadBool()) {
primary = data.ReadRemoteObject();
}
PassPrimary(primary);
HILOG_INFO("%{public}s called end", __func__);
return NO_ERROR;

View File

@ -43,7 +43,7 @@ int RemoteRegisterServiceProxy::Register(const std::string &bundleName, const sp
MessageParcel data;
if (!data.WriteInterfaceToken(IRemoteRegisterService::GetDescriptor()) || !data.WriteString(bundleName) ||
data.WriteRemoteObject(token) || !data.WriteInt32(1) || !extras.Marshalling(data) ||
!data.WriteRemoteObject(token) || !data.WriteInt32(1) || !extras.Marshalling(data) ||
!data.WriteRemoteObject(callback->AsObject())) {
HILOG_ERROR("%{public}s Failed to write transfer data.", __func__);
return IPC_INVOKER_WRITE_TRANS_ERR;

View File

@ -58,7 +58,7 @@ int RemoteRegisterServiceStub::RegisterInner(MessageParcel &data, MessageParcel
{
HILOG_INFO("%{public}s called begin", __func__);
std::string bundleName = data.ReadString();
sptr<IRemoteObject> token = data.ReadParcelable<IRemoteObject>();
sptr<IRemoteObject> token = data.ReadRemoteObject();
ExtraParams *pExtras = nullptr;
int32_t extraId = data.ReadInt32();
if (extraId != 0) {

View File

@ -123,7 +123,11 @@ int32_t AppSchedulerHost::HandleScheduleLaunchAbility(MessageParcel &data, Messa
return ERR_APPEXECFWK_PARCEL_ERROR;
}
sptr<IRemoteObject> token = data.ReadParcelable<IRemoteObject>();
sptr<IRemoteObject> token = nullptr;
if (data.ReadBool()) {
token = data.ReadRemoteObject();
}
std::shared_ptr<AAFwk::Want> want(data.ReadParcelable<AAFwk::Want>());
ScheduleLaunchAbility(*abilityInfo, token, want);
return NO_ERROR;
@ -132,7 +136,7 @@ int32_t AppSchedulerHost::HandleScheduleLaunchAbility(MessageParcel &data, Messa
int32_t AppSchedulerHost::HandleScheduleCleanAbility(MessageParcel &data, MessageParcel &reply)
{
BYTRACE(BYTRACE_TAG_APP);
sptr<IRemoteObject> token = data.ReadParcelable<IRemoteObject>();
sptr<IRemoteObject> token = data.ReadRemoteObject();
ScheduleCleanAbility(token);
return NO_ERROR;
}

View File

@ -153,7 +153,19 @@ void AppSchedulerProxy::ScheduleLaunchAbility(const AbilityInfo &info, const spt
return;
}
data.WriteParcelable(&info);
data.WriteParcelable(token.GetRefPtr());
if (token) {
if (!data.WriteBool(true) || !data.WriteRemoteObject(token.GetRefPtr())) {
HILOG_ERROR("Failed to write flag and token");
return;
}
} else {
if (!data.WriteBool(false)) {
HILOG_ERROR("Failed to write flag");
return;
}
}
if (!data.WriteParcelable(want.get())) {
HILOG_ERROR("write want fail.");
return;
@ -178,7 +190,10 @@ void AppSchedulerProxy::ScheduleCleanAbility(const sptr<IRemoteObject> &token)
if (!WriteInterfaceToken(data)) {
return;
}
data.WriteParcelable(token.GetRefPtr());
if (!data.WriteRemoteObject(token.GetRefPtr())) {
HILOG_ERROR("Failed to write token");
return;
}
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
HILOG_ERROR("Remote() is NULL");

View File

@ -85,7 +85,10 @@ int32_t AppStateCallbackHost::HandleOnAppStateChanged(MessageParcel &data, Messa
int32_t AppStateCallbackHost::HandleOnAbilityRequestDone(MessageParcel &data, MessageParcel &reply)
{
BYTRACE(BYTRACE_TAG_APP);
sptr<IRemoteObject> obj = data.ReadParcelable<IRemoteObject>();
sptr<IRemoteObject> obj = nullptr;
if (data.ReadBool()) {
obj = data.ReadRemoteObject();
}
int32_t state = data.ReadInt32();
OnAbilityRequestDone(obj, static_cast<AbilityState>(state));
return NO_ERROR;

View File

@ -42,7 +42,19 @@ void AppStateCallbackProxy::OnAbilityRequestDone(const sptr<IRemoteObject> &toke
if (!WriteInterfaceToken(data)) {
return;
}
data.WriteParcelable(token.GetRefPtr());
if (token) {
if (!data.WriteBool(true) || !data.WriteRemoteObject(token.GetRefPtr())) {
HILOG_ERROR("Failed to write flag and token");
return;
}
} else {
if (!data.WriteBool(false)) {
HILOG_ERROR("Failed to write flag");
return;
}
}
int32_t abilityState = static_cast<int32_t>(state);
data.WriteInt32(abilityState);
sptr<IRemoteObject> remote = Remote();

View File

@ -50,7 +50,7 @@ int FormMgrProxy::AddForm(
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteParcelable(callerToken)) {
if (!data.WriteRemoteObject(callerToken)) {
HILOG_ERROR("%{public}s, failed to write callerToken", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -80,7 +80,7 @@ int FormMgrProxy::DeleteForm(const int64_t formId, const sptr<IRemoteObject> &ca
HILOG_ERROR("%{public}s, failed to write want", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteParcelable(callerToken)) {
if (!data.WriteRemoteObject(callerToken)) {
HILOG_ERROR("%{public}s, failed to write callerToken", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -116,7 +116,7 @@ int FormMgrProxy::ReleaseForm(const int64_t formId, const sptr<IRemoteObject> &c
HILOG_ERROR("%{public}s, failed to write want", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteParcelable(callerToken)) {
if (!data.WriteRemoteObject(callerToken)) {
HILOG_ERROR("%{public}s, failed to write callerToken", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -234,7 +234,7 @@ int FormMgrProxy::LifecycleUpdate(
HILOG_ERROR("%{public}s, failed to write formId", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteParcelable(callerToken)) {
if (!data.WriteRemoteObject(callerToken)) {
HILOG_ERROR("%{public}s, failed to write bundleName", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -275,7 +275,7 @@ int FormMgrProxy::RequestForm(const int64_t formId, const sptr<IRemoteObject> &c
HILOG_ERROR("%{public}s, failed to write formId", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteParcelable(callerToken)) {
if (!data.WriteRemoteObject(callerToken)) {
HILOG_ERROR("%{public}s, failed to write callerToken", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -321,7 +321,7 @@ int FormMgrProxy::NotifyWhetherVisibleForms(
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteParcelable(callerToken)) {
if (!data.WriteRemoteObject(callerToken)) {
HILOG_ERROR("%{public}s, failed to write callerToken", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -362,7 +362,7 @@ int FormMgrProxy::CastTempForm(const int64_t formId, const sptr<IRemoteObject> &
HILOG_ERROR("%{public}s, failed to write want", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteParcelable(callerToken)) {
if (!data.WriteRemoteObject(callerToken)) {
HILOG_ERROR("%{public}s, failed to write callerToken", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -500,7 +500,7 @@ int FormMgrProxy::MessageEvent(const int64_t formId, const Want &want, const spt
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteParcelable(callerToken)) {
if (!data.WriteRemoteObject(callerToken)) {
HILOG_ERROR("%{public}s, failed to write callerToken", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -728,7 +728,7 @@ int FormMgrProxy::DeleteInvalidForms(const std::vector<int64_t> &formIds, const
HILOG_ERROR("%{public}s, failed to write vector formIds", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteParcelable(callerToken)) {
if (!data.WriteRemoteObject(callerToken)) {
HILOG_ERROR("%{public}s, failed to write callerToken", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -773,7 +773,7 @@ int FormMgrProxy::AcquireFormState(const Want &want, const sptr<IRemoteObject> &
HILOG_ERROR("%{public}s, failed to write want", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteParcelable(callerToken)) {
if (!data.WriteRemoteObject(callerToken)) {
HILOG_ERROR("%{public}s, failed to write callerToken", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}

View File

@ -134,7 +134,7 @@ int32_t FormMgrStub::HandleAddForm(MessageParcel &data, MessageParcel &reply)
return ERR_APPEXECFWK_PARCEL_ERROR;
}
sptr<IRemoteObject> client = data.ReadParcelable<IRemoteObject>();
sptr<IRemoteObject> client = data.ReadRemoteObject();
if (client == nullptr) {
HILOG_ERROR("%{public}s, failed to RemoteObject invalidate", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
@ -156,7 +156,7 @@ int32_t FormMgrStub::HandleAddForm(MessageParcel &data, MessageParcel &reply)
int32_t FormMgrStub::HandleDeleteForm(MessageParcel &data, MessageParcel &reply)
{
int64_t formId = data.ReadInt64();
sptr<IRemoteObject> client = data.ReadParcelable<IRemoteObject>();
sptr<IRemoteObject> client = data.ReadRemoteObject();
if (client == nullptr) {
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -173,7 +173,7 @@ int32_t FormMgrStub::HandleDeleteForm(MessageParcel &data, MessageParcel &reply)
int32_t FormMgrStub::HandleReleaseForm(MessageParcel &data, MessageParcel &reply)
{
int64_t formId = data.ReadInt64();
sptr<IRemoteObject> client = data.ReadParcelable<IRemoteObject>();
sptr<IRemoteObject> client = data.ReadRemoteObject();
if (client == nullptr) {
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -224,9 +224,9 @@ int32_t FormMgrStub::HandleLifecycleUpdate(MessageParcel &data, MessageParcel &r
if (!ret) {
return ERR_APPEXECFWK_PARCEL_ERROR;
}
sptr<IRemoteObject> client = data.ReadParcelable<IRemoteObject>();
sptr<IRemoteObject> client = data.ReadRemoteObject();
if (client == nullptr) {
HILOG_ERROR("%{public}s, failed to ReadParcelable<IRemoteObject>", __func__);
HILOG_ERROR("%{public}s, failed to get remote object.", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
int32_t updateType = data.ReadInt32();
@ -246,9 +246,9 @@ int32_t FormMgrStub::HandleRequestForm(MessageParcel &data, MessageParcel &reply
int64_t formId = data.ReadInt64();
sptr<IRemoteObject> client = data.ReadParcelable<IRemoteObject>();
sptr<IRemoteObject> client = data.ReadRemoteObject();
if (client == nullptr) {
HILOG_ERROR("%{public}s, failed to ReadParcelable<IRemoteObject>", __func__);
HILOG_ERROR("%{public}s, failed to get remote object.", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -276,7 +276,7 @@ int32_t FormMgrStub::HandleNotifyWhetherVisibleForms(MessageParcel &data, Messag
return ERR_APPEXECFWK_PARCEL_ERROR;
}
sptr<IRemoteObject> client = data.ReadParcelable<IRemoteObject>();
sptr<IRemoteObject> client = data.ReadRemoteObject();
if (client == nullptr) {
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -296,7 +296,7 @@ int32_t FormMgrStub::HandleNotifyWhetherVisibleForms(MessageParcel &data, Messag
int32_t FormMgrStub::HandleCastTempForm(MessageParcel &data, MessageParcel &reply)
{
int64_t formId = data.ReadInt64();
sptr<IRemoteObject> client = data.ReadParcelable<IRemoteObject>();
sptr<IRemoteObject> client = data.ReadRemoteObject();
if (client == nullptr) {
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -412,9 +412,9 @@ int32_t FormMgrStub::HandleMessageEvent(MessageParcel &data, MessageParcel &repl
return ERR_APPEXECFWK_PARCEL_ERROR;
}
sptr<IRemoteObject> client = data.ReadParcelable<IRemoteObject>();
sptr<IRemoteObject> client = data.ReadRemoteObject();
if (client == nullptr) {
HILOG_ERROR("%{public}s, failed to ReadParcelable<IRemoteObject>", __func__);
HILOG_ERROR("%{public}s, failed to get remote object.", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -513,9 +513,9 @@ int32_t FormMgrStub::HandleDeleteInvalidForms(MessageParcel &data, MessageParcel
HILOG_ERROR("%{public}s, failed to ReadInt64Vector", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
sptr<IRemoteObject> callerToken = data.ReadParcelable<IRemoteObject>();
sptr<IRemoteObject> callerToken = data.ReadRemoteObject();
if (callerToken == nullptr) {
HILOG_ERROR("%{public}s, failed to ReadParcelable<IRemoteObject>", __func__);
HILOG_ERROR("%{public}s, failed to get remote object.", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
int32_t numFormsDeleted = 0;
@ -546,9 +546,9 @@ int32_t FormMgrStub::HandleAcquireFormState(MessageParcel &data, MessageParcel &
HILOG_ERROR("%{public}s, failed to ReadParcelable want", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
sptr<IRemoteObject> callerToken = data.ReadParcelable<IRemoteObject>();
sptr<IRemoteObject> callerToken = data.ReadRemoteObject();
if (callerToken == nullptr) {
HILOG_ERROR("%{public}s, failed to ReadParcelable<IRemoteObject>", __func__);
HILOG_ERROR("%{public}s, failed to get remote object.", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
int32_t result = AcquireFormState(*want, callerToken, stateInfo);

View File

@ -48,7 +48,7 @@ int FormProviderProxy::AcquireProviderFormInfo(
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteParcelable(callerToken)) {
if (!data.WriteRemoteObject(callerToken)) {
HILOG_ERROR("%{public}s, failed to write callerToken", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -91,7 +91,7 @@ int FormProviderProxy::NotifyFormDelete(const int64_t formId, const Want &want,
HILOG_ERROR("%{public}s, failed to write want", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteParcelable(callerToken)) {
if (!data.WriteRemoteObject(callerToken)) {
HILOG_ERROR("%{public}s, failed to write callerToken", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -136,7 +136,7 @@ int FormProviderProxy::NotifyFormsDelete(
HILOG_ERROR("%{public}s, failed to write want", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteParcelable(callerToken)) {
if (!data.WriteRemoteObject(callerToken)) {
HILOG_ERROR("%{public}s, failed to write callerToken", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -181,7 +181,7 @@ int FormProviderProxy::NotifyFormUpdate(const int64_t formId, const Want &want,
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteParcelable(callerToken)) {
if (!data.WriteRemoteObject(callerToken)) {
HILOG_ERROR("%{public}s, failed to write callerToken.", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -235,7 +235,7 @@ int FormProviderProxy::EventNotify(const std::vector<int64_t> &formIds, const in
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteParcelable(callerToken)) {
if (!data.WriteRemoteObject(callerToken)) {
HILOG_ERROR("%{public}s, failed to write callerToken.", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -282,7 +282,7 @@ int FormProviderProxy::NotifyFormCastTempForm(
HILOG_ERROR("%{public}s, failed to write want", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteParcelable(callerToken)) {
if (!data.WriteRemoteObject(callerToken)) {
HILOG_ERROR("%{public}s, failed to write callerToken", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -330,7 +330,7 @@ int FormProviderProxy::FireFormEvent(
HILOG_ERROR("%{public}s, failed to write want", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteParcelable(callerToken)) {
if (!data.WriteRemoteObject(callerToken)) {
HILOG_ERROR("%{public}s, failed to write callerToken", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -375,7 +375,7 @@ int FormProviderProxy::AcquireState(const Want &wantArg, const Want &want, const
HILOG_ERROR("%{public}s, failed to write want", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
if (!data.WriteParcelable(callerToken)) {
if (!data.WriteRemoteObject(callerToken)) {
HILOG_ERROR("%{public}s, failed to write callerToken", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}

View File

@ -89,9 +89,9 @@ int FormProviderStub::HandleAcquireProviderFormInfo(MessageParcel &data, Message
return ERR_APPEXECFWK_PARCEL_ERROR;
}
sptr<IRemoteObject> client = data.ReadParcelable<IRemoteObject>();
sptr<IRemoteObject> client = data.ReadRemoteObject();
if (client == nullptr) {
HILOG_ERROR("%{public}s, failed to ReadParcelable<IRemoteObject>", __func__);
HILOG_ERROR("%{public}s, failed to get remote object.", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -114,9 +114,9 @@ int FormProviderStub::HandleNotifyFormDelete(MessageParcel &data, MessageParcel
return ERR_APPEXECFWK_PARCEL_ERROR;
}
sptr<IRemoteObject> client = data.ReadParcelable<IRemoteObject>();
sptr<IRemoteObject> client = data.ReadRemoteObject();
if (client == nullptr) {
HILOG_ERROR("%{public}s, failed to ReadParcelable<IRemoteObject>", __func__);
HILOG_ERROR("%{public}s, failed to get remote object.", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -141,9 +141,9 @@ int FormProviderStub::HandleNotifyFormsDelete(MessageParcel &data, MessageParcel
return ERR_APPEXECFWK_PARCEL_ERROR;
}
sptr<IRemoteObject> client = data.ReadParcelable<IRemoteObject>();
sptr<IRemoteObject> client = data.ReadRemoteObject();
if (client == nullptr) {
HILOG_ERROR("%{public}s, failed to ReadParcelable<IRemoteObject>", __func__);
HILOG_ERROR("%{public}s, failed to get remote object.", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -170,9 +170,9 @@ int FormProviderStub::HandleNotifyFormUpdate(MessageParcel &data, MessageParcel
return ERR_APPEXECFWK_PARCEL_ERROR;
}
sptr<IRemoteObject> client = data.ReadParcelable<IRemoteObject>();
sptr<IRemoteObject> client = data.ReadRemoteObject();
if (client == nullptr) {
HILOG_ERROR("%{public}s, failed to ReadParcelable<IRemoteObject>", __func__);
HILOG_ERROR("%{public}s, failed to get remote object.", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -200,9 +200,9 @@ int FormProviderStub::HandleEventNotify(MessageParcel &data, MessageParcel &repl
return ERR_APPEXECFWK_PARCEL_ERROR;
}
sptr<IRemoteObject> client = data.ReadParcelable<IRemoteObject>();
sptr<IRemoteObject> client = data.ReadRemoteObject();
if (client == nullptr) {
HILOG_ERROR("%{public}s, failed to ReadParcelable<IRemoteObject>", __func__);
HILOG_ERROR("%{public}s, failed to get remote object.", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -230,9 +230,9 @@ int FormProviderStub::HandleNotifyFormCastTempForm(MessageParcel &data, MessageP
return ERR_APPEXECFWK_PARCEL_ERROR;
}
sptr<IRemoteObject> client = data.ReadParcelable<IRemoteObject>();
sptr<IRemoteObject> client = data.ReadRemoteObject();
if (client == nullptr) {
HILOG_ERROR("%{public}s, failed to ReadParcelable<IRemoteObject>", __func__);
HILOG_ERROR("%{public}s, failed to get remote object.", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -252,13 +252,13 @@ int FormProviderStub::HandleFireFormEvent(MessageParcel &data, MessageParcel &re
std::string message = data.ReadString();
std::unique_ptr<Want> want(data.ReadParcelable<Want>());
if (!want) {
HILOG_ERROR("%{public}s fail, ReadParcelable<FormReqInfo> failed", __func__);
HILOG_ERROR("%{public}s, failed to get want.", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
sptr<IRemoteObject> client = data.ReadParcelable<IRemoteObject>();
sptr<IRemoteObject> client = data.ReadRemoteObject();
if (client == nullptr) {
HILOG_ERROR("%{public}s, failed to ReadParcelable<IRemoteObject>", __func__);
HILOG_ERROR("%{public}s, failed to get remote object.", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
@ -284,9 +284,9 @@ int FormProviderStub::HandleAcquireState(MessageParcel &data, MessageParcel &rep
HILOG_ERROR("%{public}s fail, ReadParcelable<Want> failed", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
sptr<IRemoteObject> client = data.ReadParcelable<IRemoteObject>();
sptr<IRemoteObject> client = data.ReadRemoteObject();
if (client == nullptr) {
HILOG_ERROR("%{public}s, failed to ReadParcelable<IRemoteObject>", __func__);
HILOG_ERROR("%{public}s, failed to get remote object.", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
int32_t result = AcquireState(*wantArg, *want, client);

View File

@ -47,9 +47,16 @@ void ProviderConnectProxy::OnAbilityConnectDone(
return;
}
if (!data.WriteRemoteObject(remoteObject)) {
HILOG_ERROR("%{public}s, failed to write remote object ", __func__);
return;
if (remoteObject) {
if (!data.WriteBool(true) || !data.WriteRemoteObject(remoteObject)) {
HILOG_ERROR("%{public}s, failed to write flag and remote object", __func__);
return;
}
} else {
if (!data.WriteBool(false)) {
HILOG_ERROR("%{public}s, failed to write flag", __func__);
return;
}
}
if (!data.WriteInt32(resultCode)) {

View File

@ -46,7 +46,10 @@ int ProviderConnectStub::OnRemoteRequest(
HILOG_ERROR("%{public}s failed, callback stub receive element is nullptr", __func__);
return ERR_APPEXECFWK_PARCEL_ERROR;
}
auto remoteObject = data.ReadRemoteObject();
sptr<IRemoteObject> remoteObject = nullptr;
if (data.ReadBool()) {
remoteObject = data.ReadRemoteObject();
}
auto resultCode = data.ReadInt32();
OnAbilityConnectDone(*element, remoteObject, resultCode);
delete element;

View File

@ -751,7 +751,7 @@ bool AbilitySchedulerProxy::ScheduleRegisterObserver(const Uri &uri, const sptr<
return false;
}
if (!data.WriteParcelable(dataObserver->AsObject())) {
if (!data.WriteRemoteObject(dataObserver->AsObject())) {
HILOG_ERROR("%{public}s failed to WriteParcelable dataObserver ", __func__);
return false;
}
@ -788,7 +788,7 @@ bool AbilitySchedulerProxy::ScheduleUnregisterObserver(const Uri &uri, const spt
return false;
}
if (!data.WriteParcelable(dataObserver->AsObject())) {
if (!data.WriteRemoteObject(dataObserver->AsObject())) {
HILOG_ERROR("%{public}s failed to WriteParcelable dataObserver ", __func__);
return false;
}

View File

@ -445,7 +445,7 @@ int AbilitySchedulerStub::RegisterObserverInner(MessageParcel &data, MessageParc
HILOG_ERROR("AbilitySchedulerStub uri is nullptr");
return ERR_INVALID_VALUE;
}
auto obServer = iface_cast<IDataAbilityObserver>(data.ReadParcelable<IRemoteObject>());
auto obServer = iface_cast<IDataAbilityObserver>(data.ReadRemoteObject());
if (obServer == nullptr) {
HILOG_ERROR("AbilitySchedulerStub obServer is nullptr");
return ERR_INVALID_VALUE;
@ -466,7 +466,7 @@ int AbilitySchedulerStub::UnregisterObserverInner(MessageParcel &data, MessagePa
HILOG_ERROR("AbilitySchedulerStub uri is nullptr");
return ERR_INVALID_VALUE;
}
auto obServer = iface_cast<IDataAbilityObserver>(data.ReadParcelable<IRemoteObject>());
auto obServer = iface_cast<IDataAbilityObserver>(data.ReadRemoteObject());
if (obServer == nullptr) {
HILOG_ERROR("AbilitySchedulerStub obServer is nullptr");
return ERR_INVALID_VALUE;

View File

@ -53,7 +53,7 @@ int DataObsManagerProxy::RegisterObserver(const Uri &uri, const sptr<IDataAbilit
return ERR_INVALID_VALUE;
}
if (!data.WriteParcelable(dataObserver->AsObject())) {
if (!data.WriteRemoteObject(dataObserver->AsObject())) {
HILOG_ERROR("register observer fail, dataObserver error");
return ERR_INVALID_VALUE;
}
@ -85,7 +85,7 @@ int DataObsManagerProxy::UnregisterObserver(const Uri &uri, const sptr<IDataAbil
return ERR_INVALID_VALUE;
}
if (!data.WriteParcelable(dataObserver->AsObject())) {
if (!data.WriteRemoteObject(dataObserver->AsObject())) {
HILOG_ERROR("unregister observer fail, dataObserver error");
return ERR_INVALID_VALUE;
}

View File

@ -66,7 +66,7 @@ int DataObsManagerStub::RegisterObserverInner(MessageParcel &data, MessageParcel
return ERR_INVALID_VALUE;
}
auto observer = iface_cast<IDataAbilityObserver>(data.ReadParcelable<IRemoteObject>());
auto observer = iface_cast<IDataAbilityObserver>(data.ReadRemoteObject());
int32_t result = RegisterObserver(*uri, observer);
reply.WriteInt32(result);
if (uri != nullptr) {
@ -83,7 +83,7 @@ int DataObsManagerStub::UnregisterObserverInner(MessageParcel &data, MessageParc
return ERR_INVALID_VALUE;
}
auto observer = iface_cast<IDataAbilityObserver>(data.ReadParcelable<IRemoteObject>());
auto observer = iface_cast<IDataAbilityObserver>(data.ReadRemoteObject());
int32_t result = UnregisterObserver(*uri, observer);
reply.WriteInt32(result);
if (uri != nullptr) {

View File

@ -103,6 +103,7 @@ HWTEST(ExtensionFormProfileTest, TransformTo_0101, TestSize.Level0)
ExtensionFormProfileReader::SRC,
ExtensionFormProfileReader::WINDOW,
ExtensionFormProfileReader::COLOR_MODE,
ExtensionFormProfileReader::FORM_CONFIG_ABILITY,
ExtensionFormProfileReader::FORM_VISIBLE_NOTIFY,
ExtensionFormProfileReader::SCHEDULED_UPDATE_TIME,
ExtensionFormProfileReader::UPDATE_DURATION,
@ -118,7 +119,6 @@ HWTEST(ExtensionFormProfileTest, TransformTo_0101, TestSize.Level0)
std::vector<std::string> mustPropKeys = {
ExtensionFormProfileReader::NAME,
ExtensionFormProfileReader::FORM_CONFIG_ABILITY,
ExtensionFormProfileReader::IS_DEFAULT,
ExtensionFormProfileReader::UPDATE_ENABLED,
ExtensionFormProfileReader::DEFAULT_DIMENSION,