Recovery添加从U盘升级功能

Platform: imx6

OS: Android 4.4


device/fsl 目录:

diff --git a/common/recovery/Android.mk b/common/recovery/Android.mk
index f98468b..c7a7886 100644
--- a/common/recovery/Android.mk
+++ b/common/recovery/Android.mk
@@ -1,6 +1,10 @@
 LOCAL_PATH := $(call my-dir)
 include $(CLEAR_VARS)
 
+#Kris,20151214, update by udisk.
+LOCAL_CFLAGS += -DUDISK_UPDATE
+
+
 LOCAL_MODULE_TAGS := eng
 LOCAL_C_INCLUDES += bootable/recovery
 LOCAL_SRC_FILES := recovery_ui.cpp
diff --git a/common/recovery/recovery_ui.cpp b/common/recovery/recovery_ui.cpp
index 8d128e4..5b083c7 100644
--- a/common/recovery/recovery_ui.cpp
+++ b/common/recovery/recovery_ui.cpp
@@ -35,6 +35,12 @@ const char* ITEMS[] = { "reboot system now",
                         "wipe cache partition",
                         /*Kris, Support upgrading from external sd.*/
                         "apply update from external sd",
+/*Kris, 20151214, update by udisk. {*/
+ #ifdef UDISK_UPDATE
+                        "apply update from udisk",
+#endif
+/*Kris, 20151214, update by udisk. }*/
+
                         NULL };
 
 class ImxUI : public ScreenRecoveryUI {
@@ -83,6 +89,11 @@ class ImxDevice : public Device {
           case 3: return WIPE_CACHE;
           /*Kris, Support upgrading from external sd.*/
           case 4: return APPLY_EXT;
+ /*Kris, 20151214, update by udisk. {*/
+#ifdef UDISK_UPDATE
+          case 5: return APPLY_FROM_UDISK;
+#endif
+ /*Kris, 20151214, update by udisk. }*/
           default: return NO_ACTION;
         }
     }
diff --git a/tek_mx6/fstab_recovery.freescale b/tek_mx6/fstab_recovery.freescale
index 65cd716..ec62247 100644
--- a/tek_mx6/fstab_recovery.freescale
+++ b/tek_mx6/fstab_recovery.freescale
@@ -5,6 +5,7 @@
 
 #Kris, mount external sd to /sdcard.
 /dev/block/mmcblk1p1    /sdcard      vfat    nosuid,nodev,barrier=1,data=ordered,nodelalloc                                   wait
+/dev/block/sda1         /udisk       vfat    nosuid,nodev,barrier=1,data=ordered,nodelalloc                                   wait
 /dev/block/mmcblk0p5    /system      ext4    ro                                                                               wait
 /dev/block/mmcblk0p4    /data        ext4    nosuid,nodev,nodiratime,noatime,nomblk_io_submit,noauto_da_alloc,errors=panic    wait,encryptable=footer
 /dev/block/mmcblk0p6    /cache       ext4    nosuid,nodev,nomblk_io_submit                                                    wait

bootable/recovery目录改动:

diff --git a/Android.mk b/Android.mk
index 2578c11..37ec3a4 100644
--- a/Android.mk
+++ b/Android.mk
@@ -54,6 +54,10 @@ LOCAL_STATIC_LIBRARIES := \
     libm \
     libc
 
+#Kris,20151214, update by udisk.
+LOCAL_CFLAGS += -DUDISK_UPDATE
+
+
 LOCAL_CFLAGS += -DUSE_EXT4
 LOCAL_C_INCLUDES += system/extras/ext4_utils
 LOCAL_STATIC_LIBRARIES += libext4_utils_static libz
diff --git a/device.h b/device.h
index 583de75..b469d48 100644
--- a/device.h
+++ b/device.h
@@ -65,8 +65,15 @@ class Device {
     //   - invoke a specific action (a menu position: any non-negative number)
     virtual int HandleMenuKey(int key, int visible) = 0;
 
+/*Kris, 20151214, update by udisk. {*/
+ #ifdef UDISK_UPDATE
     enum BuiltinAction { NO_ACTION, REBOOT, APPLY_EXT, APPLY_CACHE,
+                         APPLY_ADB_SIDELOAD, APPLY_FROM_UDISK,WIPE_DATA, WIPE_CACHE };
+ #else
+     enum BuiltinAction { NO_ACTION, REBOOT, APPLY_EXT, APPLY_CACHE,
                          APPLY_ADB_SIDELOAD, WIPE_DATA, WIPE_CACHE };
+#endif
+ /*Kris, 20151214, update by udisk. }*/
 
     // Perform a recovery action selected from the menu.
     // 'menu_position' will be the item number of the selected menu
diff --git a/etc/init.rc b/etc/init.rc
index c634330..0b65db9 100644
--- a/etc/init.rc
+++ b/etc/init.rc
@@ -15,6 +15,9 @@ on init
 
     symlink /system/etc /etc
 
+#Kris,20151214, update by udisk.
+    mkdir /udisk
+
     mkdir /sdcard
     mkdir /system
     mkdir /data
diff --git a/recovery.cpp b/recovery.cpp
index 5ddd730..876f036 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -81,6 +81,12 @@ static const char *TEMPORARY_LOG_FILE = "/tmp/recovery.log";
 static const char *TEMPORARY_INSTALL_FILE = "/tmp/last_install";
 static const char *SIDELOAD_TEMP_DIR = "/tmp/sideload";
 
+/*Kris, 20151214, update by udisk. {*/
+ #ifdef UDISK_UPDATE
+ static const char *UDISK_ROOT = "/udisk";
+ #endif
+ /*Kris, 20151214, update by udisk. }*/
+
 RecoveryUI* ui = NULL;
 char* locale = NULL;
 char recovery_version[PROPERTY_VALUE_MAX+1];
@@ -910,6 +916,32 @@ prompt_and_wait(Device* device, int status) {
                     }
                 }
                 break;
+/*Kris, 20151214, update by udisk. {*/
+ #ifdef UDISK_UPDATE
+              case Device::APPLY_FROM_UDISK:
+		  status = update_directory(UDISK_ROOT, UDISK_ROOT, &wipe_cache, device);
+		  if (status == INSTALL_SUCCESS && wipe_cache) {
+			  ui->Print("\n-- Wiping cache (at package request)...\n");
+			  if (erase_volume("/cache")) {
+				  ui->Print("Cache wipe failed.\n");
+			  } else {
+				  ui->Print("Cache wipe complete.\n");
+			  }
+		  }
+		  if (status >= 0) {
+			  if (status != INSTALL_SUCCESS) {
+				  ui->SetBackground(RecoveryUI::ERROR);
+				  ui->Print("Installation aborted.\n");
+			  } else if (!ui->IsTextVisible()) {
+				  return;  // reboot if logs aren't visible
+			  } else {
+				  ui->Print("\nInstall from udisk complete.\n");
+			  }
+		  }
+		  break;
+
+ #endif
+ /*Kris, 20151214, update by udisk. }*/
         }
     }
 }


你可能感兴趣的:(Recovery添加从U盘升级功能)