Search in sources :

Example 41 with LocationRequest

use of android.location.LocationRequest in project android_frameworks_base by crdroidandroid.

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();
    // TODO: http://b/23822629
    if (UserHandle.getUserId(uid) != UserHandle.USER_SYSTEM) {
        // 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 {
        mGeofenceManager.addFence(sanitizedRequest, geofence, intent, allowedResolutionLevel, uid, packageName);
    } finally {
        Binder.restoreCallingIdentity(identity);
    }
}
Also used : LocationRequest(android.location.LocationRequest)

Aggregations

LocationRequest (android.location.LocationRequest)41 WorkSource (android.os.WorkSource)17 PendingIntent (android.app.PendingIntent)6 BroadcastReceiver (android.content.BroadcastReceiver)6 Location (android.location.Location)6 ProviderRequest (com.android.internal.location.ProviderRequest)6 LocationProviderInterface (com.android.server.location.LocationProviderInterface)6 LinkedList (java.util.LinkedList)6 Intent (android.content.Intent)5 IntentFilter (android.content.IntentFilter)5 PowerManager (android.os.PowerManager)5 PowerManagerInternal (android.os.PowerManagerInternal)5 GeoFenceParams (android.location.GeoFenceParams)1