mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
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:
parent
63c38bf6fa
commit
d47e663efa
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user