Update bucket_display_list and bucket_id columns when renaming directories via MTP

Bug: 6949231

Change-Id: Ib301b250c40a6abc3cab17658e19308951b4cd4a
Signed-off-by: Mike Lockwood <lockwood@google.com>
diff --git a/src/com/android/providers/media/MediaProvider.java b/src/com/android/providers/media/MediaProvider.java
index 607dc8d..5e7762a 100644
--- a/src/com/android/providers/media/MediaProvider.java
+++ b/src/com/android/providers/media/MediaProvider.java
@@ -3983,11 +3983,18 @@
                         count = db.update(sGetTableAndWhereParam.table, initialValues,
                                 sGetTableAndWhereParam.where, whereArgs);
                         if (count > 0) {
-                            // then update the paths of any files and folders contained in the directory.
+                            // 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.length() + 1), oldPath + "/",
+                                    // update bucket_display_name and bucket_id based on new path
+                                    f.getName(),
+                                    f.toString().toLowerCase().hashCode()
+                                    };
                             helper.mNumUpdates++;
                             db.execSQL("UPDATE files SET _data=?1||SUBSTR(_data, ?2)" +
+                                    // 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