From 2a129c2f17fca58ce18e6e391cd7c59aab312f0e Mon Sep 17 00:00:00 2001 From: liangZ15 Date: Wed, 16 Mar 2022 22:55:02 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20ee3fd3c=20from=20https://gitee.com/lian?= =?UTF-8?q?gZ15/update=5Fupdateservice=5F1/pulls/68=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E4=B8=AD=E7=BB=A7=E6=94=BB=E5=87=BB=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liangZ15 --- callback/src/update_callback_proxy.cpp | 15 +++++ callback/src/update_callback_stub.cpp | 4 ++ engine/src/update_service_stub.cpp | 4 ++ .../innerkits/engine/update_service_proxy.cpp | 60 +++++++++++++++++++ 4 files changed, 83 insertions(+) diff --git a/callback/src/update_callback_proxy.cpp b/callback/src/update_callback_proxy.cpp index 9fd6f015..e165c12c 100755 --- a/callback/src/update_callback_proxy.cpp +++ b/callback/src/update_callback_proxy.cpp @@ -26,6 +26,11 @@ void UpdateCallbackProxy::OnCheckVersionDone(const VersionInfo &info) MessageParcel reply; MessageOption option { MessageOption::TF_SYNC }; + if (!data.WriteInterfaceToken(GetDescriptor())) { + ENGINE_LOGI("UpdateCallbackProxy WriteInterfaceToken fail"); + return; + } + auto remote = Remote(); ENGINE_CHECK(remote != nullptr, return, "Can not get remote"); @@ -44,6 +49,11 @@ void UpdateCallbackProxy::OnDownloadProgress(const Progress &progress) MessageParcel reply; MessageOption option { MessageOption::TF_SYNC }; + if (!data.WriteInterfaceToken(GetDescriptor())) { + ENGINE_LOGI("UpdateCallbackProxy WriteInterfaceToken fail"); + return; + } + auto remote = Remote(); ENGINE_CHECK(remote != nullptr, return, "Can not get remote"); @@ -62,6 +72,11 @@ void UpdateCallbackProxy::OnUpgradeProgress(const Progress &progress) MessageParcel reply; MessageOption option { MessageOption::TF_SYNC }; + if (!data.WriteInterfaceToken(GetDescriptor())) { + ENGINE_LOGI("UpdateCallbackProxy WriteInterfaceToken fail"); + return; + } + auto remote = Remote(); ENGINE_CHECK(remote != nullptr, return, "Can not get remote"); diff --git a/callback/src/update_callback_stub.cpp b/callback/src/update_callback_stub.cpp index 844e7df9..238544db 100644 --- a/callback/src/update_callback_stub.cpp +++ b/callback/src/update_callback_stub.cpp @@ -24,6 +24,10 @@ namespace update_engine { int32_t UpdateCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { + if (data.ReadInterfaceToken() != GetDescriptor()) { + ENGINE_LOGI("UpdateCallbackStub ReadInterfaceToken fail"); + return -1; + } switch (code) { case CHECK_VERSION: { VersionInfo info; diff --git a/engine/src/update_service_stub.cpp b/engine/src/update_service_stub.cpp index 6dd27693..f170a2f9 100755 --- a/engine/src/update_service_stub.cpp +++ b/engine/src/update_service_stub.cpp @@ -149,6 +149,10 @@ static int32_t RebootAndInstallStub(UpdateServiceStub::UpdateServiceStubPtr serv int32_t UpdateServiceStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption &option) { + if (data.ReadInterfaceToken() != GetDescriptor()) { + ENGINE_LOGI("UpdateServiceStub ReadInterfaceToken fail"); + return -1; + } static std::map requestFuncMap = { {IUpdateService::CHECK_VERSION, CheckNewVersionStub}, {IUpdateService::DOWNLOAD, DownloadVersionStub}, diff --git a/interfaces/innerkits/engine/update_service_proxy.cpp b/interfaces/innerkits/engine/update_service_proxy.cpp index 392a1725..2dca0086 100755 --- a/interfaces/innerkits/engine/update_service_proxy.cpp +++ b/interfaces/innerkits/engine/update_service_proxy.cpp @@ -29,6 +29,12 @@ int32_t UpdateServiceProxy::RegisterUpdateCallback(const UpdateContext &ctx, ENGINE_CHECK(remote != nullptr, return ERR_FLATTEN_OBJECT, "Can not get remote"); MessageParcel data; + + if (!data.WriteInterfaceToken(GetDescriptor())) { + ENGINE_LOGI("UpdateServiceProxy WriteInterfaceToken fail"); + return -1; + } + UpdateHelper::WriteUpdateContext(data, ctx); bool ret = data.WriteRemoteObject(updateCallback->AsObject()); ENGINE_CHECK(ret, return ERR_FLATTEN_OBJECT, "Can not get remote"); @@ -45,6 +51,11 @@ int32_t UpdateServiceProxy::UnregisterUpdateCallback() ENGINE_CHECK(remote != nullptr, return ERR_FLATTEN_OBJECT, "Can not get remote"); MessageParcel data; + + if (!data.WriteInterfaceToken(GetDescriptor())) { + ENGINE_LOGI("UpdateServiceProxy WriteInterfaceToken fail"); + return -1; + } MessageParcel reply; MessageOption option { MessageOption::TF_SYNC }; int32_t res = remote->SendRequest(UNREGISTER_CALLBACK, data, reply, option); @@ -59,6 +70,11 @@ int32_t UpdateServiceProxy::CheckNewVersion() ENGINE_CHECK(remote != nullptr, return ERR_FLATTEN_OBJECT, "Can not get remote"); MessageParcel data; + + if (!data.WriteInterfaceToken(GetDescriptor())) { + ENGINE_LOGI("UpdateServiceProxy WriteInterfaceToken fail"); + return -1; + } MessageParcel reply; MessageOption option(MessageOption::TF_SYNC); int32_t res = remote->SendRequest(CHECK_VERSION, data, reply, option); @@ -74,6 +90,11 @@ int32_t UpdateServiceProxy::DownloadVersion() // Construct a data sending message to the stub. MessageParcel data; + + if (!data.WriteInterfaceToken(GetDescriptor())) { + ENGINE_LOGI("UpdateServiceProxy WriteInterfaceToken fail"); + return -1; + } MessageParcel reply; MessageOption option(MessageOption::TF_ASYNC); int32_t ret = remote->SendRequest(DOWNLOAD, data, reply, option); @@ -89,6 +110,11 @@ int32_t UpdateServiceProxy::DoUpdate() // Construct a data sending message to the stub. MessageParcel data; + + if (!data.WriteInterfaceToken(GetDescriptor())) { + ENGINE_LOGI("UpdateServiceProxy WriteInterfaceToken fail"); + return -1; + } MessageParcel reply; MessageOption option(MessageOption::TF_ASYNC); int32_t ret = remote->SendRequest(UPGRADE, data, reply, option); @@ -103,6 +129,11 @@ int32_t UpdateServiceProxy::GetNewVersion(VersionInfo &versionInfo) ENGINE_CHECK(remote != nullptr, return ERR_FLATTEN_OBJECT, "Can not get remote"); MessageParcel data; + + if (!data.WriteInterfaceToken(GetDescriptor())) { + ENGINE_LOGI("UpdateServiceProxy WriteInterfaceToken fail"); + return -1; + } MessageParcel reply; MessageOption option; int32_t ret = remote->SendRequest(GET_NEW_VERSION, data, reply, option); @@ -118,6 +149,10 @@ int32_t UpdateServiceProxy::GetUpgradeStatus(UpgradeInfo &info) ENGINE_CHECK(remote != nullptr, return ERR_FLATTEN_OBJECT, "Can not get remote"); MessageParcel data; + + if (!data.WriteInterfaceToken(GetDescriptor())) { + return -1; + } MessageParcel reply; MessageOption option; int32_t ret = remote->SendRequest(GET_STATUS, data, reply, option); @@ -133,6 +168,11 @@ int32_t UpdateServiceProxy::SetUpdatePolicy(const UpdatePolicy &policy) ENGINE_CHECK(remote != nullptr, return ERR_FLATTEN_OBJECT, "Can not get remote"); MessageParcel data; + + if (!data.WriteInterfaceToken(GetDescriptor())) { + ENGINE_LOGI("UpdateServiceProxy WriteInterfaceToken fail"); + return -1; + } UpdateHelper::WriteUpdatePolicy(data, policy); MessageParcel reply; MessageOption option; @@ -152,6 +192,11 @@ int32_t UpdateServiceProxy::GetUpdatePolicy(UpdatePolicy &policy) ENGINE_CHECK(remote != nullptr, return ERR_FLATTEN_OBJECT, "Can not get remote"); MessageParcel data; + + if (!data.WriteInterfaceToken(GetDescriptor())) { + ENGINE_LOGI("UpdateServiceProxy WriteInterfaceToken fail"); + return -1; + } MessageParcel reply; MessageOption option; int32_t ret = remote->SendRequest(GET_POLICY, data, reply, option); @@ -166,6 +211,11 @@ int32_t UpdateServiceProxy::Cancel(int32_t service) ENGINE_CHECK(remote != nullptr, return ERR_FLATTEN_OBJECT, "Can not get remote"); MessageParcel data; + + if (!data.WriteInterfaceToken(GetDescriptor())) { + ENGINE_LOGI("UpdateServiceProxy WriteInterfaceToken fail"); + return -1; + } data.WriteInt32(static_cast(service)); MessageParcel reply; MessageOption option; @@ -185,6 +235,11 @@ int32_t UpdateServiceProxy::RebootAndClean(const std::string &miscFile, const st ENGINE_CHECK(remote != nullptr, return ERR_FLATTEN_OBJECT, "Can not get remote"); MessageParcel data; + + if (!data.WriteInterfaceToken(GetDescriptor())) { + ENGINE_LOGI("UpdateServiceProxy WriteInterfaceToken fail"); + return -1; + } data.WriteString16(Str8ToStr16(miscFile)); data.WriteString16(Str8ToStr16(cmd)); MessageParcel reply; @@ -204,6 +259,11 @@ int32_t UpdateServiceProxy::RebootAndInstall(const std::string &miscFile, const ENGINE_CHECK(remote != nullptr, return ERR_FLATTEN_OBJECT, "Can not get remote"); MessageParcel data; + + if (!data.WriteInterfaceToken(GetDescriptor())) { + ENGINE_LOGI("UpdateServiceProxy WriteInterfaceToken fail"); + return -1; + } data.WriteString16(Str8ToStr16(miscFile)); data.WriteString16(Str8ToStr16(packageName)); MessageParcel reply; -- Gitee