diff --git a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt index ed94684bb..819f9b592 100644 --- a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt +++ b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt @@ -22,6 +22,7 @@ import com.geeksville.analytics.DataPair import com.geeksville.android.GeeksvilleApplication import com.geeksville.android.Logging import com.geeksville.android.ServiceClient +import com.geeksville.android.isGooglePlayAvailable import com.geeksville.concurrent.handledLaunch import com.geeksville.mesh.* import com.geeksville.mesh.MeshProtos.MeshPacket @@ -242,7 +243,8 @@ class MeshService : Service(), Logging { @SuppressLint("MissingPermission") @UiThread private fun startLocationRequests() { - if (fusedLocationClient == null) { + // FIXME - currently we don't support location reading without google play + if (fusedLocationClient == null && isGooglePlayAvailable(this)) { GeeksvilleApplication.analytics.track("location_start") // Figure out how many users needed to use the phone GPS val request = LocationRequest.create().apply { diff --git a/app/src/main/java/com/geeksville/mesh/ui/SettingsFragment.kt b/app/src/main/java/com/geeksville/mesh/ui/SettingsFragment.kt index e5c158f85..c96cd66a3 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/SettingsFragment.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/SettingsFragment.kt @@ -30,6 +30,7 @@ import androidx.lifecycle.Observer import com.geeksville.android.GeeksvilleApplication import com.geeksville.android.Logging import com.geeksville.android.hideKeyboard +import com.geeksville.android.isGooglePlayAvailable import com.geeksville.concurrent.handledLaunch import com.geeksville.mesh.MainActivity import com.geeksville.mesh.R @@ -687,8 +688,9 @@ class SettingsFragment : ScreenFragment("Settings"), Logging { // To skip filtering based on name and supported feature flags (UUIDs), // don't include calls to setNamePattern() and addServiceUuid(), // respectively. This example uses Bluetooth. + // We only look for Mesh (rather than the full name) because NRF52 uses a very short name val deviceFilter: BluetoothDeviceFilter = BluetoothDeviceFilter.Builder() - .setNamePattern(Pattern.compile("Meshtastic_.*")) + .setNamePattern(Pattern.compile("Mesh.*")) // .addServiceUuid(ParcelUuid(RadioInterfaceService.BTM_SERVICE_UUID), null) .build() @@ -768,45 +770,48 @@ class SettingsFragment : ScreenFragment("Settings"), Logging { * If the user has not turned on location access throw up a toast warning */ private fun checkLocationEnabled() { - // We do this painful process because LocationManager.isEnabled is only SDK28 or latet - val builder = LocationSettingsRequest.Builder() - builder.setNeedBle(true) + // If they don't have google play FIXME for now we don't check for location access + if (isGooglePlayAvailable(requireContext())) { + // We do this painful process because LocationManager.isEnabled is only SDK28 or latet + val builder = LocationSettingsRequest.Builder() + builder.setNeedBle(true) - val request = LocationRequest.create().apply { - priority = LocationRequest.PRIORITY_HIGH_ACCURACY - } - builder.addLocationRequest(request) // Make sure we are granted high accuracy permission + val request = LocationRequest.create().apply { + priority = LocationRequest.PRIORITY_HIGH_ACCURACY + } + builder.addLocationRequest(request) // Make sure we are granted high accuracy permission - val locationSettingsResponse = LocationServices.getSettingsClient(requireActivity()) - .checkLocationSettings(builder.build()) + val locationSettingsResponse = LocationServices.getSettingsClient(requireActivity()) + .checkLocationSettings(builder.build()) - locationSettingsResponse.addOnSuccessListener { - debug("We have location access") - } + locationSettingsResponse.addOnSuccessListener { + debug("We have location access") + } - locationSettingsResponse.addOnFailureListener { exception -> - errormsg("Failed to get location access") - // We always show the toast regardless of what type of exception we receive. Because even non - // resolvable api exceptions mean user still needs to fix something. - - ///if (exception is ResolvableApiException) { + locationSettingsResponse.addOnFailureListener { exception -> + errormsg("Failed to get location access") + // We always show the toast regardless of what type of exception we receive. Because even non + // resolvable api exceptions mean user still needs to fix something. - // Location settings are not satisfied, but this can be fixed - // by showing the user a dialog. + ///if (exception is ResolvableApiException) { - // Show the dialog by calling startResolutionForResult(), - // and check the result in onActivityResult(). - // exception.startResolutionForResult(this@MainActivity, REQUEST_CHECK_SETTINGS) + // Location settings are not satisfied, but this can be fixed + // by showing the user a dialog. - // For now just punt and show a dialog - Toast.makeText( - requireContext(), - getString(R.string.location_disabled_warning), - Toast.LENGTH_SHORT - ).show() + // Show the dialog by calling startResolutionForResult(), + // and check the result in onActivityResult(). + // exception.startResolutionForResult(this@MainActivity, REQUEST_CHECK_SETTINGS) - //} else - // Exceptions.report(exception) + // For now just punt and show a dialog + Toast.makeText( + requireContext(), + getString(R.string.location_disabled_warning), + Toast.LENGTH_SHORT + ).show() + + //} else + // Exceptions.report(exception) + } } } diff --git a/geeksville-androidlib b/geeksville-androidlib index ab381a83f..cfe31d66e 160000 --- a/geeksville-androidlib +++ b/geeksville-androidlib @@ -1 +1 @@ -Subproject commit ab381a83f5380358fa8412a58635e390c3729192 +Subproject commit cfe31d66e4de324fa91a2978a76ffcfba5e01085