libdm: Fallback to legacy ueventd logic if running on an older system. am: b2cc8cb2d7
Change-Id: I5050d859e12d3ea85c5bbefaa42f76d3b1ec897a
This commit is contained in:
commit
78c6f365cd
|
@ -29,6 +29,7 @@
|
|||
#include <android-base/file.h>
|
||||
#include <android-base/logging.h>
|
||||
#include <android-base/macros.h>
|
||||
#include <android-base/properties.h>
|
||||
#include <android-base/strings.h>
|
||||
#include <uuid/uuid.h>
|
||||
|
||||
|
@ -140,6 +141,10 @@ static std::string GenerateUuid() {
|
|||
return std::string{uuid_chars};
|
||||
}
|
||||
|
||||
static bool IsRecovery() {
|
||||
return access("/system/bin/recovery", F_OK) == 0;
|
||||
}
|
||||
|
||||
bool DeviceMapper::CreateDevice(const std::string& name, const DmTable& table, std::string* path,
|
||||
const std::chrono::milliseconds& timeout_ms) {
|
||||
std::string uuid = GenerateUuid();
|
||||
|
@ -160,6 +165,16 @@ bool DeviceMapper::CreateDevice(const std::string& name, const DmTable& table, s
|
|||
if (timeout_ms <= std::chrono::milliseconds::zero()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (IsRecovery()) {
|
||||
bool non_ab_device = android::base::GetProperty("ro.build.ab_update", "").empty();
|
||||
int sdk = android::base::GetIntProperty("ro.build.version.sdk", 0);
|
||||
if (non_ab_device && sdk && sdk <= 29) {
|
||||
LOG(INFO) << "Detected ueventd incompatibility, reverting to legacy libdm behavior.";
|
||||
unique_path = *path;
|
||||
}
|
||||
}
|
||||
|
||||
if (!WaitForFile(unique_path, timeout_ms)) {
|
||||
LOG(ERROR) << "Failed waiting for device path: " << unique_path;
|
||||
DeleteDevice(name);
|
||||
|
|
Loading…
Reference in New Issue