@onekeyfe/hd-core 1.2.0-alpha.40 → 1.2.0-alpha.42
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 +14 -1
- package/__tests__/protocol-v2-resources.test.ts +204 -0
- package/__tests__/protocol-v2.test.ts +152 -282
- package/dist/api/CheckAllFirmwareRelease.d.ts.map +1 -1
- package/dist/api/FirmwareUpdateV4.d.ts +2 -4
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/data-manager/DataManager.d.ts +3 -1
- package/dist/data-manager/DataManager.d.ts.map +1 -1
- package/dist/index.d.ts +24 -3
- package/dist/index.js +348 -217
- package/dist/protocols/protocol-v2/resources.d.ts +30 -0
- package/dist/protocols/protocol-v2/resources.d.ts.map +1 -0
- package/dist/types/api/checkAllFirmwareRelease.d.ts +1 -0
- package/dist/types/api/checkAllFirmwareRelease.d.ts.map +1 -1
- package/dist/types/settings.d.ts +12 -0
- package/dist/types/settings.d.ts.map +1 -1
- package/dist/utils/patch.d.ts +1 -1
- package/dist/utils/patch.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/CheckAllFirmwareRelease.ts +35 -3
- package/src/api/FirmwareUpdateV4.ts +76 -214
- package/src/data/messages/messages-protocol-v2.json +43 -0
- package/src/data-manager/DataManager.ts +32 -7
- package/src/protocols/protocol-v2/resources.ts +233 -0
- package/src/types/api/checkAllFirmwareRelease.ts +1 -0
- package/src/types/settings.ts +26 -0
|
@@ -3666,6 +3666,15 @@ describe('API compatibility handling', () => {
|
|
|
3666
3666
|
|
|
3667
3667
|
describe('Protocol V2 firmware update targets', () => {
|
|
3668
3668
|
const OKPP_HEADER_SIZE = 0x52a0;
|
|
3669
|
+
let forceReloadDataSpy: jest.SpyInstance<Promise<void>, []>;
|
|
3670
|
+
|
|
3671
|
+
beforeEach(() => {
|
|
3672
|
+
forceReloadDataSpy = jest.spyOn(DataManager, 'forceReloadData').mockResolvedValue(undefined);
|
|
3673
|
+
});
|
|
3674
|
+
|
|
3675
|
+
afterEach(() => {
|
|
3676
|
+
jest.restoreAllMocks();
|
|
3677
|
+
});
|
|
3669
3678
|
|
|
3670
3679
|
const buildOkppHeader = ({
|
|
3671
3680
|
type = 'RESC',
|
|
@@ -3955,6 +3964,9 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
3955
3964
|
},
|
|
3956
3965
|
});
|
|
3957
3966
|
(method as any).captureProtocolV2PhysicalIdentity = jest.fn().mockResolvedValue(undefined);
|
|
3967
|
+
const prepareResourceBundles = jest
|
|
3968
|
+
.spyOn(method as any, 'prepareProtocolV2ResourceBundles')
|
|
3969
|
+
.mockResolvedValue(undefined);
|
|
3958
3970
|
(method as any).protocolV2Reboot = jest.fn();
|
|
3959
3971
|
(method as any).executeProtocolV2Update = jest.fn().mockResolvedValue(undefined);
|
|
3960
3972
|
(method as any).exitProtocolV2BootloaderToNormal = jest.fn().mockResolvedValue(undefined);
|
|
@@ -3967,6 +3979,7 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
3967
3979
|
|
|
3968
3980
|
await method.run();
|
|
3969
3981
|
|
|
3982
|
+
expect(prepareResourceBundles).toHaveBeenCalledWith(true);
|
|
3970
3983
|
expect((method as any).protocolV2Reboot).not.toHaveBeenCalled();
|
|
3971
3984
|
expect((method as any).executeProtocolV2Update).toHaveBeenCalledWith({
|
|
3972
3985
|
bootloaderBinary: null,
|
|
@@ -4979,272 +4992,6 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
4979
4992
|
getFirmwareLatestReleaseSpy.mockRestore();
|
|
4980
4993
|
});
|
|
4981
4994
|
|
|
4982
|
-
test('maps remote Pro2 resource bundles to direct-write descriptors', () => {
|
|
4983
|
-
const method = new FirmwareUpdateV4({
|
|
4984
|
-
id: 1,
|
|
4985
|
-
payload: {
|
|
4986
|
-
method: 'firmwareUpdateV4',
|
|
4987
|
-
platform: 'web',
|
|
4988
|
-
targetsToUpdate: ['resource'],
|
|
4989
|
-
},
|
|
4990
|
-
});
|
|
4991
|
-
method.init();
|
|
4992
|
-
|
|
4993
|
-
const getFirmwareLatestReleaseSpy = jest
|
|
4994
|
-
.spyOn(DataManager, 'getFirmwareLatestRelease')
|
|
4995
|
-
.mockReturnValue({
|
|
4996
|
-
required: false,
|
|
4997
|
-
version: [1, 0, 0],
|
|
4998
|
-
url: '',
|
|
4999
|
-
resourceBundles: [
|
|
5000
|
-
{
|
|
5001
|
-
name: 'images',
|
|
5002
|
-
url: 'https://example.com/images.okpkg',
|
|
5003
|
-
devicePath: 'VOL0:/resource/images/images.okpkg',
|
|
5004
|
-
version: [2, 0, 0],
|
|
5005
|
-
payloadHash: 'ab'.repeat(64),
|
|
5006
|
-
headerHash: 'cd'.repeat(64),
|
|
5007
|
-
},
|
|
5008
|
-
],
|
|
5009
|
-
fingerprint: '',
|
|
5010
|
-
changelog: {
|
|
5011
|
-
'zh-CN': '',
|
|
5012
|
-
'en-US': '',
|
|
5013
|
-
},
|
|
5014
|
-
});
|
|
5015
|
-
|
|
5016
|
-
const bundles = (method as any).prepareProtocolV2ResourceBundles('universal', {
|
|
5017
|
-
deviceType: 'pro2',
|
|
5018
|
-
firmwareVersion: '1.0.0',
|
|
5019
|
-
capabilities: [],
|
|
5020
|
-
});
|
|
5021
|
-
|
|
5022
|
-
expect(bundles).toEqual([
|
|
5023
|
-
{
|
|
5024
|
-
name: 'images',
|
|
5025
|
-
binary: expect.any(ArrayBuffer),
|
|
5026
|
-
devicePath: 'vol0:/resource/images/images.okpkg',
|
|
5027
|
-
url: 'https://example.com/images.okpkg',
|
|
5028
|
-
version: [2, 0, 0],
|
|
5029
|
-
payloadHash: 'ab'.repeat(64),
|
|
5030
|
-
headerHash: 'cd'.repeat(64),
|
|
5031
|
-
},
|
|
5032
|
-
]);
|
|
5033
|
-
expect(bundles[0].binary.byteLength).toBe(0);
|
|
5034
|
-
|
|
5035
|
-
getFirmwareLatestReleaseSpy.mockRestore();
|
|
5036
|
-
});
|
|
5037
|
-
|
|
5038
|
-
test('rejects remote RESC bundle paths before download or bootloader entry', async () => {
|
|
5039
|
-
const method = new FirmwareUpdateV4({
|
|
5040
|
-
id: 1,
|
|
5041
|
-
payload: {
|
|
5042
|
-
method: 'firmwareUpdateV4',
|
|
5043
|
-
platform: 'web',
|
|
5044
|
-
targetsToUpdate: ['resource'],
|
|
5045
|
-
},
|
|
5046
|
-
});
|
|
5047
|
-
method.init();
|
|
5048
|
-
(method as any).captureProtocolV2PhysicalIdentity = jest.fn().mockResolvedValue(undefined);
|
|
5049
|
-
|
|
5050
|
-
const getSysResourceBinarySpy = jest.spyOn(firmwareBinaryApi, 'getSysResourceBinary');
|
|
5051
|
-
const getFirmwareLatestReleaseSpy = jest
|
|
5052
|
-
.spyOn(DataManager, 'getFirmwareLatestRelease')
|
|
5053
|
-
.mockReturnValue({
|
|
5054
|
-
required: false,
|
|
5055
|
-
version: [1, 0, 0],
|
|
5056
|
-
url: '',
|
|
5057
|
-
resourceBundles: [
|
|
5058
|
-
{
|
|
5059
|
-
name: 'images',
|
|
5060
|
-
url: 'https://example.com/images.okpkg',
|
|
5061
|
-
devicePath: 'vol0:/resource/../images.okpkg',
|
|
5062
|
-
},
|
|
5063
|
-
],
|
|
5064
|
-
fingerprint: '',
|
|
5065
|
-
changelog: {
|
|
5066
|
-
'zh-CN': '',
|
|
5067
|
-
'en-US': '',
|
|
5068
|
-
},
|
|
5069
|
-
});
|
|
5070
|
-
|
|
5071
|
-
(method as any).device = stubDevice({
|
|
5072
|
-
originalDescriptor: { protocolType: 'V2' },
|
|
5073
|
-
features: { deviceType: 'pro2', firmwareVersion: '1.0.0', capabilities: [] },
|
|
5074
|
-
});
|
|
5075
|
-
(method as any).prepareRemoteProtocolV2Binaries = jest.fn().mockResolvedValue({
|
|
5076
|
-
bootloaderBinary: null,
|
|
5077
|
-
fwBinaryMap: [],
|
|
5078
|
-
});
|
|
5079
|
-
(method as any).enterProtocolV2BootloaderMode = jest.fn();
|
|
5080
|
-
method.postTipMessage = jest.fn();
|
|
5081
|
-
|
|
5082
|
-
await expect(method.run()).rejects.toThrow('resourceBundles[0].devicePath');
|
|
5083
|
-
expect(getSysResourceBinarySpy).not.toHaveBeenCalled();
|
|
5084
|
-
expect((method as any).enterProtocolV2BootloaderMode).not.toHaveBeenCalled();
|
|
5085
|
-
|
|
5086
|
-
getSysResourceBinarySpy.mockRestore();
|
|
5087
|
-
getFirmwareLatestReleaseSpy.mockRestore();
|
|
5088
|
-
});
|
|
5089
|
-
|
|
5090
|
-
test('downloads and validates remote RESC bundles before entering bootloader', async () => {
|
|
5091
|
-
const method = new FirmwareUpdateV4({
|
|
5092
|
-
id: 1,
|
|
5093
|
-
payload: {
|
|
5094
|
-
method: 'firmwareUpdateV4',
|
|
5095
|
-
platform: 'web',
|
|
5096
|
-
targetsToUpdate: ['resource'],
|
|
5097
|
-
},
|
|
5098
|
-
});
|
|
5099
|
-
method.init();
|
|
5100
|
-
(method as any).captureProtocolV2PhysicalIdentity = jest.fn().mockResolvedValue(undefined);
|
|
5101
|
-
|
|
5102
|
-
const order: string[] = [];
|
|
5103
|
-
const resourceBinary = buildOkppHeader().buffer as ArrayBuffer;
|
|
5104
|
-
const getSysResourceBinarySpy = jest
|
|
5105
|
-
.spyOn(firmwareBinaryApi, 'getSysResourceBinary')
|
|
5106
|
-
.mockImplementation(() => {
|
|
5107
|
-
order.push('download');
|
|
5108
|
-
return Promise.resolve({ binary: resourceBinary });
|
|
5109
|
-
});
|
|
5110
|
-
const getFirmwareLatestReleaseSpy = jest
|
|
5111
|
-
.spyOn(DataManager, 'getFirmwareLatestRelease')
|
|
5112
|
-
.mockReturnValue({
|
|
5113
|
-
required: false,
|
|
5114
|
-
version: [1, 0, 0],
|
|
5115
|
-
url: '',
|
|
5116
|
-
resourceBundles: [
|
|
5117
|
-
{
|
|
5118
|
-
name: 'images',
|
|
5119
|
-
url: 'https://example.com/images.okpkg',
|
|
5120
|
-
devicePath: ' VOL0:/resource/images/images.okpkg ',
|
|
5121
|
-
},
|
|
5122
|
-
],
|
|
5123
|
-
fingerprint: '',
|
|
5124
|
-
changelog: {
|
|
5125
|
-
'zh-CN': '',
|
|
5126
|
-
'en-US': '',
|
|
5127
|
-
},
|
|
5128
|
-
});
|
|
5129
|
-
|
|
5130
|
-
(method as any).device = stubDevice({
|
|
5131
|
-
originalDescriptor: { protocolType: 'V2' },
|
|
5132
|
-
features: { deviceType: 'pro2', firmwareVersion: '1.0.0', capabilities: [] },
|
|
5133
|
-
});
|
|
5134
|
-
(method as any).prepareRemoteProtocolV2Binaries = jest.fn().mockResolvedValue({
|
|
5135
|
-
bootloaderBinary: null,
|
|
5136
|
-
fwBinaryMap: [],
|
|
5137
|
-
});
|
|
5138
|
-
(method as any).enterProtocolV2BootloaderMode = jest.fn().mockImplementation(() => {
|
|
5139
|
-
order.push('bootloader');
|
|
5140
|
-
return Promise.resolve(true);
|
|
5141
|
-
});
|
|
5142
|
-
(method as any).executeProtocolV2Update = jest.fn().mockResolvedValue(undefined);
|
|
5143
|
-
(method as any).exitProtocolV2BootloaderToNormal = jest.fn().mockResolvedValue(undefined);
|
|
5144
|
-
(method as any).waitForProtocolV2FinalFeatures = jest.fn().mockResolvedValue({
|
|
5145
|
-
bootloaderVersion: '1.0.0',
|
|
5146
|
-
bleVersion: '0.0.0',
|
|
5147
|
-
firmwareVersion: '1.0.0',
|
|
5148
|
-
});
|
|
5149
|
-
method.postTipMessage = jest.fn();
|
|
5150
|
-
|
|
5151
|
-
await method.run();
|
|
5152
|
-
|
|
5153
|
-
expect(order).toEqual(['download', 'bootloader']);
|
|
5154
|
-
expect((method as any).executeProtocolV2Update).toHaveBeenCalledWith({
|
|
5155
|
-
bootloaderBinary: null,
|
|
5156
|
-
fwBinaryMap: [],
|
|
5157
|
-
resourceBundles: [
|
|
5158
|
-
{
|
|
5159
|
-
name: 'images',
|
|
5160
|
-
binary: resourceBinary,
|
|
5161
|
-
devicePath: 'vol0:/resource/images/images.okpkg',
|
|
5162
|
-
url: 'https://example.com/images.okpkg',
|
|
5163
|
-
},
|
|
5164
|
-
],
|
|
5165
|
-
});
|
|
5166
|
-
|
|
5167
|
-
getSysResourceBinarySpy.mockRestore();
|
|
5168
|
-
getFirmwareLatestReleaseSpy.mockRestore();
|
|
5169
|
-
});
|
|
5170
|
-
|
|
5171
|
-
test('rejects a remote RESC bundle without an OKPP header when metadata is absent', async () => {
|
|
5172
|
-
const method = new FirmwareUpdateV4({
|
|
5173
|
-
id: 1,
|
|
5174
|
-
payload: {
|
|
5175
|
-
method: 'firmwareUpdateV4',
|
|
5176
|
-
},
|
|
5177
|
-
});
|
|
5178
|
-
const getSysResourceBinarySpy = jest
|
|
5179
|
-
.spyOn(firmwareBinaryApi, 'getSysResourceBinary')
|
|
5180
|
-
.mockResolvedValue({ binary: new Uint8Array([1, 2, 3]).buffer });
|
|
5181
|
-
|
|
5182
|
-
await expect(
|
|
5183
|
-
(method as any).prefetchProtocolV2ResourceBundles([
|
|
5184
|
-
{
|
|
5185
|
-
name: 'images',
|
|
5186
|
-
binary: new ArrayBuffer(0),
|
|
5187
|
-
devicePath: 'vol0:/resource/images/images.okpkg',
|
|
5188
|
-
url: 'https://example.com/images.okpkg',
|
|
5189
|
-
},
|
|
5190
|
-
])
|
|
5191
|
-
).rejects.toThrow('Invalid Protocol V2 RESC bundle header: images');
|
|
5192
|
-
|
|
5193
|
-
getSysResourceBinarySpy.mockRestore();
|
|
5194
|
-
});
|
|
5195
|
-
|
|
5196
|
-
test('rejects an empty remote RESC bundle before entering bootloader', async () => {
|
|
5197
|
-
const method = new FirmwareUpdateV4({
|
|
5198
|
-
id: 1,
|
|
5199
|
-
payload: {
|
|
5200
|
-
method: 'firmwareUpdateV4',
|
|
5201
|
-
platform: 'web',
|
|
5202
|
-
targetsToUpdate: ['resource'],
|
|
5203
|
-
},
|
|
5204
|
-
});
|
|
5205
|
-
method.init();
|
|
5206
|
-
(method as any).captureProtocolV2PhysicalIdentity = jest.fn().mockResolvedValue(undefined);
|
|
5207
|
-
|
|
5208
|
-
const getSysResourceBinarySpy = jest
|
|
5209
|
-
.spyOn(firmwareBinaryApi, 'getSysResourceBinary')
|
|
5210
|
-
.mockResolvedValue({ binary: new ArrayBuffer(0) });
|
|
5211
|
-
const getFirmwareLatestReleaseSpy = jest
|
|
5212
|
-
.spyOn(DataManager, 'getFirmwareLatestRelease')
|
|
5213
|
-
.mockReturnValue({
|
|
5214
|
-
required: false,
|
|
5215
|
-
version: [1, 0, 0],
|
|
5216
|
-
url: '',
|
|
5217
|
-
resourceBundles: [
|
|
5218
|
-
{
|
|
5219
|
-
name: 'images',
|
|
5220
|
-
url: 'https://example.com/images.okpkg',
|
|
5221
|
-
devicePath: 'vol0:/resource/images/images.okpkg',
|
|
5222
|
-
},
|
|
5223
|
-
],
|
|
5224
|
-
fingerprint: '',
|
|
5225
|
-
changelog: {
|
|
5226
|
-
'zh-CN': '',
|
|
5227
|
-
'en-US': '',
|
|
5228
|
-
},
|
|
5229
|
-
});
|
|
5230
|
-
(method as any).device = stubDevice({
|
|
5231
|
-
originalDescriptor: { protocolType: 'V2' },
|
|
5232
|
-
features: { deviceType: 'pro2', firmwareVersion: '1.0.0', capabilities: [] },
|
|
5233
|
-
});
|
|
5234
|
-
(method as any).prepareRemoteProtocolV2Binaries = jest.fn().mockResolvedValue({
|
|
5235
|
-
bootloaderBinary: null,
|
|
5236
|
-
fwBinaryMap: [],
|
|
5237
|
-
});
|
|
5238
|
-
(method as any).enterProtocolV2BootloaderMode = jest.fn();
|
|
5239
|
-
method.postTipMessage = jest.fn();
|
|
5240
|
-
|
|
5241
|
-
await expect(method.run()).rejects.toThrow('Protocol V2 RESC bundle is empty: images');
|
|
5242
|
-
expect((method as any).enterProtocolV2BootloaderMode).not.toHaveBeenCalled();
|
|
5243
|
-
|
|
5244
|
-
getSysResourceBinarySpy.mockRestore();
|
|
5245
|
-
getFirmwareLatestReleaseSpy.mockRestore();
|
|
5246
|
-
});
|
|
5247
|
-
|
|
5248
4995
|
test('does not download Pro2 firmware components that App did not select', async () => {
|
|
5249
4996
|
const method = new FirmwareUpdateV4({
|
|
5250
4997
|
id: 1,
|
|
@@ -5345,6 +5092,7 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
5345
5092
|
|
|
5346
5093
|
await method.run();
|
|
5347
5094
|
|
|
5095
|
+
expect(forceReloadDataSpy).toHaveBeenCalledTimes(1);
|
|
5348
5096
|
expect((method as any).prepareRemoteProtocolV2Binaries).toHaveBeenCalledTimes(1);
|
|
5349
5097
|
expect((method as any).executeProtocolV2Update).toHaveBeenCalledWith({
|
|
5350
5098
|
bootloaderBinary: remoteBinaries.bootloaderBinary,
|
|
@@ -5352,6 +5100,31 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
5352
5100
|
});
|
|
5353
5101
|
});
|
|
5354
5102
|
|
|
5103
|
+
test('stops a remote update before reboot when the latest config cannot be refreshed', async () => {
|
|
5104
|
+
const method = new FirmwareUpdateV4({
|
|
5105
|
+
id: 1,
|
|
5106
|
+
payload: {
|
|
5107
|
+
method: 'firmwareUpdateV4',
|
|
5108
|
+
platform: 'web',
|
|
5109
|
+
},
|
|
5110
|
+
});
|
|
5111
|
+
method.init();
|
|
5112
|
+
(method as any).captureProtocolV2PhysicalIdentity = jest.fn().mockResolvedValue(undefined);
|
|
5113
|
+
(method as any).device = stubDevice({
|
|
5114
|
+
originalDescriptor: { protocolType: 'V2' },
|
|
5115
|
+
features: { deviceType: 'pro2', firmwareVersion: '0.0.0', capabilities: [] },
|
|
5116
|
+
});
|
|
5117
|
+
forceReloadDataSpy.mockRejectedValue(new Error('latest config unavailable'));
|
|
5118
|
+
(method as any).prepareRemoteProtocolV2Binaries = jest.fn();
|
|
5119
|
+
(method as any).enterProtocolV2BootloaderMode = jest.fn();
|
|
5120
|
+
method.postTipMessage = jest.fn();
|
|
5121
|
+
|
|
5122
|
+
await expect(method.run()).rejects.toThrow('latest config unavailable');
|
|
5123
|
+
|
|
5124
|
+
expect((method as any).prepareRemoteProtocolV2Binaries).not.toHaveBeenCalled();
|
|
5125
|
+
expect((method as any).enterProtocolV2BootloaderMode).not.toHaveBeenCalled();
|
|
5126
|
+
});
|
|
5127
|
+
|
|
5355
5128
|
test('keeps explicit Protocol V2 binaries isolated from remote component auto-fill', async () => {
|
|
5356
5129
|
const method = new FirmwareUpdateV4({
|
|
5357
5130
|
id: 1,
|
|
@@ -6026,34 +5799,131 @@ describe('Protocol V2 firmware reconnect identity', () => {
|
|
|
6026
5799
|
});
|
|
6027
5800
|
});
|
|
6028
5801
|
|
|
6029
|
-
test('uses
|
|
5802
|
+
test('uses ResourceInventory instead of host-side FileRead for resource comparison', async () => {
|
|
6030
5803
|
const method = new FirmwareUpdateV4({
|
|
6031
5804
|
id: 1,
|
|
6032
5805
|
payload: {
|
|
6033
5806
|
method: 'firmwareUpdateV4',
|
|
6034
|
-
platform: '
|
|
6035
|
-
|
|
5807
|
+
platform: 'web',
|
|
5808
|
+
targetsToUpdate: ['resource'],
|
|
6036
5809
|
},
|
|
6037
5810
|
});
|
|
6038
5811
|
method.init();
|
|
6039
|
-
const
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
5812
|
+
const stable = ['images', 'animation', 'wallpaper', 'translations', 'roobert', 'noto'].map(
|
|
5813
|
+
(type, index) => ({
|
|
5814
|
+
type,
|
|
5815
|
+
url: `https://example.com/${type}.okpkg`,
|
|
5816
|
+
size: index + 1,
|
|
5817
|
+
fileHash: 'a'.repeat(64),
|
|
5818
|
+
headerHash: index.toString(16).padStart(128, '0'),
|
|
5819
|
+
})
|
|
5820
|
+
);
|
|
5821
|
+
const typedCall = jest.fn().mockResolvedValue({
|
|
5822
|
+
message: {
|
|
5823
|
+
items: stable.map(item => ({
|
|
5824
|
+
type: item.type.toUpperCase(),
|
|
5825
|
+
size: item.size,
|
|
5826
|
+
header_hash: item.headerHash,
|
|
5827
|
+
})),
|
|
5828
|
+
},
|
|
6049
5829
|
});
|
|
6050
5830
|
(method as any).device = stubDevice({
|
|
6051
5831
|
getCommands: () => ({ typedCall }),
|
|
6052
5832
|
});
|
|
5833
|
+
const resourcesSpy = jest
|
|
5834
|
+
.spyOn(DataManager, 'getProtocolV2Resources')
|
|
5835
|
+
.mockReturnValue(stable as any);
|
|
5836
|
+
(method as any).downloadProtocolV2Resource = jest.fn();
|
|
5837
|
+
|
|
5838
|
+
await expect((method as any).prepareProtocolV2ResourceBundles(false)).resolves.toEqual([]);
|
|
5839
|
+
expect(typedCall).toHaveBeenCalledWith(
|
|
5840
|
+
'ResourceInventoryGet',
|
|
5841
|
+
'ResourceInventory',
|
|
5842
|
+
{},
|
|
5843
|
+
{ timeoutMs: 5000 }
|
|
5844
|
+
);
|
|
5845
|
+
expect(typedCall.mock.calls.some(call => call[0] === 'FilesystemFileRead')).toBe(false);
|
|
5846
|
+
expect((method as any).downloadProtocolV2Resource).not.toHaveBeenCalled();
|
|
5847
|
+
resourcesSpy.mockRestore();
|
|
5848
|
+
});
|
|
6053
5849
|
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
5850
|
+
test('downloads only changed resources in Application mode', async () => {
|
|
5851
|
+
const method = new FirmwareUpdateV4({
|
|
5852
|
+
id: 1,
|
|
5853
|
+
payload: { method: 'firmwareUpdateV4', platform: 'web', targetsToUpdate: ['resource'] },
|
|
5854
|
+
});
|
|
5855
|
+
method.init();
|
|
5856
|
+
const stable = ['images', 'animation', 'wallpaper', 'translations', 'roobert', 'noto'].map(
|
|
5857
|
+
(type, index) => ({
|
|
5858
|
+
type,
|
|
5859
|
+
url: `https://example.com/${type}.okpkg`,
|
|
5860
|
+
size: index + 1,
|
|
5861
|
+
fileHash: 'a'.repeat(64),
|
|
5862
|
+
headerHash: index.toString(16).padStart(128, '0'),
|
|
5863
|
+
})
|
|
5864
|
+
);
|
|
5865
|
+
const typedCall = jest.fn().mockResolvedValue({
|
|
5866
|
+
message: {
|
|
5867
|
+
items: stable.slice(1).map(item => ({
|
|
5868
|
+
type: item.type.toUpperCase(),
|
|
5869
|
+
size: item.size,
|
|
5870
|
+
header_hash: item.headerHash,
|
|
5871
|
+
})),
|
|
5872
|
+
},
|
|
5873
|
+
});
|
|
5874
|
+
(method as any).device = stubDevice({ getCommands: () => ({ typedCall }) });
|
|
5875
|
+
const resourcesSpy = jest
|
|
5876
|
+
.spyOn(DataManager, 'getProtocolV2Resources')
|
|
5877
|
+
.mockReturnValue(stable as any);
|
|
5878
|
+
(method as any).downloadProtocolV2Resource = jest.fn(resource =>
|
|
5879
|
+
Promise.resolve({
|
|
5880
|
+
name: `${resource.type}.okpkg`,
|
|
5881
|
+
binary: new ArrayBuffer(resource.size),
|
|
5882
|
+
devicePath: `vol0:/${resource.type}.okpkg`,
|
|
5883
|
+
})
|
|
5884
|
+
);
|
|
5885
|
+
|
|
5886
|
+
const bundles = await (method as any).prepareProtocolV2ResourceBundles(false);
|
|
5887
|
+
|
|
5888
|
+
expect(bundles).toHaveLength(1);
|
|
5889
|
+
expect((method as any).downloadProtocolV2Resource).toHaveBeenCalledWith(stable[0]);
|
|
5890
|
+
resourcesSpy.mockRestore();
|
|
5891
|
+
});
|
|
5892
|
+
|
|
5893
|
+
test('downloads all six resources in Bootloader recovery without inventory RPC', async () => {
|
|
5894
|
+
const method = new FirmwareUpdateV4({
|
|
5895
|
+
id: 1,
|
|
5896
|
+
payload: { method: 'firmwareUpdateV4', platform: 'web', targetsToUpdate: ['resource'] },
|
|
5897
|
+
});
|
|
5898
|
+
method.init();
|
|
5899
|
+
const stable = ['images', 'animation', 'wallpaper', 'translations', 'roobert', 'noto'].map(
|
|
5900
|
+
(type, index) => ({
|
|
5901
|
+
type,
|
|
5902
|
+
url: `https://example.com/${type}.okpkg`,
|
|
5903
|
+
size: index + 1,
|
|
5904
|
+
fileHash: 'a'.repeat(64),
|
|
5905
|
+
headerHash: index.toString(16).padStart(128, '0'),
|
|
5906
|
+
})
|
|
5907
|
+
);
|
|
5908
|
+
const typedCall = jest.fn();
|
|
5909
|
+
(method as any).device = stubDevice({ getCommands: () => ({ typedCall }) });
|
|
5910
|
+
const resourcesSpy = jest
|
|
5911
|
+
.spyOn(DataManager, 'getProtocolV2Resources')
|
|
5912
|
+
.mockReturnValue(stable as any);
|
|
5913
|
+
(method as any).downloadProtocolV2Resource = jest.fn(resource =>
|
|
5914
|
+
Promise.resolve({
|
|
5915
|
+
name: `${resource.type}.okpkg`,
|
|
5916
|
+
binary: new ArrayBuffer(resource.size),
|
|
5917
|
+
devicePath: `vol0:/${resource.type}.okpkg`,
|
|
5918
|
+
})
|
|
5919
|
+
);
|
|
5920
|
+
|
|
5921
|
+
const bundles = await (method as any).prepareProtocolV2ResourceBundles(true);
|
|
5922
|
+
|
|
5923
|
+
expect(bundles).toHaveLength(6);
|
|
5924
|
+
expect(typedCall).not.toHaveBeenCalled();
|
|
5925
|
+
expect((method as any).downloadProtocolV2Resource).toHaveBeenCalledTimes(6);
|
|
5926
|
+
resourcesSpy.mockRestore();
|
|
6057
5927
|
});
|
|
6058
5928
|
});
|
|
6059
5929
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckAllFirmwareRelease.d.ts","sourceRoot":"","sources":["../../src/api/CheckAllFirmwareRelease.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA6B,MAAM,qBAAqB,CAAC;AAY/E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"CheckAllFirmwareRelease.d.ts","sourceRoot":"","sources":["../../src/api/CheckAllFirmwareRelease.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA6B,MAAM,qBAAqB,CAAC;AAY/E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAM1C,OAAO,KAAK,EACV,kBAAkB,EAElB,kCAAkC,EAClC,+BAA+B,EAChC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EAGrB,MAAM,UAAU,CAAC;AA6HlB,KAAK,6BAA6B,GAAG;IACnC,YAAY,EAAE,aAAa,CAAC;IAC5B,MAAM,EAAE,+BAA+B,CAAC;IACxC,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,eAAe,EAAE,mBAAmB,CAAC;IACrC,UAAU,EAAE,kCAAkC,EAAE,CAAC;IACjD,eAAe,EAAE,sBAAsB,EAAE,CAAC;IAC1C,OAAO,EAAE,oBAAoB,GAAG,SAAS,CAAC;CAC3C,CAAC;AAEF,wBAAgB,8BAA8B,CAAC,EAC7C,eAAe,EACf,mBAAwB,EACxB,mBAAwB,EACxB,YAAY,EACZ,OAAO,GACR,EAAE;IACD,eAAe,EAAE,mBAAmB,CAAC;IACrC,mBAAmB,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACpD,mBAAmB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;IAC9D,YAAY,EAAE,aAAa,CAAC;IAC5B,OAAO,EAAE,oBAAoB,GAAG,SAAS,CAAC;CAC3C,GAAG,6BAA6B,CAoEhC;AAED,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,UAAU;IAC7D,qBAAqB;IAIrB,IAAI;IAME,GAAG;YAuDK,aAAa;CAoF5B"}
|
|
@@ -24,14 +24,11 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
24
24
|
private buildProtocolV2InstallItems;
|
|
25
25
|
private getRemoteComponentEntries;
|
|
26
26
|
private getRemoteComponentTarget;
|
|
27
|
-
private getProtocolV2ResourceFilePath;
|
|
28
|
-
private readProtocolV2DeviceFileHeader;
|
|
29
27
|
private downloadRemoteProtocolV2Component;
|
|
30
28
|
private prepareRemoteProtocolV2Binaries;
|
|
31
29
|
private prepareProtocolV2ResourceBundles;
|
|
32
|
-
private
|
|
30
|
+
private downloadProtocolV2Resource;
|
|
33
31
|
private syncProtocolV2ResourceBundles;
|
|
34
|
-
private isProtocolV2ResourceBundleUpToDate;
|
|
35
32
|
private isProtocolV2BootloaderMode;
|
|
36
33
|
private isProtocolV2RomloaderMode;
|
|
37
34
|
enterProtocolV2BootloaderMode(): Promise<boolean>;
|
|
@@ -45,6 +42,7 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
45
42
|
private exitProtocolV2BootloaderToNormal;
|
|
46
43
|
private probeProtocolV2NormalMode;
|
|
47
44
|
private waitForProtocolV2FinalFeatures;
|
|
45
|
+
private getProtocolV2VersionResult;
|
|
48
46
|
private waitForProtocolV2ReconnectAndFeatures;
|
|
49
47
|
private reconnectProtocolV2Device;
|
|
50
48
|
private ensureProtocolV2DeviceAcquired;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FirmwareUpdateV4.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdateV4.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FirmwareUpdateV4.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdateV4.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAkB/E,OAAO,KAAK,EAAE,sBAAsB,EAA0B,MAAM,6BAA6B,CAAC;AA+TlG,eAAO,MAAM,oCAAoC,WACvC,WAAW,GAAG,UAAU,eACnB,MAAM,GAAG,SAAS,YAKhC,CAAC;AAEF,eAAO,MAAM,iCAAiC,0BACrB,MAAM,uBACR,MAAM,SAc5B,CAAC;AAUF,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,wBAAwB,CAAC,sBAAsB,CAAC;IAC5F,OAAO,CAAC,8BAA8B,CAAC,CAAS;IAEhD,qBAAqB;IAIrB,IAAI;IA2DJ,OAAO,CAAC,8BAA8B;IAiBhC,GAAG;;;;;YAKK,aAAa;YAqEb,2BAA2B;IAWzC,OAAO,CAAC,yBAAyB;IAKjC,OAAO,CAAC,kCAAkC;YAO5B,iCAAiC;YAOjC,iCAAiC;YAOjC,iCAAiC;IAM/C,OAAO,CAAC,uBAAuB;IAI/B,OAAO,CAAC,4BAA4B;IAQpC,OAAO,CAAC,2BAA2B;IAsBnC,OAAO,CAAC,yBAAyB;IAiBjC,OAAO,CAAC,wBAAwB;YAkBlB,iCAAiC;YAmCjC,+BAA+B;YAqD/B,gCAAgC;YAmDhC,0BAA0B;YAe1B,6BAA6B;IAkC3C,OAAO,CAAC,0BAA0B;IAUlC,OAAO,CAAC,yBAAyB;IAU3B,6BAA6B;YA4BrB,+BAA+B;IA6C7C,OAAO,CAAC,6BAA6B;YAkCvB,uBAAuB;IA4GrC,OAAO,CAAC,mCAAmC;YAI7B,0BAA0B;IAaxC,OAAO,CAAC,4BAA4B;YAgEtB,uCAAuC;YA+EvC,gCAAgC;YAQhC,yBAAyB;YAQzB,8BAA8B;IAQ5C,OAAO,CAAC,0BAA0B;YAiBpB,qCAAqC;YA2CrC,yBAAyB;YAiDzB,8BAA8B;IAU5C,OAAO,CAAC,kCAAkC;YAI5B,6BAA6B;YAwB7B,wBAAwB;IAoDtC,OAAO,CAAC,sCAAsC;YAchC,cAAc;YA+Bd,6BAA6B;YAW7B,0BAA0B;YAS1B,6BAA6B;YAmB7B,gBAAgB;IAiB9B,OAAO,CAAC,qBAAqB;CAM9B"}
|
|
@@ -41,9 +41,11 @@ export default class DataManager {
|
|
|
41
41
|
"en-US": string;
|
|
42
42
|
} | undefined;
|
|
43
43
|
private static enrichFirmwareReleaseInfo;
|
|
44
|
-
static load(settings: ConnectSettings): Promise<
|
|
44
|
+
static load(settings: ConnectSettings): Promise<boolean>;
|
|
45
45
|
static updateEnv(newEnv: ConnectSettings['env']): void;
|
|
46
46
|
static checkAndReloadData(): Promise<void>;
|
|
47
|
+
static forceReloadData(): Promise<void>;
|
|
48
|
+
static getProtocolV2Resources(): import("../types").IProtocolV2Resource[] | undefined;
|
|
47
49
|
static getProtobufMessages(schema?: ProtobufMessageSchema): JSON;
|
|
48
50
|
static getSettings(key?: undefined): ConnectSettings;
|
|
49
51
|
static getSettings<T extends keyof ConnectSettings>(key: T): ConnectSettings[T];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataManager.d.ts","sourceRoot":"","sources":["../../src/data-manager/DataManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAe,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"DataManager.d.ts","sourceRoot":"","sources":["../../src/data-manager/DataManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAe,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAmBjE,OAAO,KAAK,EACV,SAAS,EACT,eAAe,EACf,aAAa,EACb,QAAQ,EACR,wBAAwB,EACxB,qBAAqB,EACrB,gBAAgB,EAChB,aAAa,EAEd,MAAM,UAAU,CAAC;AAIlB,eAAO,MAAM,eAAe,uFAMlB,CAAC;AAEX,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9D,MAAM,MAAM,uBAAuB,GAAG,iBAAiB,GAAG,gBAAgB,CAAC;AAC3E,MAAM,MAAM,qBAAqB,GAAG,uBAAuB,GAAG,UAAU,CAAC;AAsBzE,MAAM,CAAC,OAAO,OAAO,WAAW;IAC9B,MAAM,CAAC,SAAS,EAAE,aAAa,GAAG;QAChC,CAAC,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC,MAAM,aAAa,CAAC,GAAG,SAAS,CAAC;KAC7D,CA6BC;IAEF,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAAQ;IAEvC,MAAM,CAAC,QAAQ,EAAE,eAAe,CAAC;IAEjC,MAAM,CAAC,QAAQ,EAAE;SAAG,MAAM,IAAI,qBAAqB,GAAG,IAAI;KAAE,CAI1D;IAEF,MAAM,CAAC,kBAAkB,SAAK;IAE9B,MAAM,CAAC,iBAAiB,aACZ,QAAQ,gBACJ,aAAa,KAC1B,qBAAqB,CAyBtB;IAMF,MAAM,CAAC,4BAA4B;kBAKvB,QAAQ;;sBAEJ,aAAa;6BAqB3B;IAMF,MAAM,CAAC,kBAAkB,aAAc,QAAQ,gBAAgB,aAAa,wBAe1E;IAEF,MAAM,CAAC,qBAAqB,aAAc,QAAQ,gBAAgB,aAAa,wBAmB7E;IAEF,MAAM,CAAC,0BAA0B,aACrB,QAAQ,gBACJ,aAAa,KAC1B,aAAa,GAAG,SAAS,CAa1B;IAEF,MAAM,CAAC,mCAAmC,aAC9B,QAAQ,gBACJ,aAAa,KAC1B,aAAa,GAAG,SAAS,CAgB1B;IAEF,MAAM,CAAC,oBAAoB,aAAc,QAAQ,gBAAgB,aAAa;;;QAuB5E;IAEF,MAAM,CAAC,wBAAwB,aAAc,QAAQ,gBAAgB,aAAa,yDAsBhF;IAEF,MAAM,CAAC,oBAAoB,aAAc,QAAQ,KAAG,wBAAwB,CAc1E;IAEF,MAAM,CAAC,uBAAuB,aAAc,QAAQ;;;QAalD;IAEF,MAAM,CAAC,2BAA2B,aAAc,QAAQ,4DAMtD;IAEF,MAAM,CAAC,kBAAkB,iBAAkB,MAAM,KAAG,gBAAgB,CAKlE;IAEF,MAAM,CAAC,kBAAkB;;;kBAAuC;IAEhE,OAAO,CAAC,MAAM,CAAC,yBAAyB;WA4C3B,IAAI,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC;IAyE9D,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,eAAe,CAAC,KAAK,CAAC;WAalC,kBAAkB;WAUlB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAW7C,MAAM,CAAC,sBAAsB;IAI7B,MAAM,CAAC,mBAAmB,CAAC,MAAM,GAAE,qBAAyC,GAAG,IAAI;IAInF,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,SAAS,GAAG,eAAe;IAEpD,MAAM,CAAC,WAAW,CAAC,CAAC,SAAS,MAAM,eAAe,EAAE,GAAG,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC;IAU/E,MAAM,CAAC,YAAY,QAAS,eAAe,CAAC,KAAK,CAAC,aAC0B;IAG5E,MAAM,CAAC,eAAe,QAAS,eAAe,CAAC,KAAK,CAAC,aAA8B;IAGnF,MAAM,CAAC,eAAe,QAAS,eAAe,CAAC,KAAK,CAAC,aAAsB;CAC5E"}
|