5

How can I make mediascanner scan phone memory, i.e. the /data directory? I want to test playing MP3s from this directory.

When I try to hack it by replacing the "pathStr" from /mnt/sdcard to /data before MediaScanner::doProcessDirectory(), it fails saying

W/MediaScanner( 1713): Error opening directory '/data/', skipping: Permission denied.

And also crashed (probably in free).

I just want to play MP3s stored in phone memory and avoid reading the SD card for some experiments.

5
  • Without root one program can't access /data of another program.
    – roxan
    Commented Jul 20, 2012 at 8:25
  • Roxan, I understand that but how can I play mp3 from /data folder?
    – dls
    Commented Jul 20, 2012 at 8:33
  • I mean, Can I change root permission for this process somewhere?
    – dls
    Commented Jul 20, 2012 at 8:34
  • Have you tried browsing using a root file explorer such as FX, and playing through that? Having said that, you'll probably need to run the media player as root too.
    – Jeeva
    Commented Jul 20, 2012 at 9:21
  • How do you use FX? I see one app called MusicFX in my /packages/apps, will this be able to do that??
    – dls
    Commented Jul 20, 2012 at 11:04

3 Answers 3

2

EDIT: This is rendered obsolete with Jelly Bean. Android 4.1+ has a unified /data/ and /sdcard section (the sdcard partition is emulated and really resides in /data/media, it's exposed via a special fuse layer to emulate FAT32 behaviour)

My thoughts on this:

  • The media scanner scans everything below /mnt
  • /data/* is protected, only individual apps can access their folder (/data/data/[app's package name])

To get it working the way you like:

  • You need root (obviously)
  • symlink /mnt/music to /data/data/your-music-location
  • you can also do a bind-mount instead of a symlink:
    mount --bind /data/your-music-location /mnt/sdcard/your-music-location
  • Lift access rights accordingly (chmod -R ugo+rw /data/data/your-music-location)

Hope this works (the scanner should scan the whole /mnt as there's also /mnt/emmc and such). If not, you can also bind-mount a /data/data/* folder to /mnt/sdcard/your-music (as done with /mnt/sdcard/.android_secure (see the answer))

7
  • I realize that /system folder has permissions and does not require root permissions.
    – dls
    Commented Jul 20, 2012 at 11:37
  • Don't use system. It's mounted read-only and must only be used for firmware (or root-related) stuff. I'd also suggest not to use data, except for testing and learning. Does it offer so much more space than your sd card that it's worth it?
    – ce4
    Commented Jul 20, 2012 at 11:39
  • How can I list music also from /system/media/audio into music player? This will help me to play the mp3 from system memory rather than SD Card. I want to make minimal change to do this. By hacking at some place in mediaScanner I think it is possible but is there a better method where I can list music from SD Card as well as from /system/media/audio ??? Thanks in advance.
    – dls
    Commented Jul 20, 2012 at 11:39
  • I am using only for some experimental setup. So I am fine with using /system also for mp3 playback.
    – dls
    Commented Jul 20, 2012 at 11:42
  • Be warned, editing /system will survive a wipe (or reset), FYI. maybe do a 'ln -s /your/music/location /mnt/music' and have the rights set appropriate. You need to remount /system read-write before you can write to /music. AGAIN: I suggest you don't do this. (Asking such question here implies you should be more aware of the risks involved. At least IMHO)
    – ce4
    Commented Jul 20, 2012 at 11:48
0

To furnish my thoughts, hacking on just the in-built media-scanner will not just suffice, as that requires rolling your own ROM! The reason being is that media-scanner is signed with a system certificate that is shared with the ROM in question.

And thus, that requires having the signed keys from the original ROM in order to replace the in-built media-scanner.

As to attempting to put MP3s in the /system/media/audio folder - why? Are we talking about album mp3s which can creep up to between 5-8Mb in size? Or are we talking about Ogg Vorbis for ringtones/notifications?

The /system partition is limited in size depending on the manufacturer's handset setup in terms of partition layouts.

If the audio media is stored on the SDCard under the respective directory /sdcard/media/audio/Ringtones and /sdcard/media/audio/notifications, along with a URI (Uniform Resource Identifier) pointing to the appropriate media declared as "external storage media" as in "MediaStore.Audio.Media.EXTERNAL_CONTENT_URI" (see the Developer Documentation on this), it will get picked up by Android itself and will show under the Settings > Sounds, as 'Phone ringtone' or in 'Notification ringtone'.

Depending on the ROM in itself, there may be a Development tools called 'Dev Tools', in there, there is an activity which can trigger the invocation of the in-build Media-Scanner, this is in stock/vanilla AOSP Android.

-1

If you have a standard Linux file system (i.e., not FAT32) on your SD card, you could create Soft Link of /data in /mnt/sdcard.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .