summaryrefslogtreecommitdiffstats
path: root/ashmemd_client.cpp
diff options
context:
space:
mode:
authorTri Vo <trong@google.com>2019-02-08 09:45:56 -0800
committerTri Vo <trong@google.com>2019-02-08 09:45:58 -0800
commit8411a3b0166d9eb86c82eef5b8c96c2e05a7de21 (patch)
treea6de32c09aa4203a5f196fc8f536c9bdb712ecf1 /ashmemd_client.cpp
parentdf205799f399528a822fefce5ae1e6e46cea5410 (diff)
downloadplatform_system_ashmemd-8411a3b0166d9eb86c82eef5b8c96c2e05a7de21.tar.gz
platform_system_ashmemd-8411a3b0166d9eb86c82eef5b8c96c2e05a7de21.tar.bz2
platform_system_ashmemd-8411a3b0166d9eb86c82eef5b8c96c2e05a7de21.zip
ashmemd: avoid sleep cycle on non-VNDK devices.android-q-preview-1
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
Diffstat (limited to 'ashmemd_client.cpp')
-rw-r--r--ashmemd_client.cpp13
1 files changed, 10 insertions, 3 deletions
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 @@ namespace ashmemd {
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.