Rewrite compatibility checking in unit test.

Reweite the checking because protobuf support modules for Python has been
removed from prebuilt tools.

Test: atest TeleServiceTests:IsoToEccProtobufRepositoryTest#testEccDataContent
Bug: 119277125

Change-Id: Ie79c3c69026671a8cb3c96382ae4aa971c74d094
diff --git a/ecc/README.md b/ecc/README.md
index ef795d5..b5dc538 100644
--- a/ecc/README.md
+++ b/ecc/README.md
@@ -6,43 +6,28 @@
 
 gen_eccdata.sh
   - A script to launch the newest conversion toolset to convert
-    input/eccdata.txt into output/eccdata, and invoke compatibility
-    verification tools of earlier versions of toolsets.
+    input/eccdata.txt into output/eccdata.
 
 input/eccdata.txt
   - A text file in ProtoBuf text format which contains all known ECC data.
-    This file shall be compatible with the last version of format toolset,
-    but may not be compatible with all earlier versions.
 
 output/eccdata
-  - The binary file generated from input files, with the last version of
-    format toolset. This file shall be compatible with all earlier versions.
+  - The binary file generated from input files.
 
 conversion_toolset_v*
-  - Contains format definitions, converting tools and verification tools of
-    one version of ECC data format.
+  - Contains format definitions and converting tools.
 
 proto
   - A symbolic link references to protobuf folder of the newest version of
     conversion toolsets. It's used in Android.mk.
 
-Conversion Toolset
-===================
-
-Every version of conversion toolset shall include at least:
-  - A script to generate eccdata from a known version of input/eccdata.txt.
-  - A script to verify compatibility of output/eccdata generated by any
-    newer version of format toolset.
-
-The output/eccdata generated by a version of conversion toolset shall be
-able to pass compatibility verifications of all previous versions of format
-toolset.
-
 Updating ECC database
 ===================
 Steps to update the ECC database:
 1. Edit input/eccdata.txt
 2. Source and launch
 3. Run gen_eccdata.sh
-The database file "output/eccdata" should be updated.
-
+4. Make TeleService
+5. Push TeleService.apk to system/priv-app/TeleService
+6. Reboot device
+7. run 'atest TeleServiceTests:IsoToEccProtobufRepositoryTest#testEccDataContent'
diff --git a/ecc/conversion_toolset_v1/env.sh b/ecc/conversion_toolset_v1/env.sh
index 23d9f10..534c807 100644
--- a/ecc/conversion_toolset_v1/env.sh
+++ b/ecc/conversion_toolset_v1/env.sh
@@ -20,19 +20,3 @@
 PROTOBUF_DIR="${LOCAL_TOOLSET_DIR}/proto"
 PROTOBUF_FILE="${PROTOBUF_DIR}/protobuf_ecc_data.proto"
 RAW_DATA="${INTERMEDIATE_DIR}/eccdata.raw"
-
-read -d "" PYTHON_COMMAND << END || :
-${ANDROID_BUILD_TOP}/prebuilts/python/${KERNEL}-x86/2.7.5/bin/python
-END
-PYTHONPATH="${PYTHONPATH}:${INTERMEDIATE_DIR}"
-PYTHONPATH="${PYTHONPATH}:${ANDROID_BUILD_TOP}/external/nanopb-c/generator/"
-
-if ! [ -x "${PYTHON_COMMAND}" ] ; then
-  echo "Missing ${PYTHON_COMMAND}." 1>&2
-  exit 1
-fi
-
-"${PROTOC_COMMAND}" \
-  --python_out="${INTERMEDIATE_DIR}" \
-  --proto_path="${PROTOBUF_DIR}" \
-  "${PROTOBUF_FILE}"
diff --git a/ecc/conversion_toolset_v1/gen_eccdata.sh b/ecc/conversion_toolset_v1/gen_eccdata.sh
index 8dd751f..1efac37 100644
--- a/ecc/conversion_toolset_v1/gen_eccdata.sh
+++ b/ecc/conversion_toolset_v1/gen_eccdata.sh
@@ -18,19 +18,12 @@
 LOCAL_TOOLSET_DIR="${ECC_ROOT}/conversion_toolset_v1"
 source "${LOCAL_TOOLSET_DIR}/env.sh"
 
+echo "Converting eccdata..."
 ${ANDROID_BUILD_TOP}/prebuilts/tools/linux-x86_64/protoc/bin/protoc \
   --encode=ecc.AllInfo proto/protobuf_ecc_data.proto \
   < "${INPUT_DATA}" > "${RAW_DATA}"
 
-echo
-echo "Starting strict verification"
-"${PYTHON_COMMAND}" -B \
-  "${LOCAL_TOOLSET_DIR}/verify_protobuf_compatibility.py" \
-  --input="${RAW_DATA}" --strict
-echo "Passed strict verification"
-
-echo
-echo "Compressing and encoding eccdata"
+echo "Compressing eccdata..."
 gzip -c < "${RAW_DATA}" > "${OUTPUT_DATA}"
-echo "Done"
 
+echo "Done"
diff --git a/ecc/conversion_toolset_v1/verify_eccdata_compatibility.sh b/ecc/conversion_toolset_v1/verify_eccdata_compatibility.sh
deleted file mode 100644
index 8686722..0000000
--- a/ecc/conversion_toolset_v1/verify_eccdata_compatibility.sh
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/bash
-set -o errexit
-
-# Copyright 2018 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_TOOLSET_DIR="${ECC_ROOT}/conversion_toolset_v1"
-source "${LOCAL_TOOLSET_DIR}/env.sh"
-
-echo "Starting compatibility verification v1"
-echo "Decoding and decompressing eccdata"
-gunzip -c < "${OUTPUT_DATA}" > "${RAW_DATA}"
-${PYTHON_COMMAND} -B \
-  "${LOCAL_TOOLSET_DIR}/verify_protobuf_compatibility.py" \
-  --input="${RAW_DATA}"
-echo "Passed compatibility verification v1"
-
diff --git a/ecc/conversion_toolset_v1/verify_protobuf_compatibility.py b/ecc/conversion_toolset_v1/verify_protobuf_compatibility.py
deleted file mode 100644
index bc707eb..0000000
--- a/ecc/conversion_toolset_v1/verify_protobuf_compatibility.py
+++ /dev/null
@@ -1,85 +0,0 @@
-#!/usr/bin/python -B
-
-# Copyright 2018 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Notice:
-# - verify_eccdata_strict.py: Verify data which is generated by this
-# version of this toolset.
-# - verify_eccdata_compatibility.py: Verify data which is generated by any
-# newer version of this tool set for ensuring backward compatibility.
-
-import sys
-import argparse
-import protobuf_ecc_data_pb2
-
-parser = argparse.ArgumentParser()
-parser.add_argument("--input", required=True)
-parser.add_argument("--strict", action="store_true")
-args = parser.parse_args()
-
-all_ecc_info = protobuf_ecc_data_pb2.AllInfo()
-
-with open(args.input, "rb") as ecc_data_source_file:
-  all_ecc_info.ParseFromString(ecc_data_source_file.read())
-
-if (args.strict):
-  print("Verify in strict mode")
-
-assert all_ecc_info.HasField("revision")
-assert all_ecc_info.revision > 0
-assert len(all_ecc_info.countries) > 0
-
-loaded_iso = []
-for country_info in all_ecc_info.countries:
-  assert country_info.HasField("iso_code")
-  assert len(country_info.iso_code) > 0
-  assert country_info.iso_code == country_info.iso_code.strip().upper()
-  assert country_info.iso_code not in loaded_iso
-  loaded_iso.append(country_info.iso_code)
-  assert country_info.HasField("ecc_fallback")
-  assert len(country_info.ecc_fallback) > 0
-
-  if len(country_info.eccs) > 0:
-    loaded_phone_number = []
-    for ecc_info in country_info.eccs:
-      assert ecc_info.HasField("phone_number")
-      phone_number = ecc_info.phone_number.strip()
-      assert len(phone_number) > 0
-      assert phone_number not in loaded_phone_number
-      loaded_phone_number.append(phone_number)
-
-      if (args.strict):
-        assert len(ecc_info.types) > 0
-        loaded_types = []
-        for ecc_type in ecc_info.types:
-          assert ecc_type == protobuf_ecc_data_pb2.EccInfo.POLICE or \
-              ecc_type == protobuf_ecc_data_pb2.EccInfo.AMBULANCE or \
-              ecc_type == protobuf_ecc_data_pb2.EccInfo.FIRE
-          assert ecc_type not in loaded_types
-          loaded_types.append(ecc_type)
-      else:
-        # For forward compatibility, ecc_info.types could be null if a phone
-        # number contains only new types which is not defined now. Just leave
-        # a warning message for this case.
-        if len(ecc_info.types) == 0:
-          print("WARNING: No recognizable type for " + \
-              country_info.iso_code + " - " + ecc_info.phone_number)
-        else:
-          loaded_types = []
-          for ecc_type in ecc_info.types:
-            assert ecc_type not in loaded_types
-            loaded_types.append(ecc_type)
-  elif (args.strict):
-    print("Warning: Empty ecc list for country " + country_info.iso_code)
diff --git a/ecc/gen_eccdata.sh b/ecc/gen_eccdata.sh
index 5cf52de..4f3a097 100755
--- a/ecc/gen_eccdata.sh
+++ b/ecc/gen_eccdata.sh
@@ -53,15 +53,8 @@
 source "${TOOLSET_DIR}/gen_eccdata.sh"
 echo
 
-# Check compatibility with every previous version
-rm -rf "${INTERMEDIATE_DIR}/*"
-source ${ECC_ROOT}/conversion_toolset_v1/verify_eccdata_compatibility.sh
-#rm -rf "${INTERMEDIATE_DIR}/*"
-#source ${ECC_ROOT}/conversion_toolset_v2/verify_eccdata_compatibility.sh
-#rm -rf "${INTERMEDIATE_DIR}/*"
-#source ${ECC_ROOT}/conversion_toolset_v3/verify_eccdata_compatibility.sh
-#...
-
-echo
-echo "Passed all compatibility verification!"
-
+echo "To verify data compatibility:"
+echo "  1. make TeleService"
+echo "  2. push TeleService.apk to system/priv-app/TeleService"
+echo "  3. reboot device"
+echo "  4. run 'atest TeleServiceTests:IsoToEccProtobufRepositoryTest#testEccDataContent'"