faft: Support clearing multiple-bit of GBB flags

This change supports clearing multiple-bit of GBB flags such that
it saves time to write the result back.

BUG=chromium-os:32874
TEST=Run firmware_TryFwB/control.dev passed on a new installed firmware.

Change-Id: I3fc692d3098e1b850d349681f34ea5017cbbcfe3
Reviewed-on: https://gerrit.chromium.org/gerrit/29592
Reviewed-by: Vic Yang <victoryang@chromium.org>
Commit-Ready: Tom Wai-Hong Tam <waihong@chromium.org>
Tested-by: Tom Wai-Hong Tam <waihong@chromium.org>
diff --git a/server/cros/faftsequence.py b/server/cros/faftsequence.py
index bc1540f..dd3e0ab 100644
--- a/server/cros/faftsequence.py
+++ b/server/cros/faftsequence.py
@@ -2,6 +2,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+import ctypes
 import fdpexpect
 import logging
 import os
@@ -262,8 +263,8 @@
         super(FAFTSequence, self).setup()
         if not self._remote_infos['faft']['used']:
             raise error.TestError('The use_faft flag should be enabled.')
-        self.clear_gbb_flags(self.GBB_FLAG_FORCE_DEV_SWITCH_ON)
-        self.clear_gbb_flags(self.GBB_FLAG_DEV_SCREEN_SHORT_DELAY)
+        self.clear_gbb_flags(self.GBB_FLAG_FORCE_DEV_SWITCH_ON |
+                             self.GBB_FLAG_DEV_SCREEN_SHORT_DELAY)
         self.register_faft_template({
             'state_checker': (None),
             'userspace_action': (None),
@@ -348,11 +349,11 @@
         """
         gbb_flags = self.faft_client.get_gbb_flags()
         if (gbb_flags & mask):
+            new_flags = gbb_flags & ctypes.c_uint32(~mask).value
             logging.info('Clear the GBB flags of 0x%x, from 0x%x to 0x%x.' %
-                         (mask, gbb_flags, gbb_flags ^ mask))
+                         (mask, gbb_flags, new_flags))
             self.faft_client.run_shell_command(
-                    '/usr/share/vboot/bin/set_gbb_flags.sh 0x%x' %
-                    (gbb_flags ^ mask))
+                    '/usr/share/vboot/bin/set_gbb_flags.sh 0x%x' % new_flags)
             self.faft_client.reload_firmware()