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

Commit 278939fd authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Removing GridMigrationTask-v1 since it has been disabled for a while

Also removing some data migration support

Bug: 194937047
Test: Presubmit
Change-Id: I392a5f6e49ec170f63056a7664de47229896f390
parent 83ba3336
Loading
Loading
Loading
Loading
+0 −135
Original line number Original line Diff line number Diff line
package com.android.launcher3.model;


import static android.database.DatabaseUtils.queryNumEntries;

import static com.android.launcher3.LauncherSettings.Favorites.BACKUP_TABLE_NAME;
import static com.android.launcher3.LauncherSettings.Favorites.TABLE_NAME;
import static com.android.launcher3.provider.LauncherDbUtils.tableExists;
import static com.android.launcher3.util.LauncherModelHelper.APP_ICON;
import static com.android.launcher3.util.LauncherModelHelper.DESKTOP;
import static com.android.launcher3.util.LauncherModelHelper.NO__ICON;
import static com.android.launcher3.util.LauncherModelHelper.SHORTCUT;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Point;

import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.LauncherSettings.Settings;
import com.android.launcher3.util.LauncherModelHelper;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;

/**
 * Unit tests for {@link GridBackupTable}
 */
@RunWith(RobolectricTestRunner.class)
public class GridBackupTableTest {

    private static final int BACKUP_ITEM_COUNT = 12;

    private LauncherModelHelper mModelHelper;
    private Context mContext;
    private SQLiteDatabase mDb;

    @Before
    public void setUp() {
        mModelHelper = new LauncherModelHelper();
        mContext = RuntimeEnvironment.application;
        mDb = mModelHelper.provider.getDb();

        setupGridData();
    }

    private void setupGridData() {
        mModelHelper.createGrid(new int[][][]{{
                { APP_ICON, APP_ICON, SHORTCUT, SHORTCUT},
                { SHORTCUT, SHORTCUT, NO__ICON, NO__ICON},
                { NO__ICON, NO__ICON, SHORTCUT, SHORTCUT},
                { APP_ICON, SHORTCUT, SHORTCUT, APP_ICON},
        }});
        assertEquals(BACKUP_ITEM_COUNT, queryNumEntries(mDb, TABLE_NAME));
    }

    @Test
    public void backupTableCreated() {
        GridBackupTable backupTable = new GridBackupTable(mContext, mDb, 4, 4, 4);
        assertFalse(backupTable.backupOrRestoreAsNeeded());
        Settings.call(mContext.getContentResolver(), Settings.METHOD_REFRESH_BACKUP_TABLE);

        assertTrue(tableExists(mDb, BACKUP_TABLE_NAME));

        // One extra entry for properties
        assertEquals(BACKUP_ITEM_COUNT + 1, queryNumEntries(mDb, BACKUP_TABLE_NAME));
    }

    @Test
    public void backupTableRestored() {
        assertFalse(new GridBackupTable(mContext, mDb, 4, 4, 4).backupOrRestoreAsNeeded());
        Settings.call(mContext.getContentResolver(), Settings.METHOD_REFRESH_BACKUP_TABLE);

        // Delete entries
        mDb.delete(TABLE_NAME, null, null);
        assertEquals(0, queryNumEntries(mDb, TABLE_NAME));

        GridBackupTable backupTable = new GridBackupTable(mContext, mDb, 3, 3, 3);
        assertTrue(backupTable.backupOrRestoreAsNeeded());

        // Items have been restored
        assertEquals(BACKUP_ITEM_COUNT, queryNumEntries(mDb, TABLE_NAME));

        Point outSize = new Point();
        assertEquals(4, backupTable.getRestoreHotseatAndGridSize(outSize));
        assertEquals(4, outSize.x);
        assertEquals(4, outSize.y);
    }

    @Test
    public void backupTableRemovedOnAdd() {
        assertFalse(new GridBackupTable(mContext, mDb, 4, 4, 4).backupOrRestoreAsNeeded());
        Settings.call(mContext.getContentResolver(), Settings.METHOD_REFRESH_BACKUP_TABLE);

        assertTrue(tableExists(mDb, BACKUP_TABLE_NAME));

        mModelHelper.addItem(1, 2, DESKTOP, 1, 1);
        assertFalse(tableExists(mDb, BACKUP_TABLE_NAME));
    }

    @Test
    public void backupTableRemovedOnDelete() {
        assertFalse(new GridBackupTable(mContext, mDb, 4, 4, 4).backupOrRestoreAsNeeded());
        Settings.call(mContext.getContentResolver(), Settings.METHOD_REFRESH_BACKUP_TABLE);

        assertTrue(tableExists(mDb, BACKUP_TABLE_NAME));

        mContext.getContentResolver().delete(Favorites.CONTENT_URI, null, null);
        assertFalse(tableExists(mDb, BACKUP_TABLE_NAME));
    }

    @Test
    public void backupTableRetainedOnUpdate() {
        assertFalse(new GridBackupTable(mContext, mDb, 4, 4, 4).backupOrRestoreAsNeeded());
        Settings.call(mContext.getContentResolver(), Settings.METHOD_REFRESH_BACKUP_TABLE);

        assertTrue(tableExists(mDb, BACKUP_TABLE_NAME));

        ContentValues values = new ContentValues();
        values.put(Favorites.RANK, 4);
        // Something was updated
        assertTrue(mContext.getContentResolver()
                .update(Favorites.CONTENT_URI, values, null, null) > 0);

        // Backup table remains
        assertTrue(tableExists(mDb, BACKUP_TABLE_NAME));
    }
}
+0 −373
Original line number Original line Diff line number Diff line
package com.android.launcher3.model;

import static com.android.launcher3.model.GridSizeMigrationTask.getWorkspaceScreenIds;
import static com.android.launcher3.util.LauncherModelHelper.APP_ICON;
import static com.android.launcher3.util.LauncherModelHelper.HOTSEAT;
import static com.android.launcher3.util.LauncherModelHelper.SHORTCUT;
import static com.android.launcher3.util.LauncherModelHelper.TEST_PACKAGE;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Point;

import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.model.GridSizeMigrationTask.MultiStepMigrationTask;
import com.android.launcher3.util.IntArray;
import com.android.launcher3.util.LauncherModelHelper;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;

import java.util.HashSet;
import java.util.LinkedList;

/**
 * Unit tests for {@link GridSizeMigrationTask}
 */
@RunWith(RobolectricTestRunner.class)
public class GridSizeMigrationTaskTest {

    private LauncherModelHelper mModelHelper;
    private Context mContext;
    private SQLiteDatabase mDb;

    private HashSet<String> mValidPackages;
    private InvariantDeviceProfile mIdp;

    @Before
    public void setUp() {
        mModelHelper = new LauncherModelHelper();
        mContext = RuntimeEnvironment.application;
        mDb = mModelHelper.provider.getDb();

        mValidPackages = new HashSet<>();
        mValidPackages.add(TEST_PACKAGE);
        mIdp = InvariantDeviceProfile.INSTANCE.get(mContext);
    }

    @Test
    public void testHotseatMigration_apps_dropped() throws Exception {
        int[] hotseatItems = {
                mModelHelper.addItem(APP_ICON, 0, HOTSEAT, 0, 0),
                mModelHelper.addItem(SHORTCUT, 1, HOTSEAT, 0, 0),
                -1,
                mModelHelper.addItem(SHORTCUT, 3, HOTSEAT, 0, 0),
                mModelHelper.addItem(APP_ICON, 4, HOTSEAT, 0, 0),
        };

        mIdp.numDatabaseHotseatIcons = 3;
        new GridSizeMigrationTask(mContext, mDb, mValidPackages, false, 5, 3)
                .migrateHotseat();
        // First item is dropped as it has the least weight.
        verifyHotseat(hotseatItems[1], hotseatItems[3], hotseatItems[4]);
    }

    @Test
    public void testHotseatMigration_shortcuts_dropped() throws Exception {
        int[] hotseatItems = {
                mModelHelper.addItem(APP_ICON, 0, HOTSEAT, 0, 0),
                mModelHelper.addItem(30, 1, HOTSEAT, 0, 0),
                -1,
                mModelHelper.addItem(SHORTCUT, 3, HOTSEAT, 0, 0),
                mModelHelper.addItem(10, 4, HOTSEAT, 0, 0),
        };

        mIdp.numDatabaseHotseatIcons = 3;
        new GridSizeMigrationTask(mContext, mDb, mValidPackages, false, 5, 3)
                .migrateHotseat();
        // First item is dropped as it has the least weight.
        verifyHotseat(hotseatItems[1], hotseatItems[3], hotseatItems[4]);
    }

    private void verifyHotseat(int... sortedIds) {
        int screenId = 0;
        int total = 0;

        for (int id : sortedIds) {
            Cursor c = mContext.getContentResolver().query(LauncherSettings.Favorites.CONTENT_URI,
                    new String[]{LauncherSettings.Favorites._ID},
                    "container=-101 and screen=" + screenId, null, null, null);

            if (id == -1) {
                assertEquals(0, c.getCount());
            } else {
                assertEquals(1, c.getCount());
                c.moveToNext();
                assertEquals(id, c.getLong(0));
                total ++;
            }
            c.close();

            screenId++;
        }

        // Verify that not other entry exist in the DB.
        Cursor c = mContext.getContentResolver().query(LauncherSettings.Favorites.CONTENT_URI,
                new String[]{LauncherSettings.Favorites._ID},
                "container=-101", null, null, null);
        assertEquals(total, c.getCount());
        c.close();
    }

    @Test
    public void testWorkspace_empty_row_column_removed() throws Exception {
        int[][][] ids = mModelHelper.createGrid(new int[][][]{{
                {  0,  0, -1,  1},
                {  3,  1, -1,  4},
                { -1, -1, -1, -1},
                {  5,  2, -1,  6},
        }});

        new GridSizeMigrationTask(mContext, mDb, mValidPackages, false,
                new Point(4, 4), new Point(3, 3)).migrateWorkspace();

        // Column 2 and row 2 got removed.
        verifyWorkspace(new int[][][] {{
                {ids[0][0][0], ids[0][0][1], ids[0][0][3]},
                {ids[0][1][0], ids[0][1][1], ids[0][1][3]},
                {ids[0][3][0], ids[0][3][1], ids[0][3][3]},
        }});
    }

    @Test
    public void testWorkspace_new_screen_created() throws Exception {
        int[][][] ids = mModelHelper.createGrid(new int[][][]{{
                {  0,  0,  0,  1},
                {  3,  1,  0,  4},
                { -1, -1, -1, -1},
                {  5,  2, -1,  6},
        }});

        new GridSizeMigrationTask(mContext, mDb, mValidPackages, false,
                new Point(4, 4), new Point(3, 3)).migrateWorkspace();

        // Items in the second column get moved to new screen
        verifyWorkspace(new int[][][] {{
                {ids[0][0][0], ids[0][0][1], ids[0][0][3]},
                {ids[0][1][0], ids[0][1][1], ids[0][1][3]},
                {ids[0][3][0], ids[0][3][1], ids[0][3][3]},
        }, {
                {ids[0][0][2], ids[0][1][2], -1},
        }});
    }

    @Test
    public void testWorkspace_items_merged_in_next_screen() throws Exception {
        int[][][] ids = mModelHelper.createGrid(new int[][][]{{
                {  0,  0,  0,  1},
                {  3,  1,  0,  4},
                { -1, -1, -1, -1},
                {  5,  2, -1,  6},
        },{
                {  0,  0, -1,  1},
                {  3,  1, -1,  4},
        }});

        new GridSizeMigrationTask(mContext, mDb, mValidPackages, false,
                new Point(4, 4), new Point(3, 3)).migrateWorkspace();

        // Items in the second column of the first screen should get placed on the 3rd
        // row of the second screen
        verifyWorkspace(new int[][][] {{
                {ids[0][0][0], ids[0][0][1], ids[0][0][3]},
                {ids[0][1][0], ids[0][1][1], ids[0][1][3]},
                {ids[0][3][0], ids[0][3][1], ids[0][3][3]},
        }, {
                {ids[1][0][0], ids[1][0][1], ids[1][0][3]},
                {ids[1][1][0], ids[1][1][1], ids[1][1][3]},
                {ids[0][0][2], ids[0][1][2], -1},
        }});
    }

    @Test
    public void testWorkspace_items_not_merged_in_next_screen() throws Exception {
        // First screen has 2 mItems that need to be moved, but second screen has only one
        // empty space after migration (top-left corner)
        int[][][] ids = mModelHelper.createGrid(new int[][][]{{
                {  0,  0,  0,  1},
                {  3,  1,  0,  4},
                { -1, -1, -1, -1},
                {  5,  2, -1,  6},
        },{
                { -1,  0, -1,  1},
                {  3,  1, -1,  4},
                { -1, -1, -1, -1},
                {  5,  2, -1,  6},
        }});

        new GridSizeMigrationTask(mContext, mDb, mValidPackages, false,
                new Point(4, 4), new Point(3, 3)).migrateWorkspace();

        // Items in the second column of the first screen should get placed on a new screen.
        verifyWorkspace(new int[][][] {{
                {ids[0][0][0], ids[0][0][1], ids[0][0][3]},
                {ids[0][1][0], ids[0][1][1], ids[0][1][3]},
                {ids[0][3][0], ids[0][3][1], ids[0][3][3]},
        }, {
                {          -1, ids[1][0][1], ids[1][0][3]},
                {ids[1][1][0], ids[1][1][1], ids[1][1][3]},
                {ids[1][3][0], ids[1][3][1], ids[1][3][3]},
        }, {
                {ids[0][0][2], ids[0][1][2], -1},
        }});
    }

    @Test
    public void testWorkspace_first_row_blocked() throws Exception {
        if (!FeatureFlags.QSB_ON_FIRST_SCREEN) {
            return;
        }
        // The first screen has one item on the 4th column which needs moving, as the first row
        // will be kept empty.
        int[][][] ids = mModelHelper.createGrid(new int[][][]{{
                { -1, -1, -1, -1},
                {  3,  1,  7,  0},
                {  8,  7,  7, -1},
                {  5,  2,  7, -1},
        }}, 0);

        new GridSizeMigrationTask(mContext, mDb, mValidPackages, false,
                new Point(4, 4), new Point(3, 4)).migrateWorkspace();

        // Items in the second column of the first screen should get placed on a new screen.
        verifyWorkspace(new int[][][] {{
                {          -1,           -1,           -1},
                {ids[0][1][0], ids[0][1][1], ids[0][1][2]},
                {ids[0][2][0], ids[0][2][1], ids[0][2][2]},
                {ids[0][3][0], ids[0][3][1], ids[0][3][2]},
        }, {
                {ids[0][1][3]},
        }});
    }

    @Test
    public void testWorkspace_items_moved_to_empty_first_row() throws Exception {
        if (!FeatureFlags.QSB_ON_FIRST_SCREEN) {
            return;
        }
        // Items will get moved to the next screen to keep the first screen empty.
        int[][][] ids = mModelHelper.createGrid(new int[][][]{{
                { -1, -1, -1, -1},
                {  0,  1,  0,  0},
                {  8,  7,  7, -1},
                {  5,  6,  7, -1},
        }}, 0);

        new GridSizeMigrationTask(mContext, mDb, mValidPackages, false,
                new Point(4, 4), new Point(3, 3)).migrateWorkspace();

        // Items in the second column of the first screen should get placed on a new screen.
        verifyWorkspace(new int[][][] {{
                {          -1,           -1,           -1},
                {ids[0][2][0], ids[0][2][1], ids[0][2][2]},
                {ids[0][3][0], ids[0][3][1], ids[0][3][2]},
        }, {
                {ids[0][1][1], ids[0][1][0], ids[0][1][2]},
                {ids[0][1][3]},
        }});
    }

    /**
     * Verifies that the workspace mItems are arranged in the provided order.
     * @param ids A 3d array where the first dimension represents the screen, and the rest two
     *            represent the workspace grid.
     */
    private void verifyWorkspace(int[][][] ids) {
        IntArray allScreens = getWorkspaceScreenIds(mDb, LauncherSettings.Favorites.TABLE_NAME);
        assertEquals(ids.length, allScreens.size());
        int total = 0;

        for (int i = 0; i < ids.length; i++) {
            int screenId = allScreens.get(i);
            for (int y = 0; y < ids[i].length; y++) {
                for (int x = 0; x < ids[i][y].length; x++) {
                    int id = ids[i][y][x];

                    Cursor c = mContext.getContentResolver().query(
                            LauncherSettings.Favorites.CONTENT_URI,
                            new String[]{LauncherSettings.Favorites._ID},
                            "container=-100 and screen=" + screenId +
                                    " and cellX=" + x + " and cellY=" + y, null, null, null);
                    if (id == -1) {
                        assertEquals(0, c.getCount());
                    } else {
                        assertEquals(1, c.getCount());
                        c.moveToNext();
                        assertEquals(String.format("Failed to verify item at %d %d, %d", i, y, x),
                                id, c.getLong(0));
                        total++;
                    }
                    c.close();
                }
            }
        }

        // Verify that not other entry exist in the DB.
        Cursor c = mContext.getContentResolver().query(LauncherSettings.Favorites.CONTENT_URI,
                new String[]{LauncherSettings.Favorites._ID},
                "container=-100", null, null, null);
        assertEquals(total, c.getCount());
        c.close();
    }

    @Test
    public void testMultiStepMigration_small_to_large() throws Exception {
        MultiStepMigrationTaskVerifier verifier = new MultiStepMigrationTaskVerifier();
        verifier.migrate(new Point(3, 3), new Point(5, 5));
        verifier.assertCompleted();
    }

    @Test
    public void testMultiStepMigration_large_to_small() throws Exception {
        MultiStepMigrationTaskVerifier verifier = new MultiStepMigrationTaskVerifier(
                5, 5, 4, 4,
                4, 4, 3, 4
        );
        verifier.migrate(new Point(5, 5), new Point(3, 4));
        verifier.assertCompleted();
    }

    @Test
    public void testMultiStepMigration_zig_zag() throws Exception {
        MultiStepMigrationTaskVerifier verifier = new MultiStepMigrationTaskVerifier(
                5, 7, 4, 7,
                4, 7, 3, 7
        );
        verifier.migrate(new Point(5, 5), new Point(3, 7));
        verifier.assertCompleted();
    }

    private static class MultiStepMigrationTaskVerifier extends MultiStepMigrationTask {

        private final LinkedList<Point> mPoints;

        public MultiStepMigrationTaskVerifier(int... points) {
            super(null, null, null, false);

            mPoints = new LinkedList<>();
            for (int i = 0; i < points.length; i += 2) {
                mPoints.add(new Point(points[i], points[i + 1]));
            }
        }

        @Override
        protected boolean runStepTask(Point sourceSize, Point nextSize) throws Exception {
            assertEquals(sourceSize, mPoints.poll());
            assertEquals(nextSize, mPoints.poll());
            return false;
        }

        public void assertCompleted() {
            assertTrue(mPoints.isEmpty());
        }
    }
}
+20 −36
Original line number Original line Diff line number Diff line
@@ -16,7 +16,6 @@


package com.android.launcher3;
package com.android.launcher3;


import static com.android.launcher3.config.FeatureFlags.MULTI_DB_GRID_MIRATION_ALGO;
import static com.android.launcher3.provider.LauncherDbUtils.copyTable;
import static com.android.launcher3.provider.LauncherDbUtils.copyTable;
import static com.android.launcher3.provider.LauncherDbUtils.dropTable;
import static com.android.launcher3.provider.LauncherDbUtils.dropTable;
import static com.android.launcher3.provider.LauncherDbUtils.tableExists;
import static com.android.launcher3.provider.LauncherDbUtils.tableExists;
@@ -433,7 +432,6 @@ public class LauncherProvider extends ContentProvider {
                return null;
                return null;
            }
            }
            case LauncherSettings.Settings.METHOD_UPDATE_CURRENT_OPEN_HELPER: {
            case LauncherSettings.Settings.METHOD_UPDATE_CURRENT_OPEN_HELPER: {
                if (MULTI_DB_GRID_MIRATION_ALGO.get()) {
                Bundle result = new Bundle();
                Bundle result = new Bundle();
                result.putBoolean(LauncherSettings.Settings.EXTRA_VALUE,
                result.putBoolean(LauncherSettings.Settings.EXTRA_VALUE,
                        prepForMigration(
                        prepForMigration(
@@ -444,10 +442,7 @@ public class LauncherProvider extends ContentProvider {
                                        getContext(), true /* forMigration */)));
                                        getContext(), true /* forMigration */)));
                return result;
                return result;
            }
            }
                return null;
            }
            case LauncherSettings.Settings.METHOD_PREP_FOR_PREVIEW: {
            case LauncherSettings.Settings.METHOD_PREP_FOR_PREVIEW: {
                if (MULTI_DB_GRID_MIRATION_ALGO.get()) {
                Bundle result = new Bundle();
                Bundle result = new Bundle();
                result.putBoolean(LauncherSettings.Settings.EXTRA_VALUE,
                result.putBoolean(LauncherSettings.Settings.EXTRA_VALUE,
                        prepForMigration(
                        prepForMigration(
@@ -458,8 +453,6 @@ public class LauncherProvider extends ContentProvider {
                                () -> mOpenHelper));
                                () -> mOpenHelper));
                return result;
                return result;
            }
            }
                return null;
            }
            case LauncherSettings.Settings.METHOD_SWITCH_DATABASE: {
            case LauncherSettings.Settings.METHOD_SWITCH_DATABASE: {
                if (TextUtils.equals(arg, mOpenHelper.getDatabaseName())) return null;
                if (TextUtils.equals(arg, mOpenHelper.getDatabaseName())) return null;
                final DatabaseHelper helper = mOpenHelper;
                final DatabaseHelper helper = mOpenHelper;
@@ -654,8 +647,7 @@ public class LauncherProvider extends ContentProvider {
        static DatabaseHelper createDatabaseHelper(Context context, String dbName,
        static DatabaseHelper createDatabaseHelper(Context context, String dbName,
                boolean forMigration) {
                boolean forMigration) {
            if (dbName == null) {
            if (dbName == null) {
                dbName = MULTI_DB_GRID_MIRATION_ALGO.get() ? InvariantDeviceProfile.INSTANCE.get(
                dbName = InvariantDeviceProfile.INSTANCE.get(context).dbFile;
                        context).dbFile : LauncherFiles.LAUNCHER_DB;
            }
            }
            DatabaseHelper databaseHelper = new DatabaseHelper(context, dbName, forMigration);
            DatabaseHelper databaseHelper = new DatabaseHelper(context, dbName, forMigration);
            // Table creation sometimes fails silently, which leads to a crash loop.
            // Table creation sometimes fails silently, which leads to a crash loop.
@@ -666,10 +658,6 @@ public class LauncherProvider extends ContentProvider {
                // This operation is a no-op if the table already exists.
                // This operation is a no-op if the table already exists.
                databaseHelper.addFavoritesTable(databaseHelper.getWritableDatabase(), true);
                databaseHelper.addFavoritesTable(databaseHelper.getWritableDatabase(), true);
            }
            }
            if (!MULTI_DB_GRID_MIRATION_ALGO.get()) {
                databaseHelper.mBackupTableExists = tableExists(
                        databaseHelper.getReadableDatabase(), Favorites.BACKUP_TABLE_NAME);
            }
            databaseHelper.mHotseatRestoreTableExists = tableExists(
            databaseHelper.mHotseatRestoreTableExists = tableExists(
                    databaseHelper.getReadableDatabase(), Favorites.HYBRID_HOTSEAT_BACKUP_TABLE);
                    databaseHelper.getReadableDatabase(), Favorites.HYBRID_HOTSEAT_BACKUP_TABLE);


@@ -851,11 +839,7 @@ public class LauncherProvider extends ContentProvider {
                case 25:
                case 25:
                    convertShortcutsToLauncherActivities(db);
                    convertShortcutsToLauncherActivities(db);
                case 26:
                case 26:
                    // QSB was moved to the grid. Clear the first row on screen 0.
                    // QSB was moved to the grid. Ignore overlapping items
                    if (FeatureFlags.QSB_ON_FIRST_SCREEN &&
                            !LauncherDbUtils.prepareScreenZeroToHostQsb(mContext, db)) {
                        break;
                    }
                case 27: {
                case 27: {
                    // Update the favorites table so that the screen ids are ordered based on
                    // Update the favorites table so that the screen ids are ordered based on
                    // workspace page rank.
                    // workspace page rank.
+0 −3
Original line number Original line Diff line number Diff line
@@ -144,9 +144,6 @@ public final class FeatureFlags {
    public static final BooleanFlag ENABLE_DEEP_SHORTCUT_ICON_CACHE = getDebugFlag(
    public static final BooleanFlag ENABLE_DEEP_SHORTCUT_ICON_CACHE = getDebugFlag(
            "ENABLE_DEEP_SHORTCUT_ICON_CACHE", true, "R/W deep shortcut in IconCache");
            "ENABLE_DEEP_SHORTCUT_ICON_CACHE", true, "R/W deep shortcut in IconCache");


    public static final BooleanFlag MULTI_DB_GRID_MIRATION_ALGO = getDebugFlag(
            "MULTI_DB_GRID_MIRATION_ALGO", true, "Use the multi-db grid migration algorithm");

    public static final BooleanFlag ENABLE_THEMED_ICONS = getDebugFlag(
    public static final BooleanFlag ENABLE_THEMED_ICONS = getDebugFlag(
            "ENABLE_THEMED_ICONS", true, "Enable themed icons on workspace");
            "ENABLE_THEMED_ICONS", true, "Enable themed icons on workspace");


+2 −10
Original line number Original line Diff line number Diff line
@@ -16,7 +16,6 @@


package com.android.launcher3.graphics;
package com.android.launcher3.graphics;


import static com.android.launcher3.config.FeatureFlags.MULTI_DB_GRID_MIRATION_ALGO;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;


@@ -47,7 +46,6 @@ import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace;
import com.android.launcher3.Workspace;
import com.android.launcher3.graphics.LauncherPreviewRenderer.PreviewContext;
import com.android.launcher3.graphics.LauncherPreviewRenderer.PreviewContext;
import com.android.launcher3.model.BgDataModel;
import com.android.launcher3.model.BgDataModel;
import com.android.launcher3.model.GridSizeMigrationTask;
import com.android.launcher3.model.GridSizeMigrationTaskV2;
import com.android.launcher3.model.GridSizeMigrationTaskV2;
import com.android.launcher3.model.LoaderTask;
import com.android.launcher3.model.LoaderTask;
import com.android.launcher3.model.ModelDelegate;
import com.android.launcher3.model.ModelDelegate;
@@ -198,16 +196,10 @@ public class PreviewSurfaceRenderer {


    @WorkerThread
    @WorkerThread
    private boolean doGridMigrationIfNecessary() {
    private boolean doGridMigrationIfNecessary() {
        boolean needsToMigrate =
        if (!GridSizeMigrationTaskV2.needsToMigrate(mContext, mIdp)) {
                MULTI_DB_GRID_MIRATION_ALGO.get()
                        ? GridSizeMigrationTaskV2.needsToMigrate(mContext, mIdp)
                        : GridSizeMigrationTask.needsToMigrate(mContext, mIdp);
        if (!needsToMigrate) {
            return false;
            return false;
        }
        }
        return MULTI_DB_GRID_MIRATION_ALGO.get()
        return GridSizeMigrationTaskV2.migrateGridIfNeeded(mContext, mIdp);
                ? GridSizeMigrationTaskV2.migrateGridIfNeeded(mContext, mIdp)
                : GridSizeMigrationTask.migrateGridIfNeeded(mContext, mIdp);
    }
    }


    @UiThread
    @UiThread
Loading