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

Commit 335a32dc authored by Linux Build Service Account's avatar Linux Build Service Account
Browse files

Promotion of android_ui.lnx.2.1-00009.

CRs      Change ID                                   Subject
--------------------------------------------------------------------------------------------------------------
1063853   I18325e04432c0172dee4541b073067bc75d744a2   Start alarm when boot is complete

Change-Id: I492c282f0fab5311eb89663ac44fb45b5aaa9a54
CRs-Fixed: 1063853
parents 49c37331 cffe7c04
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -125,8 +125,8 @@ public class AlarmInitReceiver extends BroadcastReceiver {
        //     1. Normal mode: just get next firing alarm and pass it to alarm activity
        //     2. Encryption mode: We need to create an alarm as there is no firing alarm
        //        in this mode.
        if (ACTION_POWER_OFF_ALARM.equals(action)) {
            AlarmInstance instance = AlarmStateManager.getNextFiringAlarm(context);
        if (Intent.ACTION_BOOT_COMPLETED.equals(action) && isAlarmBoot) {
            AlarmInstance instance = AlarmInstance.getFirstAlarmInstance(cr);
            String cryptState = SystemProperties.get(DECRYPT_PROP);
            if (instance == null && (ENCRYPTING_STATE.equals(cryptState) ||
                    ENCRYPTED_STATE.equals(cryptState))) {
+28 −0
Original line number Diff line number Diff line
@@ -284,6 +284,34 @@ public final class AlarmInstance implements ClockContract.InstancesColumns {
        }
    }

    /**
     * Get first alarm instance of power off alarm which is the closest missed alarm.
     *
     * @param contentResolver to access the content provider
     */
    public static AlarmInstance getFirstAlarmInstance(ContentResolver contentResolver) {
        List<AlarmInstance> alertAlarms = getInstances(contentResolver, null);
        long currentTime = System.currentTimeMillis();

        AlarmInstance firstAlarm = null;
        long closestMissAlarmElapse = 0;

        for (AlarmInstance ai : alertAlarms) {
            long time = currentTime - ai.getAlarmTime().getTimeInMillis();

            if (time < 0) {
                continue;
            }

            if (firstAlarm == null || closestMissAlarmElapse > time) {
                firstAlarm = ai;
                closestMissAlarmElapse = time;
            }
        }

        return firstAlarm;
    }

    // Public fields
    public long mId;
    public int mYear;