Adds a Util.setSafeIcon() function used to avoid crashes.

There are many places on Settings that loads an icon provided by an application,
and if the icon is too big it crashes Settings.

This CL creates a helper method used to set an icon in a safe way, and
uses it in a few places (but most likely not all of them).

Bug: 65739885
Test: manual verification with an app providing a 2MB png

Change-Id: Iae2becb6d0ec8893328d9ef1de618f9bd12fa4a0
This commit is contained in:
Felipe Leme
2017-09-15 18:16:21 -07:00
parent b51efdb511
commit bd88450183
4 changed files with 56 additions and 3 deletions

View File

@@ -485,7 +485,7 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
preference.setKey(componentName.flattenToString());
preference.setTitle(title);
preference.setIcon(icon);
Utils.setSafeIcon(preference, icon);
final boolean serviceEnabled = accessibilityEnabled
&& enabledServices.contains(componentName);
final String serviceState = serviceEnabled ?