I am writing an app to monitor some files under /sys/devices/.../cpu. There is one file that is owned by root:root, with only read permissions for root.
I added code to exec("su"), but even then I get a file not found exception. The only way I don't get an error is if I chmod the file permissions. However, these permissions get set back to root read after boot, so I'd really like to find how to do the read without changing the file perms.
Thanks,
Jim
I was able to do this following the code here: http://code.google.com/p/market-enabler/source/browse/branches/MarketAccess/src/ru/org/amip/MarketAccess/utils/ShellInterface.java. Jim
Related
I have a rooted device and I want to change the permission to the folder 'com.android.mms'. My app is system app. Is there a way to do it?
I have already tried using process and checked this link as well.
How to get File Permission Mode programmatically in Java
They don't throw any error but doesn't do the job as well. Can someone help? Thanks!
I'm working on AOSP. I've successfully added my apk to build. Now I want to give root access to my app. I don't want to provide root access to other apps or to install the Superuser app in my build. I just want to add my app to get root access. How can I achieve that?
I went through the su.c file in path system/extras/su but I'm unable to understand the whole code.
When I went through the code, I think my objective can be achieved if I could modify su.c to provide root access to my app,compile it and add the binary to the build. Am I right?
You're moving in the right direction. You need to check the sources for su.c The only problem that you can face is how to run your program as root. To do this you need to set SUID sticky bit for the executable of your application. To do this you need to modify system/core/include/private/android_filesystem_config.h file (structure android_files[]), for instance for su program you can see how this bit is set:
{ 06755, AID_ROOT, AID_ROOT, "system/xbin/su" },
ChainFire has written a a guide on su and how to use it for normal apps. If you're intending on working with anything other than your own phone I suggest this is the approach you follow.
PFA the png, in this please note the permissions for the images inside app_themes directory. I am creating and adding files to this directory(app_themes) and during the process I do not specify any permissions at all.
Now I can see, for some png's the permission is rwxrwxrwx and for some others, it is just rw.
Though I do not specify any permission at all, why this difference in permission occurs?
I have no issues while I access a file with rwxrwxrwx from a different application, but cannot access those files which has only rw permission from a second application.
Please let me know how to resolve this by having the same permission - rwxrwxrwx for all the files.
This behaviour of android seems slightly strange!
Any help is much appreciated.
In first place, why android sets different permissions for different files, though the files are created using the same code?
I’m trying to create an app that is able to access and modify a protected database within /data/data/. This process obviously requires root privileges and I am testing this on a rooted device. The general code to access the SQLite database is complete and works against a test database that is located elsewhere (on /sdcard/).
However when I want the application to access the database within /data/data/, it obviously fails as I am trying to access it as a normal user. I have read on the topic of using the su binary on Android for a bit now, and as far as I understand it usually used to execute shell commands only.
So my initial idea of making this work was to simply change the permissions of the file when the application starts, and change it back when it quits. So before actually bothering with implementing that in the application itself, I used my file explorer to change the permission to rw-rw-rw-. However my application was still not able to open the database.
My next idea was to use the sqlite3 program directly from the shell, but I found out, that my ROM does not come with it, so I would have to distribute it myself (Titanium Backup seems to do that).
However there is something that makes me wonder if there might not be a better way: I am using Root Explorer as my file explorer and it has a built-in way to browse any SQLite database. Given that it does not seem to ship with a custom sqlite3 binary, and that my phone does not have one itself, the access seems to happen using the normal Java tools. But how does the app get root rights then?
Is there a way to make an Android application run as root? Or did I forget setting something for the permissions earlier which prevented me from accessing it? Or does anyone know how Root Explorer does it?
You cannot raise the permissions of an already running process as far as I know. The simplest answer would be to copy it somewhere using the root shell / command line edit it, then copy it back as root again. And yes, I did read your question, just didn't explain the answer fully. Hopefully it's clear now. Not sure if root explorer does that or something else, but it would work.
I am getting error like this "
error:parent Directory of a file not
writable"
in android.
I've included WRITE_EXTERNAL_STORAGE permission, but it's not working.
Having that permission doesn't allow you to write anywhere.
You should get the writable path using: Environment.getExternalStorageDirectory();.
Apart from having correct permissions and a writeable path, as was already mentioned by Macarse, you might also want to check if the SDcard mounted is writable (check the Permissions tab in the FileExplorer view it should be something like d---rwxr-x).
If not then remount the SDcard(there are adb commands to do this but are risky, I think).
My usual course of action is switching off the phone and removing and then reinserting the SDcard. Sometimes just switching off the phone helps.
I'm getting this error too, only I'm trying to write to internal storage. Any ideas on how to fix the error?
Never mind. I figured it out. Data has to be written to the file streams as bytes if saving to internal storage.