Skip to content

Commit ebb5d06

Browse files
committed
ANDROID: ag x86: disable wake alarms
On x86 platforms, especially laptops, it might make sense to never wake device up just to fetch notifications, or perform other tasks that android would wake device up for Andorid does not seem to currently use the posix timer_create entry point, but changing that too for completness, disabling alarms from userspace
1 parent 2dbb889 commit ebb5d06

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

fs/timerfd.c

+9
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,15 @@ SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags)
415415
BUILD_BUG_ON(TFD_CLOEXEC != O_CLOEXEC);
416416
BUILD_BUG_ON(TFD_NONBLOCK != O_NONBLOCK);
417417

418+
// disabling alarms for android on x86 platforms
419+
// doing it in a way that won't cause errors in frameworks/base/apex/jobscheduler/service/jni/com_android_server_alarm_AlarmManagerService.cpp
420+
if(clockid == CLOCK_REALTIME_ALARM){
421+
clockid = CLOCK_REALTIME;
422+
}
423+
if(clockid == CLOCK_BOOTTIME_ALARM){
424+
clockid = CLOCK_BOOTTIME;
425+
}
426+
418427
if ((flags & ~TFD_CREATE_FLAGS) ||
419428
(clockid != CLOCK_MONOTONIC &&
420429
clockid != CLOCK_REALTIME &&

kernel/time/posix-timers.c

+6
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,12 @@ static int common_timer_create(struct k_itimer *new_timer)
498498
static int do_timer_create(clockid_t which_clock, struct sigevent *event,
499499
timer_t __user *created_timer_id)
500500
{
501+
if(which_clock == CLOCK_REALTIME_ALARM){
502+
which_clock = CLOCK_REALTIME;
503+
}
504+
if(which_clock == CLOCK_BOOTTIME_ALARM){
505+
which_clock = CLOCK_BOOTTIME;
506+
}
501507
const struct k_clock *kc = clockid_to_kclock(which_clock);
502508
struct k_itimer *new_timer;
503509
int error, new_timer_id;

0 commit comments

Comments
 (0)