Merge "Clean up some global variables in common.h" am: 80c405f692 am: 168ce56022 am: 6f8e0ede72

am: 984dc5c263

Change-Id: I5df6ce9f82a0535c844b9474dbe57dc4e6e9e316
This commit is contained in:
Tianjie Xu
2019-07-24 18:19:26 -07:00
committed by android-build-merger
8 changed files with 60 additions and 65 deletions

View File

@@ -18,21 +18,8 @@
#include <string> #include <string>
// Not using the command-line defined macro here because this header could be included by
// device-specific recovery libraries. We static assert the value consistency in recovery.cpp.
static constexpr int kRecoveryApiVersion = 3;
class RecoveryUI;
struct selabel_handle;
extern struct selabel_handle* sehandle;
extern RecoveryUI* ui;
extern bool has_cache;
// The current stage, e.g. "1/2". // The current stage, e.g. "1/2".
extern std::string stage; extern std::string stage;
// The reason argument provided in "--reason=". // The reason argument provided in "--reason=".
extern const char* reason; extern const char* reason;
bool is_ro_debuggable();

View File

@@ -60,7 +60,8 @@
using namespace std::chrono_literals; using namespace std::chrono_literals;
static constexpr int kRecoveryApiVersion = 3; static constexpr int kRecoveryApiVersion = 3;
// Assert the version defined in code and in Android.mk are consistent. // We define RECOVERY_API_VERSION in Android.mk, which will be picked up by build system and packed
// into target_files.zip. Assert the version defined in code and in Android.mk are consistent.
static_assert(kRecoveryApiVersion == RECOVERY_API_VERSION, "Mismatching recovery API versions."); static_assert(kRecoveryApiVersion == RECOVERY_API_VERSION, "Mismatching recovery API versions.");
// Default allocation of progress bar segments to operations // Default allocation of progress bar segments to operations
@@ -621,6 +622,8 @@ InstallResult InstallPackage(Package* package, const std::string_view package_id
InstallResult result; InstallResult result;
std::vector<std::string> log_buffer; std::vector<std::string> log_buffer;
ui->Print("Supported API: %d\n", kRecoveryApiVersion);
ui->Print("Finding update package...\n"); ui->Print("Finding update package...\n");
LOG(INFO) << "Update package id: " << package_id; LOG(INFO) << "Update package id: " << package_id;
if (!package) { if (!package) {

View File

@@ -53,7 +53,7 @@ void rotate_logs(const char* last_log_file, const char* last_kmsg_file);
void check_and_fclose(FILE* fp, const std::string& name); void check_and_fclose(FILE* fp, const std::string& name);
void copy_log_file_to_pmsg(const std::string& source, const std::string& destination); void copy_log_file_to_pmsg(const std::string& source, const std::string& destination);
void copy_logs(bool save_current_log, bool has_cache, const selabel_handle* sehandle); void copy_logs(bool save_current_log);
void reset_tmplog_offset(); void reset_tmplog_offset();
void save_kernel_log(const char* destination); void save_kernel_log(const char* destination);

View File

@@ -53,3 +53,6 @@ int format_volume(const std::string& volume, const std::string& directory);
// Ensure that all and only the volumes that packages expect to find // Ensure that all and only the volumes that packages expect to find
// mounted (/tmp and /cache) are mounted. Returns 0 on success. // mounted (/tmp and /cache) are mounted. Returns 0 on success.
int setup_install_mounts(); int setup_install_mounts();
// Returns true if there is /cache in the volumes.
bool HasCache();

View File

@@ -178,9 +178,8 @@ void reset_tmplog_offset() {
tmplog_offset = 0; tmplog_offset = 0;
} }
static void copy_log_file(const std::string& source, const std::string& destination, bool append, static void copy_log_file(const std::string& source, const std::string& destination, bool append) {
const selabel_handle* sehandle) { FILE* dest_fp = fopen_path(destination, append ? "ae" : "we", logging_sehandle);
FILE* dest_fp = fopen_path(destination, append ? "ae" : "we", sehandle);
if (dest_fp == nullptr) { if (dest_fp == nullptr) {
PLOG(ERROR) << "Can't open " << destination; PLOG(ERROR) << "Can't open " << destination;
} else { } else {
@@ -203,7 +202,7 @@ static void copy_log_file(const std::string& source, const std::string& destinat
} }
} }
void copy_logs(bool save_current_log, bool has_cache, const selabel_handle* sehandle) { void copy_logs(bool save_current_log) {
// We only rotate and record the log of the current session if explicitly requested. This usually // We only rotate and record the log of the current session if explicitly requested. This usually
// happens after wipes, installation from BCB or menu selections. This is to avoid unnecessary // happens after wipes, installation from BCB or menu selections. This is to avoid unnecessary
// rotation (and possible deletion) of log files, if it does not do anything loggable. // rotation (and possible deletion) of log files, if it does not do anything loggable.
@@ -216,7 +215,7 @@ void copy_logs(bool save_current_log, bool has_cache, const selabel_handle* seha
copy_log_file_to_pmsg(Paths::Get().temporary_install_file(), LAST_INSTALL_FILE); copy_log_file_to_pmsg(Paths::Get().temporary_install_file(), LAST_INSTALL_FILE);
// We can do nothing for now if there's no /cache partition. // We can do nothing for now if there's no /cache partition.
if (!has_cache) { if (!HasCache()) {
return; return;
} }
@@ -225,9 +224,9 @@ void copy_logs(bool save_current_log, bool has_cache, const selabel_handle* seha
rotate_logs(LAST_LOG_FILE, LAST_KMSG_FILE); rotate_logs(LAST_LOG_FILE, LAST_KMSG_FILE);
// Copy logs to cache so the system can find out what happened. // Copy logs to cache so the system can find out what happened.
copy_log_file(Paths::Get().temporary_log_file(), LOG_FILE, true, sehandle); copy_log_file(Paths::Get().temporary_log_file(), LOG_FILE, true);
copy_log_file(Paths::Get().temporary_log_file(), LAST_LOG_FILE, false, sehandle); copy_log_file(Paths::Get().temporary_log_file(), LAST_LOG_FILE, false);
copy_log_file(Paths::Get().temporary_install_file(), LAST_INSTALL_FILE, false, sehandle); copy_log_file(Paths::Get().temporary_install_file(), LAST_INSTALL_FILE, false);
save_kernel_log(LAST_KMSG_FILE); save_kernel_log(LAST_KMSG_FILE);
chmod(LOG_FILE, 0600); chmod(LOG_FILE, 0600);
chown(LOG_FILE, AID_SYSTEM, AID_SYSTEM); chown(LOG_FILE, AID_SYSTEM, AID_SYSTEM);
@@ -319,7 +318,7 @@ bool RestoreLogFilesAfterFormat(const std::vector<saved_log_file>& log_files) {
// Reset the pointer so we copy from the beginning of the temp // Reset the pointer so we copy from the beginning of the temp
// log. // log.
reset_tmplog_offset(); reset_tmplog_offset();
copy_logs(true /* save_current_log */, true /* has_cache */, logging_sehandle); copy_logs(true /* save_current_log */);
return true; return true;
} }

View File

@@ -51,6 +51,8 @@ using android::fs_mgr::ReadDefaultFstab;
static Fstab fstab; static Fstab fstab;
constexpr const char* CACHE_ROOT = "/cache";
void load_volume_table() { void load_volume_table() {
if (!ReadDefaultFstab(&fstab)) { if (!ReadDefaultFstab(&fstab)) {
LOG(ERROR) << "Failed to read default fstab"; LOG(ERROR) << "Failed to read default fstab";
@@ -275,3 +277,9 @@ int setup_install_mounts() {
} }
return 0; return 0;
} }
bool HasCache() {
CHECK(!fstab.empty());
static bool has_cache = volume_for_mount_point(CACHE_ROOT) != nullptr;
return has_cache;
}

View File

@@ -69,10 +69,6 @@ static constexpr const char* LOCALE_FILE = "/cache/recovery/last_locale";
static constexpr const char* CACHE_ROOT = "/cache"; static constexpr const char* CACHE_ROOT = "/cache";
// We define RECOVERY_API_VERSION in Android.mk, which will be picked up by build system and packed
// into target_files.zip. Assert the version defined in code and in Android.mk are consistent.
static_assert(kRecoveryApiVersion == RECOVERY_API_VERSION, "Mismatching recovery API versions.");
static bool save_current_log = false; static bool save_current_log = false;
std::string stage; std::string stage;
const char* reason = nullptr; const char* reason = nullptr;
@@ -106,7 +102,7 @@ const char* reason = nullptr;
* -- after this, rebooting will restart the erase -- * -- after this, rebooting will restart the erase --
* 5. erase_volume() reformats /data * 5. erase_volume() reformats /data
* 6. erase_volume() reformats /cache * 6. erase_volume() reformats /cache
* 7. finish_recovery() erases BCB * 7. FinishRecovery() erases BCB
* -- after this, rebooting will restart the main system -- * -- after this, rebooting will restart the main system --
* 8. main() calls reboot() to boot main system * 8. main() calls reboot() to boot main system
* *
@@ -118,25 +114,25 @@ const char* reason = nullptr;
* -- after this, rebooting will attempt to reinstall the update -- * -- after this, rebooting will attempt to reinstall the update --
* 5. InstallPackage() attempts to install the update * 5. InstallPackage() attempts to install the update
* NOTE: the package install must itself be restartable from any point * NOTE: the package install must itself be restartable from any point
* 6. finish_recovery() erases BCB * 6. FinishRecovery() erases BCB
* -- after this, rebooting will (try to) restart the main system -- * -- after this, rebooting will (try to) restart the main system --
* 7. ** if install failed ** * 7. ** if install failed **
* 7a. PromptAndWait() shows an error icon and waits for the user * 7a. PromptAndWait() shows an error icon and waits for the user
* 7b. the user reboots (pulling the battery, etc) into the main system * 7b. the user reboots (pulling the battery, etc) into the main system
*/ */
bool is_ro_debuggable() { static bool IsRoDebuggable() {
return android::base::GetBoolProperty("ro.debuggable", false); return android::base::GetBoolProperty("ro.debuggable", false);
} }
// Clear the recovery command and prepare to boot a (hopefully working) system, // Clear the recovery command and prepare to boot a (hopefully working) system,
// copy our log file to cache as well (for the system to read). This function is // copy our log file to cache as well (for the system to read). This function is
// idempotent: call it as many times as you like. // idempotent: call it as many times as you like.
static void finish_recovery() { static void FinishRecovery(RecoveryUI* ui) {
std::string locale = ui->GetLocale(); std::string locale = ui->GetLocale();
// Save the locale to cache, so if recovery is next started up without a '--locale' argument // Save the locale to cache, so if recovery is next started up without a '--locale' argument
// (e.g., directly from the bootloader) it will use the last-known locale. // (e.g., directly from the bootloader) it will use the last-known locale.
if (!locale.empty() && has_cache) { if (!locale.empty() && HasCache()) {
LOG(INFO) << "Saving locale \"" << locale << "\""; LOG(INFO) << "Saving locale \"" << locale << "\"";
if (ensure_path_mounted(LOCALE_FILE) != 0) { if (ensure_path_mounted(LOCALE_FILE) != 0) {
LOG(ERROR) << "Failed to mount " << LOCALE_FILE; LOG(ERROR) << "Failed to mount " << LOCALE_FILE;
@@ -145,7 +141,7 @@ static void finish_recovery() {
} }
} }
copy_logs(save_current_log, has_cache, sehandle); copy_logs(save_current_log);
// Reset to normal system boot so recovery won't cycle indefinitely. // Reset to normal system boot so recovery won't cycle indefinitely.
std::string err; std::string err;
@@ -154,7 +150,7 @@ static void finish_recovery() {
} }
// Remove the command file, so recovery won't repeat indefinitely. // Remove the command file, so recovery won't repeat indefinitely.
if (has_cache) { if (HasCache()) {
if (ensure_path_mounted(COMMAND_FILE) != 0 || (unlink(COMMAND_FILE) && errno != ENOENT)) { if (ensure_path_mounted(COMMAND_FILE) != 0 || (unlink(COMMAND_FILE) && errno != ENOENT)) {
LOG(WARNING) << "Can't unlink " << COMMAND_FILE; LOG(WARNING) << "Can't unlink " << COMMAND_FILE;
} }
@@ -168,7 +164,7 @@ static bool yes_no(Device* device, const char* question1, const char* question2)
std::vector<std::string> headers{ question1, question2 }; std::vector<std::string> headers{ question1, question2 };
std::vector<std::string> items{ " No", " Yes" }; std::vector<std::string> items{ " No", " Yes" };
size_t chosen_item = ui->ShowMenu( size_t chosen_item = device->GetUI()->ShowMenu(
headers, items, 0, true, headers, items, 0, true,
std::bind(&Device::HandleMenuKey, device, std::placeholders::_1, std::placeholders::_2)); std::bind(&Device::HandleMenuKey, device, std::placeholders::_1, std::placeholders::_2));
return (chosen_item == 1); return (chosen_item == 1);
@@ -178,7 +174,7 @@ static bool ask_to_wipe_data(Device* device) {
std::vector<std::string> headers{ "Wipe all user data?", " THIS CAN NOT BE UNDONE!" }; std::vector<std::string> headers{ "Wipe all user data?", " THIS CAN NOT BE UNDONE!" };
std::vector<std::string> items{ " Cancel", " Factory data reset" }; std::vector<std::string> items{ " Cancel", " Factory data reset" };
size_t chosen_item = ui->ShowPromptWipeDataConfirmationMenu( size_t chosen_item = device->GetUI()->ShowPromptWipeDataConfirmationMenu(
headers, items, headers, items,
std::bind(&Device::HandleMenuKey, device, std::placeholders::_1, std::placeholders::_2)); std::bind(&Device::HandleMenuKey, device, std::placeholders::_1, std::placeholders::_2));
@@ -200,7 +196,7 @@ static InstallResult prompt_and_wipe_data(Device* device) {
}; };
// clang-format on // clang-format on
for (;;) { for (;;) {
size_t chosen_item = ui->ShowPromptWipeDataMenu( size_t chosen_item = device->GetUI()->ShowPromptWipeDataMenu(
wipe_data_menu_headers, wipe_data_menu_items, wipe_data_menu_headers, wipe_data_menu_items,
std::bind(&Device::HandleMenuKey, device, std::placeholders::_1, std::placeholders::_2)); std::bind(&Device::HandleMenuKey, device, std::placeholders::_1, std::placeholders::_2));
// If ShowMenu() returned RecoveryUI::KeyError::INTERRUPTED, WaitKey() was interrupted. // If ShowMenu() returned RecoveryUI::KeyError::INTERRUPTED, WaitKey() was interrupted.
@@ -224,7 +220,7 @@ static InstallResult prompt_and_wipe_data(Device* device) {
static void choose_recovery_file(Device* device) { static void choose_recovery_file(Device* device) {
std::vector<std::string> entries; std::vector<std::string> entries;
if (has_cache) { if (HasCache()) {
for (int i = 0; i < KEEP_LOG_COUNT; i++) { for (int i = 0; i < KEEP_LOG_COUNT; i++) {
auto add_to_entries = [&](const char* filename) { auto add_to_entries = [&](const char* filename) {
std::string log_file(filename); std::string log_file(filename);
@@ -258,7 +254,7 @@ static void choose_recovery_file(Device* device) {
size_t chosen_item = 0; size_t chosen_item = 0;
while (true) { while (true) {
chosen_item = ui->ShowMenu( chosen_item = device->GetUI()->ShowMenu(
headers, entries, chosen_item, true, headers, entries, chosen_item, true,
std::bind(&Device::HandleMenuKey, device, std::placeholders::_1, std::placeholders::_2)); std::bind(&Device::HandleMenuKey, device, std::placeholders::_1, std::placeholders::_2));
@@ -268,11 +264,11 @@ static void choose_recovery_file(Device* device) {
} }
if (entries[chosen_item] == "Back") break; if (entries[chosen_item] == "Back") break;
ui->ShowFile(entries[chosen_item]); device->GetUI()->ShowFile(entries[chosen_item]);
} }
} }
static void run_graphics_test() { static void run_graphics_test(RecoveryUI* ui) {
// Switch to graphics screen. // Switch to graphics screen.
ui->ShowText(false); ui->ShowText(false);
@@ -319,8 +315,9 @@ static void run_graphics_test() {
// as REBOOT, SHUTDOWN, or REBOOT_BOOTLOADER. Returning NO_ACTION means to take the default, which // as REBOOT, SHUTDOWN, or REBOOT_BOOTLOADER. Returning NO_ACTION means to take the default, which
// is to reboot or shutdown depending on if the --shutdown_after flag was passed to recovery. // is to reboot or shutdown depending on if the --shutdown_after flag was passed to recovery.
static Device::BuiltinAction PromptAndWait(Device* device, InstallResult status) { static Device::BuiltinAction PromptAndWait(Device* device, InstallResult status) {
auto ui = device->GetUI();
for (;;) { for (;;) {
finish_recovery(); FinishRecovery(ui);
switch (status) { switch (status) {
case INSTALL_SUCCESS: case INSTALL_SUCCESS:
case INSTALL_NONE: case INSTALL_NONE:
@@ -421,7 +418,7 @@ static Device::BuiltinAction PromptAndWait(Device* device, InstallResult status)
if (status != INSTALL_SUCCESS) { if (status != INSTALL_SUCCESS) {
ui->SetBackground(RecoveryUI::ERROR); ui->SetBackground(RecoveryUI::ERROR);
ui->Print("Installation aborted.\n"); ui->Print("Installation aborted.\n");
copy_logs(save_current_log, has_cache, sehandle); copy_logs(save_current_log);
} else if (!ui->IsTextVisible()) { } else if (!ui->IsTextVisible()) {
return Device::NO_ACTION; // reboot if logs aren't visible return Device::NO_ACTION; // reboot if logs aren't visible
} }
@@ -433,7 +430,7 @@ static Device::BuiltinAction PromptAndWait(Device* device, InstallResult status)
break; break;
case Device::RUN_GRAPHICS_TEST: case Device::RUN_GRAPHICS_TEST:
run_graphics_test(); run_graphics_test(ui);
break; break;
case Device::RUN_LOCALE_TEST: { case Device::RUN_LOCALE_TEST: {
@@ -680,6 +677,8 @@ Device::BuiltinAction start_recovery(Device* device, const std::vector<std::stri
printf("stage is [%s]\n", stage.c_str()); printf("stage is [%s]\n", stage.c_str());
printf("reason is [%s]\n", reason); printf("reason is [%s]\n", reason);
auto ui = device->GetUI();
// Set background string to "installing security update" for security update, // Set background string to "installing security update" for security update,
// otherwise set it to "installing system update". // otherwise set it to "installing system update".
ui->SetSystemUpdateText(security_update); ui->SetSystemUpdateText(security_update);
@@ -706,8 +705,6 @@ Device::BuiltinAction start_recovery(Device* device, const std::vector<std::stri
property_list(print_property, nullptr); property_list(print_property, nullptr);
printf("\n"); printf("\n");
ui->Print("Supported API: %d\n", kRecoveryApiVersion);
InstallResult status = INSTALL_SUCCESS; InstallResult status = INSTALL_SUCCESS;
// next_action indicates the next target to reboot into upon finishing the install. It could be // next_action indicates the next target to reboot into upon finishing the install. It could be
// overridden to a different reboot target per user request. // overridden to a different reboot target per user request.
@@ -768,7 +765,7 @@ Device::BuiltinAction start_recovery(Device* device, const std::vector<std::stri
// RETRY_LIMIT times before we abandon this OTA update. // RETRY_LIMIT times before we abandon this OTA update.
static constexpr int RETRY_LIMIT = 4; static constexpr int RETRY_LIMIT = 4;
if (status == INSTALL_RETRY && retry_count < RETRY_LIMIT) { if (status == INSTALL_RETRY && retry_count < RETRY_LIMIT) {
copy_logs(save_current_log, has_cache, sehandle); copy_logs(save_current_log);
retry_count += 1; retry_count += 1;
set_retry_bootloader_message(retry_count, args); set_retry_bootloader_message(retry_count, args);
// Print retry count on screen. // Print retry count on screen.
@@ -786,7 +783,7 @@ Device::BuiltinAction start_recovery(Device* device, const std::vector<std::stri
// If this is an eng or userdebug build, then automatically // If this is an eng or userdebug build, then automatically
// turn the text display on if the script fails so the error // turn the text display on if the script fails so the error
// message is visible. // message is visible.
if (is_ro_debuggable()) { if (IsRoDebuggable()) {
ui->ShowText(true); ui->ShowText(true);
} }
} }
@@ -843,7 +840,7 @@ Device::BuiltinAction start_recovery(Device* device, const std::vector<std::stri
// If this is an eng or userdebug build, automatically turn on the text display if no command // If this is an eng or userdebug build, automatically turn on the text display if no command
// is specified. Note that this should be called before setting the background to avoid // is specified. Note that this should be called before setting the background to avoid
// flickering the background image. // flickering the background image.
if (is_ro_debuggable()) { if (IsRoDebuggable()) {
ui->ShowText(true); ui->ShowText(true);
} }
status = INSTALL_NONE; // No command specified status = INSTALL_NONE; // No command specified
@@ -876,7 +873,7 @@ Device::BuiltinAction start_recovery(Device* device, const std::vector<std::stri
} }
// Save logs and clean up before rebooting or shutting down. // Save logs and clean up before rebooting or shutting down.
finish_recovery(); FinishRecovery(ui);
return next_action; return next_action;
} }

View File

@@ -63,12 +63,11 @@
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";
static constexpr const char* CACHE_ROOT = "/cache"; static RecoveryUI* ui = nullptr;
bool has_cache = false; static bool IsRoDebuggable() {
return android::base::GetBoolProperty("ro.debuggable", false);
RecoveryUI* ui = nullptr; }
struct selabel_handle* sehandle;
static void UiLogger(android::base::LogId /* id */, android::base::LogSeverity severity, static void UiLogger(android::base::LogId /* id */, android::base::LogSeverity severity,
const char* /* tag */, const char* /* file */, unsigned int /* line */, const char* /* tag */, const char* /* file */, unsigned int /* line */,
@@ -131,7 +130,7 @@ static std::vector<std::string> get_args(const int argc, char** const argv) {
} }
// --- if that doesn't work, try the command file (if we have /cache). // --- if that doesn't work, try the command file (if we have /cache).
if (args.size() == 1 && has_cache) { if (args.size() == 1 && HasCache()) {
std::string content; std::string content;
if (ensure_path_mounted(COMMAND_FILE) == 0 && if (ensure_path_mounted(COMMAND_FILE) == 0 &&
android::base::ReadFileToString(COMMAND_FILE, &content)) { android::base::ReadFileToString(COMMAND_FILE, &content)) {
@@ -148,7 +147,7 @@ static std::vector<std::string> get_args(const int argc, char** const argv) {
// Write the arguments (excluding the filename in args[0]) back into the // Write the arguments (excluding the filename in args[0]) back into the
// bootloader control block. So the device will always boot into recovery to // bootloader control block. So the device will always boot into recovery to
// finish the pending work, until finish_recovery() is called. // finish the pending work, until FinishRecovery() is called.
std::vector<std::string> options(args.cbegin() + 1, args.cend()); std::vector<std::string> options(args.cbegin() + 1, args.cend());
if (!update_bootloader_message(options, &err)) { if (!update_bootloader_message(options, &err)) {
LOG(ERROR) << "Failed to set BCB message: " << err; LOG(ERROR) << "Failed to set BCB message: " << err;
@@ -331,7 +330,6 @@ int main(int argc, char** argv) {
redirect_stdio(Paths::Get().temporary_log_file().c_str()); redirect_stdio(Paths::Get().temporary_log_file().c_str());
load_volume_table(); load_volume_table();
has_cache = volume_for_mount_point(CACHE_ROOT) != nullptr;
std::vector<std::string> args = get_args(argc, argv); std::vector<std::string> args = get_args(argc, argv);
auto args_to_parse = StringVectorToNullTerminatedArray(args); auto args_to_parse = StringVectorToNullTerminatedArray(args);
@@ -370,7 +368,7 @@ int main(int argc, char** argv) {
optind = 1; optind = 1;
if (locale.empty()) { if (locale.empty()) {
if (has_cache) { if (HasCache()) {
locale = load_locale_from_cache(); locale = load_locale_from_cache();
} }
@@ -416,7 +414,7 @@ int main(int argc, char** argv) {
} }
ui = device->GetUI(); ui = device->GetUI();
if (!has_cache) { if (!HasCache()) {
device->RemoveMenuItemForAction(Device::WIPE_CACHE); device->RemoveMenuItemForAction(Device::WIPE_CACHE);
} }
@@ -424,7 +422,7 @@ int main(int argc, char** argv) {
device->RemoveMenuItemForAction(Device::ENTER_FASTBOOT); device->RemoveMenuItemForAction(Device::ENTER_FASTBOOT);
} }
if (!is_ro_debuggable()) { if (!IsRoDebuggable()) {
device->RemoveMenuItemForAction(Device::ENTER_RESCUE); device->RemoveMenuItemForAction(Device::ENTER_RESCUE);
} }
@@ -434,7 +432,7 @@ int main(int argc, char** argv) {
LOG(INFO) << "Starting recovery (pid " << getpid() << ") on " << ctime(&start); LOG(INFO) << "Starting recovery (pid " << getpid() << ") on " << ctime(&start);
LOG(INFO) << "locale is [" << locale << "]"; LOG(INFO) << "locale is [" << locale << "]";
sehandle = selinux_android_file_context_handle(); auto sehandle = selinux_android_file_context_handle();
selinux_android_set_sehandle(sehandle); selinux_android_set_sehandle(sehandle);
if (!sehandle) { if (!sehandle) {
ui->Print("Warning: No file_contexts\n"); ui->Print("Warning: No file_contexts\n");
@@ -447,7 +445,7 @@ int main(int argc, char** argv) {
listener_thread.detach(); listener_thread.detach();
while (true) { while (true) {
std::string usb_config = fastboot ? "fastboot" : is_ro_debuggable() ? "adb" : "none"; std::string usb_config = fastboot ? "fastboot" : IsRoDebuggable() ? "adb" : "none";
std::string usb_state = android::base::GetProperty("sys.usb.state", "none"); std::string usb_state = android::base::GetProperty("sys.usb.state", "none");
if (usb_config != usb_state) { if (usb_config != usb_state) {
if (!SetUsbConfig("none")) { if (!SetUsbConfig("none")) {