Search in sources :

Example 1 with GeoFenceParams

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);
    }
}
Also used : LocationRequest(android.location.LocationRequest) GeoFenceParams(android.location.GeoFenceParams)

Example 2 with GeoFenceParams

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);
    }
}
Also used : GeoFenceParams(android.location.GeoFenceParams)

Aggregations

GeoFenceParams (android.location.GeoFenceParams)2 LocationRequest (android.location.LocationRequest)1