fix permission check
This commit is contained in:
parent
2488e37fec
commit
4046eac506
|
@ -292,8 +292,8 @@ public class MainActivity extends AppCompatActivity {
|
||||||
intentFilter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED);
|
intentFilter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED);
|
||||||
intentFilter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED);
|
intentFilter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED);
|
||||||
|
|
||||||
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_CONNECT)
|
String btPermission = getBluetoothConnectPermission();
|
||||||
!= PackageManager.PERMISSION_GRANTED) {
|
if (ActivityCompat.checkSelfPermission(this, btPermission) != PackageManager.PERMISSION_GRANTED) {
|
||||||
Log.d("BT", "No permission to connect bluetooth devices");
|
Log.d("BT", "No permission to connect bluetooth devices");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
@ -310,8 +310,8 @@ public class MainActivity extends AppCompatActivity {
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
|
||||||
boolean isInCar = pref.getBoolean("isInCarPref", false);
|
boolean isInCar = pref.getBoolean("isInCarPref", false);
|
||||||
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.BLUETOOTH_CONNECT)
|
String btPermission = getBluetoothConnectPermission();
|
||||||
!= PackageManager.PERMISSION_GRANTED) {
|
if (ActivityCompat.checkSelfPermission(context, btPermission) != PackageManager.PERMISSION_GRANTED) {
|
||||||
Log.d("BT", "No permission to connect bluetooth devices");
|
Log.d("BT", "No permission to connect bluetooth devices");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user