summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenny Guy <kennyguy@google.com>2014-05-12 11:50:19 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-05-12 11:50:19 +0000
commita1f26fdb50862abe55f648925d0b07dfd28d8208 (patch)
treeae2ba825da946d69c99009b9310ebbdcd7cefc67 /src
parente1c92c4afa7df98c13c3f57986f6f44ffe8ce952 (diff)
parent43ea7ac8ade3d6b6b354fc2f4623c14ac4e69020 (diff)
downloadandroid_packages_apps_Trebuchet-a1f26fdb50862abe55f648925d0b07dfd28d8208.tar.gz
android_packages_apps_Trebuchet-a1f26fdb50862abe55f648925d0b07dfd28d8208.tar.bz2
android_packages_apps_Trebuchet-a1f26fdb50862abe55f648925d0b07dfd28d8208.zip
Merge "Fix missing space in select statement in backup helper." into ub-now-nova
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/LauncherBackupHelper.java33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/com/android/launcher3/LauncherBackupHelper.java b/src/com/android/launcher3/LauncherBackupHelper.java
index 275fccc16..81ced7b3b 100644
--- a/src/com/android/launcher3/LauncherBackupHelper.java
+++ b/src/com/android/launcher3/LauncherBackupHelper.java
@@ -110,6 +110,7 @@ public class LauncherBackupHelper implements BackupHelper {
Favorites.SPANX, // 14
Favorites.SPANY, // 15
Favorites.TITLE, // 16
+ Favorites.PROFILE_ID, // 17
};
private static final int ID_INDEX = 0;
@@ -129,6 +130,7 @@ public class LauncherBackupHelper implements BackupHelper {
private static final int SPANX_INDEX = 14;
private static final int SPANY_INDEX = 15;
private static final int TITLE_INDEX = 16;
+ private static final int PROFILE_ID_INDEX = 17;
private static final String[] SCREEN_PROJECTION = {
WorkspaceScreens._ID, // 0
@@ -297,6 +299,11 @@ public class LauncherBackupHelper implements BackupHelper {
Set<String> savedIds = getSavedIdsByType(Key.FAVORITE, in);
if (DEBUG) Log.d(TAG, "favorite savedIds.size()=" + savedIds.size());
+ // Don't backup apps in other profiles for now.
+ UserHandleCompat myUserHandle = UserHandleCompat.myUserHandle();
+ long userSerialNumber =
+ UserManagerCompat.getInstance(mContext).getSerialNumberForUser(myUserHandle);
+
// persist things that have changed since the last backup
ContentResolver cr = mContext.getContentResolver();
Cursor cursor = cr.query(Favorites.CONTENT_URI, FAVORITE_PROJECTION,
@@ -306,16 +313,22 @@ public class LauncherBackupHelper implements BackupHelper {
cursor.moveToPosition(-1);
while(cursor.moveToNext()) {
final long id = cursor.getLong(ID_INDEX);
- final long updateTime = cursor.getLong(ID_MODIFIED);
- Key key = getKey(Key.FAVORITE, id);
- keys.add(key);
- final String backupKey = keyToBackupKey(key);
- currentIds.add(backupKey);
- if (!savedIds.contains(backupKey) || updateTime >= in.t) {
- byte[] blob = packFavorite(cursor);
- writeRowToBackup(key, blob, out, data);
+ final long profileId = cursor.getLong(PROFILE_ID_INDEX);
+ if (userSerialNumber == profileId) {
+ final long updateTime = cursor.getLong(ID_MODIFIED);
+ Key key = getKey(Key.FAVORITE, id);
+ keys.add(key);
+ final String backupKey = keyToBackupKey(key);
+ currentIds.add(backupKey);
+ if (!savedIds.contains(backupKey) || updateTime >= in.t) {
+ byte[] blob = packFavorite(cursor);
+ writeRowToBackup(key, blob, out, data);
+ } else {
+ if (VERBOSE) Log.v(TAG, "favorite " + id + " was too old: " + updateTime);
+ }
} else {
- if (VERBOSE) Log.v(TAG, "favorite " + id + " was too old: " + updateTime);
+ if (VERBOSE) Log.v(TAG, "favorite " + id + " is for other profile: "
+ + profileId);
}
}
} finally {
@@ -468,7 +481,7 @@ public class LauncherBackupHelper implements BackupHelper {
int startRows = out.rows;
if (DEBUG) Log.d(TAG, "starting here: " + startRows);
String where = "(" + Favorites.ITEM_TYPE + "=" + Favorites.ITEM_TYPE_APPLICATION + " OR " +
- Favorites.ITEM_TYPE + "=" + Favorites.ITEM_TYPE_SHORTCUT + ") AND" +
+ Favorites.ITEM_TYPE + "=" + Favorites.ITEM_TYPE_SHORTCUT + ") AND " +
Favorites.PROFILE_ID + "=" + userSerialNumber;
Cursor cursor = cr.query(Favorites.CONTENT_URI, FAVORITE_PROJECTION,
where, null, null);