Android7.0恢復出廠設置指定目錄不刪除

直接貼修改記錄:
diff --git a/bootable/recovery/mt_recovery.cpp b/bootable/recovery/mt_recovery.cpp
index 8f02fb3..247dc02 100755
--- a/bootable/recovery/mt_recovery.cpp
+++ b/bootable/recovery/mt_recovery.cpp
@@ -42,6 +42,9 @@ extern int get_menu_selection(const char* const * headers, const char* const * i
 extern void copy_log_file(const char* source, const char* destination, bool append);
 extern void finish_recovery(const char *send_intent);
 extern void wipe_data(int confirm, Device* device);
+#if USE_MTP_MODE
+extern int clean_data_partition(const char *volume);
+#endif
 extern int erase_volume(const char *volume);
 extern void copy_logs();
 extern char* browse_directory(const char* path, Device* device);
@@ -1211,7 +1214,11 @@ static bool mt_wipe_data_sp(int confirm, Device* device) {
 
     mt_set_bootloader_message("boot-recovery", NULL, stage, "recovery\n--wipe_data\n");
     device->PreWipeData();
+#if USE_MTP_MODE
+    clean_data_partition("/data");
+#else
     erase_volume("/data");
+#endif
     if(is_support_nvdata()) {
         erase_volume("/nvdata");
     }
diff --git a/bootable/recovery/recovery.cpp b/bootable/recovery/recovery.cpp
index 8f857af..5d84772 100755
--- a/bootable/recovery/recovery.cpp
+++ b/bootable/recovery/recovery.cpp
@@ -464,6 +464,18 @@ typedef struct _saved_log_file {
     struct _saved_log_file* next;
 } saved_log_file;
 
+#if USE_MTP_MODE
+int clean_data_partition(const char *volume){
+    ensure_path_mounted(volume);
+    if(0==system("for file in /data/*;do  if [ \"$file\" != \"/data/media\" ]; then busybox rm -rf $file; fi  ; done")){
+        return 0;
+    }else{
+        LOGE("clean data partition error!!!\n");
+        return -1;
+    }
+}
+#endif
+
 #if 0
 static bool erase_volume(const char* volume) {
 #else
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章