Since Android 4.2 the situation has become worse because of permissions and security changes and multi user support. The patch I am discribing here is not multi user compatible, i.e. all user will see all files on the external disk. So be warned if you want to use this feature.
First I want to describe a bit the modifications which need to be done to enable native OTG USB
- platform.xml is to be modified in such a way, that media_rw is allowed to access the external storage
<permission name="android.permission.WRITE_EXTERNAL_STORAGE" >
<group gid="sdcard_rw" />
<group gid="media_rw" />
</permission>
- vold.fstab is to be modified in such a way, that the usb is mounted automatically when the stick is plugged in
# Mounts the first usable partition of the specified device
dev_mount usbdisk /mnt/otg-usb auto /devices/platform/tegra-ehci.0
- init.grouper.rc is to be modified that on startup the mount directory is created
on init
...
mkdir /mnt/otg-usb 0777 sdcard_rw sdcard_rw
- storage_list.xml in framework-res.apk is to be modified that the external storage is added
<!-- external USB OTG storage -->
<storage android:mountPoint="/mnt/otg-usb"
android:storageDescription="@string/storage_usb"
android:primary="false"
android:removable="true" />
As you can see on the different files to be modified, several components of the Android system are involved, i.e.
- prepare a new ramdisk.img
- prepare a new framework-res.apk
- patch the platform.xml
I prepared an update.zip which applies the required modifications. The update.zip contains:
- a new boot.img including my kernel (based on android-tegra3-grouper-3.1-jb-mr1.1, but I've added DM9601 and KSM support) and a ramdisk.img with the required modifications for the otg-usb support.
- a patched framework-res.apk
- a modified platform.xml
This update is compatible only with stock Android 4.2.2 (JDQ39) and it will break future OTA updates!
If you want to apply this patch, so be sure you know what you are doing and do it on your own risk. I am not responsible for any bricks, data loss, etc.
Please note: I've tested this only on the Nexus 7 (WiFi) and I am not sure, whether it will work on the GSM-version, too, even if I believe it should work, it's disabled in the updater script at the moment.
Another thing to note: Currently only vFAT partitions are recognized. NTFS principially is supported, but vold is not handling NTFS correctly and displays an empty filesystem / a partition to be formatted.
Update 21.02.2013: I've added a pached vold to the new otg-usb-enable-20130221.zip. Now it's possible to mount also NTFS filesystems, but read only at the moment.
hello, i really want enable native otg in my nexus 7 with stock Rom but I want to known if is there a way to use it with others custom kernels, i like m-kernel
AntwortenLöschenhi again, the patch works really great, thank for your work, there only a little thing, when i unmount the usb and remove the usb stick, appear a persistent notification saying to insert a new media, how can i disable or make this notification not be persistent?
AntwortenLöschenThe boot.img contains an intramfs where there are some modifications so that ntfs mounts are working. Due to that you cannt use a different kernel, unless it contains the required modifications.
AntwortenLöschenit's difficult compile another kernel with these modifications?, for try to compile the source code of the M-kernel with this modification
LöschenNo, it's not difficult, the changes to do are described above in the text. It's only, that you need to find / checkout the sources, to get it to compile, to apply the modifictions, to prepare the initramfs and to pack it into a boot.img. Easiest way would be to integrate the new kernel into the android build process ...
LöschenIt's not difficult, but takes some time ;-)
Unfortunately the notification behaviour is "standard" and I didn't find a simple solution to remove it. By simple I mean without modifying too much and building almost a custom rom ... ;-)
AntwortenLöschenthanks for answer :)
AntwortenLöschen