Unverified Commit f9a96527 authored by Gant Laborde's avatar Gant Laborde Committed by GitHub

Merge pull request #280 from odemolliens/master

Check bluetooth permission before we start to get device bluetooth name
parents 275c64b0 fcc08e3d
...@@ -147,14 +147,20 @@ public class RNDeviceModule extends ReactContextBaseJavaModule { ...@@ -147,14 +147,20 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
String deviceName = "Unknown"; String deviceName = "Unknown";
String permission = "android.permission.BLUETOOTH";
int res = this.reactContext.checkCallingOrSelfPermission(permission);
if (res == PackageManager.PERMISSION_GRANTED) {
try { try {
BluetoothAdapter myDevice = BluetoothAdapter.getDefaultAdapter(); BluetoothAdapter myDevice = BluetoothAdapter.getDefaultAdapter();
if(myDevice!=null){ if (myDevice != null) {
deviceName = myDevice.getName(); deviceName = myDevice.getName();
} }
} catch(Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
}
try { try {
if (Class.forName("com.google.android.gms.iid.InstanceID") != null) { if (Class.forName("com.google.android.gms.iid.InstanceID") != null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment