package com.zxhy.hfilemanagermaster.permission

import android.app.ActivityManager
import android.content.Context
import android.content.pm.PackageManager
import androidx.core.content.ContextCompat

//检查是否有所有权限
fun havePermission(context: Context, permissions: Array<String>): Boolean {
    var havePermission = true
    permissions.forEach {
        if (ContextCompat.checkSelfPermission(context, it) != PackageManager.PERMISSION_GRANTED) {
            havePermission = false
        }
    }
    return havePermission
}

//检查拒绝的权限
fun denyPermission(context: Context, permissions: Array<String>): ArrayList<String> {
    val denys = arrayListOf<String>()
    permissions.forEach {
        if (ContextCompat.checkSelfPermission(context, it) == PackageManager.PERMISSION_DENIED) {
            denys.add(it)
        }
    }
    return denys
}


