use of com.android.server.location.LocationProviderInterface in project android_frameworks_base by crdroidandroid.
the class LocationManagerService method requestLocationUpdatesLocked.
private void requestLocationUpdatesLocked(LocationRequest request, Receiver receiver, int pid, int uid, String packageName) {
// use the fused provider
if (request == null)
request = DEFAULT_LOCATION_REQUEST;
String name = request.getProvider();
if (name == null) {
throw new IllegalArgumentException("provider name must not be null");
}
if (D)
Log.d(TAG, "request " + Integer.toHexString(System.identityHashCode(receiver)) + " " + name + " " + request + " from " + packageName + "(" + uid + ")");
LocationProviderInterface provider = mProvidersByName.get(name);
if (provider == null) {
throw new IllegalArgumentException("provider doesn't exist: " + name);
}
UpdateRecord record = new UpdateRecord(name, request, receiver);
UpdateRecord oldRecord = receiver.mUpdateRecords.put(name, record);
if (oldRecord != null) {
oldRecord.disposeLocked(false);
}
boolean isProviderEnabled = isAllowedByUserSettingsLocked(name, uid);
if (isProviderEnabled) {
applyRequirementsLocked(name);
} else {
// Notify the listener that updates are currently disabled
receiver.callProviderEnabledLocked(name, false);
}
// Update the monitoring here just in case multiple location requests were added to the
// same receiver (this request may be high power and the initial might not have been).
receiver.updateMonitoring(true);
}
use of com.android.server.location.LocationProviderInterface in project android_frameworks_base by AOSPA.
the class LocationManagerService method getProviderProperties.
/**
* @return null if the provider does not exist
* @throws SecurityException if the provider is not allowed to be
* accessed by the caller
*/
@Override
public ProviderProperties getProviderProperties(String provider) {
if (mProvidersByName.get(provider) == null) {
return null;
}
checkResolutionLevelIsSufficientForProviderUse(getCallerAllowedResolutionLevel(), provider);
LocationProviderInterface p;
synchronized (mLock) {
p = mProvidersByName.get(provider);
}
if (p == null)
return null;
return p.getProperties();
}
use of com.android.server.location.LocationProviderInterface in project android_frameworks_base by AOSPA.
the class LocationManagerService method getProviders.
/**
* Return all providers by name, that match criteria and are optionally
* enabled.
* Can return passive provider, but never returns fused provider.
*/
@Override
public List<String> getProviders(Criteria criteria, boolean enabledOnly) {
int allowedResolutionLevel = getCallerAllowedResolutionLevel();
ArrayList<String> out;
int uid = Binder.getCallingUid();
;
long identity = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
out = new ArrayList<String>(mProviders.size());
for (LocationProviderInterface provider : mProviders) {
String name = provider.getName();
if (LocationManager.FUSED_PROVIDER.equals(name)) {
continue;
}
if (allowedResolutionLevel >= getMinimumResolutionLevelForProviderUse(name)) {
if (enabledOnly && !isAllowedByUserSettingsLocked(name, uid)) {
continue;
}
if (criteria != null && !LocationProvider.propertiesMeetCriteria(name, provider.getProperties(), criteria)) {
continue;
}
out.add(name);
}
}
}
} finally {
Binder.restoreCallingIdentity(identity);
}
if (D)
Log.d(TAG, "getProviders()=" + out);
return out;
}
use of com.android.server.location.LocationProviderInterface in project android_frameworks_base by AOSPA.
the class LocationManagerService method providerMeetsCriteria.
@Override
public boolean providerMeetsCriteria(String provider, Criteria criteria) {
LocationProviderInterface p = mProvidersByName.get(provider);
if (p == null) {
throw new IllegalArgumentException("provider=" + provider);
}
boolean result = LocationProvider.propertiesMeetCriteria(p.getName(), p.getProperties(), criteria);
if (D)
Log.d(TAG, "providerMeetsCriteria(" + provider + ", " + criteria + ")=" + result);
return result;
}
use of com.android.server.location.LocationProviderInterface in project android_frameworks_base by AOSPA.
the class LocationManagerService method getLastLocation.
@Override
public Location getLastLocation(LocationRequest request, String packageName) {
if (D)
Log.d(TAG, "getLastLocation: " + request);
if (request == null)
request = DEFAULT_LOCATION_REQUEST;
int allowedResolutionLevel = getCallerAllowedResolutionLevel();
checkPackageName(packageName);
checkResolutionLevelIsSufficientForProviderUse(allowedResolutionLevel, request.getProvider());
// no need to sanitize this request, as only the provider name is used
final int pid = Binder.getCallingPid();
final int uid = Binder.getCallingUid();
final long identity = Binder.clearCallingIdentity();
try {
if (mBlacklist.isBlacklisted(packageName)) {
if (D)
Log.d(TAG, "not returning last loc for blacklisted app: " + packageName);
return null;
}
if (!reportLocationAccessNoThrow(pid, uid, packageName, allowedResolutionLevel)) {
if (D)
Log.d(TAG, "not returning last loc for no op app: " + packageName);
return null;
}
synchronized (mLock) {
// Figure out the provider. Either its explicitly request (deprecated API's),
// or use the fused provider
String name = request.getProvider();
if (name == null)
name = LocationManager.FUSED_PROVIDER;
LocationProviderInterface provider = mProvidersByName.get(name);
if (provider == null)
return null;
if (!isAllowedByUserSettingsLocked(name, uid))
return null;
Location location;
if (allowedResolutionLevel < RESOLUTION_LEVEL_FINE) {
// Make sure that an app with coarse permissions can't get frequent location
// updates by calling LocationManager.getLastKnownLocation repeatedly.
location = mLastLocationCoarseInterval.get(name);
} else {
location = mLastLocation.get(name);
}
if (location == null) {
return null;
}
if (allowedResolutionLevel < RESOLUTION_LEVEL_FINE) {
Location noGPSLocation = location.getExtraLocation(Location.EXTRA_NO_GPS_LOCATION);
if (noGPSLocation != null) {
return new Location(mLocationFudger.getOrCreate(noGPSLocation));
}
} else {
return new Location(location);
}
}
return null;
} finally {
Binder.restoreCallingIdentity(identity);
}
}
Aggregations