maps: gate google enrichment and street view behind opt-in
- Commit
493f6530074fe856b188918573b925b9140f6623- Author
- vayun-mathur <[email protected]>
- When
- 2026-10-23 21:00 UTC (1 month ago)
- Parents
0df91c9
Diff
SUPPLY_CHAIN_RISKS.md
diff --git a/SUPPLY_CHAIN_RISKS.md b/SUPPLY_CHAIN_RISKS.mdindex a80c97b25f..726c404248 100644--- a/SUPPLY_CHAIN_RISKS.md+++ b/SUPPLY_CHAIN_RISKS.md@@ -4,13 +4,13 @@ Apps that fetch from external servers (excluding vayunmathur.com, findfamily.cc, ## Mandatory — connects during normal use, no per-service opt-in -1. **maps** — `www.google.com` (search, ambient POI pins, place enrichment with rating/hours/photos), `maps.googleapis.com` + `streetviewpixels-pa.googleapis.com` (Street View lookup + tiles), `maps.google.com` (reviews scraper). Fires on search, map pan (pins), place select, Street View use. No master toggle; traffic overlay itself is on-device (prefetch goes to the native router, not `GoogleTrafficSource.tile`, which has no live caller).-2. **taxi** — `api.lyft.com`, `cn-geo1.uber.com` + `m.uber.com`, `api.stripe.com`, `payments.braintree-api.com`-3. **fooddelivery** — `api.deliverycollective.com`-4. **youpipe** — `youtube.com` family + `*.googlevideo.com` + `youtubei.googleapis.com` + `yt3.ggpht.com` + `suggestqueries.google.com`, `api.pipepipe.dev` (decoder/player + PO tokens), `jnn-pa.googleapis.com` (BotGuard attestation), `vimeo.com`+1. **taxi** — `api.lyft.com`, `cn-geo1.uber.com` + `m.uber.com`, `api.stripe.com`, `payments.braintree-api.com`+2. **fooddelivery** — `api.deliverycollective.com`+3. **youpipe** — `youtube.com` family + `*.googlevideo.com` + `youtubei.googleapis.com` + `yt3.ggpht.com` + `suggestqueries.google.com`, `api.pipepipe.dev` (decoder/player + PO tokens), `jnn-pa.googleapis.com` (BotGuard attestation), `vimeo.com` ## Optional — no fetch until the user enables or configures the service +4. **maps** — `www.google.com` (place enrichment + reviews scraper), `maps.googleapis.com` + `streetviewpixels-pa.googleapis.com` (Street View). Search and ambient pins are OSM-only. All Google paths gated behind one services toggle: OFF by default with a first-launch consent dialog — zero Google traffic until opt-in. 5. **appstore** — only MODERN_APPS + PROPRIETARY on by default; FDROID (`f-droid.org/repo`, `verification.f-droid.org`), PLAYSTORE (`auroraoss.com`, Play backend), ACCRESCENT (`repo.accrescent.app`, `appstore-api.accrescent.app`) are opt-in via Sources settings 6. **communicate** — only after registering a line: `chat.signal.org` (WS + REST), `cdsi.signal.org`, `cdn.signal.org` / `cdn*.signal.org` + `storage.signal.org`, `sfu.voip.signal.org`, `signalcaptchas.org`; `clients6.google.com`, `voice.google.com`; `g.whatsapp.net`, `v.whatsapp.net`, `graph.whatsapp.com`, `mmg.whatsapp.net` 7. **email** — only after adding an account: `imap.gmail.com` / `smtp.gmail.com`, `outlook.office365.com` / `smtp-mail.outlook.com`, `imap.mail.yahoo.com` / `smtp.mail.yahoo.com`, `imap.aol.com` / `smtp.aol.com`, `imap.mail.me.com` / `smtp.mail.me.com`, `imap.fastmail.com` / `smtp.fastmail.com`, `login.microsoftonline.com` + `outlook.office.com` (OAuth)
maps/src/main/java/com/vayunmathur/maps/data/MapPreferences.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/data/MapPreferences.kt b/maps/src/main/java/com/vayunmathur/maps/data/MapPreferences.ktindex f6ce484c86..3a1bfec987 100644--- a/maps/src/main/java/com/vayunmathur/maps/data/MapPreferences.kt+++ b/maps/src/main/java/com/vayunmathur/maps/data/MapPreferences.kt@@ -21,6 +21,16 @@ object MapPreferences { const val KEY_LAYER_SAFETY = "layer_safety" const val KEY_LAYER_TRANSIT = "layer_transit" + /**+ * Google services (place enrichment + reviews + Street View). OFF by+ * default: nothing contacts Google until the user opts in, via the+ * first-launch consent dialog or the settings toggle. A null (never+ * asked) value is treated as off — the dialog, not the default, decides.+ */+ const val KEY_GOOGLE_SERVICES = "google_services_enabled"+ /** Whether the first-launch Google consent dialog has been answered. */+ const val KEY_GOOGLE_CONSENT_ASKED = "google_consent_asked"+ /** * Last known user position (lon/lat doubles). Written on every accepted GPS * fix and read back to seed the cold-start camera, so the map opens where@@ -35,6 +45,7 @@ object MapPreferences { const val DEFAULT_LAYER_SATELLITE = false const val DEFAULT_LAYER_SAFETY = false const val DEFAULT_LAYER_TRANSIT = false+ const val DEFAULT_GOOGLE_SERVICES = false } /** App theme selection persisted under [MapPreferences.KEY_THEME_MODE]. */
maps/src/main/java/com/vayunmathur/maps/ui/GoogleConsentDialog.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/GoogleConsentDialog.kt b/maps/src/main/java/com/vayunmathur/maps/ui/GoogleConsentDialog.ktnew file mode 100644index 0000000000..3a6a067cb4--- /dev/null+++ b/maps/src/main/java/com/vayunmathur/maps/ui/GoogleConsentDialog.kt@@ -0,0 +1,68 @@+package com.vayunmathur.maps.ui++import androidx.compose.runtime.Composable+import androidx.compose.runtime.getValue+import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember+import androidx.compose.runtime.setValue+import androidx.compose.ui.res.stringResource+import com.vayunmathur.library.ui.ConfirmDialog+import com.vayunmathur.library.util.DataStoreUtils+import com.vayunmathur.maps.R+import com.vayunmathur.maps.data.MapPreferences+import com.vayunmathur.maps.util.MapSettingsViewModel+import kotlinx.coroutines.CoroutineScope+import kotlinx.coroutines.Dispatchers+import kotlinx.coroutines.launch++/**+ * First-launch Google services consent.+ *+ * Shown once, on the first map open: enabling turns on place enrichment+ * (ratings/hours/photos), reviews, and Street View — all of which contact+ * Google. Disabled (the default) means zero Google traffic: search, pins,+ * routing, traffic, and transit stay fully offline/first-party.+ *+ * Either answer records [MapPreferences.KEY_GOOGLE_CONSENT_ASKED] so the+ * dialog never returns; the choice stays changeable in Settings.+ */+@Composable+fun GoogleConsentDialog(settingsViewModel: MapSettingsViewModel, onDone: () -> Unit) {+ var visible by remember { mutableStateOf(true) }+ if (!visible) return+ ConfirmDialog(+ title = stringResource(R.string.google_consent_title),+ message = stringResource(R.string.google_consent_message),+ confirmLabel = stringResource(R.string.google_consent_enable),+ dismissLabel = stringResource(R.string.google_consent_disable),+ onConfirm = {+ settingsViewModel.setGoogleServices(true)+ visible = false+ onDone()+ },+ onDismiss = {+ settingsViewModel.setGoogleServices(false)+ visible = false+ onDone()+ },+ )+}++/** True when the first-launch consent dialog still needs to be shown. */+fun shouldShowGoogleConsent(ds: DataStoreUtils): Boolean =+ !ds.getBoolean(MapPreferences.KEY_GOOGLE_CONSENT_ASKED, false)++/** Synchronous gate for non-composable call sites: defaults to off. */+fun googleServicesEnabled(ds: DataStoreUtils): Boolean =+ ds.getBoolean(+ MapPreferences.KEY_GOOGLE_SERVICES,+ MapPreferences.DEFAULT_GOOGLE_SERVICES,+ )++/** Record an explicit choice without going through the ViewModel (tests, previews). */+fun recordGoogleConsent(ds: DataStoreUtils, enabled: Boolean) {+ CoroutineScope(Dispatchers.IO).launch {+ ds.setBoolean(MapPreferences.KEY_GOOGLE_SERVICES, enabled)+ ds.setBoolean(MapPreferences.KEY_GOOGLE_CONSENT_ASKED, true)+ }+}
maps/src/main/java/com/vayunmathur/maps/ui/MapContentBox.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/MapContentBox.kt b/maps/src/main/java/com/vayunmathur/maps/ui/MapContentBox.ktindex b0cb95a8ae..08cd604a45 100644--- a/maps/src/main/java/com/vayunmathur/maps/ui/MapContentBox.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/MapContentBox.kt@@ -94,7 +94,8 @@ internal fun MapPageScope.MapContentBox( // Gated on search separately from `browsing` because the sheets draw over // this box: while search is up, a drop in the bottom third lands on the sheet // rather than the map, and half a working drag is worse than no peg.- if (browsing && searchRequest == null) StreetViewPegman(camera)+ // Also gated on the Google services opt-in: no opt-in, no peg, no tiles.+ if (browsing && searchRequest == null && googleServices) StreetViewPegman(camera) // The chrome's inset, in one place. `windowInsetsPadding` *consumes* what it // applies, so the pieces below that inset themselves — the FAB stack, the scale
maps/src/main/java/com/vayunmathur/maps/ui/MapPage.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/MapPage.kt b/maps/src/main/java/com/vayunmathur/maps/ui/MapPage.ktindex 14c04864f0..e61d87c246 100644--- a/maps/src/main/java/com/vayunmathur/maps/ui/MapPage.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/MapPage.kt@@ -156,6 +156,14 @@ fun MapPage( val safetyEnabled by settingsViewModel.safetyLayer.collectAsState() val transitEnabled by settingsViewModel.transitLayer.collectAsState() val globeEnabled by settingsViewModel.globeEnabled.collectAsState()+ val googleServices by settingsViewModel.googleServices.collectAsState()+ var googleConsentDone by remember {+ mutableStateOf(+ !shouldShowGoogleConsent(+ com.vayunmathur.library.util.DataStoreUtils.getInstance(context)+ )+ )+ } // Enabling the globe at street zoom shows nothing new: the sphere only // reads past the detail threshold. Zoom out to reveal it, so the toggle // answers visibly instead of arming a mode the user cannot see.@@ -285,6 +293,7 @@ fun MapPage( safetyEnabled = safetyEnabled, transitEnabled = transitEnabled, globeEnabled = globeEnabled,+ googleServices = googleServices, body = chrome.body, moonTextures = moonTextures, darkMap = darkMap,@@ -303,6 +312,9 @@ fun MapPage( settingsAction = settingsAction, wide = wide, )+ if (!googleConsentDone) {+ GoogleConsentDialog(settingsViewModel) { googleConsentDone = true }+ } if (wide) { scope.MapWideHost( searchActions = searchActions,
maps/src/main/java/com/vayunmathur/maps/ui/MapPageScope.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/MapPageScope.kt b/maps/src/main/java/com/vayunmathur/maps/ui/MapPageScope.ktindex f6ffd5bcab..ea26e7f7e8 100644--- a/maps/src/main/java/com/vayunmathur/maps/ui/MapPageScope.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/MapPageScope.kt@@ -131,6 +131,8 @@ internal class MapPageScope( val safetyEnabled: Boolean, val transitEnabled: Boolean, val globeEnabled: Boolean,+ /** Google services opt-in (enrichment + reviews + Street View). Off = no Google traffic. */+ val googleServices: Boolean, val body: MapBody, val moonTextures: MoonTextures?, val darkMap: Boolean,
maps/src/main/java/com/vayunmathur/maps/ui/MapWideHost.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/MapWideHost.kt b/maps/src/main/java/com/vayunmathur/maps/ui/MapWideHost.ktindex 6cae2d2512..ece7803b5d 100644--- a/maps/src/main/java/com/vayunmathur/maps/ui/MapWideHost.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/MapWideHost.kt@@ -36,7 +36,6 @@ import com.vayunmathur.maps.ui.map.MapSurface import com.vayunmathur.maps.ui.map.NavigationCameraFollow import com.vayunmathur.maps.ui.map.WaypointList import com.vayunmathur.maps.ui.map.rememberMapChromeState-import com.vayunmathur.maps.ui.streetview.StreetViewPegman import com.vayunmathur.maps.ui.theme.MapChromeMetrics import com.vayunmathur.maps.util.MapsSearchViewModel import com.vayunmathur.maps.util.NavigationSessionManager
maps/src/main/java/com/vayunmathur/maps/ui/settings/MapSettingsPage.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/settings/MapSettingsPage.kt b/maps/src/main/java/com/vayunmathur/maps/ui/settings/MapSettingsPage.ktindex f760f44908..4355381231 100644--- a/maps/src/main/java/com/vayunmathur/maps/ui/settings/MapSettingsPage.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/settings/MapSettingsPage.kt@@ -46,6 +46,7 @@ fun MapSettingsPage(backStack: NavBackStack<Route>, viewModel: MapSettingsViewMo val theme by viewModel.themeMode.collectAsState() val voice by viewModel.voiceGuidance.collectAsState() val globe by viewModel.globeEnabled.collectAsState()+ val googleServices by viewModel.googleServices.collectAsState() // Pre-resolve option labels — the SettingsSelectRow `label` lambda is a plain // (non-@Composable) function, so stringResource can't be called inside it.@@ -95,6 +96,13 @@ fun MapSettingsPage(backStack: NavBackStack<Route>, viewModel: MapSettingsViewMo } SettingsSection(title = stringResource(R.string.settings_section_places)) {+ SettingsSwitchRow(+ title = stringResource(R.string.settings_google_services),+ supportingText = stringResource(R.string.settings_google_services_desc),+ checked = googleServices,+ onCheckedChange = { viewModel.setGoogleServices(it) },+ leadingContent = { IconStar() },+ ) com.vayunmathur.library.ui.SettingsRow( title = stringResource(R.string.saved_places_title), onClick = {
maps/src/main/java/com/vayunmathur/maps/util/MapSettingsViewModel.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/util/MapSettingsViewModel.kt b/maps/src/main/java/com/vayunmathur/maps/util/MapSettingsViewModel.ktindex 650695f131..50eb4cef15 100644--- a/maps/src/main/java/com/vayunmathur/maps/util/MapSettingsViewModel.kt+++ b/maps/src/main/java/com/vayunmathur/maps/util/MapSettingsViewModel.kt@@ -72,6 +72,15 @@ class MapSettingsViewModel(application: Application) : AndroidViewModel(applicat MapPreferences.KEY_LAYER_TRANSIT, MapPreferences.DEFAULT_LAYER_TRANSIT, ) + /**+ * Google services (place enrichment + reviews + Street View). Off by+ * default; the first-launch consent dialog or the settings toggle opts in.+ * Every Google call site gates on this — off means zero Google traffic.+ */+ val googleServices: StateFlow<Boolean> = boolPref(+ MapPreferences.KEY_GOOGLE_SERVICES, MapPreferences.DEFAULT_GOOGLE_SERVICES,+ )+ fun setTrafficLayer(enabled: Boolean) = launch { ds.setBoolean(MapPreferences.KEY_LAYER_TRAFFIC, enabled) } @@ -84,6 +93,12 @@ class MapSettingsViewModel(application: Application) : AndroidViewModel(applicat fun setTransitLayer(enabled: Boolean) = launch { ds.setBoolean(MapPreferences.KEY_LAYER_TRANSIT, enabled) } + fun setGoogleServices(enabled: Boolean) =+ launch {+ ds.setBoolean(MapPreferences.KEY_GOOGLE_SERVICES, enabled)+ ds.setBoolean(MapPreferences.KEY_GOOGLE_CONSENT_ASKED, true)+ }+ private fun boolPref(key: String, default: Boolean): StateFlow<Boolean> = ds.booleanFlow(key).stateIn( viewModelScope, SharingStarted.Eagerly, ds.getBoolean(key, default),
maps/src/main/java/com/vayunmathur/maps/util/SelectedFeatureViewModel.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/util/SelectedFeatureViewModel.kt b/maps/src/main/java/com/vayunmathur/maps/util/SelectedFeatureViewModel.ktindex 3769f4e823..9dac0569b3 100644--- a/maps/src/main/java/com/vayunmathur/maps/util/SelectedFeatureViewModel.kt+++ b/maps/src/main/java/com/vayunmathur/maps/util/SelectedFeatureViewModel.kt@@ -114,6 +114,13 @@ class SelectedFeatureViewModel(application: Application): AndroidViewModel(appli private val dataStore = DataStoreUtils.getInstance(application) + /** Synchronous Google-services gate (off by default): no opt-in, no fetch. */+ private fun googleServicesEnabled(): Boolean =+ dataStore.getBoolean(+ MapPreferences.KEY_GOOGLE_SERVICES,+ MapPreferences.DEFAULT_GOOGLE_SERVICES,+ )+ /** * Last fix persisted, throttled by distance — DataStore rewrites the whole * file per edit, so a standing-still phone should not rewrite it every second.@@ -249,10 +256,14 @@ class SelectedFeatureViewModel(application: Application): AndroidViewModel(appli * Emits null for other feature types and while the network scrape is in * flight; cancels the in-flight fetch when the selection changes. * [GooglePoiDataSource] caches and does its own IO, so a re-select is instant.+ *+ * Hard-gated on the Google services toggle: when off, emits null without+ * touching the network — zero Google traffic. */ @OptIn(ExperimentalCoroutinesApi::class) val currentPoiInfo: StateFlow<GooglePoiInfo?> = selectedFeature .flatMapLatest { feature ->+ if (!googleServicesEnabled()) return@flatMapLatest flowOf(null) val (name, pos) = when (feature) { is SpecificFeature.Restaurant -> feature.name to feature.position is SpecificFeature.GenericPlace -> feature.name to feature.position
maps/src/main/res/values/strings.xml
diff --git a/maps/src/main/res/values/strings.xml b/maps/src/main/res/values/strings.xmlindex 3cb9130281..76301f7407 100644--- a/maps/src/main/res/values/strings.xml+++ b/maps/src/main/res/values/strings.xml@@ -366,6 +366,18 @@ <string name="settings_globe">Globe view</string> <!-- Settings: globe toggle description. --> <string name="settings_globe_desc">Show the map as a 3D globe</string>+ <!-- Google consent dialog: title. Noun phrase. -->+ <string name="google_consent_title">Enable Google services?</string>+ <!-- Google consent dialog: body explaining what enabling contacts. -->+ <string name="google_consent_message">Place details, reviews, and Street View come from Google. If you keep this off, the map stays fully offline and nothing is sent to Google.</string>+ <!-- Google consent dialog: opt-in button. Verb. -->+ <string name="google_consent_enable">Enable</string>+ <!-- Google consent dialog: opt-out button. Verb. -->+ <string name="google_consent_disable">Keep offline</string>+ <!-- Settings: Google services toggle title. Noun. -->+ <string name="settings_google_services">Google services</string>+ <!-- Settings: Google services toggle description. -->+ <string name="settings_google_services_desc">Place details, reviews, Street View</string> <!-- Body switch: Earth option. Noun. --> <string name="body_earth">Earth</string> <!-- Body switch: Moon option. Noun. -->