summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Moreland <smoreland@google.com>2020-10-01 18:02:48 +0000
committeralk3pInjection <webmaster@raspii.tech>2021-09-27 21:17:05 +0800
commiteee61c68ef34b935adb1b1af6d1ab94b2195ee91 (patch)
tree09f7c6fe58e36e6eabff0d6017c53ec1b4cccd07
parent16f3ec7685ff1a8f146017bc1c83820d66095fcb (diff)
[master] libbinder: writeInterfaceToken char16_t* variant
This avoids the extra allocation when we don't already have a String16 created (specifically for Java). Bug: 169674485 Test: atest aidl_integration_test Change-Id: I3a6344bfdc8010f07812d7d8efbbdfd2a32c7a5e
-rw-r--r--libs/binder/Parcel.cpp7
-rw-r--r--libs/binder/include/binder/Parcel.h1
2 files changed, 7 insertions, 1 deletions
diff --git a/libs/binder/Parcel.cpp b/libs/binder/Parcel.cpp
index 64a4f9bf6d..5a802a92a4 100644
--- a/libs/binder/Parcel.cpp
+++ b/libs/binder/Parcel.cpp
@@ -528,14 +528,19 @@ constexpr int32_t kHeader = B_PACK_CHARS('S', 'Y', 'S', 'T');
// Write RPC headers. (previously just the interface token)
status_t Parcel::writeInterfaceToken(const String16& interface)
{
+ return writeInterfaceToken(interface.string(), interface.size());
+}
+
+status_t Parcel::writeInterfaceToken(const char16_t* str, size_t len) {
const IPCThreadState* threadState = IPCThreadState::self();
writeInt32(threadState->getStrictModePolicy() | STRICT_MODE_PENALTY_GATHER);
updateWorkSourceRequestHeaderPosition();
writeInt32(threadState->shouldPropagateWorkSource() ?
threadState->getCallingWorkSourceUid() : IPCThreadState::kUnsetWorkSource);
writeInt32(kHeader);
+
// currently the interface identification token is just its name as a string
- return writeString16(interface);
+ return writeString16(str, len);
}
bool Parcel::replaceCallingWorkSourceUid(uid_t uid)
diff --git a/libs/binder/include/binder/Parcel.h b/libs/binder/include/binder/Parcel.h
index c1f64fb541..cca057c104 100644
--- a/libs/binder/include/binder/Parcel.h
+++ b/libs/binder/include/binder/Parcel.h
@@ -86,6 +86,7 @@ public:
// Writes the RPC header.
status_t writeInterfaceToken(const String16& interface);
+ status_t writeInterfaceToken(const char16_t* str, size_t len);
// Parses the RPC header, returning true if the interface name
// in the header matches the expected interface from the caller.