From 192400cf334e0e8befe336861a6d214c6a88c993 Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Thu, 2 Apr 2020 09:54:23 -0700 Subject: Fail install when resources.arsc is compressed If an application targets R+, prevent the application from being installed if the app has a compressed resources.arsc or if the resources.arsc is not aligned on a 4-byte boundary. Resources tables that cannot be memory mapped have to be read into a buffer in RAM and exert unnecessary memory pressure on the system. Bug: 132742131 Test: manual (adding CTS tests) Change-Id: Ieef764c87643863de24531fac12cc520fe6d90d0 --- libs/androidfw/AssetManager2.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'libs/androidfw/AssetManager2.cpp') diff --git a/libs/androidfw/AssetManager2.cpp b/libs/androidfw/AssetManager2.cpp index eaf452b5fa71..b9765ea7212c 100644 --- a/libs/androidfw/AssetManager2.cpp +++ b/libs/androidfw/AssetManager2.cpp @@ -331,6 +331,11 @@ bool AssetManager2::GetOverlayablesToString(const android::StringPiece& package_ return true; } +bool AssetManager2::ContainsAllocatedTable() const { + return std::find_if(apk_assets_.begin(), apk_assets_.end(), + std::mem_fn(&ApkAssets::IsTableAllocated)) != apk_assets_.end(); +} + void AssetManager2::SetConfiguration(const ResTable_config& configuration) { const int diff = configuration_.diff(configuration); configuration_ = configuration; -- cgit v1.2.3-59-g8ed1b