blob: d7bcab29295dfa64b16e98e755c3abdb50006039 [file] [log] [blame]
Yifan Hongb0dde932017-02-10 17:49:58 -08001/*
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
30namespace android {
31namespace lshal {
32
33enum : 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};
42using Status = unsigned int;
43
44class Lshal {
45public:
46 int main(int argc, char **argv);
47
48private:
49 Status parseArgs(int argc, char **argv);
50 Status fetch();
Yifan Hong38d53e02017-02-13 17:51:59 -080051 void postprocess();
Yifan Hongb0dde932017-02-10 17:49:58 -080052 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 Hong38d53e02017-02-13 17:51:59 -080060 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 Hongb0dde932017-02-10 17:49:58 -080064
Yifan Hong38d53e02017-02-13 17:51:59 -080065 Table mTable{};
Yifan Hongb0dde932017-02-10 17:49:58 -080066 std::ostream &mErr = std::cerr;
67 std::ostream &mOut = std::cout;
Yifan Hong38d53e02017-02-13 17:51:59 -080068 TableEntryCompare mSortColumn = nullptr;
69 TableEntrySelect mSelectedColumns = 0;
Yifan Hongb0dde932017-02-10 17:49:58 -080070};
71
72
73} // namespace lshal
74} // namespace android
75
76#endif // FRAMEWORK_NATIVE_CMDS_LSHAL_LSHAL_H_