• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "PipeClient.h"
18 
19 #include <android/binder_ibinder.h>
20 
21 namespace android {
22 namespace automotive {
23 namespace computepipe {
24 namespace router {
25 namespace V1_0 {
26 namespace implementation {
27 
28 using namespace aidl::android::automotive::computepipe::registry;
29 using namespace ndk;
30 
PipeClient(const std::shared_ptr<IClientInfo> & info)31 PipeClient::PipeClient(const std::shared_ptr<IClientInfo>& info)
32     : mDeathMonitor(AIBinder_DeathRecipient_new(RemoteMonitor::BinderDiedCallback)),
33       mClientInfo(info) {
34 }
35 
getClientName()36 std::string PipeClient::getClientName() {
37     if (mClientInfo == nullptr) {
38         return 0;
39     }
40     std::string name;
41     auto status = mClientInfo->getClientName(&name);
42     return (status.isOk()) ? name : "";
43 }
44 
startClientMonitor()45 bool PipeClient::startClientMonitor() {
46     mState = std::make_shared<RemoteState>();
47     auto monitor = new RemoteMonitor(mState);
48     auto status = ScopedAStatus::fromStatus(
49         AIBinder_linkToDeath(mClientInfo->asBinder().get(), mDeathMonitor.get(), monitor));
50     return status.isOk();
51 }
52 
isAlive()53 bool PipeClient::isAlive() {
54     return mState->isAlive();
55 }
56 
~PipeClient()57 PipeClient::~PipeClient() {
58 }
59 }  // namespace implementation
60 }  // namespace V1_0
61 }  // namespace router
62 }  // namespace computepipe
63 }  // namespace automotive
64 }  // namespace android
65