1 /* 2 * Copyright (c) 2021, 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 #ifndef CPP_TELEMETRY_CARTELEMETRYD_SRC_CARTELEMETRYINTERNALIMPL_H_ 18 #define CPP_TELEMETRY_CARTELEMETRYD_SRC_CARTELEMETRYINTERNALIMPL_H_ 19 20 #include "TelemetryServer.h" 21 22 #include <aidl/android/automotive/telemetry/internal/BnCarTelemetryInternal.h> 23 #include <aidl/android/automotive/telemetry/internal/CarDataInternal.h> 24 #include <aidl/android/automotive/telemetry/internal/ICarDataListener.h> 25 #include <android/binder_status.h> 26 #include <utils/Mutex.h> 27 #include <utils/String16.h> 28 #include <utils/Vector.h> 29 30 namespace android { 31 namespace automotive { 32 namespace telemetry { 33 34 // Implementation of android.automotive.telemetry.ICarTelemetryInternal. 35 class CarTelemetryInternalImpl : 36 public aidl::android::automotive::telemetry::internal::BnCarTelemetryInternal { 37 public: 38 // Doesn't own `server`. 39 explicit CarTelemetryInternalImpl(TelemetryServer* server); 40 41 ndk::ScopedAStatus setListener( 42 const std::shared_ptr<aidl::android::automotive::telemetry::internal::ICarDataListener>& 43 listener) override; 44 45 ndk::ScopedAStatus clearListener() override; 46 47 ndk::ScopedAStatus addCarDataIds(const std::vector<int32_t>& ids) override; 48 49 ndk::ScopedAStatus removeCarDataIds(const std::vector<int32_t>& ids) override; 50 51 binder_status_t dump(int fd, const char** args, uint32_t numArgs) override; 52 53 private: 54 // Death recipient callback that is called when ICarDataListener dies. 55 // The cookie is a pointer to a CarTelemetryInternalImpl object. 56 static void listenerBinderDied(void* cookie); 57 58 void listenerBinderDiedImpl(); 59 60 TelemetryServer* mTelemetryServer; // not owned 61 ndk::ScopedAIBinder_DeathRecipient mBinderDeathRecipient; 62 }; 63 64 } // namespace telemetry 65 } // namespace automotive 66 } // namespace android 67 68 #endif // CPP_TELEMETRY_CARTELEMETRYD_SRC_CARTELEMETRYINTERNALIMPL_H_ 69