From 625ebd3911b82a5af4861fae5f8ee139f7d94589 Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Fri, 21 Feb 2020 15:52:57 -0800 Subject: [PATCH] Call verify in create-multiple Idmap Scan previously called Verify before calling Create. OverlayConfig should do the same. Removing the verify call caused b/149784008. Since sSystem is marked @UnsupportedAppUsage, createSystemAssetsInZygoteLocked could potentially be invoked in the system server. Rather than attempting to create the overlays a second time, first check whether the idmap must be invalidated. Bug: 149784008 Test: running forrest using web UI Change-Id: I5d995a87e8552bd156fb5415b2c46a08f4c1d6c5 --- cmds/idmap2/idmap2/CreateMultiple.cpp | 49 ++++++++++++++------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/cmds/idmap2/idmap2/CreateMultiple.cpp b/cmds/idmap2/idmap2/CreateMultiple.cpp index 0b0541fb62214..d4e888fd3119c 100644 --- a/cmds/idmap2/idmap2/CreateMultiple.cpp +++ b/cmds/idmap2/idmap2/CreateMultiple.cpp @@ -31,6 +31,7 @@ #include "idmap2/Idmap.h" #include "idmap2/Policies.h" #include "idmap2/SysTrace.h" +#include "Commands.h" using android::ApkAssets; using android::base::StringPrintf; @@ -105,32 +106,34 @@ Result CreateMultiple(const std::vector& args) { continue; } - const std::unique_ptr overlay_apk = ApkAssets::Load(overlay_apk_path); - if (!overlay_apk) { - LOG(WARNING) << "failed to load apk " << overlay_apk_path.c_str(); - continue; - } + if (!Verify(std::vector({"--idmap-path", idmap_path}))) { + const std::unique_ptr overlay_apk = ApkAssets::Load(overlay_apk_path); + if (!overlay_apk) { + LOG(WARNING) << "failed to load apk " << overlay_apk_path.c_str(); + continue; + } - const auto idmap = - Idmap::FromApkAssets(*target_apk, *overlay_apk, fulfilled_policies, !ignore_overlayable); - if (!idmap) { - LOG(WARNING) << "failed to create idmap"; - continue; - } + const auto idmap = + Idmap::FromApkAssets(*target_apk, *overlay_apk, fulfilled_policies, !ignore_overlayable); + if (!idmap) { + LOG(WARNING) << "failed to create idmap"; + continue; + } - umask(kIdmapFilePermissionMask); - std::ofstream fout(idmap_path); - if (fout.fail()) { - LOG(WARNING) << "failed to open idmap path " << idmap_path.c_str(); - continue; - } + umask(kIdmapFilePermissionMask); + std::ofstream fout(idmap_path); + if (fout.fail()) { + LOG(WARNING) << "failed to open idmap path " << idmap_path.c_str(); + continue; + } - BinaryStreamVisitor visitor(fout); - (*idmap)->accept(&visitor); - fout.close(); - if (fout.fail()) { - LOG(WARNING) << "failed to write to idmap path %s" << idmap_path.c_str(); - continue; + BinaryStreamVisitor visitor(fout); + (*idmap)->accept(&visitor); + fout.close(); + if (fout.fail()) { + LOG(WARNING) << "failed to write to idmap path %s" << idmap_path.c_str(); + continue; + } } idmap_paths.emplace_back(idmap_path);