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

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