From 899152ac438889a19bb37c32a4c6608de35ffc46 Mon Sep 17 00:00:00 2001 From: Marco Nelissen Date: Fri, 4 May 2018 11:11:50 -0700 Subject: Only rescan ringtones and such, not everything We really only localize ringtones, alarms and notifications, so there is no need to rescan everything, potentially losing manual edits the user did. Bug: 74821529 Bug: 74506985 Test: manual Change-Id: Ic3cb31b96d91319a77889755476e9b6fd21c2141 --- src/com/android/providers/media/MediaProvider.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/com/android/providers/media/MediaProvider.java b/src/com/android/providers/media/MediaProvider.java index 9d2e9961a..8f3b54b3b 100644 --- a/src/com/android/providers/media/MediaProvider.java +++ b/src/com/android/providers/media/MediaProvider.java @@ -915,7 +915,7 @@ public class MediaProvider extends ContentProvider { + " BEGIN SELECT _DELETE_FILE(old._data);END"); } - private static void updateFromKKSchema(SQLiteDatabase db, boolean internal, int fromVersion) { + private static void updateFromKKSchema(SQLiteDatabase db) { // Delete albums and artists, then clear the modification time on songs, which // will cause the media scanner to rescan everything, rebuilding the artist and // album tables along the way, while preserving playlists. @@ -924,7 +924,15 @@ public class MediaProvider extends ContentProvider { db.execSQL("DELETE from albums"); db.execSQL("DELETE from artists"); db.execSQL("ALTER TABLE files ADD COLUMN title_resource_uri TEXT DEFAULT NULL"); - db.execSQL("UPDATE files SET date_modified=0;"); + db.execSQL("UPDATE files SET date_modified=0"); + } + + private static void updateFromOCSchema(SQLiteDatabase db) { + // Add the column used for title localization, and force a rescan of any + // ringtones, alarms and notifications that may be using it. + db.execSQL("ALTER TABLE files ADD COLUMN title_resource_uri TEXT DEFAULT NULL"); + db.execSQL("UPDATE files SET date_modified=0" + + " WHERE (is_alarm IS 1) OR (is_ringtone IS 1) OR (is_notification IS 1)"); } /** @@ -953,8 +961,10 @@ public class MediaProvider extends ContentProvider { if (fromVersion < 700) { // Anything older than KK is recreated from scratch createLatestSchema(db, internal); + } else if (fromVersion < 800) { + updateFromKKSchema(db); } else if (fromVersion < 900) { - updateFromKKSchema(db, internal, fromVersion); + updateFromOCSchema(db); } sanityCheck(db, fromVersion); -- cgit v1.2.3