0
0
Fork 0
mirror of https://github.com/YTVanced/VancedMicroG synced 2024-12-05 01:07:27 +00:00

EN: Only ask for confirmation if build comes with confirm ui

This commit is contained in:
Marvin W 2020-11-19 20:07:37 +01:00
parent 568c015be7
commit bc0b08c2b6
No known key found for this signature in database
GPG key ID: 072E9235DB996F2A

View file

@ -61,17 +61,34 @@ class ExposureNotificationServiceImpl(private val context: Context, private val
return pi 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 { private suspend fun confirmPermission(permission: String): Status {
return ExposureDatabase.with(context) { database -> return ExposureDatabase.with(context) { database ->
if (tempGrantedPermissions.contains(packageName to permission)) { when {
tempGrantedPermissions.contains(packageName to permission) -> {
database.grantPermission(packageName, PackageUtils.firstSignatureDigest(context, packageName)!!, permission) database.grantPermission(packageName, PackageUtils.firstSignatureDigest(context, packageName)!!, permission)
tempGrantedPermissions.remove(packageName to permission) tempGrantedPermissions.remove(packageName to permission)
Status.SUCCESS Status.SUCCESS
} else if (!database.hasPermission(packageName, PackageUtils.firstSignatureDigest(context, packageName)!!, permission)) { }
Status(RESOLUTION_REQUIRED, "Permission EN#$permission required.", pendingConfirm(permission)) database.hasPermission(packageName, PackageUtils.firstSignatureDigest(context, packageName)!!, permission) -> {
} else {
Status.SUCCESS Status.SUCCESS
} }
!hasConfirmActivity() -> {
Status.SUCCESS
}
else -> {
Status(RESOLUTION_REQUIRED, "Permission EN#$permission required.", pendingConfirm(permission))
}
}
} }
} }