diff options
author | Brian Orr <brianorr@google.com> | 2021-06-15 12:47:53 -0700 |
---|---|---|
committer | Daniel Norman <danielnorman@google.com> | 2021-06-17 13:37:54 -0700 |
commit | 71c831703ae59baf47e0afe611fecd714c481cdf (patch) | |
tree | 06731a987032723085b9e1a65951cf96abbc19cf /cmds/idmap2/idmap2d/Idmap2Service.cpp | |
parent | 065c9e9a6e9d61d4383a91721eb56a3de253bdbe (diff) | |
parent | 81833820d54b9a6b27894f9f8dfd72222d416992 (diff) |
Merge SP1A.210604.001
Change-Id: I5200ee05285ae422d5e9c1c00f45709a5d6188be
Diffstat (limited to 'cmds/idmap2/idmap2d/Idmap2Service.cpp')
-rw-r--r-- | cmds/idmap2/idmap2d/Idmap2Service.cpp | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/cmds/idmap2/idmap2d/Idmap2Service.cpp b/cmds/idmap2/idmap2d/Idmap2Service.cpp index 05336baf9217..2cfbac3f2c26 100644 --- a/cmds/idmap2/idmap2d/Idmap2Service.cpp +++ b/cmds/idmap2/idmap2d/Idmap2Service.cpp @@ -26,6 +26,8 @@ #include <memory> #include <ostream> #include <string> +#include <utility> +#include <vector> #include "android-base/macros.h" #include "android-base/stringprintf.h" @@ -33,6 +35,7 @@ #include "idmap2/BinaryStreamVisitor.h" #include "idmap2/FileUtils.h" #include "idmap2/Idmap.h" +#include "idmap2/PrettyPrintVisitor.h" #include "idmap2/Result.h" #include "idmap2/SysTrace.h" @@ -45,6 +48,7 @@ using android::idmap2::FabricatedOverlayContainer; using android::idmap2::Idmap; using android::idmap2::IdmapHeader; using android::idmap2::OverlayResourceContainer; +using android::idmap2::PrettyPrintVisitor; using android::idmap2::TargetResourceContainer; using android::idmap2::utils::kIdmapCacheDir; using android::idmap2::utils::kIdmapFilePermissionMask; @@ -262,17 +266,17 @@ Status Idmap2Service::createFabricatedOverlay( path.c_str(), uid)); } + const auto frro = builder.Build(); + if (!frro) { + return error(StringPrintf("failed to serialize '%s:%s': %s", overlay.packageName.c_str(), + overlay.overlayName.c_str(), frro.GetErrorMessage().c_str())); + } // Persist the fabricated overlay. umask(kIdmapFilePermissionMask); std::ofstream fout(path); if (fout.fail()) { return error("failed to open frro path " + path); } - const auto frro = builder.Build(); - if (!frro) { - return error(StringPrintf("failed to serialize '%s:%s': %s", overlay.packageName.c_str(), - overlay.overlayName.c_str(), frro.GetErrorMessage().c_str())); - } auto result = frro->ToBinaryStream(fout); if (!result) { unlink(path.c_str()); @@ -352,4 +356,24 @@ binder::Status Idmap2Service::deleteFabricatedOverlay(const std::string& overlay return ok(); } +binder::Status Idmap2Service::dumpIdmap(const std::string& overlay_path, + std::string* _aidl_return) { + assert(_aidl_return); + + const auto idmap_path = Idmap::CanonicalIdmapPathFor(kIdmapCacheDir, overlay_path); + std::ifstream fin(idmap_path); + const auto idmap = Idmap::FromBinaryStream(fin); + fin.close(); + if (!idmap) { + return error(idmap.GetErrorMessage()); + } + + std::stringstream stream; + PrettyPrintVisitor visitor(stream); + (*idmap)->accept(&visitor); + *_aidl_return = stream.str(); + + return ok(); +} + } // namespace android::os |