본문 바로가기

개발 개발/Android

ICS에서 MTP대신 Mass Storage 추가하기

출처 : http://codewalkerster.blogspot.com/2012/02/android-mtp-mass-storage.html


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의 화면을 보실 수 있습니다.









'개발 개발 > Android' 카테고리의 다른 글

adb로 메모리 정보 주기적으로 보기  (0) 2012.05.29
Debugging Deadlocks on Android  (0) 2012.05.24
안드로이드 Init 프로세스 분석  (0) 2012.04.29
Android system property 개수  (0) 2012.04.24
Git 사용자 설명서  (0) 2012.03.27