@onekeyfe/hd-core 1.2.0-alpha.95 → 1.2.0-alpha.97
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 +84 -404
- package/__tests__/firmware-update/device-update-bootloader.test.ts +2 -6
- package/__tests__/firmware-update/firmware-host-binding.test.ts +0 -9
- package/__tests__/firmware-update/firmware-update-bootloader-poll.test.ts +112 -0
- package/__tests__/firmware-update/firmware-update-plan.test.ts +70 -131
- package/__tests__/firmware-update/firmware-update-prepared-plan.test.ts +1 -53
- package/__tests__/protocol-v2-resources.test.ts +232 -148
- package/__tests__/protocol-v2.test.ts +517 -1106
- package/dist/api/CheckAllFirmwareRelease.d.ts +3 -2
- package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
- package/dist/api/CheckBLEFirmwareRelease.d.ts +2 -3
- package/dist/api/CheckBLEFirmwareRelease.d.ts.map +1 -1
- package/dist/api/CheckBootloaderRelease.d.ts +1 -2
- package/dist/api/CheckBootloaderRelease.d.ts.map +1 -1
- package/dist/api/CheckFirmwareRelease.d.ts +2 -3
- package/dist/api/CheckFirmwareRelease.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV2.d.ts +0 -1
- 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 -6
- 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/FirmwareUpdateBaseMethod.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts +1 -48
- package/dist/api/firmware/FirmwareUpdatePlan.d.ts.map +1 -1
- package/dist/api/firmware/FirmwareUpdatePreparedPlan.d.ts.map +1 -1
- package/dist/api/firmware/getBinary.d.ts +1 -0
- package/dist/api/firmware/getBinary.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +3 -4
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/index.d.ts +111 -103
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +849 -1301
- package/dist/protocols/protocol-v2/resources.d.ts +28 -10
- package/dist/protocols/protocol-v2/resources.d.ts.map +1 -1
- package/dist/types/api/checkAllFirmwareRelease.d.ts +8 -20
- package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/checkBLEFirmwareRelease.d.ts +13 -2
- package/dist/types/api/checkBLEFirmwareRelease.d.ts.map +1 -1
- package/dist/types/api/checkBootloaderRelease.d.ts +6 -2
- package/dist/types/api/checkBootloaderRelease.d.ts.map +1 -1
- package/dist/types/api/checkFirmwareRelease.d.ts +13 -2
- 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/export.d.ts +1 -1
- package/dist/types/api/export.d.ts.map +1 -1
- package/dist/types/api/firmwareUpdate.d.ts +11 -3
- package/dist/types/api/firmwareUpdate.d.ts.map +1 -1
- package/dist/types/settings.d.ts +36 -35
- package/dist/types/settings.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/CheckAllFirmwareRelease.ts +80 -108
- package/src/api/CheckBLEFirmwareRelease.ts +5 -37
- package/src/api/CheckBootloaderRelease.ts +3 -35
- package/src/api/CheckFirmwareRelease.ts +7 -35
- package/src/api/FirmwareUpdateV2.ts +3 -15
- package/src/api/FirmwareUpdateV3.ts +6 -13
- package/src/api/FirmwareUpdateV4.ts +407 -824
- package/src/api/UploadPortfolio.ts +0 -18
- package/src/api/device/DeviceUpdateBootloader.ts +5 -26
- package/src/api/firmware/FirmwareHostBinding.ts +3 -16
- package/src/api/firmware/FirmwareUpdateBaseMethod.ts +2 -0
- package/src/api/firmware/FirmwareUpdatePlan.ts +88 -226
- package/src/api/firmware/FirmwareUpdatePreparedPlan.ts +3 -10
- package/src/data-manager/DataManager.ts +19 -35
- package/src/index.ts +0 -10
- package/src/protocols/protocol-v2/resources.ts +341 -157
- package/src/types/api/checkAllFirmwareRelease.ts +12 -27
- package/src/types/api/checkBLEFirmwareRelease.ts +13 -4
- package/src/types/api/checkBootloaderRelease.ts +6 -2
- package/src/types/api/checkFirmwareRelease.ts +13 -2
- package/src/types/api/checkFirmwareTypeAvailable.ts +2 -2
- package/src/types/api/export.ts +1 -6
- package/src/types/api/firmwareUpdate.ts +16 -10
- package/src/types/settings.ts +61 -35
- package/src/utils/deviceFeaturesUtils.ts +2 -2
- package/__tests__/check-firmware-release-protocol-v2.test.ts +0 -199
- package/__tests__/firmware-memory-host.test.ts +0 -112
- package/__tests__/firmware-update/firmware-prepared-host-digest.test.ts +0 -448
- package/dist/api/firmware/FirmwareMemoryHost.d.ts +0 -22
- package/dist/api/firmware/FirmwareMemoryHost.d.ts.map +0 -1
- package/dist/api/firmware/protocolV2Release.d.ts +0 -33
- package/dist/api/firmware/protocolV2Release.d.ts.map +0 -1
- package/src/api/firmware/FirmwareMemoryHost.ts +0 -142
- package/src/api/firmware/protocolV2Release.ts +0 -168
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
EDeviceType,
|
|
3
|
+
EFirmwareType,
|
|
4
|
+
ERRORS,
|
|
5
|
+
HardwareError,
|
|
6
|
+
HardwareErrorCode,
|
|
7
|
+
} from '@onekeyfe/hd-shared';
|
|
2
8
|
import semver from 'semver';
|
|
3
9
|
|
|
4
10
|
import { BaseMethod } from './BaseMethod';
|
|
@@ -11,20 +17,13 @@ import {
|
|
|
11
17
|
} from './firmware/releaseHelper';
|
|
12
18
|
import {
|
|
13
19
|
buildFirmwareUpdatePlan,
|
|
14
|
-
buildProtocolV2FirmwareUpdatePlan,
|
|
15
20
|
validateFirmwareUpdatePlanForceTargets,
|
|
16
|
-
validateProtocolV2FirmwareUpdateTargets,
|
|
17
21
|
} from './firmware/FirmwareUpdatePlan';
|
|
18
|
-
import {
|
|
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
22
|
import { getBridgeReleaseInfo } from '../utils/bridgeUpdate';
|
|
23
|
+
import {
|
|
24
|
+
buildProtocolV2ResourceUpdatePlan,
|
|
25
|
+
readProtocolV2ResourceInventory,
|
|
26
|
+
} from '../protocols/protocol-v2/resources';
|
|
28
27
|
import {
|
|
29
28
|
LoggerNames,
|
|
30
29
|
getDeviceFirmwareVersion,
|
|
@@ -33,7 +32,6 @@ import {
|
|
|
33
32
|
getLogger,
|
|
34
33
|
} from '../utils';
|
|
35
34
|
|
|
36
|
-
import type { EFirmwareType } from '@onekeyfe/hd-shared';
|
|
37
35
|
import type {
|
|
38
36
|
AllFirmwareRelease,
|
|
39
37
|
CheckAllFirmwareReleaseParams,
|
|
@@ -175,7 +173,7 @@ function buildComponentRelease({
|
|
|
175
173
|
};
|
|
176
174
|
}
|
|
177
175
|
|
|
178
|
-
|
|
176
|
+
type ProtocolV2FirmwareReleasePlan = {
|
|
179
177
|
firmwareType: EFirmwareType;
|
|
180
178
|
status: ProtocolV2FirmwareReleaseStatus;
|
|
181
179
|
hasUpgrade: boolean;
|
|
@@ -386,23 +384,31 @@ export default class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
386
384
|
}
|
|
387
385
|
|
|
388
386
|
private async runProtocolV2(): Promise<AllFirmwareRelease> {
|
|
389
|
-
const {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
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',
|
|
387
|
+
const { checkFirmwareHash = false, firmwareType: firmwareTypeParam } = this
|
|
388
|
+
.payload as CheckAllFirmwareReleaseParams;
|
|
389
|
+
const state = await this.device.getDeviceState({
|
|
390
|
+
refreshSections: checkFirmwareHash
|
|
391
|
+
? ['identity', 'versions', 'verification']
|
|
392
|
+
: ['identity', 'versions'],
|
|
405
393
|
});
|
|
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);
|
|
406
412
|
const plan = buildProtocolV2FirmwareRelease({
|
|
407
413
|
currentVersions: state.versions,
|
|
408
414
|
currentVerification: checkFirmwareHash ? state.verification : undefined,
|
|
@@ -413,94 +419,60 @@ export default class CheckAllFirmwareRelease extends BaseMethod {
|
|
|
413
419
|
});
|
|
414
420
|
const resourceDeviceType =
|
|
415
421
|
state.identity.deviceType === 'neo' ? EDeviceType.Neo : EDeviceType.Pro2;
|
|
416
|
-
const
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
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;
|
|
422
|
+
const resources = DataManager.getProtocolV2Resources(resourceDeviceType);
|
|
423
|
+
let resourceStatus: 'valid' | 'outdated' | 'unknown' = 'unknown';
|
|
424
|
+
if (resources?.length) {
|
|
425
|
+
const loaderMode = state.status.mode === 'bootloader' || state.status.mode === 'romloader';
|
|
426
|
+
// Application mode rejects host access to vol0:/bundles. Resource inventory is
|
|
427
|
+
// resolved after FirmwareUpdateV4 enters a loader instead of probing here.
|
|
428
|
+
if (loaderMode) {
|
|
429
|
+
try {
|
|
430
|
+
const inventory = await readProtocolV2ResourceInventory({
|
|
431
|
+
commands: this.device.getCommands(),
|
|
432
|
+
resources,
|
|
433
|
+
});
|
|
434
|
+
resourceStatus = buildProtocolV2ResourceUpdatePlan({
|
|
435
|
+
resources,
|
|
436
|
+
inventory,
|
|
437
|
+
mode: 'bootloader-recovery',
|
|
438
|
+
}).status;
|
|
439
|
+
} catch {
|
|
440
|
+
resourceStatus = buildProtocolV2ResourceUpdatePlan({
|
|
441
|
+
resources,
|
|
442
|
+
mode: 'bootloader-recovery',
|
|
443
|
+
}).status;
|
|
444
|
+
}
|
|
468
445
|
}
|
|
469
|
-
Log.warn(
|
|
470
|
-
'[CheckAllFirmwareRelease] Optional Protocol V2 firmware Plan is unavailable; using the release result'
|
|
471
|
-
);
|
|
472
|
-
firmwareUpdatePlan = undefined;
|
|
473
446
|
}
|
|
474
|
-
const
|
|
475
|
-
plan,
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
const
|
|
479
|
-
const
|
|
480
|
-
const { status } = plan;
|
|
447
|
+
const targetsToUpdate = [
|
|
448
|
+
...plan.targetsToUpdate,
|
|
449
|
+
...(resourceStatus === 'outdated' ? (['resource'] as const) : []),
|
|
450
|
+
];
|
|
451
|
+
const firmwareStatus = plan.status === 'unavailable' ? 'unknown' : plan.status;
|
|
452
|
+
const emptyRelease = 'none' as const;
|
|
481
453
|
|
|
482
454
|
return {
|
|
483
|
-
firmware:
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
455
|
+
firmware: {
|
|
456
|
+
status: firmwareStatus,
|
|
457
|
+
changelog: release ? [release.changelog] : [],
|
|
458
|
+
release: release ?? emptyRelease,
|
|
459
|
+
bootloaderMode: state.status.mode === 'bootloader' || state.status.mode === 'romloader',
|
|
460
|
+
},
|
|
461
|
+
ble: {
|
|
462
|
+
status: 'valid',
|
|
463
|
+
release: emptyRelease,
|
|
464
|
+
},
|
|
465
|
+
bootloader: {
|
|
466
|
+
status: 'valid',
|
|
467
|
+
release: emptyRelease,
|
|
468
|
+
},
|
|
494
469
|
features,
|
|
495
470
|
protocol: 'V2',
|
|
496
471
|
deviceType: state.identity.deviceType,
|
|
497
472
|
...plan,
|
|
498
|
-
status,
|
|
499
473
|
resourceStatus,
|
|
500
|
-
|
|
501
|
-
hasUpgrade: targetsToUpdate.length > 0,
|
|
474
|
+
hasUpgrade: plan.hasUpgrade || resourceStatus === 'outdated',
|
|
502
475
|
targetsToUpdate,
|
|
503
|
-
firmwareUpdatePlan,
|
|
504
476
|
};
|
|
505
477
|
}
|
|
506
478
|
}
|
|
@@ -1,20 +1,8 @@
|
|
|
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';
|
|
12
4
|
|
|
13
5
|
export default class CheckBLEFirmwareRelease extends BaseMethod {
|
|
14
|
-
getSupportedProtocols() {
|
|
15
|
-
return ['V1', 'V2'] as const;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
6
|
init() {
|
|
19
7
|
this.allowDeviceMode = [
|
|
20
8
|
...this.allowDeviceMode,
|
|
@@ -25,31 +13,11 @@ export default class CheckBLEFirmwareRelease extends BaseMethod {
|
|
|
25
13
|
this.skipForceUpdateCheck = true;
|
|
26
14
|
}
|
|
27
15
|
|
|
28
|
-
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
});
|
|
16
|
+
run() {
|
|
17
|
+
if (this.device.features) {
|
|
18
|
+
const releaseInfo = getBleFirmwareReleaseInfo(this.device.features);
|
|
19
|
+
return Promise.resolve(releaseInfo);
|
|
50
20
|
}
|
|
51
|
-
|
|
52
|
-
const releaseInfo = getBleFirmwareReleaseInfo(this.device.features);
|
|
53
|
-
return releaseInfo;
|
|
21
|
+
return Promise.resolve(null);
|
|
54
22
|
}
|
|
55
23
|
}
|
|
@@ -1,22 +1,10 @@
|
|
|
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';
|
|
12
4
|
|
|
13
5
|
import type { CheckBootloaderReleaseParams } from '../types/api/checkBootloaderRelease';
|
|
14
6
|
|
|
15
7
|
export default class CheckBootloaderRelease extends BaseMethod {
|
|
16
|
-
getSupportedProtocols() {
|
|
17
|
-
return ['V1', 'V2'] as const;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
8
|
init() {
|
|
21
9
|
this.allowDeviceMode = [...this.allowDeviceMode, UI_REQUEST.BOOTLOADER];
|
|
22
10
|
this.useDevicePassphraseState = false;
|
|
@@ -24,32 +12,12 @@ export default class CheckBootloaderRelease extends BaseMethod {
|
|
|
24
12
|
}
|
|
25
13
|
|
|
26
14
|
async run() {
|
|
27
|
-
if (!this.device.features)
|
|
15
|
+
if (!this.device.features) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
28
18
|
const { features } = this.device;
|
|
29
19
|
const payload = this.payload as CheckBootloaderReleaseParams;
|
|
30
20
|
|
|
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
|
-
|
|
53
21
|
const deviceFirmwareType = this.device.getCurrentFirmwareType();
|
|
54
22
|
const firmwareType = payload.firmwareType ?? deviceFirmwareType;
|
|
55
23
|
|
|
@@ -1,21 +1,10 @@
|
|
|
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';
|
|
11
4
|
|
|
12
5
|
import type { CheckFirmwareReleaseParams } from '../types/api/checkFirmwareRelease';
|
|
13
6
|
|
|
14
7
|
export default class CheckFirmwareRelease extends BaseMethod {
|
|
15
|
-
getSupportedProtocols() {
|
|
16
|
-
return ['V1', 'V2'] as const;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
8
|
init() {
|
|
20
9
|
this.allowDeviceMode = [
|
|
21
10
|
...this.allowDeviceMode,
|
|
@@ -26,33 +15,16 @@ export default class CheckFirmwareRelease extends BaseMethod {
|
|
|
26
15
|
this.skipForceUpdateCheck = true;
|
|
27
16
|
}
|
|
28
17
|
|
|
29
|
-
|
|
18
|
+
run() {
|
|
30
19
|
const payload = this.payload as CheckFirmwareReleaseParams;
|
|
31
20
|
|
|
32
|
-
if (
|
|
21
|
+
if (this.device.features) {
|
|
22
|
+
const deviceFirmwareType = this.device.getCurrentFirmwareType();
|
|
23
|
+
const firmwareType = payload.firmwareType ?? deviceFirmwareType;
|
|
33
24
|
|
|
34
|
-
|
|
35
|
-
|
|
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 });
|
|
25
|
+
const releaseInfo = getFirmwareReleaseInfo(this.device.features, firmwareType);
|
|
26
|
+
return Promise.resolve(releaseInfo);
|
|
50
27
|
}
|
|
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;
|
|
28
|
+
return Promise.resolve(null);
|
|
57
29
|
}
|
|
58
30
|
}
|
|
@@ -33,7 +33,6 @@ import {
|
|
|
33
33
|
assertFirmwareUpdatePreparedPlanBinding,
|
|
34
34
|
assertFirmwareUpdatePreparedPlanDeviceIdentity,
|
|
35
35
|
getFirmwareUpdateResourceName,
|
|
36
|
-
validateFirmwareUpdatePreparedPlan,
|
|
37
36
|
} from './firmware/FirmwareUpdatePreparedPlan';
|
|
38
37
|
|
|
39
38
|
import type { Features, KnownDevice } from '../types';
|
|
@@ -47,7 +46,6 @@ import type { FirmwareUpdatePreparedPlan } from '../types/api/firmwareUpdatePrep
|
|
|
47
46
|
type Params = {
|
|
48
47
|
binary?: ArrayBuffer;
|
|
49
48
|
artifact?: FirmwareArtifactReference;
|
|
50
|
-
hostBindingGeneration?: number;
|
|
51
49
|
resourceEntries?: Array<{
|
|
52
50
|
entryName: string;
|
|
53
51
|
artifact: FirmwareArtifactReference;
|
|
@@ -172,12 +170,6 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
172
170
|
'Firmware update binary and artifact are mutually exclusive'
|
|
173
171
|
);
|
|
174
172
|
}
|
|
175
|
-
if (payload.preparedPlan !== undefined && payload.artifact === undefined) {
|
|
176
|
-
throw ERRORS.TypedError(
|
|
177
|
-
HardwareErrorCode.CallMethodInvalidParameter,
|
|
178
|
-
'Prepared firmware plans require a prepared artifact'
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
173
|
|
|
182
174
|
if (!payload.updateType) {
|
|
183
175
|
throw ERRORS.TypedError(
|
|
@@ -208,11 +200,7 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
208
200
|
}
|
|
209
201
|
|
|
210
202
|
if ('artifact' in payload) {
|
|
211
|
-
const
|
|
212
|
-
const hostBinding = resolveFirmwareUpdateHostBinding(
|
|
213
|
-
payload.hostBindingGeneration,
|
|
214
|
-
preparedPlan.preparedPlanDigest
|
|
215
|
-
);
|
|
203
|
+
const hostBinding = resolveFirmwareUpdateHostBinding(payload.hostBindingGeneration);
|
|
216
204
|
const target = payload.isUpdateBootloader ? 'bootloader' : payload.updateType;
|
|
217
205
|
const resourceBindings = (payload.resourceEntries ?? []).map(
|
|
218
206
|
(entry: { entryName: string; artifact: FirmwareArtifactReference }) => ({
|
|
@@ -222,7 +210,7 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
222
210
|
})
|
|
223
211
|
);
|
|
224
212
|
assertFirmwareUpdatePreparedPlanBinding({
|
|
225
|
-
preparedPlan,
|
|
213
|
+
preparedPlan: payload.preparedPlan,
|
|
226
214
|
executor: 'v2',
|
|
227
215
|
platform: payload.platform,
|
|
228
216
|
scopeTargets: [target, ...(target === 'firmware' ? (['resource'] as const) : [])],
|
|
@@ -230,7 +218,7 @@ export default class FirmwareUpdateV2 extends BaseMethod<Params> {
|
|
|
230
218
|
});
|
|
231
219
|
this.params = {
|
|
232
220
|
...this.params,
|
|
233
|
-
preparedPlan,
|
|
221
|
+
preparedPlan: payload.preparedPlan,
|
|
234
222
|
artifact: payload.artifact,
|
|
235
223
|
resourceEntries: payload.resourceEntries,
|
|
236
224
|
artifactReader: hostBinding.artifactReader,
|
|
@@ -25,7 +25,6 @@ import {
|
|
|
25
25
|
assertFirmwareUpdatePreparedPlanBinding,
|
|
26
26
|
assertFirmwareUpdatePreparedPlanDeviceIdentity,
|
|
27
27
|
getFirmwareUpdateResourceName,
|
|
28
|
-
validateFirmwareUpdatePreparedPlan,
|
|
29
28
|
} from './firmware/FirmwareUpdatePreparedPlan';
|
|
30
29
|
|
|
31
30
|
import type {
|
|
@@ -78,19 +77,13 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
78
77
|
{ name: 'firmwareType', type: 'string' },
|
|
79
78
|
{ name: 'platform', type: 'string' },
|
|
80
79
|
]);
|
|
81
|
-
const
|
|
80
|
+
const hostBinding =
|
|
82
81
|
payload.artifacts || payload.preparedPlan
|
|
83
|
-
?
|
|
82
|
+
? resolveFirmwareUpdateHostBinding(payload.hostBindingGeneration)
|
|
84
83
|
: undefined;
|
|
85
|
-
|
|
86
|
-
? resolveFirmwareUpdateHostBinding(
|
|
87
|
-
payload.hostBindingGeneration,
|
|
88
|
-
preparedPlan.preparedPlanDigest
|
|
89
|
-
).artifactReader
|
|
90
|
-
: payload.artifactReader;
|
|
91
|
-
if (preparedPlan) {
|
|
84
|
+
if (hostBinding) {
|
|
92
85
|
assertFirmwareUpdatePreparedPlanBinding({
|
|
93
|
-
preparedPlan,
|
|
86
|
+
preparedPlan: payload.preparedPlan,
|
|
94
87
|
executor: 'v3',
|
|
95
88
|
platform: payload.platform,
|
|
96
89
|
scopeTargets: ['bootloader', 'firmware', 'resource', 'ble'],
|
|
@@ -131,7 +124,7 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
131
124
|
}
|
|
132
125
|
|
|
133
126
|
this.params = {
|
|
134
|
-
preparedPlan,
|
|
127
|
+
preparedPlan: payload.preparedPlan,
|
|
135
128
|
bleBinary: payload.bleBinary,
|
|
136
129
|
firmwareBinary: payload.firmwareBinary,
|
|
137
130
|
forcedUpdateRes: payload.forcedUpdateRes,
|
|
@@ -142,7 +135,7 @@ export default class FirmwareUpdateV3 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
142
135
|
resourceBinary: payload.resourceBinary,
|
|
143
136
|
firmwareType: payload.firmwareType,
|
|
144
137
|
platform: payload.platform,
|
|
145
|
-
artifactReader,
|
|
138
|
+
artifactReader: hostBinding?.artifactReader ?? payload.artifactReader,
|
|
146
139
|
artifacts: payload.artifacts,
|
|
147
140
|
};
|
|
148
141
|
}
|