Java Code Examples for android.app.AlarmManager#FLAG_STANDALONE

The following examples show how to use android.app.AlarmManager#FLAG_STANDALONE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AlarmManagerService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private void insertAndBatchAlarmLocked(Alarm alarm) {
    final int whichBatch = ((alarm.flags & AlarmManager.FLAG_STANDALONE) != 0) ? -1
            : attemptCoalesceLocked(alarm.whenElapsed, alarm.maxWhenElapsed);

    if (whichBatch < 0) {
        addBatchLocked(mAlarmBatches, new Batch(alarm));
    } else {
        final Batch batch = mAlarmBatches.get(whichBatch);
        if (batch.add(alarm)) {
            // The start time of this batch advanced, so batch ordering may
            // have just been broken.  Move it to where it now belongs.
            mAlarmBatches.remove(whichBatch);
            addBatchLocked(mAlarmBatches, batch);
        }
    }
}
 
Example 2
Source File: AlarmManagerService.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
int attemptCoalesceLocked(long whenElapsed, long maxWhen) {
    final int N = mAlarmBatches.size();
    for (int i = 0; i < N; i++) {
        Batch b = mAlarmBatches.get(i);
        if ((b.flags&AlarmManager.FLAG_STANDALONE) == 0 && b.canHold(whenElapsed, maxWhen)) {
            return i;
        }
    }
    return -1;
}