Give PermissionApps a cache for app labels and icons.
The PermissionApps class currently loads the label and icon for each
app that requests the given permission (when not set to skip UI).
This works fine when creating a single PermissionApps class, but when
creating multiple ones, this results in duplicate work. For example,
creating a PermissionGroups object will create one PermissionApps
object for each permission, so apps that request multiple permissions
will have their labels and icons loaded multiple times.
To improve performance, this patch gives PermissionApps a cache for
app labels and icons. This app is based on the similar package
manager cache that already exists. Note that the cache uses an
ArrayMap keyed on package names, which means that insertion is linear
in the number of apps.
This patch reduces the initial loading time of PermissionUsageFragment
and ManagePermissionsFragment by approximately 50% on my development
device.
Test: Open various permission screens.
Test: Time the opening of screens with and without this change.
Change-Id: Ia4a51ff7ae19cfa53b9f7ca0e50647cdf2fa971f
2 files changed