Loading robolectric_tests/src/com/android/launcher3/model/GridSizeMigrationTaskTest.java +10 −10 Original line number Diff line number Diff line Loading @@ -65,7 +65,7 @@ public class GridSizeMigrationTaskTest { }; mIdp.numHotseatIcons = 3; new GridSizeMigrationTask(mContext, mDb, mValidPackages, 5, 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]); Loading @@ -82,7 +82,7 @@ public class GridSizeMigrationTaskTest { }; mIdp.numHotseatIcons = 3; new GridSizeMigrationTask(mContext, mDb, mValidPackages, 5, 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]); Loading Loading @@ -127,7 +127,7 @@ public class GridSizeMigrationTaskTest { { 5, 2, -1, 6}, }}); new GridSizeMigrationTask(mContext, mDb, mValidPackages, new GridSizeMigrationTask(mContext, mDb, mValidPackages, false, new Point(4, 4), new Point(3, 3)).migrateWorkspace(); // Column 2 and row 2 got removed. Loading @@ -147,7 +147,7 @@ public class GridSizeMigrationTaskTest { { 5, 2, -1, 6}, }}); new GridSizeMigrationTask(mContext, mDb, mValidPackages, 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 Loading @@ -172,7 +172,7 @@ public class GridSizeMigrationTaskTest { { 3, 1, -1, 4}, }}); new GridSizeMigrationTask(mContext, mDb, mValidPackages, 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 Loading Loading @@ -204,7 +204,7 @@ public class GridSizeMigrationTaskTest { { 5, 2, -1, 6}, }}); new GridSizeMigrationTask(mContext, mDb, mValidPackages, 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. Loading Loading @@ -235,7 +235,7 @@ public class GridSizeMigrationTaskTest { { 5, 2, 7, -1}, }}, 0); new GridSizeMigrationTask(mContext, mDb, mValidPackages, 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. Loading @@ -262,7 +262,7 @@ public class GridSizeMigrationTaskTest { { 5, 6, 7, -1}, }}, 0); new GridSizeMigrationTask(mContext, mDb, mValidPackages, 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. Loading @@ -282,7 +282,7 @@ public class GridSizeMigrationTaskTest { * represent the workspace grid. */ private void verifyWorkspace(int[][][] ids) { IntArray allScreens = getWorkspaceScreenIds(mDb); IntArray allScreens = getWorkspaceScreenIds(mDb, LauncherSettings.Favorites.TABLE_NAME); assertEquals(ids.length, allScreens.size()); int total = 0; Loading Loading @@ -351,7 +351,7 @@ public class GridSizeMigrationTaskTest { private final LinkedList<Point> mPoints; public MultiStepMigrationTaskVerifier(int... points) { super(null, null, null); super(null, null, null, false); mPoints = new LinkedList<>(); for (int i = 0; i < points.length; i += 2) { Loading robolectric_tests/src/com/android/launcher3/model/LoaderCursorTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ import android.os.Process; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.ItemInfo; import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherSettings; import com.android.launcher3.WorkspaceItemInfo; import com.android.launcher3.util.Executors; import com.android.launcher3.util.LauncherRoboTestRunner; Loading Loading @@ -91,7 +92,7 @@ public class LoaderCursorTest { SCREEN, CELLX, CELLY, RESTORED, INTENT }); mLoaderCursor = new LoaderCursor(mCursor, mApp); mLoaderCursor = new LoaderCursor(mCursor, LauncherSettings.Favorites.CONTENT_URI, mApp); mLoaderCursor.allUsers.put(0, Process.myUserHandle()); } Loading src/com/android/launcher3/InvariantDeviceProfile.java +6 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import com.android.launcher3.graphics.IconShape; import com.android.launcher3.graphics.LauncherPreviewRenderer; import com.android.launcher3.util.ConfigMonitor; import com.android.launcher3.util.DefaultDisplay; import com.android.launcher3.util.DefaultDisplay.Info; Loading Loading @@ -156,6 +157,11 @@ public class InvariantDeviceProfile { @TargetApi(23) private InvariantDeviceProfile(Context context) { if (context instanceof LauncherPreviewRenderer.PreviewContext) { throw new IllegalArgumentException( "PreviewContext is passed into this IDP constructor"); } String gridName = Utilities.getPrefs(context).getBoolean(GRID_OPTIONS_PREFERENCE_KEY, false) ? Utilities.getPrefs(context).getString(KEY_IDP_GRID_NAME, null) : null; Loading src/com/android/launcher3/LauncherAppState.java +32 −18 Original line number Diff line number Diff line Loading @@ -27,6 +27,8 @@ import android.content.pm.LauncherApps; import android.os.Handler; import android.util.Log; import androidx.annotation.Nullable; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.icons.IconCache; import com.android.launcher3.icons.IconProvider; Loading Loading @@ -55,12 +57,12 @@ public class LauncherAppState { private final IconCache mIconCache; private final WidgetPreviewLoader mWidgetCache; private final InvariantDeviceProfile mInvariantDeviceProfile; private final SecureSettingsObserver mNotificationDotsObserver; private final InstallSessionTracker mInstallSessionTracker; private final SimpleBroadcastReceiver mModelChangeReceiver; private final SafeCloseable mCalendarChangeTracker; private final SafeCloseable mUserChangeListener; private SecureSettingsObserver mNotificationDotsObserver; private InstallSessionTracker mInstallSessionTracker; private SimpleBroadcastReceiver mModelChangeReceiver; private SafeCloseable mCalendarChangeTracker; private SafeCloseable mUserChangeListener; public static LauncherAppState getInstance(final Context context) { return INSTANCE.get(context); Loading @@ -74,15 +76,8 @@ public class LauncherAppState { return mContext; } private LauncherAppState(Context context) { Log.v(Launcher.TAG, "LauncherAppState initiated"); Preconditions.assertUIThread(); mContext = context; mInvariantDeviceProfile = InvariantDeviceProfile.INSTANCE.get(mContext); mIconCache = new IconCache(mContext, mInvariantDeviceProfile); mWidgetCache = new WidgetPreviewLoader(mContext, mIconCache); mModel = new LauncherModel(this, mIconCache, AppFilter.newInstance(mContext)); public LauncherAppState(Context context) { this(context, LauncherFiles.APP_ICONS_DB); mModelChangeReceiver = new SimpleBroadcastReceiver(mModel::onBroadcastIntent); Loading Loading @@ -123,6 +118,17 @@ public class LauncherAppState { } } public LauncherAppState(Context context, @Nullable String iconCacheFileName) { Log.v(Launcher.TAG, "LauncherAppState initiated"); Preconditions.assertUIThread(); mContext = context; mInvariantDeviceProfile = InvariantDeviceProfile.INSTANCE.get(context); mIconCache = new IconCache(mContext, mInvariantDeviceProfile, iconCacheFileName); mWidgetCache = new WidgetPreviewLoader(mContext, mIconCache); mModel = new LauncherModel(this, mIconCache, AppFilter.newInstance(mContext)); } protected void onNotificationSettingsChanged(boolean areNotificationDotsEnabled) { if (areNotificationDotsEnabled) { NotificationListener.requestRebind(new ComponentName( Loading @@ -148,11 +154,19 @@ public class LauncherAppState { * Call from Application.onTerminate(), which is not guaranteed to ever be called. */ public void onTerminate() { if (mModelChangeReceiver != null) { mContext.unregisterReceiver(mModelChangeReceiver); } mContext.getSystemService(LauncherApps.class).unregisterCallback(mModel); if (mInstallSessionTracker != null) { mInstallSessionTracker.unregister(); } if (mCalendarChangeTracker != null) { mCalendarChangeTracker.close(); } if (mUserChangeListener != null) { mUserChangeListener.close(); } CustomWidgetManager.INSTANCE.get(mContext).setWidgetRefreshCallback(null); if (mNotificationDotsObserver != null) { Loading src/com/android/launcher3/LauncherSettings.java +17 −6 Original line number Diff line number Diff line Loading @@ -93,15 +93,26 @@ public class LauncherSettings { public static final String TABLE_NAME = "favorites"; /** * Backup table created when when the favorites table is modified during grid migration * Backup table created when the favorites table is modified during grid migration */ public static final String BACKUP_TABLE_NAME = "favorites_bakup"; /** * The content:// style URL for this table * Temporary table used specifically for grid migrations during wallpaper preview */ public static final Uri CONTENT_URI = Uri.parse("content://" + LauncherProvider.AUTHORITY + "/" + TABLE_NAME); public static final String PREVIEW_TABLE_NAME = "favorites_preview"; /** * The content:// style URL for "favorites" table */ public static final Uri CONTENT_URI = Uri.parse("content://" + LauncherProvider.AUTHORITY + "/" + TABLE_NAME); /** * The content:// style URL for "favorites_preview" table */ public static final Uri PREVIEW_CONTENT_URI = Uri.parse("content://" + LauncherProvider.AUTHORITY + "/" + PREVIEW_TABLE_NAME); /** * The content:// style URL for a given row, identified by its id. Loading @@ -111,8 +122,8 @@ public class LauncherSettings { * @return The unique content URL for the specified row. */ public static Uri getContentUri(int id) { return Uri.parse("content://" + LauncherProvider.AUTHORITY + "/" + TABLE_NAME + "/" + id); return Uri.parse("content://" + LauncherProvider.AUTHORITY + "/" + TABLE_NAME + "/" + id); } /** Loading Loading
robolectric_tests/src/com/android/launcher3/model/GridSizeMigrationTaskTest.java +10 −10 Original line number Diff line number Diff line Loading @@ -65,7 +65,7 @@ public class GridSizeMigrationTaskTest { }; mIdp.numHotseatIcons = 3; new GridSizeMigrationTask(mContext, mDb, mValidPackages, 5, 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]); Loading @@ -82,7 +82,7 @@ public class GridSizeMigrationTaskTest { }; mIdp.numHotseatIcons = 3; new GridSizeMigrationTask(mContext, mDb, mValidPackages, 5, 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]); Loading Loading @@ -127,7 +127,7 @@ public class GridSizeMigrationTaskTest { { 5, 2, -1, 6}, }}); new GridSizeMigrationTask(mContext, mDb, mValidPackages, new GridSizeMigrationTask(mContext, mDb, mValidPackages, false, new Point(4, 4), new Point(3, 3)).migrateWorkspace(); // Column 2 and row 2 got removed. Loading @@ -147,7 +147,7 @@ public class GridSizeMigrationTaskTest { { 5, 2, -1, 6}, }}); new GridSizeMigrationTask(mContext, mDb, mValidPackages, 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 Loading @@ -172,7 +172,7 @@ public class GridSizeMigrationTaskTest { { 3, 1, -1, 4}, }}); new GridSizeMigrationTask(mContext, mDb, mValidPackages, 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 Loading Loading @@ -204,7 +204,7 @@ public class GridSizeMigrationTaskTest { { 5, 2, -1, 6}, }}); new GridSizeMigrationTask(mContext, mDb, mValidPackages, 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. Loading Loading @@ -235,7 +235,7 @@ public class GridSizeMigrationTaskTest { { 5, 2, 7, -1}, }}, 0); new GridSizeMigrationTask(mContext, mDb, mValidPackages, 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. Loading @@ -262,7 +262,7 @@ public class GridSizeMigrationTaskTest { { 5, 6, 7, -1}, }}, 0); new GridSizeMigrationTask(mContext, mDb, mValidPackages, 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. Loading @@ -282,7 +282,7 @@ public class GridSizeMigrationTaskTest { * represent the workspace grid. */ private void verifyWorkspace(int[][][] ids) { IntArray allScreens = getWorkspaceScreenIds(mDb); IntArray allScreens = getWorkspaceScreenIds(mDb, LauncherSettings.Favorites.TABLE_NAME); assertEquals(ids.length, allScreens.size()); int total = 0; Loading Loading @@ -351,7 +351,7 @@ public class GridSizeMigrationTaskTest { private final LinkedList<Point> mPoints; public MultiStepMigrationTaskVerifier(int... points) { super(null, null, null); super(null, null, null, false); mPoints = new LinkedList<>(); for (int i = 0; i < points.length; i += 2) { Loading
robolectric_tests/src/com/android/launcher3/model/LoaderCursorTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ import android.os.Process; import com.android.launcher3.InvariantDeviceProfile; import com.android.launcher3.ItemInfo; import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherSettings; import com.android.launcher3.WorkspaceItemInfo; import com.android.launcher3.util.Executors; import com.android.launcher3.util.LauncherRoboTestRunner; Loading Loading @@ -91,7 +92,7 @@ public class LoaderCursorTest { SCREEN, CELLX, CELLY, RESTORED, INTENT }); mLoaderCursor = new LoaderCursor(mCursor, mApp); mLoaderCursor = new LoaderCursor(mCursor, LauncherSettings.Favorites.CONTENT_URI, mApp); mLoaderCursor.allUsers.put(0, Process.myUserHandle()); } Loading
src/com/android/launcher3/InvariantDeviceProfile.java +6 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import com.android.launcher3.graphics.IconShape; import com.android.launcher3.graphics.LauncherPreviewRenderer; import com.android.launcher3.util.ConfigMonitor; import com.android.launcher3.util.DefaultDisplay; import com.android.launcher3.util.DefaultDisplay.Info; Loading Loading @@ -156,6 +157,11 @@ public class InvariantDeviceProfile { @TargetApi(23) private InvariantDeviceProfile(Context context) { if (context instanceof LauncherPreviewRenderer.PreviewContext) { throw new IllegalArgumentException( "PreviewContext is passed into this IDP constructor"); } String gridName = Utilities.getPrefs(context).getBoolean(GRID_OPTIONS_PREFERENCE_KEY, false) ? Utilities.getPrefs(context).getString(KEY_IDP_GRID_NAME, null) : null; Loading
src/com/android/launcher3/LauncherAppState.java +32 −18 Original line number Diff line number Diff line Loading @@ -27,6 +27,8 @@ import android.content.pm.LauncherApps; import android.os.Handler; import android.util.Log; import androidx.annotation.Nullable; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.icons.IconCache; import com.android.launcher3.icons.IconProvider; Loading Loading @@ -55,12 +57,12 @@ public class LauncherAppState { private final IconCache mIconCache; private final WidgetPreviewLoader mWidgetCache; private final InvariantDeviceProfile mInvariantDeviceProfile; private final SecureSettingsObserver mNotificationDotsObserver; private final InstallSessionTracker mInstallSessionTracker; private final SimpleBroadcastReceiver mModelChangeReceiver; private final SafeCloseable mCalendarChangeTracker; private final SafeCloseable mUserChangeListener; private SecureSettingsObserver mNotificationDotsObserver; private InstallSessionTracker mInstallSessionTracker; private SimpleBroadcastReceiver mModelChangeReceiver; private SafeCloseable mCalendarChangeTracker; private SafeCloseable mUserChangeListener; public static LauncherAppState getInstance(final Context context) { return INSTANCE.get(context); Loading @@ -74,15 +76,8 @@ public class LauncherAppState { return mContext; } private LauncherAppState(Context context) { Log.v(Launcher.TAG, "LauncherAppState initiated"); Preconditions.assertUIThread(); mContext = context; mInvariantDeviceProfile = InvariantDeviceProfile.INSTANCE.get(mContext); mIconCache = new IconCache(mContext, mInvariantDeviceProfile); mWidgetCache = new WidgetPreviewLoader(mContext, mIconCache); mModel = new LauncherModel(this, mIconCache, AppFilter.newInstance(mContext)); public LauncherAppState(Context context) { this(context, LauncherFiles.APP_ICONS_DB); mModelChangeReceiver = new SimpleBroadcastReceiver(mModel::onBroadcastIntent); Loading Loading @@ -123,6 +118,17 @@ public class LauncherAppState { } } public LauncherAppState(Context context, @Nullable String iconCacheFileName) { Log.v(Launcher.TAG, "LauncherAppState initiated"); Preconditions.assertUIThread(); mContext = context; mInvariantDeviceProfile = InvariantDeviceProfile.INSTANCE.get(context); mIconCache = new IconCache(mContext, mInvariantDeviceProfile, iconCacheFileName); mWidgetCache = new WidgetPreviewLoader(mContext, mIconCache); mModel = new LauncherModel(this, mIconCache, AppFilter.newInstance(mContext)); } protected void onNotificationSettingsChanged(boolean areNotificationDotsEnabled) { if (areNotificationDotsEnabled) { NotificationListener.requestRebind(new ComponentName( Loading @@ -148,11 +154,19 @@ public class LauncherAppState { * Call from Application.onTerminate(), which is not guaranteed to ever be called. */ public void onTerminate() { if (mModelChangeReceiver != null) { mContext.unregisterReceiver(mModelChangeReceiver); } mContext.getSystemService(LauncherApps.class).unregisterCallback(mModel); if (mInstallSessionTracker != null) { mInstallSessionTracker.unregister(); } if (mCalendarChangeTracker != null) { mCalendarChangeTracker.close(); } if (mUserChangeListener != null) { mUserChangeListener.close(); } CustomWidgetManager.INSTANCE.get(mContext).setWidgetRefreshCallback(null); if (mNotificationDotsObserver != null) { Loading
src/com/android/launcher3/LauncherSettings.java +17 −6 Original line number Diff line number Diff line Loading @@ -93,15 +93,26 @@ public class LauncherSettings { public static final String TABLE_NAME = "favorites"; /** * Backup table created when when the favorites table is modified during grid migration * Backup table created when the favorites table is modified during grid migration */ public static final String BACKUP_TABLE_NAME = "favorites_bakup"; /** * The content:// style URL for this table * Temporary table used specifically for grid migrations during wallpaper preview */ public static final Uri CONTENT_URI = Uri.parse("content://" + LauncherProvider.AUTHORITY + "/" + TABLE_NAME); public static final String PREVIEW_TABLE_NAME = "favorites_preview"; /** * The content:// style URL for "favorites" table */ public static final Uri CONTENT_URI = Uri.parse("content://" + LauncherProvider.AUTHORITY + "/" + TABLE_NAME); /** * The content:// style URL for "favorites_preview" table */ public static final Uri PREVIEW_CONTENT_URI = Uri.parse("content://" + LauncherProvider.AUTHORITY + "/" + PREVIEW_TABLE_NAME); /** * The content:// style URL for a given row, identified by its id. Loading @@ -111,8 +122,8 @@ public class LauncherSettings { * @return The unique content URL for the specified row. */ public static Uri getContentUri(int id) { return Uri.parse("content://" + LauncherProvider.AUTHORITY + "/" + TABLE_NAME + "/" + id); return Uri.parse("content://" + LauncherProvider.AUTHORITY + "/" + TABLE_NAME + "/" + id); } /** Loading