Skip to content

Commit

Permalink
Don't crash if the app doesn't have Bluetooth permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Aug 21, 2018
1 parent ad1e3c2 commit b09b25f
Showing 1 changed file with 6 additions and 0 deletions.
Expand Up @@ -11,6 +11,7 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.hardware.usb.*;
import android.os.Handler;
import android.os.Looper;
Expand Down Expand Up @@ -316,6 +317,11 @@ protected void connectHIDDeviceUSB(UsbDevice usbDevice) {
protected void initializeBluetooth() {
Log.d(TAG, "Initializing Bluetooth");

if (mContext.getPackageManager().checkPermission(android.Manifest.permission.BLUETOOTH, mContext.getPackageName()) != PackageManager.PERMISSION_GRANTED) {
Log.d(TAG, "Couldn't initialize Bluetooth, missing android.permission.BLUETOOTH");
return;
}

// Find bonded bluetooth controllers and create SteamControllers for them
mBluetoothManager = (BluetoothManager)mContext.getSystemService(Context.BLUETOOTH_SERVICE);
if (mBluetoothManager == null) {
Expand Down

0 comments on commit b09b25f

Please sign in to comment.