Loading core/jni/android_content_res_ApkAssets.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -96,7 +96,7 @@ class LoaderAssetsProvider : public AssetsProvider { } bool ForEachFile(const std::string& /* root_path */, const std::function<void(StringPiece, FileType)>& /* f */) const { android::base::function_ref<void(StringPiece, FileType)> /* f */) const { return true; } Loading libs/androidfw/AssetManager2.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -1562,11 +1562,11 @@ base::expected<std::monostate, IOError> Theme::SetTo(const Theme& source) { std::unordered_map<ApkAssetsCookie, SourceToDestinationRuntimePackageMap> src_asset_cookie_id_map; // Determine which ApkAssets are loaded in both theme AssetManagers. const auto src_assets = source.asset_manager_->GetApkAssets(); const auto& src_assets = source.asset_manager_->GetApkAssets(); for (size_t i = 0; i < src_assets.size(); i++) { const ApkAssets* src_asset = src_assets[i]; const auto dest_assets = asset_manager_->GetApkAssets(); const auto& dest_assets = asset_manager_->GetApkAssets(); for (size_t j = 0; j < dest_assets.size(); j++) { const ApkAssets* dest_asset = dest_assets[j]; if (src_asset != dest_asset) { Loading libs/androidfw/AssetsProvider.cpp +22 −23 Original line number Diff line number Diff line Loading @@ -73,9 +73,6 @@ std::unique_ptr<Asset> AssetsProvider::CreateAssetFromFd(base::unique_fd fd, (path != nullptr) ? base::unique_fd(-1) : std::move(fd)); } ZipAssetsProvider::PathOrDebugName::PathOrDebugName(std::string&& value, bool is_path) : value_(std::forward<std::string>(value)), is_path_(is_path) {} const std::string* ZipAssetsProvider::PathOrDebugName::GetPath() const { return is_path_ ? &value_ : nullptr; } Loading @@ -84,10 +81,14 @@ const std::string& ZipAssetsProvider::PathOrDebugName::GetDebugName() const { return value_; } void ZipAssetsProvider::ZipCloser::operator()(ZipArchive* a) const { ::CloseArchive(a); } ZipAssetsProvider::ZipAssetsProvider(ZipArchiveHandle handle, PathOrDebugName&& path, package_property_t flags, time_t last_mod_time) : zip_handle_(handle, ::CloseArchive), name_(std::forward<PathOrDebugName>(path)), : zip_handle_(handle), name_(std::move(path)), flags_(flags), last_mod_time_(last_mod_time) {} Loading @@ -110,14 +111,12 @@ std::unique_ptr<ZipAssetsProvider> ZipAssetsProvider::Create(std::string path, // Stat requires execute permissions on all directories path to the file. If the process does // not have execute permissions on this file, allow the zip to be opened but IsUpToDate() will // always have to return true. LOG(WARNING) << "Failed to stat file '" << path << "': " << base::SystemErrorCodeToString(errno); PLOG(WARNING) << "Failed to stat file '" << path << "'"; } } return std::unique_ptr<ZipAssetsProvider>( new ZipAssetsProvider(handle, PathOrDebugName{std::move(path), true /* is_path */}, flags, sb.st_mtime)); new ZipAssetsProvider(handle, PathOrDebugName::Path(std::move(path)), flags, sb.st_mtime)); } std::unique_ptr<ZipAssetsProvider> ZipAssetsProvider::Create(base::unique_fd fd, Loading Loading @@ -150,9 +149,8 @@ std::unique_ptr<ZipAssetsProvider> ZipAssetsProvider::Create(base::unique_fd fd, } } return std::unique_ptr<ZipAssetsProvider>( new ZipAssetsProvider(handle, PathOrDebugName{std::move(friendly_name), false /* is_path */}, flags, sb.st_mtime)); return std::unique_ptr<ZipAssetsProvider>(new ZipAssetsProvider( handle, PathOrDebugName::DebugName(std::move(friendly_name)), flags, sb.st_mtime)); } std::unique_ptr<Asset> ZipAssetsProvider::OpenInternal(const std::string& path, Loading Loading @@ -219,8 +217,9 @@ std::unique_ptr<Asset> ZipAssetsProvider::OpenInternal(const std::string& path, return asset; } bool ZipAssetsProvider::ForEachFile(const std::string& root_path, const std::function<void(StringPiece, FileType)>& f) const { bool ZipAssetsProvider::ForEachFile( const std::string& root_path, base::function_ref<void(StringPiece, FileType)> f) const { std::string root_path_full = root_path; if (root_path_full.back() != '/') { root_path_full += '/'; Loading Loading @@ -297,7 +296,7 @@ bool ZipAssetsProvider::IsUpToDate() const { } DirectoryAssetsProvider::DirectoryAssetsProvider(std::string&& path, time_t last_mod_time) : dir_(std::forward<std::string>(path)), last_mod_time_(last_mod_time) {} : dir_(std::move(path)), last_mod_time_(last_mod_time) {} std::unique_ptr<DirectoryAssetsProvider> DirectoryAssetsProvider::Create(std::string path) { struct stat sb; Loading @@ -312,7 +311,7 @@ std::unique_ptr<DirectoryAssetsProvider> DirectoryAssetsProvider::Create(std::st return nullptr; } if (path[path.size() - 1] != OS_PATH_SEPARATOR) { if (path.back() != OS_PATH_SEPARATOR) { path += OS_PATH_SEPARATOR; } Loading @@ -335,7 +334,7 @@ std::unique_ptr<Asset> DirectoryAssetsProvider::OpenInternal(const std::string& bool DirectoryAssetsProvider::ForEachFile( const std::string& /* root_path */, const std::function<void(StringPiece, FileType)>& /* f */) const { base::function_ref<void(StringPiece, FileType)> /* f */) const { return true; } Loading @@ -362,8 +361,7 @@ bool DirectoryAssetsProvider::IsUpToDate() const { MultiAssetsProvider::MultiAssetsProvider(std::unique_ptr<AssetsProvider>&& primary, std::unique_ptr<AssetsProvider>&& secondary) : primary_(std::forward<std::unique_ptr<AssetsProvider>>(primary)), secondary_(std::forward<std::unique_ptr<AssetsProvider>>(secondary)) { : primary_(std::move(primary)), secondary_(std::move(secondary)) { debug_name_ = primary_->GetDebugName() + " and " + secondary_->GetDebugName(); path_ = (primary_->GetDebugName() != kEmptyDebugString) ? primary_->GetPath() : secondary_->GetPath(); Loading @@ -385,8 +383,9 @@ std::unique_ptr<Asset> MultiAssetsProvider::OpenInternal(const std::string& path return (asset) ? std::move(asset) : secondary_->Open(path, mode, file_exists); } bool MultiAssetsProvider::ForEachFile(const std::string& root_path, const std::function<void(StringPiece, FileType)>& f) const { bool MultiAssetsProvider::ForEachFile( const std::string& root_path, base::function_ref<void(StringPiece, FileType)> f) const { return primary_->ForEachFile(root_path, f) && secondary_->ForEachFile(root_path, f); } Loading Loading @@ -424,7 +423,7 @@ std::unique_ptr<Asset> EmptyAssetsProvider::OpenInternal(const std::string& /* p bool EmptyAssetsProvider::ForEachFile( const std::string& /* root_path */, const std::function<void(StringPiece, FileType)>& /* f */) const { base::function_ref<void(StringPiece, FileType)> /* f */) const { return true; } Loading libs/androidfw/Idmap.cpp +15 −17 Original line number Diff line number Diff line Loading @@ -201,7 +201,7 @@ IdmapResMap::Result IdmapResMap::Lookup(uint32_t target_res_id) const { const auto& config = configurations_[value.config_index]; values_map[config] = value.value; } return Result(values_map); return Result(std::move(values_map)); } return {}; } Loading Loading @@ -250,8 +250,7 @@ std::optional<std::string_view> ReadString(const uint8_t** in_out_data_ptr, size } } // namespace LoadedIdmap::LoadedIdmap(std::string&& idmap_path, const Idmap_header* header, LoadedIdmap::LoadedIdmap(std::string&& idmap_path, const Idmap_header* header, const Idmap_data_header* data_header, const Idmap_target_entry* target_entries, const Idmap_target_entry_inline* target_inline_entries, Loading @@ -259,8 +258,7 @@ LoadedIdmap::LoadedIdmap(std::string&& idmap_path, const ConfigDescription* configs, const Idmap_overlay_entry* overlay_entries, std::unique_ptr<ResStringPool>&& string_pool, std::string_view overlay_apk_path, std::string_view target_apk_path) std::string_view overlay_apk_path, std::string_view target_apk_path) : header_(header), data_header_(data_header), target_entries_(target_entries), Loading libs/androidfw/include/androidfw/AssetManager2.h +1 −1 Original line number Diff line number Diff line Loading @@ -105,7 +105,7 @@ class AssetManager2 { // new resource IDs. bool SetApkAssets(std::vector<const ApkAssets*> apk_assets, bool invalidate_caches = true); inline const std::vector<const ApkAssets*> GetApkAssets() const { inline const std::vector<const ApkAssets*>& GetApkAssets() const { return apk_assets_; } Loading Loading
core/jni/android_content_res_ApkAssets.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -96,7 +96,7 @@ class LoaderAssetsProvider : public AssetsProvider { } bool ForEachFile(const std::string& /* root_path */, const std::function<void(StringPiece, FileType)>& /* f */) const { android::base::function_ref<void(StringPiece, FileType)> /* f */) const { return true; } Loading
libs/androidfw/AssetManager2.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -1562,11 +1562,11 @@ base::expected<std::monostate, IOError> Theme::SetTo(const Theme& source) { std::unordered_map<ApkAssetsCookie, SourceToDestinationRuntimePackageMap> src_asset_cookie_id_map; // Determine which ApkAssets are loaded in both theme AssetManagers. const auto src_assets = source.asset_manager_->GetApkAssets(); const auto& src_assets = source.asset_manager_->GetApkAssets(); for (size_t i = 0; i < src_assets.size(); i++) { const ApkAssets* src_asset = src_assets[i]; const auto dest_assets = asset_manager_->GetApkAssets(); const auto& dest_assets = asset_manager_->GetApkAssets(); for (size_t j = 0; j < dest_assets.size(); j++) { const ApkAssets* dest_asset = dest_assets[j]; if (src_asset != dest_asset) { Loading
libs/androidfw/AssetsProvider.cpp +22 −23 Original line number Diff line number Diff line Loading @@ -73,9 +73,6 @@ std::unique_ptr<Asset> AssetsProvider::CreateAssetFromFd(base::unique_fd fd, (path != nullptr) ? base::unique_fd(-1) : std::move(fd)); } ZipAssetsProvider::PathOrDebugName::PathOrDebugName(std::string&& value, bool is_path) : value_(std::forward<std::string>(value)), is_path_(is_path) {} const std::string* ZipAssetsProvider::PathOrDebugName::GetPath() const { return is_path_ ? &value_ : nullptr; } Loading @@ -84,10 +81,14 @@ const std::string& ZipAssetsProvider::PathOrDebugName::GetDebugName() const { return value_; } void ZipAssetsProvider::ZipCloser::operator()(ZipArchive* a) const { ::CloseArchive(a); } ZipAssetsProvider::ZipAssetsProvider(ZipArchiveHandle handle, PathOrDebugName&& path, package_property_t flags, time_t last_mod_time) : zip_handle_(handle, ::CloseArchive), name_(std::forward<PathOrDebugName>(path)), : zip_handle_(handle), name_(std::move(path)), flags_(flags), last_mod_time_(last_mod_time) {} Loading @@ -110,14 +111,12 @@ std::unique_ptr<ZipAssetsProvider> ZipAssetsProvider::Create(std::string path, // Stat requires execute permissions on all directories path to the file. If the process does // not have execute permissions on this file, allow the zip to be opened but IsUpToDate() will // always have to return true. LOG(WARNING) << "Failed to stat file '" << path << "': " << base::SystemErrorCodeToString(errno); PLOG(WARNING) << "Failed to stat file '" << path << "'"; } } return std::unique_ptr<ZipAssetsProvider>( new ZipAssetsProvider(handle, PathOrDebugName{std::move(path), true /* is_path */}, flags, sb.st_mtime)); new ZipAssetsProvider(handle, PathOrDebugName::Path(std::move(path)), flags, sb.st_mtime)); } std::unique_ptr<ZipAssetsProvider> ZipAssetsProvider::Create(base::unique_fd fd, Loading Loading @@ -150,9 +149,8 @@ std::unique_ptr<ZipAssetsProvider> ZipAssetsProvider::Create(base::unique_fd fd, } } return std::unique_ptr<ZipAssetsProvider>( new ZipAssetsProvider(handle, PathOrDebugName{std::move(friendly_name), false /* is_path */}, flags, sb.st_mtime)); return std::unique_ptr<ZipAssetsProvider>(new ZipAssetsProvider( handle, PathOrDebugName::DebugName(std::move(friendly_name)), flags, sb.st_mtime)); } std::unique_ptr<Asset> ZipAssetsProvider::OpenInternal(const std::string& path, Loading Loading @@ -219,8 +217,9 @@ std::unique_ptr<Asset> ZipAssetsProvider::OpenInternal(const std::string& path, return asset; } bool ZipAssetsProvider::ForEachFile(const std::string& root_path, const std::function<void(StringPiece, FileType)>& f) const { bool ZipAssetsProvider::ForEachFile( const std::string& root_path, base::function_ref<void(StringPiece, FileType)> f) const { std::string root_path_full = root_path; if (root_path_full.back() != '/') { root_path_full += '/'; Loading Loading @@ -297,7 +296,7 @@ bool ZipAssetsProvider::IsUpToDate() const { } DirectoryAssetsProvider::DirectoryAssetsProvider(std::string&& path, time_t last_mod_time) : dir_(std::forward<std::string>(path)), last_mod_time_(last_mod_time) {} : dir_(std::move(path)), last_mod_time_(last_mod_time) {} std::unique_ptr<DirectoryAssetsProvider> DirectoryAssetsProvider::Create(std::string path) { struct stat sb; Loading @@ -312,7 +311,7 @@ std::unique_ptr<DirectoryAssetsProvider> DirectoryAssetsProvider::Create(std::st return nullptr; } if (path[path.size() - 1] != OS_PATH_SEPARATOR) { if (path.back() != OS_PATH_SEPARATOR) { path += OS_PATH_SEPARATOR; } Loading @@ -335,7 +334,7 @@ std::unique_ptr<Asset> DirectoryAssetsProvider::OpenInternal(const std::string& bool DirectoryAssetsProvider::ForEachFile( const std::string& /* root_path */, const std::function<void(StringPiece, FileType)>& /* f */) const { base::function_ref<void(StringPiece, FileType)> /* f */) const { return true; } Loading @@ -362,8 +361,7 @@ bool DirectoryAssetsProvider::IsUpToDate() const { MultiAssetsProvider::MultiAssetsProvider(std::unique_ptr<AssetsProvider>&& primary, std::unique_ptr<AssetsProvider>&& secondary) : primary_(std::forward<std::unique_ptr<AssetsProvider>>(primary)), secondary_(std::forward<std::unique_ptr<AssetsProvider>>(secondary)) { : primary_(std::move(primary)), secondary_(std::move(secondary)) { debug_name_ = primary_->GetDebugName() + " and " + secondary_->GetDebugName(); path_ = (primary_->GetDebugName() != kEmptyDebugString) ? primary_->GetPath() : secondary_->GetPath(); Loading @@ -385,8 +383,9 @@ std::unique_ptr<Asset> MultiAssetsProvider::OpenInternal(const std::string& path return (asset) ? std::move(asset) : secondary_->Open(path, mode, file_exists); } bool MultiAssetsProvider::ForEachFile(const std::string& root_path, const std::function<void(StringPiece, FileType)>& f) const { bool MultiAssetsProvider::ForEachFile( const std::string& root_path, base::function_ref<void(StringPiece, FileType)> f) const { return primary_->ForEachFile(root_path, f) && secondary_->ForEachFile(root_path, f); } Loading Loading @@ -424,7 +423,7 @@ std::unique_ptr<Asset> EmptyAssetsProvider::OpenInternal(const std::string& /* p bool EmptyAssetsProvider::ForEachFile( const std::string& /* root_path */, const std::function<void(StringPiece, FileType)>& /* f */) const { base::function_ref<void(StringPiece, FileType)> /* f */) const { return true; } Loading
libs/androidfw/Idmap.cpp +15 −17 Original line number Diff line number Diff line Loading @@ -201,7 +201,7 @@ IdmapResMap::Result IdmapResMap::Lookup(uint32_t target_res_id) const { const auto& config = configurations_[value.config_index]; values_map[config] = value.value; } return Result(values_map); return Result(std::move(values_map)); } return {}; } Loading Loading @@ -250,8 +250,7 @@ std::optional<std::string_view> ReadString(const uint8_t** in_out_data_ptr, size } } // namespace LoadedIdmap::LoadedIdmap(std::string&& idmap_path, const Idmap_header* header, LoadedIdmap::LoadedIdmap(std::string&& idmap_path, const Idmap_header* header, const Idmap_data_header* data_header, const Idmap_target_entry* target_entries, const Idmap_target_entry_inline* target_inline_entries, Loading @@ -259,8 +258,7 @@ LoadedIdmap::LoadedIdmap(std::string&& idmap_path, const ConfigDescription* configs, const Idmap_overlay_entry* overlay_entries, std::unique_ptr<ResStringPool>&& string_pool, std::string_view overlay_apk_path, std::string_view target_apk_path) std::string_view overlay_apk_path, std::string_view target_apk_path) : header_(header), data_header_(data_header), target_entries_(target_entries), Loading
libs/androidfw/include/androidfw/AssetManager2.h +1 −1 Original line number Diff line number Diff line Loading @@ -105,7 +105,7 @@ class AssetManager2 { // new resource IDs. bool SetApkAssets(std::vector<const ApkAssets*> apk_assets, bool invalidate_caches = true); inline const std::vector<const ApkAssets*> GetApkAssets() const { inline const std::vector<const ApkAssets*>& GetApkAssets() const { return apk_assets_; } Loading