This should prevent contactFetcherTask to run when LinphoneService is not running

This commit is contained in:
Sylvain Berfini 2016-07-28 16:43:00 +02:00
parent f015c0330f
commit 8c6b34303e
2 changed files with 29 additions and 26 deletions

View file

@ -247,7 +247,9 @@ public class ContactsManager extends ContentObserver {
} }
} }
for (LinphoneFriend friend : LinphoneManager.getLc().getFriendList()) { LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
if (lc != null) {
for (LinphoneFriend friend : lc.getFriendList()) {
String refkey = friend.getRefKey(); String refkey = friend.getRefKey();
if (refkey != null) { if (refkey != null) {
boolean found = false; boolean found = false;
@ -262,7 +264,7 @@ public class ContactsManager extends ContentObserver {
if (!found) { if (!found) {
if (hasContactAccess) { if (hasContactAccess) {
// If refkey != null and hasContactAccess but there isn't a native contact with this value, then this contact has been deleted. Let's do the same with the LinphoneFriend // If refkey != null and hasContactAccess but there isn't a native contact with this value, then this contact has been deleted. Let's do the same with the LinphoneFriend
LinphoneManager.getLc().removeFriend(friend); lc.removeFriend(friend);
} else { } else {
// Refkey not null but no contact access => can't link it to native contact so display it on is own // Refkey not null but no contact access => can't link it to native contact so display it on is own
LinphoneContact contact = new LinphoneContact(); LinphoneContact contact = new LinphoneContact();
@ -277,6 +279,7 @@ public class ContactsManager extends ContentObserver {
contacts.add(contact); contacts.add(contact);
} }
} }
}
for (LinphoneContact contact : contacts) { for (LinphoneContact contact : contacts) {
// This will only get name & picture informations to be able to quickly display contacts list // This will only get name & picture informations to be able to quickly display contacts list

View file

@ -622,6 +622,7 @@ public final class LinphoneService extends Service {
} }
instance = null; instance = null;
getContentResolver().unregisterContentObserver(ContactsManager.getInstance());
LinphoneManager.destroy(); LinphoneManager.destroy();
// Make sure our notification is gone. // Make sure our notification is gone.
@ -630,7 +631,6 @@ public final class LinphoneService extends Service {
mNM.cancel(MESSAGE_NOTIF_ID); mNM.cancel(MESSAGE_NOTIF_ID);
((AlarmManager) this.getSystemService(Context.ALARM_SERVICE)).cancel(mkeepAlivePendingIntent); ((AlarmManager) this.getSystemService(Context.ALARM_SERVICE)).cancel(mkeepAlivePendingIntent);
getContentResolver().unregisterContentObserver(ContactsManager.getInstance());
super.onDestroy(); super.onDestroy();
} }