otautil: Factor out the utils that're private to recovery.
A number of utility functions are intended for serving recovery's own use. Exposing them via libotautil (which is a static lib) would pass the dependencies onto libotautil's users (e.g. recovery image, updater, host simulator, device-specific recovery UI/updater extensions etc). This CL finds a new home for the utils that are private to recovery. Test: mmma bootable/recovery Change-Id: I575e97ad099b85fe1c1c8c7c9458a5a43d4e11e1
This commit is contained in:
parent
36f72131ff
commit
e3f09a72f5
22 changed files with 92 additions and 50 deletions
|
@ -72,6 +72,7 @@ cc_defaults {
|
||||||
"libinstall",
|
"libinstall",
|
||||||
"librecovery_fastboot",
|
"librecovery_fastboot",
|
||||||
"libminui",
|
"libminui",
|
||||||
|
"librecovery_utils",
|
||||||
"libotautil",
|
"libotautil",
|
||||||
|
|
||||||
// external dependencies
|
// external dependencies
|
||||||
|
@ -148,7 +149,7 @@ cc_binary {
|
||||||
],
|
],
|
||||||
|
|
||||||
static_libs: [
|
static_libs: [
|
||||||
"libotautil",
|
"librecovery_utils",
|
||||||
],
|
],
|
||||||
|
|
||||||
init_rc: [
|
init_rc: [
|
||||||
|
@ -174,7 +175,7 @@ cc_binary {
|
||||||
],
|
],
|
||||||
|
|
||||||
static_libs: [
|
static_libs: [
|
||||||
"libotautil",
|
"librecovery_utils",
|
||||||
],
|
],
|
||||||
|
|
||||||
init_rc: [
|
init_rc: [
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#include <android-base/unique_fd.h>
|
#include <android-base/unique_fd.h>
|
||||||
#include <fs_mgr/roots.h>
|
#include <fs_mgr/roots.h>
|
||||||
|
|
||||||
#include "otautil/roots.h"
|
#include "recovery_utils/roots.h"
|
||||||
|
|
||||||
static constexpr const char* SYSTEM_E2FSCK_BIN = "/system/bin/e2fsck_static";
|
static constexpr const char* SYSTEM_E2FSCK_BIN = "/system/bin/e2fsck_static";
|
||||||
static constexpr const char* TMP_E2FSCK_BIN = "/tmp/e2fsck.bin";
|
static constexpr const char* TMP_E2FSCK_BIN = "/tmp/e2fsck.bin";
|
||||||
|
|
|
@ -37,6 +37,7 @@ cc_defaults {
|
||||||
],
|
],
|
||||||
|
|
||||||
static_libs: [
|
static_libs: [
|
||||||
|
"librecovery_utils",
|
||||||
"libotautil",
|
"libotautil",
|
||||||
|
|
||||||
// external dependencies
|
// external dependencies
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
#include "fuse_provider.h"
|
#include "fuse_provider.h"
|
||||||
#include "fuse_sideload.h"
|
#include "fuse_sideload.h"
|
||||||
#include "install/install.h"
|
#include "install/install.h"
|
||||||
#include "otautil/roots.h"
|
#include "recovery_utils/roots.h"
|
||||||
|
|
||||||
static constexpr const char* SDCARD_ROOT = "/sdcard";
|
static constexpr const char* SDCARD_ROOT = "/sdcard";
|
||||||
// How long (in seconds) we wait for the fuse-provided package file to
|
// How long (in seconds) we wait for the fuse-provided package file to
|
||||||
|
|
|
@ -51,11 +51,11 @@
|
||||||
#include "install/wipe_data.h"
|
#include "install/wipe_data.h"
|
||||||
#include "otautil/error_code.h"
|
#include "otautil/error_code.h"
|
||||||
#include "otautil/paths.h"
|
#include "otautil/paths.h"
|
||||||
#include "otautil/roots.h"
|
|
||||||
#include "otautil/sysutil.h"
|
#include "otautil/sysutil.h"
|
||||||
#include "otautil/thermalutil.h"
|
|
||||||
#include "private/setup_commands.h"
|
#include "private/setup_commands.h"
|
||||||
#include "recovery_ui/ui.h"
|
#include "recovery_ui/ui.h"
|
||||||
|
#include "recovery_utils/roots.h"
|
||||||
|
#include "recovery_utils/thermalutil.h"
|
||||||
|
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
|
|
|
@ -28,9 +28,9 @@
|
||||||
#include <android-base/stringprintf.h>
|
#include <android-base/stringprintf.h>
|
||||||
|
|
||||||
#include "otautil/dirutil.h"
|
#include "otautil/dirutil.h"
|
||||||
#include "otautil/logging.h"
|
|
||||||
#include "otautil/roots.h"
|
|
||||||
#include "recovery_ui/ui.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* CACHE_ROOT = "/cache";
|
||||||
constexpr const char* DATA_ROOT = "/data";
|
constexpr const char* DATA_ROOT = "/data";
|
||||||
|
|
|
@ -39,32 +39,4 @@ cc_library_static {
|
||||||
export_include_dirs: [
|
export_include_dirs: [
|
||||||
"include",
|
"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",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,8 +43,8 @@
|
||||||
#include <metricslogger/metrics_logger.h>
|
#include <metricslogger/metrics_logger.h>
|
||||||
#include <private/android_logger.h> /* private pmsg functions */
|
#include <private/android_logger.h> /* private pmsg functions */
|
||||||
|
|
||||||
#include "otautil/logging.h"
|
#include "recovery_utils/logging.h"
|
||||||
#include "otautil/parse_install_logs.h"
|
#include "recovery_utils/parse_install_logs.h"
|
||||||
|
|
||||||
constexpr const char* LAST_LOG_FILE = "/data/misc/recovery/last_log";
|
constexpr const char* LAST_LOG_FILE = "/data/misc/recovery/last_log";
|
||||||
constexpr const char* LAST_PMSG_FILE = "/sys/fs/pstore/pmsg-ramoops-0";
|
constexpr const char* LAST_PMSG_FILE = "/sys/fs/pstore/pmsg-ramoops-0";
|
||||||
|
|
|
@ -38,11 +38,12 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <private/android_logger.h> /* private pmsg functions */
|
#include <private/android_logger.h> /* private pmsg functions */
|
||||||
|
|
||||||
#include "otautil/logging.h"
|
#include "recovery_utils/logging.h"
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
static const char filter[] = "recovery/";
|
static const char filter[] = "recovery/";
|
||||||
|
|
|
@ -55,12 +55,12 @@
|
||||||
#include "install/wipe_device.h"
|
#include "install/wipe_device.h"
|
||||||
#include "otautil/boot_state.h"
|
#include "otautil/boot_state.h"
|
||||||
#include "otautil/error_code.h"
|
#include "otautil/error_code.h"
|
||||||
#include "otautil/logging.h"
|
|
||||||
#include "otautil/paths.h"
|
#include "otautil/paths.h"
|
||||||
#include "otautil/roots.h"
|
|
||||||
#include "otautil/sysutil.h"
|
#include "otautil/sysutil.h"
|
||||||
#include "recovery_ui/screen_ui.h"
|
#include "recovery_ui/screen_ui.h"
|
||||||
#include "recovery_ui/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* COMMAND_FILE = "/cache/recovery/command";
|
||||||
static constexpr const char* LAST_KMSG_FILE = "/cache/recovery/last_kmsg";
|
static constexpr const char* LAST_KMSG_FILE = "/cache/recovery/last_kmsg";
|
||||||
|
|
|
@ -51,14 +51,14 @@
|
||||||
#include "fastboot/fastboot.h"
|
#include "fastboot/fastboot.h"
|
||||||
#include "install/wipe_data.h"
|
#include "install/wipe_data.h"
|
||||||
#include "otautil/boot_state.h"
|
#include "otautil/boot_state.h"
|
||||||
#include "otautil/logging.h"
|
|
||||||
#include "otautil/paths.h"
|
#include "otautil/paths.h"
|
||||||
#include "otautil/roots.h"
|
|
||||||
#include "otautil/sysutil.h"
|
#include "otautil/sysutil.h"
|
||||||
#include "recovery.h"
|
#include "recovery.h"
|
||||||
#include "recovery_ui/device.h"
|
#include "recovery_ui/device.h"
|
||||||
#include "recovery_ui/stub_ui.h"
|
#include "recovery_ui/stub_ui.h"
|
||||||
#include "recovery_ui/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* COMMAND_FILE = "/cache/recovery/command";
|
||||||
static constexpr const char* LOCALE_FILE = "/cache/recovery/last_locale";
|
static constexpr const char* LOCALE_FILE = "/cache/recovery/last_locale";
|
||||||
|
|
66
recovery_utils/Android.bp
Normal file
66
recovery_utils/Android.bp
Normal file
|
@ -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",
|
||||||
|
],
|
||||||
|
}
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "otautil/logging.h"
|
#include "recovery_utils/logging.h"
|
||||||
|
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
#include "otautil/dirutil.h"
|
#include "otautil/dirutil.h"
|
||||||
#include "otautil/paths.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* LOG_FILE = "/cache/recovery/log";
|
||||||
constexpr const char* LAST_INSTALL_FILE = "/cache/recovery/last_install";
|
constexpr const char* LAST_INSTALL_FILE = "/cache/recovery/last_install";
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "otautil/parse_install_logs.h"
|
#include "recovery_utils/parse_install_logs.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "otautil/roots.h"
|
#include "recovery_utils/roots.h"
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
|
@ -14,7 +14,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "otautil/thermalutil.h"
|
#include "recovery_utils/thermalutil.h"
|
||||||
|
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
|
@ -117,6 +117,7 @@ cc_test {
|
||||||
"librecovery_ui",
|
"librecovery_ui",
|
||||||
"libfusesideload",
|
"libfusesideload",
|
||||||
"libminui",
|
"libminui",
|
||||||
|
"librecovery_utils",
|
||||||
"libotautil",
|
"libotautil",
|
||||||
"libupdater_device",
|
"libupdater_device",
|
||||||
"libupdater_core",
|
"libupdater_core",
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include <android-base/strings.h>
|
#include <android-base/strings.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "otautil/parse_install_logs.h"
|
#include "recovery_utils/parse_install_logs.h"
|
||||||
|
|
||||||
TEST(ParseInstallLogsTest, EmptyFile) {
|
TEST(ParseInstallLogsTest, EmptyFile) {
|
||||||
TemporaryFile last_install;
|
TemporaryFile last_install;
|
||||||
|
|
Loading…
Reference in a new issue