summaryrefslogtreecommitdiffstats
path: root/telephony
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-02 22:54:33 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-02 22:54:33 -0800
commit3dec7d563a2f3e1eb967ce2054a00b6620e3558c (patch)
treeaa3b0365c47cb3c1607c0dc76c8d32b4046fc287 /telephony
parent15ab3eae2ec3d73b3e8aa60b33ae41445bf83f4b (diff)
downloadframeworks_base-3dec7d563a2f3e1eb967ce2054a00b6620e3558c.zip
frameworks_base-3dec7d563a2f3e1eb967ce2054a00b6620e3558c.tar.gz
frameworks_base-3dec7d563a2f3e1eb967ce2054a00b6620e3558c.tar.bz2
auto import from //depot/cupcake/@137055
Diffstat (limited to 'telephony')
-rw-r--r--telephony/java/android/telephony/gsm/SmsMessage.java28
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/DataConnectionTracker.java3
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/GSMPhone.java36
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/GsmAlphabet.java4
4 files changed, 54 insertions, 17 deletions
diff --git a/telephony/java/android/telephony/gsm/SmsMessage.java b/telephony/java/android/telephony/gsm/SmsMessage.java
index f79b0a0..c2e0165 100644
--- a/telephony/java/android/telephony/gsm/SmsMessage.java
+++ b/telephony/java/android/telephony/gsm/SmsMessage.java
@@ -467,7 +467,7 @@ public class SmsMessage {
* units remaining until the next message. int[3] is the encoding
* type that should be used for the message.
*/
- public static int[] calculateLength(String messageBody, boolean use7bitOnly) {
+ public static int[] calculateLength(CharSequence messageBody, boolean use7bitOnly) {
int ret[] = new int[4];
try {
@@ -502,6 +502,25 @@ public class SmsMessage {
return ret;
}
+ /**
+ * Calculates the number of SMS's required to encode the message body and
+ * the number of characters remaining until the next message, given the
+ * current encoding.
+ *
+ * @param messageBody the message to encode
+ * @param use7bitOnly if true, characters that are not part of the GSM
+ * alphabet are counted as a single space char. If false, a
+ * messageBody containing non-GSM alphabet characters is calculated
+ * for 16-bit encoding.
+ * @return an int[4] with int[0] being the number of SMS's required, int[1]
+ * the number of code units used, and int[2] is the number of code
+ * units remaining until the next message. int[3] is the encoding
+ * type that should be used for the message.
+ */
+ public static int[] calculateLength(String messageBody, boolean use7bitOnly) {
+ return calculateLength((CharSequence)messageBody, use7bitOnly);
+ }
+
/**
* Get an SMS-SUBMIT PDU for a destination address and a message
@@ -541,7 +560,12 @@ public class SmsMessage {
// TP-Data-Coding-Scheme
// Default encoding, uncompressed
- bo.write(0x00);
+ // To test writing messages to the SIM card, change this value 0x00 to 0x12, which
+ // means "bits 1 and 0 contain message class, and the class is 2". Note that this
+ // takes effect for the sender. In other words, messages sent by the phone with this
+ // change will end up on the receiver's SIM card. You can then send messages to
+ // yourself (on a phone with this change) and they'll end up on the SIM card.
+ bo.write(0x00);
// (no TP-Validity-Period)
diff --git a/telephony/java/com/android/internal/telephony/gsm/DataConnectionTracker.java b/telephony/java/com/android/internal/telephony/gsm/DataConnectionTracker.java
index 1c64641..4769cd1 100644
--- a/telephony/java/com/android/internal/telephony/gsm/DataConnectionTracker.java
+++ b/telephony/java/com/android/internal/telephony/gsm/DataConnectionTracker.java
@@ -884,6 +884,9 @@ final class DataConnectionTracker extends Handler
isConnected = (state != State.IDLE && state != State.FAILED);
+ // The "current" may no longer be valid. MMS depends on this to send properly.
+ phone.updateCurrentCarrierInProvider();
+
// TODO: It'd be nice to only do this if the changed entrie(s)
// match the current operator.
createAllApnList();
diff --git a/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java b/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java
index 4ad65fc..f93c724 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java
@@ -1383,18 +1383,8 @@ public class GSMPhone extends PhoneBase {
break;
case EVENT_SIM_RECORDS_LOADED:
- mSIMRecords.getSIMOperatorNumeric();
-
- try {
- //set the current field the telephony provider according to
- //the SIM's operator
- Uri uri = Uri.withAppendedPath(Telephony.Carriers.CONTENT_URI, "current");
- ContentValues map = new ContentValues();
- map.put(Telephony.Carriers.NUMERIC, mSIMRecords.getSIMOperatorNumeric());
- mContext.getContentResolver().insert(uri, map);
- } catch (SQLException e) {
- Log.e(LOG_TAG, "Can't store current operator", e);
- }
+ updateCurrentCarrierInProvider();
+
// Check if this is a different SIM than the previous one. If so unset the
// voice mail number.
String imsi = getVmSimImsi();
@@ -1535,7 +1525,27 @@ public class GSMPhone extends PhoneBase {
}
}
}
-
+
+ /**
+ * Sets the "current" field in the telephony provider according to the SIM's operator
+ *
+ * @return true for success; false otherwise.
+ */
+ boolean updateCurrentCarrierInProvider() {
+ if (mSIMRecords != null) {
+ try {
+ Uri uri = Uri.withAppendedPath(Telephony.Carriers.CONTENT_URI, "current");
+ ContentValues map = new ContentValues();
+ map.put(Telephony.Carriers.NUMERIC, mSIMRecords.getSIMOperatorNumeric());
+ mContext.getContentResolver().insert(uri, map);
+ return true;
+ } catch (SQLException e) {
+ Log.e(LOG_TAG, "Can't store current operator", e);
+ }
+ }
+ return false;
+ }
+
/**
* Used to track the settings upon completion of the network change.
*/
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmAlphabet.java b/telephony/java/com/android/internal/telephony/gsm/GsmAlphabet.java
index 59a9422..df34897 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GsmAlphabet.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GsmAlphabet.java
@@ -532,7 +532,7 @@ public class GsmAlphabet
* needed to represent this string. Counts unencodable char as 1 septet.
*/
public static int
- countGsmSeptets(String s)
+ countGsmSeptets(CharSequence s)
{
try {
return countGsmSeptets(s, false);
@@ -549,7 +549,7 @@ public class GsmAlphabet
* char. Otherwise, counts invalid char as 1 septet
*/
public static int
- countGsmSeptets(String s, boolean throwsException) throws EncodeException
+ countGsmSeptets(CharSequence s, boolean throwsException) throws EncodeException
{
int charIndex = 0;
int sz = s.length();