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

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