Bug 1510648 - Suppress MissingPermission warnings. r=geckoview-reviewers,snorp
authorEmily Toop <etoop@mozilla.com>
Wed, 19 Dec 2018 15:49:42 +0000
changeset 512244 589569dbbb63666dc7927757c5f99aaa8ee332d0
parent 512243 6f6ad88524bcf1bea0ede4e9f11da4533792fb97
child 512245 d02e6cc785a9b1c53f83b5c9370cc37885c9208b
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgeckoview-reviewers, snorp
bugs1510648
milestone66.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 1510648 - Suppress MissingPermission warnings. r=geckoview-reviewers,snorp This is because these persmissions are the responsibility of the embedding app to request,not GeckoView's. Differential Revision: https://phabricator.services.mozilla.com/D14722
mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoNetworkManager.java
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java
@@ -1103,27 +1103,29 @@ public class GeckoAppShell
             if (milliseconds.length == 1) {
                 vibrate(milliseconds[0]);
             } else {
                 vibrate(convertIntToLongArray(milliseconds), -1);
             }
         }
     }
 
+    @SuppressLint("MissingPermission")
     @WrapForJNI(calledFrom = "gecko")
     private static void vibrate(long milliseconds) {
         sVibrationEndTime = System.nanoTime() + milliseconds * 1000000;
         sVibrationMaybePlaying = true;
         try {
             vibrator().vibrate(milliseconds);
         } catch (final SecurityException ignore) {
             Log.w(LOGTAG, "No VIBRATE permission");
         }
     }
 
+    @SuppressLint("MissingPermission")
     @WrapForJNI(calledFrom = "gecko")
     private static void vibrate(long[] pattern, int repeat) {
         // If pattern.length is odd, the last element in the pattern is a
         // meaningless delay, so don't include it in vibrationDuration.
         long vibrationDuration = 0;
         int iterLen = pattern.length & ~1;
         for (int i = 0; i < iterLen; i++) {
           vibrationDuration += pattern[i];
@@ -1133,16 +1135,17 @@ public class GeckoAppShell
         sVibrationMaybePlaying = true;
         try {
             vibrator().vibrate(pattern, repeat);
         } catch (final SecurityException ignore) {
             Log.w(LOGTAG, "No VIBRATE permission");
         }
     }
 
+    @SuppressLint("MissingPermission")
     @WrapForJNI(calledFrom = "gecko")
     private static void cancelVibrate() {
         sVibrationMaybePlaying = false;
         sVibrationEndTime = 0;
         try {
             vibrator().cancel();
         } catch (final SecurityException ignore) {
             Log.w(LOGTAG, "No VIBRATE permission");
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoNetworkManager.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoNetworkManager.java
@@ -10,16 +10,17 @@ import org.mozilla.gecko.annotation.Wrap
 import org.mozilla.gecko.util.BundleEventListener;
 import org.mozilla.gecko.util.EventCallback;
 import org.mozilla.gecko.util.GeckoBundle;
 import org.mozilla.gecko.util.NetworkUtils;
 import org.mozilla.gecko.util.NetworkUtils.ConnectionSubType;
 import org.mozilla.gecko.util.NetworkUtils.ConnectionType;
 import org.mozilla.gecko.util.NetworkUtils.NetworkStatus;
 
+import android.annotation.SuppressLint;
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.net.ConnectivityManager;
 import android.net.DhcpInfo;
 import android.net.wifi.WifiInfo;
 import android.net.wifi.WifiManager;
@@ -389,31 +390,32 @@ public class GeckoNetworkManager extends
         }
 
         try {
             WifiManager mgr = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
             if (mgr == null) {
                 return 0;
             }
 
-            DhcpInfo d = mgr.getDhcpInfo();
+            @SuppressLint("MissingPermission") DhcpInfo d = mgr.getDhcpInfo();
             if (d == null) {
                 return 0;
             }
 
             return d.gateway;
 
         } catch (Exception ex) {
             // getDhcpInfo() is not documented to require any permissions, but on some devices
             // requires android.permission.ACCESS_WIFI_STATE. Just catch the generic exception
             // here and returning 0. Not logging because this could be noisy.
             return 0;
         }
     }
 
+    @SuppressLint("MissingPermission")
     @Override // BundleEventListener
     /**
      * Handles native messages, not part of the state machine flow.
      */
     public void handleMessage(final String event, final GeckoBundle message,
                               final EventCallback callback) {
         final Context applicationContext = GeckoAppShell.getApplicationContext();
         switch (event) {
@@ -445,17 +447,17 @@ public class GeckoNetworkManager extends
     private void getWifiIPAddress(final EventCallback callback) {
         final WifiManager mgr = (WifiManager) GeckoAppShell.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
 
         if (mgr == null) {
             callback.sendError("Cannot get WifiManager");
             return;
         }
 
-        final WifiInfo info = mgr.getConnectionInfo();
+        @SuppressLint("MissingPermission") final WifiInfo info = mgr.getConnectionInfo();
         if (info == null) {
             callback.sendError("Cannot get connection info");
             return;
         }
 
         int ip = info.getIpAddress();
         if (ip == 0) {
             callback.sendError("Cannot get IPv4 address");