@onekeyfe/hd-core 1.2.0-alpha.97 → 1.2.0-alpha.98
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__/check-all-firmware-release-protocol-v2.test.ts +404 -84
- package/__tests__/check-firmware-release-protocol-v2.test.ts +199 -0
- package/__tests__/firmware-memory-host.test.ts +112 -0
- package/__tests__/firmware-update/device-update-bootloader.test.ts +13 -2
- package/__tests__/firmware-update/firmware-host-binding.test.ts +9 -0
- package/__tests__/firmware-update/firmware-prepared-host-digest.test.ts +573 -0
- package/__tests__/firmware-update/firmware-prepared-resource-archive.test.ts +150 -0
- package/__tests__/firmware-update/firmware-update-plan.test.ts +232 -70
- package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +53 -1
- package/__tests__/firmware-update/firmware-update-prepared-resource-executors.test.ts +326 -0
- package/__tests__/firmware-update/firmware-update-v2-download-before-boot.test.ts +2 -2
- package/__tests__/protocol-v2-resources.test.ts +148 -232
- package/__tests__/protocol-v2.test.ts +1236 -516
- package/dist/api/CheckAllFirmwareRelease.d.ts +2 -3
- package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
- package/dist/api/CheckBLEFirmwareRelease.d.ts +3 -2
- package/dist/api/CheckBLEFirmwareRelease.d.ts.map +1 -1
- package/dist/api/CheckBootloaderRelease.d.ts +2 -1
- package/dist/api/CheckBootloaderRelease.d.ts.map +1 -1
- package/dist/api/CheckFirmwareRelease.d.ts +3 -2
- package/dist/api/CheckFirmwareRelease.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts +1 -0
- package/dist/api/FirmwareUpdateV2.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV3.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +8 -8
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/UploadPortfolio.d.ts.map +1 -1
- package/dist/api/device/DeviceUpdateBootloader.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareHostBinding.d.ts +1 -1
- package/dist/api/firmware/FirmwareHostBinding.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareMemoryHost.d.ts +22 -0
- package/dist/api/firmware/FirmwareMemoryHost.d.ts.map +1 -0
- package/dist/api/firmware/FirmwarePreparedResourceArchive.d.ts +11 -0
- package/dist/api/firmware/FirmwarePreparedResourceArchive.d.ts.map +1 -0
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts +48 -1
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts +6 -1
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +1 -1
- package/dist/api/firmware/getBinary.d.ts +0 -1
- package/dist/api/firmware/getBinary.d.ts.map +1 -1
- package/dist/api/firmware/protocolV2Release.d.ts +33 -0
- package/dist/api/firmware/protocolV2Release.d.ts.map +1 -0
- package/dist/data-manager/DataManager.d.ts +4 -3
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/index.d.ts +108 -114
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1633 -967
- package/dist/protocols/protocol-v2/resources.d.ts +10 -28
- package/dist/protocols/protocol-v2/resources.d.ts.map +1 -1
- package/dist/types/api/checkAllFirmwareRelease.d.ts +20 -8
- package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/checkBLEFirmwareRelease.d.ts +2 -13
- package/dist/types/api/checkBLEFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/checkBootloaderRelease.d.ts +2 -6
- package/dist/types/api/checkBootloaderRelease.d.ts.map +1 -1
- package/dist/types/api/checkFirmwareRelease.d.ts +2 -13
- package/dist/types/api/checkFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/checkFirmwareTypeAvailable.d.ts +2 -2
- package/dist/types/api/checkFirmwareTypeAvailable.d.ts.map +1 -1
- package/dist/types/api/deviceUpdateBootloader.d.ts.map +1 -1
- package/dist/types/api/export.d.ts +1 -1
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +4 -12
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdatePlan.d.ts +2 -2
- package/dist/types/api/firmwareUpdatePlan.d.ts.map +1 -1
- package/dist/types/settings.d.ts +35 -36
- package/dist/types/settings.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/CheckAllFirmwareRelease.ts +108 -80
- package/src/api/CheckBLEFirmwareRelease.ts +37 -5
- package/src/api/CheckBootloaderRelease.ts +35 -3
- package/src/api/CheckFirmwareRelease.ts +35 -7
- package/src/api/FirmwareUpdateV2.ts +108 -73
- package/src/api/FirmwareUpdateV3.ts +101 -56
- package/src/api/FirmwareUpdateV4.ts +885 -403
- package/src/api/UploadPortfolio.ts +18 -0
- package/src/api/device/DeviceUpdateBootloader.ts +37 -11
- package/src/api/firmware/FirmwareHostBinding.ts +16 -3
- package/src/api/firmware/FirmwareMemoryHost.ts +142 -0
- package/src/api/firmware/FirmwarePreparedResourceArchive.ts +207 -0
- package/src/api/firmware/FirmwareUpdatePlan.ts +282 -122
- package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +27 -3
- package/src/api/firmware/protocolV2Release.ts +168 -0
- package/src/data-manager/DataManager.ts +35 -19
- package/src/index.ts +10 -0
- package/src/protocols/protocol-v2/resources.ts +157 -341
- package/src/types/api/checkAllFirmwareRelease.ts +27 -12
- package/src/types/api/checkBLEFirmwareRelease.ts +4 -13
- package/src/types/api/checkBootloaderRelease.ts +2 -6
- package/src/types/api/checkFirmwareRelease.ts +2 -13
- package/src/types/api/checkFirmwareTypeAvailable.ts +2 -2
- package/src/types/api/deviceUpdateBootloader.ts +1 -0
- package/src/types/api/export.ts +6 -1
- package/src/types/api/firmwareUpdate.ts +12 -17
- package/src/types/api/firmwareUpdatePlan.ts +2 -2
- package/src/types/settings.ts +35 -61
- package/src/utils/deviceFeaturesUtils.ts +2 -2
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
EDeviceType,
|
|
3
|
-
EFirmwareType,
|
|
4
|
-
ERRORS,
|
|
5
|
-
HardwareError,
|
|
6
|
-
HardwareErrorCode,
|
|
7
|
-
} from '@onekeyfe/hd-shared';
|
|
1
|
+
import { EDeviceType, HardwareError } from '@onekeyfe/hd-shared';
|
|
8
2
|
import semver from 'semver';
|
|
9
3
|
|
|
10
4
|
import { BaseMethod } from './BaseMethod';
|
|
@@ -17,13 +11,20 @@ import {
|
|
|
17
11
|
} from './firmware/releaseHelper';
|
|
18
12
|
import {
|
|
19
13
|
buildFirmwareUpdatePlan,
|
|
14
|
+
buildProtocolV2FirmwareUpdatePlan,
|
|
20
15
|
validateFirmwareUpdatePlanForceTargets,
|
|
16
|
+
validateProtocolV2FirmwareUpdateTargets,
|
|
21
17
|
} from './firmware/FirmwareUpdatePlan';
|
|
22
|
-
import { getBridgeReleaseInfo } from '../utils/bridgeUpdate';
|
|
23
18
|
import {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
PROTOCOL_V2_BLE_TARGETS,
|
|
20
|
+
PROTOCOL_V2_BOOTLOADER_TARGETS,
|
|
21
|
+
PROTOCOL_V2_MAIN_FIRMWARE_TARGETS,
|
|
22
|
+
getProtocolV2ComponentReleaseInfo,
|
|
23
|
+
loadProtocolV2FirmwareReleaseContext,
|
|
24
|
+
summarizeProtocolV2FirmwareRelease,
|
|
25
|
+
toProtocolV2FirmwareReleaseInfo,
|
|
26
|
+
} from './firmware/protocolV2Release';
|
|
27
|
+
import { getBridgeReleaseInfo } from '../utils/bridgeUpdate';
|
|
27
28
|
import {
|
|
28
29
|
LoggerNames,
|
|
29
30
|
getDeviceFirmwareVersion,
|
|
@@ -32,6 +33,7 @@ import {
|
|
|
32
33
|
getLogger,
|
|
33
34
|
} from '../utils';
|
|
34
35
|
|
|
36
|
+
import type { EFirmwareType } from '@onekeyfe/hd-shared';
|
|
35
37
|
import type {
|
|
36
38
|
AllFirmwareRelease,
|
|
37
39
|
CheckAllFirmwareReleaseParams,
|
|
@@ -173,7 +175,7 @@ function buildComponentRelease({
|
|
|
173
175
|
};
|
|
174
176
|
}
|
|
175
177
|
|
|
176
|
-
type ProtocolV2FirmwareReleasePlan = {
|
|
178
|
+
export type ProtocolV2FirmwareReleasePlan = {
|
|
177
179
|
firmwareType: EFirmwareType;
|
|
178
180
|
status: ProtocolV2FirmwareReleaseStatus;
|
|
179
181
|
hasUpgrade: boolean;
|
|
@@ -384,31 +386,23 @@ export default class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
384
386
|
}
|
|
385
387
|
|
|
386
388
|
private async runProtocolV2(): Promise<AllFirmwareRelease> {
|
|
387
|
-
const {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
389
|
+
const {
|
|
390
|
+
checkFirmwareHash = false,
|
|
391
|
+
firmwareType: firmwareTypeParam,
|
|
392
|
+
platform,
|
|
393
|
+
forceUpdateTargets,
|
|
394
|
+
protocolV2ForceUpdateTargets,
|
|
395
|
+
} = this.payload as CheckAllFirmwareReleaseParams;
|
|
396
|
+
const validatedForceUpdateTargets = validateFirmwareUpdatePlanForceTargets(forceUpdateTargets);
|
|
397
|
+
const validatedProtocolV2ForceUpdateTargets = validateProtocolV2FirmwareUpdateTargets(
|
|
398
|
+
protocolV2ForceUpdateTargets
|
|
399
|
+
);
|
|
400
|
+
const { state, features, firmwareType, release } = await loadProtocolV2FirmwareReleaseContext({
|
|
401
|
+
device: this.device,
|
|
402
|
+
firmwareType: firmwareTypeParam,
|
|
403
|
+
checkFirmwareHash,
|
|
404
|
+
methodName: 'checkAllFirmwareRelease',
|
|
393
405
|
});
|
|
394
|
-
if (state.identity.deviceType !== 'pro2' && state.identity.deviceType !== 'neo') {
|
|
395
|
-
throw ERRORS.TypedError(
|
|
396
|
-
HardwareErrorCode.DeviceNotSupportMethod,
|
|
397
|
-
'checkAllFirmwareRelease requires a Pro2 or Neo device for Protocol V2'
|
|
398
|
-
);
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
const { features } = this.device;
|
|
402
|
-
if (!features) {
|
|
403
|
-
throw ERRORS.TypedError(
|
|
404
|
-
HardwareErrorCode.RuntimeError,
|
|
405
|
-
'checkAllFirmwareRelease requires initialized device features'
|
|
406
|
-
);
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
const firmwareType =
|
|
410
|
-
firmwareTypeParam ?? state.identity.firmwareType ?? EFirmwareType.Universal;
|
|
411
|
-
const release = DataManager.getFirmwareLatestRelease(features, firmwareType);
|
|
412
406
|
const plan = buildProtocolV2FirmwareRelease({
|
|
413
407
|
currentVersions: state.versions,
|
|
414
408
|
currentVerification: checkFirmwareHash ? state.verification : undefined,
|
|
@@ -419,60 +413,94 @@ export default class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
419
413
|
});
|
|
420
414
|
const resourceDeviceType =
|
|
421
415
|
state.identity.deviceType === 'neo' ? EDeviceType.Neo : EDeviceType.Pro2;
|
|
422
|
-
const
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
416
|
+
const resourceSource = DataManager.getProtocolV2ResourceSource(resourceDeviceType);
|
|
417
|
+
const resourceStatus = 'unknown' as const;
|
|
418
|
+
const detectedComponentTargets = validatedForceUpdateTargets.includes('firmware')
|
|
419
|
+
? plan.components.flatMap(component =>
|
|
420
|
+
component.updateTarget ? [component.updateTarget] : []
|
|
421
|
+
)
|
|
422
|
+
: plan.targetsToUpdate;
|
|
423
|
+
const componentTargetsToUpdate = Array.from(
|
|
424
|
+
new Set([
|
|
425
|
+
...detectedComponentTargets,
|
|
426
|
+
...validatedProtocolV2ForceUpdateTargets.filter(target => target !== 'resource'),
|
|
427
|
+
])
|
|
428
|
+
);
|
|
429
|
+
const forceResourceUpdate =
|
|
430
|
+
validatedForceUpdateTargets.includes('resource') ||
|
|
431
|
+
validatedProtocolV2ForceUpdateTargets.includes('resource');
|
|
432
|
+
const targetsToUpdate = Array.from(
|
|
433
|
+
new Set([
|
|
434
|
+
...componentTargetsToUpdate,
|
|
435
|
+
...(forceResourceUpdate ? (['resource'] as const) : []),
|
|
436
|
+
])
|
|
437
|
+
);
|
|
438
|
+
let firmwareUpdatePlan: FirmwareUpdatePlan | undefined;
|
|
439
|
+
const shouldBuildFirmwareUpdatePlan = targetsToUpdate.length > 0;
|
|
440
|
+
const requestedPlatform = platform ?? 'web';
|
|
441
|
+
const requiresPreparedPlan =
|
|
442
|
+
shouldBuildFirmwareUpdatePlan &&
|
|
443
|
+
(requestedPlatform === 'native' || requestedPlatform === 'desktop');
|
|
444
|
+
try {
|
|
445
|
+
if (shouldBuildFirmwareUpdatePlan) {
|
|
446
|
+
const validatedPlan = buildProtocolV2FirmwareUpdatePlan({
|
|
447
|
+
features,
|
|
448
|
+
firmwareType,
|
|
449
|
+
platform: requestedPlatform,
|
|
450
|
+
release,
|
|
451
|
+
targetsToUpdate,
|
|
452
|
+
forceUpdateTargets: validatedForceUpdateTargets,
|
|
453
|
+
resourceArchive: resourceSource,
|
|
454
|
+
});
|
|
455
|
+
firmwareUpdatePlan = validatedPlan;
|
|
456
|
+
} else {
|
|
457
|
+
firmwareUpdatePlan = undefined;
|
|
458
|
+
}
|
|
459
|
+
} catch (error) {
|
|
460
|
+
if (
|
|
461
|
+
requiresPreparedPlan ||
|
|
462
|
+
validatedForceUpdateTargets.length > 0 ||
|
|
463
|
+
validatedProtocolV2ForceUpdateTargets.length > 0 ||
|
|
464
|
+
!(error instanceof HardwareError) ||
|
|
465
|
+
error.params?.firmwareUpdateCode !== 'FirmwarePlanInvalid'
|
|
466
|
+
) {
|
|
467
|
+
throw error;
|
|
445
468
|
}
|
|
469
|
+
Log.warn(
|
|
470
|
+
'[CheckAllFirmwareRelease] Optional Protocol V2 firmware Plan is unavailable; using the release result'
|
|
471
|
+
);
|
|
472
|
+
firmwareUpdatePlan = undefined;
|
|
446
473
|
}
|
|
447
|
-
const
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
const
|
|
452
|
-
const
|
|
474
|
+
const firmwarePlan = summarizeProtocolV2FirmwareRelease(
|
|
475
|
+
plan,
|
|
476
|
+
PROTOCOL_V2_MAIN_FIRMWARE_TARGETS
|
|
477
|
+
);
|
|
478
|
+
const blePlan = summarizeProtocolV2FirmwareRelease(plan, PROTOCOL_V2_BLE_TARGETS);
|
|
479
|
+
const bootloaderPlan = summarizeProtocolV2FirmwareRelease(plan, PROTOCOL_V2_BOOTLOADER_TARGETS);
|
|
480
|
+
const { status } = plan;
|
|
453
481
|
|
|
454
482
|
return {
|
|
455
|
-
firmware: {
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
},
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
status: 'valid',
|
|
467
|
-
release: emptyRelease,
|
|
468
|
-
},
|
|
483
|
+
firmware: toProtocolV2FirmwareReleaseInfo({ plan: firmwarePlan, state, release }),
|
|
484
|
+
ble: toProtocolV2FirmwareReleaseInfo({
|
|
485
|
+
plan: blePlan,
|
|
486
|
+
state,
|
|
487
|
+
release: getProtocolV2ComponentReleaseInfo(plan, 'COPROCESSOR'),
|
|
488
|
+
}),
|
|
489
|
+
bootloader: toProtocolV2FirmwareReleaseInfo({
|
|
490
|
+
plan: bootloaderPlan,
|
|
491
|
+
state,
|
|
492
|
+
release: getProtocolV2ComponentReleaseInfo(plan, 'BOOTLOADER'),
|
|
493
|
+
}),
|
|
469
494
|
features,
|
|
470
495
|
protocol: 'V2',
|
|
471
496
|
deviceType: state.identity.deviceType,
|
|
472
497
|
...plan,
|
|
498
|
+
status,
|
|
473
499
|
resourceStatus,
|
|
474
|
-
|
|
500
|
+
resourceArchive: resourceSource,
|
|
501
|
+
hasUpgrade: targetsToUpdate.length > 0,
|
|
475
502
|
targetsToUpdate,
|
|
503
|
+
firmwareUpdatePlan,
|
|
476
504
|
};
|
|
477
505
|
}
|
|
478
506
|
}
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import { BaseMethod } from './BaseMethod';
|
|
2
2
|
import { UI_REQUEST } from '../constants/ui-request';
|
|
3
3
|
import { getBleFirmwareReleaseInfo } from './firmware/releaseHelper';
|
|
4
|
+
import {
|
|
5
|
+
PROTOCOL_V2_BLE_TARGETS,
|
|
6
|
+
getProtocolV2ComponentReleaseInfo,
|
|
7
|
+
loadProtocolV2FirmwareReleaseContext,
|
|
8
|
+
summarizeProtocolV2FirmwareRelease,
|
|
9
|
+
toProtocolV2FirmwareReleaseInfo,
|
|
10
|
+
} from './firmware/protocolV2Release';
|
|
11
|
+
import { buildProtocolV2FirmwareRelease } from './CheckAllFirmwareRelease';
|
|
4
12
|
|
|
5
13
|
export default class CheckBLEFirmwareRelease extends BaseMethod {
|
|
14
|
+
getSupportedProtocols() {
|
|
15
|
+
return ['V1', 'V2'] as const;
|
|
16
|
+
}
|
|
17
|
+
|
|
6
18
|
init() {
|
|
7
19
|
this.allowDeviceMode = [
|
|
8
20
|
...this.allowDeviceMode,
|
|
@@ -13,11 +25,31 @@ export default class CheckBLEFirmwareRelease extends BaseMethod {
|
|
|
13
25
|
this.skipForceUpdateCheck = true;
|
|
14
26
|
}
|
|
15
27
|
|
|
16
|
-
run() {
|
|
17
|
-
if (this.device.features)
|
|
18
|
-
|
|
19
|
-
|
|
28
|
+
async run() {
|
|
29
|
+
if (!this.device.features) return null;
|
|
30
|
+
|
|
31
|
+
if (this.device.isProtocolV2()) {
|
|
32
|
+
const { state, firmwareType, release } = await loadProtocolV2FirmwareReleaseContext({
|
|
33
|
+
device: this.device,
|
|
34
|
+
methodName: 'checkBLEFirmwareRelease',
|
|
35
|
+
});
|
|
36
|
+
const plan = summarizeProtocolV2FirmwareRelease(
|
|
37
|
+
buildProtocolV2FirmwareRelease({
|
|
38
|
+
currentVersions: state.versions,
|
|
39
|
+
firmwareType,
|
|
40
|
+
release,
|
|
41
|
+
deviceType: state.identity.deviceType,
|
|
42
|
+
}),
|
|
43
|
+
PROTOCOL_V2_BLE_TARGETS
|
|
44
|
+
);
|
|
45
|
+
return toProtocolV2FirmwareReleaseInfo({
|
|
46
|
+
plan,
|
|
47
|
+
state,
|
|
48
|
+
release: getProtocolV2ComponentReleaseInfo(plan, 'COPROCESSOR'),
|
|
49
|
+
});
|
|
20
50
|
}
|
|
21
|
-
|
|
51
|
+
|
|
52
|
+
const releaseInfo = getBleFirmwareReleaseInfo(this.device.features);
|
|
53
|
+
return releaseInfo;
|
|
22
54
|
}
|
|
23
55
|
}
|
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import { BaseMethod } from './BaseMethod';
|
|
2
2
|
import { UI_REQUEST } from '../constants/ui-request';
|
|
3
3
|
import { getBootloaderReleaseInfo } from './firmware/releaseHelper';
|
|
4
|
+
import {
|
|
5
|
+
PROTOCOL_V2_BOOTLOADER_TARGETS,
|
|
6
|
+
getProtocolV2ComponentReleaseInfo,
|
|
7
|
+
loadProtocolV2FirmwareReleaseContext,
|
|
8
|
+
summarizeProtocolV2FirmwareRelease,
|
|
9
|
+
toProtocolV2FirmwareReleaseInfo,
|
|
10
|
+
} from './firmware/protocolV2Release';
|
|
11
|
+
import { buildProtocolV2FirmwareRelease } from './CheckAllFirmwareRelease';
|
|
4
12
|
|
|
5
13
|
import type { CheckBootloaderReleaseParams } from '../types/api/checkBootloaderRelease';
|
|
6
14
|
|
|
7
15
|
export default class CheckBootloaderRelease extends BaseMethod {
|
|
16
|
+
getSupportedProtocols() {
|
|
17
|
+
return ['V1', 'V2'] as const;
|
|
18
|
+
}
|
|
19
|
+
|
|
8
20
|
init() {
|
|
9
21
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.BOOTLOADER];
|
|
10
22
|
this.useDevicePassphraseState = false;
|
|
@@ -12,12 +24,32 @@ export default class CheckBootloaderRelease extends BaseMethod {
|
|
|
12
24
|
}
|
|
13
25
|
|
|
14
26
|
async run() {
|
|
15
|
-
if (!this.device.features)
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
27
|
+
if (!this.device.features) return null;
|
|
18
28
|
const { features } = this.device;
|
|
19
29
|
const payload = this.payload as CheckBootloaderReleaseParams;
|
|
20
30
|
|
|
31
|
+
if (this.device.isProtocolV2()) {
|
|
32
|
+
const { state, firmwareType, release } = await loadProtocolV2FirmwareReleaseContext({
|
|
33
|
+
device: this.device,
|
|
34
|
+
firmwareType: payload.firmwareType,
|
|
35
|
+
methodName: 'checkBootloaderRelease',
|
|
36
|
+
});
|
|
37
|
+
const plan = summarizeProtocolV2FirmwareRelease(
|
|
38
|
+
buildProtocolV2FirmwareRelease({
|
|
39
|
+
currentVersions: state.versions,
|
|
40
|
+
firmwareType,
|
|
41
|
+
release,
|
|
42
|
+
deviceType: state.identity.deviceType,
|
|
43
|
+
}),
|
|
44
|
+
PROTOCOL_V2_BOOTLOADER_TARGETS
|
|
45
|
+
);
|
|
46
|
+
return toProtocolV2FirmwareReleaseInfo({
|
|
47
|
+
plan,
|
|
48
|
+
state,
|
|
49
|
+
release: getProtocolV2ComponentReleaseInfo(plan, 'BOOTLOADER'),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
21
53
|
const deviceFirmwareType = this.device.getCurrentFirmwareType();
|
|
22
54
|
const firmwareType = payload.firmwareType ?? deviceFirmwareType;
|
|
23
55
|
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import { BaseMethod } from './BaseMethod';
|
|
2
2
|
import { UI_REQUEST } from '../constants/ui-request';
|
|
3
3
|
import { getFirmwareReleaseInfo } from './firmware/releaseHelper';
|
|
4
|
+
import {
|
|
5
|
+
PROTOCOL_V2_MAIN_FIRMWARE_TARGETS,
|
|
6
|
+
loadProtocolV2FirmwareReleaseContext,
|
|
7
|
+
summarizeProtocolV2FirmwareRelease,
|
|
8
|
+
toProtocolV2FirmwareReleaseInfo,
|
|
9
|
+
} from './firmware/protocolV2Release';
|
|
10
|
+
import { buildProtocolV2FirmwareRelease } from './CheckAllFirmwareRelease';
|
|
4
11
|
|
|
5
12
|
import type { CheckFirmwareReleaseParams } from '../types/api/checkFirmwareRelease';
|
|
6
13
|
|
|
7
14
|
export default class CheckFirmwareRelease extends BaseMethod {
|
|
15
|
+
getSupportedProtocols() {
|
|
16
|
+
return ['V1', 'V2'] as const;
|
|
17
|
+
}
|
|
18
|
+
|
|
8
19
|
init() {
|
|
9
20
|
this.allowDeviceMode = [
|
|
10
21
|
...this.allowDeviceMode,
|
|
@@ -15,16 +26,33 @@ export default class CheckFirmwareRelease extends BaseMethod {
|
|
|
15
26
|
this.skipForceUpdateCheck = true;
|
|
16
27
|
}
|
|
17
28
|
|
|
18
|
-
run() {
|
|
29
|
+
async run() {
|
|
19
30
|
const payload = this.payload as CheckFirmwareReleaseParams;
|
|
20
31
|
|
|
21
|
-
if (this.device.features)
|
|
22
|
-
const deviceFirmwareType = this.device.getCurrentFirmwareType();
|
|
23
|
-
const firmwareType = payload.firmwareType ?? deviceFirmwareType;
|
|
32
|
+
if (!this.device.features) return null;
|
|
24
33
|
|
|
25
|
-
|
|
26
|
-
|
|
34
|
+
if (this.device.isProtocolV2()) {
|
|
35
|
+
const { state, firmwareType, release } = await loadProtocolV2FirmwareReleaseContext({
|
|
36
|
+
device: this.device,
|
|
37
|
+
firmwareType: payload.firmwareType,
|
|
38
|
+
methodName: 'checkFirmwareRelease',
|
|
39
|
+
});
|
|
40
|
+
const plan = summarizeProtocolV2FirmwareRelease(
|
|
41
|
+
buildProtocolV2FirmwareRelease({
|
|
42
|
+
currentVersions: state.versions,
|
|
43
|
+
firmwareType,
|
|
44
|
+
release,
|
|
45
|
+
deviceType: state.identity.deviceType,
|
|
46
|
+
}),
|
|
47
|
+
PROTOCOL_V2_MAIN_FIRMWARE_TARGETS
|
|
48
|
+
);
|
|
49
|
+
return toProtocolV2FirmwareReleaseInfo({ plan, state, release });
|
|
27
50
|
}
|
|
28
|
-
|
|
51
|
+
|
|
52
|
+
const deviceFirmwareType = this.device.getCurrentFirmwareType();
|
|
53
|
+
const firmwareType = payload.firmwareType ?? deviceFirmwareType;
|
|
54
|
+
|
|
55
|
+
const releaseInfo = getFirmwareReleaseInfo(this.device.features, firmwareType);
|
|
56
|
+
return releaseInfo;
|
|
29
57
|
}
|
|
30
58
|
}
|