Merge changes from topic "apr17" into rvc-dev
* changes:
Consistent treatment of boolean-ish values.
Allow file movement via PermissionActivity.
diff --git a/res/values-gu/strings.xml b/res/values-gu/strings.xml
index 47be764..2d36456 100644
--- a/res/values-gu/strings.xml
+++ b/res/values-gu/strings.xml
@@ -23,7 +23,7 @@
<string name="unknown" msgid="2059049215682829375">"અજાણ"</string>
<string name="root_images" msgid="5861633549189045666">"છબીઓ"</string>
<string name="root_videos" msgid="8792703517064649453">"વિડિઓઝ"</string>
- <string name="root_audio" msgid="3505830755201326018">"ઑડિઓ"</string>
+ <string name="root_audio" msgid="3505830755201326018">"ઑડિયો"</string>
<string name="root_documents" msgid="3829103301363849237">"દસ્તાવેજો"</string>
<string name="permission_required" msgid="1460820436132943754">"આ આઇટમમાં ફેરફાર કરવા માટે અથવા તેને ડિલીટ કરવા માટે પરવાનગી હોવી જરૂરી છે."</string>
<string name="permission_required_action" msgid="706370952366113539">"આગળ વધો"</string>
diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml
index 09eac9f..80999fa 100644
--- a/res/values-pl/strings.xml
+++ b/res/values-pl/strings.xml
@@ -21,7 +21,7 @@
<string name="app_label" msgid="9035307001052716210">"Przechowywanie multimediów"</string>
<string name="artist_label" msgid="8105600993099120273">"Wykonawca"</string>
<string name="unknown" msgid="2059049215682829375">"Nieznany"</string>
- <string name="root_images" msgid="5861633549189045666">"Grafika"</string>
+ <string name="root_images" msgid="5861633549189045666">"Obrazy"</string>
<string name="root_videos" msgid="8792703517064649453">"Filmy"</string>
<string name="root_audio" msgid="3505830755201326018">"Dźwięk"</string>
<string name="root_documents" msgid="3829103301363849237">"Dokumenty"</string>
diff --git a/src/com/android/providers/media/MediaProvider.java b/src/com/android/providers/media/MediaProvider.java
index abd3bdf..89166b6 100644
--- a/src/com/android/providers/media/MediaProvider.java
+++ b/src/com/android/providers/media/MediaProvider.java
@@ -2745,12 +2745,13 @@
try {
return qb.insert(helper, values);
} catch (SQLiteConstraintException e) {
- final long rowId = getIdIfPathExistsForCallingPackage(qb, helper, path);
+ SQLiteQueryBuilder qbForUpsert = getQueryBuilderForUpsert(path);
+ final long rowId = getIdIfPathExistsForCallingPackage(qbForUpsert, helper, path);
// Apps sometimes create a file via direct path and then insert it into
// MediaStore via ContentResolver. The former should create a database entry,
// so we have to treat the latter as an upsert.
// TODO(b/149917493) Perform all INSERT operations as UPSERT.
- if (rowId != -1 && qb.update(helper, values, "_id=?",
+ if (rowId != -1 && qbForUpsert.update(helper, values, "_id=?",
new String[]{Long.toString(rowId)}) == 1) {
return rowId;
}
@@ -2781,6 +2782,28 @@
return -1;
}
+ /**
+ * @return {@link SQLiteQueryBuilder} for upsert with Files uri. This disables strict columns
+ * check to allow upsert to update any column with Files uri.
+ */
+ private SQLiteQueryBuilder getQueryBuilderForUpsert(@NonNull String path) {
+ final Uri uri = Files.getContentUriForPath(path);
+ final boolean allowHidden = isCallingPackageAllowedHidden();
+ // When Fuse inserts a file to database it doesn't set is_download column. When app tries
+ // insert with Downloads uri, upsert fails because getIdIfPathExistsForCallingPackage can't
+ // find a row ID with is_download=1. Use Files uri to query & update any existing row
+ // irrespective of is_download=1.
+ SQLiteQueryBuilder qb = getQueryBuilder(TYPE_UPDATE, matchUri(uri, allowHidden), uri,
+ Bundle.EMPTY, null);
+
+ // We won't be able to update columns that are not part of projection map of Files table. We
+ // have already checked strict columns in previous insert operation which failed with
+ // exception. Any malicious column usage would have got caught in insert operation, hence we
+ // can safely disable strict column check for upsert.
+ qb.setStrictColumns(false);
+ return qb;
+ }
+
private void maybePut(@NonNull ContentValues values, @NonNull String key,
@Nullable String value) {
if (value != null) {