Merge main into ios-port and update the iOS CFW transport

This commit is contained in:
James Babcock committed 2026-09-17 23:33:51 -07:00
commit e8e144f3f2
156 files changed
+10528 -1679

No files matched your search

+10 -11
View File
@@ -8,13 +8,13 @@ const { rle4 } = require('../.test-build/app/g2/ble-protocol.js');
test('mode-3 payload matches the production Android encoder byte for byte', () => {
// Generated with javac from g2protocol/BleImageOptimizer.java, 2026-09-08.
const vectors = [
[0, 0, 0xab, '03000001013412789c93924e000000e70096'],
[319, 479, 0x12, '039fef01013412789c4b1014020001570084'],
[3, 5, 0xa5, '03010201013412789c4b90120500016c0090'],
[0, 0, 0xab, '030000010134121a1b60'],
[319, 479, 0x12, '039fef01013412601112'],
[3, 5, 0xa5, '03010201013412601a15'],
];
for (const [x, y, value, expected] of vectors) {
const base = new Uint8Array(320 * 480), next = base.slice(); next[y * 320 + x] = value;
const payload = bbox(base, next, 640, 480, 0x1234, deflate);
const payload = bbox(base, next, 640, 480, 0x1234);
assert.equal(Buffer.from(payload).toString('hex'), expected);
assert.deepEqual(applyDisplayPayload(base, payload), next);
}
@@ -24,7 +24,7 @@ test('bounding boxes include both nibbles, preserve neighboring pixels and cover
const base = Uint8Array.from({ length: 320 * 480 }, (_, i) => i & 255);
for (const x of [0, 1, 2, 3, 4, 637, 638, 639]) for (const y of [0, 1, 2, 477, 478, 479]) {
const next = base.slice(); next[y * 320 + (x >> 1)] ^= x % 2 ? 15 : 240;
const payload = bbox(base, next, 640, 480, 1, deflate);
const payload = bbox(base, next, 640, 480, 1);
assert.deepEqual([...payload.slice(1, 5)], [Math.floor(x / 4), Math.floor(y / 2), 1, 1]);
assert.deepEqual(applyDisplayPayload(base, payload), next);
}
@@ -49,19 +49,18 @@ test('seeded sparse edits reconstruct exactly across successive bounding-box upd
for (let fid = 1; fid <= 60; fid++) {
const next = base.slice(), bx = random(280), by = random(440);
for (let n = 0; n < 20; n++) next[(by + random(40)) * 320 + bx + random(40)] ^= 0xff;
const payload = bbox(base, next, 640, 480, fid, deflate);
const payload = bbox(base, next, 640, 480, fid);
assert.ok(payload); assert.equal(payload[5] | (payload[6] << 8), fid);
assert.deepEqual(applyDisplayPayload(base, payload), next);
base = next;
}
});
test('a small edit compresses only its region and reduces bytes on a busy screen', () => {
test('a small edit encodes only its region on a busy screen', () => {
const base = Uint8Array.from({ length: 320 * 480 }, (_, i) => i & 255), next = base.slice();
next[100 * 320 + 100] ^= 255;
let compressedInputBytes = 0;
const payload = bbox(base, next, 640, 480, 1, bytes => { compressedInputBytes += bytes.length; return deflate(bytes); });
assert.ok(compressedInputBytes <= 8); // A 4x2 rectangle, at most one RLE byte per pixel.
assert.ok(payload.length < (1 + deflate(rle4(next)).length) / 10);
const payload = bbox(base, next, 640, 480, 1);
assert.ok(payload.length <= 15);
assert.ok(payload.length < (1 + rle4(next).length) / 10);
assert.deepEqual(applyDisplayPayload(base, payload), next);
});