Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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_SHELL_PLATFORM_ANDROID_APK_ASSET_PROVIDER_H_
6#define FLUTTER_SHELL_PLATFORM_ANDROID_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
15namespace flutter {
16
18 public:
19 virtual std::unique_ptr<fml::Mapping> GetAsMapping(
20 const std::string& asset_name) const = 0;
21
22 protected:
23 virtual ~APKAssetProviderInternal() = default;
24};
25
26class APKAssetProvider final : public AssetResolver {
27 public:
28 explicit APKAssetProvider(JNIEnv* env,
29 jobject assetManager,
30 std::string directory);
31
32 explicit APKAssetProvider(std::shared_ptr<APKAssetProviderInternal> impl);
33
34 ~APKAssetProvider() = default;
35
36 // Returns a new 'std::unique_ptr<APKAssetProvider>' with the same 'impl_' as
37 // this provider.
38 std::unique_ptr<APKAssetProvider> Clone() const;
39
40 // Obtain a raw pointer to the APKAssetProviderInternal.
41 //
42 // This method is intended for use in tests. Callers must not
43 // delete the returned pointer.
44 APKAssetProviderInternal* GetImpl() const { return impl_.get(); }
45
46 bool operator==(const AssetResolver& other) const override;
47
48 private:
49 std::shared_ptr<APKAssetProviderInternal> impl_;
50
51 // |flutter::AssetResolver|
52 bool IsValid() const override;
53
54 // |flutter::AssetResolver|
55 bool IsValidAfterAssetManagerChange() const override;
56
57 // |AssetResolver|
59
60 // |flutter::AssetResolver|
61 std::unique_ptr<fml::Mapping> GetAsMapping(
62 const std::string& asset_name) const override;
63
64 // |AssetResolver|
65 const APKAssetProvider* as_apk_asset_provider() const override {
66 return this;
67 }
68
70};
71
72} // namespace flutter
73
74#endif // FLUTTER_SHELL_PLATFORM_ANDROID_APK_ASSET_PROVIDER_H_
virtual ~APKAssetProviderInternal()=default
virtual std::unique_ptr< fml::Mapping > GetAsMapping(const std::string &asset_name) const =0
bool IsValid() const override
bool operator==(const AssetResolver &other) const override
std::unique_ptr< fml::Mapping > GetAsMapping(const std::string &asset_name) const override
APKAssetProviderInternal * GetImpl() const
const APKAssetProvider * as_apk_asset_provider() const override
std::unique_ptr< APKAssetProvider > Clone() const
bool IsValidAfterAssetManagerChange() const override
Certain asset resolvers are still valid after the asset manager is replaced before a hot reload,...
AssetResolver::AssetResolverType GetType() const override
Gets the type of AssetResolver this is. Types are defined in AssetResolverType.
AssetResolverType
Identifies the type of AssetResolver an instance is.
#define FML_DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition macros.h:27
Definition __init__.py:1