Compare commits

...
Author SHA1 Message Date
Blendman974 1d230a4014 docs: record release preserving the stock EvenHub canvas 2026-11-06 04:09:44 +01:00
Blendman974 cfa5a5a2bf Merge stock EvenHub canvas preservation 2026-11-06 03:38:18 +01:00
Blendman974 49099d5efe fix: preserve the stock EvenHub canvas in full screen 2026-11-06 03:38:18 +01:00
Blendman974 eae11ffa9c docs: record release with independent per-app keep awake 2026-11-06 03:32:57 +01:00
Blendman974 c705fc2222 Merge independent per-app keep-awake preference 2026-11-06 03:29:24 +01:00
Blendman974 772d5e0fe7 feat: separate per-app keep awake from full screen 2026-11-06 03:29:23 +01:00
Blendman974 964aa88c54 docs: record full-screen and notification dismissal release validation 2026-11-06 03:23:08 +01:00
Blendman974 3bba69ff56 Merge notification dismissal test fixture fix 2026-11-06 03:22:25 +01:00
Blendman974 5b3a4fa747 test: supply notification image tone fixture 2026-11-06 03:22:25 +01:00
Blendman974 c7225752dd Merge notification bulk dismissal 2026-11-06 03:19:58 +01:00
Blendman974 3124ae852a feat: dismiss all notifications from the app menu 2026-11-06 03:19:58 +01:00
Blendman974 7ba73c7659 feat: per-app full screen with idle sleep inhibition 2026-11-06 03:18:01 +01:00
Blendman974 badebb0a17 Merge per-app full screen and keep-awake behavior 2026-11-06 03:18:01 +01:00
Blendman974 da8d5c1960 docs: record combined multilingual Whisper release validation 2026-11-06 02:15:31 +01:00
Blendman974 30e436488f Merge local Whisper capture sharing fix 2026-11-06 02:13:43 +01:00
Blendman974 c5b57e85b0 fix: distinguish automatic local language from legacy English captures 2026-11-06 02:13:43 +01:00
Blendman974 1441d1015c Merge Whisper language build and regression fixes 2026-11-06 02:11:58 +01:00
Blendman974 44e4cd7300 fix: preserve caption engine configuration and settings fixtures 2026-11-06 02:11:58 +01:00
Blendman974 b1b53d1f79 Merge multilingual Whisper transcription
# Conflicts:
#	app/g2/dashboard-controller.ts
2026-11-06 02:09:22 +01:00
Blendman974 85a5a041f2 feat: select transcription language for cloud and local Whisper 2026-11-06 02:08:58 +01:00
Blendman974 b9ff58271d Merge Wear OS release build support 2026-11-06 01:42:07 +01:00
Blendman974 2b14ea38b4 build: support Wear OS release SDK 2026-11-06 01:41:57 +01:00
Blendman974 a9b0644217 docs: record combined release including app switcher close actions 2026-11-06 01:22:46 +01:00
Blendman974 be939f401b test: update system menu expectations and explicit in-app hold focus 2026-11-06 01:22:28 +01:00
Blendman974 e0887f9968 Merge app switcher regression test updates 2026-11-06 01:22:28 +01:00
Blendman974 9df5bd1598 fix: remove unreachable switcher focus branch after menu routing 2026-11-06 01:19:51 +01:00
Blendman974 ed3508ebfe Merge app switcher routing typecheck fix 2026-11-06 01:19:51 +01:00
Blendman974 299bf470c3 feat: add app switcher actions to close current or all apps 2026-11-06 01:19:13 +01:00
Blendman974 5820c3c441 Merge app switcher close menu 2026-11-06 01:19:13 +01:00
Blendman974 ec0be434ad Merge Android 16 KiB page alignment fix 2026-11-06 00:57:10 +01:00
Blendman974 68c9dc7ae9 fix: align llama native library for Android 16 KiB pages 2026-11-06 00:57:10 +01:00
Blendman974 40cd9eb5ba docs: record integrated APK build and software validation 2026-11-06 00:29:41 +01:00
Blendman974 61c017a0b0 test: verify executable Nix Android build tools 2026-11-06 00:27:12 +01:00
Blendman974 e915608b1a build: support Nix host CMake and Ninja for Android native libraries 2026-11-06 00:25:36 +01:00
Blendman974 e1e48ec038 chore: complete build-only Nix SDK and document head-up firmware checks 2026-11-06 00:22:05 +01:00
Blendman974 66f4147e38 Merge Nix Android build configuration fixes 2026-11-06 00:11:03 +01:00
Blendman974 096510f5ad chore: align Nix build tooling with Android Kotlin requirements 2026-11-06 00:11:03 +01:00
Blendman974 0786657441 Merge shared Android calendar selection 2026-11-06 00:05:59 +01:00
Blendman974 de318a7714 Merge notification filter preferences 2026-11-06 00:05:58 +01:00
Blendman974 398c62af9a feat: persist and synchronize head-up wake and angle controls 2026-11-06 00:05:48 +01:00
Blendman974 6397928c60 test: keep calendar widget imports isolated and update window fixture 2026-11-06 00:00:07 +01:00
Blendman974 1f12237dfe feat: share Android calendar selection across readers 2026-11-05 23:59:34 +01:00
Blendman974 62ae01a4f1 feat: configure notification defaults and bulk source actions 2026-11-05 23:54:14 +01:00
Blendman974 19cf564251 chore: add pinned Nix development environment 2026-11-05 23:52:02 +01:00
77 changed files with 2290 additions and 87 deletions

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
watch_file devenv.nix devenv.yaml devenv.lock
eval "$(devenv direnvrc)"
use devenv
+5
View File
@@ -49,6 +49,11 @@ faceclaw_settings.xml
faceclaw_settings*.json
# Developer configs
.devenv*
.direnv/
.android/
devenv.local.nix
local.properties
build_paths.sh
**/xcuserdata/
+8
View File
@@ -162,6 +162,14 @@ tasks.register("prepareFaceclawNativeLibs") {
def faceclawLlamaCppTag = "b10333"
def faceclawFindSdkCmakeDir = {
// NixOS and other managed environments can provide patched host tools.
def explicitCmake = System.getenv("ANDROID_CMAKE_HOME")
if (explicitCmake != null) {
def explicitDir = file(explicitCmake)
if (faceclawHostExecutable(file("$explicitDir/bin"), "cmake").exists()
&& faceclawHostExecutable(file("$explicitDir/bin"), "ninja").exists()) return explicitDir
throw new GradleException("ANDROID_CMAKE_HOME must contain bin/cmake and bin/ninja: $explicitDir")
}
def sdkRoot = System.getenv("ANDROID_HOME") ?: System.getenv("ANDROID_SDK_ROOT")
if (sdkRoot == null) return null
def cmakeRoot = file("$sdkRoot/cmake")
@@ -25,18 +25,21 @@ internal object AndroidSpeechEngines {
private const val FEATURE_DIM = 80
/** Sherpa-onnx configuration for the on-device model files in [modelDir]. */
fun recognizerConfig(modelDir: File, kind: VoiceModelKind): OfflineRecognizerConfig {
fun recognizerConfig(
modelDir: File, kind: VoiceModelKind,
whisper: WhisperModelFiles = WhisperModelFiles.forLanguage(null),
): OfflineRecognizerConfig {
val modelConfig = OfflineModelConfig.builder()
.setNumThreads(1)
if (kind == VoiceModelKind.WHISPER) {
modelConfig
.setWhisper(OfflineWhisperModelConfig.builder()
.setEncoder(File(modelDir, "base.en-encoder.int8.onnx").absolutePath)
.setDecoder(File(modelDir, "base.en-decoder.int8.onnx").absolutePath)
.setLanguage("en")
.setEncoder(File(modelDir, whisper.encoder).absolutePath)
.setDecoder(File(modelDir, whisper.decoder).absolutePath)
.setLanguage(whisper.language)
.setTask("transcribe")
.build())
.setTokens(File(modelDir, "base.en-tokens.txt").absolutePath)
.setTokens(File(modelDir, whisper.tokens).absolutePath)
} else {
modelConfig
.setMoonshine(OfflineMoonshineModelConfig.builder()
@@ -249,6 +249,8 @@ class FaceclawBleCommunicator(context: Context, rightAddress: String?, leftAddre
fun enableWearDetectionAndRequestState() = core.enableWearDetectionAndRequestState()
fun configureHeadUpWake(enabled: Int, angle: Int) = core.configureHeadUpWake(enabled, angle)
fun startBandwidthBenchmark(messageSize: Int, windowSize: Int, durationMs: Int): Boolean =
core.startBandwidthBenchmark(messageSize, windowSize, durationMs)
@@ -54,7 +54,8 @@ class FaceclawCalendarProvider private constructor() {
* boundaries the provider stores them as.
*/
@JvmStatic
fun getUpcomingEventsJson(context: Context?, maxEvents: Int, windowMs: Long): String {
@JvmOverloads
fun getUpcomingEventsJson(context: Context?, maxEvents: Int, windowMs: Long, selectedCalendarIdsJson: String = "null"): String {
if (context == null || maxEvents <= 0) {
return "[]"
}
@@ -73,11 +74,21 @@ class FaceclawCalendarProvider private constructor() {
val events = ArrayList<Event>()
var cursor: Cursor? = null
try {
// Filter instances before the cutoff/limit so excluded calendars
// cannot crowd out selected calendars, including recurrences.
val ids = if (selectedCalendarIdsJson == "null") null else JSONArray(selectedCalendarIdsJson)
if (ids != null && ids.length() == 0) return "[]"
val args = ids?.let { values -> Array(values.length()) { index ->
values.getString(index).also { require(it.matches(Regex("[0-9]+"))) }
} }
val selection = args?.let {
CalendarContract.Instances.CALENDAR_ID + " IN (" + it.joinToString(",") { "?" } + ")"
}
cursor = context.contentResolver.query(
uri,
PROJECTION,
null,
null,
selection,
args,
CalendarContract.Instances.BEGIN + " ASC")
if (cursor != null) {
val utc = Calendar.getInstance(TimeZone.getTimeZone("UTC"))
@@ -118,6 +129,33 @@ class FaceclawCalendarProvider private constructor() {
return out.toString()
}
@JvmStatic
fun getCalendarsJson(context: Context?): String {
if (context == null) return "[]"
val out = JSONArray()
try {
context.contentResolver.query(
CalendarContract.Calendars.CONTENT_URI,
arrayOf(CalendarContract.Calendars._ID, CalendarContract.Calendars.CALENDAR_DISPLAY_NAME,
CalendarContract.Calendars.ACCOUNT_NAME, CalendarContract.Calendars.ACCOUNT_TYPE),
null, null, CalendarContract.Calendars.CALENDAR_DISPLAY_NAME + " ASC",
)?.use { cursor ->
while (cursor.moveToNext()) {
out.put(JSONObject().apply {
put("id", cursor.getLong(0).toString())
put("name", cursor.getString(1) ?: "")
put("accountName", cursor.getString(2) ?: "")
put("accountType", cursor.getString(3) ?: "")
})
}
}
} catch (t: Throwable) {
Log.w(TAG, "failed to read calendars", t)
return "[]"
}
return out.toString()
}
private fun readEvent(cursor: Cursor, utc: Calendar, local: Calendar): Event {
val allDay = cursor.getInt(4) != 0
var startMs = cursor.getLong(2)
@@ -504,6 +504,18 @@ class FaceclawMediaNotificationListenerService : NotificationListenerService() {
}
}
@JvmStatic
fun dismissAllNotifications(): Boolean {
val service = activeService ?: return false
return try {
service.cancelAllNotifications()
true
} catch (t: Throwable) {
Log.w(TAG, "failed to dismiss all notifications", t)
false
}
}
private fun emitNotificationPosted(key: String?) {
emitNotificationEvent(key) { listener, eventKey -> listener.onNotificationPosted(eventKey) }
}
@@ -32,17 +32,6 @@ class FaceclawVoiceController(context: Context) {
"decoder_model_merged.ort",
"tokens.txt"
)
// Second on-device model: sherpa-onnx's offline Whisper backend (base.en,
// int8-quantized -- see the model-choice note in asr-model.ts). Directory
// shared with the TS-side download flow, same convention as ASR_MODEL_DIR.
// Whisper re-encodes the whole buffer on every call, so the shared session
// skips live partials for it; see VoiceCaptureSession.processRecognizer.
private const val ASR_WHISPER_MODEL_DIR = "sherpa-onnx-whisper-base-en-int8"
private val ASR_WHISPER_MODEL_FILES = arrayOf(
"base.en-encoder.int8.onnx",
"base.en-decoder.int8.onnx",
"base.en-tokens.txt"
)
// 50 ms chunks match the G2 packet cadence the rest of the pipeline
// (endpointing, transcript pacing) is tuned for.
private const val PHONE_MIC_CHUNK_SAMPLES = SAMPLE_RATE / 20
@@ -84,6 +73,7 @@ class FaceclawVoiceController(context: Context) {
private val mainHandler = Handler(Looper.getMainLooper())
@Volatile
private var communicator: FaceclawBleCommunicator? = null
private var whisperModel = WhisperModelFiles.forLanguage(null)
private val host = object : VoiceCaptureHost {
override val dispatcher = CallbackDispatcher { action -> mainHandler.post { action() } }
@@ -122,7 +112,7 @@ class FaceclawVoiceController(context: Context) {
override fun loadTranscriber(kind: VoiceModelKind): OfflineTranscriber {
val modelDir = findAsrModelDir(kind) ?: throw IllegalStateException("voice model missing")
return AndroidSpeechEngines.SherpaTranscriber(AndroidSpeechEngines.recognizerConfig(modelDir, kind))
return AndroidSpeechEngines.SherpaTranscriber(AndroidSpeechEngines.recognizerConfig(modelDir, kind, whisperModel))
}
override fun speakerEmbedder(modelPath: String): SpeakerEmbedder {
@@ -168,6 +158,11 @@ class FaceclawVoiceController(context: Context) {
session.setOnboardModelKind(kind)
}
/** Language for the next on-device Whisper capture; empty enables auto-detection. */
fun setOnboardLanguage(language: String?) {
whisperModel = WhisperModelFiles.forLanguage(language)
}
/**
* When true, watch the decoded PCM and fire {@code onSpeechEnd} once the
* speaker stops. Used by hands-free ("Hey Even") capture, which has no
@@ -263,8 +258,8 @@ class FaceclawVoiceController(context: Context) {
*/
private fun findAsrModelDir(kind: VoiceModelKind): File? {
val whisper = kind == VoiceModelKind.WHISPER
val dirName = if (whisper) ASR_WHISPER_MODEL_DIR else ASR_MODEL_DIR
val fileNames = if (whisper) ASR_WHISPER_MODEL_FILES else ASR_MODEL_FILES
val dirName = if (whisper) whisperModel.dirName else ASR_MODEL_DIR
val fileNames = if (whisper) whisperModel.files else ASR_MODEL_FILES.toList()
val modelDir = File(appContext.filesDir, ASR_ROOT + File.separator + dirName)
for (fileName in fileNames) {
val file = File(modelDir, fileName)
@@ -29,3 +29,8 @@ add_subdirectory(${LLAMA_CPP_SOURCE_DIR} llama.cpp-build EXCLUDE_FROM_ALL)
add_library(faceclaw_llama SHARED faceclaw_llama.cpp)
target_link_libraries(faceclaw_llama PRIVATE llama android log)
# NDK r27 defaults to 4 KiB. Align both LOAD segments and RELRO boundaries
# for Android devices using 16 KiB pages, including debug APKs.
target_link_options(faceclaw_llama PRIVATE
"-Wl,-z,max-page-size=16384"
"-Wl,-z,common-page-size=16384")
+5
View File
@@ -3,6 +3,7 @@ import { invalidateCalendarCache, onCalendarChanged } from "../../native/calenda
import { makeImageWindowIcon, windowIcon } from "../../ui/shell/chrome-layer";
import { CalendarLayer } from "./calendar";
import { renderCalendarDateIcon } from "./calendar-icon";
import { calendarSelectionMenuItems } from "./calendar-filter";
import {
createInProcessWindow,
YieldAtRootLayer,
@@ -44,6 +45,10 @@ export function createCalendarAppWindow(options: InProcessAppOptions): InProcess
icon: "calendar",
drawIcon: makeImageWindowIcon(renderCalendarDateIcon, windowIcon("calendar", "Ca")),
closeable: true,
menuItems: () => calendarSelectionMenuItems().map(item => ({ ...item, onSelect: (ctx, menu) => {
ctx.stack.pop();
return item.onSelect(ctx, menu);
} })),
actions: options.actions,
baseLayer: new YieldAtRootLayer(new CalendarLayer(requestPermission)),
submitFrame: options.submitFrame,
+94
View File
@@ -0,0 +1,94 @@
import { getDefaultSmallFont } from "../../graphics/ui-fonts";
import { type GrayImage } from "../../graphics/image";
import { truncateText } from "../../graphics/textwrap";
import { readCalendarSelection, setCalendarSelection } from "../../native/calendar-selection";
import { readAvailableCalendars } from "../../native/calendar-sources";
import { hasCalendarPermission } from "../../native/calendar-permissions";
import { type InputEvent } from "../../ui/gestures";
import { type Layer, type LayerContext, type PaintBelow } from "../../ui/layers";
import { drawToggleMenuItem, MenuLayer, type MenuItem } from "../../ui/menu";
/** Shared preference for every Android calendar reader. */
export class CalendarFilterLayer implements Layer {
private menu: MenuLayer | null = null;
private width = 0;
private keys: string[] = [];
private currentMenu(ctx: LayerContext): MenuLayer {
const calendars = readAvailableCalendars().sort((a, b) =>
a.name.localeCompare(b.name) || a.accountName.localeCompare(b.accountName) || a.id.localeCompare(b.id));
const selection = readCalendarSelection();
const known = new Set(calendars.map(calendar => calendar.id));
const keys = ["all", "none"];
const toggle = (id: string) => {
// Leaving all mode snapshots the current calendars. Newly added calendars
// then stay excluded until selected individually or all mode is restored.
const ids = new Set(readCalendarSelection() ?? calendars.map(calendar => calendar.id));
if (ids.has(id)) ids.delete(id); else ids.add(id);
setCalendarSelection(Array.from(ids));
};
const items: MenuItem[] = [{
label: "All calendars",
description: "Include all calendars, including calendars added later.",
onSelect: () => setCalendarSelection(null),
render: ({ image, x, y, width, selected }) => drawToggleMenuItem(image, getDefaultSmallFont(), x, y, width,
"All calendars", readCalendarSelection() === null, selected),
}, {
label: "No calendars",
onSelect: () => setCalendarSelection([]),
render: ({ image, x, y, width, selected }) => drawToggleMenuItem(image, getDefaultSmallFont(), x, y, width,
"No calendars", readCalendarSelection()?.length === 0, selected),
}];
const rows = [
...calendars.map(calendar => ({ id: calendar.id,
label: `${calendar.name || "(unnamed)"} / ${calendar.accountName || "Local"} (${calendar.accountType || "local"}) #${calendar.id}` })),
...(selection ?? []).filter(id => !known.has(id)).map(id => ({ id, label: `Unavailable calendar #${id}` })),
];
for (const row of rows) {
keys.push(`calendar:${row.id}`);
items.push({
label: row.label,
description: row.label,
onSelect: () => toggle(row.id),
render: ({ image, x, y, width, selected }) => {
const font = getDefaultSmallFont();
const ids = readCalendarSelection();
drawToggleMenuItem(image, font, x, y, width, truncateText(font, row.label, width - 48),
ids === null || ids.includes(row.id), selected);
},
});
}
if (!calendars.length) items.push({
label: hasCalendarPermission() ? "No calendars available" : "Grant calendar permission on your phone",
disabled: true, onSelect: () => {},
});
const key = this.menu?.selectedIndex != null ? this.keys[this.menu.selectedIndex] : "all";
const index = Math.max(0, keys.indexOf(key ?? "all"));
this.keys = keys;
const width = ctx.stack.getBaseSize().width;
if (!this.menu || this.width !== width) {
this.width = width;
this.menu = new MenuLayer("Calendars displayed", items, {
x: 8, y: 8, width: width - 16, opaque: true, showBorder: false,
footer: "Shared by Calendar and Glanceboard",
}).selectItem(index);
} else this.menu.setItems(items, index);
return this.menu;
}
paint(ctx: LayerContext, paintBelow: PaintBelow): GrayImage {
return this.currentMenu(ctx).paint(ctx, paintBelow);
}
async handleInput(event: InputEvent, ctx: LayerContext): Promise<void> {
await this.currentMenu(ctx).handleInput(event, ctx);
}
}
export function calendarSelectionMenuItems(): MenuItem[] {
return global.isAndroid ? [{
label: "Calendars displayed",
description: "Choose the calendars used by Calendar, Glanceboard and other calendar views.",
onSelect: ctx => ctx.stack.push(new CalendarFilterLayer()),
}] : [];
}
+22 -13
View File
@@ -4,7 +4,7 @@
* makes the content area exactly the 576x288 surface EvenHub apps expect.
*/
import { GrayImage } from "../../graphics/image";
import { EVENHUB_SCREEN_WIDTH } from "./compositor";
import { EVENHUB_SCREEN_WIDTH, EVENHUB_SCREEN_HEIGHT } from "./compositor";
import { directionalFallback, isDirectionalInput, type InputEvent } from "../../ui/gestures";
import { type Layer, type LayerContext } from "../../ui/layers";
import {
@@ -24,21 +24,26 @@ class EvenHubAppLayer implements Layer {
* extension's source field should see that they came from the watch.
*/
readonly acceptsDirectional = true;
private tallCanvas = false;
constructor(private readonly session: EvenHubSession) {}
setTallCanvas(tall: boolean): void {
this.tallCanvas = tall;
}
paint(ctx: LayerContext): GrayImage {
const size = ctx.stack.getBaseSize();
// EvenHub apps lay out for the stock 576-wide surface. In the Full
// Screen display mode the window is 640 wide; paint at stock width and
// centre it rather than leaving all the slack on the right.
if (size.width > EVENHUB_SCREEN_WIDTH) {
const content = this.session.paint({ width: EVENHUB_SCREEN_WIDTH, height: size.height }, ctx.stack.isFocused());
const image = new GrayImage(size.width, size.height, 0);
content.composeInto(image, Math.floor((size.width - EVENHUB_SCREEN_WIDTH) / 2), 0);
return image;
}
return this.session.paint(size, ctx.stack.isFocused());
// Host full screen hides chrome; it does not enlarge the stock app canvas.
// Only the app's explicit Faceclaw extended-layout request opts into height.
const canvas = { width: EVENHUB_SCREEN_WIDTH, height: this.tallCanvas ? size.height : EVENHUB_SCREEN_HEIGHT };
const content = this.session.paint(canvas, ctx.stack.isFocused());
if (size.width === canvas.width && size.height === canvas.height) return content;
const image = new GrayImage(size.width, size.height, 0);
// Clip text to its logical canvas before placing it in the larger host window.
image.bitBlt(content.withDrawsBaked(), Math.max(0, Math.floor((size.width - canvas.width) / 2)),
Math.max(0, Math.floor((size.height - canvas.height) / 2)));
return image;
}
handleInput(event: InputEvent): void {
@@ -60,6 +65,7 @@ export function createEvenHubWindow(
requestShellRender: () => void,
): InProcessWindow {
const fallbackIcon = windowIcon("package", session.manifest.name.charAt(0).toUpperCase() || "E");
const appLayer = new EvenHubAppLayer(session);
const created = createInProcessWindow({
appId,
windowId,
@@ -91,7 +97,7 @@ export function createEvenHubWindow(
{ label: "Show phone UI", onSelect: (ctx: LayerContext) => { ctx.stack.pop(); onShowPhone(); } },
],
actions: options.actions,
baseLayer: new EvenHubAppLayer(session),
baseLayer: appLayer,
submitFrame: options.submitFrame,
setSurfaceVisible: options.setSurfaceVisible,
removeSurface: options.removeSurface,
@@ -109,7 +115,10 @@ export function createEvenHubWindow(
pushOverlay: (layer) => created.stack.push(layer),
// The extended layout uses the full 576x452 app area ("max"); stock apps
// stay in the 576x288 band ("medium").
setTallCanvas: (tall) => created.setHeightMode(tall ? "max" : "medium"),
setTallCanvas: (tall) => {
appLayer.setTallCanvas(tall);
created.setHeightMode(tall ? "max" : "medium");
},
setAttention: (attention) => shell.setWindowAttention(windowId, attention),
// Only while the app listens for text: otherwise the shell's Type Into App
// destinations (voice dialog, phone keyboard, watch) would send into a void.
+2 -1
View File
@@ -1,5 +1,6 @@
import { type GlanceWidgetDefinition, type GlanceWidgetId } from "../widget";
import { CalendarWidget } from "./calendar-widget";
import { calendarSelectionMenuItems } from "../../calendar/calendar-filter";
import { CompassWidget } from "./compass-widget";
import { MusicWidget, musicSettingsMenuItems } from "./music-widget";
import { NightscoutWidget } from "./nightscout-widget";
@@ -11,7 +12,7 @@ import { HealthWidget } from "./health-widget";
/** Every widget a board slot can hold. */
export const GLANCE_WIDGETS: readonly GlanceWidgetDefinition[] = [
{ id: "system-card", label: "System card", settingsMenuItems: systemCardSettingsMenuItems, create: () => new SystemCardWidget() },
{ id: "calendar", label: "Calendar", tall: true, create: () => new CalendarWidget() },
{ id: "calendar", label: "Calendar", tall: true, settingsMenuItems: calendarSelectionMenuItems, create: () => new CalendarWidget() },
{ id: "terminal", label: "Terminal", tall: true, create: () => new TerminalWidget() },
{ id: "t3code", label: "T3 Code", tall: true, create: () => new T3CodeWidget() },
{ id: "nightscout", label: "Nightscout", create: () => new NightscoutWidget() },
+10 -1
View File
@@ -1,6 +1,6 @@
import { NotificationsListLayer } from "../../ui/notifications";
import { NotificationFilterLayer } from "../../ui/notification-filter";
import { onAndroidNotificationsChanged } from "../../native/notification-icons";
import { ALL_NOTIFICATIONS, dismissAllNotifications, onAndroidNotificationsChanged, readActiveNotifications } from "../../native/notification-icons";
import {
createInProcessWindow,
YieldAtRootLayer,
@@ -32,6 +32,15 @@ export function createNotificationsAppWindow(options: InProcessAppOptions): InPr
ctx.stack.pop();
ctx.stack.push(new NotificationFilterLayer());
},
}, {
label: "Dismiss all notifications",
description: "Dismiss notifications on the phone and glasses. System-protected notifications may remain.",
disabled: () => readActiveNotifications(ALL_NOTIFICATIONS).length === 0,
onSelect: (ctx) => {
ctx.stack.pop();
dismissAllNotifications();
created.requestRender();
},
}],
actions: options.actions,
baseLayer: new YieldAtRootLayer(new NotificationsListLayer()),
+23 -3
View File
@@ -1,4 +1,5 @@
import { startRemoteInput } from "../remote/service";
import { getHeadUpPreferences,appSwitcherPositionSetting,statusBarPositionSetting,statusBarVisibilitySetting,windowBorderSetting,assistantAllowProactiveSetting,assistantBackendSetting,assistantBridgeHostSetting,assistantBridgePortSetting,assistantBridgeTokenSetting,getBrightnessPreferences,displayLayoutSetting,navigateDisplayLayoutSetting,terminalDisplayLayoutSetting,elevenLabsApiKeySetting,getStringSettingById,openAiApiKeySetting,nightscoutApiTokenSetting,firmwareDebugFlagsSetting,whisperServerApiKeySetting,getVoiceTranscriptionLanguage,whisperServerModelSetting,whisperServerUrlSetting,lockScreenEnabledSetting,nightscoutSiteUrlSetting,onAnySettingChanged,previewColorSetting,ringConnectionModeSetting,type RingConnectionMode,saveVoiceRecordingsSetting,sonioxApiKeySetting,screenTimeoutSetting,screenTimeoutSettingToMs,suspendEvenHubWhenScreenOffSetting,voiceProviderSetting,wakeWordActionSetting,type ConfigSettingString } from "../ui/dashboard-settings";
import { acceptInput, resetRingInputFilter } from "../ui/input-monitor";
import { Application, Dialogs, ImageSource } from "@nativescript/core";
import { EvenAIStatus, EvenAIStatusName, EventSourceType, EventSourceTypeName, OsEventTypeList, OsEventTypeName, WatchGestureType, WatchGestureTypeName } from "./events";
@@ -78,7 +79,6 @@ import { loadPersistedOpenApps, savePersistedOpenApps } from "../ui/shell/open-a
import { appViewportRect, isOnSwitcherEdge, sidebarStripVisible, type ScreenRect, type WindowHeightMode } from "../ui/shell/geometry";
import { type ContinuousCaptureOptions, type LayerActions, type TextSettingsEditToggle, type TranscriptionChoice } from "../ui/layers";
import { type KeyboardInputSession } from "../ui/shell/keyboard-input";
import { appSwitcherPositionSetting, statusBarPositionSetting, statusBarVisibilitySetting, windowBorderSetting, assistantAllowProactiveSetting, assistantBackendSetting, assistantBridgeHostSetting, assistantBridgePortSetting, assistantBridgeTokenSetting, getBrightnessPreferences, displayLayoutSetting, navigateDisplayLayoutSetting, terminalDisplayLayoutSetting, elevenLabsApiKeySetting, getStringSettingById, openAiApiKeySetting, nightscoutApiTokenSetting, firmwareDebugFlagsSetting, whisperServerApiKeySetting, whisperServerLanguageSetting, whisperServerModelSetting, whisperServerUrlSetting, lockScreenEnabledSetting, nightscoutSiteUrlSetting, onAnySettingChanged, previewColorSetting, ringConnectionModeSetting, type RingConnectionMode, saveVoiceRecordingsSetting, sonioxApiKeySetting, screenTimeoutSetting, screenTimeoutSettingToMs, suspendEvenHubWhenScreenOffSetting, voiceProviderSetting, wakeWordActionSetting, type ConfigSettingString } from "../ui/dashboard-settings";
import { isIgnoringBatteryOptimizations, requestIgnoreBatteryOptimizations } from "../native/battery-optimization";
import {
getInstalledEvenHubAppById,
@@ -296,6 +296,7 @@ class DashboardController {
private silentMode = false;
// Brightness value last pushed to the glasses; see pushBrightness.
private lastPushedBrightness: string | null = null;
private lastPushedHeadUp: string | null = null;
// Last battery level the glasses reported, kept across disconnects so a
// drop-off right after a low reading can be explained as a flat battery.
private lastHeadsetBattery: number | null = null;
@@ -451,6 +452,8 @@ class DashboardController {
openNotificationsWindow: () =>
this.openInProcessAppInBackground(NOTIFICATIONS_WINDOW_ID, NOTIFICATIONS_SURFACE_ID, createNotificationsAppWindow),
onSwitcherBarHeightChanged: () => this.applySwitcherBarHeight(),
onWindowLayoutChanged: () => this.applySwitcherBarHeight(),
isLocked: () => this.glassesLocked,
onScreenStateChanged: (on) => {
// Any wake of the regular UI replaces a showing Glanceboard.
if (on) this.glance.dismiss();
@@ -476,6 +479,7 @@ class DashboardController {
// Apply a firmware-debug-flags toggle live while connected (Java dedups).
this.pushFirmwareDebugFlags();
this.pushBrightness();
this.pushHeadUpPreferences();
this.syncEvenHubScreenOffSetting();
// Display mode size first: a reflow repositions every surface too, so
// the band-position check after it then has nothing left to do.
@@ -483,6 +487,7 @@ class DashboardController {
this.applyVerticalPositionIfChanged();
this.applyAppLayoutsIfChanged();
this.syncAssistantBridgeIfChanged();
this.retargetContinuousCapture();
this.syncLockScreenSettingIfChanged();
// A Preview color or scaling change should show on the mirror at once,
// not at the next composited frame (cheap: floor-limited, dedup'd on
@@ -1084,6 +1089,19 @@ class DashboardController {
});
}
private pushHeadUpPreferences(force = false): void {
if (!global.isAndroid || !this.communicator) return;
const { enabled, angle } = getHeadUpPreferences();
if (enabled < 0 && angle < 0) return;
const value = JSON.stringify({ enabled, angle });
if (!force && value === this.lastPushedHeadUp) return;
this.lastPushedHeadUp = value;
void this.communicator.configureHeadUpWake(enabled, angle).catch(error => {
this.lastPushedHeadUp = null;
this.appendLog(`head-up configuration failed: ${this.formatError(error)}`);
});
}
/** Save the occupied part of the composited screen as a 4-bit grayscale PNG. */
saveScreenshot(): string {
const path = this.display?.saveScreenshot(shell.screenshotCropRect()) ?? "";
@@ -1533,6 +1551,7 @@ class DashboardController {
// ahead of them. Mirrors ensurePreviewDisplay.
await communicator.configureCompositorScreen(G2_LENS_WIDTH, G2_LENS_HEIGHT);
await communicator.configureBrightness(getBrightnessPreferences());
this.pushHeadUpPreferences(true);
this.offState = communicator.onStateChange((state) => {
if (state.phase !== "connected") resetRingInputFilter();
if (isHaltedSessionPhase(state.phase)) {
@@ -1570,6 +1589,7 @@ class DashboardController {
// mode-7 control message once the dashboard container is warmed up.
this.pushFirmwareDebugFlags();
this.pushBrightness(true);
this.pushHeadUpPreferences(true);
this.handRingBackToGlassesIfNeeded();
}
if (mappedPhase !== "connected" && mappedPhase !== "charging") {
@@ -2197,14 +2217,14 @@ class DashboardController {
private voiceCaptureOptions(communicator: FaceclawCommunicatorBridge | null) {
// A window that needs its own provider and language sets them for every
// capture while it is open, so push-to-talk still shares its stream.
// Otherwise only Whisper server is told a language (its own setting).
// Otherwise use the shared transcription-language preference.
const choice = this.transcriptionChoice();
const provider = choice?.provider ?? voiceProviderSetting.get();
return {
communicator: communicator?.getNativeCommunicator() ?? null,
usePhoneMic: communicator === null,
provider,
language: choice ? choice.language : provider === "whisper-server" ? whisperServerLanguageSetting.get() : "",
language: choice ? choice.language : getVoiceTranscriptionLanguage(provider),
elevenLabsApiKey: elevenLabsApiKeySetting.get(),
openAiApiKey: openAiApiKeySetting.get(),
sonioxApiKey: sonioxApiKeySetting.get(),
+10 -4
View File
@@ -51,7 +51,7 @@ import { mirrorToPanelFraction, phonePreviewCrop } from './phone-preview-crop'
import { onAnySettingChanged,
previewColorSetting, lockScreenEnabledSetting, getBrightnessPreferences, getStringSettingById,
nightscoutSiteUrlSetting, nightscoutApiTokenSetting, voiceProviderSetting, elevenLabsApiKeySetting,
openAiApiKeySetting, sonioxApiKeySetting, whisperServerApiKeySetting, whisperServerLanguageSetting,
openAiApiKeySetting, sonioxApiKeySetting, whisperServerApiKeySetting, getVoiceTranscriptionLanguage,
whisperServerModelSetting, whisperServerUrlSetting, ringConnectionModeSetting, saveTranscribeAudioSetting } from '../ui/dashboard-settings'
import { transcriptionKey, type VoiceProviderSelection } from '../native/cloud-stt-provider'
import type { PhoneGesture } from '../phone-ui/phone-gestures'
@@ -218,6 +218,12 @@ export class IosPreviewController {
shell.foregroundWindow()?.requestRender()
this.requestShellRender()
},
onWindowLayoutChanged: () => {
this.relayout()
shell.foregroundWindow()?.requestRender()
this.requestShellRender()
},
isLocked: () => this.glassesLocked,
onScreenStateChanged: on => {
if (on) this.glance.dismiss()
// A wake unblanks only once the next shell render has staged an awake
@@ -398,6 +404,7 @@ export class IosPreviewController {
const phone = readPhoneBatteryState()
this.logBluetooth(`Phone battery ${phone.battery ?? "unknown"}% charging=${phone.charging}`)
this.offSettings = onAnySettingChanged(() => {
this.syncContinuousCapture()
this.syncLockSetting()
this.pushBrightness()
this.relayout()
@@ -1152,13 +1159,12 @@ export class IosPreviewController {
/**
* The transcription provider setting and the keys the cloud ones need. A
* window that needs its own provider and language (Translate) sets them for
* every capture while it is open; otherwise only Whisper server is told a
* language (its own setting).
* every capture while it is open; otherwise use the shared language preference.
*/
private voiceProvider(): VoiceProviderSelection {
const choice = [...this.continuousClients.values()].find(options => options.transcription)?.transcription
const provider = choice?.provider ?? voiceProviderSetting.get()
return { provider, language: choice ? choice.language : provider === 'whisper-server' ? whisperServerLanguageSetting.get() : '',
return { provider, language: choice ? choice.language : getVoiceTranscriptionLanguage(provider),
elevenLabsApiKey: elevenLabsApiKeySetting.get(), openAiApiKey: openAiApiKeySetting.get(), sonioxApiKey: sonioxApiKeySetting.get(),
whisperServerUrl: whisperServerUrlSetting.get(), whisperServerModel: whisperServerModelSetting.get(),
whisperServerApiKey: whisperServerApiKeySetting.get() }
+32 -2
View File
@@ -9,7 +9,7 @@ declare const java: any;
* than bundled in the APK; FaceclawVoiceController reads the files from the
* directory each model's `dirName` names.
*
* Two models, same shape:
* Downloadable models, same shape:
* - "moonshine": the original on-device option (three files). The model is
* no longer bundled in the APK; it is fetched into the same filesDir
* location that earlier releases copied the bundled files to, so
@@ -29,12 +29,17 @@ declare const java: any;
* used for Moonshine below. Every hash here was computed locally from a
* freshly downloaded copy of the file, not copied from a doc page.
*
* - "whisper-base": multilingual base, int8-quantized. Used for non-English
* speech and auto-detection; English-only downloads remain untouched.
* SHA-256/size values come from the maintainer's LFS metadata, with the
* vocabulary hash computed locally. URLs pin the source revision.
*
* Mirrors the on-phone assistant model flow in llama.ts, except each model
* here is multiple files rather than one; they download sequentially through
* FaceclawModelDownloader (resume + pinned sha256 per file).
*/
export type AsrModelId = "moonshine" | "whisper-base-en";
export type AsrModelId = "moonshine" | "whisper-base-en" | "whisper-base";
type AsrModelFile = {
name: string;
@@ -105,6 +110,30 @@ export const ASR_MODELS: Record<AsrModelId, AsrModelDef> = {
],
totalBytes: 160626066,
},
"whisper-base": {
label: "Whisper (multilingual, base)",
dirName: "sherpa-onnx-whisper-base-int8",
baseUrl: "https://huggingface.co/csukuangfj/sherpa-onnx-whisper-base/resolve/bb53ee204431c90d314c1cc08d28d23e5b7927cc/",
files: [
{
name: "base-encoder.int8.onnx",
sha256: "0b8fb1304b6109976038efff5ace81720e00386f3ff6b54ee8c75291ca0a1e11",
sizeBytes: 29120534,
},
{
name: "base-decoder.int8.onnx",
sha256: "9759d217388a01b3a4c7c15533201067b48ae819c4daafc8624e64b9409dc02d",
sizeBytes: 130672026,
},
{
name: "base-tokens.txt",
sha256: "b34b360dbb493e781e479794586d661700670d65564001f23024971d1f2fa126",
sizeBytes: 816730,
},
],
totalBytes: 160609290,
},
};
export type AsrModelState = {
@@ -129,6 +158,7 @@ function freshRuntime(): ModelRuntime {
const runtimes: Record<AsrModelId, ModelRuntime> = {
moonshine: freshRuntime(),
"whisper-base-en": freshRuntime(),
"whisper-base": freshRuntime(),
};
function modelDirPath(id: AsrModelId): string {
+19
View File
@@ -0,0 +1,19 @@
import { getStringSetting, setStringSetting } from "./settings-store";
export const CALENDAR_SELECTION_KEY = "calendar.selectedIds";
/** null means all calendars (including future ones); [] explicitly means none. */
export function readCalendarSelection(): string[] | null {
try {
const value = JSON.parse(getStringSetting(CALENDAR_SELECTION_KEY, "null"));
if (value === null) return null;
if (!Array.isArray(value) || !value.every(id => typeof id === "string" && /^\d+$/.test(id))) return null;
return Array.from(new Set<string>(value));
} catch {
return null;
}
}
export function setCalendarSelection(ids: readonly string[] | null): void {
if (ids !== null && !ids.every(id => /^\d+$/.test(id))) throw new Error("Invalid calendar ID");
setStringSetting(CALENDAR_SELECTION_KEY, JSON.stringify(ids === null ? null : Array.from(new Set(ids))));
}
+22
View File
@@ -0,0 +1,22 @@
import { Utils } from "@nativescript/core";
import { hasCalendarPermission } from "./calendar-permissions";
declare const com: any;
export type CalendarSource = { id: string; name: string; accountName: string; accountType: string };
/** Android calendar IDs survive renames and distinguish equal display names. */
export function readAvailableCalendars(): CalendarSource[] {
if (!global.isAndroid || !hasCalendarPermission()) return [];
try {
const context = Utils.android.getApplicationContext();
if (!context) return [];
const parsed = JSON.parse(String(com.faceclaw.app.FaceclawCalendarProvider.getCalendarsJson(context)));
if (!Array.isArray(parsed)) return [];
return parsed.filter(row => row && typeof row.id === "string" && /^\d+$/.test(row.id))
.map(row => ({ id: row.id, name: String(row.name ?? ""),
accountName: String(row.accountName ?? ""), accountType: String(row.accountType ?? "") }));
} catch {
return [];
}
}
+15 -3
View File
@@ -2,6 +2,8 @@ import { Utils } from "@nativescript/core";
import { hasCalendarPermission } from "../g2/android-permissions";
import { spanCurrent } from "./frame-timings";
import { type CalendarEvent, type CalendarReadState } from "./calendar-types";
import { CALENDAR_SELECTION_KEY, readCalendarSelection } from "./calendar-selection";
import { onSettingsStoreChanged } from "./settings-store";
export type { CalendarEvent } from "./calendar-types";
declare const com: any;
@@ -13,14 +15,21 @@ declare const com: any;
*/
// Android reads synchronously; iOS notifies subscribers after background reads.
export function onCalendarChanged(_listener: () => void): () => void { return () => {}; }
export function onCalendarChanged(listener: () => void): () => void {
return onSettingsStoreChanged(key => {
if (key === CALENDAR_SELECTION_KEY || key == null) {
invalidateCalendarCache();
listener();
}
});
}
export function getCalendarReadState(): CalendarReadState { return "ready"; }
const DEFAULT_MAX_EVENTS = 50;
const DEFAULT_WINDOW_MS = 14 * 24 * 60 * 60 * 1000;
const CACHE_MS = 30_000;
let cache: { events: CalendarEvent[]; atMs: number; maxEvents: number; windowMs: number } | null = null;
let cache: { events: CalendarEvent[]; atMs: number; maxEvents: number; windowMs: number; selection: string } | null = null;
/**
* Upcoming events from now through the given window, ordered by start time.
@@ -35,9 +44,11 @@ export function readUpcomingEvents(
if (!global.isAndroid || !hasCalendarPermission()) return [];
const now = Date.now();
const selection = JSON.stringify(readCalendarSelection());
if (
!forceRefresh &&
cache &&
cache.selection === selection &&
cache.maxEvents === maxEvents &&
cache.windowMs === windowMs &&
now - cache.atMs < CACHE_MS
@@ -55,6 +66,7 @@ export function readUpcomingEvents(
context,
Math.max(0, Math.round(maxEvents)),
Math.max(0, Math.round(windowMs)),
selection,
),
),
);
@@ -62,7 +74,7 @@ export function readUpcomingEvents(
const events = Array.isArray(parsed)
? parsed.map(normalizeEvent).filter((event): event is CalendarEvent => Boolean(event))
: [];
cache = { events, atMs: now, maxEvents, windowMs };
cache = { events, atMs: now, maxEvents, windowMs, selection };
return events;
} catch {
return [];
+3 -2
View File
@@ -14,7 +14,7 @@ export type VoiceProviderSelection = {
provider: VoiceProviderKind;
/**
* Spoken language the provider should expect (ISO 639-1); empty lets it
* detect the language. Cloud providers only.
* detect the language. Also used by on-device Whisper.
*/
language?: string;
elevenLabsApiKey: string;
@@ -77,7 +77,8 @@ function isConfigured(provider: CloudProvider, selection: VoiceProviderSelection
* to expect. A running capture is shared only by holders asking for the same.
*/
export function transcriptionKey(selection: Pick<VoiceProviderSelection, "provider" | "language">): string {
return `${selection.provider}:${(selection.language ?? "").trim().toLowerCase()}`;
const fallback = selection.provider === "onboard-whisper" ? "en" : "";
return `${selection.provider}:${(selection.language ?? fallback).trim().toLowerCase()}`;
}
/** Whether createCloudSttClient would return a cloud client for this selection. */
+5
View File
@@ -519,6 +519,11 @@ export class FaceclawCommunicatorBridge {
await this.enqueueJavaCall(() => this.communicator.enableWearDetectionAndRequestState());
}
/** -1 leaves a field unchanged. The native session retains explicit values across reconnects. */
async configureHeadUpWake(enabled: number, angle: number): Promise<void> {
await this.enqueueJavaCall(() => this.communicator.configureHeadUpWake(enabled, angle));
}
/** Whether the transport prelude has finished (each arm reports "connected" before it). */
isSessionReady(): boolean {
return Boolean(this.communicator.isSessionReady());
+10
View File
@@ -26,6 +26,16 @@ export function iosNotificationState(): AncsState { return active?.state ?? 'dis
export function readActiveNotifications(maxNotifications = 50) { return active?.read(maxNotifications) ?? [] }
export function invokeNotificationAction(key: string, index: number): boolean { return active?.action(key,index) ?? false }
export function dismissNotification(key: string): boolean { return active?.dismiss(key) ?? false }
export function dismissAllNotifications(): boolean {
const client = active
if (!client) return false
// Snapshot: removals may arrive while dismissal requests are being sent.
let accepted = true
for (const notification of [...client.read(ALL_NOTIFICATIONS)]) {
if (!client.dismiss(notification.key)) accepted = false
}
return accepted
}
export function onAndroidNotificationPosted(listener: (key: string) => void): () => void {
listeners.add(listener); return () => { listeners.delete(listener) }
}
+7
View File
@@ -337,6 +337,13 @@ export function dismissNotification(notificationKey: string): boolean {
);
}
/** Explicit user action: dismiss on the phone as well as on the glasses. */
export function dismissAllNotifications(): boolean {
if (!global.isAndroid) return false;
invalidateIconCaches();
return Boolean(com.faceclaw.app.FaceclawMediaNotificationListenerService.dismissAllNotifications());
}
export function onAndroidNotificationPosted(listener: (notificationKey: string) => void): () => void {
return addNotificationListener(notificationPostedListeners, listener);
}
+30 -5
View File
@@ -1,6 +1,16 @@
import { getStringSetting, setStringSetting } from "./settings-store";
const SOURCES_KEY = "notifications.sources";
const DEFAULT_KEY = "notifications.newAppsEnabledByDefault";
/** Unset preserves the behavior of existing installations. */
export function newNotificationAppsEnabledByDefault(): boolean {
return getStringSetting(DEFAULT_KEY, "true") !== "false";
}
export function setNewNotificationAppsEnabledByDefault(enabled: boolean): void {
setStringSetting(DEFAULT_KEY, String(enabled));
}
export type NotificationSource = {
packageName: string;
@@ -8,8 +18,15 @@ export type NotificationSource = {
showOnGlasses: boolean;
};
type SavedSource = Omit<NotificationSource, "showOnGlasses"> & { showOnGlasses?: boolean };
/** Sources outlive their active notifications so a muted app can always be re-enabled. */
export function readNotificationSources(): NotificationSource[] {
const enabled = newNotificationAppsEnabledByDefault();
return readSavedSources().map((source) => ({ ...source, showOnGlasses: source.showOnGlasses ?? enabled }));
}
function readSavedSources(): SavedSource[] {
try {
const parsed = JSON.parse(getStringSetting(SOURCES_KEY, "[]"));
if (!Array.isArray(parsed)) return [];
@@ -17,7 +34,7 @@ export function readNotificationSources(): NotificationSource[] {
.map((source) => ({
packageName: source.packageName,
appName: typeof source.appName === "string" && source.appName ? source.appName : source.packageName,
showOnGlasses: source.showOnGlasses !== false,
showOnGlasses: typeof source.showOnGlasses === "boolean" ? source.showOnGlasses : undefined,
}));
} catch {
return [];
@@ -25,7 +42,7 @@ export function readNotificationSources(): NotificationSource[] {
}
export function rememberNotificationSources(notifications: { packageName: string; appName: string }[]): void {
const sources = new Map(readNotificationSources().map((source) => [source.packageName, source]));
const sources = new Map(readSavedSources().map((source) => [source.packageName, source]));
let changed = false;
for (const notification of notifications) {
if (!notification.packageName) continue;
@@ -35,7 +52,7 @@ export function rememberNotificationSources(notifications: { packageName: string
sources.set(notification.packageName, {
packageName: notification.packageName,
appName,
showOnGlasses: previous?.showOnGlasses ?? true,
showOnGlasses: previous?.showOnGlasses,
});
changed = true;
}
@@ -44,12 +61,13 @@ export function rememberNotificationSources(notifications: { packageName: string
}
export function shouldShowNotificationOnGlasses(packageName: string): boolean {
return readNotificationSources().find((source) => source.packageName === packageName)?.showOnGlasses ?? true;
return readNotificationSources().find((source) => source.packageName === packageName)?.showOnGlasses
?? newNotificationAppsEnabledByDefault();
}
export function setNotificationSourceEnabled(source: { packageName: string; appName: string }, enabled: boolean): void {
if (!source.packageName) return;
const sources = new Map(readNotificationSources().map((item) => [item.packageName, item]));
const sources = new Map(readSavedSources().map((item) => [item.packageName, item]));
sources.set(source.packageName, {
packageName: source.packageName,
appName: source.appName || source.packageName,
@@ -57,3 +75,10 @@ export function setNotificationSourceEnabled(source: { packageName: string; appN
});
setStringSetting(SOURCES_KEY, JSON.stringify(Array.from(sources.values())));
}
/** Set explicit choices only for sources already discovered; leave the future default alone. */
export function setAllNotificationSourcesEnabled(enabled: boolean): void {
setStringSetting(SOURCES_KEY, JSON.stringify(readSavedSources().map((source) => ({
...source, showOnGlasses: enabled,
}))));
}
+24
View File
@@ -0,0 +1,24 @@
/** Languages supported by both Whisper backends, in picker order. */
export const TRANSCRIPTION_LANGUAGES = {
en: "English", fr: "French", de: "German", es: "Spanish", it: "Italian",
pt: "Portuguese", nl: "Dutch", ar: "Arabic", zh: "Chinese", cs: "Czech",
da: "Danish", fi: "Finnish", el: "Greek", he: "Hebrew", hi: "Hindi",
hu: "Hungarian", id: "Indonesian", ja: "Japanese", ko: "Korean",
no: "Norwegian", pl: "Polish", ro: "Romanian", ru: "Russian", sk: "Slovak",
sv: "Swedish", th: "Thai", tr: "Turkish", uk: "Ukrainian", vi: "Vietnamese",
} as const;
export type TranscriptionLanguage = "default" | "auto" | keyof typeof TRANSCRIPTION_LANGUAGES;
/** An empty language asks Whisper to detect it; default preserves each engine's old behavior. */
export function resolveTranscriptionLanguage(
choice: TranscriptionLanguage, provider: string, serverLanguage = "",
): string {
// Moonshine is English-only; Apple's on-device recognizer retains its own locale.
if (provider === "onboard") return "";
if (choice === "default") {
if (provider === "onboard-whisper") return "en";
return provider === "whisper-server" ? serverLanguage.trim().toLowerCase() : "";
}
return choice === "auto" ? "" : choice;
}
+2 -1
View File
@@ -58,7 +58,7 @@ export type PushToTalkOptions = {
whisperServerUrl?: string;
whisperServerModel?: string;
whisperServerApiKey?: string;
/** Spoken language for cloud providers (see VoiceProviderSelection.language). */
/** Spoken language for cloud providers and on-device Whisper; empty detects, absent keeps local English. */
language?: string;
saveRecording: boolean;
/**
@@ -396,6 +396,7 @@ export class FaceclawVoiceControlBridge {
// Which on-device model to load; a no-op setter for every provider except
// "onboard-whisper" (FaceclawVoiceController defaults to Moonshine).
this.controller?.setOnboardModelKind(options.provider === "onboard-whisper" ? "whisper" : "moonshine");
this.controller?.setOnboardLanguage(options.language ?? "en");
const captureId = this.nextNativeCaptureId++;
this.nativeCaptureFinished = new Promise((resolve) => { this.nativeCaptureResolvers.set(captureId, resolve); });
this.controller?.start("onboard", captureId);
+85 -2
View File
@@ -18,6 +18,7 @@ import {
} from "~/assistant/models";
import { isLocalModelReady } from "../native/local-llm";
import { normalizeWhisperServerUrl } from "../native/whisper-server-stt";
import { TRANSCRIPTION_LANGUAGES, resolveTranscriptionLanguage, type TranscriptionLanguage } from "../native/transcription-language";
import { normalizeOpenAiCompatibleUrl } from "../native/openai-chat";
import { isValidSpotifyClientId, SPOTIFY_CLIENT_ID_KEY } from "../native/spotify-auth";
import { drawRightValueMenuItem, drawToggleMenuItem, MenuItem, openModalMenu } from "./menu";
@@ -148,6 +149,39 @@ export class ConfigSettingBoolean<TId extends string = string> extends ConfigSet
}
}
const appFullscreenSettings = new Map<string, ConfigSettingBoolean>();
/** A user choice independent of an app's own temporary immersive mode. */
export function appFullscreenSetting(appId: string): ConfigSettingBoolean {
let setting = appFullscreenSettings.get(appId);
if (!setting) {
setting = new ConfigSettingBoolean({
id: `app-fullscreen-${appId}`, label: "Full screen",
storageKey: `display.fullscreen.${appId}`, defaultValue: false,
reportInAnalytics: false,
});
appFullscreenSettings.set(appId, setting);
}
return setting;
}
const appKeepAwakeSettings = new Map<string, ConfigSettingBoolean>();
/** Independent of full screen; applies only while this app is visible. */
export function appKeepAwakeSetting(appId: string): ConfigSettingBoolean {
let setting = appKeepAwakeSettings.get(appId);
if (!setting) {
setting = new ConfigSettingBoolean({
id: `app-keep-awake-${appId}`, label: "Keep screen awake",
description: "Prevent automatic sleep while this app is visible, in any display mode.",
storageKey: `display.keepAwake.${appId}`, defaultValue: false,
reportInAnalytics: false,
});
appKeepAwakeSettings.set(appId, setting);
}
return setting;
}
type ConfigSettingEnumOptions<TValue extends string, TId extends string> = ConfigSettingOptions<TValue, TId> & {
values: readonly TValue[];
normalize?: (value: string | null | undefined) => TValue;
@@ -555,6 +589,38 @@ export const brightnessSetting = new ConfigSettingEnum<BrightnessSetting>({
description: "Auto uses Faceclaw's ambient-light curve; numbers set a fixed level. 2 is the dimmest level.",
});
/** String storage distinguishes an untouched firmware preference from explicit ON/OFF. */
class HeadUpWakeSetting extends ConfigSettingBoolean {
get(): boolean { return getStringSetting(this.storageKey, "true") !== "false"; }
set(value: boolean): boolean { setStringSetting(this.storageKey, String(value)); return value; }
}
export const headUpWakeSetting = new HeadUpWakeSetting({
id: "head-up-wake", label: "Head-up wake", storageKey: "display.headUpWake", defaultValue: true,
description: "Enable waking the glasses when you look up. Until changed, the glasses keep their current setting. Glanceboard's Show on head tilt chooses what appears after waking.",
});
export function normalizeHeadUpAngle(value: string | null | undefined): string {
if (value == null || value.trim() === "" || !Number.isFinite(Number(value))) return "30";
return String(Math.max(0, Math.min(60, Math.round(Number(value)))));
}
export const headUpAngleSetting = new ConfigSettingEnum({
id: "head-up-angle", label: "Head-up angle", storageKey: "display.headUpAngle", defaultValue: "30",
values: Array.from({ length: 61 }, (_, angle) => String(angle)),
normalize: normalizeHeadUpAngle,
formatValue: angle => `${angle}°`,
description: "Look-up trigger angle, 0–60 degrees. Until changed, the glasses keep their current angle. Requires validation on your Faceclaw firmware.",
});
/** -1 means leave that firmware field unchanged; no writes on an untouched installation. */
export function getHeadUpPreferences(): { enabled: number; angle: number } {
const enabled = getStringSetting("display.headUpWake", "");
const angle = getStringSetting("display.headUpAngle", "");
return { enabled: enabled === "true" ? 1 : enabled === "false" ? 0 : -1,
angle: angle === "" ? -1 : Number(normalizeHeadUpAngle(angle)) };
}
const AUTO_BRIGHTNESS_LEVELS = ["2", "5", "10", "20", "25", "30", "40", "50", "60", "70", "80", "90", "100"] as const;
export const autoBrightnessMinSetting = new ConfigSettingEnum({
id: "autoBrightnessMin", label: "Auto minimum", storageKey: "display.autoBrightnessMin",
@@ -1115,9 +1181,26 @@ export const whisperServerModelSetting = new ConfigSettingString({
description: "Model id sent to the Whisper server. Leave empty to use the first model the server lists.",
});
export const voiceLanguageSetting = new ConfigSettingEnum<TranscriptionLanguage>({
id: "voice-language",
label: "Transcription language",
storageKey: "voice.language",
defaultValue: "default",
values: ["default", "auto", ...(Object.keys(TRANSCRIPTION_LANGUAGES) as (keyof typeof TRANSCRIPTION_LANGUAGES)[])],
formatValue: (value) => value === "default" ? "Provider default"
: value === "auto" ? "Auto-detect" : TRANSCRIPTION_LANGUAGES[value],
description: "Spoken language for OpenAI, on-device Whisper and other cloud transcription providers. " +
"Provider default preserves English for on-device Whisper and auto-detection for cloud providers, with the server's own language below. " +
"On-device Whisper needs the multilingual model for auto-detection or languages other than English. Moonshine remains English-only.",
});
export function getVoiceTranscriptionLanguage(provider: VoiceProvider): string {
return resolveTranscriptionLanguage(voiceLanguageSetting.get(), provider, whisperServerLanguageSetting.get());
}
export const whisperServerLanguageSetting = new ConfigSettingString({
id: "whisper-server-language",
label: "Whisper language",
label: "Whisper server language",
storageKey: "voice.whisperServerLanguage",
defaultValue: "",
editorTitle: "Language code, e.g. en or sk (empty: auto)",
@@ -1125,7 +1208,7 @@ export const whisperServerLanguageSetting = new ConfigSettingString({
formatValue: (value) => value || "Auto-detect",
validate: (value) => (!value.trim() || /^[a-z]{2,3}$/i.test(value.trim()) ? null : "Use a language code like en, sk or cs."),
description:
"Spoken language for the Whisper server. Leave empty to auto-detect; a wrong fixed language makes Whisper translate into it instead of transcribing.",
"Spoken language for the Whisper server when Transcription language is Provider default. Leave empty to auto-detect.",
});
export const whisperServerApiKeySetting = new ConfigSettingString({
+7 -1
View File
@@ -49,6 +49,8 @@ import {
veniceWebSearchSetting,
batteryDisplayModeSetting,
brightnessSetting,
headUpWakeSetting,
headUpAngleSetting,
autoBrightnessMinSetting,
autoBrightnessMaxSetting,
autoBrightnessCurveSetting,
@@ -87,6 +89,7 @@ import {
toggleSettingMenuItem,
useMicControlSetting,
voiceProviderSetting,
voiceLanguageSetting,
screenTimeoutSetting,
wakeToLastAppSetting,
wakeWordActionSetting,
@@ -116,6 +119,7 @@ function settingsSections(): SettingsSection[] {
// the dashboard controller when changed and on each connect.
enumSettingMenuItem(brightnessSetting),
autoBrightnessMenuItem(),
...(!global.isIOS ? [toggleSettingMenuItem(headUpWakeSetting), enumSettingMenuItem(headUpAngleSetting)] : []),
enumSettingMenuItem(screenTimeoutSetting, {
onChange: () => {
shell.noteUserActivity();
@@ -141,9 +145,11 @@ function settingsSections(): SettingsSection[] {
items: [
enumSettingMenuItem(wakeWordActionSetting),
enumSettingMenuItem(voiceProviderSetting),
enumSettingMenuItem(voiceLanguageSetting),
...whisperServerMenuItems(),
asrModelMenuItem("moonshine"),
asrModelMenuItem("whisper-base-en"),
asrModelMenuItem("whisper-base"),
],
},
{
@@ -278,7 +284,7 @@ function settingsSections(): SettingsSection[] {
toggleSettingMenuItem(showBleBandwidthSetting)] };
// No downloadable on-device models: iOS's on-device option is Apple's recognizer.
if (section.label === "Voice") return { label: "Voice", items: [enumSettingMenuItem(wakeWordActionSetting),
enumSettingMenuItem(voiceProviderSetting), toggleSettingMenuItem(saveTranscribeAudioSetting), ...whisperServerMenuItems()] };
enumSettingMenuItem(voiceProviderSetting), enumSettingMenuItem(voiceLanguageSetting), toggleSettingMenuItem(saveTranscribeAudioSetting), ...whisperServerMenuItems()] };
if (deferred.has(section.label)) return { label: section.label, items: [{
label: "Not available on iOS yet", disabled: true, onSelect: () => {},
description: `${section.label} integration has not been ported to iOS.`,
+19 -7
View File
@@ -2,7 +2,7 @@ import { getDefaultSmallFont } from "../graphics/ui-fonts";
import { GrayImage } from "../graphics/image";
import { truncateText } from "../graphics/textwrap";
import { ALL_NOTIFICATIONS, readActiveNotifications } from "../native/notification-icons";
import { readNotificationSources, setNotificationSourceEnabled, shouldShowNotificationOnGlasses } from "../native/notification-sources";
import { newNotificationAppsEnabledByDefault, setNewNotificationAppsEnabledByDefault, setAllNotificationSourcesEnabled, readNotificationSources, setNotificationSourceEnabled, shouldShowNotificationOnGlasses } from "../native/notification-sources";
import { type InputEvent } from "./gestures";
import { type Layer, type LayerContext, type PaintBelow } from "./layers";
import { drawToggleMenuItem, MenuLayer, type MenuItem } from "./menu";
@@ -11,14 +11,26 @@ import { drawToggleMenuItem, MenuLayer, type MenuItem } from "./menu";
export class NotificationFilterLayer implements Layer {
private menu: MenuLayer | null = null;
private menuWidth = 0;
/** The package behind each current row, parallel to the menu's items. */
/** Stable row keys, including controls, parallel to the menu's items. */
private packages: string[] = [];
private currentMenu(ctx: LayerContext): MenuLayer {
readActiveNotifications(ALL_NOTIFICATIONS);
const sources = readNotificationSources().sort((a, b) =>
a.appName.localeCompare(b.appName) || a.packageName.localeCompare(b.packageName));
const items: MenuItem[] = sources.map((source) => ({
const items: MenuItem[] = [{
label: "New apps enabled by default",
onSelect: () => setNewNotificationAppsEnabledByDefault(!newNotificationAppsEnabledByDefault()),
render: ({ image, x, y, width, selected }) => {
const font = getDefaultSmallFont();
drawToggleMenuItem(image, font, x, y, width,
truncateText(font, "New apps enabled by default", width - 48), newNotificationAppsEnabledByDefault(), selected);
},
}, {
label: "Enable all", onSelect: () => setAllNotificationSourcesEnabled(true),
}, {
label: "Disable all", onSelect: () => setAllNotificationSourcesEnabled(false),
}, ...sources.map<MenuItem>((source) => ({
label: source.appName,
onSelect: () => setNotificationSourceEnabled(source, !shouldShowNotificationOnGlasses(source.packageName)),
render: ({ image, x, y, width, selected }) => {
@@ -26,11 +38,11 @@ export class NotificationFilterLayer implements Layer {
drawToggleMenuItem(image, font, x, y, width, truncateText(font, source.appName, width - 48),
shouldShowNotificationOnGlasses(source.packageName), selected);
},
}));
if (!items.length) items.push({ label: "No notification sources discovered yet.", disabled: true, onSelect: () => {} });
}))];
if (!sources.length) items.push({ label: "No notification sources discovered yet.", disabled: true, onSelect: () => {} });
const selectedPackage = this.menu?.selectedIndex != null ? this.packages[this.menu.selectedIndex] : undefined;
const index = sources.findIndex((source) => source.packageName === selectedPackage);
this.packages = sources.map((source) => source.packageName);
this.packages = ["default", "enable-all", "disable-all", ...sources.map((source) => `source:${source.packageName}`)];
const index = selectedPackage === undefined ? 0 : this.packages.indexOf(selectedPackage);
const width = ctx.stack.getBaseSize().width;
if (!this.menu || width !== this.menuWidth) {
+2 -1
View File
@@ -1,6 +1,7 @@
import { G2_LENS_HEIGHT, G2_LENS_WIDTH } from "../../graphics/image";
import {
appSwitcherPositionSetting,
appFullscreenSetting,
type AppSwitcherPosition,
displayLayoutSetting,
type DisplayLayout,
@@ -118,7 +119,7 @@ export function setAppImmersive(appId: string, immersive: boolean): boolean {
}
export function isImmersive(appId?: string): boolean {
return appId !== undefined && immersiveApps.has(appId);
return appId !== undefined && (immersiveApps.has(appId) || appFullscreenSetting(appId).get());
}
/** Whether an app's windows span the panel's whole width: Full Screen, or immersive. */
+65 -11
View File
@@ -31,6 +31,9 @@ import type { AssistantContext } from "../../assistant/types";
import { SingleNotificationLayer } from "../notifications";
import {
anthropicApiKeySetting,
appFullscreenSetting,
appKeepAwakeSetting,
toggleSettingMenuItem,
assistantHermesKeySetting,
assistantHermesUrlSetting,
assistantBackendSetting,
@@ -94,7 +97,8 @@ import type { AppSwitcherPosition } from "../dashboard-settings";
* Input flow: every event enters via receiveInput. The shell consumes
* everything while the sidebar or a shell overlay has focus and forwards the
* rest to the focused window. Long-press opens the shell-owned system menu
* (Focus app switcher, Voice input, Brightness, Close window, Debug) without reaching the
* (Focus app switcher, Voice input, Brightness, Close current app, Close all apps,
* Debug) without reaching the
* app, so the shell keeps working when a window's handler hangs; a window
* that claims long-press for a move of its own gets it forwarded instead, and
* holding the press past the escape threshold still opens the system menu.
@@ -109,7 +113,7 @@ export type ShellWindow = {
title: string;
/** Compositor surface this window renders to; configured at connect / launch. */
surfaceId: string;
/** Whether the system menu offers Close window (the launcher is pinned). */
/** Whether the system menu can close this window (the launcher is pinned). */
closeable: boolean;
/**
* True when tap-then-hold currently opens the window's own context menu
@@ -222,6 +226,10 @@ export type ShellConfig = {
* after the shell paint that found it.
*/
onSwitcherBarHeightChanged?: () => void;
/** A per-app full-screen choice changed the viewport and compositor geometry. */
onWindowLayoutChanged?: () => void;
/** An app's keep-awake preference must not keep the lock screen awake. */
isLocked?: () => boolean;
/**
* The Notifications app's window, opened in the background (neither
* foregrounded nor focused) unless it is open already, for the switcher
@@ -655,6 +663,12 @@ class Shell {
if (window) this.closeWindow(window.windowId);
}
/** Snapshot ids: close callbacks may remove themselves or other windows. */
closeAllWindows(): void {
const ids = this.windows.filter(window => window.closeable).map(window => window.windowId);
for (const id of ids) this.closeWindow(id);
}
getWindows(): readonly ShellWindow[] {
return this.windows;
}
@@ -866,7 +880,9 @@ class Shell {
// A foreground window that is playing video holds it off the same way.
const foreground = this.foregroundWindow();
if (this.activeVoiceLayer || this.activeKeyboardLayer || this.assistantSession?.isTurnActive() ||
foreground?.isVoiceCapturing?.() || foreground?.keepsScreenOn?.()) {
foreground?.isVoiceCapturing?.() || foreground?.keepsScreenOn?.() ||
(foreground?.closeable && !this.config.isLocked?.() &&
appKeepAwakeSetting(foreground.appId).get())) {
this.lastInputAtMs = nowMs;
return false;
}
@@ -1073,6 +1089,12 @@ class Shell {
if (this.activeVoiceLayer || !this.stack.isAtBase()) {
return { shell: true, window: false };
}
// The switcher owns its menu even when the selected app uses a hold
// for a game move or voice capture.
if (this.focus === "sidebar") {
this.openEscapeMenu();
return { shell: true, window: false };
}
const window = this.foregroundWindow();
if (!window) {
return { shell: true, window: false };
@@ -1082,10 +1104,6 @@ class Shell {
return { shell: true, window: false };
}
if (!window.holdToTalk) this.startEscapeMenuTimer();
if (this.focus === "sidebar") {
this.focus = "window";
window.onFocus?.(this.lastInput);
}
// The window owns frameId from here (render or explicit finish).
await window.handleInput(event, frameId);
return { shell: true, window: true };
@@ -1096,6 +1114,10 @@ class Shell {
// first), which answers with its own menu or asks for the system menu
// when it has none.
if (event.type === "short-then-long-press") {
if (this.focus === "sidebar" && !this.activeVoiceLayer && this.stack.isAtBase()) {
this.openEscapeMenu();
return { shell: true, window: false };
}
const window = this.foregroundWindow();
if (window?.holdToTalk) {
this.openEscapeMenu();
@@ -1913,7 +1935,7 @@ class Shell {
/**
* The system/escape menu: the entries every window shares (Focus app
* switcher, Voice input, Brightness, Close window) plus Debug. Shell-owned and
* switcher, Voice input, Brightness, Close current app, Close all apps) plus Debug. Shell-owned and
* shell-drawn (never the app's), so an unresponsive app can always be
* closed. It opens for long-press (over the app's own menu too), after an
* extended hold in a window that claims long-press, and on a window's
@@ -1926,16 +1948,16 @@ class Shell {
const items: MenuItem[] = [];
if (foreground.closeable) {
items.push({
label: "Close window",
label: "Close current app",
onSelect: (ctx) => {
// Pop the menu first (its onRemoved returns focus to the sidebar),
// then close the window the menu was opened over.
ctx.stack.pop();
this.closeForegroundWindow();
this.closeWindow(foreground.windowId);
},
});
}
// Close window sits first but the menu opens on Focus app switcher, so a
// Close current app sits first but the menu opens on Focus app switcher, so a
// reflexive tap never closes the window.
const initialSelection = items.length;
items.push(
@@ -1959,6 +1981,38 @@ class Shell {
},
}]),
);
items.push({
label: "Close all apps",
disabled: () => !this.windows.some(window => window.closeable),
onSelect: (ctx) => {
ctx.stack.pop();
this.closeAllWindows();
},
});
if (foreground.closeable) {
const fullscreen = appFullscreenSetting(foreground.appId);
items.push({
label: fullscreen.get() ? "Exit full screen" : "Enter full screen",
description: "Use the whole display for this app.",
onSelect: (ctx) => {
ctx.stack.pop();
if (!this.windows.some(window => window.windowId === foreground.windowId)) return;
fullscreen.set(!fullscreen.get());
this.noteUserActivity();
this.config.onWindowLayoutChanged?.();
this.focusWindow(foreground.windowId);
this.config.requestShellRender();
},
});
items.push(toggleSettingMenuItem(appKeepAwakeSetting(foreground.appId), {
onChange: (ctx) => {
ctx.stack.pop();
this.noteUserActivity();
this.focusWindow(foreground.windowId);
this.config.requestShellRender();
},
}));
}
if (brightnessSetting.get() !== "auto") {
items.push({
label: "Brightness",
+1 -1
View File
@@ -9,7 +9,7 @@ import type { WorkerAppReply } from "./shell/worker-window";
* The window context menu, opened by tap-then-hold: an app's own menu,
* holding its app-specific actions. The shell's system menu (long-press)
* carries the entries every window shares — Focus app switcher, Voice input,
* Close window — so an app with nothing of its own to offer has no menu of
* Close current app, Close all apps — so an app with nothing of its own to offer has no menu of
* its own: tap-then-hold then opens the system menu in its place, so both
* gestures land on the same menu. The system menu is also the safety net:
* shell-owned, so an unresponsive app can always be closed (a window that
+65
View File
@@ -0,0 +1,65 @@
{
"nodes": {
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1793731702,
"narHash": "sha256-WlVNaWXVTYaGBNey2Z+20sY1lT7BvzJEECb+VlDDdk0=",
"owner": "cachix",
"repo": "devenv",
"rev": "9655d320b8f9df74dbecf681f52a7334574606c3",
"type": "github"
},
"original": {
"dir": "src/modules",
"owner": "cachix",
"repo": "devenv",
"type": "github"
}
},
"nixpkgs": {
"inputs": {
"nixpkgs-src": "nixpkgs-src"
},
"locked": {
"lastModified": 1793043970,
"narHash": "sha256-m14odYTdkBUEkJOiEYs2zjGjn8fcjvdCJsm45+k084U=",
"owner": "cachix",
"repo": "devenv-nixpkgs",
"rev": "d97234e58d4e90e3bf77c082fc3b546e51200938",
"type": "github"
},
"original": {
"owner": "cachix",
"ref": "rolling",
"repo": "devenv-nixpkgs",
"type": "github"
}
},
"nixpkgs-src": {
"flake": false,
"locked": {
"lastModified": 1792812153,
"narHash": "sha256-T2+XBfNbf9pecLUWS4+RtuVNZ3W8K5taG5QdV71mWlk=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "674a2028661e550a97400c1cc992b9cca9a668a1",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"devenv": "devenv",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}
+42
View File
@@ -0,0 +1,42 @@
{ pkgs, config, lib, ... }:
{
languages.javascript = {
enable = true;
package = pkgs.nodejs_22;
};
languages.java = {
enable = true;
jdk.package = pkgs.jdk21;
lsp.enable = false;
};
android = {
enable = true;
platforms.version = [ "35" ];
buildTools.version = [ "34.0.0" "35.0.0" "35.0.1" ];
ndk.enable = true;
ndk.version = [ "27.2.12479018" ];
cmake.version = [ ];
emulator.enable = false;
systemImages.enable = false;
sources.enable = false;
};
packages = with pkgs; [ git gh curl jq ripgrep python3 pkg-config gnumake gcc unzip zip ];
# Gradle's downloaded aapt2 cannot run directly on NixOS.
# Keep API 35 aapt2 for phone builds even with Wear's older tools installed.
env.GRADLE_OPTS = lib.mkForce "-Dorg.gradle.project.android.aapt2FromMavenOverride=${config.env.ANDROID_HOME}/build-tools/35.0.0/aapt2";
# NativeScript's doctor rejects a valid build-only SDK without an emulator.
# enterTest below checks the actual tools used by our local builds.
env.NS_SKIP_ENV_CHECK = "1";
env.ANDROID_CMAKE_HOME = "${pkgs.symlinkJoin {
name = "faceclaw-cmake";
paths = [ pkgs.cmake pkgs.ninja ];
}}";
scripts.faceclaw-setup.exec = "npm ci";
scripts.faceclaw-test.exec = "npm test";
enterShell = ''
export PATH="$DEVENV_ROOT/node_modules/.bin:$PATH"
'';
enterTest = ''
bash "$DEVENV_ROOT/scripts/check-devenv.sh"
'';
}
+7
View File
@@ -0,0 +1,7 @@
inputs:
nixpkgs:
url: github:cachix/devenv-nixpkgs/rolling
nixpkgs:
allow_unfree: true
android_sdk:
accept_license: true
+29
View File
@@ -0,0 +1,29 @@
# Nix development environment
Install Nix with flakes and devenv, then run `devenv shell` in this directory
(or `nix run nixpkgs#devenv -- shell`). With direnv, `direnv allow` loads `.envrc`.
The committed `devenv.lock` pins the environment inputs.
The environment provides Node 22/npm, Java 21, Android SDK/platform 35,
build-tools 34.0.0 (Wear OS) and 35.0.0/35.0.1 (phone and NativeScript plugins), NDK 27, CMake,
Git/GitHub CLI, Python and build utilities. `ANDROID_CMAKE_HOME` selects the
Nix-patched CMake/Ninja pair for the native Android libraries (the SDK's bundled
Ninja can crash on NixOS). Other environments keep using the SDK's CMake.
Android SDK licenses are accepted through `devenv.yaml`. Gradle uses the
Nix-patched SDK aapt2. Gradle itself comes from the repository's wrapper.
The emulator and system images are omitted. `NS_SKIP_ENV_CHECK=1` bypasses
NativeScript doctor's mandatory emulator check; `devenv test` checks the actual
SDK/JDK build prerequisites instead.
Run `faceclaw-setup` (`npm ci`) once, then `faceclaw-test` (`npm test`),
`npm run lint` and `npm run test:kotlin`. `devenv test` checks the environment.
`bash build.sh` builds the Android app; it does not install it. On NixOS, any
additional downloaded native executables may require the host's nix-ld support.
iOS builds still require macOS/Xcode and are outside this Linux environment.
Keep machine-specific signing/device settings in the ignored `build_paths.sh`.
Use `gh auth login` separately if GitHub CLI is not already authenticated.
Software tests do not validate Bluetooth behavior on physical glasses. Record
device/firmware versions and manual results separately for hardware checks.
Do not flash firmware during development without explicit permission.
+45
View File
@@ -0,0 +1,45 @@
# Combined release build
Branch: `integration/device-preferences`. It contains notification defaults and
bulk actions, Android calendar selection, head-up wake/angle, Android 16 KiB
page compatibility, the app switcher close menu, and multilingual Whisper
transcription (OpenAI and on-device), per-app full screen and an independent
per-app keep-awake switch, and explicit bulk notification dismissal.
The switcher change is isolated on `feat/app-switcher-close-menu`, based on
`main`, for a future independent PR. Whisper language selection is isolated on
`feat/whisper-languages`, also based on `main`. Full screen is isolated on
`feat/app-fullscreen` (based on the app switcher menu branch). Bulk dismissal
is part of `feat/notification-filter-default`. No PR was created.
Validation on 2026-11-06:
- JS/TS suite: 1,084 passed, 2 skipped, 0 failed, including full-screen layout,
independent keep-awake persistence, idle sleep behavior, bulk dismissal and
preservation of the stock EvenHub 576x288 logical canvas in full screen.
- Kotlin: 272 tests passed, including multilingual Whisper file selection.
- TypeScript `tsc --noEmit`: passed.
- oxlint on changed TypeScript: passed.
- APK page checker: 5 unit tests passed; all 7 packaged native libraries pass
16 KiB LOAD/RELRO checks. APK ZIP alignment also passes.
- Release build: passed, `debuggable=false`, signature verified and identical
to the locally signed release previously installed on the Pixel.
- Packaged JavaScript contains the close actions, all earlier settings and the
multilingual Whisper preference/model download, full-screen commands and bulk
notification dismissal and independent Keep screen awake. Signature matches
Wear OS too.
Artifact: `dist/faceclaw-all-features-release.apk` (95,270,300 bytes).
SHA-256, also saved next to the APK:
```text
7a2875f512b9715e7af998f600429a3172e8428c84abf11e6badc0c2790707a6
```
The APK is built for local installation with the existing local signing key.
It has not been installed during this feature task. Manual tests on glasses
remain pending; see [the switcher validation procedure](validation-app-switcher-menu.md)
and [Whisper language validation](validation-whisper-languages.md),
[full-screen validation](validation-app-fullscreen.md),
[bulk dismissal validation](validation-dismiss-all-notifications.md), as well as
the earlier per-feature validation documents. No firmware was flashed.
+33
View File
@@ -0,0 +1,33 @@
# Android 16 KiB page compatibility
The initial debug APK triggered Android's page-size compatibility warning.
Its `libfaceclaw_llama.so` LOAD segments were aligned to 4096 bytes. The other
six packaged arm64 libraries were aligned to 16384 bytes, and APK ZIP alignment
already passed `zipalign -c -P 16 4`.
The llama JNI shared library now links with both `max-page-size=16384` and
`common-page-size=16384`, matching the LC3 JNI library. This changes the native
binary layout rather than hiding the compatibility warning or disabling debug.
Gradle already tracks CMakeLists.txt as an input, and Ninja reconfigures and
relinks existing builds after this change.
Reproduce the regression and artifact checks inside `devenv shell`:
```sh
python3 -m unittest discover -s tests -p test_apk_pages.py
bash build.sh
python3 scripts/check-apk-pages.py platforms/android/app/build/outputs/apk/debug/app-debug.apk
"$ANDROID_HOME/build-tools/35.0.1/zipalign" -c -P 16 4 platforms/android/app/build/outputs/apk/debug/app-debug.apk
```
The checker rejects the initial APK and reports its misaligned llama library.
Five unit tests cover 4 KiB rejection, 16 KiB acceptance, RELRO boundaries and
invalid ELF program headers. APK checks inspect all arm64/x86_64 shared libraries.
Reference: [Android's 16 KiB guidance](https://developer.android.com/guide/practices/page-sizes).
Static alignment and successful installation do not prove every native code
path works on-device; voice/LLM features still require functional testing.
The rebuilt APK passes all seven native-library checks, ZIP alignment and APK
signature verification. The connected Pixel 10 Pro Fold reports `getconf
PAGE_SIZE` = 4096; actual execution with 16 KiB pages remains untested.
+36
View File
@@ -0,0 +1,36 @@
# Per-app full screen and keep awake
Long-press opens the system menu. Closeable apps offer Enter full screen / Exit
full screen. The choice persists per app through the existing settings store,
independently of global display layout and app-controlled immersive mode.
Full screen fills the 640x480 panel, hides chrome while the app has focus, and
resizes existing in-process and worker windows without restarting the app.
The switcher remains accessible through the system menu.
Stock EvenHub apps retain their logical 576x288 canvas in every host display
mode, including full screen. Content is centered at native pixel scale and
clipped to that canvas; extra space does not change wrapping or layout.
Only an app's explicit Faceclaw extended-layout request enables a taller canvas.
Regression tests compare the complete stock raster against its centered
full-screen placement, including text crossing the logical canvas boundary.
Keep screen awake is a separate On/Off switch immediately after the full-screen
action in the system menu. It defaults off and persists per app independently
of full screen. Existing full-screen preferences remain unchanged and do not
implicitly enable keep awake.
Automatic idle sleep is suspended only while an app with Keep screen awake
enabled is in the foreground, in any display mode. A background app does not
hold the display awake. Full screen alone does not suppress idle sleep.
The lock screen and explicit sleep still work. The inactivity countdown starts
fresh after disabling keep awake or leaving a kept-awake app. Existing automatic
holds for voice capture, assistant turns and video playback remain in effect.
Software regressions cover geometry with every switcher position, preserving
other display settings and persistence after reload, captured menu targets,
exit, independent keep-awake persistence, foreground/background idle behavior,
lock timeout and manual sleep.
On glasses, verify entry/exit from both in-process apps and worker apps,
reflow, state retention, idle timeout, app switching, lock/off-head behavior,
and reconnection. These hardware checks remain pending. No firmware change.
+35
View File
@@ -0,0 +1,35 @@
# App switcher close menu
Feature branch: `feat/app-switcher-close-menu`, based on `main` so it can be
reviewed independently. The combined build lives on `integration/device-preferences`.
With the app switcher focused, long-press or tap-then-hold opens the existing
shell-owned System menu. “Close current app” closes the selected window when it
is closeable. It is absent for the pinned launcher (the large application grid).
“Close all apps” closes every closeable window, including background windows and
multiple windows belonging to one app. Pinned windows remain available.
Both actions reuse the shell's normal close/cleanup path. The menu closes before
the windows do, and focus returns to the switcher. It opens on “Focus app switcher”
to avoid an accidental close. With no closeable windows, “Close all apps” is disabled.
No new preferences or persistence format are introduced.
Software: `tests/app-switcher-menu.test.cjs` covers both gestures, apps claiming
holds/hold-to-talk, launcher exclusion, captured close targets, cancellation,
default selection, multiple windows, reentrant removal, callback errors and
screen-off behavior. Existing in-app gesture routing remains unchanged.
Manual validation on glasses remains pending:
1. Open several apps, focus the app switcher, and open the menu with both gestures.
2. Close the selected app; verify its surface disappears and other apps remain.
3. Select the large application grid; verify “Close current app” is absent.
4. Use “Close all apps”; verify the launcher remains usable and apps can reopen.
5. Repeat for left/right/bottom/popup switcher positions and with a running game,
a hold-to-talk app and an app exposing multiple windows.
6. Check cancel/back and the initial selection do not close anything. Check both
menu gestures still work normally when focus is inside an app.
Closing windows retains each app's existing lifecycle semantics; it does not
uninstall apps or reset their preferences. Existing app-specific shutdown behavior
(such as a remote terminal connection) is the same as closing its window normally.
+29
View File
@@ -0,0 +1,29 @@
# Android calendar selection validation
Software: `npm test` and `bash lint.sh` for changed TypeScript files.
`tests/calendar-selection.test.cjs` covers preference reloads, all versus none,
duplicate names/accounts, selection changes with cached readers, deleted IDs,
recurrence occurrences and forwarding the selection to the provider before its
limit. Provider SQL structure is checked statically; the mocked bridge does not
replace an Android CalendarContract integration test.
On an Android device (pending):
1. With no saved preference, compare events with the current release.
2. Open Calendar's window menu > Calendars displayed (also available through
Glanceboard's Calendar widget settings). Select between two equal-named
calendars belonging to different accounts. Check ID/account labels.
3. Create more than 50 early events in an excluded calendar and later recurring
events in a selected calendar. Check those later occurrences still appear.
4. Select “No calendars”: Calendar, Glanceboard and any other readers must be
empty immediately. Restart and confirm the selection persists.
5. Select individual calendars, rename one, then delete one. Remaining selections
must stay unchanged. A missing selected ID is shown as unavailable and may be
removed; it never causes a fallback to all calendars.
6. Select “All calendars”, add a calendar, and check it is included. In individual
mode, newly added calendars stay excluded. Check all-day and timed recurring
events in both Calendar and Glanceboard, including timezone/DST boundaries.
IDs are Android CalendarContract IDs, stable across display-name changes within
an installation. Removing/re-adding an account can create new calendar IDs.
The iOS calendar reader and its behavior are unchanged; iOS selection is deferred.
+51
View File
@@ -0,0 +1,51 @@
# Integrated device preferences
Branch: `integration/device-preferences`. Separate implementation branches are
`feat/notification-filter-default`, `feat/calendar-selection` and
`feat/head-up-wake`. No pull requests were created.
Software validation on Linux/NixOS, 2026-11-06:
- JavaScript/TypeScript suite: 1,059 passed, 3 skipped, 0 failed.
- Shared Kotlin Android host suite: 269 passed, 0 failures/errors.
- TypeScript: `tsc --noEmit` passes.
- oxlint: passes with existing warnings outside the changes.
- Nix tools: Node 22, Java 21, Android SDK 35, both build-tools versions,
adb, host CMake/Ninja and NDK verified. Tested using devenv 2.4.0.
Reproduce with `devenv shell`, then:
```sh
npm ci
npm test
npm run test:kotlin
npx tsc --noEmit
bash lint.sh
bash scripts/check-devenv.sh
bash build.sh
```
The build produces a debug APK for arm64 Android phones. It does not install
the APK or flash firmware. Build output and machine-local signing/SDK files
are ignored by Git.
Final artifact: `dist/faceclaw-device-preferences-debug.apk` (115,876,494 bytes),
package `com.faceclaw.app`, version 0.8.6 (806). Build completed successfully;
APK v2 signature verified with `apksigner`. The packaged JavaScript contains all
three controls, and the DEX contains the new calendar and head-up native APIs.
SHA-256 (also saved alongside the APK):
```text
091ced145d499ec00aa03cbea60f5cec7a2167e459896c4b5b45211e1c9a7e8a
```
The updated APK also passes ELF LOAD/RELRO and ZIP alignment checks for 16 KiB
pages; see [16 KiB validation](validation-android-16k.md).
Glasses validation remains pending. The APK was installed on a Pixel 10 Pro Fold,
which currently reports 4096-byte pages. No glasses were used. See the
manual procedures for [notifications](validation-notifications.md),
[Android calendars](validation-calendars.md) and [head-up wake](validation-head-up.md).
In particular, successful BLE encoding and simulated ACK/reconnect tests do
not establish physical wake/angle behavior on a target Faceclaw firmware.
The iOS calendar-selection port is deferred.
@@ -0,0 +1,20 @@
# Dismiss all notifications
The Notifications app menu offers Dismiss all notifications, disabled when the
list is empty. This explicit action dismisses notifications on the phone too;
popup filtering and source/default preferences remain independent.
Android uses NotificationListenerService.cancelAllNotifications, so dismissal
is not limited to the 50 items displayed by the list and Android controls which
notifications are removable. The normal removal callbacks update the list and
popups. Missing listener access returns false without changing preferences.
iOS uses the existing ANCS dismissal operation on a snapshot of all known keys;
notifications without a negative action may remain.
Software tests cover menu action/disabled state, more than 50 notifications,
native bridge dispatch, disconnected access and ANCS bulk dismissal.
On a device, verify the permission-granted/revoked cases, protected or ongoing
notifications, notification groups, and consistency with the phone's tray.
Hardware validation remains pending.
Reference: https://developer.android.com/reference/android/service/notification/NotificationListenerService#cancelAllNotifications()
+53
View File
@@ -0,0 +1,53 @@
# Head-up wake: software and hardware validation
The Android Display settings now contain “Head-up wake” and “Head-up angle”.
Glanceboard's “Show on head tilt” still only chooses which UI appears on wake.
Protocol reference: [OpenG2 Companion G2Protocol.swift](https://github.com/mmirman/open-g2-companion/blob/1400d1006ba045379a3ff34d0832add6fa10ced4/modules/ffs-ble/ios/G2Protocol.swift),
`setHeadUpSwitch` / `setHeadUpAngle`; dispatch to both lenses in
[`G2Central.swift`](https://github.com/mmirman/open-g2-companion/blob/1400d1006ba045379a3ff34d0832add6fa10ced4/modules/ffs-ble/ios/G2Central.swift).
Wire format uses Faceclaw's UI-settings sid 0x09, request flag, command 1, transaction
magic, device-receive-info field 3 / head-up field 4. Switch (field 1) and
angle (field 2) are sent in separate messages, including explicit zero values.
Angles are clamped to the reference's 0–60 degree range. No firmware patch,
firmware download or flash is needed by this implementation.
Untouched installations send neither field. The UI describes this inherited
state; its displayed ON/30 degree fallback is not a read-back of device state.
Changing just one control preserves the other device field. Explicit choices
are persisted in the existing settings store and resent on every connection.
The native session also retains them through transport reconnects and retries
after setting ACK timeouts. ACK reception confirms transport, not physical wake.
Software checks:
- `tests/head-up-wake.test.cjs`: persistence, untouched fields, angle bounds,
independence from Glanceboard, deduplication, reconnect and error recovery.
- `HeadUpProtocolTest`: byte-for-byte settings messages, including OFF and 0°.
- `GlassesSessionCoreTest`: both lenses, separate writes, pre-existing device
settings preserved, angle clamp and automatic transport reconnection.
Hardware validation: **pending**. Implementation was requested without device
access; protocol compatibility and physical effect on the target Faceclaw CFW
are not established by these software tests. The reference targets stock
2.2.6.10, while this repository normally uses newer Faceclaw firmware.
Source inspection of [Faceclaw's gesture forwarding](https://github.com/jimrandomh/g2flash/blob/845f665e0dfdcfd06b7d3a294388de6f17a5bd59/patches/gesture_fwd.c)
confirms that head-up/down forwarding while a page owns the screen checks the
stock `head_up_switch`. This supports using the existing setting rather than a
firmware patch, but does not establish the physical angle or wake behavior.
On the target glasses, record both lens firmware versions and test:
1. Leave preferences untouched and verify prior wake behavior remains unchanged.
2. Disable Head-up wake; sleep the display, raise the head repeatedly, and confirm
no wake. Check taps still wake normally.
3. Enable it and compare 0°, 30° and 60° trigger angles. Confirm other wake
gestures remain usable, including at the extreme values.
4. Reconnect Bluetooth, then restart the phone app; repeat ON/OFF and angle checks.
5. Toggle Glanceboard and “Show on head tilt” independently; disabled wake should
stay disabled, enabled wake should show the selected UI.
6. Check both lenses remain synchronized, including reconnecting only one arm.
Do not change firmware to run these checks without explicit permission.
+23
View File
@@ -0,0 +1,23 @@
# Notification filter validation
Software: `npm test` and `bash lint.sh app/native/notification-sources.ts app/ui/notification-filter.ts`.
The notification suite covers legacy preferences, reloads of the settings store,
discovery, default changes without overwriting exceptions, both bulk actions,
empty lists, stable menu selection and popup suppression before wake.
Hardware validation (pending; no glasses tested):
1. On an existing installation, check that enabled and muted applications retain
their behavior before touching the new default.
2. Turn “New apps enabled by default” off; restart the app. Send a notification
from a previously unknown package: it must appear in the filter and on the
phone, without waking the glasses or showing a glasses popup.
3. Enable that package individually; send another notification and check its popup.
4. Change the default in both directions; verify individual exceptions survive.
5. Use “Disable all”, then discover another package: it follows the default.
Repeat with “Enable all” while the default is off.
6. Restart and repeat notifications from enabled and disabled sources. Check that
bulk actions and filtering never dismiss notifications on the phone.
Only popup delivery on glasses is filtered. The notification tray and phone
notification lifecycle retain their existing behavior.
+46
View File
@@ -0,0 +1,46 @@
# Whisper transcription languages
Settings > Voice > Transcription language selects French, English, 27 other
languages, or auto-detection. It applies to ordinary dictation and continuous
transcription using OpenAI, on-device Whisper, and the other cloud providers.
Translate retains its own spoken-language preference. Moonshine remains
English-only; Apple's on-device speech recognizer retains its own locale.
The initial **Provider default** preserves existing installations: English for
on-device Whisper, auto-detection for OpenAI/other cloud providers, and the saved
Whisper server language for self-hosted Whisper. Selecting another shared
language overrides the server language without deleting it. Returning to Provider
default restores it. Settings persist through the existing settings store.
For French or auto-detection with **On-device (Whisper)**, download
**On-device model: Whisper (multilingual, base)** in Settings > Voice (~161 MB).
English uses the existing English-only base model; neither model is deleted or
downloaded automatically. A missing model uses the existing “Voice model not
downloaded” status. Language changes restart active continuous transcription;
other captures use the new language when started.
## Software validation
- JavaScript regression tests exercise stored settings/reload, compatible
defaults, French and auto-detection, Translate overrides in Android/iOS capture
options, the OpenAI WebSocket configuration, and local bridge restart/sharing.
- Kotlin tests exercise English/French/other/automatic model selection and file
names. Android release compilation checks the actual sherpa-onnx bridge.
- New model downloads use a pinned Hugging Face revision, per-file SHA-256 and
the existing resumable downloader. Encoder/decoder hashes and sizes come from
repository LFS metadata; the vocabulary hash was computed from its contents.
## Device validation still required
With both phone microphone preview and glasses microphone, check French dictation
(including accents), auto-detection, English rollback, continuous capture while
changing language, cancellation/resumption of model download, and persistence
after restarting the app. Compare OpenAI and offline Whisper on the same phrases.
No paid API call, microphone recording, or firmware update is needed for the
software checks above; recognition accuracy and latency require device testing.
## References
- [OpenAI Realtime transcription: language configuration](https://developers.openai.com/api/docs/guides/realtime-transcription)
- [sherpa-onnx Whisper configuration and automatic language detection](https://github.com/k2-fsa/sherpa-onnx/blob/master/sherpa-onnx/csrc/offline-whisper-model-config.cc)
- [Multilingual base model, pinned revision](https://huggingface.co/csukuangfj/sherpa-onnx-whisper-base/tree/bb53ee204431c90d314c1cc08d28d23e5b7927cc)
@@ -0,0 +1,18 @@
package com.faceclaw.app
/** The English-only files remain usable after upgrading; other languages need multilingual base. */
data class WhisperModelFiles(val language: String) {
val englishOnly: Boolean get() = language == "en"
val dirName: String get() = if (englishOnly) "sherpa-onnx-whisper-base-en-int8" else "sherpa-onnx-whisper-base-int8"
private val prefix: String get() = if (englishOnly) "base.en" else "base"
val encoder: String get() = "$prefix-encoder.int8.onnx"
val decoder: String get() = "$prefix-decoder.int8.onnx"
val tokens: String get() = "$prefix-tokens.txt"
val files: List<String> get() = listOf(encoder, decoder, tokens)
companion object {
/** Null preserves the old English default; an empty code enables automatic detection. */
fun forLanguage(language: String?): WhisperModelFiles =
WhisperModelFiles(language?.trim()?.lowercase() ?: "en")
}
}
@@ -497,6 +497,23 @@ class BleProtocol {
)
}
/** Stock HeadUpSetting: switch and angle are separate oneof writes (field 4 of device info). */
@JvmStatic
fun buildSetHeadUpWake(magic: Int, enabled: Boolean): ByteArray = concat(
CollectionUtils.listOf(
encodeVarintField(1, 1), encodeVarintField(2, magic),
encodeMessageField(3, encodeMessageField(4, encodeVarintField(1, if (enabled) 1 else 0))),
)
)
@JvmStatic
fun buildSetHeadUpAngle(magic: Int, angle: Int): ByteArray = concat(
CollectionUtils.listOf(
encodeVarintField(1, 1), encodeVarintField(2, magic),
encodeMessageField(3, encodeMessageField(4, encodeVarintField(2, angle.coerceIn(0, 60)))),
)
)
/** Enable the firmware's wear detector (DeviceReceiveInfoFromAPP field 5). */
@JvmStatic
fun buildSetWearDetection(magic: Int, enabled: Boolean): ByteArray {
@@ -188,6 +188,17 @@ class MessageBuilder {
)
}
fun headUpControl(leftArm: Boolean, enabled: Boolean?, angle: Int): OutboundMessage {
val magic = magicPool.allocate()
return OutboundMessage(
"head-up-control", if (enabled == null) "head-up angle=$angle" else "head-up wake=$enabled",
BleProtocol.SID_UI_SETTING, BleProtocol.FLAG_REQUEST, magic,
if (enabled == null) BleProtocol.buildSetHeadUpAngle(magic, angle)
else BleProtocol.buildSetHeadUpWake(magic, enabled),
ACK_TIMEOUT_MS, -1, leftArm,
)
}
fun createLayout(): OutboundMessage {
var magic: Int = magicPool.allocate()
return OutboundMessage(
@@ -304,6 +304,8 @@ class GlassesSessionCore(
internal var brightnessSentLevel = -1
internal var brightnessAlsStartedAt = -2000L
internal var brightnessDemoPolling = false
internal var headUpPreferences: Pair<Int, Int>? = null
internal var headUpSent: Pair<Int, Int>? = null
internal var cfwCleanupDelivered = false
internal var lastCfwCleanupAckMagic = 0
@@ -920,6 +922,15 @@ class GlassesSessionCore(
interruptibleSleep.interrupt()
}
/** Explicit preferences only; -1 leaves the corresponding firmware field alone. */
fun configureHeadUpWake(enabled: Int, angle: Int) {
require(enabled in -1..1)
monitor.withLock {
headUpPreferences = Pair(enabled, if (angle < 0) -1 else angle.coerceIn(0, 60))
}
interruptibleSleep.interrupt()
}
/**
* Enable the stock wear detector, then ask CFW to emit its current cached
* state. The queue order matters: the query must run after the setting is
@@ -2232,6 +2243,7 @@ class GlassesSessionCore(
shutdownRequested = false
fixedLayoutCreated = false
clearAllMessagesLocked("session ready")
headUpSent = null
displayedFingerprint = ""
lastAckAtMs = now()
lastIncomingAtMs = lastAckAtMs
@@ -0,0 +1,22 @@
package com.faceclaw.app
/** Both arms receive separate stock settings messages; no CFW changes required. */
internal fun GlassesSessionCore.enqueueHeadUpPreferencesLocked() {
val desired = headUpPreferences ?: return
if (!sessionReady || shutdownRequested || chargingMode || headUpSent == desired
|| hasPendingOrInflightKindLocked("head-up-control")) return
for (leftArm in listOf(true, false)) {
// Set the angle before enabling wake. Omitted fields preserve device preferences.
if (desired.second >= 0) {
val message = messageBuilder.headUpControl(leftArm, null, desired.second)
message.onTimeout = MessageCallback { headUpSent = null; logLine("head-up angle ack timeout") }
pendingMessages.addLast(message)
}
if (desired.first >= 0) {
val message = messageBuilder.headUpControl(leftArm, desired.first == 1, -1)
message.onTimeout = MessageCallback { headUpSent = null; logLine("head-up wake ack timeout") }
pendingMessages.addLast(message)
}
}
headUpSent = desired
}
@@ -74,6 +74,7 @@ internal fun GlassesSessionCore.driveSession(): Long {
clearPendingMessagesLocked("after CFW cleanup")
return 250
}
enqueueHeadUpPreferencesLocked()
if (sessionReady
&& now - lastFaceclawFramebufferLeaseQueuedAtMs >= FACECLAW_WAKE_LEASE_RENEW_MS
&& !hasPendingOrInflightKindLocked("framebuffer-lease-control")) {
+57
View File
@@ -0,0 +1,57 @@
#!/usr/bin/env python3
"""Check ELF64 LOAD/RELRO alignment in an APK; pair with zipalign -c -P 16 4."""
import argparse
import struct
import zipfile
PAGE = 16384
def alignment_errors(data):
if len(data) < 64 or data[:4] != b"\x7fELF" or data[4] != 2 or data[5] not in (1, 2):
return ["expected an ELF64 library"]
endian = "<" if data[5] == 1 else ">"
offset = struct.unpack_from(endian + "Q", data, 32)[0]
size, count = struct.unpack_from(endian + "HH", data, 54)
if size < 56 or offset + size * count > len(data):
return ["invalid program headers"]
headers = [struct.unpack_from(endian + "IIQQQQQQ", data, offset + i * size) for i in range(count)]
errors = []
loads = [h for h in headers if h[0] == 1]
if not loads:
errors.append("no LOAD segments")
for h in loads:
if h[7] < PAGE or h[7] % PAGE or (h[3] - h[2]) % PAGE:
errors.append(f"LOAD alignment {h[7]} is incompatible with 16 KiB pages")
for h in headers:
if h[0] != 0x6474E552:
continue
end = h[3] + h[6]
# A RELRO ending within a writable LOAD may protect unrelated writable
# data on a 16 KiB device. A separate LOAD after RELRO is also safe.
if end % PAGE and any(p[1] & 2 and p[3] <= h[3] and end < p[3] + p[6] for p in loads):
errors.append("RELRO ends inside writable LOAD without 16 KiB alignment")
return errors
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("apk")
args = parser.parse_args()
checked = 0
failed = False
with zipfile.ZipFile(args.apk) as archive:
for name in archive.namelist():
if not name.startswith(("lib/arm64-v8a/", "lib/x86_64/")) or not name.endswith(".so"):
continue
checked += 1
errors = alignment_errors(archive.read(name))
failed |= bool(errors)
print(f"{'FAIL' if errors else 'OK'} {name}" + (": " + "; ".join(errors) if errors else ""))
if not checked:
parser.error("no 64-bit native libraries found")
return int(failed)
if __name__ == "__main__":
raise SystemExit(main())
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
set -euo pipefail
node --version
java -version
test -f "$ANDROID_HOME/platforms/android-35/android.jar"
for version in 34.0.0 35.0.0 35.0.1; do
"$ANDROID_HOME/build-tools/$version/aapt2" version
done
"$ANDROID_HOME/platform-tools/adb" version
"$ANDROID_CMAKE_HOME/bin/cmake" --version
"$ANDROID_CMAKE_HOME/bin/ninja" --version
case "$(uname -s)" in
Darwin) ndk_host=darwin-x86_64 ;;
*) ndk_host=linux-x86_64 ;;
esac
test -x "$ANDROID_HOME/ndk/27.2.12479018/toolchains/llvm/prebuilt/$ndk_host/bin/clang"
echo "Faceclaw development tools verified."
+4
View File
@@ -267,6 +267,9 @@ function shellEnv({ wakeAction = 'voice-input', skipConfirmation = false } = {})
}
const voiceDialogs = [];
const settings = { wakeWordActionSetting: { get: () => wakeAction }, brightnessSetting: { get: () => 'auto' },
appFullscreenSetting: () => ({ get: () => false }),
appKeepAwakeSetting: () => ({ label: 'Keep screen awake', get: () => false }),
toggleSettingMenuItem: setting => ({ label: setting.label }),
assistantSkipConfirmationSetting: { get: () => skipConfirmation } };
const { shell, rawInputEventToInputEvent } = load('app/ui/shell/shell.ts', {
'../../graphics/shell-scene': { encodeShellScene: () => new Uint8Array([0, 0]) },
@@ -370,6 +373,7 @@ test('ordinary apps retain long-press system menu and games retain the escape ti
assert.deepEqual(env.input, []);
env.shell.stack.clearToBase();
env.app.window.claimsLongPress = () => true;
env.shell.focusWindow('ai-chat');
await env.shell.receiveInput(env.event('long-press'));
assert.notEqual(env.shell.escapeMenuTimer, null);
await env.shell.receiveInput(env.event('long-press-release'));
+21
View File
@@ -15,6 +15,8 @@ function geometry() {
appSwitcherPositionSetting: 'left', uiDepthSetting: '0', statusBarPositionSetting: 'top',
statusBarVisibilitySetting: 'always', windowBorderSetting: true,
}).map(([name, value]) => [name, { value, get() { return this.value; } }]));
const fullscreen = new Map();
settings.appFullscreenSetting = id => ({ get: () => fullscreen.get(id) ?? false, set: value => fullscreen.set(id, value) });
const context = { exports: {}, require: (name) => {
if (name === '../../graphics/image') return { G2_LENS_WIDTH: 640, G2_LENS_HEIGHT: 480 };
assert.equal(name, '../dashboard-settings');
@@ -27,6 +29,25 @@ function geometry() {
const LAYOUTS = ['band-top', 'band-high', 'band-middle', 'band-low', 'band-bottom', 'tall', 'fullscreen'];
test('user full screen spans the panel with any switcher and survives app immersive cleanup', () => {
const g = geometry();
const previous = g.rect('min', 'test');
for (const position of ['left', 'right', 'bottom', 'popup']) {
g.settings.appSwitcherPositionSetting.value = position;
g.settings.appFullscreenSetting('test').set(true);
assert.deepEqual(g.rect('min', 'test'), { x: 0, y: 0, width: 640, height: 480 });
assert.equal(g.sidebarStripVisible('window', 'test'), false);
assert.equal(g.sidebarStripVisible('sidebar', 'test'), true);
g.setAppImmersive('test', true);
g.setAppImmersive('test', false);
assert.equal(g.isImmersive('test'), true);
assert.equal(g.isImmersive('other'), false);
}
g.settings.appSwitcherPositionSetting.value = 'left';
g.settings.appFullscreenSetting('test').set(false);
assert.deepEqual(g.rect('min', 'test'), previous);
});
test('defaults preserve normal windows, EvenHub height and tall terminal sessions', () => {
const g = geometry();
assert.deepEqual(g.rect('min', 'navigate'), { x: 64, y: 124, width: 576, height: 260 });
+226
View File
@@ -0,0 +1,226 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const vm = require('node:vm');
const ts = require('typescript');
function fixture(options = {}) {
const source = ts.createSourceFile('shell.ts', fs.readFileSync(path.join(__dirname, '../app/ui/shell/shell.ts'), 'utf8'), ts.ScriptTarget.Latest, true);
const shellClass = source.statements.find(node => ts.isClassDeclaration(node) && node.name.text === 'Shell');
const names = new Set(['routeInput', 'openEscapeMenu', 'closeAllWindows', 'closeWindow', 'removeWindow',
'foregroundWindow', 'noteWindowVisible', 'mostRecentWindowIndex', 'yieldFocusToSidebar', 'applyScreenTimeout']);
const methods = shellClass.members.filter(node => names.has(node.name?.getText(source)));
assert.equal(methods.length, names.size);
const overlay = source.statements.find(node => ts.isClassDeclaration(node) && node.name.text === 'ShellOverlayMenuLayer');
class MenuLayer {
constructor(title, items) { this.title = title; this.items = items; }
selectItem(index) { this.selectedIndex = index; }
}
const fullscreen = new Map();
const keepAwake = new Map();
const context = {
exports: {}, MenuLayer, console: { warn: () => {} },
appViewportRect: () => ({ x: 0, y: 0, width: 576 }), CONTEXT_MENU_DIM: 0.5,
brightnessSetting: { get: () => 'auto' }, gestureHints: () => 'App menu',
GESTURE_SHORT_THEN_LONG_PRESS: 'tap-hold', makeInputEvent: event => event,
isWatchInput: event => event.source === 'watch', isDirectionalInput: () => false,
appFullscreenSetting: id => ({ get: () => fullscreen.get(id) ?? false, set: value => fullscreen.set(id, value) }),
appKeepAwakeSetting: id => ({ label: 'Keep screen awake', get: () => keepAwake.get(id) ?? false, set: value => keepAwake.set(id, value) }),
toggleSettingMenuItem: (setting, options) => ({ label: setting.label, onSelect(ctx) {
setting.set(!setting.get()); options.onChange(ctx);
} }),
};
vm.runInNewContext(ts.transpileModule(`${overlay.getText(source)}\nexport class Shell { ${methods.map(node => node.getText(source)).join('\n')} }`, {
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
}).outputText, context);
const s = new context.exports.Shell();
const closed = [], delivered = [], warnings = [], renders = [];
context.console.warn = message => warnings.push(message);
const window = (id, closeable = true, extra = {}) => ({
appId: id, windowId: id, closeable,
handleInput: async event => delivered.push([id, event.type]),
requestRender: () => renders.push(id),
close: () => closed.push(id),
...extra,
});
const launcher = window('launcher', false);
const app = window('current', true, options.app);
const background = window('background');
const layers = [];
s.stack = {
isAtBase: () => !layers.length,
push: layer => layers.push(layer),
pop: () => layers.pop()?.onRemoved?.(),
popIfTop: predicate => { if (!layers.length || !predicate(layers.at(-1))) return false; s.stack.pop(); return true; },
handleInput: async event => { if (event.type === 'double-click') s.stack.pop(); },
};
Object.assign(s, {
windows: [launcher, app, background], selectedIndex: 1, focus: 'sidebar', screenOn: true,
mruWindowIds: ['current', 'background', 'launcher'], attention: new Map(),
config: { voiceInputEnabled: false, requestShellRender() {}, onWindowsChanged() {} },
cancelEscapeMenuTimer() {}, startEscapeMenuTimer() { s.escapeStarted = true; },
lastInput: null,
lastInputAtMs: 0,
noteUserActivity() { this.lastInputAtMs = 100; },
focusWindow(id) { this.selectedIndex = this.windows.findIndex(w => w.windowId === id); this.focus = 'window'; },
sleep() { this.screenOn = false; },
});
const input = type => s.routeInput({ type, source: 'ring', timestampMs: 100 }, 1);
const menu = () => layers.at(-1);
const choose = label => {
const item = menu().items.find(item => item.label === label);
assert.ok(item, label);
item.onSelect({ stack: s.stack });
};
return { s, input, menu, choose, closed, delivered, warnings, renders, launcher, app, background, window, fullscreen, keepAwake };
}
test('full screen targets the captured app without inhibiting idle sleep', async () => {
const h = fixture();
h.s.config.getScreenTimeoutMs = () => 1000;
let relayouts = 0;
h.s.config.onWindowLayoutChanged = () => relayouts++;
await h.input('long-press');
h.s.selectedIndex = 2;
h.choose('Enter full screen');
assert.equal(h.fullscreen.get('current'), true);
assert.equal(h.s.foregroundWindow().windowId, 'current');
assert.equal(h.s.focus, 'window');
assert.equal(relayouts, 1);
assert.equal(h.s.applyScreenTimeout(5000), true);
h.s.screenOn = true;
h.s.focusWindow('current');
await h.input('long-press');
h.choose('Exit full screen');
assert.equal(h.fullscreen.get('current'), false);
assert.equal(relayouts, 2);
assert.equal(h.s.applyScreenTimeout(7000), true);
});
test('keep awake is independent of full screen and applies only to the visible app', async () => {
const h = fixture();
h.s.config.getScreenTimeoutMs = () => 1000;
await h.input('long-press');
const labels = h.menu().items.map(item => item.label);
assert.equal(labels.indexOf('Keep screen awake'), labels.indexOf('Enter full screen') + 1);
h.s.selectedIndex = 2;
h.choose('Keep screen awake');
assert.equal(h.keepAwake.get('current'), true);
assert.equal(h.fullscreen.get('current'), undefined);
assert.equal(h.s.foregroundWindow().windowId, 'current');
assert.equal(h.s.applyScreenTimeout(5000), false);
h.s.focusWindow('background');
assert.equal(h.s.applyScreenTimeout(5500), false);
assert.equal(h.s.applyScreenTimeout(6000), true);
h.s.screenOn = true;
h.s.focusWindow('current');
await h.input('long-press'); h.choose('Enter full screen');
assert.equal(h.s.applyScreenTimeout(7000), false);
await h.input('long-press'); h.choose('Exit full screen');
assert.equal(h.keepAwake.get('current'), true);
assert.equal(h.s.applyScreenTimeout(8000), false);
await h.input('long-press'); h.choose('Keep screen awake');
assert.equal(h.keepAwake.get('current'), false);
assert.equal(h.s.applyScreenTimeout(9000), true);
});
test('keep awake does not suppress lock timeout or manual sleep, and options are absent for the launcher', async () => {
const h = fixture();
h.fullscreen.set('current', true);
h.keepAwake.set('current', true);
h.s.config.getScreenTimeoutMs = () => 1000;
h.s.config.isLocked = () => true;
assert.equal(h.s.applyScreenTimeout(5000), true);
h.s.screenOn = true;
h.s.config.isLocked = () => false;
h.s.sleep();
assert.equal(h.s.screenOn, false);
h.s.screenOn = true;
h.s.selectedIndex = 0;
await h.input('long-press');
assert.ok(!h.menu().items.some(item => /full screen/.test(item.label)));
assert.ok(!h.menu().items.some(item => item.label === 'Keep screen awake'));
});
test('switcher opens its menu on hold or tap-hold even for an app claiming holds or hold-to-talk', async () => {
for (const type of ['long-press', 'short-then-long-press']) {
for (const app of [{}, { claimsLongPress: () => true }, { holdToTalk: true }]) {
const h = fixture({ app });
await h.input(type);
assert.ok(h.menu());
assert.ok(h.menu().items.some(item => item.label === 'Close current app'));
assert.ok(h.menu().items.some(item => item.label === 'Close all apps'));
assert.equal(h.menu().items[h.menu().selectedIndex].label, 'Focus app switcher');
assert.deepEqual(h.delivered, [['current', 'system-menu-opened']]);
assert.equal(h.s.escapeStarted, undefined);
assert.equal(h.s.focus, 'sidebar');
}
}
});
test('close current app closes the captured window and preserves the launcher and background windows', async () => {
const h = fixture();
await h.input('long-press');
h.s.selectedIndex = 2; // An asynchronous focus change must not redirect the close action.
h.choose('Close current app');
assert.deepEqual(h.closed, ['current']);
assert.deepEqual(h.s.windows.map(w => w.windowId), ['launcher', 'background']);
assert.equal(h.s.focus, 'sidebar');
assert.equal(h.menu(), undefined);
});
test('launcher offers close all but never close current; close all leaves only the launcher', async () => {
const h = fixture();
h.s.selectedIndex = 0;
await h.input('short-then-long-press');
assert.ok(!h.menu().items.some(item => item.label === 'Close current app'));
h.choose('Close all apps');
assert.deepEqual(h.closed, ['current', 'background']);
assert.deepEqual(h.s.windows.map(w => w.windowId), ['launcher']);
assert.equal(h.s.selectedIndex, 0);
assert.equal(h.s.focus, 'sidebar');
await h.input('long-press');
assert.equal(h.menu().items.find(item => item.label === 'Close all apps').disabled(), true);
});
test('close all uses normal cleanup despite reentrant removal, multiple windows per app and throwing callbacks', () => {
const h = fixture();
h.s.windows.push(h.window('another', true, { appId: 'current' }), h.window('pinned', false));
h.app.close = () => { h.closed.push('current'); h.s.removeWindow('current'); };
h.background.close = () => { h.closed.push('background'); throw new Error('failed cleanup'); };
h.s.closeAllWindows();
assert.deepEqual(h.closed, ['current', 'background', 'another']);
assert.deepEqual(h.s.windows.map(w => w.windowId), ['launcher', 'pinned']);
assert.equal(h.warnings.length, 1);
assert.equal(h.s.foregroundWindow().windowId, 'launcher');
});
test('default selection and cancel do not close apps; an open overlay never receives a second menu', async () => {
const h = fixture();
await h.input('long-press');
h.choose(h.menu().items[h.menu().selectedIndex].label);
assert.deepEqual(h.closed, []);
await h.input('long-press');
const menu = h.menu();
await h.input('long-press');
assert.equal(h.menu(), menu);
await h.input('double-click');
assert.equal(h.menu(), undefined);
assert.deepEqual(h.closed, []);
});
test('in-app hold actions and app menus keep their existing routing; asleep switcher stays asleep', async () => {
for (const [app, type] of [[{ claimsLongPress: () => true }, 'long-press'], [{ holdToTalk: true }, 'long-press'], [{}, 'short-then-long-press']]) {
const h = fixture({ app });
h.s.focus = 'window';
await h.input(type);
assert.deepEqual(h.delivered, [['current', type]]);
assert.equal(h.menu(), undefined);
}
const h = fixture();
h.s.screenOn = false;
await h.input('long-press');
assert.equal(h.menu(), undefined);
assert.deepEqual(h.closed, []);
});
@@ -55,6 +55,7 @@ function settingsEnv(initialUrl = '', initialModel = 'openai-compatible') {
ASR_MODELS: {
moonshine: { label: 'Moonshine', sizeBytes: 1 },
'whisper-base-en': { label: 'Whisper Base English', sizeBytes: 1 },
'whisper-base': { label: 'Whisper Base Multilingual', sizeBytes: 1 },
},
asrModelState: () => ({}), cancelAsrModelDownload() {},
deleteAsrModel() {}, startAsrModelDownload() {}, onAsrModelStateChanged: () => () => {},
+1
View File
@@ -26,6 +26,7 @@ function settingsFixture(store = new Map()) {
};
if (id.includes('brightness-curve')) return require('../.test-build/app/g2/brightness-curve.js');
if (id.includes('animation-speed')) return require('../.test-build/app/ui/animation-speed.js');
if (id.includes('transcription-language')) return require('../.test-build/app/native/transcription-language.js');
return { Layer: class {}, ASSISTANT_MODEL_CHOICES: [] };
}};
vm.runInNewContext(ts.transpileModule(fs.readFileSync('app/ui/dashboard-settings.ts', 'utf8'), {
+8 -2
View File
@@ -39,6 +39,9 @@ const menu = load('app/ui/menu.ts', {
function fixture(initial = '50', viewport = { x: 64, y: 124, width: 576, height: 260 }) {
let value = initial, writes = 0, closed = 0;
const settings = {
appFullscreenSetting: () => ({ get: () => false }),
appKeepAwakeSetting: () => ({ label: 'Keep screen awake', get: () => false }),
toggleSettingMenuItem: setting => ({ label: setting.label }),
brightnessSetting: { get: () => value, set: (next) => { value = next; writes++; } },
brightnessSettingToLevel: (value) => value === 'auto' ? null : Number(value),
};
@@ -120,13 +123,16 @@ test('system menu hides brightness in Auto and opens its picker between Voice in
shell.openSystemMenu('test');
let opened = shell.stack.layers.at(-1);
assert.deepEqual(Array.from(opened.items, (item) => item.label),
['Close window', 'Focus app switcher', 'Voice input', 'Debug']);
['Close current app', 'Focus app switcher', 'Voice input', 'Close all apps', 'Enter full screen', 'Keep screen awake', 'Debug']);
shell.stack.clearToBase();
f.settings.brightnessSetting.set('40');
shell.openSystemMenu('test');
opened = shell.stack.layers.at(-1);
assert.deepEqual(Array.from(opened.items, (item) => item.label),
['Close window', 'Focus app switcher', 'Voice input', 'Brightness', 'Debug']);
['Close current app', 'Focus app switcher', 'Voice input', 'Close all apps', 'Enter full screen', 'Keep screen awake', 'Brightness', 'Debug']);
await shell.stack.handleInput(gestures.makeInputEvent({ type: 'scroll-down' }));
await shell.stack.handleInput(gestures.makeInputEvent({ type: 'scroll-down' }));
await shell.stack.handleInput(gestures.makeInputEvent({ type: 'scroll-down' }));
await shell.stack.handleInput(gestures.makeInputEvent({ type: 'scroll-down' }));
await shell.stack.handleInput(gestures.makeInputEvent({ type: 'scroll-down' }));
await shell.stack.handleInput(gestures.makeInputEvent({ type: 'click', source: 'ring' }));
+150
View File
@@ -0,0 +1,150 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const vm = require('node:vm');
const ts = require('typescript');
const source = file => fs.readFileSync(path.join(__dirname, '..', file), 'utf8');
function load(file, modules, globals = {}) {
const context = { exports: {}, require: name => {
assert.ok(name in modules, `Unexpected import ${name}`);
return modules[name];
}, ...globals };
vm.runInNewContext(ts.transpileModule(source(file), {
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
}).outputText, context);
return context.exports;
}
function fixture(settings = new Map()) {
const listeners = new Set();
const storage = {
getStringSetting: (key, fallback) => settings.get(key) ?? fallback,
setStringSetting: (key, value) => { settings.set(key, value); for (const fn of listeners) fn(key); },
onSettingsStoreChanged: fn => { listeners.add(fn); return () => listeners.delete(fn); },
};
const prefs = load('app/native/calendar-selection.ts', { './settings-store': storage });
let permitted = true;
const calls = [];
const calendars = [
{ id: '1', name: 'Work', accountName: 'one@example.com', accountType: 'google' },
{ id: '2', name: 'Work', accountName: 'two@example.com', accountType: 'google' },
];
const events = [
{ id: 1, calendarId: '1', startMs: 10000, endMs: 20000, title: 'Excluded early' },
{ id: 9, calendarId: '2', startMs: 30000, endMs: 40000, title: 'Recurrence one' },
{ id: 9, calendarId: '2', startMs: 50000, endMs: 60000, title: 'Recurrence two' },
];
const modules = {
'@nativescript/core': { Utils: { android: { getApplicationContext: () => ({}) } } },
'../g2/android-permissions': { hasCalendarPermission: () => permitted },
'./calendar-permissions': { hasCalendarPermission: () => permitted },
'./frame-timings': { spanCurrent: (_name, fn) => fn() },
'./calendar-selection': prefs,
'./settings-store': storage,
};
const globals = { global: { isAndroid: true }, com: { faceclaw: { app: { FaceclawCalendarProvider: {
getCalendarsJson: () => JSON.stringify(calendars),
getUpcomingEventsJson: (_ctx, max, window, selection) => {
calls.push({ max, window, selection });
const ids = JSON.parse(selection);
return JSON.stringify(events.filter(event => ids === null || ids.includes(event.calendarId)).slice(0, max));
},
} } } } };
const api = load('app/native/calendar.ts', modules, globals);
const sources = load('app/native/calendar-sources.ts', modules, globals);
return { api, prefs, sources, modules, globals, settings, calls, calendars,
permissions: value => { permitted = value; } };
}
test('calendar selection distinguishes all and none, survives restart and rejects invalid data', () => {
const f = fixture();
assert.equal(f.prefs.readCalendarSelection(), null);
f.prefs.setCalendarSelection([]);
assert.deepEqual(Array.from(fixture(f.settings).prefs.readCalendarSelection()), []);
f.prefs.setCalendarSelection(['2', '2', '1']);
assert.deepEqual(Array.from(fixture(f.settings).prefs.readCalendarSelection()), ['2', '1']);
f.prefs.setCalendarSelection(null);
assert.equal(fixture(f.settings).prefs.readCalendarSelection(), null);
assert.throws(() => f.prefs.setCalendarSelection(['1 OR 1=1']));
for (const value of ['oops', '{}', '[false]', '["bad"]']) {
f.settings.set(f.prefs.CALENDAR_SELECTION_KEY, value);
assert.equal(f.prefs.readCalendarSelection(), null);
}
});
test('shared reader forwards IDs before limiting, preserves recurrence occurrences and invalidates all cached query variants', async () => {
const f = fixture();
assert.equal(f.api.readUpcomingEvents(1)[0].title, 'Excluded early');
f.api.readUpcomingEvents(1);
assert.equal(f.calls.length, 1);
let notifications = 0;
const off = f.api.onCalendarChanged(() => notifications++);
f.prefs.setCalendarSelection(['2']);
const rows = f.api.readUpcomingEvents(2);
assert.deepEqual(Array.from(rows, event => event.id), [9, 9]);
assert.equal(f.calls.at(-1).selection, '["2"]');
assert.equal(notifications, 1);
assert.equal((await f.api.readUpcomingEventsAsync(1))[0].title, 'Recurrence one');
off();
f.prefs.setCalendarSelection([]);
assert.equal(notifications, 1);
assert.equal(f.api.readUpcomingEvents(1).length, 0, 'selection cache key works even without subscriptions');
assert.equal(fixture(f.settings).api.readUpcomingEvents().length, 0);
f.prefs.setCalendarSelection(['999']);
assert.equal(f.api.readUpcomingEvents().length, 0, 'deleted calendar does not revert to all');
f.permissions(false);
assert.equal(f.api.readUpcomingEvents().length, 0);
assert.equal(f.sources.readAvailableCalendars().length, 0);
});
test('calendar menu distinguishes equal names by account and ID; all, none, deleted and individual selections share preferences', () => {
const f = fixture();
const { CalendarFilterLayer } = load('app/apps/calendar/calendar-filter.ts', {
'../../graphics/ui-fonts': { getDefaultSmallFont: () => ({}) },
'../../graphics/textwrap': { truncateText: (_font, text) => text },
'../../native/calendar-selection': f.prefs,
'../../native/calendar-sources': f.sources,
'../../native/calendar-permissions': { hasCalendarPermission: () => true },
'../../ui/menu': {
drawToggleMenuItem: () => {},
MenuLayer: class {
constructor(_title, items) { this.items = items; this.selectedIndex = 0; }
selectItem(index) { this.selectedIndex = index; return this; }
setItems(items, index) { this.items = items; this.selectedIndex = index; }
paint() { return this.items; }
},
},
}, f.globals);
const layer = new CalendarFilterLayer();
const ctx = { stack: { getBaseSize: () => ({ width: 576 }) } };
const rows = () => layer.paint(ctx, () => {});
assert.ok(rows()[2].label.includes('one@example.com'));
assert.ok(rows()[3].label.includes('two@example.com'));
rows()[2].onSelect();
assert.deepEqual(Array.from(f.prefs.readCalendarSelection()), ['2']);
rows()[1].onSelect();
assert.equal(f.api.readUpcomingEvents().length, 0);
rows()[3].onSelect();
assert.deepEqual(Array.from(f.prefs.readCalendarSelection()), ['2']);
f.calendars.pop();
const missing = rows().find(row => row.label === 'Unavailable calendar #2');
assert.ok(missing);
missing.onSelect();
assert.equal(f.prefs.readCalendarSelection().length, 0);
rows()[0].onSelect();
assert.equal(f.prefs.readCalendarSelection(), null);
});
test('Android provider restricts Instances with bound calendar IDs before cutoff and limit', () => {
const kotlin = source('App_Resources/Android/src/main/java/com/faceclaw/app/FaceclawCalendarProvider.kt');
assert.match(kotlin, /Instances\.CALENDAR_ID/);
assert.match(kotlin, /if \(ids != null && ids.length\(\) == 0\) return "\[\]"/);
assert.match(kotlin, /PROJECTION,\s+selection,\s+args,/);
assert.ok(kotlin.indexOf('selection,\n args,') < kotlin.indexOf('events.take(limit)'));
assert.match(kotlin, /CalendarContract\.Calendars\._ID/);
assert.match(kotlin, /CalendarContract\.Calendars\.ACCOUNT_NAME/);
for (const file of ['app/apps/calendar/calendar.ts', 'app/apps/glanceboard/widgets/calendar-widget.ts']) {
assert.match(source(file), /readUpcomingEvents/);
assert.match(source(file), /native\/calendar"/);
}
});
+4 -2
View File
@@ -207,6 +207,8 @@ test('provider selection falls back to on-device without a key and connects the
// A running capture is shared only on the same provider and language.
assert.equal(transcriptionKey({ provider: 'soniox', language: ' JA ' }), 'soniox:ja');
assert.notEqual(transcriptionKey({ provider: 'soniox' }), transcriptionKey({ provider: 'soniox', language: 'ja' }));
assert.equal(transcriptionKey({ provider: 'onboard-whisper' }), transcriptionKey({ provider: 'onboard-whisper', language: 'en' }));
assert.notEqual(transcriptionKey({ provider: 'onboard-whisper' }), transcriptionKey({ provider: 'onboard-whisper', language: '' }));
const statuses = [];
const options = { onTranscript() {}, onStatus: status => statuses.push(status), onError() {} };
const selection = { provider: 'onboard', elevenLabsApiKey: '', openAiApiKey: ' ', sonioxApiKey: 'soniox-key' };
@@ -225,13 +227,13 @@ test('provider selection falls back to on-device without a key and connects the
});
test('a spoken-language hint reaches each provider on the wire, and is left out to auto-detect', () => {
for (const language of ['ja', '']) {
for (const language of ['fr', 'ja', '']) {
const elevenlabs = harness('elevenlabs', true, { language });
assert.equal(new URL(elevenlabs.sockets[0].url).searchParams.get('language_code'), language || null);
const soniox = harness('soniox', true, { language });
soniox.open();
assert.deepEqual(JSON.parse(soniox.sockets[0].sent[0]).language_hints, language ? ['ja'] : undefined);
assert.deepEqual(JSON.parse(soniox.sockets[0].sent[0]).language_hints, language ? [language] : undefined);
const openai = harness('openai', true, { language });
openai.open();
+69
View File
@@ -0,0 +1,69 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const { loader } = require('./helpers/load-typescript.cjs');
test('Notifications menu dismisses all, including beyond the visible list, and leaves filters untouched', () => {
let options, active = Array.from({ length: 80 }, (_, i) => ({ key: String(i) }));
let dismissals = 0, renders = 0, pops = 0;
const load = loader({}, {
'../../ui/notifications': { NotificationsListLayer: class {} },
'../../ui/notification-filter': { NotificationFilterLayer: class {} },
'../../native/notification-icons': {
ALL_NOTIFICATIONS: 0x7fffffff,
readActiveNotifications(max) { assert.equal(max, 0x7fffffff); return active; },
dismissAllNotifications() { dismissals++; active = []; return true; },
onAndroidNotificationsChanged: () => () => {},
},
'../../ui/shell/in-process-window': {
YieldAtRootLayer: class {},
createInProcessWindow(value) { options = value; return { requestRender() { renders++; } }; },
},
});
load('app/apps/notifications/notifications-app.ts').createNotificationsAppWindow({});
const items = options.menuItems();
assert.equal(items[0].label, 'Notification filter');
const action = items.find(x => x.label === 'Dismiss all notifications');
assert.equal(action.disabled(), false);
assert.equal(dismissals, 0);
action.onSelect({ stack: { pop() { pops++; } } });
assert.equal(dismissals, 1);
assert.equal(pops, 1);
assert.equal(renders, 1);
assert.equal(action.disabled(), true);
});
test('Android bulk action uses the native listener and propagates unavailable access', () => {
let calls = 0, allowed = false;
const load = loader({ global: { isAndroid: true }, com: { faceclaw: { app: {
FaceclawMediaNotificationListenerService: { dismissAllNotifications() { calls++; return allowed; } },
} } } }, {
'../graphics/image': {}, './frame-timings': {}, '../util/array-util': {},
'./notification-sources': {}, './image-files': { PHOTO_TONE: { gamma: 1 } }, './notification-types': { NOTIFICATION_ICON_SIZE: 24 },
});
const api = load('app/native/notification-icons.ts');
assert.equal(api.dismissAllNotifications(), false);
allowed = true;
assert.equal(api.dismissAllNotifications(), true);
assert.equal(calls, 2);
});
test('iOS snapshots all ANCS keys and continues when a notification cannot be dismissed', () => {
const load = loader({}, {
'../graphics/pebble-icons': {}, '../g2/ancs-client': {}, './notification-app-icons': {}, './notification-sources': {},
});
const api = load('app/native/notification-icons.ios.ts');
assert.equal(api.dismissAllNotifications(), false);
const active = Array.from({ length: 80 }, (_, i) => ({ key: String(i) })), attempted = [];
api.bindIosNotifications({
read(max) { assert.equal(max, api.ALL_NOTIFICATIONS); return active; },
dismiss(key) {
attempted.push(key);
if (key === '1') return false;
active.splice(active.findIndex(x => x.key === key), 1);
return true;
},
});
assert.equal(api.dismissAllNotifications(), false);
assert.equal(attempted.length, 80);
assert.deepEqual(active, [{ key: '1' }]);
});
+30
View File
@@ -12,6 +12,7 @@ function settingsFixture(store = new Map()) {
};
if (id.includes('brightness-curve')) return require('../.test-build/app/g2/brightness-curve.js');
if (id.includes('animation-speed')) return require('../.test-build/app/ui/animation-speed.js');
if (id.includes('transcription-language')) return require('../.test-build/app/native/transcription-language.js');
return { Layer: class {}, ASSISTANT_MODEL_CHOICES: [] };
}};
vm.runInNewContext(ts.transpileModule(fs.readFileSync('app/ui/dashboard-settings.ts', 'utf8'), {
@@ -64,3 +65,32 @@ test('Full Screen is offered only with a bottom or popup app switcher', () => {
assert.deepEqual(Array.from(api.DISPLAY_LAYOUT_VALUES, (value) => api.displayLayoutLabel(value)),
['Band · Top', 'Band · High', 'Band · Middle', 'Band · Low', 'Band · Bottom', 'Tall', 'Full Screen']);
});
test('per-app full screen defaults off, persists across restart and preserves display preferences', () => {
const store = new Map([['display.layout', 'band-low'], ['terminal.displayLayout', 'tall']]);
const prefs = settingsFixture(store);
assert.equal(prefs.appFullscreenSetting('terminal').get(), false);
prefs.appFullscreenSetting('terminal').set(true);
const restarted = settingsFixture(store);
assert.equal(restarted.appFullscreenSetting('terminal').get(), true);
assert.equal(restarted.appFullscreenSetting('other').get(), false);
restarted.appFullscreenSetting('terminal').set(false);
assert.equal(restarted.displayLayoutSetting.get(), 'band-low');
assert.equal(store.get('terminal.displayLayout'), 'tall');
});
test('keep awake persists per app independently of full screen, including existing full-screen choices', () => {
const store = new Map([['display.fullscreen.terminal', true]]);
let prefs = settingsFixture(store);
assert.equal(prefs.appFullscreenSetting('terminal').get(), true);
assert.equal(prefs.appKeepAwakeSetting('terminal').get(), false);
prefs.appKeepAwakeSetting('terminal').set(true);
prefs = settingsFixture(store);
assert.equal(prefs.appKeepAwakeSetting('terminal').get(), true);
assert.equal(prefs.appKeepAwakeSetting('other').get(), false);
prefs.appFullscreenSetting('terminal').set(false);
assert.equal(prefs.appKeepAwakeSetting('terminal').get(), true);
prefs.appKeepAwakeSetting('terminal').set(false);
prefs = settingsFixture(store);
assert.equal(prefs.appKeepAwakeSetting('terminal').get(), false);
});
+81
View File
@@ -0,0 +1,81 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const { loader } = require('./helpers/load-typescript.cjs');
const { GrayImage } = require('../.test-build/app/graphics/image.js');
function fixture() {
let options, hooks;
const paints = [], heights = [];
const session = {
manifest: { name: 'Test', packageId: 'test.app' },
renderWindowIcon() {}, contextMenuItems: () => [], keepsScreenOn: () => false,
attachWindow(value) { hooks = value; },
paint(size, focused) {
paints.push({ ...size, focused });
const image = new GrayImage(size.width, size.height);
image.setPixel(0, 0, 255);
image.setPixel(size.width - 1, size.height - 1, 120);
// Deliberately overflow a deferred text run: stock clips it at 576x288.
image.drawFwText({ bakeFwTextRun(target, run, dx, dy) {
target.fillRect(run.x + dx, run.y + dy, 20, 20, run.value);
} }, 570, 280, 200, [{}]);
return image;
},
};
const load = loader({}, {
'../../graphics/image': { GrayImage },
'./compositor': { EVENHUB_SCREEN_WIDTH: 576, EVENHUB_SCREEN_HEIGHT: 288 },
'../../ui/gestures': {}, '../../ui/shell/shell': { shell: {} }, './session': {},
'../../ui/shell/chrome-layer': { windowIcon: () => () => null, makeImageWindowIcon: () => () => null },
'./installed-apps': {},
'../../ui/shell/in-process-window': { createInProcessWindow(value) {
options = value;
return { window: {}, stack: {}, requestRender() {}, setHeightMode(mode) { heights.push(mode); } };
} },
});
load('app/apps/evenhub/evenhub-window.ts').createEvenHubWindow('test', 'test', session, {}, () => {}, () => {});
return { paints, heights, hooks: () => hooks,
paint(width, height, focused = true) {
return options.baseLayer.paint({ stack: { getBaseSize: () => ({ width, height }), isFocused: () => focused } });
},
};
}
test('stock EvenHub canvas remains 576x288 through full-screen entry, resize and exit', () => {
const f = fixture();
for (const [width, height] of [[576, 288], [640, 480], [576, 452], [640, 480], [576, 288]]) {
const image = f.paint(width, height);
assert.deepEqual(f.paints.at(-1), { width: 576, height: 288, focused: true });
assert.equal(image.width, width);
assert.equal(image.height, height);
}
});
test('full screen centers stock pixels at native scale and clips overflowing text to the stock canvas', () => {
const f = fixture();
const stock = f.paint(576, 288).withDrawsBaked();
const full = f.paint(640, 480).withDrawsBaked();
for (let y = 0; y < 480; y++) {
for (let x = 0; x < 640; x++) {
const expected = x >= 32 && x < 608 && y >= 96 && y < 384 ? stock.getPixel(x - 32, y - 96) : 0;
assert.equal(full.getPixel(x, y), expected);
}
}
});
test('only an explicit extended-layout request opts into the taller canvas', () => {
const f = fixture();
f.paint(640, 480, false);
assert.deepEqual(f.paints.at(-1), { width: 576, height: 288, focused: false });
f.hooks().setTallCanvas(true);
assert.deepEqual(f.heights, ['max']);
f.paint(576, 452);
assert.equal(f.paints.at(-1).height, 452);
f.paint(640, 480);
assert.equal(f.paints.at(-1).width, 576);
assert.equal(f.paints.at(-1).height, 480);
f.hooks().setTallCanvas(false);
f.paint(640, 480);
assert.deepEqual(f.heights, ['max', 'medium']);
assert.equal(f.paints.at(-1).height, 288);
});
+76
View File
@@ -0,0 +1,76 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const vm = require('node:vm');
const ts = require('typescript');
const source = file => fs.readFileSync(path.join(__dirname, '..', file), 'utf8');
function evaluate(code, globals) {
const context = { exports: {}, ...globals };
vm.runInNewContext(ts.transpileModule(code, {
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
}).outputText, context);
return context.exports;
}
function settings(values = new Map()) {
const file = ts.createSourceFile('settings.ts', source('app/ui/dashboard-settings.ts'), ts.ScriptTarget.Latest, true);
const names = new Set(['ConfigSetting', 'ConfigSettingBoolean', 'ConfigSettingEnum', 'HeadUpWakeSetting',
'headUpWakeSetting', 'normalizeHeadUpAngle', 'headUpAngleSetting', 'getHeadUpPreferences']);
const code = file.statements.filter(node => names.has(node.name?.text) ||
(ts.isVariableStatement(node) && node.declarationList.declarations.some(d => names.has(d.name.getText(file)))))
.map(node => node.getText(file)).join('\n');
return evaluate(code, {
fixedChoiceSettings: new Map(),
getStringSetting: (key, fallback) => values.get(key) ?? fallback,
setStringSetting: (key, value) => values.set(key, value),
});
}
test('head-up preferences preserve untouched device fields and persist each explicit choice separately', () => {
const values = new Map();
let prefs = settings(values);
assert.equal(prefs.getHeadUpPreferences().enabled, -1);
assert.equal(prefs.getHeadUpPreferences().angle, -1);
prefs.headUpWakeSetting.set(false);
prefs = settings(values);
assert.equal(prefs.headUpWakeSetting.get(), false);
assert.equal(prefs.getHeadUpPreferences().enabled, 0);
assert.equal(prefs.getHeadUpPreferences().angle, -1);
prefs.headUpAngleSetting.set('75');
prefs = settings(values);
assert.equal(prefs.headUpAngleSetting.get(), '60');
assert.equal(prefs.getHeadUpPreferences().enabled, 0);
assert.equal(prefs.getHeadUpPreferences().angle, 60);
for (const [input, expected] of [['-5', '0'], ['20.8', '21'], ['NaN', '30'], ['', '30']]) {
assert.equal(prefs.headUpAngleSetting.set(input), expected);
}
assert.equal(values.has('glanceboard.showOnHeadTilt'), false);
});
test('controller skips unset preferences, deduplicates changes and forces reconnect synchronization', async () => {
const file = ts.createSourceFile('controller.ts', source('app/g2/dashboard-controller.ts'), ts.ScriptTarget.Latest, true);
const controller = file.statements.find(node => ts.isClassDeclaration(node) && node.name.text === 'DashboardController');
const method = controller.members.find(node => node.name?.getText(file) === 'pushHeadUpPreferences').getText(file);
let prefs = { enabled: -1, angle: -1 };
const { Harness } = evaluate(`export class Harness { ${method} }`, {
global: { isAndroid: true }, getHeadUpPreferences: () => prefs,
});
const h = new Harness(), calls = [];
h.communicator = { configureHeadUpWake: async (...args) => calls.push(args) };
h.pushHeadUpPreferences(); assert.equal(calls.length, 0);
prefs = { enabled: 0, angle: 25 };
h.pushHeadUpPreferences(); h.pushHeadUpPreferences();
assert.deepEqual(calls, [[0, 25]]);
h.pushHeadUpPreferences(true); assert.equal(calls.length, 2);
prefs = { enabled: 1, angle: 40 }; h.pushHeadUpPreferences();
assert.deepEqual(calls.at(-1), [1, 40]);
let failures = 0;
h.communicator.configureHeadUpWake = async () => { throw new Error('offline'); };
h.appendLog = () => failures++;
h.formatError = error => error.message;
h.pushHeadUpPreferences(true);
await new Promise(resolve => setImmediate(resolve));
assert.equal(h.lastPushedHeadUp, null); assert.equal(failures, 1);
const connect = controller.members.find(node => node.name?.getText(file) === 'connect').getText(file);
assert.match(connect, /pushHeadUpPreferences\(true\)/);
});
+3 -1
View File
@@ -6,6 +6,7 @@ const ts = require('typescript');
const path = require('node:path');
// The provider settings ios-preview-controller hands the voice bridge.
const voiceSettings = { voiceProviderSetting: { get: () => 'onboard' }, elevenLabsApiKeySetting: { get: () => '' },
getVoiceTranscriptionLanguage: () => '',
openAiApiKeySetting: { get: () => '' }, sonioxApiKeySetting: { get: () => '' },
whisperServerUrlSetting: { get: () => '' }, whisperServerModelSetting: { get: () => '' },
whisperServerLanguageSetting: { get: () => '' }, whisperServerApiKeySetting: { get: () => '' } };
@@ -168,6 +169,7 @@ test('settings-driven repaint runs after font cache invalidation, regardless of
let cachedFont = 'Light';
const api = load('app/ui/dashboard-settings.ts', { global: { isIOS: true },
require: id => id.includes('settings-store') ? { onSettingsStoreChanged: fn => listeners.push(fn) }
: id.endsWith('/transcription-language') ? load('app/native/transcription-language.ts', {})
: { Layer: class {}, ASSISTANT_MODEL_CHOICES: [] },
setTimeout: fn => tasks.push(fn),
});
@@ -384,7 +386,7 @@ test('iOS continuous capture is shared by windows and restarts after a disconnec
recordTo: name => { bridge.recording = name; },
setRawSession: session => { bridge.rawSession = session; } };
const settings = { ...voiceSettings, voiceProviderSetting: { get: () => 'whisper-server' },
whisperServerUrlSetting: { get: () => 'http://whisper.local:8000' }, whisperServerLanguageSetting: { get: () => 'en' },
whisperServerUrlSetting: { get: () => 'http://whisper.local:8000' }, getVoiceTranscriptionLanguage: () => 'en',
saveTranscribeAudioSetting: { get: () => true } };
const { IosPreviewController } = load('app/g2/ios-preview-controller.ts', {
require: id => id === '../native/ios-voice-input' ? { iosVoiceInput: bridge } : id === '../ui/dashboard-settings' ? settings
+1
View File
@@ -199,6 +199,7 @@ test('Calendar window subscribes, refreshes periodically, and cleans up on close
'../../native/calendar': { onCalendarChanged: fn => { listener = fn; return () => unsubscribed++; } },
'../../ui/shell/chrome-layer': { makeImageWindowIcon() {}, windowIcon() {} },
'./calendar': { CalendarLayer: class {} }, './calendar-icon': {},
'./calendar-filter': { calendarSelectionMenuItems: () => [] },
'../../ui/shell/in-process-window': { YieldAtRootLayer: class {}, createInProcessWindow: value => { options = value; return app; } },
}, { setInterval: fn => { tick = fn; return 1; }, clearInterval: () => cleared++ });
createCalendarAppWindow({ onClosed: () => closed++ });
@@ -316,6 +316,33 @@ private class Session {
}
class GlassesSessionCoreTest {
@Test fun headUpWritesOnlyExplicitFieldsToBothArmsAndResendsAfterReconnect() {
val s = Session()
try {
s.startAndAwaitLayout()
fun writes() = s.link.writes.filter { it.kind == "head-up-control" }
assertEquals(0, writes().size, "untouched firmware preferences must not be written")
s.core.configureHeadUpWake(0, 30)
assertTrue(waitUntil(5_000) { writes().size == 4 })
for (arm in listOf(LEFT, RIGHT)) {
val commands = writes().filter { it.address == arm }
assertContentEquals(BleProtocol.buildSetHeadUpAngle(commands[0].magic, 30), commands[0].pb)
assertContentEquals(BleProtocol.buildSetHeadUpWake(commands[1].magic, false), commands[1].pb)
}
s.core.handleTransportFailure("head-up reconnect test")
assertTrue(waitUntil(5_000) { !s.layoutCreated() })
s.platform.offsetMs += 10_000
s.core.interruptibleSleep.interrupt()
assertTrue(waitUntil(5_000) { s.layoutCreated() && writes().size == 8 }, s.host.logs().takeLast(10).toString())
s.core.configureHeadUpWake(-1, 100)
assertTrue(waitUntil(5_000) { writes().size == 10 })
assertTrue(writes().takeLast(2).all { it.label == "head-up angle=60" })
s.core.configureHeadUpWake(1, -1)
assertTrue(waitUntil(5_000) { writes().size == 12 })
assertTrue(writes().takeLast(2).all { it.label == "head-up wake=true" })
} finally { s.core.close() }
}
@Test fun brightnessConfigPrecedesFirstFrameAndSleepWakeFollowsComposites() {
val s = Session()
s.core.configureBrightness(false, 70, 2, 100, "0:0,1000:100", 280)
@@ -0,0 +1,17 @@
package com.faceclaw.app
import kotlin.test.Test
import kotlin.test.assertContentEquals
class HeadUpProtocolTest {
private fun bytes(hex: String) = hex.chunked(2).map { it.toInt(16).toByte() }.toByteArray()
@Test fun separateSwitchAndAngleMessagesMatchReferenceWireFormat() {
// G2SettingPackage{1=1, 2=magic, 3={4=HeadUpSetting{1=switch | 2=angle}}}.
assertContentEquals(bytes("080110071a0422020800"), BleProtocol.buildSetHeadUpWake(7, false))
assertContentEquals(bytes("080110071a0422020801"), BleProtocol.buildSetHeadUpWake(7, true))
assertContentEquals(bytes("080110071a042202101e"), BleProtocol.buildSetHeadUpAngle(7, 30))
assertContentEquals(bytes("080110071a0422021000"), BleProtocol.buildSetHeadUpAngle(7, -10))
assertContentEquals(bytes("080110071a042202103c"), BleProtocol.buildSetHeadUpAngle(7, 100))
}
}
@@ -0,0 +1,35 @@
package com.faceclaw.app
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertTrue
class WhisperModelFilesTest {
@Test fun existingEnglishFilesRemainUsable() {
for (language in listOf(null, "en", " EN ")) {
val model = WhisperModelFiles.forLanguage(language)
assertTrue(model.englishOnly)
assertEquals("en", model.language)
assertEquals("sherpa-onnx-whisper-base-en-int8", model.dirName)
assertEquals(listOf("base.en-encoder.int8.onnx", "base.en-decoder.int8.onnx", "base.en-tokens.txt"), model.files)
}
}
@Test fun frenchAndOtherLanguagesUseMultilingualFiles() {
for (language in listOf("fr", "de", "ja", " FR ")) {
val model = WhisperModelFiles.forLanguage(language)
assertFalse(model.englishOnly)
assertEquals(language.trim().lowercase(), model.language)
assertEquals("sherpa-onnx-whisper-base-int8", model.dirName)
assertEquals(listOf("base-encoder.int8.onnx", "base-decoder.int8.onnx", "base-tokens.txt"), model.files)
}
}
@Test fun autoDetectionUsesMultilingualFilesWithAnEmptyLanguage() {
val model = WhisperModelFiles.forLanguage("")
assertFalse(model.englishOnly)
assertEquals("", model.language)
assertEquals(WhisperModelFiles.forLanguage("fr").files, model.files)
}
}
+63
View File
@@ -165,6 +165,7 @@ test('cancel and back dismiss the popup without changing source preferences', as
test('filter toggles persist after notifications disappear and discovers new sources while open', async () => {
const app = ui();
app.paint(app.filter);
for (let i = 0; i < 3; i++) await app.input(app.filter, 'scroll-down');
await app.input(app.filter, 'click');
assert.equal(app.prefs.shouldShowNotificationOnGlasses(mail.packageName), false);
app.active([{ packageName: 'com.alpha', appName: 'Alpha' }]);
@@ -177,6 +178,68 @@ test('filter toggles persist after notifications disappear and discovers new sou
assert.equal(app.prefs.shouldShowNotificationOnGlasses('com.alpha'), true);
});
test('default persists without overwriting explicit choices, including legacy saved sources', () => {
const settings = new Map([['notifications.sources', JSON.stringify([
{ ...mail, showOnGlasses: true },
{ packageName: 'muted', appName: 'Muted', showOnGlasses: false },
])]]);
let prefs = store(settings);
prefs.rememberNotificationSources([{ packageName: 'discovered', appName: 'Discovered' }]);
prefs.setNewNotificationAppsEnabledByDefault(false);
prefs = store(settings);
assert.equal(prefs.newNotificationAppsEnabledByDefault(), false);
assert.equal(prefs.shouldShowNotificationOnGlasses(mail.packageName), true);
assert.equal(prefs.shouldShowNotificationOnGlasses('muted'), false);
assert.equal(prefs.shouldShowNotificationOnGlasses('discovered'), false);
assert.equal(prefs.shouldShowNotificationOnGlasses('future'), false);
prefs.rememberNotificationSources([{ packageName: 'future', appName: 'Future' }]);
prefs.setNotificationSourceEnabled({ packageName: 'future', appName: 'Future' }, true);
prefs.setNewNotificationAppsEnabledByDefault(true);
prefs.setNewNotificationAppsEnabledByDefault(false);
assert.equal(store(settings).shouldShowNotificationOnGlasses('future'), true);
});
test('bulk choices persist for known sources without changing the default for future sources', () => {
const settings = new Map();
let prefs = store(settings);
prefs.rememberNotificationSources([mail]);
prefs.setAllNotificationSourcesEnabled(false);
prefs = store(settings);
assert.equal(prefs.shouldShowNotificationOnGlasses(mail.packageName), false);
assert.equal(prefs.shouldShowNotificationOnGlasses('future'), true);
prefs.setNewNotificationAppsEnabledByDefault(false);
prefs.setAllNotificationSourcesEnabled(true);
prefs = store(settings);
assert.equal(prefs.shouldShowNotificationOnGlasses(mail.packageName), true);
assert.equal(prefs.shouldShowNotificationOnGlasses('future'), false);
prefs.rememberNotificationSources([{ packageName: 'future', appName: 'Future' }]);
assert.equal(prefs.shouldShowNotificationOnGlasses('future'), false);
prefs.setAllNotificationSourcesEnabled(false);
assert.ok(prefs.readNotificationSources().every(source => !source.showOnGlasses));
});
test('filter controls work with an empty list and keep selection as sources arrive', async () => {
const app = ui();
app.active([]);
const labels = app.paint(app.filter).texts.map(({ text }) => text);
assert.ok(labels.includes('New apps enabled by default'));
assert.ok(labels.includes('Enable all'));
assert.ok(labels.includes('Disable all'));
await app.input(app.filter, 'click');
assert.equal(app.prefs.newNotificationAppsEnabledByDefault(), false);
app.active([mail]);
app.paint(app.filter);
assert.equal(app.prefs.shouldShowNotificationOnGlasses(mail.packageName), false);
await app.input(app.filter, 'scroll-down');
await app.input(app.filter, 'click');
assert.equal(app.prefs.shouldShowNotificationOnGlasses(mail.packageName), true);
assert.equal(app.prefs.newNotificationAppsEnabledByDefault(), false);
await app.input(app.filter, 'scroll-down');
await app.input(app.filter, 'click');
assert.equal(app.prefs.shouldShowNotificationOnGlasses(mail.packageName), false);
assert.equal(app.dismissals(), 0);
});
test('popup action wraps fully and stays visible with small and large fonts', async () => {
for (const size of [12, 20]) {
const app = ui(size);
+40
View File
@@ -0,0 +1,40 @@
import importlib.util
from pathlib import Path
import struct
import unittest
spec = importlib.util.spec_from_file_location("apk_pages", Path(__file__).parents[1] / "scripts/check-apk-pages.py")
checker = importlib.util.module_from_spec(spec)
spec.loader.exec_module(checker)
def elf(alignment=16384, relro_end=16384, writable_end=32768):
data = bytearray(64 + 2 * 56)
data[:6] = b"\x7fELF\x02\x01"
struct.pack_into("<Q", data, 32, 64)
struct.pack_into("<HH", data, 54, 56, 2)
struct.pack_into("<IIQQQQQQ", data, 64, 1, 6, 0, 0, 0, writable_end, writable_end, alignment)
struct.pack_into("<IIQQQQQQ", data, 120, 0x6474E552, 4, 0, 0, 0, relro_end, relro_end, 1)
return data
class AlignmentTests(unittest.TestCase):
def test_rejects_4k_loads(self):
self.assertTrue(checker.alignment_errors(elf(alignment=4096)))
def test_accepts_16k_loads_and_relro(self):
self.assertEqual([], checker.alignment_errors(elf()))
def test_rejects_relro_protecting_writable_data(self):
self.assertTrue(checker.alignment_errors(elf(relro_end=4096)))
def test_accepts_relro_at_end_of_writable_load(self):
self.assertEqual([], checker.alignment_errors(elf(relro_end=4096, writable_end=4096)))
def test_rejects_invalid_headers(self):
self.assertTrue(checker.alignment_errors(b"not ELF"))
self.assertTrue(checker.alignment_errors(elf()[:70]))
if __name__ == "__main__":
unittest.main()
+1
View File
@@ -28,6 +28,7 @@
"../app/ui/menu-core.ts",
"../app/phone-ui/phone-gestures.ts",
"../app/native/java-direct-buffer.ts",
"../app/native/transcription-language.ts",
"../app/native/notification-types.ts",
"../app/g2/firmware-compat.ts",
"../app/g2/glasses-hardware-identity.ts",
+24 -2
View File
@@ -163,7 +163,8 @@ function androidBridge() {
starts: 0,
setListener(listener) { this.listener = listener; },
setCommunicator() {}, setUsePhoneMic() {}, setSaveRecordings() {}, setEndpointing() {},
setNoiseSuppression() {}, setBeamFilter() {}, clearSpeakerVerification() {}, setOnboardModelKind() {},
setNoiseSuppression() {}, setBeamFilter() {}, clearSpeakerVerification() {},
setOnboardModelKind(kind) { this.modelKind = kind; }, setOnboardLanguage(language) { this.language = language; },
start(_mode, id) { this.captureId = id; this.active = true; this.starts++; },
stop() { this.active = false; },
isCapturing() { return this.active; },
@@ -171,7 +172,8 @@ function androidBridge() {
const { FaceclawVoiceControlBridge } = load('app/native/voice-control.ts', {
'@nativescript/core': { Utils: { android: { getApplicationContext: () => ({}) } } },
'./speech-pause': { SpeechPauseDetector: class { reset() {} } },
'./cloud-stt-provider': { createCloudSttClient: () => null, transcriptionKey: options => options.provider },
'./cloud-stt-provider': { createCloudSttClient: () => null,
transcriptionKey: options => `${options.provider}:${options.language ?? (options.provider === 'onboard-whisper' ? 'en' : '')}` },
}, { global: { isAndroid: true }, com: { faceclaw: { app: {
FaceclawVoiceController: function () { return controller; },
FaceclawVoiceControllerListener: function (listener) { return listener; },
@@ -179,6 +181,26 @@ function androidBridge() {
return { bridge: new FaceclawVoiceControlBridge(), controller };
}
test('local Whisper receives French and restarts for auto or English, sharing an unchanged language', () => {
const { bridge, controller } = androidBridge();
bridge.startContinuousCapture({ provider: 'onboard-whisper', language: 'fr' });
assert.equal(controller.modelKind, 'whisper');
assert.equal(controller.language, 'fr');
bridge.startPushToTalk({ provider: 'onboard-whisper', language: 'fr' });
assert.equal(controller.starts, 1);
bridge.retargetContinuousCapture({ provider: 'onboard-whisper', language: '' });
assert.equal(controller.language, '');
assert.equal(controller.starts, 2);
bridge.retargetContinuousCapture({ provider: 'onboard-whisper' });
// An omitted language preserves the native bridge's original English behavior.
assert.equal(controller.language, 'en');
assert.equal(controller.starts, 3);
bridge.retargetContinuousCapture({ provider: 'onboard-whisper', language: 'en' });
assert.equal(controller.language, 'en');
assert.equal(controller.starts, 3);
bridge.stop();
});
test('native completion is capture-specific, follows the final, and does not wait for shared capture', async () => {
const { bridge, controller } = androidBridge();
const options = { provider: 'onboard-whisper' };
+131
View File
@@ -0,0 +1,131 @@
const test = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const vm = require('node:vm');
const ts = require('typescript');
function load(file, requireModule = () => ({}), globals = {}) {
const exports = {};
vm.runInNewContext(ts.transpileModule(fs.readFileSync(path.join(__dirname, '..', file), 'utf8'), {
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
}).outputText, { exports, require: requireModule, console, global: { isAndroid: true }, ...globals });
return exports;
}
const languages = load('app/native/transcription-language.ts');
function settings(values = new Map()) {
return load('app/ui/dashboard-settings.ts', name => name.endsWith('/transcription-language') ? languages
: name.includes('settings-store') ? {
getStringSetting: (key, fallback) => values.get(key) ?? fallback,
setStringSetting: (key, value) => values.set(key, value),
getBooleanSetting: (_key, fallback) => fallback,
onSettingsStoreChanged() {},
} : { Layer: class {}, ASSISTANT_MODEL_CHOICES: [] });
}
test('language defaults preserve local English, cloud detection and an existing server preference', () => {
const values = new Map([['voice.whisperServerLanguage', 'sk']]);
const s = settings(values);
assert.equal(s.voiceLanguageSetting.get(), 'default');
assert.equal(s.getVoiceTranscriptionLanguage('onboard-whisper'), 'en');
assert.equal(s.getVoiceTranscriptionLanguage('whisper'), '');
assert.equal(s.getVoiceTranscriptionLanguage('whisper-server'), 'sk');
assert.deepEqual([...values], [['voice.whisperServerLanguage', 'sk']]);
});
test('French and auto-detection persist across restart without overwriting server exceptions', () => {
const values = new Map([['voice.whisperServerLanguage', 'sk']]);
let s = settings(values);
s.voiceLanguageSetting.set('fr');
s = settings(values);
assert.equal(s.voiceLanguageSetting.displayValue(), 'French');
for (const provider of ['whisper', 'onboard-whisper', 'whisper-server', 'elevenlabs', 'soniox']) {
assert.equal(s.getVoiceTranscriptionLanguage(provider), 'fr');
}
assert.equal(s.getVoiceTranscriptionLanguage('onboard'), '');
s.voiceLanguageSetting.set('auto');
s = settings(values);
assert.equal(s.getVoiceTranscriptionLanguage('onboard-whisper'), '');
assert.equal(s.getVoiceTranscriptionLanguage('whisper'), '');
s.voiceLanguageSetting.set('default');
assert.equal(s.getVoiceTranscriptionLanguage('whisper-server'), 'sk');
assert.equal(s.getVoiceTranscriptionLanguage('onboard-whisper'), 'en');
});
test('corrupt language preferences revert to the compatible provider defaults', () => {
const s = settings(new Map([['voice.language', 'invalid']]));
assert.equal(s.getVoiceTranscriptionLanguage('onboard-whisper'), 'en');
assert.equal(s.getVoiceTranscriptionLanguage('whisper'), '');
});
test('Android and iOS capture options use the shared language and preserve Translate overrides', () => {
const s = settings();
s.voiceLanguageSetting.set('fr');
s.voiceProviderSetting.set('whisper');
for (const [file, name, method] of [
['app/g2/dashboard-controller.ts', 'DashboardController', 'voiceCaptureOptions'],
['app/g2/ios-preview-controller.ts', 'IosPreviewController', 'voiceProvider'],
]) {
const host = { continuousClients: new Map() };
host.transcriptionChoice = () => [...host.continuousClients.values()].find(x => x.transcription)?.transcription;
// Run each real capture-options method with only its native dependencies stubbed.
const source = fs.readFileSync(path.join(__dirname, '..', file), 'utf8');
const tree = ts.createSourceFile(file, source, ts.ScriptTarget.Latest, true);
const declaration = tree.statements.find(n => ts.isClassDeclaration(n) && n.name.text === name);
const member = declaration.members.find(n => n.name?.getText(tree) === method);
const capture = loadBody(member.body.getText(tree), s, host);
assert.equal(capture().language, 'fr');
host.continuousClients.set('translate', { transcription: { provider: 'soniox', language: 'ja' } });
assert.equal(capture().provider, 'soniox');
assert.equal(capture().language, 'ja');
host.continuousClients.clear();
assert.equal(capture().language, 'fr');
}
});
function loadBody(body, s, host) {
const globals = { ...s, wearerVerificationOptions: () => null, micSession: { captureProcessingOptions: () => ({}) } };
return vm.runInNewContext(`(function(communicator) ${body})`, globals).bind(host, null);
}
test('multilingual downloads and deletion leave an existing English model intact', () => {
const files = new Map(), downloads = [];
const asr = load('app/native/asr-model.ts', () => ({
Utils: { android: { getApplicationContext: () => ({ getFilesDir: () => ({ getAbsolutePath: () => '/files' }) }) } },
}), {
java: { io: { File: class {
constructor(name) { this.name = name; }
exists() { return files.has(this.name); }
length() { return files.get(this.name) ?? 0; }
delete() { return files.delete(this.name); }
} } },
com: { faceclaw: { app: {
FaceclawModelDownloaderListener: function(listener) { return listener; },
FaceclawModelDownloader: class {
constructor(url, destination, hash, size, listener) {
Object.assign(this, { url, destination, hash, size, listener }); downloads.push(this);
}
start() {}
cancel() {}
},
} } },
});
const english = asr.ASR_MODELS['whisper-base-en'];
for (const file of english.files) files.set(`/files/faceclaw-voice-asr/${english.dirName}/${file.name}`, file.sizeBytes);
assert.equal(asr.isAsrModelReady('whisper-base-en'), true);
assert.equal(asr.isAsrModelReady('whisper-base'), false);
asr.startAsrModelDownload('whisper-base');
assert.equal(asr.asrModelState('whisper-base').status, 'downloading');
for (let index = 0; index < 3; index++) {
const download = downloads[index];
assert.match(download.url, /sherpa-onnx-whisper-base\/resolve\/[a-f0-9]{40}\/base-/);
assert.match(download.hash, /^[a-f0-9]{64}$/);
files.set(download.destination, download.size);
download.listener.onDone();
}
assert.equal(downloads.length, 3);
assert.equal(asr.isAsrModelReady('whisper-base'), true);
asr.deleteAsrModel('whisper-base');
assert.equal(asr.isAsrModelReady('whisper-base'), false);
assert.equal(asr.isAsrModelReady('whisper-base-en'), true);
});