diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2015-03-14 02:25:41 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2015-03-14 02:25:41 -0700 |
commit | b5b4b3844d18f05fc7a48f87e4de15566ab573b4 (patch) | |
tree | 9fe7122e63cd03b85c1d23a4a4d8bb219c6786dc | |
parent | 9de0ecf7e3d5dc2462841bbd3de262ebd8067f63 (diff) | |
parent | c58940b47ce372385fa52afa3f9eb85d7dadc590 (diff) | |
download | android_packages_apps_ContactsCommon-b5b4b3844d18f05fc7a48f87e4de15566ab573b4.tar.gz android_packages_apps_ContactsCommon-b5b4b3844d18f05fc7a48f87e4de15566ab573b4.tar.bz2 android_packages_apps_ContactsCommon-b5b4b3844d18f05fc7a48f87e4de15566ab573b4.zip |
Merge "Fix NPE when custom protocol is unset"
-rw-r--r-- | src/com/android/contacts/common/model/dataitem/ImDataItem.java | 25 |
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; } |