Fix SKT and KT Special Cases

Allow the special SKT and KT scenarios to permit the original
test cases, since those special cases don't apply everywhere
it seems...

Change-Id: Idf7ba9fab4338d2d3b52d629df074521d5cd1957
diff --git a/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java b/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
index c0c26ef..bda7172 100755
--- a/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
@@ -158,19 +158,24 @@
         assertNotNull(dividedMessages);
         int numParts;
         if (TelephonyUtils.isSkt(mTelephonyManager)) {
-            numParts = 5;
+            assertTrue(isComplete(dividedMessages, 5) || isComplete(dividedMessages, 3));
         } else if (TelephonyUtils.isKt(mTelephonyManager)) {
-            numParts = 4;
+            assertTrue(isComplete(dividedMessages, 4) || isComplete(dividedMessages, 3));
         } else {
-            numParts = 3;
+            assertTrue(isComplete(dividedMessages, 3));
         }
-        assertEquals(numParts, dividedMessages.size());
+    }
+
+    private boolean isComplete(List<String> dividedMessages, int numParts) {
+        if (dividedMessages.size() != numParts) {
+            return false;
+        }
 
         String actualMessage = "";
         for (int i = 0; i < numParts; i++) {
             actualMessage += dividedMessages.get(i);
         }
-        assertEquals(LONG_TEXT, actualMessage);
+        return LONG_TEXT.equals(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 27f290b..4b5b55a 100644
--- a/tests/tests/telephony/src/android/telephony/cts/SmsMessageTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/SmsMessageTest.java
@@ -65,6 +65,8 @@
     private static final int STATUS_ON_ICC_DEF = -1;
     private static final int TPLAYER_LENGTH_FOR_PDU = 23;
     private static final long TIMESTAMP_MILLIS = 1149631383000l;
+    private static final int SEPTETS_SKT = 80;
+    private static final int SEPTETS_KT = 90;
 
     @Override
     protected void setUp() throws Exception {
@@ -188,7 +190,7 @@
         int[] result = SmsMessage.calculateLength(sms.getMessageBody(), true);
         assertEquals(SMS_NUMBER1, result[0]);
         assertEquals(sms.getMessageBody().length(), result[1]);
-        assertEquals(getNumSeptets() - sms.getMessageBody().length(), result[2]);
+        assertRemaining(sms.getMessageBody().length(), result[2]);
         assertEquals(SmsMessage.ENCODING_7BIT, result[3]);
         assertEquals(pdu, toHexString(sms.getPdu()));
 
@@ -220,7 +222,7 @@
         result = SmsMessage.calculateLength(msgBody, false);
         assertEquals(SMS_NUMBER2, result[0]);
         assertEquals(sms.getMessageBody().length(), result[1]);
-        assertEquals(getNumSeptets() - sms.getMessageBody().length(), result[2]);
+        assertRemaining(sms.getMessageBody().length(), result[2]);
         assertEquals(SmsMessage.ENCODING_7BIT, result[3]);
 
         // Test createFromPdu Ucs to Sms
@@ -231,20 +233,26 @@
         result = SmsMessage.calculateLength(sms.getMessageBody(), true);
         assertEquals(SMS_NUMBER3, result[0]);
         assertEquals(sms.getMessageBody().length(), result[1]);
-        assertEquals(getNumSeptets() - sms.getMessageBody().length(), result[2]);
+        assertRemaining(sms.getMessageBody().length(), result[2]);
         assertEquals(SmsMessage.ENCODING_7BIT, result[3]);
     }
 
-    private int getNumSeptets() {
+    private void assertRemaining(int messageLength, int remaining) {
         if (TelephonyUtils.isSkt(mTelephonyManager)) {
-            return 80;
+            assertTrue(checkRemaining(SEPTETS_SKT, messageLength, remaining)
+                    || checkRemaining(SmsMessage.MAX_USER_DATA_SEPTETS, messageLength, remaining));
         } else if (TelephonyUtils.isKt(mTelephonyManager)) {
-            return 90;
+            assertTrue(checkRemaining(SEPTETS_KT, messageLength, remaining)
+                    || checkRemaining(SmsMessage.MAX_USER_DATA_SEPTETS, messageLength, remaining));
         } else {
-            return SmsMessage.MAX_USER_DATA_SEPTETS;
+            assertTrue(checkRemaining(SmsMessage.MAX_USER_DATA_SEPTETS, messageLength, remaining));
         }
     }
 
+    private boolean checkRemaining(int total, int messageLength, int remaining) {
+        return total - messageLength == remaining;
+    }
+
     @TestTargets({
         @TestTargetNew(
             level = TestLevel.COMPLETE,