diff options
author | Jean-Baptiste Queru <jbq@google.com> | 2010-11-29 10:56:33 -0800 |
---|---|---|
committer | Android Code Review <code-review@android.com> | 2010-11-29 10:56:33 -0800 |
commit | f759ed6c8a5903eb6f486aa970fc60ec992fcd41 (patch) | |
tree | fe08246d8add2a1884746c562b40679c3201cbfc | |
parent | 12505ca2f8db8b9856e3d36dc572b75810c878d3 (diff) | |
parent | 5245f945af4b95ec9cb3b4beb3b4dab0ef22f3ca (diff) | |
download | AccountsAndSyncSettings-tools_r9.tar.gz |
Merge "Fixed system-crash when displaying account-list."tools_r9tools_r8froyo-plus-aosp
-rw-r--r-- | src/com/android/settings/AccountPreferenceBase.java | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/src/com/android/settings/AccountPreferenceBase.java b/src/com/android/settings/AccountPreferenceBase.java index 520b9d7..c1b3c41 100644 --- a/src/com/android/settings/AccountPreferenceBase.java +++ b/src/com/android/settings/AccountPreferenceBase.java @@ -31,6 +31,7 @@ import android.content.Context; import android.content.SyncAdapterType; import android.content.SyncStatusObserver; import android.content.pm.PackageManager; +import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Handler; @@ -132,12 +133,16 @@ class AccountPreferenceBase extends PreferenceActivity implements OnAccountsUpda protected Drawable getDrawableForType(final String accountType) { Drawable icon = null; if (mTypeToAuthDescription.containsKey(accountType)) { + AuthenticatorDescription desc = null; try { - AuthenticatorDescription desc = (AuthenticatorDescription) - mTypeToAuthDescription.get(accountType); - Context authContext = createPackageContext(desc.packageName, 0); - icon = authContext.getResources().getDrawable(desc.iconId); + desc = (AuthenticatorDescription)mTypeToAuthDescription.get(accountType); + if (desc != null) { + Context authContext = createPackageContext(desc.packageName, 0); + icon = authContext.getResources().getDrawable(desc.iconId); + } } catch (PackageManager.NameNotFoundException e) { + Log.w(TAG, "failed createPackageContext for account type " + accountType); + } catch (Resources.NotFoundException e) { // TODO: place holder icon for missing account icons? Log.w(TAG, "No icon for account type " + accountType); } @@ -153,14 +158,18 @@ class AccountPreferenceBase extends PreferenceActivity implements OnAccountsUpda protected CharSequence getLabelForType(final String accountType) { CharSequence label = null; if (mTypeToAuthDescription.containsKey(accountType)) { - try { - AuthenticatorDescription desc = (AuthenticatorDescription) - mTypeToAuthDescription.get(accountType); - Context authContext = createPackageContext(desc.packageName, 0); - label = authContext.getResources().getText(desc.labelId); - } catch (PackageManager.NameNotFoundException e) { - Log.w(TAG, "No label for account type " + ", type " + accountType); - } + AuthenticatorDescription desc = null; + try { + desc = (AuthenticatorDescription)mTypeToAuthDescription.get(accountType); + if (desc != null) { + Context authContext = createPackageContext(desc.packageName, 0); + label = authContext.getResources().getText(desc.labelId); + } + } catch (PackageManager.NameNotFoundException e) { + Log.w(TAG, "failed createPackageContext for account type " + accountType); + } catch (Resources.NotFoundException e) { + Log.w(TAG, "No label for account type " + accountType); + } } return label; } |