diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 5c1487df..680de522 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -24,10 +24,14 @@ A clear and concise description of what you expected to happen. **Screenshots** If applicable, add screenshots to help explain your problem. -**Smartphone (please complete the following information):** - - Device: [e.g. Pixel 11 Pro] +**Device & App Info** +Please open **About (i) → Copy debug info** in Native Alpha and paste the output below (or fill in manually): +``` + +``` + - Device (if not using Copy debug info): [e.g. Pixel 11 Pro] - Android version: [e.g. Android 17] - - App version [In the About (i) screen, e.g. v1.6.3] + - App version [In the About (i) screen, e.g. v1.6.8] **Additional context** Add any other context about the problem here. diff --git a/app/src/main/kotlin/com/cylonid/nativealpha/ui/about/AboutScreen.kt b/app/src/main/kotlin/com/cylonid/nativealpha/ui/about/AboutScreen.kt index 879afbc7..39e9b9f9 100644 --- a/app/src/main/kotlin/com/cylonid/nativealpha/ui/about/AboutScreen.kt +++ b/app/src/main/kotlin/com/cylonid/nativealpha/ui/about/AboutScreen.kt @@ -1,5 +1,7 @@ package com.cylonid.nativealpha.ui.about +import android.content.ClipData +import android.content.ClipboardManager import android.content.Intent import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Box @@ -20,7 +22,9 @@ import androidx.compose.material.icons.automirrored.rounded.ArrowBack import androidx.compose.material.icons.automirrored.rounded.KeyboardArrowRight import androidx.compose.material.icons.automirrored.rounded.OpenInNew import androidx.compose.material.icons.rounded.AutoAwesome +import androidx.compose.material.icons.rounded.BugReport import androidx.compose.material.icons.rounded.Code +import androidx.compose.material.icons.rounded.ContentCopy import androidx.compose.material.icons.rounded.Description import androidx.compose.material.icons.rounded.Extension import androidx.compose.material.icons.rounded.Favorite @@ -37,6 +41,8 @@ import androidx.compose.material3.IconButtonDefaults import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MediumFlexibleTopAppBar import androidx.compose.material3.Scaffold +import androidx.compose.material3.SnackbarHost +import androidx.compose.material3.SnackbarHostState import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.material3.TextButton @@ -45,6 +51,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -64,6 +71,10 @@ import com.cylonid.nativealpha.ui.components.ReleaseNotesBottomSheet import com.cylonid.nativealpha.ui.components.RoundedCardContainer import com.cylonid.nativealpha.ui.components.SettingsActionItem import com.cylonid.nativealpha.ui.components.SettingsSectionHeader +import com.cylonid.nativealpha.util.DebugInfoFormatter +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext import timber.log.Timber @OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterial3ExpressiveApi::class) @@ -77,16 +88,20 @@ fun AboutScreen( val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior() val context = LocalContext.current + val snackbarHostState = remember { SnackbarHostState() } + val coroutineScope = rememberCoroutineScope() + val copiedMessage = stringResource(R.string.about_debug_info_copied) var releaseNotes by remember { mutableStateOf(null) } androidx.compose.runtime.LaunchedEffect(Unit) { releaseNotes = - kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.IO) { + withContext(Dispatchers.IO) { ReleaseNotesRepository.load(context) } } Scaffold( modifier = modifier.nestedScroll(scrollBehavior.nestedScrollConnection), + snackbarHost = { SnackbarHost(hostState = snackbarHostState) }, topBar = { MediumFlexibleTopAppBar( title = { @@ -267,6 +282,24 @@ fun AboutScreen( ) }, ) + + SettingsActionItem( + title = stringResource(R.string.about_debug_info_title), + description = stringResource(R.string.about_debug_info_desc), + icon = Icons.Rounded.BugReport, + trailingIcon = Icons.Rounded.ContentCopy, + onClick = { + coroutineScope.launch { + val debugText = + withContext(Dispatchers.IO) { + DebugInfoFormatter.format(DebugInfoFormatter.collect(context)) + } + val clipboard = context.getSystemService(ClipboardManager::class.java) + clipboard?.setPrimaryClip(ClipData.newPlainText("Native Alpha Debug Info", debugText)) + snackbarHostState.showSnackbar(copiedMessage) + } + }, + ) } if (BuildConfig.FLAVOR == "extendedGithub") { diff --git a/app/src/main/kotlin/com/cylonid/nativealpha/util/DebugInfoFormatter.kt b/app/src/main/kotlin/com/cylonid/nativealpha/util/DebugInfoFormatter.kt new file mode 100644 index 00000000..5eb1ee2f --- /dev/null +++ b/app/src/main/kotlin/com/cylonid/nativealpha/util/DebugInfoFormatter.kt @@ -0,0 +1,204 @@ +package com.cylonid.nativealpha.util + +import android.app.LocaleManager +import android.content.Context +import android.os.Build +import android.os.PowerManager +import androidx.webkit.WebViewCompat +import com.cylonid.nativealpha.BuildConfig +import com.cylonid.nativealpha.model.DataManager +import java.io.IOException + +/** + * Sanitized diagnostic snapshot of the app, device, OS, WebView, and aggregate settings for bug reports. + */ +data class DebugInfo( + val appVersionName: String, + val appVersionCode: Int, + val buildFlavor: String, + val buildType: String, + val androidRelease: String, + val sdkInt: Int, + val securityPatch: String, + val manufacturer: String, + val brand: String, + val model: String, + val device: String, + val buildDisplay: String, + val romVersion: String?, + val webViewPackage: String?, + val webViewVersion: String?, + val appLocale: String, + val themeMode: String, + val dynamicColor: Boolean, + val ignoringBatteryOptimizations: Boolean?, + val activeWebAppCount: Int, + val sandboxedWebAppCount: Int, + val globalAdblockEnabled: Boolean, + val globalBiometricEnabled: Boolean, +) + +/** + * Collects and formats non-PII diagnostic device, WebView, and app information for clipboard sharing. + */ +object DebugInfoFormatter { + /** + * Collects live diagnostic metadata from [context], [Build], [WebViewCompat], and [DataManager]. + * Safe to invoke off the main thread because it may query `getprop` for OEM ROM version. + */ + fun collect( + context: Context, + getProperty: (String) -> String? = ::readSystemProperty, + ): DebugInfo { + val localeTag = resolveLocaleTag(context) + val webViewPkg = runCatching { WebViewCompat.getCurrentWebViewPackage(context) }.getOrNull() + val powerManager = context.getSystemService(PowerManager::class.java) + val ignoringBattery = + runCatching { + powerManager?.isIgnoringBatteryOptimizations(context.packageName) + }.getOrNull() + + val dataManager = DataManager.getInstance() + val settings = runCatching { dataManager.settings }.getOrNull() + val activeApps = runCatching { dataManager.activeWebsites }.getOrDefault(emptyList()) + val themeMode = + when (settings?.themeId) { + 0 -> "System" + 1 -> "Dark" + 2 -> "Light" + null -> "Unknown" + else -> "Custom(${settings.themeId})" + } + + return DebugInfo( + appVersionName = BuildConfig.VERSION_NAME, + appVersionCode = BuildConfig.VERSION_CODE, + buildFlavor = BuildConfig.FLAVOR, + buildType = BuildConfig.BUILD_TYPE, + androidRelease = Build.VERSION.RELEASE.orEmpty(), + sdkInt = Build.VERSION.SDK_INT, + securityPatch = Build.VERSION.SECURITY_PATCH.orEmpty(), + manufacturer = Build.MANUFACTURER.orEmpty(), + brand = Build.BRAND.orEmpty(), + model = Build.MODEL.orEmpty(), + device = Build.DEVICE.orEmpty(), + buildDisplay = Build.DISPLAY.orEmpty(), + romVersion = detectRomVersion(Build.MANUFACTURER.orEmpty(), getProperty), + webViewPackage = webViewPkg?.packageName, + webViewVersion = webViewPkg?.versionName, + appLocale = localeTag, + themeMode = themeMode, + dynamicColor = settings?.isDynamicColor ?: false, + ignoringBatteryOptimizations = ignoringBattery, + activeWebAppCount = activeApps.size, + sandboxedWebAppCount = activeApps.count { it.isUseContainer }, + globalAdblockEnabled = settings?.globalWebApp?.isUseAdblock ?: false, + globalBiometricEnabled = settings?.globalWebApp?.isBiometricProtection ?: false, + ) + } + + /** + * Formats [info] as a clean multi-line plain-text block suitable for pasting into issue trackers. + */ + fun format(info: DebugInfo): String = + buildString { + appendLine("App: Native Alpha ${info.appVersionName} (${info.appVersionCode}, ${info.buildFlavor}/${info.buildType})") + appendLine("Android: ${info.androidRelease} (API ${info.sdkInt})") + if (info.securityPatch.isNotBlank()) { + appendLine("Security Patch: ${info.securityPatch}") + } + appendLine("Device: ${info.manufacturer} ${info.model} (${info.brand}/${info.device})") + if (!info.romVersion.isNullOrBlank()) { + appendLine("ROM: ${info.romVersion}") + } + if (info.buildDisplay.isNotBlank()) { + appendLine("Build: ${info.buildDisplay}") + } + if (!info.webViewPackage.isNullOrBlank()) { + val versionSuffix = + info.webViewVersion + ?.takeIf { it.isNotBlank() } + ?.let { " ($it)" } + .orEmpty() + appendLine("WebView: ${info.webViewPackage}$versionSuffix") + } + appendLine("Locale: ${info.appLocale} | Theme: ${info.themeMode} (DynamicColor=${info.dynamicColor})") + if (info.ignoringBatteryOptimizations != null) { + appendLine("Battery Optimization Ignored: ${info.ignoringBatteryOptimizations}") + } + append( + "WebApps: ${info.activeWebAppCount} active (${info.sandboxedWebAppCount} sandboxed) | " + + "Global Adblock=${info.globalAdblockEnabled}, Biometric=${info.globalBiometricEnabled}", + ) + } + + /** + * Detects common OEM skin / custom ROM version strings from standard system properties. + */ + internal fun detectRomVersion( + manufacturer: String, + getProperty: (String) -> String?, + ): String? { + val mfr = manufacturer.trim().lowercase() + + val oneUi = formatOneUiVersion(getProperty("ro.build.version.oneui")) + if (oneUi != null) return oneUi + if (mfr == "samsung") { + getProperty("ro.build.PDA")?.takeIf { it.isNotBlank() }?.let { return "One UI ($it)" } + } + + getProperty("ro.mi.os.version.name")?.takeIf { it.isNotBlank() }?.let { return "HyperOS $it" } + getProperty("ro.miui.ui.version.name")?.takeIf { it.isNotBlank() }?.let { return "MIUI $it" } + + getProperty("ro.build.version.oplusrom")?.takeIf { it.isNotBlank() }?.let { + val label = if (mfr == "oneplus") "OxygenOS" else "ColorOS" + return "$label $it" + } + + getProperty("ro.nothing.version.id")?.takeIf { it.isNotBlank() }?.let { return "Nothing OS $it" } + getProperty("ro.lineage.version")?.takeIf { it.isNotBlank() }?.let { return "LineageOS $it" } + + return null + } + + /** + * Converts Samsung's integer `ro.build.version.oneui` property (e.g. `"80000"`, `"60101"`) + * into a human-readable string (e.g. `"One UI 8.0"`, `"One UI 6.1.1"`). + */ + internal fun formatOneUiVersion(rawVersion: String?): String? { + val code = rawVersion?.trim()?.toIntOrNull() ?: return null + if (code < 10000) return null + val major = code / 10000 + val minor = (code % 10000) / 100 + val patch = code % 100 + return if (patch > 0) "One UI $major.$minor.$patch" else "One UI $major.$minor" + } + + private fun resolveLocaleTag(context: Context): String { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + val appLocales = context.getSystemService(LocaleManager::class.java)?.applicationLocales + if (appLocales != null && !appLocales.isEmpty) { + return appLocales.toLanguageTags() + } + } + val locales = context.resources.configuration.locales + return if (!locales.isEmpty) locales[0].toLanguageTag() else "default" + } + + private fun readSystemProperty(key: String): String? = + try { + val process = + ProcessBuilder("getprop", key) + .redirectErrorStream(true) + .start() + val output = process.inputStream.bufferedReader().use { it.readText().trim() } + if (process.waitFor() == 0 && output.isNotEmpty()) output else null + } catch (_: IOException) { + null + } catch (_: SecurityException) { + null + } catch (_: InterruptedException) { + Thread.currentThread().interrupt() + null + } +} diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 377eb445..59f6694b 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -187,4 +187,7 @@ PDF wird geladen… Wiederholen Erneut „Zurück“ drücken zum Beenden + Debug-Infos kopieren + Geräte-, WebView- und App-Diagnosedaten für Fehlerberichte kopieren + Debug-Infos in die Zwischenablage kopiert diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 3424a83b..5b403211 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -188,4 +188,7 @@ Cargando PDF… Reintentar Pulsa atrás de nuevo para salir + Copiar info de depuración + Copia el diagnóstico del dispositivo, WebView y la app para informes de error + Info de depuración copiada al portapapeles diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index d318e1ff..2849778b 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -187,4 +187,7 @@ Caricamento PDF… Riprova Premi di nuovo indietro per uscire + Copia info di debug + Copia la diagnostica di dispositivo, WebView e app per le segnalazioni + Info di debug copiate negli appunti diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1dda5f9f..e75c9499 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -191,4 +191,7 @@ Loading PDF… Retry Press back again to exit + Copy debug info + Copy device, WebView, and app diagnostics for bug reports + Debug info copied to clipboard diff --git a/app/src/test/java/com/cylonid/nativealpha/ui/about/AboutScreenTest.kt b/app/src/test/java/com/cylonid/nativealpha/ui/about/AboutScreenTest.kt new file mode 100644 index 00000000..ed313cb0 --- /dev/null +++ b/app/src/test/java/com/cylonid/nativealpha/ui/about/AboutScreenTest.kt @@ -0,0 +1,69 @@ +package com.cylonid.nativealpha.ui.about + +import android.content.ClipboardManager +import android.content.Context +import androidx.compose.ui.test.assertIsDisplayed +import androidx.compose.ui.test.junit4.v2.createComposeRule +import androidx.compose.ui.test.onNodeWithText +import androidx.compose.ui.test.performClick +import androidx.compose.ui.test.performScrollTo +import androidx.test.core.app.ApplicationProvider +import com.cylonid.nativealpha.R +import com.cylonid.nativealpha.ui.theme.NativeAlphaTheme +import org.junit.Assert.assertNotNull +import org.junit.Assert.assertTrue +import org.junit.Before +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner +import org.robolectric.annotation.Config + +@RunWith(RobolectricTestRunner::class) +@Config(sdk = [34]) +class AboutScreenTest { + @get:Rule + val composeTestRule = createComposeRule() + + private lateinit var context: Context + + @Before + fun setUp() { + context = ApplicationProvider.getApplicationContext() + } + + @Test + fun testCopyDebugInfoCopiesDiagnosticTextAndShowsSnackbar() { + composeTestRule.setContent { + NativeAlphaTheme { + AboutScreen(onNavigateBack = {}) + } + } + + val copyTitle = context.getString(R.string.about_debug_info_title) + val copiedMessage = context.getString(R.string.about_debug_info_copied) + + val copyNode = composeTestRule.onNodeWithText(copyTitle) + copyNode.performScrollTo() + copyNode.assertIsDisplayed() + copyNode.performClick() + + val clipboard = context.getSystemService(ClipboardManager::class.java)!! + composeTestRule.waitUntil(timeoutMillis = 5_000) { + clipboard.primaryClip != null + } + + val clipText = + clipboard.primaryClip!! + .getItemAt(0) + .text + .toString() + assertNotNull(clipText) + assertTrue(clipText.contains("App: Native Alpha")) + assertTrue(clipText.contains("Android:")) + assertTrue(clipText.contains("Device:")) + assertTrue(clipText.contains("WebApps:")) + + composeTestRule.onNodeWithText(copiedMessage).assertIsDisplayed() + } +} diff --git a/app/src/test/java/com/cylonid/nativealpha/util/DebugInfoFormatterTest.kt b/app/src/test/java/com/cylonid/nativealpha/util/DebugInfoFormatterTest.kt new file mode 100644 index 00000000..97abb2cf --- /dev/null +++ b/app/src/test/java/com/cylonid/nativealpha/util/DebugInfoFormatterTest.kt @@ -0,0 +1,213 @@ +package com.cylonid.nativealpha.util + +import android.content.Context +import androidx.test.core.app.ApplicationProvider +import com.cylonid.nativealpha.model.DataManager +import com.cylonid.nativealpha.model.WebApp +import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse +import org.junit.Assert.assertNull +import org.junit.Assert.assertTrue +import org.junit.Before +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner +import org.robolectric.annotation.Config + +@RunWith(RobolectricTestRunner::class) +@Config(sdk = [34]) +class DebugInfoFormatterTest { + private lateinit var context: Context + + @Before + fun setUp() { + context = ApplicationProvider.getApplicationContext() + DataManager.getInstance().websites.clear() + } + + @Test + fun testFormatIncludesAllPopulatedFields() { + val info = + DebugInfo( + appVersionName = "1.6.7", + appVersionCode = 42, + buildFlavor = "standard", + buildType = "release", + androidRelease = "15", + sdkInt = 35, + securityPatch = "2026-11-05", + manufacturer = "Google", + brand = "google", + model = "Pixel 8 Pro", + device = "husky", + buildDisplay = "AP3A.241105.007", + romVersion = "One UI 7.0", + webViewPackage = "com.google.android.webview", + webViewVersion = "131.0.6778.104", + appLocale = "en-US", + themeMode = "System", + dynamicColor = true, + ignoringBatteryOptimizations = true, + activeWebAppCount = 5, + sandboxedWebAppCount = 2, + globalAdblockEnabled = true, + globalBiometricEnabled = false, + ) + + val formatted = DebugInfoFormatter.format(info) + assertTrue(formatted.contains("App: Native Alpha 1.6.7 (42, standard/release)")) + assertTrue(formatted.contains("Android: 15 (API 35)")) + assertTrue(formatted.contains("Security Patch: 2026-11-05")) + assertTrue(formatted.contains("Device: Google Pixel 8 Pro (google/husky)")) + assertTrue(formatted.contains("ROM: One UI 7.0")) + assertTrue(formatted.contains("Build: AP3A.241105.007")) + assertTrue(formatted.contains("WebView: com.google.android.webview (131.0.6778.104)")) + assertTrue(formatted.contains("Locale: en-US | Theme: System (DynamicColor=true)")) + assertTrue(formatted.contains("Battery Optimization Ignored: true")) + assertTrue(formatted.contains("WebApps: 5 active (2 sandboxed) | Global Adblock=true, Biometric=false")) + } + + @Test + fun testFormatOmitsOptionalBlankOrNullFields() { + val info = + DebugInfo( + appVersionName = "1.6.7", + appVersionCode = 42, + buildFlavor = "standard", + buildType = "debug", + androidRelease = "14", + sdkInt = 34, + securityPatch = "", + manufacturer = "Google", + brand = "google", + model = "Pixel", + device = "generic", + buildDisplay = "", + romVersion = null, + webViewPackage = null, + webViewVersion = null, + appLocale = "en", + themeMode = "Dark", + dynamicColor = false, + ignoringBatteryOptimizations = null, + activeWebAppCount = 0, + sandboxedWebAppCount = 0, + globalAdblockEnabled = false, + globalBiometricEnabled = false, + ) + + val formatted = DebugInfoFormatter.format(info) + assertFalse(formatted.contains("Security Patch:")) + assertFalse(formatted.contains("ROM:")) + assertFalse(formatted.contains("Build:")) + assertFalse(formatted.contains("WebView:")) + assertFalse(formatted.contains("Battery Optimization Ignored:")) + assertTrue(formatted.contains("Locale: en | Theme: Dark (DynamicColor=false)")) + } + + @Test + fun testDetectRomVersionSupportsMajorOemSkins() { + assertEquals( + "One UI 8.0", + DebugInfoFormatter.detectRomVersion("Samsung") { key -> + if (key == "ro.build.version.oneui") "80000" else null + }, + ) + assertEquals( + "One UI (S918BXXU)", + DebugInfoFormatter.detectRomVersion("samsung") { key -> + if (key == "ro.build.PDA") "S918BXXU" else null + }, + ) + assertEquals( + "HyperOS 2.0", + DebugInfoFormatter.detectRomVersion("Xiaomi") { key -> + if (key == "ro.mi.os.version.name") "2.0" else null + }, + ) + assertEquals( + "MIUI V14", + DebugInfoFormatter.detectRomVersion("Xiaomi") { key -> + if (key == "ro.miui.ui.version.name") "V14" else null + }, + ) + assertEquals( + "OxygenOS 15.0", + DebugInfoFormatter.detectRomVersion("OnePlus") { key -> + if (key == "ro.build.version.oplusrom") "15.0" else null + }, + ) + assertEquals( + "ColorOS 15.0", + DebugInfoFormatter.detectRomVersion("OPPO") { key -> + if (key == "ro.build.version.oplusrom") "15.0" else null + }, + ) + assertEquals( + "Nothing OS 3.0", + DebugInfoFormatter.detectRomVersion("Nothing") { key -> + if (key == "ro.nothing.version.id") "3.0" else null + }, + ) + assertEquals( + "LineageOS 22.1", + DebugInfoFormatter.detectRomVersion("Google") { key -> + if (key == "ro.lineage.version") "22.1" else null + }, + ) + assertNull(DebugInfoFormatter.detectRomVersion("Google") { null }) + } + + @Test + fun testFormatOneUiVersion() { + assertNull(DebugInfoFormatter.formatOneUiVersion(null)) + assertNull(DebugInfoFormatter.formatOneUiVersion("abc")) + assertNull(DebugInfoFormatter.formatOneUiVersion("9999")) + assertEquals("One UI 8.0", DebugInfoFormatter.formatOneUiVersion("80000")) + assertEquals("One UI 6.1.1", DebugInfoFormatter.formatOneUiVersion("60101")) + } + + @Test + fun testCollectAggregatesWebAppCountsWithoutLeakingPii() { + val dm = DataManager.getInstance() + dm.settings.isDynamicColor = true + dm.settings.themeId = 1 + dm.settings.globalWebApp.isUseAdblock = true + dm.settings.globalWebApp.isBiometricProtection = true + + dm.websites.add( + WebApp("https://secret-amazon.example", 0, 0).apply { + title = "SecretAmazon" + isUseContainer = true + containerId = 0 + isActiveEntry = true + }, + ) + dm.websites.add( + WebApp("https://github.example", 1, 1).apply { + title = "PrivateGitHub" + isUseContainer = false + isActiveEntry = true + }, + ) + dm.websites.add( + WebApp("https://deleted.example", 2, 2).apply { + isUseContainer = true + isActiveEntry = false + }, + ) + + val info = DebugInfoFormatter.collect(context) { null } + val formatted = DebugInfoFormatter.format(info) + + assertEquals(2, info.activeWebAppCount) + assertEquals(1, info.sandboxedWebAppCount) + assertEquals("Dark", info.themeMode) + assertTrue(info.dynamicColor) + assertTrue(info.globalAdblockEnabled) + assertTrue(info.globalBiometricEnabled) + assertFalse(formatted.contains("secret-amazon.example")) + assertFalse(formatted.contains("SecretAmazon")) + assertFalse(formatted.contains("PrivateGitHub")) + } +}