summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRubin Xu <rubinxu@google.com>2015-06-12 16:18:15 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-06-12 16:18:16 +0000
commit47d329f79af7ae74e6b840eb90c15b7cdc294b53 (patch)
tree2c551468f891137aa06d5da2f57659e8a0d171c4
parentdabba2f6c41ae366c65c4667ee7be312eb96f39a (diff)
parentd1ce82ae8b5ff9c32480234ceab84f6679fe2885 (diff)
downloadpackages_apps_Settings-47d329f79af7ae74e6b840eb90c15b7cdc294b53.tar.gz
packages_apps_Settings-47d329f79af7ae74e6b840eb90c15b7cdc294b53.tar.bz2
packages_apps_Settings-47d329f79af7ae74e6b840eb90c15b7cdc294b53.zip
Merge "Defensively load untrusted icons from account authenticator" into mnc-dev
-rw-r--r--src/com/android/settings/MasterClear.java11
-rw-r--r--src/com/android/settings/accounts/AuthenticatorHelper.java3
-rw-r--r--src/com/android/settings/accounts/ChooseAccountActivity.java11
3 files changed, 16 insertions, 9 deletions
diff --git a/src/com/android/settings/MasterClear.java b/src/com/android/settings/MasterClear.java
index 23f681228..6ab36c1f3 100644
--- a/src/com/android/settings/MasterClear.java
+++ b/src/com/android/settings/MasterClear.java
@@ -234,15 +234,18 @@ public class MasterClear extends InstrumentedFragment {
authContext.getDrawable(desc.iconId), userHandle);
}
} catch (PackageManager.NameNotFoundException e) {
- Log.w(TAG, "No icon for account type " + desc.type);
+ Log.w(TAG, "Bad package name for account type " + desc.type);
+ } catch (Resources.NotFoundException e) {
+ Log.w(TAG, "Invalid icon id for account type " + desc.type, e);
+ }
+ if (icon == null) {
+ icon = context.getPackageManager().getDefaultActivityIcon();
}
TextView child = (TextView)inflater.inflate(R.layout.master_clear_account,
contents, false);
child.setText(account.name);
- if (icon != null) {
- child.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
- }
+ child.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
contents.addView(child);
}
}
diff --git a/src/com/android/settings/accounts/AuthenticatorHelper.java b/src/com/android/settings/accounts/AuthenticatorHelper.java
index 86e0da5e8..56a689cc6 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 c4dace8d1..12077af59 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();
+ }
}
/**