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

Commit c699a60f authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "HostStubGen: Allow @Throw on @NativeSubstitutionClass native methods" into main

parents 7d3d72fe 39d2c720
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -27,6 +27,10 @@ import android.annotation.SuppressLint;
import android.annotation.TestApi;
import android.app.AppOpsManager;
import android.compat.annotation.UnsupportedAppUsage;
import android.ravenwood.annotation.RavenwoodKeepWholeClass;
import android.ravenwood.annotation.RavenwoodNativeSubstitutionClass;
import android.ravenwood.annotation.RavenwoodReplace;
import android.ravenwood.annotation.RavenwoodThrow;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.ArraySet;
@@ -228,6 +232,8 @@ import java.util.function.IntFunction;
 * {@link #readMap(Map, ClassLoader, Class, Class)},
 * {@link #readSparseArray(ClassLoader, Class)}.
 */
@RavenwoodKeepWholeClass
@RavenwoodNativeSubstitutionClass("com.android.hoststubgen.nativesubstitution.Parcel_host")
public final class Parcel {

    private static final boolean DEBUG_RECYCLE = false;
@@ -382,8 +388,10 @@ public final class Parcel {
    @CriticalNative
    private static native void nativeMarkSensitive(long nativePtr);
    @FastNative
    @RavenwoodThrow
    private static native void nativeMarkForBinder(long nativePtr, IBinder binder);
    @CriticalNative
    @RavenwoodThrow
    private static native boolean nativeIsForRpc(long nativePtr);
    @CriticalNative
    private static native int nativeDataSize(long nativePtr);
@@ -415,14 +423,17 @@ public final class Parcel {
    private static native int nativeWriteFloat(long nativePtr, float val);
    @CriticalNative
    private static native int nativeWriteDouble(long nativePtr, double val);
    @RavenwoodThrow
    private static native void nativeSignalExceptionForError(int error);
    @FastNative
    private static native void nativeWriteString8(long nativePtr, String val);
    @FastNative
    private static native void nativeWriteString16(long nativePtr, String val);
    @FastNative
    @RavenwoodThrow
    private static native void nativeWriteStrongBinder(long nativePtr, IBinder val);
    @FastNative
    @RavenwoodThrow
    private static native void nativeWriteFileDescriptor(long nativePtr, FileDescriptor val);

    private static native byte[] nativeCreateByteArray(long nativePtr);
@@ -441,8 +452,10 @@ public final class Parcel {
    @FastNative
    private static native String nativeReadString16(long nativePtr);
    @FastNative
    @RavenwoodThrow
    private static native IBinder nativeReadStrongBinder(long nativePtr);
    @FastNative
    @RavenwoodThrow
    private static native FileDescriptor nativeReadFileDescriptor(long nativePtr);

    private static native long nativeCreate();
@@ -452,7 +465,9 @@ public final class Parcel {
    private static native byte[] nativeMarshall(long nativePtr);
    private static native void nativeUnmarshall(
            long nativePtr, byte[] data, int offset, int length);
    @RavenwoodThrow
    private static native int nativeCompareData(long thisNativePtr, long otherNativePtr);
    @RavenwoodThrow
    private static native boolean nativeCompareDataInRange(
            long ptrA, int offsetA, long ptrB, int offsetB, int length);
    private static native void nativeAppendFrom(
@@ -461,13 +476,17 @@ public final class Parcel {
    private static native boolean nativeHasFileDescriptors(long nativePtr);
    private static native boolean nativeHasFileDescriptorsInRange(
            long nativePtr, int offset, int length);
    @RavenwoodThrow
    private static native void nativeWriteInterfaceToken(long nativePtr, String interfaceName);
    @RavenwoodThrow
    private static native void nativeEnforceInterface(long nativePtr, String interfaceName);

    @CriticalNative
    @RavenwoodThrow
    private static native boolean nativeReplaceCallingWorkSourceUid(
            long nativePtr, int workSourceUid);
    @CriticalNative
    @RavenwoodThrow
    private static native int nativeReadCallingWorkSourceUid(long nativePtr);

    /** Last time exception with a stack trace was written */
@@ -476,6 +495,7 @@ public final class Parcel {
    private static final int WRITE_EXCEPTION_STACK_TRACE_THRESHOLD_MS = 1000;

    @CriticalNative
    @RavenwoodThrow
    private static native long nativeGetOpenAshmemSize(long nativePtr);

    public final static Parcelable.Creator<String> STRING_CREATOR
@@ -634,10 +654,12 @@ public final class Parcel {

    /** @hide */
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    @RavenwoodThrow
    public static native long getGlobalAllocSize();

    /** @hide */
    @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
    @RavenwoodThrow
    public static native long getGlobalAllocCount();

    /**
@@ -2918,6 +2940,7 @@ public final class Parcel {
     * @see #writeNoException
     * @see #readException
     */
    @RavenwoodReplace
    public final void writeException(@NonNull Exception e) {
        AppOpsManager.prefixParcelWithAppOpsIfNeeded(this);

@@ -3017,6 +3040,7 @@ public final class Parcel {
     * @see #writeException
     * @see #readException
     */
    @RavenwoodReplace
    public final void writeNoException() {
        AppOpsManager.prefixParcelWithAppOpsIfNeeded(this);

+2 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.os;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.ravenwood.annotation.RavenwoodKeepWholeClass;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -86,6 +87,7 @@ import java.lang.annotation.RetentionPolicy;
 *     }
 * }</pre></section></div></div>
 */
@RavenwoodKeepWholeClass
public interface Parcelable {
    /** @hide */
    @IntDef(flag = true, prefix = { "PARCELABLE_" }, value = {
+0 −6
Original line number Diff line number Diff line
@@ -92,12 +92,6 @@ class com.android.internal.util.StringPool stubclass
class com.android.internal.os.SomeArgs 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
+2 −0
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ android.os.IBinder
android.os.Looper
android.os.Message
android.os.MessageQueue
android.os.Parcel
android.os.Parcelable
android.os.Process
android.os.SystemClock
android.os.ThreadLocalWorkSource
+0 −55
Original line number Diff line number Diff line
@@ -15,9 +15,6 @@
 */
package com.android.hoststubgen.nativesubstitution;

import android.os.IBinder;

import java.io.FileDescriptor;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
@@ -143,12 +140,6 @@ public class Parcel_host {
    public static void nativeMarkSensitive(long nativePtr) {
        getInstance(nativePtr).mSensitive = true;
    }
    public static void nativeMarkForBinder(long nativePtr, IBinder binder) {
        throw new RuntimeException("Not implemented yet");
    }
    public static boolean nativeIsForRpc(long nativePtr) {
        throw new RuntimeException("Not implemented yet");
    }
    public static int nativeDataSize(long nativePtr) {
        return getInstance(nativePtr).mSize;
    }
@@ -236,9 +227,6 @@ public class Parcel_host {
    public static int nativeWriteDouble(long nativePtr, double val) {
        return nativeWriteLong(nativePtr, Double.doubleToLongBits(val));
    }
    public static void nativeSignalExceptionForError(int error) {
        throw new RuntimeException("Not implemented yet");
    }

    private static int align4(int val) {
        return ((val + 3) / 4) * 4;
@@ -256,12 +244,6 @@ public class Parcel_host {
        // Just reuse String8
        nativeWriteString8(nativePtr, val);
    }
    public static void nativeWriteStrongBinder(long nativePtr, IBinder val) {
        throw new RuntimeException("Not implemented yet");
    }
    public static void nativeWriteFileDescriptor(long nativePtr, FileDescriptor val) {
        throw new RuntimeException("Not implemented yet");
    }

    public static byte[] nativeCreateByteArray(long nativePtr) {
        return nativeReadBlob(nativePtr);
@@ -348,12 +330,6 @@ public class Parcel_host {
    public static String nativeReadString16(long nativePtr) {
        return nativeReadString8(nativePtr);
    }
    public static IBinder nativeReadStrongBinder(long nativePtr) {
        throw new RuntimeException("Not implemented yet");
    }
    public static FileDescriptor nativeReadFileDescriptor(long nativePtr) {
        throw new RuntimeException("Not implemented yet");
    }

    public static byte[] nativeMarshall(long nativePtr) {
        var p = getInstance(nativePtr);
@@ -367,13 +343,6 @@ public class Parcel_host {
        p.mPos += length;
        p.updateSize();
    }
    public static int nativeCompareData(long thisNativePtr, long otherNativePtr) {
        throw new RuntimeException("Not implemented yet");
    }
    public static boolean nativeCompareDataInRange(
            long ptrA, int offsetA, long ptrB, int offsetB, int length) {
        throw new RuntimeException("Not implemented yet");
    }
    public static void nativeAppendFrom(
            long thisNativePtr, long otherNativePtr, int srcOffset, int length) {
        var dst = getInstance(thisNativePtr);
@@ -397,28 +366,4 @@ public class Parcel_host {
        // Assume false for now, because we don't support writing FDs yet.
        return false;
    }
    public static void nativeWriteInterfaceToken(long nativePtr, String interfaceName) {
        throw new RuntimeException("Not implemented yet");
    }
    public static void nativeEnforceInterface(long nativePtr, String interfaceName) {
        throw new RuntimeException("Not implemented yet");
    }

    public static boolean nativeReplaceCallingWorkSourceUid(
            long nativePtr, int workSourceUid) {
        throw new RuntimeException("Not implemented yet");
    }
    public static int nativeReadCallingWorkSourceUid(long nativePtr) {
        throw new RuntimeException("Not implemented yet");
    }

    public static long nativeGetOpenAshmemSize(long nativePtr) {
        throw new RuntimeException("Not implemented yet");
    }
    public static long getGlobalAllocSize() {
        throw new RuntimeException("Not implemented yet");
    }
    public static long getGlobalAllocCount() {
        throw new RuntimeException("Not implemented yet");
    }
}
Loading