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

Commit 53d95015 authored by Pawit Pornkitprasan's avatar Pawit Pornkitprasan Committed by Jessica Wagantall
Browse files

Blacklist: fix NPE

getCallerInfo() can be null if the caller info is being
asynchronously read. Use a different method to get the phone number.

Change-Id: I4b77552a3e3cddd6d3fc9ba8e13721d7431f6141
(cherry picked from commit 0343fed4)
parent 6ee0d233
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -468,6 +468,13 @@ final class Call implements CreateConnectionResponse {
        return mCallerInfo == null ? null : mCallerInfo.name;
    }

    String getNumber() {
        if (mCallerInfo != null) {
            return mCallerInfo.phoneNumber;
        }
        return mHandle == null ? null : mHandle.getSchemeSpecificPart();
    }

    Bitmap getPhotoIcon() {
        return mCallerInfo == null ? null : mCallerInfo.cachedPhotoIcon;
    }
+5 −2
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ import android.telecom.TelecomManager;
import android.telephony.TelephonyManager;

import com.android.internal.telephony.CallStateException;
import com.android.internal.telephony.CallerInfo;
import com.android.internal.telephony.Connection;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.TelephonyProperties;
@@ -2016,7 +2015,11 @@ public final class CallsManager extends Call.ListenerBase {
    }

    protected boolean isCallBlacklisted(Call c) {
        final String number = c.getCallerInfo().phoneNumber;
        final String number = c.getNumber();
        if (number == null) {
            return false;
        }

        // See if the number is in the blacklist
        // Result is one of: MATCH_NONE, MATCH_LIST or MATCH_REGEX
        int listType = BlacklistUtils.isListed(mContext, number, BlacklistUtils.BLOCK_CALLS);