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

Commit a95ceff6 authored by Tyler Gunn's avatar Tyler Gunn Committed by Gerrit Code Review
Browse files

Merge "Support enhanced call blocking function"

parents 94a35fce d7885b83
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
package com.android.internal.telephony;

import android.content.Context;
import android.os.Bundle;
import android.provider.BlockedNumberContract;
import android.telephony.Rlog;

@@ -12,18 +13,23 @@ public class BlockChecker {
    private static final boolean VDBG = false; // STOPSHIP if true.

    /**
     * Returns {@code true} if {@code phoneNumber} is blocked.
     * Returns {@code true} if {@code phoneNumber} is blocked according to {@code extras}.
     * <p>
     * This method catches all underlying exceptions to ensure that this method never throws any
     * exception.
     *
     * @param context the context of the caller.
     * @param phoneNumber the number to check.
     * @param extras the extra attribute of the number.
     * @return {@code true} if the number is blocked. {@code false} otherwise.
     */
    public static boolean isBlocked(Context context, String phoneNumber) {
    public static boolean isBlocked(Context context, String phoneNumber, Bundle extras) {
        boolean isBlocked = false;
        long startTimeNano = System.nanoTime();

        try {
            if (BlockedNumberContract.SystemContract.shouldSystemBlockNumber(
                    context, phoneNumber)) {
                    context, phoneNumber, extras)) {
                Rlog.d(TAG, phoneNumber + " is blocked.");
                isBlocked = true;
            }
+2 −2
Original line number Diff line number Diff line
@@ -762,7 +762,7 @@ public abstract class InboundSmsHandler extends StateMachine {
        if (messageCount == 1) {
            // single-part message
            pdus = new byte[][]{tracker.getPdu()};
            block = BlockChecker.isBlocked(mContext, tracker.getDisplayAddress());
            block = BlockChecker.isBlocked(mContext, tracker.getDisplayAddress(), null);
        } else {
            // multi-part message
            Cursor cursor = null;
@@ -819,7 +819,7 @@ public abstract class InboundSmsHandler extends StateMachine {
                        // could be used for block checking purpose.
                        block = BlockChecker.isBlocked(mContext,
                                cursor.getString(PDU_SEQUENCE_PORT_PROJECTION_INDEX_MAPPING
                                        .get(DISPLAY_ADDRESS_COLUMN)));
                                        .get(DISPLAY_ADDRESS_COLUMN)), null);
                    }
                }
            } catch (SQLException e) {
+1 −1
Original line number Diff line number Diff line
@@ -270,7 +270,7 @@ public class WapPushOverSms implements ServiceConnection {
            if (parsedPdu != null && parsedPdu.getMessageType() == MESSAGE_TYPE_NOTIFICATION_IND) {
                final NotificationInd nInd = (NotificationInd) parsedPdu;
                if (nInd.getFrom() != null
                        && BlockChecker.isBlocked(mContext, nInd.getFrom().getString())) {
                        && BlockChecker.isBlocked(mContext, nInd.getFrom().getString(), null)) {
                    result.statusCode = Intents.RESULT_SMS_HANDLED;
                    return result;
                }