Bug 1241855 - Suppressg lint checks for location permissions. r=nalexander
authorMaurya Talisetti <maurya1985@yahoo.com>
Fri, 04 Mar 2016 05:48:00 -0500
changeset 287329 1c4c637484bae5c326f745875d00bffc88b461f7
parent 287328 e89ea2cf1c201d22c5bdeb135c63b96c1c688c36
child 287330 990089efe3f6495607dcd68b8f8b103d145e34a9
push id18080
push userryanvm@gmail.com
push dateWed, 09 Mar 2016 02:53:13 +0000
treeherderfx-team@990089efe3f6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs1241855
milestone48.0a1
Bug 1241855 - Suppressg lint checks for location permissions. r=nalexander
mobile/android/base/java/org/mozilla/gecko/GeckoAppShell.java
mobile/android/stumbler/java/org/mozilla/mozstumbler/service/stumblerthread/scanners/GPSScanner.java
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoAppShell.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoAppShell.java
@@ -28,16 +28,17 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.NoSuchElementException;
 import java.util.StringTokenizer;
 import java.util.TreeMap;
 import java.util.concurrent.ConcurrentHashMap;
 
+import android.annotation.SuppressLint;
 import android.content.ContentResolver;
 import org.mozilla.gecko.annotation.JNITarget;
 import org.mozilla.gecko.annotation.RobocopTarget;
 import org.mozilla.gecko.annotation.WrapForJNI;
 import org.mozilla.gecko.AppConstants.Versions;
 import org.mozilla.gecko.db.BrowserDB;
 import org.mozilla.gecko.db.LocalURLMetadata;
 import org.mozilla.gecko.db.URLMetadataTable;
@@ -471,16 +472,17 @@ public class GeckoAppShell
         ThreadUtils.getUiHandler().postDelayed(sCallbackRunnable, delay);
     }
 
     private static float getLocationAccuracy(Location location) {
         float radius = location.getAccuracy();
         return (location.hasAccuracy() && radius > 0) ? radius : 1001;
     }
 
+    @SuppressLint("MissingPermission") // Permissions are explicitly checked for in enableLocation()
     private static Location getLastKnownLocation(LocationManager lm) {
         Location lastKnownLocation = null;
         List<String> providers = lm.getAllProviders();
 
         for (String provider : providers) {
             Location location = lm.getLastKnownLocation(provider);
             if (location == null) {
                 continue;
@@ -498,16 +500,17 @@ public class GeckoAppShell
                 lastKnownLocation = location;
             }
         }
 
         return lastKnownLocation;
     }
 
     @WrapForJNI
+    @SuppressLint("MissingPermission") // Permissions are explicitly checked for within this method
     public static void enableLocation(final boolean enable) {
         Permissions
                 .from((Activity) getContext())
                 .withPermissions(Manifest.permission.ACCESS_FINE_LOCATION)
                 .onUIThread()
                 .doNotPromptIf(!enable)
                 .run(new Runnable() {
                     @Override
--- a/mobile/android/stumbler/java/org/mozilla/mozstumbler/service/stumblerthread/scanners/GPSScanner.java
+++ b/mobile/android/stumbler/java/org/mozilla/mozstumbler/service/stumblerthread/scanners/GPSScanner.java
@@ -1,14 +1,15 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.mozstumbler.service.stumblerthread.scanners;
 
+import android.annotation.SuppressLint;
 import android.content.Context;
 import android.content.Intent;
 import android.location.GpsSatellite;
 import android.location.GpsStatus;
 import android.location.Location;
 import android.location.LocationListener;
 import android.location.LocationManager;
 import android.location.LocationProvider;
@@ -71,31 +72,33 @@ public class GPSScanner implements Locat
             String msg = "No GPS available, scanning not started.";
             Log.d(LOG_TAG, msg);
             AppGlobals.guiLogError(msg);
             return false;
         }
         return true;
     }
 
+    @SuppressLint("MissingPermission") // Permissions are explicitly checked for in StumblerService.onHandleIntent()
     private void startPassiveMode() {
         LocationManager locationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
         if (!isGpsAvailable(locationManager)) {
             return;
         }
 
         locationManager.requestLocationUpdates(LocationManager.PASSIVE_PROVIDER, 0, 0, this);
 
         final int timeDiffSec = Long.valueOf((System.currentTimeMillis() - mTelemetry_lastStartedMs) / 1000).intValue();
         if (mTelemetry_lastStartedMs > 0 && timeDiffSec > 0) {
             TelemetryWrapper.addToHistogram(AppGlobals.TELEMETRY_TIME_BETWEEN_STARTS_SEC, timeDiffSec);
         }
         mTelemetry_lastStartedMs = System.currentTimeMillis();
     }
 
+    @SuppressLint("MissingPermission") // Permissions are explicitly checked for in StumblerService.onHandleIntent()
     private void startActiveMode() {
         LocationManager lm = getLocationManager();
         if (!isGpsAvailable(lm)) {
             return;
         }
 
         lm.requestLocationUpdates(LocationManager.GPS_PROVIDER,
                                   ACTIVE_MODE_GPS_MIN_UPDATE_TIME_MS,
@@ -131,16 +134,17 @@ public class GPSScanner implements Locat
                     reportLocationLost();
                 }
             }
         };
 
         lm.addGpsStatusListener(mGPSListener);
     }
 
+    @SuppressLint("MissingPermission") // Permissions are explicitly checked for in StumblerService.onHandleIntent()
     public void stop() {
         LocationManager lm = getLocationManager();
         lm.removeUpdates(this);
         reportLocationLost();
 
         if (mGPSListener != null) {
           lm.removeGpsStatusListener(mGPSListener);
           mGPSListener = null;