Missing Commits from ICS MR1

I did a manual diff, and here are some changes that got lost...

Change-Id: I6a8c052629085dde78ad95c2407c349e4e43db71
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index bcf3dd9..d9afe8d 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -36,7 +36,6 @@
     <uses-permission android:name="android.permission.WAKE_LOCK" />
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
     <uses-feature android:name="android.hardware.usb.accessory" />
-    <uses-sdk android:minSdkVersion="10" />
 
     <!-- Needed by the Audio Quality Verifier to store the sound samples that will be mailed. -->
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
@@ -72,7 +71,11 @@
                     android:resource="@xml/accessory_filter" />
         </activity>
 
-        <provider android:name=".TestResultsProvider"
+        <activity android:name=".ReportViewerActivity"
+                android:configChanges="keyboardHidden|orientation"
+                android:label="@string/report_viewer" />
+
+        <provider android:name=".TestResultsProvider" 
                 android:authorities="com.android.cts.verifier.testresultsprovider" />
 
         <activity android:name=".admin.PolicySerializationTestActivity"
diff --git a/apps/CtsVerifier/jni/verifier/com_android_cts_verifier_os_FileUtils.cpp b/apps/CtsVerifier/jni/verifier/com_android_cts_verifier_os_FileUtils.cpp
index 9c69f1a..f2b8034 100644
--- a/apps/CtsVerifier/jni/verifier/com_android_cts_verifier_os_FileUtils.cpp
+++ b/apps/CtsVerifier/jni/verifier/com_android_cts_verifier_os_FileUtils.cpp
@@ -20,6 +20,7 @@
 #include <sys/stat.h>
 #include <grp.h>
 #include <pwd.h>
+#include <unistd.h>
 
 static jfieldID gFileStatusDevFieldID;
 static jfieldID gFileStatusInoFieldID;
@@ -33,6 +34,7 @@
 static jfieldID gFileStatusAtimeFieldID;
 static jfieldID gFileStatusMtimeFieldID;
 static jfieldID gFileStatusCtimeFieldID;
+static jfieldID gFileStatusExecutableID;
 
 /* Copied from hidden API: frameworks/base/core/jni/android_os_FileUtils.cpp */
 jboolean com_android_cts_verifier_os_FileUtils_getFileStatus(JNIEnv* env, jobject thiz,
@@ -60,6 +62,11 @@
             env->SetLongField(fileStatus, gFileStatusMtimeFieldID, s.st_mtime);
             env->SetLongField(fileStatus, gFileStatusCtimeFieldID, s.st_ctime);
         }
+        if (access(pathStr, X_OK) == 0) {
+            env->SetBooleanField(fileStatus, gFileStatusExecutableID, JNI_TRUE);
+        } else {
+            env->SetBooleanField(fileStatus, gFileStatusExecutableID, JNI_FALSE);
+        }
     }
 
     env->ReleaseStringUTFChars(path, pathStr);
@@ -107,6 +114,7 @@
     gFileStatusAtimeFieldID = env->GetFieldID(fileStatusClass, "atime", "J");
     gFileStatusMtimeFieldID = env->GetFieldID(fileStatusClass, "mtime", "J");
     gFileStatusCtimeFieldID = env->GetFieldID(fileStatusClass, "ctime", "J");
+    gFileStatusExecutableID = env->GetFieldID(fileStatusClass, "executable", "Z");
 
     return env->RegisterNatives(clazz, gMethods, 
             sizeof(gMethods) / sizeof(JNINativeMethod)); 
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java
index 3736711..3ea9451 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java
@@ -164,6 +164,10 @@
             new Feature("android.hardware.screen.portrait", false),
     };
 
+    public static final Feature[] ALL_ICE_CREAM_SANDWICH_FEATURES = {
+            new Feature(PackageManager.FEATURE_WIFI_DIRECT, false),
+    };
+
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -194,6 +198,9 @@
 
         // add features from latest to last so that the latest requirements are put in the set first
         int apiVersion = Build.VERSION.SDK_INT;
+        if (apiVersion >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
+            Collections.addAll(features, ALL_ICE_CREAM_SANDWICH_FEATURES);
+        }
         if (apiVersion >= Build.VERSION_CODES.HONEYCOMB_MR2) {
             Collections.addAll(features, ALL_HONEYCOMB_MR2_FEATURES);
         }
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/os/FileUtils.java b/apps/CtsVerifier/src/com/android/cts/verifier/os/FileUtils.java
index c767e7a..5633c16 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/os/FileUtils.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/os/FileUtils.java
@@ -62,6 +62,7 @@
         private long atime;
         private long mtime;
         private long ctime;
+        private boolean executable;
 
         public int getUid() {
             return uid;
@@ -90,6 +91,10 @@
         public boolean isSetGid() {
             return hasModeFlag(mode, S_ISGID);
         }
+
+        public boolean isExecutableByCTS() {
+            return executable;
+        }
     }
 
     /**
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/suid/SuidFilesActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/suid/SuidFilesActivity.java
index 7d99c2d..ac290f2 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/suid/SuidFilesActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/suid/SuidFilesActivity.java
@@ -231,9 +231,11 @@
             @Override
             public boolean accept(File pathname) {
                 if (FileUtils.getFileStatus(pathname.getPath(), status, true)) {
+                    // only files with setUid which can be executable by CTS are reported.
                     return !status.isDirectory()
                             && !status.isSymbolicLink()
-                            && status.isSetUid();
+                            && status.isSetUid()
+                            && status.isExecutableByCTS();
                 } else {
                     Log.w(TAG, "Could not stat " + pathname);
                     return false;
diff --git a/tests/tests/media/src/android/media/cts/AudioRecordTest.java b/tests/tests/media/src/android/media/cts/AudioRecordTest.java
index 1ddcdd5..8be109a 100644
--- a/tests/tests/media/src/android/media/cts/AudioRecordTest.java
+++ b/tests/tests/media/src/android/media/cts/AudioRecordTest.java
@@ -47,6 +47,10 @@
     protected void setUp() throws Exception {
         super.setUp();
 
+        if (!hasMicrophone()) {
+            return;
+        }
+
         /*
          * InstrumentationTestRunner.onStart() calls Looper.prepare(), which creates a looper
          * for the current thread. However, since we don't actually call loop() in the test,
@@ -80,8 +84,10 @@
 
     @Override
     protected void tearDown() throws Exception {
-        mAudioRecord.release();
-        mLooper.quit();
+        if (hasMicrophone()) {
+            mAudioRecord.release();
+            mLooper.quit();
+        }
         super.tearDown();
     }
 
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 8c6ad01..27f290b 100644
--- a/tests/tests/telephony/src/android/telephony/cts/SmsMessageTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/SmsMessageTest.java
@@ -188,7 +188,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()));
 
@@ -220,7 +220,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
@@ -231,10 +231,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() {
+    }
+}