From b0f5100d636404af6be3bc0f891d3630bfcd5472 Mon Sep 17 00:00:00 2001 From: Kevin Schoedel Date: Thu, 6 Apr 2017 13:49:41 -0400 Subject: Don't stack-allocate binder objects. These inherit from RefBase and need to be owned in an sp<>. Bug: 36854729 Test: manual on Pixel phone Change-Id: I5ac6f50c1a21d4c8b224d41149b16da4d438dba7 Merged-In: I54dac1298dca1eb3ab5e6751366ba67bb2e1906c --- services/vr/virtual_touchpad/main.cpp | 9 +++++---- services/vr/vr_window_manager/vr_window_manager.cpp | 14 +++++++------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/services/vr/virtual_touchpad/main.cpp b/services/vr/virtual_touchpad/main.cpp index 68f1d70d84..55ac9bf764 100644 --- a/services/vr/virtual_touchpad/main.cpp +++ b/services/vr/virtual_touchpad/main.cpp @@ -8,8 +8,9 @@ int main() { ALOGI("Starting"); - android::dvr::VirtualTouchpadService touchpad_service( - std::move(android::dvr::VirtualTouchpadEvdev::Create())); + android::sp touchpad_service = + new android::dvr::VirtualTouchpadService( + android::dvr::VirtualTouchpadEvdev::Create()); signal(SIGPIPE, SIG_IGN); android::sp ps(android::ProcessState::self()); @@ -19,8 +20,8 @@ int main() { android::sp sm(android::defaultServiceManager()); const android::status_t service_status = - sm->addService(android::String16(touchpad_service.SERVICE_NAME()), - &touchpad_service, false /*allowIsolated*/); + sm->addService(android::String16(touchpad_service->SERVICE_NAME()), + touchpad_service, false /*allowIsolated*/); if (service_status != android::OK) { ALOGE("virtual touchpad service not added: %d", static_cast(service_status)); diff --git a/services/vr/vr_window_manager/vr_window_manager.cpp b/services/vr/vr_window_manager/vr_window_manager.cpp index 6636dc5606..9d7afe3a42 100644 --- a/services/vr/vr_window_manager/vr_window_manager.cpp +++ b/services/vr/vr_window_manager/vr_window_manager.cpp @@ -20,20 +20,20 @@ int main(int /* argc */, char** /* argv */) { LOG_ALWAYS_FATAL_IF(app_status != 0, "failed to initialize: %d", app_status); // Create vr_wm_binder. - android::service::vr::VrWindowManagerBinder vr_wm_binder(app); - const int status = vr_wm_binder.Initialize(); + android::sp vr_wm_binder = + new android::service::vr::VrWindowManagerBinder(app); + const int status = vr_wm_binder->Initialize(); LOG_ALWAYS_FATAL_IF(status != 0, "initialization failed: %d", status); android::sp sm(android::defaultServiceManager()); - const android::status_t vr_wm_binder_status = - sm->addService( - android::service::vr::VrWindowManagerBinder::SERVICE_NAME(), - &vr_wm_binder, false /*allowIsolated*/); + const android::status_t vr_wm_binder_status = sm->addService( + android::service::vr::VrWindowManagerBinder::SERVICE_NAME(), + vr_wm_binder, false /*allowIsolated*/); LOG_ALWAYS_FATAL_IF(vr_wm_binder_status != android::OK, "vr_wm_binder service not added: %d", static_cast(vr_wm_binder_status)); - app.SetControllerDataProvider(&vr_wm_binder); + app.SetControllerDataProvider(vr_wm_binder.get()); android::hardware::ProcessState::self()->startThreadPool(); -- cgit v1.2.3-59-g8ed1b