main.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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/NonUiNotifier.h"
  11. int main() {
  12. sp<ISensorManager> manager = ISensorManager::getService();
  13. if (manager == nullptr) {
  14. LOG(ERROR) << "failed to get ISensorManager";
  15. return EXIT_FAILURE;
  16. }
  17. std::vector<std::unique_ptr<SensorNotifier>> notifiers;
  18. notifiers.push_back(std::make_unique<NonUiNotifier>(manager));
  19. for (const auto& notifier : notifiers) {
  20. notifier->activate();
  21. }
  22. std::unique_ptr<SensorNotifierExt> sensorNotifierExt =
  23. std::make_unique<SensorNotifierExt>(manager);
  24. for (const auto& notifier : sensorNotifierExt->mNotifiers) {
  25. notifier->activate();
  26. }
  27. while (true) {
  28. // Sleep to keep the notifiers alive
  29. std::this_thread::sleep_for(std::chrono::seconds(10));
  30. }
  31. // Should never reach this
  32. return EXIT_SUCCESS;
  33. }