diff options
-rw-r--r-- | cmds/idmap2/idmap2/Scan.cpp | 30 | ||||
-rwxr-xr-x | cmds/idmap2/static-checks.sh | 10 |
2 files changed, 31 insertions, 9 deletions
diff --git a/cmds/idmap2/idmap2/Scan.cpp b/cmds/idmap2/idmap2/Scan.cpp index 49187475ccdb..4f88127f8af1 100644 --- a/cmds/idmap2/idmap2/Scan.cpp +++ b/cmds/idmap2/idmap2/Scan.cpp @@ -39,6 +39,17 @@ using android::idmap2::ZipFile; using android::idmap2::utils::FindFiles; namespace { + +struct InputOverlay { + bool operator<(InputOverlay const& rhs) const { + return priority < rhs.priority || (priority == rhs.priority && apk_path < rhs.apk_path); + } + + std::string apk_path; // NOLINT(misc-non-private-member-variables-in-classes) + std::string idmap_path; // NOLINT(misc-non-private-member-variables-in-classes) + int priority; // NOLINT(misc-non-private-member-variables-in-classes) +}; + std::unique_ptr<std::vector<std::string>> FindApkFiles(const std::vector<std::string>& dirs, bool recursive, std::ostream& out_error) { const auto predicate = [](unsigned char type, const std::string& path) -> bool { @@ -58,6 +69,7 @@ std::unique_ptr<std::vector<std::string>> FindApkFiles(const std::vector<std::st } return std::make_unique<std::vector<std::string>>(paths.cbegin(), paths.cend()); } + } // namespace bool Scan(const std::vector<std::string>& args, std::ostream& out_error) { @@ -87,7 +99,7 @@ bool Scan(const std::vector<std::string>& args, std::ostream& out_error) { return false; } - std::vector<std::string> interesting_apks; + std::vector<InputOverlay> interesting_apks; for (const std::string& path : *apk_paths) { std::unique_ptr<const ZipFile> zip = ZipFile::Open(path); if (!zip) { @@ -132,27 +144,29 @@ bool Scan(const std::vector<std::string>& args, std::ostream& out_error) { continue; } + // Sort the static overlays in ascending priority order + std::string idmap_path = Idmap::CanonicalIdmapPathFor(output_directory, path); + InputOverlay input{path, idmap_path, priority}; interesting_apks.insert( - std::lower_bound(interesting_apks.begin(), interesting_apks.end(), path), path); + std::lower_bound(interesting_apks.begin(), interesting_apks.end(), input), input); } std::stringstream stream; - for (const auto& apk : interesting_apks) { - const std::string idmap_path = Idmap::CanonicalIdmapPathFor(output_directory, apk); + for (const auto& overlay : interesting_apks) { std::stringstream dev_null; - if (!Verify(std::vector<std::string>({"--idmap-path", idmap_path}), dev_null) && + if (!Verify(std::vector<std::string>({"--idmap-path", overlay.idmap_path}), dev_null) && !Create(std::vector<std::string>({ "--target-apk-path", target_apk_path, "--overlay-apk-path", - apk, + overlay.apk_path, "--idmap-path", - idmap_path, + overlay.idmap_path, }), out_error)) { return false; } - stream << idmap_path << std::endl; + stream << overlay.idmap_path << std::endl; } std::cout << stream.str(); diff --git a/cmds/idmap2/static-checks.sh b/cmds/idmap2/static-checks.sh index 560ccb692bb1..ad9830b8a096 100755 --- a/cmds/idmap2/static-checks.sh +++ b/cmds/idmap2/static-checks.sh @@ -70,7 +70,15 @@ function _bpfmt() function _cpplint() { local cpplint="${ANDROID_BUILD_TOP}/tools/repohooks/tools/cpplint.py" - $cpplint --quiet $cpp_files + local output="$($cpplint --quiet $cpp_files 2>&1 >/dev/null | grep -v \ + -e 'Found C system header after C++ system header.' \ + -e 'Unknown NOLINT error category: misc-non-private-member-variables-in-classes' \ + )" + if [[ "$output" ]]; then + echo "$output" + return 1 + fi + return 0 } function _parse_args() |