From e0f0b5b4841520c4886e09a77975e51dad17d3a5 Mon Sep 17 00:00:00 2001 From: YZBruh Date: Wed, 27 Aug 2025 15:50:40 +0300 Subject: [PATCH] pmt: Improvements for developers - Android.bp was written to be included in ROMs/recoveries etc. in Android build system. - Macros have been added to simplify feature creation. - Some bug fixes (for JSON and pmt). --- Android.bp | 110 +++++++++++++++++++ include/nlohmann/json.hpp | 5 - src/FunctionManager.cpp | 2 +- src/PartitionManager.cpp | 2 + src/functions/BackupFunction.cpp | 10 +- src/functions/EraseFunction.cpp | 10 +- src/functions/FlashFunction.cpp | 10 +- src/functions/InfoFunction.cpp | 9 +- src/functions/MemoryTestFunction.cpp | 9 +- src/functions/PartitionSizeFunction.cpp | 8 +- src/functions/RealPathFunction.cpp | 8 +- src/functions/RebootFunction.cpp | 8 +- src/functions/TypeFunction.cpp | 8 +- src/functions/functions.hpp | 86 ++++----------- srclib/libhelper/include/libhelper/lib.hpp | 9 ++ srclib/libhelper/src/Classes.cpp | 8 ++ srclib/libhelper/src/Utilities.cpp | 5 + srclib/libpartition_map/src/PartitionMap.cpp | 2 + 18 files changed, 200 insertions(+), 109 deletions(-) create mode 100644 Android.bp diff --git a/Android.bp b/Android.bp new file mode 100644 index 0000000..8e262c3 --- /dev/null +++ b/Android.bp @@ -0,0 +1,110 @@ +// +// Copyright 2025 Yağız Zengin +// +// 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. +// + +// Partition manager tool source list +filegroup { + name: "pmt_srcs", + srcs: [ + "src/FunctionManager.cpp", + "src/Main.cpp", + "src/PartitionManager.cpp", + "src/functions/BackupFunction.cpp", + "src/functions/EraseFunction.cpp", + "src/functions/FlashFunction.cpp", + "src/functions/InfoFunction.cpp", + "src/functions/MemoryTestFunction.cpp", + "src/functions/PartitionSizeFunction.cpp", + "src/functions/RealPathFunction.cpp", + "src/functions/RebootFunction.cpp", + "src/functions/TypeFunction.cpp", + ], +} + +// libhelper source list +filegroup { + name: "libhelper_srcs", + srcs: [ + "srclib/libhelper/src/Checkers.cpp", + "srclib/libhelper/src/Classes.cpp", + "srclib/libhelper/src/FileUtil.cpp", + "srclib/libhelper/src/Sha256.cpp", + "srclib/libhelper/src/Utilities.cpp", + ], +} + +// libpartition_map source list +filegroup { + name: "libpartition_map_srcs", + srcs: [ + "srclib/libpartition_map/src/Getters.cpp", + "srclib/libpartition_map/src/Magic.cpp", + "srclib/libpartition_map/src/PartitionMap.cpp", + "srclib/libpartition_map/src/Type.cpp", + ], +} + +// Default configurations of pmt +cc_defaults { + name: "pmt_defaults", + recovery_available: true, + cflags: [ + "-Wall", + "-Werror", + "-Wno-deprecated-declarations", + "-Os", + "-fexceptions", + "-DANDROID_BUILD", + ], + ldflags: ["-Wl,-s"], + local_include_dirs: [ + "include", + "srclib/libhelper/include", + "srclib/libpartition_map/include", + ], + export_include_dirs: [ + "include", + "srclib/libhelper/include", + "srclib/libpartition_map/include", + ], + shared_libs: ["libbase"], +} + +// Build libhelper library +cc_library_shared { + name: "libhelper", + defaults: ["pmt_defaults"], + srcs: [":libhelper_srcs"], +} + +// Build libpartition_map library +cc_library_shared { + name: "libpartition_map", + defaults: ["pmt_defaults"], + srcs: [":libpartition_map_srcs"], + shared_libs: ["libhelper"], + static_libs: ["libc++fs"], +} + +// Build pmt +cc_binary { + name: "pmt", + defaults: ["pmt_defaults"], + srcs: [":pmt_srcs"], + shared_libs: [ + "libhelper", + "libpartition_map", + ], +} diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 82d69f7..b62ead7 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -6090,12 +6090,7 @@ inline void to_json(BasicJsonType& j, const T& t) template inline void to_json(BasicJsonType& j, const std_fs::path& p) { -#ifdef JSON_HAS_CPP_20 - const std::u8string s = p.u8string(); - j = std::string(s.begin(), s.end()); -#else j = p.u8string(); // returns std::string in C++17 -#endif } #endif diff --git a/src/FunctionManager.cpp b/src/FunctionManager.cpp index 6c5dd44..090fe80 100644 --- a/src/FunctionManager.cpp +++ b/src/FunctionManager.cpp @@ -71,7 +71,7 @@ void basic_function_manager::registerFunction( std::unique_ptr _func, CLI::App &_app) { LOGN(PMTF, INFO) << "registering function: " << _func->name() << std::endl; for (const auto &f : _functions) { - if (strcmp(f->name(), _func->name()) != 0) { + if (std::string(_func->name()) == std::string(f->name())) { LOGN(PMTF, INFO) << "Function is already registered: " << _func->name() << ". Skipping." << std::endl; return; diff --git a/src/PartitionManager.cpp b/src/PartitionManager.cpp index bf085da..acc3b07 100644 --- a/src/PartitionManager.cpp +++ b/src/PartitionManager.cpp @@ -20,7 +20,9 @@ #include #include #include +#ifndef ANDROID_BUILD #include +#endif #include #include diff --git a/src/functions/BackupFunction.cpp b/src/functions/BackupFunction.cpp index f34773c..7acfea8 100644 --- a/src/functions/BackupFunction.cpp +++ b/src/functions/BackupFunction.cpp @@ -27,7 +27,7 @@ #define BFUN "backupFunction" namespace PartitionManager { -pair backupFunction::runAsync(const std::string &partitionName, +RUN_ASYNC(backupFunction)(const std::string &partitionName, const std::string &outputName, const uint64_t bufferSize) { if (!Variables->PartMap->hasPartition(partitionName)) @@ -105,7 +105,7 @@ pair backupFunction::runAsync(const std::string &partitionName, true}; } -bool backupFunction::init(CLI::App &_app) { +INIT(backupFunction) { LOGN(BFUN, INFO) << "Initializing variables of backup function." << std::endl; cmd = _app.add_subcommand("backup", "Backup partition(s) to file(s)"); cmd->add_option("partition(s)", rawPartitions, "Partition name(s)") @@ -123,7 +123,7 @@ bool backupFunction::init(CLI::App &_app) { return true; } -bool backupFunction::run() { +RUN(backupFunction) { processCommandLine(partitions, outputNames, rawPartitions, rawOutputNames, ',', true); if (!outputNames.empty() && partitions.size() != outputNames.size()) @@ -161,7 +161,7 @@ bool backupFunction::run() { return endResult; } -bool backupFunction::isUsed() const { return cmd->parsed(); } +IS_USED_COMMON_BODY(backupFunction) -const char *backupFunction::name() const { return BFUN; } +NAME(backupFunction) { return BFUN; } } // namespace PartitionManager diff --git a/src/functions/EraseFunction.cpp b/src/functions/EraseFunction.cpp index aae7d28..f6151b3 100644 --- a/src/functions/EraseFunction.cpp +++ b/src/functions/EraseFunction.cpp @@ -25,7 +25,7 @@ Copyright 2025 Yağız Zengin #define EFUN "eraseFunction" namespace PartitionManager { -pair eraseFunction::runAsync(const std::string &partitionName, +RUN_ASYNC(eraseFunction)(const std::string &partitionName, const uint64_t bufferSize) { if (!Variables->PartMap->hasPartition(partitionName)) return {format("Couldn't find partition: %s", partitionName.data()), false}; @@ -87,7 +87,7 @@ pair eraseFunction::runAsync(const std::string &partitionName, true}; } -bool eraseFunction::init(CLI::App &_app) { +INIT(eraseFunction) { LOGN(EFUN, INFO) << "Initializing variables of erase function." << std::endl; cmd = _app.add_subcommand("erase", "Writes zero bytes to partition(s)"); cmd->add_option("partition(s)", partitions, "Partition name(s)") @@ -100,7 +100,7 @@ bool eraseFunction::init(CLI::App &_app) { return true; } -bool eraseFunction::run() { +RUN(eraseFunction) { std::vector> futures; for (const auto &partitionName : partitions) { uint64_t buf = bufferSize; @@ -127,7 +127,7 @@ bool eraseFunction::run() { return endResult; } -bool eraseFunction::isUsed() const { return cmd->parsed(); } +IS_USED_COMMON_BODY(eraseFunction) -const char *eraseFunction::name() const { return EFUN; } +NAME(eraseFunction) { return EFUN; } } // namespace PartitionManager diff --git a/src/functions/FlashFunction.cpp b/src/functions/FlashFunction.cpp index e450be3..5e8afc6 100644 --- a/src/functions/FlashFunction.cpp +++ b/src/functions/FlashFunction.cpp @@ -25,7 +25,7 @@ Copyright 2025 Yağız Zengin #define FFUN "flashFunction" namespace PartitionManager { -pair flashFunction::runAsync(const std::string &partitionName, +RUN_ASYNC(flashFunction)(const std::string &partitionName, const std::string &imageName, const uint64_t bufferSize) { if (!Helper::fileIsExists(imageName)) @@ -92,7 +92,7 @@ pair flashFunction::runAsync(const std::string &partitionName, true}; } -bool flashFunction::init(CLI::App &_app) { +INIT(flashFunction) { LOGN(FFUN, INFO) << "Initializing variables of flash function." << std::endl; cmd = _app.add_subcommand("flash", "Flash image(s) to partition(s)"); cmd->add_option("partition(s)", rawPartitions, "Partition name(s)") @@ -110,7 +110,7 @@ bool flashFunction::init(CLI::App &_app) { return true; } -bool flashFunction::run() { +RUN(flashFunction) { processCommandLine(partitions, imageNames, rawPartitions, rawImageNames, ',', true); if (partitions.size() != imageNames.size()) @@ -148,7 +148,7 @@ bool flashFunction::run() { return endResult; } -bool flashFunction::isUsed() const { return cmd->parsed(); } +IS_USED_COMMON_BODY(flashFunction) -const char *flashFunction::name() const { return FFUN; } +NAME(flashFunction) { return FFUN; } } // namespace PartitionManager diff --git a/src/functions/InfoFunction.cpp b/src/functions/InfoFunction.cpp index c4e456a..f90dbcc 100644 --- a/src/functions/InfoFunction.cpp +++ b/src/functions/InfoFunction.cpp @@ -24,7 +24,8 @@ Copyright 2025 Yağız Zengin #define IFUN "infoFunction" namespace PartitionManager { -bool infoFunction::init(CLI::App &_app) { + +INIT(infoFunction) { LOGN(IFUN, INFO) << "Initializing variables of info printer function." << std::endl; cmd = _app.add_subcommand("info", "Tell info(s) of input partition list") @@ -53,7 +54,7 @@ bool infoFunction::init(CLI::App &_app) { return true; } -bool infoFunction::run() { +RUN(infoFunction) { if (partitions.back() == "get-all" || partitions.back() == "getvar-all") { partitions.clear(); const auto parts = Variables->PartMap->getPartitionList(); @@ -111,7 +112,7 @@ bool infoFunction::run() { return true; } -bool infoFunction::isUsed() const { return cmd->parsed(); } +IS_USED_COMMON_BODY(infoFunction) -const char *infoFunction::name() const { return IFUN; }; +NAME(infoFunction) { return IFUN; }; } // namespace PartitionManager diff --git a/src/functions/MemoryTestFunction.cpp b/src/functions/MemoryTestFunction.cpp index b4cefc8..770dd4d 100644 --- a/src/functions/MemoryTestFunction.cpp +++ b/src/functions/MemoryTestFunction.cpp @@ -27,7 +27,7 @@ Copyright 2025 Yağız Zengin namespace PartitionManager { -bool memoryTestFunction::init(CLI::App &_app) { +INIT(memoryTestFunction) { LOGN(MTFUN, INFO) << "Initializing variables of memory test function." << std::endl; cmd = _app.add_subcommand("memtest", "Test your write/read speed of device."); @@ -56,7 +56,7 @@ bool memoryTestFunction::init(CLI::App &_app) { return true; } -bool memoryTestFunction::run() { +RUN(memoryTestFunction) { LOGN(MTFUN, INFO) << "Starting memory test on " << testPath << std::endl; Helper::garbageCollector collector; const std::string test = Helper::pathJoin(testPath, "test.bin"); @@ -122,8 +122,7 @@ bool memoryTestFunction::run() { return true; } -bool memoryTestFunction::isUsed() const { return cmd->parsed(); } - -const char *memoryTestFunction::name() const { return MTFUN; } +IS_USED_COMMON_BODY(memoryTestFunction) +NAME(memoryTestFunction) { return MTFUN; } } // namespace PartitionManager diff --git a/src/functions/PartitionSizeFunction.cpp b/src/functions/PartitionSizeFunction.cpp index f837b8a..bd5f94e 100644 --- a/src/functions/PartitionSizeFunction.cpp +++ b/src/functions/PartitionSizeFunction.cpp @@ -27,7 +27,7 @@ std::string convertTo(const uint64_t size, const std::string &multiple) { } namespace PartitionManager { -bool partitionSizeFunction::init(CLI::App &_app) { +INIT(partitionSizeFunction) { LOGN(SFUN, INFO) << "Initializing variables of partition size getter function." << std::endl; @@ -54,7 +54,7 @@ bool partitionSizeFunction::init(CLI::App &_app) { return true; } -bool partitionSizeFunction::run() { +RUN(partitionSizeFunction) { for (const auto &partition : partitions) { if (!Variables->PartMap->hasPartition(partition)) throw Error("Couldn't find partition: %s", partition.data()); @@ -89,7 +89,7 @@ bool partitionSizeFunction::run() { return true; } -bool partitionSizeFunction::isUsed() const { return cmd->parsed(); } +IS_USED_COMMON_BODY(partitionSizeFunction) -const char *partitionSizeFunction::name() const { return SFUN; } +NAME(partitionSizeFunction) { return SFUN; } } // namespace PartitionManager diff --git a/src/functions/RealPathFunction.cpp b/src/functions/RealPathFunction.cpp index d861aa5..d715fa7 100644 --- a/src/functions/RealPathFunction.cpp +++ b/src/functions/RealPathFunction.cpp @@ -20,7 +20,7 @@ #define RPFUN "realPathFunction" namespace PartitionManager { -bool realPathFunction::init(CLI::App &_app) { +INIT(realPathFunction) { LOGN(RPFUN, INFO) << "Initializing variables of real path function." << std::endl; cmd = _app.add_subcommand("real-path", "Tell real paths of partition(s)"); @@ -32,7 +32,7 @@ bool realPathFunction::init(CLI::App &_app) { return true; } -bool realPathFunction::run() { +RUN(realPathFunction) { for (const auto &partition : partitions) { if (!Variables->PartMap->hasPartition(partition)) throw Error("Couldn't find partition: %s", partition.data()); @@ -56,7 +56,7 @@ bool realPathFunction::run() { return true; } -bool realPathFunction::isUsed() const { return cmd->parsed(); } +IS_USED_COMMON_BODY(realPathFunction) -const char *realPathFunction::name() const { return RPFUN; } +NAME(realPathFunction) { return RPFUN; } } // namespace PartitionManager diff --git a/src/functions/RebootFunction.cpp b/src/functions/RebootFunction.cpp index 5fd279b..44b8eca 100644 --- a/src/functions/RebootFunction.cpp +++ b/src/functions/RebootFunction.cpp @@ -20,7 +20,7 @@ Copyright 2025 Yağız Zengin #define RFUN "rebootFunction" namespace PartitionManager { -bool rebootFunction::init(CLI::App &_app) { +INIT(rebootFunction) { LOGN(RFUN, INFO) << "Initializing variables of reboot function." << std::endl; cmd = _app.add_subcommand("reboot", "Reboots device"); cmd->add_option("rebootTarget", rebootTarget, @@ -28,7 +28,7 @@ bool rebootFunction::init(CLI::App &_app) { return true; } -bool rebootFunction::run() { +RUN(rebootFunction) { LOGN(RFUN, INFO) << "Rebooting device!!! (custom reboot target: " << (rebootTarget.empty() ? "none" : rebootTarget) << std::endl; @@ -39,7 +39,7 @@ bool rebootFunction::run() { return true; } -bool rebootFunction::isUsed() const { return cmd->parsed(); } +IS_USED_COMMON_BODY(rebootFunction) -const char *rebootFunction::name() const { return RFUN; } +NAME(rebootFunction) { return RFUN; } } // namespace PartitionManager diff --git a/src/functions/TypeFunction.cpp b/src/functions/TypeFunction.cpp index dd620fb..a9460f6 100644 --- a/src/functions/TypeFunction.cpp +++ b/src/functions/TypeFunction.cpp @@ -20,7 +20,7 @@ #define TFUN "typeFunction" namespace PartitionManager { -bool typeFunction::init(CLI::App &_app) { +INIT(typeFunction) { LOGN(TFUN, INFO) << "Initializing variables of type function." << std::endl; cmd = _app.add_subcommand("type", "Get type of the partition(s) or image(s)"); cmd->add_option("content(s)", contents, "Content(s)") @@ -39,7 +39,7 @@ bool typeFunction::init(CLI::App &_app) { return true; } -bool typeFunction::run() { +RUN(typeFunction) { std::unordered_map magics; if (onlyCheckAndroidMagics) magics.merge(PartitionMap::Extras::AndroidMagicMap); @@ -75,8 +75,8 @@ bool typeFunction::run() { return true; } -bool typeFunction::isUsed() const { return cmd->parsed(); } +IS_USED_COMMON_BODY(typeFunction) -const char *typeFunction::name() const { return TFUN; } +NAME(typeFunction) { return TFUN; } } // namespace PartitionManager diff --git a/src/functions/functions.hpp b/src/functions/functions.hpp index 990be99..49f6e6e 100644 --- a/src/functions/functions.hpp +++ b/src/functions/functions.hpp @@ -21,6 +21,20 @@ #include #include +#define INIT(cls) bool cls::init(CLI::App &_app) +#define RUN(cls) bool cls::run() +#define RUN_ASYNC(cls) pair cls::runAsync +#define IS_USED(cls) bool cls::isUsed() const +#define IS_USED_COMMON_BODY(cls) bool cls::isUsed() const { return cmd->parsed(); } +#define NAME(cls) const char *cls::name() const + +#define COMMON_FUNCTION_BODY() \ + CLI::App *cmd = nullptr; \ + bool init(CLI::App &_app) override; \ + bool run() override; \ + [[nodiscard]] bool isUsed() const override; \ + [[nodiscard]] const char *name() const override + namespace PartitionManager { using pair = std::pair; @@ -32,15 +46,9 @@ private: uint64_t bufferSize = 0; public: - CLI::App *cmd = nullptr; - - bool init(CLI::App &_app) override; - bool run() override; + COMMON_FUNCTION_BODY(); static pair runAsync(const std::string &partitionName, const std::string &outputName, uint64_t bufferSize); - - [[nodiscard]] bool isUsed() const override; - [[nodiscard]] const char *name() const override; }; // Image flasher function @@ -51,15 +59,9 @@ private: uint64_t bufferSize = 0; public: - CLI::App *cmd = nullptr; - - bool init(CLI::App &_app) override; - bool run() override; + COMMON_FUNCTION_BODY(); static pair runAsync(const std::string &partitionName, const std::string &imageName, uint64_t bufferSize); - - [[nodiscard]] bool isUsed() const override; - [[nodiscard]] const char *name() const override; }; // Eraser function (writes zero bytes to partition) @@ -69,14 +71,8 @@ private: uint64_t bufferSize = 0; public: - CLI::App *cmd = nullptr; - - bool init(CLI::App &_app) override; - bool run() override; + COMMON_FUNCTION_BODY(); static pair runAsync(const std::string &partitionName, uint64_t bufferSize); - - [[nodiscard]] bool isUsed() const override; - [[nodiscard]] const char *name() const override; }; // Partition size getter function @@ -87,13 +83,7 @@ private: asGiga = false; public: - CLI::App *cmd = nullptr; - - bool init(CLI::App &_app) override; - bool run() override; - - [[nodiscard]] bool isUsed() const override; - [[nodiscard]] const char *name() const override; + COMMON_FUNCTION_BODY(); }; // Partition info getter function @@ -105,13 +95,7 @@ private: bool jsonFormat = false; public: - CLI::App *cmd = nullptr; - - bool init(CLI::App &_app) override; - bool run() override; - - [[nodiscard]] bool isUsed() const override; - [[nodiscard]] const char *name() const override; + COMMON_FUNCTION_BODY(); }; class realPathFunction final : public FunctionBase { @@ -120,13 +104,7 @@ private: bool realLinkPath = false; public: - CLI::App *cmd = nullptr; - - bool init(CLI::App &_app) override; - bool run() override; - - [[nodiscard]] bool isUsed() const override; - [[nodiscard]] const char *name() const override; + COMMON_FUNCTION_BODY(); }; class typeFunction final : public FunctionBase { @@ -136,13 +114,7 @@ private: uint64_t bufferSize = 0; public: - CLI::App *cmd = nullptr; - - bool init(CLI::App &_app) override; - bool run() override; - - [[nodiscard]] bool isUsed() const override; - [[nodiscard]] const char *name() const override; + COMMON_FUNCTION_BODY(); }; class rebootFunction final : public FunctionBase { @@ -150,13 +122,7 @@ private: std::string rebootTarget; public: - CLI::App *cmd = nullptr; - - bool init(CLI::App &_app) override; - bool run() override; - - [[nodiscard]] bool isUsed() const override; - [[nodiscard]] const char *name() const override; + COMMON_FUNCTION_BODY(); }; class memoryTestFunction final : public FunctionBase { @@ -166,13 +132,7 @@ private: bool doNotReadTest = false; public: - CLI::App *cmd = nullptr; - - bool init(CLI::App &_app) override; - bool run() override; - - [[nodiscard]] bool isUsed() const override; - [[nodiscard]] const char *name() const override; + COMMON_FUNCTION_BODY(); }; } // namespace PartitionManager diff --git a/srclib/libhelper/include/libhelper/lib.hpp b/srclib/libhelper/include/libhelper/lib.hpp index 405b37e..859d75d 100644 --- a/srclib/libhelper/include/libhelper/lib.hpp +++ b/srclib/libhelper/include/libhelper/lib.hpp @@ -243,6 +243,14 @@ std::string getLibVersion(); #define LOGNF_IF(name, file, level, condition) \ if (condition) Helper::Logger(level, __func__, file, name, __FILE__, __LINE__) +#ifdef ANDROID_BUILD +#define MKVERSION(name) \ + char vinfo[512]; \ + sprintf(vinfo, \ + "%s 1.2.0 [XXXX-XX-XX XX.XX.XX]\nBuildType: Release\nCompiler: clang\n" \ + "BuildFlags: -Wall;-Werror;-Wno-deprecated-declarations;-Os", name); \ + return std::string(vinfo) +#else #define MKVERSION(name) \ char vinfo[512]; \ sprintf(vinfo, \ @@ -251,5 +259,6 @@ std::string getLibVersion(); name, BUILD_VERSION, BUILD_DATE, BUILD_TIME, BUILD_TYPE, \ BUILD_CMAKE_VERSION, BUILD_COMPILER_VERSION, BUILD_FLAGS); \ return std::string(vinfo) +#endif #endif // #ifndef LIBHELPER_LIB_HPP diff --git a/srclib/libhelper/src/Classes.cpp b/srclib/libhelper/src/Classes.cpp index 56b5de1..ab04e5b 100644 --- a/srclib/libhelper/src/Classes.cpp +++ b/srclib/libhelper/src/Classes.cpp @@ -58,10 +58,18 @@ Logger::~Logger() { fd != -1) close(fd); else { +#ifdef ANDROID_BUILD + LoggingProperties::setLogFile("/tmp/last_pmt_logs.log") +#else LoggingProperties::setLogFile("last_logs.log"); +#endif LOGN(HELPER, INFO) << "Cannot create log file: " << _logFile << ": " << strerror(errno) +#ifdef ANDROID_BUILD + << " New logging file: /tmp/last_pmt_logs.log (this file)." +#else << " New logging file: last_logs.log (this file)." +#endif << std::endl; } } diff --git a/srclib/libhelper/src/Utilities.cpp b/srclib/libhelper/src/Utilities.cpp index 959b4ce..3a83765 100644 --- a/srclib/libhelper/src/Utilities.cpp +++ b/srclib/libhelper/src/Utilities.cpp @@ -19,7 +19,12 @@ #include #include #include +#ifndef ANDROID_BUILD #include +#include +#else +#include +#endif #include #include #include diff --git a/srclib/libpartition_map/src/PartitionMap.cpp b/srclib/libpartition_map/src/PartitionMap.cpp index 309296f..7905249 100644 --- a/srclib/libpartition_map/src/PartitionMap.cpp +++ b/srclib/libpartition_map/src/PartitionMap.cpp @@ -20,7 +20,9 @@ #include #include #include +#ifndef ANDROID_BUILD #include +#endif #include #include #include