简体   繁体   English

Android在不使用listFiles()方法的情况下列出目录中的所有文件

[英]Android list all files in directory without using listFiles() method

I am working on a sort of android applications analyzer, by inspecting apps' smali code. 我正在通过检查应用程序的smali代码来开发一种android应用程序分析器。 In particular I need to know whenever an app tries to get the list of files included in a certain parent directory, so I am currently tracking the following method call (and its overloads): 特别是,我需要知道每当应用尝试获取某个父目录中包含的文件列表时,因此我目前正在跟踪以下方法调用(及其重载):

File[] children = someFolder.listFiles();

What I would like to know is if there is any other method that leads to the same result that I should add to my "tracked" methods, or if the above-mentioned method is the only way to list a folder's content? 我想知道的是,是否还有其他方法可以产生与应添加到“跟踪”方法中的结果相同的结果,或者上述方法是否是列出文件夹内容的唯一方法?

Depending on the kernel/ROM a user could run a command in the likes of ls /your/watched/path and just get the output of that command. 根据内核/ ROM的不同,用户可以像ls /your/watched/path这样的命令运行命令,然后获取该命令的输出。

If the phone is rooted they most certainly can do this (usually a rooted phone will have busybox). 如果手机是植根的,则他们肯定可以做到这一点(通常,植根的手机将具有busybox)。 On a non-rooted device this may or may not be possible due to file restrictions and such. 在无根设备上,由于文件限制等原因,这可能会或可能不会。

See a related answer: Any way to run shell commands on android programmatically? 看到一个相关的答案:以任何方式在Android上以编程方式运行Shell命令吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM