1 /** 2 * Copyright 2019 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 17 #include "PipeRunner.h" 18 19 #include <android/binder_ibinder.h> 20 21 #include <mutex> 22 23 namespace android { 24 namespace automotive { 25 namespace computepipe { 26 namespace router { 27 namespace V1_0 { 28 namespace implementation { 29 30 using namespace aidl::android::automotive::computepipe::runner; 31 using namespace ndk; 32 PipeRunner(const std::shared_ptr<IPipeRunner> & graphRunner)33PipeRunner::PipeRunner(const std::shared_ptr<IPipeRunner>& graphRunner) : runner(graphRunner) { 34 } 35 RunnerHandle(const std::shared_ptr<IPipeRunner> & r)36RunnerHandle::RunnerHandle(const std::shared_ptr<IPipeRunner>& r) 37 : PipeHandle(std::make_unique<PipeRunner>(r)), 38 mDeathMonitor(AIBinder_DeathRecipient_new(RemoteMonitor::BinderDiedCallback)) { 39 } 40 startPipeMonitor()41bool RunnerHandle::startPipeMonitor() { 42 mState = std::make_shared<RemoteState>(); 43 auto monitor = new RemoteMonitor(mState); 44 auto status = ScopedAStatus::fromStatus( 45 AIBinder_linkToDeath(mInterface->runner->asBinder().get(), mDeathMonitor.get(), monitor)); 46 return status.isOk(); 47 } 48 isAlive()49bool RunnerHandle::isAlive() { 50 return mState->isAlive(); 51 } 52 clone() const53PipeHandle<PipeRunner>* RunnerHandle::clone() const { 54 return new RunnerHandle(mInterface->runner); 55 } 56 ~RunnerHandle()57RunnerHandle::~RunnerHandle() { 58 } 59 60 } // namespace implementation 61 } // namespace V1_0 62 } // namespace router 63 } // namespace computepipe 64 } // namespace automotive 65 } // namespace android 66