1 /****************************************************************************** 2 * 3 * Copyright 2014 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 #include "AlarmTestHarness.h" 20 21 #include <hardware/bluetooth.h> 22 23 #include "osi/include/alarm.h" 24 #include "osi/include/wakelock.h" 25 26 static bool is_wake_lock_acquired = false; 27 acquire_wake_lock_cb(const char * lock_name)28static int acquire_wake_lock_cb(const char* lock_name) { 29 is_wake_lock_acquired = true; 30 return BT_STATUS_SUCCESS; 31 } 32 release_wake_lock_cb(const char * lock_name)33static int release_wake_lock_cb(const char* lock_name) { 34 is_wake_lock_acquired = false; 35 return BT_STATUS_SUCCESS; 36 } 37 38 static bt_os_callouts_t bt_wakelock_callouts = { 39 sizeof(bt_os_callouts_t), NULL, acquire_wake_lock_cb, release_wake_lock_cb}; 40 SetUp()41void AlarmTestHarness::SetUp() { 42 AllocationTestHarness::SetUp(); 43 44 TIMER_INTERVAL_FOR_WAKELOCK_IN_MS = 500; 45 46 wakelock_set_os_callouts(&bt_wakelock_callouts); 47 } 48 TearDown()49void AlarmTestHarness::TearDown() { 50 alarm_cleanup(); 51 wakelock_cleanup(); 52 wakelock_set_os_callouts(NULL); 53 54 AllocationTestHarness::TearDown(); 55 } 56 WakeLockHeld()57bool AlarmTestHarness::WakeLockHeld() { return is_wake_lock_acquired; } 58