wakelock.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /******************************************************************************
  2. *
  3. * Copyright 2015 Google, Inc.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at:
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. ******************************************************************************/
  18. #pragma once
  19. #include <hardware/bluetooth.h>
  20. #include <stdbool.h>
  21. // Set the Bluetooth OS callouts to |callouts|.
  22. // This function should be called when native kernel wakelocks are not used
  23. // directly. If this function is not called, or |callouts| is NULL, then native
  24. // kernel wakelocks will be used.
  25. void wakelock_set_os_callouts(bt_os_callouts_t* callouts);
  26. // Acquire the Bluetooth wakelock.
  27. // The function is thread safe.
  28. // Return true on success, otherwise false.
  29. bool wakelock_acquire(void);
  30. // Release the Bluetooth wakelock.
  31. // The function is thread safe.
  32. // Return true on success, otherwise false.
  33. bool wakelock_release(void);
  34. // Cleanup the wakelock internal state.
  35. // This function should be called by the OSI module cleanup during
  36. // graceful shutdown.
  37. void wakelock_cleanup(void);
  38. // This function should not need to be called normally.
  39. // /sys/power/wake_{|un}lock are used by default.
  40. // This is not guaranteed to have any effect after an alarm has been
  41. // set with alarm_set.
  42. // If |lock_path| or |unlock_path| are NULL, that path is not changed.
  43. void wakelock_set_paths(const char* lock_path, const char* unlock_path);
  44. // Dump wakelock-related debug info to the |fd| file descriptor.
  45. // The caller is responsible for closing the |fd|.
  46. void wakelock_debug_dump(int fd);