Re-land "Hold a global reference to the AssetManager Java object backing the APKAssetProvider" (flutter/engine#5132)

Fixes https://github.com/flutter/flutter/issues/16222
This commit is contained in:
Jason Simmons 2018-04-30 12:29:40 -07:00 committed by GitHub
parent 63c38bf6fa
commit d47e663efa
2 changed files with 5 additions and 2 deletions

View File

@ -10,7 +10,8 @@ namespace blink {
APKAssetProvider::APKAssetProvider(JNIEnv* env,
jobject jassetManager,
std::string directory)
: directory_(std::move(directory)) {
: java_asset_manager_(env, jassetManager),
directory_(std::move(directory)) {
assetManager_ = AAssetManager_fromJava(env, jassetManager);
}

View File

@ -9,6 +9,7 @@
#include <jni.h>
#include "flutter/assets/asset_resolver.h"
#include "flutter/fml/platform/android/scoped_java_ref.h"
#include "lib/fxl/memory/ref_counted.h"
namespace blink {
@ -21,6 +22,7 @@ class APKAssetProvider final : public AssetResolver {
virtual ~APKAssetProvider();
private:
fml::jni::ScopedJavaGlobalRef<jobject> java_asset_manager_;
AAssetManager* assetManager_;
const std::string directory_;
@ -36,4 +38,4 @@ class APKAssetProvider final : public AssetResolver {
} // namespace blink
#endif // FLUTTER_ASSETS_APK_ASSET_PROVIDER_H
#endif // FLUTTER_ASSETS_APK_ASSET_PROVIDER_H