Cap oversized icons loaded via PackageManager to prevent crashes
An app can set its icon, logo or banner to an excessively large size
(e.g., 8,000 x 8,000 px). When loaded via PackageManager and drawn on
a hardware-accelerated canvas (e.g., in Settings or Launcher), this
throws a RuntimeException ("trying to draw too large bitmap") or
triggers an OOM, persistently crashing the system UI.
Here we are opening a new hidden api that gets resources but capped to
a maximum dimension of 2048 px. This api will be used by PackageManager
for fetching icon resources. Since it's not easy to determine if a
resource is icon/banner/logo just based on the id, we will be simply
relying on the callers to pass us that info.
In ResourcesImpl, we cache the capped resources with a separate key
(63rd bit of the key is used to mark capping).
Tag: agy
Flag: EXEMPT BUGFIX
Bug: 472701802
Test: atest FrameworksCoreTests:ResourcesDrawableTest
Test: atest CtsSecurityBulletinHostTestCases:android.security.cts.BUG_472701802
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:600a468f3f42832458eca1bc68d29b7b15dd21d6
Cherrypicked by Aesir (go/aesir-backport-automation)
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:4da5613fa6feb1d7ddd132393d393b063a79e0ac
Merged-In: If9b86e93befdba0a72f400546868455b4485b281
Change-Id: If9b86e93befdba0a72f400546868455b4485b281
10 files changed