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

Commit 32995223 authored by John Reck's avatar John Reck
Browse files

Convert utils fastjni -> @FastNative

Test: builds & boots, refactor no behavior change
Change-Id: Ieb569a70fd05b88a8d2bd7b285099c1fc1888a75
parent 39a561f5
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ import android.util.Log;
import android.util.SparseArray;
import android.util.TypedValue;

import dalvik.annotation.optimization.FastNative;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
@@ -752,6 +754,7 @@ public final class AssetManager implements AutoCloseable {
     * applications.
     * {@hide}
     */
    @FastNative
    public native final void setConfiguration(int mcc, int mnc, String locale,
            int orientation, int touchscreen, int density, int keyboard,
            int keyboardHidden, int navigation, int screenWidth, int screenHeight,
@@ -761,13 +764,18 @@ public final class AssetManager implements AutoCloseable {
    /**
     * Retrieve the resource identifier for the given resource name.
     */
    @FastNative
    /*package*/ native final int getResourceIdentifier(String type,
                                                       String name,
                                                       String defPackage);

    @FastNative
    /*package*/ native final String getResourceName(int resid);
    @FastNative
    /*package*/ native final String getResourcePackageName(int resid);
    @FastNative
    /*package*/ native final String getResourceTypeName(int resid);
    @FastNative
    /*package*/ native final String getResourceEntryName(int resid);
    
    private native final long openAsset(String fileName, int accessMode);
@@ -781,15 +789,19 @@ public final class AssetManager implements AutoCloseable {
    private native final int readAssetChar(long asset);
    private native final int readAsset(long asset, byte[] b, int off, int len);
    private native final long seekAsset(long asset, long offset, int whence);
    @FastNative
    private native final long getAssetLength(long asset);
    @FastNative
    private native final long getAssetRemainingLength(long asset);

    /** Returns true if the resource was found, filling in mRetStringBlock and
     *  mRetData. */
    @FastNative
    private native final int loadResourceValue(int ident, short density, TypedValue outValue,
            boolean resolve);
    /** Returns true if the resource was found, filling in mRetStringBlock and
     *  mRetData. */
    @FastNative
    private native final int loadResourceBagValue(int ident, int bagEntryId, TypedValue outValue,
                                               boolean resolve);
    /*package*/ static final int STYLE_NUM_ENTRIES = 6;
@@ -802,17 +814,24 @@ public final class AssetManager implements AutoCloseable {
    static final int STYLE_CHANGING_CONFIGURATIONS = 4;

    /*package*/ static final int STYLE_DENSITY = 5;
    @FastNative
    /*package*/ native static final boolean applyStyle(long theme,
            int defStyleAttr, int defStyleRes, long xmlParser,
            int[] inAttrs, int[] outValues, int[] outIndices);
    @FastNative
    /*package*/ native static final boolean resolveAttrs(long theme,
            int defStyleAttr, int defStyleRes, int[] inValues,
            int[] inAttrs, int[] outValues, int[] outIndices);
    @FastNative
    /*package*/ native final boolean retrieveAttributes(
            long xmlParser, int[] inAttrs, int[] outValues, int[] outIndices);
    @FastNative
    /*package*/ native final int getArraySize(int resource);
    @FastNative
    /*package*/ native final int retrieveArray(int resource, int[] outValues);
    @FastNative
    private native final int getStringBlockCount();
    @FastNative
    private native final long getNativeStringBlock(int block);

    /**
@@ -845,17 +864,22 @@ public final class AssetManager implements AutoCloseable {
    /*package*/ native static final void applyThemeStyle(long theme, int styleRes, boolean force);
    /*package*/ native static final void copyTheme(long dest, long source);
    /*package*/ native static final void clearTheme(long theme);
    @FastNative
    /*package*/ native static final int loadThemeAttributeValue(long theme, int ident,
                                                                TypedValue outValue,
                                                                boolean resolve);
    /*package*/ native static final void dumpTheme(long theme, int priority, String tag, String prefix);
    @FastNative
    /*package*/ native static final @NativeConfig int getThemeChangingConfigurations(long theme);

    private native final long openXmlAssetNative(int cookie, String fileName);

    private native final String[] getArrayStringResource(int arrayRes);
    @FastNative
    private native final int[] getArrayStringInfo(int arrayRes);
    @FastNative
    /*package*/ native final int[] getArrayIntResource(int arrayRes);
    @FastNative
    /*package*/ native final int[] getStyleAttributes(int themeRes);

    private native final void init(boolean isSystem);
+23 −4
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import android.util.TypedValue;

import com.android.internal.util.XmlUtils;

import dalvik.annotation.optimization.FastNative;

import org.xmlpull.v1.XmlPullParserException;

import java.io.IOException;
@@ -492,25 +494,42 @@ final class XmlBlock {
                                                 int offset,
                                                 int size);
    private static final native long nativeGetStringBlock(long obj);

    private static final native long nativeCreateParseState(long obj);
    private static final native void nativeDestroyParseState(long state);
    private static final native void nativeDestroy(long obj);

    // ----------- @FastNative ------------------

    @FastNative
    /*package*/ static final native int nativeNext(long state);
    @FastNative
    private static final native int nativeGetNamespace(long state);
    @FastNative
    /*package*/ static final native int nativeGetName(long state);
    @FastNative
    private static final native int nativeGetText(long state);
    @FastNative
    private static final native int nativeGetLineNumber(long state);
    @FastNative
    private static final native int nativeGetAttributeCount(long state);
    @FastNative
    private static final native int nativeGetAttributeNamespace(long state, int idx);
    @FastNative
    private static final native int nativeGetAttributeName(long state, int idx);
    @FastNative
    private static final native int nativeGetAttributeResource(long state, int idx);
    @FastNative
    private static final native int nativeGetAttributeDataType(long state, int idx);
    @FastNative
    private static final native int nativeGetAttributeData(long state, int idx);
    @FastNative
    private static final native int nativeGetAttributeStringValue(long state, int idx);
    @FastNative
    private static final native int nativeGetIdAttribute(long state);
    @FastNative
    private static final native int nativeGetClassAttribute(long state);
    @FastNative
    private static final native int nativeGetStyleAttribute(long state);
    @FastNative
    private static final native int nativeGetAttributeIndex(long state, String namespace, String name);
    private static final native void nativeDestroyParseState(long state);

    private static final native void nativeDestroy(long obj);
}
+13 −1
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@ package android.util;

import android.graphics.Path;

import dalvik.annotation.optimization.FastNative;

/**
 * @hide
 */
@@ -119,14 +121,24 @@ public class PathParser {
    // Native functions are defined below.
    private static native void nParseStringForPath(long pathPtr, String pathString,
            int stringLength);
    private static native long nCreatePathDataFromString(String pathString, int stringLength);

    // ----------------- @FastNative -----------------------

    @FastNative
    private static native void nCreatePathFromPathData(long outPathPtr, long pathData);
    @FastNative
    private static native long nCreateEmptyPathData();
    @FastNative
    private static native long nCreatePathData(long nativePtr);
    private static native long nCreatePathDataFromString(String pathString, int stringLength);
    @FastNative
    private static native boolean nInterpolatePathData(long outDataPtr, long fromDataPtr,
            long toDataPtr, float fraction);
    @FastNative
    private static native void nFinalize(long nativePtr);
    @FastNative
    private static native boolean nCanMorph(long fromDataPtr, long toDataPtr);
    @FastNative
    private static native void nSetPathData(long outDataPtr, long fromDataPtr);
}

+44 −22
Original line number Diff line number Diff line
@@ -2161,9 +2161,11 @@ static const JNINativeMethod gAssetManagerMethods[] = {
        (void*) android_content_AssetManager_readAsset },
    { "seekAsset",      "(JJI)J",
        (void*) android_content_AssetManager_seekAsset },
    { "getAssetLength", "!(J)J",
    // @FastNative
    { "getAssetLength", "(J)J",
        (void*) android_content_AssetManager_getAssetLength },
    { "getAssetRemainingLength", "!(J)J",
    // @FastNative
    { "getAssetRemainingLength", "(J)J",
        (void*) android_content_AssetManager_getAssetRemainingLength },
    { "addAssetPathNative", "(Ljava/lang/String;Z)I",
        (void*) android_content_AssetManager_addAssetPath },
@@ -2179,25 +2181,35 @@ static const JNINativeMethod gAssetManagerMethods[] = {
        (void*) android_content_AssetManager_getNonSystemLocales },
    { "getSizeConfigurations", "()[Landroid/content/res/Configuration;",
        (void*) android_content_AssetManager_getSizeConfigurations },
    { "setConfiguration", "!(IILjava/lang/String;IIIIIIIIIIIIII)V",
    // @FastNative
    { "setConfiguration", "(IILjava/lang/String;IIIIIIIIIIIIII)V",
        (void*) android_content_AssetManager_setConfiguration },
    { "getResourceIdentifier","!(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I",
    // @FastNative
    { "getResourceIdentifier","(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I",
        (void*) android_content_AssetManager_getResourceIdentifier },
    { "getResourceName","!(I)Ljava/lang/String;",
    // @FastNative
    { "getResourceName","(I)Ljava/lang/String;",
        (void*) android_content_AssetManager_getResourceName },
    { "getResourcePackageName","!(I)Ljava/lang/String;",
    // @FastNative
    { "getResourcePackageName","(I)Ljava/lang/String;",
        (void*) android_content_AssetManager_getResourcePackageName },
    { "getResourceTypeName","!(I)Ljava/lang/String;",
    // @FastNative
    { "getResourceTypeName","(I)Ljava/lang/String;",
        (void*) android_content_AssetManager_getResourceTypeName },
    { "getResourceEntryName","!(I)Ljava/lang/String;",
    // @FastNative
    { "getResourceEntryName","(I)Ljava/lang/String;",
        (void*) android_content_AssetManager_getResourceEntryName },
    { "loadResourceValue","!(ISLandroid/util/TypedValue;Z)I",
    // @FastNative
    { "loadResourceValue","(ISLandroid/util/TypedValue;Z)I",
        (void*) android_content_AssetManager_loadResourceValue },
    { "loadResourceBagValue","!(IILandroid/util/TypedValue;Z)I",
    // @FastNative
    { "loadResourceBagValue","(IILandroid/util/TypedValue;Z)I",
        (void*) android_content_AssetManager_loadResourceBagValue },
    { "getStringBlockCount","!()I",
    // @FastNative
    { "getStringBlockCount","()I",
        (void*) android_content_AssetManager_getStringBlockCount },
    { "getNativeStringBlock","!(I)J",
    // @FastNative
    { "getNativeStringBlock","(I)J",
        (void*) android_content_AssetManager_getNativeStringBlock },
    { "getCookieName","(I)Ljava/lang/String;",
        (void*) android_content_AssetManager_getCookieName },
@@ -2215,21 +2227,28 @@ static const JNINativeMethod gAssetManagerMethods[] = {
        (void*) android_content_AssetManager_copyTheme },
    { "clearTheme", "(J)V",
        (void*) android_content_AssetManager_clearTheme },
    { "loadThemeAttributeValue", "!(JILandroid/util/TypedValue;Z)I",
    // @FastNative
    { "loadThemeAttributeValue", "(JILandroid/util/TypedValue;Z)I",
        (void*) android_content_AssetManager_loadThemeAttributeValue },
    { "getThemeChangingConfigurations", "!(J)I",
    // @FastNative
    { "getThemeChangingConfigurations", "(J)I",
        (void*) android_content_AssetManager_getThemeChangingConfigurations },
    { "dumpTheme", "(JILjava/lang/String;Ljava/lang/String;)V",
        (void*) android_content_AssetManager_dumpTheme },
    { "applyStyle","!(JIIJ[I[I[I)Z",
    // @FastNative
    { "applyStyle","(JIIJ[I[I[I)Z",
        (void*) android_content_AssetManager_applyStyle },
    { "resolveAttrs","!(JII[I[I[I[I)Z",
    // @FastNative
    { "resolveAttrs","(JII[I[I[I[I)Z",
        (void*) android_content_AssetManager_resolveAttrs },
    { "retrieveAttributes","!(J[I[I[I)Z",
    // @FastNative
    { "retrieveAttributes","(J[I[I[I)Z",
        (void*) android_content_AssetManager_retrieveAttributes },
    { "getArraySize","!(I)I",
    // @FastNative
    { "getArraySize","(I)I",
        (void*) android_content_AssetManager_getArraySize },
    { "retrieveArray","!(I[I)I",
    // @FastNative
    { "retrieveArray","(I[I)I",
        (void*) android_content_AssetManager_retrieveArray },

    // XML files.
@@ -2239,11 +2258,14 @@ static const JNINativeMethod gAssetManagerMethods[] = {
    // Arrays.
    { "getArrayStringResource","(I)[Ljava/lang/String;",
        (void*) android_content_AssetManager_getArrayStringResource },
    { "getArrayStringInfo","!(I)[I",
    // @FastNative
    { "getArrayStringInfo","(I)[I",
        (void*) android_content_AssetManager_getArrayStringInfo },
    { "getArrayIntResource","!(I)[I",
    // @FastNative
    { "getArrayIntResource","(I)[I",
        (void*) android_content_AssetManager_getArrayIntResource },
    { "getStyleAttributes","!(I)[I",
    // @FastNative
    { "getStyleAttributes","(I)[I",
        (void*) android_content_AssetManager_getStyleAttributes },

    // Bookkeeping.
+10 −7
Original line number Diff line number Diff line
@@ -101,14 +101,17 @@ static void setSkPathFromPathData(JNIEnv*, jobject, jlong outPathPtr, jlong path

static const JNINativeMethod gMethods[] = {
    {"nParseStringForPath", "(JLjava/lang/String;I)V", (void*)parseStringForPath},
    {"nCreateEmptyPathData", "!()J", (void*)createEmptyPathData},
    {"nCreatePathData", "!(J)J", (void*)createPathData},
    {"nCreatePathDataFromString", "(Ljava/lang/String;I)J", (void*)createPathDataFromStringPath},
    {"nInterpolatePathData", "!(JJJF)Z", (void*)interpolatePathData},
    {"nFinalize", "!(J)V", (void*)deletePathData},
    {"nCanMorph", "!(JJ)Z", (void*)canMorphPathData},
    {"nSetPathData", "!(JJ)V", (void*)setPathData},
    {"nCreatePathFromPathData", "!(JJ)V", (void*)setSkPathFromPathData},

    // ---------------- @FastNative -----------------

    {"nCreateEmptyPathData", "()J", (void*)createEmptyPathData},
    {"nCreatePathData", "(J)J", (void*)createPathData},
    {"nInterpolatePathData", "(JJJF)Z", (void*)interpolatePathData},
    {"nFinalize", "(J)V", (void*)deletePathData},
    {"nCanMorph", "(JJ)Z", (void*)canMorphPathData},
    {"nSetPathData", "(JJ)V", (void*)setPathData},
    {"nCreatePathFromPathData", "(JJ)V", (void*)setSkPathFromPathData},
};

int register_android_util_PathParser(JNIEnv* env) {
Loading