summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/accounts
diff options
context:
space:
mode:
authorRubin Xu <rubinxu@google.com>2015-06-08 17:21:19 +0100
committerRubin Xu <rubinxu@google.com>2015-06-08 17:21:19 +0100
commitd1ce82ae8b5ff9c32480234ceab84f6679fe2885 (patch)
treeaef68e5a9516ba34817d3a4fbdcea91c0379e3e0 /src/com/android/settings/accounts
parentb777c6e20541a01f4219e1020445d091fbfe3217 (diff)
downloadpackages_apps_Settings-d1ce82ae8b5ff9c32480234ceab84f6679fe2885.zip
packages_apps_Settings-d1ce82ae8b5ff9c32480234ceab84f6679fe2885.tar.gz
packages_apps_Settings-d1ce82ae8b5ff9c32480234ceab84f6679fe2885.tar.bz2
Defensively load untrusted icons from account authenticator
Catch Resources.NotFoundException which should cover all parsing errors from loadDrawables(); also substitute a default icon if parsing returns null. Bug: 17760671 Change-Id: Ia0ec25e34974ed85b6ffe6882d5bce003d64e9d6
Diffstat (limited to 'src/com/android/settings/accounts')
-rw-r--r--src/com/android/settings/accounts/AuthenticatorHelper.java3
-rw-r--r--src/com/android/settings/accounts/ChooseAccountActivity.java11
2 files changed, 9 insertions, 5 deletions
diff --git a/src/com/android/settings/accounts/AuthenticatorHelper.java b/src/com/android/settings/accounts/AuthenticatorHelper.java
index 86e0da5..56a689c 100644
--- a/src/com/android/settings/accounts/AuthenticatorHelper.java
+++ b/src/com/android/settings/accounts/AuthenticatorHelper.java
@@ -96,7 +96,8 @@ final public class AuthenticatorHelper extends BroadcastReceiver {
/**
* Gets an icon associated with a particular account type. If none found, return null.
* @param accountType the type of account
- * @return a drawable for the icon or null if one cannot be found.
+ * @return a drawable for the icon or a default icon returned by
+ * {@link PackageManager#getDefaultActivityIcon} if one cannot be found.
*/
public Drawable getDrawableForType(Context context, final String accountType) {
Drawable icon = null;
diff --git a/src/com/android/settings/accounts/ChooseAccountActivity.java b/src/com/android/settings/accounts/ChooseAccountActivity.java
index c4dace8..12077af 100644
--- a/src/com/android/settings/accounts/ChooseAccountActivity.java
+++ b/src/com/android/settings/accounts/ChooseAccountActivity.java
@@ -214,7 +214,8 @@ public class ChooseAccountActivity extends InstrumentedPreferenceActivity {
/**
* Gets an icon associated with a particular account type. If none found, return null.
* @param accountType the type of account
- * @return a drawable for the icon or null if one cannot be found.
+ * @return a drawable for the icon or a default icon returned by
+ * {@link PackageManager#getDefaultActivityIcon} if one cannot be found.
*/
protected Drawable getDrawableForType(final String accountType) {
Drawable icon = null;
@@ -225,14 +226,16 @@ public class ChooseAccountActivity extends InstrumentedPreferenceActivity {
icon = getPackageManager().getUserBadgedIcon(
authContext.getDrawable(desc.iconId), mUserHandle);
} catch (PackageManager.NameNotFoundException e) {
- // TODO: place holder icon for missing account icons?
Log.w(TAG, "No icon name for account type " + accountType);
} catch (Resources.NotFoundException e) {
- // TODO: place holder icon for missing account icons?
Log.w(TAG, "No icon resource for account type " + accountType);
}
}
- return icon;
+ if (icon != null) {
+ return icon;
+ } else {
+ return getPackageManager().getDefaultActivityIcon();
+ }
}
/**