ashmemd: avoid sleep cycle on non-VNDK devices.
On non-VNDK device (e.g. sailfish) the code path to ashmemd is the same,
which results in vendor processes always failing to get ashmemd service.
Use checkService() to fail immediately, instead of waiting for the
service.
Fixes: 123999623
Test: boot sailfish, no sleep cycles when trying to reach ashmemd.
Change-Id: I4fce14fad28b509cd112370bc4cc2eafd45c6c75
diff --git a/ashmemd_client.cpp b/ashmemd_client.cpp
index 1984358..3380209 100644
--- a/ashmemd_client.cpp
+++ b/ashmemd_client.cpp
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#include <android-base/logging.h>
#include <android/ashmemd/IAshmemDeviceService.h>
#include <binder/IServiceManager.h>
@@ -28,17 +29,23 @@
sp<IAshmemDeviceService> getAshmemService() {
sp<IServiceManager> sm = android::defaultServiceManager();
- sp<IBinder> binder = sm->getService(String16("ashmem_device_service"));
+ sp<IBinder> binder = sm->checkService(String16("ashmem_device_service"));
return interface_cast<IAshmemDeviceService>(binder);
}
extern "C" int openAshmemdFd() {
static sp<IAshmemDeviceService> ashmemService = getAshmemService();
- if (!ashmemService) return -1;
+ if (!ashmemService) {
+ LOG(ERROR) << "Failed to get IAshmemDeviceService.";
+ return -1;
+ }
ParcelFileDescriptor fd;
auto status = ashmemService->open(&fd);
- if (!status.isOk()) return -1;
+ if (!status.isOk()) {
+ LOG(ERROR) << "Failed IAshmemDeviceService::open()";
+ return -1;
+ }
// unique_fd is the underlying type of ParcelFileDescriptor, i.e. fd is
// closed when it falls out of scope, so we make a dup.