Merge "Include pending media as well when deleting mediastore entries." into rvc-dev

This commit is contained in:
Sudheer Shanka
2020-02-27 17:49:53 +00:00
committed by Android (Google) Code Review
3 changed files with 52 additions and 17 deletions

View File

@@ -3827,6 +3827,18 @@ public abstract class ContentResolver implements ContentInterface {
return queryArgs;
}
/** @hide */
public static @NonNull Bundle includeSqlSelectionArgs(@NonNull Bundle queryArgs,
@Nullable String selection, @Nullable String[] selectionArgs) {
if (selection != null) {
queryArgs.putString(QUERY_ARG_SQL_SELECTION, selection);
}
if (selectionArgs != null) {
queryArgs.putStringArray(QUERY_ARG_SQL_SELECTION_ARGS, selectionArgs);
}
return queryArgs;
}
/**
* Returns structured sort args formatted as an SQL sort clause.
*

View File

@@ -16,6 +16,7 @@
package android.database;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.ContentValues;
@@ -1548,4 +1549,24 @@ public class DatabaseUtils {
}
return -1;
}
/**
* Escape the given argument for use in a {@code LIKE} statement.
* @hide
*/
public static String escapeForLike(@NonNull String arg) {
// Shamelessly borrowed from com.android.providers.media.util.DatabaseUtils
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < arg.length(); i++) {
final char c = arg.charAt(i);
switch (c) {
case '%': sb.append('\\');
break;
case '_': sb.append('\\');
break;
}
sb.append(c);
}
return sb.toString();
}
}