fix: Conflict incoming changes from 15-dev

This commit is contained in:
Pun Butrach committed 2026-01-10 20:49:12 +07:00
1 parent 14e352c827
commit 2e76c99dad
1726 files changed
+146970 -95027

No files matched your search

@@ -16,7 +16,6 @@
package com.android.launcher3.model;
import static com.android.launcher3.LauncherSettings.Favorites.addTableToDb;
import static com.android.launcher3.Utilities.SHOULD_SHOW_FIRST_PAGE_WIDGET;
import static com.android.launcher3.provider.LauncherDbUtils.dropTable;
import android.content.ContentValues;
@@ -37,10 +36,11 @@ import androidx.annotation.NonNull;
import com.android.launcher3.AutoInstallsLayout;
import com.android.launcher3.AutoInstallsLayout.LayoutParserCallback;
import com.android.launcher3.BuildConfig;
import com.android.launcher3.BuildConfigs;
import com.android.launcher3.LauncherSettings;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.Utilities;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.logging.FileLog;
import com.android.launcher3.pm.UserCache;
import com.android.launcher3.provider.LauncherDbUtils;
@@ -68,10 +68,8 @@ public class DatabaseHelper extends NoLocaleSQLiteHelper implements
LayoutParserCallback {
/**
* Represents the schema of the database. Changes in scheme need not be
* backwards compatible.
* When increasing the scheme version, ensure that downgrade_schema.json is
* updated
* Represents the schema of the database. Changes in scheme need not be backwards compatible.
* When increasing the scheme version, ensure that downgrade_schema.json is updated
*/
public static final int SCHEMA_VERSION = 32;
private static final String TAG = "DatabaseHelper";
@@ -98,16 +96,14 @@ public class DatabaseHelper extends NoLocaleSQLiteHelper implements
}
protected void initIds() {
// In the case where neither onCreate nor onUpgrade gets called, we read the
// maxId from
// In the case where neither onCreate nor onUpgrade gets called, we read the maxId from
// the DB here
mMaxItemId.compareAndSet(-1, initializeMaxItemId(getWritableDatabase()));
}
@Override
public void onCreate(SQLiteDatabase db) {
if (LOGD)
Log.d(TAG, "creating new launcher database");
if (LOGD) Log.d(TAG, "creating new launcher database");
mMaxItemId.set(1);
@@ -141,11 +137,9 @@ public class DatabaseHelper extends NoLocaleSQLiteHelper implements
}
/**
* One-time data updated before support of onDowngrade was added. This update is
* backwards
* One-time data updated before support of onDowngrade was added. This update is backwards
* compatible and can safely be run multiple times.
* Note: No new logic should be added here after release, as the new logic might
* not get
* Note: No new logic should be added here after release, as the new logic might not get
* executed on an existing device.
* TODO: Move this to db upgrade path, once the downgrade path is released.
*/
@@ -263,7 +257,7 @@ public class DatabaseHelper extends NoLocaleSQLiteHelper implements
Favorites.SCREEN, IntArray.wrap(-777, -778)), null);
}
case 30: {
if (FeatureFlags.QSB_ON_FIRST_SCREEN) {
if (BuildConfigs.QSB_ON_FIRST_SCREEN) {
// Clean up first row in screen 0 as it might contain junk data.
Log.d(TAG, "Cleaning up first row");
db.delete(Favorites.TABLE_NAME,
@@ -271,8 +265,7 @@ public class DatabaseHelper extends NoLocaleSQLiteHelper implements
"%1$s = %2$d AND %3$s = %4$d AND %5$s = %6$d",
Favorites.SCREEN, 0,
Favorites.CONTAINER, Favorites.CONTAINER_DESKTOP,
Favorites.CELLY, 0),
null);
Favorites.CELLY, 0), null);
}
}
case 31: {
@@ -315,8 +308,7 @@ public class DatabaseHelper extends NoLocaleSQLiteHelper implements
}
/**
* Removes widgets which are registered to the Launcher's host, but are not
* present
* Removes widgets which are registered to the Launcher's host, but are not present
* in our model.
*/
public void removeGhostWidgets(SQLiteDatabase db) {
@@ -352,12 +344,13 @@ public class DatabaseHelper extends NoLocaleSQLiteHelper implements
.mapToObj(String::valueOf)
.collect(Collectors.joining(",", "[", "]"));
final String allValidLauncherDbWidgetIds = Arrays.stream(
validWidgets.getArray().toArray()).mapToObj(String::valueOf)
validWidgets.getArray().toArray()).mapToObj(String::valueOf)
.collect(Collectors.joining(",", "[", "]"));
FileLog.d(TAG,
"One or more widgets was removed: "
+ " allLauncherHostWidgetIds=" + allLauncherHostWidgetIds
+ ", allValidLauncherDbWidgetIds=" + allValidLauncherDbWidgetIds);
+ ", allValidLauncherDbWidgetIds=" + allValidLauncherDbWidgetIds
);
}
} finally {
holder.destroy();
@@ -365,21 +358,21 @@ public class DatabaseHelper extends NoLocaleSQLiteHelper implements
}
/**
* Replaces all shortcuts of type {@link Favorites#ITEM_TYPE_SHORTCUT} which
* have a valid
* Replaces all shortcuts of type {@link Favorites#ITEM_TYPE_SHORTCUT} which have a valid
* launcher activity target with {@link Favorites#ITEM_TYPE_APPLICATION}.
*/
@Thunk
void convertShortcutsToLauncherActivities(SQLiteDatabase db) {
try (SQLiteTransaction t = new SQLiteTransaction(db);
// Only consider the primary user as other users can't have a shortcut.
Cursor c = db.query(Favorites.TABLE_NAME,
new String[] { Favorites._ID, Favorites.INTENT },
"itemType=" + Favorites.ITEM_TYPE_SHORTCUT
+ " AND profileId=" + getDefaultUserSerial(),
null, null, null, null);
SQLiteStatement updateStmt = db.compileStatement("UPDATE favorites SET itemType="
+ Favorites.ITEM_TYPE_APPLICATION + " WHERE _id=?")) {
// Only consider the primary user as other users can't have a shortcut.
Cursor c = db.query(Favorites.TABLE_NAME,
new String[]{Favorites._ID, Favorites.INTENT},
"itemType=" + Favorites.ITEM_TYPE_SHORTCUT
+ " AND profileId=" + getDefaultUserSerial(),
null, null, null, null);
SQLiteStatement updateStmt = db.compileStatement("UPDATE favorites SET itemType="
+ Favorites.ITEM_TYPE_APPLICATION + " WHERE _id=?")
) {
final int idIndex = c.getColumnIndexOrThrow(Favorites._ID);
final int intentIndex = c.getColumnIndexOrThrow(Favorites.INTENT);
@@ -417,14 +410,14 @@ public class DatabaseHelper extends NoLocaleSQLiteHelper implements
// Get a map for folder ID to folder width
Cursor c = db.rawQuery("SELECT container, MAX(cellX) FROM favorites"
+ " WHERE container IN (SELECT _id FROM favorites WHERE itemType = ?)"
+ " GROUP BY container;",
new String[] { Integer.toString(Favorites.ITEM_TYPE_FOLDER) });
+ " WHERE container IN (SELECT _id FROM favorites WHERE itemType = ?)"
+ " GROUP BY container;",
new String[]{Integer.toString(Favorites.ITEM_TYPE_FOLDER)});
while (c.moveToNext()) {
db.execSQL("UPDATE favorites SET rank=cellX+(cellY*?) WHERE "
+ "container=? AND cellX IS NOT NULL AND cellY IS NOT NULL;",
new Object[] { c.getLong(1) + 1, c.getLong(0) });
+ "container=? AND cellX IS NOT NULL AND cellY IS NOT NULL;",
new Object[]{c.getLong(1) + 1, c.getLong(0)});
}
c.close();
@@ -449,14 +442,10 @@ public class DatabaseHelper extends NoLocaleSQLiteHelper implements
return true;
}
// Generates a new ID to use for an object in your database. This method should
// be only
// called from the main UI thread. As an exception, we do call it when we call
// the
// constructor from the worker thread; however, this doesn't extend until after
// the
// constructor is called, and we only pass a reference to LauncherProvider to
// LauncherApp
// Generates a new ID to use for an object in your database. This method should be only
// called from the main UI thread. As an exception, we do call it when we call the
// constructor from the worker thread; however, this doesn't extend until after the
// constructor is called, and we only pass a reference to LauncherProvider to LauncherApp
// after that point
@Override
public int generateNewItemId() {
@@ -501,8 +490,7 @@ public class DatabaseHelper extends NoLocaleSQLiteHelper implements
}
/**
* Returns a new ID to use for a workspace screen in your database that is
* greater than all
* Returns a new ID to use for a workspace screen in your database that is greater than all
* existing screen IDs
*/
public int getNewScreenId() {
@@ -535,8 +523,7 @@ public class DatabaseHelper extends NoLocaleSQLiteHelper implements
} catch (IllegalArgumentException exception) {
String message = exception.getMessage();
if (message.contains("re-open") && message.contains("already-closed")) {
// Don't crash trying to end a transaction an an already closed DB. See
// b/173162852.
// Don't crash trying to end a transaction an an already closed DB. See b/173162852.
} else {
throw exception;
}