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 | |
parent | 065c9e9a6e9d61d4383a91721eb56a3de253bdbe (diff) | |
parent | 81833820d54b9a6b27894f9f8dfd72222d416992 (diff) |
Merge SP1A.210604.001
Change-Id: I5200ee05285ae422d5e9c1c00f45709a5d6188be
Diffstat (limited to 'cmds')
-rw-r--r-- | cmds/idmap2/CPPLINT.cfg | 2 | ||||
-rw-r--r-- | cmds/idmap2/OWNERS | 3 | ||||
-rw-r--r-- | cmds/idmap2/idmap2/CommandUtils.cpp | 1 | ||||
-rw-r--r-- | cmds/idmap2/idmap2/CommandUtils.h | 8 | ||||
-rw-r--r-- | cmds/idmap2/idmap2/Create.cpp | 1 | ||||
-rw-r--r-- | cmds/idmap2/idmap2d/Idmap2Service.cpp | 34 | ||||
-rw-r--r-- | cmds/idmap2/idmap2d/Idmap2Service.h | 4 | ||||
-rw-r--r-- | cmds/idmap2/idmap2d/aidl/services/android/os/IIdmap2.aidl | 3 | ||||
-rw-r--r-- | cmds/idmap2/include/idmap2/FabricatedOverlay.h | 11 | ||||
-rw-r--r-- | cmds/idmap2/include/idmap2/ResourceContainer.h | 7 | ||||
-rw-r--r-- | cmds/idmap2/libidmap2/FabricatedOverlay.cpp | 12 | ||||
-rw-r--r-- | cmds/idmap2/libidmap2/PrettyPrintVisitor.cpp | 1 | ||||
-rw-r--r-- | cmds/idmap2/libidmap2/RawPrintVisitor.cpp | 2 | ||||
-rw-r--r-- | cmds/idmap2/libidmap2/ResourceContainer.cpp | 9 | ||||
-rw-r--r-- | cmds/idmap2/libidmap2/ResourceUtils.cpp | 1 | ||||
-rw-r--r-- | cmds/idmap2/tests/FabricatedOverlayTests.cpp | 3 | ||||
-rw-r--r-- | cmds/idmap2/tests/IdmapTests.cpp | 4 | ||||
-rw-r--r-- | cmds/idmap2/tests/R.h | 4 | ||||
-rw-r--r-- | cmds/idmap2/tests/XmlParserTests.cpp | 2 |
19 files changed, 82 insertions, 30 deletions
diff --git a/cmds/idmap2/CPPLINT.cfg b/cmds/idmap2/CPPLINT.cfg index 20ed43c2a76a..eada694095d6 100644 --- a/cmds/idmap2/CPPLINT.cfg +++ b/cmds/idmap2/CPPLINT.cfg @@ -15,4 +15,4 @@ set noparent linelength=100 root=.. -filter=+build/include_alpha,-runtime/references,-build/c++ +filter=+build/include_alpha,-runtime/references,-build/c++,-build/include_alpha diff --git a/cmds/idmap2/OWNERS b/cmds/idmap2/OWNERS index f1903a5a54a7..69dfcc98340d 100644 --- a/cmds/idmap2/OWNERS +++ b/cmds/idmap2/OWNERS @@ -1,3 +1,4 @@ set noparent toddke@google.com -rtmitchell@google.com
\ No newline at end of file +rtmitchell@google.com +patb@google.com
\ No newline at end of file diff --git a/cmds/idmap2/idmap2/CommandUtils.cpp b/cmds/idmap2/idmap2/CommandUtils.cpp index bf30a76d581a..63235ff7d199 100644 --- a/cmds/idmap2/idmap2/CommandUtils.cpp +++ b/cmds/idmap2/idmap2/CommandUtils.cpp @@ -19,6 +19,7 @@ #include <string> #include <vector> +#include "idmap2/CommandUtils.h" #include "idmap2/Idmap.h" #include "idmap2/Result.h" #include "idmap2/SysTrace.h" diff --git a/cmds/idmap2/idmap2/CommandUtils.h b/cmds/idmap2/idmap2/CommandUtils.h index e06896784d6a..341fec84ce9a 100644 --- a/cmds/idmap2/idmap2/CommandUtils.h +++ b/cmds/idmap2/idmap2/CommandUtils.h @@ -14,8 +14,10 @@ * limitations under the License. */ -#ifndef IDMAP2_IDMAP2_COMMAND_UTILS_H_ -#define IDMAP2_IDMAP2_COMMAND_UTILS_H_ +#ifndef IDMAP2_IDMAP2_COMMANDUTILS_H_ +#define IDMAP2_IDMAP2_COMMANDUTILS_H_ + +#include <string> #include "idmap2/PolicyUtils.h" #include "idmap2/Result.h" @@ -24,4 +26,4 @@ android::idmap2::Result<android::idmap2::Unit> Verify( const std::string& idmap_path, const std::string& target_path, const std::string& overlay_path, const std::string& overlay_name, PolicyBitmask fulfilled_policies, bool enforce_overlayable); -#endif // IDMAP2_IDMAP2_COMMAND_UTILS_H_ +#endif // IDMAP2_IDMAP2_COMMANDUTILS_H_ diff --git a/cmds/idmap2/idmap2/Create.cpp b/cmds/idmap2/idmap2/Create.cpp index 977a0bbadafb..d5f1b895facf 100644 --- a/cmds/idmap2/idmap2/Create.cpp +++ b/cmds/idmap2/idmap2/Create.cpp @@ -20,6 +20,7 @@ #include <fstream> #include <memory> #include <ostream> +#include <string> #include <vector> #include "androidfw/ResourceTypes.h" 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 diff --git a/cmds/idmap2/idmap2d/Idmap2Service.h b/cmds/idmap2/idmap2d/Idmap2Service.h index 4d16ff39884b..c16c3c52155f 100644 --- a/cmds/idmap2/idmap2d/Idmap2Service.h +++ b/cmds/idmap2/idmap2d/Idmap2Service.h @@ -24,7 +24,9 @@ #include <idmap2/ResourceContainer.h> #include <idmap2/Result.h> +#include <memory> #include <string> +#include <vector> namespace android::os { @@ -60,6 +62,8 @@ class Idmap2Service : public BinderService<Idmap2Service>, public BnIdmap2 { binder::Status getFabricatedOverlayInfos( std::vector<os::FabricatedOverlayInfo>* _aidl_return) override; + binder::Status dumpIdmap(const std::string& overlay_path, std::string* _aidl_return) override; + private: // idmap2d is killed after a period of inactivity, so any information stored on this class should // be able to be recalculated if idmap2 dies and restarts. diff --git a/cmds/idmap2/idmap2d/aidl/services/android/os/IIdmap2.aidl b/cmds/idmap2/idmap2d/aidl/services/android/os/IIdmap2.aidl index 35bca98bcf69..48cee69ca779 100644 --- a/cmds/idmap2/idmap2d/aidl/services/android/os/IIdmap2.aidl +++ b/cmds/idmap2/idmap2d/aidl/services/android/os/IIdmap2.aidl @@ -16,8 +16,8 @@ package android.os; -import android.os.FabricatedOverlayInternal; import android.os.FabricatedOverlayInfo; +import android.os.FabricatedOverlayInternal; /** * @hide @@ -40,4 +40,5 @@ interface IIdmap2 { @nullable FabricatedOverlayInfo createFabricatedOverlay(in FabricatedOverlayInternal overlay); List<FabricatedOverlayInfo> getFabricatedOverlayInfos(); boolean deleteFabricatedOverlay(@utf8InCpp String path); + @utf8InCpp String dumpIdmap(@utf8InCpp String overlayApkPath); } diff --git a/cmds/idmap2/include/idmap2/FabricatedOverlay.h b/cmds/idmap2/include/idmap2/FabricatedOverlay.h index be687d98081e..375671881e5f 100644 --- a/cmds/idmap2/include/idmap2/FabricatedOverlay.h +++ b/cmds/idmap2/include/idmap2/FabricatedOverlay.h @@ -14,15 +14,17 @@ * limitations under the License. */ -#ifndef IDMAP2_INCLUDE_IDMAP2_FABRICATEDOVERLAY_H -#define IDMAP2_INCLUDE_IDMAP2_FABRICATEDOVERLAY_H +#ifndef IDMAP2_INCLUDE_IDMAP2_FABRICATEDOVERLAY_H_ +#define IDMAP2_INCLUDE_IDMAP2_FABRICATEDOVERLAY_H_ #include <libidmap2/proto/fabricated_v1.pb.h> #include <iostream> #include <map> #include <memory> +#include <string> #include <unordered_map> +#include <vector> #include "idmap2/ResourceContainer.h" #include "idmap2/Result.h" @@ -68,7 +70,8 @@ struct FabricatedOverlay { Result<SerializedData*> InitializeData() const; Result<uint32_t> GetCrc() const; - FabricatedOverlay(pb::FabricatedOverlay&& overlay, std::optional<uint32_t> crc_from_disk = {}); + explicit FabricatedOverlay(pb::FabricatedOverlay&& overlay, + std::optional<uint32_t> crc_from_disk = {}); pb::FabricatedOverlay overlay_pb_; std::optional<uint32_t> crc_from_disk_; @@ -102,4 +105,4 @@ struct FabricatedOverlayContainer : public OverlayResourceContainer { } // namespace android::idmap2 -#endif // IDMAP2_INCLUDE_IDMAP2_FABRICATEDOVERLAY_H +#endif // IDMAP2_INCLUDE_IDMAP2_FABRICATEDOVERLAY_H_ diff --git a/cmds/idmap2/include/idmap2/ResourceContainer.h b/cmds/idmap2/include/idmap2/ResourceContainer.h index 74a6f5666c2a..c3ba4640bd77 100644 --- a/cmds/idmap2/include/idmap2/ResourceContainer.h +++ b/cmds/idmap2/include/idmap2/ResourceContainer.h @@ -14,9 +14,10 @@ * limitations under the License. */ -#ifndef IDMAP2_INCLUDE_IDMAP2_RESOURCECONTAINER_H -#define IDMAP2_INCLUDE_IDMAP2_RESOURCECONTAINER_H +#ifndef IDMAP2_INCLUDE_IDMAP2_RESOURCECONTAINER_H_ +#define IDMAP2_INCLUDE_IDMAP2_RESOURCECONTAINER_H_ +#include <memory> #include <string> #include <variant> #include <vector> @@ -103,4 +104,4 @@ struct OverlayResourceContainer : public ResourceContainer { } // namespace android::idmap2 -#endif // IDMAP2_INCLUDE_IDMAP2_RESOURCECONTAINER_H +#endif // IDMAP2_INCLUDE_IDMAP2_RESOURCECONTAINER_H_ diff --git a/cmds/idmap2/libidmap2/FabricatedOverlay.cpp b/cmds/idmap2/libidmap2/FabricatedOverlay.cpp index 4f61801aa594..8352dbb7b619 100644 --- a/cmds/idmap2/libidmap2/FabricatedOverlay.cpp +++ b/cmds/idmap2/libidmap2/FabricatedOverlay.cpp @@ -23,6 +23,10 @@ #include <zlib.h> #include <fstream> +#include <map> +#include <memory> +#include <string> +#include <utility> namespace android::idmap2 { @@ -89,7 +93,7 @@ Result<FabricatedOverlay> FabricatedOverlay::Builder::Build() { auto package = entries.find(package_name); if (package == entries.end()) { package = entries - .insert(std::make_pair<>( + .insert(std::make_pair( package_name, std::map<std::string, std::map<std::string, TargetValue>>())) .first; } @@ -98,13 +102,13 @@ Result<FabricatedOverlay> FabricatedOverlay::Builder::Build() { if (type == package->second.end()) { type = package->second - .insert(std::make_pair<>(type_name.to_string(), std::map<std::string, TargetValue>())) + .insert(std::make_pair(type_name.to_string(), std::map<std::string, TargetValue>())) .first; } auto entry = type->second.find(entry_name.to_string()); if (entry == type->second.end()) { - entry = type->second.insert(std::make_pair<>(entry_name.to_string(), TargetValue())).first; + entry = type->second.insert(std::make_pair(entry_name.to_string(), TargetValue())).first; } entry->second = TargetValue{res_entry.data_type, res_entry.data_value}; @@ -299,4 +303,4 @@ Result<std::string> FabContainer::GetResourceName(ResourceId /* id */) const { return Error("Fabricated overlay does not contain resources."); } -} // namespace android::idmap2
\ No newline at end of file +} // namespace android::idmap2 diff --git a/cmds/idmap2/libidmap2/PrettyPrintVisitor.cpp b/cmds/idmap2/libidmap2/PrettyPrintVisitor.cpp index 721612cc567b..d10a2785aaba 100644 --- a/cmds/idmap2/libidmap2/PrettyPrintVisitor.cpp +++ b/cmds/idmap2/libidmap2/PrettyPrintVisitor.cpp @@ -18,6 +18,7 @@ #include <istream> #include <string> +#include <utility> #include "android-base/macros.h" #include "android-base/stringprintf.h" diff --git a/cmds/idmap2/libidmap2/RawPrintVisitor.cpp b/cmds/idmap2/libidmap2/RawPrintVisitor.cpp index a016a36a2e3d..779538c617f4 100644 --- a/cmds/idmap2/libidmap2/RawPrintVisitor.cpp +++ b/cmds/idmap2/libidmap2/RawPrintVisitor.cpp @@ -18,6 +18,8 @@ #include <algorithm> #include <cstdarg> +#include <string> +#include <utility> #include "android-base/macros.h" #include "android-base/stringprintf.h" diff --git a/cmds/idmap2/libidmap2/ResourceContainer.cpp b/cmds/idmap2/libidmap2/ResourceContainer.cpp index 9147ccaaa17a..a62472c8f11e 100644 --- a/cmds/idmap2/libidmap2/ResourceContainer.cpp +++ b/cmds/idmap2/libidmap2/ResourceContainer.cpp @@ -16,6 +16,11 @@ #include "idmap2/ResourceContainer.h" +#include <memory> +#include <string> +#include <utility> +#include <vector> + #include "androidfw/ApkAssets.h" #include "androidfw/AssetManager.h" #include "androidfw/Util.h" @@ -323,7 +328,7 @@ ApkResourceContainer::ApkResourceContainer(std::unique_ptr<ZipAssetsProvider> zi Result<std::unique_ptr<ApkResourceContainer>> ApkResourceContainer::FromPath( const std::string& path) { - auto zip_assets = ZipAssetsProvider::Create(path); + auto zip_assets = ZipAssetsProvider::Create(path, 0 /* flags */); if (zip_assets == nullptr) { return Error("failed to load zip assets"); } @@ -445,4 +450,4 @@ Result<std::unique_ptr<OverlayResourceContainer>> OverlayResourceContainer::From return std::unique_ptr<OverlayResourceContainer>(result->release()); } -} // namespace android::idmap2
\ No newline at end of file +} // namespace android::idmap2 diff --git a/cmds/idmap2/libidmap2/ResourceUtils.cpp b/cmds/idmap2/libidmap2/ResourceUtils.cpp index e809bf1f4b02..32c04d2a6cab 100644 --- a/cmds/idmap2/libidmap2/ResourceUtils.cpp +++ b/cmds/idmap2/libidmap2/ResourceUtils.cpp @@ -17,6 +17,7 @@ #include "idmap2/ResourceUtils.h" #include <memory> +#include <string> #include "androidfw/StringPiece.h" #include "androidfw/Util.h" diff --git a/cmds/idmap2/tests/FabricatedOverlayTests.cpp b/cmds/idmap2/tests/FabricatedOverlayTests.cpp index 79ab2438af74..468ea0c634c1 100644 --- a/cmds/idmap2/tests/FabricatedOverlayTests.cpp +++ b/cmds/idmap2/tests/FabricatedOverlayTests.cpp @@ -19,6 +19,7 @@ #include <idmap2/FabricatedOverlay.h> #include <fstream> +#include <utility> namespace android::idmap2 { @@ -135,4 +136,4 @@ TEST(FabricatedOverlayTests, SerializeAndDeserialize) { EXPECT_EQ(Res_value::TYPE_INT_DEC, entry->data_type); } -} // namespace android::idmap2
\ No newline at end of file +} // namespace android::idmap2 diff --git a/cmds/idmap2/tests/IdmapTests.cpp b/cmds/idmap2/tests/IdmapTests.cpp index 9516ff83d718..9c6402a6e36e 100644 --- a/cmds/idmap2/tests/IdmapTests.cpp +++ b/cmds/idmap2/tests/IdmapTests.cpp @@ -83,7 +83,7 @@ TEST(IdmapTests, IdmapFailParsingDifferentVersion) { std::stringstream stream; stream << android::kIdmapMagic; stream << 0xffffffffU; - stream << std::string(kJunkSize, (char)0xffU); + stream << std::string(kJunkSize, static_cast<char>(0xffU)); ASSERT_FALSE(Idmap::FromBinaryStream(stream)); } @@ -92,7 +92,7 @@ TEST(IdmapTests, IdmapFailParsingDifferentMagic) { std::stringstream stream; stream << 0xffffffffU; stream << android::kIdmapCurrentVersion; - stream << std::string(kJunkSize, (char)0xffU); + stream << std::string(kJunkSize, static_cast<char>(0xffU)); ASSERT_FALSE(Idmap::FromBinaryStream(stream)); } diff --git a/cmds/idmap2/tests/R.h b/cmds/idmap2/tests/R.h index ac9b0580d2d9..89219c9c8213 100644 --- a/cmds/idmap2/tests/R.h +++ b/cmds/idmap2/tests/R.h @@ -66,8 +66,8 @@ namespace R::overlay { constexpr ResourceId str1 = 0x7f02000b; constexpr ResourceId str3 = 0x7f02000c; constexpr ResourceId str4 = 0x7f02000d; - } -} + } // namespace string +} // namespace R::overlay // clang-format on } // namespace android::idmap2 diff --git a/cmds/idmap2/tests/XmlParserTests.cpp b/cmds/idmap2/tests/XmlParserTests.cpp index eaf10a7d9282..016c5c3a01a5 100644 --- a/cmds/idmap2/tests/XmlParserTests.cpp +++ b/cmds/idmap2/tests/XmlParserTests.cpp @@ -26,7 +26,7 @@ namespace android::idmap2 { Result<XmlParser> CreateTestParser(const std::string& test_file) { - auto zip = ZipAssetsProvider::Create(GetTestDataPath() + "/target/target.apk"); + auto zip = ZipAssetsProvider::Create(GetTestDataPath() + "/target/target.apk", 0 /* flags */); if (zip == nullptr) { return Error("Failed to open zip file"); } |