diff --git a/Android.bp b/Android.bp index 0eb5fd9e..0759e08d 100644 --- a/Android.bp +++ b/Android.bp @@ -72,6 +72,7 @@ cc_defaults { "libinstall", "librecovery_fastboot", "libminui", + "librecovery_utils", "libotautil", // external dependencies @@ -148,7 +149,7 @@ cc_binary { ], static_libs: [ - "libotautil", + "librecovery_utils", ], init_rc: [ @@ -174,7 +175,7 @@ cc_binary { ], static_libs: [ - "libotautil", + "librecovery_utils", ], init_rc: [ diff --git a/fsck_unshare_blocks.cpp b/fsck_unshare_blocks.cpp index 9dc0fd8e..e0b2d966 100644 --- a/fsck_unshare_blocks.cpp +++ b/fsck_unshare_blocks.cpp @@ -36,7 +36,7 @@ #include #include -#include "otautil/roots.h" +#include "recovery_utils/roots.h" static constexpr const char* SYSTEM_E2FSCK_BIN = "/system/bin/e2fsck_static"; static constexpr const char* TMP_E2FSCK_BIN = "/tmp/e2fsck.bin"; diff --git a/install/Android.bp b/install/Android.bp index e2402704..d4606e92 100644 --- a/install/Android.bp +++ b/install/Android.bp @@ -37,6 +37,7 @@ cc_defaults { ], static_libs: [ + "librecovery_utils", "libotautil", // external dependencies diff --git a/install/fuse_install.cpp b/install/fuse_install.cpp index 8a7a278e..143b5d3f 100644 --- a/install/fuse_install.cpp +++ b/install/fuse_install.cpp @@ -37,7 +37,7 @@ #include "fuse_provider.h" #include "fuse_sideload.h" #include "install/install.h" -#include "otautil/roots.h" +#include "recovery_utils/roots.h" static constexpr const char* SDCARD_ROOT = "/sdcard"; // How long (in seconds) we wait for the fuse-provided package file to diff --git a/install/install.cpp b/install/install.cpp index 9d67b010..9166f9cf 100644 --- a/install/install.cpp +++ b/install/install.cpp @@ -51,11 +51,11 @@ #include "install/wipe_data.h" #include "otautil/error_code.h" #include "otautil/paths.h" -#include "otautil/roots.h" #include "otautil/sysutil.h" -#include "otautil/thermalutil.h" #include "private/setup_commands.h" #include "recovery_ui/ui.h" +#include "recovery_utils/roots.h" +#include "recovery_utils/thermalutil.h" using namespace std::chrono_literals; diff --git a/install/wipe_data.cpp b/install/wipe_data.cpp index 765a8152..82660bef 100644 --- a/install/wipe_data.cpp +++ b/install/wipe_data.cpp @@ -28,9 +28,9 @@ #include #include "otautil/dirutil.h" -#include "otautil/logging.h" -#include "otautil/roots.h" #include "recovery_ui/ui.h" +#include "recovery_utils/logging.h" +#include "recovery_utils/roots.h" constexpr const char* CACHE_ROOT = "/cache"; constexpr const char* DATA_ROOT = "/data"; @@ -120,4 +120,4 @@ bool WipeData(Device* device, bool convert_fbe) { } ui->Print("Data wipe %s.\n", success ? "complete" : "failed"); return success; -} \ No newline at end of file +} diff --git a/otautil/Android.bp b/otautil/Android.bp index 6f816a17..c8f97468 100644 --- a/otautil/Android.bp +++ b/otautil/Android.bp @@ -39,32 +39,4 @@ cc_library_static { export_include_dirs: [ "include", ], - - target: { - android: { - srcs: [ - "logging.cpp", - "parse_install_logs.cpp", - "roots.cpp", - "thermalutil.cpp", - ], - - include_dirs: [ - "system/vold", - ], - - static_libs: [ - "libfstab", - ], - - shared_libs: [ - "libext4_utils", - "libfs_mgr", - ], - - export_static_lib_headers: [ - "libfstab", - ], - }, - }, } diff --git a/recovery-persist.cpp b/recovery-persist.cpp index 294017a1..6dbf8625 100644 --- a/recovery-persist.cpp +++ b/recovery-persist.cpp @@ -43,8 +43,8 @@ #include #include /* private pmsg functions */ -#include "otautil/logging.h" -#include "otautil/parse_install_logs.h" +#include "recovery_utils/logging.h" +#include "recovery_utils/parse_install_logs.h" constexpr const char* LAST_LOG_FILE = "/data/misc/recovery/last_log"; constexpr const char* LAST_PMSG_FILE = "/sys/fs/pstore/pmsg-ramoops-0"; diff --git a/recovery-refresh.cpp b/recovery-refresh.cpp index d41755d0..42acd05b 100644 --- a/recovery-refresh.cpp +++ b/recovery-refresh.cpp @@ -38,11 +38,12 @@ // #include + #include #include /* private pmsg functions */ -#include "otautil/logging.h" +#include "recovery_utils/logging.h" int main(int argc, char **argv) { static const char filter[] = "recovery/"; diff --git a/recovery.cpp b/recovery.cpp index 4862dfcc..682ddbc4 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -55,12 +55,12 @@ #include "install/wipe_device.h" #include "otautil/boot_state.h" #include "otautil/error_code.h" -#include "otautil/logging.h" #include "otautil/paths.h" -#include "otautil/roots.h" #include "otautil/sysutil.h" #include "recovery_ui/screen_ui.h" #include "recovery_ui/ui.h" +#include "recovery_utils/logging.h" +#include "recovery_utils/roots.h" static constexpr const char* COMMAND_FILE = "/cache/recovery/command"; static constexpr const char* LAST_KMSG_FILE = "/cache/recovery/last_kmsg"; diff --git a/recovery_main.cpp b/recovery_main.cpp index a04c1bba..89253dcd 100644 --- a/recovery_main.cpp +++ b/recovery_main.cpp @@ -51,14 +51,14 @@ #include "fastboot/fastboot.h" #include "install/wipe_data.h" #include "otautil/boot_state.h" -#include "otautil/logging.h" #include "otautil/paths.h" -#include "otautil/roots.h" #include "otautil/sysutil.h" #include "recovery.h" #include "recovery_ui/device.h" #include "recovery_ui/stub_ui.h" #include "recovery_ui/ui.h" +#include "recovery_utils/logging.h" +#include "recovery_utils/roots.h" static constexpr const char* COMMAND_FILE = "/cache/recovery/command"; static constexpr const char* LOCALE_FILE = "/cache/recovery/last_locale"; diff --git a/recovery_utils/Android.bp b/recovery_utils/Android.bp new file mode 100644 index 00000000..271d0799 --- /dev/null +++ b/recovery_utils/Android.bp @@ -0,0 +1,66 @@ +// Copyright (C) 2019 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. + +// A utility lib that's local to recovery (in contrast, libotautil is exposed to device-specific +// recovery_ui lib as well as device-specific updater). +cc_library_static { + name: "librecovery_utils", + + recovery_available: true, + + defaults: [ + "recovery_defaults", + ], + + srcs: [ + "logging.cpp", + "parse_install_logs.cpp", + "roots.cpp", + "thermalutil.cpp", + ], + + shared_libs: [ + "libbase", + "libext4_utils", + "libfs_mgr", + "libselinux", + ], + + export_include_dirs: [ + "include", + ], + + include_dirs: [ + "system/vold", + ], + + static_libs: [ + "libotautil", + + // external dependency + "libfstab", + ], + + export_static_lib_headers: [ + "libfstab", + ], + + // Should avoid exposing to the libs that might be used in device-specific codes (e.g. + // libedify, libotautil, librecovery_ui). + visibility: [ + "//bootable/recovery", + "//bootable/recovery/install", + "//bootable/recovery/tests", + ], +} diff --git a/otautil/include/otautil/logging.h b/recovery_utils/include/recovery_utils/logging.h similarity index 100% rename from otautil/include/otautil/logging.h rename to recovery_utils/include/recovery_utils/logging.h diff --git a/otautil/include/otautil/parse_install_logs.h b/recovery_utils/include/recovery_utils/parse_install_logs.h similarity index 100% rename from otautil/include/otautil/parse_install_logs.h rename to recovery_utils/include/recovery_utils/parse_install_logs.h diff --git a/otautil/include/otautil/roots.h b/recovery_utils/include/recovery_utils/roots.h similarity index 100% rename from otautil/include/otautil/roots.h rename to recovery_utils/include/recovery_utils/roots.h diff --git a/otautil/include/otautil/thermalutil.h b/recovery_utils/include/recovery_utils/thermalutil.h similarity index 100% rename from otautil/include/otautil/thermalutil.h rename to recovery_utils/include/recovery_utils/thermalutil.h diff --git a/otautil/logging.cpp b/recovery_utils/logging.cpp similarity index 99% rename from otautil/logging.cpp rename to recovery_utils/logging.cpp index 3db0e8ac..52f12a8d 100644 --- a/otautil/logging.cpp +++ b/recovery_utils/logging.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "otautil/logging.h" +#include "recovery_utils/logging.h" #include #include @@ -38,7 +38,7 @@ #include "otautil/dirutil.h" #include "otautil/paths.h" -#include "otautil/roots.h" +#include "recovery_utils/roots.h" constexpr const char* LOG_FILE = "/cache/recovery/log"; constexpr const char* LAST_INSTALL_FILE = "/cache/recovery/last_install"; diff --git a/otautil/parse_install_logs.cpp b/recovery_utils/parse_install_logs.cpp similarity index 98% rename from otautil/parse_install_logs.cpp rename to recovery_utils/parse_install_logs.cpp index 13a72992..c8631762 100644 --- a/otautil/parse_install_logs.cpp +++ b/recovery_utils/parse_install_logs.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "otautil/parse_install_logs.h" +#include "recovery_utils/parse_install_logs.h" #include diff --git a/otautil/roots.cpp b/recovery_utils/roots.cpp similarity index 99% rename from otautil/roots.cpp rename to recovery_utils/roots.cpp index e098b4b7..f717ec20 100644 --- a/otautil/roots.cpp +++ b/recovery_utils/roots.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "otautil/roots.h" +#include "recovery_utils/roots.h" #include #include diff --git a/otautil/thermalutil.cpp b/recovery_utils/thermalutil.cpp similarity index 98% rename from otautil/thermalutil.cpp rename to recovery_utils/thermalutil.cpp index 4660e057..5436355d 100644 --- a/otautil/thermalutil.cpp +++ b/recovery_utils/thermalutil.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "otautil/thermalutil.h" +#include "recovery_utils/thermalutil.h" #include #include diff --git a/tests/Android.bp b/tests/Android.bp index 3335c0b8..5b881e36 100644 --- a/tests/Android.bp +++ b/tests/Android.bp @@ -117,6 +117,7 @@ cc_test { "librecovery_ui", "libfusesideload", "libminui", + "librecovery_utils", "libotautil", "libupdater_device", "libupdater_core", diff --git a/tests/unit/parse_install_logs_test.cpp b/tests/unit/parse_install_logs_test.cpp index 72169a0c..052f71c9 100644 --- a/tests/unit/parse_install_logs_test.cpp +++ b/tests/unit/parse_install_logs_test.cpp @@ -22,7 +22,7 @@ #include #include -#include "otautil/parse_install_logs.h" +#include "recovery_utils/parse_install_logs.h" TEST(ParseInstallLogsTest, EmptyFile) { TemporaryFile last_install;