Remove FastJNI optimization on AssetManager to avoid dead lock.

I found there was a dead lock among main, android.display and GC threads
when running monkey test.
 - Main thread got a mutex and was suspended by GC thread.
 - Android.display thread waited for mutex held by main thread.
 - GC thread waited for suspention of android.display thread.

This will lead to ANR or screen freeze.

Fixes: 32480078
Test: builds

Change-Id: I13cf1eca3cb3b7c01aa754874f2b48aab0b472e8
This commit is contained in:
Tim Zhang
2017-02-16 09:55:27 +08:00
committed by John Reck
parent d632305e37
commit fe25b1adaf
2 changed files with 0 additions and 44 deletions

View File

@@ -776,7 +776,6 @@ 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,
@@ -786,18 +785,13 @@ 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);
@@ -811,19 +805,15 @@ 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;
@@ -836,24 +826,17 @@ 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 void applyStyle(long theme,
int defStyleAttr, int defStyleRes, long xmlParser,
int[] inAttrs, int length, long outValuesAddress, long outIndicesAddress);
@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);
/**
@@ -886,22 +869,17 @@ 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);

View File

@@ -1578,10 +1578,8 @@ static const JNINativeMethod gAssetManagerMethods[] = {
(void*) android_content_AssetManager_readAsset },
{ "seekAsset", "(JJI)J",
(void*) android_content_AssetManager_seekAsset },
// @FastNative
{ "getAssetLength", "(J)J",
(void*) android_content_AssetManager_getAssetLength },
// @FastNative
{ "getAssetRemainingLength", "(J)J",
(void*) android_content_AssetManager_getAssetRemainingLength },
{ "addAssetPathNative", "(Ljava/lang/String;Z)I",
@@ -1598,34 +1596,24 @@ static const JNINativeMethod gAssetManagerMethods[] = {
(void*) android_content_AssetManager_getNonSystemLocales },
{ "getSizeConfigurations", "()[Landroid/content/res/Configuration;",
(void*) android_content_AssetManager_getSizeConfigurations },
// @FastNative
{ "setConfiguration", "(IILjava/lang/String;IIIIIIIIIIIIIII)V",
(void*) android_content_AssetManager_setConfiguration },
// @FastNative
{ "getResourceIdentifier","(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I",
(void*) android_content_AssetManager_getResourceIdentifier },
// @FastNative
{ "getResourceName","(I)Ljava/lang/String;",
(void*) android_content_AssetManager_getResourceName },
// @FastNative
{ "getResourcePackageName","(I)Ljava/lang/String;",
(void*) android_content_AssetManager_getResourcePackageName },
// @FastNative
{ "getResourceTypeName","(I)Ljava/lang/String;",
(void*) android_content_AssetManager_getResourceTypeName },
// @FastNative
{ "getResourceEntryName","(I)Ljava/lang/String;",
(void*) android_content_AssetManager_getResourceEntryName },
// @FastNative
{ "loadResourceValue","(ISLandroid/util/TypedValue;Z)I",
(void*) android_content_AssetManager_loadResourceValue },
// @FastNative
{ "loadResourceBagValue","(IILandroid/util/TypedValue;Z)I",
(void*) android_content_AssetManager_loadResourceBagValue },
// @FastNative
{ "getStringBlockCount","()I",
(void*) android_content_AssetManager_getStringBlockCount },
// @FastNative
{ "getNativeStringBlock","(I)J",
(void*) android_content_AssetManager_getNativeStringBlock },
{ "getCookieName","(I)Ljava/lang/String;",
@@ -1644,27 +1632,20 @@ static const JNINativeMethod gAssetManagerMethods[] = {
(void*) android_content_AssetManager_copyTheme },
{ "clearTheme", "(J)V",
(void*) android_content_AssetManager_clearTheme },
// @FastNative
{ "loadThemeAttributeValue", "(JILandroid/util/TypedValue;Z)I",
(void*) android_content_AssetManager_loadThemeAttributeValue },
// @FastNative
{ "getThemeChangingConfigurations", "(J)I",
(void*) android_content_AssetManager_getThemeChangingConfigurations },
{ "dumpTheme", "(JILjava/lang/String;Ljava/lang/String;)V",
(void*) android_content_AssetManager_dumpTheme },
// @FastNative
{ "applyStyle","(JIIJ[IIJJ)V",
(void*) android_content_AssetManager_applyStyle },
// @FastNative
{ "resolveAttrs","(JII[I[I[I[I)Z",
(void*) android_content_AssetManager_resolveAttrs },
// @FastNative
{ "retrieveAttributes","(J[I[I[I)Z",
(void*) android_content_AssetManager_retrieveAttributes },
// @FastNative
{ "getArraySize","(I)I",
(void*) android_content_AssetManager_getArraySize },
// @FastNative
{ "retrieveArray","(I[I)I",
(void*) android_content_AssetManager_retrieveArray },
@@ -1675,13 +1656,10 @@ static const JNINativeMethod gAssetManagerMethods[] = {
// Arrays.
{ "getArrayStringResource","(I)[Ljava/lang/String;",
(void*) android_content_AssetManager_getArrayStringResource },
// @FastNative
{ "getArrayStringInfo","(I)[I",
(void*) android_content_AssetManager_getArrayStringInfo },
// @FastNative
{ "getArrayIntResource","(I)[I",
(void*) android_content_AssetManager_getArrayIntResource },
// @FastNative
{ "getStyleAttributes","(I)[I",
(void*) android_content_AssetManager_getStyleAttributes },