Android “阅读”的访问权限/系统/等级/电源/电池/电流“立即”;安卓工作室(华为P20)

Android “阅读”的访问权限/系统/等级/电源/电池/电流“立即”;安卓工作室(华为P20),android,file-permissions,battery,Android,File Permissions,Battery,各位。我试图访问文件“/sys/class/power\u supply/Battery/current\u now”,以检索华为P20中的电池电流 f = File("/sys/class/power_supply/Battery/current_now"); if (f.exists()) { return OneLineReader.getValue(f, true) 然而,我得到的错误是 java.io.FileNotFoundException:/sys/class/power

各位。我试图访问文件“/sys/class/power\u supply/Battery/current\u now”,以检索华为P20中的电池电流

f =  File("/sys/class/power_supply/Battery/current_now");
if (f.exists()) {
  return OneLineReader.getValue(f, true)
然而,我得到的错误是

java.io.FileNotFoundException:/sys/class/power\u supply/Battery/current\u now:open failed:EACCES(权限被拒绝)

我已授予对存储器的读写权限

private val PERMISSIONS_STORAGE = arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)

fun verifyStoragePermissions(activity: Activity) {
    // Check if we have write permission
    val permission = ActivityCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE)

    if (permission != PackageManager.PERMISSION_GRANTED) {
        // We don't have permission so prompt the user
        ActivityCompat.requestPermissions(
                activity,
                PERMISSIONS_STORAGE,
                REQUEST_EXTERNAL_STORAGE
        )
    }
}

有人知道这个问题的提示吗?

您需要关闭selinux。
使用adb shell“setEnforce0”然后你可以从你的应用程序中读取它

current\u now是文件还是文件夹???current\u now是文件扩展名是什么?我想知道该文件是系统文件,需要通过“root”或其他方式访问该文件。我使用本页中的方法。