use of android.location.GeoFenceParams in project android_frameworks_base by ParanoidAndroid.
the class LocationManagerService method requestGeofence.
@Override
public void requestGeofence(LocationRequest request, Geofence geofence, PendingIntent intent, String packageName) {
if (request == null)
request = DEFAULT_LOCATION_REQUEST;
int allowedResolutionLevel = getCallerAllowedResolutionLevel();
checkResolutionLevelIsSufficientForGeofenceUse(allowedResolutionLevel);
checkPendingIntent(intent);
checkPackageName(packageName);
checkResolutionLevelIsSufficientForProviderUse(allowedResolutionLevel, request.getProvider());
LocationRequest sanitizedRequest = createSanitizedRequest(request, allowedResolutionLevel);
if (D)
Log.d(TAG, "requestGeofence: " + sanitizedRequest + " " + geofence + " " + intent);
// geo-fence manager uses the public location API, need to clear identity
int uid = Binder.getCallingUid();
if (UserHandle.getUserId(uid) != UserHandle.USER_OWNER) {
// temporary measure until geofences work for secondary users
Log.w(TAG, "proximity alerts are currently available only to the primary user");
return;
}
long identity = Binder.clearCallingIdentity();
try {
if (mGeoFencer != null && mGeoFencerEnabled) {
long expiration;
if (sanitizedRequest.getExpireAt() == Long.MAX_VALUE) {
// -1 means forever
expiration = -1;
} else {
expiration = sanitizedRequest.getExpireAt() - SystemClock.elapsedRealtime();
}
mGeoFencer.add(new GeoFenceParams(uid, geofence.getLatitude(), geofence.getLongitude(), geofence.getRadius(), expiration, intent, packageName));
} else {
mGeofenceManager.addFence(sanitizedRequest, geofence, intent, allowedResolutionLevel, uid, packageName);
}
} finally {
Binder.restoreCallingIdentity(identity);
}
}
use of android.location.GeoFenceParams in project android_frameworks_base by ParanoidAndroid.
the class GeoFencerBase method transferService.
public void transferService(GeoFencerBase geofencer) {
for (GeoFenceParams alert : geofencer.mGeoFences.values()) {
geofencer.stop(alert.mIntent);
add(alert);
}
}
Aggregations