客户预置了一些资源在内置的/data/media/0/目录下,但是恢复出厂设置会把data给清掉,需要在恢复出厂设置时不删除掉/data/media/0/的特定文件:
大致有两种思路:
1.将需要保留的目录在删除前复制到另外一个分区,比如cache分区,格式化完data分区再移动回来。
2.恢复出厂设置的操作不要执行格式化,而是执行命令rm,只删除需要删除的目录,其他目录保留。
由于abc目录文件较大,差不多2G,思路1由于找不到分区暂存,故现采用思路2。
修改bootable/recovery/recovery.c里面对data分区清除的代码:
static bool wipe_data(int should_confirm, Device* device) {
if (should_confirm && !yes_no(device, "Wipe all user data?", " THIS CAN NOT BE UNDONE!")) {
return false;
}
modified_flash = true;
ui->Print("\n-- Wiping data...\n");
bool success =
device->PreWipeData() &&
erase_volume("/data") &&
erase_volume("/cache") &&
device->PostWipeData();
ui->Print("Data wipe %s.\n", success ? "complete" : "failed");
return success;
}
static bool erase_volume(const char* volume) {
bool is_cache = (strcmp(volume, CACHE_ROOT) == 0);
...
ensure_path_unmounted(volume);
result = format_volume(volume);改成:
int result = 0;
if(is_cache) {
ensure_path_unmounted(volume);
result = format_volume(volume);
} else {