From 9e9ce925418a0075234b3cc34261c6be32095412 Mon Sep 17 00:00:00 2001 From: David Christie Date: Thu, 12 Sep 2013 13:04:32 -0700 Subject: Don't track LocationManager internal requests in AppOps (b/10725757). AppOps stats are used to populate the "apps recently using location" list in settings->location. There is no reason to show Android OS in that list simply because of internal location requests supporting other clients. Change-Id: I6908aa63deb19d22733b8d9cdae6ea5dbbea55e0 --- .../android/server/location/FlpHardwareProvider.java | 16 +++++++++++++--- .../android/server/location/GpsLocationProvider.java | 17 +++++++++++++++-- 2 files changed, 28 insertions(+), 5 deletions(-) (limited to 'services') diff --git a/services/java/com/android/server/location/FlpHardwareProvider.java b/services/java/com/android/server/location/FlpHardwareProvider.java index 60893b8..fab84a8 100644 --- a/services/java/com/android/server/location/FlpHardwareProvider.java +++ b/services/java/com/android/server/location/FlpHardwareProvider.java @@ -26,6 +26,7 @@ import android.location.FusedBatchOptions; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; +import android.location.LocationRequest; import android.content.Context; import android.os.Bundle; @@ -73,10 +74,19 @@ public class FlpHardwareProvider { // register for listening for passive provider data LocationManager manager = (LocationManager) mContext.getSystemService( Context.LOCATION_SERVICE); - manager.requestLocationUpdates( + final long minTime = 0; + final float minDistance = 0; + final boolean oneShot = false; + LocationRequest request = LocationRequest.createFromDeprecatedProvider( LocationManager.PASSIVE_PROVIDER, - 0 /* minTime */, - 0 /* minDistance */, + minTime, + minDistance, + oneShot); + // Don't keep track of this request since it's done on behalf of other clients + // (which are kept track of separately). + request.setHideFromAppOps(true); + manager.requestLocationUpdates( + request, new NetworkLocationListener(), Looper.myLooper()); } diff --git a/services/java/com/android/server/location/GpsLocationProvider.java b/services/java/com/android/server/location/GpsLocationProvider.java index 6053c61..9c76c19 100644 --- a/services/java/com/android/server/location/GpsLocationProvider.java +++ b/services/java/com/android/server/location/GpsLocationProvider.java @@ -512,8 +512,21 @@ public class GpsLocationProvider implements LocationProviderInterface { public void run() { LocationManager locManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE); - locManager.requestLocationUpdates(LocationManager.PASSIVE_PROVIDER, - 0, 0, new NetworkLocationListener(), mHandler.getLooper()); + final long minTime = 0; + final float minDistance = 0; + final boolean oneShot = false; + LocationRequest request = LocationRequest.createFromDeprecatedProvider( + LocationManager.PASSIVE_PROVIDER, + minTime, + minDistance, + oneShot); + // Don't keep track of this request since it's done on behalf of other clients + // (which are kept track of separately). + request.setHideFromAppOps(true); + locManager.requestLocationUpdates( + request, + new NetworkLocationListener(), + mHandler.getLooper()); } }); } -- cgit v1.1