`
quanminchaoren
  • 浏览: 911328 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Android emulated sdcard

阅读更多

如果要添加 emulated sdcard ,需要一下几个内容修改:

 

1. patch:

 

  1. diff --git a/init.rc b/init.rc  
  2. index bd6c22e..3a55e6a 100755  
  3. --- a/init.rc  
  4. +++ b/init.rc  
  5. @@ -184,11 +184,15 @@ on post-fs-data  
  6.      # create directory for DRM plug-ins  
  7.      mkdir /data/drm 0774 drm drm  
  8.   
  9. +    # we will remap this as /mnt/sdcard with the sdcard fuse tool  
  10. +    mkdir /data/media 0775 media_rw media_rw  
  11. +    chown media_rw media_rw /data/media  
  12. +  
  13.      # If there is no fs-post-data action in the init.<device>.rc file, you  
  14.      # must uncomment this line, otherwise encrypted filesystems  
  15.      # won't work.  
  16.      # Set indication (checked by vold) that we have finished this action  
  17. -    #setprop vold.post_fs_data_done 1  
  18. +    setprop vold.post_fs_data_done 1  
  19.   
  20.      chown system system /sys/class/android_usb/android0/f_mass_storage/lun/file  
  21.      chmod 0660 /sys/class/android_usb/android0/f_mass_storage/lun/file  
  22. @@ -509,3 +513,9 @@ service iprenew_eth0 /system/bin/dhcpcd -n  
  23.      disabled  
  24.      oneshot  
  25.   
  26. +# create virtual SD card at /mnt/sdcard, based on the /data/media directory  
  27. +# daemon will drop to user/group system/media_rw after initializing  
  28. +# underlying files in /data/media will be created with user and group media_rw (1023)  
  29. +#service sdcard /system/bin/sdcard /data/media 1023 1023  
  30. +service sdcard /system/bin/sdcard /data/media /mnt/shell/emulated 1023 1023
  31. +    class late_start  
  32. +  
  33. diff --git a/device.mk b/device.mk  
  34. index bd72276..c836943 100755  
  35. --- a/device.mk  
  36. +++ b/device.mk  
  37. @@ -6,6 +6,8 @@ PRODUCT_PACKAGES := \  
  38.      VisualizationWallpapers \  
  39.      librs_jni  
  40.   
  41. +PRODUCT_CHARACTERISTICS += nosdcard  
  42. +  
  43.  DEVICE_PACKAGE_OVERLAYS := \  
  44.      device/stm/kem/overlay  
  45.   
  46. diff --git a/overlay/frameworks/base/core/res/res/xml/storage_list.xml b/overlay/frameworks/base/core/res/res/xml/storage_list.xml  
  47. new file mode 100644  
  48. index 0000000..043530d  
  49. --- /dev/null  
  50. +++ b/overlay/frameworks/base/core/res/res/xml/storage_list.xml  
  51. @@ -0,0 +1,41 @@  
  52. +<?xml version="1.0" encoding="utf-8"?>  
  53. +<!--  
  54. +**  
  55. +** Copyright 2011, The Android Open Source Project  
  56. +**  
  57. +** Licensed under the Apache License, Version 2.0 (the "License")  
  58. +** you may not use this file except in compliance with the License.  
  59. +** You may obtain a copy of the License at  
  60. +**  
  61. +**     http://www.apache.org/licenses/LICENSE-2.0  
  62. +**  
  63. +** Unless required by applicable law or agreed to in writing, software  
  64. +** distributed under the License is distributed on an "AS IS" BASIS,  
  65. +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
  66. +** See the License for the specific language governing permissions and  
  67. +** limitations under the License.  
  68. +*/  
  69. +-->  
  70. +  
  71. +<!-- The <device> element should contain one or more <storage> elements.  
  72. +     Exactly one of these should have the attribute primary="true".  
  73. +     This storage will be the primary external storage and should have path="/mnt/sdcard".  
  74. +     Each storage should have both a path and description attribute set.  
  75. +     The following boolean attributes are optional:  
  76. +  
  77. +        primary:    this storage is the primary external storage  
  78. +        removable:  this is removable storage (for example, a real SD card)  
  79. +        emulated:   the storage is emulated via the FUSE sdcard daemon  
  80. +        mtp-reserve: number of megabytes of storage MTP should reserve for free storage  
  81. +                     (used for emulated storage that is shared with system's data partition)  
  82. +  
  83. +      A storage should not have both emulated and removable set to true  
  84. +-->  
  85. +  
  86. +<StorageList xmlns:android="http://schemas.android.com/apk/res/android">  
  87. +    <storage android:storageDescription="@string/storage_internal"
  88. +             android:emulated="true"  
  89. +             android:mtpReserve="100" />  
  90. +</StorageList>  


2. kernel config

       需要 CONFIG_FUSE_FS=y

 

查看有没有 /mnt/sdcard:

       开机后adb shell进去后df下即可

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics