Move registration of AssetManager.mObject to zygote.
bug: 73865351 Test: m Change-Id: I9d0f0c8ae016b8823246e25bfdbff0d4fd8eaae1
This commit is contained in:
@@ -75,9 +75,8 @@ static struct assetfiledescriptor_offsets_t {
|
||||
jfieldID mLength;
|
||||
} gAssetFileDescriptorOffsets;
|
||||
|
||||
static struct assetmanager_offsets_t {
|
||||
jfieldID mObject;
|
||||
} gAssetManagerOffsets;
|
||||
// This is also used by asset_manager.cpp.
|
||||
assetmanager_offsets_t gAssetManagerOffsets;
|
||||
|
||||
static struct {
|
||||
jfieldID native_ptr;
|
||||
|
||||
@@ -27,6 +27,11 @@ namespace android {
|
||||
extern AAssetManager* NdkAssetManagerForJavaObject(JNIEnv* env, jobject jassetmanager);
|
||||
extern Guarded<AssetManager2>* AssetManagerForJavaObject(JNIEnv* env, jobject jassetmanager);
|
||||
extern Guarded<AssetManager2>* AssetManagerForNdkAssetManager(AAssetManager* assetmanager);
|
||||
struct assetmanager_offsets_t
|
||||
{
|
||||
jfieldID mObject;
|
||||
};
|
||||
extern assetmanager_offsets_t gAssetManagerOffsets;
|
||||
|
||||
} // namespace android
|
||||
|
||||
|
||||
@@ -55,33 +55,11 @@ struct AAsset {
|
||||
|
||||
// -------------------- Public native C API --------------------
|
||||
|
||||
/**
|
||||
* Supporting information
|
||||
*/
|
||||
|
||||
static struct assetmanager_offsets_t
|
||||
{
|
||||
jfieldID mObject;
|
||||
} gAssetManagerOffsets;
|
||||
|
||||
static volatile bool gJNIConfigured = false;
|
||||
static Mutex gMutex;
|
||||
|
||||
/**
|
||||
* Asset Manager functionality
|
||||
*/
|
||||
AAssetManager* AAssetManager_fromJava(JNIEnv* env, jobject assetManager)
|
||||
{
|
||||
{
|
||||
Mutex::Autolock _l(gMutex);
|
||||
|
||||
if (gJNIConfigured == false) {
|
||||
jclass amClass = env->FindClass("android/content/res/AssetManager");
|
||||
gAssetManagerOffsets.mObject = env->GetFieldID(amClass, "mObject", "J");
|
||||
gJNIConfigured = true;
|
||||
}
|
||||
}
|
||||
|
||||
return (AAssetManager*) env->GetLongField(assetManager, gAssetManagerOffsets.mObject);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user