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

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