From b738ce4bb20d7f627ea0d38f0e6af4e394306080 Mon Sep 17 00:00:00 2001 From: James Babcock Date: Tue, 28 Jul 2026 10:16:44 -0700 Subject: [PATCH] Add screen-recording option --- .../faceclaw/app/FaceclawBleCommunicator.java | 43 ++- .../com/faceclaw/app/GifScreenRecorder.java | 273 ++++++++++++++++++ .../java/com/faceclaw/app/ScreenshotUtil.java | 122 ++++++-- app/g2/dashboard-controller.ts | 67 ++++- app/native/faceclaw-communicator.ts | 24 +- app/native/raw-screenshot.ts | 24 -- app/phone-ui/main-page.xml | 6 +- app/phone-ui/main-view-model.ts | 44 ++- app/ui/dashboard-settings.ts | 21 +- app/ui/dashboard/settings-menus.ts | 4 +- app/ui/shell/worker-window.ts | 17 ++ app/workers/terminal-app.worker.ts | 98 ++++++- 12 files changed, 644 insertions(+), 99 deletions(-) create mode 100644 App_Resources/Android/src/main/java/com/faceclaw/app/GifScreenRecorder.java delete mode 100644 app/native/raw-screenshot.ts diff --git a/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawBleCommunicator.java b/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawBleCommunicator.java index f919e0eb..45810fa7 100644 --- a/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawBleCommunicator.java +++ b/App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawBleCommunicator.java @@ -437,14 +437,49 @@ public class FaceclawBleCommunicator implements FaceclawBleListener, Runnable { java.nio.ByteBuffer.wrap(composite.gray), composite.width, composite.height, brightenGamma); } - /** Save the current composite as a raw 4bpp screenshot; returns the path or "". */ - public String saveRawCompositeScreenshot() throws java.io.IOException { + /** Save the current composite as a 4-bit grayscale PNG; returns the path or "". */ + public String saveCompositePngScreenshot() throws java.io.IOException { SurfaceCompositor.Composite composite = compositor.previewComposite(); if (composite == null) { return ""; } - return ScreenshotUtil.saveRawScreenshot( - appContext, java.nio.ByteBuffer.wrap(composite.gray), composite.width, composite.height); + return ScreenshotUtil.savePngScreenshot(appContext, composite.gray, composite.width, composite.height); + } + + // Active animated-GIF screen recording, or null when idle. Frames are + // pushed by recordScreenFrame(), which the TS side calls at each + // phone-preview flush. + private volatile GifScreenRecorder screenRecorder; + + /** Begin collecting composite frames for an animated-GIF screen recording. */ + public void startScreenRecording() { + screenRecorder = new GifScreenRecorder(); + } + + /** Capture the current composite into the active recording; no-op when idle. */ + public void recordScreenFrame() { + GifScreenRecorder recorder = screenRecorder; + if (recorder == null) { + return; + } + SurfaceCompositor.Composite composite = compositor.previewComposite(); + if (composite == null) { + return; + } + recorder.addFrame(composite.gray, composite.width, composite.height, System.currentTimeMillis()); + } + + /** Finish the recording and save it as an animated GIF; returns the path or "". */ + public String stopScreenRecording() throws java.io.IOException { + GifScreenRecorder recorder = screenRecorder; + screenRecorder = null; + if (recorder == null) { + return ""; + } + if (recorder.isOverflowed()) { + logLine("screen recording hit its frame cap; the tail was dropped"); + } + return recorder.save(appContext); } /** diff --git a/App_Resources/Android/src/main/java/com/faceclaw/app/GifScreenRecorder.java b/App_Resources/Android/src/main/java/com/faceclaw/app/GifScreenRecorder.java new file mode 100644 index 00000000..cfba7631 --- /dev/null +++ b/App_Resources/Android/src/main/java/com/faceclaw/app/GifScreenRecorder.java @@ -0,0 +1,273 @@ +package com.faceclaw.app; + +import android.content.Context; + +import java.io.BufferedOutputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.zip.DataFormatException; +import java.util.zip.Inflater; + +/** + * Accumulates composited screen frames and saves them as a looping animated + * GIF with a 16-entry grayscale palette. Stored frames are deflate-compressed + * (a typical UI frame shrinks from 166KB of indices to a few KB) so long + * recordings stay affordable in memory; consecutive identical frames are + * deduplicated, with the elapsed time folded into the next frame's delay. + */ +public final class GifScreenRecorder { + /** Backstop against unbounded growth if a recording is left running. */ + private static final int MAX_FRAMES = 3600; + /** Displayed duration of the final frame, which has no successor. */ + private static final int LAST_FRAME_DELAY_CS = 100; + /** Below this, GIF renderers historically clamp or ignore the delay. */ + private static final int MIN_FRAME_DELAY_CS = 2; + + private static final class Frame { + final byte[] deflatedIndices; + final long timestampMs; + + Frame(byte[] deflatedIndices, long timestampMs) { + this.deflatedIndices = deflatedIndices; + this.timestampMs = timestampMs; + } + } + + private final List frames = new ArrayList<>(); + /** Undeflated copy of the newest frame, kept for duplicate detection. */ + private byte[] lastIndices; + private int width; + private int height; + private boolean overflowed; + + /** + * Append the current screen. gray is 8bpp; only the top nibble (the + * display's native depth, and the palette index) is kept. + */ + public synchronized void addFrame(byte[] gray, int width, int height, long timestampMs) { + if (gray == null || width <= 0 || height <= 0 || gray.length < width * height) { + return; + } + if (frames.isEmpty()) { + this.width = width; + this.height = height; + } else if (width != this.width || height != this.height) { + return; + } + byte[] indices = new byte[width * height]; + for (int i = 0; i < indices.length; i++) { + indices[i] = (byte) ((gray[i] & 0xff) >>> 4); + } + if (lastIndices != null && Arrays.equals(indices, lastIndices)) { + return; + } + if (frames.size() >= MAX_FRAMES) { + overflowed = true; + return; + } + frames.add(new Frame(ScreenshotUtil.zlibDeflate(indices), timestampMs)); + lastIndices = indices; + } + + /** True if frames were dropped because the recording hit MAX_FRAMES. */ + public synchronized boolean isOverflowed() { + return overflowed; + } + + /** + * Encode the recording as an animated GIF in the screenshots directory. + * Returns the absolute path, or "" if no frames were captured. + */ + public synchronized String save(Context context) throws IOException { + if (frames.isEmpty()) { + return ""; + } + File file = new File(ScreenshotUtil.ensureScreenshotsDir(context), "recording-" + ScreenshotUtil.timestamp() + ".gif"); + try (OutputStream out = new BufferedOutputStream(new FileOutputStream(file))) { + writeGif(out); + } + return file.getAbsolutePath(); + } + + private void writeGif(OutputStream out) throws IOException { + out.write('G'); + out.write('I'); + out.write('F'); + out.write('8'); + out.write('9'); + out.write('a'); + // Logical screen descriptor: global color table present, 8 bits of + // color resolution, 2^(3+1)=16 palette entries. + writeShortLE(out, width); + writeShortLE(out, height); + out.write(0x80 | 0x70 | 0x03); + out.write(0); // background color index + out.write(0); // pixel aspect ratio + for (int i = 0; i < 16; i++) { + int v = i * 17; + out.write(v); + out.write(v); + out.write(v); + } + // Netscape application extension: loop forever. + out.write(0x21); + out.write(0xff); + out.write(11); + out.write("NETSCAPE2.0".getBytes("US-ASCII")); + out.write(3); + out.write(1); + writeShortLE(out, 0); + out.write(0); + + for (int i = 0; i < frames.size(); i++) { + Frame frame = frames.get(i); + // Each frame displays until the next one was captured; the last + // frame has no successor, so give it a nominal one-second hold. + int delayCs = LAST_FRAME_DELAY_CS; + if (i + 1 < frames.size()) { + long deltaMs = frames.get(i + 1).timestampMs - frame.timestampMs; + delayCs = (int) Math.max(MIN_FRAME_DELAY_CS, Math.min(0xffff, Math.round(deltaMs / 10.0))); + } + // Graphic control extension: no disposal, no transparency. + out.write(0x21); + out.write(0xf9); + out.write(4); + out.write(0x04); // disposal method 1 (do not dispose) + writeShortLE(out, delayCs); + out.write(0); // transparent color index (unused) + out.write(0); + // Image descriptor: full frame, no local color table. + out.write(0x2c); + writeShortLE(out, 0); + writeShortLE(out, 0); + writeShortLE(out, width); + writeShortLE(out, height); + out.write(0); + writeLzwImageData(out, inflate(frame.deflatedIndices, width * height)); + } + out.write(0x3b); // trailer + } + + private static byte[] inflate(byte[] deflated, int size) throws IOException { + Inflater inflater = new Inflater(); + inflater.setInput(deflated); + byte[] data = new byte[size]; + try { + int offset = 0; + while (offset < size && !inflater.finished()) { + int n = inflater.inflate(data, offset, size - offset); + if (n == 0) break; + offset += n; + } + if (offset != size) { + throw new IOException("recorded frame truncated: " + offset + " of " + size); + } + } catch (DataFormatException e) { + throw new IOException("recorded frame corrupt", e); + } finally { + inflater.end(); + } + return data; + } + + /** GIF LZW compression of a 4-bit index stream (minimum code size 4). */ + private static void writeLzwImageData(OutputStream out, byte[] indices) throws IOException { + final int minCodeSize = 4; + out.write(minCodeSize); + SubBlockBitWriter writer = new SubBlockBitWriter(out); + final int clearCode = 1 << minCodeSize; + final int eoiCode = clearCode + 1; + int codeSize = minCodeSize + 1; + int nextCode = eoiCode + 1; + HashMap table = new HashMap<>(); + writer.writeCode(clearCode, codeSize); + int prefix = indices[0] & 0xff; + for (int i = 1; i < indices.length; i++) { + int k = indices[i] & 0xff; + int key = (prefix << 8) | k; + Integer code = table.get(key); + if (code != null) { + prefix = code; + continue; + } + writer.writeCode(prefix, codeSize); + if (nextCode == 0x1000) { + writer.writeCode(clearCode, codeSize); + table.clear(); + codeSize = minCodeSize + 1; + nextCode = eoiCode + 1; + } else { + if (nextCode >= (1 << codeSize)) { + codeSize++; + } + table.put(key, nextCode++); + } + prefix = k; + } + writer.writeCode(prefix, codeSize); + writer.writeCode(eoiCode, codeSize); + writer.finish(); + } + + /** + * Packs LZW codes LSB-first into bytes and the bytes into the 255-byte + * data sub-blocks GIF image data is carried in. + */ + private static final class SubBlockBitWriter { + private final OutputStream out; + private final byte[] block = new byte[255]; + private int blockLength; + private int bitBuffer; + private int bitCount; + + SubBlockBitWriter(OutputStream out) { + this.out = out; + } + + void writeCode(int code, int codeSize) throws IOException { + bitBuffer |= code << bitCount; + bitCount += codeSize; + while (bitCount >= 8) { + writeByte(bitBuffer & 0xff); + bitBuffer >>>= 8; + bitCount -= 8; + } + } + + void finish() throws IOException { + if (bitCount > 0) { + writeByte(bitBuffer & 0xff); + bitBuffer = 0; + bitCount = 0; + } + flushBlock(); + out.write(0); // block terminator + } + + private void writeByte(int b) throws IOException { + block[blockLength++] = (byte) b; + if (blockLength == 255) { + flushBlock(); + } + } + + private void flushBlock() throws IOException { + if (blockLength == 0) return; + out.write(blockLength); + out.write(block, 0, blockLength); + blockLength = 0; + } + } + + private static void writeShortLE(OutputStream out, int value) throws IOException { + out.write(value & 0xff); + out.write((value >>> 8) & 0xff); + } +} diff --git a/App_Resources/Android/src/main/java/com/faceclaw/app/ScreenshotUtil.java b/App_Resources/Android/src/main/java/com/faceclaw/app/ScreenshotUtil.java index f80cf7ef..9ffdcd1b 100644 --- a/App_Resources/Android/src/main/java/com/faceclaw/app/ScreenshotUtil.java +++ b/App_Resources/Android/src/main/java/com/faceclaw/app/ScreenshotUtil.java @@ -2,43 +2,123 @@ package com.faceclaw.app; import android.content.Context; +import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; -import java.nio.ByteBuffer; +import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; +import java.util.zip.CRC32; +import java.util.zip.Deflater; /** - * Saves raw screenshots for compression experiments. The output is the exact - * headerless top-down 4bpp frame buffer that gets zlib-compressed on the wire - * (build4bppBmp followed by pack4bppFromBmp), deliberately untransformed — no - * resize, no gamma, no header. + * Saves screenshots of the composited screen as 4-bit grayscale PNGs (the + * display's native depth). Retrieve with + * adb pull /sdcard/Android/data/com.faceclaw.app/files/screenshots/ */ public final class ScreenshotUtil { private ScreenshotUtil() {} /** Returns the absolute path of the written file. */ - public static String saveRawScreenshot(Context context, ByteBuffer image8bpp, int width, int height) throws java.io.IOException { - if (image8bpp == null || width <= 0 || height <= 0 || image8bpp.remaining() < width * height) { + public static String savePngScreenshot(Context context, byte[] gray, int width, int height) throws IOException { + if (gray == null || width <= 0 || height <= 0 || gray.length < width * height) { throw new IllegalArgumentException("invalid screenshot buffer"); } - byte[] gray = new byte[image8bpp.remaining()]; - image8bpp.get(gray); - byte[] packed = BmpUtil.pack4bppFromBmp(BmpUtil.build4bppBmp(gray, width, height)); - if (packed.length == 0) { - throw new IllegalStateException("failed to pack 4bpp frame"); - } - - File dir = new File(context.getExternalFilesDir(null), "screenshots"); - if (!dir.exists() && !dir.mkdirs()) { - throw new java.io.IOException("failed to create " + dir); - } - String stamp = new SimpleDateFormat("yyyyMMdd-HHmmss-SSS", Locale.US).format(new Date()); - File file = new File(dir, "screen-" + stamp + "-" + width + "x" + height + ".4bpp"); + byte[] png = encode4BitGrayPng(gray, width, height); + File file = new File(ensureScreenshotsDir(context), "screen-" + timestamp() + ".png"); try (FileOutputStream out = new FileOutputStream(file)) { - out.write(packed); + out.write(png); } return file.getAbsolutePath(); } + + static File ensureScreenshotsDir(Context context) throws IOException { + File dir = new File(context.getExternalFilesDir(null), "screenshots"); + if (!dir.exists() && !dir.mkdirs()) { + throw new IOException("failed to create " + dir); + } + return dir; + } + + static String timestamp() { + return new SimpleDateFormat("yyyyMMdd-HHmmss-SSS", Locale.US).format(new Date()); + } + + /** + * Encode an 8bpp grayscale buffer as a bit-depth-4 grayscale PNG, keeping + * the top nibble of each pixel (the same quantization the wire format uses). + */ + static byte[] encode4BitGrayPng(byte[] gray, int width, int height) { + // Raw scanlines: one filter byte (0 = None) then two pixels per byte, + // leftmost pixel in the high nibble. + int rowBytes = (width + 1) / 2; + byte[] raw = new byte[height * (1 + rowBytes)]; + int p = 0; + for (int y = 0; y < height; y++) { + raw[p++] = 0; + int row = y * width; + for (int x = 0; x < width; x += 2) { + int hi = (gray[row + x] & 0xff) >>> 4; + int lo = (x + 1 < width) ? (gray[row + x + 1] & 0xff) >>> 4 : 0; + raw[p++] = (byte) ((hi << 4) | lo); + } + } + + ByteArrayOutputStream out = new ByteArrayOutputStream(); + out.write(0x89); + out.write('P'); + out.write('N'); + out.write('G'); + out.write(0x0d); + out.write(0x0a); + out.write(0x1a); + out.write(0x0a); + + ByteArrayOutputStream ihdr = new ByteArrayOutputStream(); + writeIntBE(ihdr, width); + writeIntBE(ihdr, height); + ihdr.write(4); // bit depth + ihdr.write(0); // color type: grayscale + ihdr.write(0); // compression + ihdr.write(0); // filter + ihdr.write(0); // interlace + writeChunk(out, "IHDR", ihdr.toByteArray()); + writeChunk(out, "IDAT", zlibDeflate(raw)); + writeChunk(out, "IEND", new byte[0]); + return out.toByteArray(); + } + + static byte[] zlibDeflate(byte[] data) { + Deflater deflater = new Deflater(); + deflater.setInput(data); + deflater.finish(); + ByteArrayOutputStream out = new ByteArrayOutputStream(Math.max(64, data.length / 8)); + byte[] buffer = new byte[8192]; + while (!deflater.finished()) { + out.write(buffer, 0, deflater.deflate(buffer)); + } + deflater.end(); + return out.toByteArray(); + } + + private static void writeChunk(ByteArrayOutputStream out, String type, byte[] data) { + writeIntBE(out, data.length); + CRC32 crc = new CRC32(); + for (int i = 0; i < 4; i++) { + int b = type.charAt(i); + out.write(b); + crc.update(b); + } + out.write(data, 0, data.length); + crc.update(data); + writeIntBE(out, (int) crc.getValue()); + } + + private static void writeIntBE(ByteArrayOutputStream out, int value) { + out.write((value >>> 24) & 0xff); + out.write((value >>> 16) & 0xff); + out.write((value >>> 8) & 0xff); + out.write(value & 0xff); + } } diff --git a/app/g2/dashboard-controller.ts b/app/g2/dashboard-controller.ts index a38e9dbe..51777e46 100644 --- a/app/g2/dashboard-controller.ts +++ b/app/g2/dashboard-controller.ts @@ -90,7 +90,6 @@ import { firmwareDebugFlagsSetting, nightscoutSiteUrlSetting, onAnySettingChanged, - rawScreenshotsEnabledSetting, saveVoiceRecordingsSetting, screenTimeoutSetting, screenTimeoutSettingToMs, @@ -122,7 +121,7 @@ export type DashboardSnapshot = { evenAppConflictWarningVisible: boolean; firmwareWarningMessage: string; firmwareWarningVisible: boolean; - rawScreenshotsEnabled: boolean; + screenRecordingActive: boolean; batteryOptimizationWarningVisible: boolean; }; @@ -203,6 +202,7 @@ class DashboardController { private evenAppConflictMessage = ""; private firmwareWarningMessage = ""; private batteryOptimizationWarningVisible = false; + private screenRecordingActive = false; private displayPreview: ImageSource | null = createInitialDisplayPreview(); private silentMode = false; // Brightness value last pushed to the glasses; see pushBrightness. @@ -311,7 +311,7 @@ class DashboardController { }); }); // Settings toggled from the glasses can change what the phone UI shows - // (e.g. the raw-screenshot button), so re-emit the snapshot on any change. + // (e.g. the text-setting editor), so re-emit the snapshot on any change. onAnySettingChanged(() => { this.emit(); // Apply a firmware-debug-flags toggle live while connected (Java dedups). @@ -520,13 +520,45 @@ class DashboardController { void this.communicator.setBrightness(level === null, level ?? 0).catch(() => {}); } + /** Save the current composited screen as a 4-bit grayscale PNG. */ + saveScreenshot(): string { + const path = this.communicator?.saveScreenshot() ?? ""; + this.appendLog(path ? `screenshot saved: ${path}` : "screenshot skipped: not connected"); + return path; + } + /** - * Save the current composited screen as the raw headerless 4bpp frame - * buffer the wire compressor sees; test data for compression experiments. + * Begin collecting composited frames for an animated-GIF screen recording. + * Frames are captured at the same points the phone-side preview is + * refreshed, so the recording matches what the phone display showed. */ - saveRawDashboardScreenshot(): string { - const path = this.communicator?.saveRawCompositeScreenshot() ?? ""; - this.appendLog(path ? `raw screenshot saved: ${path}` : "raw screenshot skipped: not connected"); + startScreenRecording(): void { + if (this.screenRecordingActive) return; + const communicator = this.communicator; + if (!communicator) { + this.appendLog("screen recording skipped: not connected"); + return; + } + communicator.startScreenRecording(); + // Capture the starting frame immediately rather than waiting for the + // next preview flush. + communicator.recordScreenFrame(); + this.screenRecordingActive = true; + this.appendLog("screen recording started"); + this.emit(); + } + + /** Finish the recording and save it as an animated GIF; returns the path or "". */ + stopScreenRecording(): string { + if (!this.screenRecordingActive) return ""; + this.screenRecordingActive = false; + let path = ""; + try { + path = this.communicator?.stopScreenRecording() ?? ""; + } finally { + this.emit(); + } + this.appendLog(path ? `screen recording saved: ${path}` : "screen recording discarded: no frames"); return path; } @@ -552,7 +584,7 @@ class DashboardController { evenAppConflictWarningVisible: this.evenAppConflictMessage.length > 0, firmwareWarningMessage: this.firmwareWarningMessage, firmwareWarningVisible: this.firmwareWarningMessage.length > 0, - rawScreenshotsEnabled: rawScreenshotsEnabledSetting.get(), + screenRecordingActive: this.screenRecordingActive, batteryOptimizationWarningVisible: this.batteryOptimizationWarningVisible, }; } @@ -908,6 +940,18 @@ class DashboardController { this.evenHubSessionSuspended = false; this.evenHubResumePromise = null; + // The recording's frame store lives in the communicator, so save what has + // accumulated rather than silently losing it with the connection. + if (this.screenRecordingActive) { + this.screenRecordingActive = false; + try { + const path = communicator?.stopScreenRecording() ?? ""; + this.appendLog(path ? `screen recording saved: ${path}` : "screen recording discarded: no frames"); + } catch (error) { + this.appendLog(`screen recording save failed: ${this.formatError(error)}`); + } + } + try { const leaseReleased = await communicator?.setFaceclawWakeLeaseEnabled(false).catch((error) => { this.appendLog(`wake takeover lease release failed: ${this.formatError(error)}`); @@ -1654,6 +1698,11 @@ class DashboardController { return; } this.lastConnectedPreviewUpdateAtMs = now; + // The recorder captures at the same cadence the phone-side preview is + // refreshed, so the GIF matches what the phone display showed. + if (this.screenRecordingActive) { + this.communicator.recordScreenFrame(); + } const preview = this.communicator.getCompositePreview(); if (preview) { this.setDisplayPreview(preview); diff --git a/app/native/faceclaw-communicator.ts b/app/native/faceclaw-communicator.ts index f1f196ff..ce896c89 100644 --- a/app/native/faceclaw-communicator.ts +++ b/app/native/faceclaw-communicator.ts @@ -390,10 +390,28 @@ export class FaceclawCommunicatorBridge { return bitmap ? new ImageSource(bitmap) : null; } - /** Save the current composite as a raw 4bpp screenshot; returns the path (empty if none). */ - saveRawCompositeScreenshot(): string { + /** Save the current composite as a 4-bit grayscale PNG; returns the path (empty if none). */ + saveScreenshot(): string { if (!global.isAndroid) return ""; - return String(this.communicator.saveRawCompositeScreenshot()); + return String(this.communicator.saveCompositePngScreenshot()); + } + + /** Begin collecting composite frames for an animated-GIF screen recording. */ + startScreenRecording(): void { + if (!global.isAndroid) return; + this.communicator.startScreenRecording(); + } + + /** Capture the current composite into the active recording; no-op when idle. */ + recordScreenFrame(): void { + if (!global.isAndroid) return; + this.communicator.recordScreenFrame(); + } + + /** Finish the recording and save the animated GIF; returns the path (empty if no frames). */ + stopScreenRecording(): string { + if (!global.isAndroid) return ""; + return String(this.communicator.stopScreenRecording()); } /** diff --git a/app/native/raw-screenshot.ts b/app/native/raw-screenshot.ts deleted file mode 100644 index 39e0ebc4..00000000 --- a/app/native/raw-screenshot.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { Utils } from "@nativescript/core"; - -import { type GrayImage } from "../graphics/image"; - -declare const com: any; - -/** - * Save an image as the raw headerless 576x288 4bpp frame buffer (the exact - * bytes the wire compressor sees) for compression experiments. Returns the - * absolute path of the written file; retrieve with - * adb pull /sdcard/Android/data/com.faceclaw.app/files/screenshots/ - */ -export function saveRawScreenshot(image: GrayImage): string { - const context = Utils.android.getApplicationContext(); - if (!context) throw new Error("Android application context unavailable"); - return String( - com.faceclaw.app.ScreenshotUtil.saveRawScreenshot( - context, - image.pixels.buffer, - image.width, - image.height, - ), - ); -} diff --git a/app/phone-ui/main-page.xml b/app/phone-ui/main-page.xml index 6d34beb6..bf7bc295 100644 --- a/app/phone-ui/main-page.xml +++ b/app/phone-ui/main-page.xml @@ -2,6 +2,8 @@ + + @@ -42,7 +44,7 @@