diff --git a/callback/src/update_callback_proxy.cpp b/callback/src/update_callback_proxy.cpp index 9fd6f015a31696405ebcf9ea25bf14718e2b9026..e165c12c49b1542b6c5dde283d60c5003a623f3d 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 844e7df953c3503a78c3e7512af6487ed0654507..238544dbb5514a50e43673442d99e9cbee4e3470 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 6dd276937851d93178b394504f97d38e1c0d72ec..f170a2f984a9ea499741b553e94a677df39c1657 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 392a172580d7c68a938f78e50ec6134b4b8a58b6..2dca0086396523be5c7c44c486afb4799019bbdd 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;