Avoid allocation on Java Binder fast path

We recently added a new API to the native Parcel class that avoids a
string allocation in enforceInterface.  Have the Java JNI glue for
Parcel use this new interface.

Test: builds
Change-Id: I50b29ef95e214812c5fa83514497e0a188a635aa
This commit is contained in:
Daniel Colascione
2020-02-24 03:18:55 -08:00
parent 59d40857ad
commit bcd771bd08

View File

@@ -625,8 +625,8 @@ static void android_os_Parcel_enforceInterface(JNIEnv* env, jclass clazz, jlong
IPCThreadState* threadState = IPCThreadState::self();
const int32_t oldPolicy = threadState->getStrictModePolicy();
const bool isValid = parcel->enforceInterface(
String16(reinterpret_cast<const char16_t*>(str),
env->GetStringLength(name)),
reinterpret_cast<const char16_t*>(str),
env->GetStringLength(name),
threadState);
env->ReleaseStringCritical(name, str);
if (isValid) {