diff --git a/interfaces/innerkits/src/bundle_active_proxy.cpp b/interfaces/innerkits/src/bundle_active_proxy.cpp index d441f4ff74024cb487bf0b3109ed999b41971223..068794f08f8d3a55148f756c3c173d4647faba60 100644 --- a/interfaces/innerkits/src/bundle_active_proxy.cpp +++ b/interfaces/innerkits/src/bundle_active_proxy.cpp @@ -25,6 +25,9 @@ int BundleActiveProxy::ReportEvent(std::string& bundleName, std::string& ability MessageParcel data; MessageParcel reply; MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + return -1; + } data.WriteString(bundleName); data.WriteString(abilityName); data.WriteString(abilityId); @@ -42,6 +45,9 @@ bool BundleActiveProxy::IsBundleIdle(const std::string& bundleName) MessageParcel data; MessageParcel reply; MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + return false; + } data.WriteString(bundleName); Remote() -> SendRequest(IS_BUNDLE_IDLE, data, reply, option); int32_t result = reply.ReadInt32(); @@ -55,12 +61,15 @@ std::vector BundleActiveProxy::QueryPackageStats(const MessageParcel data; MessageParcel reply; MessageOption option; + std::vector result; + if (!data.WriteInterfaceToken(GetDescriptor())) { + return result; + } data.WriteInt32(intervalType); data.WriteInt64(beginTime); data.WriteInt64(endTime); Remote() -> SendRequest(QUERY_USAGE_STATS, data, reply, option); int32_t size = reply.ReadInt32(); - std::vector result; std::shared_ptr tmp; for (int i = 0; i < size; i++) { tmp = tmp->Unmarshalling(reply); @@ -84,11 +93,14 @@ std::vector BundleActiveProxy::QueryEvents(const int64_t begi MessageParcel data; MessageParcel reply; MessageOption option; + std::vector result; + if (!data.WriteInterfaceToken(GetDescriptor())) { + return result; + } data.WriteInt64(beginTime); data.WriteInt64(endTime); Remote() -> SendRequest(QUERY_EVENTS, data, reply, option); int32_t size = reply.ReadInt32(); - std::vector result; std::shared_ptr tmp; for (int i = 0; i < size; i++) { tmp = tmp->Unmarshalling(reply); @@ -109,6 +121,9 @@ void BundleActiveProxy::SetBundleGroup(const std::string& bundleName, int newGro MessageParcel data; MessageParcel reply; MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + return; + } data.WriteString(bundleName); data.WriteInt32(newGroup); data.WriteInt32(userId); @@ -121,12 +136,15 @@ std::vector BundleActiveProxy::QueryCurrentPackageStat MessageParcel data; MessageParcel reply; MessageOption option; + std::vector result; + if (!data.WriteInterfaceToken(GetDescriptor())) { + return result; + } data.WriteInt32(intervalType); data.WriteInt64(beginTime); data.WriteInt64(endTime); Remote() -> SendRequest(QUERY_CURRENT_USAGE_STATS, data, reply, option); int32_t size = reply.ReadInt32(); - std::vector result; std::shared_ptr tmp; for (int i = 0; i < size; i++) { tmp = tmp->Unmarshalling(reply); @@ -150,11 +168,14 @@ std::vector BundleActiveProxy::QueryCurrentEvents(const int64 MessageParcel data; MessageParcel reply; MessageOption option; + std::vector result; + if (!data.WriteInterfaceToken(GetDescriptor())) { + return result; + } data.WriteInt64(beginTime); data.WriteInt64(endTime); Remote() -> SendRequest(QUERY_CURRENT_EVENTS, data, reply, option); int32_t size = reply.ReadInt32(); - std::vector result; std::shared_ptr tmp; for (int i = 0; i < size; i++) { tmp = tmp->Unmarshalling(reply); @@ -175,6 +196,9 @@ int BundleActiveProxy::QueryPackageGroup() MessageParcel data; MessageParcel reply; MessageOption option; + if (!data.WriteInterfaceToken(GetDescriptor())) { + return -1; + } Remote() -> SendRequest(QUERY_BUNDLE_GROUP, data, reply, option); int32_t packageGroup = reply.ReadInt32(); BUNDLE_ACTIVE_LOGI("BundleActiveProxy::QueryPackageGroup result is %{public}d", packageGroup); diff --git a/services/common/src/bundle_active_stub.cpp b/services/common/src/bundle_active_stub.cpp index d254db2d8b9decd99ae5e4f7adce13b81a677e4d..99beeea269752e3665563d37f46b87acfcf356ee 100644 --- a/services/common/src/bundle_active_stub.cpp +++ b/services/common/src/bundle_active_stub.cpp @@ -22,6 +22,9 @@ namespace DeviceUsageStats { int32_t BundleActiveStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel &reply, MessageOption &option) { + if (data.ReadInterfaceToken() != GetDescriptor()) { + return -1; + } switch (code) { case REPORT_EVENT: { std::string bundleName = data.ReadString();