Browse Source

Fix device detection when an app is opened

master
meriadec 7 years ago
parent
commit
da77531eff
No known key found for this signature in database GPG Key ID: 1D2FC2305E2CB399
  1. 11
      src/internals/usb/devices.js
  2. 3
      src/internals/usb/manager/constants.js

11
src/internals/usb/devices.js

@ -38,8 +38,15 @@ export default (send: IPCSend) => ({
async function isValidHIDDevice(devicePath: string): Promise<boolean> {
try {
const transport: Transport<*> = await CommNodeHid.open(devicePath)
await transport.send(...APDUS.GET_FIRMWARE)
return true
try {
await transport.send(...APDUS.GET_FIRMWARE)
return true
} catch (err) {
// if we are inside an app, the first call should have failed,
// so we try this one
await transport.send(...APDUS.GET_FIRMWARE_FALLBACK)
return true
}
} catch (err) {
return false
}

3
src/internals/usb/manager/constants.js

@ -4,4 +4,7 @@ export const BASE_SOCKET_URL = 'ws://api.ledgerwallet.com/update/install'
// List of APDUS
export const APDUS = {
GET_FIRMWARE: [0xe0, 0x01, 0x00, 0x00],
// we dont have common call that works inside app & dashboard
// TODO: this should disappear.
GET_FIRMWARE_FALLBACK: [0xe0, 0xc4, 0x00, 0x00],
}

Loading…
Cancel
Save