[ATFT] Add option to skip rebooting after fusing vboot key.
am: cb1f5404c8

Change-Id: Ic4d4010e597a9308128bca6b9b67181d66ec6845
diff --git a/at-factory-tool/atft.py b/at-factory-tool/atft.py
index bd541ff..e0fc098 100644
--- a/at-factory-tool/atft.py
+++ b/at-factory-tool/atft.py
@@ -1866,6 +1866,14 @@
       if 'KEY_DIR' in configs:
         self.key_dir = configs['KEY_DIR']
 
+      # For some SoC, a reboot is not required after locking down bootloader
+      # since it will reboot itself. 'SKIP_REBOOT' should be configured to True
+      # for this case.
+      if 'SKIP_REBOOT' in configs:
+        self.skip_reboot = configs['SKIP_REBOOT']
+      else:
+        self.skip_reboot = False
+
       device_usb_locations_initialized = False
       for i in range(TARGET_DEV_SIZE):
         if self.device_usb_locations[i]:
@@ -4118,7 +4126,7 @@
         self.listing_device_lock.acquire()
         self.atft_manager.Reboot(
             target, self.reboot_timeout, LambdaSuccessCallback,
-            LambdaTimeoutCallback)
+            LambdaTimeoutCallback, self.skip_reboot)
       finally:
         self.listing_device_lock.release()
     except ProductNotSpecifiedException as e:
diff --git a/at-factory-tool/atftman.py b/at-factory-tool/atftman.py
index be78f8c..d2d526f 100644
--- a/at-factory-tool/atftman.py
+++ b/at-factory-tool/atftman.py
@@ -1010,7 +1010,8 @@
       target.provision_status = ProvisionStatus.UNLOCKAVB_FAILED
       raise e
 
-  def Reboot(self, target, timeout, success_callback, timeout_callback):
+  def Reboot(self, target, timeout, success_callback, timeout_callback,
+             skip_reboot=False):
     """Reboot the target device.
 
     Args:
@@ -1020,6 +1021,9 @@
         successfully.
       timeout_callback: The callback function called when the device reboots
         timeout.
+      skip_reboot: Whether to skip reboot and only register the device as a
+        rebooting device. This is applicable if the device is already rebooting
+        and we want to register the callbacks.
     Raises:
       FastbootFailure: When fastboot command fails.
 
@@ -1028,7 +1032,8 @@
     otherwise call the timeout_callback.
     """
     try:
-      target.Reboot()
+      if not skip_reboot:
+        target.Reboot()
       serial = target.serial_number
       location = target.location
       # We assume after the reboot the device would disappear