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

Commit bbe5fdf8 authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Do not allow registration of null callbacks

Some client is registering null callbacks and causing NPE.
Let's crash earilier to figure out what's causing the behavior.

Fixes: 128895449
Test: start systemui, stop systemui
Test: all sysui tests and boot health tests still pass
Change-Id: I8caafc980c2dde0f9187fbd6205dbd2027233e60
parent 2e5dd8cf
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -16,9 +16,11 @@

package com.android.systemui.statusbar.policy;

import android.annotation.NonNull;
import android.app.ActivityManager;
import android.content.Context;

import com.android.internal.util.Preconditions;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.systemui.settings.CurrentUserTracker;
@@ -69,7 +71,8 @@ public class KeyguardMonitorImpl extends KeyguardUpdateMonitorCallback
    }

    @Override
    public void addCallback(Callback callback) {
    public void addCallback(@NonNull Callback callback) {
        Preconditions.checkNotNull(callback, "Callback must not be null. b/128895449");
        mCallbacks.add(callback);
        if (mCallbacks.size() != 0 && !mListening) {
            mListening = true;
@@ -81,7 +84,8 @@ public class KeyguardMonitorImpl extends KeyguardUpdateMonitorCallback
    }

    @Override
    public void removeCallback(Callback callback) {
    public void removeCallback(@NonNull Callback callback) {
        Preconditions.checkNotNull(callback, "Callback must not be null. b/128895449");
        if (mCallbacks.remove(callback) && mCallbacks.size() == 0 && mListening) {
            mListening = false;
            mKeyguardUpdateMonitor.removeCallback(this);