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

if [ "$(cat  out_adevtool_deps/soong/.intermediates/packages/modules/Uwb/androidx_backend/androidx.core.uwb.backend.aidl_interface_interface/has_development )" = "1" ]; then mkdir -p packages/modules/Uwb/androidx_backend/aidl_api/androidx.core.uwb.backend.aidl_interface/4 &&  cp -rf out_adevtool_deps/soong/.intermediates/packages/modules/Uwb/androidx_backend/androidx.core.uwb.backend.aidl_interface_interface/dump/. packages/modules/Uwb/androidx_backend/aidl_api/androidx.core.uwb.backend.aidl_interface/4 ; fi
if [ "$(cat  out_adevtool_deps/soong/.intermediates/packages/modules/Uwb/androidx_backend/androidx.core.uwb.backend.aidl_interface_interface/has_development )" = "1" ]; then echo "There is change between ToT version and the latest stable version. Freezing androidx.core.uwb.backend.aidl_interface-V4." ; else echo "There is no change from the latest stable version of androidx.core.uwb.backend.aidl_interface. Nothing happened." ; fi
if [ "$(cat  out_adevtool_deps/soong/.intermediates/packages/modules/Uwb/androidx_backend/androidx.core.uwb.backend.aidl_interface_interface/has_development )" = "1" ]; then out_adevtool_deps/host/linux-x86/bin/bpmodify -w -m androidx.core.uwb.backend.aidl_interface -parameter versions -remove-property packages/modules/Uwb/androidx_backend/Android.bp ; fi
if [ "$(cat  out_adevtool_deps/soong/.intermediates/packages/modules/Uwb/androidx_backend/androidx.core.uwb.backend.aidl_interface_interface/has_development )" = "1" ]; then out_adevtool_deps/host/linux-x86/bin/bpmodify -w -m androidx.core.uwb.backend.aidl_interface -parameter versions_with_info -add-literal '{version: "4", imports: []}'  packages/modules/Uwb/androidx_backend/Android.bp && out_adevtool_deps/host/linux-x86/bin/bpmodify -w -m androidx.core.uwb.backend.aidl_interface -parameter frozen -set-bool true packages/modules/Uwb/androidx_backend/Android.bp ; fi
