Loading cmds/idmap2/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -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: { Loading cmds/idmap2/idmap2/Verify.cpp→cmds/idmap2/idmap2/CommandUtils.cpp +6 −16 Original line number Diff line number Diff line Loading @@ -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(); Loading @@ -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"); } Loading cmds/idmap2/idmap2/CommandUtils.h 0 → 100644 +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_ cmds/idmap2/idmap2/Commands.h +0 −1 Original line number Diff line number Diff line Loading @@ -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_ cmds/idmap2/idmap2/CreateMultiple.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -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" Loading Loading @@ -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 Loading
cmds/idmap2/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -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: { Loading
cmds/idmap2/idmap2/Verify.cpp→cmds/idmap2/idmap2/CommandUtils.cpp +6 −16 Original line number Diff line number Diff line Loading @@ -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(); Loading @@ -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"); } Loading
cmds/idmap2/idmap2/CommandUtils.h 0 → 100644 +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_
cmds/idmap2/idmap2/Commands.h +0 −1 Original line number Diff line number Diff line Loading @@ -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_
cmds/idmap2/idmap2/CreateMultiple.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -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" Loading Loading @@ -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