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

Commit b785da02 authored by Yurii Zubrytskyi's avatar Yurii Zubrytskyi Committed by Android (Google) Code Review
Browse files

Merge "idmap2 code cleanup"

parents 744056a2 a29f3c02
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -18,8 +18,8 @@
#include <sys/types.h>  // umask

#include <fstream>
#include <iostream>
#include <memory>
#include <ostream>
#include <string>
#include <vector>

@@ -51,7 +51,7 @@ using android::idmap2::utils::UidHasWriteAccessToPath;
Result<Unit> CreateMultiple(const std::vector<std::string>& args) {
  SYSTRACE << "CreateMultiple " << args;
  std::string target_apk_path;
  std::string idmap_dir = kIdmapCacheDir;
  std::string idmap_dir{kIdmapCacheDir};
  std::vector<std::string> overlay_apk_paths;
  std::vector<std::string> policies;
  bool ignore_overlayable = false;
@@ -67,7 +67,7 @@ Result<Unit> CreateMultiple(const std::vector<std::string>& args) {
          .OptionalOption("--idmap-dir",
                          StringPrintf("output: path to the directory in which to write idmap file"
                                       " (defaults to %s)",
                                       kIdmapCacheDir),
                                       kIdmapCacheDir.data()),
                          &idmap_dir)
          .OptionalOption("--policy",
                          "input: an overlayable policy this overlay fulfills"
@@ -142,7 +142,7 @@ Result<Unit> CreateMultiple(const std::vector<std::string>& args) {
  }

  for (const std::string& idmap_path : idmap_paths) {
    std::cout << idmap_path << std::endl;
    std::cout << idmap_path << '\n';
  }

  return Unit{};
+2 −2
Original line number Diff line number Diff line
@@ -16,9 +16,9 @@

#include <algorithm>
#include <fstream>
#include <iostream>
#include <iterator>
#include <memory>
#include <ostream>
#include <string>
#include <utility>
#include <vector>
@@ -230,7 +230,7 @@ Result<Unit> Lookup(const std::vector<std::string>& args) {
    if (!value) {
      return Error(value.GetError(), "resource 0x%08x not found", *resid);
    }
    std::cout << *value << std::endl;
    std::cout << *value << '\n';
  }

  return Unit{};
+4 −4
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ void PrintUsage(const NameToFunctionMap& commands, std::ostream& out) {
    }
    out << iter->first;
  }
  out << "]" << std::endl;
  out << "]" << '\n';
}

}  // namespace
@@ -65,18 +65,18 @@ int main(int argc, char** argv) {
  const std::unique_ptr<std::vector<std::string>> args =
      CommandLineOptions::ConvertArgvToVector(argc - 1, const_cast<const char**>(argv + 1));
  if (!args) {
    std::cerr << "error: failed to parse command line options" << std::endl;
    std::cerr << "error: failed to parse command line options" << '\n';
    return EXIT_FAILURE;
  }
  const auto iter = commands.find(argv[1]);
  if (iter == commands.end()) {
    std::cerr << argv[1] << ": command not found" << std::endl;
    std::cerr << argv[1] << ": command not found" << '\n';
    PrintUsage(commands, std::cerr);
    return EXIT_FAILURE;
  }
  const auto result = iter->second(*args);
  if (!result) {
    std::cerr << "error: " << result.GetErrorMessage() << std::endl;
    std::cerr << "error: " << result.GetErrorMessage() << '\n';
    return EXIT_FAILURE;
  }
  return EXIT_SUCCESS;
+1 −1
Original line number Diff line number Diff line
@@ -257,7 +257,7 @@ Status Idmap2Service::createFabricatedOverlay(
    const std::string random_suffix = RandomStringForPath(kSuffixLength);
    file_name = StringPrintf("%s-%s-%s.frro", overlay.packageName.c_str(),
                             overlay.overlayName.c_str(), random_suffix.c_str());
    path = StringPrintf("%s/%s", kIdmapCacheDir, file_name.c_str());
    path = StringPrintf("%s/%s", kIdmapCacheDir.data(), file_name.c_str());

    // Invoking std::filesystem::exists with a file name greater than 255 characters will cause this
    // process to abort since the name exceeds the maximum file name size.
+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@
#define IDMAP2_INCLUDE_IDMAP2_BINARYSTREAMVISITOR_H_

#include <cstdint>
#include <iostream>
#include <ostream>
#include <string>

#include "idmap2/Idmap.h"
Loading