Loading core/res/res/values/config.xml +15 −53 Original line number Diff line number Diff line Loading @@ -1628,29 +1628,21 @@ config_timeZoneRulesUpdateTrackingEnabled are true.] --> <integer name="config_timeZoneRulesCheckRetryCount">5</integer> <!-- Whether to enable network location overlay which allows network location provider to be replaced by an app at run-time. When disabled, only the config_networkLocationProviderPackageName package will be searched for network location provider, otherwise packages whose signature matches the signatures of config_locationProviderPackageNames will be searched, and the service with the highest version number will be picked. Anyone who wants to disable the overlay mechanism can set it to false. --> <!-- Whether to enable network location overlay which allows network location provider to be replaced by an app at run-time. When disabled, only the config_networkLocationProviderPackageName package will be searched for network location provider, otherwise any system package is eligible. Anyone who wants to disable the overlay mechanism can set it to false. --> <bool name="config_enableNetworkLocationOverlay" translatable="false">true</bool> <!-- Package name providing network location support. Used only when config_enableNetworkLocationOverlay is false. --> <string name="config_networkLocationProviderPackageName" translatable="false">@null</string> <!-- Whether to enable fused location provider overlay which allows fused location provider to be replaced by an app at run-time. When disabled, only the config_fusedLocationProviderPackageName package will be searched for fused location provider, otherwise packages whose signature matches the signatures of config_locationProviderPackageNames will be searched, and the service with the highest version number will be picked. Anyone who wants to disable the overlay mechanism can set it to false. --> <!-- Whether to enable fused location provider overlay which allows fused location provider to be replaced by an app at run-time. When disabled, only the config_fusedLocationProviderPackageName package will be searched for fused location provider, otherwise any system package is eligible. Anyone who wants to disable the overlay mechanism can set it to false. --> <bool name="config_enableFusedLocationOverlay" translatable="false">true</bool> <!-- Package name providing fused location support. Used only when config_enableFusedLocationOverlay is false. --> Loading @@ -1669,25 +1661,10 @@ --> <string name="config_defaultNetworkRecommendationProviderPackage" translatable="false"></string> <!-- Whether to enable Hardware FLP overlay which allows Hardware FLP to be replaced by an app at run-time. When disabled, only the config_hardwareFlpPackageName package will be searched for Hardware Flp, otherwise packages whose signature matches the signatures of config_locationProviderPackageNames will be searched, and the service with the highest version number will be picked. Anyone who wants to disable the overlay mechanism can set it to false. --> <bool name="config_enableHardwareFlpOverlay" translatable="false">true</bool> <!-- Package name providing Hardware Flp. Used only when config_enableHardwareFlpOverlay is false. --> <string name="config_hardwareFlpPackageName" translatable="false">com.android.location.fused</string> <!-- Whether to enable geocoder overlay which allows geocoder to be replaced by an app at run-time. When disabled, only the config_geocoderProviderPackageName package will be searched for geocoder, otherwise packages whose signature matches the signatures of config_locationProviderPackageNames will be searched, and the service with the highest version number will be picked. Anyone who wants to geocoder, otherwise any system package is eligible. Anyone who wants to disable the overlay mechanism can set it to false. --> <bool name="config_enableGeocoderOverlay" translatable="false">true</bool> Loading @@ -1698,9 +1675,7 @@ <!-- Whether to enable geofence overlay which allows geofence to be replaced by an app at run-time. When disabled, only the config_geofenceProviderPackageName package will be searched for geofence implementation, otherwise packages whose signature matches the signatures of config_locationProviderPackageNames will be searched, and the service with the highest version number will be picked. Anyone who geofence implementation, otherwise any system package is eligible. Anyone who wants to disable the overlay mechanism can set it to false. --> <bool name="config_enableGeofenceOverlay" translatable="false">true</bool> Loading @@ -1711,9 +1686,7 @@ <!-- Whether to enable Hardware Activity-Recognition overlay which allows Hardware Activity-Recognition to be replaced by an app at run-time. When disabled, only the config_activityRecognitionHardwarePackageName package will be searched for its implementation, otherwise packages whose signature matches the signatures of config_locationProviderPackageNames will be searched, and the service with the highest version number will be picked. Anyone who its implementation, otherwise any system package is eligible. Anyone who wants to disable the overlay mechanism can set it to false. --> <bool name="config_enableActivityRecognitionHardwareOverlay" translatable="false">true</bool> Loading @@ -1721,19 +1694,8 @@ config_enableActivityRecognitionHardwareOverlay is false. --> <string name="config_activityRecognitionHardwarePackageName" translatable="false">@null</string> <!-- Package name(s) containing location provider support. These packages can contain services implementing location providers, such as the Geocode Provider, Network Location Provider, and Fused Location Provider. They will each be searched for service components implementing these providers. It is strongly recommended that the packages explicitly named below are on the system image, so that they will not map to a 3rd party application. 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. --> <!-- Package name(s) containing location provider support. These packages will be auto-granted several permissions by the system, and should be system packages. --> <string-array name="config_locationProviderPackageNames" translatable="false"> <!-- The standard AOSP fused location provider --> <item>com.android.location.fused</item> Loading core/res/res/values/symbols.xml +0 −2 Original line number Diff line number Diff line Loading @@ -1869,7 +1869,6 @@ <java-symbol type="bool" name="config_dozeAfterScreenOffByDefault" /> <java-symbol type="bool" name="config_enableActivityRecognitionHardwareOverlay" /> <java-symbol type="bool" name="config_enableFusedLocationOverlay" /> <java-symbol type="bool" name="config_enableHardwareFlpOverlay" /> <java-symbol type="bool" name="config_enableGeocoderOverlay" /> <java-symbol type="bool" name="config_enableGeofenceOverlay" /> <java-symbol type="bool" name="config_enableNetworkLocationOverlay" /> Loading Loading @@ -2019,7 +2018,6 @@ <java-symbol type="string" name="config_datause_iface" /> <java-symbol type="string" name="config_activityRecognitionHardwarePackageName" /> <java-symbol type="string" name="config_fusedLocationProviderPackageName" /> <java-symbol type="string" name="config_hardwareFlpPackageName" /> <java-symbol type="string" name="config_geocoderProviderPackageName" /> <java-symbol type="string" name="config_geofenceProviderPackageName" /> <java-symbol type="string" name="config_networkLocationProviderPackageName" /> Loading services/core/java/com/android/server/LocationManagerService.java +27 −137 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ package com.android.server; import static android.Manifest.permission.ACCESS_COARSE_LOCATION; import static android.Manifest.permission.ACCESS_FINE_LOCATION; import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_AWARE; import static android.content.pm.PackageManager.MATCH_SYSTEM_ONLY; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static android.location.LocationManager.FUSED_PROVIDER; import static android.location.LocationManager.GPS_PROVIDER; Loading @@ -35,14 +37,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ResolveInfo; import android.content.pm.Signature; import android.content.res.Resources; import android.hardware.location.ActivityRecognitionHardware; import android.location.Address; import android.location.Criteria; import android.location.GeocoderParams; Loading @@ -52,6 +47,7 @@ import android.location.IBatchedLocationCallback; import android.location.IGnssMeasurementsListener; import android.location.IGnssNavigationMessageListener; import android.location.IGnssStatusListener; import android.location.IGpsGeofenceHardware; import android.location.ILocationListener; import android.location.ILocationManager; import android.location.Location; Loading Loading @@ -91,11 +87,11 @@ import com.android.internal.util.IndentingPrintWriter; import com.android.internal.util.Preconditions; import com.android.server.location.AbstractLocationProvider; import com.android.server.location.AbstractLocationProvider.State; import com.android.server.location.ActivityRecognitionProxy; import com.android.server.location.CallerIdentity; import com.android.server.location.GeocoderProxy; import com.android.server.location.GeofenceManager; import com.android.server.location.GeofenceProxy; import com.android.server.location.HardwareActivityRecognitionProxy; import com.android.server.location.LocationFudger; import com.android.server.location.LocationProviderProxy; import com.android.server.location.LocationRequestStatistics; Loading @@ -114,7 +110,6 @@ import java.io.FileDescriptor; import java.io.PrintStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; Loading Loading @@ -542,77 +537,6 @@ public class LocationManagerService extends ILocationManager.Stub { } } @GuardedBy("mLock") private void ensureFallbackFusedProviderPresentLocked(String[] pkgs) { PackageManager pm = mContext.getPackageManager(); String systemPackageName = mContext.getPackageName(); ArrayList<HashSet<Signature>> sigSets = ServiceWatcher.getSignatureSets(mContext, pkgs); List<ResolveInfo> rInfos = pm.queryIntentServicesAsUser( new Intent(FUSED_LOCATION_SERVICE_ACTION), PackageManager.GET_META_DATA, mUserInfoStore.getCurrentUserId()); for (ResolveInfo rInfo : rInfos) { String packageName = rInfo.serviceInfo.packageName; // Check that the signature is in the list of supported sigs. If it's not in // this list the standard provider binding logic won't bind to it. try { PackageInfo pInfo; pInfo = pm.getPackageInfo(packageName, PackageManager.GET_SIGNATURES); if (!ServiceWatcher.isSignatureMatch(pInfo.signatures, sigSets)) { Log.w(TAG, packageName + " resolves service " + FUSED_LOCATION_SERVICE_ACTION + ", but has wrong signature, ignoring"); continue; } } catch (NameNotFoundException e) { Log.e(TAG, "missing package: " + packageName); continue; } // Get the version info if (rInfo.serviceInfo.metaData == null) { Log.w(TAG, "Found fused provider without metadata: " + packageName); continue; } int version = rInfo.serviceInfo.metaData.getInt( ServiceWatcher.EXTRA_SERVICE_VERSION, -1); if (version == 0) { // This should be the fallback fused location provider. // Make sure it's in the system partition. if ((rInfo.serviceInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) { if (D) Log.d(TAG, "Fallback candidate not in /system: " + packageName); continue; } // Check that the fallback is signed the same as the OS // as a proxy for coreApp="true" if (pm.checkSignatures(systemPackageName, packageName) != PackageManager.SIGNATURE_MATCH) { if (D) { Log.d(TAG, "Fallback candidate not signed the same as system: " + packageName); } continue; } // Found a valid fallback. if (D) Log.d(TAG, "Found fallback provider: " + packageName); return; } else { if (D) Log.d(TAG, "Fallback candidate not version 0: " + packageName); } } throw new IllegalStateException("Unable to find a fused location provider that is in the " + "system partition with version 0 and signed with the platform certificate. " + "Such a package is needed to provide a default fused location provider in the " + "event that no other fused location provider has been installed or is currently " + "available. For example, coreOnly boot mode when decrypting the data " + "partition. The fallback must also be marked coreApp=\"true\" in the manifest"); } @GuardedBy("mLock") private void initializeProvidersLocked() { if (GnssManagerService.isGnssSupported()) { Loading @@ -622,33 +546,11 @@ public class LocationManagerService extends ILocationManager.Stub { gnssManager.setRealProvider(mGnssManagerService.getGnssLocationProvider()); } /* 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(); 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)); } ensureFallbackFusedProviderPresentLocked(pkgs); LocationProviderProxy networkProvider = LocationProviderProxy.createAndBind( LocationProviderProxy networkProvider = LocationProviderProxy.createAndRegister( mContext, 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); com.android.internal.R.string.config_networkLocationProviderPackageName); if (networkProvider != null) { LocationProviderManager networkManager = new LocationProviderManager(NETWORK_PROVIDER); mProviderManagers.add(networkManager); Loading @@ -657,13 +559,18 @@ public class LocationManagerService extends ILocationManager.Stub { Slog.w(TAG, "no network location provider found"); } // ensure that a fused provider exists which will work in direct boot Preconditions.checkState(!mContext.getPackageManager().queryIntentServicesAsUser( new Intent(FUSED_LOCATION_SERVICE_ACTION), MATCH_DIRECT_BOOT_AWARE | MATCH_SYSTEM_ONLY, UserHandle.USER_SYSTEM).isEmpty(), "Unable to find a direct boot aware fused location provider"); // bind to fused provider LocationProviderProxy fusedProvider = LocationProviderProxy.createAndBind( LocationProviderProxy fusedProvider = LocationProviderProxy.createAndRegister( mContext, 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); com.android.internal.R.string.config_fusedLocationProviderPackageName); if (fusedProvider != null) { LocationProviderManager fusedManager = new LocationProviderManager(FUSED_PROVIDER); mProviderManagers.add(fusedManager); Loading @@ -674,47 +581,30 @@ public class LocationManagerService extends ILocationManager.Stub { } // 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); mGeocodeProvider = GeocoderProxy.createAndRegister(mContext); if (mGeocodeProvider == null) { Slog.e(TAG, "no geocoder provider found"); } // bind to geofence proxy if (mGnssManagerService != null) { // 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, mGnssManagerService.getGpsGeofenceProxy(), null); IGpsGeofenceHardware gpsGeofenceHardware = mGnssManagerService.getGpsGeofenceProxy(); if (gpsGeofenceHardware != null) { GeofenceProxy provider = GeofenceProxy.createAndBind(mContext, gpsGeofenceHardware); if (provider == null) { Slog.d(TAG, "Unable to bind FLP Geofence proxy."); Slog.d(TAG, "unable to bind to GeofenceProxy"); } } } // bind to hardware activity recognition boolean activityRecognitionHardwareIsSupported = ActivityRecognitionHardware.isSupported(); ActivityRecognitionHardware activityRecognitionHardware = null; if (activityRecognitionHardwareIsSupported) { activityRecognitionHardware = ActivityRecognitionHardware.getInstance(mContext); } else { Slog.d(TAG, "Hardware Activity-Recognition not supported."); } ActivityRecognitionProxy proxy = ActivityRecognitionProxy.createAndBind( mContext, activityRecognitionHardwareIsSupported, activityRecognitionHardware, com.android.internal.R.bool.config_enableActivityRecognitionHardwareOverlay, com.android.internal.R.string.config_activityRecognitionHardwarePackageName, com.android.internal.R.array.config_locationProviderPackageNames); if (proxy == null) { Slog.d(TAG, "Unable to bind ActivityRecognitionProxy."); HardwareActivityRecognitionProxy hardwareActivityRecognitionProxy = HardwareActivityRecognitionProxy.createAndRegister(mContext); if (hardwareActivityRecognitionProxy == null) { Log.e(TAG, "unable to bind ActivityRecognitionProxy"); } String[] testProviderStrings = resources.getStringArray( String[] testProviderStrings = mContext.getResources().getStringArray( com.android.internal.R.array.config_testLocationProviders); for (String testProviderString : testProviderStrings) { String[] fragments = testProviderString.split(","); Loading services/core/java/com/android/server/ServiceWatcher.java +256 −250 File changed.Preview size limit exceeded, changes collapsed. Show changes services/core/java/com/android/server/location/GeocoderProxy.java +19 −21 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.location; import android.annotation.Nullable; import android.content.Context; import android.location.Address; import android.location.GeocoderParams; Loading @@ -28,40 +29,38 @@ import java.util.List; /** * Proxy for IGeocodeProvider implementations. * * @hide */ public class GeocoderProxy { private static final String TAG = "GeocoderProxy"; private static final String SERVICE_ACTION = "com.android.location.service.GeocodeProvider"; private final ServiceWatcher mServiceWatcher; public static GeocoderProxy createAndBind(Context context, int overlaySwitchResId, int defaultServicePackageNameResId, int initialPackageNamesResId) { GeocoderProxy proxy = new GeocoderProxy(context, overlaySwitchResId, defaultServicePackageNameResId, initialPackageNamesResId); if (proxy.bind()) { /** * Creates and registers this proxy. If no suitable service is available for the proxy, returns * null. */ @Nullable public static GeocoderProxy createAndRegister(Context context) { GeocoderProxy proxy = new GeocoderProxy(context); if (proxy.register()) { return proxy; } else { return null; } } private GeocoderProxy(Context context, int overlaySwitchResId, int defaultServicePackageNameResId, int initialPackageNamesResId) { mServiceWatcher = new ServiceWatcher(context, TAG, SERVICE_ACTION, overlaySwitchResId, defaultServicePackageNameResId, initialPackageNamesResId, BackgroundThread.getHandler()); } private final ServiceWatcher mServiceWatcher; private boolean bind() { return mServiceWatcher.start(); private GeocoderProxy(Context context) { mServiceWatcher = new ServiceWatcher(context, BackgroundThread.getHandler(), SERVICE_ACTION, null, null, com.android.internal.R.bool.config_enableGeocoderOverlay, com.android.internal.R.string.config_geocoderProviderPackageName); } public String getConnectedPackageName() { return mServiceWatcher.getCurrentPackageName(); private boolean register() { return mServiceWatcher.register(); } public String getFromLocation(double latitude, double longitude, int maxResults, Loading @@ -83,5 +82,4 @@ public class GeocoderProxy { maxResults, params, addrs); }, "Service not Available"); } } Loading
core/res/res/values/config.xml +15 −53 Original line number Diff line number Diff line Loading @@ -1628,29 +1628,21 @@ config_timeZoneRulesUpdateTrackingEnabled are true.] --> <integer name="config_timeZoneRulesCheckRetryCount">5</integer> <!-- Whether to enable network location overlay which allows network location provider to be replaced by an app at run-time. When disabled, only the config_networkLocationProviderPackageName package will be searched for network location provider, otherwise packages whose signature matches the signatures of config_locationProviderPackageNames will be searched, and the service with the highest version number will be picked. Anyone who wants to disable the overlay mechanism can set it to false. --> <!-- Whether to enable network location overlay which allows network location provider to be replaced by an app at run-time. When disabled, only the config_networkLocationProviderPackageName package will be searched for network location provider, otherwise any system package is eligible. Anyone who wants to disable the overlay mechanism can set it to false. --> <bool name="config_enableNetworkLocationOverlay" translatable="false">true</bool> <!-- Package name providing network location support. Used only when config_enableNetworkLocationOverlay is false. --> <string name="config_networkLocationProviderPackageName" translatable="false">@null</string> <!-- Whether to enable fused location provider overlay which allows fused location provider to be replaced by an app at run-time. When disabled, only the config_fusedLocationProviderPackageName package will be searched for fused location provider, otherwise packages whose signature matches the signatures of config_locationProviderPackageNames will be searched, and the service with the highest version number will be picked. Anyone who wants to disable the overlay mechanism can set it to false. --> <!-- Whether to enable fused location provider overlay which allows fused location provider to be replaced by an app at run-time. When disabled, only the config_fusedLocationProviderPackageName package will be searched for fused location provider, otherwise any system package is eligible. Anyone who wants to disable the overlay mechanism can set it to false. --> <bool name="config_enableFusedLocationOverlay" translatable="false">true</bool> <!-- Package name providing fused location support. Used only when config_enableFusedLocationOverlay is false. --> Loading @@ -1669,25 +1661,10 @@ --> <string name="config_defaultNetworkRecommendationProviderPackage" translatable="false"></string> <!-- Whether to enable Hardware FLP overlay which allows Hardware FLP to be replaced by an app at run-time. When disabled, only the config_hardwareFlpPackageName package will be searched for Hardware Flp, otherwise packages whose signature matches the signatures of config_locationProviderPackageNames will be searched, and the service with the highest version number will be picked. Anyone who wants to disable the overlay mechanism can set it to false. --> <bool name="config_enableHardwareFlpOverlay" translatable="false">true</bool> <!-- Package name providing Hardware Flp. Used only when config_enableHardwareFlpOverlay is false. --> <string name="config_hardwareFlpPackageName" translatable="false">com.android.location.fused</string> <!-- Whether to enable geocoder overlay which allows geocoder to be replaced by an app at run-time. When disabled, only the config_geocoderProviderPackageName package will be searched for geocoder, otherwise packages whose signature matches the signatures of config_locationProviderPackageNames will be searched, and the service with the highest version number will be picked. Anyone who wants to geocoder, otherwise any system package is eligible. Anyone who wants to disable the overlay mechanism can set it to false. --> <bool name="config_enableGeocoderOverlay" translatable="false">true</bool> Loading @@ -1698,9 +1675,7 @@ <!-- Whether to enable geofence overlay which allows geofence to be replaced by an app at run-time. When disabled, only the config_geofenceProviderPackageName package will be searched for geofence implementation, otherwise packages whose signature matches the signatures of config_locationProviderPackageNames will be searched, and the service with the highest version number will be picked. Anyone who geofence implementation, otherwise any system package is eligible. Anyone who wants to disable the overlay mechanism can set it to false. --> <bool name="config_enableGeofenceOverlay" translatable="false">true</bool> Loading @@ -1711,9 +1686,7 @@ <!-- Whether to enable Hardware Activity-Recognition overlay which allows Hardware Activity-Recognition to be replaced by an app at run-time. When disabled, only the config_activityRecognitionHardwarePackageName package will be searched for its implementation, otherwise packages whose signature matches the signatures of config_locationProviderPackageNames will be searched, and the service with the highest version number will be picked. Anyone who its implementation, otherwise any system package is eligible. Anyone who wants to disable the overlay mechanism can set it to false. --> <bool name="config_enableActivityRecognitionHardwareOverlay" translatable="false">true</bool> Loading @@ -1721,19 +1694,8 @@ config_enableActivityRecognitionHardwareOverlay is false. --> <string name="config_activityRecognitionHardwarePackageName" translatable="false">@null</string> <!-- Package name(s) containing location provider support. These packages can contain services implementing location providers, such as the Geocode Provider, Network Location Provider, and Fused Location Provider. They will each be searched for service components implementing these providers. It is strongly recommended that the packages explicitly named below are on the system image, so that they will not map to a 3rd party application. 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. --> <!-- Package name(s) containing location provider support. These packages will be auto-granted several permissions by the system, and should be system packages. --> <string-array name="config_locationProviderPackageNames" translatable="false"> <!-- The standard AOSP fused location provider --> <item>com.android.location.fused</item> Loading
core/res/res/values/symbols.xml +0 −2 Original line number Diff line number Diff line Loading @@ -1869,7 +1869,6 @@ <java-symbol type="bool" name="config_dozeAfterScreenOffByDefault" /> <java-symbol type="bool" name="config_enableActivityRecognitionHardwareOverlay" /> <java-symbol type="bool" name="config_enableFusedLocationOverlay" /> <java-symbol type="bool" name="config_enableHardwareFlpOverlay" /> <java-symbol type="bool" name="config_enableGeocoderOverlay" /> <java-symbol type="bool" name="config_enableGeofenceOverlay" /> <java-symbol type="bool" name="config_enableNetworkLocationOverlay" /> Loading Loading @@ -2019,7 +2018,6 @@ <java-symbol type="string" name="config_datause_iface" /> <java-symbol type="string" name="config_activityRecognitionHardwarePackageName" /> <java-symbol type="string" name="config_fusedLocationProviderPackageName" /> <java-symbol type="string" name="config_hardwareFlpPackageName" /> <java-symbol type="string" name="config_geocoderProviderPackageName" /> <java-symbol type="string" name="config_geofenceProviderPackageName" /> <java-symbol type="string" name="config_networkLocationProviderPackageName" /> Loading
services/core/java/com/android/server/LocationManagerService.java +27 −137 Original line number Diff line number Diff line Loading @@ -18,6 +18,8 @@ package com.android.server; import static android.Manifest.permission.ACCESS_COARSE_LOCATION; import static android.Manifest.permission.ACCESS_FINE_LOCATION; import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_AWARE; import static android.content.pm.PackageManager.MATCH_SYSTEM_ONLY; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static android.location.LocationManager.FUSED_PROVIDER; import static android.location.LocationManager.GPS_PROVIDER; Loading @@ -35,14 +37,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ResolveInfo; import android.content.pm.Signature; import android.content.res.Resources; import android.hardware.location.ActivityRecognitionHardware; import android.location.Address; import android.location.Criteria; import android.location.GeocoderParams; Loading @@ -52,6 +47,7 @@ import android.location.IBatchedLocationCallback; import android.location.IGnssMeasurementsListener; import android.location.IGnssNavigationMessageListener; import android.location.IGnssStatusListener; import android.location.IGpsGeofenceHardware; import android.location.ILocationListener; import android.location.ILocationManager; import android.location.Location; Loading Loading @@ -91,11 +87,11 @@ import com.android.internal.util.IndentingPrintWriter; import com.android.internal.util.Preconditions; import com.android.server.location.AbstractLocationProvider; import com.android.server.location.AbstractLocationProvider.State; import com.android.server.location.ActivityRecognitionProxy; import com.android.server.location.CallerIdentity; import com.android.server.location.GeocoderProxy; import com.android.server.location.GeofenceManager; import com.android.server.location.GeofenceProxy; import com.android.server.location.HardwareActivityRecognitionProxy; import com.android.server.location.LocationFudger; import com.android.server.location.LocationProviderProxy; import com.android.server.location.LocationRequestStatistics; Loading @@ -114,7 +110,6 @@ import java.io.FileDescriptor; import java.io.PrintStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; Loading Loading @@ -542,77 +537,6 @@ public class LocationManagerService extends ILocationManager.Stub { } } @GuardedBy("mLock") private void ensureFallbackFusedProviderPresentLocked(String[] pkgs) { PackageManager pm = mContext.getPackageManager(); String systemPackageName = mContext.getPackageName(); ArrayList<HashSet<Signature>> sigSets = ServiceWatcher.getSignatureSets(mContext, pkgs); List<ResolveInfo> rInfos = pm.queryIntentServicesAsUser( new Intent(FUSED_LOCATION_SERVICE_ACTION), PackageManager.GET_META_DATA, mUserInfoStore.getCurrentUserId()); for (ResolveInfo rInfo : rInfos) { String packageName = rInfo.serviceInfo.packageName; // Check that the signature is in the list of supported sigs. If it's not in // this list the standard provider binding logic won't bind to it. try { PackageInfo pInfo; pInfo = pm.getPackageInfo(packageName, PackageManager.GET_SIGNATURES); if (!ServiceWatcher.isSignatureMatch(pInfo.signatures, sigSets)) { Log.w(TAG, packageName + " resolves service " + FUSED_LOCATION_SERVICE_ACTION + ", but has wrong signature, ignoring"); continue; } } catch (NameNotFoundException e) { Log.e(TAG, "missing package: " + packageName); continue; } // Get the version info if (rInfo.serviceInfo.metaData == null) { Log.w(TAG, "Found fused provider without metadata: " + packageName); continue; } int version = rInfo.serviceInfo.metaData.getInt( ServiceWatcher.EXTRA_SERVICE_VERSION, -1); if (version == 0) { // This should be the fallback fused location provider. // Make sure it's in the system partition. if ((rInfo.serviceInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) { if (D) Log.d(TAG, "Fallback candidate not in /system: " + packageName); continue; } // Check that the fallback is signed the same as the OS // as a proxy for coreApp="true" if (pm.checkSignatures(systemPackageName, packageName) != PackageManager.SIGNATURE_MATCH) { if (D) { Log.d(TAG, "Fallback candidate not signed the same as system: " + packageName); } continue; } // Found a valid fallback. if (D) Log.d(TAG, "Found fallback provider: " + packageName); return; } else { if (D) Log.d(TAG, "Fallback candidate not version 0: " + packageName); } } throw new IllegalStateException("Unable to find a fused location provider that is in the " + "system partition with version 0 and signed with the platform certificate. " + "Such a package is needed to provide a default fused location provider in the " + "event that no other fused location provider has been installed or is currently " + "available. For example, coreOnly boot mode when decrypting the data " + "partition. The fallback must also be marked coreApp=\"true\" in the manifest"); } @GuardedBy("mLock") private void initializeProvidersLocked() { if (GnssManagerService.isGnssSupported()) { Loading @@ -622,33 +546,11 @@ public class LocationManagerService extends ILocationManager.Stub { gnssManager.setRealProvider(mGnssManagerService.getGnssLocationProvider()); } /* 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(); 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)); } ensureFallbackFusedProviderPresentLocked(pkgs); LocationProviderProxy networkProvider = LocationProviderProxy.createAndBind( LocationProviderProxy networkProvider = LocationProviderProxy.createAndRegister( mContext, 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); com.android.internal.R.string.config_networkLocationProviderPackageName); if (networkProvider != null) { LocationProviderManager networkManager = new LocationProviderManager(NETWORK_PROVIDER); mProviderManagers.add(networkManager); Loading @@ -657,13 +559,18 @@ public class LocationManagerService extends ILocationManager.Stub { Slog.w(TAG, "no network location provider found"); } // ensure that a fused provider exists which will work in direct boot Preconditions.checkState(!mContext.getPackageManager().queryIntentServicesAsUser( new Intent(FUSED_LOCATION_SERVICE_ACTION), MATCH_DIRECT_BOOT_AWARE | MATCH_SYSTEM_ONLY, UserHandle.USER_SYSTEM).isEmpty(), "Unable to find a direct boot aware fused location provider"); // bind to fused provider LocationProviderProxy fusedProvider = LocationProviderProxy.createAndBind( LocationProviderProxy fusedProvider = LocationProviderProxy.createAndRegister( mContext, 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); com.android.internal.R.string.config_fusedLocationProviderPackageName); if (fusedProvider != null) { LocationProviderManager fusedManager = new LocationProviderManager(FUSED_PROVIDER); mProviderManagers.add(fusedManager); Loading @@ -674,47 +581,30 @@ public class LocationManagerService extends ILocationManager.Stub { } // 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); mGeocodeProvider = GeocoderProxy.createAndRegister(mContext); if (mGeocodeProvider == null) { Slog.e(TAG, "no geocoder provider found"); } // bind to geofence proxy if (mGnssManagerService != null) { // 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, mGnssManagerService.getGpsGeofenceProxy(), null); IGpsGeofenceHardware gpsGeofenceHardware = mGnssManagerService.getGpsGeofenceProxy(); if (gpsGeofenceHardware != null) { GeofenceProxy provider = GeofenceProxy.createAndBind(mContext, gpsGeofenceHardware); if (provider == null) { Slog.d(TAG, "Unable to bind FLP Geofence proxy."); Slog.d(TAG, "unable to bind to GeofenceProxy"); } } } // bind to hardware activity recognition boolean activityRecognitionHardwareIsSupported = ActivityRecognitionHardware.isSupported(); ActivityRecognitionHardware activityRecognitionHardware = null; if (activityRecognitionHardwareIsSupported) { activityRecognitionHardware = ActivityRecognitionHardware.getInstance(mContext); } else { Slog.d(TAG, "Hardware Activity-Recognition not supported."); } ActivityRecognitionProxy proxy = ActivityRecognitionProxy.createAndBind( mContext, activityRecognitionHardwareIsSupported, activityRecognitionHardware, com.android.internal.R.bool.config_enableActivityRecognitionHardwareOverlay, com.android.internal.R.string.config_activityRecognitionHardwarePackageName, com.android.internal.R.array.config_locationProviderPackageNames); if (proxy == null) { Slog.d(TAG, "Unable to bind ActivityRecognitionProxy."); HardwareActivityRecognitionProxy hardwareActivityRecognitionProxy = HardwareActivityRecognitionProxy.createAndRegister(mContext); if (hardwareActivityRecognitionProxy == null) { Log.e(TAG, "unable to bind ActivityRecognitionProxy"); } String[] testProviderStrings = resources.getStringArray( String[] testProviderStrings = mContext.getResources().getStringArray( com.android.internal.R.array.config_testLocationProviders); for (String testProviderString : testProviderStrings) { String[] fragments = testProviderString.split(","); Loading
services/core/java/com/android/server/ServiceWatcher.java +256 −250 File changed.Preview size limit exceeded, changes collapsed. Show changes
services/core/java/com/android/server/location/GeocoderProxy.java +19 −21 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.location; import android.annotation.Nullable; import android.content.Context; import android.location.Address; import android.location.GeocoderParams; Loading @@ -28,40 +29,38 @@ import java.util.List; /** * Proxy for IGeocodeProvider implementations. * * @hide */ public class GeocoderProxy { private static final String TAG = "GeocoderProxy"; private static final String SERVICE_ACTION = "com.android.location.service.GeocodeProvider"; private final ServiceWatcher mServiceWatcher; public static GeocoderProxy createAndBind(Context context, int overlaySwitchResId, int defaultServicePackageNameResId, int initialPackageNamesResId) { GeocoderProxy proxy = new GeocoderProxy(context, overlaySwitchResId, defaultServicePackageNameResId, initialPackageNamesResId); if (proxy.bind()) { /** * Creates and registers this proxy. If no suitable service is available for the proxy, returns * null. */ @Nullable public static GeocoderProxy createAndRegister(Context context) { GeocoderProxy proxy = new GeocoderProxy(context); if (proxy.register()) { return proxy; } else { return null; } } private GeocoderProxy(Context context, int overlaySwitchResId, int defaultServicePackageNameResId, int initialPackageNamesResId) { mServiceWatcher = new ServiceWatcher(context, TAG, SERVICE_ACTION, overlaySwitchResId, defaultServicePackageNameResId, initialPackageNamesResId, BackgroundThread.getHandler()); } private final ServiceWatcher mServiceWatcher; private boolean bind() { return mServiceWatcher.start(); private GeocoderProxy(Context context) { mServiceWatcher = new ServiceWatcher(context, BackgroundThread.getHandler(), SERVICE_ACTION, null, null, com.android.internal.R.bool.config_enableGeocoderOverlay, com.android.internal.R.string.config_geocoderProviderPackageName); } public String getConnectedPackageName() { return mServiceWatcher.getCurrentPackageName(); private boolean register() { return mServiceWatcher.register(); } public String getFromLocation(double latitude, double longitude, int maxResults, Loading @@ -83,5 +82,4 @@ public class GeocoderProxy { maxResults, params, addrs); }, "Service not Available"); } }