Loading cmds/idmap2/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -222,6 +222,7 @@ cc_test { }, data: [ "tests/data/**/*.apk", "tests/data/**/*.png", ], compile_multilib: "first", test_options: { Loading cmds/idmap2/idmap2d/Idmap2Service.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ #include "idmap2/PrettyPrintVisitor.h" #include "idmap2/Result.h" #include "idmap2/SysTrace.h" #include <fcntl.h> using android::base::StringPrintf; using android::binder::Status; Loading Loading @@ -238,6 +239,9 @@ Status Idmap2Service::createFabricatedOverlay( if (res.dataType == Res_value::TYPE_STRING) { builder.SetResourceValue(res.resourceName, res.dataType, res.stringData.value(), res.configuration.value_or(std::string())); } else if (res.binaryData.has_value()) { builder.SetResourceValue(res.resourceName, res.binaryData->get(), res.configuration.value_or(std::string())); } else { builder.SetResourceValue(res.resourceName, res.dataType, res.data, res.configuration.value_or(std::string())); Loading @@ -264,6 +268,7 @@ Status Idmap2Service::createFabricatedOverlay( file_name.c_str(), kMaxFileNameLength)); } } while (std::filesystem::exists(path)); builder.setFrroPath(path); const uid_t uid = IPCThreadState::self()->getCallingUid(); if (!UidHasWriteAccessToPath(uid, path)) { Loading cmds/idmap2/idmap2d/aidl/core/android/os/FabricatedOverlayInternalEntry.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -24,5 +24,6 @@ parcelable FabricatedOverlayInternalEntry { int dataType; int data; @nullable @utf8InCpp String stringData; @nullable ParcelFileDescriptor binaryData; @nullable @utf8InCpp String configuration; } No newline at end of file cmds/idmap2/include/idmap2/FabricatedOverlay.h +16 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ #include "idmap2/ResourceContainer.h" #include "idmap2/Result.h" #include <binder/ParcelFileDescriptor.h> namespace android::idmap2 { Loading @@ -45,6 +46,15 @@ struct FabricatedOverlay { const std::string& data_string_value, const std::string& configuration); Builder& SetResourceValue(const std::string& resource_name, std::optional<android::base::borrowed_fd>&& binary_value, const std::string& configuration); inline Builder& setFrroPath(std::string frro_path) { frro_path_ = std::move(frro_path); return *this; } WARN_UNUSED Result<FabricatedOverlay> Build(); private: Loading @@ -53,6 +63,7 @@ struct FabricatedOverlay { DataType data_type; DataValue data_value; std::string data_string_value; std::optional<android::base::borrowed_fd> data_binary_value; std::string configuration; }; Loading @@ -60,6 +71,7 @@ struct FabricatedOverlay { std::string name_; std::string target_package_name_; std::string target_overlayable_; std::string frro_path_; std::vector<Entry> entries_; }; Loading @@ -79,10 +91,14 @@ struct FabricatedOverlay { explicit FabricatedOverlay(pb::FabricatedOverlay&& overlay, std::string&& string_pool_data_, std::vector<android::base::borrowed_fd> binary_files_, off_t total_binary_bytes_, std::optional<uint32_t> crc_from_disk = {}); pb::FabricatedOverlay overlay_pb_; std::string string_pool_data_; std::vector<android::base::borrowed_fd> binary_files_; uint32_t total_binary_bytes_; std::optional<uint32_t> crc_from_disk_; mutable std::optional<SerializedData> data_; Loading cmds/idmap2/include/idmap2/ResourceUtils.h +2 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <optional> #include <string> #include <android-base/unique_fd.h> #include "androidfw/AssetManager2.h" #include "idmap2/Result.h" Loading @@ -41,6 +42,7 @@ struct TargetValue { DataType data_type; DataValue data_value; std::string data_string_value; std::optional<android::base::borrowed_fd> data_binary_value; }; struct TargetValueWithConfig { Loading Loading
cmds/idmap2/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -222,6 +222,7 @@ cc_test { }, data: [ "tests/data/**/*.apk", "tests/data/**/*.png", ], compile_multilib: "first", test_options: { Loading
cmds/idmap2/idmap2d/Idmap2Service.cpp +5 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ #include "idmap2/PrettyPrintVisitor.h" #include "idmap2/Result.h" #include "idmap2/SysTrace.h" #include <fcntl.h> using android::base::StringPrintf; using android::binder::Status; Loading Loading @@ -238,6 +239,9 @@ Status Idmap2Service::createFabricatedOverlay( if (res.dataType == Res_value::TYPE_STRING) { builder.SetResourceValue(res.resourceName, res.dataType, res.stringData.value(), res.configuration.value_or(std::string())); } else if (res.binaryData.has_value()) { builder.SetResourceValue(res.resourceName, res.binaryData->get(), res.configuration.value_or(std::string())); } else { builder.SetResourceValue(res.resourceName, res.dataType, res.data, res.configuration.value_or(std::string())); Loading @@ -264,6 +268,7 @@ Status Idmap2Service::createFabricatedOverlay( file_name.c_str(), kMaxFileNameLength)); } } while (std::filesystem::exists(path)); builder.setFrroPath(path); const uid_t uid = IPCThreadState::self()->getCallingUid(); if (!UidHasWriteAccessToPath(uid, path)) { Loading
cmds/idmap2/idmap2d/aidl/core/android/os/FabricatedOverlayInternalEntry.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -24,5 +24,6 @@ parcelable FabricatedOverlayInternalEntry { int dataType; int data; @nullable @utf8InCpp String stringData; @nullable ParcelFileDescriptor binaryData; @nullable @utf8InCpp String configuration; } No newline at end of file
cmds/idmap2/include/idmap2/FabricatedOverlay.h +16 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ #include "idmap2/ResourceContainer.h" #include "idmap2/Result.h" #include <binder/ParcelFileDescriptor.h> namespace android::idmap2 { Loading @@ -45,6 +46,15 @@ struct FabricatedOverlay { const std::string& data_string_value, const std::string& configuration); Builder& SetResourceValue(const std::string& resource_name, std::optional<android::base::borrowed_fd>&& binary_value, const std::string& configuration); inline Builder& setFrroPath(std::string frro_path) { frro_path_ = std::move(frro_path); return *this; } WARN_UNUSED Result<FabricatedOverlay> Build(); private: Loading @@ -53,6 +63,7 @@ struct FabricatedOverlay { DataType data_type; DataValue data_value; std::string data_string_value; std::optional<android::base::borrowed_fd> data_binary_value; std::string configuration; }; Loading @@ -60,6 +71,7 @@ struct FabricatedOverlay { std::string name_; std::string target_package_name_; std::string target_overlayable_; std::string frro_path_; std::vector<Entry> entries_; }; Loading @@ -79,10 +91,14 @@ struct FabricatedOverlay { explicit FabricatedOverlay(pb::FabricatedOverlay&& overlay, std::string&& string_pool_data_, std::vector<android::base::borrowed_fd> binary_files_, off_t total_binary_bytes_, std::optional<uint32_t> crc_from_disk = {}); pb::FabricatedOverlay overlay_pb_; std::string string_pool_data_; std::vector<android::base::borrowed_fd> binary_files_; uint32_t total_binary_bytes_; std::optional<uint32_t> crc_from_disk_; mutable std::optional<SerializedData> data_; Loading
cmds/idmap2/include/idmap2/ResourceUtils.h +2 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <optional> #include <string> #include <android-base/unique_fd.h> #include "androidfw/AssetManager2.h" #include "idmap2/Result.h" Loading @@ -41,6 +42,7 @@ struct TargetValue { DataType data_type; DataValue data_value; std::string data_string_value; std::optional<android::base::borrowed_fd> data_binary_value; }; struct TargetValueWithConfig { Loading