Bug 1366644 - Part 2: Work around new deprecation warnings from Android SDK 25/26. r=maliu
authorNick Alexander <nalexander@mozilla.com>
Wed, 21 Jun 2017 10:11:03 -0700
changeset 386853 ea8854aacc680feb363e63451aca3bf661138698
parent 386852 ba0e40a0b33f21b78a17c46c5ce0d586c1a28ab6
child 386854 1c49a7a7cb5ecab97b2bd3a3384631e6718b748f
push id96311
push userarchaeopteryx@coole-files.de
push dateWed, 18 Oct 2017 09:52:02 +0000
treeherdermozilla-inbound@a8a1e8cc1980 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaliu
bugs1366644
milestone58.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 1366644 - Part 2: 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',