Loading src/com/android/launcher3/AppWidgetsRestoredReceiver.java +8 −4 Original line number Diff line number Diff line Loading @@ -86,13 +86,12 @@ public class AppWidgetsRestoredReceiver extends BroadcastReceiver { long mainProfileId = UserCache.INSTANCE.get(context) .getSerialNumberForUser(myUserHandle()); String oldWidgetId = Integer.toString(oldWidgetIds[i]); int result = new ContentWriter(context, new ContentWriter.CommitParams( "appWidgetId=? and (restored & 1) = 1 and profileId=?", new String[] { oldWidgetId, Long.toString(mainProfileId) })) final String where = "appWidgetId=? and (restored & 1) = 1 and profileId=?"; final String[] args = new String[] { oldWidgetId, Long.toString(mainProfileId) }; int result = new ContentWriter(context, new ContentWriter.CommitParams(where, args)) .put(LauncherSettings.Favorites.APPWIDGET_ID, newWidgetIds[i]) .put(LauncherSettings.Favorites.RESTORED, state) .commit(); if (result == 0) { Cursor cursor = cr.query(Favorites.CONTENT_URI, new String[] {Favorites.APPWIDGET_ID}, Loading @@ -106,6 +105,11 @@ public class AppWidgetsRestoredReceiver extends BroadcastReceiver { cursor.close(); } } // attempt to update widget id in backup table as well new ContentWriter(context, ContentWriter.CommitParams.backupCommitParams(where, args)) .put(LauncherSettings.Favorites.APPWIDGET_ID, newWidgetIds[i]) .put(LauncherSettings.Favorites.RESTORED, state) .commit(); } LauncherAppState app = LauncherAppState.getInstanceNoCreate(); Loading src/com/android/launcher3/LauncherSettings.java +6 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,12 @@ public class LauncherSettings { public static final Uri CONTENT_URI = Uri.parse("content://" + LauncherProvider.AUTHORITY + "/" + TABLE_NAME); /** * The content:// style URL for "favorites_bakup" table */ public static final Uri BACKUP_CONTENT_URI = Uri.parse("content://" + LauncherProvider.AUTHORITY + "/" + BACKUP_TABLE_NAME); /** * The content:// style URL for "favorites_preview" table */ Loading src/com/android/launcher3/util/ContentWriter.java +15 −3 Original line number Diff line number Diff line Loading @@ -113,14 +113,26 @@ public class ContentWriter { public static final class CommitParams { final Uri mUri = LauncherSettings.Favorites.CONTENT_URI; String mWhere; String[] mSelectionArgs; final Uri mUri; final String mWhere; final String[] mSelectionArgs; public CommitParams(String where, String[] selectionArgs) { this(LauncherSettings.Favorites.CONTENT_URI, where, selectionArgs); } private CommitParams(Uri uri, String where, String[] selectionArgs) { mUri = uri; mWhere = where; mSelectionArgs = selectionArgs; } /** * Creates commit params for backup table. */ public static CommitParams backupCommitParams(String where, String[] selectionArgs) { return new CommitParams( LauncherSettings.Favorites.BACKUP_CONTENT_URI, where, selectionArgs); } } } Loading
src/com/android/launcher3/AppWidgetsRestoredReceiver.java +8 −4 Original line number Diff line number Diff line Loading @@ -86,13 +86,12 @@ public class AppWidgetsRestoredReceiver extends BroadcastReceiver { long mainProfileId = UserCache.INSTANCE.get(context) .getSerialNumberForUser(myUserHandle()); String oldWidgetId = Integer.toString(oldWidgetIds[i]); int result = new ContentWriter(context, new ContentWriter.CommitParams( "appWidgetId=? and (restored & 1) = 1 and profileId=?", new String[] { oldWidgetId, Long.toString(mainProfileId) })) final String where = "appWidgetId=? and (restored & 1) = 1 and profileId=?"; final String[] args = new String[] { oldWidgetId, Long.toString(mainProfileId) }; int result = new ContentWriter(context, new ContentWriter.CommitParams(where, args)) .put(LauncherSettings.Favorites.APPWIDGET_ID, newWidgetIds[i]) .put(LauncherSettings.Favorites.RESTORED, state) .commit(); if (result == 0) { Cursor cursor = cr.query(Favorites.CONTENT_URI, new String[] {Favorites.APPWIDGET_ID}, Loading @@ -106,6 +105,11 @@ public class AppWidgetsRestoredReceiver extends BroadcastReceiver { cursor.close(); } } // attempt to update widget id in backup table as well new ContentWriter(context, ContentWriter.CommitParams.backupCommitParams(where, args)) .put(LauncherSettings.Favorites.APPWIDGET_ID, newWidgetIds[i]) .put(LauncherSettings.Favorites.RESTORED, state) .commit(); } LauncherAppState app = LauncherAppState.getInstanceNoCreate(); Loading
src/com/android/launcher3/LauncherSettings.java +6 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,12 @@ public class LauncherSettings { public static final Uri CONTENT_URI = Uri.parse("content://" + LauncherProvider.AUTHORITY + "/" + TABLE_NAME); /** * The content:// style URL for "favorites_bakup" table */ public static final Uri BACKUP_CONTENT_URI = Uri.parse("content://" + LauncherProvider.AUTHORITY + "/" + BACKUP_TABLE_NAME); /** * The content:// style URL for "favorites_preview" table */ Loading
src/com/android/launcher3/util/ContentWriter.java +15 −3 Original line number Diff line number Diff line Loading @@ -113,14 +113,26 @@ public class ContentWriter { public static final class CommitParams { final Uri mUri = LauncherSettings.Favorites.CONTENT_URI; String mWhere; String[] mSelectionArgs; final Uri mUri; final String mWhere; final String[] mSelectionArgs; public CommitParams(String where, String[] selectionArgs) { this(LauncherSettings.Favorites.CONTENT_URI, where, selectionArgs); } private CommitParams(Uri uri, String where, String[] selectionArgs) { mUri = uri; mWhere = where; mSelectionArgs = selectionArgs; } /** * Creates commit params for backup table. */ public static CommitParams backupCommitParams(String where, String[] selectionArgs) { return new CommitParams( LauncherSettings.Favorites.BACKUP_CONTENT_URI, where, selectionArgs); } } }