summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenny Guy <kennyguy@google.com>2014-05-09 16:44:18 +0100
committerKenny Guy <kennyguy@google.com>2014-05-09 18:05:29 +0100
commit43ea7ac8ade3d6b6b354fc2f4623c14ac4e69020 (patch)
treeed48420fe591cdbfd60c1f0c8ecbaa9ba5e14a61 /src
parent1317e2dd4a2fb097d1e54759536d515fdeca2c3e (diff)
downloadandroid_packages_apps_Trebuchet-43ea7ac8ade3d6b6b354fc2f4623c14ac4e69020.tar.gz
android_packages_apps_Trebuchet-43ea7ac8ade3d6b6b354fc2f4623c14ac4e69020.tar.bz2
android_packages_apps_Trebuchet-43ea7ac8ade3d6b6b354fc2f4623c14ac4e69020.zip
Fix missing space in select statement in backup helper.
Also check when backing up favourites that they are for current user. Change-Id: Ic9d496c30612ee531fa84a22f852b3012df00b4f
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);