@@ -41,6 +41,8 @@ export const MIN_UPDATE_V3_BOOTLOADER_VERSION = '2.8.0';
4141export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod < FirmwareUpdateV3Params > {
4242 checkPromise : Deferred < any > | null = null ;
4343
44+ private isSwitchFirmware = false ;
45+
4446 init ( ) {
4547 this . allowDeviceMode = [ UI_REQUEST . BOOTLOADER , UI_REQUEST . NOT_INITIALIZE ] ;
4648 this . requireDeviceMode = [ ] ;
@@ -91,6 +93,7 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
9193
9294 const deviceFirmwareType = getFirmwareType ( features ) ;
9395 const firmwareType = this . params . firmwareType ?? deviceFirmwareType ;
96+ this . isSwitchFirmware = firmwareType !== deviceFirmwareType ;
9497
9598 let resourceBinary : ArrayBuffer | null = null ;
9699 let fwBinaryMap : { fileName : string ; binary : ArrayBuffer } [ ] = [ ] ;
@@ -468,6 +471,17 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
468471 return '' ;
469472 }
470473
474+ private canPromptWebUsbSwitchFirmwareReconnect ( ) : boolean {
475+ if ( ! this . isSwitchFirmware ) {
476+ return false ;
477+ }
478+ return (
479+ DataManager . isBrowserWebUsb ( DataManager . getSettings ( 'env' ) ) &&
480+ ! this . payload . skipWebDevicePrompt &&
481+ this . device . listenerCount ( DEVICE . SELECT_DEVICE_FOR_SWITCH_FIRMWARE_WEB_DEVICE ) > 0
482+ ) ;
483+ }
484+
471485 /**
472486 * @description Reconnect device - While update with bootloader, it will reconnect device
473487 * @param {number } timeout - The timeout for the reconnection
@@ -503,17 +517,14 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
503517 const deviceDiff = await this . device . deviceConnector ?. enumerate ( ) ;
504518 const devicesDescriptor = deviceDiff ?. descriptors ?? [ ] ;
505519
506- const canPromptWebUsbBootloader =
507- DataManager . isBrowserWebUsb ( DataManager . getSettings ( 'env' ) ) &&
508- ! this . payload . skipWebDevicePrompt &&
509- this . device . listenerCount ( DEVICE . SELECT_DEVICE_IN_BOOTLOADER_FOR_WEB_DEVICE ) > 0 ;
520+ const canPromptSwitchFirmwareReconnect = this . canPromptWebUsbSwitchFirmwareReconnect ( ) ;
510521
511- if ( canPromptWebUsbBootloader ) {
522+ if ( canPromptSwitchFirmwareReconnect ) {
512523 webUsbCheckCount += 1 ;
513524 if ( webUsbCheckCount > 4 ) {
514- this . postTipMessage ( FirmwareUpdateTipMessage . SelectDeviceInBootloaderForWebDevice ) ;
525+ this . postTipMessage ( FirmwareUpdateTipMessage . SwitchFirmwareReconnectDevice ) ;
515526 try {
516- await this . _promptDeviceInBootloaderForWebDevice ( ) ;
527+ await this . _promptDeviceForSwitchFirmwareWebDevice ( ) ;
517528 } catch ( e ) {
518529 Log . log ( 'WebUSB re-authorization failed: ' , e ) ;
519530 }
0 commit comments