2

I made a filemanager that I want go be able to navegate/modify some system folders (say, /data/). I copied my apk to /system/app, gave 644 permission to the apk file, and rebooted. Yet, my app is still run without root privileges (deny simple access to /data). I'm using Cyanogenmod 11.

Any clue?

Thanks!

L.

Luis A. Florit
  • 2,169
  • 1
  • 33
  • 58

1 Answers1

1

To clarify, the app being in the /system/app folder does not run it as root. Android is linux based, so having root access means that your app is able to run shell commands as the root user.

Generally speaking an app being in the /system/app folder makes all declared permissions available to it, (for example, declaring WRITE_SECURE_SETTINGS only does anything for system apps), and then the code that was only available to system apps is now available to yours as well.

For reliability, you should use shell commands where possible for anything that's normally unavailable. Do not use java.io.File to access files that are normally restricted.

I would recommend using RootTools as it makes running shell commands as root much easier. The first 3 pages on this linux command cheat sheet will probably cover everything you need.

Reed
  • 14,703
  • 8
  • 66
  • 110
  • I want my filemanager to do two things: access all directories (and create/delete things on them if not mounted RO), and to mount encrypted filesystems. Currently, I cannot do any of these. My app has `ACCESS_SUPERUSER` permission declared in the `AndroidManifest.xml`, and when I install it, it shows only one permission: `#Full access to everything`. I install it, and yet the system does not allow me to execute `su`, but it shows my app as `Deny` in the dev options in the settings, despite it never asked for any permission. That's why I tried to make it a system app, but failed... – Luis A. Florit Sep 17 '14 at 00:20
  • ...BTW, sorry, but I don't quite understand how your answer can help me, nor how `RootTools` can... How can I achieve the two things I want to do with my filemanager? – Luis A. Florit Sep 17 '14 at 00:30
  • @LuisA.Florit, I'll update my answer tomorrow to try and help. – Reed Sep 17 '14 at 00:48
  • Wait... I upgraded to CYM 11 M10, and now `su` works fine. No doubt it was a bug. So now I can mount/umount encrypted stuff as I was always able to do. Therefore, the only question that remains is: how can I give my app permissions to navigate the filesystem and modify the stuff that is not RO? Thanks! – Luis A. Florit Sep 17 '14 at 01:58
  • What code are you using to try and access the files? – Reed Sep 17 '14 at 17:02
  • I check canRead and canExecute on a folder before listFiles. – Luis A. Florit Sep 19 '14 at 12:08
  • I updated my answer. Long story short, don't use `java.io.File`. Use the linux-based shell commands. – Reed Sep 20 '14 at 19:47
  • I'm wondering if this method can help me make an app I didn't write access files it normally can't... – Michael Feb 06 '22 at 02:19