Merge changes Ie8fe724d,Ifd42f31d
* changes:
SF: clean up casting around histogram reporting
binder: add read/writeUint64Vector functions
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index ab94719..d285030 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -878,6 +878,16 @@
return writeNullableTypedVector(val, &Parcel::writeInt64);
}
+status_t Parcel::writeUint64Vector(const std::vector<uint64_t>& val)
+{
+ return writeTypedVector(val, &Parcel::writeUint64);
+}
+
+status_t Parcel::writeUint64Vector(const std::unique_ptr<std::vector<uint64_t>>& val)
+{
+ return writeNullableTypedVector(val, &Parcel::writeUint64);
+}
+
status_t Parcel::writeFloatVector(const std::vector<float>& val)
{
return writeTypedVector(val, &Parcel::writeFloat);
@@ -1739,6 +1749,14 @@
return readTypedVector(val, &Parcel::readInt64);
}
+status_t Parcel::readUint64Vector(std::unique_ptr<std::vector<uint64_t>>* val) const {
+ return readNullableTypedVector(val, &Parcel::readUint64);
+}
+
+status_t Parcel::readUint64Vector(std::vector<uint64_t>* val) const {
+ return readTypedVector(val, &Parcel::readUint64);
+}
+
status_t Parcel::readFloatVector(std::unique_ptr<std::vector<float>>* val) const {
return readNullableTypedVector(val, &Parcel::readFloat);
}
diff --git a/libs/binder/include/binder/Parcel.h b/libs/binder/include/binder/Parcel.h
index c9c273a..cd151ee 100644
--- a/libs/binder/include/binder/Parcel.h
+++ b/libs/binder/include/binder/Parcel.h
@@ -139,6 +139,8 @@
status_t writeInt32Vector(const std::vector<int32_t>& val);
status_t writeInt64Vector(const std::unique_ptr<std::vector<int64_t>>& val);
status_t writeInt64Vector(const std::vector<int64_t>& val);
+ status_t writeUint64Vector(const std::unique_ptr<std::vector<uint64_t>>& val);
+ status_t writeUint64Vector(const std::vector<uint64_t>& val);
status_t writeFloatVector(const std::unique_ptr<std::vector<float>>& val);
status_t writeFloatVector(const std::vector<float>& val);
status_t writeDoubleVector(const std::unique_ptr<std::vector<double>>& val);
@@ -313,6 +315,8 @@
status_t readInt32Vector(std::vector<int32_t>* val) const;
status_t readInt64Vector(std::unique_ptr<std::vector<int64_t>>* val) const;
status_t readInt64Vector(std::vector<int64_t>* val) const;
+ status_t readUint64Vector(std::unique_ptr<std::vector<uint64_t>>* val) const;
+ status_t readUint64Vector(std::vector<uint64_t>* val) const;
status_t readFloatVector(std::unique_ptr<std::vector<float>>* val) const;
status_t readFloatVector(std::vector<float>* val) const;
status_t readDoubleVector(std::unique_ptr<std::vector<double>>* val) const;
diff --git a/libs/binder/tests/binderLibTest.cpp b/libs/binder/tests/binderLibTest.cpp
index cd37d49..f23ed5d 100644
--- a/libs/binder/tests/binderLibTest.cpp
+++ b/libs/binder/tests/binderLibTest.cpp
@@ -72,6 +72,7 @@
BINDER_LIB_TEST_GET_PTR_SIZE_TRANSACTION,
BINDER_LIB_TEST_CREATE_BINDER_TRANSACTION,
BINDER_LIB_TEST_GET_WORK_SOURCE_TRANSACTION,
+ BINDER_LIB_TEST_ECHO_VECTOR,
};
pid_t start_server_process(int arg2, bool usePoll = false)
@@ -1060,6 +1061,21 @@
EXPECT_EQ(NO_ERROR, ret2);
}
+TEST_F(BinderLibTest, VectorSent) {
+ Parcel data, reply;
+ sp<IBinder> server = addServer();
+ ASSERT_TRUE(server != nullptr);
+
+ std::vector<uint64_t> const testValue = { std::numeric_limits<uint64_t>::max(), 0, 200 };
+ data.writeUint64Vector(testValue);
+
+ status_t ret = server->transact(BINDER_LIB_TEST_ECHO_VECTOR, data, &reply);
+ EXPECT_EQ(NO_ERROR, ret);
+ std::vector<uint64_t> readValue;
+ ret = reply.readUint64Vector(&readValue);
+ EXPECT_EQ(readValue, testValue);
+}
+
class BinderLibTestService : public BBinder
{
public:
@@ -1363,6 +1379,14 @@
reply->writeInt32(IPCThreadState::self()->getCallingWorkSourceUid());
return NO_ERROR;
}
+ case BINDER_LIB_TEST_ECHO_VECTOR: {
+ std::vector<uint64_t> vector;
+ auto err = data.readUint64Vector(&vector);
+ if (err != NO_ERROR)
+ return err;
+ reply->writeUint64Vector(vector);
+ return NO_ERROR;
+ }
default:
return UNKNOWN_TRANSACTION;
};
diff --git a/libs/gui/ISurfaceComposer.cpp b/libs/gui/ISurfaceComposer.cpp
index bd943c1..2d6be26 100644
--- a/libs/gui/ISurfaceComposer.cpp
+++ b/libs/gui/ISurfaceComposer.cpp
@@ -675,23 +675,19 @@
return result;
}
- result = reply.readInt64Vector(
- reinterpret_cast<std::vector<int64_t>*>(&outStats->component_0_sample));
+ result = reply.readUint64Vector(&outStats->component_0_sample);
if (result != NO_ERROR) {
return result;
}
- result = reply.readInt64Vector(
- reinterpret_cast<std::vector<int64_t>*>(&outStats->component_1_sample));
+ result = reply.readUint64Vector(&outStats->component_1_sample);
if (result != NO_ERROR) {
return result;
}
- result = reply.readInt64Vector(
- reinterpret_cast<std::vector<int64_t>*>(&outStats->component_2_sample));
+ result = reply.readUint64Vector(&outStats->component_2_sample);
if (result != NO_ERROR) {
return result;
}
- result = reply.readInt64Vector(
- reinterpret_cast<std::vector<int64_t>*>(&outStats->component_3_sample));
+ result = reply.readUint64Vector(&outStats->component_3_sample);
return result;
}
};
@@ -1121,14 +1117,10 @@
result = getDisplayedContentSample(display, maxFrames, timestamp, &stats);
if (result == NO_ERROR) {
reply->writeUint64(stats.numFrames);
- reply->writeInt64Vector(
- *reinterpret_cast<std::vector<int64_t>*>(&stats.component_0_sample));
- reply->writeInt64Vector(
- *reinterpret_cast<std::vector<int64_t>*>(&stats.component_1_sample));
- reply->writeInt64Vector(
- *reinterpret_cast<std::vector<int64_t>*>(&stats.component_2_sample));
- reply->writeInt64Vector(
- *reinterpret_cast<std::vector<int64_t>*>(&stats.component_3_sample));
+ reply->writeUint64Vector(stats.component_0_sample);
+ reply->writeUint64Vector(stats.component_1_sample);
+ reply->writeUint64Vector(stats.component_2_sample);
+ reply->writeUint64Vector(stats.component_3_sample);
}
return result;
}