Merge branch 'heads/android-14.0.0_r18' into 14-dev
This commit is contained in:
1 parent
32700b0100
commit
cc8f9828ab
756 files changed
+23785
-12235
No files matched your search
@@ -66,8 +66,10 @@ 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";
|
||||
@@ -94,7 +96,8 @@ 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
|
||||
if (mMaxItemId == -1) {
|
||||
mMaxItemId = initializeMaxItemId(getWritableDatabase());
|
||||
@@ -103,7 +106,8 @@ public class DatabaseHelper extends NoLocaleSQLiteHelper implements
|
||||
|
||||
@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 = 1;
|
||||
|
||||
@@ -137,9 +141,11 @@ 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.
|
||||
*/
|
||||
@@ -265,7 +271,8 @@ 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);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -309,7 +316,8 @@ 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) {
|
||||
@@ -344,7 +352,7 @@ public class DatabaseHelper extends NoLocaleSQLiteHelper implements
|
||||
final String allWidgetsIds = Arrays.stream(allWidgets).mapToObj(String::valueOf)
|
||||
.collect(Collectors.joining(",", "[", "]"));
|
||||
final String validWidgetsIds = 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. db_path=" + db.getPath()
|
||||
@@ -357,21 +365,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);
|
||||
|
||||
@@ -409,14 +417,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();
|
||||
@@ -441,10 +449,14 @@ 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() {
|
||||
@@ -490,7 +502,8 @@ 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() {
|
||||
@@ -523,7 +536,8 @@ 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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user