blob: bfd6a404f87fd6a8a4224121079fce009f5d6110 [file] [log] [blame]
Yifan Hongb0dde932017-02-10 17:49:58 -08001/*
Yifan Hong443df792017-05-09 18:49:45 -07002 * Copyright (C) 2017 The Android Open Source Project
Yifan Hongb0dde932017-02-10 17:49:58 -08003 *
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
Yifan Hong443df792017-05-09 18:49:45 -070020#include <iostream>
Yifan Hongb0dde932017-02-10 17:49:58 -080021#include <string>
Yifan Hongb0dde932017-02-10 17:49:58 -080022
Yifan Hong443df792017-05-09 18:49:45 -070023#include <android-base/macros.h>
Yifan Hongb0dde932017-02-10 17:49:58 -080024#include <android/hidl/manager/1.0/IServiceManager.h>
Yifan Hong443df792017-05-09 18:49:45 -070025#include <utils/StrongPointer.h>
Yifan Hongb0dde932017-02-10 17:49:58 -080026
Yifan Hongded398e2017-09-07 13:54:28 -070027#include "Command.h"
Yifan Hong4b865492017-02-28 19:38:24 -080028#include "NullableOStream.h"
Yifan Hong443df792017-05-09 18:49:45 -070029#include "utils.h"
Yifan Hongb0dde932017-02-10 17:49:58 -080030
31namespace android {
32namespace lshal {
33
Yifan Hongb0dde932017-02-10 17:49:58 -080034class Lshal {
35public:
Yifan Hong443df792017-05-09 18:49:45 -070036 Lshal();
Yifan Hongb2a2ecb2017-09-07 15:08:22 -070037 virtual ~Lshal() {}
Yifan Hong9881df92017-05-10 14:33:05 -070038 Lshal(std::ostream &out, std::ostream &err,
39 sp<hidl::manager::V1_0::IServiceManager> serviceManager,
40 sp<hidl::manager::V1_0::IServiceManager> passthroughManager);
Yifan Hong443df792017-05-09 18:49:45 -070041 Status main(const Arg &arg);
42 void usage(const std::string &command = "") const;
Yifan Hongb2a2ecb2017-09-07 15:08:22 -070043 virtual NullableOStream<std::ostream> err() const;
44 virtual NullableOStream<std::ostream> out() const;
Yifan Hong9881df92017-05-10 14:33:05 -070045 const sp<hidl::manager::V1_0::IServiceManager> &serviceManager() const;
46 const sp<hidl::manager::V1_0::IServiceManager> &passthroughManager() const;
Yifan Hongb0dde932017-02-10 17:49:58 -080047
Yifan Hong48dc9f82017-05-09 19:33:08 -070048 Status emitDebugInfo(
Andreas Huber28d35912017-03-24 13:14:11 -070049 const std::string &interfaceName,
Yifan Hong443df792017-05-09 18:49:45 -070050 const std::string &instanceName,
51 const std::vector<std::string> &options,
Yifan Hong48dc9f82017-05-09 19:33:08 -070052 std::ostream &out,
53 NullableOStream<std::ostream> err) const;
Yifan Hongded398e2017-09-07 13:54:28 -070054
55 std::unique_ptr<Command> selectCommand(const std::string& command);
56
Yifan Hong443df792017-05-09 18:49:45 -070057private:
58 Status parseArgs(const Arg &arg);
Yifan Hongded398e2017-09-07 13:54:28 -070059
Yifan Hong443df792017-05-09 18:49:45 -070060 std::string mCommand;
61 Arg mCmdArgs;
Yifan Hong9881df92017-05-10 14:33:05 -070062 NullableOStream<std::ostream> mOut;
63 NullableOStream<std::ostream> mErr;
64
65 sp<hidl::manager::V1_0::IServiceManager> mServiceManager;
66 sp<hidl::manager::V1_0::IServiceManager> mPassthroughManager;
Andreas Huber28d35912017-03-24 13:14:11 -070067
Yifan Hong443df792017-05-09 18:49:45 -070068 DISALLOW_COPY_AND_ASSIGN(Lshal);
Yifan Hongb0dde932017-02-10 17:49:58 -080069};
70
Yifan Hongb0dde932017-02-10 17:49:58 -080071} // namespace lshal
72} // namespace android
73
74#endif // FRAMEWORK_NATIVE_CMDS_LSHAL_LSHAL_H_