gpt4 book ai didi

android - 根资源管理器 Android 11 (API 30)

转载 作者:行者123 更新时间:2023-12-04 23:49:47 26 4
gpt4 key购买 nike

当我以 api 30 为目标并尝试检索路径“/data/data”(具有 root 权限)中的文件列表时,我只获得了我的应用程序的文件夹,而使用 api 29 或更低版本,我获得了所有文件。
即使使用 api 30,我如何检索所有文件?
使用的代码:

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import com.topjohnwu.superuser.Shell

class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val result = Shell.su("ls -la /data/data").exec()
Log.e("files", result.out.toString())
}
}
我使用这个库作为根: https://github.com/topjohnwu/libsu

最佳答案

以下是 Android 11 中添加的新限制:
https://developer.android.com/about/versions/11/privacy/storage

Document access restrictions

To give developers time for testing, the following changes related > to the Storage Access Framework (SAF) take effectonly if your app targets Android 11 or higher.

Access to directories

You can no longer use theACTION_OPEN_DOCUMENT_TREEintent action to request access to the following directories:

  • The root directory of the internal storage volume.
  • The root directory of each SD card volume that the device manufacturer considers to be reliable, regardless of whether the cardis emulated or removable. A reliable volume is one that an app cansuccessfully access most of the time.
  • The Download directory.

Access to files

You can no longer use theACTION_OPEN_DOCUMENT_TREEor theACTION_OPEN_DOCUMENTintent action to request that the user select individual files fromthe following directories:

  • The Android/data/ directory and all subdirectories.
  • The Android/obb/ directory and all subdirectories.

关于android - 根资源管理器 Android 11 (API 30),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69838420/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com