Loading src/java/com/android/internal/telephony/BlockChecker.java +25 −2 Original line number Original line Diff line number Diff line package com.android.internal.telephony; package com.android.internal.telephony; import android.content.Context; import android.content.Context; import android.os.Bundle; import android.provider.BlockedNumberContract; import android.provider.BlockedNumberContract; import android.telephony.Rlog; import android.telephony.Rlog; Loading @@ -12,18 +13,40 @@ public class BlockChecker { private static final boolean VDBG = false; // STOPSHIP if true. 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> * <p> * This method catches all underlying exceptions to ensure that this method never throws any * This method catches all underlying exceptions to ensure that this method never throws any * exception. * exception. * <p> * @deprecated use {@link #isBlocked(Context, String, Bundle)} instead. * * @param context the context of the caller. * @param phoneNumber the number to check. * @return {@code true} if the number is blocked. {@code false} otherwise. */ */ @Deprecated public static boolean isBlocked(Context context, String phoneNumber) { public static boolean isBlocked(Context context, String phoneNumber) { return isBlocked(context, phoneNumber, null /* extras */); } /** * 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, Bundle extras) { boolean isBlocked = false; boolean isBlocked = false; long startTimeNano = System.nanoTime(); long startTimeNano = System.nanoTime(); try { try { if (BlockedNumberContract.SystemContract.shouldSystemBlockNumber( if (BlockedNumberContract.SystemContract.shouldSystemBlockNumber( context, phoneNumber)) { context, phoneNumber, extras)) { Rlog.d(TAG, phoneNumber + " is blocked."); Rlog.d(TAG, phoneNumber + " is blocked."); isBlocked = true; isBlocked = true; } } Loading src/java/com/android/internal/telephony/InboundSmsHandler.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -762,7 +762,7 @@ public abstract class InboundSmsHandler extends StateMachine { if (messageCount == 1) { if (messageCount == 1) { // single-part message // single-part message pdus = new byte[][]{tracker.getPdu()}; pdus = new byte[][]{tracker.getPdu()}; block = BlockChecker.isBlocked(mContext, tracker.getDisplayAddress()); block = BlockChecker.isBlocked(mContext, tracker.getDisplayAddress(), null); } else { } else { // multi-part message // multi-part message Cursor cursor = null; Cursor cursor = null; Loading Loading @@ -819,7 +819,7 @@ public abstract class InboundSmsHandler extends StateMachine { // could be used for block checking purpose. // could be used for block checking purpose. block = BlockChecker.isBlocked(mContext, block = BlockChecker.isBlocked(mContext, cursor.getString(PDU_SEQUENCE_PORT_PROJECTION_INDEX_MAPPING cursor.getString(PDU_SEQUENCE_PORT_PROJECTION_INDEX_MAPPING .get(DISPLAY_ADDRESS_COLUMN))); .get(DISPLAY_ADDRESS_COLUMN)), null); } } } } } catch (SQLException e) { } catch (SQLException e) { Loading src/java/com/android/internal/telephony/WapPushOverSms.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -270,7 +270,7 @@ public class WapPushOverSms implements ServiceConnection { if (parsedPdu != null && parsedPdu.getMessageType() == MESSAGE_TYPE_NOTIFICATION_IND) { if (parsedPdu != null && parsedPdu.getMessageType() == MESSAGE_TYPE_NOTIFICATION_IND) { final NotificationInd nInd = (NotificationInd) parsedPdu; final NotificationInd nInd = (NotificationInd) parsedPdu; if (nInd.getFrom() != null if (nInd.getFrom() != null && BlockChecker.isBlocked(mContext, nInd.getFrom().getString())) { && BlockChecker.isBlocked(mContext, nInd.getFrom().getString(), null)) { result.statusCode = Intents.RESULT_SMS_HANDLED; result.statusCode = Intents.RESULT_SMS_HANDLED; return result; return result; } } Loading Loading
src/java/com/android/internal/telephony/BlockChecker.java +25 −2 Original line number Original line Diff line number Diff line package com.android.internal.telephony; package com.android.internal.telephony; import android.content.Context; import android.content.Context; import android.os.Bundle; import android.provider.BlockedNumberContract; import android.provider.BlockedNumberContract; import android.telephony.Rlog; import android.telephony.Rlog; Loading @@ -12,18 +13,40 @@ public class BlockChecker { private static final boolean VDBG = false; // STOPSHIP if true. 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> * <p> * This method catches all underlying exceptions to ensure that this method never throws any * This method catches all underlying exceptions to ensure that this method never throws any * exception. * exception. * <p> * @deprecated use {@link #isBlocked(Context, String, Bundle)} instead. * * @param context the context of the caller. * @param phoneNumber the number to check. * @return {@code true} if the number is blocked. {@code false} otherwise. */ */ @Deprecated public static boolean isBlocked(Context context, String phoneNumber) { public static boolean isBlocked(Context context, String phoneNumber) { return isBlocked(context, phoneNumber, null /* extras */); } /** * 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, Bundle extras) { boolean isBlocked = false; boolean isBlocked = false; long startTimeNano = System.nanoTime(); long startTimeNano = System.nanoTime(); try { try { if (BlockedNumberContract.SystemContract.shouldSystemBlockNumber( if (BlockedNumberContract.SystemContract.shouldSystemBlockNumber( context, phoneNumber)) { context, phoneNumber, extras)) { Rlog.d(TAG, phoneNumber + " is blocked."); Rlog.d(TAG, phoneNumber + " is blocked."); isBlocked = true; isBlocked = true; } } Loading
src/java/com/android/internal/telephony/InboundSmsHandler.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -762,7 +762,7 @@ public abstract class InboundSmsHandler extends StateMachine { if (messageCount == 1) { if (messageCount == 1) { // single-part message // single-part message pdus = new byte[][]{tracker.getPdu()}; pdus = new byte[][]{tracker.getPdu()}; block = BlockChecker.isBlocked(mContext, tracker.getDisplayAddress()); block = BlockChecker.isBlocked(mContext, tracker.getDisplayAddress(), null); } else { } else { // multi-part message // multi-part message Cursor cursor = null; Cursor cursor = null; Loading Loading @@ -819,7 +819,7 @@ public abstract class InboundSmsHandler extends StateMachine { // could be used for block checking purpose. // could be used for block checking purpose. block = BlockChecker.isBlocked(mContext, block = BlockChecker.isBlocked(mContext, cursor.getString(PDU_SEQUENCE_PORT_PROJECTION_INDEX_MAPPING cursor.getString(PDU_SEQUENCE_PORT_PROJECTION_INDEX_MAPPING .get(DISPLAY_ADDRESS_COLUMN))); .get(DISPLAY_ADDRESS_COLUMN)), null); } } } } } catch (SQLException e) { } catch (SQLException e) { Loading
src/java/com/android/internal/telephony/WapPushOverSms.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -270,7 +270,7 @@ public class WapPushOverSms implements ServiceConnection { if (parsedPdu != null && parsedPdu.getMessageType() == MESSAGE_TYPE_NOTIFICATION_IND) { if (parsedPdu != null && parsedPdu.getMessageType() == MESSAGE_TYPE_NOTIFICATION_IND) { final NotificationInd nInd = (NotificationInd) parsedPdu; final NotificationInd nInd = (NotificationInd) parsedPdu; if (nInd.getFrom() != null if (nInd.getFrom() != null && BlockChecker.isBlocked(mContext, nInd.getFrom().getString())) { && BlockChecker.isBlocked(mContext, nInd.getFrom().getString(), null)) { result.statusCode = Intents.RESULT_SMS_HANDLED; result.statusCode = Intents.RESULT_SMS_HANDLED; return result; return result; } } Loading