Remove factory.* items from VPD in finalize.

BUG=chrome-os-partner:19472
TEST=unit tests, manual on device

Change-Id: Ia2df23b4a6291fbe88fb39f6fdef95905227d7f6
Reviewed-on: https://gerrit.chromium.org/gerrit/51272
Tested-by: Jon Salz <jsalz@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Commit-Queue: Jon Salz <jsalz@chromium.org>
diff --git a/py/gooftool/gooftool.py b/py/gooftool/gooftool.py
index 6c140e3..8ee64da 100755
--- a/py/gooftool/gooftool.py
+++ b/py/gooftool/gooftool.py
@@ -576,6 +576,13 @@
   event_log.Log('clear_gbb_flags')
 
 
+@Command('clear_factory_vpd_entries')
+def ClearFactoryVPDEntries(options):  # pylint: disable=W0613
+  """Clears factory.* items in the RW VPD."""
+  entries = GetGooftool(options).ClearFactoryVPDEntries()
+  event_log.Log('clear_factory_vpd_entries', entries=FilterDict(entries))
+
+
 @Command('prepare_wipe',
          CmdArg('--fast', action='store_true',
                 help='use non-secure but faster wipe method.'))
@@ -705,17 +712,20 @@
 def Finalize(options):
   """Verify system readiness and trigger transition into release state.
 
-  This routine first verifies system state (see verify command), modifies
-  firmware bitmaps to match locale, and then clears all of the factory-friendly
-  flags from the GBB.  If everything is fine, it enables firmware write
-  protection (cannot rollback after this stage), uploads system logs & reports,
-  and sets the necessary boot flags to cause wipe of the factory image on the
-  next boot.
+  This routine does the following:
+  - Verifies system state (see verify command)
+  - Modifies firmware bitmaps to match locale
+  - Clears all factory-friendly flags from the GBB
+  - Removes factory-specific entries from RW_VPD (factory.*)
+  - Enables firmware write protection (cannot rollback after this)
+  - Uploads system logs & reports
+  - Sets the necessary boot flags to cause wipe of the factory image on the
+    next boot.
   """
-
   Verify(options)
   SetFirmwareBitmapLocale(options)
   ClearGBBFlags(options)
+  ClearFactoryVPDEntries(options)
   if options.no_write_protect:
     logging.warn('WARNING: Firmware Write Protection is SKIPPED.')
     event_log.Log('wp', fw='both', status='skipped')