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

Commit 55835861 authored by Jeremy Meyer's avatar Jeremy Meyer Committed by Android (Google) Code Review
Browse files

Merge "implement drawable frros"

parents 0077f82b a761f332
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -222,6 +222,7 @@ cc_test {
    },
    data: [
        "tests/data/**/*.apk",
        "tests/data/**/*.png",
    ],
    compile_multilib: "first",
    test_options: {
+5 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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()));
@@ -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)) {
+1 −0
Original line number Diff line number Diff line
@@ -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
+16 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@

#include "idmap2/ResourceContainer.h"
#include "idmap2/Result.h"
#include <binder/ParcelFileDescriptor.h>

namespace android::idmap2 {

@@ -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:
@@ -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;
    };

@@ -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_;
  };

@@ -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_;

+2 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@

#include <optional>
#include <string>
#include <android-base/unique_fd.h>

#include "androidfw/AssetManager2.h"
#include "idmap2/Result.h"
@@ -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