Search in sources :

Example 26 with LocationProviderInterface

use of com.android.server.location.LocationProviderInterface in project android_frameworks_base by DirtyUnicorns.

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

Example 27 with LocationProviderInterface

use of com.android.server.location.LocationProviderInterface in project android_frameworks_base by AOSPA.

the class LocationManagerService method addTestProvider.

@Override
public void addTestProvider(String name, ProviderProperties properties, String opPackageName) {
    if (!canCallerAccessMockLocation(opPackageName)) {
        return;
    }
    if (LocationManager.PASSIVE_PROVIDER.equals(name)) {
        throw new IllegalArgumentException("Cannot mock the passive location provider");
    }
    long identity = Binder.clearCallingIdentity();
    synchronized (mLock) {
        // remove the real provider if we are replacing GPS or network provider
        if (LocationManager.GPS_PROVIDER.equals(name) || LocationManager.NETWORK_PROVIDER.equals(name) || LocationManager.FUSED_PROVIDER.equals(name)) {
            LocationProviderInterface p = mProvidersByName.get(name);
            if (p != null) {
                removeProviderLocked(p);
            }
        }
        addTestProviderLocked(name, properties);
        updateProvidersLocked();
    }
    Binder.restoreCallingIdentity(identity);
}
Also used : LocationProviderInterface(com.android.server.location.LocationProviderInterface)

Example 28 with LocationProviderInterface

use of com.android.server.location.LocationProviderInterface in project android_frameworks_base by AOSPA.

the class LocationManagerService method updateProviderListenersLocked.

private void updateProviderListenersLocked(String provider, boolean enabled) {
    int listeners = 0;
    LocationProviderInterface p = mProvidersByName.get(provider);
    if (p == null)
        return;
    ArrayList<Receiver> deadReceivers = null;
    ArrayList<UpdateRecord> records = mRecordsByProvider.get(provider);
    if (records != null) {
        final int N = records.size();
        for (int i = 0; i < N; i++) {
            UpdateRecord record = records.get(i);
            if (record != null && record.mReceiver != null && isCurrentProfile(UserHandle.getUserId(record.mReceiver.mUid))) {
                // Sends a notification message to the receiver
                if (!record.mReceiver.callProviderEnabledLocked(provider, enabled)) {
                    if (deadReceivers == null) {
                        deadReceivers = new ArrayList<Receiver>();
                    }
                    deadReceivers.add(record.mReceiver);
                }
                listeners++;
            }
        }
    }
    if (deadReceivers != null) {
        for (int i = deadReceivers.size() - 1; i >= 0; i--) {
            removeUpdatesLocked(deadReceivers.get(i));
        }
    }
    if (enabled) {
        p.enable();
        if (listeners > 0) {
            applyRequirementsLocked(provider);
        }
    } else {
        p.disable();
    }
}
Also used : BroadcastReceiver(android.content.BroadcastReceiver) LocationProviderInterface(com.android.server.location.LocationProviderInterface)

Example 29 with LocationProviderInterface

use of com.android.server.location.LocationProviderInterface in project android_frameworks_base by AOSPA.

the class LocationManagerService method updateProvidersLocked.

private void updateProvidersLocked() {
    boolean changesMade = false;
    for (int i = mProviders.size() - 1; i >= 0; i--) {
        LocationProviderInterface p = mProviders.get(i);
        boolean isEnabled = p.isEnabled();
        String name = p.getName();
        boolean shouldBeEnabled = isAllowedByCurrentUserSettingsLocked(name);
        if (isEnabled && !shouldBeEnabled) {
            updateProviderListenersLocked(name, false);
            // If any provider has been disabled, clear all last locations for all providers.
            // This is to be on the safe side in case a provider has location derived from
            // this disabled provider.
            mLastLocation.clear();
            mLastLocationCoarseInterval.clear();
            changesMade = true;
        } else if (!isEnabled && shouldBeEnabled) {
            updateProviderListenersLocked(name, true);
            changesMade = true;
        }
    }
    if (changesMade) {
        mContext.sendBroadcastAsUser(new Intent(LocationManager.PROVIDERS_CHANGED_ACTION), UserHandle.ALL);
        mContext.sendBroadcastAsUser(new Intent(LocationManager.MODE_CHANGED_ACTION), UserHandle.ALL);
    }
}
Also used : PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) LocationProviderInterface(com.android.server.location.LocationProviderInterface)

Example 30 with LocationProviderInterface

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

Aggregations

LocationProviderInterface (com.android.server.location.LocationProviderInterface)95 BroadcastReceiver (android.content.BroadcastReceiver)18 Location (android.location.Location)18 MockProvider (com.android.server.location.MockProvider)13 PendingIntent (android.app.PendingIntent)6 Intent (android.content.Intent)6 LocationRequest (android.location.LocationRequest)6 Bundle (android.os.Bundle)6 WorkSource (android.os.WorkSource)6 ProviderRequest (com.android.internal.location.ProviderRequest)6 LocationProviderProxy (com.android.server.location.LocationProviderProxy)6 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 FlpHardwareProvider (com.android.server.location.FlpHardwareProvider)5 PackageProviderKey (com.android.server.location.LocationRequestStatistics.PackageProviderKey)5 PackageStatistics (com.android.server.location.LocationRequestStatistics.PackageStatistics)5