Add resume from hibernation in first stage init
If bootconfig hibernation_resume_device is present in boot config, then we write that value to /sys/power/resume Bug: 339688542 Test: Check resume from hibernation/boots with/without config present Change-Id: I1a9bf63af4dab07e494740722898c1aba33c00b5
This commit is contained in:
parent
6d85bb3ef5
commit
d96c6b8e88
3 changed files with 22 additions and 3 deletions
|
|
@ -39,9 +39,6 @@ std::string GetFstabPath();
|
|||
void ImportBootconfigFromString(const std::string& bootconfig,
|
||||
const std::function<void(std::string, std::string)>& fn);
|
||||
|
||||
bool GetBootconfigFromString(const std::string& bootconfig, const std::string& key,
|
||||
std::string* out);
|
||||
|
||||
void ImportKernelCmdlineFromString(const std::string& cmdline,
|
||||
const std::function<void(std::string, std::string)>& fn);
|
||||
|
||||
|
|
|
|||
|
|
@ -153,5 +153,8 @@ bool GetKernelCmdline(const std::string& key, std::string* out);
|
|||
// Return the "other" slot for the given slot suffix.
|
||||
std::string OtherSlotSuffix(const std::string& suffix);
|
||||
|
||||
bool GetBootconfigFromString(const std::string& bootconfig, const std::string& key,
|
||||
std::string* out);
|
||||
|
||||
} // namespace fs_mgr
|
||||
} // namespace android
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
#include <android-base/logging.h>
|
||||
#include <android-base/stringprintf.h>
|
||||
#include <android/avf_cc_flags.h>
|
||||
#include <fs_mgr.h>
|
||||
#include <modprobe/modprobe.h>
|
||||
#include <private/android_filesystem_config.h>
|
||||
|
||||
|
|
@ -303,6 +304,22 @@ static BootMode GetBootMode(const std::string& cmdline, const std::string& bootc
|
|||
return BootMode::NORMAL_MODE;
|
||||
}
|
||||
|
||||
static void MaybeResumeFromHibernation(const std::string& bootconfig) {
|
||||
std::string hibernationResumeDevice;
|
||||
android::fs_mgr::GetBootconfigFromString(bootconfig, "androidboot.hibernation_resume_device",
|
||||
&hibernationResumeDevice);
|
||||
if (!hibernationResumeDevice.empty()) {
|
||||
android::base::unique_fd fd(open("/sys/power/resume", O_RDWR | O_CLOEXEC));
|
||||
if (fd >= 0) {
|
||||
if (!android::base::WriteStringToFd(hibernationResumeDevice, fd)) {
|
||||
PLOG(ERROR) << "Failed to write to /sys/power/resume";
|
||||
}
|
||||
} else {
|
||||
PLOG(ERROR) << "Failed to open /sys/power/resume";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static std::unique_ptr<FirstStageMount> CreateFirstStageMount(const std::string& cmdline) {
|
||||
auto ret = FirstStageMount::Create(cmdline);
|
||||
if (ret.ok()) {
|
||||
|
|
@ -442,6 +459,8 @@ int FirstStageMain(int argc, char** argv) {
|
|||
<< module_elapse_time.count() << " ms";
|
||||
}
|
||||
|
||||
MaybeResumeFromHibernation(bootconfig);
|
||||
|
||||
std::unique_ptr<FirstStageMount> fsm;
|
||||
|
||||
bool created_devices = false;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue