#!/usr/bin/env bash
set -euo pipefail

if [ "$(cat  out_adevtool_deps/soong/.intermediates/hardware/interfaces/automotive/evs/aidl/android.hardware.automotive.evs_interface/has_development )" = "1" ]; then mkdir -p hardware/interfaces/automotive/evs/aidl/aidl_api/android.hardware.automotive.evs/3 &&  cp -rf out_adevtool_deps/soong/.intermediates/hardware/interfaces/automotive/evs/aidl/android.hardware.automotive.evs_interface/dump/. hardware/interfaces/automotive/evs/aidl/aidl_api/android.hardware.automotive.evs/3 ; fi
if [ "$(cat  out_adevtool_deps/soong/.intermediates/hardware/interfaces/automotive/evs/aidl/android.hardware.automotive.evs_interface/has_development )" = "1" ]; then echo "There is change between ToT version and the latest stable version. Freezing android.hardware.automotive.evs-V3." ; else echo "There is no change from the latest stable version of android.hardware.automotive.evs. Nothing happened." ; fi
if [ "$(cat  out_adevtool_deps/soong/.intermediates/hardware/interfaces/automotive/evs/aidl/android.hardware.automotive.evs_interface/has_development )" = "1" ]; then out_adevtool_deps/host/linux-x86/bin/bpmodify -w -m android.hardware.automotive.evs -parameter versions -remove-property hardware/interfaces/automotive/evs/aidl/Android.bp ; fi
if [ "$(cat  out_adevtool_deps/soong/.intermediates/hardware/interfaces/automotive/evs/aidl/android.hardware.automotive.evs_interface/has_development )" = "1" ]; then out_adevtool_deps/host/linux-x86/bin/bpmodify -w -m android.hardware.automotive.evs -parameter versions_with_info -add-literal '{version: "3", imports: ["android.hardware.graphics.common-V7", "android.hardware.common-V2"]}'  hardware/interfaces/automotive/evs/aidl/Android.bp && out_adevtool_deps/host/linux-x86/bin/bpmodify -w -m android.hardware.automotive.evs -parameter frozen -set-bool true hardware/interfaces/automotive/evs/aidl/Android.bp ; fi
