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

Commit 1c319ea0 authored by Ryan Mitchell's avatar Ryan Mitchell Committed by Android (Google) Code Review
Browse files

Merge changes I0539656f,I4c9f29da,Iac679828 into sc-dev

* changes:
  OverlayManager Fabricated RROs
  Add fabricated RRO generation to libidmap2
  Query overlays using package and name
parents 0177fad8 6a2ca782
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -369,6 +369,7 @@ filegroup {
        ":framework_native_aidl",
        ":gatekeeper_aidl",
        ":gsiservice_aidl",
        ":idmap2_core_aidl",
        ":incidentcompanion_aidl",
        ":inputconstants_aidl",
        ":installd_aidl",
+69 −21
Original line number Diff line number Diff line
@@ -51,13 +51,18 @@ cc_library {
            static: {
                enabled: false,
            },
            static_libs: [
                "libidmap2_protos",
            ],
            shared_libs: [
                "libandroidfw",
                "libbase",
                "libcutils",
                "libidmap2_policies",
                "libprotobuf-cpp-lite",
                "libutils",
                "libz",
                "libziparchive",
                "libidmap2_policies",
            ],
        },
        host: {
@@ -68,14 +73,29 @@ cc_library {
                "libandroidfw",
                "libbase",
                "libcutils",
                "libidmap2_policies",
                "libidmap2_protos",
                "libprotobuf-cpp-lite",
                "libutils",
                "libz",
                "libziparchive",
                "libidmap2_policies",
            ],
        },
    },
}

cc_library {
    name: "libidmap2_protos",
    srcs: [
        "libidmap2/proto/*.proto",
    ],
    host_supported: true,
    proto: {
        type: "lite",
        export_proto_headers: true,
    },
}

cc_library {
    name: "libidmap2_policies",
    defaults: [
@@ -88,9 +108,6 @@ cc_library {
            enabled: true,
        },
        android: {
            static: {
                enabled: false,
            },
            shared_libs: [
                "libandroidfw",
            ],
@@ -119,6 +136,7 @@ cc_test {
    srcs: [
        "tests/BinaryStreamVisitorTests.cpp",
        "tests/CommandLineOptionsTests.cpp",
        "tests/FabricatedOverlayTests.cpp",
        "tests/FileUtilsTests.cpp",
        "tests/Idmap2BinaryTests.cpp",
        "tests/IdmapTests.cpp",
@@ -130,20 +148,27 @@ cc_test {
        "tests/ResourceUtilsTests.cpp",
        "tests/ResultTests.cpp",
        "tests/XmlParserTests.cpp",
        "tests/ZipFileTests.cpp",
    ],
    static_libs: ["libgmock"],
    required: [
        "idmap2",
    ],
    static_libs: [
        "libgmock",
        "libidmap2_protos",
    ],
    target: {
        android: {
            shared_libs: [
                "libandroidfw",
                "libbase",
                "libidmap2",
                "libidmap2_policies",
                "liblog",
                "libprotobuf-cpp-lite",
                "libutils",
                "libz",
                "libz",
                "libziparchive",
                "libidmap2_policies",
            ],
        },
        host: {
@@ -152,10 +177,11 @@ cc_test {
                "libbase",
                "libcutils",
                "libidmap2",
                "libidmap2_policies",
                "liblog",
                "libprotobuf-cpp-lite",
                "libutils",
                "libziparchive",
                "libidmap2_policies",
            ],
            shared_libs: [
                "libz",
@@ -189,6 +215,9 @@ cc_binary {
        "idmap2/Lookup.cpp",
        "idmap2/Main.cpp",
    ],
    static_libs: [
        "libidmap2_protos",
    ],
    target: {
        android: {
            shared_libs: [
@@ -196,9 +225,11 @@ cc_binary {
                "libbase",
                "libcutils",
                "libidmap2",
                "libidmap2_policies",
                "libprotobuf-cpp-lite",
                "libutils",
                "libz",
                "libziparchive",
                "libidmap2_policies",
            ],
        },
        host: {
@@ -207,10 +238,11 @@ cc_binary {
                "libbase",
                "libcutils",
                "libidmap2",
                "libidmap2_policies",
                "liblog",
                "libprotobuf-cpp-lite",
                "libutils",
                "libziparchive",
                "libidmap2_policies",
            ],
            shared_libs: [
                "libz",
@@ -236,11 +268,14 @@ cc_binary {
        "libbinder",
        "libcutils",
        "libidmap2",
        "libidmap2_policies",
        "libprotobuf-cpp-lite",
        "libutils",
        "libziparchive",
        "libidmap2_policies",
    ],
    static_libs: [
        "libc++fs",
        "libidmap2_protos",
        "libidmap2daidl",
    ],
    init_rc: ["idmap2d/idmap2d.rc"],
@@ -248,28 +283,41 @@ cc_binary {

cc_library_static {
    name: "libidmap2daidl",
    defaults: [
        "idmap2_defaults",
    ],
    tidy: false,
    host_supported: false,
    srcs: [
        ":idmap2_aidl",
        ":idmap2_core_aidl",
    ],
    header_libs: [
        "libbinder_headers",
    ],
    shared_libs: [
        "libbase",
    ],
    aidl: {
        export_aidl_headers: true,
        local_include_dirs: [
            "idmap2d/aidl/core",
            "idmap2d/aidl/services/",
        ],
    },
}

filegroup {
    name: "idmap2_core_aidl",
    srcs: [
        "idmap2d/aidl/core/android/os/FabricatedOverlayInternal.aidl",
        "idmap2d/aidl/core/android/os/FabricatedOverlayInternalEntry.aidl",
        "idmap2d/aidl/core/android/os/FabricatedOverlayInfo.aidl",
    ],
    path: "idmap2d/aidl/core/",
}

filegroup {
    name: "idmap2_aidl",
    srcs: [
        "idmap2d/aidl/android/os/IIdmap2.aidl",
        "idmap2d/aidl/services/android/os/IIdmap2.aidl",
    ],
    path: "idmap2d/aidl",
    path: "idmap2d/aidl/services/",
}

aidl_interface {
@@ -281,7 +329,7 @@ aidl_interface {
filegroup {
    name: "overlayable_policy_aidl_files",
    srcs: [
        "idmap2d/aidl/android/os/OverlayablePolicy.aidl",
        "idmap2d/aidl/services/android/os/OverlayablePolicy.aidl",
    ],
    path: "idmap2d/aidl",
    path: "idmap2d/aidl/services/",
}
+14 −3
Original line number Diff line number Diff line
@@ -25,7 +25,9 @@

using android::idmap2::Error;
using android::idmap2::IdmapHeader;
using android::idmap2::OverlayResourceContainer;
using android::idmap2::Result;
using android::idmap2::TargetResourceContainer;
using android::idmap2::Unit;

Result<Unit> Verify(const std::string& idmap_path, const std::string& target_path,
@@ -39,11 +41,20 @@ Result<Unit> Verify(const std::string& idmap_path, const std::string& target_pat
    return Error("failed to parse idmap header");
  }

  const auto header_ok = header->IsUpToDate(target_path, overlay_path, overlay_name,
                                            fulfilled_policies, enforce_overlayable);
  auto target = TargetResourceContainer::FromPath(target_path);
  if (!target) {
    return Error("failed to load target '%s'", target_path.c_str());
  }

  auto overlay = OverlayResourceContainer::FromPath(overlay_path);
  if (!overlay) {
    return Error("failed to load overlay '%s'", overlay_path.c_str());
  }

  const auto header_ok = header->IsUpToDate(**target, **overlay, overlay_name, fulfilled_policies,
                                            enforce_overlayable);
  if (!header_ok) {
    return Error(header_ok.GetError(), "idmap not up to date");
  }

  return Unit{};
}
+13 −12
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@
#include <fstream>
#include <memory>
#include <ostream>
#include <string>
#include <vector>

#include "androidfw/ResourceTypes.h"
@@ -31,12 +30,13 @@
#include "idmap2/PolicyUtils.h"
#include "idmap2/SysTrace.h"

using android::ApkAssets;
using android::idmap2::BinaryStreamVisitor;
using android::idmap2::CommandLineOptions;
using android::idmap2::Error;
using android::idmap2::Idmap;
using android::idmap2::OverlayResourceContainer;
using android::idmap2::Result;
using android::idmap2::TargetResourceContainer;
using android::idmap2::Unit;
using android::idmap2::utils::kIdmapFilePermissionMask;
using android::idmap2::utils::PoliciesToBitmaskResult;
@@ -93,18 +93,18 @@ Result<Unit> Create(const std::vector<std::string>& args) {
    fulfilled_policies |= PolicyFlags::PUBLIC;
  }

  const std::unique_ptr<const ApkAssets> target_apk = ApkAssets::Load(target_apk_path);
  if (!target_apk) {
    return Error("failed to load apk %s", target_apk_path.c_str());
  const auto target = TargetResourceContainer::FromPath(target_apk_path);
  if (!target) {
    return Error("failed to load target '%s'", target_apk_path.c_str());
  }

  const std::unique_ptr<const ApkAssets> overlay_apk = ApkAssets::Load(overlay_apk_path);
  if (!overlay_apk) {
    return Error("failed to load apk %s", overlay_apk_path.c_str());
  const auto overlay = OverlayResourceContainer::FromPath(overlay_apk_path);
  if (!overlay) {
    return Error("failed to load apk overlay '%s'", overlay_apk_path.c_str());
  }

  const auto idmap = Idmap::FromApkAssets(*target_apk, *overlay_apk, overlay_name,
                                          fulfilled_policies, !ignore_overlayable);
  const auto idmap = Idmap::FromContainers(**target, **overlay, overlay_name, fulfilled_policies,
                                           !ignore_overlayable);
  if (!idmap) {
    return Error(idmap.GetError(), "failed to create idmap");
  }
@@ -112,13 +112,14 @@ Result<Unit> Create(const std::vector<std::string>& args) {
  umask(kIdmapFilePermissionMask);
  std::ofstream fout(idmap_path);
  if (fout.fail()) {
    return Error("failed to open idmap path %s", idmap_path.c_str());
    return Error("failed to open idmap path '%s'", idmap_path.c_str());
  }

  BinaryStreamVisitor visitor(fout);
  (*idmap)->accept(&visitor);
  fout.close();
  if (fout.fail()) {
    return Error("failed to write to idmap path %s", idmap_path.c_str());
    return Error("failed to write to idmap path '%s'", idmap_path.c_str());
  }

  return Unit{};
+9 −8
Original line number Diff line number Diff line
@@ -34,13 +34,14 @@
#include "idmap2/PolicyUtils.h"
#include "idmap2/SysTrace.h"

using android::ApkAssets;
using android::base::StringPrintf;
using android::idmap2::BinaryStreamVisitor;
using android::idmap2::CommandLineOptions;
using android::idmap2::Error;
using android::idmap2::Idmap;
using android::idmap2::OverlayResourceContainer;
using android::idmap2::Result;
using android::idmap2::TargetResourceContainer;
using android::idmap2::Unit;
using android::idmap2::utils::kIdmapCacheDir;
using android::idmap2::utils::kIdmapFilePermissionMask;
@@ -91,9 +92,9 @@ Result<Unit> CreateMultiple(const std::vector<std::string>& args) {
    fulfilled_policies |= PolicyFlags::PUBLIC;
  }

  const std::unique_ptr<const ApkAssets> target_apk = ApkAssets::Load(target_apk_path);
  if (!target_apk) {
    return Error("failed to load apk %s", target_apk_path.c_str());
  const auto target = TargetResourceContainer::FromPath(target_apk_path);
  if (!target) {
    return Error("failed to load target '%s'", target_apk_path.c_str());
  }

  std::vector<std::string> idmap_paths;
@@ -108,14 +109,14 @@ Result<Unit> CreateMultiple(const std::vector<std::string>& args) {
    // TODO(b/175014391): Support multiple overlay tags in OverlayConfig
    if (!Verify(idmap_path, target_apk_path, overlay_apk_path, "", fulfilled_policies,
                !ignore_overlayable)) {
      const std::unique_ptr<const ApkAssets> overlay_apk = ApkAssets::Load(overlay_apk_path);
      if (!overlay_apk) {
      const auto overlay = OverlayResourceContainer::FromPath(overlay_apk_path);
      if (!overlay) {
        LOG(WARNING) << "failed to load apk " << overlay_apk_path.c_str();
        continue;
      }

      const auto idmap = Idmap::FromApkAssets(*target_apk, *overlay_apk, "", fulfilled_policies,
                                              !ignore_overlayable);
      const auto idmap =
          Idmap::FromContainers(**target, **overlay, "", fulfilled_policies, !ignore_overlayable);
      if (!idmap) {
        LOG(WARNING) << "failed to create idmap";
        continue;
Loading