summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJay Shrauner <shrauner@google.com>2014-10-22 10:31:28 -0700
committerJay Shrauner <shrauner@google.com>2014-10-22 10:32:55 -0700
commit67ee630fb784b4264ccd57f9daaeeccc72f8d06c (patch)
treed2959467a788bfad2eb4ed7d8d0bb0401a10cf14 /src
parentf02db281c7499d3ada231e1c6d3e663b482a8e1d (diff)
downloadandroid_packages_apps_ContactsCommon-67ee630fb784b4264ccd57f9daaeeccc72f8d06c.tar.gz
android_packages_apps_ContactsCommon-67ee630fb784b4264ccd57f9daaeeccc72f8d06c.tar.bz2
android_packages_apps_ContactsCommon-67ee630fb784b4264ccd57f9daaeeccc72f8d06c.zip
Fix NPE when custom protocol is unset
Bug:18086070 Change-Id: I1325426425c3eadf574132982a0ca6386e2dfd53
Diffstat (limited to 'src')
-rw-r--r--src/com/android/contacts/common/model/dataitem/ImDataItem.java25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/com/android/contacts/common/model/dataitem/ImDataItem.java b/src/com/android/contacts/common/model/dataitem/ImDataItem.java
index d1af2462..f89e5c6a 100644
--- a/src/com/android/contacts/common/model/dataitem/ImDataItem.java
+++ b/src/com/android/contacts/common/model/dataitem/ImDataItem.java
@@ -21,6 +21,7 @@ import android.content.Context;
import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Email;
import android.provider.ContactsContract.CommonDataKinds.Im;
+import android.text.TextUtils;
/**
* Represents an IM data item, wrapping the columns in
@@ -91,21 +92,21 @@ public class ImDataItem extends DataItem {
// IM can have the same data put different protocol. These should not collapse.
if (!getData().equals(that.getData())) {
return false;
- } else if (isProtocolValid() && that.isProtocolValid() &&
- getProtocol() != that.getProtocol()) {
+ } else if (!isProtocolValid() || !that.isProtocolValid()) {
+ // Deal with invalid protocol as if it was custom. If either has a non valid
+ // protocol, check to see if the other has a valid that is not custom
+ if (isProtocolValid()) {
+ return getProtocol() == Im.PROTOCOL_CUSTOM;
+ } else if (that.isProtocolValid()) {
+ return that.getProtocol() == Im.PROTOCOL_CUSTOM;
+ }
+ return true;
+ } else if (getProtocol() != that.getProtocol()) {
return false;
- } else if (isProtocolValid() && that.isProtocolValid() &&
- getProtocol() == Im.PROTOCOL_CUSTOM &&
- !getCustomProtocol().equals(that.getCustomProtocol())) {
+ } else if (getProtocol() == Im.PROTOCOL_CUSTOM &&
+ !TextUtils.equals(getCustomProtocol(), that.getCustomProtocol())) {
// Check if custom protocols are not the same
return false;
- } else if ((isProtocolValid() && !that.isProtocolValid() &&
- getProtocol() != Im.PROTOCOL_CUSTOM) ||
- (that.isProtocolValid() && !isProtocolValid() &&
- that.getProtocol() != Im.PROTOCOL_CUSTOM)) {
- // Deal with invalid protocol as if it was custom. If either has a non valid protocol,
- // check to see if the other has a valid that is not custom
- return false;
}
return true;
}