summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-06-20 14:09:26 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-06-20 14:09:26 +0000
commit598809fca6c789f61420648946e6934582469aff (patch)
tree0534c15ff09f8524624ed38d5656112e0ed733fe
parenta70f46713ae8c24fe92d696a04dc2753901c6d57 (diff)
parent94833d1e27fad8d86887f70eac7b706e80a69096 (diff)
downloadMediaProvider-android13-frc-extservices-release.tar.gz
Snap for 8745897 from 94833d1e27fad8d86887f70eac7b706e80a69096 to tm-frc-extservices-releaset_frc_ext_330443000android13-frc-extservices-release
Change-Id: I952f40e13d981fea9901c80f859b0154ab26daeb
-rw-r--r--src/com/android/providers/media/DatabaseHelper.java70
-rw-r--r--src/com/android/providers/media/MediaProvider.java9
2 files changed, 41 insertions, 38 deletions
diff --git a/src/com/android/providers/media/DatabaseHelper.java b/src/com/android/providers/media/DatabaseHelper.java
index a5c25110e..e4700b074 100644
--- a/src/com/android/providers/media/DatabaseHelper.java
+++ b/src/com/android/providers/media/DatabaseHelper.java
@@ -87,6 +87,7 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
+import java.util.Locale;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
@@ -499,30 +500,29 @@ public class DatabaseHelper extends SQLiteOpenHelper implements AutoCloseable {
@Override
public void onDowngrade(final SQLiteDatabase db, final int oldV, final int newV) {
- Log.w(TAG,
- String.format(
- "onDowngrade() for %s from %s to %s. Deleting database:%s in case of a "
- + "downgrade.",
- mName, oldV, newV, mName));
+ Log.w(TAG, String.format(Locale.ROOT,
+ "onDowngrade() for %s from %s to %s. Deleting database:%s in case of a "
+ + "downgrade.", mName, oldV, newV, mName));
deleteDatabaseFiles();
throw new IllegalStateException(
- String.format("Crashing MP process on database downgrade of %s.", mName));
+ String.format(Locale.ROOT, "Crashing MP process on database downgrade of %s.",
+ mName));
}
private void deleteDatabaseFiles() {
File dbDir = mContext.getDatabasePath(mName).getParentFile();
File[] files = dbDir.listFiles();
if (files == null) {
- Log.w(TAG,
- String.format("No database files found on path:%s.", dbDir.getAbsolutePath()));
+ Log.w(TAG, String.format(Locale.ROOT, "No database files found on path:%s.",
+ dbDir.getAbsolutePath()));
return;
}
for (File file : files) {
if (file.getName().startsWith(mName)) {
file.delete();
- Log.w(TAG,
- String.format("Database file:%s deleted.", file.getAbsolutePath()));
+ Log.w(TAG, String.format(Locale.ROOT, "Database file:%s deleted.",
+ file.getAbsolutePath()));
}
}
}
@@ -547,17 +547,17 @@ public class DatabaseHelper extends SQLiteOpenHelper implements AutoCloseable {
boolean isLastUsedDatabaseSession = isLastUsedDatabaseSession(db);
Optional<Long> nextRowIdFromXattrOptional = getNextRowIdFromXattr();
if (isLastUsedDatabaseSession && nextRowIdFromXattrOptional.isPresent()) {
- Log.i(TAG, String.format("No database change across sequential open calls for %s.",
- mName));
+ Log.i(TAG, String.format(Locale.ROOT,
+ "No database change across sequential open calls for %s.", mName));
mNextRowIdBackup.set(nextRowIdFromXattrOptional.get());
updateSessionIdInDatabaseAndExternalStorage(db);
return;
}
- Log.w(TAG, String.format(
+ Log.w(TAG, String.format(Locale.ROOT,
"%s database inconsistent: isLastUsedDatabaseSession:%b, "
- + "nextRowIdOptionalPresent:%b",
- mName, isLastUsedDatabaseSession, nextRowIdFromXattrOptional.isPresent()));
+ + "nextRowIdOptionalPresent:%b", mName, isLastUsedDatabaseSession,
+ nextRowIdFromXattrOptional.isPresent()));
// TODO(b/222313219): Add an assert to ensure that next row id xattr is always
// present when DB session id matches across sequential open calls.
updateNextRowIdInDatabaseAndExternalStorage(db);
@@ -585,8 +585,8 @@ public class DatabaseHelper extends SQLiteOpenHelper implements AutoCloseable {
boolean setOnExternalStorage = setXattr(DATA_MEDIA_XATTR_DIRECTORY_PATH,
getSessionIdXattrKeyForDatabase(), uuid);
if (setOnDatabase && setOnExternalStorage) {
- Log.i(TAG, String.format("SessionId set to %s on paths %s and %s.", uuid, db.getPath(),
- DATA_MEDIA_XATTR_DIRECTORY_PATH));
+ Log.i(TAG, String.format(Locale.ROOT, "SessionId set to %s on paths %s and %s.", uuid,
+ db.getPath(), DATA_MEDIA_XATTR_DIRECTORY_PATH));
}
}
@@ -1809,7 +1809,8 @@ public class DatabaseHelper extends SQLiteOpenHelper implements AutoCloseable {
}
private void updateUserId(SQLiteDatabase db) {
- db.execSQL(String.format("ALTER TABLE files ADD COLUMN _user_id INTEGER DEFAULT %d;",
+ db.execSQL(String.format(Locale.ROOT,
+ "ALTER TABLE files ADD COLUMN _user_id INTEGER DEFAULT %d;",
UserHandle.myUserId()));
}
@@ -2271,10 +2272,10 @@ public class DatabaseHelper extends SQLiteOpenHelper implements AutoCloseable {
backupNextRowId(nextRowId);
// Insert and delete a row to update sqlite_sequence counter
- db.execSQL(String.format("INSERT INTO files(_ID) VALUES (%d)", nextRowId));
- db.execSQL(String.format("DELETE FROM files WHERE _ID=%d", nextRowId));
- Log.i(TAG, String.format("Updated sqlite counter of Files table of %s to %d.", mName,
- nextRowId));
+ db.execSQL(String.format(Locale.ROOT, "INSERT INTO files(_ID) VALUES (%d)", nextRowId));
+ db.execSQL(String.format(Locale.ROOT, "DELETE FROM files WHERE _ID=%d", nextRowId));
+ Log.i(TAG, String.format(Locale.ROOT, "Updated sqlite counter of Files table of %s to %d.",
+ mName, nextRowId));
}
/**
@@ -2288,8 +2289,8 @@ public class DatabaseHelper extends SQLiteOpenHelper implements AutoCloseable {
String.valueOf(backupId));
if (setOnExternalStorage) {
mNextRowIdBackup.set(backupId);
- Log.i(TAG, String.format("Backed up next row id as:%d on path:%s for %s.", backupId,
- DATA_MEDIA_XATTR_DIRECTORY_PATH, mName));
+ Log.i(TAG, String.format(Locale.ROOT, "Backed up next row id as:%d on path:%s for %s.",
+ backupId, DATA_MEDIA_XATTR_DIRECTORY_PATH, mName));
}
}
@@ -2299,7 +2300,7 @@ public class DatabaseHelper extends SQLiteOpenHelper implements AutoCloseable {
Os.getxattr(DATA_MEDIA_XATTR_DIRECTORY_PATH,
getNextRowIdXattrKeyForDatabase()))));
} catch (Exception e) {
- Log.e(TAG, String.format("Xattr:%s not found on external storage.",
+ Log.e(TAG, String.format(Locale.ROOT, "Xattr:%s not found on external storage.",
getNextRowIdXattrKeyForDatabase()), e);
return Optional.empty();
}
@@ -2312,7 +2313,8 @@ public class DatabaseHelper extends SQLiteOpenHelper implements AutoCloseable {
return EXTERNAL_DB_NEXT_ROW_ID_XATTR_KEY;
}
throw new RuntimeException(
- String.format("Next row id xattr key not defined for database:%s.", mName));
+ String.format(Locale.ROOT, "Next row id xattr key not defined for database:%s.",
+ mName));
}
protected String getSessionIdXattrKeyForDatabase() {
@@ -2322,7 +2324,8 @@ public class DatabaseHelper extends SQLiteOpenHelper implements AutoCloseable {
return EXTERNAL_DB_SESSION_ID_XATTR_KEY;
}
throw new RuntimeException(
- String.format("Session id xattr key not defined for database:%s.", mName));
+ String.format(Locale.ROOT, "Session id xattr key not defined for database:%s.",
+ mName));
}
protected static boolean setXattr(String path, String key, String value) {
@@ -2334,9 +2337,8 @@ public class DatabaseHelper extends SQLiteOpenHelper implements AutoCloseable {
Log.d(TAG, String.format("xattr set to %s for key:%s on path: %s.", value, key, path));
return true;
} catch (Exception e) {
- Log.e(TAG,
- String.format("Failed to set xattr:%s to %s for path: %s.", key, value, path),
- e);
+ Log.e(TAG, String.format(Locale.ROOT, "Failed to set xattr:%s to %s for path: %s.", key,
+ value, path), e);
return false;
}
}
@@ -2345,9 +2347,8 @@ public class DatabaseHelper extends SQLiteOpenHelper implements AutoCloseable {
try {
return Optional.of(Arrays.toString(Os.getxattr(path, key)));
} catch (Exception e) {
- Log.w(TAG,
- String.format("Exception encountered while reading xattr:%s from path:%s.", key,
- path));
+ Log.w(TAG, String.format(Locale.ROOT,
+ "Exception encountered while reading xattr:%s from path:%s.", key, path));
return Optional.empty();
}
}
@@ -2380,7 +2381,8 @@ public class DatabaseHelper extends SQLiteOpenHelper implements AutoCloseable {
}
if (!(new File(DATA_MEDIA_XATTR_DIRECTORY_PATH)).exists()) {
- Log.w(TAG, String.format("Skipping row id recovery as path:%s does not exist.",
+ Log.w(TAG, String.format(Locale.ROOT,
+ "Skipping row id recovery as path:%s does not exist.",
DATA_MEDIA_XATTR_DIRECTORY_PATH));
return false;
}
diff --git a/src/com/android/providers/media/MediaProvider.java b/src/com/android/providers/media/MediaProvider.java
index 3305fa626..680cde0ec 100644
--- a/src/com/android/providers/media/MediaProvider.java
+++ b/src/com/android/providers/media/MediaProvider.java
@@ -848,15 +848,16 @@ public class MediaProvider extends ContentProvider {
Optional<Long> nextRowIdBackupOptional = helper.getNextRowId();
if (!nextRowIdBackupOptional.isPresent()) {
- throw new RuntimeException(String.format("Cannot find next row id xattr for %s.",
- helper.getDatabaseName()));
+ throw new RuntimeException(
+ String.format(Locale.ROOT, "Cannot find next row id xattr for %s.",
+ helper.getDatabaseName()));
}
if (id >= nextRowIdBackupOptional.get()) {
helper.backupNextRowId(id);
} else {
- Log.v(TAG, String.format("Inserted id:%d less than next row id backup:%d.", id,
- nextRowIdBackupOptional.get()));
+ Log.v(TAG, String.format(Locale.ROOT, "Inserted id:%d less than next row id backup:%d.",
+ id, nextRowIdBackupOptional.get()));
}
}