mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-17 14:10:54 +02:00
check also if the location service globally is on not only the app location permission
This commit is contained in:
@@ -20,6 +20,7 @@ import android.Manifest;
|
|||||||
import android.bluetooth.BluetoothGattService;
|
import android.bluetooth.BluetoothGattService;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.location.LocationManager;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
|
||||||
import com.health.openscale.core.OpenScale;
|
import com.health.openscale.core.OpenScale;
|
||||||
@@ -49,6 +50,8 @@ import io.reactivex.plugins.RxJavaPlugins;
|
|||||||
import io.reactivex.subjects.PublishSubject;
|
import io.reactivex.subjects.PublishSubject;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
|
import static android.content.Context.LOCATION_SERVICE;
|
||||||
|
|
||||||
public abstract class BluetoothCommunication {
|
public abstract class BluetoothCommunication {
|
||||||
public enum BT_STATUS_CODE {
|
public enum BT_STATUS_CODE {
|
||||||
BT_RETRIEVE_SCALE_DATA,
|
BT_RETRIEVE_SCALE_DATA,
|
||||||
@@ -478,8 +481,11 @@ public abstract class BluetoothCommunication {
|
|||||||
// (e.g. Sony Xperia Z5 compact, Android 7.1.1). For some scales (e.g. Medisana BS444)
|
// (e.g. Sony Xperia Z5 compact, Android 7.1.1). For some scales (e.g. Medisana BS444)
|
||||||
// it seems to be a requirement that the scale is discovered before connecting to it.
|
// it seems to be a requirement that the scale is discovered before connecting to it.
|
||||||
// Otherwise the connection almost never succeeds.
|
// Otherwise the connection almost never succeeds.
|
||||||
|
LocationManager locationManager = (LocationManager)context.getSystemService(LOCATION_SERVICE);
|
||||||
|
|
||||||
if (ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION)
|
if (ContextCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION)
|
||||||
== PackageManager.PERMISSION_GRANTED) {
|
== PackageManager.PERMISSION_GRANTED && locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)
|
||||||
|
) {
|
||||||
Timber.d("Do LE scan before connecting to device");
|
Timber.d("Do LE scan before connecting to device");
|
||||||
scanSubscription = bleClient.scanBleDevices(
|
scanSubscription = bleClient.scanBleDevices(
|
||||||
new ScanSettings.Builder()
|
new ScanSettings.Builder()
|
||||||
|
Reference in New Issue
Block a user