| Yifan Hong | b0dde93 | 2017-02-10 17:49:58 -0800 | [diff] [blame] | 1 | /* | 
| Yifan Hong | 443df79 | 2017-05-09 18:49:45 -0700 | [diff] [blame] | 2 | * Copyright (C) 2017 The Android Open Source Project | 
| Yifan Hong | b0dde93 | 2017-02-10 17:49:58 -0800 | [diff] [blame] | 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 |  | 
| Steven Moreland | 0b8e387 | 2019-06-25 08:54:34 -0700 | [diff] [blame] | 17 | #pragma once | 
| Yifan Hong | b0dde93 | 2017-02-10 17:49:58 -0800 | [diff] [blame] | 18 |  | 
| Yifan Hong | 96bc714 | 2023-12-18 21:57:56 -0800 | [diff] [blame] | 19 | #include <chrono> | 
| Yifan Hong | 443df79 | 2017-05-09 18:49:45 -0700 | [diff] [blame] | 20 | #include <iostream> | 
| Yifan Hong | b0dde93 | 2017-02-10 17:49:58 -0800 | [diff] [blame] | 21 | #include <string> | 
| Yifan Hong | b0dde93 | 2017-02-10 17:49:58 -0800 | [diff] [blame] | 22 |  | 
| Yifan Hong | 443df79 | 2017-05-09 18:49:45 -0700 | [diff] [blame] | 23 | #include <android-base/macros.h> | 
| Yifan Hong | b0dde93 | 2017-02-10 17:49:58 -0800 | [diff] [blame] | 24 | #include <android/hidl/manager/1.0/IServiceManager.h> | 
| Yifan Hong | 443df79 | 2017-05-09 18:49:45 -0700 | [diff] [blame] | 25 | #include <utils/StrongPointer.h> | 
| Yifan Hong | b0dde93 | 2017-02-10 17:49:58 -0800 | [diff] [blame] | 26 |  | 
| Yifan Hong | ded398e | 2017-09-07 13:54:28 -0700 | [diff] [blame] | 27 | #include "Command.h" | 
| Yifan Hong | 4b86549 | 2017-02-28 19:38:24 -0800 | [diff] [blame] | 28 | #include "NullableOStream.h" | 
| Yifan Hong | 6884b87 | 2020-07-09 16:38:18 -0700 | [diff] [blame] | 29 | #include "ParentDebugInfoLevel.h" | 
| Yifan Hong | 443df79 | 2017-05-09 18:49:45 -0700 | [diff] [blame] | 30 | #include "utils.h" | 
| Yifan Hong | b0dde93 | 2017-02-10 17:49:58 -0800 | [diff] [blame] | 31 |  | 
|  | 32 | namespace android { | 
|  | 33 | namespace lshal { | 
|  | 34 |  | 
| Yifan Hong | b0dde93 | 2017-02-10 17:49:58 -0800 | [diff] [blame] | 35 | class Lshal { | 
|  | 36 | public: | 
| Yifan Hong | 443df79 | 2017-05-09 18:49:45 -0700 | [diff] [blame] | 37 | Lshal(); | 
| Yifan Hong | b2a2ecb | 2017-09-07 15:08:22 -0700 | [diff] [blame] | 38 | virtual ~Lshal() {} | 
| Yifan Hong | 9881df9 | 2017-05-10 14:33:05 -0700 | [diff] [blame] | 39 | Lshal(std::ostream &out, std::ostream &err, | 
|  | 40 | sp<hidl::manager::V1_0::IServiceManager> serviceManager, | 
|  | 41 | sp<hidl::manager::V1_0::IServiceManager> passthroughManager); | 
| Yifan Hong | 443df79 | 2017-05-09 18:49:45 -0700 | [diff] [blame] | 42 | Status main(const Arg &arg); | 
| Yifan Hong | a8bedc6 | 2017-09-08 18:00:31 -0700 | [diff] [blame] | 43 | // global usage | 
|  | 44 | void usage(); | 
| Yifan Hong | b2a2ecb | 2017-09-07 15:08:22 -0700 | [diff] [blame] | 45 | virtual NullableOStream<std::ostream> err() const; | 
|  | 46 | virtual NullableOStream<std::ostream> out() const; | 
| Yifan Hong | 9881df9 | 2017-05-10 14:33:05 -0700 | [diff] [blame] | 47 | const sp<hidl::manager::V1_0::IServiceManager> &serviceManager() const; | 
|  | 48 | const sp<hidl::manager::V1_0::IServiceManager> &passthroughManager() const; | 
| Yifan Hong | b0dde93 | 2017-02-10 17:49:58 -0800 | [diff] [blame] | 49 |  | 
| Yifan Hong | 48dc9f8 | 2017-05-09 19:33:08 -0700 | [diff] [blame] | 50 | Status emitDebugInfo( | 
| Andreas Huber | 28d3591 | 2017-03-24 13:14:11 -0700 | [diff] [blame] | 51 | const std::string &interfaceName, | 
| Yifan Hong | 443df79 | 2017-05-09 18:49:45 -0700 | [diff] [blame] | 52 | const std::string &instanceName, | 
|  | 53 | const std::vector<std::string> &options, | 
| Yifan Hong | 6884b87 | 2020-07-09 16:38:18 -0700 | [diff] [blame] | 54 | ParentDebugInfoLevel parentDebugInfoLevel, | 
| Yifan Hong | 48dc9f8 | 2017-05-09 19:33:08 -0700 | [diff] [blame] | 55 | std::ostream &out, | 
|  | 56 | NullableOStream<std::ostream> err) const; | 
| Yifan Hong | ded398e | 2017-09-07 13:54:28 -0700 | [diff] [blame] | 57 |  | 
| Yifan Hong | 795b6ec | 2017-09-13 11:25:28 -0700 | [diff] [blame] | 58 | Command* selectCommand(const std::string& command) const; | 
|  | 59 |  | 
|  | 60 | void forEachCommand(const std::function<void(const Command* c)>& f) const; | 
| Yifan Hong | ded398e | 2017-09-07 13:54:28 -0700 | [diff] [blame] | 61 |  | 
| Yifan Hong | 96bc714 | 2023-12-18 21:57:56 -0800 | [diff] [blame] | 62 | void setWaitTimeForTest(std::chrono::milliseconds ipcCallWait, | 
|  | 63 | std::chrono::milliseconds debugDumpWait); | 
|  | 64 | std::chrono::milliseconds getIpcCallWait() const; | 
|  | 65 | std::chrono::milliseconds getDebugDumpWait() const; | 
|  | 66 |  | 
| Yifan Hong | 443df79 | 2017-05-09 18:49:45 -0700 | [diff] [blame] | 67 | private: | 
|  | 68 | Status parseArgs(const Arg &arg); | 
| Yifan Hong | ded398e | 2017-09-07 13:54:28 -0700 | [diff] [blame] | 69 |  | 
| Yifan Hong | 443df79 | 2017-05-09 18:49:45 -0700 | [diff] [blame] | 70 | std::string mCommand; | 
| Yifan Hong | 9881df9 | 2017-05-10 14:33:05 -0700 | [diff] [blame] | 71 | NullableOStream<std::ostream> mOut; | 
|  | 72 | NullableOStream<std::ostream> mErr; | 
|  | 73 |  | 
|  | 74 | sp<hidl::manager::V1_0::IServiceManager> mServiceManager; | 
|  | 75 | sp<hidl::manager::V1_0::IServiceManager> mPassthroughManager; | 
| Andreas Huber | 28d3591 | 2017-03-24 13:14:11 -0700 | [diff] [blame] | 76 |  | 
| Yifan Hong | 795b6ec | 2017-09-13 11:25:28 -0700 | [diff] [blame] | 77 | std::vector<std::unique_ptr<Command>> mRegisteredCommands; | 
|  | 78 |  | 
| Yifan Hong | 96bc714 | 2023-12-18 21:57:56 -0800 | [diff] [blame] | 79 | std::chrono::milliseconds mIpcCallWait{500}; | 
|  | 80 | std::chrono::milliseconds mDebugDumpWait{10000}; | 
|  | 81 |  | 
| Yifan Hong | 443df79 | 2017-05-09 18:49:45 -0700 | [diff] [blame] | 82 | DISALLOW_COPY_AND_ASSIGN(Lshal); | 
| Yifan Hong | b0dde93 | 2017-02-10 17:49:58 -0800 | [diff] [blame] | 83 | }; | 
|  | 84 |  | 
| Yifan Hong | b0dde93 | 2017-02-10 17:49:58 -0800 | [diff] [blame] | 85 | }  // namespace lshal | 
|  | 86 | }  // namespace android |