diff options
-rw-r--r-- | minadbd/Android.bp | 2 | ||||
-rw-r--r-- | minadbd/minadbd_services.cpp | 21 | ||||
-rw-r--r-- | tests/Android.bp | 11 | ||||
-rw-r--r-- | update_verifier/care_map_generator.py | 39 |
4 files changed, 45 insertions, 28 deletions
diff --git a/minadbd/Android.bp b/minadbd/Android.bp index 00244ee7e..370232b3f 100644 --- a/minadbd/Android.bp +++ b/minadbd/Android.bp @@ -52,6 +52,7 @@ cc_library { cc_test { name: "minadbd_test", + isolated: true, defaults: [ "minadbd_defaults", @@ -64,7 +65,6 @@ cc_test { static_libs: [ "libminadbd_services", "libadbd", - "libBionicGtestMain", ], shared_libs: [ diff --git a/minadbd/minadbd_services.cpp b/minadbd/minadbd_services.cpp index ab1939e92..e9c51da0a 100644 --- a/minadbd/minadbd_services.cpp +++ b/minadbd/minadbd_services.cpp @@ -33,19 +33,20 @@ #include "sysdeps.h" static void sideload_host_service(unique_fd sfd, const std::string& args) { - int file_size; - int block_size; - if (sscanf(args.c_str(), "%d:%d", &file_size, &block_size) != 2) { - printf("bad sideload-host arguments: %s\n", args.c_str()); - exit(1); - } + int64_t file_size; + int block_size; + if ((sscanf(args.c_str(), "%" SCNd64 ":%d", &file_size, &block_size) != 2) || file_size <= 0 || + block_size <= 0) { + printf("bad sideload-host arguments: %s\n", args.c_str()); + exit(1); + } - printf("sideload-host file size %d block size %d\n", file_size, block_size); + printf("sideload-host file size %" PRId64 " block size %d\n", file_size, block_size); - int result = run_adb_fuse(sfd, file_size, block_size); + int result = run_adb_fuse(sfd, file_size, block_size); - printf("sideload_host finished\n"); - exit(result == 0 ? 0 : 1); + printf("sideload_host finished\n"); + exit(result == 0 ? 0 : 1); } unique_fd daemon_service_to_fd(const char* name, atransport* /* transport */) { diff --git a/tests/Android.bp b/tests/Android.bp index 9f3dce78c..2cfc32572 100644 --- a/tests/Android.bp +++ b/tests/Android.bp @@ -100,6 +100,7 @@ librecovery_static_libs = [ cc_test { name: "recovery_unit_test", + isolated: true, defaults: [ "recovery_test_defaults", @@ -118,7 +119,6 @@ cc_test { "libotautil", "libupdater", "libgtest_prod", - "libBionicGtestMain", ], data: ["testdata/*"], @@ -126,6 +126,7 @@ cc_test { cc_test { name: "recovery_manual_test", + isolated: true, defaults: [ "recovery_test_defaults", @@ -136,14 +137,11 @@ cc_test { srcs: [ "manual/recovery_test.cpp", ], - - static_libs: [ - "libBionicGtestMain", - ], } cc_test { name: "recovery_component_test", + isolated: true, defaults: [ "recovery_test_defaults", @@ -160,7 +158,6 @@ cc_test { "libupdater", "libupdate_verifier", "libprotobuf-cpp-lite", - "libBionicGtestMain", ], data: [ @@ -171,6 +168,7 @@ cc_test { cc_test_host { name: "recovery_host_test", + isolated: true, defaults: [ "recovery_test_defaults", @@ -194,7 +192,6 @@ cc_test_host { "libdivsufsort64", "libdivsufsort", "libz", - "libBionicGtestMain", ], data: ["testdata/*"], diff --git a/update_verifier/care_map_generator.py b/update_verifier/care_map_generator.py index 5057ffea7..051d98deb 100644 --- a/update_verifier/care_map_generator.py +++ b/update_verifier/care_map_generator.py @@ -27,32 +27,44 @@ import sys import care_map_pb2 -def GenerateCareMapProtoFromLegacyFormat(lines): +def GenerateCareMapProtoFromLegacyFormat(lines, fingerprint_enabled): """Constructs a care map proto message from the lines of the input file.""" # Expected format of the legacy care_map.txt: # system # system's care_map ranges + # [system's fingerprint property id] + # [system's fingerprint] # [vendor] # [vendor's care_map ranges] + # [vendor's fingerprint property id] + # [vendor's fingerprint] # ... - assert len(lines) % 2 == 0, "line count must be even: {}".format(len(lines)) + + step = 4 if fingerprint_enabled else 2 + assert len(lines) % step == 0, \ + "line count must be multiple of {}: {}".format(step, len(lines)) care_map_proto = care_map_pb2.CareMap() - for index in range(0, len(lines), 2): + for index in range(0, len(lines), step): info = care_map_proto.partitions.add() info.name = lines[index] info.ranges = lines[index + 1] - - logging.info("Adding '%s': '%s' to care map", info.name, info.ranges) + if fingerprint_enabled: + info.id = lines[index + 2] + info.fingerprint = lines[index + 3] + logging.info("Care map info: name %s, ranges %s, id %s, fingerprint %s", + info.name, info.ranges, info.id, info.fingerprint) return care_map_proto -def ParseProtoMessage(message): +def ParseProtoMessage(message, fingerprint_enabled): """Parses the care_map proto message and returns its text representation. Args: - message: care_map in protobuf message + message: Care_map in protobuf format. + fingerprint_enabled: Input protobuf message contains the fields 'id' and + 'fingerprint'. Returns: A string of the care_map information, similar to the care_map legacy @@ -66,8 +78,11 @@ def ParseProtoMessage(message): assert info.name, "partition name is required in care_map" assert info.ranges, "source range is required in care_map" info_list += [info.name, info.ranges] + if fingerprint_enabled: + assert info.id, "property id is required in care_map" + assert info.fingerprint, "fingerprint is required in care_map" + info_list += [info.id, info.fingerprint] - # TODO(xunchang) add a flag to output id & fingerprint also. return '\n'.join(info_list) @@ -81,6 +96,10 @@ def main(argv): " specified).") parser.add_argument("output_file", help="Path to output file to write the result.") + parser.add_argument("--no_fingerprint", action="store_false", + dest="fingerprint_enabled", + help="The 'id' and 'fingerprint' fields are disabled in" + " the caremap.") parser.add_argument("--parse_proto", "-p", action="store_true", help="Parses the input as proto message, and outputs" " the care_map in plain text.") @@ -96,10 +115,10 @@ def main(argv): content = input_care_map.read() if args.parse_proto: - result = ParseProtoMessage(content) + result = ParseProtoMessage(content, args.fingerprint_enabled) else: care_map_proto = GenerateCareMapProtoFromLegacyFormat( - content.rstrip().splitlines()) + content.rstrip().splitlines(), args.fingerprint_enabled) result = care_map_proto.SerializeToString() with open(args.output_file, 'w') as output: |