Added logs & fixed some issues in contact removal
This commit is contained in:
parent
4fd25bb1b0
commit
53a748409d
4 changed files with 23 additions and 8 deletions
|
@ -146,6 +146,7 @@ class AndroidContact implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
void deleteAndroidContact() {
|
void deleteAndroidContact() {
|
||||||
|
Log.i("[Contact] Deleting Android contact ", this);
|
||||||
ContactsManager.getInstance().delete(mAndroidId);
|
ContactsManager.getInstance().delete(mAndroidId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,14 +95,13 @@ class AsyncContactsLoader extends AsyncTask<Void, Void, AsyncContactsLoader.Asyn
|
||||||
}
|
}
|
||||||
|
|
||||||
LinphoneContact contact = (LinphoneContact) friend.getUserData();
|
LinphoneContact contact = (LinphoneContact) friend.getUserData();
|
||||||
// A previously fetched friend from rc file will have a user data,
|
|
||||||
// so the next fetches won't add it in data.contacts
|
|
||||||
// and thus the "new friends" count in log will be different /!\
|
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
if (contact.getAndroidId() != null) {
|
if (contact.getAndroidId() != null) {
|
||||||
contact.clearAddresses();
|
contact.clearAddresses();
|
||||||
androidContactsCache.put(contact.getAndroidId(), contact);
|
androidContactsCache.put(contact.getAndroidId(), contact);
|
||||||
nativeIds.add(contact.getAndroidId());
|
nativeIds.add(contact.getAndroidId());
|
||||||
|
} else {
|
||||||
|
data.contacts.add(contact);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (friend.getRefKey() != null) {
|
if (friend.getRefKey() != null) {
|
||||||
|
@ -198,7 +197,7 @@ class AsyncContactsLoader extends AsyncTask<Void, Void, AsyncContactsLoader.Asyn
|
||||||
+ contacts.size()
|
+ contacts.size()
|
||||||
+ " native contacts plus "
|
+ " native contacts plus "
|
||||||
+ data.contacts.size()
|
+ data.contacts.size()
|
||||||
+ " new friends in the configuration file");
|
+ " friends in the configuration file");
|
||||||
for (LinphoneContact contact : contacts) {
|
for (LinphoneContact contact : contacts) {
|
||||||
if (isCancelled()) {
|
if (isCancelled()) {
|
||||||
Log.w("[Contacts Manager] Task cancelled");
|
Log.w("[Contacts Manager] Task cancelled");
|
||||||
|
|
|
@ -495,6 +495,7 @@ public class ContactsManager extends ContentObserver
|
||||||
ArrayList<ContentProviderOperation> ops = new ArrayList<>();
|
ArrayList<ContentProviderOperation> ops = new ArrayList<>();
|
||||||
|
|
||||||
for (String id : ids) {
|
for (String id : ids) {
|
||||||
|
Log.i("[Contacts Manager] Adding Android contact id ", id, " to batch removal");
|
||||||
String[] args = new String[] {id};
|
String[] args = new String[] {id};
|
||||||
ops.add(
|
ops.add(
|
||||||
ContentProviderOperation.newDelete(ContactsContract.RawContacts.CONTENT_URI)
|
ContentProviderOperation.newDelete(ContactsContract.RawContacts.CONTENT_URI)
|
||||||
|
|
|
@ -401,12 +401,23 @@ public class LinphoneContact extends AndroidContact
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteFriend() {
|
public void deleteFriend() {
|
||||||
|
if (mFriend == null) return;
|
||||||
Core core = LinphoneManager.getCore();
|
Core core = LinphoneManager.getCore();
|
||||||
if (mFriend != null && core != null) {
|
if (core == null) return;
|
||||||
for (FriendList list : core.getFriendsLists()) {
|
|
||||||
list.removeFriend(mFriend);
|
boolean found = false;
|
||||||
|
Log.i("[Contact] Deleting friend ", mFriend.getName(), " for contact ", this);
|
||||||
|
for (FriendList list : core.getFriendsLists()) {
|
||||||
|
FriendList.Status status = list.removeFriend(mFriend);
|
||||||
|
if (status == FriendList.Status.OK) {
|
||||||
|
Log.w("[Contact] Friend found in list " + list.getDisplayName());
|
||||||
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
Log.w("[Contact] Friend removal failed, friend doesn't belong to any friend list");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createOrUpdateFriendFromNativeContact() {
|
public void createOrUpdateFriendFromNativeContact() {
|
||||||
|
@ -645,7 +656,10 @@ public class LinphoneContact extends AndroidContact
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete() {
|
public void delete() {
|
||||||
deleteAndroidContact();
|
Log.i("[Contact] Deleting contact ", this);
|
||||||
|
if (isAndroidContact()) {
|
||||||
|
deleteAndroidContact();
|
||||||
|
}
|
||||||
if (isFriend()) {
|
if (isFriend()) {
|
||||||
deleteFriend();
|
deleteFriend();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue