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

Commit 6c2c137f authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Merge "Add policies and enforce overlayable to header" into rvc-dev am:...

Merge "Merge "Add policies and enforce overlayable to header" into rvc-dev am: 2201f8b6 am: 64d0e6f3 am: e2426c48" into rvc-qpr-dev-plus-aosp am: 1da88a7c

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11481145

Change-Id: I1af37d280e52ea663678d4bf62f2818bfa4f13dc
parents f3824851 1da88a7c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -168,13 +168,13 @@ cc_binary {
    ],
    host_supported: true,
    srcs: [
        "idmap2/CommandUtils.cpp",
        "idmap2/Create.cpp",
        "idmap2/CreateMultiple.cpp",
        "idmap2/Dump.cpp",
        "idmap2/Lookup.cpp",
        "idmap2/Main.cpp",
        "idmap2/Scan.cpp",
        "idmap2/Verify.cpp",
    ],
    target: {
        android: {
+6 −16
Original line number Diff line number Diff line
@@ -19,30 +19,19 @@
#include <string>
#include <vector>

#include "idmap2/CommandLineOptions.h"
#include "idmap2/Idmap.h"
#include "idmap2/Result.h"
#include "idmap2/SysTrace.h"

using android::idmap2::CommandLineOptions;
using android::idmap2::Error;
using android::idmap2::IdmapHeader;
using android::idmap2::Result;
using android::idmap2::Unit;

Result<Unit> Verify(const std::vector<std::string>& args) {
  SYSTRACE << "Verify " << args;
  std::string idmap_path;

  const CommandLineOptions opts =
      CommandLineOptions("idmap2 verify")
          .MandatoryOption("--idmap-path", "input: path to idmap file to verify", &idmap_path);

  const auto opts_ok = opts.Parse(args);
  if (!opts_ok) {
    return opts_ok.GetError();
  }

Result<Unit> Verify(const std::string& idmap_path, const std::string& target_path,
                    const std::string& overlay_path, uint32_t fulfilled_policies,
                    bool enforce_overlayable) {
  SYSTRACE << "Verify " << idmap_path;
  std::ifstream fin(idmap_path);
  const std::unique_ptr<const IdmapHeader> header = IdmapHeader::FromBinaryStream(fin);
  fin.close();
@@ -50,7 +39,8 @@ Result<Unit> Verify(const std::vector<std::string>& args) {
    return Error("failed to parse idmap header");
  }

  const auto header_ok = header->IsUpToDate();
  const auto header_ok = header->IsUpToDate(target_path.c_str(), overlay_path.c_str(),
                                            fulfilled_policies, enforce_overlayable);
  if (!header_ok) {
    return Error(header_ok.GetError(), "idmap not up to date");
  }
+28 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef IDMAP2_IDMAP2_COMMAND_UTILS_H_
#define IDMAP2_IDMAP2_COMMAND_UTILS_H_

#include "idmap2/Result.h"

android::idmap2::Result<android::idmap2::Unit> Verify(const std::string& idmap_path,
                                                      const std::string& target_path,
                                                      const std::string& overlay_path,
                                                      uint32_t fulfilled_policies,
                                                      bool enforce_overlayable);

#endif  // IDMAP2_IDMAP2_COMMAND_UTILS_H_
+0 −1
Original line number Diff line number Diff line
@@ -27,6 +27,5 @@ android::idmap2::Result<android::idmap2::Unit> CreateMultiple(const std::vector<
android::idmap2::Result<android::idmap2::Unit> Dump(const std::vector<std::string>& args);
android::idmap2::Result<android::idmap2::Unit> Lookup(const std::vector<std::string>& args);
android::idmap2::Result<android::idmap2::Unit> Scan(const std::vector<std::string>& args);
android::idmap2::Result<android::idmap2::Unit> Verify(const std::vector<std::string>& args);

#endif  // IDMAP2_IDMAP2_COMMANDS_H_
+3 −1
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#include "android-base/stringprintf.h"
#include "idmap2/BinaryStreamVisitor.h"
#include "idmap2/CommandLineOptions.h"
#include "idmap2/CommandUtils.h"
#include "idmap2/FileUtils.h"
#include "idmap2/Idmap.h"
#include "idmap2/Policies.h"
@@ -103,7 +104,8 @@ Result<Unit> CreateMultiple(const std::vector<std::string>& args) {
      continue;
    }

    if (!Verify(std::vector<std::string>({"--idmap-path", idmap_path}))) {
    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) {
        LOG(WARNING) << "failed to load apk " << overlay_apk_path.c_str();
Loading