Fix debug page crash on Android <11

This commit is contained in:
Damontecres 2025-11-22 14:07:52 -05:00
parent 78e6304571
commit eea650bb39
No known key found for this signature in database

View file

@ -202,19 +202,31 @@ fun DebugPage(
color = MaterialTheme.colorScheme.onSurface, color = MaterialTheme.colorScheme.onSurface,
) )
val pkgInfo = context.packageManager.getPackageInfo(context.packageName, 0) val pkgInfo = context.packageManager.getPackageInfo(context.packageName, 0)
val installSource = context.packageManager.getInstallSourceInfo(context.packageName) val installInfo =
listOf( if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
"Version Name: ${pkgInfo.versionName}", val installSource =
"Version Code: ${pkgInfo.versionCodeLong}", context.packageManager.getInstallSourceInfo(context.packageName)
"Build type: ${BuildConfig.BUILD_TYPE}", buildList {
"Debug enabled: ${BuildConfig.DEBUG}", if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
"ABIs: ${Build.SUPPORTED_ABIS.toList()}", add("Install source: ${installSource.packageSource}")
"Install source: ${installSource.packageSource}", }
"Installer: ${installSource.installingPackageName}", add("Installer: ${installSource.installingPackageName}")
"Initiator: ${installSource.initiatingPackageName}", add("Initiator: ${installSource.initiatingPackageName}")
}
} else {
listOf(context.packageManager.getInstallerPackageName(context.packageName))
}
(
listOf(
"Version Name: ${pkgInfo.versionName}",
"Version Code: ${pkgInfo.versionCodeLong}",
"Build type: ${BuildConfig.BUILD_TYPE}",
"Debug enabled: ${BuildConfig.DEBUG}",
"ABIs: ${Build.SUPPORTED_ABIS.toList()}",
) + installInfo
).forEach { ).forEach {
Text( Text(
text = it, text = it.toString(),
style = MaterialTheme.typography.bodySmall, style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurface, color = MaterialTheme.colorScheme.onSurface,
) )