am 4c5eaae5
: am 47d329f7
: Merge "Defensively load untrusted icons from account authenticator" into mnc-dev
* commit '4c5eaae564f20e47e6c3a4f7906446b195c639da': Defensively load untrusted icons from account authenticator
This commit is contained in:
@@ -234,15 +234,18 @@ public class MasterClear extends InstrumentedFragment {
|
|||||||
authContext.getDrawable(desc.iconId), userHandle);
|
authContext.getDrawable(desc.iconId), userHandle);
|
||||||
}
|
}
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} 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,
|
TextView child = (TextView)inflater.inflate(R.layout.master_clear_account,
|
||||||
contents, false);
|
contents, false);
|
||||||
child.setText(account.name);
|
child.setText(account.name);
|
||||||
if (icon != null) {
|
child.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
|
||||||
child.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
|
|
||||||
}
|
|
||||||
contents.addView(child);
|
contents.addView(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -96,7 +96,8 @@ final public class AuthenticatorHelper extends BroadcastReceiver {
|
|||||||
/**
|
/**
|
||||||
* Gets an icon associated with a particular account type. If none found, return null.
|
* Gets an icon associated with a particular account type. If none found, return null.
|
||||||
* @param accountType the type of account
|
* @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) {
|
public Drawable getDrawableForType(Context context, final String accountType) {
|
||||||
Drawable icon = null;
|
Drawable icon = null;
|
||||||
|
@@ -214,7 +214,8 @@ public class ChooseAccountActivity extends InstrumentedPreferenceActivity {
|
|||||||
/**
|
/**
|
||||||
* Gets an icon associated with a particular account type. If none found, return null.
|
* Gets an icon associated with a particular account type. If none found, return null.
|
||||||
* @param accountType the type of account
|
* @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) {
|
protected Drawable getDrawableForType(final String accountType) {
|
||||||
Drawable icon = null;
|
Drawable icon = null;
|
||||||
@@ -225,14 +226,16 @@ public class ChooseAccountActivity extends InstrumentedPreferenceActivity {
|
|||||||
icon = getPackageManager().getUserBadgedIcon(
|
icon = getPackageManager().getUserBadgedIcon(
|
||||||
authContext.getDrawable(desc.iconId), mUserHandle);
|
authContext.getDrawable(desc.iconId), mUserHandle);
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
// TODO: place holder icon for missing account icons?
|
|
||||||
Log.w(TAG, "No icon name for account type " + accountType);
|
Log.w(TAG, "No icon name for account type " + accountType);
|
||||||
} catch (Resources.NotFoundException e) {
|
} catch (Resources.NotFoundException e) {
|
||||||
// TODO: place holder icon for missing account icons?
|
|
||||||
Log.w(TAG, "No icon resource for account type " + accountType);
|
Log.w(TAG, "No icon resource for account type " + accountType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return icon;
|
if (icon != null) {
|
||||||
|
return icon;
|
||||||
|
} else {
|
||||||
|
return getPackageManager().getDefaultActivityIcon();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user