5#include "flutter/shell/platform/android/apk_asset_provider.h"
13#include "flutter/assets/asset_resolver.h"
14#include "flutter/fml/logging.h"
24 size_t GetSize()
const override {
return AAsset_getLength(asset_); }
27 return reinterpret_cast<const uint8_t*
>(AAsset_getBuffer(asset_));
41 jobject jassetManager,
42 std::string directory)
43 : java_asset_manager_(
env, jassetManager),
44 directory_(
std::move(directory)) {
45 asset_manager_ = AAssetManager_fromJava(
env, jassetManager);
51 const std::string& asset_name)
const override {
53 ss << directory_.c_str() <<
"/" << asset_name;
54 AAsset* asset = AAssetManager_open(asset_manager_, ss.str().c_str(),
60 return std::make_unique<APKAssetMapping>(asset);
65 AAssetManager* asset_manager_;
66 const std::string directory_;
73 std::string directory)
76 std::move(directory))) {}
79 std::shared_ptr<APKAssetProviderInternal> impl)
80 : impl_(
std::move(impl)) {}
83bool APKAssetProvider::IsValid()
const {
88bool APKAssetProvider::IsValidAfterAssetManagerChange()
const {
94 return AssetResolver::AssetResolverType::kApkAssetProvider;
98std::unique_ptr<fml::Mapping> APKAssetProvider::GetAsMapping(
99 const std::string& asset_name)
const {
100 return impl_->GetAsMapping(asset_name);
104 return std::make_unique<APKAssetProvider>(impl_);
109 if (!other_provider) {
112 return impl_ == other_provider->impl_;
~APKAssetMapping() override
APKAssetMapping(AAsset *asset)
size_t GetSize() const override
const uint8_t * GetMapping() const override
bool IsDontNeedSafe() const override
std::unique_ptr< fml::Mapping > GetAsMapping(const std::string &asset_name) const override
~APKAssetProviderImpl()=default
APKAssetProviderImpl(JNIEnv *env, jobject jassetManager, std::string directory)
bool operator==(const AssetResolver &other) const override
APKAssetProvider(JNIEnv *env, jobject assetManager, std::string directory)
std::unique_ptr< APKAssetProvider > Clone() const
AssetResolverType
Identifies the type of AssetResolver an instance is.
virtual const APKAssetProvider * as_apk_asset_provider() const