Fastbootd update for state

Next CL will enable the actual support so all this logic
can be use.

Test: unit tests
Bug: 148109220
Change-Id: I173f36e2bb5be5b95b58cebfd9e3c59f9c97b017
diff --git a/src/com/android/tradefed/device/NativeDevice.java b/src/com/android/tradefed/device/NativeDevice.java
index 45124bd..cc5b8d6 100644
--- a/src/com/android/tradefed/device/NativeDevice.java
+++ b/src/com/android/tradefed/device/NativeDevice.java
@@ -447,8 +447,7 @@
         String propValue = getProperty(propName);
         if (propValue != null) {
             return propValue;
-        } else if (TestDeviceState.FASTBOOT.equals(getDeviceState()) &&
-                fastbootVar != null) {
+        } else if (isStateBootloaderOrFastbootd() && fastbootVar != null) {
             CLog.i("%s for device %s is null, re-querying in fastboot", description,
                     getSerialNumber());
             return getFastbootVariable(fastbootVar);
@@ -2936,11 +2935,11 @@
             throws DeviceNotAvailableException, UnsupportedOperationException {
         rebootIntoFastbootInternal(false);
     }
-    
+
     /**
      * Reboots the device into bootloader or fastbootd mode.
      *
-     * @param isBootloader: true to boot the device into bootloader mode, false to boot the device
+     * @param isBootloader true to boot the device into bootloader mode, false to boot the device
      *     into fastbootd mode.
      * @throws DeviceNotAvailableException if connection with device is lost and cannot be
      *     recovered.
@@ -2948,7 +2947,7 @@
     private void rebootIntoFastbootInternal(boolean isBootloader)
             throws DeviceNotAvailableException {
         final RebootMode mode =
-                isBootloader ? RebootMode.REBOOT_INTO_BOOTLOADER : RebootMode.REBOOT_INTO_FASTBOOT;
+                isBootloader ? RebootMode.REBOOT_INTO_BOOTLOADER : RebootMode.REBOOT_INTO_FASTBOOTD;
         if (!mFastbootEnabled) {
             throw new UnsupportedOperationException(
                     String.format("Fastboot is not available and cannot reboot into %s", mode));
@@ -2958,13 +2957,14 @@
         CLog.i(
                 "Rebooting device %s in state %s into %s",
                 getSerialNumber(), getDeviceState(), mode);
-        if (TestDeviceState.FASTBOOT.equals(getDeviceState())) {
+        if (isStateBootloaderOrFastbootd()) {
             CLog.i("device %s already in fastboot. Rebooting anyway", getSerialNumber());
             executeFastbootCommand(String.format("reboot-%s", mode));
         } else {
             CLog.i("Booting device %s into %s", getSerialNumber(), mode);
             doAdbReboot(mode, null);
         }
+
         if (!mStateMonitor.waitForDeviceBootloader(mOptions.getFastbootTimeout())) {
             recoverDeviceFromBootloader();
         }
@@ -3120,7 +3120,7 @@
     protected enum RebootMode {
         REBOOT_FULL(""),
         REBOOT_USERSPACE("userspace"),
-        REBOOT_INTO_FASTBOOT("fastboot"),
+        REBOOT_INTO_FASTBOOTD("fastboot"),
         REBOOT_INTO_BOOTLOADER("bootloader"),
         REBOOT_INTO_SIDELOAD("sideload"),
         REBOOT_INTO_SIDELOAD_AUTO_REBOOT("sideload-auto-reboot"),