I am developing several AudioEffect subclasses that are being compiled into Android 4.0.3 ICS... I am trying to dump raw PCM data to files, but because the AudioEffects run in the context of the mediaserver process it seems there is no file writing permissions available.
fopen("/data/local/tmp/pcm_in.pcm", "w");
is returning a NULL pointer and errno 13 (permission denied).
Any ideas how I can grant mediaserver this permission, or write to a folder I can access? I'm compiling the OS, so anything goes...
More specifically: How are permissions for these native/system services determined? I don't suppose they have a AndroidManifest.xml...
I suspect the problem is that you don't have permissions to create a file at /data/local/tmp. In fact i'm not even sure that directory exists on Android.
Instead you should either use the private storage for an app or save the files to the SD card. See this for more information: http://developer.android.com/guide/topics/data/data-storage.html
Maybe you can just create a folder with permission.
root#android:/mount -o remount,rw /
root#android:/mkdir test
root#android:/chown media:media test
root#android:/chmod 777 test
Then you can do whatever you want.
z.B.
fopen("/test/pcm_in.pcm", "w");
Related
I've my app as system-priv and build along with my AOSP code. now my app needs to copy the tombstone folder which is under /data/tombstones to /sdcard.
thanks in advance
I got it worked.
There are 2 parts
i) You've to register tombstones path using FileObserver, so whenever new tombstone created you'll get the callback.
ii) Your app should have the permission to read this path otherwise you'll get an avc denied due to SELinux. So add permission to system_app.te file of sepolicy.
I tried to read a file from this path: data/data/com.example.app/shared_prefs/data.xml. I made a small textview in my app to show some logs. it showed me the stacktrace: /data/data/com.example.app/shared_prefs/data.xml (Permission denied) I gave the app superuser permissions and added these permissions in the AndroidManifest.xml --> android.permission.WRITE_EXTERNAL_STORAGE & android.permission.READ_EXTERNAL_STORAGE. But it still doesnt work
Giving superuser permissions to an app does not change anything as those permissions are not automatically used: superuser permissions means that you have the permission to execute something with root permissions but you don't have root permissions!
For using superuser permissions you have to execute an external application using Runtime.getRuntime().exec(..) and you have to execute it using the "su" binary. All operations performed by the external application will then be executed using superuser permission.
BTW: If you have busybox installed you can use "cp" (file copy) as the external application.
I'm trying to open files from C in my Android app/library. This did work at some point but stopped working after changing several things that seem completely irrelevant, and don't run until after this error occurs.
I am using the following function in C: *ppFile = fopen(fullUncFilePathAndName, "r+b"); and then again with permissions "w+b"
After each of these calls, errno = 13 (Permission Denied).
The file path is /data/data/{appFolder}/files/{filename} (got from Context.getFilesDir().getAbsolutePath(), and the working directory according to the C functions is "/". This is on internal storage, but I added the permission WRITE_EXTERNAL_STORAGE just because I had nothing else to do.
Can anyone think why reading or writing to existing and non-existent files in internal storage from an NDK library would fail with permission errors?
This problem solved itself in the best worst way possible. I deleted my app's data folder in the file browser, and then at the next build the app created its files without a hitch.
You could also clean the project and recompile from scratch.
I'm trying to create zip file inside my application files folder (/data/data/myapp/files) but getting "failed to create zip file | open failed: EACCES (Permission denied)" error message every time. As I can see using android debug bridge, my files folder have "rwx------" permissions and "root" owner and group. I think this is the problem but I can't understand why my folder have this owner and group?
Make sure you :
have rooted your device
have the rights to write on the internal storage
are not trying to test it with the usb storage enabled on your phone
added the permission <uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" /> in your manifest
I solved the problem by manually setting right owner, group and permissions on my application files folder (using chmod, chown and chgrp commands). It does not seem like an answer, because it is still unclear why this folder got wrong permissions but unfortunately I don't have enough time to understand where problem is.
I am trying to do method profiling for my application on Android 2.1 htc eris. It complains:
06-15 15:48:04.602: E/dalvikvm(826): Unable to open trace file '/sdcard/com.mayapp.trace': Permission denied
I have the following entry for user permission on my AndroidManifest.xml:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
When I do adb push, I get the following error:
adb push AndroidManifest.xml a.txt
failed to copy 'AndroidManifest.xml' to 'a.txt': Read-only file system
Am I missing something here?
This may not be the answer but you could use
File dir = Environment.getExternalStorageDirectory();
to access external sd card. My assumption is you wrote the directory yourself.
It was a combination of badly placed sd card and read/write access to the sdcard. Used adb push/pull to verify the sd card and also used adb remount to change the access. that solved the issue.