SensorNotifierUtils.cpp 557 B

123456789101112131415161718192021222324252627282930
  1. /*
  2. * Copyright (C) 2024 The LineageOS Project
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #define LOG_TAG "SensorNotifierUtils"
  7. #include "SensorNotifierUtils.h"
  8. #include <android-base/logging.h>
  9. bool readBool(int fd) {
  10. char c;
  11. int rc;
  12. rc = lseek(fd, 0, SEEK_SET);
  13. if (rc) {
  14. LOG(ERROR) << "failed to seek fd, err: " << rc;
  15. return false;
  16. }
  17. rc = read(fd, &c, sizeof(char));
  18. if (rc != 1) {
  19. LOG(ERROR) << "failed to read bool from fd, err: " << rc;
  20. return false;
  21. }
  22. return c != '0';
  23. }