Bug 1534074 - Use in place api check to prevent Lint ApiDetector errors; r=AndreiLazar
authorPetru Lingurar <petru.lingurar@softvision.ro>
Mon, 11 Mar 2019 08:51:29 +0000
changeset 521326 cde32a9377303e91de8854649b704ae082c4cd5f
parent 521325 6e04cf2319d2c6513fc0d4e5df6cfd42e087d1fe
child 521327 3a421f33761b6b852b6b18ee61fb8dc33f8e0d7f
push id10866
push usernerli@mozilla.com
push dateTue, 12 Mar 2019 18:59:09 +0000
treeherdermozilla-beta@445c24a51727 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersAndreiLazar
bugs1534074
milestone67.0a1
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 1534074 - Use in place api check to prevent Lint ApiDetector errors; r=AndreiLazar Previous code was using our own sugary feature26Plus check which Lint doesn't properly follow. As such even if the code was properly guarded and behaved correctly Lint would show errors about improper usage of methods which require higher api levels. Doing the api check in place ensures it will get picked up by Lint's ApiDetector and so it will not report about such errors here. Differential Revision: https://phabricator.services.mozilla.com/D22889
mobile/android/base/java/org/mozilla/gecko/LauncherActivity.java
--- a/mobile/android/base/java/org/mozilla/gecko/LauncherActivity.java
+++ b/mobile/android/base/java/org/mozilla/gecko/LauncherActivity.java
@@ -7,16 +7,17 @@ package org.mozilla.gecko;
 
 import android.app.Activity;
 import android.app.PendingIntent;
 import android.appwidget.AppWidgetManager;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
 import android.net.Uri;
+import android.os.Build;
 import android.os.Bundle;
 import android.support.annotation.NonNull;
 import android.support.customtabs.CustomTabsIntent;
 import android.util.Log;
 
 import org.mozilla.gecko.home.HomeConfig;
 import org.mozilla.gecko.mma.MmaDelegate;
 import org.mozilla.gecko.search.SearchWidgetConfigurationActivity;
@@ -225,17 +226,17 @@ public class LauncherActivity extends Ac
                     // the user can actually set a default browser (Bug 1312686).
                     final Intent changeDefaultApps = new Intent("android.settings.MANAGE_DEFAULT_APPS_SETTINGS");
                     startActivity(changeDefaultApps);
                 } else {
                     dispatchUrlIntent(SUMO_DEFAULT_BROWSER);
                 }
                 break;
             case LINK_SEARCH_WIDGET:
-                if (AppConstants.Versions.feature26Plus) {
+                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                     AppWidgetManager appWidgetManager = getApplicationContext().getSystemService(AppWidgetManager.class);
                     ComponentName componentName = new ComponentName(this, SearchWidgetProvider.class);
 
                     if (appWidgetManager != null && appWidgetManager.isRequestPinAppWidgetSupported()) {
                         // Create the PendingIntent object only if your app needs to be notified
                         // that the user allowed the widget to be pinned. Note that, if the pinning
                         // operation fails, your app isn't notified.
                         Intent pinnedWidgetCallbackIntent = new Intent(getApplicationContext(), SearchWidgetConfigurationActivity.class);