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,
)
val pkgInfo = context.packageManager.getPackageInfo(context.packageName, 0)
val installSource = context.packageManager.getInstallSourceInfo(context.packageName)
val installInfo =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
val installSource =
context.packageManager.getInstallSourceInfo(context.packageName)
buildList {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
add("Install source: ${installSource.packageSource}")
}
add("Installer: ${installSource.installingPackageName}")
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()}",
"Install source: ${installSource.packageSource}",
"Installer: ${installSource.installingPackageName}",
"Initiator: ${installSource.initiatingPackageName}",
) + installInfo
).forEach {
Text(
text = it,
text = it.toString(),
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurface,
)