Merge "Add logging for which type of migration occurs." into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
d3e559a244
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
;
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,6 +100,13 @@ public class DeviceGridState implements Comparable<DeviceGridState> {
|
||||
return mNumHotseat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the grid type.
|
||||
*/
|
||||
public int getGridType() {
|
||||
return mGridType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the device state to shared preferences
|
||||
*/
|
||||
@@ -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));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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).
|
||||
|
||||
@@ -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) {
|
||||
|
||||
+9
-1
@@ -27,6 +27,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.SmallTest
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import com.android.launcher3.Flags
|
||||
import com.android.launcher3.GridType.Companion.GRID_TYPE_ANY
|
||||
import com.android.launcher3.InvariantDeviceProfile
|
||||
import com.android.launcher3.LauncherSettings.Favorites
|
||||
import com.android.launcher3.celllayout.testgenerator.ValidGridMigrationTestCaseGenerator
|
||||
@@ -46,7 +47,14 @@ import org.junit.runner.RunWith
|
||||
|
||||
private data class Grid(val tableName: String, val size: Point, val items: List<WorkspaceItem>) {
|
||||
fun toGridState(): DeviceGridState =
|
||||
DeviceGridState(size.x, size.y, size.x, InvariantDeviceProfile.TYPE_PHONE, tableName)
|
||||
DeviceGridState(
|
||||
size.x,
|
||||
size.y,
|
||||
size.x,
|
||||
InvariantDeviceProfile.TYPE_PHONE,
|
||||
tableName,
|
||||
GRID_TYPE_ANY,
|
||||
)
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
|
||||
@@ -22,6 +22,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.SmallTest
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import com.android.launcher3.Flags
|
||||
import com.android.launcher3.GridType.Companion.GRID_TYPE_ANY
|
||||
import com.android.launcher3.InvariantDeviceProfile.TYPE_PHONE
|
||||
import com.android.launcher3.LauncherSettings.Favorites.TABLE_NAME
|
||||
import com.android.launcher3.celllayout.board.CellLayoutBoard
|
||||
@@ -192,15 +193,22 @@ class GridMigrationTest {
|
||||
@Test
|
||||
fun `5x5 to 3x3`() =
|
||||
runTest(
|
||||
src = GridMigrationData(DB_FILE, DeviceGridState(5, 5, 5, TYPE_PHONE, DB_FILE)),
|
||||
src =
|
||||
GridMigrationData(
|
||||
DB_FILE,
|
||||
DeviceGridState(5, 5, 5, TYPE_PHONE, DB_FILE, GRID_TYPE_ANY),
|
||||
),
|
||||
dst =
|
||||
GridMigrationData(
|
||||
null, // in memory db, to download a new db change null for
|
||||
// the filename of the db name to store it. Do not use existing names.
|
||||
DeviceGridState(3, 3, 3, TYPE_PHONE, ""),
|
||||
DeviceGridState(3, 3, 3, TYPE_PHONE, "", GRID_TYPE_ANY),
|
||||
),
|
||||
target =
|
||||
GridMigrationData("result5x5to3x3.db", DeviceGridState(3, 3, 3, TYPE_PHONE, "")),
|
||||
GridMigrationData(
|
||||
"result5x5to3x3.db",
|
||||
DeviceGridState(3, 3, 3, TYPE_PHONE, "", GRID_TYPE_ANY),
|
||||
),
|
||||
)
|
||||
|
||||
@JvmField
|
||||
@@ -215,15 +223,22 @@ class GridMigrationTest {
|
||||
@Test
|
||||
fun `5x5 to 4x7`() =
|
||||
runTest(
|
||||
src = GridMigrationData(DB_FILE, DeviceGridState(5, 5, 5, TYPE_PHONE, DB_FILE)),
|
||||
src =
|
||||
GridMigrationData(
|
||||
DB_FILE,
|
||||
DeviceGridState(5, 5, 5, TYPE_PHONE, DB_FILE, GRID_TYPE_ANY),
|
||||
),
|
||||
dst =
|
||||
GridMigrationData(
|
||||
null, // in memory db, to download a new db change null for
|
||||
// the filename of the db name to store it. Do not use existing names.
|
||||
DeviceGridState(4, 7, 4, TYPE_PHONE, ""),
|
||||
DeviceGridState(4, 7, 4, TYPE_PHONE, "", GRID_TYPE_ANY),
|
||||
),
|
||||
target =
|
||||
GridMigrationData("result5x5to4x7.db", DeviceGridState(4, 7, 4, TYPE_PHONE, "")),
|
||||
GridMigrationData(
|
||||
"result5x5to4x7.db",
|
||||
DeviceGridState(4, 7, 4, TYPE_PHONE, "", GRID_TYPE_ANY),
|
||||
),
|
||||
)
|
||||
|
||||
@JvmField
|
||||
@@ -238,16 +253,23 @@ class GridMigrationTest {
|
||||
@Test
|
||||
fun `5x5 to 5x8`() =
|
||||
runTest(
|
||||
src = GridMigrationData(DB_FILE, DeviceGridState(5, 5, 5, TYPE_PHONE, DB_FILE)),
|
||||
src =
|
||||
GridMigrationData(
|
||||
DB_FILE,
|
||||
DeviceGridState(5, 5, 5, TYPE_PHONE, DB_FILE, GRID_TYPE_ANY),
|
||||
),
|
||||
dst =
|
||||
GridMigrationData(
|
||||
null, // in memory db, to download a new db change null
|
||||
// for
|
||||
// the filename of the db name to store it. Do not use existing names.
|
||||
DeviceGridState(5, 8, 5, TYPE_PHONE, ""),
|
||||
DeviceGridState(5, 8, 5, TYPE_PHONE, "", GRID_TYPE_ANY),
|
||||
),
|
||||
target =
|
||||
GridMigrationData("result5x5to5x8.db", DeviceGridState(5, 8, 5, TYPE_PHONE, "")),
|
||||
GridMigrationData(
|
||||
"result5x5to5x8.db",
|
||||
DeviceGridState(5, 8, 5, TYPE_PHONE, "", GRID_TYPE_ANY),
|
||||
),
|
||||
)
|
||||
|
||||
companion object {
|
||||
|
||||
Reference in New Issue
Block a user