Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fd69e0b5 authored by Sunny Goyal's avatar Sunny Goyal Committed by Android (Google) Code Review
Browse files

Merge "Adding rank column in backup" into ub-launcher3-burnaby

parents 946609f0 107ea634
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -101,7 +101,10 @@ message Favorite {
  optional string iconPackage = 16;
  optional string iconResource = 17;
  optional bytes icon = 18;

  // Added in backup version 4
  optional TargetType targetType = 19 [default = TARGET_NONE];
  optional int32 rank = 20;
}

message Screen {
@@ -121,6 +124,7 @@ message Widget {
  optional Resource icon = 4;
  optional Resource preview = 5;

  // Added in backup version 3
  // Assume that a widget is resizable upto 2x2 if no data is available
  optional int32 minSpanX = 6 [default = 2];
  optional int32 minSpanY = 7 [default = 2];
+3 −2
Original line number Diff line number Diff line
@@ -91,11 +91,12 @@ public class LauncherBackupAgentHelper extends BackupAgentHelper {
            LauncherAppState.getLauncherProvider().clearFlagEmptyDbCreated();
            LauncherClings.synchonouslyMarkFirstRunClingDismissed(this);

            // TODO: Update the backup set to include rank.
            // Rank was added in v4.
            if (mHelper.restoredBackupVersion <= 3) {
                LauncherAppState.getLauncherProvider().updateFolderItemsRank();
                LauncherAppState.getLauncherProvider().convertShortcutsToLauncherActivities();
            }

            LauncherAppState.getLauncherProvider().convertShortcutsToLauncherActivities();
        } else {
            if (VERBOSE) Log.v(TAG, "Nothing was restored, clearing DB");
            LauncherAppState.getLauncherProvider().createEmptyDB();
+12 −3
Original line number Diff line number Diff line
@@ -75,7 +75,7 @@ public class LauncherBackupHelper implements BackupHelper {
    private static final boolean VERBOSE = LauncherBackupAgentHelper.VERBOSE;
    private static final boolean DEBUG = LauncherBackupAgentHelper.DEBUG;

    private static final int BACKUP_VERSION = 3;
    private static final int BACKUP_VERSION = 4;
    private static final int MAX_JOURNAL_SIZE = 1000000;

    // Journal key is such that it is always smaller than any dynamically generated
@@ -107,6 +107,7 @@ public class LauncherBackupHelper implements BackupHelper {
        Favorites.SPANY,                   // 15
        Favorites.TITLE,                   // 16
        Favorites.PROFILE_ID,              // 17
        Favorites.RANK,                    // 18
    };

    private static final int ID_INDEX = 0;
@@ -126,6 +127,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 RANK_INDEX = 18;

    private static final String[] SCREEN_PROJECTION = {
        WorkspaceScreens._ID,              // 0
@@ -441,7 +443,10 @@ public class LauncherBackupHelper implements BackupHelper {
                Key key = getKey(Key.FAVORITE, id);
                mKeys.add(key);
                final String backupKey = keyToBackupKey(key);
                if (!mExistingKeys.contains(backupKey) || updateTime >= mLastBackupRestoreTime) {

                // Favorite proto changed in v4. Backup again if the version is old.
                if (!mExistingKeys.contains(backupKey) || updateTime >= mLastBackupRestoreTime
                        || restoredBackupVersion < 4) {
                    writeRowToBackup(key, packFavorite(cursor), data);
                } else {
                    if (DEBUG) Log.d(TAG, "favorite already backup up: " + id);
@@ -648,7 +653,9 @@ public class LauncherBackupHelper implements BackupHelper {
                } else {
                    Log.w(TAG, "empty intent on appwidget: " + id);
                }
                if (mExistingKeys.contains(backupKey) && restoredBackupVersion >= BACKUP_VERSION) {

                // Widget backup proto changed in v3. So add it again if the original backup is old.
                if (mExistingKeys.contains(backupKey) && restoredBackupVersion >= 3) {
                    if (DEBUG) Log.d(TAG, "already saved widget " + backupKey);

                    // remember that we already backed this up previously
@@ -783,6 +790,7 @@ public class LauncherBackupHelper implements BackupHelper {
        favorite.spanX = c.getInt(SPANX_INDEX);
        favorite.spanY = c.getInt(SPANY_INDEX);
        favorite.iconType = c.getInt(ICON_TYPE_INDEX);
        favorite.rank = c.getInt(RANK_INDEX);

        String title = c.getString(TITLE_INDEX);
        if (!TextUtils.isEmpty(title)) {
@@ -870,6 +878,7 @@ public class LauncherBackupHelper implements BackupHelper {
        values.put(Favorites.CELLY, favorite.cellY);
        values.put(Favorites.SPANX, favorite.spanX);
        values.put(Favorites.SPANY, favorite.spanY);
        values.put(Favorites.RANK, favorite.rank);

        if (favorite.itemType == Favorites.ITEM_TYPE_SHORTCUT) {
            values.put(Favorites.ICON_TYPE, favorite.iconType);