1 /* 2 * Copyright (C) 2017 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 #pragma once 18 19 #include <iostream> 20 #include <string> 21 22 #include <android-base/macros.h> 23 #include <android/hidl/manager/1.0/IServiceManager.h> 24 #include <utils/StrongPointer.h> 25 26 #include "Command.h" 27 #include "NullableOStream.h" 28 #include "ParentDebugInfoLevel.h" 29 #include "utils.h" 30 31 namespace android { 32 namespace lshal { 33 34 class Lshal { 35 public: 36 Lshal(); ~Lshal()37 virtual ~Lshal() {} 38 Lshal(std::ostream &out, std::ostream &err, 39 sp<hidl::manager::V1_0::IServiceManager> serviceManager, 40 sp<hidl::manager::V1_0::IServiceManager> passthroughManager); 41 Status main(const Arg &arg); 42 // global usage 43 void usage(); 44 virtual NullableOStream<std::ostream> err() const; 45 virtual NullableOStream<std::ostream> out() const; 46 const sp<hidl::manager::V1_0::IServiceManager> &serviceManager() const; 47 const sp<hidl::manager::V1_0::IServiceManager> &passthroughManager() const; 48 49 Status emitDebugInfo( 50 const std::string &interfaceName, 51 const std::string &instanceName, 52 const std::vector<std::string> &options, 53 ParentDebugInfoLevel parentDebugInfoLevel, 54 std::ostream &out, 55 NullableOStream<std::ostream> err) const; 56 57 Command* selectCommand(const std::string& command) const; 58 59 void forEachCommand(const std::function<void(const Command* c)>& f) const; 60 61 private: 62 Status parseArgs(const Arg &arg); 63 64 std::string mCommand; 65 NullableOStream<std::ostream> mOut; 66 NullableOStream<std::ostream> mErr; 67 68 sp<hidl::manager::V1_0::IServiceManager> mServiceManager; 69 sp<hidl::manager::V1_0::IServiceManager> mPassthroughManager; 70 71 std::vector<std::unique_ptr<Command>> mRegisteredCommands; 72 73 DISALLOW_COPY_AND_ASSIGN(Lshal); 74 }; 75 76 } // namespace lshal 77 } // namespace android 78