Skip to content

Commit

Permalink
fix(suite): disable reboot to bootloader for T2 with WebUSB
Browse files Browse the repository at this point in the history
(cherry picked from commit b5ae8b5)
  • Loading branch information
matejkriz authored and komret committed Nov 3, 2023
1 parent 302695b commit 99636a4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/suite/src/hooks/firmware/useRebootRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { getFirmwareVersion } from '@trezor/device-utils';
import type { TrezorDevice } from 'src/types/suite';
import { useDispatch, useSelector } from 'src/hooks/suite';
import { SUITE } from 'src/actions/suite/constants';
import { isWebUsb } from 'src/utils/suite/transport';

export type RebootRequestedMode = 'bootloader' | 'normal';
export type RebootPhase = 'initial' | 'wait-for-confirm' | 'disconnected' | 'done';
Expand All @@ -23,12 +24,19 @@ export const useRebootRequest = (
): RebootRequest => {
const [phase, setPhase] = useState<RebootPhase>('initial');

const transport = useSelector(state => state.suite.transport);

const isWebUsbTransport = isWebUsb(transport);

// Default reboot method is 'manual'. If the device is connected when
// the hook is first called and fw version is sufficient,
// then the 'automatic' method is enabled.
// Automatic reboot to bootloader not working properly with WebUSB so it's disabled for now.
const [method, setMethod] = useState<RebootMethod>(() => {
if (!device?.connected || !device?.features) return 'manual';
if (!device?.connected || !device?.features || isWebUsbTransport) return 'manual';

const deviceFwVersion = getFirmwareVersion(device);

return requestedMode === 'bootloader' &&
valid(deviceFwVersion) &&
satisfies(deviceFwVersion, '>=1.10.0 <2.0.0 || >=2.6.0')
Expand Down

0 comments on commit 99636a4

Please sign in to comment.