Search in sources :

Example 6 with LocationProviderProxy

use of com.android.server.location.LocationProviderProxy 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;
    }
}
Also used : PassiveProvider(com.android.server.location.PassiveProvider) LocationProviderProxy(com.android.server.location.LocationProviderProxy) GeofenceProxy(com.android.server.location.GeofenceProxy) GpsLocationProvider(com.android.server.location.GpsLocationProvider) ArrayList(java.util.ArrayList) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) Resources(android.content.res.Resources)

Example 7 with LocationProviderProxy

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

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;
    if (GnssLocationProvider.isSupported()) {
        // Create a gps location provider
        GnssLocationProvider gnssProvider = new GnssLocationProvider(mContext, this, mLocationHandler.getLooper());
        mGnssSystemInfoProvider = gnssProvider.getGnssSystemInfoProvider();
        mGnssStatusProvider = gnssProvider.getGnssStatusProvider();
        mNetInitiatedListener = gnssProvider.getNetInitiatedListener();
        addProviderLocked(gnssProvider);
        mRealProviders.put(LocationManager.GPS_PROVIDER, gnssProvider);
        mGnssMeasurementsProvider = gnssProvider.getGnssMeasurementsProvider();
        mGnssNavigationMessageProvider = gnssProvider.getGnssNavigationMessageProvider();
        mGpsGeofenceProxy = gnssProvider.getGpsGeofenceProxy();
    }
    /*
        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 fused hardware provider if supported
    // in devices without support, requesting an instance of FlpHardwareProvider will raise an
    // exception, so make sure we only do that when supported
    FlpHardwareProvider flpHardwareProvider;
    if (FlpHardwareProvider.isSupported()) {
        flpHardwareProvider = FlpHardwareProvider.getInstance(mContext);
        FusedProxy fusedProxy = FusedProxy.createAndBind(mContext, mLocationHandler, flpHardwareProvider.getLocationHardware(), com.android.internal.R.bool.config_enableHardwareFlpOverlay, com.android.internal.R.string.config_hardwareFlpPackageName, com.android.internal.R.array.config_locationProviderPackageNames);
        if (fusedProxy == null) {
            Slog.d(TAG, "Unable to bind FusedProxy.");
        }
    } else {
        flpHardwareProvider = null;
        Slog.d(TAG, "FLP HAL not supported");
    }
    // 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, mGpsGeofenceProxy, flpHardwareProvider != null ? flpHardwareProvider.getGeofenceHardware() : null);
    if (provider == null) {
        Slog.d(TAG, "Unable to bind FLP Geofence proxy.");
    }
    // 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, mLocationHandler, 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.");
    }
    mComboNlpPackageName = resources.getString(com.android.internal.R.string.config_comboNetworkLocationProvider);
    if (mComboNlpPackageName != null) {
        mComboNlpReadyMarker = mComboNlpPackageName + ".nlp:ready";
        mComboNlpScreenMarker = mComboNlpPackageName + ".nlp:screen";
    }
    String[] testProviderStrings = resources.getStringArray(com.android.internal.R.array.config_testLocationProviders);
    for (String testProviderString : testProviderStrings) {
        String[] fragments = testProviderString.split(",");
        String name = fragments[0].trim();
        if (mProvidersByName.get(name) != null) {
            throw new IllegalArgumentException("Provider \"" + name + "\" already exists");
        }
        ProviderProperties properties = new ProviderProperties(Boolean.parseBoolean(fragments[1]), /* requiresNetwork */
        Boolean.parseBoolean(fragments[2]), /* requiresSatellite */
        Boolean.parseBoolean(fragments[3]), /* requiresCell */
        Boolean.parseBoolean(fragments[4]), /* hasMonetaryCost */
        Boolean.parseBoolean(fragments[5]), /* supportsAltitude */
        Boolean.parseBoolean(fragments[6]), /* supportsSpeed */
        Boolean.parseBoolean(fragments[7]), /* supportsBearing */
        Integer.parseInt(fragments[8]), /* powerRequirement */
        Integer.parseInt(fragments[9]));
        addTestProviderLocked(name, properties);
    }
}
Also used : ActivityRecognitionProxy(com.android.server.location.ActivityRecognitionProxy) LocationProviderProxy(com.android.server.location.LocationProviderProxy) ArrayList(java.util.ArrayList) PassiveProvider(com.android.server.location.PassiveProvider) FusedProxy(com.android.server.location.FusedProxy) ProviderProperties(com.android.internal.location.ProviderProperties) GeofenceProxy(com.android.server.location.GeofenceProxy) GnssLocationProvider(com.android.server.location.GnssLocationProvider) Resources(android.content.res.Resources) ActivityRecognitionHardware(android.hardware.location.ActivityRecognitionHardware) FlpHardwareProvider(com.android.server.location.FlpHardwareProvider)

Example 8 with LocationProviderProxy

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

the class LocationManagerService method screenLocationLocked.

private Location screenLocationLocked(Location location, String provider) {
    if (isMockProvider(LocationManager.NETWORK_PROVIDER)) {
        return location;
    }
    LocationProviderProxy providerProxy = (LocationProviderProxy) mProvidersByName.get(LocationManager.NETWORK_PROVIDER);
    if (mComboNlpPackageName == null || providerProxy == null || false == provider.equals(LocationManager.NETWORK_PROVIDER) || isMockProvider(LocationManager.NETWORK_PROVIDER)) {
        return location;
    }
    String connectedNlpPackage = providerProxy.getConnectedPackageName();
    if (connectedNlpPackage == null || !connectedNlpPackage.equals(mComboNlpPackageName)) {
        return location;
    }
    Bundle extras = location.getExtras();
    boolean isBeingScreened = false;
    if (extras == null || !extras.containsKey(mComboNlpReadyMarker)) {
        // see if Combo Nlp is a passive listener
        ArrayList<UpdateRecord> records = mRecordsByProvider.get(LocationManager.PASSIVE_PROVIDER);
        if (records != null) {
            for (UpdateRecord r : records) {
                if (r.mReceiver.mPackageName.equals(mComboNlpPackageName)) {
                    if (!isBeingScreened) {
                        isBeingScreened = true;
                        if (extras == null) {
                            location.setExtras(new Bundle());
                            extras = location.getExtras();
                        }
                        extras.putBoolean(mComboNlpScreenMarker, true);
                    }
                    // send location to Combo Nlp for screening
                    if (!r.mReceiver.callLocationChangedLocked(location)) {
                        Slog.w(TAG, "RemoteException calling onLocationChanged on " + r.mReceiver);
                    } else {
                        if (D) {
                            Log.d(TAG, "Sending location for screening");
                        }
                    }
                }
            }
        }
        if (isBeingScreened) {
            return null;
        }
        if (D) {
            Log.d(TAG, "Not screening locations");
        }
    } else {
        if (D) {
            Log.d(TAG, "This location is marked as ready for broadcast");
        }
        // clear the ready marker
        extras.remove(mComboNlpReadyMarker);
    }
    return location;
}
Also used : LocationProviderProxy(com.android.server.location.LocationProviderProxy) Bundle(android.os.Bundle)

Example 9 with LocationProviderProxy

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

the class LocationManagerService method dump.

@Override
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
    if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) {
        pw.println("Permission Denial: can't dump LocationManagerService from from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid());
        return;
    }
    synchronized (mLock) {
        pw.println("Current Location Manager state:");
        pw.println("  Location Listeners:");
        for (Receiver receiver : mReceivers.values()) {
            pw.println("    " + receiver);
        }
        pw.println("  Active Records by Provider:");
        for (Map.Entry<String, ArrayList<UpdateRecord>> entry : mRecordsByProvider.entrySet()) {
            pw.println("    " + entry.getKey() + ":");
            for (UpdateRecord record : entry.getValue()) {
                pw.println("      " + record);
            }
        }
        pw.println("  Historical Records by Provider:");
        for (Map.Entry<PackageProviderKey, PackageStatistics> entry : mRequestStatistics.statistics.entrySet()) {
            PackageProviderKey key = entry.getKey();
            PackageStatistics stats = entry.getValue();
            pw.println("    " + key.packageName + ": " + key.providerName + ": " + stats);
        }
        pw.println("  Last Known Locations:");
        for (Map.Entry<String, Location> entry : mLastLocation.entrySet()) {
            String provider = entry.getKey();
            Location location = entry.getValue();
            pw.println("    " + provider + ": " + location);
        }
        pw.println("  Last Known Locations Coarse Intervals:");
        for (Map.Entry<String, Location> entry : mLastLocationCoarseInterval.entrySet()) {
            String provider = entry.getKey();
            Location location = entry.getValue();
            pw.println("    " + provider + ": " + location);
        }
        mGeofenceManager.dump(pw);
        if (mEnabledProviders.size() > 0) {
            pw.println("  Enabled Providers:");
            for (String i : mEnabledProviders) {
                pw.println("    " + i);
            }
        }
        if (mDisabledProviders.size() > 0) {
            pw.println("  Disabled Providers:");
            for (String i : mDisabledProviders) {
                pw.println("    " + i);
            }
        }
        pw.append("  ");
        mBlacklist.dump(pw);
        if (mMockProviders.size() > 0) {
            pw.println("  Mock Providers:");
            for (Map.Entry<String, MockProvider> i : mMockProviders.entrySet()) {
                i.getValue().dump(pw, "      ");
            }
        }
        pw.append("  fudger: ");
        mLocationFudger.dump(fd, pw, args);
        if (args.length > 0 && "short".equals(args[0])) {
            return;
        }
        for (LocationProviderInterface provider : mProviders) {
            pw.print(provider.getName() + " Internal State");
            if (provider instanceof LocationProviderProxy) {
                LocationProviderProxy proxy = (LocationProviderProxy) provider;
                pw.print(" (" + proxy.getConnectedPackageName() + ")");
            }
            pw.println(":");
            provider.dump(fd, pw, args);
        }
    }
}
Also used : PackageStatistics(com.android.server.location.LocationRequestStatistics.PackageStatistics) LocationProviderProxy(com.android.server.location.LocationProviderProxy) ArrayList(java.util.ArrayList) BroadcastReceiver(android.content.BroadcastReceiver) PackageProviderKey(com.android.server.location.LocationRequestStatistics.PackageProviderKey) MockProvider(com.android.server.location.MockProvider) LocationProviderInterface(com.android.server.location.LocationProviderInterface) Map(java.util.Map) HashMap(java.util.HashMap) Location(android.location.Location)

Example 10 with LocationProviderProxy

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

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;
    if (GnssLocationProvider.isSupported()) {
        // Create a gps location provider
        GnssLocationProvider gnssProvider = new GnssLocationProvider(mContext, this, mLocationHandler.getLooper());
        mGnssSystemInfoProvider = gnssProvider.getGnssSystemInfoProvider();
        mGnssStatusProvider = gnssProvider.getGnssStatusProvider();
        mNetInitiatedListener = gnssProvider.getNetInitiatedListener();
        addProviderLocked(gnssProvider);
        mRealProviders.put(LocationManager.GPS_PROVIDER, gnssProvider);
        mGnssMeasurementsProvider = gnssProvider.getGnssMeasurementsProvider();
        mGnssNavigationMessageProvider = gnssProvider.getGnssNavigationMessageProvider();
        mGpsGeofenceProxy = gnssProvider.getGpsGeofenceProxy();
    }
    /*
        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 fused hardware provider if supported
    // in devices without support, requesting an instance of FlpHardwareProvider will raise an
    // exception, so make sure we only do that when supported
    FlpHardwareProvider flpHardwareProvider;
    if (FlpHardwareProvider.isSupported()) {
        flpHardwareProvider = FlpHardwareProvider.getInstance(mContext);
        FusedProxy fusedProxy = FusedProxy.createAndBind(mContext, mLocationHandler, flpHardwareProvider.getLocationHardware(), com.android.internal.R.bool.config_enableHardwareFlpOverlay, com.android.internal.R.string.config_hardwareFlpPackageName, com.android.internal.R.array.config_locationProviderPackageNames);
        if (fusedProxy == null) {
            Slog.d(TAG, "Unable to bind FusedProxy.");
        }
    } else {
        flpHardwareProvider = null;
        Slog.d(TAG, "FLP HAL not supported");
    }
    // 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, mGpsGeofenceProxy, flpHardwareProvider != null ? flpHardwareProvider.getGeofenceHardware() : null);
    if (provider == null) {
        Slog.d(TAG, "Unable to bind FLP Geofence proxy.");
    }
    // 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, mLocationHandler, 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.");
    }
    String[] testProviderStrings = resources.getStringArray(com.android.internal.R.array.config_testLocationProviders);
    for (String testProviderString : testProviderStrings) {
        String[] fragments = testProviderString.split(",");
        String name = fragments[0].trim();
        if (mProvidersByName.get(name) != null) {
            throw new IllegalArgumentException("Provider \"" + name + "\" already exists");
        }
        ProviderProperties properties = new ProviderProperties(Boolean.parseBoolean(fragments[1]), /* requiresNetwork */
        Boolean.parseBoolean(fragments[2]), /* requiresSatellite */
        Boolean.parseBoolean(fragments[3]), /* requiresCell */
        Boolean.parseBoolean(fragments[4]), /* hasMonetaryCost */
        Boolean.parseBoolean(fragments[5]), /* supportsAltitude */
        Boolean.parseBoolean(fragments[6]), /* supportsSpeed */
        Boolean.parseBoolean(fragments[7]), /* supportsBearing */
        Integer.parseInt(fragments[8]), /* powerRequirement */
        Integer.parseInt(fragments[9]));
        addTestProviderLocked(name, properties);
    }
}
Also used : ActivityRecognitionProxy(com.android.server.location.ActivityRecognitionProxy) LocationProviderProxy(com.android.server.location.LocationProviderProxy) ArrayList(java.util.ArrayList) PassiveProvider(com.android.server.location.PassiveProvider) FusedProxy(com.android.server.location.FusedProxy) ProviderProperties(com.android.internal.location.ProviderProperties) GeofenceProxy(com.android.server.location.GeofenceProxy) GnssLocationProvider(com.android.server.location.GnssLocationProvider) Resources(android.content.res.Resources) ActivityRecognitionHardware(android.hardware.location.ActivityRecognitionHardware) FlpHardwareProvider(com.android.server.location.FlpHardwareProvider)

Aggregations

LocationProviderProxy (com.android.server.location.LocationProviderProxy)15 ArrayList (java.util.ArrayList)12 BroadcastReceiver (android.content.BroadcastReceiver)6 Resources (android.content.res.Resources)6 Location (android.location.Location)6 GeofenceProxy (com.android.server.location.GeofenceProxy)6 LocationProviderInterface (com.android.server.location.LocationProviderInterface)6 MockProvider (com.android.server.location.MockProvider)6 PassiveProvider (com.android.server.location.PassiveProvider)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 ActivityRecognitionHardware (android.hardware.location.ActivityRecognitionHardware)5 ProviderProperties (com.android.internal.location.ProviderProperties)5 ActivityRecognitionProxy (com.android.server.location.ActivityRecognitionProxy)5 FlpHardwareProvider (com.android.server.location.FlpHardwareProvider)5 FusedProxy (com.android.server.location.FusedProxy)5 GnssLocationProvider (com.android.server.location.GnssLocationProvider)5 PackageProviderKey (com.android.server.location.LocationRequestStatistics.PackageProviderKey)5 PackageStatistics (com.android.server.location.LocationRequestStatistics.PackageStatistics)5 Bundle (android.os.Bundle)3