Merge "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." into klp-dev

This commit is contained in:
David Christie
2013-09-12 20:39:31 +00:00
committed by Android (Google) Code Review
2 changed files with 28 additions and 5 deletions

View File

@@ -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());
}

View File

@@ -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());
}
});
}