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

Commit 49b7ba4d authored by Narayan Kamath's avatar Narayan Kamath Committed by Gerrit Code Review
Browse files

Merge "AArch64: Make AssetManager and related classes 64-bit compatible"

parents 1cadc07d 896043d6
Loading
Loading
Loading
Loading
+37 −37
Original line number Diff line number Diff line
@@ -69,13 +69,13 @@ public final class AssetManager {
    private final long[] mOffsets = new long[2];
    
    // For communication with native code.
    private int mObject;
    private long mObject;

    private StringBlock mStringBlocks[] = null;
    
    private int mNumRefs = 1;
    private boolean mOpen = true;
    private HashMap<Integer, RuntimeException> mRefStacks; 
    private HashMap<Long, RuntimeException> mRefStacks;
 
    /**
     * Create a new AssetManager containing only the basic system assets.
@@ -224,7 +224,7 @@ public final class AssetManager {
        return retArray;
    }
    
    /*package*/ final boolean getThemeValue(int theme, int ident,
    /*package*/ final boolean getThemeValue(long theme, int ident,
            TypedValue outValue, boolean resolveRefs) {
        int block = loadThemeAttributeValue(theme, ident, outValue, resolveRefs);
        if (block >= 0) {
@@ -312,7 +312,7 @@ public final class AssetManager {
            if (!mOpen) {
                throw new RuntimeException("Assetmanager has been closed");
            }
            int asset = openAsset(fileName, accessMode);
            long asset = openAsset(fileName, accessMode);
            if (asset != 0) {
                AssetInputStream res = new AssetInputStream(asset);
                incRefsLocked(res.hashCode());
@@ -404,7 +404,7 @@ public final class AssetManager {
            if (!mOpen) {
                throw new RuntimeException("Assetmanager has been closed");
            }
            int asset = openNonAssetNative(cookie, fileName, accessMode);
            long asset = openNonAssetNative(cookie, fileName, accessMode);
            if (asset != 0) {
                AssetInputStream res = new AssetInputStream(asset);
                incRefsLocked(res.hashCode());
@@ -484,7 +484,7 @@ public final class AssetManager {
            if (!mOpen) {
                throw new RuntimeException("Assetmanager has been closed");
            }
            int xmlBlock = openXmlAssetNative(cookie, fileName);
            long xmlBlock = openXmlAssetNative(cookie, fileName);
            if (xmlBlock != 0) {
                XmlBlock res = new XmlBlock(this, xmlBlock);
                incRefsLocked(res.hashCode());
@@ -500,18 +500,18 @@ public final class AssetManager {
        }
    }

    /*package*/ final int createTheme() {
    /*package*/ final long createTheme() {
        synchronized (this) {
            if (!mOpen) {
                throw new RuntimeException("Assetmanager has been closed");
            }
            int res = newTheme();
            long res = newTheme();
            incRefsLocked(res);
            return res;
        }
    }

    /*package*/ final void releaseTheme(int theme) {
    /*package*/ final void releaseTheme(long theme) {
        synchronized (this) {
            deleteTheme(theme);
            decRefsLocked(theme);
@@ -537,7 +537,7 @@ public final class AssetManager {
    
    public final class AssetInputStream extends InputStream {
        public final int getAssetInt() {
            return mAsset;
            return (int) mAsset;
        }
        /**
         * @hide
@@ -545,7 +545,7 @@ public final class AssetManager {
        public final long getNativeAsset() {
            return mAsset;
        }
        private AssetInputStream(int asset)
        private AssetInputStream(long asset)
        {
            mAsset = asset;
            mLength = getAssetLength(asset);
@@ -597,7 +597,7 @@ public final class AssetManager {
            close();
        }

        private int mAsset;
        private long mAsset;
        private long mLength;
        private long mMarkPos;
    }
@@ -678,19 +678,19 @@ public final class AssetManager {
    /*package*/ native final String getResourceTypeName(int resid);
    /*package*/ native final String getResourceEntryName(int resid);
    
    private native final int openAsset(String fileName, int accessMode);
    private native final long openAsset(String fileName, int accessMode);
    private final native ParcelFileDescriptor openAssetFd(String fileName,
            long[] outOffsets) throws IOException;
    private native final int openNonAssetNative(int cookie, String fileName,
    private native final long openNonAssetNative(int cookie, String fileName,
            int accessMode);
    private native ParcelFileDescriptor openNonAssetFdNative(int cookie,
            String fileName, long[] outOffsets) throws IOException;
    private native final void destroyAsset(int asset);
    private native final int readAssetChar(int asset);
    private native final int readAsset(int asset, byte[] b, int off, int len);
    private native final long seekAsset(int asset, long offset, int whence);
    private native final long getAssetLength(int asset);
    private native final long getAssetRemainingLength(int asset);
    private native final void destroyAsset(long asset);
    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);
    private native final long getAssetLength(long asset);
    private native final long getAssetRemainingLength(long asset);

    /** Returns true if the resource was found, filling in mRetStringBlock and
     *  mRetData. */
@@ -707,15 +707,15 @@ public final class AssetManager {
    /*package*/ static final int STYLE_RESOURCE_ID = 3;
    /*package*/ static final int STYLE_CHANGING_CONFIGURATIONS = 4;
    /*package*/ static final int STYLE_DENSITY = 5;
    /*package*/ native static final boolean applyStyle(int theme,
            int defStyleAttr, int defStyleRes, int xmlParser,
    /*package*/ native static final boolean applyStyle(long theme,
            int defStyleAttr, int defStyleRes, long xmlParser,
            int[] inAttrs, int[] outValues, int[] outIndices);
    /*package*/ native final boolean retrieveAttributes(
            int xmlParser, int[] inAttrs, int[] outValues, int[] outIndices);
            long xmlParser, int[] inAttrs, int[] outValues, int[] outIndices);
    /*package*/ native final int getArraySize(int resource);
    /*package*/ native final int retrieveArray(int resource, int[] outValues);
    private native final int getStringBlockCount();
    private native final int getNativeStringBlock(int block);
    private native final long getNativeStringBlock(int block);

    /**
     * {@hide}
@@ -737,16 +737,16 @@ public final class AssetManager {
     */
    public native static final int getGlobalAssetManagerCount();
    
    private native final int newTheme();
    private native final void deleteTheme(int theme);
    /*package*/ native static final void applyThemeStyle(int theme, int styleRes, boolean force);
    /*package*/ native static final void copyTheme(int dest, int source);
    /*package*/ native static final int loadThemeAttributeValue(int theme, int ident,
    private native final long newTheme();
    private native final void deleteTheme(long theme);
    /*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 int loadThemeAttributeValue(long theme, int ident,
                                                                TypedValue outValue,
                                                                boolean resolve);
    /*package*/ native static final void dumpTheme(int theme, int priority, String tag, String prefix);
    /*package*/ native static final void dumpTheme(long theme, int priority, String tag, String prefix);

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

    private native final String[] getArrayStringResource(int arrayRes);
    private native final int[] getArrayStringInfo(int arrayRes);
@@ -755,19 +755,19 @@ public final class AssetManager {
    private native final void init();
    private native final void destroy();

    private final void incRefsLocked(int id) {
    private final void incRefsLocked(long id) {
        if (DEBUG_REFS) {
            if (mRefStacks == null) {
                mRefStacks = new HashMap<Integer, RuntimeException>();
                mRefStacks = new HashMap<Long, RuntimeException>();
            }
            RuntimeException ex = new RuntimeException();
            ex.fillInStackTrace();
                mRefStacks.put(this.hashCode(), ex);
            }
            mRefStacks.put(id, ex);
        }
        mNumRefs++;
    }
    
    private final void decRefsLocked(int id) {
    private final void decRefsLocked(long id) {
        if (DEBUG_REFS && mRefStacks != null) {
            mRefStacks.remove(id);
        }
+1 −1
Original line number Diff line number Diff line
@@ -1460,7 +1460,7 @@ public class Resources {
        }

        private final AssetManager mAssets;
        private final int mTheme;
        private final long mTheme;
    }

    /**
+7 −7
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ final class StringBlock {
    private static final String TAG = "AssetManager";
    private static final boolean localLOGV = false;

    private final int mNative;
    private final long mNative;
    private final boolean mUseSparse;
    private final boolean mOwnsNative;
    private CharSequence[] mStrings;
@@ -474,7 +474,7 @@ final class StringBlock {
     *  are doing!  The given native object must exist for the entire lifetime
     *  of this newly creating StringBlock.
     */
    StringBlock(int obj, boolean useSparse) {
    StringBlock(long obj, boolean useSparse) {
        mNative = obj;
        mUseSparse = useSparse;
        mOwnsNative = false;
@@ -482,11 +482,11 @@ final class StringBlock {
                + ": " + nativeGetSize(mNative));
    }

    private static native int nativeCreate(byte[] data,
    private static native long nativeCreate(byte[] data,
                                                 int offset,
                                                 int size);
    private static native int nativeGetSize(int obj);
    private static native String nativeGetString(int obj, int idx);
    private static native int[] nativeGetStyle(int obj, int idx);
    private static native void nativeDestroy(int obj);
    private static native int nativeGetSize(long obj);
    private static native String nativeGetString(long obj, int idx);
    private static native int[] nativeGetStyle(long obj, int idx);
    private static native void nativeDestroy(long obj);
}
+25 −25
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ final class XmlBlock {
    }

    /*package*/ final class Parser implements XmlResourceParser {
        Parser(int parseState, XmlBlock block) {
        Parser(long parseState, XmlBlock block) {
            mParseState = parseState;
            mBlock = block;
            block.mOpenCount++;
@@ -458,7 +458,7 @@ final class XmlBlock {
            return mStrings.get(id);
        }

        /*package*/ int mParseState;
        /*package*/ long mParseState;
        private final XmlBlock mBlock;
        private boolean mStarted = false;
        private boolean mDecNextDepth = false;
@@ -476,41 +476,41 @@ final class XmlBlock {
     *  are doing!  The given native object must exist for the entire lifetime
     *  of this newly creating XmlBlock.
     */
    XmlBlock(AssetManager assets, int xmlBlock) {
    XmlBlock(AssetManager assets, long xmlBlock) {
        mAssets = assets;
        mNative = xmlBlock;
        mStrings = new StringBlock(nativeGetStringBlock(xmlBlock), false);
    }

    private final AssetManager mAssets;
    private final int mNative;
    private final long mNative;
    /*package*/ final StringBlock mStrings;
    private boolean mOpen = true;
    private int mOpenCount = 1;

    private static final native int nativeCreate(byte[] data,
    private static final native long nativeCreate(byte[] data,
                                                 int offset,
                                                 int size);
    private static final native int nativeGetStringBlock(int obj);
    private static final native long nativeGetStringBlock(long obj);

    private static final native int nativeCreateParseState(int obj);
    /*package*/ static final native int nativeNext(int state);
    private static final native int nativeGetNamespace(int state);
    /*package*/ static final native int nativeGetName(int state);
    private static final native int nativeGetText(int state);
    private static final native int nativeGetLineNumber(int state);
    private static final native int nativeGetAttributeCount(int state);
    private static final native int nativeGetAttributeNamespace(int state, int idx);
    private static final native int nativeGetAttributeName(int state, int idx);
    private static final native int nativeGetAttributeResource(int state, int idx);
    private static final native int nativeGetAttributeDataType(int state, int idx);
    private static final native int nativeGetAttributeData(int state, int idx);
    private static final native int nativeGetAttributeStringValue(int state, int idx);
    private static final native int nativeGetIdAttribute(int state);
    private static final native int nativeGetClassAttribute(int state);
    private static final native int nativeGetStyleAttribute(int state);
    private static final native int nativeGetAttributeIndex(int state, String namespace, String name);
    private static final native void nativeDestroyParseState(int state);
    private static final native long nativeCreateParseState(long obj);
    /*package*/ static final native int nativeNext(long state);
    private static final native int nativeGetNamespace(long state);
    /*package*/ static final native int nativeGetName(long state);
    private static final native int nativeGetText(long state);
    private static final native int nativeGetLineNumber(long state);
    private static final native int nativeGetAttributeCount(long state);
    private static final native int nativeGetAttributeNamespace(long state, int idx);
    private static final native int nativeGetAttributeName(long state, int idx);
    private static final native int nativeGetAttributeResource(long state, int idx);
    private static final native int nativeGetAttributeDataType(long state, int idx);
    private static final native int nativeGetAttributeData(long state, int idx);
    private static final native int nativeGetAttributeStringValue(long state, int idx);
    private static final native int nativeGetIdAttribute(long state);
    private static final native int nativeGetClassAttribute(long state);
    private static final native int nativeGetStyleAttribute(long state);
    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(int obj);
    private static final native void nativeDestroy(long obj);
}
+80 −70

File changed.

Preview size limit exceeded, changes collapsed.

Loading