Fix NPE caused by Id96aea69
I added an explicit null check for account type, but null was actually used for
the fallback account type.
Bug 5171336
Change-Id: Ia0b98d0e9451eb3fc33d52db09feaff390875e33
diff --git a/src/com/android/contacts/model/AccountTypeWithDataSet.java b/src/com/android/contacts/model/AccountTypeWithDataSet.java
index d5cdbdd..f1b2344 100644
--- a/src/com/android/contacts/model/AccountTypeWithDataSet.java
+++ b/src/com/android/contacts/model/AccountTypeWithDataSet.java
@@ -25,16 +25,14 @@
* Encapsulates an "account type" string and a "data set" string.
*/
public class AccountTypeWithDataSet {
- /** account type will never be null. */
+ /** account type. Can be null for fallback type. */
public final String accountType;
/** dataSet may be null, but never be "". */
public final String dataSet;
private AccountTypeWithDataSet(String accountType, String dataSet) {
- if (accountType == null) throw new NullPointerException();
-
- this.accountType = accountType;
+ this.accountType = TextUtils.isEmpty(accountType) ? null : accountType;
this.dataSet = TextUtils.isEmpty(dataSet) ? null : dataSet;
}
@@ -53,7 +51,8 @@
@Override
public int hashCode() {
- return Objects.hashCode(accountType) ^ (dataSet == null ? 0 : Objects.hashCode(dataSet));
+ return (accountType == null ? 0 : accountType.hashCode())
+ ^ (dataSet == null ? 0 : dataSet.hashCode());
}
@Override