I have one phone that upon plugged into a computer, shows up as an MTP device. The SD card and the internal storage are visible on the computer. I can also change it to only mount the SD card and then it unmounts the SD card from the phone and directly connects it like if it were to be an SD to USB adapter.
I want to be able to do this on another phone, but not with an SD card, I want to be able to use a part of the internal flash memory in the same manner so that I can connect the phone as if it were a USB stick and I also want to be able to connect it as an MTP device. It would be handy if I can do this with tmpfs too, so I can basically use the phone's available RAM as temporary high speed USB storage.
The reason I want to do this is because MTP is incredibly slow for loading the directories, file transfer is a bit faster but still a fraction of what USB 2.0 can achieve. I want to use the RAM so that the internal storage isn't affected and filled up for no reason since the phone doesn't have that much free storage. On the other phone, connecting it in SD card adapter mode causes windows to see it as an actual sd card so Windows doesn't open the storage in MTP mode which misses file properties and is super sluggish. Another reason for using RAM is that the internal storage can't be unmounted while Android is running on the phone so you wouldn't be able to use it as USB storage in anything other than MTP.
Are there any ways of doing this using busybox, or by modifying some system files?
I know this has to be possible but I don't know how it works with the SD card adapter mode on the ohter phone and I don't know how to replicate it for other storage media. The phone is rooted so I can do anything to the system I want. Preferrably on Android 4 and up. How can I accomplish such result?
- Update
I was able to get UMS working on the phone thanks to Irfan's comment. I can change the drive that mounts by editing the "file" file.
To do this, first the command cat /proc/partitions
.
Then you can write echo '/dev/block/vold/<major>:<minor>' -n> /sys/devices/virtual/android_usb/android0/f_mass_storage/lun/file
I am not done yet though, I need to know how to now how to forward the path in "file" to tmpfs. I can't find a device file for tmpfs like all the other partitions. Is there a vold partition for tmpfs, or can I maybe link to a folder in file? How can I put the path to tmpfs inside "file"?