Android emulated sdcard
程序员文章站
2024-01-17 16:34:10
...
如果要添加 emulated sdcard ,需要一下几个内容修改:
1. patch:
- diff --git a/init.rc b/init.rc
- index bd6c22e..3a55e6a 100755
- --- a/init.rc
- +++ b/init.rc
- @@ -184,11 +184,15 @@ on post-fs-data
- # create directory for DRM plug-ins
- mkdir /data/drm 0774 drm drm
- + # 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
- +
- # If there is no fs-post-data action in the init.<device>.rc file, you
- # must uncomment this line, otherwise encrypted filesystems
- # won't work.
- # Set indication (checked by vold) that we have finished this action
- - #setprop vold.post_fs_data_done 1
- + setprop vold.post_fs_data_done 1
- chown system system /sys/class/android_usb/android0/f_mass_storage/lun/file
- chmod 0660 /sys/class/android_usb/android0/f_mass_storage/lun/file
- @@ -509,3 +513,9 @@ service iprenew_eth0 /system/bin/dhcpcd -n
- disabled
- oneshot
- +# 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
- +service sdcard /system/bin/sdcard /data/media /mnt/shell/emulated 1023 1023
- + class late_start
- +
- diff --git a/device.mk b/device.mk
- index bd72276..c836943 100755
- --- a/device.mk
- +++ b/device.mk
- @@ -6,6 +6,8 @@ PRODUCT_PACKAGES := \
- VisualizationWallpapers \
- librs_jni
- +PRODUCT_CHARACTERISTICS += nosdcard
- +
- DEVICE_PACKAGE_OVERLAYS := \
- device/stm/kem/overlay
- diff --git a/overlay/frameworks/base/core/res/res/xml/storage_list.xml b/overlay/frameworks/base/core/res/res/xml/storage_list.xml
- new file mode 100644
- index 0000000..043530d
- --- /dev/null
- +++ b/overlay/frameworks/base/core/res/res/xml/storage_list.xml
- @@ -0,0 +1,41 @@
- +<?xml version="1.0" encoding="utf-8"?>
- +<!--
- +**
- +** Copyright 2011, The Android Open Source Project
- +**
- +** Licensed under the Apache License, Version 2.0 (the "License")
- +** you may not use this file except in compliance with the License.
- +** You may obtain a copy of the License at
- +**
- +** http://www.apache.org/licenses/LICENSE-2.0
- +**
- +** Unless required by applicable law or agreed to in writing, software
- +** distributed under the License is distributed on an "AS IS" BASIS,
- +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- +** See the License for the specific language governing permissions and
- +** limitations under the License.
- +*/
- +-->
- +
- +<!-- The <device> element should contain one or more <storage> elements.
- + Exactly one of these should have the attribute primary="true".
- + This storage will be the primary external storage and should have path="/mnt/sdcard".
- + Each storage should have both a path and description attribute set.
- + The following boolean attributes are optional:
- +
- + primary: this storage is the primary external storage
- + removable: this is removable storage (for example, a real SD card)
- + emulated: the storage is emulated via the FUSE sdcard daemon
- + mtp-reserve: number of megabytes of storage MTP should reserve for free storage
- + (used for emulated storage that is shared with system's data partition)
- +
- + A storage should not have both emulated and removable set to true
- +-->
- +
- +<StorageList xmlns:android="http://schemas.android.com/apk/res/android">
- + <storage android:storageDescription="@string/storage_internal"
- + android:emulated="true"
- + android:mtpReserve="100" />
- +</StorageList>
2. kernel config
需要 CONFIG_FUSE_FS=y
查看有没有 /mnt/sdcard:
开机后adb shell进去后df下即可