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