summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Klasén <simon.klasen@sonyericsson.com>2010-11-09 11:52:06 +0100
committerJohan Redestig <johan.redestig@sonyericsson.com>2010-11-09 11:52:06 +0100
commit5245f945af4b95ec9cb3b4beb3b4dab0ef22f3ca (patch)
tree363401e707280730b434581ff1e72753c30a0480
parent46f880c87cd2a8e3ca5c259a9babc24850ddf746 (diff)
downloadAccountsAndSyncSettings-5245f945af4b95ec9cb3b4beb3b4dab0ef22f3ca.tar.gz
Fixed system-crash when displaying account-list.
Catch exception thrown when icon/label is not set in account authenticator. Change-Id: Ie133a84c802e6d72f8a1ffd9202bcce48e60ba17
-rw-r--r--src/com/android/settings/AccountPreferenceBase.java33
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;
}