Flutter Engine
apk_asset_provider.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef FLUTTER_ASSETS_APK_ASSET_PROVIDER_H_
6 #define FLUTTER_ASSETS_APK_ASSET_PROVIDER_H_
7 
8 #include <android/asset_manager_jni.h>
9 #include <jni.h>
10 
11 #include "flutter/assets/asset_resolver.h"
12 #include "flutter/fml/memory/ref_counted.h"
13 #include "flutter/fml/platform/android/scoped_java_ref.h"
14 
15 namespace flutter {
16 
17 class APKAssetProvider final : public AssetResolver {
18  public:
19  explicit APKAssetProvider(JNIEnv* env,
20  jobject assetManager,
21  std::string directory);
22  ~APKAssetProvider() override;
23 
24  private:
25  fml::jni::ScopedJavaGlobalRef<jobject> java_asset_manager_;
26  AAssetManager* assetManager_;
27  const std::string directory_;
28 
29  // |flutter::AssetResolver|
30  bool IsValid() const override;
31 
32  // |flutter::AssetResolver|
33  bool IsValidAfterAssetManagerChange() const override;
34 
35  // |flutter::AssetResolver|
36  std::unique_ptr<fml::Mapping> GetAsMapping(
37  const std::string& asset_name) const override;
38 
39  FML_DISALLOW_COPY_AND_ASSIGN(APKAssetProvider);
40 };
41 
42 } // namespace flutter
43 
44 #endif // FLUTTER_ASSETS_APK_ASSET_PROVIDER_H
APKAssetProvider(JNIEnv *env, jobject assetManager, std::string directory)