Merge "Cosmetic cleanups to SMSDispatcher classes." into gingerbread
This commit is contained in:
@ -44,10 +44,6 @@ import android.util.Config;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
import com.android.internal.telephony.CommandsInterface;
|
|
||||||
import com.android.internal.telephony.SmsMessageBase;
|
|
||||||
import com.android.internal.telephony.SmsResponse;
|
|
||||||
import com.android.internal.telephony.WapPushOverSms;
|
|
||||||
import com.android.internal.util.HexDump;
|
import com.android.internal.util.HexDump;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
@ -75,7 +71,7 @@ public abstract class SMSDispatcher extends Handler {
|
|||||||
private static final int DEFAULT_SMS_MAX_COUNT = 100;
|
private static final int DEFAULT_SMS_MAX_COUNT = 100;
|
||||||
|
|
||||||
/** Default timeout for SMS sent query */
|
/** Default timeout for SMS sent query */
|
||||||
private static final int DEFAULT_SMS_TIMOUEOUT = 6000;
|
private static final int DEFAULT_SMS_TIMEOUT = 6000;
|
||||||
|
|
||||||
protected static final String[] RAW_PROJECTION = new String[] {
|
protected static final String[] RAW_PROJECTION = new String[] {
|
||||||
"pdu",
|
"pdu",
|
||||||
@ -83,8 +79,6 @@ public abstract class SMSDispatcher extends Handler {
|
|||||||
"destination_port",
|
"destination_port",
|
||||||
};
|
};
|
||||||
|
|
||||||
static final int MAIL_SEND_SMS = 1;
|
|
||||||
|
|
||||||
static final protected int EVENT_NEW_SMS = 1;
|
static final protected int EVENT_NEW_SMS = 1;
|
||||||
|
|
||||||
static final protected int EVENT_SEND_SMS_COMPLETE = 2;
|
static final protected int EVENT_SEND_SMS_COMPLETE = 2;
|
||||||
@ -143,7 +137,7 @@ public abstract class SMSDispatcher extends Handler {
|
|||||||
|
|
||||||
private SmsCounter mCounter;
|
private SmsCounter mCounter;
|
||||||
|
|
||||||
private ArrayList mSTrackers = new ArrayList(MO_MSG_QUEUE_LIMIT);
|
private ArrayList<SmsTracker> mSTrackers = new ArrayList<SmsTracker>(MO_MSG_QUEUE_LIMIT);
|
||||||
|
|
||||||
/** Wake lock to ensure device stays awake while dispatching the SMS intent. */
|
/** Wake lock to ensure device stays awake while dispatching the SMS intent. */
|
||||||
private PowerManager.WakeLock mWakeLock;
|
private PowerManager.WakeLock mWakeLock;
|
||||||
@ -154,10 +148,6 @@ public abstract class SMSDispatcher extends Handler {
|
|||||||
*/
|
*/
|
||||||
private final int WAKE_LOCK_TIMEOUT = 5000;
|
private final int WAKE_LOCK_TIMEOUT = 5000;
|
||||||
|
|
||||||
private static SmsMessage mSmsMessage;
|
|
||||||
private static SmsMessageBase mSmsMessageBase;
|
|
||||||
private SmsMessageBase.SubmitPduBase mSubmitPduBase;
|
|
||||||
|
|
||||||
protected boolean mStorageAvailable = true;
|
protected boolean mStorageAvailable = true;
|
||||||
protected boolean mReportMemoryStatusPending = false;
|
protected boolean mReportMemoryStatusPending = false;
|
||||||
|
|
||||||
@ -345,7 +335,7 @@ public abstract class SMSDispatcher extends Handler {
|
|||||||
msg.obj = null;
|
msg.obj = null;
|
||||||
if (mSTrackers.isEmpty() == false) {
|
if (mSTrackers.isEmpty() == false) {
|
||||||
try {
|
try {
|
||||||
SmsTracker sTracker = (SmsTracker)mSTrackers.remove(0);
|
SmsTracker sTracker = mSTrackers.remove(0);
|
||||||
sTracker.mSentIntent.send(RESULT_ERROR_LIMIT_EXCEEDED);
|
sTracker.mSentIntent.send(RESULT_ERROR_LIMIT_EXCEEDED);
|
||||||
} catch (CanceledException ex) {
|
} catch (CanceledException ex) {
|
||||||
Log.e(TAG, "failed to send back RESULT_ERROR_LIMIT_EXCEEDED");
|
Log.e(TAG, "failed to send back RESULT_ERROR_LIMIT_EXCEEDED");
|
||||||
@ -358,7 +348,7 @@ public abstract class SMSDispatcher extends Handler {
|
|||||||
|
|
||||||
case EVENT_SEND_CONFIRMED_SMS:
|
case EVENT_SEND_CONFIRMED_SMS:
|
||||||
if (mSTrackers.isEmpty() == false) {
|
if (mSTrackers.isEmpty() == false) {
|
||||||
SmsTracker sTracker = (SmsTracker)mSTrackers.remove(mSTrackers.size() - 1);
|
SmsTracker sTracker = mSTrackers.remove(mSTrackers.size() - 1);
|
||||||
if (isMultipartTracker(sTracker)) {
|
if (isMultipartTracker(sTracker)) {
|
||||||
sendMultipartSms(sTracker);
|
sendMultipartSms(sTracker);
|
||||||
} else {
|
} else {
|
||||||
@ -372,7 +362,7 @@ public abstract class SMSDispatcher extends Handler {
|
|||||||
if (mSTrackers.isEmpty() == false) {
|
if (mSTrackers.isEmpty() == false) {
|
||||||
// Remove the latest one.
|
// Remove the latest one.
|
||||||
try {
|
try {
|
||||||
SmsTracker sTracker = (SmsTracker)mSTrackers.remove(mSTrackers.size() - 1);
|
SmsTracker sTracker = mSTrackers.remove(mSTrackers.size() - 1);
|
||||||
sTracker.mSentIntent.send(RESULT_ERROR_LIMIT_EXCEEDED);
|
sTracker.mSentIntent.send(RESULT_ERROR_LIMIT_EXCEEDED);
|
||||||
} catch (CanceledException ex) {
|
} catch (CanceledException ex) {
|
||||||
Log.e(TAG, "failed to send back RESULT_ERROR_LIMIT_EXCEEDED");
|
Log.e(TAG, "failed to send back RESULT_ERROR_LIMIT_EXCEEDED");
|
||||||
@ -679,7 +669,7 @@ public abstract class SMSDispatcher extends Handler {
|
|||||||
* @param destPort the port to deliver the message to
|
* @param destPort the port to deliver the message to
|
||||||
* @param data the body of the message to send
|
* @param data the body of the message to send
|
||||||
* @param sentIntent if not NULL this <code>PendingIntent</code> is
|
* @param sentIntent if not NULL this <code>PendingIntent</code> is
|
||||||
* broadcast when the message is sucessfully sent, or failed.
|
* broadcast when the message is successfully sent, or failed.
|
||||||
* The result code will be <code>Activity.RESULT_OK<code> for success,
|
* The result code will be <code>Activity.RESULT_OK<code> for success,
|
||||||
* or one of these errors:<br>
|
* or one of these errors:<br>
|
||||||
* <code>RESULT_ERROR_GENERIC_FAILURE</code><br>
|
* <code>RESULT_ERROR_GENERIC_FAILURE</code><br>
|
||||||
@ -706,7 +696,7 @@ public abstract class SMSDispatcher extends Handler {
|
|||||||
* the current default SMSC
|
* the current default SMSC
|
||||||
* @param text the body of the message to send
|
* @param text the body of the message to send
|
||||||
* @param sentIntent if not NULL this <code>PendingIntent</code> is
|
* @param sentIntent if not NULL this <code>PendingIntent</code> is
|
||||||
* broadcast when the message is sucessfully sent, or failed.
|
* broadcast when the message is successfully sent, or failed.
|
||||||
* The result code will be <code>Activity.RESULT_OK<code> for success,
|
* The result code will be <code>Activity.RESULT_OK<code> for success,
|
||||||
* or one of these errors:<br>
|
* or one of these errors:<br>
|
||||||
* <code>RESULT_ERROR_GENERIC_FAILURE</code><br>
|
* <code>RESULT_ERROR_GENERIC_FAILURE</code><br>
|
||||||
@ -761,7 +751,7 @@ public abstract class SMSDispatcher extends Handler {
|
|||||||
* defatult SMSC
|
* defatult SMSC
|
||||||
* @param pdu the raw PDU to send
|
* @param pdu the raw PDU to send
|
||||||
* @param sentIntent if not NULL this <code>Intent</code> is
|
* @param sentIntent if not NULL this <code>Intent</code> is
|
||||||
* broadcast when the message is sucessfully sent, or failed.
|
* broadcast when the message is successfully sent, or failed.
|
||||||
* The result code will be <code>Activity.RESULT_OK<code> for success,
|
* The result code will be <code>Activity.RESULT_OK<code> for success,
|
||||||
* or one of these errors:
|
* or one of these errors:
|
||||||
* <code>RESULT_ERROR_GENERIC_FAILURE</code>
|
* <code>RESULT_ERROR_GENERIC_FAILURE</code>
|
||||||
@ -837,7 +827,7 @@ public abstract class SMSDispatcher extends Handler {
|
|||||||
|
|
||||||
mSTrackers.add(tracker);
|
mSTrackers.add(tracker);
|
||||||
sendMessageDelayed ( obtainMessage(EVENT_ALERT_TIMEOUT, d),
|
sendMessageDelayed ( obtainMessage(EVENT_ALERT_TIMEOUT, d),
|
||||||
DEFAULT_SMS_TIMOUEOUT);
|
DEFAULT_SMS_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getAppNameByIntent(PendingIntent intent) {
|
protected String getAppNameByIntent(PendingIntent intent) {
|
||||||
@ -931,7 +921,7 @@ public abstract class SMSDispatcher extends Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keeps track of an SMS that has been sent to the RIL, until it it has
|
* Keeps track of an SMS that has been sent to the RIL, until it has
|
||||||
* successfully been sent, or we're done trying.
|
* successfully been sent, or we're done trying.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -972,27 +962,26 @@ public abstract class SMSDispatcher extends Handler {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private BroadcastReceiver mResultReceiver = new BroadcastReceiver() {
|
private BroadcastReceiver mResultReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
if (intent.getAction().equals(Intent.ACTION_DEVICE_STORAGE_LOW)) {
|
if (intent.getAction().equals(Intent.ACTION_DEVICE_STORAGE_LOW)) {
|
||||||
mStorageAvailable = false;
|
mStorageAvailable = false;
|
||||||
mCm.reportSmsMemoryStatus(false, obtainMessage(EVENT_REPORT_MEMORY_STATUS_DONE));
|
mCm.reportSmsMemoryStatus(false, obtainMessage(EVENT_REPORT_MEMORY_STATUS_DONE));
|
||||||
} else if (intent.getAction().equals(Intent.ACTION_DEVICE_STORAGE_OK)) {
|
} else if (intent.getAction().equals(Intent.ACTION_DEVICE_STORAGE_OK)) {
|
||||||
mStorageAvailable = true;
|
mStorageAvailable = true;
|
||||||
mCm.reportSmsMemoryStatus(true, obtainMessage(EVENT_REPORT_MEMORY_STATUS_DONE));
|
mCm.reportSmsMemoryStatus(true, obtainMessage(EVENT_REPORT_MEMORY_STATUS_DONE));
|
||||||
} else {
|
} else {
|
||||||
// Assume the intent is one of the SMS receive intents that
|
// Assume the intent is one of the SMS receive intents that
|
||||||
// was sent as an ordered broadcast. Check result and ACK.
|
// was sent as an ordered broadcast. Check result and ACK.
|
||||||
int rc = getResultCode();
|
int rc = getResultCode();
|
||||||
boolean success = (rc == Activity.RESULT_OK)
|
boolean success = (rc == Activity.RESULT_OK)
|
||||||
|| (rc == Intents.RESULT_SMS_HANDLED);
|
|| (rc == Intents.RESULT_SMS_HANDLED);
|
||||||
|
|
||||||
// For a multi-part message, this only ACKs the last part.
|
// For a multi-part message, this only ACKs the last part.
|
||||||
// Previous parts were ACK'd as they were received.
|
// Previous parts were ACK'd as they were received.
|
||||||
acknowledgeLastIncomingSms(success, rc, null);
|
acknowledgeLastIncomingSms(success, rc, null);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -28,21 +28,20 @@ import android.database.SQLException;
|
|||||||
import android.os.AsyncResult;
|
import android.os.AsyncResult;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.provider.Telephony;
|
import android.provider.Telephony;
|
||||||
import android.provider.Telephony.Sms.Intents;
|
import android.provider.Telephony.Sms.Intents;
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.util.Config;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.telephony.SmsManager;
|
import android.telephony.SmsManager;
|
||||||
import android.telephony.SmsMessage.MessageClass;
|
import android.telephony.SmsMessage.MessageClass;
|
||||||
|
import android.util.Config;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.internal.telephony.TelephonyProperties;
|
|
||||||
import com.android.internal.telephony.CommandsInterface;
|
import com.android.internal.telephony.CommandsInterface;
|
||||||
|
import com.android.internal.telephony.SMSDispatcher;
|
||||||
import com.android.internal.telephony.SmsHeader;
|
import com.android.internal.telephony.SmsHeader;
|
||||||
import com.android.internal.telephony.SmsMessageBase;
|
import com.android.internal.telephony.SmsMessageBase;
|
||||||
import com.android.internal.telephony.SMSDispatcher;
|
|
||||||
import com.android.internal.telephony.SmsMessageBase.TextEncodingDetails;
|
import com.android.internal.telephony.SmsMessageBase.TextEncodingDetails;
|
||||||
import com.android.internal.telephony.cdma.SmsMessage;
|
import com.android.internal.telephony.TelephonyProperties;
|
||||||
import com.android.internal.telephony.cdma.sms.SmsEnvelope;
|
import com.android.internal.telephony.cdma.sms.SmsEnvelope;
|
||||||
import com.android.internal.telephony.cdma.sms.UserData;
|
import com.android.internal.telephony.cdma.sms.UserData;
|
||||||
import com.android.internal.util.HexDump;
|
import com.android.internal.util.HexDump;
|
||||||
@ -51,20 +50,16 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.lang.Boolean;
|
|
||||||
|
|
||||||
|
|
||||||
final class CdmaSMSDispatcher extends SMSDispatcher {
|
final class CdmaSMSDispatcher extends SMSDispatcher {
|
||||||
private static final String TAG = "CDMA";
|
private static final String TAG = "CDMA";
|
||||||
|
|
||||||
private CDMAPhone mCdmaPhone;
|
|
||||||
|
|
||||||
private byte[] mLastDispatchedSmsFingerprint;
|
private byte[] mLastDispatchedSmsFingerprint;
|
||||||
private byte[] mLastAcknowledgedSmsFingerprint;
|
private byte[] mLastAcknowledgedSmsFingerprint;
|
||||||
|
|
||||||
CdmaSMSDispatcher(CDMAPhone phone) {
|
CdmaSMSDispatcher(CDMAPhone phone) {
|
||||||
super(phone);
|
super(phone);
|
||||||
mCdmaPhone = phone;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -129,7 +124,7 @@ final class CdmaSMSDispatcher extends SMSDispatcher {
|
|||||||
Log.d(TAG, "Voicemail count=" + voicemailCount);
|
Log.d(TAG, "Voicemail count=" + voicemailCount);
|
||||||
// Store the voicemail count in preferences.
|
// Store the voicemail count in preferences.
|
||||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(
|
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(
|
||||||
((CDMAPhone) mPhone).getContext());
|
mPhone.getContext());
|
||||||
SharedPreferences.Editor editor = sp.edit();
|
SharedPreferences.Editor editor = sp.edit();
|
||||||
editor.putInt(CDMAPhone.VM_COUNT_CDMA, voicemailCount);
|
editor.putInt(CDMAPhone.VM_COUNT_CDMA, voicemailCount);
|
||||||
editor.commit();
|
editor.commit();
|
||||||
@ -176,7 +171,7 @@ final class CdmaSMSDispatcher extends SMSDispatcher {
|
|||||||
* TODO(cleanup): Why are we using a getter method for this
|
* TODO(cleanup): Why are we using a getter method for this
|
||||||
* (and for so many other sms fields)? Trivial getters and
|
* (and for so many other sms fields)? Trivial getters and
|
||||||
* setters like this are direct violations of the style guide.
|
* setters like this are direct violations of the style guide.
|
||||||
* If the purpose is to protect agaist writes (by not
|
* If the purpose is to protect against writes (by not
|
||||||
* providing a setter) then any protection is illusory (and
|
* providing a setter) then any protection is illusory (and
|
||||||
* hence bad) for cases where the values are not primitives,
|
* hence bad) for cases where the values are not primitives,
|
||||||
* such as this call for the header. Since this is an issue
|
* such as this call for the header. Since this is an issue
|
||||||
@ -440,7 +435,7 @@ final class CdmaSMSDispatcher extends SMSDispatcher {
|
|||||||
protected void sendSms(SmsTracker tracker) {
|
protected void sendSms(SmsTracker tracker) {
|
||||||
HashMap map = tracker.mData;
|
HashMap map = tracker.mData;
|
||||||
|
|
||||||
byte smsc[] = (byte[]) map.get("smsc");
|
// byte smsc[] = (byte[]) map.get("smsc"); // unused for CDMA
|
||||||
byte pdu[] = (byte[]) map.get("pdu");
|
byte pdu[] = (byte[]) map.get("pdu");
|
||||||
|
|
||||||
Message reply = obtainMessage(EVENT_SEND_SMS_COMPLETE, tracker);
|
Message reply = obtainMessage(EVENT_SEND_SMS_COMPLETE, tracker);
|
||||||
|
@ -27,13 +27,12 @@ import android.telephony.ServiceState;
|
|||||||
import android.util.Config;
|
import android.util.Config;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.internal.telephony.IccUtils;
|
|
||||||
import com.android.internal.telephony.SmsMessageBase.TextEncodingDetails;
|
|
||||||
import com.android.internal.telephony.gsm.SmsMessage;
|
|
||||||
import com.android.internal.telephony.CommandsInterface;
|
import com.android.internal.telephony.CommandsInterface;
|
||||||
|
import com.android.internal.telephony.IccUtils;
|
||||||
import com.android.internal.telephony.SMSDispatcher;
|
import com.android.internal.telephony.SMSDispatcher;
|
||||||
import com.android.internal.telephony.SmsHeader;
|
import com.android.internal.telephony.SmsHeader;
|
||||||
import com.android.internal.telephony.SmsMessageBase;
|
import com.android.internal.telephony.SmsMessageBase;
|
||||||
|
import com.android.internal.telephony.SmsMessageBase.TextEncodingDetails;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -97,20 +96,20 @@ final class GsmSMSDispatcher extends SMSDispatcher {
|
|||||||
if (sms.isTypeZero()) {
|
if (sms.isTypeZero()) {
|
||||||
// As per 3GPP TS 23.040 9.2.3.9, Type Zero messages should not be
|
// As per 3GPP TS 23.040 9.2.3.9, Type Zero messages should not be
|
||||||
// Displayed/Stored/Notified. They should only be acknowledged.
|
// Displayed/Stored/Notified. They should only be acknowledged.
|
||||||
Log.d(TAG, "Received short message type 0, Dont display or store it. Send Ack");
|
Log.d(TAG, "Received short message type 0, Don't display or store it. Send Ack");
|
||||||
return Intents.RESULT_SMS_HANDLED;
|
return Intents.RESULT_SMS_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special case the message waiting indicator messages
|
// Special case the message waiting indicator messages
|
||||||
if (sms.isMWISetMessage()) {
|
if (sms.isMWISetMessage()) {
|
||||||
mGsmPhone.updateMessageWaitingIndicator(true);
|
mGsmPhone.updateMessageWaitingIndicator(true);
|
||||||
handled |= sms.isMwiDontStore();
|
handled = sms.isMwiDontStore();
|
||||||
if (Config.LOGD) {
|
if (Config.LOGD) {
|
||||||
Log.d(TAG, "Received voice mail indicator set SMS shouldStore=" + !handled);
|
Log.d(TAG, "Received voice mail indicator set SMS shouldStore=" + !handled);
|
||||||
}
|
}
|
||||||
} else if (sms.isMWIClearMessage()) {
|
} else if (sms.isMWIClearMessage()) {
|
||||||
mGsmPhone.updateMessageWaitingIndicator(false);
|
mGsmPhone.updateMessageWaitingIndicator(false);
|
||||||
handled |= sms.isMwiDontStore();
|
handled = sms.isMwiDontStore();
|
||||||
if (Config.LOGD) {
|
if (Config.LOGD) {
|
||||||
Log.d(TAG, "Received voice mail indicator clear SMS shouldStore=" + !handled);
|
Log.d(TAG, "Received voice mail indicator clear SMS shouldStore=" + !handled);
|
||||||
}
|
}
|
||||||
@ -301,7 +300,7 @@ final class GsmSMSDispatcher extends SMSDispatcher {
|
|||||||
map.put("smsc", pdus.encodedScAddress);
|
map.put("smsc", pdus.encodedScAddress);
|
||||||
map.put("pdu", pdus.encodedMessage);
|
map.put("pdu", pdus.encodedMessage);
|
||||||
|
|
||||||
SmsTracker tracker = SmsTrackerFactory(map, sentIntent, deliveryIntent);
|
SmsTracker tracker = SmsTrackerFactory(map, sentIntent, deliveryIntent);
|
||||||
sendSms(tracker);
|
sendSms(tracker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user