1#!/bin/bash
2
3# This script is used to generate uwb conuntry configuration file,
4# and the PRODUCT_COPY_FILES list in uwb_calibration_country.mk based on uwb_country.conf
5# Bug: 196073172, 233619860
6
7count=1
8
9LOCAL_PATH=device/google/tangorpro/uwb
10
11echo "# Copyright (C) 2023 The Android Open-Source Project"
12echo "#"
13echo "# Licensed under the Apache License, Version 2.0 (the \"License\");"
14echo "# you may not use this file except in compliance with the License."
15echo "# You may obtain a copy of the License at"
16echo "#"
17echo "#      http://www.apache.org/licenses/LICENSE-2.0"
18echo "#"
19echo "# Unless required by applicable law or agreed to in writing, software"
20echo "# distributed under the License is distributed on an \"AS IS\" BASIS,"
21echo "# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied."
22echo "# See the License for the specific language governing permissions and"
23echo "# limitations under the License."
24echo ""
25echo "# This file was autogenerated by country_conf_gen.sh"
26echo ""
27echo "ifneq (\$(LOCAL_PATH),$LOCAL_PATH)"
28echo "  \$(error LOCAL_PATH in country_conf_gen.sh needs to be updated, and uwb_calibration_country.mk regenerated)"
29echo "endif"
30echo "diffs := \$(shell diff \$(LOCAL_PATH)/uwb_calibration_country.mk <($LOCAL_PATH/country_conf_gen.sh))"
31echo "ifneq (\$(diffs),)"
32echo "  \$(error $LOCAL_PATH/uwb_calibration_country.mk is not up to date, please run $LOCAL_PATH/country_conf_gen.sh > $LOCAL_PATH/uwb_calibration_country.mk)"
33echo "endif"
34echo ""
35echo "PRODUCT_COPY_FILES += \\"
36while read line ; do
37    if [[ "$line" =~ ^"*" ]]; then
38        header=${line:1}
39    elif [[ "$line" =~ ^"\"" ]]; then
40        #line=$(echo ${line/,} | tr -d "\"")
41        country[count]=$(echo $line | cut -d ':' -f1 | tr -d "\"")
42        code[count]=$(echo $line | cut -d ':' -f2 | tr -d "\"" | tr -d " ")
43            if [ "$header" = "FCC" ]; then
44                echo "    \$(LOCAL_PATH)/UWB-calibration-fcc.conf:\$(TARGET_COPY_OUT_VENDOR)/etc/uwb/UWB-calibration-${code[$count]}.conf \\"
45            elif [ "$header" = "CE" ]; then
46                echo "    \$(LOCAL_PATH)/UWB-calibration-ce.conf:\$(TARGET_COPY_OUT_VENDOR)/etc/uwb/UWB-calibration-${code[$count]}.conf \\"
47            elif [ "$header" = "JP" ]; then
48                echo "    \$(LOCAL_PATH)/UWB-calibration-jp.conf:\$(TARGET_COPY_OUT_VENDOR)/etc/uwb/UWB-calibration-${code[$count]}.conf \\"
49            elif [ "$header" = "TW" ]; then
50                echo "    \$(LOCAL_PATH)/UWB-calibration-tw.conf:\$(TARGET_COPY_OUT_VENDOR)/etc/uwb/UWB-calibration-${code[$count]}.conf \\"
51            elif [ "$header" = "Restricted" ]; then
52                echo "    \$(LOCAL_PATH)/UWB-calibration-restricted.conf:\$(TARGET_COPY_OUT_VENDOR)/etc/uwb/UWB-calibration-${code[$count]}.conf \\"
53            fi
54    fi
55((count++))
56done < $LOCAL_PATH/uwb_country.conf
57