diff options
-rw-r--r-- | core/java/android/content/res/AssetManager.java | 74 | ||||
-rw-r--r-- | core/java/android/content/res/Resources.java | 2 | ||||
-rw-r--r-- | core/java/android/content/res/StringBlock.java | 14 | ||||
-rw-r--r-- | core/java/android/content/res/XmlBlock.java | 50 | ||||
-rw-r--r-- | core/java/android/os/CountDownTimer.java | 15 | ||||
-rw-r--r-- | core/jni/android_opengl_EGL14.cpp | 2 | ||||
-rw-r--r-- | core/jni/android_util_AssetManager.cpp | 150 | ||||
-rw-r--r-- | core/jni/android_util_StringBlock.cpp | 30 | ||||
-rw-r--r-- | core/jni/android_util_XmlBlock.cpp | 164 | ||||
-rw-r--r-- | include/androidfw/ResourceTypes.h | 13 | ||||
-rw-r--r-- | libs/androidfw/AssetManager.cpp | 6 | ||||
-rw-r--r-- | libs/androidfw/ResourceTypes.cpp | 28 | ||||
-rw-r--r-- | native/android/asset_manager.cpp | 4 | ||||
-rw-r--r-- | preloaded-classes | 2 | ||||
-rw-r--r-- | tools/aapt/AaptAssets.cpp | 2 | ||||
-rw-r--r-- | tools/aapt/Resource.cpp | 3 |
16 files changed, 287 insertions, 272 deletions
diff --git a/core/java/android/content/res/AssetManager.java b/core/java/android/content/res/AssetManager.java index 93ce633fdcdc..780c4be49738 100644 --- a/core/java/android/content/res/AssetManager.java +++ b/core/java/android/content/res/AssetManager.java @@ -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>(); - RuntimeException ex = new RuntimeException(); - ex.fillInStackTrace(); - mRefStacks.put(this.hashCode(), ex); + mRefStacks = new HashMap<Long, RuntimeException>(); } + RuntimeException ex = new RuntimeException(); + ex.fillInStackTrace(); + 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); } diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java index cd5b5d2f2ba1..7fc364f86792 100644 --- a/core/java/android/content/res/Resources.java +++ b/core/java/android/content/res/Resources.java @@ -1460,7 +1460,7 @@ public class Resources { } private final AssetManager mAssets; - private final int mTheme; + private final long mTheme; } /** diff --git a/core/java/android/content/res/StringBlock.java b/core/java/android/content/res/StringBlock.java index 78180b1c69a9..77b8a3314148 100644 --- a/core/java/android/content/res/StringBlock.java +++ b/core/java/android/content/res/StringBlock.java @@ -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); } diff --git a/core/java/android/content/res/XmlBlock.java b/core/java/android/content/res/XmlBlock.java index bea652911789..3ad357f28704 100644 --- a/core/java/android/content/res/XmlBlock.java +++ b/core/java/android/content/res/XmlBlock.java @@ -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); } diff --git a/core/java/android/os/CountDownTimer.java b/core/java/android/os/CountDownTimer.java index 15e6405b1d22..58acbcf5684b 100644 --- a/core/java/android/os/CountDownTimer.java +++ b/core/java/android/os/CountDownTimer.java @@ -16,8 +16,6 @@ package android.os; -import android.util.Log; - /** * Schedule a countdown until a time in the future, with * regular notifications on intervals along the way. @@ -56,6 +54,11 @@ public abstract class CountDownTimer { private final long mCountdownInterval; private long mStopTimeInFuture; + + /** + * boolean representing if the timer was cancelled + */ + private boolean mCancelled = false; /** * @param millisInFuture The number of millis in the future from the call @@ -72,7 +75,8 @@ public abstract class CountDownTimer { /** * Cancel the countdown. */ - public final void cancel() { + public synchronized final void cancel() { + mCancelled = true; mHandler.removeMessages(MSG); } @@ -80,6 +84,7 @@ public abstract class CountDownTimer { * Start the countdown. */ public synchronized final CountDownTimer start() { + mCancelled = false; if (mMillisInFuture <= 0) { onFinish(); return this; @@ -112,6 +117,10 @@ public abstract class CountDownTimer { public void handleMessage(Message msg) { synchronized (CountDownTimer.this) { + if (mCancelled) { + return; + } + final long millisLeft = mStopTimeInFuture - SystemClock.elapsedRealtime(); if (millisLeft <= 0) { diff --git a/core/jni/android_opengl_EGL14.cpp b/core/jni/android_opengl_EGL14.cpp index 1fe4b08d9721..5b0a4b2e4039 100644 --- a/core/jni/android_opengl_EGL14.cpp +++ b/core/jni/android_opengl_EGL14.cpp @@ -630,7 +630,7 @@ not_valid_surface: if (producer == NULL) goto not_valid_surface; - window = new android::Surface(producer); + window = new android::Surface(producer, true); if (window == NULL) goto not_valid_surface; diff --git a/core/jni/android_util_AssetManager.cpp b/core/jni/android_util_AssetManager.cpp index 883691856bbe..f96aef857757 100644 --- a/core/jni/android_util_AssetManager.cpp +++ b/core/jni/android_util_AssetManager.cpp @@ -88,7 +88,7 @@ jint copyValue(JNIEnv* env, jobject outValue, const ResTable* table, { env->SetIntField(outValue, gTypedValueOffsets.mType, value.dataType); env->SetIntField(outValue, gTypedValueOffsets.mAssetCookie, - (jint)table->getTableCookie(block)); + static_cast<jint>(table->getTableCookie(block))); env->SetIntField(outValue, gTypedValueOffsets.mData, value.data); env->SetObjectField(outValue, gTypedValueOffsets.mString, NULL); env->SetIntField(outValue, gTypedValueOffsets.mResourceId, ref); @@ -105,7 +105,8 @@ jint copyValue(JNIEnv* env, jobject outValue, const ResTable* table, // this guy is exported to other jni routines AssetManager* assetManagerForJavaObject(JNIEnv* env, jobject obj) { - AssetManager* am = (AssetManager*)env->GetIntField(obj, gAssetManagerOffsets.mObject); + jlong amHandle = env->GetLongField(obj, gAssetManagerOffsets.mObject); + AssetManager* am = reinterpret_cast<AssetManager*>(amHandle); if (am != NULL) { return am; } @@ -113,7 +114,7 @@ AssetManager* assetManagerForJavaObject(JNIEnv* env, jobject obj) return NULL; } -static jint android_content_AssetManager_openAsset(JNIEnv* env, jobject clazz, +static jlong android_content_AssetManager_openAsset(JNIEnv* env, jobject clazz, jstring fileName, jint mode) { AssetManager* am = assetManagerForJavaObject(env, clazz); @@ -125,6 +126,7 @@ static jint android_content_AssetManager_openAsset(JNIEnv* env, jobject clazz, ScopedUtfChars fileName8(env, fileName); if (fileName8.c_str() == NULL) { + jniThrowException(env, "java/lang/IllegalArgumentException", "Empty file name"); return -1; } @@ -143,7 +145,7 @@ static jint android_content_AssetManager_openAsset(JNIEnv* env, jobject clazz, //printf("Created Asset Stream: %p\n", a); - return (jint)a; + return reinterpret_cast<jlong>(a); } static jobject returnParcelFileDescriptor(JNIEnv* env, Asset* a, jlongArray outOffsets) @@ -205,7 +207,7 @@ static jobject android_content_AssetManager_openAssetFd(JNIEnv* env, jobject cla return returnParcelFileDescriptor(env, a, outOffsets); } -static jint android_content_AssetManager_openNonAssetNative(JNIEnv* env, jobject clazz, +static jlong android_content_AssetManager_openNonAssetNative(JNIEnv* env, jobject clazz, jint cookie, jstring fileName, jint mode) @@ -240,7 +242,7 @@ static jint android_content_AssetManager_openNonAssetNative(JNIEnv* env, jobject //printf("Created Asset Stream: %p\n", a); - return (jint)a; + return reinterpret_cast<jlong>(a); } static jobject android_content_AssetManager_openNonAssetFdNative(JNIEnv* env, jobject clazz, @@ -320,9 +322,9 @@ static jobjectArray android_content_AssetManager_list(JNIEnv* env, jobject clazz } static void android_content_AssetManager_destroyAsset(JNIEnv* env, jobject clazz, - jint asset) + jlong assetHandle) { - Asset* a = (Asset*)asset; + Asset* a = reinterpret_cast<Asset*>(assetHandle); //printf("Destroying Asset Stream: %p\n", a); @@ -335,9 +337,9 @@ static void android_content_AssetManager_destroyAsset(JNIEnv* env, jobject clazz } static jint android_content_AssetManager_readAssetChar(JNIEnv* env, jobject clazz, - jint asset) + jlong assetHandle) { - Asset* a = (Asset*)asset; + Asset* a = reinterpret_cast<Asset*>(assetHandle); if (a == NULL) { jniThrowNullPointerException(env, "asset"); @@ -350,10 +352,10 @@ static jint android_content_AssetManager_readAssetChar(JNIEnv* env, jobject claz } static jint android_content_AssetManager_readAsset(JNIEnv* env, jobject clazz, - jint asset, jbyteArray bArray, + jlong assetHandle, jbyteArray bArray, jint off, jint len) { - Asset* a = (Asset*)asset; + Asset* a = reinterpret_cast<Asset*>(assetHandle); if (a == NULL || bArray == NULL) { jniThrowNullPointerException(env, "asset"); @@ -374,7 +376,7 @@ static jint android_content_AssetManager_readAsset(JNIEnv* env, jobject clazz, ssize_t res = a->read(b+off, len); env->ReleaseByteArrayElements(bArray, b, 0); - if (res > 0) return res; + if (res > 0) return static_cast<jint>(res); if (res < 0) { jniThrowException(env, "java/io/IOException", ""); @@ -383,10 +385,10 @@ static jint android_content_AssetManager_readAsset(JNIEnv* env, jobject clazz, } static jlong android_content_AssetManager_seekAsset(JNIEnv* env, jobject clazz, - jint asset, + jlong assetHandle, jlong offset, jint whence) { - Asset* a = (Asset*)asset; + Asset* a = reinterpret_cast<Asset*>(assetHandle); if (a == NULL) { jniThrowNullPointerException(env, "asset"); @@ -398,9 +400,9 @@ static jlong android_content_AssetManager_seekAsset(JNIEnv* env, jobject clazz, } static jlong android_content_AssetManager_getAssetLength(JNIEnv* env, jobject clazz, - jint asset) + jlong assetHandle) { - Asset* a = (Asset*)asset; + Asset* a = reinterpret_cast<Asset*>(assetHandle); if (a == NULL) { jniThrowNullPointerException(env, "asset"); @@ -411,9 +413,9 @@ static jlong android_content_AssetManager_getAssetLength(JNIEnv* env, jobject cl } static jlong android_content_AssetManager_getAssetRemainingLength(JNIEnv* env, jobject clazz, - jint asset) + jlong assetHandle) { - Asset* a = (Asset*)asset; + Asset* a = reinterpret_cast<Asset*>(assetHandle); if (a == NULL) { jniThrowNullPointerException(env, "asset"); @@ -725,7 +727,11 @@ static jint android_content_AssetManager_loadResourceValue(JNIEnv* env, jobject } #endif } - return block >= 0 ? copyValue(env, outValue, &res, value, ref, block, typeSpecFlags, &config) : block; + if (block >= 0) { + return copyValue(env, outValue, &res, value, ref, block, typeSpecFlags, &config); + } + + return static_cast<jint>(block); } static jint android_content_AssetManager_loadResourceBagValue(JNIEnv* env, jobject clazz, @@ -759,7 +765,7 @@ static jint android_content_AssetManager_loadResourceBagValue(JNIEnv* env, jobje res.unlock(); if (block < 0) { - return block; + return static_cast<jint>(block); } uint32_t ref = ident; @@ -772,7 +778,11 @@ static jint android_content_AssetManager_loadResourceBagValue(JNIEnv* env, jobje } #endif } - return block >= 0 ? copyValue(env, outValue, &res, value, ref, block, typeSpecFlags) : block; + if (block >= 0) { + return copyValue(env, outValue, &res, value, ref, block, typeSpecFlags); + } + + return static_cast<jint>(block); } static jint android_content_AssetManager_getStringBlockCount(JNIEnv* env, jobject clazz) @@ -784,14 +794,14 @@ static jint android_content_AssetManager_getStringBlockCount(JNIEnv* env, jobjec return am->getResources().getTableCount(); } -static jint android_content_AssetManager_getNativeStringBlock(JNIEnv* env, jobject clazz, +static jlong android_content_AssetManager_getNativeStringBlock(JNIEnv* env, jobject clazz, jint block) { AssetManager* am = assetManagerForJavaObject(env, clazz); if (am == NULL) { return 0; } - return (jint)am->getResources().getTableStringBlock(block); + return reinterpret_cast<jlong>(am->getResources().getTableStringBlock(block)); } static jstring android_content_AssetManager_getCookieName(JNIEnv* env, jobject clazz, @@ -810,43 +820,43 @@ static jstring android_content_AssetManager_getCookieName(JNIEnv* env, jobject c return str; } -static jint android_content_AssetManager_newTheme(JNIEnv* env, jobject clazz) +static jlong android_content_AssetManager_newTheme(JNIEnv* env, jobject clazz) { AssetManager* am = assetManagerForJavaObject(env, clazz); if (am == NULL) { return 0; } - return (jint)(new ResTable::Theme(am->getResources())); + return reinterpret_cast<jlong>(new ResTable::Theme(am->getResources())); } static void android_content_AssetManager_deleteTheme(JNIEnv* env, jobject clazz, - jint themeInt) + jlong themeHandle) { - ResTable::Theme* theme = (ResTable::Theme*)themeInt; + ResTable::Theme* theme = reinterpret_cast<ResTable::Theme*>(themeHandle); delete theme; } static void android_content_AssetManager_applyThemeStyle(JNIEnv* env, jobject clazz, - jint themeInt, + jlong themeHandle, jint styleRes, jboolean force) { - ResTable::Theme* theme = (ResTable::Theme*)themeInt; + ResTable::Theme* theme = reinterpret_cast<ResTable::Theme*>(themeHandle); theme->applyStyle(styleRes, force ? true : false); } static void android_content_AssetManager_copyTheme(JNIEnv* env, jobject clazz, - jint destInt, jint srcInt) + jlong destHandle, jlong srcHandle) { - ResTable::Theme* dest = (ResTable::Theme*)destInt; - ResTable::Theme* src = (ResTable::Theme*)srcInt; + ResTable::Theme* dest = reinterpret_cast<ResTable::Theme*>(destHandle); + ResTable::Theme* src = reinterpret_cast<ResTable::Theme*>(srcHandle); dest->setTo(*src); } static jint android_content_AssetManager_loadThemeAttributeValue( - JNIEnv* env, jobject clazz, jint themeInt, jint ident, jobject outValue, jboolean resolve) + JNIEnv* env, jobject clazz, jlong themeHandle, jint ident, jobject outValue, jboolean resolve) { - ResTable::Theme* theme = (ResTable::Theme*)themeInt; + ResTable::Theme* theme = reinterpret_cast<ResTable::Theme*>(themeHandle); const ResTable& res(theme->getResTable()); Res_value value; @@ -867,10 +877,10 @@ static jint android_content_AssetManager_loadThemeAttributeValue( } static void android_content_AssetManager_dumpTheme(JNIEnv* env, jobject clazz, - jint themeInt, jint pri, + jlong themeHandle, jint pri, jstring tag, jstring prefix) { - ResTable::Theme* theme = (ResTable::Theme*)themeInt; + ResTable::Theme* theme = reinterpret_cast<ResTable::Theme*>(themeHandle); const ResTable& res(theme->getResTable()); // XXX Need to use params. @@ -878,10 +888,10 @@ static void android_content_AssetManager_dumpTheme(JNIEnv* env, jobject clazz, } static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject clazz, - jint themeToken, + jlong themeToken, jint defStyleAttr, jint defStyleRes, - jint xmlParserToken, + jlong xmlParserToken, jintArray attrs, jintArray outValues, jintArray outIndices) @@ -902,9 +912,9 @@ static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject cla DEBUG_STYLES(LOGI("APPLY STYLE: theme=0x%x defStyleAttr=0x%x defStyleRes=0x%x xml=0x%x", themeToken, defStyleAttr, defStyleRes, xmlParserToken)); - ResTable::Theme* theme = (ResTable::Theme*)themeToken; + ResTable::Theme* theme = reinterpret_cast<ResTable::Theme*>(themeToken); const ResTable& res = theme->getResTable(); - ResXMLParser* xmlParser = (ResXMLParser*)xmlParserToken; + ResXMLParser* xmlParser = reinterpret_cast<ResXMLParser*>(xmlParserToken); ResTable_config config; Res_value value; @@ -1097,7 +1107,7 @@ static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject cla dest[STYLE_TYPE] = value.dataType; dest[STYLE_DATA] = value.data; dest[STYLE_ASSET_COOKIE] = - block != kXmlBlock ? (jint)res.getTableCookie(block) : (jint)-1; + block != kXmlBlock ? reinterpret_cast<jint>(res.getTableCookie(block)) : (jint)-1; dest[STYLE_RESOURCE_ID] = resid; dest[STYLE_CHANGING_CONFIGURATIONS] = typeSetFlags; dest[STYLE_DENSITY] = config.density; @@ -1123,7 +1133,7 @@ static jboolean android_content_AssetManager_applyStyle(JNIEnv* env, jobject cla } static jboolean android_content_AssetManager_retrieveAttributes(JNIEnv* env, jobject clazz, - jint xmlParserToken, + jlong xmlParserToken, jintArray attrs, jintArray outValues, jintArray outIndices) @@ -1240,7 +1250,7 @@ static jboolean android_content_AssetManager_retrieveAttributes(JNIEnv* env, job dest[STYLE_TYPE] = value.dataType; dest[STYLE_DATA] = value.data; dest[STYLE_ASSET_COOKIE] = - block != kXmlBlock ? (jint)res.getTableCookie(block) : (jint)-1; + block != kXmlBlock ? reinterpret_cast<jint>(res.getTableCookie(block)) : (jint)-1; dest[STYLE_RESOURCE_ID] = resid; dest[STYLE_CHANGING_CONFIGURATIONS] = typeSetFlags; dest[STYLE_DENSITY] = config.density; @@ -1280,7 +1290,7 @@ static jint android_content_AssetManager_getArraySize(JNIEnv* env, jobject clazz ssize_t bagOff = res.getBagLocked(id, &defStyleEnt); res.unlock(); - return bagOff; + return static_cast<jint>(bagOff); } static jint android_content_AssetManager_retrieveArray(JNIEnv* env, jobject clazz, @@ -1352,7 +1362,7 @@ static jint android_content_AssetManager_retrieveArray(JNIEnv* env, jobject claz // Write the final value back to Java. dest[STYLE_TYPE] = value.dataType; dest[STYLE_DATA] = value.data; - dest[STYLE_ASSET_COOKIE] = (jint)res.getTableCookie(block); + dest[STYLE_ASSET_COOKIE] = reinterpret_cast<jint>(res.getTableCookie(block)); dest[STYLE_RESOURCE_ID] = resid; dest[STYLE_CHANGING_CONFIGURATIONS] = typeSetFlags; dest[STYLE_DENSITY] = config.density; @@ -1370,7 +1380,7 @@ static jint android_content_AssetManager_retrieveArray(JNIEnv* env, jobject claz return i; } -static jint android_content_AssetManager_openXmlAssetNative(JNIEnv* env, jobject clazz, +static jlong android_content_AssetManager_openXmlAssetNative(JNIEnv* env, jobject clazz, jint cookie, jstring fileName) { @@ -1405,7 +1415,7 @@ static jint android_content_AssetManager_openXmlAssetNative(JNIEnv* env, jobject return 0; } - return (jint)block; + return reinterpret_cast<jlong>(block); } static jintArray android_content_AssetManager_getArrayStringInfo(JNIEnv* env, jobject clazz, @@ -1580,17 +1590,17 @@ static void android_content_AssetManager_init(JNIEnv* env, jobject clazz) am->addDefaultAssets(); ALOGV("Created AssetManager %p for Java object %p\n", am, clazz); - env->SetIntField(clazz, gAssetManagerOffsets.mObject, (jint)am); + env->SetLongField(clazz, gAssetManagerOffsets.mObject, reinterpret_cast<jlong>(am)); } static void android_content_AssetManager_destroy(JNIEnv* env, jobject clazz) { AssetManager* am = (AssetManager*) - (env->GetIntField(clazz, gAssetManagerOffsets.mObject)); + (env->GetLongField(clazz, gAssetManagerOffsets.mObject)); ALOGV("Destroying AssetManager %p for Java object %p\n", am, clazz); if (am != NULL) { delete am; - env->SetIntField(clazz, gAssetManagerOffsets.mObject, 0); + env->SetLongField(clazz, gAssetManagerOffsets.mObject, 0); } } @@ -1624,27 +1634,27 @@ static JNINativeMethod gAssetManagerMethods[] = { /* name, signature, funcPtr */ // Basic asset stuff. - { "openAsset", "(Ljava/lang/String;I)I", + { "openAsset", "(Ljava/lang/String;I)J", (void*) android_content_AssetManager_openAsset }, { "openAssetFd", "(Ljava/lang/String;[J)Landroid/os/ParcelFileDescriptor;", (void*) android_content_AssetManager_openAssetFd }, - { "openNonAssetNative", "(ILjava/lang/String;I)I", + { "openNonAssetNative", "(ILjava/lang/String;I)J", (void*) android_content_AssetManager_openNonAssetNative }, { "openNonAssetFdNative", "(ILjava/lang/String;[J)Landroid/os/ParcelFileDescriptor;", (void*) android_content_AssetManager_openNonAssetFdNative }, { "list", "(Ljava/lang/String;)[Ljava/lang/String;", (void*) android_content_AssetManager_list }, - { "destroyAsset", "(I)V", + { "destroyAsset", "(J)V", (void*) android_content_AssetManager_destroyAsset }, - { "readAssetChar", "(I)I", + { "readAssetChar", "(J)I", (void*) android_content_AssetManager_readAssetChar }, - { "readAsset", "(I[BII)I", + { "readAsset", "(J[BII)I", (void*) android_content_AssetManager_readAsset }, - { "seekAsset", "(IJI)J", + { "seekAsset", "(JJI)J", (void*) android_content_AssetManager_seekAsset }, - { "getAssetLength", "(I)J", + { "getAssetLength", "(J)J", (void*) android_content_AssetManager_getAssetLength }, - { "getAssetRemainingLength", "(I)J", + { "getAssetRemainingLength", "(J)J", (void*) android_content_AssetManager_getAssetRemainingLength }, { "addAssetPathNative", "(Ljava/lang/String;)I", (void*) android_content_AssetManager_addAssetPath }, @@ -1674,27 +1684,27 @@ static JNINativeMethod gAssetManagerMethods[] = { (void*) android_content_AssetManager_loadResourceBagValue }, { "getStringBlockCount","()I", (void*) android_content_AssetManager_getStringBlockCount }, - { "getNativeStringBlock","(I)I", + { "getNativeStringBlock","(I)J", (void*) android_content_AssetManager_getNativeStringBlock }, { "getCookieName","(I)Ljava/lang/String;", (void*) android_content_AssetManager_getCookieName }, // Themes. - { "newTheme", "()I", + { "newTheme", "()J", (void*) android_content_AssetManager_newTheme }, - { "deleteTheme", "(I)V", + { "deleteTheme", "(J)V", (void*) android_content_AssetManager_deleteTheme }, - { "applyThemeStyle", "(IIZ)V", + { "applyThemeStyle", "(JIZ)V", (void*) android_content_AssetManager_applyThemeStyle }, - { "copyTheme", "(II)V", + { "copyTheme", "(JJ)V", (void*) android_content_AssetManager_copyTheme }, - { "loadThemeAttributeValue", "(IILandroid/util/TypedValue;Z)I", + { "loadThemeAttributeValue", "(JILandroid/util/TypedValue;Z)I", (void*) android_content_AssetManager_loadThemeAttributeValue }, - { "dumpTheme", "(IILjava/lang/String;Ljava/lang/String;)V", + { "dumpTheme", "(JILjava/lang/String;Ljava/lang/String;)V", (void*) android_content_AssetManager_dumpTheme }, - { "applyStyle","(IIII[I[I[I)Z", + { "applyStyle","(JIIJ[I[I[I)Z", (void*) android_content_AssetManager_applyStyle }, - { "retrieveAttributes","(I[I[I[I)Z", + { "retrieveAttributes","(J[I[I[I)Z", (void*) android_content_AssetManager_retrieveAttributes }, { "getArraySize","(I)I", (void*) android_content_AssetManager_getArraySize }, @@ -1702,7 +1712,7 @@ static JNINativeMethod gAssetManagerMethods[] = { (void*) android_content_AssetManager_retrieveArray }, // XML files. - { "openXmlAssetNative", "(ILjava/lang/String;)I", + { "openXmlAssetNative", "(ILjava/lang/String;)J", (void*) android_content_AssetManager_openXmlAssetNative }, // Arrays. @@ -1766,7 +1776,7 @@ int register_android_content_AssetManager(JNIEnv* env) jclass assetManager = env->FindClass("android/content/res/AssetManager"); LOG_FATAL_IF(assetManager == NULL, "Unable to find class android/content/res/AssetManager"); gAssetManagerOffsets.mObject - = env->GetFieldID(assetManager, "mObject", "I"); + = env->GetFieldID(assetManager, "mObject", "J"); LOG_FATAL_IF(gAssetManagerOffsets.mObject == NULL, "Unable to find AssetManager.mObject"); jclass stringClass = env->FindClass("java/lang/String"); diff --git a/core/jni/android_util_StringBlock.cpp b/core/jni/android_util_StringBlock.cpp index 463d3c0bd5cf..f29250f4619d 100644 --- a/core/jni/android_util_StringBlock.cpp +++ b/core/jni/android_util_StringBlock.cpp @@ -31,7 +31,7 @@ namespace android { // ---------------------------------------------------------------------------- -static jint android_content_StringBlock_nativeCreate(JNIEnv* env, jobject clazz, +static jlong android_content_StringBlock_nativeCreate(JNIEnv* env, jobject clazz, jbyteArray bArray, jint off, jint len) { @@ -56,13 +56,13 @@ static jint android_content_StringBlock_nativeCreate(JNIEnv* env, jobject clazz, return 0; } - return (jint)osb; + return reinterpret_cast<jlong>(osb); } static jint android_content_StringBlock_nativeGetSize(JNIEnv* env, jobject clazz, - jint token) + jlong token) { - ResStringPool* osb = (ResStringPool*)token; + ResStringPool* osb = reinterpret_cast<ResStringPool*>(token); if (osb == NULL) { jniThrowNullPointerException(env, NULL); return 0; @@ -72,9 +72,9 @@ static jint android_content_StringBlock_nativeGetSize(JNIEnv* env, jobject clazz } static jstring android_content_StringBlock_nativeGetString(JNIEnv* env, jobject clazz, - jint token, jint idx) + jlong token, jint idx) { - ResStringPool* osb = (ResStringPool*)token; + ResStringPool* osb = reinterpret_cast<ResStringPool*>(token); if (osb == NULL) { jniThrowNullPointerException(env, NULL); return 0; @@ -96,9 +96,9 @@ static jstring android_content_StringBlock_nativeGetString(JNIEnv* env, jobject } static jintArray android_content_StringBlock_nativeGetStyle(JNIEnv* env, jobject clazz, - jint token, jint idx) + jlong token, jint idx) { - ResStringPool* osb = (ResStringPool*)token; + ResStringPool* osb = reinterpret_cast<ResStringPool*>(token); if (osb == NULL) { jniThrowNullPointerException(env, NULL); return NULL; @@ -139,9 +139,9 @@ static jintArray android_content_StringBlock_nativeGetStyle(JNIEnv* env, jobject } static void android_content_StringBlock_nativeDestroy(JNIEnv* env, jobject clazz, - jint token) + jlong token) { - ResStringPool* osb = (ResStringPool*)token; + ResStringPool* osb = reinterpret_cast<ResStringPool*>(token); if (osb == NULL) { jniThrowNullPointerException(env, NULL); return; @@ -157,15 +157,15 @@ static void android_content_StringBlock_nativeDestroy(JNIEnv* env, jobject clazz */ static JNINativeMethod gStringBlockMethods[] = { /* name, signature, funcPtr */ - { "nativeCreate", "([BII)I", + { "nativeCreate", "([BII)J", (void*) android_content_StringBlock_nativeCreate }, - { "nativeGetSize", "(I)I", + { "nativeGetSize", "(J)I", (void*) android_content_StringBlock_nativeGetSize }, - { "nativeGetString", "(II)Ljava/lang/String;", + { "nativeGetString", "(JI)Ljava/lang/String;", (void*) android_content_StringBlock_nativeGetString }, - { "nativeGetStyle", "(II)[I", + { "nativeGetStyle", "(JI)[I", (void*) android_content_StringBlock_nativeGetStyle }, - { "nativeDestroy", "(I)V", + { "nativeDestroy", "(J)V", (void*) android_content_StringBlock_nativeDestroy }, }; diff --git a/core/jni/android_util_XmlBlock.cpp b/core/jni/android_util_XmlBlock.cpp index ad6033b1c175..03de5c0a1cd9 100644 --- a/core/jni/android_util_XmlBlock.cpp +++ b/core/jni/android_util_XmlBlock.cpp @@ -31,7 +31,7 @@ namespace android { // ---------------------------------------------------------------------------- -static jint android_content_XmlBlock_nativeCreate(JNIEnv* env, jobject clazz, +static jlong android_content_XmlBlock_nativeCreate(JNIEnv* env, jobject clazz, jbyteArray bArray, jint off, jint len) { @@ -55,25 +55,25 @@ static jint android_content_XmlBlock_nativeCreate(JNIEnv* env, jobject clazz, return 0; } - return (jint)osb; + return reinterpret_cast<jlong>(osb); } -static jint android_content_XmlBlock_nativeGetStringBlock(JNIEnv* env, jobject clazz, - jint token) +static jlong android_content_XmlBlock_nativeGetStringBlock(JNIEnv* env, jobject clazz, + jlong token) { - ResXMLTree* osb = (ResXMLTree*)token; + ResXMLTree* osb = reinterpret_cast<ResXMLTree*>(token); if (osb == NULL) { jniThrowNullPointerException(env, NULL); return 0; } - return (jint)&osb->getStrings(); + return reinterpret_cast<jlong>(&osb->getStrings()); } -static jint android_content_XmlBlock_nativeCreateParseState(JNIEnv* env, jobject clazz, - jint token) +static jlong android_content_XmlBlock_nativeCreateParseState(JNIEnv* env, jobject clazz, + jlong token) { - ResXMLTree* osb = (ResXMLTree*)token; + ResXMLTree* osb = reinterpret_cast<ResXMLTree*>(token); if (osb == NULL) { jniThrowNullPointerException(env, NULL); return 0; @@ -87,19 +87,19 @@ static jint android_content_XmlBlock_nativeCreateParseState(JNIEnv* env, jobject st->restart(); - return (jint)st; + return reinterpret_cast<jlong>(st); } static jint android_content_XmlBlock_nativeNext(JNIEnv* env, jobject clazz, - jint token) + jlong token) { - ResXMLParser* st = (ResXMLParser*)token; + ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token); if (st == NULL) { return ResXMLParser::END_DOCUMENT; } do { - jint code = (jint)st->next(); + ResXMLParser::event_code_t code = st->next(); switch (code) { case ResXMLParser::START_TAG: return 2; @@ -123,139 +123,139 @@ bad: } static jint android_content_XmlBlock_nativeGetNamespace(JNIEnv* env, jobject clazz, - jint token) + jlong token) { - ResXMLParser* st = (ResXMLParser*)token; + ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token); if (st == NULL) { return -1; } - return (jint)st->getElementNamespaceID(); + return static_cast<jint>(st->getElementNamespaceID()); } static jint android_content_XmlBlock_nativeGetName(JNIEnv* env, jobject clazz, - jint token) + jlong token) { - ResXMLParser* st = (ResXMLParser*)token; + ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token); if (st == NULL) { return -1; } - return (jint)st->getElementNameID(); + return static_cast<jint>(st->getElementNameID()); } static jint android_content_XmlBlock_nativeGetText(JNIEnv* env, jobject clazz, - jint token) + jlong token) { - ResXMLParser* st = (ResXMLParser*)token; + ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token); if (st == NULL) { return -1; } - return (jint)st->getTextID(); + return static_cast<jint>(st->getTextID()); } static jint android_content_XmlBlock_nativeGetLineNumber(JNIEnv* env, jobject clazz, - jint token) + jlong token) { - ResXMLParser* st = (ResXMLParser*)token; + ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token); if (st == NULL) { jniThrowNullPointerException(env, NULL); return 0; } - return (jint)st->getLineNumber(); + return static_cast<jint>(st->getLineNumber()); } static jint android_content_XmlBlock_nativeGetAttributeCount(JNIEnv* env, jobject clazz, - jint token) + jlong token) { - ResXMLParser* st = (ResXMLParser*)token; + ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token); if (st == NULL) { jniThrowNullPointerException(env, NULL); return 0; } - return (jint)st->getAttributeCount(); + return static_cast<jint>(st->getAttributeCount()); } static jint android_content_XmlBlock_nativeGetAttributeNamespace(JNIEnv* env, jobject clazz, - jint token, jint idx) + jlong token, jint idx) { - ResXMLParser* st = (ResXMLParser*)token; + ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token); if (st == NULL) { jniThrowNullPointerException(env, NULL); return 0; } - return (jint)st->getAttributeNamespaceID(idx); + return static_cast<jint>(st->getAttributeNamespaceID(idx)); } static jint android_content_XmlBlock_nativeGetAttributeName(JNIEnv* env, jobject clazz, - jint token, jint idx) + jlong token, jint idx) { - ResXMLParser* st = (ResXMLParser*)token; + ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token); if (st == NULL) { jniThrowNullPointerException(env, NULL); return 0; } - return (jint)st->getAttributeNameID(idx); + return static_cast<jint>(st->getAttributeNameID(idx)); } static jint android_content_XmlBlock_nativeGetAttributeResource(JNIEnv* env, jobject clazz, - jint token, jint idx) + jlong token, jint idx) { - ResXMLParser* st = (ResXMLParser*)token; + ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token); if (st == NULL) { jniThrowNullPointerException(env, NULL); return 0; } - return (jint)st->getAttributeNameResID(idx); + return static_cast<jint>(st->getAttributeNameResID(idx)); } static jint android_content_XmlBlock_nativeGetAttributeDataType(JNIEnv* env, jobject clazz, - jint token, jint idx) + jlong token, jint idx) { - ResXMLParser* st = (ResXMLParser*)token; + ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token); if (st == NULL) { jniThrowNullPointerException(env, NULL); return 0; } - return (jint)st->getAttributeDataType(idx); + return static_cast<jint>(st->getAttributeDataType(idx)); } static jint android_content_XmlBlock_nativeGetAttributeData(JNIEnv* env, jobject clazz, - jint token, jint idx) + jlong token, jint idx) { - ResXMLParser* st = (ResXMLParser*)token; + ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token); if (st == NULL) { jniThrowNullPointerException(env, NULL); return 0; } - return (jint)st->getAttributeData(idx); + return static_cast<jint>(st->getAttributeData(idx)); } static jint android_content_XmlBlock_nativeGetAttributeStringValue(JNIEnv* env, jobject clazz, - jint token, jint idx) + jlong token, jint idx) { - ResXMLParser* st = (ResXMLParser*)token; + ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token); if (st == NULL) { jniThrowNullPointerException(env, NULL); return 0; } - return (jint)st->getAttributeValueStringID(idx); + return static_cast<jint>(st->getAttributeValueStringID(idx)); } static jint android_content_XmlBlock_nativeGetAttributeIndex(JNIEnv* env, jobject clazz, - jint token, + jlong token, jstring ns, jstring name) { - ResXMLParser* st = (ResXMLParser*)token; + ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token); if (st == NULL || name == NULL) { jniThrowNullPointerException(env, NULL); return 0; @@ -271,7 +271,7 @@ static jint android_content_XmlBlock_nativeGetAttributeIndex(JNIEnv* env, jobjec const char16_t* name16 = env->GetStringChars(name, NULL); jsize nameLen = env->GetStringLength(name); - jint idx = (jint)st->indexOfAttribute(ns16, nsLen, name16, nameLen); + jint idx = static_cast<jint>(st->indexOfAttribute(ns16, nsLen, name16, nameLen)); if (ns) { env->ReleaseStringChars(ns, ns16); @@ -282,35 +282,35 @@ static jint android_content_XmlBlock_nativeGetAttributeIndex(JNIEnv* env, jobjec } static jint android_content_XmlBlock_nativeGetIdAttribute(JNIEnv* env, jobject clazz, - jint token) + jlong token) { - ResXMLParser* st = (ResXMLParser*)token; + ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token); if (st == NULL) { jniThrowNullPointerException(env, NULL); return 0; } ssize_t idx = st->indexOfID(); - return idx >= 0 ? (jint)st->getAttributeValueStringID(idx) : -1; + return idx >= 0 ? static_cast<jint>(st->getAttributeValueStringID(idx)) : -1; } static jint android_content_XmlBlock_nativeGetClassAttribute(JNIEnv* env, jobject clazz, - jint token) + jlong token) { - ResXMLParser* st = (ResXMLParser*)token; + ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token); if (st == NULL) { jniThrowNullPointerException(env, NULL); return 0; } ssize_t idx = st->indexOfClass(); - return idx >= 0 ? (jint)st->getAttributeValueStringID(idx) : -1; + return idx >= 0 ? static_cast<jint>(st->getAttributeValueStringID(idx)) : -1; } static jint android_content_XmlBlock_nativeGetStyleAttribute(JNIEnv* env, jobject clazz, - jint token) + jlong token) { - ResXMLParser* st = (ResXMLParser*)token; + ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token); if (st == NULL) { jniThrowNullPointerException(env, NULL); return 0; @@ -332,9 +332,9 @@ static jint android_content_XmlBlock_nativeGetStyleAttribute(JNIEnv* env, jobjec } static void android_content_XmlBlock_nativeDestroyParseState(JNIEnv* env, jobject clazz, - jint token) + jlong token) { - ResXMLParser* st = (ResXMLParser*)token; + ResXMLParser* st = reinterpret_cast<ResXMLParser*>(token); if (st == NULL) { jniThrowNullPointerException(env, NULL); return; @@ -344,9 +344,9 @@ static void android_content_XmlBlock_nativeDestroyParseState(JNIEnv* env, jobjec } static void android_content_XmlBlock_nativeDestroy(JNIEnv* env, jobject clazz, - jint token) + jlong token) { - ResXMLTree* osb = (ResXMLTree*)token; + ResXMLTree* osb = reinterpret_cast<ResXMLTree*>(token); if (osb == NULL) { jniThrowNullPointerException(env, NULL); return; @@ -362,47 +362,47 @@ static void android_content_XmlBlock_nativeDestroy(JNIEnv* env, jobject clazz, */ static JNINativeMethod gXmlBlockMethods[] = { /* name, signature, funcPtr */ - { "nativeCreate", "([BII)I", + { "nativeCreate", "([BII)J", (void*) android_content_XmlBlock_nativeCreate }, - { "nativeGetStringBlock", "(I)I", + { "nativeGetStringBlock", "(J)J", (void*) android_content_XmlBlock_nativeGetStringBlock }, - { "nativeCreateParseState", "(I)I", + { "nativeCreateParseState", "(J)J", (void*) android_content_XmlBlock_nativeCreateParseState }, - { "nativeNext", "(I)I", + { "nativeNext", "(J)I", (void*) android_content_XmlBlock_nativeNext }, - { "nativeGetNamespace", "(I)I", + { "nativeGetNamespace", "(J)I", (void*) android_content_XmlBlock_nativeGetNamespace }, - { "nativeGetName", "(I)I", + { "nativeGetName", "(J)I", (void*) android_content_XmlBlock_nativeGetName }, - { "nativeGetText", "(I)I", + { "nativeGetText", "(J)I", (void*) android_content_XmlBlock_nativeGetText }, - { "nativeGetLineNumber", "(I)I", + { "nativeGetLineNumber", "(J)I", (void*) android_content_XmlBlock_nativeGetLineNumber }, - { "nativeGetAttributeCount", "(I)I", + { "nativeGetAttributeCount", "(J)I", (void*) android_content_XmlBlock_nativeGetAttributeCount }, - { "nativeGetAttributeNamespace","(II)I", + { "nativeGetAttributeNamespace","(JI)I", (void*) android_content_XmlBlock_nativeGetAttributeNamespace }, - { "nativeGetAttributeName", "(II)I", + { "nativeGetAttributeName", "(JI)I", (void*) android_content_XmlBlock_nativeGetAttributeName }, - { "nativeGetAttributeResource", "(II)I", + { "nativeGetAttributeResource", "(JI)I", (void*) android_content_XmlBlock_nativeGetAttributeResource }, - { "nativeGetAttributeDataType", "(II)I", + { "nativeGetAttributeDataType", "(JI)I", (void*) android_content_XmlBlock_nativeGetAttributeDataType }, - { "nativeGetAttributeData", "(II)I", + { "nativeGetAttributeData", "(JI)I", (void*) android_content_XmlBlock_nativeGetAttributeData }, - { "nativeGetAttributeStringValue", "(II)I", + { "nativeGetAttributeStringValue", "(JI)I", (void*) android_content_XmlBlock_nativeGetAttributeStringValue }, - { "nativeGetAttributeIndex", "(ILjava/lang/String;Ljava/lang/String;)I", + { "nativeGetAttributeIndex", "(JLjava/lang/String;Ljava/lang/String;)I", (void*) android_content_XmlBlock_nativeGetAttributeIndex }, - { "nativeGetIdAttribute", "(I)I", + { "nativeGetIdAttribute", "(J)I", (void*) android_content_XmlBlock_nativeGetIdAttribute }, - { "nativeGetClassAttribute", "(I)I", + { "nativeGetClassAttribute", "(J)I", (void*) android_content_XmlBlock_nativeGetClassAttribute }, - { "nativeGetStyleAttribute", "(I)I", + { "nativeGetStyleAttribute", "(J)I", (void*) android_content_XmlBlock_nativeGetStyleAttribute }, - { "nativeDestroyParseState", "(I)V", + { "nativeDestroyParseState", "(J)V", (void*) android_content_XmlBlock_nativeDestroyParseState }, - { "nativeDestroy", "(I)V", + { "nativeDestroy", "(J)V", (void*) android_content_XmlBlock_nativeDestroy }, }; diff --git a/include/androidfw/ResourceTypes.h b/include/androidfw/ResourceTypes.h index 5151b06aec5b..679976649733 100644 --- a/include/androidfw/ResourceTypes.h +++ b/include/androidfw/ResourceTypes.h @@ -1279,14 +1279,13 @@ class ResTable { public: ResTable(); - ResTable(const void* data, size_t size, void* cookie, + ResTable(const void* data, size_t size, const int32_t cookie, bool copyData=false); ~ResTable(); - status_t add(const void* data, size_t size, void* cookie, - bool copyData=false, const void* idmap = NULL); - status_t add(Asset* asset, void* cookie, - bool copyData=false, const void* idmap = NULL); + status_t add(Asset* asset, const int32_t cookie, bool copyData, + const void* idmap); + status_t add(const void *data, size_t size); status_t add(ResTable* src); status_t getError() const; @@ -1534,7 +1533,7 @@ public: // but not the names their entries or types. const ResStringPool* getTableStringBlock(size_t index) const; // Return unique cookie identifier for the given resource table. - void* getTableCookie(size_t index) const; + int32_t getTableCookie(size_t index) const; // Return the configurations (ResTable_config) that we know about void getConfigurations(Vector<ResTable_config>* configs) const; @@ -1569,7 +1568,7 @@ private: struct PackageGroup; struct bag_set; - status_t add(const void* data, size_t size, void* cookie, + status_t addInternal(const void* data, size_t size, const int32_t cookie, Asset* asset, bool copyData, const Asset* idmap); ssize_t getResourcePackageIndex(uint32_t resID) const; diff --git a/libs/androidfw/AssetManager.cpp b/libs/androidfw/AssetManager.cpp index 52ab361846f6..08328d06ac7d 100644 --- a/libs/androidfw/AssetManager.cpp +++ b/libs/androidfw/AssetManager.cpp @@ -335,7 +335,7 @@ bool AssetManager::createIdmapFileLocked(const String8& originalPath, const Stri ALOGW("failed to find resources.arsc in %s\n", ap.path.string()); goto error; } - tables[i].add(ass, (void*)1, false); + tables[i].add(ass, 1, false /* copyData */, NULL /* idMap */); } if (!getZipEntryCrcLocked(originalPath, "resources.arsc", &originalCrc)) { @@ -682,7 +682,7 @@ const ResTable* AssetManager::getResTable(bool required) const // can quickly copy it out for others. ALOGV("Creating shared resources for %s", ap.path.string()); sharedRes = new ResTable(); - sharedRes->add(ass, (void*)(i+1), false, idmap); + sharedRes->add(ass, i + 1, false, idmap); sharedRes = const_cast<AssetManager*>(this)-> mZipSet.setZipResourceTable(ap.path, sharedRes); } @@ -706,7 +706,7 @@ const ResTable* AssetManager::getResTable(bool required) const rt->add(sharedRes); } else { ALOGV("Parsing resources for %s", ap.path.string()); - rt->add(ass, (void*)(i+1), !shared, idmap); + rt->add(ass, i + 1, !shared, idmap); } if (!shared) { diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp index 1cc3563e0f3d..72d331c520a7 100644 --- a/libs/androidfw/ResourceTypes.cpp +++ b/libs/androidfw/ResourceTypes.cpp @@ -66,9 +66,9 @@ namespace android { // size measured in sizeof(uint32_t) #define IDMAP_HEADER_SIZE (ResTable::IDMAP_HEADER_SIZE_BYTES / sizeof(uint32_t)) -static void printToLogFunc(void* cookie, const char* txt) +static void printToLogFunc(int32_t cookie, const char* txt) { - ALOGV("%s", txt); + ALOGV("[cookie=%d] %s", cookie, txt); } // Standard C isspace() is only required to look at the low byte of its input, so @@ -2461,7 +2461,7 @@ struct ResTable::Header size_t size; const uint8_t* dataEnd; size_t index; - void* cookie; + int32_t cookie; ResStringPool values; uint32_t* resourceIDMap; @@ -2860,12 +2860,12 @@ ResTable::ResTable() //ALOGI("Creating ResTable %p\n", this); } -ResTable::ResTable(const void* data, size_t size, void* cookie, bool copyData) +ResTable::ResTable(const void* data, size_t size, const int32_t cookie, bool copyData) : mError(NO_INIT) { memset(&mParams, 0, sizeof(mParams)); memset(mPackageMap, 0, sizeof(mPackageMap)); - add(data, size, cookie, copyData); + addInternal(data, size, cookie, NULL /* asset */, copyData, NULL /* idMap */); LOG_FATAL_IF(mError != NO_ERROR, "Error parsing resource table"); //ALOGI("Creating ResTable %p\n", this); } @@ -2881,13 +2881,12 @@ inline ssize_t ResTable::getResourcePackageIndex(uint32_t resID) const return ((ssize_t)mPackageMap[Res_GETPACKAGE(resID)+1])-1; } -status_t ResTable::add(const void* data, size_t size, void* cookie, bool copyData, - const void* idmap) -{ - return add(data, size, cookie, NULL, copyData, reinterpret_cast<const Asset*>(idmap)); +status_t ResTable::add(const void* data, size_t size) { + return addInternal(data, size, 0 /* cookie */, NULL /* asset */, + false /* copyData */, NULL /* idMap */); } -status_t ResTable::add(Asset* asset, void* cookie, bool copyData, const void* idmap) +status_t ResTable::add(Asset* asset, const int32_t cookie, bool copyData, const void* idmap) { const void* data = asset->getBuffer(true); if (data == NULL) { @@ -2895,7 +2894,8 @@ status_t ResTable::add(Asset* asset, void* cookie, bool copyData, const void* id return UNKNOWN_ERROR; } size_t size = (size_t)asset->getLength(); - return add(data, size, cookie, asset, copyData, reinterpret_cast<const Asset*>(idmap)); + return addInternal(data, size, cookie, asset, copyData, + reinterpret_cast<const Asset*>(idmap)); } status_t ResTable::add(ResTable* src) @@ -2922,7 +2922,7 @@ status_t ResTable::add(ResTable* src) return mError; } -status_t ResTable::add(const void* data, size_t size, void* cookie, +status_t ResTable::addInternal(const void* data, size_t size, const int32_t cookie, Asset* asset, bool copyData, const Asset* idmap) { if (!data) return NO_ERROR; @@ -2945,7 +2945,7 @@ status_t ResTable::add(const void* data, size_t size, void* cookie, const bool notDeviceEndian = htods(0xf0) != 0xf0; LOAD_TABLE_NOISY( - ALOGV("Adding resources to ResTable: data=%p, size=0x%x, cookie=%p, asset=%p, copy=%d " + ALOGV("Adding resources to ResTable: data=%p, size=0x%x, cookie=%d, asset=%p, copy=%d " "idmap=%p\n", data, size, cookie, asset, copyData, idmap)); if (copyData || notDeviceEndian) { @@ -4930,7 +4930,7 @@ const ResStringPool* ResTable::getTableStringBlock(size_t index) const return &mHeaders[index]->values; } -void* ResTable::getTableCookie(size_t index) const +int32_t ResTable::getTableCookie(size_t index) const { return mHeaders[index]->cookie; } diff --git a/native/android/asset_manager.cpp b/native/android/asset_manager.cpp index 01db1d3cace4..dee3f8c700ed 100644 --- a/native/android/asset_manager.cpp +++ b/native/android/asset_manager.cpp @@ -76,12 +76,12 @@ AAssetManager* AAssetManager_fromJava(JNIEnv* env, jobject assetManager) if (gJNIConfigured == false) { jclass amClass = env->FindClass("android/content/res/AssetManager"); - gAssetManagerOffsets.mObject = env->GetFieldID(amClass, "mObject", "I"); + gAssetManagerOffsets.mObject = env->GetFieldID(amClass, "mObject", "J"); gJNIConfigured = true; } } - return (AAssetManager*) env->GetIntField(assetManager, gAssetManagerOffsets.mObject); + return (AAssetManager*) env->GetLongField(assetManager, gAssetManagerOffsets.mObject); } AAsset* AAssetManager_open(AAssetManager* amgr, const char* filename, int mode) diff --git a/preloaded-classes b/preloaded-classes index 342126d56b41..02bd0bcf6461 100644 --- a/preloaded-classes +++ b/preloaded-classes @@ -2456,8 +2456,6 @@ org.apache.harmony.security.fortress.Engine$ServiceCacheEntry org.apache.harmony.security.fortress.Engine$SpiAndProvider org.apache.harmony.security.fortress.SecurityAccess org.apache.harmony.security.fortress.Services -org.apache.harmony.security.provider.cert.DRLCertFactory -org.apache.harmony.security.provider.cert.X509CertImpl org.apache.harmony.security.provider.crypto.CryptoProvider org.apache.harmony.security.utils.AlgNameMapper org.apache.harmony.security.utils.ObjectIdentifier diff --git a/tools/aapt/AaptAssets.cpp b/tools/aapt/AaptAssets.cpp index d8e113a2d140..ebf45382af85 100644 --- a/tools/aapt/AaptAssets.cpp +++ b/tools/aapt/AaptAssets.cpp @@ -2651,7 +2651,7 @@ status_t AaptAssets::addIncludedResources(const sp<AaptFile>& file) { const ResTable& res = getIncludedResources(); // XXX dirty! - return const_cast<ResTable&>(res).add(file->getData(), file->getSize(), NULL); + return const_cast<ResTable&>(res).add(file->getData(), file->getSize()); } const ResTable& AaptAssets::getIncludedResources() const diff --git a/tools/aapt/Resource.cpp b/tools/aapt/Resource.cpp index 386888bb14ed..57d44f2a4ab0 100644 --- a/tools/aapt/Resource.cpp +++ b/tools/aapt/Resource.cpp @@ -1320,8 +1320,7 @@ status_t buildResources(Bundle* bundle, const sp<AaptAssets>& assets) } // Read resources back in, - finalResTable.add(resFile->getData(), resFile->getSize(), NULL); - + finalResTable.add(resFile->getData(), resFile->getSize()); #if 0 NOISY( printf("Generated resources:\n"); |