forked from Blendman974/faceclaw
Add stats collection and first-run on-glasses onboarding app
This commit is contained in:
1 parent
84baee9c76
commit
406cefe0c5
73 files changed
+3906
-98
No files matched your search
@@ -45,10 +45,10 @@ const MIRROR_TOUCH_GESTURES: Record<Exclude<MirrorTouchKind, "tap">, WearRemoteI
|
||||
"swipe-left": "swipe-left",
|
||||
"swipe-right": "swipe-right",
|
||||
};
|
||||
import { findSoundEffect, playSoundEffect } from "../ui/sound-effects";
|
||||
import { GlanceHost } from "./glance-host";
|
||||
import { type GlanceEvent } from "./glance-state";
|
||||
import { isPreviewOnlyMode, isWelcomeSoundPending, setWelcomeSoundPending } from "../phone-ui/onboarding-state";
|
||||
import { isPreviewOnlyMode } from "../phone-ui/onboarding-state";
|
||||
import { claimGlassesOnboardingAutoLaunch, ONBOARDING_APP_ID } from "../apps/onboarding/onboarding-progress";
|
||||
import { beginRenderPass, endRenderPass } from "../util/render-freshness";
|
||||
import { voiceControlBridge } from "../native/voice-control";
|
||||
import { G2_LENS_HEIGHT, G2_LENS_WIDTH, GrayImage } from "../graphics/image";
|
||||
@@ -278,9 +278,6 @@ class DashboardController {
|
||||
// drop-off right after a low reading can be explained as a flat battery.
|
||||
private lastHeadsetBattery: number | null = null;
|
||||
private readonly listeners = new Set<DashboardListener>();
|
||||
// Set at connect time from the persisted flag; the one-time post-onboarding
|
||||
// welcome sound plays on the first rendered frame (proof the session is warm).
|
||||
private welcomeSoundArmed = false;
|
||||
|
||||
private communicator: FaceclawCommunicatorBridge | null = null;
|
||||
// Headless stand-in for the compositor when no glasses are paired
|
||||
@@ -1413,7 +1410,6 @@ class DashboardController {
|
||||
this.teardownPreviewDisplay();
|
||||
this.lastInput = "waiting...";
|
||||
this.lastSys = "none yet";
|
||||
this.welcomeSoundArmed = isWelcomeSoundPending();
|
||||
this.firmwareWarningMessage = "";
|
||||
this.glassesWorn = null;
|
||||
this.wakeAfterChargingReconnect = false;
|
||||
@@ -1580,11 +1576,12 @@ class DashboardController {
|
||||
// parked by the previous session (or by an EvenHub suspend) resumes.
|
||||
this.resumeVoiceCapture();
|
||||
// A rendered frame means the session is warmed up (fixedLayoutCreated),
|
||||
// so the buzzer won't be dropped. Play the one-time welcome sound now.
|
||||
if (this.welcomeSoundArmed) {
|
||||
this.welcomeSoundArmed = false;
|
||||
setWelcomeSoundPending(false);
|
||||
void this.playWelcomeSound();
|
||||
// so the onboarding's welcome jingle won't be dropped. Open the
|
||||
// on-glasses onboarding if this version hasn't been through it.
|
||||
if (claimGlassesOnboardingAutoLaunch()) {
|
||||
this.launchApp(ONBOARDING_APP_ID).catch((error) => {
|
||||
this.appendLog(`onboarding launch failed: ${this.formatError(error)}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -2741,21 +2738,6 @@ class DashboardController {
|
||||
await this.communicator.playBuzzerSequence(payload);
|
||||
}
|
||||
|
||||
/** One-time celebratory jingle on the first connection after onboarding. */
|
||||
private async playWelcomeSound(): Promise<void> {
|
||||
const effect = findSoundEffect("questcomplete");
|
||||
if (!effect) return;
|
||||
try {
|
||||
await playSoundEffect(
|
||||
effect,
|
||||
(payload) => this.playBuzzerSequence(payload),
|
||||
(ms) => new Promise((resolve) => setTimeout(resolve, ms)),
|
||||
);
|
||||
} catch (error) {
|
||||
this.appendLog(`welcome sound failed: ${this.formatError(error)}`);
|
||||
}
|
||||
}
|
||||
|
||||
private clearDashboardTimer(): void {
|
||||
this.cancelEvenHubSuspendTimer();
|
||||
if (this.shellRefreshTimer) {
|
||||
|
||||
@@ -48,8 +48,7 @@ import { DISPLAY_MODE_VALUES, displayModeLabel, displayModeSetting, onAnySetting
|
||||
previewColorSetting, lockScreenEnabledSetting, getBrightnessPreferences, getStringSettingById,
|
||||
nightscoutSiteUrlSetting, nightscoutApiTokenSetting } from '../ui/dashboard-settings'
|
||||
import type { PhoneGesture } from '../phone-ui/phone-gestures'
|
||||
import { isWelcomeSoundPending, setWelcomeSoundPending } from '../phone-ui/onboarding-state'
|
||||
import { findSoundEffect, playSoundEffect } from '../ui/sound-effects'
|
||||
import { claimGlassesOnboardingAutoLaunch, ONBOARDING_APP_ID } from '../apps/onboarding/onboarding-progress'
|
||||
|
||||
const SHELL_SURFACE_ID = 'shell'
|
||||
const SHELL_SURFACE_Z_ORDER = 1
|
||||
@@ -681,7 +680,7 @@ export class IosPreviewController {
|
||||
private emitState(): void {
|
||||
if (this.state.phase !== 'connected') resetRingInputFilter()
|
||||
this.pushBrightness()
|
||||
this.maybePlayWelcomeSound(this.state)
|
||||
this.maybeLaunchOnboarding(this.state)
|
||||
if (this.state.phase !== 'connected' && this.state.phase !== 'connecting') this.glassesWorn = null
|
||||
if (this.state.phase !== 'connected') iosVoiceInput.handleSessionEnded()
|
||||
shell.setBatteryLevels({ headset: this.state.battery, headsetCharging: this.state.charging })
|
||||
@@ -770,7 +769,7 @@ export class IosPreviewController {
|
||||
if (this.communicator !== communicator) return
|
||||
this.state = { ...this.state, frames: this.state.frames + 1 }
|
||||
this.onActivity()
|
||||
this.maybePlayWelcomeSound(this.state)
|
||||
this.maybeLaunchOnboarding(this.state)
|
||||
if (this.active) this.onConnectionState({ ...this.state })
|
||||
this.schedulePreviewUpdate()
|
||||
}),
|
||||
@@ -878,16 +877,13 @@ export class IosPreviewController {
|
||||
this.glance.reset()
|
||||
await communicator.close().catch(error => this.logBluetooth(`Close: ${String(error)}`))
|
||||
}
|
||||
private maybePlayWelcomeSound(state: SessionState): void {
|
||||
private maybeLaunchOnboarding(state: SessionState): void {
|
||||
const firstNewFrame = state.frames > this.acknowledgedFrames
|
||||
this.acknowledgedFrames = state.frames
|
||||
// Match Android: wait for an acknowledged frame before consuming the jingle.
|
||||
if (!firstNewFrame || state.phase !== 'connected' || !isWelcomeSoundPending()) return
|
||||
setWelcomeSoundPending(false)
|
||||
const effect = findSoundEffect('questcomplete')
|
||||
if (effect) void playSoundEffect(effect, payload => this.actions.playBuzzerSequence(payload),
|
||||
ms => new Promise(resolve => setTimeout(resolve, ms)))
|
||||
.catch(error => this.logBluetooth(`Welcome sound failed: ${error}`))
|
||||
// Match Android: wait for an acknowledged frame (a warm session, so the
|
||||
// onboarding's welcome jingle isn't dropped) before opening it.
|
||||
if (!firstNewFrame || state.phase !== 'connected' || !claimGlassesOnboardingAutoLaunch()) return
|
||||
void this.launchApp(ONBOARDING_APP_ID)
|
||||
}
|
||||
startVoiceInput(): void { if (!this.glassesLocked) shell.startVoiceInput() }
|
||||
private async prepareVoiceCapture(): Promise<boolean> {
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
* Transport is app/native/wear-bridge.ts (Java FaceclawWearBridge); the
|
||||
* message shapes are documented in wear/PROTOCOL.md.
|
||||
*/
|
||||
import { flagAnalyticsEvent } from "../analytics/analytics";
|
||||
import { type AppDefinition } from "../apps/app-definition";
|
||||
import { getInstalledEvenHubApps, installedEvenHubAppId } from "../apps/evenhub/installed-apps";
|
||||
import { WEAR_PATHS, wearBridge, type WearMessage } from "../native/wear-bridge";
|
||||
@@ -167,6 +168,7 @@ export class WearRemote {
|
||||
// with it (no placeholder).
|
||||
if (changed) this.watchBatteryPollsUnanswered = 0;
|
||||
if (connection.reachable) {
|
||||
flagAnalyticsEvent("minimal", "device.wear.reachable");
|
||||
this.publishNow(true);
|
||||
this.pollWatchBattery(true);
|
||||
} else if (changed) {
|
||||
@@ -326,6 +328,7 @@ export class WearRemote {
|
||||
return;
|
||||
}
|
||||
|
||||
flagAnalyticsEvent("minimal", "device.wear.used");
|
||||
switch (message.path) {
|
||||
case WEAR_PATHS.input:
|
||||
await this.handleInput(message.payload, ack);
|
||||
|
||||
Reference in new issue
Block a user