Skip to content

Commit

Permalink
Fix Ledger X disconnect event not being propagated
Browse files Browse the repository at this point in the history
  • Loading branch information
angelix committed Sep 17, 2021
1 parent 73d97ff commit 119c436
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 31 deletions.
Expand Up @@ -372,36 +372,9 @@ private void closeLedger(final HardwareConnectInteraction interaction, final BTC
private void doLogin(final HardwareConnectInteraction interaction) {
device.setHwWallet(mHwWallet);
interaction.onDeviceReady();

// mDisposables.add(Observable.just(interaction.getGreenSession())
// .observeOn(Schedulers.computation())
// .map((session) -> {
//
// //Bridge.INSTANCE.loginWithDevice(interaction.context(), interaction.getSession().getNativeSession(), network, bReConnectSession, mHwWallet, new HardwareCodeResolver(interaction, mHwWallet));
//
// return session;
// })
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe((session) -> {
// interaction.onLoginSuccess();
// }, (final Throwable e) -> {
// e.printStackTrace();
// interaction.getGreenSession().disconnect();
//
// // If the error is the Anti-Exfil validation violation we show that prominently.
// // Otherwise show a generic error and reconnect/retry message.
// final String idValidationFailed = interaction.context().getResources().getResourceEntryName(R.string.id_signature_validation_failed_if);
// if (idValidationFailed.equals(e.getMessage())) {
// interaction.showInstructions(R.string.id_signature_validation_failed_if);
// } else {
// interaction.showError(interaction.context().getString(R.string.id_error_logging_in_with_hardware));
// interaction.showInstructions(R.string.id_please_reconnect_your_hardware);
// }
// })
// );
}

public void onDestroy() {
mDisposables.dispose();
mDisposables.clear();
}
}
Expand Up @@ -90,12 +90,14 @@ public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState
} else if (newState == BluetoothProfile.STATE_DISCONNECTING) {
// Disconnect, clean up BLE stack resources
gatt.close();
}else if ( newState == BluetoothProfile.STATE_DISCONNECTED){
Log.i("LedgerBLEAdapter", "Send BLE disconnect event");
bleDisconnectEvent.onNext(true);
}
}

if (newState == BluetoothProfile.STATE_DISCONNECTED) {
Log.i("LedgerBLEAdapter", "Send BLE disconnect event");
bleDisconnectEvent.onNext(true);
}

ledgerDevice.getGattCallback().onConnectionStateChange(gatt, status, newState);
}
}
Expand Down

0 comments on commit 119c436

Please sign in to comment.