Bump.py: Add new level to libvts_vintf_test_common

This file also needs to be updated to prepare for the next release.

Test: python bump.py 202504 202604 B C 16 17
Bug: 389665041
Change-Id: I552fce3355e447fcfb600ad465072eaf398b27c3
diff --git a/compatibility_matrices/bump.py b/compatibility_matrices/bump.py
index 91f58d4..ef79ada 100755
--- a/compatibility_matrices/bump.py
+++ b/compatibility_matrices/bump.py
@@ -60,6 +60,7 @@
         self.copy_matrix()
         self.edit_android_bp()
         self.bump_libvintf()
+        self.bump_libvts_vintf()
 
     def bump_kernel_configs(self):
         check_call([
@@ -157,6 +158,20 @@
                                         }} break;"""),
                             "    "*3))
 
+    def bump_libvts_vintf(self):
+      if not self.current_version:
+        print("Skip libvts_vintf update...")
+        return
+      try:
+        check_call(["grep", "-h",
+                    f"{self.next_level}, Level::{self.next_letter.upper()}",
+                    f"{self.top}/test/vts-testcase/hal/treble/vintf/libvts_vintf_test_common/common.cpp"])
+        print("libvts_vintf is already up-to-date")
+      except subprocess.CalledProcessError:
+        print("Adding new API level to libvts_vintf")
+        add_lines_below(f"{self.top}/test/vts-testcase/hal/treble/vintf/libvts_vintf_test_common/common.cpp",
+                        f"        {{{self.current_level}, Level::{self.current_letter.upper()}}},",
+                        f"        {{{self.next_level}, Level::{self.next_letter.upper()}}},\n")
 
 def add_lines_above(file, pattern, lines):
     with open(file, 'r+') as f:
@@ -171,6 +186,16 @@
         f.write(f"\n{lines}\n{pattern}\n".join(split_text))
         f.truncate()
 
+def add_lines_below(file, pattern, lines):
+    final_lines = []
+    with open(file, 'r+') as f:
+        for line in f:
+          final_lines.append(line)
+          if pattern in line:
+              final_lines.append(lines)
+        f.seek(0)
+        f.write("".join(final_lines))
+        f.truncate()
 
 def main():
     parser = argparse.ArgumentParser(description=__doc__)