Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 91f414e4 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Support Parcel, Bundle under Ravenwood, with CTS.

We have baseline implementations of the Parcel and Bundle, so we're
ready to support them under the Ravenwood environment.  Brings along
the relevant CTS to prove that it works consistently on both devices
and Ravenwood.  Make a few test-driven bug fixes to Parcel code.

Currently does not support FDs or Binders.

Add new `@IgnoreUnderRavenwood` annotation that is respected by a
new `RavenwoodRule`, letting the same test code be shared to run
under both devices and Ravenwood.  Currently packaged under our own
area of the tree, but named to match layout of `platform_testing`
for future migration.

Add "ThrowClass" policy.

Bug: 292141694
Test: atest-dev CtsOsTestCasesRavenwood CtsOsTestCases:ParcelTest CtsOsTestCases:BundleTest
Change-Id: I88d19afff47fbea6557e922a10e8555ee0f70ba3
parent 37ddff60
Loading
Loading
Loading
Loading
+8 −1
Original line number Original line Diff line number Diff line
@@ -77,10 +77,17 @@ android_ravenwood_libgroup {
        "framework-minus-apex.ravenwood",
        "framework-minus-apex.ravenwood",
        "hoststubgen-helper-runtime.ravenwood",
        "hoststubgen-helper-runtime.ravenwood",
        "hoststubgen-helper-framework-runtime.ravenwood",
        "hoststubgen-helper-framework-runtime.ravenwood",
        "junit",
        "truth",
        "ravenwood-junit",
    ],
    ],
}
}


android_ravenwood_libgroup {
android_ravenwood_libgroup {
    name: "ravenwood-utils",
    name: "ravenwood-utils",
    libs: [],
    libs: [
        "junit",
        "truth",
        "ravenwood-junit",
    ],
}
}
+13 −1
Original line number Original line Diff line number Diff line
@@ -333,6 +333,12 @@ public class Binder implements IBinder {
    @CriticalNative
    @CriticalNative
    public static final native boolean isDirectlyHandlingTransactionNative();
    public static final native boolean isDirectlyHandlingTransactionNative();


    /** @hide */
    public static final boolean isDirectlyHandlingTransactionNative$ravenwood() {
        // Ravenwood doesn't support IPC
        return false;
    }

    private static boolean sIsHandlingBinderTransaction = false;
    private static boolean sIsHandlingBinderTransaction = false;


    /**
    /**
@@ -715,7 +721,9 @@ public class Binder implements IBinder {
     */
     */
    public Binder(@Nullable String descriptor) {
    public Binder(@Nullable String descriptor) {
        mObject = getNativeBBinderHolder();
        mObject = getNativeBBinderHolder();
        if (mObject != 0L) {
            NoImagePreloadHolder.sRegistry.registerNativeAllocation(this, mObject);
            NoImagePreloadHolder.sRegistry.registerNativeAllocation(this, mObject);
        }


        if (FIND_POTENTIAL_LEAKS) {
        if (FIND_POTENTIAL_LEAKS) {
            final Class<? extends Binder> klass = getClass();
            final Class<? extends Binder> klass = getClass();
@@ -1277,6 +1285,10 @@ public class Binder implements IBinder {


    private static native long getNativeBBinderHolder();
    private static native long getNativeBBinderHolder();


    private static long getNativeBBinderHolder$ravenwood() {
        return 0L;
    }

    /**
    /**
     * By default, we use the calling UID since we can always trust it.
     * By default, we use the calling UID since we can always trust it.
     */
     */
+15 −1
Original line number Original line Diff line number Diff line
@@ -1558,7 +1558,7 @@ public final class Parcel {
        ensureWithinMemoryLimit(typeSize, totalObjects);
        ensureWithinMemoryLimit(typeSize, totalObjects);
    }
    }


    private void ensureWithinMemoryLimit(int typeSize, @NonNull int length) {
    private void ensureWithinMemoryLimit(int typeSize, int length) {
        int estimatedAllocationSize = 0;
        int estimatedAllocationSize = 0;
        try {
        try {
            estimatedAllocationSize = Math.multiplyExact(typeSize, length);
            estimatedAllocationSize = Math.multiplyExact(typeSize, length);
@@ -2956,6 +2956,14 @@ public final class Parcel {
        }
        }
    }
    }


    /** @hide */
    public final void writeException$ravenwood(@NonNull Exception e) {
        // Ravenwood doesn't support IPC, no transaction headers needed
        writeInt(getExceptionCode(e));
        writeString(e.getMessage());
        writeInt(0);
    }

    /** @hide */
    /** @hide */
    public static int getExceptionCode(@NonNull Throwable e) {
    public static int getExceptionCode(@NonNull Throwable e) {
        int code = 0;
        int code = 0;
@@ -3039,6 +3047,12 @@ public final class Parcel {
        }
        }
    }
    }


    /** @hide */
    public final void writeNoException$ravenwood() {
        // Ravenwood doesn't support IPC, no transaction headers needed
        writeInt(0);
    }

    /**
    /**
     * Special function for reading an exception result from the header of
     * Special function for reading an exception result from the header of
     * a parcel, to be used after receiving the result of a transaction.  This
     * a parcel, to be used after receiving the result of a transaction.  This
+25 −1
Original line number Original line Diff line number Diff line
@@ -71,8 +71,9 @@ class android.util.proto.WireTypeMismatchException stubclass
# Misc
# Misc
class android.util.Dumpable stubclass
class android.util.Dumpable stubclass
class android.util.DebugUtils stubclass
class android.util.DebugUtils stubclass
class android.util.UtilConfig stubclass
class android.util.MathUtils stubclass
class android.util.Patterns stubclass
class android.util.Patterns stubclass
class android.util.UtilConfig stubclass


# Internals
# Internals
class com.android.internal.util.ArrayUtils stubclass
class com.android.internal.util.ArrayUtils stubclass
@@ -89,3 +90,26 @@ class com.android.internal.util.GrowingArrayUtils stubclass
class com.android.internal.util.LineBreakBufferedWriter stubclass
class com.android.internal.util.LineBreakBufferedWriter stubclass
class com.android.internal.util.Preconditions stubclass
class com.android.internal.util.Preconditions stubclass
class com.android.internal.util.StringPool stubclass
class com.android.internal.util.StringPool stubclass

# Parcel
class android.os.Parcel stubclass
    method writeException (Ljava/lang/Exception;)V @writeException$ravenwood
    method writeNoException ()V @writeNoException$ravenwood
class android.os.Parcel !com.android.hoststubgen.nativesubstitution.Parcel_host

class android.os.Parcelable stubclass
class android.os.ParcelFormatException stubclass
class android.os.BadParcelableException stubclass
class android.os.BadTypeParcelableException stubclass

# Binder: just enough to construct, no further functionality
class android.os.Binder stub
    method <init> ()V stub
    method <init> (Ljava/lang/String;)V stub
    method isDirectlyHandlingTransaction ()Z stub
    method isDirectlyHandlingTransactionNative ()Z @isDirectlyHandlingTransactionNative$ravenwood
    method getNativeBBinderHolder ()J @getNativeBBinderHolder$ravenwood

# Containers
class android.os.BaseBundle stubclass
class android.os.Bundle stubclass
+11 −0
Original line number Original line Diff line number Diff line
@@ -32,3 +32,14 @@ java_library {
    host_supported: true,
    host_supported: true,
    visibility: ["//visibility:public"],
    visibility: ["//visibility:public"],
}
}

java_library {
    name: "ravenwood-junit",
    srcs: ["junit-src/**/*.java"],
    libs: [
        "junit",
    ],
    sdk_version: "core_current",
    host_supported: true,
    visibility: ["//visibility:public"],
}
Loading