cloudending
cloudending

Reputation: 105

How to traversed /proc directory in android in APK

I have a apk which sharedUserId is android.uid.system.And I want to traverse the /proc directory to search how many pids in my android phone.

        File procFile = new File(PROC_DIR_PATH);//PROC_DIR_PATH = "/proc"
        String[] filenames = procFile.list();

but filenames lacks of a lot of pids. I put the code in system_server and I can traverse all pid under /proc

Upvotes: 0

Views: 1052

Answers (1)

turkishweb
turkishweb

Reputation: 427

It depends on which Android version you are testing your app.

Normally, you should get this information from the Android framework, using getRunningTasks(int); unluckily, from android API 21 on, this method is deprecated.

Moreover, on newer Android (API 23+) the right to access a lot of different resources inside /proc has been removed to increase security. Even though I did not tested it, you can probably bypass this by running your app on a rooted device.

Upvotes: 1

Related Questions