am eac7cc5e
: Merge "Add null check for sync authorities of an account type" into lmp-dev
* commit 'eac7cc5eead6d79fb6e0558d8005b4c8ea1911a1': Add null check for sync authorities of an account type
This commit is contained in:
committed by
Android Git Automerger
commit
94e2341bb5
@@ -361,20 +361,9 @@ public class AccountSettings extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
for (int i = 0; i < accountTypes.length; i++) {
|
for (int i = 0; i < accountTypes.length; i++) {
|
||||||
final String accountType = accountTypes[i];
|
final String accountType = accountTypes[i];
|
||||||
if (mAuthoritiesCount > 0) {
|
// Skip showing any account that does not have any of the requested authorities
|
||||||
// Skip showing any account that does not have any of the requested authorities
|
if (!accountTypeHasAnyRequestedAuthorities(helper, accountType)) {
|
||||||
final ArrayList<String> authoritiesForType = helper.getAuthoritiesForAccountType(
|
continue;
|
||||||
accountType);
|
|
||||||
boolean show = false;
|
|
||||||
for (int j = 0; j < mAuthoritiesCount; j++) {
|
|
||||||
if (authoritiesForType.contains(mAuthorities[j])) {
|
|
||||||
show = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!show) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
final CharSequence label = helper.getLabelForType(getActivity(), accountType);
|
final CharSequence label = helper.getLabelForType(getActivity(), accountType);
|
||||||
if (label == null) {
|
if (label == null) {
|
||||||
@@ -418,6 +407,26 @@ public class AccountSettings extends SettingsPreferenceFragment
|
|||||||
return accountTypePreferences;
|
return accountTypePreferences;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean accountTypeHasAnyRequestedAuthorities(AuthenticatorHelper helper,
|
||||||
|
String accountType) {
|
||||||
|
if (mAuthoritiesCount == 0) {
|
||||||
|
// No authorities required
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
final ArrayList<String> authoritiesForType = helper.getAuthoritiesForAccountType(
|
||||||
|
accountType);
|
||||||
|
if (authoritiesForType == null) {
|
||||||
|
Log.d(TAG, "No sync authorities for account type: " + accountType);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (int j = 0; j < mAuthoritiesCount; j++) {
|
||||||
|
if (authoritiesForType.contains(mAuthorities[j])) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private class AccountPreference extends Preference implements OnPreferenceClickListener {
|
private class AccountPreference extends Preference implements OnPreferenceClickListener {
|
||||||
/**
|
/**
|
||||||
* Title of the tile that is shown to the user.
|
* Title of the tile that is shown to the user.
|
||||||
|
@@ -190,10 +190,10 @@ final public class AuthenticatorHelper extends BroadcastReceiver {
|
|||||||
mEnabledAccountTypes.add(account.type);
|
mEnabledAccountTypes.add(account.type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
buildAccountTypeToAuthoritiesMap();
|
||||||
if (mListeningToAccountUpdates) {
|
if (mListeningToAccountUpdates) {
|
||||||
mListener.onAccountsUpdate(mUserHandle);
|
mListener.onAccountsUpdate(mUserHandle);
|
||||||
}
|
}
|
||||||
buildAccountTypeToAuthoritiesMap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user