Skip to content

Commit

Permalink
Merge pull request #280 from odemolliens/master
Browse files Browse the repository at this point in the history
Check bluetooth permission before we start to get device bluetooth name
  • Loading branch information
GantMan committed Jan 30, 2018
2 parents 275c64b + fcc08e3 commit f9a9652
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,21 @@ public String getCarrier() {

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());
Expand Down

0 comments on commit f9a9652

Please sign in to comment.