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;
}
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);
}
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();
}
}
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);
}
}
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();
}
Aggregations