这个方法只适合有内置存储的情况,至于和平分区的不在考虑之列
1 在vendor/sprd下新建一个文件夹built_in_video 里边放置要内置的视频文件及copy脚步
脚步如下:internal_media.mk
LOCAL_PATH:= vendor/sprd/built_in_video
PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/media/Girs_Gee_0.mp4:system/preloadvideo/Girs_Gee_0.mp4
把这个internal_media.mk include到主mk中
include vendor/sprd/built_in_video/internal_media.mk
2 在vendor/sprd/open-source/tools新建文件夹preloadvideo里边放置加载内置U盘后把system/preloadvideo/Girs文件复制到内置U盘中
Android.mk如下
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := preloadvideo.sh
LOCAL_MODULE_CLASS := EXECUTABLES
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
LOCAL_SRC_FILES := preloadvideo.sh
include $(BUILD_PREBUILT)
#!/system/bin/sh
PRELOAD_DEST=/storage/sdcard0/Movies
PRELOAD_FLAG=${PRELOAD_DEST}/preloadvideo
PRELOAD_SOURCE=/system/preloadvideo
if [ ! -d ${PRELOAD_DEST} ]
then
mkdir -p ${PRELOAD_DEST}
fi
if [ ! -f ${PRELOAD_FLAG} ]
then
files=$(ls ${PRELOAD_SOURCE}/)
for i in ${files};do
cat ${PRELOAD_SOURCE}/${i} > ${PRELOAD_DEST}/${i}
done
echo "abcd" > ${PRELOAD_FLAG}
fi
在主工程主mk中添加
PRODUCT_PACKAGES += \
preloadvideo.sh
3 在和工程mk相同的文件夹下的init.board.rc
service preloadvideo /system/bin/logwrapper /system/xbin/preloadvideo.sh
class main
disabled
oneshot
preloadvideo.sh
4 frameworks/base/services/java/com/android/server/MountService.java
在方法notifyVolumeStateChange
else if (newState == VolumeState.Mounted) {
if (DEBUG_EVENTS) Slog.i(TAG, "updating volume state mounted");
updatePublicVolumeState(volume, Environment.MEDIA_MOUNTED);
action = Intent.ACTION_MEDIA_MOUNTED;
android.os.SystemProperties.set("ctl.start", "preloadvideo");
这个是加载内置存储的时候运行service preloadvideo把视频复制到内置存储中