diff --git a/mobile/android/base/db/SQLiteBridgeContentProvider.java b/mobile/android/base/db/SQLiteBridgeContentProvider.java index ee719927dfd1..283e1739bf05 100644 --- a/mobile/android/base/db/SQLiteBridgeContentProvider.java +++ b/mobile/android/base/db/SQLiteBridgeContentProvider.java @@ -66,6 +66,14 @@ public abstract class SQLiteBridgeContentProvider extends ContentProvider { shutdown(); } + /** + * Return true of the query is from Firefox Sync. + * @param uri query URI + */ + public static boolean isCallerSync(Uri uri) { + String isSync = uri.getQueryParameter(BrowserContract.PARAM_IS_SYNC); + return !TextUtils.isEmpty(isSync); + } private SQLiteBridge getDB(Context context, final String databasePath) { SQLiteBridge bridge = null; @@ -327,7 +335,8 @@ public abstract class SQLiteBridgeContentProvider extends ContentProvider { } if (rowsAdded > 0) { - mContext.getContentResolver().notifyChange(uri, null); + final boolean shouldSyncToNetwork = !isCallerSync(uri); + mContext.getContentResolver().notifyChange(uri, null, shouldSyncToNetwork); } return rowsAdded; diff --git a/mobile/android/base/db/TabsProvider.java b/mobile/android/base/db/TabsProvider.java index fbd59e656cc3..34df1cbfd91a 100644 --- a/mobile/android/base/db/TabsProvider.java +++ b/mobile/android/base/db/TabsProvider.java @@ -107,6 +107,15 @@ public class TabsProvider extends ContentProvider { } } + /** + * Return true of the query is from Firefox Sync. + * @param uri query URI + */ + public static boolean isCallerSync(Uri uri) { + String isSync = uri.getQueryParameter(BrowserContract.PARAM_IS_SYNC); + return !TextUtils.isEmpty(isSync); + } + final class TabsDatabaseHelper extends SQLiteOpenHelper { public TabsDatabaseHelper(Context context, String databasePath) { super(context, databasePath, null, DATABASE_VERSION); @@ -297,8 +306,10 @@ public class TabsProvider extends ContentProvider { deleted = deleteInTransaction(uri, selection, selectionArgs); } - if (deleted > 0) - getContext().getContentResolver().notifyChange(uri, null); + if (deleted > 0) { + final boolean shouldSyncToNetwork = !isCallerSync(uri); + getContext().getContentResolver().notifyChange(uri, null, shouldSyncToNetwork); + } return deleted; } @@ -365,8 +376,10 @@ public class TabsProvider extends ContentProvider { result = insertInTransaction(uri, values); } - if (result != null) - getContext().getContentResolver().notifyChange(uri, null); + if (result != null) { + final boolean shouldSyncToNetwork = !isCallerSync(uri); + getContext().getContentResolver().notifyChange(uri, null, shouldSyncToNetwork); + } return result; } @@ -425,8 +438,10 @@ public class TabsProvider extends ContentProvider { updated = updateInTransaction(uri, values, selection, selectionArgs); } - if (updated > 0) - getContext().getContentResolver().notifyChange(uri, null); + if (updated > 0) { + final boolean shouldSyncToNetwork = !isCallerSync(uri); + getContext().getContentResolver().notifyChange(uri, null, shouldSyncToNetwork); + } return updated; } @@ -577,8 +592,10 @@ public class TabsProvider extends ContentProvider { db.endTransaction(); } - if (successes > 0) - mContext.getContentResolver().notifyChange(uri, null); + if (successes > 0) { + final boolean shouldSyncToNetwork = !isCallerSync(uri); + mContext.getContentResolver().notifyChange(uri, null, shouldSyncToNetwork); + } return successes; } diff --git a/mobile/android/base/db/TransactionalProvider.java b/mobile/android/base/db/TransactionalProvider.java index 9f4fe9a24e28..536953ab544b 100644 --- a/mobile/android/base/db/TransactionalProvider.java +++ b/mobile/android/base/db/TransactionalProvider.java @@ -353,7 +353,8 @@ public abstract class TransactionalProvider extends } if (deleted > 0) { - getContext().getContentResolver().notifyChange(uri, null); + final boolean shouldSyncToNetwork = !isCallerSync(uri); + getContext().getContentResolver().notifyChange(uri, null, shouldSyncToNetwork); } return deleted; @@ -377,7 +378,8 @@ public abstract class TransactionalProvider extends } if (result != null) { - getContext().getContentResolver().notifyChange(uri, null); + final boolean shouldSyncToNetwork = !isCallerSync(uri); + getContext().getContentResolver().notifyChange(uri, null, shouldSyncToNetwork); } return result; @@ -401,7 +403,8 @@ public abstract class TransactionalProvider extends } if (updated > 0) { - getContext().getContentResolver().notifyChange(uri, null); + final boolean shouldSyncToNetwork = !isCallerSync(uri); + getContext().getContentResolver().notifyChange(uri, null, shouldSyncToNetwork); } return updated; @@ -434,7 +437,8 @@ public abstract class TransactionalProvider extends } if (successes > 0) { - mContext.getContentResolver().notifyChange(uri, null); + final boolean shouldSyncToNetwork = !isCallerSync(uri); + mContext.getContentResolver().notifyChange(uri, null, shouldSyncToNetwork); } return successes;