Search in sources :

Example 61 with Location

use of android.location.Location in project android_frameworks_base by ResurrectionRemix.

the class KMLFormatter method getOutput.

public String getOutput(TrackerEntry entry) {
    LineBuilder builder = new LineBuilder();
    if (entry.getType() == EntryType.LOCATION_TYPE) {
        Location loc = entry.getLocation();
        builder.addLine("<Placemark>");
        builder.addLine("<description>");
        builder.addLine("accuracy = " + loc.getAccuracy());
        builder.addLine("distance from last network location  = " + entry.getDistFromNetLocation());
        builder.addLine("</description>");
        builder.addLine("<TimeStamp>");
        builder.addLine("<when>" + entry.getTimestamp() + "</when>");
        builder.addLine("</TimeStamp>");
        builder.addLine("<Point>");
        builder.addLine("<coordinates>");
        builder.addLine(loc.getLongitude() + "," + loc.getLatitude() + "," + loc.getAltitude());
        builder.addLine("</coordinates>");
        builder.addLine("</Point>");
        builder.addLine("</Placemark>");
    }
    return builder.toString();
}
Also used : Location(android.location.Location)

Example 62 with Location

use of android.location.Location in project android_frameworks_base by ResurrectionRemix.

the class ExternalSharedPermsTest method testRunLocationAndBluetooth.

/** The use of location manager and bluetooth below are simply to simulate an app that
     *  tries to use them, so we can verify whether permissions are granted and accessible.
     * */
public void testRunLocationAndBluetooth() {
    LocationManager locationManager = (LocationManager) getInstrumentation().getContext().getSystemService(Context.LOCATION_SERVICE);
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, new LocationListener() {

        public void onLocationChanged(Location location) {
        }

        public void onProviderDisabled(String provider) {
        }

        public void onProviderEnabled(String provider) {
        }

        public void onStatusChanged(String provider, int status, Bundle extras) {
        }
    });
    BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    if ((mBluetoothAdapter != null) && (!mBluetoothAdapter.isEnabled())) {
        mBluetoothAdapter.getName();
    }
}
Also used : LocationManager(android.location.LocationManager) Bundle(android.os.Bundle) LocationListener(android.location.LocationListener) BluetoothAdapter(android.bluetooth.BluetoothAdapter) Location(android.location.Location)

Example 63 with Location

use of android.location.Location in project android_frameworks_base by ResurrectionRemix.

the class ExternalSharedPermsDiffKeyTest method testRunBluetoothAndFineLocation.

/** The use of location manager and bluetooth below are simply to simulate an app that
     *  tries to use them, so we can verify whether permissions are granted and accessible.
     * */
public void testRunBluetoothAndFineLocation() {
    LocationManager locationManager = (LocationManager) getInstrumentation().getContext().getSystemService(Context.LOCATION_SERVICE);
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, new LocationListener() {

        public void onLocationChanged(Location location) {
        }

        public void onProviderDisabled(String provider) {
        }

        public void onProviderEnabled(String provider) {
        }

        public void onStatusChanged(String provider, int status, Bundle extras) {
        }
    });
    BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    if ((mBluetoothAdapter != null) && (!mBluetoothAdapter.isEnabled())) {
        mBluetoothAdapter.getName();
    }
    fail("this app was signed by a different cert and should crash/fail to run by now");
}
Also used : LocationManager(android.location.LocationManager) Bundle(android.os.Bundle) LocationListener(android.location.LocationListener) BluetoothAdapter(android.bluetooth.BluetoothAdapter) Location(android.location.Location)

Example 64 with Location

use of android.location.Location in project android_frameworks_base by ResurrectionRemix.

the class ExternalSharedPermsFLTest method testRunFineLocation.

/** The use of location manager below is simply to simulate an app that
     *  tries to use it, so we can verify whether permissions are granted and accessible.
     * */
public void testRunFineLocation() {
    LocationManager locationManager = (LocationManager) getInstrumentation().getContext().getSystemService(Context.LOCATION_SERVICE);
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, new LocationListener() {

        public void onLocationChanged(Location location) {
        }

        public void onProviderDisabled(String provider) {
        }

        public void onProviderEnabled(String provider) {
        }

        public void onStatusChanged(String provider, int status, Bundle extras) {
        }
    });
}
Also used : LocationManager(android.location.LocationManager) Bundle(android.os.Bundle) LocationListener(android.location.LocationListener) Location(android.location.Location)

Example 65 with Location

use of android.location.Location in project android_frameworks_base by ResurrectionRemix.

the class GnssLocationProvider method reportGeofenceStatus.

/**
     * called from native code to report GPS status change.
     */
private void reportGeofenceStatus(int status, int flags, double latitude, double longitude, double altitude, float speed, float bearing, float accuracy, long timestamp) {
    if (mGeofenceHardwareImpl == null) {
        mGeofenceHardwareImpl = GeofenceHardwareImpl.getInstance(mContext);
    }
    Location location = buildLocation(flags, latitude, longitude, altitude, speed, bearing, accuracy, timestamp);
    int monitorStatus = GeofenceHardware.MONITOR_CURRENTLY_UNAVAILABLE;
    if (status == GPS_GEOFENCE_AVAILABLE) {
        monitorStatus = GeofenceHardware.MONITOR_CURRENTLY_AVAILABLE;
    }
    mGeofenceHardwareImpl.reportGeofenceMonitorStatus(GeofenceHardware.MONITORING_TYPE_GPS_HARDWARE, monitorStatus, location, FusedBatchOptions.SourceTechnologies.GNSS);
}
Also used : GsmCellLocation(android.telephony.gsm.GsmCellLocation) Location(android.location.Location)

Aggregations

Location (android.location.Location)290 Bundle (android.os.Bundle)50 LocationListener (android.location.LocationListener)38 LocationManager (android.location.LocationManager)33 ArrayList (java.util.ArrayList)29 Criteria (android.location.Criteria)20 LocationProviderInterface (com.android.server.location.LocationProviderInterface)18 GsmCellLocation (android.telephony.gsm.GsmCellLocation)17 BluetoothAdapter (android.bluetooth.BluetoothAdapter)12 BroadcastReceiver (android.content.BroadcastReceiver)12 Handler (android.os.Handler)10 MockProvider (com.android.server.location.MockProvider)9 Intent (android.content.Intent)8 Timer (java.util.Timer)8 Test (org.junit.Test)8 PendingIntent (android.app.PendingIntent)7 IOException (java.io.IOException)7 LocationProviderProxy (com.android.server.location.LocationProviderProxy)6 HashMap (java.util.HashMap)6 List (java.util.List)6