Yifan Hong | b0dde93 | 2017-02-10 17:49:58 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 FRAMEWORK_NATIVE_CMDS_LSHAL_LSHAL_H_ |
| 18 | #define FRAMEWORK_NATIVE_CMDS_LSHAL_LSHAL_H_ |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | |
| 22 | #include <iostream> |
| 23 | #include <string> |
| 24 | #include <vector> |
| 25 | |
| 26 | #include <android/hidl/manager/1.0/IServiceManager.h> |
| 27 | |
| 28 | #include "TableEntry.h" |
| 29 | |
| 30 | namespace android { |
| 31 | namespace lshal { |
| 32 | |
| 33 | enum : unsigned int { |
| 34 | OK = 0, |
| 35 | USAGE = 1 << 0, |
| 36 | NO_BINDERIZED_MANAGER = 1 << 1, |
| 37 | NO_PASSTHROUGH_MANAGER = 1 << 2, |
| 38 | DUMP_BINDERIZED_ERROR = 1 << 3, |
| 39 | DUMP_PASSTHROUGH_ERROR = 1 << 4, |
| 40 | DUMP_ALL_LIBS_ERROR = 1 << 5, |
| 41 | }; |
| 42 | using Status = unsigned int; |
| 43 | |
| 44 | class Lshal { |
| 45 | public: |
| 46 | int main(int argc, char **argv); |
| 47 | |
| 48 | private: |
| 49 | Status parseArgs(int argc, char **argv); |
| 50 | Status fetch(); |
Yifan Hong | 38d53e0 | 2017-02-13 17:51:59 -0800 | [diff] [blame^] | 51 | void postprocess(); |
Yifan Hong | b0dde93 | 2017-02-10 17:49:58 -0800 | [diff] [blame] | 52 | void dump() const; |
| 53 | void usage() const; |
| 54 | void putEntry(TableEntry &&entry); |
| 55 | Status fetchPassthrough(const sp<::android::hidl::manager::V1_0::IServiceManager> &manager); |
| 56 | Status fetchBinderized(const sp<::android::hidl::manager::V1_0::IServiceManager> &manager); |
| 57 | Status fetchAllLibraries(const sp<::android::hidl::manager::V1_0::IServiceManager> &manager); |
| 58 | bool getReferencedPids( |
| 59 | pid_t serverPid, std::map<uint64_t, Pids> *objects) const; |
Yifan Hong | 38d53e0 | 2017-02-13 17:51:59 -0800 | [diff] [blame^] | 60 | void printLine( |
| 61 | const std::string &interfaceName, |
| 62 | const std::string &transport, const std::string &server, |
| 63 | const std::string &address, const std::string &clients) const; |
Yifan Hong | b0dde93 | 2017-02-10 17:49:58 -0800 | [diff] [blame] | 64 | |
Yifan Hong | 38d53e0 | 2017-02-13 17:51:59 -0800 | [diff] [blame^] | 65 | Table mTable{}; |
Yifan Hong | b0dde93 | 2017-02-10 17:49:58 -0800 | [diff] [blame] | 66 | std::ostream &mErr = std::cerr; |
| 67 | std::ostream &mOut = std::cout; |
Yifan Hong | 38d53e0 | 2017-02-13 17:51:59 -0800 | [diff] [blame^] | 68 | TableEntryCompare mSortColumn = nullptr; |
| 69 | TableEntrySelect mSelectedColumns = 0; |
Yifan Hong | b0dde93 | 2017-02-10 17:49:58 -0800 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | |
| 73 | } // namespace lshal |
| 74 | } // namespace android |
| 75 | |
| 76 | #endif // FRAMEWORK_NATIVE_CMDS_LSHAL_LSHAL_H_ |