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

Commit 2841e0af authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "If you set an alarm before the epoch, you're gonna have a bad time"

parents 6d64d5ab 5f221e8f
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -257,6 +257,14 @@ public class AlarmManager

    private void setImpl(int type, long triggerAtMillis, long windowMillis, long intervalMillis,
            PendingIntent operation) {
        if (triggerAtMillis < 0) {
            if (mAlwaysExact) {
                // Fatal error for KLP+ apps to use negative trigger times
                throw new IllegalArgumentException("Invalid alarm trigger time "
                        + triggerAtMillis);
            }
            triggerAtMillis = 0;
        }
        try {
            mService.set(type, triggerAtMillis, windowMillis, intervalMillis, operation);
        } catch (RemoteException ex) {
+16 −2
Original line number Diff line number Diff line
@@ -521,6 +521,14 @@ class AlarmManagerService extends IAlarmManager.Stub {
            throw new IllegalArgumentException("Invalid alarm type " + type);
        }

        if (triggerAtTime < 0) {
            final long who = Binder.getCallingUid();
            final long what = Binder.getCallingPid();
            Slog.w(TAG, "Invalid alarm trigger time! " + triggerAtTime + " from uid=" + who
                    + " pid=" + what);
            triggerAtTime = 0;
        }

        final long nowElapsed = SystemClock.elapsedRealtime();
        final long triggerElapsed = convertToElapsed(triggerAtTime, type);
        final long maxElapsed;
@@ -567,7 +575,12 @@ class AlarmManagerService extends IAlarmManager.Stub {
        }

        if (DEBUG_VALIDATE) {
            if (doValidate && validateConsistencyLocked()) {
            if (doValidate && !validateConsistencyLocked()) {
                Slog.v(TAG, "Tipping-point operation: type=" + type + " when=" + when
                        + " when(hex)=" + Long.toHexString(when)
                        + " whenElapsed=" + whenElapsed + " maxWhen=" + maxWhen
                        + " interval=" + interval + " op=" + operation
                        + " standalone=" + isStandalone);
                rebatchAllAlarmsLocked(false);
                reschedule = true;
            }
@@ -586,8 +599,9 @@ class AlarmManagerService extends IAlarmManager.Stub {
        final int NZ = mAlarmBatches.size();
        for (int iz = 0; iz < NZ; iz++) {
            Batch bz = mAlarmBatches.get(iz);
            Slog.v(TAG, "Batch " + iz + ": " + bz);
            pw.append("Batch "); pw.print(iz); pw.append(": "); pw.println(bz);
            dumpAlarmList(pw, bz.alarms, "  ", nowELAPSED, nowRTC);
            pw.flush();
            Slog.v(TAG, bs.toString());
            bs.reset();
        }