Sanity check screenId before persisting ItemInfo.

Bug: 13447571
Change-Id: I014dcf1eb313c2312953716fb53e542caaeb285b
This commit is contained in:
Adrian Roos
2014-04-28 15:45:52 +02:00
parent 4ff73887f2
commit 8f3f6830f2
2 changed files with 7 additions and 2 deletions
+6 -1
View File
@@ -132,7 +132,7 @@ public class ItemInfo {
*
* @param values
*/
void onAddToDatabase(ContentValues values) {
void onAddToDatabase(ContentValues values) {
values.put(LauncherSettings.BaseLauncherColumns.ITEM_TYPE, itemType);
values.put(LauncherSettings.Favorites.CONTAINER, container);
values.put(LauncherSettings.Favorites.SCREEN, screenId);
@@ -140,6 +140,11 @@ public class ItemInfo {
values.put(LauncherSettings.Favorites.CELLY, cellY);
values.put(LauncherSettings.Favorites.SPANX, spanX);
values.put(LauncherSettings.Favorites.SPANY, spanY);
if (screenId == Workspace.EXTRA_EMPTY_SCREEN_ID) {
// We should never persist an item on the extra empty screen.
throw new RuntimeException("Screen id should not be EXTRA_EMPTY_SCREEN_ID");
}
}
void updateValuesWithCoordinates(ContentValues values, int cellX, int cellY) {
+1 -1
View File
@@ -126,7 +126,7 @@ public class Workspace extends SmoothPagedView
private static boolean sAccessibilityEnabled;
// The screen id used for the empty screen always present to the right.
private final static long EXTRA_EMPTY_SCREEN_ID = -201;
final static long EXTRA_EMPTY_SCREEN_ID = -201;
private final static long CUSTOM_CONTENT_SCREEN_ID = -301;
private HashMap<Long, CellLayout> mWorkspaceScreens = new HashMap<Long, CellLayout>();