Lshal.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Copyright (C) 2017 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. #ifndef FRAMEWORK_NATIVE_CMDS_LSHAL_LSHAL_H_
  17. #define FRAMEWORK_NATIVE_CMDS_LSHAL_LSHAL_H_
  18. #include <iostream>
  19. #include <string>
  20. #include <android-base/macros.h>
  21. #include <android/hidl/manager/1.0/IServiceManager.h>
  22. #include <utils/StrongPointer.h>
  23. #include "Command.h"
  24. #include "HelpCommand.h"
  25. #include "NullableOStream.h"
  26. #include "utils.h"
  27. namespace android {
  28. namespace lshal {
  29. class Lshal {
  30. public:
  31. Lshal();
  32. virtual ~Lshal() {}
  33. Lshal(std::ostream &out, std::ostream &err,
  34. sp<hidl::manager::V1_0::IServiceManager> serviceManager,
  35. sp<hidl::manager::V1_0::IServiceManager> passthroughManager);
  36. Status main(const Arg &arg);
  37. // global usage
  38. void usage();
  39. virtual NullableOStream<std::ostream> err() const;
  40. virtual NullableOStream<std::ostream> out() const;
  41. const sp<hidl::manager::V1_0::IServiceManager> &serviceManager() const;
  42. const sp<hidl::manager::V1_0::IServiceManager> &passthroughManager() const;
  43. Status emitDebugInfo(
  44. const std::string &interfaceName,
  45. const std::string &instanceName,
  46. const std::vector<std::string> &options,
  47. bool excludesParentInstances,
  48. std::ostream &out,
  49. NullableOStream<std::ostream> err) const;
  50. Command* selectCommand(const std::string& command) const;
  51. void forEachCommand(const std::function<void(const Command* c)>& f) const;
  52. private:
  53. Status parseArgs(const Arg &arg);
  54. std::string mCommand;
  55. NullableOStream<std::ostream> mOut;
  56. NullableOStream<std::ostream> mErr;
  57. sp<hidl::manager::V1_0::IServiceManager> mServiceManager;
  58. sp<hidl::manager::V1_0::IServiceManager> mPassthroughManager;
  59. std::vector<std::unique_ptr<Command>> mRegisteredCommands;
  60. DISALLOW_COPY_AND_ASSIGN(Lshal);
  61. };
  62. } // namespace lshal
  63. } // namespace android
  64. #endif // FRAMEWORK_NATIVE_CMDS_LSHAL_LSHAL_H_