Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,37 @@
android:label="Edge"
android:name=".EdgeApplication"
android:icon="@mipmap/launcher_icon">
<!-- ── ZERO-COLLECTION BY DEFAULT (privacy tier 1) ──
Every Firebase SDK auto-starts collecting the moment the app
process does: Analytics logs first_open/session_start, Performance
opens app-start + network traces, Crashlytics uploads any startup
crash. All of that happens BEFORE Dart has read the user's stored
telemetry consent (an async SharedPreferences load off the startup
critical path), so relying on the runtime setters alone meant a
fresh install collected before consent existed.

These three flags turn the SDKs' auto-collection OFF at process
start. They are the "enabled" (not "deactivated") variants, so
TelemetryService can still switch collection ON at runtime once —
and only once — affirmative consent has been loaded. Do NOT flip
any of these to true: consent is the only thing allowed to. -->
<meta-data
android:name="firebase_analytics_collection_enabled"
android:value="false" />
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="false" />
<meta-data
android:name="firebase_performance_collection_enabled"
android:value="false" />
<!-- No ad/measurement signals, ever — nothing here is consent-gated
back on. -->
<meta-data
android:name="google_analytics_default_allow_ad_personalization_signals"
android:value="false" />
<meta-data
android:name="google_analytics_adid_collection_enabled"
android:value="false" />
<activity
android:name=".MainActivity"
android:exported="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ class OpenStrapWidgetProvider : HomeWidgetProvider() {
val readiness = w.readInt(prefs, "readiness", -1)
val strain = w.readDouble(prefs, "strain", -1.0)
val sleepMin = w.readInt(prefs, "sleep_min", -1)
val needMin = w.readInt(prefs, "sleep_need_min", 480)
// -1 = none. The Dart writer uses the same sentinel; the ring below
// already gates on needMin > 0, so an unknown need leaves it empty
// instead of filling against a fabricated 8h denominator.
val needMin = w.readInt(prefs, "sleep_need_min", -1)
val hrv = w.readInt(prefs, "hrv", -1)
val hrvBaseline = w.readInt(prefs, "hrv_baseline", -1)

Expand Down
6 changes: 3 additions & 3 deletions ios/OpenStrapWatch Watch App/WatchMetrics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct WatchMetrics {
var readiness: Int // 0–100, -1 = none
var strain: Double // 0–21, -1 = none
var sleepMin: Int // minutes asleep, -1 = none
var needMin: Int // sleep need (min)
var needMin: Int // sleep need (min); -1 = none — never fabricate 8h
var hrv: Int // RMSSD ms, -1 = none
var hrvBaseline: Int // baseline RMSSD ms, -1 = none
var rhr: Int // bpm, -1 = none
Expand All @@ -29,7 +29,7 @@ struct WatchMetrics {
var themeDark: Bool // mirror the app's Ember-on-Paper (false) / Char (true)

static let empty = WatchMetrics(
hasData: false, readiness: -1, strain: -1, sleepMin: -1, needMin: 480,
hasData: false, readiness: -1, strain: -1, sleepMin: -1, needMin: -1,
hrv: -1, hrvBaseline: -1, rhr: -1, coachLine: "", battPct: -1, updatedAt: 0,
themeDark: true)

Expand All @@ -40,7 +40,7 @@ struct WatchMetrics {
readiness: d?.object(forKey: "readiness") as? Int ?? -1,
strain: d?.object(forKey: "strain") as? Double ?? -1,
sleepMin: d?.object(forKey: "sleep_min") as? Int ?? -1,
needMin: d?.object(forKey: "sleep_need_min") as? Int ?? 480,
needMin: d?.object(forKey: "sleep_need_min") as? Int ?? -1,
hrv: d?.object(forKey: "hrv") as? Int ?? -1,
hrvBaseline: d?.object(forKey: "hrv_baseline") as? Int ?? -1,
rhr: d?.object(forKey: "rhr") as? Int ?? -1,
Expand Down
6 changes: 3 additions & 3 deletions ios/OpenStrapWidget/OpenStrapWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct OpenStrapEntry: TimelineEntry {
let readiness: Int // -1 = none (composite 0..100) — the headline
let strain: Double // -1 = none
let sleepMin: Int // -1 = none
let needMin: Int
let needMin: Int // -1 = none (sleep need, min) — never fabricate 8h
let hrv: Int // -1 = none (RMSSD, ms)
let hrvBaseline: Int // -1 = none (personal RMSSD baseline, ms)
let rhr: Int // -1 = none
Expand Down Expand Up @@ -106,7 +106,7 @@ private enum Store {
readiness: d?.object(forKey: "readiness") as? Int ?? -1,
strain: d?.object(forKey: "strain") as? Double ?? -1,
sleepMin: d?.object(forKey: "sleep_min") as? Int ?? -1,
needMin: (d?.object(forKey: "sleep_need_min") as? Int) ?? 480,
needMin: (d?.object(forKey: "sleep_need_min") as? Int) ?? -1,
hrv: d?.object(forKey: "hrv") as? Int ?? -1,
hrvBaseline: d?.object(forKey: "hrv_baseline") as? Int ?? -1,
rhr: d?.object(forKey: "rhr") as? Int ?? -1,
Expand Down Expand Up @@ -171,7 +171,7 @@ private enum TodayAPI {
let strain = val(daily, "strain") ?? -1
let rhr = val(daily, "resting_hr").map { Int($0.rounded()) } ?? -1
let sleepMin = val(sleep, "duration_min").map { Int($0.rounded()) } ?? -1
let needMin = val(sleep, "need_min").map { Int($0.rounded()) } ?? 480
let needMin = val(sleep, "need_min").map { Int($0.rounded()) } ?? -1
let hrv = (hrvObj?["rmssd"] as? NSNumber).map { Int($0.doubleValue.rounded()) } ?? -1
let hrvBase = (hrvObj?["baseline"] as? NSNumber).map { Int($0.doubleValue.rounded()) } ?? -1

Expand Down
25 changes: 25 additions & 0 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,31 @@
<dict>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<!-- ── ZERO-COLLECTION BY DEFAULT (privacy tier 1) ──
Every Firebase SDK auto-starts collecting the moment
Firebase.initializeApp runs: Analytics logs first_open/session_start,
Performance opens app-start + network traces, Crashlytics uploads any
startup crash. That is long before Dart has read the user's stored
telemetry consent (an async SharedPreferences load off the startup
critical path), so the runtime setters alone meant a fresh install
collected before consent existed.

These are the "Enabled = false" variants (NOT the permanent
...Deactivated ones), so TelemetryService can still switch collection
ON at runtime once — and only once — affirmative consent has loaded.
Do NOT flip any of these to true: consent is the only thing allowed
to. Keep in sync with android/app/src/main/AndroidManifest.xml. -->
<key>FIREBASE_ANALYTICS_COLLECTION_ENABLED</key>
<false/>
<key>FirebaseCrashlyticsCollectionEnabled</key>
<false/>
<key>firebase_performance_collection_enabled</key>
<false/>
<!-- No ad/measurement signals, ever — never consent-gated back on. -->
<key>GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_PERSONALIZATION_SIGNALS</key>
<false/>
<key>GOOGLE_ANALYTICS_IDFV_COLLECTION_ENABLED</key>
<false/>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
Expand Down
7 changes: 7 additions & 0 deletions lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:provider/provider.dart';

import 'ai/briefing.dart';
import 'coach/coach_config.dart';
import 'notify/notification_service.dart';
import 'notify/tap_router.dart';
import 'state/app_state.dart';
import 'state/prefs.dart';
Expand Down Expand Up @@ -67,6 +68,12 @@ class _OpenStrapAppState extends State<OpenStrapApp> with WidgetsBindingObserver
void didChangeAppLifecycleState(AppLifecycleState state) {
final app = context.read<AppState>();
if (state == AppLifecycleState.resumed) {
// The user may have flipped our notification switch either way in OS
// Settings while we were backgrounded. Drop the cached authorization
// decision so the next present/schedule re-reads reality — a denial used
// to latch for the whole process, silencing every notification and
// scheduled reminder until a full app restart.
NotificationService.instance.invalidatePermissionCache();
app.maybeFinishFromLiveActivity();
unawaited(app.maybeStopBreathingFromLiveActivity());
app.refreshAppStatus(); // re-check OTA + admin banner on every foreground
Expand Down
Loading
Loading