[HELP] Internal Storage not accessible a.k.a How to clear com.android.providers.media.MediaApplication data

Search This thread

0xCuter

Member
Apr 14, 2022
40
1
Hi,

Since a few days I'm unable to see any data in my phone via gallery or file manager or any application, and I'm unable to save any data to internal storage. (example: I'm able to use whatsapp for texting, but I can't receive/send any audio/picture and I can't access the old ones).

And I keep getting this error message:"com.android.providers.media.MediaApplication keeps stopping."

I don't know if that's what causing it or if that's just a consequence of not being able to access internal storage.

I can still see all the used storage from settings though.

Phone has unlocked bootloader, but no root/custom rom/recovery.

I saw other Oneplus users started getting the same error these days... (I have a Oneplus 6, but others have different models like Oneplus Nord).
Someone resolved by wiping system and they were able to retrieve storage content and functionality, but they lost apps data, I'm trying to find another way since I have an unlocked bootloader.

An user on stackoverflow suggested I should clean the com.android.providers.media.MediaApplication app data to regenerate the database, but I couldn't figure out how to do it
I tried cleaning media and media.module packages (not media.MediaApplication) from adb but no luck even if successful.
I tried removing "com.android.providers.media" (not media.MediaApplication, I couldn't find that one) folder from data/data with twrp file manager but no luck...
Is there a way to specifically clean "com.android.providers.media.MediaApplication"?

If anyone has any other suggestion on things to try, post it here please.
Thank you in advance
 

0xCuter

Member
Apr 14, 2022
40
1

0xCuter

Member
Apr 14, 2022
40
1
Btw in theory I could backup even when the phone is on I think, the only thing is that the method should save the files to pc/external otg memory since it's like there is no /sdcard storage... Do you think that's possible with some apps (like titanium or similar)?
 
Last edited:

0xCuter

Member
Apr 14, 2022
40
1
It's Android 11.
I already tried to backup with "adb backup --twrp --compress data", but it asks for confirmation on the phone (swiping I guess) but since the screen is broken I can't see... touch still works but I tried swiping randomly and nothing happens
Found this for the nandroid backup:
You can use open recovery script in TWRP. See http://wiki.rootzwiki.com/OpenRecoveryScript
If you have the file
/cache/recovery/openrecoveryscript
then TWRP will process it when it starts.

If the file contains
backup BSDO myBackup
then the boot (kernel), system, and data partitions will be backed up in compressed format and named myBackup.

So, on your PC, create the openrecoveryscript file, boot into recovery, use ADB to push the file to /cache/recovery/openrecoveryscript then reboot back into recovery. That should trigger the backup process.
Note, the backup will be written to the default location TWRP for backups.
 

alecxs

Forum Moderator
Staff member
Feb 17, 2016
5,092
8
5,313
gitlab.com
I think my script only works for Android 10. The reason it is looking for paths in packages.xml - this file is no longer xml format since Android 11.

I need to fix the script and use abx2xml to convert the packages.xml before processing. should not be a big deal, but I don't think TWRP comes with that binary so I need to know the path, probably /system_root/system/bin/abx2xml and if not a static standalone executable, also the path of the library.

I have another project currently so if you only want Whatsapp, you can get the files from adb.
Code:
adb shell
# tar -vzcpf /sdcard/whatsapp.tar.gz /data/user*/0/com.whatsapp /sdcard/Android/media/com.whatsapp
# exit
adb pull /sdcard/whatsapp.tar.gz

to restore files on other phone just extract the tar.gz into / rootdir.

to restore, you need to know the new uid/gid + secontext of target whatsapp directory beforehand, to set new uid/gid + secontext afterwards:
Code:
# chown -Rh 10123.10123 /data/user*/0/com.whatsapp
# chcon -Rh u:object_r:app_data_file:s0 /data/user*/0/com.whatsapp
(user* stands for user and user_de)

Btw in theory I could backup even when the phone is on I think, the only thing is that the method should save the files to pc/external otg memory since it's like there is no /sdcard storage... Do you think that's possible with some apps (like titanium or similar)?
that's possible with scrcpy over tcpip (wifi) + Migrate. but I still don't understand why you have access to /data but not /sdcard. maybe it's easier to just symlink /storage/emulated/0 to /sdcard and solve that issue.
 
Last edited:
  • Like
Reactions: 0xCuter

0xCuter

Member
Apr 14, 2022
40
1
I think my script only works for Android 10. The reason it is looking for paths in packages.xml - this file is no longer xml format since Android 11.

I need to fix the script and use abx2xml to convert the packages.xml before processing. should not be a big deal, but I don't think TWRP comes with that binary so I need to know the path, probably /system_root/system/bin/abx2xml and if not a static standalone executable, also the path of the library.

I have another project currently so if you only want Whatsapp, you can get the files from adb.
Code:
adb shell
# tar -vzcpf /sdcard/whatsapp.tar.gz /data/user*/0/com.whatsapp /sdcard/Android/media/com.whatsapp
# exit
adb pull /sdcard/whatsapp.tar.gz

to restore files on other phone just extract the tar.gz into / rootdir.

to restore, you need to know the new uid/gid + secontext of target whatsapp directory beforehand, to set new uid/gid + secontext afterwards:
Code:
# chown -Rh 10123.10123 /data/user*/0/com.whatsapp
# chcon -Rh u:object_r:app_data_file:s0 /data/user*/0/com.whatsapp
(user* stands for user and user_de)


that's possible with scrcpy over tcpip (wifi) + Migrate. but I still don't understand why you have access to /data but not /sdcard. maybe it's easier to just symlink /storage/emulated/0 to /sdcard and solve that issue.
Whatsapp would be the only "vital" one, but it would be nice to have some other apps as well...

Btw I don't really know if using the backup apps from phone and not from recovery would work, it was just my supposition since I can use most apps normally except from functions where storage is involved... is there a way to check if I have access without trying directly to backup? (i don't have root atm)

maybe it's easier to just symlink /storage/emulated/0 to /sdcard and solve that issue.
Don't really understand this... one thing for sure is that I don't have access to storage/emulated/0
 

alecxs

Forum Moderator
Staff member
Feb 17, 2016
5,092
8
5,313
gitlab.com
in TWRP, do the last line of post #3. then check your PC platform-tools directory for backup.ab - watch the file size growing. after ~ 1 hour it should be finished. now pull /tmp/recovery.log and look inside, you should see a list of files.
 
  • Like
Reactions: 0xCuter

0xCuter

Member
Apr 14, 2022
40
1
in TWRP, do the last line of post #3. then check your PC platform-tools directory for backup.ab - watch the file size growing. after ~ 1 hour it should be finished. now pull /tmp/recovery.log and look inside, you should see a list of files.
As I said a few posts above I already tried to backup with "adb backup --twrp --compress data", but it asks for confirmation on the phone (selecting partitions + swiping) but since the screen is broken I can't see... touch still works but I don't know which partitions are selected by default

I could try this maybe:
You can use open recovery script in TWRP. See http://wiki.rootzwiki.com/OpenRecoveryScript
If you have the file
/cache/recovery/openrecoveryscript
then TWRP will process it when it starts.

If the file contains
backup BSDO myBackup
then the boot (kernel), system, and data partitions will be backed up in compressed format and named myBackup.

So, on your PC, create the openrecoveryscript file, boot into recovery, use ADB to push the file to /cache/recovery/openrecoveryscript then reboot back into recovery. That should trigger the backup process.
Note, the backup will be written to the default location TWRP for backups.

But what would having the list of files in tmp/recovery.log accomplish?
 

alecxs

Forum Moderator
Staff member
Feb 17, 2016
5,092
8
5,313
gitlab.com
https://twrp.me/faq/openrecoveryscript.html
Code:
adb backup :
	Use the adb backup command of the host computer to backup the device:
        adb backup --twrp [compress] [PARTITION-LIST]
            PARTITION-LIST: partition(s) name(s) without leading '/'. Only partition present into fstab can be backuped.


adb restore  FILENAME :
    Use the adb restore command of the host computer to restore FILENAME where FILENAME is a previously backup taken with adb backup.
this works without confirmation, no need to select partitions. the selection is done from cmd line. Did you check file size grow?
(ignore the confirmation request "WARNING adb backup is deprecated... Now Unlock your device and confirm...")
Code:
adb backup --twrp --compress data
the recovery.log tells you if the backup went successful. But you can also make screenshots with Vol Down + Pwr and pull them. This way you know what is displayed.
 
Last edited:
  • Like
Reactions: 0xCuter

0xCuter

Member
Apr 14, 2022
40
1
https://twrp.me/faq/openrecoveryscript.html
Code:
adb backup :
    Use the adb backup command of the host computer to backup the device:
        adb backup --twrp [compress] [PARTITION-LIST]
            PARTITION-LIST: partition(s) name(s) without leading '/'. Only partition present into fstab can be backuped.


adb restore  FILENAME :
    Use the adb restore command of the host computer to restore FILENAME where FILENAME is a previously backup taken with adb backup.
this works without confirmation, no need to select partitions. the selection is done from cmd line. Did you check file size grow?

the recovery.log tells you if the backup went successful. But you can also make screenshots with Vol Down + Pwr and pull them. This way you know what is displayed.
1. Which partition/s should I choose?
2. Are you making me do the nandroid backup to try this? https://android.stackexchange.com/questions/214065/backup-whatsapp-from-nandroid
3. Wouldn't it be faster to do the "tar -vzcpf" thingy for every app instead?
(I guess the apps I would like to backup are like 5 or less from the top of my mind...)
4. If yes, is this command "precise" or do I need to look up something first to modify it? i didn't understand what you wrote before...
to restore, you need to know the new uid/gid + secontext of target whatsapp directory beforehand, to set new uid/gid + secontext afterwards:
Code:
# chown -Rh 10123.10123 /data/user*/0/com.whatsapp
# chcon -Rh u:eek:bject_r:app_data_file:s0 /data/user*/0/com.whatsapp
And btw, thank you a lot for what you are doing...
 

alecxs

Forum Moderator
Staff member
Feb 17, 2016
5,092
8
5,313
gitlab.com
1. "data" is the only partition needed
2. yes, but it's a backup including secontext..
3. ..which simple tar is not capable of (no --selinux flag)
4. the backup cmd is exact. for restoring you need to replace the uid/gid with actual one (10123.10123 is just example)
you can view with ls -nd ...
 
  • Like
Reactions: 0xCuter

0xCuter

Member
Apr 14, 2022
40
1
1. "data" is the only partition needed
2. yes, but it's a backup including secontext..
3. ..which simple tar is not capable of (no --selinux flag)
4. the backup cmd is exact. for restoring you need to replace the uid/gid with actual one (10123.10123 is just example)
you can view with ls -nd ...
So what's the problem if there is no secontext/--selinux flag? Is it gonna be the same when I do the chown+chcon command?
 

0xCuter

Member
Apr 14, 2022
40
1
Hopefully. but u:object_r:app_data_file:s0 is maybe not the right secontext, so better check that with ls -Zd
Hello Alecxs, sorry to bother you again... So, I tried connecting a USB-key through OTG (using scrcpy over wifi) but it doesn't get reconized (yes, I activated OTG), so Swift Backup/AppDash is not an option.
I was able to backup through "adb backup --twrp --compress data" and it worked like you said... I now have a 5 GB backup.ab file.
What should I do now? Should I follow this? https://android.stackexchange.com/questions/214065/backup-whatsapp-from-nandroid
His backup was into folders though, how do I access the .ab file? And should I put my backup into the new phone for this?

Or should I follow this:
if you only want Whatsapp, you can get the files from adb.
Code:
adb shell
# tar -vzcpf /sdcard/whatsapp.tar.gz /data/user*/0/com.whatsapp /sdcard/Android/media/com.whatsapp
# exit
adb pull /sdcard/whatsapp.tar.gz

to restore files on other phone just extract the tar.gz into / rootdir.

to restore, you need to know the new uid/gid + secontext of target whatsapp directory beforehand, to set new uid/gid + secontext afterwards:
Code:
# chown -Rh 10123.10123 /data/user*/0/com.whatsapp
# chcon -Rh u:eek:bject_r:app_data_file:s0 /data/user*/0/com.whatsapp
(user* stands for user and user_de)

Or now that I have the .ab backup is there another option altogheter?
 

alecxs

Forum Moderator
Staff member
Feb 17, 2016
5,092
8
5,313
gitlab.com
on linux you can convert the backup into win files with this script (the first line). win files can be extracted with tar (the last line).

so install WhatsApp on new phone and open the app once. then replace the files in its directory with the files from backup. update the uid and check WhatsApp again.

Alternative it should be possible to create a Migrate backup of WhatsApp on the new phone, replace the files inside the backup with the files from old WhatsApp and restore it, if that is easier for you.

I could write a script to automatize this, but I don't have time for scripting, so please do it manually like described in post #29.

Unfortunately I didn't had time to fix the other script to work with abx file, that would make it easier with migrate.

I will check XDA few times a day, tell me if you have trouble understanding things.

you could also try to restore the whole backup.ab from TWRP adb to new phone. it probably won't boot, but maybe you're lucky and it works. I have heared people doing this.
 
  • Like
Reactions: 0xCuter

0xCuter

Member
Apr 14, 2022
40
1
on linux you can convert the backup into win files with this script (the first line). win files can be extracted with tar (the last line).

so install WhatsApp on new phone and open the app once. then replace the files in its directory with the files from backup. update the uid and check WhatsApp again.

Alternative it should be possible to create a Migrate backup of WhatsApp on the new phone, replace the files inside the backup with the files from old WhatsApp and restore it, if that is easier for you.

I could write a script to automatize this, but I don't have time for scripting, so please do it manually like described in post #29.

Unfortunately I didn't had time to fix the other script to work with abx file, that would make it easier with migrate.

I will check XDA few times a day, tell me if you have trouble understanding things.

you could also try to restore the whole backup.ab from TWRP adb to new phone. it probably won't boot, but maybe you're lucky and it works. I have heared people doing this.
No worries... no need to write any script
I will try to do it directly on the new phone without going through Migrate

1. Regarding the .ab file conversion, should it work on macos as well? cause I try executing the script, it doesn't give any error but nothing happens...
2. In case I don't wanna go through Migrate I still haven't understood if I should do the "stackexchange link" method from the backup file or the post #29 method directly from the phone data folder... or a combination of the two
 

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    you wrote you already did successfully - obviously that is not the cause. my suspect is broken encryption (you will figure out from recovery.log)
    1
    encrypted files look like this +NiZZaTrs3RFzYegpkEk if encryption is not the reason, it could be symlinks messed up. in android enable usb-debugging and check from adb shell.

    (repeat this for each result)
    Code:
    readlink /sdcard
    readlink ...

    in TWRP recovery check for files like /data/system/uiderrors.txt
    /data/log
    (don't know exact names) you can adb pull files to PC and inspect with wordpad or Notepad++

    last but no least you can capture logcat during boot for further analysis
    Code:
    adb logcat > logcat.txt

    if you're going to factory reset device, install Magisk from TWRP and backup apps to usb flash drive with Migrate-NG beforehand. copy all your pictures + backups to PC
    Code:
    adb pull -a /sdcard

    if you can't install Migrate or can't get usb-otg to work, get a backup to PC at least, I can tell you how to restore single apps from it later (ignore the confirmation request "WARNING adb backup is deprecated... Now Unlock your device and confirm...")
    Code:
    adb backup --twrp --compress data
    1
    -as previously stated the phone is not able to access internal storage, but I'm able to access it in recovery mode through adb so pulling files should not be an issue.
    yes, if that is true all fine, you can run the Migrate_EMERGENCY_FLASHABLE.zip from recovery and restore app data on other device with Migrate
    1
    yes, you can do it from adb. best is MicroSD Card as target directory. copy the zip into the target directory, mount data system vendor product, then install zip. on the first trial it will fail because packages.list needed. but it will create one you can edit. delete unwanted packages before second trial. you can repeat as often you want, existing backups won't created twice.

    Code:
    adb push Migrate_EMERGENCY_FLASHABLE.zip /sdcard
    adb shell
    # mount /system_root
    # mount /system
    # mount /vendor
    # mount /product
    # mount /external_sd
    # mkdir /external_sd/Migrate
    # cd /external_sd/Migrate
    # mv /sdcard/Migrate_EMERGENCY_FLASHABLE.zip .
    # twrp install ./Migrate_EMERGENCY_FLASHABLE.zip
    # exit
    adb pull /external_sd/Migrate/packages.list
    edit the file with editor and push it back

    https://twrp.me/faq/openrecoveryscript.html
    1
    No need to root old phone, TWRP already provides root access for backup purposes. the new phone should be rooted by flashing magisk patched boot.img because the TWRP install method is deprecated. I know I gave only short hints, so don't hesitate to ask for more detailed instructions in case you don't know what to do for some specific step...