use of com.android.server.location.LocationProviderInterface in project android_frameworks_base by AOSPA.
the class LocationManagerService method getAllProviders.
/**
* Returns all providers by name, including passive, but excluding
* fused, also including ones that are not permitted to
* be accessed by the calling activity or are currently disabled.
*/
@Override
public List<String> getAllProviders() {
ArrayList<String> out;
synchronized (mLock) {
out = new ArrayList<String>(mProviders.size());
for (LocationProviderInterface provider : mProviders) {
String name = provider.getName();
if (LocationManager.FUSED_PROVIDER.equals(name)) {
continue;
}
out.add(name);
}
}
if (D)
Log.d(TAG, "getAllProviders()=" + out);
return out;
}
use of com.android.server.location.LocationProviderInterface in project android_frameworks_base by AOSPA.
the class LocationManagerService method shutdownComponents.
/**
* Provides a way for components held by the {@link LocationManagerService} to clean-up
* gracefully on system's shutdown.
*
* NOTES:
* 1) Only provides a chance to clean-up on an opt-in basis. This guarantees back-compat
* support for components that do not wish to handle such event.
*/
private void shutdownComponents() {
if (D)
Log.d(TAG, "Shutting down components...");
LocationProviderInterface gpsProvider = mProvidersByName.get(LocationManager.GPS_PROVIDER);
if (gpsProvider != null && gpsProvider.isEnabled()) {
gpsProvider.disable();
}
// avoids an exception to be thrown by the singleton factory method
if (FlpHardwareProvider.isSupported()) {
FlpHardwareProvider flpHardwareProvider = FlpHardwareProvider.getInstance(mContext);
flpHardwareProvider.cleanup();
}
}
use of com.android.server.location.LocationProviderInterface in project android_frameworks_base by AOSPA.
the class LocationManagerService method isProviderEnabled.
@Override
public boolean isProviderEnabled(String provider) {
// so we discourage its use
if (LocationManager.FUSED_PROVIDER.equals(provider))
return false;
int uid = Binder.getCallingUid();
long identity = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
LocationProviderInterface p = mProvidersByName.get(provider);
if (p == null)
return false;
return isAllowedByUserSettingsLocked(provider, uid);
}
} finally {
Binder.restoreCallingIdentity(identity);
}
}
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();
}
}
Aggregations