Merge "Revert "Change titile from Ringtone to Notification sound""
diff --git a/src/com/android/providers/media/MediaProvider.java b/src/com/android/providers/media/MediaProvider.java
old mode 100644
new mode 100755
index 5dc21de..fae3a13
--- a/src/com/android/providers/media/MediaProvider.java
+++ b/src/com/android/providers/media/MediaProvider.java
@@ -2762,14 +2762,8 @@
return cid;
}
- // Use "LIKE" instead of "=" on case insensitive file systems so we do a
- // case insensitive match when looking for parent directory.
- // TODO: investigate whether a "nocase" constraint on the column and
- // using "=" would give the same result faster.
- String selection = (mCaseInsensitivePaths ? MediaStore.MediaColumns.DATA + " LIKE ?1"
- // The like above makes it use the index.
- // The comparison below makes it correct when the path has wildcard chars
- + " AND lower(_data)=lower(?1)"
+ String selection = (mCaseInsensitivePaths ? MediaStore.MediaColumns.DATA
+ + " =?1 COLLATE nocase"
// search only directories.
+ " AND format=" + MtpConstants.FORMAT_ASSOCIATION
: MediaStore.MediaColumns.DATA + "=?");
@@ -3460,11 +3454,8 @@
ContentValues mediatype = new ContentValues();
mediatype.put("media_type", 0);
int numrows = db.update("files", mediatype,
- // the "like" test makes use of the index, while the lower() test ensures it
- // doesn't match entries it shouldn't when the path contains sqlite wildcards
- "_data LIKE ? AND lower(substr(_data,1,?))=lower(?)",
- new String[] { hiddenroot + "/%",
- "" + (hiddenroot.length() + 1), hiddenroot + "/"});
+ "_data >= ? COLLATE nocase AND _data < ? COLLATE nocase",
+ new String[] { hiddenroot + "/", hiddenroot + "0"});
helper.mNumUpdates += numrows;
ContentResolver res = getContext().getContentResolver();
res.notifyChange(Uri.parse("content://media/"), null);
@@ -3502,10 +3493,8 @@
@Override
public void onMediaScannerConnected() {
Cursor c = mDb.query("files", openFileColumns,
- // the "like" test makes use of the index, while the lower() ensures it
- // doesn't match entries it shouldn't when the path contains sqlite wildcards
- "_data like ? AND lower(substr(_data,1,?))=lower(?)",
- new String[] { mPath + "/%", "" + (mPath.length() + 1), mPath + "/"},
+ "_data >= ? COLLATE nocase AND _data < ? COLLATE nocase",
+ new String[] { mPath + "/", mPath + "0"},
null, null, null);
while (c.moveToNext()) {
String d = c.getString(0);
@@ -3989,7 +3978,7 @@
if (count > 0) {
// update the paths of any files and folders contained in the directory
Object[] bindArgs = new Object[] {newPath, oldPath.length() + 1,
- oldPath + "/%", (oldPath.length() + 1), oldPath + "/",
+ oldPath + "/", oldPath + "0",
// update bucket_display_name and bucket_id based on new path
f.getName(),
f.toString().toLowerCase().hashCode()
@@ -3999,10 +3988,7 @@
// also update bucket_display_name
",bucket_display_name=?6" +
",bucket_id=?7" +
- // the "like" test makes use of the index, while the lower()
- // test ensures it doesn't match entries it shouldn't when the
- // path contains sqlite wildcards
- " WHERE _data LIKE ?3 AND lower(substr(_data,1,?4))=lower(?5);",
+ " WHERE _data >= ?3 COLLATE nocase AND _data < ?4 COLLATE nocase;",
bindArgs);
}
@@ -4921,7 +4907,7 @@
if (EXTERNAL_DATABASE_NAME.equals(name)) {
return true;
}
- if (name.startsWith("external-")) {
+ if (name.startsWith("external-") && name.endsWith(".db")) {
return true;
}
return false;
@@ -5004,15 +4990,15 @@
// external database files
File recentDbFile = null;
for (String database : context.databaseList()) {
- if (database.startsWith("external-")) {
+ if (database.startsWith("external-") && database.endsWith(".db")) {
File file = context.getDatabasePath(database);
if (recentDbFile == null) {
recentDbFile = file;
} else if (file.lastModified() > recentDbFile.lastModified()) {
- recentDbFile.delete();
+ context.deleteDatabase(recentDbFile.getName());
recentDbFile = file;
} else {
- file.delete();
+ context.deleteDatabase(file.getName());
}
}
}