Bug 1506649 - Part 2: Better API version linting. r=snorp
authorJan Henning <jh+bugzilla@buttercookie.de>
Wed, 26 Dec 2018 20:19:22 +0000
changeset 512170 fd078630d6661dfa3cc43dc793c45fda91e4b78c
parent 512169 242e66d8473405df9973d38ebed676b84edc9241
child 512171 5651b431fe2cecfc584357461be0822b84238952
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/ContentUriUtils.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/ContentUriUtils.java
@@ -11,17 +11,16 @@
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
 package org.mozilla.gecko.util;
-import android.annotation.SuppressLint;
 import android.content.ContentUris;
 import android.content.Context;
 import android.database.Cursor;
 import android.net.Uri;
 import android.os.Build;
 import android.os.Environment;
 import android.provider.DocumentsContract;
 import android.provider.MediaStore;
@@ -41,22 +40,19 @@ public class ContentUriUtils {
      * <br>
      * Callers should check whether the path is local before assuming it
      * represents a local file.
      * @param context The context.
      * @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);
                 final String[] split = docId.split(":");
                 final String type = split[0];
                 if ("primary".equalsIgnoreCase(type)) {
                     return Environment.getExternalStorageDirectory() + "/" + split[1];