Commit fcc08e3d authored by Olivier Demolliens's avatar Olivier Demolliens

Check bluetooth permission before we start to get device bluetooth name

parent c1e93065
......@@ -140,15 +140,21 @@ public class RNDeviceModule extends ReactContextBaseJavaModule {
String deviceName = "Unknown";
try {
BluetoothAdapter myDevice = BluetoothAdapter.getDefaultAdapter();
if(myDevice!=null){
deviceName = myDevice.getName();
String permission = "android.permission.BLUETOOTH";
int res = this.reactContext.checkCallingOrSelfPermission(permission);
if (res == PackageManager.PERMISSION_GRANTED) {
try {
BluetoothAdapter myDevice = BluetoothAdapter.getDefaultAdapter();
if (myDevice != null) {
deviceName = myDevice.getName();
}
} catch (Exception e) {
e.printStackTrace();
}
} catch(Exception e) {
e.printStackTrace();
}
try {
if (Class.forName("com.google.android.gms.iid.InstanceID") != null) {
constants.put("instanceId", com.google.android.gms.iid.InstanceID.getInstance(this.reactContext).getId());
......
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