Merge "libcutils: fallback to /dev/ashmem"
am: 6e016ef80e
Change-Id: Ie8fcbadf4841a0b8537657598cd5dc1a01742f67
diff --git a/libcutils/ashmem-dev.cpp b/libcutils/ashmem-dev.cpp
index 340572c..8c232f0 100644
--- a/libcutils/ashmem-dev.cpp
+++ b/libcutils/ashmem-dev.cpp
@@ -203,19 +203,23 @@
{
static const std::string ashmem_device_path = get_ashmem_device_path();
- int ret;
- struct stat st;
-
if (ashmem_device_path.empty()) {
return -1;
}
int fd = TEMP_FAILURE_RETRY(open(ashmem_device_path.c_str(), O_RDWR | O_CLOEXEC));
+
+ // fallback for APEX w/ use_vendor on Q, which would have still used /dev/ashmem
+ if (fd < 0) {
+ fd = TEMP_FAILURE_RETRY(open("/dev/ashmem", O_RDWR | O_CLOEXEC));
+ }
+
if (fd < 0) {
return fd;
}
- ret = TEMP_FAILURE_RETRY(fstat(fd, &st));
+ struct stat st;
+ int ret = TEMP_FAILURE_RETRY(fstat(fd, &st));
if (ret < 0) {
int save_errno = errno;
close(fd);