Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b0f5100d authored by Kevin Schoedel's avatar Kevin Schoedel
Browse files

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
parent 3fdeae8b
Loading
Loading
Loading
Loading
+5 −4
Original line number Original line Diff line number Diff line
@@ -8,8 +8,9 @@


int main() {
int main() {
  ALOGI("Starting");
  ALOGI("Starting");
  android::dvr::VirtualTouchpadService touchpad_service(
  android::sp<android::dvr::VirtualTouchpadService> touchpad_service =
      std::move(android::dvr::VirtualTouchpadEvdev::Create()));
      new android::dvr::VirtualTouchpadService(
          android::dvr::VirtualTouchpadEvdev::Create());


  signal(SIGPIPE, SIG_IGN);
  signal(SIGPIPE, SIG_IGN);
  android::sp<android::ProcessState> ps(android::ProcessState::self());
  android::sp<android::ProcessState> ps(android::ProcessState::self());
@@ -19,8 +20,8 @@ int main() {


  android::sp<android::IServiceManager> sm(android::defaultServiceManager());
  android::sp<android::IServiceManager> sm(android::defaultServiceManager());
  const android::status_t service_status =
  const android::status_t service_status =
      sm->addService(android::String16(touchpad_service.SERVICE_NAME()),
      sm->addService(android::String16(touchpad_service->SERVICE_NAME()),
                     &touchpad_service, false /*allowIsolated*/);
                     touchpad_service, false /*allowIsolated*/);
  if (service_status != android::OK) {
  if (service_status != android::OK) {
    ALOGE("virtual touchpad service not added: %d",
    ALOGE("virtual touchpad service not added: %d",
          static_cast<int>(service_status));
          static_cast<int>(service_status));
+7 −7
Original line number Original line Diff line number Diff line
@@ -20,20 +20,20 @@ int main(int /* argc */, char** /* argv */) {
  LOG_ALWAYS_FATAL_IF(app_status != 0, "failed to initialize: %d", app_status);
  LOG_ALWAYS_FATAL_IF(app_status != 0, "failed to initialize: %d", app_status);


  // Create vr_wm_binder.
  // Create vr_wm_binder.
  android::service::vr::VrWindowManagerBinder vr_wm_binder(app);
  android::sp<android::service::vr::VrWindowManagerBinder> vr_wm_binder =
  const int status = vr_wm_binder.Initialize();
      new android::service::vr::VrWindowManagerBinder(app);
  const int status = vr_wm_binder->Initialize();
  LOG_ALWAYS_FATAL_IF(status != 0, "initialization failed: %d", status);
  LOG_ALWAYS_FATAL_IF(status != 0, "initialization failed: %d", status);


  android::sp<android::IServiceManager> sm(android::defaultServiceManager());
  android::sp<android::IServiceManager> sm(android::defaultServiceManager());
  const android::status_t vr_wm_binder_status =
  const android::status_t vr_wm_binder_status = sm->addService(
      sm->addService(
      android::service::vr::VrWindowManagerBinder::SERVICE_NAME(),
      android::service::vr::VrWindowManagerBinder::SERVICE_NAME(),
          &vr_wm_binder, false /*allowIsolated*/);
      vr_wm_binder, false /*allowIsolated*/);
  LOG_ALWAYS_FATAL_IF(vr_wm_binder_status != android::OK,
  LOG_ALWAYS_FATAL_IF(vr_wm_binder_status != android::OK,
                      "vr_wm_binder service not added: %d",
                      "vr_wm_binder service not added: %d",
                      static_cast<int>(vr_wm_binder_status));
                      static_cast<int>(vr_wm_binder_status));


  app.SetControllerDataProvider(&vr_wm_binder);
  app.SetControllerDataProvider(vr_wm_binder.get());


  android::hardware::ProcessState::self()->startThreadPool();
  android::hardware::ProcessState::self()->startThreadPool();