MTK_2SDCARD_SWAP=yes
#yes means Internal && SDcard, no means Internal && Phone
打开时应用可选安装位置是内部存储空间或外置SD卡
关闭时应用仅可以装在内部存储空间或内置SD卡上。
MTK_2SDCARD_SWAP=no
MTK_SHARED_SDCARD=yes
这种情况下APK只能安装在设备内存(internal device storage),无法安装到内置T卡;
内置资源:
(1)MTK_SHARED_SDCARD=no
当MTK_SHARED_SDCARD=no,参考文档Make_And_DL_FAT_Image.pdf
linux下,以root登录,用mkfs.vfat建立loop device for FAT Image
adb remount && adb shell
//取得FAT partition id
# cat /proc/emmc
//根据ID得到FAT partition size
# cat /proc/partitions
//mmcblk0p8 1760768
mkfs.vfat -v -C fat.img 1760768
2.
把fat.img mount到指定目录
mkdir fat_disk
sudo mount -o loop,iocharset=utf8 fat.img fat_disk/
用df命令可以看到/dev/loopx被mount到此
3.
将预置资源放入fat_disk
sudo cp -r '../apks_preInstall' .
4.
sudo umount fat_disk/
5.
压缩
cd '../mediatek/build/tools'
chmod +x trim
./trim '../fat.img' fat_sparse.img
6.
修改scatter.txt
partition_name: FAT
is_download: true
参考FAQ12384,处理Recovery时的状况
1,预置同样的资源到user不可见的分区,misc\system\data\apks_preInstall.
2,recovery结束,拷贝资源到SD卡上。
...\bootable\recovery\Recovery.cpp
static int restore_dir_file(char *des_dir_path, char *src_dir_path)
{
int ret= 0;
DIR* dir_des = NULL;
DIR* dir_src = NULL;
struct dirent* de_des = NULL;
struct dirent* de_src = NULL;
FILE * fdes = NULL;
FILE * fsrc = NULL;
char src_file_path[256] = {0};
char des_file_path[256] = {0};
char buf[256] = {0};
int name_len = 0;
int size = 0, file_len = 0;
printf("\n\nenter, %s \n\n", __func__);
printf("src dir:%s\n", src_dir_path);
printf("des dir:%s\n", des_dir_path);
//open dir
dir_src = opendir(src_dir_path);
if(dir_src == NULL) {
printf("open src dir error:%s\n", src_dir_path);
return -1;
}
dir_des = opendir(des_dir_path);
if(dir_des == NULL) {
ret = -1;
if(errno == ENOENT) {
printf("des dir not exist:%s\n", des_dir_path);
ret = mkdir(des_dir_path, (S_IRWXU | S_IRWXG | S_IRWXO));
}
if(ret < 0) {
closedir(dir_src);
printf("open des dir error:%s\n", des_dir_path);
return -1;
}
else {
printf("mkdir des dir:%s\n", des_dir_path);
dir_des = opendir(des_dir_path);
}
}
printf("dir_src=%d, dir_des=%d\n", dir_src, dir_des);
while ((de_src = readdir(dir_src)) != NULL) {
printf("d_name: %s\n", de_src->d_name);
if (de_src->d_type == DT_DIR) {
name_len = strlen(de_src->d_name);
// skip "." and ".." entries
if ((name_len == 1 && de_src->d_name[0] == '.') ||
(name_len == 2 && de_src->d_name[0] == '.' && de_src->d_name[1] == '.')) {
continue;
}
else {
//src dir path append the folder's d_name
sprintf(src_file_path, "%s/%s", src_dir_path, de_src->d_name);
printf("src dir path: %s\n", src_file_path);
//des dir path append the folder's d_name
sprintf(des_file_path, "%s/%s", des_dir_path, de_src->d_name);
printf("des dir path: %s\n", des_file_path);
printf("---entry sub dir to restore\n");
ret = restore_dir_file(des_file_path, src_file_path);
printf("sub dir restore ret=%d\n", ret);
}
}
else if (de_src->d_type == DT_REG) {
//open src file
sprintf(src_file_path, "%s/%s", src_dir_path, de_src->d_name);
printf("src_file_path: %s\n", src_file_path);
fsrc = fopen(src_file_path, "r");
printf("fsrc=%d\n", fsrc);
//create des file
sprintf(des_file_path, "%s/%s", des_dir_path, de_src->d_name);
printf("des_file_path: %s\n", des_file_path);
fdes = fopen_path(des_file_path, "w");
printf("fdes=%d\n", fdes);
//read from src file, write to des file
file_len= 0;
while (!feof(fsrc)) {
size = fread(buf, sizeof(char), sizeof(buf), fsrc);
fwrite(buf, sizeof(char), size, fdes);
memset(buf, 0, sizeof(buf));
file_len += size;
}
fflush(fdes);
printf("%s: file_len=%d\n", de_src->d_name, file_len);
//close file
fclose(fsrc);
fclose(fdes);
}
}
//close dir
closedir(dir_src);
closedir(dir_des);
printf("\n\nexit, %s \n\n", __func__);
return 0;
}
int recovery_restore_special(char *des_dir_path, char *src_dir_path)
{
int ret= 0;
printf("\n\n++ %s ++\n\n", __func__);
printf("src dir:%s\n", src_dir_path);
printf("des dir:%s\n", des_dir_path);
//mount path
ret = ensure_path_mounted(src_dir_path);
if(ret < 0) {
printf("mount src dir error:%s\n", src_dir_path);
return -1;
}
printf("mount:%s ret=%d\n", src_dir_path, ret);
ret = ensure_path_mounted(des_dir_path);
if(ret < 0) {
printf("mount des dir error:%s\n", des_dir_path);
ensure_path_unmounted(src_dir_path);
return -1;
}
printf("mount:%s ret=%d\n", des_dir_path, ret);
//restore dir and file
ret = restore_dir_file(des_dir_path, src_dir_path);
printf("restore ret=%d\n", ret);
//unmount
ensure_path_unmounted(src_dir_path);
ensure_path_unmounted(des_dir_path);
printf("\n\n-- %s --\n\n", __func__);
return 0;
}
int
main(int argc, char **argv) {
...
//data/apks_preInstall/ ---> /sdcard/apks_preInstall/
recovery_restore_special("/sdcard/apks_preInstall", "/system/data/apks_preInstall");
// Otherwise, get ready to boot the main system...
finish_recovery(send_intent);
ui->Print("Rebooting...\n");
property_set(ANDROID_RB_PROPERTY, "reboot,");
return EXIT_SUCCESS;
}
/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
(2)MTK_SHARED_SDCARD=yes参考FAQ11640 FAQ11614
alps\vendor\mediatek\project_name\artifacts\out\target\product\your_project_name\
下创建data\media\目录,将预制资源放于此目录下,重新build new之后,userdata image中就带有您的预制资源。
FAQ10734(MTK_SPECIAL_FACTORY_RESET)
MTK_SPECIAL_FACTORY_RESET=yes
/*------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
[FAQ11954]实现恢复出厂后不重新启动手机
/bootable/recovery/recovery.cpp文件如下处修改:
// Otherwise, get ready to boot the main system...
finish_recovery(send_intent);
return EXIT_SUCCESS;//添加这一句,直接return,进入recovery mode
ui->Print("Rebooting...\n");
android_reboot(ANDROID_RB_RESTART, 0, 0);
return EXIT_SUCCESS;
}