+ if (locationManager != null)
+ {
+ try {
+ locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1, this);
+ location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
+ } catch (Exception e) {
+ locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000, 1, this);
+ location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
+ }
+
+ if (location != null)
+ AltosDebug.debug("Resume, location is %f,%f\n",
+ location.getLatitude(),
+ location.getLongitude());
+ AltosDebug.debug("Failed to get GPS updates\n");
+ }
+
+ if (do_update)
+ update_ui(telemetry_state, state, true);
+ }
+
+ static final int MY_PERMISSION_REQUEST = 1001;
+
+ public boolean have_location_permission = false;
+ public boolean have_storage_permission = false;
+ public boolean have_bluetooth_permission = false;
+ public boolean have_bluetooth_connect_permission = false;
+ public boolean have_bluetooth_scan_permission = false;
+ public boolean asked_permission = false;
+
+ static final String BLUETOOTH_CONNECT = "android.permission.BLUETOOTH_CONNECT";
+ static final String BLUETOOTH_SCAN = "android.permission.BLUETOOTH_SCAN";
+
+ AltosMapOnline map_online;
+
+ void
+ tell_map_permission(AltosMapOnline map_online) {
+ this.map_online = map_online;
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, String[] permissions,
+ int[] grantResults) {
+ if (requestCode == MY_PERMISSION_REQUEST) {
+ for (int i = 0; i < grantResults.length; i++) {
+ if (grantResults[i] == PackageManager.PERMISSION_GRANTED) {
+ if (permissions[i].equals(Manifest.permission.ACCESS_FINE_LOCATION)) {
+ have_location_permission = true;
+ enable_location_updates(true);
+ if (map_online != null)
+ map_online.position_permission();
+ }
+ if (permissions[i].equals(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
+ have_storage_permission = true;
+ }
+ if (permissions[i].equals(Manifest.permission.BLUETOOTH)) {
+ have_bluetooth_permission = true;
+ }
+ if (permissions[i].equals(BLUETOOTH_CONNECT)) {
+ have_bluetooth_connect_permission = true;
+ }
+ if (permissions[i].equals(BLUETOOTH_SCAN)) {
+ have_bluetooth_scan_permission = true;
+ }
+ }
+ }
+ }
+ }