Move reboot() from common.h into otautil/sysutil.h.

This breaks the dependency on common.h (which belongs to
recovery/librecovery) from librecovery_ui. reboot() is now owned by
libotautil, which is expected to be a leaf node to be depended on.

With the change, recovery and updater also share the same reboot() code
now.

Test: mmma -j bootable/recovery
Change-Id: I1cc5d702cfe49302048db33d31c9c87ddc97ac71
This commit is contained in:
Tao Bao
2018-05-03 23:01:13 -07:00
parent 17054c051a
commit 2c52639d01
8 changed files with 21 additions and 20 deletions
+1
View File
@@ -65,6 +65,7 @@ LOCAL_MODULE := librecovery_ui
LOCAL_STATIC_LIBRARIES := \
libminui \
libotautil \
libbase
ifneq ($(TARGET_RECOVERY_UI_MARGIN_HEIGHT),)
-2
View File
@@ -48,6 +48,4 @@ void ui_print(const char* format, ...) __printflike(1, 2);
bool is_ro_debuggable();
bool reboot(const std::string& command);
#endif // RECOVERY_COMMON_H
+1
View File
@@ -48,6 +48,7 @@ cc_library_static {
static_libs: [
"libselinux",
"libcutils",
],
},
},
+4
View File
@@ -50,4 +50,8 @@ class MemMapping {
std::vector<MappedRange> ranges_;
};
// Wrapper function to trigger a reboot, by additionally handling quiescent reboot mode. The
// command should start with "reboot," (e.g. "reboot,bootloader" or "reboot,").
bool reboot(const std::string& command);
#endif // _OTAUTIL_SYSUTIL
+10
View File
@@ -28,8 +28,10 @@
#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/properties.h>
#include <android-base/strings.h>
#include <android-base/unique_fd.h>
#include <cutils/android_reboot.h>
bool MemMapping::MapFD(int fd) {
struct stat sb;
@@ -201,3 +203,11 @@ MemMapping::~MemMapping() {
};
ranges_.clear();
}
bool reboot(const std::string& command) {
std::string cmd = command;
if (android::base::GetBoolProperty("ro.boot.quiescent", false)) {
cmd += ",quiescent";
}
return android::base::SetProperty(ANDROID_RB_PROPERTY, cmd);
}
+1 -8
View File
@@ -70,6 +70,7 @@
#include "otautil/dirutil.h"
#include "otautil/error_code.h"
#include "otautil/paths.h"
#include "otautil/sysutil.h"
#include "roots.h"
#include "rotate_logs.h"
#include "screen_ui.h"
@@ -177,14 +178,6 @@ bool is_ro_debuggable() {
return android::base::GetBoolProperty("ro.debuggable", false);
}
bool reboot(const std::string& command) {
std::string cmd = command;
if (android::base::GetBoolProperty("ro.boot.quiescent", false)) {
cmd += ",quiescent";
}
return android::base::SetProperty(ANDROID_RB_PROPERTY, cmd);
}
// command line args come from, in decreasing precedence:
// - the actual command line
// - the bootloader control block (one per line, after "recovery")
+2 -4
View File
@@ -36,14 +36,12 @@
#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/parseint.h>
#include <android-base/properties.h>
#include <android-base/strings.h>
#include <cutils/android_reboot.h>
#include <minui/minui.h>
#include "common.h"
#include "roots.h"
#include "device.h"
#include "otautil/sysutil.h"
#include "roots.h"
static constexpr int UI_WAIT_KEY_TIMEOUT_SEC = 120;
static constexpr const char* BRIGHTNESS_FILE = "/sys/class/leds/lcd-backlight/brightness";
+2 -6
View File
@@ -48,7 +48,6 @@
#include <android-base/strings.h>
#include <applypatch/applypatch.h>
#include <bootloader_message/bootloader_message.h>
#include <cutils/android_reboot.h>
#include <ext4_utils/wipe.h>
#include <openssl/sha.h>
#include <selinux/label.h>
@@ -62,6 +61,7 @@
#include "otautil/error_code.h"
#include "otautil/mounts.h"
#include "otautil/print_sha1.h"
#include "otautil/sysutil.h"
#include "updater/updater.h"
// Send over the buffer to recovery though the command pipe.
@@ -874,11 +874,7 @@ Value* RebootNowFn(const char* name, State* state, const std::vector<std::unique
return StringValue("");
}
std::string reboot_cmd = "reboot," + property;
if (android::base::GetBoolProperty("ro.boot.quiescent", false)) {
reboot_cmd += ",quiescent";
}
android::base::SetProperty(ANDROID_RB_PROPERTY, reboot_cmd);
reboot("reboot," + property);
sleep(5);
return ErrorAbort(state, kRebootFailure, "%s() failed to reboot", name);