fix(update): canRequestPackageInstalls 包 try/catch,旧包也不闪退
Some checks are pending
Release / build (push) Waiting to run
Some checks are pending
Release / build (push) Waiting to run
- 旧版本未声明 REQUEST_INSTALL_PACKAGES 时调该 API 本身会抛 SecurityException - 现在降级为 capture 后按 false 处理,引导去系统设置开启未知来源 - 版本升至 1.6.9
This commit is contained in:
parent
40af5db889
commit
4597fb0f8e
@ -16,8 +16,8 @@ android {
|
||||
applicationId = "com.rainy.token"
|
||||
minSdk = 31
|
||||
targetSdk = 35
|
||||
versionCode = 18
|
||||
versionName = "1.6.8"
|
||||
versionCode = 19
|
||||
versionName = "1.6.9"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables {
|
||||
|
||||
@ -80,7 +80,9 @@ class UpdateViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
fun install(file: File) {
|
||||
if (!context.packageManager.canRequestPackageInstalls()) {
|
||||
val canInstall = runCatching { context.packageManager.canRequestPackageInstalls() }
|
||||
.getOrDefault(false)
|
||||
if (!canInstall) {
|
||||
_uiState.update { it.copy(phase = Phase.NeedInstallPermission) }
|
||||
return
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user