factory_install: Detect virtual developer switches.

"crossystem vdat_flags" is the better & portable way to find out developer
switch state.

BUG=chromium-os:32836
TEST=Manual.

Change-Id: I38f4b5bc590e59b1bedb5aa919479e3f09e90e36
Reviewed-on: https://gerrit.chromium.org/gerrit/28480
Commit-Ready: Hung-Te Lin <hungte@chromium.org>
Tested-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-by: Jay Kim <yongjaek@chromium.org>
diff --git a/factory_install.sh b/factory_install.sh
index 9bb9625..6bd04e2 100644
--- a/factory_install.sh
+++ b/factory_install.sh
@@ -651,16 +651,21 @@
     EC_PRESENT=1
     log "EC flash is present"
   else
+    EC_PRESENT=0
     log "EC flash is not present or supported"
   fi
 }
 
 test_devsw_presence() {
-  if crossystem devsw_cur 1>&2; then
+  local VBSD_HONOR_VIRT_DEV_SWITCH="0x400"
+  local vdat_flags="$(crossystem vdat_flags || echo 0)"
+
+  if [ "$((vdat_flags & VBSD_HONOR_VIRT_DEV_SWITCH))" = "0" ]; then
+    DEVSW_PRESENT=1
     log "Physical developer switch is present"
   else
     DEVSW_PRESENT=0
-    log "Physical developer switch is not present"
+    log "Using virtual developer switch (no physical switch)"
   fi
 }
 
@@ -727,6 +732,7 @@
   colorize "green"
 
   test_ec_flash_presence
+  test_devsw_presence
 
   reset_chromeos_device
 
@@ -739,7 +745,6 @@
   overrides
 
   if [ -n "$install_from_omaha" ]; then
-    test_devsw_presence
 
     colorize "yellow"
     log "Waiting for ethernet connectivity to install"