Merge "DO NOT MERGE Update CTS Version to 2.3_r10" into gingerbread
diff --git a/tests/tests/telephony/src/android/telephony/cts/PhoneNumberUtilsTest.java b/tests/tests/telephony/src/android/telephony/cts/PhoneNumberUtilsTest.java
index 23891e0..1c45735 100644
--- a/tests/tests/telephony/src/android/telephony/cts/PhoneNumberUtilsTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/PhoneNumberUtilsTest.java
@@ -455,6 +455,11 @@
 
         // Test isWellFormedSmsAddress
         assertTrue(PhoneNumberUtils.isWellFormedSmsAddress("+17005554141"));
-        assertFalse(PhoneNumberUtils.isWellFormedSmsAddress("android"));
+        // KT allow a to be a dialable character, the network portion of 'android' is 'a'
+        if (TelephonyUtils.isKt(tm)) {
+            assertTrue(PhoneNumberUtils.isWellFormedSmsAddress("android"));
+        } else {
+            assertFalse(PhoneNumberUtils.isWellFormedSmsAddress("android"));
+        }
     }
 }
diff --git a/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java b/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
index ddce3cd..c0c26ef 100755
--- a/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
@@ -27,12 +27,12 @@
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.pm.PackageManager;
+import android.os.Bundle;
 import android.os.SystemClock;
 import android.telephony.SmsManager;
+import android.telephony.SmsMessage;
 import android.telephony.TelephonyManager;
 import android.test.AndroidTestCase;
-import android.telephony.SmsMessage;
-import android.os.Bundle;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -46,7 +46,6 @@
 @TestTargetClass(SmsManager.class)
 public class SmsManagerTest extends AndroidTestCase {
 
-    private static final int NUM_TEXT_PARTS = 3;
     private static final String LONG_TEXT =
         "This is a very long text. This text should be broken into three " +
         "separate messages.This is a very long text. This text should be broken into " +
@@ -157,9 +156,21 @@
     public void testDivideMessage() {
         ArrayList<String> dividedMessages = divideMessage(LONG_TEXT);
         assertNotNull(dividedMessages);
-        assertEquals(NUM_TEXT_PARTS, dividedMessages.size());
-        assertEquals(LONG_TEXT,
-                dividedMessages.get(0) + dividedMessages.get(1) + dividedMessages.get(2));
+        int numParts;
+        if (TelephonyUtils.isSkt(mTelephonyManager)) {
+            numParts = 5;
+        } else if (TelephonyUtils.isKt(mTelephonyManager)) {
+            numParts = 4;
+        } else {
+            numParts = 3;
+        }
+        assertEquals(numParts, dividedMessages.size());
+
+        String actualMessage = "";
+        for (int i = 0; i < numParts; i++) {
+            actualMessage += dividedMessages.get(i);
+        }
+        assertEquals(LONG_TEXT, actualMessage);
     }
 
     @TestTargets({
diff --git a/tests/tests/telephony/src/android/telephony/cts/SmsMessageTest.java b/tests/tests/telephony/src/android/telephony/cts/SmsMessageTest.java
index 515f8b5..f9f1f15 100644
--- a/tests/tests/telephony/src/android/telephony/cts/SmsMessageTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/SmsMessageTest.java
@@ -30,7 +30,6 @@
 public class SmsMessageTest extends AndroidTestCase{
 
     private TelephonyManager mTelephonyManager;
-
     private static final String DISPLAY_MESSAGE_BODY = "test subject /test body";
     private static final String DMB = "{ testBody[^~\\] }";
     private static final String EMAIL_ADD = "foo@example.com";
@@ -184,7 +183,7 @@
         int[] result = SmsMessage.calculateLength(sms.getMessageBody(), true);
         assertEquals(SMS_NUMBER1, result[0]);
         assertEquals(sms.getMessageBody().length(), result[1]);
-        assertEquals(SmsMessage.MAX_USER_DATA_SEPTETS - sms.getMessageBody().length(), result[2]);
+        assertEquals(getNumSeptets() - sms.getMessageBody().length(), result[2]);
         assertEquals(SmsMessage.ENCODING_7BIT, result[3]);
         assertEquals(pdu, toHexString(sms.getPdu()));
 
@@ -216,7 +215,7 @@
         result = SmsMessage.calculateLength(msgBody, false);
         assertEquals(SMS_NUMBER2, result[0]);
         assertEquals(sms.getMessageBody().length(), result[1]);
-        assertEquals(SmsMessage.MAX_USER_DATA_SEPTETS - sms.getMessageBody().length(), result[2]);
+        assertEquals(getNumSeptets() - sms.getMessageBody().length(), result[2]);
         assertEquals(SmsMessage.ENCODING_7BIT, result[3]);
 
         // Test createFromPdu Ucs to Sms
@@ -227,10 +226,20 @@
         result = SmsMessage.calculateLength(sms.getMessageBody(), true);
         assertEquals(SMS_NUMBER3, result[0]);
         assertEquals(sms.getMessageBody().length(), result[1]);
-        assertEquals(SmsMessage.MAX_USER_DATA_SEPTETS - sms.getMessageBody().length(), result[2]);
+        assertEquals(getNumSeptets() - sms.getMessageBody().length(), result[2]);
         assertEquals(SmsMessage.ENCODING_7BIT, result[3]);
     }
 
+    private int getNumSeptets() {
+        if (TelephonyUtils.isSkt(mTelephonyManager)) {
+            return 80;
+        } else if (TelephonyUtils.isKt(mTelephonyManager)) {
+            return 90;
+        } else {
+            return SmsMessage.MAX_USER_DATA_SEPTETS;
+        }
+    }
+
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,
diff --git a/tests/tests/telephony/src/android/telephony/cts/TelephonyUtils.java b/tests/tests/telephony/src/android/telephony/cts/TelephonyUtils.java
new file mode 100644
index 0000000..c2ca833
--- /dev/null
+++ b/tests/tests/telephony/src/android/telephony/cts/TelephonyUtils.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2011 The Android Open Source 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 android.telephony.cts;
+
+import android.telephony.TelephonyManager;
+
+class TelephonyUtils {
+
+    public static boolean isSkt(TelephonyManager telephonyManager) {
+        return isOperator(telephonyManager, "45005");
+    }
+
+    public static boolean isKt(TelephonyManager telephonyManager) {
+        return isOperator(telephonyManager, "45002")
+                || isOperator(telephonyManager, "45004")
+                || isOperator(telephonyManager, "45008");
+    }
+
+    private static boolean isOperator(TelephonyManager telephonyManager, String operator) {
+        String simOperator = telephonyManager.getSimOperator();
+        return simOperator != null && simOperator.equals(operator);
+    }
+
+    private TelephonyUtils() {
+    }
+}