@onekeyfe/hd-core 1.1.34-alpha.3 → 1.1.34-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__tests__/DeviceCommands.test.ts +0 -217
- package/__tests__/evmLedgerLegacySafety.test.ts +4 -15
- package/__tests__/evmSignTransaction.test.ts +1 -1
- package/__tests__/evmSignTypedData.test.ts +1 -1
- package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +31 -48
- package/__tests__/preInitialize.test.ts +0 -33
- package/dist/api/BaseMethod.d.ts +0 -12
- package/dist/api/BaseMethod.d.ts.map +1 -1
- package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
- package/dist/api/CheckBootloaderRelease.d.ts.map +1 -1
- package/dist/api/CheckFirmwareRelease.d.ts.map +1 -1
- package/dist/api/FirmwareUpdate.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts +3 -14
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts +3 -10
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/GetFeatures.d.ts +1 -1
- package/dist/api/GetFeatures.d.ts.map +1 -1
- package/dist/api/GetOnekeyFeatures.d.ts.map +1 -1
- package/dist/api/GetPassphraseState.d.ts.map +1 -1
- package/dist/api/PromptWebDeviceAccess.d.ts.map +1 -1
- package/dist/api/SearchDevices.d.ts +1 -5
- package/dist/api/SearchDevices.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumGetAddress.d.ts +6 -2
- package/dist/api/alephium/AlephiumGetAddress.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumSignMessage.d.ts +5 -2
- package/dist/api/alephium/AlephiumSignMessage.d.ts.map +1 -1
- package/dist/api/alephium/AlephiumSignTransaction.d.ts +8 -5
- package/dist/api/alephium/AlephiumSignTransaction.d.ts.map +1 -1
- package/dist/api/allnetwork/AllNetworkGetAddressBase.d.ts.map +1 -1
- package/dist/api/aptos/AptosGetAddress.d.ts.map +1 -1
- package/dist/api/benfen/BenfenGetAddress.d.ts +9 -2
- package/dist/api/benfen/BenfenGetAddress.d.ts.map +1 -1
- package/dist/api/benfen/BenfenGetPublicKey.d.ts +9 -2
- package/dist/api/benfen/BenfenGetPublicKey.d.ts.map +1 -1
- package/dist/api/benfen/BenfenSignMessage.d.ts +8 -2
- package/dist/api/benfen/BenfenSignMessage.d.ts.map +1 -1
- package/dist/api/benfen/BenfenSignTransaction.d.ts +8 -2
- package/dist/api/benfen/BenfenSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCGetAddress.d.ts +11 -1
- package/dist/api/btc/BTCGetAddress.d.ts.map +1 -1
- package/dist/api/btc/BTCGetPublicKey.d.ts +11 -1
- package/dist/api/btc/BTCGetPublicKey.d.ts.map +1 -1
- package/dist/api/btc/BTCSignMessage.d.ts +15 -1
- package/dist/api/btc/BTCSignMessage.d.ts.map +1 -1
- package/dist/api/btc/BTCSignPsbt.d.ts.map +1 -1
- package/dist/api/btc/BTCSignTransaction.d.ts +11 -1
- package/dist/api/btc/BTCSignTransaction.d.ts.map +1 -1
- package/dist/api/btc/BTCVerifyMessage.d.ts +11 -1
- package/dist/api/btc/BTCVerifyMessage.d.ts.map +1 -1
- package/dist/api/btc/helpers/versionLimit.d.ts +11 -2
- package/dist/api/btc/helpers/versionLimit.d.ts.map +1 -1
- package/dist/api/cardano/CardanoSignTransaction.d.ts.map +1 -1
- package/dist/api/conflux/ConfluxSignTransaction.d.ts.map +1 -1
- package/dist/api/device/DeviceCancel.d.ts.map +1 -1
- package/dist/api/device/DeviceChangePin.d.ts.map +1 -1
- package/dist/api/device/DeviceFullyUploadResource.d.ts +2 -1
- package/dist/api/device/DeviceFullyUploadResource.d.ts.map +1 -1
- package/dist/api/device/DeviceLock.d.ts.map +1 -1
- package/dist/api/device/DeviceRebootToBoardloader.d.ts +1 -1
- package/dist/api/device/DeviceRebootToBoardloader.d.ts.map +1 -1
- package/dist/api/device/DeviceRebootToBootloader.d.ts.map +1 -1
- package/dist/api/device/DeviceSettings.d.ts.map +1 -1
- package/dist/api/device/DeviceSupportFeatures.d.ts.map +1 -1
- package/dist/api/device/DeviceUnlock.d.ts +1 -1
- package/dist/api/device/DeviceUnlock.d.ts.map +1 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts +1 -7
- package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
- package/dist/api/device/DeviceUploadResource.d.ts.map +1 -1
- package/dist/api/device/DeviceVerify.d.ts.map +1 -1
- package/dist/api/device/DeviceWipe.d.ts.map +1 -1
- package/dist/api/dynex/DnxGetAddress.d.ts.map +1 -1
- package/dist/api/dynex/DnxSignTransaction.d.ts.map +1 -1
- package/dist/api/evm/EVMGetPublicKey.d.ts.map +1 -1
- package/dist/api/evm/EVMSignMessageEIP712.d.ts +8 -2
- package/dist/api/evm/EVMSignMessageEIP712.d.ts.map +1 -1
- package/dist/api/evm/EVMSignTypedData.d.ts.map +1 -1
- package/dist/api/evm/latest/signTypedData.d.ts +1 -1
- package/dist/api/evm/latest/signTypedData.d.ts.map +1 -1
- package/dist/api/evm/latest/signTypedHash.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/getAddress.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/getPublicKey.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/signMessage.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/signTypedData.d.ts +1 -1
- package/dist/api/evm/legacyV1/signTypedData.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/signTypedHash.d.ts.map +1 -1
- package/dist/api/evm/legacyV1/verifyMessage.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts +1 -10
- package/dist/api/firmware/FirmwareUpdateBaseMethod.d.ts.map +1 -1
- package/dist/api/firmware/bootloaderHelper.d.ts.map +1 -1
- package/dist/api/firmware/getBinary.d.ts +0 -11
- package/dist/api/firmware/getBinary.d.ts.map +1 -1
- package/dist/api/firmware/updateBootloader.d.ts +0 -2
- package/dist/api/firmware/updateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/uploadFirmware.d.ts +1 -9
- package/dist/api/firmware/uploadFirmware.d.ts.map +1 -1
- package/dist/api/helpers/batchGetPublickeys.d.ts +0 -3
- package/dist/api/helpers/batchGetPublickeys.d.ts.map +1 -1
- package/dist/api/index.d.ts +0 -29
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/kaspa/KaspaSignTransaction.d.ts.map +1 -1
- package/dist/api/lightning/LnurlAuth.d.ts +0 -4
- package/dist/api/lightning/LnurlAuth.d.ts.map +1 -1
- package/dist/api/neo/NeoGetAddress.d.ts +8 -2
- package/dist/api/neo/NeoGetAddress.d.ts.map +1 -1
- package/dist/api/neo/NeoSignTransaction.d.ts +8 -2
- package/dist/api/neo/NeoSignTransaction.d.ts.map +1 -1
- package/dist/api/nervos/NervosGetAddress.d.ts +9 -2
- package/dist/api/nervos/NervosGetAddress.d.ts.map +1 -1
- package/dist/api/nervos/NervosSignTransaction.d.ts +12 -9
- package/dist/api/nervos/NervosSignTransaction.d.ts.map +1 -1
- package/dist/api/nexa/NexaGetAddress.d.ts +8 -2
- package/dist/api/nexa/NexaGetAddress.d.ts.map +1 -1
- package/dist/api/nexa/NexaSignTransaction.d.ts +9 -2
- package/dist/api/nexa/NexaSignTransaction.d.ts.map +1 -1
- package/dist/api/polkadot/PolkadotGetAddress.d.ts +0 -3
- package/dist/api/polkadot/PolkadotGetAddress.d.ts.map +1 -1
- package/dist/api/polkadot/networks.d.ts +0 -3
- package/dist/api/polkadot/networks.d.ts.map +1 -1
- package/dist/api/scdo/ScdoGetAddress.d.ts +6 -2
- package/dist/api/scdo/ScdoGetAddress.d.ts.map +1 -1
- package/dist/api/scdo/ScdoSignMessage.d.ts +5 -2
- package/dist/api/scdo/ScdoSignMessage.d.ts.map +1 -1
- package/dist/api/scdo/ScdoSignTransaction.d.ts +5 -2
- package/dist/api/scdo/ScdoSignTransaction.d.ts.map +1 -1
- package/dist/api/solana/SolGetAddress.d.ts +0 -1
- package/dist/api/solana/SolGetAddress.d.ts.map +1 -1
- package/dist/api/solana/SolSignMessage.d.ts +0 -3
- package/dist/api/solana/SolSignMessage.d.ts.map +1 -1
- package/dist/api/solana/SolSignOffchainMessage.d.ts +0 -3
- package/dist/api/solana/SolSignOffchainMessage.d.ts.map +1 -1
- package/dist/api/solana/SolSignTransaction.d.ts +0 -6
- package/dist/api/solana/SolSignTransaction.d.ts.map +1 -1
- package/dist/api/stellar/StellarGetAddress.d.ts +1 -2
- package/dist/api/stellar/StellarGetAddress.d.ts.map +1 -1
- package/dist/api/stellar/StellarSignTransaction.d.ts +2 -3
- package/dist/api/stellar/StellarSignTransaction.d.ts.map +1 -1
- package/dist/api/sui/SuiGetAddress.d.ts +0 -3
- package/dist/api/sui/SuiGetAddress.d.ts.map +1 -1
- package/dist/api/sui/SuiGetPublicKey.d.ts +0 -3
- package/dist/api/sui/SuiGetPublicKey.d.ts.map +1 -1
- package/dist/api/sui/SuiSignMessage.d.ts +0 -3
- package/dist/api/sui/SuiSignMessage.d.ts.map +1 -1
- package/dist/api/sui/SuiSignTransaction.d.ts +2 -5
- package/dist/api/sui/SuiSignTransaction.d.ts.map +1 -1
- package/dist/api/ton/TonGetAddress.d.ts +0 -3
- package/dist/api/ton/TonGetAddress.d.ts.map +1 -1
- package/dist/api/ton/TonSignData.d.ts +0 -1
- package/dist/api/ton/TonSignData.d.ts.map +1 -1
- package/dist/api/ton/TonSignMessage.d.ts +0 -3
- package/dist/api/ton/TonSignMessage.d.ts.map +1 -1
- package/dist/api/ton/TonSignProof.d.ts +0 -3
- package/dist/api/ton/TonSignProof.d.ts.map +1 -1
- package/dist/api/tron/TronSignMessage.d.ts +0 -3
- package/dist/api/tron/TronSignMessage.d.ts.map +1 -1
- package/dist/api/tron/TronSignTransaction.d.ts +0 -3
- package/dist/api/tron/TronSignTransaction.d.ts.map +1 -1
- package/dist/api/utils.d.ts +1 -2
- package/dist/api/utils.d.ts.map +1 -1
- package/dist/constants/index.d.ts +1 -2
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/core/RequestQueue.d.ts +1 -19
- package/dist/core/RequestQueue.d.ts.map +1 -1
- package/dist/core/index.d.ts +1 -4
- package/dist/core/index.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +5 -9
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/data-manager/MessagesConfig.d.ts +2 -2
- package/dist/data-manager/MessagesConfig.d.ts.map +1 -1
- package/dist/data-manager/TransportManager.d.ts +4 -5
- package/dist/data-manager/TransportManager.d.ts.map +1 -1
- package/dist/data-manager/connectSettings.d.ts.map +1 -1
- package/dist/device/Device.d.ts +16 -60
- package/dist/device/Device.d.ts.map +1 -1
- package/dist/device/DeviceCommands.d.ts +14 -16
- package/dist/device/DeviceCommands.d.ts.map +1 -1
- package/dist/device/DeviceConnector.d.ts +1 -2
- package/dist/device/DeviceConnector.d.ts.map +1 -1
- package/dist/device/DevicePool.d.ts +2 -4
- package/dist/device/DevicePool.d.ts.map +1 -1
- package/dist/events/call.d.ts +0 -7
- package/dist/events/call.d.ts.map +1 -1
- package/dist/events/core.d.ts +2 -2
- package/dist/events/core.d.ts.map +1 -1
- package/dist/events/device.d.ts +2 -11
- package/dist/events/device.d.ts.map +1 -1
- package/dist/events/iframe.d.ts +0 -1
- package/dist/events/iframe.d.ts.map +1 -1
- package/dist/events/logBlockEvent.d.ts +0 -1
- package/dist/events/logBlockEvent.d.ts.map +1 -1
- package/dist/events/ui-request.d.ts +2 -26
- package/dist/events/ui-request.d.ts.map +1 -1
- package/dist/index.d.ts +451 -1797
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5556 -26855
- package/dist/inject.d.ts +2 -3
- package/dist/inject.d.ts.map +1 -1
- package/dist/lowLevelInject.d.ts +1 -2
- package/dist/lowLevelInject.d.ts.map +1 -1
- package/dist/topLevelInject.d.ts.map +1 -1
- package/dist/types/api/checkAllFirmwareRelease.d.ts +2 -4
- package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/deviceSettings.d.ts +0 -9
- package/dist/types/api/deviceSettings.d.ts.map +1 -1
- package/dist/types/api/deviceUnlock.d.ts +1 -1
- package/dist/types/api/deviceUnlock.d.ts.map +1 -1
- package/dist/types/api/deviceUpdateBootloader.d.ts +1 -6
- package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
- package/dist/types/api/export.d.ts +1 -4
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +1 -114
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/getFeatures.d.ts.map +1 -1
- package/dist/types/api/getOnekeyFeatures.d.ts.map +1 -1
- package/dist/types/api/getPassphraseState.d.ts +1 -2
- package/dist/types/api/getPassphraseState.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +2 -48
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/searchDevices.d.ts +2 -2
- package/dist/types/api/searchDevices.d.ts.map +1 -1
- package/dist/types/device.d.ts +5 -207
- package/dist/types/device.d.ts.map +1 -1
- package/dist/types/params.d.ts +0 -3
- package/dist/types/params.d.ts.map +1 -1
- package/dist/types/settings.d.ts +0 -33
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/capabilitieUtils.d.ts.map +1 -1
- package/dist/utils/deviceFeaturesUtils.d.ts +9 -17
- package/dist/utils/deviceFeaturesUtils.d.ts.map +1 -1
- package/dist/utils/deviceInfoUtils.d.ts +8 -10
- package/dist/utils/deviceInfoUtils.d.ts.map +1 -1
- package/dist/utils/deviceSettings.d.ts +0 -2
- package/dist/utils/deviceSettings.d.ts.map +1 -1
- package/dist/utils/deviceVersionUtils.d.ts +5 -6
- package/dist/utils/deviceVersionUtils.d.ts.map +1 -1
- package/dist/utils/findDefectiveBatchDevice.d.ts +1 -1
- package/dist/utils/homescreen.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -3
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/dist/utils/tracing.d.ts.map +1 -1
- package/dist/utils/versionUtils.d.ts +1 -1
- package/package.json +4 -4
- package/src/api/BaseMethod.ts +23 -60
- package/src/api/CheckAllFirmwareRelease.ts +3 -16
- package/src/api/CheckBootloaderRelease.ts +2 -1
- package/src/api/CheckFirmwareRelease.ts +2 -1
- package/src/api/FirmwareUpdate.ts +7 -15
- package/src/api/FirmwareUpdateV2.ts +148 -354
- package/src/api/FirmwareUpdateV3.ts +62 -376
- package/src/api/GetFeatures.ts +4 -12
- package/src/api/GetOnekeyFeatures.ts +3 -15
- package/src/api/GetPassphraseState.ts +10 -9
- package/src/api/PromptWebDeviceAccess.ts +1 -10
- package/src/api/SearchDevices.ts +3 -33
- package/src/api/alephium/AlephiumGetAddress.ts +2 -6
- package/src/api/alephium/AlephiumSignMessage.ts +1 -6
- package/src/api/alephium/AlephiumSignTransaction.ts +4 -15
- package/src/api/allnetwork/AllNetworkGetAddressBase.ts +21 -25
- package/src/api/aptos/AptosGetAddress.ts +3 -2
- package/src/api/benfen/BenfenGetAddress.ts +7 -11
- package/src/api/benfen/BenfenGetPublicKey.ts +2 -6
- package/src/api/benfen/BenfenSignMessage.ts +1 -6
- package/src/api/benfen/BenfenSignTransaction.ts +1 -6
- package/src/api/btc/BTCGetPublicKey.ts +2 -3
- package/src/api/btc/BTCSignPsbt.ts +2 -1
- package/src/api/btc/helpers/versionLimit.ts +1 -7
- package/src/api/cardano/CardanoSignTransaction.ts +4 -2
- package/src/api/conflux/ConfluxSignTransaction.ts +2 -5
- package/src/api/device/DeviceCancel.ts +0 -1
- package/src/api/device/DeviceChangePin.ts +0 -24
- package/src/api/device/DeviceFullyUploadResource.ts +7 -6
- package/src/api/device/DeviceLock.ts +3 -2
- package/src/api/device/DeviceRebootToBoardloader.ts +1 -11
- package/src/api/device/DeviceRebootToBootloader.ts +1 -11
- package/src/api/device/DeviceSettings.ts +0 -121
- package/src/api/device/DeviceSupportFeatures.ts +13 -2
- package/src/api/device/DeviceUnlock.ts +0 -9
- package/src/api/device/DeviceUpdateBootloader.ts +11 -175
- package/src/api/device/DeviceUploadResource.ts +5 -4
- package/src/api/device/DeviceVerify.ts +2 -1
- package/src/api/device/DeviceWipe.ts +0 -19
- package/src/api/dynex/DnxGetAddress.ts +0 -6
- package/src/api/dynex/DnxSignTransaction.ts +0 -6
- package/src/api/evm/EVMGetAddress.ts +1 -1
- package/src/api/evm/EVMGetPublicKey.ts +4 -3
- package/src/api/evm/EVMSignMessage.ts +1 -1
- package/src/api/evm/EVMSignMessageEIP712.ts +1 -14
- package/src/api/evm/EVMSignTransaction.ts +1 -1
- package/src/api/evm/EVMSignTypedData.ts +18 -30
- package/src/api/evm/EVMVerifyMessage.ts +1 -1
- package/src/api/evm/latest/signTypedHash.ts +4 -2
- package/src/api/evm/legacyV1/getAddress.ts +3 -5
- package/src/api/evm/legacyV1/getPublicKey.ts +3 -5
- package/src/api/evm/legacyV1/signMessage.ts +3 -5
- package/src/api/evm/legacyV1/signTypedData.ts +8 -9
- package/src/api/evm/legacyV1/signTypedHash.ts +7 -7
- package/src/api/evm/legacyV1/verifyMessage.ts +3 -5
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +15 -83
- package/src/api/firmware/bootloaderHelper.ts +2 -3
- package/src/api/firmware/getBinary.ts +1 -1
- package/src/api/firmware/releaseHelper.ts +3 -3
- package/src/api/firmware/updateBootloader.ts +4 -19
- package/src/api/firmware/uploadFirmware.ts +34 -148
- package/src/api/helpers/batchGetPublickeys.ts +6 -51
- package/src/api/index.ts +0 -32
- package/src/api/kaspa/KaspaSignTransaction.ts +3 -2
- package/src/api/lightning/LnurlAuth.ts +0 -4
- package/src/api/neo/NeoGetAddress.ts +1 -6
- package/src/api/neo/NeoSignTransaction.ts +1 -6
- package/src/api/nervos/NervosGetAddress.ts +2 -6
- package/src/api/nervos/NervosSignTransaction.ts +4 -14
- package/src/api/nexa/NexaGetAddress.ts +2 -6
- package/src/api/nexa/NexaSignTransaction.ts +12 -11
- package/src/api/polkadot/networks.ts +0 -9
- package/src/api/scdo/ScdoGetAddress.ts +2 -6
- package/src/api/scdo/ScdoSignMessage.ts +1 -6
- package/src/api/scdo/ScdoSignTransaction.ts +2 -6
- package/src/api/solana/SolGetAddress.ts +0 -4
- package/src/api/solana/SolSignMessage.ts +0 -3
- package/src/api/solana/SolSignOffchainMessage.ts +0 -3
- package/src/api/solana/SolSignTransaction.ts +0 -6
- package/src/api/stellar/StellarGetAddress.ts +1 -10
- package/src/api/stellar/StellarSignTransaction.ts +1 -14
- package/src/api/sui/SuiGetAddress.ts +3 -5
- package/src/api/sui/SuiGetPublicKey.ts +0 -3
- package/src/api/sui/SuiSignMessage.ts +0 -3
- package/src/api/sui/SuiSignTransaction.ts +12 -14
- package/src/api/ton/TonGetAddress.ts +0 -3
- package/src/api/ton/TonSignData.ts +3 -6
- package/src/api/ton/TonSignMessage.ts +5 -6
- package/src/api/ton/TonSignProof.ts +0 -3
- package/src/api/tron/TronSignMessage.ts +1 -4
- package/src/api/tron/TronSignTransaction.ts +0 -3
- package/src/api/utils.ts +3 -7
- package/src/api/xrp/XrpSignTransaction.ts +1 -1
- package/src/constants/index.ts +1 -7
- package/src/core/RequestQueue.ts +4 -124
- package/src/core/index.ts +116 -255
- package/src/data-manager/DataManager.ts +49 -61
- package/src/data-manager/MessagesConfig.ts +14 -14
- package/src/data-manager/TransportManager.ts +12 -38
- package/src/data-manager/connectSettings.ts +0 -15
- package/src/device/Device.ts +164 -759
- package/src/device/DeviceCommands.ts +36 -245
- package/src/device/DeviceConnector.ts +4 -29
- package/src/device/DevicePool.ts +21 -69
- package/src/events/call.ts +0 -6
- package/src/events/core.ts +0 -2
- package/src/events/device.ts +1 -17
- package/src/events/iframe.ts +0 -1
- package/src/events/logBlockEvent.ts +0 -30
- package/src/events/ui-request.ts +2 -32
- package/src/index.ts +0 -9
- package/src/inject.ts +3 -75
- package/src/lowLevelInject.ts +1 -8
- package/src/topLevelInject.ts +1 -7
- package/src/types/api/checkAllFirmwareRelease.ts +2 -4
- package/src/types/api/deviceSettings.ts +0 -9
- package/src/types/api/deviceUnlock.ts +1 -1
- package/src/types/api/deviceUpdateBootloader.ts +1 -10
- package/src/types/api/export.ts +0 -25
- package/src/types/api/firmwareUpdate.ts +1 -163
- package/src/types/api/getFeatures.ts +0 -3
- package/src/types/api/getOnekeyFeatures.ts +0 -3
- package/src/types/api/getPassphraseState.ts +2 -10
- package/src/types/api/index.ts +2 -89
- package/src/types/api/searchDevices.ts +2 -2
- package/src/types/device.ts +5 -266
- package/src/types/params.ts +0 -11
- package/src/types/settings.ts +29 -54
- package/src/utils/capabilitieUtils.ts +2 -1
- package/src/utils/deviceFeaturesUtils.ts +84 -122
- package/src/utils/deviceInfoUtils.ts +87 -38
- package/src/utils/deviceSettings.ts +0 -48
- package/src/utils/deviceVersionUtils.ts +62 -25
- package/src/utils/findDefectiveBatchDevice.ts +8 -8
- package/src/utils/homescreen.ts +0 -10
- package/src/utils/index.ts +0 -4
- package/src/utils/tracing.ts +1 -3
- package/__tests__/AllNetworkGetAddressBase.tracing.test.ts +0 -75
- package/__tests__/RequestQueue.test.ts +0 -140
- package/__tests__/UploadPortfolio.test.ts +0 -46
- package/__tests__/connectSettings.test.ts +0 -61
- package/__tests__/device-lifecycle-events.test.ts +0 -117
- package/__tests__/device-pool-state.test.ts +0 -132
- package/__tests__/device-settings.test.ts +0 -286
- package/__tests__/device-state-mapper.test.ts +0 -229
- package/__tests__/device-utils.test.ts +0 -106
- package/__tests__/device-wallet-session-store.test.ts +0 -191
- package/__tests__/filesystemValidation.test.ts +0 -53
- package/__tests__/firmware-update/firmware-artifact-source.test.ts +0 -119
- package/__tests__/firmware-update/firmware-checkpoint.test.ts +0 -105
- package/__tests__/firmware-update/firmware-host-binding.test.ts +0 -73
- package/__tests__/firmware-update/firmware-update-capabilities.test.ts +0 -17
- package/__tests__/firmware-update/firmware-update-plan.test.ts +0 -358
- package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +0 -200
- package/__tests__/firmware-update/firmware-update-recovery.test.ts +0 -81
- package/__tests__/firmware-update/firmware-upload-source.test.ts +0 -70
- package/__tests__/get-device-state.test.ts +0 -403
- package/__tests__/logBlockEvent.test.ts +0 -61
- package/__tests__/logger.test.ts +0 -34
- package/__tests__/open-wallet-session.test.ts +0 -565
- package/__tests__/pro2Wallpaper.test.ts +0 -39
- package/__tests__/protocol-v2-bootloader-mode.test.ts +0 -37
- package/__tests__/protocol-v2-firmware-targets.test.ts +0 -19
- package/__tests__/protocol-v2.test.ts +0 -6008
- package/__tests__/protocolV2FileWrite.test.ts +0 -67
- package/__tests__/public-pro2-api-boundary.test.ts +0 -66
- package/__tests__/search-devices.test.ts +0 -136
- package/dist/api/ClearSessionCache.d.ts +0 -9
- package/dist/api/ClearSessionCache.d.ts.map +0 -1
- package/dist/api/DirList.d.ts +0 -10
- package/dist/api/DirList.d.ts.map +0 -1
- package/dist/api/DirMake.d.ts +0 -9
- package/dist/api/DirMake.d.ts.map +0 -1
- package/dist/api/DirRemove.d.ts +0 -9
- package/dist/api/DirRemove.d.ts.map +0 -1
- package/dist/api/FileDelete.d.ts +0 -9
- package/dist/api/FileDelete.d.ts.map +0 -1
- package/dist/api/FileRead.d.ts +0 -19
- package/dist/api/FileRead.d.ts.map +0 -1
- package/dist/api/FileWrite.d.ts +0 -25
- package/dist/api/FileWrite.d.ts.map +0 -1
- package/dist/api/FirmwareUpdateV4.d.ts +0 -75
- package/dist/api/FirmwareUpdateV4.d.ts.map +0 -1
- package/dist/api/GetDeviceState.d.ts +0 -7
- package/dist/api/GetDeviceState.d.ts.map +0 -1
- package/dist/api/OpenWalletSession.d.ts +0 -14
- package/dist/api/OpenWalletSession.d.ts.map +0 -1
- package/dist/api/PathInfo.d.ts +0 -10
- package/dist/api/PathInfo.d.ts.map +0 -1
- package/dist/api/UploadPortfolio.d.ts +0 -18
- package/dist/api/UploadPortfolio.d.ts.map +0 -1
- package/dist/api/firmware/FirmwareArtifactSource.d.ts +0 -26
- package/dist/api/firmware/FirmwareArtifactSource.d.ts.map +0 -1
- package/dist/api/firmware/FirmwareCheckpoint.d.ts +0 -15
- package/dist/api/firmware/FirmwareCheckpoint.d.ts.map +0 -1
- package/dist/api/firmware/FirmwareHostBinding.d.ts +0 -6
- package/dist/api/firmware/FirmwareHostBinding.d.ts.map +0 -1
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts +0 -3
- package/dist/api/firmware/FirmwareUpdateCapabilities.d.ts.map +0 -1
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts +0 -29
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +0 -1
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts +0 -25
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +0 -1
- package/dist/api/firmware/progressThrottle.d.ts +0 -3
- package/dist/api/firmware/progressThrottle.d.ts.map +0 -1
- package/dist/api/helpers/filesystemValidation.d.ts +0 -10
- package/dist/api/helpers/filesystemValidation.d.ts.map +0 -1
- package/dist/api/helpers/protocolV2FileWrite.d.ts +0 -33
- package/dist/api/helpers/protocolV2FileWrite.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts +0 -6
- package/dist/api/protocol-v2/DeviceFactoryInfoGet.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts +0 -7
- package/dist/api/protocol-v2/DeviceFactoryInfoSet.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts +0 -7
- package/dist/api/protocol-v2/DeviceFirmwareUpdate.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts +0 -7
- package/dist/api/protocol-v2/DeviceGetFirmwareUpdateStatus.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts +0 -6
- package/dist/api/protocol-v2/DeviceGetOnboardingStatus.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceInfoGet.d.ts +0 -28
- package/dist/api/protocol-v2/DeviceInfoGet.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceReboot.d.ts +0 -7
- package/dist/api/protocol-v2/DeviceReboot.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceSessionOpen.d.ts +0 -28
- package/dist/api/protocol-v2/DeviceSessionOpen.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceSettingsGet.d.ts +0 -6
- package/dist/api/protocol-v2/DeviceSettingsGet.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceSettingsPageShow.d.ts +0 -16
- package/dist/api/protocol-v2/DeviceSettingsPageShow.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceSettingsSet.d.ts +0 -12
- package/dist/api/protocol-v2/DeviceSettingsSet.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceStatusGet.d.ts +0 -6
- package/dist/api/protocol-v2/DeviceStatusGet.d.ts.map +0 -1
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts +0 -26
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +0 -1
- package/dist/api/protocol-v2/FilesystemFormat.d.ts +0 -6
- package/dist/api/protocol-v2/FilesystemFormat.d.ts.map +0 -1
- package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts +0 -6
- package/dist/api/protocol-v2/FilesystemPermissionFix.d.ts.map +0 -1
- package/dist/api/protocol-v2/Ping.d.ts +0 -8
- package/dist/api/protocol-v2/Ping.d.ts.map +0 -1
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts +0 -6
- package/dist/api/protocol-v2/ProtocolInfoRequest.d.ts.map +0 -1
- package/dist/api/protocol-v2/helpers.d.ts +0 -42
- package/dist/api/protocol-v2/helpers.d.ts.map +0 -1
- package/dist/core/deviceEventRegistration.d.ts +0 -11
- package/dist/core/deviceEventRegistration.d.ts.map +0 -1
- package/dist/device/DeviceFeaturesState.d.ts +0 -4
- package/dist/device/DeviceFeaturesState.d.ts.map +0 -1
- package/dist/device/DeviceStateMapper.d.ts +0 -13
- package/dist/device/DeviceStateMapper.d.ts.map +0 -1
- package/dist/device/DeviceStateProjector.d.ts +0 -7
- package/dist/device/DeviceStateProjector.d.ts.map +0 -1
- package/dist/device/DeviceStateStore.d.ts +0 -21
- package/dist/device/DeviceStateStore.d.ts.map +0 -1
- package/dist/device/DeviceWalletSessionStore.d.ts +0 -15
- package/dist/device/DeviceWalletSessionStore.d.ts.map +0 -1
- package/dist/device/cloneDeviceState.d.ts +0 -2
- package/dist/device/cloneDeviceState.d.ts.map +0 -1
- package/dist/device/deviceIdentity.d.ts +0 -5
- package/dist/device/deviceIdentity.d.ts.map +0 -1
- package/dist/deviceProfile/buildDeviceFeatures.d.ts +0 -12
- package/dist/deviceProfile/buildDeviceFeatures.d.ts.map +0 -1
- package/dist/deviceProfile/index.d.ts +0 -2
- package/dist/deviceProfile/index.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/deviceSession.d.ts +0 -7
- package/dist/protocols/protocol-v2/deviceSession.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/features.d.ts +0 -88
- package/dist/protocols/protocol-v2/features.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/firmware.d.ts +0 -15
- package/dist/protocols/protocol-v2/firmware.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/index.d.ts +0 -5
- package/dist/protocols/protocol-v2/index.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/lockedError.d.ts +0 -2
- package/dist/protocols/protocol-v2/lockedError.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/settingsUnlockPolicy.d.ts +0 -16
- package/dist/protocols/protocol-v2/settingsUnlockPolicy.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/uiInteraction.d.ts +0 -39
- package/dist/protocols/protocol-v2/uiInteraction.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/unlockRetry.d.ts +0 -11
- package/dist/protocols/protocol-v2/unlockRetry.d.ts.map +0 -1
- package/dist/protocols/protocol-v2/walletSession.d.ts +0 -21
- package/dist/protocols/protocol-v2/walletSession.d.ts.map +0 -1
- package/dist/types/api/firmwareUpdateCapabilities.d.ts +0 -13
- package/dist/types/api/firmwareUpdateCapabilities.d.ts.map +0 -1
- package/dist/types/api/firmwareUpdatePlan.d.ts +0 -35
- package/dist/types/api/firmwareUpdatePlan.d.ts.map +0 -1
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts +0 -43
- package/dist/types/api/firmwareUpdatePreparedPlan.d.ts.map +0 -1
- package/dist/types/api/getDeviceState.d.ts +0 -12
- package/dist/types/api/getDeviceState.d.ts.map +0 -1
- package/dist/types/api/openWalletSession.d.ts +0 -35
- package/dist/types/api/openWalletSession.d.ts.map +0 -1
- package/dist/types/api/protocolV2.d.ts +0 -113
- package/dist/types/api/protocolV2.d.ts.map +0 -1
- package/dist/types/api/sessionCache.d.ts +0 -10
- package/dist/types/api/sessionCache.d.ts.map +0 -1
- package/dist/utils/deviceFeaturesCompat.d.ts +0 -13
- package/dist/utils/deviceFeaturesCompat.d.ts.map +0 -1
- package/dist/utils/pro2Wallpaper.d.ts +0 -12
- package/dist/utils/pro2Wallpaper.d.ts.map +0 -1
- package/src/api/ClearSessionCache.ts +0 -28
- package/src/api/DirList.ts +0 -33
- package/src/api/DirMake.ts +0 -23
- package/src/api/DirRemove.ts +0 -23
- package/src/api/FileDelete.ts +0 -23
- package/src/api/FileRead.ts +0 -183
- package/src/api/FileWrite.ts +0 -71
- package/src/api/FirmwareUpdateV4.ts +0 -2279
- package/src/api/GetDeviceState.ts +0 -55
- package/src/api/OpenWalletSession.ts +0 -211
- package/src/api/PathInfo.ts +0 -41
- package/src/api/UploadPortfolio.ts +0 -50
- package/src/api/firmware/FirmwareArtifactSource.ts +0 -278
- package/src/api/firmware/FirmwareCheckpoint.ts +0 -188
- package/src/api/firmware/FirmwareHostBinding.ts +0 -108
- package/src/api/firmware/FirmwareUpdateCapabilities.ts +0 -13
- package/src/api/firmware/FirmwareUpdatePlan.ts +0 -729
- package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +0 -403
- package/src/api/firmware/progressThrottle.ts +0 -44
- package/src/api/helpers/filesystemValidation.ts +0 -112
- package/src/api/helpers/protocolV2FileWrite.ts +0 -193
- package/src/api/protocol-v2/DeviceFactoryInfoGet.ts +0 -20
- package/src/api/protocol-v2/DeviceFactoryInfoSet.ts +0 -32
- package/src/api/protocol-v2/DeviceFirmwareUpdate.ts +0 -61
- package/src/api/protocol-v2/DeviceGetFirmwareUpdateStatus.ts +0 -55
- package/src/api/protocol-v2/DeviceGetOnboardingStatus.ts +0 -18
- package/src/api/protocol-v2/DeviceInfoGet.ts +0 -145
- package/src/api/protocol-v2/DeviceReboot.ts +0 -26
- package/src/api/protocol-v2/DeviceSessionOpen.ts +0 -102
- package/src/api/protocol-v2/DeviceSettingsGet.ts +0 -18
- package/src/api/protocol-v2/DeviceSettingsPageShow.ts +0 -70
- package/src/api/protocol-v2/DeviceSettingsSet.ts +0 -44
- package/src/api/protocol-v2/DeviceStatusGet.ts +0 -16
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +0 -131
- package/src/api/protocol-v2/FilesystemFormat.ts +0 -19
- package/src/api/protocol-v2/FilesystemPermissionFix.ts +0 -16
- package/src/api/protocol-v2/Ping.ts +0 -18
- package/src/api/protocol-v2/ProtocolInfoRequest.ts +0 -16
- package/src/api/protocol-v2/helpers.ts +0 -203
- package/src/core/deviceEventRegistration.ts +0 -23
- package/src/data/messages/messages-protocol-v2.json +0 -13544
- package/src/device/DeviceFeaturesState.ts +0 -34
- package/src/device/DeviceStateMapper.ts +0 -348
- package/src/device/DeviceStateProjector.ts +0 -95
- package/src/device/DeviceStateStore.ts +0 -201
- package/src/device/DeviceWalletSessionStore.ts +0 -78
- package/src/device/cloneDeviceState.ts +0 -39
- package/src/device/deviceIdentity.ts +0 -18
- package/src/deviceProfile/buildDeviceFeatures.ts +0 -391
- package/src/deviceProfile/index.ts +0 -4
- package/src/protocols/protocol-v2/deviceSession.ts +0 -24
- package/src/protocols/protocol-v2/features.ts +0 -163
- package/src/protocols/protocol-v2/firmware.ts +0 -21
- package/src/protocols/protocol-v2/index.ts +0 -18
- package/src/protocols/protocol-v2/lockedError.ts +0 -10
- package/src/protocols/protocol-v2/settingsUnlockPolicy.ts +0 -61
- package/src/protocols/protocol-v2/uiInteraction.ts +0 -210
- package/src/protocols/protocol-v2/unlockRetry.ts +0 -76
- package/src/protocols/protocol-v2/walletSession.ts +0 -202
- package/src/types/api/firmwareUpdateCapabilities.ts +0 -13
- package/src/types/api/firmwareUpdatePlan.ts +0 -52
- package/src/types/api/firmwareUpdatePreparedPlan.ts +0 -55
- package/src/types/api/getDeviceState.ts +0 -19
- package/src/types/api/openWalletSession.ts +0 -54
- package/src/types/api/protocolV2.ts +0 -244
- package/src/types/api/sessionCache.ts +0 -14
- package/src/utils/deviceFeaturesCompat.ts +0 -173
- package/src/utils/pro2Wallpaper.ts +0 -109
|
@@ -14,44 +14,27 @@ import { BaseMethod } from './BaseMethod';
|
|
|
14
14
|
import { validateParams } from './helpers/paramsValidator';
|
|
15
15
|
import { DevicePool } from '../device/DevicePool';
|
|
16
16
|
import { getBinary, getInfo, getSysResourceBinary } from './firmware/getBinary';
|
|
17
|
+
import { updateResources, uploadFirmware } from './firmware/uploadFirmware';
|
|
17
18
|
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
LoggerNames,
|
|
20
|
+
getDeviceFirmwareVersion,
|
|
21
|
+
getDeviceType,
|
|
22
|
+
getDeviceUUID,
|
|
23
|
+
getFirmwareType,
|
|
24
|
+
getLogger,
|
|
25
|
+
wait,
|
|
26
|
+
} from '../utils';
|
|
23
27
|
import { FirmwareUpdateTipMessage, createUiMessage } from '../events/ui-request';
|
|
24
28
|
import { DeviceModelToTypes } from '../types';
|
|
25
29
|
import { DataManager } from '../data-manager';
|
|
26
30
|
import { DEVICE } from '../events';
|
|
27
|
-
import { type FirmwareByteSource, openFirmwareByteSource } from './firmware/FirmwareArtifactSource';
|
|
28
|
-
import { FirmwareCheckpointWriter } from './firmware/FirmwareCheckpoint';
|
|
29
|
-
import { resolveFirmwareUpdateHostBinding } from './firmware/FirmwareHostBinding';
|
|
30
|
-
import {
|
|
31
|
-
assertFirmwareUpdatePreparedPlanBinding,
|
|
32
|
-
getFirmwareUpdateResourceName,
|
|
33
|
-
} from './firmware/FirmwareUpdatePreparedPlan';
|
|
34
31
|
|
|
35
32
|
import type { Features, KnownDevice } from '../types';
|
|
33
|
+
import type { Device } from '../device/Device';
|
|
36
34
|
import type { FirmwareBinary } from './firmware/getBinary';
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
FirmwareArtifactReference,
|
|
40
|
-
FirmwareCheckpointParams,
|
|
41
|
-
} from '../types/api/firmwareUpdate';
|
|
42
|
-
import type { FirmwareUpdatePreparedPlan } from '../types/api/firmwareUpdatePreparedPlan';
|
|
43
|
-
|
|
44
|
-
type Params = FirmwareCheckpointParams & {
|
|
35
|
+
|
|
36
|
+
type Params = {
|
|
45
37
|
binary?: ArrayBuffer;
|
|
46
|
-
artifact?: FirmwareArtifactReference;
|
|
47
|
-
resourceArtifact?: FirmwareArtifactReference;
|
|
48
|
-
resourceEntries?: Array<{
|
|
49
|
-
entryName: string;
|
|
50
|
-
artifact: FirmwareArtifactReference;
|
|
51
|
-
}>;
|
|
52
|
-
artifactReader?: FirmwareArtifactReader;
|
|
53
|
-
preparedPlan?: FirmwareUpdatePreparedPlan;
|
|
54
|
-
platform?: FirmwareUpdatePreparedPlan['platform'];
|
|
55
38
|
version?: number[];
|
|
56
39
|
updateType: 'firmware' | 'ble';
|
|
57
40
|
forcedUpdateRes?: boolean;
|
|
@@ -132,13 +115,6 @@ const normalizeFirmwareBinary = (binary: unknown): FirmwareBinary | undefined =>
|
|
|
132
115
|
return normalized.buffer;
|
|
133
116
|
};
|
|
134
117
|
|
|
135
|
-
const toArrayBuffer = (binary: FirmwareBinary): ArrayBuffer => {
|
|
136
|
-
if (binary instanceof ArrayBuffer) {
|
|
137
|
-
return binary;
|
|
138
|
-
}
|
|
139
|
-
return new Uint8Array(binary.buffer, binary.byteOffset, binary.byteLength).slice().buffer;
|
|
140
|
-
};
|
|
141
|
-
|
|
142
118
|
export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
143
119
|
checkPromise: Deferred<any> | null = null;
|
|
144
120
|
|
|
@@ -185,42 +161,6 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
185
161
|
binary: payload.binary,
|
|
186
162
|
};
|
|
187
163
|
}
|
|
188
|
-
|
|
189
|
-
if ('artifact' in payload) {
|
|
190
|
-
const hostBinding = resolveFirmwareUpdateHostBinding(payload.hostBindingGeneration);
|
|
191
|
-
const target = payload.isUpdateBootloader ? 'bootloader' : payload.updateType;
|
|
192
|
-
const resourceBindings = [
|
|
193
|
-
...(payload.resourceArtifact
|
|
194
|
-
? [{ target: 'resource' as const, artifact: payload.resourceArtifact }]
|
|
195
|
-
: []),
|
|
196
|
-
...(payload.resourceEntries ?? []).map(
|
|
197
|
-
(entry: { entryName: string; artifact: FirmwareArtifactReference }) => ({
|
|
198
|
-
target: 'resource' as const,
|
|
199
|
-
entryName: entry.entryName,
|
|
200
|
-
artifact: entry.artifact,
|
|
201
|
-
})
|
|
202
|
-
),
|
|
203
|
-
];
|
|
204
|
-
assertFirmwareUpdatePreparedPlanBinding({
|
|
205
|
-
preparedPlan: payload.preparedPlan,
|
|
206
|
-
executor: 'v2',
|
|
207
|
-
platform: payload.platform,
|
|
208
|
-
scopeTargets: [target, ...(target === 'firmware' ? (['resource'] as const) : [])],
|
|
209
|
-
bindings: [{ target, artifact: payload.artifact }, ...resourceBindings],
|
|
210
|
-
});
|
|
211
|
-
this.params = {
|
|
212
|
-
...this.params,
|
|
213
|
-
preparedPlan: payload.preparedPlan,
|
|
214
|
-
hostBindingGeneration: payload.hostBindingGeneration,
|
|
215
|
-
artifact: payload.artifact,
|
|
216
|
-
resourceArtifact: payload.resourceArtifact,
|
|
217
|
-
resourceEntries: payload.resourceEntries,
|
|
218
|
-
artifactReader: hostBinding.artifactReader,
|
|
219
|
-
checkpointSink: hostBinding.checkpointSink,
|
|
220
|
-
checkpointSequenceStart: payload.checkpointSequenceStart,
|
|
221
|
-
resumeCheckpoint: payload.resumeCheckpoint,
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
164
|
}
|
|
225
165
|
|
|
226
166
|
postTipMessage = (message: string) => {
|
|
@@ -234,7 +174,7 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
234
174
|
);
|
|
235
175
|
};
|
|
236
176
|
|
|
237
|
-
private async _promptDeviceInBootloaderForWebDevice() {
|
|
177
|
+
private async _promptDeviceInBootloaderForWebDevice({ device }: { device: Device }) {
|
|
238
178
|
return new Promise((resolve, reject) => {
|
|
239
179
|
if (this.device.listenerCount(DEVICE.SELECT_DEVICE_IN_BOOTLOADER_FOR_WEB_DEVICE) > 0) {
|
|
240
180
|
this.device.emit(
|
|
@@ -265,8 +205,9 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
265
205
|
// eslint-disable-next-line prefer-const
|
|
266
206
|
let timeoutTimer: ReturnType<typeof setTimeout> | undefined;
|
|
267
207
|
|
|
268
|
-
const
|
|
269
|
-
|
|
208
|
+
const isTouchOrProDevice =
|
|
209
|
+
getDeviceType(this?.device?.features) === EDeviceType.Touch ||
|
|
210
|
+
getDeviceType(this?.device?.features) === EDeviceType.Pro;
|
|
270
211
|
|
|
271
212
|
const intervalTimer: ReturnType<typeof setInterval> | undefined = setInterval(
|
|
272
213
|
async () => {
|
|
@@ -288,7 +229,9 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
288
229
|
|
|
289
230
|
try {
|
|
290
231
|
this.postTipMessage(FirmwareUpdateTipMessage.SelectDeviceInBootloaderForWebDevice);
|
|
291
|
-
const confirmed = await this._promptDeviceInBootloaderForWebDevice(
|
|
232
|
+
const confirmed = await this._promptDeviceInBootloaderForWebDevice({
|
|
233
|
+
device: this.device,
|
|
234
|
+
});
|
|
292
235
|
if (confirmed) {
|
|
293
236
|
await this._checkDeviceInBootloaderMode(connectId, intervalTimer, timeoutTimer);
|
|
294
237
|
}
|
|
@@ -310,7 +253,7 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
310
253
|
true
|
|
311
254
|
);
|
|
312
255
|
await this.device.initialize();
|
|
313
|
-
if (this.device.
|
|
256
|
+
if (this.device.features?.bootloader_mode) {
|
|
314
257
|
clearInterval(intervalTimer);
|
|
315
258
|
this.checkPromise?.resolve(true);
|
|
316
259
|
}
|
|
@@ -343,7 +286,7 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
343
286
|
const devicesDescriptor = deviceDiff?.descriptors ?? [];
|
|
344
287
|
const { deviceList } = await DevicePool.getDevices(devicesDescriptor, connectId);
|
|
345
288
|
|
|
346
|
-
if (deviceList.length === 1 && deviceList[0]?.
|
|
289
|
+
if (deviceList.length === 1 && deviceList[0]?.features?.bootloader_mode) {
|
|
347
290
|
// should update current device from cache
|
|
348
291
|
// because device was reboot and had some new requests
|
|
349
292
|
this.device.updateFromCache(deviceList[0]);
|
|
@@ -357,22 +300,22 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
357
300
|
return false;
|
|
358
301
|
}
|
|
359
302
|
|
|
360
|
-
isEnteredManuallyBoot() {
|
|
361
|
-
const deviceType =
|
|
303
|
+
isEnteredManuallyBoot(features: Features) {
|
|
304
|
+
const deviceType = getDeviceType(features);
|
|
362
305
|
const isMini = deviceType === EDeviceType.Mini;
|
|
363
306
|
const isBoot183ClassicUpBle =
|
|
364
307
|
this.params.updateType === 'firmware' &&
|
|
365
308
|
deviceType === EDeviceType.Classic &&
|
|
366
|
-
|
|
309
|
+
features.bootloader_version === '1.8.3';
|
|
367
310
|
return isMini || isBoot183ClassicUpBle;
|
|
368
311
|
}
|
|
369
312
|
|
|
370
|
-
isSupportResourceUpdate(updateType: string) {
|
|
313
|
+
isSupportResourceUpdate(features: Features, updateType: string) {
|
|
371
314
|
if (updateType !== 'firmware') return false;
|
|
372
315
|
|
|
373
|
-
const deviceType =
|
|
316
|
+
const deviceType = getDeviceType(features);
|
|
374
317
|
const isTouchMode = deviceType === EDeviceType.Touch || deviceType === EDeviceType.Pro;
|
|
375
|
-
const currentVersion =
|
|
318
|
+
const currentVersion = getDeviceFirmwareVersion(features).join('.');
|
|
376
319
|
|
|
377
320
|
return isTouchMode && semver.gte(currentVersion, '3.2.0');
|
|
378
321
|
}
|
|
@@ -383,8 +326,8 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
383
326
|
*/
|
|
384
327
|
checkVersionForCopyTouchResource(features: Features | undefined, firmwareType: EFirmwareType) {
|
|
385
328
|
if (!features) return;
|
|
386
|
-
const deviceType =
|
|
387
|
-
const currentVersion =
|
|
329
|
+
const deviceType = getDeviceType(features);
|
|
330
|
+
const currentVersion = getDeviceFirmwareVersion(features).join('.');
|
|
388
331
|
const targetVersion = this.params.version?.join('.');
|
|
389
332
|
const { updateType } = this.params;
|
|
390
333
|
|
|
@@ -408,302 +351,153 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
408
351
|
async run() {
|
|
409
352
|
const { device, params } = this;
|
|
410
353
|
const { features, commands } = device;
|
|
411
|
-
const deviceType =
|
|
412
|
-
const checkpointWriter = new FirmwareCheckpointWriter(params, {
|
|
413
|
-
required: !!params.artifactReader,
|
|
414
|
-
});
|
|
415
|
-
|
|
416
|
-
// Protocol V2 (Pro2) uses DeviceFirmwareUpdate and must not enter this legacy flow.
|
|
417
|
-
if (device.isProtocolV2()) {
|
|
418
|
-
throw ERRORS.TypedError(
|
|
419
|
-
HardwareErrorCode.RuntimeError,
|
|
420
|
-
'Protocol V2 firmware update must use firmwareUpdateV4'
|
|
421
|
-
);
|
|
422
|
-
}
|
|
354
|
+
const deviceType = getDeviceType(features);
|
|
423
355
|
|
|
424
|
-
const deviceFirmwareType = device.
|
|
356
|
+
const deviceFirmwareType = getFirmwareType(device.features);
|
|
425
357
|
const firmwareType = params.firmwareType ?? deviceFirmwareType;
|
|
426
358
|
|
|
427
359
|
this.checkVersionForCopyTouchResource(features, firmwareType);
|
|
428
360
|
|
|
429
|
-
let
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
}
|
|
361
|
+
let preparedBinary: FirmwareBinary | undefined;
|
|
362
|
+
const acquireFirmwareBinary = async (): Promise<FirmwareBinary> => {
|
|
363
|
+
try {
|
|
364
|
+
if (preparedBinary) {
|
|
365
|
+
return preparedBinary;
|
|
366
|
+
}
|
|
436
367
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
}
|
|
442
|
-
const source = await openFirmwareByteSource({
|
|
443
|
-
binary: toArrayBuffer(binary),
|
|
444
|
-
});
|
|
445
|
-
if (!source) {
|
|
446
|
-
throw new Error('firmware binary is empty or invalid');
|
|
447
|
-
}
|
|
448
|
-
preparedSource = source;
|
|
449
|
-
return source;
|
|
368
|
+
if (params.binary !== undefined) {
|
|
369
|
+
preparedBinary = normalizeFirmwareBinary(params.binary);
|
|
370
|
+
if (!preparedBinary) {
|
|
371
|
+
throw new Error('firmware binary is empty or invalid');
|
|
450
372
|
}
|
|
373
|
+
return preparedBinary;
|
|
374
|
+
}
|
|
451
375
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
throw new Error('firmware artifact is not prepared');
|
|
459
|
-
}
|
|
460
|
-
preparedSource = source;
|
|
461
|
-
return source;
|
|
462
|
-
}
|
|
376
|
+
if (!device.features) {
|
|
377
|
+
throw ERRORS.TypedError(
|
|
378
|
+
HardwareErrorCode.RuntimeError,
|
|
379
|
+
'no features found for this device'
|
|
380
|
+
);
|
|
381
|
+
}
|
|
463
382
|
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
383
|
+
this.postTipMessage('DownloadFirmware');
|
|
384
|
+
const firmware = await getBinary({
|
|
385
|
+
features: device.features,
|
|
386
|
+
version: params.version,
|
|
387
|
+
updateType: params.updateType,
|
|
388
|
+
isUpdateBootloader: params.isUpdateBootloader,
|
|
389
|
+
firmwareType,
|
|
390
|
+
requestOptions: FIRMWARE_DOWNLOAD_REQUEST_OPTIONS,
|
|
391
|
+
});
|
|
392
|
+
preparedBinary = normalizeFirmwareBinary(firmware.binary);
|
|
393
|
+
if (!preparedBinary) {
|
|
394
|
+
throw new Error('downloaded firmware binary is empty or invalid');
|
|
395
|
+
}
|
|
396
|
+
this.postTipMessage('DownloadFirmwareSuccess');
|
|
397
|
+
return preparedBinary;
|
|
398
|
+
} catch (err) {
|
|
399
|
+
throw ERRORS.TypedError(HardwareErrorCode.FirmwareUpdateDownloadFailed, err.message ?? err);
|
|
400
|
+
}
|
|
401
|
+
};
|
|
470
402
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
'Firmware must be prepared by the external firmware host',
|
|
478
|
-
{
|
|
479
|
-
firmwareUpdateCode: 'FirmwareArtifactsNotPrepared',
|
|
480
|
-
artifactName: 'firmware',
|
|
481
|
-
}
|
|
482
|
-
);
|
|
483
|
-
}
|
|
403
|
+
if (!features?.bootloader_mode && features) {
|
|
404
|
+
const uuid = getDeviceUUID(features);
|
|
405
|
+
// should go to bootloader mode manually
|
|
406
|
+
if (this.isEnteredManuallyBoot(features)) {
|
|
407
|
+
return Promise.reject(ERRORS.TypedError(HardwareErrorCode.FirmwareUpdateManuallyEnterBoot));
|
|
408
|
+
}
|
|
484
409
|
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
410
|
+
// check & upgrade firmware resource
|
|
411
|
+
if (features && this.isSupportResourceUpdate(features, params.updateType)) {
|
|
412
|
+
this.postTipMessage('CheckLatestUiResource');
|
|
413
|
+
const resourceUrl = DataManager.getSysResourcesLatestRelease({
|
|
414
|
+
features,
|
|
415
|
+
forcedUpdateRes: params.forcedUpdateRes,
|
|
416
|
+
firmwareType,
|
|
417
|
+
});
|
|
418
|
+
if (resourceUrl) {
|
|
419
|
+
this.postTipMessage('DownloadLatestUiResource');
|
|
420
|
+
const resource = await getSysResourceBinary(resourceUrl);
|
|
421
|
+
this.postTipMessage('DownloadLatestUiResourceSuccess');
|
|
422
|
+
if (resource) {
|
|
423
|
+
await updateResources(
|
|
424
|
+
this.device.getCommands().typedCall.bind(this.device.getCommands()),
|
|
425
|
+
this.postMessage,
|
|
426
|
+
device,
|
|
427
|
+
resource.binary
|
|
428
|
+
);
|
|
503
429
|
}
|
|
504
|
-
preparedSource = source;
|
|
505
|
-
this.postTipMessage('DownloadFirmwareSuccess');
|
|
506
|
-
return source;
|
|
507
|
-
} catch (err) {
|
|
508
|
-
throw ERRORS.TypedError(
|
|
509
|
-
HardwareErrorCode.FirmwareUpdateDownloadFailed,
|
|
510
|
-
err.message ?? err
|
|
511
|
-
);
|
|
512
430
|
}
|
|
513
|
-
}
|
|
431
|
+
}
|
|
514
432
|
|
|
515
|
-
if
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
433
|
+
// check if the device commands has been disposed
|
|
434
|
+
this.device?.commands?.checkDisposed();
|
|
435
|
+
|
|
436
|
+
// A failed firmware download must leave the device in normal mode.
|
|
437
|
+
await acquireFirmwareBinary();
|
|
438
|
+
|
|
439
|
+
// The request may outlive the current transport command instance.
|
|
440
|
+
this.device?.commands?.checkDisposed();
|
|
441
|
+
|
|
442
|
+
// auto go to bootloader mode
|
|
443
|
+
try {
|
|
444
|
+
this.postTipMessage('AutoRebootToBootloader');
|
|
445
|
+
const bootRes = await commands.typedCall('DeviceBackToBoot', 'Success');
|
|
446
|
+
// @ts-expect-error
|
|
447
|
+
if (bootRes.type === 'CallMethodError') {
|
|
448
|
+
throw ERRORS.TypedError(HardwareErrorCode.FirmwareUpdateAutoEnterBootFailure);
|
|
520
449
|
}
|
|
450
|
+
this.postTipMessage('GoToBootloaderSuccess');
|
|
451
|
+
this.checkDeviceToBootloader(this.payload.connectId);
|
|
521
452
|
|
|
522
|
-
//
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
// check & upgrade firmware resource
|
|
526
|
-
if (this.isSupportResourceUpdate(params.updateType)) {
|
|
527
|
-
this.postTipMessage('CheckLatestUiResource');
|
|
528
|
-
const resourceUrl = DataManager.getSysResourcesLatestRelease({
|
|
529
|
-
features,
|
|
530
|
-
forcedUpdateRes: params.forcedUpdateRes,
|
|
531
|
-
firmwareType,
|
|
532
|
-
});
|
|
533
|
-
if (resourceUrl) {
|
|
534
|
-
this.postTipMessage('DownloadLatestUiResource');
|
|
535
|
-
if (params.resourceEntries?.length) {
|
|
536
|
-
const sources: Array<{
|
|
537
|
-
entryName: string;
|
|
538
|
-
source: FirmwareByteSource;
|
|
539
|
-
}> = [];
|
|
540
|
-
try {
|
|
541
|
-
for (const entry of params.resourceEntries) {
|
|
542
|
-
const resourceName = getFirmwareUpdateResourceName(entry.entryName);
|
|
543
|
-
const source = await openFirmwareByteSource({
|
|
544
|
-
artifact: entry.artifact,
|
|
545
|
-
reader: params.artifactReader,
|
|
546
|
-
});
|
|
547
|
-
if (!source) {
|
|
548
|
-
throw new Error('Firmware resource entry is not prepared');
|
|
549
|
-
}
|
|
550
|
-
sources.push({ entryName: resourceName, source });
|
|
551
|
-
}
|
|
552
|
-
await checkpointWriter.commit({
|
|
553
|
-
stage: 'FILE_TRANSFER_STARTED',
|
|
554
|
-
target: 'resource',
|
|
555
|
-
});
|
|
556
|
-
await updateResourcesFromSources(
|
|
557
|
-
this.device.getCommands().typedCall.bind(this.device.getCommands()),
|
|
558
|
-
this.postMessage,
|
|
559
|
-
device,
|
|
560
|
-
sources.map(entry => ({
|
|
561
|
-
entryName: entry.entryName,
|
|
562
|
-
source: entry.source,
|
|
563
|
-
}))
|
|
564
|
-
);
|
|
565
|
-
await checkpointWriter.commit({
|
|
566
|
-
stage: 'FILE_TRANSFER_COMPLETED',
|
|
567
|
-
target: 'resource',
|
|
568
|
-
});
|
|
569
|
-
} finally {
|
|
570
|
-
await Promise.all(
|
|
571
|
-
sources.map(entry => entry.source.close().catch(() => undefined))
|
|
572
|
-
);
|
|
573
|
-
}
|
|
574
|
-
this.postTipMessage('DownloadLatestUiResourceSuccess');
|
|
575
|
-
} else {
|
|
576
|
-
let resourceBinary: ArrayBuffer | Buffer;
|
|
577
|
-
if (params.resourceArtifact) {
|
|
578
|
-
throw ERRORS.TypedError(
|
|
579
|
-
HardwareErrorCode.RuntimeError,
|
|
580
|
-
'Firmware resource archive must be materialized into prepared entries',
|
|
581
|
-
{
|
|
582
|
-
firmwareUpdateCode: 'FirmwareArtifactsNotPrepared',
|
|
583
|
-
artifactName: 'resource',
|
|
584
|
-
}
|
|
585
|
-
);
|
|
586
|
-
} else {
|
|
587
|
-
if (
|
|
588
|
-
params.artifactReader ||
|
|
589
|
-
DataManager.getSettings('firmwareManifestMode') === 'external-only'
|
|
590
|
-
) {
|
|
591
|
-
throw ERRORS.TypedError(
|
|
592
|
-
HardwareErrorCode.RuntimeError,
|
|
593
|
-
'Firmware resource must be prepared by the external firmware host',
|
|
594
|
-
{
|
|
595
|
-
firmwareUpdateCode: 'FirmwareArtifactsNotPrepared',
|
|
596
|
-
artifactName: 'resource',
|
|
597
|
-
}
|
|
598
|
-
);
|
|
599
|
-
}
|
|
600
|
-
resourceBinary = (await getSysResourceBinary(resourceUrl)).binary;
|
|
601
|
-
}
|
|
602
|
-
this.postTipMessage('DownloadLatestUiResourceSuccess');
|
|
603
|
-
await checkpointWriter.commit({
|
|
604
|
-
stage: 'FILE_TRANSFER_STARTED',
|
|
605
|
-
target: 'resource',
|
|
606
|
-
});
|
|
607
|
-
await updateResources(
|
|
608
|
-
this.device.getCommands().typedCall.bind(this.device.getCommands()),
|
|
609
|
-
this.postMessage,
|
|
610
|
-
device,
|
|
611
|
-
resourceBinary
|
|
612
|
-
);
|
|
613
|
-
await checkpointWriter.commit({
|
|
614
|
-
stage: 'FILE_TRANSFER_COMPLETED',
|
|
615
|
-
target: 'resource',
|
|
616
|
-
});
|
|
617
|
-
}
|
|
618
|
-
}
|
|
453
|
+
// force clean classic device cache so that the device can initialize again
|
|
454
|
+
if (DeviceModelToTypes.model_classic.includes(deviceType)) {
|
|
455
|
+
DevicePool.clearDeviceCache(uuid);
|
|
619
456
|
}
|
|
457
|
+
delete DevicePool.devicesCache[''];
|
|
458
|
+
await this.checkPromise?.promise;
|
|
459
|
+
this.checkPromise = null;
|
|
620
460
|
|
|
621
461
|
// check if the device commands has been disposed
|
|
622
462
|
this.device?.commands?.checkDisposed();
|
|
623
463
|
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
target: params.isUpdateBootloader ? 'bootloader' : params.updateType,
|
|
633
|
-
});
|
|
634
|
-
const bootRes = await commands.typedCall('DeviceBackToBoot', 'Success');
|
|
635
|
-
// @ts-expect-error
|
|
636
|
-
if (bootRes.type === 'CallMethodError') {
|
|
637
|
-
throw ERRORS.TypedError(HardwareErrorCode.FirmwareUpdateAutoEnterBootFailure);
|
|
638
|
-
}
|
|
639
|
-
this.postTipMessage('GoToBootloaderSuccess');
|
|
640
|
-
this.checkDeviceToBootloader(this.payload.connectId);
|
|
641
|
-
|
|
642
|
-
// force clean classic device cache so that the device can initialize again
|
|
643
|
-
if (DeviceModelToTypes.model_classic.includes(deviceType)) {
|
|
644
|
-
DevicePool.clearDeviceCache(serialNo);
|
|
645
|
-
}
|
|
646
|
-
delete DevicePool.devicesCache[''];
|
|
647
|
-
await this.checkPromise?.promise;
|
|
648
|
-
this.checkPromise = null;
|
|
649
|
-
|
|
650
|
-
// check if the device commands has been disposed
|
|
651
|
-
this.device?.commands?.checkDisposed();
|
|
652
|
-
|
|
653
|
-
/**
|
|
654
|
-
* Touch 1 with bootloader v2.5.0 issue: BLE chip need more time for looking up name, here change the delay time to 3000ms after rebooting.
|
|
655
|
-
*/
|
|
656
|
-
const isTouch = DeviceModelToTypes.model_touch.includes(deviceType);
|
|
657
|
-
await wait(isTouch ? 3000 : 1500);
|
|
658
|
-
} catch (e) {
|
|
659
|
-
if (e instanceof HardwareError) {
|
|
660
|
-
return Promise.reject(e);
|
|
661
|
-
}
|
|
662
|
-
console.log('auto go to bootloader mode failed: ', e);
|
|
663
|
-
return Promise.reject(
|
|
664
|
-
ERRORS.TypedError(HardwareErrorCode.FirmwareUpdateAutoEnterBootFailure)
|
|
665
|
-
);
|
|
464
|
+
/**
|
|
465
|
+
* Touch 1 with bootloader v2.5.0 issue: BLE chip need more time for looking up name, here change the delay time to 3000ms after rebooting.
|
|
466
|
+
*/
|
|
467
|
+
const isTouch = DeviceModelToTypes.model_touch.includes(deviceType);
|
|
468
|
+
await wait(isTouch ? 3000 : 1500);
|
|
469
|
+
} catch (e) {
|
|
470
|
+
if (e instanceof HardwareError) {
|
|
471
|
+
return Promise.reject(e);
|
|
666
472
|
}
|
|
473
|
+
console.log('auto go to bootloader mode failed: ', e);
|
|
474
|
+
return Promise.reject(
|
|
475
|
+
ERRORS.TypedError(HardwareErrorCode.FirmwareUpdateAutoEnterBootFailure)
|
|
476
|
+
);
|
|
667
477
|
}
|
|
478
|
+
}
|
|
668
479
|
|
|
669
|
-
|
|
670
|
-
|
|
480
|
+
// Devices already in bootloader mode still acquire through the same helper.
|
|
481
|
+
const binary = await acquireFirmwareBinary();
|
|
671
482
|
|
|
672
|
-
|
|
673
|
-
|
|
483
|
+
// check if the device commands has been disposed
|
|
484
|
+
this.device?.commands?.checkDisposed();
|
|
674
485
|
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
const target = params.isUpdateBootloader ? 'bootloader' : params.updateType;
|
|
678
|
-
await checkpointWriter.commit({
|
|
679
|
-
stage: 'FILE_TRANSFER_STARTED',
|
|
680
|
-
target,
|
|
681
|
-
});
|
|
682
|
-
const response = await uploadFirmwareFromSource(
|
|
683
|
-
params.updateType,
|
|
684
|
-
this.device.getCommands().typedCall.bind(this.device.getCommands()),
|
|
685
|
-
this.postMessage,
|
|
686
|
-
device,
|
|
687
|
-
source,
|
|
688
|
-
true,
|
|
689
|
-
params.isUpdateBootloader
|
|
690
|
-
);
|
|
691
|
-
await checkpointWriter.commit({
|
|
692
|
-
stage: 'FILE_TRANSFER_COMPLETED',
|
|
693
|
-
target,
|
|
694
|
-
});
|
|
486
|
+
await this.device.acquire();
|
|
695
487
|
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
488
|
+
const response = await uploadFirmware(
|
|
489
|
+
params.updateType,
|
|
490
|
+
this.device.getCommands().typedCall.bind(this.device.getCommands()),
|
|
491
|
+
this.postMessage,
|
|
492
|
+
device,
|
|
493
|
+
{ payload: binary, rebootOnSuccess: true },
|
|
494
|
+
params.isUpdateBootloader
|
|
495
|
+
);
|
|
699
496
|
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
target,
|
|
703
|
-
});
|
|
704
|
-
return response;
|
|
705
|
-
} finally {
|
|
706
|
-
await preparedSource?.close().catch(() => undefined);
|
|
497
|
+
if (this.connectId) {
|
|
498
|
+
DevicePool.clearDeviceCache(this.connectId);
|
|
707
499
|
}
|
|
500
|
+
|
|
501
|
+
return response;
|
|
708
502
|
}
|
|
709
503
|
}
|