Bug 1352015 - Part 1: Work around new deprecation warnings from Android SDK 25/26. r=maliu draft
authorNick Alexander <nalexander@mozilla.com>
Wed, 21 Jun 2017 10:11:03 -0700
changeset 678603 a79ce6276f4a5a8278ff75847303adaf1963533b
parent 678602 9c2110acb75c643dc049c1c4a67a4125ce1725e9
child 678604 d019a936a03d1c706ca19f487ffd73f06decf804
push id83975
push usernalexander@mozilla.com
push dateWed, 11 Oct 2017 16:10:55 +0000
reviewersmaliu
bugs1352015
milestone58.0a1
Bug 1352015 - Part 1: Work around new deprecation warnings from Android SDK 25/26. r=maliu MozReview-Commit-ID: CDDGqQBQHDS
mobile/android/base/java/org/mozilla/gecko/updater/UpdateService.java
mobile/android/bouncer/java/org/mozilla/bouncer/BouncerService.java
mobile/android/search/java/org/mozilla/search/PostSearchFragment.java
mobile/android/stumbler/moz.build
mobile/android/tests/browser/junit3/moz.build
--- a/mobile/android/base/java/org/mozilla/gecko/updater/UpdateService.java
+++ b/mobile/android/base/java/org/mozilla/gecko/updater/UpdateService.java
@@ -142,18 +142,18 @@ public class UpdateService extends Inten
     @Override
     public void onCreate () {
         mCrashHandler = CrashHandler.createDefaultCrashHandler(getApplicationContext());
 
         super.onCreate();
 
         mPrefs = getSharedPreferences(PREFS_NAME, 0);
         mNotificationManager = NotificationManagerCompat.from(this);
-        mConnectivityManager = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
-        mWifiLock = ((WifiManager)getSystemService(Context.WIFI_SERVICE))
+        mConnectivityManager = (ConnectivityManager) getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
+        mWifiLock = ((WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE))
                     .createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, PREFS_NAME);
         mCancelDownload = false;
     }
 
     @Override
     public void onDestroy() {
         mCrashHandler.unregister();
         mCrashHandler = null;
--- a/mobile/android/bouncer/java/org/mozilla/bouncer/BouncerService.java
+++ b/mobile/android/bouncer/java/org/mozilla/bouncer/BouncerService.java
@@ -90,22 +90,18 @@ public class BouncerService extends Inte
                 getFiles(path + "/" + file, acc);
             }
         } else {
             // We're a file -- accumulate.
             acc.add(path);
         }
     }
 
-    private String getDataDir() {
-        return getApplicationInfo().dataDir;
-    }
-
     private File getDataFile(final String path) {
-        File outFile = new File(getDataDir(), path);
+        File outFile = new File(getApplicationInfo().dataDir, path);
         File dir = outFile.getParentFile();
 
         if (dir != null && !dir.exists()) {
             Log.d(LOGTAG, "Creating " + dir.getAbsolutePath());
             if (!dir.mkdirs()) {
                 Log.e(LOGTAG, "Unable to create directories: " + dir.getAbsolutePath());
                 return null;
             }
--- a/mobile/android/search/java/org/mozilla/search/PostSearchFragment.java
+++ b/mobile/android/search/java/org/mozilla/search/PostSearchFragment.java
@@ -105,16 +105,17 @@ public class PostSearchFragment extends 
         private boolean networkError;
 
         @Override
         public void onPageStarted(WebView view, final String url, Bitmap favicon) {
             // Reset the error state.
             networkError = false;
         }
 
+        @SuppressWarnings("deprecation")
         @Override
         public boolean shouldOverrideUrlLoading(WebView view, String url) {
             // Ignore about:blank URL loads and the first results page we try to load.
             if (TextUtils.equals(url, Constants.ABOUT_BLANK) || resultsPageHost == null) {
                 return false;
             }
 
             String host = null;
--- a/mobile/android/stumbler/moz.build
+++ b/mobile/android/stumbler/moz.build
@@ -7,9 +7,11 @@
 with Files('**'):
     BUG_COMPONENT = ('Android Background Services', 'Geolocation')
 
 include('stumbler_sources.mozbuild')
 
 stumbler_jar = add_java_jar('stumbler')
 stumbler_jar.sources += stumbler_sources
 stumbler_jar.extra_jars += [CONFIG['ANDROID_SUPPORT_V4_AAR_LIB']]
-stumbler_jar.javac_flags += ['-Xlint:all']
+# Android has deprecated most of the GPS interfaces stumbler uses, so
+# we need -deprecation.
+stumbler_jar.javac_flags += ['-Xlint:all,-deprecation']
--- a/mobile/android/tests/browser/junit3/moz.build
+++ b/mobile/android/tests/browser/junit3/moz.build
@@ -26,17 +26,20 @@ jar.sources += [
     'src/org/mozilla/tests/browser/junit3/TestGeckoProfilesProvider.java',
     'src/org/mozilla/tests/browser/junit3/TestGeckoSharedPrefs.java',
     'src/org/mozilla/tests/browser/junit3/TestImageDownloader.java',
     'src/org/mozilla/tests/browser/junit3/TestJarReader.java',
     'src/org/mozilla/tests/browser/junit3/TestRawResource.java',
     'src/org/mozilla/tests/browser/junit3/TestSuggestedSites.java',
 ]
 jar.generated_sources = [] # None yet -- try to keep it this way.
-jar.javac_flags += ['-Xlint:all']
+# MockResources has been deprecated, so we need -deprecation.  See
+# https://github.com/Countly/countly-sdk-android/blob/ae89490a5646e7db09c855f62b35c861819300cd/sdk/src/androidTest/java/ly/count/android/sdk/DeviceInfoTests.java#L80
+# for a Mockito-based approach.
+jar.javac_flags += ['-Xlint:all,-deprecation']
 
 jar.extra_jars += [
     CONFIG['ANDROID_SUPPORT_V4_AAR_LIB'],
     CONFIG['ANDROID_RECYCLERVIEW_V7_AAR_LIB'],
     TOPOBJDIR + '/mobile/android/base/constants.jar',
     TOPOBJDIR + '/mobile/android/base/gecko-R.jar',
     TOPOBJDIR + '/mobile/android/base/gecko-browser.jar',
     TOPOBJDIR + '/mobile/android/base/gecko-mozglue.jar',