2012년 2월 9일 목요일

android MTP <-> Mass Storage

android ICS부터 MTP를 지원합니다.
Gingerbread의 Mass Storage 방식으로 수정해 보겠습니다.


overlay/frameworks/base/core/res/xml/storage_list.xml 입니다.


<StorageList xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- removable is not set in nosdcard product -->
    <storage android:mountPoint="/mnt/sdcard"
        android:storageDescription="@string/storage_usb"
        android:primary="true"
        android:emulated="true"
        android:mtpReserve="100" />
</StorageList>

아래와 같이 바꿉니다.



<StorageList xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- removable is not set in nosdcard product -->
    <storage android:mountPoint="/mnt/sdcard"
        android:storageDescription="@string/storage_internal"
        android:primary="true"
        android:emulated="false"
        android:allowMassStorage="true" />
</StorageList>

init.[PRODUCT_NAME].rc

fuse 관련된 부분 삭제 합니다.


on post-fs-data
    # we will remap this as /mnt/sdcard with the sdcard fuse tool
    mkdir /data/media 0775 media_rw media_rw
    chown media_rw media_rw /data/media


on fs
    mount ext4 ...
    mount ext4 ...
    mount ext4 ...
    setprop ro.crypto.fuse_sdcard true

#/sdcard

    export EXTERNAL_STORAGE /mnt/sdcard
    mkdir /mnt/sdcard 0000 system system
    symlink /mnt/sdcard /sdcard



# create virtual SD card at /mnt/sdcard, based on the /data/media directory
# daemon will drop to user/group system/media_rw after initializing
# underlying files in /data/media will be created with user and group media_rw (1023)
service sdcard /system/bin/sdcard /data/media 1023 1023
    class late_start

init.[PRODUCT_NAME].usb.rc


on property:sys.usb.config=mtp
    write /sys/class/android_usb/android0/enable 0
    ...
    ...
    setprop sys.usb.state $sys.usb.config

on property:sys.usb.config=mtp,adb
    ...
    ...
    start adbd

mtp를 mass_storage로 바꿉니다.

그리고 vold.fstab을 만듭니다.


## Vold 2.0 Generic fstab
## - San Mehat (san@android.com)
##

#######################
## Regular device mount
##
## Format: dev_mount <label> <mount_point> <part> <sysfs_path1...>
## label        - Label for the volume
## mount_point  - Where the volume will be mounted
## part         - Partition # (1 based), or 'auto' for first usable partition.
## <sysfs_path> - List of sysfs paths to source devices, must start with '/' character
## flags        - (optional) Comma separated list of flags, must not contain '/' character
######################


dev_mount sdcard /mnt/sdcard auto [vfat mount 할 node] nonremovable,encryptable

그리고 BoardCongig.mk 또는 device.mk에 vold.fstab를 복사하는 문장 추가합니다.

PRODUCT_COPY_FILES += \
device/hardkernel/odroida4/vold.fstab:system/etc/vold.fstab \
        ...

persist.sys.usb.config=mtp를 mass_storage로 변경...


# Set default USB interface
PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
    persist.sys.usb.config=mass_storage


이렇게 수정하면 ICS에서도 Gingerbread의 화면을 보실 수 있습니다.








http://source.android.com/devices/tech/storage/config-example.html

댓글 쓰기