Replaced binascii.hexlify(x).decode('ascii') with x.hex().

Replaced the binascii.hexlify(x).decode('ascii') construct, which worked
for both py2/py3, to x.hex(), which now only works on py3 but is better
readable.

Bug: 151336743
Test: external/avb$ atest :all
Test: ./aftltool_integration_test.py
Change-Id: I3cb77b0cd77d2463448e37d707d1ab2b7a8a39fb
diff --git a/avbtool.py b/avbtool.py
index 3f8421d..dad60d6 100755
--- a/avbtool.py
+++ b/avbtool.py
@@ -1419,10 +1419,8 @@
     o.write('      FEC size:              {} bytes\n'.format(self.fec_size))
     o.write('      Hash Algorithm:        {}\n'.format(self.hash_algorithm))
     o.write('      Partition Name:        {}\n'.format(self.partition_name))
-    o.write('      Salt:                  {}\n'.format(
-        binascii.hexlify(self.salt).decode('ascii')))
-    o.write('      Root Digest:           {}\n'.format(
-        binascii.hexlify(self.root_digest).decode('ascii')))
+    o.write('      Salt:                  {}\n'.format(self.salt.hex()))
+    o.write('      Root Digest:           {}\n'.format(self.root_digest.hex()))
     o.write('      Flags:                 {}\n'.format(self.flags))
 
   def encode(self):
@@ -1592,10 +1590,8 @@
     o.write('      Image Size:            {} bytes\n'.format(self.image_size))
     o.write('      Hash Algorithm:        {}\n'.format(self.hash_algorithm))
     o.write('      Partition Name:        {}\n'.format(self.partition_name))
-    o.write('      Salt:                  {}\n'.format(
-        binascii.hexlify(self.salt).decode('ascii')))
-    o.write('      Digest:                {}\n'.format(
-        binascii.hexlify(self.digest).decode('ascii')))
+    o.write('      Salt:                  {}\n'.format(self.salt.hex()))
+    o.write('      Digest:                {}\n'.format(self.digest.hex()))
     o.write('      Flags:                 {}\n'.format(self.flags))
 
   def encode(self):
@@ -2562,14 +2558,14 @@
 
     for desc in descriptors:
       if isinstance(desc, AvbHashDescriptor):
-        digest = binascii.hexlify(desc.digest).decode('ascii')
+        digest = desc.digest.hex()
         if json_partitions is not None:
           json_partitions.append({'name': desc.partition_name,
                                   'digest': digest})
         else:
           output.write('{}: {}\n'.format(desc.partition_name, digest))
       elif isinstance(desc, AvbHashtreeDescriptor):
-        digest = binascii.hexlify(desc.root_digest).decode('ascii')
+        digest = desc.root_digest.hex()
         if json_partitions is not None:
           json_partitions.append({'name': desc.partition_name,
                                   'digest': digest})
@@ -2623,7 +2619,7 @@
         hasher.update(ch_vbmeta_blob)
 
     digest = hasher.digest()
-    output.write('{}\n'.format(binascii.hexlify(digest).decode('ascii')))
+    output.write('{}\n'.format(digest.hex()))
 
   def calculate_kernel_cmdline(self, image_filename, hashtree_disabled, output):
     """Implements the 'calculate_kernel_cmdline' command.
@@ -2757,19 +2753,18 @@
 
     """
     c = 'dm="1 vroot none ro 1,'
-    c += '0'  # start
-    c += ' {}'.format((ht.image_size // 512))  # size (# sectors)
-    c += ' verity {}'.format(ht.dm_verity_version)  # type and version
-    c += ' PARTUUID=$(ANDROID_SYSTEM_PARTUUID)'  # data_dev
-    c += ' PARTUUID=$(ANDROID_SYSTEM_PARTUUID)'  # hash_dev
-    c += ' {}'.format(ht.data_block_size)  # data_block
-    c += ' {}'.format(ht.hash_block_size)  # hash_block
+    c += '0'                                                # start
+    c += ' {}'.format((ht.image_size // 512))               # size (# sectors)
+    c += ' verity {}'.format(ht.dm_verity_version)          # type and version
+    c += ' PARTUUID=$(ANDROID_SYSTEM_PARTUUID)'             # data_dev
+    c += ' PARTUUID=$(ANDROID_SYSTEM_PARTUUID)'             # hash_dev
+    c += ' {}'.format(ht.data_block_size)                   # data_block
+    c += ' {}'.format(ht.hash_block_size)                   # hash_block
     c += ' {}'.format(ht.image_size // ht.data_block_size)  # #blocks
     c += ' {}'.format(ht.image_size // ht.data_block_size)  # hash_offset
-    c += ' {}'.format(ht.hash_algorithm)  # hash_alg
-    c += ' {}'.format(
-        binascii.hexlify(ht.root_digest).decode('ascii'))  # root_digest
-    c += ' {}'.format(binascii.hexlify(ht.salt).decode('ascii'))  # salt
+    c += ' {}'.format(ht.hash_algorithm)                    # hash_alg
+    c += ' {}'.format(ht.root_digest.hex())                 # root_digest
+    c += ' {}'.format(ht.salt.hex())                        # salt
     if ht.fec_num_roots > 0:
       c += ' 10'  # number of optional args
       c += ' $(ANDROID_VERITY_MODE)'