diff options
author | Fred Quintana <fredq@google.com> | 2010-01-12 11:40:20 -0800 |
---|---|---|
committer | Fred Quintana <fredq@google.com> | 2010-01-12 12:13:38 -0800 |
commit | 3578be4d4a3347b3cf05a26d1bfe41a307afe85e (patch) | |
tree | 662e9eec70d9a6b3d43a7c819c9556ff44be09b0 | |
parent | bf003fe7eb508565cf83289c26f4069ff025a52c (diff) | |
download | AccountsAndSyncSettings-3578be4d4a3347b3cf05a26d1bfe41a307afe85e.tar.gz |
fix an NPE when there are no syncadapters associated with an account
-rw-r--r-- | src/com/android/settings/ManageAccountsSettings.java | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/src/com/android/settings/ManageAccountsSettings.java b/src/com/android/settings/ManageAccountsSettings.java index b1f1077..4ffbf71 100644 --- a/src/com/android/settings/ManageAccountsSettings.java +++ b/src/com/android/settings/ManageAccountsSettings.java @@ -43,6 +43,7 @@ import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.TextView; +import android.util.Log; import java.util.ArrayList; import java.util.Date; @@ -184,25 +185,32 @@ public class ManageAccountsSettings extends AccountPreferenceBase implements Vie Account account = accountPref.getAccount(); int syncCount = 0; boolean syncIsFailing = false; - for (String authority : accountPref.getAuthorities()) { - SyncStatusInfo status = ContentResolver.getSyncStatus(account, authority); - boolean syncEnabled = ContentResolver.getSyncAutomatically(account, authority) - && masterSyncAutomatically - && backgroundDataSetting; - boolean authorityIsPending = ContentResolver.isSyncPending(account, authority); - boolean activelySyncing = activeSyncValues != null - && activeSyncValues.authority.equals(authority) - && activeSyncValues.account.equals(account); - boolean lastSyncFailed = status != null - && syncEnabled - && status.lastFailureTime != 0 - && status.getLastFailureMesgAsInt(0) - != ContentResolver.SYNC_ERROR_SYNC_ALREADY_IN_PROGRESS; - if (lastSyncFailed && !activelySyncing && !authorityIsPending) { - syncIsFailing = true; - anySyncFailed = true; + final ArrayList<String> authorities = accountPref.getAuthorities(); + if (authorities != null) { + for (String authority : authorities) { + SyncStatusInfo status = ContentResolver.getSyncStatus(account, authority); + boolean syncEnabled = ContentResolver.getSyncAutomatically(account, authority) + && masterSyncAutomatically + && backgroundDataSetting; + boolean authorityIsPending = ContentResolver.isSyncPending(account, authority); + boolean activelySyncing = activeSyncValues != null + && activeSyncValues.authority.equals(authority) + && activeSyncValues.account.equals(account); + boolean lastSyncFailed = status != null + && syncEnabled + && status.lastFailureTime != 0 + && status.getLastFailureMesgAsInt(0) + != ContentResolver.SYNC_ERROR_SYNC_ALREADY_IN_PROGRESS; + if (lastSyncFailed && !activelySyncing && !authorityIsPending) { + syncIsFailing = true; + anySyncFailed = true; + } + syncCount += syncEnabled && userFacing.contains(authority) ? 1 : 0; + } + } else { + if (Log.isLoggable(TAG, Log.VERBOSE)) { + Log.v(TAG, "no syncadapters found for " + account); } - syncCount += syncEnabled && userFacing.contains(authority) ? 1 : 0; } int syncStatus = AccountPreference.SYNC_DISABLED; if (syncIsFailing) { |