use of com.android.server.location.GpsLocationProvider in project android_frameworks_base by ParanoidAndroid.
the class LocationManagerService method loadProvidersLocked.
private void loadProvidersLocked() {
// create a passive location provider, which is always enabled
PassiveProvider passiveProvider = new PassiveProvider(this);
addProviderLocked(passiveProvider);
mEnabledProviders.add(passiveProvider.getName());
mPassiveProvider = passiveProvider;
// Create a gps location provider
GpsLocationProvider gpsProvider = new GpsLocationProvider(mContext, this, mLocationHandler.getLooper());
if (GpsLocationProvider.isSupported()) {
mGpsStatusProvider = gpsProvider.getGpsStatusProvider();
mNetInitiatedListener = gpsProvider.getNetInitiatedListener();
addProviderLocked(gpsProvider);
mRealProviders.put(LocationManager.GPS_PROVIDER, gpsProvider);
}
/*
Load package name(s) containing location provider support.
These packages can contain services implementing location providers:
Geocoder Provider, Network Location Provider, and
Fused Location Provider. They will each be searched for
service components implementing these providers.
The location framework also has support for installation
of new location providers at run-time. The new package does not
have to be explicitly listed here, however it must have a signature
that matches the signature of at least one package on this list.
*/
Resources resources = mContext.getResources();
ArrayList<String> providerPackageNames = new ArrayList<String>();
String[] pkgs = resources.getStringArray(com.android.internal.R.array.config_locationProviderPackageNames);
if (D)
Log.d(TAG, "certificates for location providers pulled from: " + Arrays.toString(pkgs));
if (pkgs != null)
providerPackageNames.addAll(Arrays.asList(pkgs));
ensureFallbackFusedProviderPresentLocked(providerPackageNames);
// bind to network provider
LocationProviderProxy networkProvider = LocationProviderProxy.createAndBind(mContext, LocationManager.NETWORK_PROVIDER, NETWORK_LOCATION_SERVICE_ACTION, com.android.internal.R.bool.config_enableNetworkLocationOverlay, com.android.internal.R.string.config_networkLocationProviderPackageName, com.android.internal.R.array.config_locationProviderPackageNames, mLocationHandler);
if (networkProvider != null) {
mRealProviders.put(LocationManager.NETWORK_PROVIDER, networkProvider);
mProxyProviders.add(networkProvider);
addProviderLocked(networkProvider);
} else {
Slog.w(TAG, "no network location provider found");
}
// bind to fused provider
LocationProviderProxy fusedLocationProvider = LocationProviderProxy.createAndBind(mContext, LocationManager.FUSED_PROVIDER, FUSED_LOCATION_SERVICE_ACTION, com.android.internal.R.bool.config_enableFusedLocationOverlay, com.android.internal.R.string.config_fusedLocationProviderPackageName, com.android.internal.R.array.config_locationProviderPackageNames, mLocationHandler);
if (fusedLocationProvider != null) {
addProviderLocked(fusedLocationProvider);
mProxyProviders.add(fusedLocationProvider);
mEnabledProviders.add(fusedLocationProvider.getName());
mRealProviders.put(LocationManager.FUSED_PROVIDER, fusedLocationProvider);
} else {
Slog.e(TAG, "no fused location provider found", new IllegalStateException("Location service needs a fused location provider"));
}
// bind to geocoder provider
mGeocodeProvider = GeocoderProxy.createAndBind(mContext, com.android.internal.R.bool.config_enableGeocoderOverlay, com.android.internal.R.string.config_geocoderProviderPackageName, com.android.internal.R.array.config_locationProviderPackageNames, mLocationHandler);
if (mGeocodeProvider == null) {
Slog.e(TAG, "no geocoder provider found");
}
// bind to geofence provider
GeofenceProxy provider = GeofenceProxy.createAndBind(mContext, com.android.internal.R.bool.config_enableGeofenceOverlay, com.android.internal.R.string.config_geofenceProviderPackageName, com.android.internal.R.array.config_locationProviderPackageNames, mLocationHandler, gpsProvider.getGpsGeofenceProxy());
if (provider == null) {
Slog.e(TAG, "no geofence provider found");
}
mGeoFencerPackageName = resources.getString(com.android.internal.R.string.config_geofenceProvider);
if (mGeoFencerPackageName != null && mPackageManager.resolveService(new Intent(mGeoFencerPackageName), 0) != null) {
mGeoFencer = GeoFencerProxy.getGeoFencerProxy(mContext, mGeoFencerPackageName);
mGeoFencerEnabled = true;
} else {
mGeoFencer = null;
mGeoFencerEnabled = false;
}
}
Aggregations