Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 01d38893 authored by Mao Jinlong's avatar Mao Jinlong
Browse files

Alarm: ignore less than 2 mins upcomming power off alarm

2 minutes is our define for enough boot up time for a power off alarm.
For current design, it can only afford upcoming power off alarm which
is later than 2 minutes. Kernel alarm driver only take care the power
off alarm which is 2 minutes later. And the framework only pass the
first power off alarm to kernel. So we need to find the first 2
minutes later upcomming power off alarm to kernel, otherwise it will
be no power off alarm from kernel's perspective. Fix the bug by
ignoring less than 2 mins upcomming alarm as power off alarm, and
only treat it as a normal alarm.

CRs-Fixed: 624561
Change-Id: I91379ecb2b378441ac2edb36212531ba6f203d8a
parent 0ac0d17d
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -72,6 +72,10 @@ class AlarmManagerService extends IAlarmManager.Stub {
    // warning message.  The time duration is in milliseconds.
    private static final long LATE_ALARM_THRESHOLD = 10 * 1000;

    // The threshold for the power off alarm time can be set. The time
    // duration is in milliseconds.
    private static final long POWER_OFF_ALARM_THRESHOLD = 120 * 1000;

    private static final int RTC_WAKEUP_MASK = 1 << RTC_WAKEUP;
    private static final int RTC_MASK = 1 << RTC;
    private static final int ELAPSED_REALTIME_WAKEUP_MASK = 1 << ELAPSED_REALTIME_WAKEUP; 
@@ -689,7 +693,8 @@ class AlarmManagerService extends IAlarmManager.Stub {
        final int N = mAlarmBatches.size();
        for (int i = 0; i < N; i++) {
            Batch b = mAlarmBatches.get(i);
            if (b.isRtcPowerOffWakeup()) {
            long intervalTime  = b.start - SystemClock.elapsedRealtime();
            if (b.isRtcPowerOffWakeup() && intervalTime > POWER_OFF_ALARM_THRESHOLD) {
                return b;
            }
        }