Check /dev/binder access before calling defaultServiceManager() am: 41b7c70821 am: 5e682c2851
am: 1ab425f135

Change-Id: I6648512fd0d5074b7299f3b9148a9905c4f8c912
diff --git a/ashmemd_client.cpp b/ashmemd_client.cpp
index 3380209..04227ba 100644
--- a/ashmemd_client.cpp
+++ b/ashmemd_client.cpp
@@ -28,6 +28,11 @@
 namespace ashmemd {
 
 sp<IAshmemDeviceService> getAshmemService() {
+    // Calls to defaultServiceManager() crash the process if it doesn't have appropriate
+    // binder permissions. Check these permissions proactively.
+    if (access("/dev/binder", R_OK | W_OK) != 0) {
+        return nullptr;
+    }
     sp<IServiceManager> sm = android::defaultServiceManager();
     sp<IBinder> binder = sm->checkService(String16("ashmem_device_service"));
     return interface_cast<IAshmemDeviceService>(binder);