blob: c87ebc3b987bc9168e9b64924f3bf803280d2638 [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();
51 void dump() const;
52 void usage() const;
53 void putEntry(TableEntry &&entry);
54 Status fetchPassthrough(const sp<::android::hidl::manager::V1_0::IServiceManager> &manager);
55 Status fetchBinderized(const sp<::android::hidl::manager::V1_0::IServiceManager> &manager);
56 Status fetchAllLibraries(const sp<::android::hidl::manager::V1_0::IServiceManager> &manager);
57 bool getReferencedPids(
58 pid_t serverPid, std::map<uint64_t, Pids> *objects) const;
59
60
61 Table mTable;
62 std::ostream &mErr = std::cerr;
63 std::ostream &mOut = std::cout;
64};
65
66
67} // namespace lshal
68} // namespace android
69
70#endif // FRAMEWORK_NATIVE_CMDS_LSHAL_LSHAL_H_