Commit 6dd31063 authored by Ricki Hirner's avatar Ricki Hirner

Android 7 workaround: update hash after group membership operations

parent e46e85c7
......@@ -138,33 +138,11 @@ public class LocalContact extends AndroidContact implements LocalResource {
}
@Override
public int update(Contact contact) throws ContactsStorageException {
int result = super.update(contact);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
// workaround for Android 7 which sets DIRTY flag when only meta-data is changed
updateHashCode();
return result;
}
@Override
public Uri create() throws ContactsStorageException {
Uri uri = super.create();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
// workaround for Android 7 which sets DIRTY flag when only meta-data is changed
updateHashCode();
return uri;
}
/**
* Calculates a hash code from the contact's data (VCard) and group memberships.
* @return hash code of contact data (including group memberships)
*/
public int dataHashCode() throws FileNotFoundException, ContactsStorageException {
protected int dataHashCode() throws FileNotFoundException, ContactsStorageException {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N)
App.log.severe("dataHashCode() should not be called on Android <7");
......@@ -172,7 +150,7 @@ public class LocalContact extends AndroidContact implements LocalResource {
return getContact().hashCode() ^ groupMemberships.hashCode();
}
protected void updateHashCode() throws ContactsStorageException {
public void updateHashCode() throws ContactsStorageException {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N)
App.log.severe("updateHashCode() should not be called on Android <7");
......@@ -191,7 +169,7 @@ public class LocalContact extends AndroidContact implements LocalResource {
}
}
int getLastHashCode() throws ContactsStorageException {
public int getLastHashCode() throws ContactsStorageException {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N)
App.log.severe("getLastHashCode() should not be called on Android <7");
......
......@@ -490,6 +490,10 @@ public class ContactsSyncManager extends SyncManager {
batch.commit();
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && local instanceof LocalContact)
// workaround for Android 7 which sets DIRTY flag when only meta-data is changed
((LocalContact)local).updateHashCode();
currentLocalResource = null;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment