Android 5上有
a bug个,有关任何应用程序可以如何通过一定的权限清除所有缓存文件,但无法清除一个包的缓存文件,除了具有签名级权限.它的细节在哪里
PackageManager has a deleteApplicationCacheFiles() to delete the cache from one package.
This method is hidden from the SDK, and it requires
DELETE_CACHE_FILES, a signature-level permission.
PackageManager also has a freeStorageAndNotify() method, to delete
cache files from all packages. This method is hidden from the SDK, and
it requires the CLEAR_APP_CACHE permission, which is merely flagged
as “dangerous”.
有人建议,DELETE_CACHE_FILES应该有其级别放松,
CLEAR_APP_CACHE应该提高其级别.
框架工程师回应
Note that freeStorageAndNotify's purpose is not to wipe out all cache
files, but to free up X amount of space, for example by play store
before it tries to download and install an app. So there are reasons
to use it that work well with the system, but no reason for an app to
use the method that just blindly erases all cache files for a single
app (that is just there for the Settings app UI).
如果确实不是应用程序错误,那么您没有搞砸权限,它在Marshmallow / 6 / api 23上工作,而不是其他只能意味着它成为签名级别许可的工具,如DELETE_CACHE_FILES.
A signature|system permission, meaning that it can only be held by
apps that are signed with the firmware’s signing key or are installed
on the system partition (e.g., by a rooted device user). As described
in 07001.
考虑到他们的预期用途/愿景(没有任何理由让应用程序使用只是盲目擦除单个应用程序的所有缓存文件的方法),这是有道理的.由于该错误,它甚至可能受到限制.当Android 6的代码出来时,我们会更加了解(目前可用的是5.1.1 – link to PackageManager’s freeStorageAndNotify).