Update vintf finalization script

Run vintf finalization if the target configuration does not set
RELEASE_BOARD_API_LEVEL_FROZEN to 'true'; and FINAL_BOARD_API_LEVEL
which is the version to finalize is the same with the
RELEASE_BOARD_API_LEVEL which is the version that the current tree is
building.

Also define build-step-0-and-m.sh that runs a test build after the
vintf finalization process.

Ignore-AOSP-First: finalization script is an exception
Bug: 331696132
Test: tools/finalization/build-step-0-and-m.sh
Change-Id: I22b9096d57c935e64c4d28f16b95afaa84b79465
diff --git a/tools/finalization/build-step-0-and-m.sh b/tools/finalization/build-step-0-and-m.sh
new file mode 100755
index 0000000..4843800
--- /dev/null
+++ b/tools/finalization/build-step-0-and-m.sh
@@ -0,0 +1,20 @@
+
+#!/bin/bash
+# Copyright 2024 Google Inc. All rights reserved.
+set -ex
+function help() {
+    echo "Finalize VINTF and build a target for test."
+    echo "usage: $(basename "$0") target [goals...]"
+}
+function finalize_main_step0_and_m() {
+    if [ $# == 0 ] ; then
+        help
+        exit 1
+    fi;
+    local top="$(dirname "$0")"/../../../..
+    source $top/build/make/tools/finalization/build-step-0.sh
+    local m="$top/build/soong/soong_ui.bash --make-mode TARGET_PRODUCT=$1 TARGET_RELEASE=fina_0 TARGET_BUILD_VARIANT=userdebug"
+    # This command tests the release state for AIDL.
+    AIDL_FROZEN_REL=true $m ${@:2}
+}
+finalize_main_step0_and_m $@