1 /* 2 * Copyright (C) 2020 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 #pragma once 17 18 #include <aidl/android/hardware/dumpstate/BnDumpstateDevice.h> 19 #include <aidl/android/hardware/dumpstate/IDumpstateDevice.h> 20 #include <android/binder_status.h> 21 22 #include <automotive/filesystem> 23 #include <functional> 24 25 #include <grpc++/grpc++.h> 26 27 #include "DumpstateServer.grpc.pb.h" 28 #include "DumpstateServer.pb.h" 29 30 namespace aidl::android::hardware::dumpstate::implementation { 31 32 namespace fs = ::android::hardware::automotive::filesystem; 33 34 class DumpstateDevice : public BnDumpstateDevice { 35 public: 36 explicit DumpstateDevice(const std::string& addr); 37 38 ::ndk::ScopedAStatus dumpstateBoard(const std::vector<::ndk::ScopedFileDescriptor>& in_fds, 39 IDumpstateDevice::DumpstateMode in_mode, 40 int64_t in_timeoutMillis) override; 41 42 ::ndk::ScopedAStatus getVerboseLoggingEnabled(bool* _aidl_return) override; 43 ::ndk::ScopedAStatus setVerboseLoggingEnabled(bool in_enable) override; 44 45 bool isHealthy(); 46 47 private: 48 bool dumpRemoteLogs(::grpc::ClientReaderInterface<dumpstate_proto::DumpstateBuffer>* reader, 49 const fs::path& dumpPath); 50 bool dumpString(const std::string& text, const fs::path& dumpPath); 51 52 bool dumpHelperSystem(int textFd, int binFd); 53 54 std::vector<std::string> getAvailableServices(); 55 56 std::string mServiceAddr; 57 std::shared_ptr<::grpc::Channel> mGrpcChannel; 58 std::unique_ptr<dumpstate_proto::DumpstateServer::Stub> mGrpcStub; 59 }; 60 61 } // namespace aidl::android::hardware::dumpstate::implementation 62