[DEV] Taming the MediaScanner - Android Software/Hacking General [Developers Only]

The MediaScanner is kind of a pig. It also turns out that even though the Android Developer docs tell you that Android only uses a specific set of media directories on an SDcard, the Scanner always scans every directory on the card.
(Android Docs)
I've patched it so that only these specific directories are scanned, which saves a lot of time for me now, and I don't have to mess around with the stupid ".nomedia" files to keep the scanner from looking where it doesn't belong.
Patch is here:
https://gitorious.org/hycdroid/pack...mmit/7552a1d66cdc718e0a3e3a22e55151a289a94fd1
If you're building your own ROMs you might want to adopt this. For XDAndroid installed on an SDcard life is unbearable without it.
Looks like there was already an existing bug report filed with Google about this
http://code.google.com/p/android/issues/detail?id=11731
I've added my info there too.

This is usefull, if sd card no media files exists, not scan directory /system/media/audio yet.
Do we need to include this internal dirctory for MediaScanner?
Althought weekend comes, it's late now.

I didn't change any of the behavior for scanning internal storage. So /system/media is the same as before.
Sent from my MSM using Tapatalk

Just added the relevant Google bug report info to the first post.

How would I apply the media scanner patch to my device?

wmg316 said:
How would I apply the media scanner patch to my device?
Click to expand...
Click to collapse
Hm, it doesn't look like it's a signed app. Maybe you can just use mine. Try it and let me know if it runs or crashes on you.
First go to the Market and install "Rescan Media Root" - this lets you invoke the MediaScanner on demand. You'll want to have this to verify the fix without needing a reboot.
In one window on your PC, backup your existing MediaProvider.apk:
Code:
adb shell
mount -o remount,rw /system
cd /system/app
mv MediaProvider.apk MediaProvider.apk.O
In another window, install the new one:
Code:
adb push MediaProvider.apk /system/app/
In the first window:
Code:
mount -o remount,ro /system
Then go to Settings / Applications / Manage Applications / All / Media Storage
and press "Clear Data" to wipe out your existing mediascanner database.
Open the Gallery app and you should see that it's totally empty.
Then run the Rescan Media app. It should say "Everything worked fine." Press the Back button to quit it.
Then open the Gallery app again and you should see some media, but not as much as before. If that worked then you're all set. Your next reboot should go a lot faster...

Related

Backing up apps / data (plus archiving/restore idea)

Ok, even though I have market and browser cache being saved to my sdcard, I still occasionally run into space issues due to the small /data partition. Prior to removing apps, I decided to back up my apps and data.
I have backed up my data partition using:
busybox tar -cvf /sdcard/data_backup_20081206.tar /data
After saving a copy to my computer via USB, I did MD5 checksum checks to make sure no corruption during the copy. I still need to do tests to see if I ever have corruption based on the thread in this forum.
* Anyone else making backups using other methods (rsync, etc.)?
--------------------------------------
This got me thinking to some other phone OS's that don't really run apps from SDCARDS, but rather store them and copy them to the phone prior to running them.
I would think that we could (with root access) write an app that moves files from the /data folders to a /sdcard/dataarchive folder, when you wanted to archive an app you don't use much and wanted to save space. Then the Archiver app could restore the files when you eventually wanted to run the app.
* Is there an easy way to see what files are used by each app? Someone mentioned a manifest file at one point.
For example, it looks like neocore is at minimum using:
/data/dalvik-cache/[email protected]@[email protected]
/data/app/com.qualcomm.qx.neocore.apk
/data/data/com.qualcomm.qx.neocore
* Is there a thread someone could point me to that better explains the whole APK packaging and storage of applications and their data?
** Is the structure usually just as above, except just replacing com.qualcomm.qx.neocore with the proper app name?
** When do things get saved to app-private?
O' great community... thanks for your help.
-oldsk00lz
i was looking for a way to synch my /Music and my /Pictures so I came across this blog. im mounting the g1's sdcard on a linux machine in this scenario
http://philnelson.name/tag/rsync/
heres my script that i use. hope this helps a little.
Code:
#!/bin/bash
echo "Syncing /Music /media/FC30-3DA9/Music for updates to /media/E0E4-AA14................................................................."
rsync -rvv /media/FC30-3DA9/Music /media/E0E4-AA14
echo "Syncing /Music /media/E0E4-AA14 for updates to /media/FC30-3DA9/Music................................................................."
rsync -rvv /media/E0E4-AA14/Music /media/FC30-3DA
echo "Syncing /Music /media/E0E4-AA14 for updates to /media/FC30-3DA9/Music................................................................."
rsync -rvv /media/E0E4-AA14/dcim /media/FC30-3DA9/Pictures/g1Cam

Question about adding stock apps back

I have read and still don't understand how to add back apps like Sprint TV. I have them all saved on my computer I just do not know the commands to get them back into the phone. Do the apps I want to ad back need to be in a certain dir on my computer first. If someone could explain or either point me to a thread that explains this I would really appriciate it.
Seems I found an easy way to add sprints, htc's apps back into the phone once removed. I saved all of them on my computer and used HTC Sync to install the app back. I removed Nscar as a test using root manager, rebooted and it was gone, then opened up HTC synch and added it back. Not sure how to get the odex files back in but it works with apk files.
AFter testing it om HTCfootprints it would not install this. Installed Nscar with no problems.
I am also trying to figure out how to add sprint tv back onto my Hero. I see that people are saying to use adb push, but I can't seem to get it to work. I just rooted with the new fresh rom and everything is great, I just want to add back sprint tv. Any help would be appreciated, thanks
Im a total noob, but I got it the apps back on this way:
Go to the directory where the ADK Tools directory is. Then the following commands:
adb shell
su
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
chmod 777 /system
chmod 777 /system/app
exit
exit
Then I copied the .apk files that I wanted to push to the tools directory
I am in.
Then did this:
adb push Sprint_TV.apk /system/app
I found it is case sensitive, so make sure you type the filename exactly.
I rebooted my phone and the apps (such as Sprint TV) were back.
I hope this helps, like I said, I spent an hour trying to figure it out, but this worked for me.
I would not recommend doing a chmod 777 on your system or app directory. Not that anything bad will necessarily happen, but it's generally not a good idea to mess with system file permissions when you don't have to.
Your procedure would work fine without those commands at all, in fact. You don't even need to enter the shell; just adb remount and then adb push.
those instructions worked perfectly. Thanks a ton.
I tried this with HtcFootprints. I removed the widget as well. When I added all 4 back in I can see the widget for footprints, but the footprint icon does not show up in the apps section.
Another thing of intrest. When I added Nscar back using HTC Sync, it now shows up as a third party app. It is no longer a system app and I can uninstall it like a market app.
Ok scratch that I did the Footprints again and the Icon is now there Thanks a Ton
I was able to push HtcTwitter.apk and .odex. i cannot get the widget to show up in the add HTC widgets menu. Any ideas?
Well, after trying my hand at update/rom modding with some success... I'm willing to take a shot at making update.zip files to easily flash individual stock apps back onto your phone. That's if there's any interest.
obelisk79 said:
Well, after trying my hand at update/rom modding with some success... I'm willing to take a shot at making update.zip files to easily flash individual stock apps back onto your phone. That's if there's any interest.
Click to expand...
Click to collapse
That would be great and very helpful to many
Easy Peasy App Install
I just copied the files to my SD card. I then browsed to the SD card folder using Linda File Manager and "clicked" the file. It asked me if I wanted to use Linda File Manager or Package Installer. I selected Package Installer and it proceeded to installed the package for me. Not need to get into the console or use any commands.
VOILA!

Cannot delete files or folders within /data/data/

Setup: CROMI 3.4.7 with Data2SD
I am having issues deleting folders and files within the /data/data/ portion of my file structure. I have tried with both th File Manager HD and ES File Explorer but I keep getting messages saying that I am unable to delete those folders and files.
The reason I am trying to delete this is because I was unable to install certain apps, and continually got an error message during installation that said:
Unknown error code during application install: "-24"
From searching forums, I found that the issue is that previous installations (I guess I forgot to do a factory reset before reflashing a ROM) left certain system folders and files for certain applications, which prevented a fresh installation from taking place. Other users have resolved this issue by deleting the relevant files in the /data/data/ section of their tablet.
I have circumvented the issue by renaming those folders (which for some reason works), but still cannot delete those renamed folders. I've tried messing with the permissions, but still no luck.
Any ideas?
Possibly an ownership problem?
Boot into recovery, plug in the USB cable, go into adb shell. Make sure that /data is mounted. Then do something like:
cd /data/data
chown -R media_rw.media_rw *
Might wanna backup first...
danger-rat said:
cd /data/data
chown -R media_rw.media_rw *
Click to expand...
Click to collapse
Don't do that if you want any apps to work afterwards.
Eeeeek, good catch!
I was thinking data/media.
You could do this just for the specific folders you want to delete, but not all...

[Help] Changes to /system won't stick, even after mounting as rw

I've posted about this on StackExchange here (http://android.stackexchange.com/q/157846/126804) but it seems no one can/bothers to answer it. More details are available in the link.
I'm currently trying to convert some user apps into system apps. I've successfully moved the apps into /system/app by making a NAND image and mounting it on Linux, but it throws an error when I try to launch those apps (ClassNotFoundException, something about missing dex). I've already set the permissions the same as the other apps inside /system/app.
Another thing that I've noticed is that I can make any change to /system (copying files, editing, renaming, etc.), but everything gets wiped after a reboot. The same happens with another partition named /custpack (this is what the OEM uses to fill the phone with boatware). I've also tried to place the apps there, but same thing.
How can I debug this?

Mount binding SD card folder works for moving WhatsApp media

¿Why do people use xposed or foldermount? It is pretty easy to accomplish a binding mount.
BTW, I tried foldermount and it failed because it didn't fix permissions
And link2SD didn't even try moving the WhatsApp media
Here we go: (commands run from adb, could use terminal):
First, move your WhatsApp content to the sd card. (I moved /data/media/0/WhatsApp/* to /data/sdext2/WhatsApp/)
Now fix permissions (and ownership)
Code:
chown -R root:root /data/sdext2/WhatsApp
chmod -Rv 777 /data/sdext2WhatsApp
Now, mount the sdcard folder into the internal memory folder
Code:
mount -o bind /data/sdext2/WhatsApp /data/media/0/WhatsApp
Considering
/data/sdext2 is a mounted external sdcard. This means that the folder is accessible. Makes sense since you just created /data/sdext2/WhatsApp to move the WhatsApp media into there.
/data/media/0/WhatsApp is the WhatsApp folder It is the original location of the WhatsApp media and MUST EXIST check its permissions, too, btw, just in case. Always try the real location ignore /storage/emulated/0/WhatsApp or any other symlink or emulated
Now restart whatsapp and test. Working means you can access your downloaded pictures and you can download new ones. Either that or, In which way is it not working?
If it works ok, make the code line which mounts the folder to be run on startup. I pasted it in my /system/etc/init.d folder because my rom supports it. If you are following this guide, you probably know how to make code run on startup.
It is so easy, why are people installing apps or frameworks for something SO FREAKIN' EASY!?
BTW, whatsapp couldn't use symlink. That's why I had to use a foldermount.
tested on: lollipop 5.0, samsung i9500, halcyon rom and kernel
pppppp said:
¿Why do people use xposed or foldermount? It is pretty easy to accomplish a binding mount.
tested on: lollipop 5.0, samsung i9500, halcyon rom and kernel
Click to expand...
Click to collapse
Did you by any chance get to test with pie? Or are you still on ancient lollipop?

Categories

Resources