diff --git a/frameworks/kits/ability/native/src/continuation/distributed/reverse_continuation_scheduler_replica_proxy.cpp b/frameworks/kits/ability/native/src/continuation/distributed/reverse_continuation_scheduler_replica_proxy.cpp index b2533679ea..e4286717bb 100644 --- a/frameworks/kits/ability/native/src/continuation/distributed/reverse_continuation_scheduler_replica_proxy.cpp +++ b/frameworks/kits/ability/native/src/continuation/distributed/reverse_continuation_scheduler_replica_proxy.cpp @@ -39,10 +39,19 @@ void ReverseContinuationSchedulerReplicaProxy::PassPrimary(const sptr remoteObject = Remote(); if (remoteObject == nullptr) { HILOG_ERROR("ReverseContinuationSchedulerReplicaProxy::PassPrimary Remote() is NULL"); diff --git a/frameworks/kits/ability/native/src/continuation/distributed/reverse_continuation_scheduler_replica_stub.cpp b/frameworks/kits/ability/native/src/continuation/distributed/reverse_continuation_scheduler_replica_stub.cpp index 95c5125590..12cccd9cdd 100644 --- a/frameworks/kits/ability/native/src/continuation/distributed/reverse_continuation_scheduler_replica_stub.cpp +++ b/frameworks/kits/ability/native/src/continuation/distributed/reverse_continuation_scheduler_replica_stub.cpp @@ -34,7 +34,10 @@ ReverseContinuationSchedulerReplicaStub::~ReverseContinuationSchedulerReplicaStu int32_t ReverseContinuationSchedulerReplicaStub::PassPrimaryInner(MessageParcel &data, MessageParcel &reply) { HILOG_INFO("%{public}s called begin", __func__); - const sptr primary = data.ReadParcelable(); + sptr primary = nullptr; + if (data.ReadBool()) { + primary = data.ReadRemoteObject(); + } PassPrimary(primary); HILOG_INFO("%{public}s called end", __func__); return NO_ERROR; diff --git a/frameworks/kits/ability/native/src/continuation/remote_register_service/remote_register_service_proxy.cpp b/frameworks/kits/ability/native/src/continuation/remote_register_service/remote_register_service_proxy.cpp index fc8444944e..e32bf837d3 100644 --- a/frameworks/kits/ability/native/src/continuation/remote_register_service/remote_register_service_proxy.cpp +++ b/frameworks/kits/ability/native/src/continuation/remote_register_service/remote_register_service_proxy.cpp @@ -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; diff --git a/frameworks/kits/ability/native/src/continuation/remote_register_service/remote_register_service_stub.cpp b/frameworks/kits/ability/native/src/continuation/remote_register_service/remote_register_service_stub.cpp index bb586401a0..ca66789372 100644 --- a/frameworks/kits/ability/native/src/continuation/remote_register_service/remote_register_service_stub.cpp +++ b/frameworks/kits/ability/native/src/continuation/remote_register_service/remote_register_service_stub.cpp @@ -58,7 +58,7 @@ int RemoteRegisterServiceStub::RegisterInner(MessageParcel &data, MessageParcel { HILOG_INFO("%{public}s called begin", __func__); std::string bundleName = data.ReadString(); - sptr token = data.ReadParcelable(); + sptr token = data.ReadRemoteObject(); ExtraParams *pExtras = nullptr; int32_t extraId = data.ReadInt32(); if (extraId != 0) { diff --git a/interfaces/innerkits/app_manager/src/appmgr/app_scheduler_host.cpp b/interfaces/innerkits/app_manager/src/appmgr/app_scheduler_host.cpp index e7a3464991..3397d0ce98 100644 --- a/interfaces/innerkits/app_manager/src/appmgr/app_scheduler_host.cpp +++ b/interfaces/innerkits/app_manager/src/appmgr/app_scheduler_host.cpp @@ -123,7 +123,11 @@ int32_t AppSchedulerHost::HandleScheduleLaunchAbility(MessageParcel &data, Messa return ERR_APPEXECFWK_PARCEL_ERROR; } - sptr token = data.ReadParcelable(); + sptr token = nullptr; + if (data.ReadBool()) { + token = data.ReadRemoteObject(); + } + std::shared_ptr want(data.ReadParcelable()); 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 token = data.ReadParcelable(); + sptr token = data.ReadRemoteObject(); ScheduleCleanAbility(token); return NO_ERROR; } diff --git a/interfaces/innerkits/app_manager/src/appmgr/app_scheduler_proxy.cpp b/interfaces/innerkits/app_manager/src/appmgr/app_scheduler_proxy.cpp index afff1b4cc6..9fd134c3c3 100644 --- a/interfaces/innerkits/app_manager/src/appmgr/app_scheduler_proxy.cpp +++ b/interfaces/innerkits/app_manager/src/appmgr/app_scheduler_proxy.cpp @@ -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 &token) if (!WriteInterfaceToken(data)) { return; } - data.WriteParcelable(token.GetRefPtr()); + if (!data.WriteRemoteObject(token.GetRefPtr())) { + HILOG_ERROR("Failed to write token"); + return; + } sptr remote = Remote(); if (remote == nullptr) { HILOG_ERROR("Remote() is NULL"); diff --git a/interfaces/innerkits/app_manager/src/appmgr/app_state_callback_host.cpp b/interfaces/innerkits/app_manager/src/appmgr/app_state_callback_host.cpp index f05cdce3ff..eaf7ef2b27 100644 --- a/interfaces/innerkits/app_manager/src/appmgr/app_state_callback_host.cpp +++ b/interfaces/innerkits/app_manager/src/appmgr/app_state_callback_host.cpp @@ -85,7 +85,10 @@ int32_t AppStateCallbackHost::HandleOnAppStateChanged(MessageParcel &data, Messa int32_t AppStateCallbackHost::HandleOnAbilityRequestDone(MessageParcel &data, MessageParcel &reply) { BYTRACE(BYTRACE_TAG_APP); - sptr obj = data.ReadParcelable(); + sptr obj = nullptr; + if (data.ReadBool()) { + obj = data.ReadRemoteObject(); + } int32_t state = data.ReadInt32(); OnAbilityRequestDone(obj, static_cast(state)); return NO_ERROR; diff --git a/interfaces/innerkits/app_manager/src/appmgr/app_state_callback_proxy.cpp b/interfaces/innerkits/app_manager/src/appmgr/app_state_callback_proxy.cpp index 82aa11ef4f..1c5ff722a6 100644 --- a/interfaces/innerkits/app_manager/src/appmgr/app_state_callback_proxy.cpp +++ b/interfaces/innerkits/app_manager/src/appmgr/app_state_callback_proxy.cpp @@ -42,7 +42,19 @@ void AppStateCallbackProxy::OnAbilityRequestDone(const sptr &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(state); data.WriteInt32(abilityState); sptr remote = Remote(); diff --git a/interfaces/innerkits/form_manager/src/form_mgr_proxy.cpp b/interfaces/innerkits/form_manager/src/form_mgr_proxy.cpp index 79205a7d13..d596bb2092 100644 --- a/interfaces/innerkits/form_manager/src/form_mgr_proxy.cpp +++ b/interfaces/innerkits/form_manager/src/form_mgr_proxy.cpp @@ -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 &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 &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 &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 & 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 &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 & 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; } diff --git a/interfaces/innerkits/form_manager/src/form_mgr_stub.cpp b/interfaces/innerkits/form_manager/src/form_mgr_stub.cpp index 8aa8fa3f96..5afa6099b4 100644 --- a/interfaces/innerkits/form_manager/src/form_mgr_stub.cpp +++ b/interfaces/innerkits/form_manager/src/form_mgr_stub.cpp @@ -134,7 +134,7 @@ int32_t FormMgrStub::HandleAddForm(MessageParcel &data, MessageParcel &reply) return ERR_APPEXECFWK_PARCEL_ERROR; } - sptr client = data.ReadParcelable(); + sptr 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 client = data.ReadParcelable(); + sptr 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 client = data.ReadParcelable(); + sptr 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 client = data.ReadParcelable(); + sptr client = data.ReadRemoteObject(); if (client == nullptr) { - HILOG_ERROR("%{public}s, failed to ReadParcelable", __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 client = data.ReadParcelable(); + sptr client = data.ReadRemoteObject(); if (client == nullptr) { - HILOG_ERROR("%{public}s, failed to ReadParcelable", __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 client = data.ReadParcelable(); + sptr 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 client = data.ReadParcelable(); + sptr 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 client = data.ReadParcelable(); + sptr client = data.ReadRemoteObject(); if (client == nullptr) { - HILOG_ERROR("%{public}s, failed to ReadParcelable", __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 callerToken = data.ReadParcelable(); + sptr callerToken = data.ReadRemoteObject(); if (callerToken == nullptr) { - HILOG_ERROR("%{public}s, failed to ReadParcelable", __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 callerToken = data.ReadParcelable(); + sptr callerToken = data.ReadRemoteObject(); if (callerToken == nullptr) { - HILOG_ERROR("%{public}s, failed to ReadParcelable", __func__); + HILOG_ERROR("%{public}s, failed to get remote object.", __func__); return ERR_APPEXECFWK_PARCEL_ERROR; } int32_t result = AcquireFormState(*want, callerToken, stateInfo); diff --git a/interfaces/innerkits/form_manager/src/form_provider_proxy.cpp b/interfaces/innerkits/form_manager/src/form_provider_proxy.cpp index 24e0c0c35f..2811361c81 100644 --- a/interfaces/innerkits/form_manager/src/form_provider_proxy.cpp +++ b/interfaces/innerkits/form_manager/src/form_provider_proxy.cpp @@ -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 &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; } diff --git a/interfaces/innerkits/form_manager/src/form_provider_stub.cpp b/interfaces/innerkits/form_manager/src/form_provider_stub.cpp index 0a5f5c2456..d801cd94d3 100644 --- a/interfaces/innerkits/form_manager/src/form_provider_stub.cpp +++ b/interfaces/innerkits/form_manager/src/form_provider_stub.cpp @@ -89,9 +89,9 @@ int FormProviderStub::HandleAcquireProviderFormInfo(MessageParcel &data, Message return ERR_APPEXECFWK_PARCEL_ERROR; } - sptr client = data.ReadParcelable(); + sptr client = data.ReadRemoteObject(); if (client == nullptr) { - HILOG_ERROR("%{public}s, failed to ReadParcelable", __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 client = data.ReadParcelable(); + sptr client = data.ReadRemoteObject(); if (client == nullptr) { - HILOG_ERROR("%{public}s, failed to ReadParcelable", __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 client = data.ReadParcelable(); + sptr client = data.ReadRemoteObject(); if (client == nullptr) { - HILOG_ERROR("%{public}s, failed to ReadParcelable", __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 client = data.ReadParcelable(); + sptr client = data.ReadRemoteObject(); if (client == nullptr) { - HILOG_ERROR("%{public}s, failed to ReadParcelable", __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 client = data.ReadParcelable(); + sptr client = data.ReadRemoteObject(); if (client == nullptr) { - HILOG_ERROR("%{public}s, failed to ReadParcelable", __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 client = data.ReadParcelable(); + sptr client = data.ReadRemoteObject(); if (client == nullptr) { - HILOG_ERROR("%{public}s, failed to ReadParcelable", __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(data.ReadParcelable()); if (!want) { - HILOG_ERROR("%{public}s fail, ReadParcelable failed", __func__); + HILOG_ERROR("%{public}s, failed to get want.", __func__); return ERR_APPEXECFWK_PARCEL_ERROR; } - sptr client = data.ReadParcelable(); + sptr client = data.ReadRemoteObject(); if (client == nullptr) { - HILOG_ERROR("%{public}s, failed to ReadParcelable", __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 failed", __func__); return ERR_APPEXECFWK_PARCEL_ERROR; } - sptr client = data.ReadParcelable(); + sptr client = data.ReadRemoteObject(); if (client == nullptr) { - HILOG_ERROR("%{public}s, failed to ReadParcelable", __func__); + HILOG_ERROR("%{public}s, failed to get remote object.", __func__); return ERR_APPEXECFWK_PARCEL_ERROR; } int32_t result = AcquireState(*wantArg, *want, client); diff --git a/interfaces/innerkits/form_manager/src/provider_connect_proxy.cpp b/interfaces/innerkits/form_manager/src/provider_connect_proxy.cpp index 8bacde4f6b..95d5a4bccf 100644 --- a/interfaces/innerkits/form_manager/src/provider_connect_proxy.cpp +++ b/interfaces/innerkits/form_manager/src/provider_connect_proxy.cpp @@ -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)) { diff --git a/interfaces/innerkits/form_manager/src/provider_connect_stub.cpp b/interfaces/innerkits/form_manager/src/provider_connect_stub.cpp index 16e42a278c..5282424260 100644 --- a/interfaces/innerkits/form_manager/src/provider_connect_stub.cpp +++ b/interfaces/innerkits/form_manager/src/provider_connect_stub.cpp @@ -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 remoteObject = nullptr; + if (data.ReadBool()) { + remoteObject = data.ReadRemoteObject(); + } auto resultCode = data.ReadInt32(); OnAbilityConnectDone(*element, remoteObject, resultCode); delete element; diff --git a/services/abilitymgr/src/ability_scheduler_proxy.cpp b/services/abilitymgr/src/ability_scheduler_proxy.cpp index 6f83c66782..ef750dfeeb 100644 --- a/services/abilitymgr/src/ability_scheduler_proxy.cpp +++ b/services/abilitymgr/src/ability_scheduler_proxy.cpp @@ -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; } diff --git a/services/abilitymgr/src/ability_scheduler_stub.cpp b/services/abilitymgr/src/ability_scheduler_stub.cpp index 2ba752daec..7248c39e2d 100644 --- a/services/abilitymgr/src/ability_scheduler_stub.cpp +++ b/services/abilitymgr/src/ability_scheduler_stub.cpp @@ -445,7 +445,7 @@ int AbilitySchedulerStub::RegisterObserverInner(MessageParcel &data, MessageParc HILOG_ERROR("AbilitySchedulerStub uri is nullptr"); return ERR_INVALID_VALUE; } - auto obServer = iface_cast(data.ReadParcelable()); + auto obServer = iface_cast(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(data.ReadParcelable()); + auto obServer = iface_cast(data.ReadRemoteObject()); if (obServer == nullptr) { HILOG_ERROR("AbilitySchedulerStub obServer is nullptr"); return ERR_INVALID_VALUE; diff --git a/services/dataobsmgr/src/dataobs_mgr_proxy.cpp b/services/dataobsmgr/src/dataobs_mgr_proxy.cpp index 3fec040235..d634f2bd84 100644 --- a/services/dataobsmgr/src/dataobs_mgr_proxy.cpp +++ b/services/dataobsmgr/src/dataobs_mgr_proxy.cpp @@ -53,7 +53,7 @@ int DataObsManagerProxy::RegisterObserver(const Uri &uri, const sptrAsObject())) { + 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 sptrAsObject())) { + if (!data.WriteRemoteObject(dataObserver->AsObject())) { HILOG_ERROR("unregister observer fail, dataObserver error"); return ERR_INVALID_VALUE; } diff --git a/services/dataobsmgr/src/dataobs_mgr_stub.cpp b/services/dataobsmgr/src/dataobs_mgr_stub.cpp index 3c1e8ba343..e5f6b8d197 100644 --- a/services/dataobsmgr/src/dataobs_mgr_stub.cpp +++ b/services/dataobsmgr/src/dataobs_mgr_stub.cpp @@ -66,7 +66,7 @@ int DataObsManagerStub::RegisterObserverInner(MessageParcel &data, MessageParcel return ERR_INVALID_VALUE; } - auto observer = iface_cast(data.ReadParcelable()); + auto observer = iface_cast(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(data.ReadParcelable()); + auto observer = iface_cast(data.ReadRemoteObject()); int32_t result = UnregisterObserver(*uri, observer); reply.WriteInt32(result); if (uri != nullptr) { diff --git a/services/formmgr/test/unittest/fms_form_info_mgr_test/fms_form_info_mgr_test.cpp b/services/formmgr/test/unittest/fms_form_info_mgr_test/fms_form_info_mgr_test.cpp index 3d28488cb5..93cd81605c 100644 --- a/services/formmgr/test/unittest/fms_form_info_mgr_test/fms_form_info_mgr_test.cpp +++ b/services/formmgr/test/unittest/fms_form_info_mgr_test/fms_form_info_mgr_test.cpp @@ -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 mustPropKeys = { ExtensionFormProfileReader::NAME, - ExtensionFormProfileReader::FORM_CONFIG_ABILITY, ExtensionFormProfileReader::IS_DEFAULT, ExtensionFormProfileReader::UPDATE_ENABLED, ExtensionFormProfileReader::DEFAULT_DIMENSION,