mirror of
https://github.com/YTVanced/VancedMicroG
synced 2024-12-04 08:47:26 +00:00
EN: Only ask for confirmation if build comes with confirm ui
This commit is contained in:
parent
568c015be7
commit
bc0b08c2b6
1 changed files with 25 additions and 8 deletions
|
@ -61,16 +61,33 @@ class ExposureNotificationServiceImpl(private val context: Context, private val
|
|||
return pi
|
||||
}
|
||||
|
||||
private fun hasConfirmActivity(): Boolean {
|
||||
val intent = Intent(ACTION_CONFIRM)
|
||||
intent.`package` = context.packageName
|
||||
return try {
|
||||
context.packageManager.resolveActivity(intent, 0) != null
|
||||
} catch (e: Exception) {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun confirmPermission(permission: String): Status {
|
||||
return ExposureDatabase.with(context) { database ->
|
||||
if (tempGrantedPermissions.contains(packageName to permission)) {
|
||||
database.grantPermission(packageName, PackageUtils.firstSignatureDigest(context, packageName)!!, permission)
|
||||
tempGrantedPermissions.remove(packageName to permission)
|
||||
Status.SUCCESS
|
||||
} else if (!database.hasPermission(packageName, PackageUtils.firstSignatureDigest(context, packageName)!!, permission)) {
|
||||
Status(RESOLUTION_REQUIRED, "Permission EN#$permission required.", pendingConfirm(permission))
|
||||
} else {
|
||||
Status.SUCCESS
|
||||
when {
|
||||
tempGrantedPermissions.contains(packageName to permission) -> {
|
||||
database.grantPermission(packageName, PackageUtils.firstSignatureDigest(context, packageName)!!, permission)
|
||||
tempGrantedPermissions.remove(packageName to permission)
|
||||
Status.SUCCESS
|
||||
}
|
||||
database.hasPermission(packageName, PackageUtils.firstSignatureDigest(context, packageName)!!, permission) -> {
|
||||
Status.SUCCESS
|
||||
}
|
||||
!hasConfirmActivity() -> {
|
||||
Status.SUCCESS
|
||||
}
|
||||
else -> {
|
||||
Status(RESOLUTION_REQUIRED, "Permission EN#$permission required.", pendingConfirm(permission))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue