1 /****************************************************************************** 2 * 3 * Copyright (C) 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 19 #pragma once 20 21 #include <hardware/bluetooth.h> 22 #include <stdbool.h> 23 24 // Set the Bluetooth OS callouts to |callouts|. 25 // This function should be called when native kernel wakelocks are not used 26 // directly. If this function is not called, or |callouts| is NULL, then native 27 // kernel wakelocks will be used. 28 void wakelock_set_os_callouts(bt_os_callouts_t* callouts); 29 30 // Acquire the Bluetooth wakelock. 31 // The function is thread safe. 32 // Return true on success, otherwise false. 33 bool wakelock_acquire(void); 34 35 // Release the Bluetooth wakelock. 36 // The function is thread safe. 37 // Return true on success, otherwise false. 38 bool wakelock_release(void); 39 40 // Cleanup the wakelock internal state. 41 // This function should be called by the OSI module cleanup during 42 // graceful shutdown. 43 void wakelock_cleanup(void); 44 45 // This function should not need to be called normally. 46 // /sys/power/wake_{|un}lock are used by default. 47 // This is not guaranteed to have any effect after an alarm has been 48 // set with alarm_set. 49 // If |lock_path| or |unlock_path| are NULL, that path is not changed. 50 void wakelock_set_paths(const char* lock_path, const char* unlock_path); 51 52 // Dump wakelock-related debug info to the |fd| file descriptor. 53 // The caller is responsible for closing the |fd|. 54 void wakelock_debug_dump(int fd); 55