summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2023-06-02 20:49:46 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2023-06-02 20:49:46 +0000
commitcda0139fe8540b3b05af8800d2ae07a92cdd04da (patch)
treee44f9937727e075bdf53bb3521d9e27c0ee558c0
parent0e23a455abdc9262f20a42cc25e36208e57c637b (diff)
parent34fd5b1fa5d6ca284d09cb8d3021fb9254477cc0 (diff)
Merge "RPC binder: limit experimental wire protocol usage" am: 38b89eaed9 am: 70a999bfe4 am: 61025d85fd am: 9542b6765b am: 34fd5b1fa5
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/2610070 Change-Id: I5e07935c62a47e08587692b0f353ad27a6565d54 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--libs/binder/RpcState.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/libs/binder/RpcState.cpp b/libs/binder/RpcState.cpp
index ff35f5f35c..5c1b2305a6 100644
--- a/libs/binder/RpcState.cpp
+++ b/libs/binder/RpcState.cpp
@@ -34,6 +34,10 @@
#include <inttypes.h>
+#ifdef __ANDROID__
+#include <cutils/properties.h>
+#endif
+
namespace android {
using base::StringPrintf;
@@ -399,14 +403,27 @@ status_t RpcState::rpcRec(
}
bool RpcState::validateProtocolVersion(uint32_t version) {
- if (version >= RPC_WIRE_PROTOCOL_VERSION_NEXT &&
- version != RPC_WIRE_PROTOCOL_VERSION_EXPERIMENTAL) {
+ if (version == RPC_WIRE_PROTOCOL_VERSION_EXPERIMENTAL) {
+#if defined(__ANDROID__)
+ char codename[PROPERTY_VALUE_MAX];
+ property_get("ro.build.version.codename", codename, "");
+ if (!strcmp(codename, "REL")) {
+ ALOGE("Cannot use experimental RPC binder protocol on a release branch.");
+ return false;
+ }
+#else
+ // don't restrict on other platforms, though experimental should
+ // only really be used for testing, we don't have a good way to see
+ // what is shipping outside of Android
+#endif
+ } else if (version >= RPC_WIRE_PROTOCOL_VERSION_NEXT) {
ALOGE("Cannot use RPC binder protocol version %u which is unknown (current protocol "
"version "
"is %u).",
version, RPC_WIRE_PROTOCOL_VERSION);
return false;
}
+
return true;
}