how to grant android mediaserver file write permission?

Go To StackoverFlow.com

0

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...

2012-04-05 19:41
by yano


0

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

2012-04-05 20:45
by slayton
AudioEffects run in the mediaserver process, and this is native C code, so I'm just looking to grant mediaserver permissions to write anywhere, I assumed the tmp folder would be available, and it does in fact exist - yano 2012-04-05 20:47
@yano so I'm just looking to grant mediaserver permissions to write anywhere without root this just isn't possible, sorr - slayton 2012-04-05 23:23
my phone is a development phone, so I have root access. I was trying to edit init.rc to run it as root, but for some reason it kept getting reverted to the "media" user - yano 2012-04-06 00:33
the permissions are set in the java file's manifest file in which you are including your s - Sunny Kumar Aditya 2012-04-06 09:33
mediaserver is not part of an APK, and in fact is a native executable started by init.rc when the phone boot - yano 2012-04-06 22:29


0

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");
2016-03-28 07:26
by sir
Ads