Skip to content

Commit

Permalink
Add new bt permissions (#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
José Pereda authored Mar 31, 2023
1 parent 7c0cc65 commit 7fc532b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Gluon
* Copyright (c) 2020, 2023, Gluon
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -48,6 +48,7 @@
import android.bluetooth.le.AdvertiseCallback;

import android.content.Intent;
import android.os.Build;
import android.util.Log;

import java.nio.ByteBuffer;
Expand Down Expand Up @@ -90,6 +91,13 @@ private void init() {
if (!fineloc) {
Log.v(TAG, "No permission to get fine location");
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
boolean btPermissions = Util.verifyPermissions(new String[]{
"android.permission.BLUETOOTH_SCAN", "android.permission.BLUETOOTH_ADVERTISE", "android.permission.BLUETOOTH_CONNECT"});
if (!btPermissions) {
Log.v(TAG, "No permission to scan and/or be discovered by and/or connect to Bluetooth devices");
}
}
final BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
if (!adapter.isEnabled()) {
Log.v(TAG, "DalvikBle, init, adapter not enabled");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<?xml version='1.0' encoding="utf-8"?>
<manifest xmlns:android='http://schemas.android.com/apk/res/android' xmlns:tools="http://schemas.android.com/tools">
<uses-sdk android:minSdkVersion="21" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
</manifest>

0 comments on commit 7fc532b

Please sign in to comment.