Home | History | Annotate | Download | only in hardware_composer
      1 /*
      2  * Copyright 2017 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 #include <binder/ProcessState.h>
     17 #include <binder/IServiceManager.h>
     18 #include <hwbinder/IPCThreadState.h>
     19 #include <impl/vr_hwc.h>
     20 #include <inttypes.h>
     21 
     22 #include "vr_composer.h"
     23 
     24 int main() {
     25   android::ProcessState::self()->startThreadPool();
     26 
     27   // Register the hwbinder HWC HAL service used by SurfaceFlinger while in VR
     28   // mode.
     29   android::sp<android::dvr::VrHwc> service = new android::dvr::VrHwc();
     30 
     31   LOG_ALWAYS_FATAL_IF(!service.get(), "Failed to get service");
     32   LOG_ALWAYS_FATAL_IF(service->isRemote(), "Service is remote");
     33 
     34   const char instance[] = "vr";
     35   LOG_ALWAYS_FATAL_IF(service->registerAsService(instance) != android::OK,
     36                       "Failed to register service");
     37 
     38   android::sp<android::dvr::VrComposer> composer =
     39       new android::dvr::VrComposer(service.get());
     40 
     41   android::sp<android::IServiceManager> sm(android::defaultServiceManager());
     42 
     43   // Register the binder service used by VR Window Manager service to receive
     44   // frame information from VR HWC HAL.
     45   android::status_t status = sm->addService(
     46       android::dvr::VrComposer::SERVICE_NAME(), composer.get(),
     47       false /* allowIsolated */);
     48   LOG_ALWAYS_FATAL_IF(status != android::OK,
     49                       "VrDisplay service failed to start: %" PRId32, status);
     50 
     51   android::hardware::ProcessState::self()->startThreadPool();
     52   android::hardware::IPCThreadState::self()->joinThreadPool();
     53 
     54   return 0;
     55 }
     56