Bug 1491094 - Don't require ACCESS_WIFI_STATE for GeckoView r=droeh a=me GECKOVIEW_62_RELBRANCH
authorJames Willcox <snorp@snorp.net>
Fri, 28 Sep 2018 18:34:57 +0000
branchGECKOVIEW_62_RELBRANCH
changeset 481189 97c33560b0e2
parent 481188 7f2d67c5d804
child 481198 582b268dcabc
push id1803
push userjwillcox@mozilla.com
push date2018-09-28 18:45 +0000
treeherdermozilla-release@97c33560b0e2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdroeh, me
bugs1491094
milestone62.0.3
Bug 1491094 - Don't require ACCESS_WIFI_STATE for GeckoView r=droeh a=me Fennec will continue to require this. While we're here, also make 'touchscreen' feature optional. Differential Revision: https://phabricator.services.mozilla.com/D7125
mobile/android/geckoview/src/main/AndroidManifest.xml
mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoNetworkManager.java
--- a/mobile/android/geckoview/src/main/AndroidManifest.xml
+++ b/mobile/android/geckoview/src/main/AndroidManifest.xml
@@ -1,51 +1,42 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
           package="org.mozilla.geckoview">
 
-    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
     <uses-permission android:name="android.permission.INTERNET"/>
     <uses-permission android:name="android.permission.WAKE_LOCK"/>
 
     <uses-feature
             android:name="android.hardware.location"
             android:required="false"/>
     <uses-feature
             android:name="android.hardware.location.gps"
             android:required="false"/>
-    <uses-feature android:name="android.hardware.touchscreen"/>
 
     <uses-feature
+            android:name="android.hardware.touchscreen"
+            android:required="false"/>
+    <uses-feature
             android:name="android.hardware.camera"
             android:required="false"/>
     <uses-feature
             android:name="android.hardware.camera.autofocus"
             android:required="false"/>
 
-    <!-- #ifdef MOZ_WEBRTC -->
-    <!--
-         TODO preprocess AndroidManifest.xml so that we can
-         conditionally include WebRTC permissions based on MOZ_WEBRTC.
-    -->
     <uses-feature
             android:name="android.hardware.audio.low_latency"
             android:required="false"/>
-    -->
     <uses-feature
             android:name="android.hardware.microphone"
             android:required="false"/>
-    -->
     <uses-feature
             android:name="android.hardware.camera.any"
             android:required="false"/>
-    -->
-    <!-- #endif -->
-
 
     <!-- GeckoView requires OpenGL ES 2.0 -->
     <uses-feature
             android:glEsVersion="0x00020000"
             android:required="true"/>
 
     <application>
 
@@ -79,9 +70,9 @@
         </service>
         <service
                 android:name="org.mozilla.gecko.CrashReporterService"
                 android:exported="false"
                 android:process=":crashreporter">
         </service>
     </application>
 
-</manifest>
\ No newline at end of file
+</manifest>
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoNetworkManager.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoNetworkManager.java
@@ -385,16 +385,20 @@ public class GeckoNetworkManager extends
 
     private static int wifiDhcpGatewayAddress(final Context context) {
         if (context == null) {
             return 0;
         }
 
         try {
             WifiManager mgr = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
+            if (mgr == null) {
+                return 0;
+            }
+
             DhcpInfo d = mgr.getDhcpInfo();
             if (d == null) {
                 return 0;
             }
 
             return d.gateway;
 
         } catch (Exception ex) {
@@ -411,16 +415,19 @@ public class GeckoNetworkManager extends
      */
     public void handleMessage(final String event, final GeckoBundle message,
                               final EventCallback callback) {
         final Context applicationContext = GeckoAppShell.getApplicationContext();
         switch (event) {
             case "Wifi:Enable":
                 final WifiManager mgr = (WifiManager)
                         applicationContext.getSystemService(Context.WIFI_SERVICE);
+                if (mgr == null) {
+                    return;
+                }
 
                 if (!mgr.isWifiEnabled()) {
                     mgr.setWifiEnabled(true);
                     break;
                 }
 
                 // If Wifi is enabled, maybe you need to select a network
                 Intent intent = new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS);