Added some missing null checks
This commit is contained in:
parent
278fd99245
commit
383c54f817
1 changed files with 28 additions and 14 deletions
|
@ -195,7 +195,7 @@ public class LinphoneContact extends AndroidContact
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPhotoUri(Uri uri) {
|
private void setPhotoUri(Uri uri) {
|
||||||
if (uri.equals(mPhotoUri)) return;
|
if (uri != null && uri.equals(mPhotoUri)) return;
|
||||||
mPhotoUri = uri;
|
mPhotoUri = uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ public class LinphoneContact extends AndroidContact
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setThumbnailUri(Uri uri) {
|
private void setThumbnailUri(Uri uri) {
|
||||||
if (uri.equals(mThumbnailUri)) return;
|
if (uri != null && uri.equals(mThumbnailUri)) return;
|
||||||
mThumbnailUri = uri;
|
mThumbnailUri = uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,14 +216,16 @@ public class LinphoneContact extends AndroidContact
|
||||||
if (noa == null) return;
|
if (noa == null) return;
|
||||||
|
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
|
String normalizedPhone = noa.getNormalizedPhone();
|
||||||
// Check for duplicated phone numbers but with different formats
|
// Check for duplicated phone numbers but with different formats
|
||||||
for (LinphoneNumberOrAddress number : mAddresses) {
|
for (LinphoneNumberOrAddress number : mAddresses) {
|
||||||
if (!number.isSIPAddress()) {
|
if (!number.isSIPAddress()) {
|
||||||
if ((!noa.isSIPAddress()
|
if ((!noa.isSIPAddress()
|
||||||
&& noa.getNormalizedPhone().equals(number.getNormalizedPhone()))
|
&& normalizedPhone != null
|
||||||
|
&& normalizedPhone.equals(number.getNormalizedPhone()))
|
||||||
|| (noa.isSIPAddress()
|
|| (noa.isSIPAddress()
|
||||||
&& noa.getValue().equals(number.getNormalizedPhone()))
|
&& noa.getValue().equals(number.getNormalizedPhone()))
|
||||||
|| (noa.getNormalizedPhone().equals(number.getValue()))) {
|
|| (normalizedPhone != null && normalizedPhone.equals(number.getValue()))) {
|
||||||
Log.d("[Linphone Contact] Duplicated entry detected: " + noa);
|
Log.d("[Linphone Contact] Duplicated entry detected: " + noa);
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
|
@ -247,7 +249,8 @@ public class LinphoneContact extends AndroidContact
|
||||||
for (LinphoneNumberOrAddress noa : getNumbersOrAddresses()) {
|
for (LinphoneNumberOrAddress noa : getNumbersOrAddresses()) {
|
||||||
if (noa.isSIPAddress()) {
|
if (noa.isSIPAddress()) {
|
||||||
String value = noa.getValue();
|
String value = noa.getValue();
|
||||||
if (address.startsWith(value) || value.equals("sip:" + address)) {
|
if (value != null
|
||||||
|
&& (address.startsWith(value) || value.equals("sip:" + address))) {
|
||||||
// Startswith is to workaround the fact that the
|
// Startswith is to workaround the fact that the
|
||||||
// address may have a ;gruu= at the end...
|
// address may have a ;gruu= at the end...
|
||||||
return true;
|
return true;
|
||||||
|
@ -274,7 +277,8 @@ public class LinphoneContact extends AndroidContact
|
||||||
}
|
}
|
||||||
LinphoneNumberOrAddress toRemove = null;
|
LinphoneNumberOrAddress toRemove = null;
|
||||||
for (LinphoneNumberOrAddress address : mAddresses) {
|
for (LinphoneNumberOrAddress address : mAddresses) {
|
||||||
if (noa.getOldValue().equals(address.getValue())
|
if (noa.getOldValue() != null
|
||||||
|
&& noa.getOldValue().equals(address.getValue())
|
||||||
&& noa.isSIPAddress() == address.isSIPAddress()) {
|
&& noa.isSIPAddress() == address.isSIPAddress()) {
|
||||||
toRemove = address;
|
toRemove = address;
|
||||||
break;
|
break;
|
||||||
|
@ -305,7 +309,8 @@ public class LinphoneContact extends AndroidContact
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (LinphoneNumberOrAddress address : mAddresses) {
|
for (LinphoneNumberOrAddress address : mAddresses) {
|
||||||
if (noa.getOldValue().equals(address.getValue())
|
if (noa.getOldValue() != null
|
||||||
|
&& noa.getOldValue().equals(address.getValue())
|
||||||
&& noa.isSIPAddress() == address.isSIPAddress()) {
|
&& noa.isSIPAddress() == address.isSIPAddress()) {
|
||||||
address.setValue(noa.getValue());
|
address.setValue(noa.getValue());
|
||||||
break;
|
break;
|
||||||
|
@ -428,7 +433,9 @@ public class LinphoneContact extends AndroidContact
|
||||||
if (mFriend == null) return false;
|
if (mFriend == null) return false;
|
||||||
for (LinphoneNumberOrAddress noa : getNumbersOrAddresses()) {
|
for (LinphoneNumberOrAddress noa : getNumbersOrAddresses()) {
|
||||||
PresenceModel pm = mFriend.getPresenceModelForUriOrTel(noa.getValue());
|
PresenceModel pm = mFriend.getPresenceModelForUriOrTel(noa.getValue());
|
||||||
if (pm != null && pm.getBasicStatus().equals(PresenceBasicStatus.Open)) {
|
if (pm != null
|
||||||
|
&& pm.getBasicStatus() != null
|
||||||
|
&& pm.getBasicStatus().equals(PresenceBasicStatus.Open)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -451,13 +458,18 @@ public class LinphoneContact extends AndroidContact
|
||||||
|
|
||||||
public boolean hasPresenceModelForUriOrTelCapability(String uri, FriendCapability capability) {
|
public boolean hasPresenceModelForUriOrTelCapability(String uri, FriendCapability capability) {
|
||||||
if (mFriend == null) return false;
|
if (mFriend == null) return false;
|
||||||
if (mFriend.getPresenceModelForUriOrTel(uri) != null) {
|
|
||||||
return mFriend.getPresenceModelForUriOrTel(uri).hasCapability(capability);
|
PresenceModel presence = mFriend.getPresenceModelForUriOrTel(uri);
|
||||||
|
if (presence != null) {
|
||||||
|
return presence.hasCapability(capability);
|
||||||
} else {
|
} else {
|
||||||
for (LinphoneNumberOrAddress noa : getNumbersOrAddresses()) {
|
for (LinphoneNumberOrAddress noa : getNumbersOrAddresses()) {
|
||||||
if (getContactFromPresenceModelForUriOrTel(noa.getValue()).equals(uri)) {
|
String contact = getContactFromPresenceModelForUriOrTel(noa.getValue());
|
||||||
return mFriend.getPresenceModelForUriOrTel(noa.getValue())
|
if (contact != null && contact.equals(uri)) {
|
||||||
.hasCapability(capability);
|
presence = mFriend.getPresenceModelForUriOrTel(noa.getValue());
|
||||||
|
if (presence != null) {
|
||||||
|
return presence.hasCapability(capability);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -613,7 +625,9 @@ public class LinphoneContact extends AndroidContact
|
||||||
// Test presence of the value
|
// Test presence of the value
|
||||||
PresenceModel pm = getFriend().getPresenceModelForUriOrTel(value);
|
PresenceModel pm = getFriend().getPresenceModelForUriOrTel(value);
|
||||||
// If presence is not null
|
// If presence is not null
|
||||||
if (pm != null && pm.getBasicStatus().equals(PresenceBasicStatus.Open)) {
|
if (pm != null
|
||||||
|
&& pm.getBasicStatus() != null
|
||||||
|
&& pm.getBasicStatus().equals(PresenceBasicStatus.Open)) {
|
||||||
Log.d("[Contact] Found presence information for phone number " + value);
|
Log.d("[Contact] Found presence information for phone number " + value);
|
||||||
if (!isLinphoneAddressMimeEntryAlreadyExisting(value)) {
|
if (!isLinphoneAddressMimeEntryAlreadyExisting(value)) {
|
||||||
// Do the action on the contact only once if it has not been done yet
|
// Do the action on the contact only once if it has not been done yet
|
||||||
|
|
Loading…
Reference in a new issue