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

Commit bb76a6ce authored by Christopher Tate's avatar Christopher Tate
Browse files

Relax null parameter enforcement for legacy apps

No longer throws when calling cancel() with a null PendingIntent if
the app targets SDK < NYC.

Bug 25798631

Change-Id: Ic91f42808811645b01802abcc785f4218aac0e8b
parent ec741671
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import android.os.Handler;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.SystemClock;
import android.os.UserHandle;
import android.os.WorkSource;
import android.text.TextUtils;
@@ -869,13 +868,19 @@ public class AlarmManager {
     * {@link Intent#filterEquals}), will be canceled.
     *
     * @param operation IntentSender which matches a previously added
     * IntentSender.
     * IntentSender. This parameter must not be {@code null}.
     *
     * @see #set
     */
    public void cancel(PendingIntent operation) {
        if (operation == null) {
            throw new NullPointerException("operation");
            final String msg = "cancel() called with a null PendingIntent";
            if (mTargetSdkVersion >= Build.VERSION_CODES.N) {
                throw new NullPointerException(msg);
            } else {
                Log.e(TAG, msg);
                return;
            }
        }

        try {
@@ -891,7 +896,7 @@ public class AlarmManager {
     */
    public void cancel(OnAlarmListener listener) {
        if (listener == null) {
            throw new NullPointerException("listener");
            throw new NullPointerException("cancel() called with a null OnAlarmListener");
        }

        ListenerWrapper wrapper = null;