Merge "Call verify in create-multiple" into rvc-dev

This commit is contained in:
TreeHugger Robot
2020-02-26 18:10:44 +00:00
committed by Android (Google) Code Review

View File

@@ -31,6 +31,7 @@
#include "idmap2/Idmap.h" #include "idmap2/Idmap.h"
#include "idmap2/Policies.h" #include "idmap2/Policies.h"
#include "idmap2/SysTrace.h" #include "idmap2/SysTrace.h"
#include "Commands.h"
using android::ApkAssets; using android::ApkAssets;
using android::base::StringPrintf; using android::base::StringPrintf;
@@ -105,32 +106,34 @@ Result<Unit> CreateMultiple(const std::vector<std::string>& args) {
continue; continue;
} }
const std::unique_ptr<const ApkAssets> overlay_apk = ApkAssets::Load(overlay_apk_path); if (!Verify(std::vector<std::string>({"--idmap-path", idmap_path}))) {
if (!overlay_apk) { const std::unique_ptr<const ApkAssets> overlay_apk = ApkAssets::Load(overlay_apk_path);
LOG(WARNING) << "failed to load apk " << overlay_apk_path.c_str(); if (!overlay_apk) {
continue; LOG(WARNING) << "failed to load apk " << overlay_apk_path.c_str();
} continue;
}
const auto idmap = const auto idmap =
Idmap::FromApkAssets(*target_apk, *overlay_apk, fulfilled_policies, !ignore_overlayable); Idmap::FromApkAssets(*target_apk, *overlay_apk, fulfilled_policies, !ignore_overlayable);
if (!idmap) { if (!idmap) {
LOG(WARNING) << "failed to create idmap"; LOG(WARNING) << "failed to create idmap";
continue; continue;
} }
umask(kIdmapFilePermissionMask); umask(kIdmapFilePermissionMask);
std::ofstream fout(idmap_path); std::ofstream fout(idmap_path);
if (fout.fail()) { if (fout.fail()) {
LOG(WARNING) << "failed to open idmap path " << idmap_path.c_str(); LOG(WARNING) << "failed to open idmap path " << idmap_path.c_str();
continue; continue;
} }
BinaryStreamVisitor visitor(fout); BinaryStreamVisitor visitor(fout);
(*idmap)->accept(&visitor); (*idmap)->accept(&visitor);
fout.close(); fout.close();
if (fout.fail()) { if (fout.fail()) {
LOG(WARNING) << "failed to write to idmap path %s" << idmap_path.c_str(); LOG(WARNING) << "failed to write to idmap path %s" << idmap_path.c_str();
continue; continue;
}
} }
idmap_paths.emplace_back(idmap_path); idmap_paths.emplace_back(idmap_path);