Pebble 2/LE: fix potential NPE

here
Andreas Shimokawa 2016-12-01 00:20:21 +01:00
parent 74c20f3a82
commit 2993bb6b5c
2 changed files with 7 additions and 4 deletions

View File

@ -40,6 +40,9 @@ class PebbleGATTServer extends BluetoothGattServerCallback {
BluetoothManager bluetoothManager = (BluetoothManager) mContext.getSystemService(Context.BLUETOOTH_SERVICE);
mBluetoothGattServer = bluetoothManager.openGattServer(mContext, this);
if (mBluetoothGattServer == null) {
return false;
}
BluetoothGattService pebbleGATTService = new BluetoothGattService(SERVER_SERVICE, BluetoothGattService.SERVICE_TYPE_PRIMARY);
pebbleGATTService.addCharacteristic(new BluetoothGattCharacteristic(READ_CHARACTERISTICS, BluetoothGattCharacteristic.PROPERTY_READ, BluetoothGattCharacteristic.PERMISSION_READ));

View File

@ -33,10 +33,10 @@ public class PebbleLESupport {
}
mPebbleGATTServer = new PebbleGATTServer(this, context, mBtDevice);
mPebbleGATTServer.initialize();
mPebbleGATTClient = new PebbleGATTClient(this, context, mBtDevice);
mPebbleGATTClient.initialize();
if (mPebbleGATTServer.initialize()) {
mPebbleGATTClient = new PebbleGATTClient(this, context, mBtDevice);
mPebbleGATTClient.initialize();
}
}
void writeToPipedOutputStream(byte[] value, int offset, int count) {