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

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