diff options
Diffstat (limited to 'src/com/android/providers/contacts/AccountWithDataSet.java')
-rw-r--r-- | src/com/android/providers/contacts/AccountWithDataSet.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/com/android/providers/contacts/AccountWithDataSet.java b/src/com/android/providers/contacts/AccountWithDataSet.java index bfae1128..e1f633ea 100644 --- a/src/com/android/providers/contacts/AccountWithDataSet.java +++ b/src/com/android/providers/contacts/AccountWithDataSet.java @@ -17,10 +17,14 @@ package com.android.providers.contacts; import android.accounts.Account; +import android.provider.ContactsContract; +import android.provider.ContactsContract.SimAccount; import android.text.TextUtils; import com.google.common.base.Objects; +import java.util.List; + /** * Account information that includes the data set, if any. */ @@ -105,4 +109,23 @@ public class AccountWithDataSet { } return false; } + + /** + * @return {@code true} if there is a {@link SimAccount} with a matching account name and type + * in the passed list. + * The list should be obtained from {@link ContactsDatabaseHelper#getAllSimAccounts()} so it + * will already have valid SIM accounts so only name and type need to be compared. + */ + public boolean inSimAccounts(List<SimAccount> simAccountList) { + // Note we don't want to create a new SimAccount object from this instance, as this method + // does not need to know about the SIM slot or the EF type. It only needs to know whether + // the name and type match since the passed list will only contain valid SIM accounts. + for (SimAccount simAccount : simAccountList) { + if (Objects.equal(simAccount.getAccountName(), getAccountName()) + && Objects.equal(simAccount.getAccountType(), getAccountType())) { + return true; + } + } + return false; + } } |