main.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 "SscCalApi.h"
  11. #include "notifiers/AodNotifier.h"
  12. #include "notifiers/LightNotifier.h"
  13. #include "notifiers/NonUiNotifier.h"
  14. int main() {
  15. sp<ISensorManager> manager = ISensorManager::getService();
  16. if (manager == nullptr) {
  17. LOG(ERROR) << "failed to get ISensorManager";
  18. return EXIT_FAILURE;
  19. }
  20. SscCalApiWrapper::getInstance().initCurrentSensors(
  21. android::base::GetBoolProperty("persist.vendor.debug.ssccalapi", false));
  22. std::vector<std::unique_ptr<SensorNotifier>> notifiers;
  23. notifiers.push_back(std::make_unique<AodNotifier>(manager));
  24. notifiers.push_back(std::make_unique<LightNotifier>(manager));
  25. notifiers.push_back(std::make_unique<NonUiNotifier>(manager));
  26. for (const auto& notifier : notifiers) {
  27. notifier->activate();
  28. }
  29. std::unique_ptr<SensorNotifierExt> sensorNotifierExt =
  30. std::make_unique<SensorNotifierExt>(manager);
  31. for (const auto& notifier : sensorNotifierExt->mNotifiers) {
  32. notifier->activate();
  33. }
  34. while (true) {
  35. // Sleep to keep the notifiers alive
  36. std::this_thread::sleep_for(std::chrono::seconds(10));
  37. }
  38. // Should never reach this
  39. return EXIT_SUCCESS;
  40. }