public void openWhenClose(Master master, Slave slave, String key) { Permission p = slave.getPermission(this); if (p == null || !p.isValid()) { mPermissionsListener.error(BluetoothClient.DONT_HAVE_PERMISSION); return; } mBluetoothClient = BluetoothClient.getInstance(mContext, this); if (!mBluetoothClient.isSupported()) { mBluetoothListener.bluetoothNotSupported(); return; } else if (!mBluetoothClient.isEnabled()) { mBluetoothListener.enableBluetooth(); return; } mBluetoothClient.executeOpenDoorWhenClose(p.getKey(), master.getName(), slave.getId()); }