Bug 1390203: Add NetworkUtils.isWifi. r=sebastian
authorMichael Comella <michael.l.comella@gmail.com>
Tue, 22 Aug 2017 17:27:19 -0700
changeset 376426 c3726830fb8d8b97bd926b206a00c7ac1f42882d
parent 376425 2df1315830002f0eb4e02f044c8f20517bdd8194
child 376427 30602859cba7e9fbb8f4b3b2ee0744c516532800
push id49465
push usermichael.l.comella@gmail.com
push dateWed, 23 Aug 2017 21:55:46 +0000
treeherderautoland@30602859cba7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1390203
milestone57.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 1390203: Add NetworkUtils.isWifi. r=sebastian It doesn't appear we simply check for a wifi connection type anywhere so the existing code shouldn't need to be updated. MozReview-Commit-ID: 7MqIbdB7uRI
mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/NetworkUtils.java
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/NetworkUtils.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/NetworkUtils.java
@@ -105,16 +105,21 @@ public class NetworkUtils {
                 return ConnectionSubType.WIMAX;
             case ConnectivityManager.TYPE_WIFI:
                 return ConnectionSubType.WIFI;
             default:
                 return ConnectionSubType.UNKNOWN;
         }
     }
 
+    public static boolean isWifi(@NonNull final Context context) {
+        final ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+        return getConnectionType(connectivityManager) == ConnectionType.WIFI;
+    }
+
     public static ConnectionType getConnectionType(ConnectivityManager connectivityManager) {
         if (connectivityManager == null) {
             return ConnectionType.NONE;
         }
 
         final NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
         if (networkInfo == null) {
             return ConnectionType.NONE;