main.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (C) 2024 The LineageOS Project
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #define LOG_TAG "SensorNotifier"
  7. #include <android-base/logging.h>
  8. #include <android-base/properties.h>
  9. #include "SensorNotifierExt.h"
  10. #include "notifiers/AodNotifier.h"
  11. #include "notifiers/NonUiNotifier.h"
  12. int main() {
  13. sp<ISensorManager> manager = ISensorManager::getService();
  14. if (manager == nullptr) {
  15. LOG(ERROR) << "failed to get ISensorManager";
  16. return EXIT_FAILURE;
  17. }
  18. std::vector<std::unique_ptr<SensorNotifier>> notifiers;
  19. notifiers.push_back(std::make_unique<AodNotifier>(manager));
  20. notifiers.push_back(std::make_unique<NonUiNotifier>(manager));
  21. for (const auto& notifier : notifiers) {
  22. notifier->activate();
  23. }
  24. std::unique_ptr<SensorNotifierExt> sensorNotifierExt =
  25. std::make_unique<SensorNotifierExt>(manager);
  26. for (const auto& notifier : sensorNotifierExt->mNotifiers) {
  27. notifier->activate();
  28. }
  29. while (true) {
  30. // Sleep to keep the notifiers alive
  31. std::this_thread::sleep_for(std::chrono::seconds(10));
  32. }
  33. // Should never reach this
  34. return EXIT_SUCCESS;
  35. }