Parcel: lift 'isForRpc' here from native
Platform API, in order to fix bugs like b/254835230 where certain utilities call getCallingUid, which doesn't make sense for RPC calls. Bug: 254835230 Test: android.os.ParcelTest Change-Id: If2dd13d8edd515c945ccde2a2554f6f2b7b87b26
This commit is contained in:
@@ -368,6 +368,8 @@ public final class Parcel {
|
||||
@FastNative
|
||||
private static native void nativeMarkForBinder(long nativePtr, IBinder binder);
|
||||
@CriticalNative
|
||||
private static native boolean nativeIsForRpc(long nativePtr);
|
||||
@CriticalNative
|
||||
private static native int nativeDataSize(long nativePtr);
|
||||
@CriticalNative
|
||||
private static native int nativeDataAvail(long nativePtr);
|
||||
@@ -645,6 +647,15 @@ public final class Parcel {
|
||||
nativeMarkForBinder(mNativePtr, binder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this Parcel is written for an RPC transaction.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public final boolean isForRpc() {
|
||||
return nativeIsForRpc(mNativePtr);
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@ParcelFlags
|
||||
@TestApi
|
||||
|
||||
@@ -116,6 +116,11 @@ static void android_os_Parcel_markForBinder(JNIEnv* env, jclass clazz, jlong nat
|
||||
}
|
||||
}
|
||||
|
||||
static jboolean android_os_Parcel_isForRpc(jlong nativePtr) {
|
||||
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
|
||||
return parcel ? parcel->isForRpc() : false;
|
||||
}
|
||||
|
||||
static jint android_os_Parcel_dataSize(jlong nativePtr)
|
||||
{
|
||||
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
|
||||
@@ -808,6 +813,8 @@ static const JNINativeMethod gParcelMethods[] = {
|
||||
// @FastNative
|
||||
{"nativeMarkForBinder", "(JLandroid/os/IBinder;)V", (void*)android_os_Parcel_markForBinder},
|
||||
// @CriticalNative
|
||||
{"nativeIsForRpc", "(J)Z", (void*)android_os_Parcel_isForRpc},
|
||||
// @CriticalNative
|
||||
{"nativeDataSize", "(J)I", (void*)android_os_Parcel_dataSize},
|
||||
// @CriticalNative
|
||||
{"nativeDataAvail", "(J)I", (void*)android_os_Parcel_dataAvail},
|
||||
|
||||
@@ -36,6 +36,13 @@ public class ParcelTest {
|
||||
private static final String INTERFACE_TOKEN_1 = "IBinder interface token";
|
||||
private static final String INTERFACE_TOKEN_2 = "Another IBinder interface token";
|
||||
|
||||
@Test
|
||||
public void testIsForRpc() {
|
||||
Parcel p = Parcel.obtain();
|
||||
assertEquals(false, p.isForRpc());
|
||||
p.recycle();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCallingWorkSourceUidAfterWrite() {
|
||||
Parcel p = Parcel.obtain();
|
||||
|
||||
Reference in New Issue
Block a user