summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/GridType.kt33
-rw-r--r--src/com/android/launcher3/InvariantDeviceProfile.java16
-rw-r--r--src/com/android/launcher3/LauncherPrefs.kt4
-rw-r--r--src/com/android/launcher3/logging/StatsLogManager.java6
-rw-r--r--src/com/android/launcher3/model/DeviceGridState.java20
-rw-r--r--src/com/android/launcher3/model/GridSizeMigrationDBController.java17
-rw-r--r--src/com/android/launcher3/model/GridSizeMigrationLogic.kt12
7 files changed, 100 insertions, 8 deletions
diff --git a/src/com/android/launcher3/GridType.kt b/src/com/android/launcher3/GridType.kt
new file mode 100644
index 0000000000..d006b8f35f
--- /dev/null
+++ b/src/com/android/launcher3/GridType.kt
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2025 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher3
+
+import androidx.annotation.IntDef
+
+/** The type of grid. */
+@IntDef(GridType.GRID_TYPE_ONE_GRID, GridType.GRID_TYPE_NON_ONE_GRID, GridType.GRID_TYPE_ANY)
+@Retention(AnnotationRetention.SOURCE)
+annotation class GridType {
+ companion object {
+ /** These are grids that use one grid spec. */
+ const val GRID_TYPE_ONE_GRID = 1
+ /** These are grids that don't use one grid spec. */
+ const val GRID_TYPE_NON_ONE_GRID = 2
+ /** Any grid type. */
+ const val GRID_TYPE_ANY = GRID_TYPE_NON_ONE_GRID or GRID_TYPE_ONE_GRID
+ }
+}
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index f189549463..15a4fc4072 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -16,6 +16,9 @@
package com.android.launcher3;
+import static com.android.launcher3.GridType.GRID_TYPE_ANY;
+import static com.android.launcher3.GridType.GRID_TYPE_NON_ONE_GRID;
+import static com.android.launcher3.GridType.GRID_TYPE_ONE_GRID;
import static com.android.launcher3.LauncherPrefs.DB_FILE;
import static com.android.launcher3.LauncherPrefs.ENABLE_TWOLINE_ALLAPPS_TOGGLE;
import static com.android.launcher3.LauncherPrefs.FIXED_LANDSCAPE_MODE;
@@ -241,6 +244,8 @@ public class InvariantDeviceProfile {
*/
public boolean isFixedLandscape = false;
+ @GridType
+ public int gridType;
public String dbFile;
public int defaultLayoutId;
public int demoModeLayoutId;
@@ -369,6 +374,7 @@ public class InvariantDeviceProfile {
numColumns = closestProfile.numColumns;
numSearchContainerColumns = closestProfile.numSearchContainerColumns;
dbFile = closestProfile.dbFile;
+ gridType = closestProfile.gridType;
defaultLayoutId = closestProfile.defaultLayoutId;
demoModeLayoutId = closestProfile.demoModeLayoutId;
@@ -936,10 +942,7 @@ public class InvariantDeviceProfile {
private static final int DEVICE_CATEGORY_PHONE = 1 << 0;
private static final int DEVICE_CATEGORY_TABLET = 1 << 1;
private static final int DEVICE_CATEGORY_MULTI_DISPLAY = 1 << 2;
- private static final int GRID_TYPE_ONE_GRID = 1 << 0;
- private static final int GRID_TYPE_NON_ONE_GRID = 1 << 1;
- private static final int GRID_TYPE_ALL = 1 << 2;
- private static final int DEVICE_CATEGORY_ALL =
+ private static final int DEVICE_CATEGORY_ANY =
DEVICE_CATEGORY_PHONE | DEVICE_CATEGORY_TABLET | DEVICE_CATEGORY_MULTI_DISPLAY;
private static final int INLINE_QSB_FOR_PORTRAIT = 1 << 0;
@@ -955,6 +958,7 @@ public class InvariantDeviceProfile {
public final int numColumns;
public final int numSearchContainerColumns;
public final int deviceCategory;
+ @GridType
public final int gridType;
private final int[] numFolderRows = new int[COUNT_SIZES];
@@ -1003,7 +1007,7 @@ public class InvariantDeviceProfile {
gridIconId = a.getResourceId(
R.styleable.GridDisplayOption_gridIconId, INVALID_RESOURCE_HANDLE);
deviceCategory = a.getInt(R.styleable.GridDisplayOption_deviceCategory,
- DEVICE_CATEGORY_ALL);
+ DEVICE_CATEGORY_ANY);
mGridSizeSpecsId = a.getResourceId(
R.styleable.GridDisplayOption_gridSizeSpecsId, INVALID_RESOURCE_HANDLE);
mIsDualGrid = a.getBoolean(R.styleable.GridDisplayOption_isDualGrid, false);
@@ -1141,7 +1145,7 @@ public class InvariantDeviceProfile {
}
mIsFixedLandscape = a.getBoolean(R.styleable.GridDisplayOption_isFixedLandscape, false);
- gridType = a.getInt(R.styleable.GridDisplayOption_gridType, GRID_TYPE_ALL);
+ gridType = a.getInt(R.styleable.GridDisplayOption_gridType, GRID_TYPE_ANY);
int inlineForRotation = a.getInt(R.styleable.GridDisplayOption_inlineQsb,
DONT_INLINE_QSB);
diff --git a/src/com/android/launcher3/LauncherPrefs.kt b/src/com/android/launcher3/LauncherPrefs.kt
index 7a04b0f950..30c4529613 100644
--- a/src/com/android/launcher3/LauncherPrefs.kt
+++ b/src/com/android/launcher3/LauncherPrefs.kt
@@ -20,6 +20,7 @@ import android.content.Context.MODE_PRIVATE
import android.content.SharedPreferences
import androidx.annotation.VisibleForTesting
import com.android.launcher3.BuildConfig.WIDGET_ON_FIRST_SCREEN
+import com.android.launcher3.GridType.Companion.GRID_TYPE_ANY
import com.android.launcher3.InvariantDeviceProfile.GRID_NAME_PREFS_KEY
import com.android.launcher3.InvariantDeviceProfile.NON_FIXED_LANDSCAPE_GRID_NAME_PREFS_KEY
import com.android.launcher3.LauncherFiles.DEVICE_PREFERENCES_KEY
@@ -266,6 +267,9 @@ constructor(@ApplicationContext private val encryptedContext: Context) {
@JvmField
val DB_FILE = backedUpItem(DeviceGridState.KEY_DB_FILE, "", EncryptionType.ENCRYPTED)
@JvmField
+ val GRID_TYPE =
+ backedUpItem(DeviceGridState.KEY_GRID_TYPE, GRID_TYPE_ANY, EncryptionType.ENCRYPTED)
+ @JvmField
val SHOULD_SHOW_SMARTSPACE =
backedUpItem(
SHOULD_SHOW_SMARTSPACE_KEY,
diff --git a/src/com/android/launcher3/logging/StatsLogManager.java b/src/com/android/launcher3/logging/StatsLogManager.java
index 44d2e266f7..40b597f838 100644
--- a/src/com/android/launcher3/logging/StatsLogManager.java
+++ b/src/com/android/launcher3/logging/StatsLogManager.java
@@ -890,6 +890,12 @@ public class StatsLogManager implements ResourceBasedOverride {
@UiEvent(doc = "Row shift grid migration occurred")
LAUNCHER_ROW_SHIFT_GRID_MIGRATION(2201),
+ @UiEvent(doc = "Do standard migration when upgrading to one grid")
+ LAUNCHER_STANDARD_ONE_GRID_MIGRATION(2205),
+
+ @UiEvent(doc = "Do row shift migration when upgrading to one grid")
+ LAUNCHER_ROW_SHIFT_ONE_GRID_MIGRATION(2206),
+
// ADD MORE
;
diff --git a/src/com/android/launcher3/model/DeviceGridState.java b/src/com/android/launcher3/model/DeviceGridState.java
index 96ce4c83db..32ea4b5fd7 100644
--- a/src/com/android/launcher3/model/DeviceGridState.java
+++ b/src/com/android/launcher3/model/DeviceGridState.java
@@ -19,6 +19,7 @@ package com.android.launcher3.model;
import static com.android.launcher3.InvariantDeviceProfile.DeviceType;
import static com.android.launcher3.LauncherPrefs.DB_FILE;
import static com.android.launcher3.LauncherPrefs.DEVICE_TYPE;
+import static com.android.launcher3.LauncherPrefs.GRID_TYPE;
import static com.android.launcher3.LauncherPrefs.HOTSEAT_COUNT;
import static com.android.launcher3.LauncherPrefs.WORKSPACE_SIZE;
@@ -41,17 +42,21 @@ public class DeviceGridState implements Comparable<DeviceGridState> {
public static final String KEY_HOTSEAT_COUNT = "migration_src_hotseat_count";
public static final String KEY_DEVICE_TYPE = "migration_src_device_type";
public static final String KEY_DB_FILE = "migration_src_db_file";
+ public static final String KEY_GRID_TYPE = "migration_src_grid_type";
private final String mGridSizeString;
private final int mNumHotseat;
private final @DeviceType int mDeviceType;
private final String mDbFile;
+ private final int mGridType;
- public DeviceGridState(int columns, int row, int numHotseat, int deviceType, String dbFile) {
+ public DeviceGridState(int columns, int row, int numHotseat, int deviceType, String dbFile,
+ int gridType) {
mGridSizeString = String.format(Locale.ENGLISH, "%d,%d", columns, row);
mNumHotseat = numHotseat;
mDeviceType = deviceType;
mDbFile = dbFile;
+ mGridType = gridType;
}
public DeviceGridState(InvariantDeviceProfile idp) {
@@ -59,6 +64,7 @@ public class DeviceGridState implements Comparable<DeviceGridState> {
mNumHotseat = idp.numDatabaseHotseatIcons;
mDeviceType = idp.deviceType;
mDbFile = idp.dbFile;
+ mGridType = idp.gridType;
}
public DeviceGridState(Context context) {
@@ -70,6 +76,7 @@ public class DeviceGridState implements Comparable<DeviceGridState> {
mNumHotseat = lp.get(HOTSEAT_COUNT);
mDeviceType = lp.get(DEVICE_TYPE);
mDbFile = lp.get(DB_FILE);
+ mGridType = lp.get(GRID_TYPE);
}
/**
@@ -94,6 +101,13 @@ public class DeviceGridState implements Comparable<DeviceGridState> {
}
/**
+ * Returns the grid type.
+ */
+ public int getGridType() {
+ return mGridType;
+ }
+
+ /**
* Stores the device state to shared preferences
*/
public void writeToPrefs(Context context) {
@@ -101,7 +115,9 @@ public class DeviceGridState implements Comparable<DeviceGridState> {
WORKSPACE_SIZE.to(mGridSizeString),
HOTSEAT_COUNT.to(mNumHotseat),
DEVICE_TYPE.to(mDeviceType),
- DB_FILE.to(mDbFile));
+ DB_FILE.to(mDbFile),
+ GRID_TYPE.to(mGridType));
+
}
/**
diff --git a/src/com/android/launcher3/model/GridSizeMigrationDBController.java b/src/com/android/launcher3/model/GridSizeMigrationDBController.java
index 3e4394373a..12ba07de4e 100644
--- a/src/com/android/launcher3/model/GridSizeMigrationDBController.java
+++ b/src/com/android/launcher3/model/GridSizeMigrationDBController.java
@@ -17,11 +17,16 @@
package com.android.launcher3.model;
import static com.android.launcher3.Flags.enableSmartspaceRemovalToggle;
+import static com.android.launcher3.GridType.GRID_TYPE_NON_ONE_GRID;
+import static com.android.launcher3.GridType.GRID_TYPE_ONE_GRID;
+import static com.android.launcher3.InvariantDeviceProfile.TYPE_TABLET;
import static com.android.launcher3.LauncherSettings.Favorites.TABLE_NAME;
import static com.android.launcher3.LauncherSettings.Favorites.TMP_TABLE;
import static com.android.launcher3.Utilities.SHOULD_SHOW_FIRST_PAGE_WIDGET;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ROW_SHIFT_GRID_MIGRATION;
+import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ROW_SHIFT_ONE_GRID_MIGRATION;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_STANDARD_GRID_MIGRATION;
+import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_STANDARD_ONE_GRID_MIGRATION;
import static com.android.launcher3.model.LoaderTask.SMARTSPACE_ON_HOME_SCREEN;
import static com.android.launcher3.provider.LauncherDbUtils.copyTable;
import static com.android.launcher3.provider.LauncherDbUtils.dropTable;
@@ -157,6 +162,9 @@ public class GridSizeMigrationDBController {
// Save current configuration, so that the migration does not run again.
destDeviceState.writeToPrefs(context);
t.commit();
+ if (isOneGridMigration(srcDeviceState, destDeviceState)) {
+ statsLogManager.logger().log(LAUNCHER_ROW_SHIFT_ONE_GRID_MIGRATION);
+ }
statsLogManager.logger().log(LAUNCHER_ROW_SHIFT_GRID_MIGRATION);
return true;
}
@@ -169,6 +177,9 @@ public class GridSizeMigrationDBController {
destDeviceState.getNumHotseat(), targetSize, srcDeviceState, destDeviceState);
dropTable(t.getDb(), TMP_TABLE);
t.commit();
+ if (isOneGridMigration(srcDeviceState, destDeviceState)) {
+ statsLogManager.logger().log(LAUNCHER_STANDARD_ONE_GRID_MIGRATION);
+ }
statsLogManager.logger().log(LAUNCHER_STANDARD_GRID_MIGRATION);
return true;
} catch (Exception e) {
@@ -291,6 +302,12 @@ public class GridSizeMigrationDBController {
return true;
}
+ protected static boolean isOneGridMigration(DeviceGridState srcDeviceState,
+ DeviceGridState destDeviceState) {
+ return srcDeviceState.getDeviceType() != TYPE_TABLET
+ && srcDeviceState.getGridType() == GRID_TYPE_NON_ONE_GRID
+ && destDeviceState.getGridType() == GRID_TYPE_ONE_GRID;
+ }
/**
* Calculate the differences between {@code src} (denoted by A) and {@code dest}
* (denoted by B).
diff --git a/src/com/android/launcher3/model/GridSizeMigrationLogic.kt b/src/com/android/launcher3/model/GridSizeMigrationLogic.kt
index 2957e3c608..d88f6ccfc6 100644
--- a/src/com/android/launcher3/model/GridSizeMigrationLogic.kt
+++ b/src/com/android/launcher3/model/GridSizeMigrationLogic.kt
@@ -32,8 +32,11 @@ import com.android.launcher3.config.FeatureFlags
import com.android.launcher3.logging.FileLog
import com.android.launcher3.logging.StatsLogManager
import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ROW_SHIFT_GRID_MIGRATION
+import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_ROW_SHIFT_ONE_GRID_MIGRATION
import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_STANDARD_GRID_MIGRATION
+import com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_STANDARD_ONE_GRID_MIGRATION
import com.android.launcher3.model.GridSizeMigrationDBController.DbReader
+import com.android.launcher3.model.GridSizeMigrationDBController.isOneGridMigration
import com.android.launcher3.provider.LauncherDbUtils.SQLiteTransaction
import com.android.launcher3.provider.LauncherDbUtils.copyTable
import com.android.launcher3.provider.LauncherDbUtils.dropTable
@@ -95,7 +98,12 @@ class GridSizeMigrationLogic {
// Save current configuration, so that the migration does not run again.
destDeviceState.writeToPrefs(context)
t.commit()
+
+ if (isOneGridMigration(srcDeviceState, destDeviceState)) {
+ statsLogManager.logger().log(LAUNCHER_ROW_SHIFT_ONE_GRID_MIGRATION)
+ }
statsLogManager.logger().log(LAUNCHER_ROW_SHIFT_GRID_MIGRATION)
+
return
}
@@ -125,6 +133,10 @@ class GridSizeMigrationLogic {
dropTable(t.db, TMP_TABLE)
t.commit()
+
+ if (isOneGridMigration(srcDeviceState, destDeviceState)) {
+ statsLogManager.logger().log(LAUNCHER_STANDARD_ONE_GRID_MIGRATION)
+ }
statsLogManager.logger().log(LAUNCHER_STANDARD_GRID_MIGRATION)
}
} catch (e: Exception) {