Fix app crash on startup on some Android TV

Why do you guys even exist
This commit is contained in:
AntsyLich
2026-03-23 21:12:30 +06:00
parent 42daa3f432
commit b40f1d3975
2 changed files with 12 additions and 7 deletions
+1
View File
@@ -15,6 +15,7 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co
- Fix app crashing when trying to add extension repo with existing signature ([@AntsyLich](https://github.com/AntsyLich))
- Potentially fix 'database is locked' crash ([@AntsyLich](https://github.com/AntsyLich))
- Fix occasional crash when mass installing/uninstalling extension using `PackageManager` ([@AntsyLich](https://github.com/AntsyLich))
- Fix app crash on startup on some Android TV ([@AntsyLich](https://github.com/AntsyLich))
## [v0.19.5] - 2026-03-20
### Changed
@@ -13,6 +13,7 @@ import kotlin.coroutines.resume
object WebViewUtil {
private const val CHROME_PACKAGE = "com.android.chrome"
private const val YOUTUBE_FOR_TV_PACKAGE = "com.google.android.youtube.tv"
private const val SYSTEM_SETTINGS_PACKAGE = "com.android.settings"
const val MINIMUM_WEBVIEW_VERSION = 118
@@ -56,13 +57,16 @@ object WebViewUtil {
}
fun spoofedPackageName(context: Context): String {
return try {
context.packageManager.getPackageInfo(CHROME_PACKAGE, PackageManager.GET_META_DATA)
CHROME_PACKAGE
} catch (_: PackageManager.NameNotFoundException) {
SYSTEM_SETTINGS_PACKAGE
}
return runCatching { context.packageManager.getPackageInfo(CHROME_PACKAGE, 0) }
.recoverCatching { context.packageManager.getPackageInfo(SYSTEM_SETTINGS_PACKAGE, 0) }
.recoverCatching { context.packageManager.getPackageInfo(YOUTUBE_FOR_TV_PACKAGE, 0) }
.fold(
onSuccess = { it.packageName },
onFailure = {
context.packageManager.getInstalledPackages(0)
.random().packageName
},
)
}
}