androidMain.tech.skot.libraries.map.DeclaredPermissionHelperImpl.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of viewlegacy Show documentation
Show all versions of viewlegacy Show documentation
viewlegacy module for SK-Map skot library
The newest version!
package tech.skot.libraries.map
import android.content.Context
import android.content.pm.PackageManager
import tech.skot.core.view.SKPermission
import tech.skot.view.SKPermissionAndroid
class DeclaredPermissionHelperImpl(
private val context: Context
) : tech.skot.libraries.map.DeclaredPermissionHelper {
override fun isPermissionDeclaredForApp(permission: SKPermission): Boolean {
val name = (permission as? SKPermissionAndroid?)?.name
val packageName = context.packageName
try {
val packageInfo =
context.packageManager.getPackageInfo(
packageName,
PackageManager.GET_PERMISSIONS
)
val declaredPermissions = packageInfo.requestedPermissions
if (declaredPermissions != null && declaredPermissions.isNotEmpty()) {
for (p in declaredPermissions) {
if (p.equals(name, ignoreCase = true)) {
return true
}
}
}
} catch (e: PackageManager.NameNotFoundException) {
e.printStackTrace()
return false
}
return false
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy