Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/java/android/provider/Telephony.java b/src/java/android/provider/Telephony.java
- index df328b7..bc9d415 100755
- --- a/src/java/android/provider/Telephony.java
- +++ b/src/java/android/provider/Telephony.java
- @@ -35,10 +35,8 @@ import android.util.Patterns;
- import com.android.internal.telephony.PhoneConstants;
- import com.android.internal.telephony.SmsApplication;
- -import java.util.ArrayList;
- -import java.util.Arrays;
- +
- import java.util.HashSet;
- -import java.util.List;
- import java.util.Set;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- @@ -843,51 +841,6 @@ public final class Telephony {
- public static final int RESULT_SMS_DUPLICATED = 5;
- /**
- - * Used internally: The sender of the SMS was blacklisted
- - * for not being listed in the contact list
- - * @hide
- - */
- - public static final int RESULT_SMS_BLACKLISTED_UNKNOWN = 6;
- -
- - /**
- - * Used internally: The sender of the SMS was blacklisted
- - * for being listed in the blacklist
- - * @hide
- - */
- - public static final int RESULT_SMS_BLACKLISTED_LIST = 7;
- -
- - /**
- - * Used internally: The sender of the SMS was blacklisted
- - * for matching a blacklist regex entry
- - * @hide
- - */
- - public static final int RESULT_SMS_BLACKLISTED_REGEX = 8;
- -
- - /**
- - * Used internally:
- - * Broadcast Action: A new protected text-based SMS message has been received
- - * by the device. This intent will be delivered to all registered
- - * receivers who possess {@link android.Manifest.permission#RECEIVE_PROTECTED_SMS}.
- - * These apps SHOULD NOT write the message or notify the user.
- - * The intent will have the following extra values:
- - * </p>
- - *
- - * <ul>
- - * <li><em>"pdus"</em> - An Object[] of byte[]s containing the PDUs
- - * that make up the message.</li>
- - * </ul>
- - *
- - * <p>The extra values can be extracted using
- - * {@link #getMessagesFromIntent(Intent)}.</p>
- - *
- - * <p>If a BroadcastReceiver encounters an error while processing
- - * this intent it should set the result code appropriately.</p>
- - * @hide
- - */
- - public static final String PROTECTED_SMS_RECEIVED_ACTION =
- - "android.provider.Telephony.ACTION_PROTECTED_SMS_RECEIVED";
- -
- - /**
- * Activity action: Ask the user to change the default
- * SMS application. This will show a dialog that asks the
- * user whether they want to replace the current default
- @@ -1253,61 +1206,6 @@ public final class Telephony {
- }
- return msgs;
- }
- -
- - /**
- - * Read the normalized addresses out of PDUs
- - * @param pdus bytes for PDUs
- - * @param format the format of the message
- - * @return a list of Addresses for the PDUs
- - * @hide
- - */
- - public static List<String> getNormalizedAddressesFromPdus(byte[][] pdus,
- - String format) {
- - int pduCount = pdus.length;
- - SmsMessage[] msgs = new SmsMessage[pduCount];
- - List<String> addresses = new ArrayList<String>();
- -
- - for (int i = 0; i < pduCount; i++) {
- - byte[] pdu = (byte[]) pdus[i];
- - msgs[i] = SmsMessage.createFromPdu(pdu, format);
- - // If the originating address is null on our message
- - // then the format for SmsMessage createFromPdu is likely
- - // incorrect. SmsMessage createFromPdu(the new method)
- - // takes in a format parameter that it gets from the Tracker
- - // however, on some of our legacy devices using a legacy ril,
- - // since that format is derived by getting voice tech,
- - // we can get a bad format and no valid members.
- - // Thus we introduce a hack that utilizes the deprecated
- - // SmsMessage.createFromPdu if we get a null originating address.
- - if (msgs[i].getOriginatingAddress() == null) {
- - msgs[i] = SmsMessage.createFromPdu(pdu);
- - }
- - String originatingAddress = msgs[i].getOriginatingAddress();
- - if (!TextUtils.isEmpty(originatingAddress)) {
- - String normalized = normalizeDigitsOnly(originatingAddress);
- - addresses.add(normalized);
- - }
- - }
- - return addresses;
- - }
- -
- - private static String normalizeDigitsOnly(String number) {
- - return normalizeDigits(number, false /* strip non-digits */).toString();
- - }
- -
- - private static StringBuilder normalizeDigits(String number, boolean keepNonDigits) {
- - StringBuilder normalizedDigits = new StringBuilder(number.length());
- - for (char c : number.toCharArray()) {
- - int digit = Character.digit(c, 10);
- - if (digit != -1) {
- - normalizedDigits.append(digit);
- - } else if (keepNonDigits) {
- - normalizedDigits.append(c);
- - }
- - }
- - return normalizedDigits;
- - }
- -
- }
- }
- @@ -3180,76 +3078,4 @@ public final class Telephony {
- CMAS_CERTAINTY
- };
- }
- -
- - /**
- - * Contains phone numbers that are blacklisted
- - * for phone and/or message purposes.
- - * @hide
- - */
- - public static final class Blacklist implements BaseColumns {
- - /**
- - * The content:// style URL for this table
- - */
- - public static final Uri CONTENT_URI =
- -
- - Uri.parse("content://blacklist");
- -
- - /**
- - * The content:// style URL for filtering this table by number.
- - * When using this, make sure the number is correctly encoded
- - * when appended to the Uri.
- - */
- - public static final Uri CONTENT_FILTER_BYNUMBER_URI =
- - Uri.parse("content://blacklist/bynumber");
- -
- - /**
- - * The content:// style URL for filtering this table on phone numbers
- - */
- - public static final Uri CONTENT_PHONE_URI =
- - Uri.parse("content://blacklist/phone");
- -
- - /**
- - * The content:// style URL for filtering this table on message numbers
- - */
- - public static final Uri CONTENT_MESSAGE_URI =
- - Uri.parse("content://blacklist/message");
- -
- -
- - /**
- - * Query parameter used to match numbers by regular-expression like
- - * matching. Supported are the '*' and the '.' operators.
- - * <p>
- - * TYPE: boolean
- - */
- - public static final String REGEX_KEY = "regex";
- -
- - /**
- - * The default sort order for this table
- - */
- - public static final String DEFAULT_SORT_ORDER = "number ASC";
- -
- - /**
- - * The phone number as the user entered it.
- - * <P>Type: TEXT</P>
- - */
- - public static final String NUMBER = "number";
- -
- - /**
- - * Whether the number contains a regular expression pattern
- - * <P>Type: BOOLEAN (read only)</P>
- - */
- - public static final String IS_REGEX = "is_regex";
- -
- - /**
- - * Blacklisting mode for phone calls
- - * <P>Type: INTEGER (int)</P>
- - */
- - public static final String PHONE_MODE = "phone";
- -
- - /**
- - * Blacklisting mode for messages
- - * <P>Type: INTEGER (int)</P>
- - */
- - public static final String MESSAGE_MODE = "message";
- - }
- }
- diff --git a/src/java/android/telephony/SmsMessage.java b/src/java/android/telephony/SmsMessage.java
- index 11a7371..dd80fbb 100644
- --- a/src/java/android/telephony/SmsMessage.java
- +++ b/src/java/android/telephony/SmsMessage.java
- @@ -94,12 +94,6 @@ public class SmsMessage {
- */
- public static final String FORMAT_3GPP2 = "3gpp2";
- - /**
- - * Indicates a synthetic SMS message.
- - * @hide
- - */
- - public static final String FORMAT_SYNTHETIC = "synthetic";
- -
- /** Contains actual SmsMessage. Only public for debugging and for framework layer.
- *
- * @hide
- @@ -175,9 +169,6 @@ public class SmsMessage {
- int activePhone = TelephonyManager.getDefault().getCurrentPhoneType();
- String format = (PHONE_TYPE_CDMA == activePhone) ?
- SmsConstants.FORMAT_3GPP2 : SmsConstants.FORMAT_3GPP;
- - if (com.android.internal.telephony.SyntheticSmsMessage.isSyntheticPdu(pdu)) {
- - format = FORMAT_SYNTHETIC;
- - }
- message = createFromPdu(pdu, format);
- if (null == message || null == message.mWrappedSmsMessage) {
- @@ -206,8 +197,6 @@ public class SmsMessage {
- wrappedMessage = com.android.internal.telephony.cdma.SmsMessage.createFromPdu(pdu);
- } else if (SmsConstants.FORMAT_3GPP.equals(format)) {
- wrappedMessage = com.android.internal.telephony.gsm.SmsMessage.createFromPdu(pdu);
- - } else if (FORMAT_SYNTHETIC.equals(format)) {
- - wrappedMessage = com.android.internal.telephony.SyntheticSmsMessage.createFromPdu(pdu);
- } else {
- Rlog.e(LOG_TAG, "createFromPdu(): unsupported message format " + format);
- return null;
- @@ -568,7 +557,7 @@ public class SmsMessage {
- * form or null if unavailable
- */
- public String getOriginatingAddress() {
- - return mWrappedSmsMessage != null ? mWrappedSmsMessage.getOriginatingAddress() : null;
- + return mWrappedSmsMessage.getOriginatingAddress();
- }
- /**
- diff --git a/src/java/android/telephony/gsm/SmsMessage.java b/src/java/android/telephony/gsm/SmsMessage.java
- index f42eb2f..8d5dac7 100644
- --- a/src/java/android/telephony/gsm/SmsMessage.java
- +++ b/src/java/android/telephony/gsm/SmsMessage.java
- @@ -158,14 +158,6 @@ public class SmsMessage {
- wrappedMessage = com.android.internal.telephony.gsm.SmsMessage.createFromPdu(pdu);
- }
- - // Hangouts, and some other bad citizens, are using this deprecated API call.
- - // Make sure that WhisperPush and Voice+ integration properly work,
- - // as this may be a synthetic message.
- - if (wrappedMessage == null) {
- - // returns null if it is not synthetic. (likely malformed)
- - wrappedMessage = com.android.internal.telephony.SyntheticSmsMessage.createFromPdu(pdu);
- - }
- -
- return new SmsMessage(wrappedMessage);
- }
- diff --git a/src/java/com/android/internal/telephony/IccSmsInterfaceManager.java b/src/java/com/android/internal/telephony/IccSmsInterfaceManager.java
- index 26fd296..7432662 100644
- --- a/src/java/com/android/internal/telephony/IccSmsInterfaceManager.java
- +++ b/src/java/com/android/internal/telephony/IccSmsInterfaceManager.java
- @@ -24,9 +24,8 @@ import android.content.Context;
- import android.database.Cursor;
- import android.database.sqlite.SQLiteException;
- import android.net.Uri;
- -import android.os.Binder;
- -import android.os.RemoteException;
- import android.os.AsyncResult;
- +import android.os.Binder;
- import android.os.Handler;
- import android.os.Message;
- import android.os.UserManager;
- @@ -34,7 +33,6 @@ import android.provider.Telephony;
- import android.telephony.Rlog;
- import android.telephony.SmsManager;
- import android.telephony.SmsMessage;
- -import android.telephony.TelephonyManager;
- import android.util.Log;
- import com.android.internal.telephony.gsm.SmsBroadcastConfigInfo;
- @@ -42,6 +40,7 @@ import com.android.internal.telephony.cdma.CdmaSmsBroadcastConfigInfo;
- import com.android.internal.telephony.uicc.IccConstants;
- import com.android.internal.telephony.uicc.IccFileHandler;
- import com.android.internal.telephony.uicc.UiccController;
- +import com.android.internal.telephony.SmsNumberUtils;
- import com.android.internal.telephony.uicc.IccRecords;
- import com.android.internal.util.HexDump;
- @@ -61,7 +60,7 @@ import android.telephony.TelephonyManager;
- */
- public class IccSmsInterfaceManager {
- static final String LOG_TAG = "IccSmsInterfaceManager";
- - static final boolean DBG = false;
- + static final boolean DBG = true;
- protected final Object mLock = new Object();
- protected boolean mSuccess;
- @@ -306,9 +305,6 @@ public class IccSmsInterfaceManager {
- return mSuccess;
- }
- - public void synthesizeMessages(String originatingAddress, String scAddress, List<String> messages, long timestampMillis) throws RemoteException {
- - }
- -
- /**
- * Retrieves all messages currently stored on Icc.
- *
- @@ -321,6 +317,10 @@ public class IccSmsInterfaceManager {
- mContext.enforceCallingOrSelfPermission(
- Manifest.permission.RECEIVE_SMS,
- "Reading messages from Icc");
- + if (mAppOps.noteOp(AppOpsManager.OP_READ_ICC_SMS, Binder.getCallingUid(),
- + callingPackage) != AppOpsManager.MODE_ALLOWED) {
- + return new ArrayList<SmsRawData>();
- + }
- synchronized(mLock) {
- IccFileHandler fh = mPhone.getIccFileHandler();
- @@ -462,32 +462,16 @@ public class IccSmsInterfaceManager {
- public void sendText(String callingPackage, String destAddr, String scAddr,
- String text, PendingIntent sentIntent, PendingIntent deliveryIntent) {
- - int callingUid = Binder.getCallingUid();
- -
- - String[] callingParts = callingPackage.split("\\\\");
- - if (callingUid == android.os.Process.PHONE_UID &&
- - callingParts.length > 1) {
- - callingUid = Integer.parseInt(callingParts[1]);
- - }
- -
- - // Reset the calling package, remove the trailing uid so
- - // shouldWriteMessageForPackage can match correctly
- - // if our message has been synthesized by an
- - // external package
- - callingPackage = callingParts[0];
- -
- - if (Binder.getCallingPid() != android.os.Process.myPid()) {
- - mPhone.getContext().enforceCallingPermission(
- - Manifest.permission.SEND_SMS,
- - "Sending SMS message");
- - }
- + mPhone.getContext().enforceCallingPermission(
- + Manifest.permission.SEND_SMS,
- + "Sending SMS message");
- if (Rlog.isLoggable("SMS", Log.VERBOSE)) {
- log("sendText: destAddr=" + destAddr + " scAddr=" + scAddr +
- " text='"+ text + "' sentIntent=" +
- sentIntent + " deliveryIntent=" + deliveryIntent);
- }
- - if (mAppOps.noteOp(AppOpsManager.OP_SEND_SMS, callingUid,
- - callingParts[0]) != AppOpsManager.MODE_ALLOWED) {
- + if (mAppOps.noteOp(AppOpsManager.OP_SEND_SMS, Binder.getCallingUid(),
- + callingPackage) != AppOpsManager.MODE_ALLOWED) {
- return;
- }
- destAddr = filterDestAddress(destAddr);
- @@ -607,25 +591,9 @@ public class IccSmsInterfaceManager {
- public void sendMultipartText(String callingPackage, String destAddr, String scAddr,
- List<String> parts, List<PendingIntent> sentIntents,
- List<PendingIntent> deliveryIntents) {
- - int callingUid = Binder.getCallingUid();
- -
- - String[] callingParts = callingPackage.split("\\\\");
- - if (callingUid == android.os.Process.PHONE_UID &&
- - callingParts.length > 1) {
- - callingUid = Integer.parseInt(callingParts[1]);
- - }
- -
- - // Reset the calling package, remove the trailing uid so
- - // shouldWriteMessageForPackage can match correctly
- - // if our message has been synthesized by an
- - // external package
- - callingPackage = callingParts[0];
- -
- - if (Binder.getCallingPid() != android.os.Process.myPid()) {
- - mPhone.getContext().enforceCallingPermission(
- - Manifest.permission.SEND_SMS,
- - "Sending SMS message");
- - }
- + mPhone.getContext().enforceCallingPermission(
- + Manifest.permission.SEND_SMS,
- + "Sending SMS message");
- if (Rlog.isLoggable("SMS", Log.VERBOSE)) {
- int i = 0;
- for (String part : parts) {
- @@ -633,8 +601,8 @@ public class IccSmsInterfaceManager {
- ", part[" + (i++) + "]=" + part);
- }
- }
- - if (mAppOps.noteOp(AppOpsManager.OP_SEND_SMS, callingUid,
- - callingParts[0]) != AppOpsManager.MODE_ALLOWED) {
- + if (mAppOps.noteOp(AppOpsManager.OP_SEND_SMS, Binder.getCallingUid(),
- + callingPackage) != AppOpsManager.MODE_ALLOWED) {
- return;
- }
- @@ -831,6 +799,7 @@ public class IccSmsInterfaceManager {
- throw new IllegalArgumentException("Not a supportted RAN Type");
- }
- }
- +
- synchronized public boolean enableGsmBroadcastRange(int startMessageId, int endMessageId) {
- if (DBG) log("enableGsmBroadcastRange");
- @@ -1350,28 +1319,4 @@ public class IccSmsInterfaceManager {
- }
- return mSmscSuccess;
- }
- -
- - /** @hide **/
- - public boolean isShortSMSCode(String destAddr) {
- - TelephonyManager telephonyManager;
- - int smsCategory = SmsUsageMonitor.CATEGORY_NOT_SHORT_CODE;
- -
- - telephonyManager =(TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
- -
- - String countryIso = telephonyManager.getSimCountryIso();
- - if (countryIso == null || countryIso.length() != 2) {
- - countryIso = telephonyManager.getNetworkCountryIso();
- - }
- -
- - smsCategory = SmsUsageMonitor.mergeShortCodeCategories(smsCategory,
- - mPhone.mSmsUsageMonitor.checkDestination(destAddr, countryIso));
- -
- - if (smsCategory == SmsUsageMonitor.CATEGORY_NOT_SHORT_CODE
- - || smsCategory == SmsUsageMonitor.CATEGORY_FREE_SHORT_CODE
- - || smsCategory == SmsUsageMonitor.CATEGORY_STANDARD_SHORT_CODE) {
- - return false; // not a premium short code
- - }
- -
- - return true;
- - }
- }
- diff --git a/src/java/com/android/internal/telephony/InboundSmsHandler.java b/src/java/com/android/internal/telephony/InboundSmsHandler.java
- index f0b8788..653c06f 100644
- --- a/src/java/com/android/internal/telephony/InboundSmsHandler.java
- +++ b/src/java/com/android/internal/telephony/InboundSmsHandler.java
- @@ -49,7 +49,6 @@ import android.os.SystemProperties;
- import android.os.UserHandle;
- import android.os.UserManager;
- import android.preference.PreferenceManager;
- -import android.provider.Settings;
- import android.provider.Telephony;
- import android.provider.Telephony.Sms.Intents;
- import android.service.carrier.CarrierMessagingService;
- @@ -66,20 +65,14 @@ import android.text.TextUtils;
- import com.android.internal.telephony.uicc.UiccCard;
- import com.android.internal.telephony.uicc.UiccController;
- -import android.text.TextUtils;
- -import com.android.internal.telephony.util.BlacklistUtils;
- -import com.android.internal.telephony.PhoneBase;
- import com.android.internal.util.HexDump;
- import com.android.internal.util.State;
- import com.android.internal.util.StateMachine;
- import java.io.ByteArrayOutputStream;
- -import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.ArrayList;
- -import java.util.Collections;
- import java.util.List;
- -import java.util.Map;
- /**
- * This class broadcasts incoming SMS messages to interested apps after storing them in
- @@ -482,40 +475,20 @@ public abstract class InboundSmsHandler extends StateMachine {
- return;
- }
- - int result, blacklistMatchType = -1;
- - SmsMessage sms = null;
- -
- + int result;
- try {
- - sms = (SmsMessage) ar.result;
- + SmsMessage sms = (SmsMessage) ar.result;
- result = dispatchMessage(sms.mWrappedSmsMessage);
- } catch (RuntimeException ex) {
- loge("Exception dispatching message", ex);
- result = Intents.RESULT_SMS_GENERIC_ERROR;
- }
- - // Translate (internal) blacklist check results to
- - // RESULT_SMS_HANDLED + match type
- - switch (result) {
- - case Intents.RESULT_SMS_BLACKLISTED_UNKNOWN:
- - blacklistMatchType = BlacklistUtils.MATCH_UNKNOWN;
- - result = Intents.RESULT_SMS_HANDLED;
- - break;
- - case Intents.RESULT_SMS_BLACKLISTED_LIST:
- - blacklistMatchType = BlacklistUtils.MATCH_LIST;
- - result = Intents.RESULT_SMS_HANDLED;
- - break;
- - case Intents.RESULT_SMS_BLACKLISTED_REGEX:
- - blacklistMatchType = BlacklistUtils.MATCH_REGEX;
- - result = Intents.RESULT_SMS_HANDLED;
- - break;
- - }
- -
- -
- // RESULT_OK means that the SMS will be acknowledged by special handling,
- // e.g. for SMS-PP data download. Any other result, we should ack here.
- if (result != Activity.RESULT_OK) {
- boolean handled = (result == Intents.RESULT_SMS_HANDLED);
- - notifyAndAcknowledgeLastIncomingSms(handled, result, blacklistMatchType, sms, null);
- + notifyAndAcknowledgeLastIncomingSms(handled, result, null);
- }
- }
- @@ -609,26 +582,14 @@ public abstract class InboundSmsHandler extends StateMachine {
- * and send an acknowledge message to the network.
- * @param success indicates that last message was successfully received.
- * @param result result code indicating any error
- - * @param blacklistMatchType blacklist type if the message was blacklisted,
- - * -1 if it wasn't blacklisted
- - * @param sms incoming SMS
- * @param response callback message sent when operation completes.
- */
- void notifyAndAcknowledgeLastIncomingSms(boolean success,
- - int result, int blacklistMatchType, SmsMessage sms, Message response) {
- - if (!success || blacklistMatchType >= 0) {
- + int result, Message response) {
- + if (!success) {
- // broadcast SMS_REJECTED_ACTION intent
- Intent intent = new Intent(Intents.SMS_REJECTED_ACTION);
- intent.putExtra("result", result);
- - intent.putExtra("blacklisted", blacklistMatchType >= 0);
- - if (blacklistMatchType >= 0) {
- - intent.putExtra("blacklistMatchType", blacklistMatchType);
- - }
- - if (sms != null) {
- - intent.putExtra("sender", sms.getOriginatingAddress());
- - intent.putExtra("timestamp", sms.getTimestampMillis());
- - }
- - if (DBG) log("notifyAndAcknowledgeLastIncomingSms(): reject intent= " + intent);
- mContext.sendBroadcast(intent, android.Manifest.permission.RECEIVE_SMS);
- }
- acknowledgeLastIncomingSms(success, result, response);
- @@ -650,11 +611,6 @@ public abstract class InboundSmsHandler extends StateMachine {
- * @return {@link Intents#RESULT_SMS_HANDLED} if the message was accepted, or an error status
- */
- protected int dispatchNormalMessage(SmsMessageBase sms) {
- - int blacklistResult = checkIfBlacklisted(sms);
- - if (blacklistResult != Intents.RESULT_SMS_HANDLED) {
- - return blacklistResult;
- - }
- -
- SmsHeader smsHeader = sms.getUserDataHeader();
- InboundSmsTracker tracker;
- @@ -684,22 +640,6 @@ public abstract class InboundSmsHandler extends StateMachine {
- return addTrackerToRawTableAndSendMessage(tracker);
- }
- - private int checkIfBlacklisted(SmsMessageBase sms) {
- - int result = BlacklistUtils.isListed(mContext,
- - sms.getOriginatingAddress(), BlacklistUtils.BLOCK_MESSAGES);
- -
- - switch (result) {
- - case BlacklistUtils.MATCH_UNKNOWN:
- - return Intents.RESULT_SMS_BLACKLISTED_UNKNOWN;
- - case BlacklistUtils.MATCH_LIST:
- - return Intents.RESULT_SMS_BLACKLISTED_LIST;
- - case BlacklistUtils.MATCH_REGEX:
- - return Intents.RESULT_SMS_BLACKLISTED_REGEX;
- - }
- -
- - return Intents.RESULT_SMS_HANDLED;
- - }
- -
- /**
- * Helper to add the tracker to the raw table and then send a message to broadcast it, if
- * successful. Returns the SMS intent status to return to the SMSC.
- @@ -816,21 +756,6 @@ public abstract class InboundSmsHandler extends StateMachine {
- return (result == Activity.RESULT_OK);
- }
- - List<String> regAddresses = Settings.Secure.getDelimitedStringAsList(mContext.getContentResolver(),
- - Settings.Secure.PROTECTED_SMS_ADDRESSES , "|");
- -
- - List<String> allAddresses = Intents
- - .getNormalizedAddressesFromPdus(pdus, tracker.getFormat());
- -
- - if (!Collections.disjoint(regAddresses, allAddresses)) {
- - Intent intent = new Intent(Intents.PROTECTED_SMS_RECEIVED_ACTION);
- - intent.putExtra("pdus", pdus);
- - intent.putExtra("format", tracker.getFormat());
- - dispatchIntent(intent, android.Manifest.permission.RECEIVE_PROTECTED_SMS,
- - AppOpsManager.OP_RECEIVE_SMS, resultReceiver, UserHandle.OWNER);
- - return true;
- - }
- -
- List<String> carrierPackages = null;
- UiccCard card = UiccController.getInstance().getUiccCard(mPhone.getPhoneId());
- if (card != null) {
- diff --git a/src/java/com/android/internal/telephony/PhoneProxy.java b/src/java/com/android/internal/telephony/PhoneProxy.java
- index e7781be..59248f1 100644
- --- a/src/java/com/android/internal/telephony/PhoneProxy.java
- +++ b/src/java/com/android/internal/telephony/PhoneProxy.java
- @@ -96,8 +96,7 @@ public class PhoneProxy extends Handler implements Phone {
- mPhoneId = phone.getPhoneId();
- mIccSmsInterfaceManager =
- new IccSmsInterfaceManager((PhoneBase)this.mActivePhone);
- - mIccCardProxy = new IccCardProxy(mActivePhone.getContext(),
- - mCommandsInterface, mActivePhone.getPhoneId());
- + mIccCardProxy = new IccCardProxy(mActivePhone.getContext(), mCommandsInterface, mActivePhone.getPhoneId());
- if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM) {
- // For the purpose of IccCardProxy we only care about the technology family
- diff --git a/src/java/com/android/internal/telephony/ProxyController.java b/src/java/com/android/internal/telephony/ProxyController.java
- index ca9d35c..b25b983 100644
- --- a/src/java/com/android/internal/telephony/ProxyController.java
- +++ b/src/java/com/android/internal/telephony/ProxyController.java
- @@ -101,7 +101,7 @@ public class ProxyController {
- mDctController = DctController.makeDctController((PhoneProxy[])phoneProxy, t.getLooper());
- mUiccPhoneBookController = new UiccPhoneBookController(mProxyPhones);
- mPhoneSubInfoController = new PhoneSubInfoController(mProxyPhones);
- - mUiccSmsController = new UiccSmsController(mProxyPhones, context);
- + mUiccSmsController = new UiccSmsController(mProxyPhones);
- logd("Constructor - Exit");
- }
- diff --git a/src/java/com/android/internal/telephony/SMSDispatcher.java b/src/java/com/android/internal/telephony/SMSDispatcher.java
- index 0eff576..08cb115 100644
- --- a/src/java/com/android/internal/telephony/SMSDispatcher.java
- +++ b/src/java/com/android/internal/telephony/SMSDispatcher.java
- @@ -35,7 +35,6 @@ import android.os.AsyncResult;
- import android.os.Binder;
- import android.os.Handler;
- import android.os.Message;
- -import android.os.Process;
- import android.os.RemoteException;
- import android.os.SystemProperties;
- import android.provider.Settings;
- @@ -68,9 +67,7 @@ import com.android.internal.telephony.GsmAlphabet.TextEncodingDetails;
- import com.android.internal.telephony.uicc.UiccCard;
- import com.android.internal.telephony.uicc.UiccController;
- -import java.util.Arrays;
- import java.util.ArrayList;
- -import java.util.Collections;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Random;
- @@ -173,7 +170,6 @@ public abstract class SMSDispatcher extends Handler {
- /* Flags indicating whether the current device allows sms service */
- protected boolean mSmsCapable = true;
- protected boolean mSmsSendDisabled;
- - private boolean mSmsPseudoMultipart;
- protected static int getNextConcatenatedRef() {
- sConcatenatedRef += 1;
- @@ -202,7 +198,6 @@ public abstract class SMSDispatcher extends Handler {
- com.android.internal.R.bool.config_sms_capable);
- mSmsSendDisabled = !SystemProperties.getBoolean(
- TelephonyProperties.PROPERTY_SMS_SEND, mSmsCapable);
- - mSmsPseudoMultipart = SystemProperties.getBoolean("telephony.sms.pseudo_multipart", false);
- Rlog.d(TAG, "SMSDispatcher: ctor mSmsCapable=" + mSmsCapable + " format=" + getFormat()
- + " mSmsSendDisabled=" + mSmsSendDisabled);
- }
- @@ -335,16 +330,6 @@ public abstract class SMSDispatcher extends Handler {
- }
- }
- - private static boolean isSystemUid(Context context, String pkgName) {
- - final PackageManager packageManager = context.getPackageManager();
- - try {
- - return packageManager.getPackageInfo(pkgName, 0)
- - .applicationInfo.uid == Process.SYSTEM_UID;
- - } catch (PackageManager.NameNotFoundException e) {
- - return false;
- - }
- - }
- -
- /**
- * Use the carrier messaging service to send a data or text SMS.
- */
- @@ -862,17 +847,7 @@ public abstract class SMSDispatcher extends Handler {
- ArrayList<String> parts, ArrayList<PendingIntent> sentIntents,
- ArrayList<PendingIntent> deliveryIntents, Uri messageUri, String callingPkg,
- int priority, boolean isExpectMore, int validityPeriod) {
- -
- - if (mSmsPseudoMultipart) {
- - // Send as individual messages as the combination of device and
- - // carrier behavior may not process concatenated messages correctly.
- - sendPseudoMultipartText(destAddr, scAddr, parts, sentIntents, deliveryIntents,
- - messageUri, callingPkg, priority, isExpectMore, validityPeriod);
- - return;
- - }
- -
- final String fullMessageText = getMultipartMessageText(parts);
- -
- int refNumber = getNextConcatenatedRef() & 0x00FF;
- int msgCount = parts.size();
- int encoding = SmsConstants.ENCODING_UNKNOWN;
- @@ -956,72 +931,6 @@ public abstract class SMSDispatcher extends Handler {
- }
- /**
- - * Send a multi-part text based SMS as individual messages
- - * (i.e., without User Data Headers).
- - *
- - * @param destAddr the address to send the message to
- - * @param scAddr is the service center address or null to use
- - * the current default SMSC
- - * @param parts an <code>ArrayList</code> of strings that, in order,
- - * comprise the original message
- - * @param sentIntents if not null, an <code>ArrayList</code> of
- - * <code>PendingIntent</code>s (one for each message part) that is
- - * broadcast when the corresponding message part has been sent.
- - * The result code will be <code>Activity.RESULT_OK<code> for success,
- - * or one of these errors:
- - * <code>RESULT_ERROR_GENERIC_FAILURE</code>
- - * <code>RESULT_ERROR_RADIO_OFF</code>
- - * <code>RESULT_ERROR_NULL_PDU</code>
- - * <code>RESULT_ERROR_NO_SERVICE</code>.
- - * The per-application based SMS control checks sentIntent. If sentIntent
- - * is NULL the caller will be checked against all unknown applications,
- - * which cause smaller number of SMS to be sent in checking period.
- - * @param deliveryIntents if not null, an <code>ArrayList</code> of
- - * <code>PendingIntent</code>s (one for each message part) that is
- - * broadcast when the corresponding message part has been delivered
- - * to the recipient. The raw pdu of the status report is in the
- - * extended data ("pdu").
- - * @param messageUri optional URI of the message if it is already stored in the system
- - * @param callingPkg the calling package name
- - * @param priority Priority level of the message
- - * Refer specification See 3GPP2 C.S0015-B, v2.0, table 4.5.9-1
- - * ---------------------------------
- - * PRIORITY | Level of Priority
- - * ---------------------------------
- - * '00' | Normal
- - * '01' | Interactive
- - * '10' | Urgent
- - * '11' | Emergency
- - * ----------------------------------
- - * Any Other values included Negative considered as Invalid Priority Indicator of the message.
- - * @param isExpectMore is a boolean to indicate the sending message is multi segmented or not.
- - * @param validityPeriod Validity Period of the message in mins.
- - * Refer specification 3GPP TS 23.040 V6.8.1 section 9.2.3.12.1.
- - * Validity Period(Minimum) -> 5 mins
- - * Validity Period(Maximum) -> 635040 mins(i.e.63 weeks).
- - * Any Other values included Negative considered as Invalid Validity Period of the message.
- - */
- - private void sendPseudoMultipartText(String destAddr, String scAddr,
- - ArrayList<String> parts, ArrayList<PendingIntent> sentIntents,
- - ArrayList<PendingIntent> deliveryIntents,
- - Uri messageUri, String callingPkg,
- - int priority, boolean isExpectMore, int validityPeriod) {
- - int msgCount = parts.size();
- - for (int i = 0; i < msgCount; i++) {
- - PendingIntent sentIntent = null;
- - if (sentIntents != null && sentIntents.size() > i) {
- - sentIntent = sentIntents.get(i);
- - }
- - PendingIntent deliveryIntent = null;
- - if (deliveryIntents != null && deliveryIntents.size() > i) {
- - deliveryIntent = deliveryIntents.get(i);
- - }
- - sendText(destAddr, scAddr, parts.get(i), sentIntent, deliveryIntent,
- - messageUri, callingPkg, priority, isExpectMore, validityPeriod);
- - }
- - }
- -
- - /**
- * Create a new SubmitPdu and return the SMS tracker.
- */
- protected abstract SmsTracker getNewSubmitPduTracker(String destinationAddress, String scAddress,
- @@ -1067,21 +976,10 @@ public abstract class SMSDispatcher extends Handler {
- tracker.onFailed(mContext, RESULT_ERROR_NULL_PDU, 0/*errorCode*/);
- return;
- }
- -
- - PendingIntent sentIntent = tracker.mSentIntent;
- +
- // Get calling app package name via UID from Binder call
- PackageManager pm = mContext.getPackageManager();
- - int callingUid = Binder.getCallingUid();
- - // Special case: We're being proxied by the telephony stack itself,
- - // so use the intent generator's UID if one exists
- - String[] packageNames;
- -
- - if (callingUid == android.os.Process.PHONE_UID && sentIntent != null &&
- - sentIntent.getCreatorPackage() != null) {
- - packageNames = new String[] { sentIntent.getCreatorPackage() };
- - } else {
- - packageNames = pm.getPackagesForUid(callingUid);
- - }
- + String[] packageNames = pm.getPackagesForUid(Binder.getCallingUid());
- if (packageNames == null || packageNames.length == 0) {
- // Refuse to send SMS if we can't get the calling package name.
- @@ -1123,15 +1021,6 @@ public abstract class SMSDispatcher extends Handler {
- * @return true if the destination is approved; false if user confirmation event was sent
- */
- boolean checkDestination(SmsTracker tracker) {
- - List<String> ignorePackages = Arrays.asList(
- - mContext.getResources().getStringArray(R.array.config_ignored_sms_packages));
- -
- - String packageName = resolvePackageName(tracker);
- -
- - if (ignorePackages.contains(packageName)) {
- - return true;
- - }
- -
- if (mContext.checkCallingOrSelfPermission(SEND_SMS_NO_CONFIRMATION_PERMISSION)
- == PackageManager.PERMISSION_GRANTED) {
- return true; // app is pre-approved to send to short codes
- @@ -1230,25 +1119,6 @@ public abstract class SMSDispatcher extends Handler {
- }
- /**
- - * Returns the package name from the original creator of the sms, even
- - * if the package is mapped with others in a specific UID (like System UID)
- - *
- - * @param tracker
- - * @return the package name that created the original sms
- - */
- - private String resolvePackageName(SmsTracker tracker) {
- - PendingIntent sentIntent = tracker.mSentIntent;
- - String packageName = tracker.mAppInfo.applicationInfo.packageName;
- - // System UID maps to multiple packages. Try to narrow it
- - // down to an actual sender if possible
- - if (isSystemUid(mContext, packageName) && sentIntent != null &&
- - sentIntent.getCreatorPackage() != null) {
- - packageName = sentIntent.getCreatorPackage();
- - }
- - return packageName;
- - }
- -
- - /**
- * Post an alert when SMS needs confirmation due to excessive usage.
- * @param tracker an SmsTracker for the current message.
- */
- @@ -1691,17 +1561,7 @@ public abstract class SMSDispatcher extends Handler {
- boolean isExpectMore, String fullMessageText, boolean isText, int validityPeriod) {
- // Get calling app package name via UID from Binder call
- PackageManager pm = mContext.getPackageManager();
- - int callingUid = Binder.getCallingUid();
- - // Special case: We're being proxied by the telephony stack itself,
- - // so use the intent generator's UID if one exists
- - String[] packageNames;
- -
- - if (callingUid == android.os.Process.PHONE_UID && sentIntent != null &&
- - sentIntent.getCreatorPackage() != null) {
- - packageNames = new String[] { sentIntent.getCreatorPackage() };
- - } else {
- - packageNames = pm.getPackagesForUid(callingUid);
- - }
- + String[] packageNames = pm.getPackagesForUid(Binder.getCallingUid());
- // Get package info via packagemanager
- PackageInfo appInfo = null;
- diff --git a/src/java/com/android/internal/telephony/ServiceStateTracker.java b/src/java/com/android/internal/telephony/ServiceStateTracker.java
- index ec13605..c957633 100644
- --- a/src/java/com/android/internal/telephony/ServiceStateTracker.java
- +++ b/src/java/com/android/internal/telephony/ServiceStateTracker.java
- @@ -17,9 +17,7 @@
- package com.android.internal.telephony;
- import android.app.PendingIntent;
- -import android.content.BroadcastReceiver;
- import android.content.Context;
- -import android.content.Intent;
- import android.content.IntentFilter;
- import android.content.SharedPreferences;
- import android.os.AsyncResult;
- @@ -29,7 +27,6 @@ import android.os.Registrant;
- import android.os.RegistrantList;
- import android.os.SystemClock;
- import android.os.SystemProperties;
- -import android.os.UserHandle;
- import android.preference.PreferenceManager;
- import android.telephony.CellInfo;
- import android.telephony.ServiceState;
- @@ -38,11 +35,11 @@ import android.telephony.SubscriptionManager;
- import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener;
- import android.telephony.TelephonyManager;
- import android.text.TextUtils;
- -import android.util.NativeTextHelper;
- import android.util.Pair;
- import android.util.TimeUtils;
- import android.net.ConnectivityManager;
- import android.net.NetworkInfo;
- +import android.content.Context;
- import java.io.FileDescriptor;
- import java.io.PrintWriter;
- @@ -84,13 +81,6 @@ public abstract class ServiceStateTracker extends Handler {
- // so we don't want the reference to change.
- protected final CellInfo mCellInfo;
- - // PLMN/SPN data we last broadcasted
- - private int mCurSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
- - private String mCurPlmn;
- - private boolean mCurShowPlmn = false;
- - private String mCurSpn;
- - private boolean mCurShowSpn = false;
- -
- protected SignalStrength mSignalStrength = new SignalStrength();
- // TODO - this should not be public, right now used externally GsmConnetion.
- @@ -251,6 +241,7 @@ public abstract class ServiceStateTracker extends Handler {
- if (DBG) log("SubscriptionListener.onSubscriptionInfoChanged");
- // Set the network type, in case the radio does not restore it.
- int subId = mPhoneBase.getSubId();
- + int previousSubId = mPhoneBase.getSubId();
- if (previousSubId != subId) {
- previousSubId = subId;
- if (SubscriptionManager.isValidSubscriptionId(subId)) {
- @@ -279,18 +270,10 @@ public abstract class ServiceStateTracker extends Handler {
- editor.commit();
- }
- }
- - updateSpnDisplay();
- }
- }
- };
- - private BroadcastReceiver mReceiver = new BroadcastReceiver() {
- - @Override
- - public void onReceive(Context context, Intent intent) {
- - updateSpnDisplay();
- - }
- - };
- -
- protected ServiceStateTracker(PhoneBase phoneBase, CommandsInterface ci, CellInfo cellInfo) {
- mPhoneBase = phoneBase;
- mCellInfo = cellInfo;
- @@ -306,9 +289,6 @@ public abstract class ServiceStateTracker extends Handler {
- mSubscriptionManager
- .addOnSubscriptionsChangedListener(mOnSubscriptionsChangedListener);
- - mPhoneBase.getContext().registerReceiver(mReceiver,
- - new IntentFilter(Intent.ACTION_LOCALE_CHANGED));
- -
- mPhoneBase.setSystemProperty(TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE,
- ServiceState.rilRadioTechnologyToString(ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN));
- mCi.registerForImsNetworkStateChanged(this, EVENT_IMS_STATE_CHANGED, null);
- @@ -327,7 +307,6 @@ public abstract class ServiceStateTracker extends Handler {
- mCi.unregisterForCellInfoList(this);
- mSubscriptionManager
- .removeOnSubscriptionsChangedListener(mOnSubscriptionsChangedListener);
- - mPhoneBase.getContext().unregisterReceiver(mReceiver);
- }
- public boolean getDesiredPowerState() {
- @@ -963,11 +942,6 @@ public abstract class ServiceStateTracker extends Handler {
- pw.println(" mDontPollSignalStrength=" + mDontPollSignalStrength);
- pw.println(" mPendingRadioPowerOffAfterDataOff=" + mPendingRadioPowerOffAfterDataOff);
- pw.println(" mPendingRadioPowerOffAfterDataOffTag=" + mPendingRadioPowerOffAfterDataOffTag);
- - pw.println(" mCurSubId=" + mCurSubId);
- - pw.println(" mCurSpn=" + mCurSpn);
- - pw.println(" mCurShowSpn=" + mCurShowSpn);
- - pw.println(" mCurPlmn=" + mCurPlmn);
- - pw.println(" mCurShowPlmn=" + mCurShowPlmn);
- pw.flush();
- }
- @@ -1121,58 +1095,10 @@ public abstract class ServiceStateTracker extends Handler {
- protected abstract void setRoamingType(ServiceState currentServiceState);
- protected String getHomeOperatorNumeric() {
- - final Context context = mPhoneBase.getContext();
- - final TelephonyManager tm =
- - (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
- - return tm.getSimOperatorNumericForPhone(mPhoneBase.getPhoneId());
- + return SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, "");
- }
- protected int getPhoneId() {
- return mPhoneBase.getPhoneId();
- }
- -
- - private String adaptCarrierNameToLocale(Context context, String name) {
- - return NativeTextHelper.getLocalString(context, name,
- - com.android.internal.R.array.origin_carrier_names,
- - com.android.internal.R.array.locale_carrier_names);
- - }
- -
- - protected void sendSpnStringsBroadcastIfNeeded(String plmn, boolean showPlmn,
- - String spn, boolean showSpn) {
- - final Context context = mPhoneBase.getContext();
- - final int phoneId = mPhoneBase.getPhoneId();
- - final int subId = mPhoneBase.getSubId();
- -
- - if (context.getResources().getBoolean(
- - com.android.internal.R.bool.config_monitor_locale_change)) {
- - plmn = adaptCarrierNameToLocale(context, plmn);
- - spn = adaptCarrierNameToLocale(context, spn);
- - }
- -
- - if (subId != mCurSubId
- - || showPlmn != mCurShowPlmn
- - || showSpn != mCurShowSpn
- - || !TextUtils.equals(spn, mCurSpn)
- - || !TextUtils.equals(plmn, mCurPlmn)) {
- - if (DBG) {
- - log(String.format("sendSpnStringsBroadcast:" +
- - " showPlmn='%b' plmn='%s' showSpn='%b' spn='%s' for sub %d",
- - showPlmn, plmn, showSpn, spn, subId));
- - }
- - Intent intent = new Intent(TelephonyIntents.SPN_STRINGS_UPDATED_ACTION);
- - intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
- - intent.putExtra(TelephonyIntents.EXTRA_SHOW_SPN, showSpn);
- - intent.putExtra(TelephonyIntents.EXTRA_SPN, spn);
- - intent.putExtra(TelephonyIntents.EXTRA_SHOW_PLMN, showPlmn);
- - intent.putExtra(TelephonyIntents.EXTRA_PLMN, plmn);
- - SubscriptionManager.putPhoneIdAndSubIdExtra(intent, phoneId, subId);
- - mPhoneBase.getContext().sendStickyBroadcastAsUser(intent, UserHandle.ALL);
- - }
- -
- - mCurShowSpn = showSpn;
- - mCurShowPlmn = showPlmn;
- - mCurSpn = spn;
- - mCurPlmn = plmn;
- - mCurSubId = subId;
- - }
- }
- diff --git a/src/java/com/android/internal/telephony/SmsApplication.java b/src/java/com/android/internal/telephony/SmsApplication.java
- index 315b377..56ff988 100644
- --- a/src/java/com/android/internal/telephony/SmsApplication.java
- +++ b/src/java/com/android/internal/telephony/SmsApplication.java
- @@ -42,10 +42,8 @@ import android.telephony.SmsManager;
- import android.telephony.TelephonyManager;
- import android.util.Log;
- -import com.android.internal.R;
- import com.android.internal.content.PackageMonitor;
- -import java.util.Arrays;
- import java.util.Collection;
- import java.util.HashMap;
- import java.util.List;
- @@ -749,13 +747,6 @@ public final class SmsApplication {
- defaultSmsPackage = component.getPackageName();
- }
- - List<String> ignorePackages = Arrays.asList(
- - context.getResources().getStringArray(R.array.config_ignored_sms_packages));
- -
- - if (ignorePackages.contains(packageName)) {
- - return false;
- - }
- -
- if ((defaultSmsPackage == null || !defaultSmsPackage.equals(packageName)) &&
- !packageName.equals(BLUETOOTH_PACKAGE_NAME)) {
- // To write the message for someone other than the default SMS and BT app
- diff --git a/src/java/com/android/internal/telephony/SmsUsageMonitor.java b/src/java/com/android/internal/telephony/SmsUsageMonitor.java
- index 7182e05..aa9f4e5 100644
- --- a/src/java/com/android/internal/telephony/SmsUsageMonitor.java
- +++ b/src/java/com/android/internal/telephony/SmsUsageMonitor.java
- @@ -22,7 +22,6 @@ import android.content.Context;
- import android.content.pm.ApplicationInfo;
- import android.content.res.XmlResourceParser;
- import android.database.ContentObserver;
- -import android.net.Uri;
- import android.os.Binder;
- import android.os.Handler;
- import android.os.Process;
- @@ -108,8 +107,8 @@ public class SmsUsageMonitor {
- /** Premium SMS permission when the owner has allowed the app to send premium SMS. */
- public static final int PREMIUM_SMS_PERMISSION_ALWAYS_ALLOW = 3;
- - private int mCheckPeriod;
- - private int mMaxAllowed;
- + private final int mCheckPeriod;
- + private final int mMaxAllowed;
- private final HashMap<String, ArrayList<Long>> mSmsStamp =
- new HashMap<String, ArrayList<Long>>();
- @@ -129,9 +128,6 @@ public class SmsUsageMonitor {
- /** Handler for responding to content observer updates. */
- private final SettingsObserverHandler mSettingsObserverHandler;
- - /** Handler for responding to content observer updates sms limits. */
- - private final SmsLimitObserverHandler mSmsLimitObserverHandler;
- -
- /** File holding the patterns */
- private final File mPatternFile = new File(SHORT_CODE_PATH);
- @@ -254,56 +250,20 @@ public class SmsUsageMonitor {
- }
- /**
- - * Observe the global setting for sms limits
- - */
- - private class SmsLimitObserver extends ContentObserver {
- - private final Context mContext;
- -
- - SmsLimitObserver(Handler handler, Context context) {
- - super(handler);
- - mContext = context;
- - onChange(false);
- - }
- -
- - @Override
- - public void onChange(boolean selfChange) {
- - onChange(selfChange, null);
- - }
- -
- - @Override
- - public void onChange(boolean selfChange, Uri uri) {
- - ContentResolver resolver = mContext.getContentResolver();
- - mMaxAllowed = Settings.Global.getInt(resolver,
- - Settings.Global.SMS_OUTGOING_CHECK_MAX_COUNT,
- - DEFAULT_SMS_MAX_COUNT);
- -
- - mCheckPeriod = Settings.Global.getInt(resolver,
- - Settings.Global.SMS_OUTGOING_CHECK_INTERVAL_MS,
- - DEFAULT_SMS_CHECK_PERIOD);
- - }
- - }
- -
- - private class SmsLimitObserverHandler extends Handler {
- - SmsLimitObserverHandler(Context context) {
- - ContentResolver resolver = context.getContentResolver();
- -
- - ContentObserver globalObserver = new SmsLimitObserver(this, context);
- -
- - resolver.registerContentObserver(Settings.Global.getUriFor(
- - Settings.Global.SMS_OUTGOING_CHECK_MAX_COUNT), false, globalObserver);
- - resolver.registerContentObserver(Settings.Global.getUriFor(
- - Settings.Global.SMS_OUTGOING_CHECK_INTERVAL_MS), false, globalObserver);
- - }
- - }
- -
- - /**
- * Create SMS usage monitor.
- * @param context the context to use to load resources and get TelephonyManager service
- */
- public SmsUsageMonitor(Context context) {
- mContext = context;
- + ContentResolver resolver = context.getContentResolver();
- +
- + mMaxAllowed = Settings.Global.getInt(resolver,
- + Settings.Global.SMS_OUTGOING_CHECK_MAX_COUNT,
- + DEFAULT_SMS_MAX_COUNT);
- - mSmsLimitObserverHandler = new SmsLimitObserverHandler(mContext);
- + mCheckPeriod = Settings.Global.getInt(resolver,
- + Settings.Global.SMS_OUTGOING_CHECK_INTERVAL_MS,
- + DEFAULT_SMS_CHECK_PERIOD);
- mSettingsObserverHandler = new SettingsObserverHandler(mContext, mCheckEnabled);
- diff --git a/src/java/com/android/internal/telephony/SubscriptionController.java b/src/java/com/android/internal/telephony/SubscriptionController.java
- index 8b00dc6..2ca3b04 100755
- --- a/src/java/com/android/internal/telephony/SubscriptionController.java
- +++ b/src/java/com/android/internal/telephony/SubscriptionController.java
- @@ -171,11 +171,20 @@ public class SubscriptionController extends ISub.Stub {
- int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY,
- SubscriptionManager.INVALID_SUBSCRIPTION_ID);
- if (intent.getAction().equals(TelephonyIntents.SPN_STRINGS_UPDATED_ACTION)) {
- - setPlmnSpn(subId,
- - intent.getBooleanExtra(TelephonyIntents.EXTRA_SHOW_PLMN, false),
- - intent.getStringExtra(TelephonyIntents.EXTRA_PLMN),
- - intent.getBooleanExtra(TelephonyIntents.EXTRA_SHOW_SPN, false),
- - intent.getStringExtra(TelephonyIntents.EXTRA_SPN));
- + if (intent.getBooleanExtra(TelephonyIntents.EXTRA_SHOW_PLMN, false)) {
- + String carrierText = intent.getStringExtra(TelephonyIntents.EXTRA_PLMN);
- + if (intent.getBooleanExtra(TelephonyIntents.EXTRA_SHOW_SPN, false)) {
- + // Need to show both plmn and spn.
- + String separator = mContext.getString(
- + com.android.internal.R.string.kg_text_message_separator).toString();
- + carrierText = new StringBuilder().append(carrierText).append(separator)
- + .append(intent.getStringExtra(TelephonyIntents.EXTRA_SPN))
- + .toString();
- + }
- + setCarrierText(carrierText, subId);
- + } else if (intent.getBooleanExtra(TelephonyIntents.EXTRA_SHOW_SPN, false)) {
- + setCarrierText(intent.getStringExtra(TelephonyIntents.EXTRA_PLMN), subId);
- + }
- }
- }
- };
- @@ -851,11 +860,13 @@ public class SubscriptionController extends ISub.Stub {
- * @param spn spn to be included in carrier text
- * @return true if carrier text is set, false otherwise
- */
- - public boolean setPlmnSpn(int subId, boolean showPlmn, String plmn,
- + public boolean setPlmnSpn(int slotId, boolean showPlmn, String plmn,
- boolean showSpn, String spn) {
- + int[] subIds = getSubId(slotId);
- if (mContext.getPackageManager().resolveContentProvider(
- SubscriptionManager.CONTENT_URI.getAuthority(), 0) == null ||
- - !SubscriptionManager.isValidSubscriptionId(subId)) {
- + subIds == null ||
- + !SubscriptionManager.isValidSubscriptionId(subIds[0])) {
- // No place to store this info. Notify registrants of the change anyway as they
- // might retrieve the SPN/PLMN text from the SST sticky broadcast.
- // TODO: This can be removed once SubscriptionController is not running on devices
- @@ -864,37 +875,22 @@ public class SubscriptionController extends ISub.Stub {
- notifySubscriptionInfoChanged();
- return false;
- }
- -
- - if (plmn != null && showPlmn && spn != null && showSpn) {
- - if (mContext.getResources().getBoolean(
- - com.android.internal.R.bool.config_spn_display_control)) {
- - logd("[setPlmnSpn] Do not display SPN string when PLMN and SPN both need to show"
- - + "and PLMN string is not null");
- - showSpn = false;
- - }
- - }
- -
- - final String carrierText;
- + String carrierText = "";
- if (showPlmn) {
- + carrierText = plmn;
- if (showSpn) {
- // Need to show both plmn and spn.
- String separator = mContext.getString(
- com.android.internal.R.string.kg_text_message_separator).toString();
- - carrierText = new StringBuilder()
- - .append(plmn)
- - .append(separator)
- - .append(spn)
- + carrierText = new StringBuilder().append(carrierText).append(separator).append(spn)
- .toString();
- - } else {
- - carrierText = plmn;
- }
- } else if (showSpn) {
- carrierText = spn;
- - } else {
- - carrierText = "";
- }
- -
- - setCarrierText(carrierText, subId);
- + for (int i = 0; i < subIds.length; i++) {
- + setCarrierText(carrierText, subIds[i]);
- + }
- return true;
- }
- diff --git a/src/java/com/android/internal/telephony/SyntheticSmsMessage.java b/src/java/com/android/internal/telephony/SyntheticSmsMessage.java
- deleted file mode 100644
- index 0953470..0000000
- --- a/src/java/com/android/internal/telephony/SyntheticSmsMessage.java
- +++ /dev/null
- @@ -1,125 +0,0 @@
- -/*
- - * Copyright (C) 2014 The CyanogenMod Project
- - *
- - * Licensed under the Apache License, Version 2.0 (the "License");
- - * you may not use this file except in compliance with the License.
- - * You may obtain a copy of the License at
- - *
- - * http://www.apache.org/licenses/LICENSE-2.0
- - *
- - * Unless required by applicable law or agreed to in writing, software
- - * distributed under the License is distributed on an "AS IS" BASIS,
- - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- - * See the License for the specific language governing permissions and
- - * limitations under the License.
- - */
- -
- -package com.android.internal.telephony;
- -
- -import org.json.JSONObject;
- -
- -import com.android.internal.telephony.SmsConstants.MessageClass;
- -
- -public class SyntheticSmsMessage extends SmsMessageBase {
- - public static class SyntheticAddress extends SmsAddress {
- - }
- -
- - public static boolean isSyntheticPdu(byte[] pdu) {
- - try {
- - JSONObject json = new JSONObject(new String(pdu));
- - return json.optBoolean("synthetic", false);
- - }
- - catch (Exception e) {
- - }
- - return false;
- - }
- -
- - public static SyntheticSmsMessage createFromPdu(byte[] pdu) {
- - try {
- - // TODO: use Parcelable or Bundle or something that serializes?
- - JSONObject json = new JSONObject(new String(pdu));
- - SyntheticSmsMessage message = new SyntheticSmsMessage(
- - json.getString("originatingAddress"),
- - json.optString("scAddress", null),
- - json.getString("messageBody"),
- - json.getLong("timestampMillis"));
- - return message;
- - }
- - catch (Exception e) {
- - e.printStackTrace();
- - }
- - return null;
- - }
- -
- - public SyntheticSmsMessage(String originatingAddress, String scAddress, String messageBody, long timestampMillis) {
- - this.mOriginatingAddress = new SyntheticAddress();
- - this.mOriginatingAddress.address = originatingAddress;
- -
- - this.mMessageBody = messageBody;
- - this.mScTimeMillis = timestampMillis;
- - this.mScAddress = scAddress;
- -
- - try {
- - JSONObject json = new JSONObject();
- - json.put("originatingAddress", originatingAddress);
- - json.put("scAddress", scAddress);
- - json.put("messageBody", messageBody);
- - json.put("timestampMillis", timestampMillis);
- - json.put("synthetic", true);
- - this.mPdu = json.toString().getBytes();
- - }
- - catch (Exception e) {
- - e.printStackTrace();
- - }
- - }
- -
- - @Override
- - public MessageClass getMessageClass() {
- - return SmsConstants.MessageClass.UNKNOWN;
- - }
- -
- - @Override
- - public int getProtocolIdentifier() {
- - return 0;
- - }
- -
- - @Override
- - public boolean isReplace() {
- - return false;
- - }
- -
- - @Override
- - public boolean isCphsMwiMessage() {
- - return false;
- - }
- -
- - @Override
- - public boolean isMWIClearMessage() {
- - return false;
- - }
- -
- - @Override
- - public boolean isMWISetMessage() {
- - return false;
- - }
- -
- - @Override
- - public boolean isMwiDontStore() {
- - return false;
- - }
- -
- - @Override
- - public int getStatus() {
- - return 0;
- - }
- -
- - @Override
- - public boolean isStatusReportMessage() {
- - return false;
- - }
- -
- - @Override
- - public boolean isReplyPathPresent() {
- - return false;
- - }
- -}
- \ No newline at end of file
- diff --git a/src/java/com/android/internal/telephony/UiccSmsController.java b/src/java/com/android/internal/telephony/UiccSmsController.java
- index e65155b..4262179 100644
- --- a/src/java/com/android/internal/telephony/UiccSmsController.java
- +++ b/src/java/com/android/internal/telephony/UiccSmsController.java
- @@ -2,7 +2,6 @@
- * Copyright (C) 2008 The Android Open Source Project
- * Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
- * Not a Contribution.
- - * Copyright (c) 2015 The CyanogenMod Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- @@ -19,188 +18,35 @@
- package com.android.internal.telephony;
- -import android.Manifest;
- -import android.app.Activity;
- import android.app.ActivityThread;
- -import android.app.AppOpsManager;
- import android.app.PendingIntent;
- -import android.content.BroadcastReceiver;
- -import android.content.ComponentName;
- import android.content.Context;
- -import android.content.Intent;
- import android.net.Uri;
- import android.os.Binder;
- -import android.os.Handler;
- -import android.os.PowerManager;
- import android.os.RemoteException;
- import android.os.ServiceManager;
- -import android.os.UserHandle;
- -import android.provider.Telephony.Sms.Intents;
- import android.telephony.Rlog;
- -import android.telephony.SmsMessage;
- import android.telephony.SubscriptionInfo;
- -import android.util.Log;
- import android.telephony.SubscriptionManager;
- import android.telephony.TelephonyManager;
- import java.util.List;
- -import java.util.ArrayList;
- /**
- * UiccSmsController to provide an inter-process communication to
- * access Sms in Icc.
- */
- public class UiccSmsController extends ISms.Stub {
- -
- static final String LOG_TAG = "RIL_UiccSmsController";
- protected Phone[] mPhone;
- - protected UiccSmsController(Phone[] phone, Context context){
- + protected UiccSmsController(Phone[] phone){
- mPhone = phone;
- - mContext = context;
- +
- if (ServiceManager.getService("isms") == null) {
- ServiceManager.addService("isms", this);
- }
- -
- - createWakelock();
- - }
- -
- - private void createWakelock() {
- - PowerManager pm = (PowerManager)mContext.getSystemService(Context.POWER_SERVICE);
- - mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "IccSmsInterfaceManager");
- - mWakeLock.setReferenceCounted(true);
- - }
- -
- - private BroadcastReceiver mReceiver = new BroadcastReceiver() {
- - public void onReceive(Context context, Intent intent) {
- - // check if the message was aborted
- - if (getResultCode() != Activity.RESULT_OK) {
- - return;
- - }
- - String destAddr = getResultData();
- - String scAddr = intent.getStringExtra("scAddr");
- - int subId = intent.getIntExtra("subId", getDefaultSmsSubId());
- - String callingPackage = intent.getStringExtra("callingPackage");
- - ArrayList<String> parts = intent.getStringArrayListExtra("parts");
- - ArrayList<PendingIntent> sentIntents = intent.getParcelableArrayListExtra("sentIntents");
- - ArrayList<PendingIntent> deliveryIntents = intent.getParcelableArrayListExtra("deliveryIntents");
- -
- - if (intent.getIntExtra("callingUid", 0) != 0) {
- - callingPackage = callingPackage + "\\" + intent.getIntExtra("callingUid", 0);
- - }
- -
- - if (intent.getBooleanExtra("multipart", false)) {
- - if (Rlog.isLoggable("SMS", Log.VERBOSE)) {
- - log("ProxiedMultiPartSms destAddr: " + destAddr +
- - "\n scAddr= " + scAddr +
- - "\n subId= " + subId +
- - "\n callingPackage= " + callingPackage +
- - "\n partsSize= " + parts.size());
- - }
- - getIccSmsInterfaceManager(subId)
- - .sendMultipartText(callingPackage, destAddr, scAddr, parts,
- - sentIntents, deliveryIntents);
- - return;
- - }
- -
- - PendingIntent sentIntent = null;
- - if (sentIntents != null && sentIntents.size() > 0) {
- - sentIntent = sentIntents.get(0);
- - }
- - PendingIntent deliveryIntent = null;
- - if (deliveryIntents != null && deliveryIntents.size() > 0) {
- - deliveryIntent = deliveryIntents.get(0);
- - }
- - String text = null;
- - if (parts != null && parts.size() > 0) {
- - text = parts.get(0);
- - }
- - if (Rlog.isLoggable("SMS", Log.VERBOSE)) {
- - log("ProxiedSms destAddr: " + destAddr +
- - "\n scAddr=" + scAddr +
- - "\n subId= " + subId +
- - "\n callingPackage=" + callingPackage);
- - }
- - getIccSmsInterfaceManager(subId).sendText(callingPackage, destAddr,
- - scAddr, text, sentIntent, deliveryIntent);
- - }
- - };
- -
- - private Context mContext;
- - private PowerManager.WakeLock mWakeLock;
- - private static final int WAKE_LOCK_TIMEOUT = 5000;
- - private final Handler mHandler = new Handler();
- - private void dispatchPdus(byte[][] pdus) {
- - Intent intent = new Intent(Intents.SMS_DELIVER_ACTION);
- - // Direct the intent to only the default SMS app. If we can't find a default SMS app
- - // then send it to all broadcast receivers.
- - ComponentName componentName = SmsApplication.getDefaultSmsApplication(mContext, true);
- - if (componentName == null)
- - return;
- -
- - if (Rlog.isLoggable("SMS", Log.VERBOSE)) {
- - log("dispatchPdu pdus: " + pdus +
- - "\n componentName=" + componentName +
- - "\n format=" + SmsMessage.FORMAT_SYNTHETIC);
- - }
- -
- - // Deliver SMS message only to this receiver
- - intent.setComponent(componentName);
- - intent.putExtra("pdus", pdus);
- - intent.putExtra("format", SmsMessage.FORMAT_SYNTHETIC);
- - dispatch(intent, Manifest.permission.RECEIVE_SMS);
- -
- - intent.setAction(Intents.SMS_RECEIVED_ACTION);
- - intent.setComponent(null);
- - dispatch(intent, Manifest.permission.RECEIVE_SMS);
- - }
- -
- - private void dispatch(Intent intent, String permission) {
- - // Hold a wake lock for WAKE_LOCK_TIMEOUT seconds, enough to give any
- - // receivers time to take their own wake locks.
- - mWakeLock.acquire(WAKE_LOCK_TIMEOUT);
- - intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
- - mContext.sendOrderedBroadcast(intent, permission, AppOpsManager.OP_RECEIVE_SMS, null,
- - mHandler, Activity.RESULT_OK, null, null);
- - }
- -
- - private void broadcastOutgoingSms(
- - int subId, String callingPackage, String destAddr, String scAddr, boolean multipart,
- - ArrayList<String> parts, ArrayList<PendingIntent> sentIntents,
- - ArrayList<PendingIntent> deliveryIntents, int priority, boolean isExpectMore,
- - int validityPeriod) {
- - Intent broadcast = new Intent(Intent.ACTION_NEW_OUTGOING_SMS);
- - broadcast.putExtra("destAddr", destAddr);
- - broadcast.putExtra("scAddr", scAddr);
- - broadcast.putExtra("subId", subId);
- - broadcast.putExtra("multipart", multipart);
- - broadcast.putExtra("callingPackage", callingPackage);
- - broadcast.putExtra("callingUid", android.os.Binder.getCallingUid());
- - broadcast.putStringArrayListExtra("parts", parts);
- - broadcast.putParcelableArrayListExtra("sentIntents", sentIntents);
- - broadcast.putParcelableArrayListExtra("deliveryIntents", deliveryIntents);
- - broadcast.putExtra("priority", priority);
- - broadcast.putExtra("isExpectMore", isExpectMore);
- - broadcast.putExtra("validityPeriod", validityPeriod);
- -
- - if (Rlog.isLoggable("SMS", Log.VERBOSE)) {
- - log("Broadcasting sms destAddr: " + destAddr +
- - "\n scAddr= " + scAddr +
- - "\n subId= " + subId +
- - "\n multipart= " + multipart +
- - "\n callingPackager= " + callingPackage +
- - "\n callingUid= " + android.os.Binder.getCallingUid() +
- - "\n parts= " + parts.size() +
- - "\n sentIntents= " + sentIntents.size() +
- - "\n deliveryIntents= " + deliveryIntents.size() +
- - "\n priority= " + priority +
- - "\n isExpectMore= " + isExpectMore +
- - "\n validityPeriod= " + validityPeriod);
- - }
- - mContext.sendOrderedBroadcastAsUser(broadcast, UserHandle.OWNER,
- - android.Manifest.permission.INTERCEPT_SMS,
- - mReceiver, null, Activity.RESULT_OK, destAddr, null);
- }
- public boolean
- @@ -305,33 +151,29 @@ public class UiccSmsController extends ISms.Stub {
- public void sendTextForSubscriber(int subId, String callingPackage, String destAddr,
- String scAddr, String text, PendingIntent sentIntent, PendingIntent deliveryIntent) {
- - sendTextWithOptionsUsingSubscriber(subId, callingPackage, destAddr, scAddr, text,
- - sentIntent, deliveryIntent, -1, false, -1);
- + IccSmsInterfaceManager iccSmsIntMgr = getIccSmsInterfaceManager(subId);
- + if (iccSmsIntMgr != null) {
- + iccSmsIntMgr.sendText(callingPackage, destAddr, scAddr, text, sentIntent,
- + deliveryIntent);
- + } else {
- + Rlog.e(LOG_TAG,"sendText iccSmsIntMgr is null for" +
- + " Subscription: " + subId);
- + }
- }
- public void sendTextWithOptionsUsingSubscriber(int subId, String callingPackage,
- - String destAddr, String scAddr, String text, PendingIntent sentIntent,
- - PendingIntent deliveryIntent, int priority, boolean isExpectMore,
- + String destAddr, String scAddr, String parts, PendingIntent sentIntents,
- + PendingIntent deliveryIntents, int priority, boolean isExpectMore,
- int validityPeriod) {
- - mContext.enforceCallingPermission(
- - android.Manifest.permission.SEND_SMS,
- - "Sending SMS message");
- IccSmsInterfaceManager iccSmsIntMgr = getIccSmsInterfaceManager(subId);
- - if (iccSmsIntMgr.isShortSMSCode(destAddr)) {
- - iccSmsIntMgr.sendTextWithOptions(callingPackage, destAddr, scAddr, text,
- - sentIntent, deliveryIntent, priority, isExpectMore, validityPeriod);
- - return;
- + if (iccSmsIntMgr != null ) {
- + iccSmsIntMgr.sendTextWithOptions(callingPackage, destAddr, scAddr, parts, sentIntents,
- + deliveryIntents, priority, isExpectMore, validityPeriod);
- + } else {
- + Rlog.e(LOG_TAG,"sendTextWithOptions iccSmsIntMgr is null for" +
- + " Subscription: " + subId);
- }
- - ArrayList<String> parts = new ArrayList<String>();
- - parts.add(text);
- - ArrayList<PendingIntent> sentIntents = new ArrayList<PendingIntent>();
- - sentIntents.add(sentIntent);
- - ArrayList<PendingIntent> deliveryIntents = new ArrayList<PendingIntent>();
- - deliveryIntents.add(deliveryIntent);
- - broadcastOutgoingSms(subId, callingPackage, destAddr, scAddr, false, parts, sentIntents,
- - deliveryIntents, priority, isExpectMore, validityPeriod);
- }
- -
- public void sendMultipartText(String callingPackage, String destAddr, String scAddr,
- List<String> parts, List<PendingIntent> sentIntents,
- List<PendingIntent> deliveryIntents) throws android.os.RemoteException {
- @@ -343,28 +185,28 @@ public class UiccSmsController extends ISms.Stub {
- String scAddr, List<String> parts, List<PendingIntent> sentIntents,
- List<PendingIntent> deliveryIntents)
- throws android.os.RemoteException {
- - sendMultipartTextWithOptionsUsingSubscriber(subId, callingPackage, destAddr,
- - scAddr, parts, sentIntents, deliveryIntents, -1, false, -1);
- + IccSmsInterfaceManager iccSmsIntMgr = getIccSmsInterfaceManager(subId);
- + if (iccSmsIntMgr != null ) {
- + iccSmsIntMgr.sendMultipartText(callingPackage, destAddr, scAddr, parts, sentIntents,
- + deliveryIntents);
- + } else {
- + Rlog.e(LOG_TAG,"sendMultipartText iccSmsIntMgr is null for" +
- + " Subscription: " + subId);
- + }
- }
- public void sendMultipartTextWithOptionsUsingSubscriber(int subId, String callingPackage,
- String destAddr, String scAddr, List<String> parts, List<PendingIntent> sentIntents,
- List<PendingIntent> deliveryIntents, int priority, boolean isExpectMore,
- int validityPeriod) {
- - mContext.enforceCallingPermission(
- - android.Manifest.permission.SEND_SMS,
- - "Sending SMS message");
- IccSmsInterfaceManager iccSmsIntMgr = getIccSmsInterfaceManager(subId);
- - if (iccSmsIntMgr.isShortSMSCode(destAddr)) {
- - iccSmsIntMgr.sendMultipartTextWithOptions(callingPackage, destAddr,
- - scAddr, parts, sentIntents, deliveryIntents, -1, false, -1);
- - return;
- + if (iccSmsIntMgr != null ) {
- + iccSmsIntMgr.sendMultipartTextWithOptions(callingPackage, destAddr, scAddr, parts,
- + sentIntents, deliveryIntents, priority, isExpectMore, validityPeriod);
- + } else {
- + Rlog.e(LOG_TAG,"sendMultipartTextWithOptions iccSmsIntMgr is null for" +
- + " Subscription: " + subId);
- }
- - broadcastOutgoingSms(subId, callingPackage, destAddr, scAddr, true,
- - parts != null ? new ArrayList<String>(parts) : null,
- - sentIntents != null ? new ArrayList<PendingIntent>(sentIntents) : null,
- - deliveryIntents != null ? new ArrayList<PendingIntent>(deliveryIntents) : null,
- - -1, false, -1);
- }
- public boolean enableCellBroadcast(int messageIdentifier, int ranType)
- @@ -530,20 +372,6 @@ public class UiccSmsController extends ISms.Stub {
- getIccSmsInterfaceManager(subId).injectSmsPdu(pdu, format, receivedIntent);
- }
- - @Override
- - public void synthesizeMessages(String originatingAddress,
- - String scAddress, List<String> messages, long timestampMillis) throws RemoteException {
- - mContext.enforceCallingPermission(
- - android.Manifest.permission.BROADCAST_SMS, "");
- - byte[][] pdus = new byte[messages.size()][];
- - for (int i = 0; i < messages.size(); i++) {
- - SyntheticSmsMessage message = new SyntheticSmsMessage(originatingAddress,
- - scAddress, messages.get(i), timestampMillis);
- - pdus[i] = message.getPdu();
- - }
- - dispatchPdus(pdus);
- - }
- -
- /**
- * get sms interface manager object based on subscription.
- **/
- @@ -650,8 +478,4 @@ public class UiccSmsController extends ISms.Stub {
- return false;
- }
- }
- -
- - protected void log(String msg) {
- - Log.d(LOG_TAG, "[UiccSmsController] " + msg);
- - }
- }
- diff --git a/src/java/com/android/internal/telephony/cdma/CDMALTEPhone.java b/src/java/com/android/internal/telephony/cdma/CDMALTEPhone.java
- index 38487cc..ea943d8 100644
- --- a/src/java/com/android/internal/telephony/cdma/CDMALTEPhone.java
- +++ b/src/java/com/android/internal/telephony/cdma/CDMALTEPhone.java
- @@ -233,31 +233,10 @@ public class CDMALTEPhone extends CDMAPhone {
- return false;
- }
- - // return IMSI from CSIM as subscriber ID if available, otherwise reads from USIM
- + // return IMSI from USIM as subscriber ID.
- @Override
- public String getSubscriberId() {
- - IccRecords r = (mIccRecords != null) ? mIccRecords.get() : null;
- - if (r != null) {
- - String imsi = r.getIMSI();
- - if (!TextUtils.isEmpty(imsi)) {
- - log("IMSI = " + imsi);
- - return imsi;
- - }
- - }
- -
- - log("IMSI undefined");
- - return "";
- - }
- -
- -
- - // fix CTS test expecting IMEI to be used as device ID when in LteOnCdma mode
- - @Override
- - public String getDeviceId() {
- - if (TelephonyManager.getLteOnCdmaModeStatic() == PhoneConstants.LTE_ON_CDMA_TRUE) {
- - return mImei;
- - } else {
- - return super.getDeviceId();
- - }
- + return (mSimRecords != null) ? mSimRecords.getIMSI() : "";
- }
- // return GID1 from USIM
- diff --git a/src/java/com/android/internal/telephony/cdma/CDMAPhone.java b/src/java/com/android/internal/telephony/cdma/CDMAPhone.java
- index 422bb6f..5a683c1 100644
- --- a/src/java/com/android/internal/telephony/cdma/CDMAPhone.java
- +++ b/src/java/com/android/internal/telephony/cdma/CDMAPhone.java
- @@ -1956,7 +1956,7 @@ public class CDMAPhone extends PhoneBase {
- if (status) {
- IccRecords iccRecords = mIccRecords.get();
- if (iccRecords != null) {
- - setSystemProperty(TelephonyProperties.PROPERTY_ICC_OPERATOR_ALPHA,
- + SystemProperties.set(TelephonyProperties.PROPERTY_ICC_OPERATOR_ALPHA,
- iccRecords.getServiceProviderName());
- }
- if (mSST != null) {
- diff --git a/src/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java b/src/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
- index 01d19bf..dcc5a01 100644
- --- a/src/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
- +++ b/src/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
- @@ -40,6 +40,7 @@ import android.telephony.Rlog;
- import android.telephony.ServiceState;
- import android.telephony.SignalStrength;
- import android.telephony.TelephonyManager;
- +import android.telephony.SubscriptionManager;
- import android.telephony.cdma.CdmaCellLocation;
- import android.text.TextUtils;
- import android.util.EventLog;
- @@ -129,6 +130,9 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
- private PowerManager.WakeLock mWakeLock;
- private static final String WAKELOCK_TAG = "ServiceStateTracker";
- + /** Contains the name of the registered network in CDMA (either ONS or ERI text). */
- + protected String mCurPlmn = null;
- +
- protected String mMdn;
- protected int mHomeSystemId[] = null;
- protected int mHomeNetworkId[] = null;
- @@ -599,7 +603,27 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
- "of service, set plmn='" + plmn + "'");
- }
- - sendSpnStringsBroadcastIfNeeded(plmn, plmn != null, "", false);
- + if (!TextUtils.equals(plmn, mCurPlmn)) {
- + // Allow A blank plmn, "" to set showPlmn to true. Previously, we
- + // would set showPlmn to true only if plmn was not empty, i.e. was not
- + // null and not blank. But this would cause us to incorrectly display
- + // "No Service". Now showPlmn is set to true for any non null string.
- + boolean showPlmn = plmn != null;
- + if (DBG) {
- + log(String.format("updateSpnDisplay: changed sending intent" +
- + " showPlmn='%b' plmn='%s'", showPlmn, plmn));
- + }
- + Intent intent = new Intent(TelephonyIntents.SPN_STRINGS_UPDATED_ACTION);
- + intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
- + intent.putExtra(TelephonyIntents.EXTRA_SHOW_SPN, false);
- + intent.putExtra(TelephonyIntents.EXTRA_SPN, "");
- + intent.putExtra(TelephonyIntents.EXTRA_SHOW_PLMN, showPlmn);
- + intent.putExtra(TelephonyIntents.EXTRA_PLMN, plmn);
- + SubscriptionManager.putPhoneIdAndSubIdExtra(intent, mPhone.getPhoneId());
- + mPhone.getContext().sendStickyBroadcastAsUser(intent, UserHandle.ALL);
- + }
- +
- + mCurPlmn = plmn;
- }
- /**
- @@ -2086,6 +2110,7 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
- pw.println(" mSavedTime=" + mSavedTime);
- pw.println(" mSavedAtTime=" + mSavedAtTime);
- pw.println(" mWakeLock=" + mWakeLock);
- + pw.println(" mCurPlmn=" + mCurPlmn);
- pw.println(" mMdn=" + mMdn);
- pw.println(" mHomeSystemId=" + mHomeSystemId);
- pw.println(" mHomeNetworkId=" + mHomeNetworkId);
- diff --git a/src/java/com/android/internal/telephony/gsm/GSMPhone.java b/src/java/com/android/internal/telephony/gsm/GSMPhone.java
- index 422f0f0..a41556a 100644
- --- a/src/java/com/android/internal/telephony/gsm/GSMPhone.java
- +++ b/src/java/com/android/internal/telephony/gsm/GSMPhone.java
- @@ -2052,7 +2052,7 @@ public class GSMPhone extends PhoneBase {
- if (status) {
- IccRecords iccRecords = mIccRecords.get();
- if (iccRecords != null) {
- - setSystemProperty(TelephonyProperties.PROPERTY_ICC_OPERATOR_ALPHA,
- + SystemProperties.set(TelephonyProperties.PROPERTY_ICC_OPERATOR_ALPHA,
- iccRecords.getServiceProviderName());
- }
- if (mSST != null) {
- diff --git a/src/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java b/src/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
- index 2b6d7c4..1f1aa0b 100644
- --- a/src/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
- +++ b/src/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java
- @@ -48,9 +48,8 @@ import android.telephony.CellLocation;
- import android.telephony.Rlog;
- import android.telephony.ServiceState;
- import android.telephony.SignalStrength;
- -import android.telephony.SubscriptionManager;
- -import android.telephony.TelephonyManager;
- import android.telephony.gsm.GsmCellLocation;
- +import android.telephony.TelephonyManager;
- import android.text.TextUtils;
- import android.util.EventLog;
- import android.util.TimeUtils;
- @@ -66,6 +65,7 @@ import com.android.internal.telephony.PhoneFactory;
- import com.android.internal.telephony.RILConstants;
- import com.android.internal.telephony.RestrictedState;
- import com.android.internal.telephony.ServiceStateTracker;
- +import android.telephony.SubscriptionManager;
- import com.android.internal.telephony.TelephonyIntents;
- import com.android.internal.telephony.TelephonyProperties;
- import com.android.internal.telephony.dataconnection.DcTrackerBase;
- @@ -157,6 +157,12 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
- private PowerManager.WakeLock mWakeLock;
- private static final String WAKELOCK_TAG = "ServiceStateTracker";
- + /** Keep track of SPN display rules, so we only broadcast intent if something changes. */
- + private String mCurSpn = null;
- + private String mCurPlmn = null;
- + private boolean mCurShowPlmn = false;
- + private boolean mCurShowSpn = false;
- +
- /** Notification type. */
- static final int PS_ENABLED = 1001; // Access Control blocks data service
- static final int PS_DISABLED = 1002; // Access Control enables data service
- @@ -637,7 +643,30 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
- showSpn = false;
- }
- - sendSpnStringsBroadcastIfNeeded(plmn, showPlmn, spn, showSpn);
- + // Update SPN_STRINGS_UPDATED_ACTION IFF any value changes
- + if (showPlmn != mCurShowPlmn
- + || showSpn != mCurShowSpn
- + || !TextUtils.equals(spn, mCurSpn)
- + || !TextUtils.equals(plmn, mCurPlmn)) {
- + if (DBG) {
- + log(String.format("updateSpnDisplay: changed" +
- + " sending intent rule=" + rule +
- + " showPlmn='%b' plmn='%s' showSpn='%b' spn='%s'",
- + showPlmn, plmn, showSpn, spn));
- + }
- + Intent intent = new Intent(TelephonyIntents.SPN_STRINGS_UPDATED_ACTION);
- + intent.putExtra(TelephonyIntents.EXTRA_SHOW_SPN, showSpn);
- + intent.putExtra(TelephonyIntents.EXTRA_SPN, spn);
- + intent.putExtra(TelephonyIntents.EXTRA_SHOW_PLMN, showPlmn);
- + intent.putExtra(TelephonyIntents.EXTRA_PLMN, plmn);
- + SubscriptionManager.putPhoneIdAndSubIdExtra(intent, mPhone.getPhoneId());
- + mPhone.getContext().sendStickyBroadcastAsUser(intent, UserHandle.ALL);
- + }
- +
- + mCurShowSpn = showSpn;
- + mCurShowPlmn = showPlmn;
- + mCurSpn = spn;
- + mCurPlmn = plmn;
- }
- /**
- @@ -2138,6 +2167,10 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
- pw.println(" mReportedGprsNoReg=" + mReportedGprsNoReg);
- pw.println(" mNotification=" + mNotification);
- pw.println(" mWakeLock=" + mWakeLock);
- + pw.println(" mCurSpn=" + mCurSpn);
- + pw.println(" mCurShowSpn=" + mCurShowSpn);
- + pw.println(" mCurPlmn=" + mCurPlmn);
- + pw.println(" mCurShowPlmn=" + mCurShowPlmn);
- pw.flush();
- }
- diff --git a/src/java/com/android/internal/telephony/uicc/IccRecords.java b/src/java/com/android/internal/telephony/uicc/IccRecords.java
- index 86bdca9..50aedf6 100644
- --- a/src/java/com/android/internal/telephony/uicc/IccRecords.java
- +++ b/src/java/com/android/internal/telephony/uicc/IccRecords.java
- @@ -41,8 +41,6 @@ import java.io.PrintWriter;
- import java.nio.ByteBuffer;
- import java.util.concurrent.atomic.AtomicBoolean;
- -import static com.android.internal.telephony.TelephonyProperties.PROPERTY_ICC_OPERATOR_ALPHA;
- -
- /**
- * {@hide}
- */
- @@ -66,8 +64,6 @@ public abstract class IccRecords extends Handler implements IccConstants {
- protected AdnRecordCache mAdnCache;
- - private SpnOverride mSpnOverride;
- -
- // ***** Cached SIM State; cleared on channel close
- protected boolean mRecordsRequested = false; // true if we've made requests for the sim records
- @@ -131,7 +127,6 @@ public abstract class IccRecords extends Handler implements IccConstants {
- + " mCi=" + mCi
- + " mFh=" + mFh
- + " mParentApp=" + mParentApp
- - + " mSpnOverride=" + "mSpnOverride"
- + " recordsLoadedRegistrants=" + mRecordsLoadedRegistrants
- + " mImsiReadyRegistrants=" + mImsiReadyRegistrants
- + " mRecordsEventsRegistrants=" + mRecordsEventsRegistrants
- @@ -184,7 +179,6 @@ public abstract class IccRecords extends Handler implements IccConstants {
- } else {
- mCi.registerForIccRefresh(this, EVENT_REFRESH, null);
- }
- - mSpnOverride = new SpnOverride();
- }
- /**
- @@ -445,15 +439,6 @@ public abstract class IccRecords extends Handler implements IccConstants {
- mSpn = spn;
- }
- - protected void setSpnFromConfig(String carrier) {
- - if (mSpnOverride.containsCarrier(carrier)) {
- - String overrideSpn = mSpnOverride.getSpn(carrier);
- - log("set override spn carrier: " + carrier + ", spn: " + overrideSpn);
- - setServiceProviderName(overrideSpn);
- - setSystemProperty(PROPERTY_ICC_OPERATOR_ALPHA, getServiceProviderName());
- - }
- - }
- -
- /**
- * Set voice mail number to SIM record
- *
- @@ -873,7 +858,6 @@ public abstract class IccRecords extends Handler implements IccConstants {
- pw.println(" mCi=" + mCi);
- pw.println(" mFh=" + mFh);
- pw.println(" mParentApp=" + mParentApp);
- - pw.println(" mSpnOverride=" + mSpnOverride);
- pw.println(" recordsLoadedRegistrants: size=" + mRecordsLoadedRegistrants.size());
- for (int i = 0; i < mRecordsLoadedRegistrants.size(); i++) {
- pw.println(" recordsLoadedRegistrants[" + i + "]="
- diff --git a/src/java/com/android/internal/telephony/uicc/RuimRecords.java b/src/java/com/android/internal/telephony/uicc/RuimRecords.java
- index 4d16293..b7edcec 100644
- --- a/src/java/com/android/internal/telephony/uicc/RuimRecords.java
- +++ b/src/java/com/android/internal/telephony/uicc/RuimRecords.java
- @@ -425,7 +425,7 @@ public final class RuimRecords extends IccRecords {
- }
- if (DBG) log("spn=" + getServiceProviderName());
- if (DBG) log("spnCondition=" + mCsimSpnDisplayCondition);
- - setSystemProperty(PROPERTY_ICC_OPERATOR_ALPHA, getServiceProviderName());
- + SystemProperties.set(PROPERTY_ICC_OPERATOR_ALPHA, getServiceProviderName());
- }
- }
- @@ -923,7 +923,6 @@ public final class RuimRecords extends IccRecords {
- operator + "'");
- setSystemProperty(PROPERTY_ICC_OPERATOR_NUMERIC, operator);
- setSystemProperty(PROPERTY_APN_RUIM_OPERATOR_NUMERIC, operator);
- - setSpnFromConfig(operator);
- } else {
- log("onAllRecordsLoaded empty 'gsm.sim.operator.numeric' skipping");
- }
- diff --git a/src/java/com/android/internal/telephony/uicc/SIMRecords.java b/src/java/com/android/internal/telephony/uicc/SIMRecords.java
- index cd65830..65139d5 100644
- --- a/src/java/com/android/internal/telephony/uicc/SIMRecords.java
- +++ b/src/java/com/android/internal/telephony/uicc/SIMRecords.java
- @@ -61,6 +61,8 @@ public class SIMRecords extends IccRecords {
- VoiceMailConstants mVmConfig;
- + SpnOverride mSpnOverride;
- +
- // ***** Cached SIM State; cleared on channel close
- private boolean mCallForwardingEnabled;
- @@ -99,6 +101,7 @@ public class SIMRecords extends IccRecords {
- public String toString() {
- return "SimRecords: " + super.toString()
- + " mVmConfig" + mVmConfig
- + + " mSpnOverride=" + "mSpnOverride"
- + " callForwardingEnabled=" + mCallForwardingEnabled
- + " spnState=" + mSpnState
- + " mCphsInfo=" + mCphsInfo
- @@ -197,6 +200,7 @@ public class SIMRecords extends IccRecords {
- mAdnCache = new AdnRecordCache(mFh);
- mVmConfig = new VoiceMailConstants();
- + mSpnOverride = new SpnOverride();
- mRecordsRequested = false; // No load request is made till SIM ready
- @@ -1499,6 +1503,14 @@ public class SIMRecords extends IccRecords {
- //***** Private methods
- + private void setSpnFromConfig(String carrier) {
- + if (mSpnOverride.containsCarrier(carrier)) {
- + setServiceProviderName(mSpnOverride.getSpn(carrier));
- + setSystemProperty(PROPERTY_ICC_OPERATOR_ALPHA, getServiceProviderName());
- + }
- + }
- +
- +
- private void setVoiceMailByCountry (String spn) {
- if (mVmConfig.containsCarrier(spn)) {
- mIsVoiceMailFixed = true;
- @@ -1716,7 +1728,6 @@ public class SIMRecords extends IccRecords {
- */
- private void getSpnFsm(boolean start, AsyncResult ar) {
- byte[] data;
- - boolean foundSpn = false;
- if (start) {
- // Check previous state to see if there is outstanding
- @@ -1754,13 +1765,9 @@ public class SIMRecords extends IccRecords {
- if (DBG) log("Load EF_SPN: " + getServiceProviderName()
- + " spnDisplayCondition: " + mSpnDisplayCondition);
- setSystemProperty(PROPERTY_ICC_OPERATOR_ALPHA, getServiceProviderName());
- - if (!TextUtils.isEmpty(getServiceProviderName())) {
- - foundSpn = true;
- - }
- mSpnState = GetSpnFsmState.IDLE;
- - }
- - if (!foundSpn) {
- + } else {
- mFh.loadEFTransparent( EF_SPN_CPHS,
- obtainMessage(EVENT_GET_SPN_DONE));
- mRecordsToLoad++;
- @@ -1780,13 +1787,8 @@ public class SIMRecords extends IccRecords {
- if (DBG) log("Load EF_SPN_CPHS: " + getServiceProviderName());
- setSystemProperty(PROPERTY_ICC_OPERATOR_ALPHA, getServiceProviderName());
- - if (!TextUtils.isEmpty(getServiceProviderName())) {
- - foundSpn = true;
- - }
- -
- mSpnState = GetSpnFsmState.IDLE;
- - }
- - if (!foundSpn) {
- + } else {
- mFh.loadEFTransparent(
- EF_SPN_SHORT_CPHS, obtainMessage(EVENT_GET_SPN_DONE));
- mRecordsToLoad++;
- @@ -1801,16 +1803,9 @@ public class SIMRecords extends IccRecords {
- if (DBG) log("Load EF_SPN_SHORT_CPHS: " + getServiceProviderName());
- setSystemProperty(PROPERTY_ICC_OPERATOR_ALPHA, getServiceProviderName());
- -
- - if (!TextUtils.isEmpty(getServiceProviderName())) {
- - foundSpn = true;
- - }
- -
- - }
- -
- - if (!foundSpn) {
- + }else {
- if (DBG) log("No SPN loaded in either CHPS or 3GPP");
- - if (mPnnHomeName != null && (mSpn == null || TextUtils.isEmpty(mSpn))) {
- + if (mPnnHomeName != null && mSpn == null) {
- if (DBG) log("Falling back to home network name for SPN");
- mSpn = mPnnHomeName;
- setSystemProperty(PROPERTY_ICC_OPERATOR_ALPHA, mSpn);
- @@ -1948,6 +1943,7 @@ public class SIMRecords extends IccRecords {
- pw.println(" extends:");
- super.dump(fd, pw, args);
- pw.println(" mVmConfig=" + mVmConfig);
- + pw.println(" mSpnOverride=" + mSpnOverride);
- pw.println(" mCallForwardingEnabled=" + mCallForwardingEnabled);
- pw.println(" mSpnState=" + mSpnState);
- pw.println(" mCphsInfo=" + mCphsInfo);
- diff --git a/src/java/com/android/internal/telephony/util/BlacklistUtils.java b/src/java/com/android/internal/telephony/util/BlacklistUtils.java
- deleted file mode 100644
- index 1c37ef2..0000000
- --- a/src/java/com/android/internal/telephony/util/BlacklistUtils.java
- +++ /dev/null
- @@ -1,184 +0,0 @@
- -/*
- - * Copyright (C) 2013 The CyanogenMod Project
- - *
- - * Licensed under the Apache License, Version 2.0 (the "License");
- - * you may not use this file except in compliance with the License.
- - * You may obtain a copy of the License at
- - *
- - * http://www.apache.org/licenses/LICENSE-2.0
- - *
- - * Unless required by applicable law or agreed to in writing, software
- - * distributed under the License is distributed on an "AS IS" BASIS,
- - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- - * See the License for the specific language governing permissions and
- - * limitations under the License.
- - */
- -
- -package com.android.internal.telephony.util;
- -
- -import android.content.ContentValues;
- -import android.content.Context;
- -import android.database.Cursor;
- -import android.net.Uri;
- -import android.os.UserHandle;
- -import android.provider.Settings;
- -import android.provider.Telephony.Blacklist;
- -import android.text.TextUtils;
- -import android.util.Log;
- -
- -import java.util.ArrayList;
- -import java.util.List;
- -
- -import com.android.internal.telephony.CallerInfo;
- -
- -/**
- - * Blacklist Utility Class
- - * @hide
- - */
- -public class BlacklistUtils {
- - private static final String TAG = "BlacklistUtils";
- - private static final boolean DEBUG = false;
- -
- - // Blacklist matching type
- - public final static int MATCH_NONE = 0;
- - public final static int MATCH_PRIVATE = 1;
- - public final static int MATCH_UNKNOWN = 2;
- - public final static int MATCH_LIST = 3;
- - public final static int MATCH_REGEX = 4;
- -
- - public final static int BLOCK_CALLS =
- - Settings.System.BLACKLIST_BLOCK << Settings.System.BLACKLIST_PHONE_SHIFT;
- - public final static int BLOCK_MESSAGES =
- - Settings.System.BLACKLIST_BLOCK << Settings.System.BLACKLIST_MESSAGE_SHIFT;
- -
- - public static boolean addOrUpdate(Context context, String number, int flags, int valid) {
- - ContentValues cv = new ContentValues();
- -
- - if ((valid & BLOCK_CALLS) != 0) {
- - cv.put(Blacklist.PHONE_MODE, (flags & BLOCK_CALLS) != 0 ? 1 : 0);
- - }
- - if ((valid & BLOCK_MESSAGES) != 0) {
- - cv.put(Blacklist.MESSAGE_MODE, (flags & BLOCK_MESSAGES) != 0 ? 1 : 0);
- - }
- -
- - Uri uri = Uri.withAppendedPath(Blacklist.CONTENT_FILTER_BYNUMBER_URI, number);
- - int count = context.getContentResolver().update(uri, cv, null, null);
- -
- - return count > 0;
- - }
- -
- - /**
- - * Check if the number is in the blacklist
- - * @param number: Number to check
- - * @return one of: MATCH_NONE, MATCH_PRIVATE, MATCH_UNKNOWN, MATCH_LIST or MATCH_REGEX
- - */
- - public static int isListed(Context context, String number, int mode) {
- - if (!isBlacklistEnabled(context)) {
- - return MATCH_NONE;
- - }
- -
- - if (DEBUG) {
- - Log.d(TAG, "Checking number " + number + " against the Blacklist for mode " + mode);
- - }
- -
- - final String type;
- -
- - if (mode == BLOCK_CALLS) {
- - if (DEBUG) Log.d(TAG, "Checking if an incoming call should be blocked");
- - type = Blacklist.PHONE_MODE;
- - } else if (mode == BLOCK_MESSAGES) {
- - if (DEBUG) Log.d(TAG, "Checking if an incoming message should be blocked");
- - type = Blacklist.MESSAGE_MODE;
- - } else {
- - Log.e(TAG, "Invalid mode " + mode);
- - return MATCH_NONE;
- - }
- -
- - if (isBlacklistUnknownNumberEnabled(context, mode)) {
- - CallerInfo ci = CallerInfo.getCallerInfo(context, number);
- - if (ci == null || !ci.contactExists) {
- - if (DEBUG) Log.d(TAG, "Blacklist matched due to unknown number");
- - return MATCH_UNKNOWN;
- - }
- - }
- -
- - // Private and unknown number matching
- - if (TextUtils.isEmpty(number)) {
- - if (isBlacklistPrivateNumberEnabled(context, mode)) {
- - if (DEBUG) Log.d(TAG, "Blacklist matched due to private number");
- - return MATCH_PRIVATE;
- - }
- - return MATCH_NONE;
- - }
- -
- - Uri.Builder builder = Blacklist.CONTENT_FILTER_BYNUMBER_URI.buildUpon();
- - builder.appendPath(number);
- - if (isBlacklistRegexEnabled(context)) {
- - builder.appendQueryParameter(Blacklist.REGEX_KEY, "1");
- - }
- -
- - int result = MATCH_NONE;
- - Cursor c = context.getContentResolver().query(builder.build(),
- - new String[] { Blacklist.IS_REGEX, type }, null, null, null);
- -
- - if (c != null) {
- - if (DEBUG) Log.d(TAG, "Blacklist query successful, " + c.getCount() + " matches");
- - int regexColumnIndex = c.getColumnIndexOrThrow(Blacklist.IS_REGEX);
- - int modeColumnIndex = c.getColumnIndexOrThrow(type);
- - boolean whitelisted = false;
- -
- - c.moveToPosition(-1);
- - while (c.moveToNext()) {
- - boolean isRegex = c.getInt(regexColumnIndex) != 0;
- - boolean blocked = c.getInt(modeColumnIndex) != 0;
- -
- - if (!isRegex) {
- - whitelisted = !blocked;
- - result = MATCH_LIST;
- - if (blocked) {
- - break;
- - }
- - } else if (blocked) {
- - result = MATCH_REGEX;
- - }
- - }
- - if (whitelisted) {
- - result = MATCH_NONE;
- - }
- - c.close();
- - }
- -
- - if (DEBUG) Log.d(TAG, "Blacklist check result for number " + number + " is " + result);
- - return result;
- - }
- -
- - public static boolean isBlacklistEnabled(Context context) {
- - return Settings.System.getIntForUser(context.getContentResolver(),
- - Settings.System.PHONE_BLACKLIST_ENABLED, 1,
- - UserHandle.USER_CURRENT_OR_SELF) != 0;
- - }
- -
- - public static boolean isBlacklistNotifyEnabled(Context context) {
- - return Settings.System.getIntForUser(context.getContentResolver(),
- - Settings.System.PHONE_BLACKLIST_NOTIFY_ENABLED, 1,
- - UserHandle.USER_CURRENT_OR_SELF) != 0;
- - }
- -
- - public static boolean isBlacklistPrivateNumberEnabled(Context context, int mode) {
- - return (Settings.System.getIntForUser(context.getContentResolver(),
- - Settings.System.PHONE_BLACKLIST_PRIVATE_NUMBER_MODE, 0,
- - UserHandle.USER_CURRENT_OR_SELF) & mode) != 0;
- - }
- -
- - public static boolean isBlacklistUnknownNumberEnabled(Context context, int mode) {
- - return (Settings.System.getIntForUser(context.getContentResolver(),
- - Settings.System.PHONE_BLACKLIST_UNKNOWN_NUMBER_MODE, 0,
- - UserHandle.USER_CURRENT_OR_SELF) & mode) != 0;
- - }
- -
- - public static boolean isBlacklistRegexEnabled(Context context) {
- - return Settings.System.getIntForUser(context.getContentResolver(),
- - Settings.System.PHONE_BLACKLIST_REGEX_ENABLED, 0,
- - UserHandle.USER_CURRENT_OR_SELF) != 0;
- - }
- -}
- diff --git a/src/java/com/google/android/mms/pdu/RetrieveConf.java b/src/java/com/google/android/mms/pdu/RetrieveConf.java
- index 7d2396e..98e67c0 100644
- --- a/src/java/com/google/android/mms/pdu/RetrieveConf.java
- +++ b/src/java/com/google/android/mms/pdu/RetrieveConf.java
- @@ -34,7 +34,6 @@ public class RetrieveConf extends MultimediaMessagePdu {
- public RetrieveConf() throws InvalidHeaderValueException {
- super();
- setMessageType(PduHeaders.MESSAGE_TYPE_RETRIEVE_CONF);
- - setTransactionId(generateTransactionId());
- }
- /**
- @@ -44,7 +43,6 @@ public class RetrieveConf extends MultimediaMessagePdu {
- */
- RetrieveConf(PduHeaders headers) {
- super(headers);
- - setTransactionId(generateTransactionId());
- }
- /**
- @@ -55,12 +53,6 @@ public class RetrieveConf extends MultimediaMessagePdu {
- */
- RetrieveConf(PduHeaders headers, PduBody body) {
- super(headers, body);
- - setTransactionId(generateTransactionId());
- - }
- -
- - private byte[] generateTransactionId() {
- - String transactionId = "T" + Long.toHexString(System.currentTimeMillis());
- - return transactionId.getBytes();
- }
- /**
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement