这种方法仅仅适合有内置存储的情况,至于和平分区的不在考虑之列
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
在主project主mk中加入
PRODUCT_PACKAGES +=
preloadvideo.sh
3 在和projectmk同样的目录下的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把视频拷贝到内置存储中