Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignore updates to sync adapter only columns #770

Merged
merged 1 commit into from
Feb 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,7 @@ public int updateInTransaction(final SQLiteDatabase db, Uri uri, final ContentVa
final boolean isSyncAdapter)
{
int count = 0;
boolean dataChanged = !TASK_LIST_SYNC_COLUMNS.containsAll(values.keySet());
switch (mUriMatcher.match(uri))
{
case SYNCSTATE_ID:
Expand Down Expand Up @@ -1097,7 +1098,7 @@ public int updateInTransaction(final SQLiteDatabase db, Uri uri, final ContentVa
final TaskAdapter task = new CursorContentValuesTaskAdapter(cursor, cursor.getCount() > 1 ? new ContentValues(values) : values);

mTaskProcessorChain.update(db, task, isSyncAdapter);
if (task.hasUpdates())
if (dataChanged && task.hasUpdates())
{
mChanged = true;
}
Expand All @@ -1109,7 +1110,7 @@ public int updateInTransaction(final SQLiteDatabase db, Uri uri, final ContentVa
cursor.close();
}

if (count > 0)
if (dataChanged)
{
postNotifyUri(Instances.getContentUri(mAuthority));
postNotifyUri(Tasks.getContentUri(mAuthority));
Expand Down Expand Up @@ -1139,7 +1140,7 @@ public int updateInTransaction(final SQLiteDatabase db, Uri uri, final ContentVa
}
}

if (count > 0)
if (dataChanged)
{
postNotifyUri(Instances.getContentUri(mAuthority));
postNotifyUri(Tasks.getContentUri(mAuthority));
Expand Down Expand Up @@ -1213,7 +1214,7 @@ public int updateInTransaction(final SQLiteDatabase db, Uri uri, final ContentVa
operation.run(getContext(), mAsyncHandler, uri, db, values);
}

if (!TASK_LIST_SYNC_COLUMNS.containsAll(values.keySet()))
if (dataChanged)
{
// send notifications, because non-sync columns have been updated
postNotifyUri(uri);
Expand Down Expand Up @@ -1312,19 +1313,19 @@ public String getType(Uri uri)
protected void onEndTransaction(boolean callerIsSyncAdapter)
{
super.onEndTransaction(callerIsSyncAdapter);
Intent providerChangedIntent = new Intent(Intent.ACTION_PROVIDER_CHANGED, TaskContract.getContentUri(mAuthority));
if (mChanged)
{
Intent providerChangedIntent = new Intent(Intent.ACTION_PROVIDER_CHANGED, TaskContract.getContentUri(mAuthority));
updateNotifications();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
{
// for now we only notify our own package
// we'll have to figure out how to do this correctly on Android 8+, e.g. how is it done by CalendarProvider and ContactsProvider
providerChangedIntent.setPackage(getContext().getPackageName());
}
getContext().sendBroadcast(providerChangedIntent);
mChanged = false;
}
if (Build.VERSION.SDK_INT >= 26)
{
// for now we only notify our own package
// we'll have to figure out how to do this correctly on Android 8+, e.g. how is it done by CalendarProvider and ContactsProvider
providerChangedIntent.setPackage(getContext().getPackageName());
}
getContext().sendBroadcast(providerChangedIntent);

if (Boolean.TRUE.equals(mStaleListCreated.get()))
{
Expand Down