Bug 1506649 - Part 2: Better API version linting. r=snorp

Because getOriginalFilePathFromUri() doesn't use framework methods newer than
Kitkat, instead of a generic @SuppressLint("NewAPI") it would be better to use
@TargetApi(19), so you still get warned if you start using framework methods
more recent than API19.

However because the isKitkat helper variable is only used in one place, in the
end we simply replace it with a direct Build.VERSION.SDK_INT check, so that we
don't have to use any special handling for the linter.

Differential Revision: https://phabricator.services.mozilla.com/D15258

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jan Henning 2018-12-26 20:19:22 +00:00
Родитель 13289db4f3
Коммит 04948eb567
1 изменённых файлов: 1 добавлений и 5 удалений

Просмотреть файл

@ -16,7 +16,6 @@
package org.mozilla.gecko.util;
import android.annotation.SuppressLint;
import android.content.ContentUris;
import android.content.Context;
import android.database.Cursor;
@ -46,12 +45,9 @@ public class ContentUriUtils {
* @param uri The Uri to query.
* @author paulburke
*/
@SuppressLint("NewAPI")
public static @Nullable String getOriginalFilePathFromUri(final Context context, final Uri uri) {
final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
// DocumentProvider
if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) {
if (Build.VERSION.SDK_INT >= 19 && DocumentsContract.isDocumentUri(context, uri)) {
// ExternalStorageProvider
if (isExternalStorageDocument(uri)) {
final String docId = DocumentsContract.getDocumentId(uri);