Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 72864d29 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes I1d3e5e66,I86b869af,Iab4d3902,I645ee722

* changes:
  Fix <overlay-config-signature> comments
  Fix non-inclusive OMS test language
  Remove malloc/free for inline overlay values
  OMS: Add config_signature policy handling
parents b3230cd6 70e02d42
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@
#include <android-base/unique_fd.h>
#include <binder/BinderService.h>

#include <string>

#include "android/os/BnIdmap2.h"

namespace android::os {
+1 −0
Original line number Diff line number Diff line
@@ -29,4 +29,5 @@ interface OverlayablePolicy {
  const int ODM_PARTITION = 0x00000020;
  const int OEM_PARTITION = 0x00000040;
  const int ACTOR_SIGNATURE = 0x00000080;
  const int CONFIG_SIGNATURE = 0x0000100;
}
+1 −2
Original line number Diff line number Diff line
@@ -36,12 +36,11 @@ class BinaryStreamVisitor : public Visitor {
  void visit(const IdmapData::Header& header) override;

 private:
  void Write(const void* value, size_t length);
  void Write8(uint8_t value);
  void Write16(uint16_t value);
  void Write32(uint32_t value);
  void WriteString256(const StringPiece& value);
  void WriteString(const std::string& value);
  void WriteString(const StringPiece& value);
  std::ostream& stream_;
};

+64 −54
Original line number Diff line number Diff line
@@ -18,47 +18,44 @@
 * # idmap file format (current version)
 *
 * idmap                      := header data*
 * header            := magic version target_crc overlay_crc target_path overlay_path debug_info
 * data              := data_header data_block*
 * data_header       := target_package_id types_count
 * data_block        := target_type overlay_type entry_count entry_offset entry*
 * overlay_path      := string256
 * target_path       := string256
 * header                     := magic version target_crc overlay_crc fulfilled_policies
 *                               enforce_overlayable target_path overlay_path debug_info
 * data                       := data_header target_entry* target_inline_entry* overlay_entry*
 *                               string_pool
 * data_header                := target_package_id overlay_package_id padding(2) target_entry_count
 *                               target_inline_entry_count overlay_entry_count string_pool_index
 * target_entry               := target_id overlay_id
 * target_inline_entry        := target_id Res_value::size padding(1) Res_value::type
 *                               Res_value::value
 * overlay_entry              := overlay_id target_id
 *
 * debug_info                 := string
 * string            := <uint32_t> <uint8_t>+ '\0'+
 * entry             := <uint32_t>
 * entry_count       := <uint16_t>
 * entry_offset      := <uint16_t>
 * enforce_overlayable        := <uint32_t>
 * fulfilled_policies         := <uint32_t>
 * magic                      := <uint32_t>
 * overlay_crc                := <uint32_t>
 * overlay_type      := <uint16_t>
 * overlay_entry_count        := <uint32_t>
 * overlay_id                 := <uint32_t>
 * overlay_package_id         := <uint8_t>
 * overlay_path               := string256
 * padding(n)                 := <uint8_t>[n]
 * Res_value::size            := <uint16_t>
 * Res_value::type            := <uint8_t>
 * Res_value::value           := <uint32_t>
 * string                     := <uint32_t> <uint8_t>+ padding(n)
 * string256                  := <uint8_t>[256]
 * string_pool                := string
 * string_pool_index          := <uint32_t>
 * string_pool_length         := <uint32_t>
 * target_crc                 := <uint32_t>
 * target_package_id := <uint16_t>
 * target_type       := <uint16_t>
 * types_count       := <uint16_t>
 * target_entry_count         := <uint32_t>
 * target_inline_entry_count  := <uint32_t>
 * target_id                  := <uint32_t>
 * target_package_id          := <uint8_t>
 * target_path                := string256
 * value_type                 := <uint8_t>
 * value_data                 := <uint32_t>
 * version                    := <uint32_t>
 *
 *
 * # idmap file format changelog
 * ## v1
 * - Identical to idmap v1.
 *
 * ## v2
 * - Entries are no longer separated by type into type specific data blocks.
 * - Added overlay-indexed target resource id lookup capabilities.
 * - Target and overlay entries are stored as a sparse array in the data block. The target entries
 *   array maps from target resource id to overlay data type and value and the array is sorted by
 *   target resource id. The overlay entries array maps from overlay resource id to target resource
 *   id and the array is sorted by overlay resource id. It is important for both arrays to be sorted
 *   to allow for O(log(number_of_overlaid_resources)) performance when looking up resource
 *   mappings at runtime.
 * - Idmap can now encode a type and value to override a resource without needing a table entry.
 * - A string pool block is included to retrieve the value of strings that do not have a resource
 *   table entry.
 *
 * ## v3
 * - Add 'debug' block to IdmapHeader.
 */

#ifndef IDMAP2_INCLUDE_IDMAP2_IDMAP_H_
@@ -183,6 +180,10 @@ class IdmapData {
      return target_entry_count;
    }

    inline uint32_t GetTargetInlineEntryCount() const {
      return target_entry_inline_count;
    }

    inline uint32_t GetOverlayEntryCount() const {
      return overlay_entry_count;
    }
@@ -191,19 +192,15 @@ class IdmapData {
      return string_pool_index_offset;
    }

    inline uint32_t GetStringPoolLength() const {
      return string_pool_len;
    }

    void accept(Visitor* v) const;

   private:
    PackageId target_package_id_;
    PackageId overlay_package_id_;
    uint32_t target_entry_count;
    uint32_t target_entry_inline_count;
    uint32_t overlay_entry_count;
    uint32_t string_pool_index_offset;
    uint32_t string_pool_len;
    Header() = default;

    friend Idmap;
@@ -213,8 +210,12 @@ class IdmapData {

  struct TargetEntry {
    ResourceId target_id;
    TargetValue::DataType data_type;
    TargetValue::DataValue data_value;
    ResourceId overlay_id;
  };

  struct TargetInlineEntry {
    ResourceId target_id;
    TargetValue value;
  };

  struct OverlayEntry {
@@ -227,20 +228,24 @@ class IdmapData {
  static Result<std::unique_ptr<const IdmapData>> FromResourceMapping(
      const ResourceMapping& resource_mapping);

  inline const std::unique_ptr<const Header>& GetHeader() const {
  const std::unique_ptr<const Header>& GetHeader() const {
    return header_;
  }

  inline const std::vector<TargetEntry>& GetTargetEntries() const {
  const std::vector<TargetEntry>& GetTargetEntries() const {
    return target_entries_;
  }

  inline const std::vector<OverlayEntry>& GetOverlayEntries() const {
  const std::vector<TargetInlineEntry>& GetTargetInlineEntries() const {
    return target_inline_entries_;
  }

  const std::vector<OverlayEntry>& GetOverlayEntries() const {
    return overlay_entries_;
  }

  inline const void* GetStringPoolData() const {
    return string_pool_.get();
  const std::string& GetStringPoolData() const {
    return string_pool_data_;
  }

  void accept(Visitor* v) const;
@@ -251,8 +256,9 @@ class IdmapData {

  std::unique_ptr<const Header> header_;
  std::vector<TargetEntry> target_entries_;
  std::vector<TargetInlineEntry> target_inline_entries_;
  std::vector<OverlayEntry> overlay_entries_;
  std::unique_ptr<uint8_t[]> string_pool_;
  std::string string_pool_data_;

  friend Idmap;
  DISALLOW_COPY_AND_ASSIGN(IdmapData);
@@ -304,6 +310,10 @@ class Visitor {
  virtual void visit(const IdmapData::Header& header) = 0;
};

inline size_t CalculatePadding(size_t data_length) {
  return (4 - (data_length % 4)) % 4;
}

}  // namespace android::idmap2

#endif  // IDMAP2_INCLUDE_IDMAP2_IDMAP_H_
+2 −1
Original line number Diff line number Diff line
@@ -41,8 +41,9 @@ class PrettyPrintVisitor : public Visitor {

 private:
  std::ostream& stream_;
  std::unique_ptr<const ApkAssets> target_apk_;
  AssetManager2 target_am_;
  AssetManager2 overlay_am_;
  std::vector<std::unique_ptr<const ApkAssets>> apk_assets_;
};

}  // namespace idmap2
Loading