@onekeyfe/hd-core 1.2.0-alpha.166 → 1.2.0-alpha.168
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__/pro2Wallpaper.test.ts +66 -0
- package/__tests__/protocol-v2.test.ts +220 -19
- package/dist/api/FirmwareUpdateV4.d.ts +1 -0
- package/dist/api/FirmwareUpdateV4.d.ts.map +1 -1
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts +2 -1
- package/dist/api/protocol-v2/DeviceUploadWallpaper.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +231 -62
- package/dist/utils/pro2Wallpaper.d.ts +3 -1
- package/dist/utils/pro2Wallpaper.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/api/FirmwareUpdateV4.ts +73 -5
- package/src/api/protocol-v2/DeviceUploadWallpaper.ts +12 -2
- package/src/core/index.ts +6 -107
- package/src/utils/pro2Wallpaper.ts +197 -1
|
@@ -1,5 +1,48 @@
|
|
|
1
1
|
import { encodePro2Wallpaper } from '../src/utils/pro2Wallpaper';
|
|
2
2
|
|
|
3
|
+
// The test decoder mirrors LZ4's bit-packed token and offset format.
|
|
4
|
+
/* eslint-disable no-bitwise */
|
|
5
|
+
|
|
6
|
+
function decodeLz4Block(data: Uint8Array, expectedLength: number) {
|
|
7
|
+
const output = new Uint8Array(expectedLength);
|
|
8
|
+
let inputOffset = 0;
|
|
9
|
+
let outputOffset = 0;
|
|
10
|
+
|
|
11
|
+
const readLength = (initialLength: number) => {
|
|
12
|
+
let length = initialLength;
|
|
13
|
+
if (length === 0x0f) {
|
|
14
|
+
let extension = 0xff;
|
|
15
|
+
while (extension === 0xff) {
|
|
16
|
+
extension = data[inputOffset];
|
|
17
|
+
inputOffset += 1;
|
|
18
|
+
length += extension;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return length;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
while (inputOffset < data.byteLength) {
|
|
25
|
+
const token = data[inputOffset];
|
|
26
|
+
inputOffset += 1;
|
|
27
|
+
const literalLength = readLength(token >> 4);
|
|
28
|
+
output.set(data.subarray(inputOffset, inputOffset + literalLength), outputOffset);
|
|
29
|
+
inputOffset += literalLength;
|
|
30
|
+
outputOffset += literalLength;
|
|
31
|
+
if (inputOffset >= data.byteLength) break;
|
|
32
|
+
|
|
33
|
+
const matchOffset = data[inputOffset] | (data[inputOffset + 1] << 8);
|
|
34
|
+
inputOffset += 2;
|
|
35
|
+
const matchLength = readLength(token & 0x0f) + 4;
|
|
36
|
+
for (let index = 0; index < matchLength; index += 1) {
|
|
37
|
+
output[outputOffset] = output[outputOffset - matchOffset];
|
|
38
|
+
outputOffset += 1;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
expect(outputOffset).toBe(expectedLength);
|
|
43
|
+
return output;
|
|
44
|
+
}
|
|
45
|
+
|
|
3
46
|
describe('encodePro2Wallpaper', () => {
|
|
4
47
|
test('encodes opaque pixels as aligned LVGL v9 RGB565 data', () => {
|
|
5
48
|
const result = encodePro2Wallpaper({
|
|
@@ -28,6 +71,29 @@ describe('encodePro2Wallpaper', () => {
|
|
|
28
71
|
expect(Array.from(result.data.slice(12))).toEqual([0x1f, 0x00, 0xff, 0xff, 128, 255]);
|
|
29
72
|
});
|
|
30
73
|
|
|
74
|
+
test('encodes an I8 palette and pixel indices as an LVGL LZ4 block', () => {
|
|
75
|
+
const result = encodePro2Wallpaper({
|
|
76
|
+
width: 2,
|
|
77
|
+
height: 1,
|
|
78
|
+
rgba: new Uint8Array([255, 0, 0, 255, 0, 255, 0, 255]),
|
|
79
|
+
encoding: 'i8-lz4',
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
expect(result.colorFormat).toBe('I8');
|
|
83
|
+
expect(Array.from(result.data.slice(0, 12))).toEqual([
|
|
84
|
+
0x19, 0x0a, 0x08, 0, 2, 0, 1, 0, 2, 0, 0, 0,
|
|
85
|
+
]);
|
|
86
|
+
const view = new DataView(result.data.buffer, result.data.byteOffset, result.data.byteLength);
|
|
87
|
+
expect(view.getUint32(12, true)).toBe(2);
|
|
88
|
+
expect(view.getUint32(16, true)).toBe(result.data.byteLength - 24);
|
|
89
|
+
expect(view.getUint32(20, true)).toBe(1026);
|
|
90
|
+
|
|
91
|
+
const rawData = decodeLz4Block(result.data.slice(24), 1026);
|
|
92
|
+
expect(Array.from(rawData.slice(210 * 4, 210 * 4 + 4))).toEqual([0, 0, 255, 255]);
|
|
93
|
+
expect(Array.from(rawData.slice(36 * 4, 36 * 4 + 4))).toEqual([0, 255, 0, 255]);
|
|
94
|
+
expect(Array.from(rawData.slice(-2))).toEqual([210, 36]);
|
|
95
|
+
});
|
|
96
|
+
|
|
31
97
|
test('rejects invalid dimensions and RGBA byte length', () => {
|
|
32
98
|
expect(() => encodePro2Wallpaper({ width: 0, height: 1, rgba: new Uint8Array() })).toThrow(
|
|
33
99
|
'width'
|
|
@@ -194,7 +194,13 @@ describe('DeviceUploadWallpaper', () => {
|
|
|
194
194
|
refreshProtocolV2SettingsAfterMutation: jest.fn().mockResolvedValue({}),
|
|
195
195
|
});
|
|
196
196
|
|
|
197
|
-
|
|
197
|
+
afterEach(() => {
|
|
198
|
+
jest.restoreAllMocks();
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
test('uses I8 with LZ4 when uploading a Pro2 wallpaper over BLE', async () => {
|
|
202
|
+
jest.spyOn(DataManager, 'getSettings').mockReturnValue('lowlevel');
|
|
203
|
+
jest.spyOn(DataManager, 'isBleConnect').mockReturnValue(true);
|
|
198
204
|
const typedCall = jest.fn().mockImplementation((request, _response, params) => {
|
|
199
205
|
if (request === 'FilesystemDirMake') return { message: { message: 'directory ready' } };
|
|
200
206
|
if (request === 'FilesystemFileWrite') {
|
|
@@ -237,7 +243,7 @@ describe('DeviceUploadWallpaper', () => {
|
|
|
237
243
|
});
|
|
238
244
|
expect(device.refreshProtocolV2SettingsAfterMutation).toHaveBeenCalledTimes(1);
|
|
239
245
|
expect(typedCall.mock.calls.some(call => call[0] === 'SetWallpaper')).toBe(false);
|
|
240
|
-
expect(result).toMatchObject({ colorFormat: '
|
|
246
|
+
expect(result).toMatchObject({ colorFormat: 'I8', message: 'wallpaper applied' });
|
|
241
247
|
const fileWriteCallCount = typedCall.mock.calls.filter(
|
|
242
248
|
call => call[0] === 'FilesystemFileWrite'
|
|
243
249
|
).length;
|
|
@@ -275,6 +281,8 @@ describe('DeviceUploadWallpaper', () => {
|
|
|
275
281
|
});
|
|
276
282
|
|
|
277
283
|
test('returns success when wallpaper read-back fails after apply', async () => {
|
|
284
|
+
jest.spyOn(DataManager, 'getSettings').mockReturnValue('desktop-webusb');
|
|
285
|
+
jest.spyOn(DataManager, 'isBleConnect').mockReturnValue(false);
|
|
278
286
|
const typedCall = jest.fn().mockImplementation((request, _response, params) => {
|
|
279
287
|
if (request === 'FilesystemDirMake') return { message: {} };
|
|
280
288
|
if (request === 'FilesystemFileWrite') {
|
|
@@ -300,7 +308,10 @@ describe('DeviceUploadWallpaper', () => {
|
|
|
300
308
|
(method as any).device = device;
|
|
301
309
|
method.init();
|
|
302
310
|
|
|
303
|
-
await expect(method.run()).resolves.toMatchObject({
|
|
311
|
+
await expect(method.run()).resolves.toMatchObject({
|
|
312
|
+
colorFormat: 'RGB565',
|
|
313
|
+
message: 'wallpaper applied',
|
|
314
|
+
});
|
|
304
315
|
expect(device.refreshProtocolV2SettingsAfterMutation).toHaveBeenCalledTimes(1);
|
|
305
316
|
});
|
|
306
317
|
|
|
@@ -317,6 +328,19 @@ describe('DeviceUploadWallpaper', () => {
|
|
|
317
328
|
expect(() => method.init()).toThrow('fileName');
|
|
318
329
|
});
|
|
319
330
|
|
|
331
|
+
test('rejects unsupported wallpaper encodings before device communication', () => {
|
|
332
|
+
const method = new DeviceUploadWallpaper({
|
|
333
|
+
id: 1,
|
|
334
|
+
payload: {
|
|
335
|
+
method: 'deviceUploadWallpaper',
|
|
336
|
+
jpegBase64: createJpegBase64(604, 1024),
|
|
337
|
+
encoding: 'gzip',
|
|
338
|
+
} as any,
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
expect(() => method.init()).toThrow('encoding');
|
|
342
|
+
});
|
|
343
|
+
|
|
320
344
|
test('rejects unsupported firmware before creating or writing files', async () => {
|
|
321
345
|
const typedCall = jest.fn();
|
|
322
346
|
const method = new DeviceUploadWallpaper({
|
|
@@ -5362,11 +5386,7 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
5362
5386
|
interaction,
|
|
5363
5387
|
},
|
|
5364
5388
|
});
|
|
5365
|
-
expect(call).toHaveBeenCalledWith(
|
|
5366
|
-
'DeviceFirmwareUpdateRequest',
|
|
5367
|
-
{},
|
|
5368
|
-
{ returnAfterWrite: true }
|
|
5369
|
-
);
|
|
5389
|
+
expect(call).toHaveBeenCalledWith('DeviceFirmwareUpdateRequest', {});
|
|
5370
5390
|
expect(typedCall.mock.invocationCallOrder[0]).toBeLessThan(call.mock.invocationCallOrder[0]);
|
|
5371
5391
|
expect((method.postMessage as jest.Mock).mock.invocationCallOrder[0]).toBeLessThan(
|
|
5372
5392
|
call.mock.invocationCallOrder[0]
|
|
@@ -5436,6 +5456,32 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
5436
5456
|
expect(method.postProgressMessage).not.toHaveBeenCalled();
|
|
5437
5457
|
});
|
|
5438
5458
|
|
|
5459
|
+
test('continues to install polling when the empty request releases BLE transport', async () => {
|
|
5460
|
+
const method = new FirmwareUpdateV4({
|
|
5461
|
+
id: 1,
|
|
5462
|
+
payload: {
|
|
5463
|
+
method: 'firmwareUpdateV4',
|
|
5464
|
+
},
|
|
5465
|
+
});
|
|
5466
|
+
const typedCall = jest.fn().mockResolvedValue({ type: 'Success', message: {} });
|
|
5467
|
+
const call = jest.fn().mockRejectedValue(new Error('React Native BLE transport released'));
|
|
5468
|
+
|
|
5469
|
+
(method as any).device = stubDevice({
|
|
5470
|
+
getCommands: () => ({ typedCall, call }),
|
|
5471
|
+
createProtocolV2UiPhaseMetadata: jest.fn().mockReturnValue(undefined),
|
|
5472
|
+
toMessageObject: jest.fn().mockReturnValue({ connectId: 'pro2' }),
|
|
5473
|
+
});
|
|
5474
|
+
method.postMessage = jest.fn();
|
|
5475
|
+
|
|
5476
|
+
await expect(
|
|
5477
|
+
(method as any).protocolV2StartFirmwareUpdate({
|
|
5478
|
+
targets: [{ target_id: 4, path: 'vol0:/application_p1.bin' }],
|
|
5479
|
+
})
|
|
5480
|
+
).resolves.toBeUndefined();
|
|
5481
|
+
|
|
5482
|
+
expect(call).toHaveBeenCalledWith('DeviceFirmwareUpdateRequest', {});
|
|
5483
|
+
});
|
|
5484
|
+
|
|
5439
5485
|
test('polls only firmware status while Protocol V2 bootloader is installing', async () => {
|
|
5440
5486
|
const method = new FirmwareUpdateV4({
|
|
5441
5487
|
id: 1,
|
|
@@ -5678,6 +5724,169 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
5678
5724
|
expect(typedCall).toHaveBeenCalledTimes(3);
|
|
5679
5725
|
});
|
|
5680
5726
|
|
|
5727
|
+
test('ignores a mixed stale failure snapshot until ordered current records replace it', async () => {
|
|
5728
|
+
const method = new FirmwareUpdateV4({
|
|
5729
|
+
id: 1,
|
|
5730
|
+
payload: {
|
|
5731
|
+
method: 'firmwareUpdateV4',
|
|
5732
|
+
},
|
|
5733
|
+
});
|
|
5734
|
+
const targets = [
|
|
5735
|
+
{ target_id: 3, path: 'vol0:/bootloader.bin' },
|
|
5736
|
+
{ target_id: 4, path: 'vol0:/application_p1.bin' },
|
|
5737
|
+
{ target_id: 7, path: 'vol0:/se01.bin' },
|
|
5738
|
+
{ target_id: 8, path: 'vol0:/se02.bin' },
|
|
5739
|
+
];
|
|
5740
|
+
const staleRecords = [
|
|
5741
|
+
{
|
|
5742
|
+
target_id: 'FW_MGMT_TARGET_BOOTLOADER',
|
|
5743
|
+
status: 'FW_MGMT_UPDATER_TASK_STATUS_PENDING',
|
|
5744
|
+
payload_version: 0,
|
|
5745
|
+
path: 'vol0:/bootloader.bin',
|
|
5746
|
+
},
|
|
5747
|
+
{
|
|
5748
|
+
target_id: 'FW_MGMT_TARGET_APPLICATION_P1',
|
|
5749
|
+
status: 'FW_MGMT_UPDATER_TASK_STATUS_FINISHED',
|
|
5750
|
+
payload_version: 0x010000,
|
|
5751
|
+
path: 'vol0:/application_p1.bin',
|
|
5752
|
+
},
|
|
5753
|
+
{
|
|
5754
|
+
target_id: 'FW_MGMT_TARGET_SE01',
|
|
5755
|
+
status: 'FW_MGMT_UPDATER_TASK_STATUS_FAILED_VERIFY',
|
|
5756
|
+
payload_version: 0,
|
|
5757
|
+
path: 'vol0:/se01.bin',
|
|
5758
|
+
},
|
|
5759
|
+
{
|
|
5760
|
+
target_id: 'FW_MGMT_TARGET_SE02',
|
|
5761
|
+
status: 'FW_MGMT_UPDATER_TASK_STATUS_FAILED_VERIFY',
|
|
5762
|
+
payload_version: 0,
|
|
5763
|
+
path: 'vol0:/se02.bin',
|
|
5764
|
+
},
|
|
5765
|
+
];
|
|
5766
|
+
const typedCall = jest
|
|
5767
|
+
.fn()
|
|
5768
|
+
.mockResolvedValueOnce({
|
|
5769
|
+
type: 'DeviceFirmwareUpdateStatus',
|
|
5770
|
+
message: { records: staleRecords },
|
|
5771
|
+
})
|
|
5772
|
+
.mockResolvedValueOnce({
|
|
5773
|
+
type: 'DeviceFirmwareUpdateStatus',
|
|
5774
|
+
message: {
|
|
5775
|
+
records: targets.map(target => ({ ...target, status: 0, payload_version: 0 })),
|
|
5776
|
+
},
|
|
5777
|
+
})
|
|
5778
|
+
.mockResolvedValueOnce({
|
|
5779
|
+
type: 'DeviceFirmwareUpdateStatus',
|
|
5780
|
+
message: {
|
|
5781
|
+
records: [
|
|
5782
|
+
{ ...targets[0], status: 0, payload_version: 0 },
|
|
5783
|
+
{ ...targets[1], status: 1, payload_version: 0 },
|
|
5784
|
+
{ ...targets[2], status: 0, payload_version: 0 },
|
|
5785
|
+
{ ...targets[3], status: 0, payload_version: 0 },
|
|
5786
|
+
],
|
|
5787
|
+
},
|
|
5788
|
+
})
|
|
5789
|
+
.mockResolvedValueOnce({
|
|
5790
|
+
type: 'DeviceFirmwareUpdateStatus',
|
|
5791
|
+
message: {
|
|
5792
|
+
records: targets.map(target => ({
|
|
5793
|
+
...target,
|
|
5794
|
+
status: 2,
|
|
5795
|
+
payload_version: 0x010000,
|
|
5796
|
+
})),
|
|
5797
|
+
},
|
|
5798
|
+
});
|
|
5799
|
+
const setTimeoutSpy = jest.spyOn(global, 'setTimeout').mockImplementation(((
|
|
5800
|
+
callback: () => void
|
|
5801
|
+
) => {
|
|
5802
|
+
callback();
|
|
5803
|
+
return 0 as any;
|
|
5804
|
+
}) as typeof setTimeout);
|
|
5805
|
+
|
|
5806
|
+
(method as any).device = stubDevice({
|
|
5807
|
+
getCommands: () => ({ typedCall }),
|
|
5808
|
+
});
|
|
5809
|
+
(method as any).reconnectProtocolV2Device = jest.fn().mockResolvedValue(undefined);
|
|
5810
|
+
(method as any).verifyProtocolV2ReconnectIdentity = jest.fn().mockResolvedValue(undefined);
|
|
5811
|
+
(method as any).protocolV2InstallStatusBaseline = staleRecords;
|
|
5812
|
+
method.postProgressMessage = jest.fn();
|
|
5813
|
+
|
|
5814
|
+
try {
|
|
5815
|
+
await expect(
|
|
5816
|
+
(method as any).waitForProtocolV2FirmwareUpdateComplete(targets, true)
|
|
5817
|
+
).resolves.toBeUndefined();
|
|
5818
|
+
} finally {
|
|
5819
|
+
setTimeoutSpy.mockRestore();
|
|
5820
|
+
}
|
|
5821
|
+
|
|
5822
|
+
expect(typedCall).toHaveBeenCalledTimes(4);
|
|
5823
|
+
expect(method.postProgressMessage).toHaveBeenCalledWith(100, 'installingFirmware');
|
|
5824
|
+
});
|
|
5825
|
+
|
|
5826
|
+
test('reports a failed target after the current records replace the stale baseline', async () => {
|
|
5827
|
+
const method = new FirmwareUpdateV4({
|
|
5828
|
+
id: 1,
|
|
5829
|
+
payload: {
|
|
5830
|
+
method: 'firmwareUpdateV4',
|
|
5831
|
+
},
|
|
5832
|
+
});
|
|
5833
|
+
const targets = [
|
|
5834
|
+
{ target_id: 4, path: 'vol0:/application_p1.bin' },
|
|
5835
|
+
{ target_id: 7, path: 'vol0:/se01.bin' },
|
|
5836
|
+
];
|
|
5837
|
+
const staleRecords = [
|
|
5838
|
+
{ ...targets[0], status: 2, payload_version: 0x010000 },
|
|
5839
|
+
{ ...targets[1], status: 6, payload_version: 0 },
|
|
5840
|
+
];
|
|
5841
|
+
const typedCall = jest
|
|
5842
|
+
.fn()
|
|
5843
|
+
.mockResolvedValueOnce({
|
|
5844
|
+
type: 'DeviceFirmwareUpdateStatus',
|
|
5845
|
+
message: { records: staleRecords },
|
|
5846
|
+
})
|
|
5847
|
+
.mockResolvedValueOnce({
|
|
5848
|
+
type: 'DeviceFirmwareUpdateStatus',
|
|
5849
|
+
message: {
|
|
5850
|
+
records: targets.map(target => ({ ...target, status: 0, payload_version: 0 })),
|
|
5851
|
+
},
|
|
5852
|
+
})
|
|
5853
|
+
.mockResolvedValueOnce({
|
|
5854
|
+
type: 'DeviceFirmwareUpdateStatus',
|
|
5855
|
+
message: {
|
|
5856
|
+
records: [
|
|
5857
|
+
{ ...targets[0], status: 2, payload_version: 0x010000 },
|
|
5858
|
+
{ ...targets[1], status: 6, payload_version: 0 },
|
|
5859
|
+
],
|
|
5860
|
+
},
|
|
5861
|
+
});
|
|
5862
|
+
const setTimeoutSpy = jest.spyOn(global, 'setTimeout').mockImplementation(((
|
|
5863
|
+
callback: () => void
|
|
5864
|
+
) => {
|
|
5865
|
+
callback();
|
|
5866
|
+
return 0 as any;
|
|
5867
|
+
}) as typeof setTimeout);
|
|
5868
|
+
|
|
5869
|
+
(method as any).device = stubDevice({
|
|
5870
|
+
getCommands: () => ({ typedCall }),
|
|
5871
|
+
});
|
|
5872
|
+
(method as any).reconnectProtocolV2Device = jest.fn().mockResolvedValue(undefined);
|
|
5873
|
+
(method as any).verifyProtocolV2ReconnectIdentity = jest.fn().mockResolvedValue(undefined);
|
|
5874
|
+
(method as any).protocolV2InstallStatusBaseline = staleRecords;
|
|
5875
|
+
|
|
5876
|
+
try {
|
|
5877
|
+
await expect(
|
|
5878
|
+
(method as any).waitForProtocolV2FirmwareUpdateComplete(targets, true)
|
|
5879
|
+
).rejects.toMatchObject({
|
|
5880
|
+
errorCode: HardwareErrorCode.FirmwareError,
|
|
5881
|
+
params: { firmwareUpdateCode: 'FirmwareInstallFailed' },
|
|
5882
|
+
});
|
|
5883
|
+
} finally {
|
|
5884
|
+
setTimeoutSpy.mockRestore();
|
|
5885
|
+
}
|
|
5886
|
+
|
|
5887
|
+
expect(typedCall).toHaveBeenCalledTimes(3);
|
|
5888
|
+
});
|
|
5889
|
+
|
|
5681
5890
|
test('waits five minutes before rejecting normal mode without install evidence', async () => {
|
|
5682
5891
|
const method = new FirmwareUpdateV4({
|
|
5683
5892
|
id: 1,
|
|
@@ -8726,11 +8935,7 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
8726
8935
|
'Success',
|
|
8727
8936
|
{ targets: [{ target_id: 4, path: 'vol1:firmware.bin' }] },
|
|
8728
8937
|
]);
|
|
8729
|
-
expect(call).toHaveBeenCalledWith(
|
|
8730
|
-
'DeviceFirmwareUpdateRequest',
|
|
8731
|
-
{},
|
|
8732
|
-
{ returnAfterWrite: true }
|
|
8733
|
-
);
|
|
8938
|
+
expect(call).toHaveBeenCalledWith('DeviceFirmwareUpdateRequest', {});
|
|
8734
8939
|
expect(method.postTipMessage).not.toHaveBeenCalled();
|
|
8735
8940
|
expect(method.postProgressMessage).not.toHaveBeenCalled();
|
|
8736
8941
|
|
|
@@ -8740,7 +8945,7 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
8740
8945
|
expect(method.postProgressMessage).not.toHaveBeenCalled();
|
|
8741
8946
|
});
|
|
8742
8947
|
|
|
8743
|
-
test('sends an empty Protocol V2 firmware install request
|
|
8948
|
+
test('sends an empty Protocol V2 firmware install request and waits for its response', async () => {
|
|
8744
8949
|
const method = new FirmwareUpdateV4({
|
|
8745
8950
|
id: 1,
|
|
8746
8951
|
payload: {
|
|
@@ -8767,11 +8972,7 @@ describe('Protocol V2 firmware update targets', () => {
|
|
|
8767
8972
|
});
|
|
8768
8973
|
|
|
8769
8974
|
expect(typedCall.mock.calls[0][0]).toBe('DeviceFirmwareUpdateStage');
|
|
8770
|
-
expect(call).toHaveBeenCalledWith(
|
|
8771
|
-
'DeviceFirmwareUpdateRequest',
|
|
8772
|
-
{},
|
|
8773
|
-
{ returnAfterWrite: true }
|
|
8774
|
-
);
|
|
8975
|
+
expect(call).toHaveBeenCalledWith('DeviceFirmwareUpdateRequest', {});
|
|
8775
8976
|
expect(method.postTipMessage).not.toHaveBeenCalled();
|
|
8776
8977
|
});
|
|
8777
8978
|
});
|
|
@@ -17,6 +17,7 @@ export default class FirmwareUpdateV4 extends FirmwareUpdateBaseMethod<FirmwareU
|
|
|
17
17
|
private protocolV2LatestFinalFeatures?;
|
|
18
18
|
private protocolV2LatestFinalDeviceInfo?;
|
|
19
19
|
private protocolV2InstallBaselineVersions;
|
|
20
|
+
private protocolV2InstallStatusBaseline?;
|
|
20
21
|
private protocolV2LastRuntimeProbeFeatures?;
|
|
21
22
|
private protocolV2LastTransferProgress?;
|
|
22
23
|
private protocolV2LastTransferProgressAt;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FirmwareUpdateV4.d.ts","sourceRoot":"","sources":["../../src/api/FirmwareUpdateV4.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkD,MAAM,qBAAqB,CAAC;AA0BlG,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AA+B/E,OAAO,KAAK,EAEV,sBAAsB,EAEvB,MAAM,6BAA6B,CAAC;AAoErC,wBAAgB,wCAAwC,CACtD,UAAU,EAAE,WAAW,GAAG,MAAM,GAAG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,qCAAqC;IAyB7C,OAAO,CAAC,kCAAkC;IAgB1C,OAAO,CAAC,8CAA8C;YAIxC,uCAAuC;YAuOvC,gCAAgC;YAehC,yBAAyB;IASvC,OAAO,CAAC,2BAA2B;YAMrB,8BAA8B;IAQ5C,OAAO,CAAC,0BAA0B;YAkBpB,mCAAmC;YAWnC,qCAAqC;YAmDrC,yBAAyB;YA8DzB,8BAA8B;IAU5C,OAAO,CAAC,kCAAkC;YAQ5B,cAAc;YAuCd,6BAA6B;YAW7B,0BAA0B;YAS1B,6BAA6B;YAwD7B,gBAAgB;IAiB9B,OAAO,CAAC,qBAAqB;CAM9B"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { BaseMethod } from '../BaseMethod';
|
|
2
|
-
import { type Pro2WallpaperColorFormat } from '../../utils/pro2Wallpaper';
|
|
2
|
+
import { type Pro2WallpaperColorFormat, type Pro2WallpaperEncoding } from '../../utils/pro2Wallpaper';
|
|
3
3
|
export type DeviceUploadWallpaperParams = {
|
|
4
4
|
jpegBase64: string;
|
|
5
5
|
fileName?: string;
|
|
6
6
|
chunkSize?: number;
|
|
7
|
+
encoding?: Pro2WallpaperEncoding;
|
|
7
8
|
};
|
|
8
9
|
export type DeviceUploadWallpaperResponse = {
|
|
9
10
|
path: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeviceUploadWallpaper.d.ts","sourceRoot":"","sources":["../../../src/api/protocol-v2/DeviceUploadWallpaper.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"DeviceUploadWallpaper.d.ts","sourceRoot":"","sources":["../../../src/api/protocol-v2/DeviceUploadWallpaper.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAQ3C,OAAO,EAGL,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAE3B,MAAM,2BAA2B,CAAC;AAEnC,M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;IAElE,OAAO,CAAC,iBAAiB,CAAoB;;IAS7C,OAAO,CAAC,cAAc;IA6BhB,aAAa,CAAC,OAAO,EAAE,WAAW;IAuExC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;YAOV,gBAAgB;CAiC/B;AAED,eAAO,MAAM,QAAQ,YAIpB,CAAC;AAEF,eAAO,MAAM,aAAa,uBAYzB,CAAC;AAMF,eAAO,MAAM,IAAI,aACL,eAAe,aACd,GAAG,WACL,6BAA6B,8BAiBvC,CAAC;AAEF,eAAO,MAAM,eAAe;SAKrB,eAAe,CAAC,KAAK,CAAC;eAChB,GAAG;;UASf,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1113,11 +1113,13 @@ declare const switchTransport: ({ env, Transport, plugin, }: {
|
|
|
1113
1113
|
|
|
1114
1114
|
declare const PRO2_WALLPAPER_WIDTH = 604;
|
|
1115
1115
|
declare const PRO2_WALLPAPER_HEIGHT = 1024;
|
|
1116
|
-
type Pro2WallpaperColorFormat = 'RGB565' | 'RGB565A8';
|
|
1116
|
+
type Pro2WallpaperColorFormat = 'RGB565' | 'RGB565A8' | 'I8';
|
|
1117
|
+
type Pro2WallpaperEncoding = 'rgb565' | 'i8-lz4';
|
|
1117
1118
|
declare function encodePro2Wallpaper(options: {
|
|
1118
1119
|
width: number;
|
|
1119
1120
|
height: number;
|
|
1120
1121
|
rgba: Uint8Array | ArrayBuffer;
|
|
1122
|
+
encoding?: Pro2WallpaperEncoding;
|
|
1121
1123
|
}): {
|
|
1122
1124
|
data: Uint8Array;
|
|
1123
1125
|
colorFormat: Pro2WallpaperColorFormat;
|
|
@@ -1127,6 +1129,7 @@ type DeviceUploadWallpaperParams = {
|
|
|
1127
1129
|
jpegBase64: string;
|
|
1128
1130
|
fileName?: string;
|
|
1129
1131
|
chunkSize?: number;
|
|
1132
|
+
encoding?: Pro2WallpaperEncoding;
|
|
1130
1133
|
};
|
|
1131
1134
|
type DeviceUploadWallpaperResponse = {
|
|
1132
1135
|
path: string;
|