Merge "Fix the mono test" into jb-mr2-dev
diff --git a/build/test_package.mk b/build/test_package.mk
index aa9a4dd..46718a8 100644
--- a/build/test_package.mk
+++ b/build/test_package.mk
@@ -21,6 +21,7 @@
# Disable by default so "m cts" will work in emulator builds
LOCAL_DEX_PREOPT := false
+LOCAL_PROGUARD_ENABLED := disabled
include $(BUILD_PACKAGE)
diff --git a/hostsidetests/appsecurity/test-apps/AppAccessData/src/com/android/cts/appaccessdata/AccessPrivateDataTest.java b/hostsidetests/appsecurity/test-apps/AppAccessData/src/com/android/cts/appaccessdata/AccessPrivateDataTest.java
index 8a44dfa..40d3cff 100644
--- a/hostsidetests/appsecurity/test-apps/AppAccessData/src/com/android/cts/appaccessdata/AccessPrivateDataTest.java
+++ b/hostsidetests/appsecurity/test-apps/AppAccessData/src/com/android/cts/appaccessdata/AccessPrivateDataTest.java
@@ -16,21 +16,24 @@
package com.android.cts.appaccessdata;
+import java.io.BufferedReader;
+import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
+import java.io.FileReader;
import java.io.IOException;
import android.test.AndroidTestCase;
/**
- * Test that another app's private data cannot be accessed.
+ * Test that another app's private data cannot be accessed, while its public data can.
*
- * Assumes that {@link APP_WITH_DATA_PKG} has already created the private data.
+ * Assumes that {@link APP_WITH_DATA_PKG} has already created the private and public data.
*/
public class AccessPrivateDataTest extends AndroidTestCase {
/**
- * The Android package name of the application that owns the private data
+ * The Android package name of the application that owns the data
*/
private static final String APP_WITH_DATA_PKG = "com.android.cts.appwithdata";
@@ -39,9 +42,15 @@
* {@link APP_WITH_DATA_PKG}.
*/
private static final String PRIVATE_FILE_NAME = "private_file.txt";
+ /**
+ * Name of public file to access. This must match the name of the file created by
+ * {@link APP_WITH_DATA_PKG}.
+ */
+ private static final String PUBLIC_FILE_NAME = "public_file.txt";
/**
- * Tests that another app's private file cannot be accessed
+ * Tests that another app's private data cannot be accessed. It includes file
+ * and detailed traffic stats.
* @throws IOException
*/
public void testAccessPrivateData() throws IOException {
@@ -58,5 +67,60 @@
} catch (SecurityException e) {
// also valid
}
+ accessPrivateTrafficStats();
+ }
+
+ /**
+ * Tests that another app's public file can be accessed
+ * @throws IOException
+ */
+ public void testAccessPublicData() throws IOException {
+ try {
+ getOtherAppUid();
+ } catch (FileNotFoundException e) {
+ fail("Was not able to access another app's public file: " + e);
+ } catch (SecurityException e) {
+ fail("Was not able to access another app's public file: " + e);
+ }
+ }
+
+ private int getOtherAppUid() throws IOException, FileNotFoundException, SecurityException {
+ // construct the absolute file path to the other app's public file
+ String publicFilePath = String.format("/data/data/%s/files/%s", APP_WITH_DATA_PKG,
+ PUBLIC_FILE_NAME);
+ DataInputStream inputStream = new DataInputStream(new FileInputStream(publicFilePath));
+ int otherAppUid = (int)inputStream.readInt();
+ inputStream.close();
+ return otherAppUid;
+ }
+
+ private void accessPrivateTrafficStats() throws IOException {
+ int otherAppUid = -1;
+ try {
+ otherAppUid = getOtherAppUid();
+ } catch (FileNotFoundException e) {
+ fail("Was not able to access another app's public file: " + e);
+ } catch (SecurityException e) {
+ fail("Was not able to access another app's public file: " + e);
+ }
+
+ boolean foundOtherStats = false;
+ try {
+ BufferedReader qtaguidReader = new BufferedReader(new FileReader("/proc/net/xt_qtaguid/stats"));
+ String line;
+ while ((line = qtaguidReader.readLine()) != null) {
+ String tokens[] = line.split(" ");
+ if (tokens.length > 3 && tokens[3].equals(String.valueOf(otherAppUid))) {
+ foundOtherStats = true;
+ if (!tokens[2].equals("0x0")) {
+ fail("Other apps detailed traffic stats leaked");
+ }
+ }
+ }
+ qtaguidReader.close();
+ } catch (FileNotFoundException e) {
+ fail("Was not able to access qtaguid/stats: " + e);
+ }
+ assertTrue("Was expecting to find other apps' traffic stats", foundOtherStats);
}
}
diff --git a/hostsidetests/appsecurity/test-apps/AppWithData/AndroidManifest.xml b/hostsidetests/appsecurity/test-apps/AppWithData/AndroidManifest.xml
index 4b10030..9decbcd 100644
--- a/hostsidetests/appsecurity/test-apps/AppWithData/AndroidManifest.xml
+++ b/hostsidetests/appsecurity/test-apps/AppWithData/AndroidManifest.xml
@@ -22,6 +22,7 @@
access.
-->
+ <uses-permission android:name="android.permission.INTERNET" />
<application>
<uses-library android:name="android.test.runner" />
</application>
diff --git a/hostsidetests/appsecurity/test-apps/AppWithData/src/com/android/cts/appwithdata/CreatePrivateDataTest.java b/hostsidetests/appsecurity/test-apps/AppWithData/src/com/android/cts/appwithdata/CreatePrivateDataTest.java
index 1de6464..e11681a 100644
--- a/hostsidetests/appsecurity/test-apps/AppWithData/src/com/android/cts/appwithdata/CreatePrivateDataTest.java
+++ b/hostsidetests/appsecurity/test-apps/AppWithData/src/com/android/cts/appwithdata/CreatePrivateDataTest.java
@@ -22,10 +22,23 @@
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
+import android.net.TrafficStats;
import android.test.AndroidTestCase;
+import android.util.Log;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+import java.io.BufferedReader;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
+import java.io.FileReader;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
/**
* Test that will create private app data.
@@ -36,9 +49,15 @@
public class CreatePrivateDataTest extends AndroidTestCase {
/**
+ * The Android package name of the application that owns the private data
+ */
+ private static final String APP_WITH_DATA_PKG = "com.android.cts.appwithdata";
+
+ /**
* Name of private file to create.
*/
private static final String PRIVATE_FILE_NAME = "private_file.txt";
+ private static final String PUBLIC_FILE_NAME = "public_file.txt";
private static final String PREFERENCES_FILE_NAME = "preferences";
private static final String PREFERENCE_KEY = "preference_key";
@@ -49,7 +68,8 @@
static final String DB_VALUE = "test_value";
/**
- * Creates a file private to this app
+ * Creates the private data for this app, which includes
+ * file, database entries, and traffic stats.
* @throws IOException if any error occurred when creating the file
*/
public void testCreatePrivateData() throws IOException {
@@ -59,8 +79,34 @@
outputStream.close();
assertTrue(getContext().getFileStreamPath(PRIVATE_FILE_NAME).exists());
+ outputStream = getContext().openFileOutput(PUBLIC_FILE_NAME,
+ Context.MODE_WORLD_READABLE);
+ DataOutputStream dataOut = new DataOutputStream(outputStream);
+ dataOut.writeInt(getContext().getApplicationInfo().uid);
+ dataOut.close();
+ outputStream.close();
+ // Ensure that some file will be accessible via the same path that will be used by other app.
+ accessPublicData();
+
writeToPreferences();
writeToDatabase();
+ createTrafficStatsWithTags();
+ }
+
+ private void accessPublicData() throws IOException {
+ try {
+ // construct the absolute file path to the app's public's file the same
+ // way as the appaccessdata package will.
+ String publicFilePath = String.format("/data/data/%s/files/%s", APP_WITH_DATA_PKG,
+ PUBLIC_FILE_NAME);
+ DataInputStream inputStream = new DataInputStream(new FileInputStream(publicFilePath));
+ int otherAppUid = (int)inputStream.readInt();
+ inputStream.close();
+ } catch (FileNotFoundException e) {
+ fail("Was not able to access own public file: " + e);
+ } catch (SecurityException e) {
+ fail("Was not able to access own public file: " + e);
+ }
}
private void writeToPreferences() {
@@ -127,6 +173,76 @@
}
}
+ private void accessOwnTrafficStats() throws IOException {
+ final int ownAppUid = getContext().getApplicationInfo().uid;
+
+ boolean foundOwnDetailedStats = false;
+ try {
+ BufferedReader qtaguidReader = new BufferedReader(new FileReader("/proc/net/xt_qtaguid/stats"));
+ String line;
+ while ((line = qtaguidReader.readLine()) != null) {
+ String tokens[] = line.split(" ");
+ if (tokens.length > 3 && tokens[3].equals(String.valueOf(ownAppUid))) {
+ if (!tokens[2].equals("0x0")) {
+ foundOwnDetailedStats = true;
+ }
+ }
+ }
+ qtaguidReader.close();
+ } catch (FileNotFoundException e) {
+ fail("Was not able to access qtaguid/stats: " + e);
+ }
+ assertTrue("Was expecting to find own traffic stats", foundOwnDetailedStats);
+ }
+
+ private void createTrafficStatsWithTags() throws IOException {
+
+ // Transfer 1MB of data across an explicitly localhost socket.
+ final int byteCount = 1024;
+ final int packetCount = 1024;
+
+ final ServerSocket server = new ServerSocket(0);
+ new Thread("CreatePrivateDataTest.createTrafficStatsWithTags") {
+ @Override
+ public void run() {
+ try {
+ Socket socket = new Socket("localhost", server.getLocalPort());
+ // Make sure that each write()+flush() turns into a packet:
+ // disable Nagle.
+ socket.setTcpNoDelay(true);
+ OutputStream out = socket.getOutputStream();
+ byte[] buf = new byte[byteCount];
+ for (int i = 0; i < packetCount; i++) {
+ TrafficStats.setThreadStatsTag(i % 10);
+ TrafficStats.tagSocket(socket);
+ out.write(buf);
+ out.flush();
+ }
+ out.close();
+ socket.close();
+ } catch (IOException e) {
+ assertTrue("io exception" + e, false);
+ }
+ }
+ }.start();
+
+ try {
+ Socket socket = server.accept();
+ InputStream in = socket.getInputStream();
+ byte[] buf = new byte[byteCount];
+ int read = 0;
+ while (read < byteCount * packetCount) {
+ int n = in.read(buf);
+ assertTrue("Unexpected EOF", n > 0);
+ read += n;
+ }
+ } finally {
+ server.close();
+ }
+
+ accessOwnTrafficStats();
+ }
+
static class TestDatabaseOpenHelper extends SQLiteOpenHelper {
static final String _ID = "_id";
diff --git a/tests/Android.mk b/tests/Android.mk
index 15705dd..4a87b07 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -20,7 +20,8 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)\
$(call all-renderscript-files-under, src)\
src/android/app/cts/ISecondary.aidl\
- src/android/os/cts/IEmptyService.aidl
+ src/android/os/cts/IEmptyService.aidl\
+ src/android/security/cts/activity/ISecureRandomService.aidl
LOCAL_JAVA_LIBRARIES := android.test.runner
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
index 636a945..b992482 100644
--- a/tests/AndroidManifest.xml
+++ b/tests/AndroidManifest.xml
@@ -107,6 +107,9 @@
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.READ_SYNC_STATS" />
+ <!-- Used for ClonedSecureRandomTest -->
+ <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
+
<!-- Used for PackageManager test, don't delete this permission-tree -->
<permission-tree android:name="com.android.cts.stub.permission.TEST_DYNAMIC"
android:label="Test Tree"/>
@@ -994,6 +997,9 @@
<activity android:name="android.renderscriptgraphics.cts.RenderscriptGLStubActivity"
android:label="RenderscriptGLStub"/>
+
+ <service android:name="android.security.cts.activity.SecureRandomService"
+ android:process=":secureRandom"/>
</application>
diff --git a/tests/deviceadmin/AndroidManifest.xml b/tests/deviceadmin/AndroidManifest.xml
index 69bc74d..2395d99 100644
--- a/tests/deviceadmin/AndroidManifest.xml
+++ b/tests/deviceadmin/AndroidManifest.xml
@@ -40,6 +40,17 @@
</intent-filter>
</receiver>
+ <!-- Device Admin that needs to be in the deactivated state in order
+ for tests to pass. -->
+ <receiver android:name="android.deviceadmin.cts.CtsDeviceAdminDeactivatedReceiver"
+ android:permission="android.permission.BIND_DEVICE_ADMIN">
+ <meta-data android:name="android.app.device_admin"
+ android:resource="@xml/device_admin" />
+ <intent-filter>
+ <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
+ </intent-filter>
+ </receiver>
+
<!-- Helper Activity used by Device Admin activation tests -->
<activity android:name="android.deviceadmin.cts.CtsDeviceAdminActivationTestActivity"
android:label="Device Admin activation test" />
diff --git a/tests/deviceadmin/src/android/deviceadmin/cts/CtsDeviceAdminDeactivatedReceiver.java b/tests/deviceadmin/src/android/deviceadmin/cts/CtsDeviceAdminDeactivatedReceiver.java
new file mode 100644
index 0000000..ec59f63
--- /dev/null
+++ b/tests/deviceadmin/src/android/deviceadmin/cts/CtsDeviceAdminDeactivatedReceiver.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2013 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.deviceadmin.cts;
+
+import android.app.admin.DeviceAdminReceiver;
+
+public class CtsDeviceAdminDeactivatedReceiver extends DeviceAdminReceiver {
+}
diff --git a/tests/src/android/security/cts/activity/ISecureRandomService.aidl b/tests/src/android/security/cts/activity/ISecureRandomService.aidl
new file mode 100644
index 0000000..af264c9
--- /dev/null
+++ b/tests/src/android/security/cts/activity/ISecureRandomService.aidl
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2013 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.security.cts.activity;
+
+interface ISecureRandomService {
+ int getRandomBytesAndPid(inout byte[] randomBytes);
+}
diff --git a/tests/src/android/security/cts/activity/SecureRandomService.java b/tests/src/android/security/cts/activity/SecureRandomService.java
new file mode 100644
index 0000000..2d425b3
--- /dev/null
+++ b/tests/src/android/security/cts/activity/SecureRandomService.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2013 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.security.cts.activity;
+
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.Message;
+import android.security.cts.activity.ISecureRandomService;
+
+import android.app.Service;
+import android.content.Intent;
+
+import java.security.SecureRandom;
+
+public class SecureRandomService extends Service {
+ /**
+ * This helps the process shut down a little faster and get us a new
+ * PID earlier than calling stopService.
+ */
+ private Handler mShutdownHandler = new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+ stopSelf();
+ }
+ };
+
+ private final ISecureRandomService.Stub mBinder = new ISecureRandomService.Stub() {
+
+ /**
+ * Returns output from SecureRandom and the current process PID. Note
+ * that this should only be called once. To ensure that it's only called
+ * once, this will throw an error if it's called twice in a row.
+ */
+ public int getRandomBytesAndPid(byte[] randomBytes) {
+ mShutdownHandler.sendEmptyMessage(-1);
+
+ SecureRandom sr = new SecureRandom();
+ sr.nextBytes(randomBytes);
+ return android.os.Process.myPid();
+ }
+ };
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ return mBinder;
+ }
+}
diff --git a/tests/tests/accessibilityservice/AndroidManifest.xml b/tests/tests/accessibilityservice/AndroidManifest.xml
index c000460..ac75553 100644
--- a/tests/tests/accessibilityservice/AndroidManifest.xml
+++ b/tests/tests/accessibilityservice/AndroidManifest.xml
@@ -19,6 +19,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.cts.accessibilityservice">
+ <uses-sdk android:minSdkVersion="18"
+ android:targetSdkVersion="18" />
+
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<application android:theme="@android:style/Theme.Holo.NoActionBar" >
diff --git a/tests/tests/accessibilityservice/res/layout/accessibility_text_traversal_test.xml b/tests/tests/accessibilityservice/res/layout/accessibility_text_traversal_test.xml
index 5b3d2e6..f86f00f 100644
--- a/tests/tests/accessibilityservice/res/layout/accessibility_text_traversal_test.xml
+++ b/tests/tests/accessibilityservice/res/layout/accessibility_text_traversal_test.xml
@@ -32,6 +32,10 @@
android:id="@+id/text"
android:layout_width="200dip"
android:layout_height="200dip"
+ android:includeFontPadding="false"
+ android:textSize="14dip"
+ android:textStyle="normal"
+ android:fontFamily="sans-serif"
/>
<EditText
@@ -41,6 +45,10 @@
android:maxLines="1000"
android:scrollbars="vertical"
android:focusable="false"
+ android:includeFontPadding="false"
+ android:textSize="18dip"
+ android:textStyle="normal"
+ android:fontFamily="sans-serif"
/>
</LinearLayout>
diff --git a/tests/tests/admin/src/android/admin/cts/DeviceAdminActivationTest.java b/tests/tests/admin/src/android/admin/cts/DeviceAdminActivationTest.java
index 7e09989..cb0425a 100644
--- a/tests/tests/admin/src/android/admin/cts/DeviceAdminActivationTest.java
+++ b/tests/tests/admin/src/android/admin/cts/DeviceAdminActivationTest.java
@@ -19,13 +19,14 @@
import android.app.Activity;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
+import android.content.Context;
import android.content.Intent;
import android.deviceadmin.cts.CtsDeviceAdminBrokenReceiver;
import android.deviceadmin.cts.CtsDeviceAdminBrokenReceiver2;
import android.deviceadmin.cts.CtsDeviceAdminBrokenReceiver3;
import android.deviceadmin.cts.CtsDeviceAdminBrokenReceiver4;
import android.deviceadmin.cts.CtsDeviceAdminBrokenReceiver5;
-import android.deviceadmin.cts.CtsDeviceAdminReceiver;
+import android.deviceadmin.cts.CtsDeviceAdminDeactivatedReceiver;
import android.deviceadmin.cts.CtsDeviceAdminActivationTestActivity;
import android.deviceadmin.cts.CtsDeviceAdminActivationTestActivity.OnActivityResultListener;
import android.os.SystemClock;
@@ -98,37 +99,49 @@
}
public void testActivateGoodReceiverDisplaysActivationUi() throws Exception {
- startAddDeviceAdminActivityForResult(CtsDeviceAdminReceiver.class);
+ assertDeviceAdminDeactivated(CtsDeviceAdminDeactivatedReceiver.class);
+ startAddDeviceAdminActivityForResult(CtsDeviceAdminDeactivatedReceiver.class);
assertWithTimeoutOnActivityResultNotInvoked();
// The UI is up and running. Assert that dismissing the UI returns the corresponding result
// to the test activity.
finishActivateDeviceAdminActivity();
assertWithTimeoutOnActivityResultInvokedWithResultCode(Activity.RESULT_CANCELED);
+ assertDeviceAdminDeactivated(CtsDeviceAdminDeactivatedReceiver.class);
}
public void testActivateBrokenReceiverFails() throws Exception {
+ assertDeviceAdminDeactivated(CtsDeviceAdminBrokenReceiver.class);
startAddDeviceAdminActivityForResult(CtsDeviceAdminBrokenReceiver.class);
assertWithTimeoutOnActivityResultInvokedWithResultCode(Activity.RESULT_CANCELED);
+ assertDeviceAdminDeactivated(CtsDeviceAdminBrokenReceiver.class);
}
public void testActivateBrokenReceiver2Fails() throws Exception {
+ assertDeviceAdminDeactivated(CtsDeviceAdminBrokenReceiver2.class);
startAddDeviceAdminActivityForResult(CtsDeviceAdminBrokenReceiver2.class);
assertWithTimeoutOnActivityResultInvokedWithResultCode(Activity.RESULT_CANCELED);
+ assertDeviceAdminDeactivated(CtsDeviceAdminBrokenReceiver2.class);
}
public void testActivateBrokenReceiver3Fails() throws Exception {
+ assertDeviceAdminDeactivated(CtsDeviceAdminBrokenReceiver3.class);
startAddDeviceAdminActivityForResult(CtsDeviceAdminBrokenReceiver3.class);
assertWithTimeoutOnActivityResultInvokedWithResultCode(Activity.RESULT_CANCELED);
+ assertDeviceAdminDeactivated(CtsDeviceAdminBrokenReceiver3.class);
}
public void testActivateBrokenReceiver4Fails() throws Exception {
+ assertDeviceAdminDeactivated(CtsDeviceAdminBrokenReceiver4.class);
startAddDeviceAdminActivityForResult(CtsDeviceAdminBrokenReceiver4.class);
assertWithTimeoutOnActivityResultInvokedWithResultCode(Activity.RESULT_CANCELED);
+ assertDeviceAdminDeactivated(CtsDeviceAdminBrokenReceiver4.class);
}
public void testActivateBrokenReceiver5Fails() throws Exception {
+ assertDeviceAdminDeactivated(CtsDeviceAdminBrokenReceiver5.class);
startAddDeviceAdminActivityForResult(CtsDeviceAdminBrokenReceiver5.class);
assertWithTimeoutOnActivityResultInvokedWithResultCode(Activity.RESULT_CANCELED);
+ assertDeviceAdminDeactivated(CtsDeviceAdminBrokenReceiver5.class);
}
private void startAddDeviceAdminActivityForResult(Class<?> receiverClass) {
@@ -179,4 +192,12 @@
private void finishActivateDeviceAdminActivity() {
getActivity().finishActivity(REQUEST_CODE_ACTIVATE_ADMIN);
}
+
+ private void assertDeviceAdminDeactivated(Class<?> receiverClass) {
+ DevicePolicyManager devicePolicyManager =
+ (DevicePolicyManager) getActivity().getSystemService(
+ Context.DEVICE_POLICY_SERVICE);
+ assertFalse(devicePolicyManager.isAdminActive(
+ new ComponentName(getInstrumentation().getTargetContext(), receiverClass)));
+ }
}
diff --git a/tests/tests/drm/Android.mk b/tests/tests/drm/Android.mk
index 3264c32..8b76cd8 100644
--- a/tests/tests/drm/Android.mk
+++ b/tests/tests/drm/Android.mk
@@ -16,8 +16,8 @@
include $(CLEAR_VARS)
-# don't include this package in any target
-LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_TAGS := tests
+
# and when built explicitly put it in the data partition
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
@@ -31,7 +31,13 @@
LOCAL_INSTRUMENTATION_FOR := CtsTestStubs
+LOCAL_JNI_SHARED_LIBRARIES := \
+ libctsdrm_jni \
+ libdrmtestplugin
+
# uncomment when dalvik.annotation.Test* are removed or part of SDK
#LOCAL_SDK_VERSION := current
include $(BUILD_CTS_PACKAGE)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/tests/drm/jni/Android.mk b/tests/tests/drm/jni/Android.mk
new file mode 100644
index 0000000..06b2df9
--- /dev/null
+++ b/tests/tests/drm/jni/Android.mk
@@ -0,0 +1,32 @@
+# Copyright (C) 2012 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.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libctsdrm_jni
+
+# Don't include this package in any configuration by default.
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := \
+ CtsDrmJniOnLoad.cpp \
+ android_drm_cts_NativeCodeTest.cpp
+
+LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
+
+LOCAL_SHARED_LIBRARIES := liblog libdl
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/drm/jni/CtsDrmJniOnLoad.cpp b/tests/tests/drm/jni/CtsDrmJniOnLoad.cpp
new file mode 100644
index 0000000..a9ec3da
--- /dev/null
+++ b/tests/tests/drm/jni/CtsDrmJniOnLoad.cpp
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+#include <jni.h>
+#include <stdio.h>
+
+extern int register_android_drm_cts_NativeCodeTest(JNIEnv*);
+
+jint JNI_OnLoad(JavaVM *vm, void *reserved) {
+ JNIEnv *env = NULL;
+
+ if (vm->GetEnv((void **) &env, JNI_VERSION_1_4) != JNI_OK) {
+ return JNI_ERR;
+ }
+
+ if (register_android_drm_cts_NativeCodeTest(env)) {
+ return JNI_ERR;
+ }
+
+ return JNI_VERSION_1_4;
+}
diff --git a/tests/tests/drm/jni/android_drm_cts_NativeCodeTest.cpp b/tests/tests/drm/jni/android_drm_cts_NativeCodeTest.cpp
new file mode 100644
index 0000000..398a44e
--- /dev/null
+++ b/tests/tests/drm/jni/android_drm_cts_NativeCodeTest.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+#include <jni.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+#include <utils/Log.h>
+
+/*
+ * Returns true iff this device may be vulnerable to installation of rogue drm
+ * plugins, as determined by the existance of the _installDrmEngine symbol in the
+ * libdrmframework_jni.so library.
+ */
+static jboolean android_drm_cts_InstallDrmEngineTest(JNIEnv* env, jobject thiz)
+{
+ jboolean result = false;
+
+ // install /system/lib/libdrmtestplugin.so
+ FILE *f = popen("service call drm.drmManager 6 i32 0 i32 31 i32 1937339183 i32 795698548 "
+ "i32 794978668 i32 1684171116 i32 1702129010 i32 1819309171 i32 1852401525 "
+ "i32 7303982 i32 1598902849", "r");
+ if (f) {
+ char buffer[128];
+ if (fgets(buffer, sizeof(buffer), f) != NULL) {
+ const char *match = "Result: Parcel(00000000 '....')";
+ if (!strncmp(buffer, match, strlen(match))) {
+ result = true;
+ }
+ }
+ pclose(f);
+ }
+ return result;
+}
+
+static JNINativeMethod gMethods[] = {
+ { "doInstallDrmEngineTest", "()Z",
+ (void *) android_drm_cts_InstallDrmEngineTest },
+};
+
+int register_android_drm_cts_NativeCodeTest(JNIEnv* env)
+{
+ jclass clazz = env->FindClass("android/drm/cts/NativeCodeTest");
+ return env->RegisterNatives(clazz, gMethods,
+ sizeof(gMethods) / sizeof(JNINativeMethod));
+}
diff --git a/tests/tests/drm/lib/Android.mk b/tests/tests/drm/lib/Android.mk
new file mode 100644
index 0000000..3ebc4a0
--- /dev/null
+++ b/tests/tests/drm/lib/Android.mk
@@ -0,0 +1,37 @@
+# Copyright (C) 2012 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.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := libdrmtestplugin
+
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := \
+ TestPlugin.cpp
+
+LOCAL_C_INCLUDES := \
+ $(JNI_H_INCLUDE) \
+ $(TOP)/frameworks/av/drm/libdrmframework/plugins/common/include
+
+LOCAL_SHARED_LIBRARIES := \
+ liblog \
+ libutils
+
+LOCAL_STATIC_LIBRARIES := \
+ libdrmframeworkcommon
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/tests/tests/drm/lib/TestPlugin.cpp b/tests/tests/drm/lib/TestPlugin.cpp
new file mode 100644
index 0000000..5708909
--- /dev/null
+++ b/tests/tests/drm/lib/TestPlugin.cpp
@@ -0,0 +1,182 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "TestPlugin"
+#include <utils/Log.h>
+
+#include <drm/DrmRights.h>
+#include <drm/DrmConstraints.h>
+#include <drm/DrmMetadata.h>
+#include <drm/DrmInfo.h>
+#include <drm/DrmInfoEvent.h>
+#include <drm/DrmInfoStatus.h>
+#include <drm/DrmConvertedStatus.h>
+#include <drm/DrmInfoRequest.h>
+#include <drm/DrmSupportInfo.h>
+#include <TestPlugin.h>
+
+using namespace android;
+
+
+// This extern "C" is mandatory to be managed by TPlugInManager
+extern "C" IDrmEngine* create() {
+ return new TestPlugIn();
+}
+
+// This extern "C" is mandatory to be managed by TPlugInManager
+extern "C" void destroy(IDrmEngine* pPlugIn) {
+ delete pPlugIn;
+ pPlugIn = NULL;
+}
+
+TestPlugIn::TestPlugIn()
+ : DrmEngineBase() {
+
+}
+
+TestPlugIn::~TestPlugIn() {
+
+}
+
+DrmMetadata* TestPlugIn::onGetMetadata(int uniqueId, const String8* path) {
+ return NULL;
+}
+
+DrmConstraints* TestPlugIn::onGetConstraints(
+ int uniqueId, const String8* path, int action) {
+ return NULL;
+}
+
+DrmInfoStatus* TestPlugIn::onProcessDrmInfo(int uniqueId, const DrmInfo* drmInfo) {
+ return NULL;
+}
+
+status_t TestPlugIn::onSetOnInfoListener(
+ int uniqueId, const IDrmEngine::OnInfoListener* infoListener) {
+ return DRM_NO_ERROR;
+}
+
+status_t TestPlugIn::onInitialize(int uniqueId) {
+ return DRM_NO_ERROR;
+}
+
+status_t TestPlugIn::onTerminate(int uniqueId) {
+ return DRM_NO_ERROR;
+}
+
+DrmSupportInfo* TestPlugIn::onGetSupportInfo(int uniqueId) {
+ DrmSupportInfo* drmSupportInfo = new DrmSupportInfo();
+ return drmSupportInfo;
+}
+
+status_t TestPlugIn::onSaveRights(int uniqueId, const DrmRights& drmRights,
+ const String8& rightsPath, const String8& contentPath) {
+ return DRM_NO_ERROR;
+}
+
+DrmInfo* TestPlugIn::onAcquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest) {
+ return NULL;
+}
+
+bool TestPlugIn::onCanHandle(int uniqueId, const String8& path) {
+ return false;
+}
+
+String8 TestPlugIn::onGetOriginalMimeType(int uniqueId, const String8& path, int fd) {
+ return String8("video/none");
+}
+
+int TestPlugIn::onGetDrmObjectType(
+ int uniqueId, const String8& path, const String8& mimeType) {
+ return DrmObjectType::UNKNOWN;
+}
+
+int TestPlugIn::onCheckRightsStatus(int uniqueId, const String8& path, int action) {
+ int rightsStatus = RightsStatus::RIGHTS_VALID;
+ return rightsStatus;
+}
+
+status_t TestPlugIn::onConsumeRights(int uniqueId, DecryptHandle* decryptHandle,
+ int action, bool reserve) {
+ return DRM_NO_ERROR;
+}
+
+status_t TestPlugIn::onSetPlaybackStatus(int uniqueId, DecryptHandle* decryptHandle,
+ int playbackStatus, int64_t position) {
+ return DRM_NO_ERROR;
+}
+
+bool TestPlugIn::onValidateAction(int uniqueId, const String8& path,
+ int action, const ActionDescription& description) {
+ return true;
+}
+
+status_t TestPlugIn::onRemoveRights(int uniqueId, const String8& path) {
+ return DRM_NO_ERROR;
+}
+
+status_t TestPlugIn::onRemoveAllRights(int uniqueId) {
+ return DRM_NO_ERROR;
+}
+
+status_t TestPlugIn::onOpenConvertSession(int uniqueId, int convertId) {
+ return DRM_NO_ERROR;
+}
+
+DrmConvertedStatus* TestPlugIn::onConvertData(
+ int uniqueId, int convertId, const DrmBuffer* inputData) {
+ return new DrmConvertedStatus(DrmConvertedStatus::STATUS_OK, NULL, 0);
+}
+
+DrmConvertedStatus* TestPlugIn::onCloseConvertSession(int uniqueId, int convertId) {
+ return new DrmConvertedStatus(DrmConvertedStatus::STATUS_OK, NULL, 0);
+}
+
+status_t TestPlugIn::onOpenDecryptSession(
+ int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length) {
+ return DRM_ERROR_CANNOT_HANDLE;
+}
+
+status_t TestPlugIn::onOpenDecryptSession(
+ int uniqueId, DecryptHandle* decryptHandle, const char* uri) {
+ return DRM_ERROR_CANNOT_HANDLE;
+}
+
+status_t TestPlugIn::onCloseDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
+ return DRM_NO_ERROR;
+}
+
+status_t TestPlugIn::onInitializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
+ int decryptUnitId, const DrmBuffer* headerInfo) {
+ return DRM_NO_ERROR;
+}
+
+status_t TestPlugIn::onDecrypt(int uniqueId, DecryptHandle* decryptHandle,
+ int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
+ return DRM_NO_ERROR;
+}
+
+status_t TestPlugIn::onFinalizeDecryptUnit(
+ int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
+ return DRM_NO_ERROR;
+}
+
+ssize_t TestPlugIn::onPread(int uniqueId, DecryptHandle* decryptHandle,
+ void* buffer, ssize_t numBytes, off64_t offset) {
+ return 0;
+}
+
diff --git a/tests/tests/drm/lib/TestPlugin.h b/tests/tests/drm/lib/TestPlugin.h
new file mode 100644
index 0000000..40d4ec7
--- /dev/null
+++ b/tests/tests/drm/lib/TestPlugin.h
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2010 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.
+ */
+
+#ifndef __DRM_TEST_PLUGIN_H__
+#define __DRM_TEST_PLUGIN_H__
+
+#include <DrmEngineBase.h>
+
+namespace android {
+
+class TestPlugIn : public DrmEngineBase {
+
+public:
+ TestPlugIn();
+ virtual ~TestPlugIn();
+
+protected:
+ DrmConstraints* onGetConstraints(int uniqueId, const String8* path, int action);
+
+ DrmMetadata* onGetMetadata(int uniqueId, const String8* path);
+
+ status_t onInitialize(int uniqueId);
+
+ status_t onSetOnInfoListener(int uniqueId, const IDrmEngine::OnInfoListener* infoListener);
+
+ status_t onTerminate(int uniqueId);
+
+ bool onCanHandle(int uniqueId, const String8& path);
+
+ DrmInfoStatus* onProcessDrmInfo(int uniqueId, const DrmInfo* drmInfo);
+
+ status_t onSaveRights(int uniqueId, const DrmRights& drmRights,
+ const String8& rightsPath, const String8& contentPath);
+
+ DrmInfo* onAcquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest);
+
+ String8 onGetOriginalMimeType(int uniqueId, const String8& path, int fd);
+
+ int onGetDrmObjectType(int uniqueId, const String8& path, const String8& mimeType);
+
+ int onCheckRightsStatus(int uniqueId, const String8& path, int action);
+
+ status_t onConsumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
+
+ status_t onSetPlaybackStatus(
+ int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position);
+
+ bool onValidateAction(
+ int uniqueId, const String8& path, int action, const ActionDescription& description);
+
+ status_t onRemoveRights(int uniqueId, const String8& path);
+
+ status_t onRemoveAllRights(int uniqueId);
+
+ status_t onOpenConvertSession(int uniqueId, int convertId);
+
+ DrmConvertedStatus* onConvertData(int uniqueId, int convertId, const DrmBuffer* inputData);
+
+ DrmConvertedStatus* onCloseConvertSession(int uniqueId, int convertId);
+
+ DrmSupportInfo* onGetSupportInfo(int uniqueId);
+
+ status_t onOpenDecryptSession(
+ int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length);
+
+ status_t onOpenDecryptSession(
+ int uniqueId, DecryptHandle* decryptHandle, const char* uri);
+
+ status_t onCloseDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
+
+ status_t onInitializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
+ int decryptUnitId, const DrmBuffer* headerInfo);
+
+ status_t onDecrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
+ const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV);
+
+ status_t onFinalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
+
+ ssize_t onPread(int uniqueId, DecryptHandle* decryptHandle,
+ void* buffer, ssize_t numBytes, off64_t offset);
+
+private:
+ DecryptHandle* openDecryptSessionImpl();
+};
+
+};
+
+#endif /* __DRM_TEST_PLUGIN_H__ */
diff --git a/tests/tests/drm/src/android/drm/cts/NativeCodeTest.java b/tests/tests/drm/src/android/drm/cts/NativeCodeTest.java
new file mode 100644
index 0000000..856cb88
--- /dev/null
+++ b/tests/tests/drm/src/android/drm/cts/NativeCodeTest.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2013 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.drm.cts;
+
+import junit.framework.TestCase;
+
+public class NativeCodeTest extends TestCase {
+
+ static {
+ System.loadLibrary("ctsdrm_jni");
+ }
+
+ public void testInstallDrmEngine() throws Exception {
+ assertFalse("Device is vulnerable to arbitrary code execution in drmserver process.",
+ doInstallDrmEngineTest());
+ }
+
+ /**
+ * Returns true iff this device is vulnerable to arbitrary code execution in drm server
+ */
+ private static native boolean doInstallDrmEngineTest();
+}
diff --git a/tests/tests/media/src/android/media/cts/StreamingMediaPlayerTest.java b/tests/tests/media/src/android/media/cts/StreamingMediaPlayerTest.java
index a3c9454..1d78967 100644
--- a/tests/tests/media/src/android/media/cts/StreamingMediaPlayerTest.java
+++ b/tests/tests/media/src/android/media/cts/StreamingMediaPlayerTest.java
@@ -96,7 +96,7 @@
+ "&sparams=ip,ipbits,expire,id,itag,source"
+ "&signature=3CFCAFB87EB9FC943FACDC54FEC8C725A801642C."
+ "7D77ACBC4CAF40349BF093E302B635757E45F345"
- + "&key=test_key1&user=android-device-test", 480, 270);
+ + "&key=test_key1&user=android-device-test", 640, 360);
}
public void testHTTP_H264Base_AAC_Video2() throws Exception {
playVideoTest("http://redirector.c.youtube.com/videoplayback?id=c80658495af60617"
@@ -104,7 +104,7 @@
+ "&sparams=ip,ipbits,expire,id,itag,source"
+ "&signature=A11D8BA0AA67A27F1409BE0C0B96B756625DB88B."
+ "9BF4C93A130583ADBDF2B953AD5A8A58F518B012"
- + "&key=test_key1&user=android-device-test", 480, 270);
+ + "&key=test_key1&user=android-device-test", 640, 360);
}
// Streaming HLS video from YouTube
diff --git a/tests/tests/net/src/android/net/cts/SSLCertificateSocketFactoryTest.java b/tests/tests/net/src/android/net/cts/SSLCertificateSocketFactoryTest.java
index 70ab54d..ceb74d1 100644
--- a/tests/tests/net/src/android/net/cts/SSLCertificateSocketFactoryTest.java
+++ b/tests/tests/net/src/android/net/cts/SSLCertificateSocketFactoryTest.java
@@ -86,9 +86,9 @@
}
// a host and port that are expected to be available but have
- // a cert with a different CN, in this case CN=mtalk.google.com
- private static String TEST_CREATE_SOCKET_HOST = "mobile-gtalk.l.google.com";
- private static int TEST_CREATE_SOCKET_PORT = 5228;
+ // a cert with a different CN, in this case CN=mail.google.com
+ private static String TEST_CREATE_SOCKET_HOST = "googlemail.com";
+ private static int TEST_CREATE_SOCKET_PORT = 443;
/**
* b/2807618 Make sure that hostname verifcation in cases were it
diff --git a/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java b/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
index 48c03b9..296fe44 100644
--- a/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
+++ b/tests/tests/permission/src/android/permission/cts/FileSystemPermissionTest.java
@@ -389,6 +389,7 @@
"/data/data/recovery/HTCFOTA",
"/data/data/recovery/OMADM",
"/data/data/shared",
+ "/data/diag_logs",
"/data/dontpanic",
"/data/drm",
"/data/drm/fwdlock",
@@ -464,6 +465,7 @@
"/data/system",
"/data/tmp",
"/data/tombstones",
+ "/data/tombstones/ramdump",
"/data/tpapi",
"/data/tpapi/etc",
"/data/tpapi/etc/tpa",
@@ -704,7 +706,9 @@
new File("/dev/tty"),
new File("/dev/urandom"),
new File("/dev/xt_qtaguid"), // b/9088251
- new File("/dev/zero")
+ new File("/dev/zero"),
+ new File("/dev/fimg2d"), // b/10428016
+ new File("/dev/mobicore-user") // b/10428016
));
public void testAllCharacterDevicesAreSecure() throws Exception {
@@ -716,6 +720,24 @@
insecure.isEmpty());
}
+ public void testDevRandomWorldReadableAndWritable() throws Exception {
+ FileUtils.FileStatus status = new FileUtils.FileStatus();
+ assertTrue(FileUtils.getFileStatus("/dev/random", status, false));
+ assertTrue(
+ "/dev/random not world-readable/writable. Actual mode: 0"
+ + Integer.toString(status.mode, 8),
+ (status.mode & 0666) == 0666);
+ }
+
+ public void testDevUrandomWorldReadableAndWritable() throws Exception {
+ FileUtils.FileStatus status = new FileUtils.FileStatus();
+ assertTrue(FileUtils.getFileStatus("/dev/urandom", status, false));
+ assertTrue(
+ "/dev/urandom not world-readable/writable. Actual mode: 0"
+ + Integer.toString(status.mode, 8),
+ (status.mode & 0666) == 0666);
+ }
+
private static Set<File>
getAllInsecureDevicesInDirAndSubdir(File dir, int type) throws Exception {
assertTrue(dir.isDirectory());
diff --git a/tests/tests/provider/src/android/provider/cts/CalendarTest.java b/tests/tests/provider/src/android/provider/cts/CalendarTest.java
index 3c10d0c..bd8e06d 100644
--- a/tests/tests/provider/src/android/provider/cts/CalendarTest.java
+++ b/tests/tests/provider/src/android/provider/cts/CalendarTest.java
@@ -1965,6 +1965,10 @@
assertTrue(eventId >= 0);
return eventValues;
}
+
+ public long getCalendarId() {
+ return mCalendarId;
+ }
}
/**
@@ -2000,7 +2004,8 @@
CalendarContract.Instances.CONTENT_BY_DAY_URI, julianStart + "/" + julianEnd);
// Query the range, sorting by event start time
- Cursor c = mContentResolver.query(uri, null, null, null, Events.DTSTART);
+ Cursor c = mContentResolver.query(uri, null, Instances.CALENDAR_ID + "="
+ + helper.getCalendarId(), null, Events.DTSTART);
// Assert that two events are returned
assertEquals(c.getCount(), 2);
diff --git a/tests/tests/security/AndroidManifest.xml b/tests/tests/security/AndroidManifest.xml
index 6c2c87a..771a184 100644
--- a/tests/tests/security/AndroidManifest.xml
+++ b/tests/tests/security/AndroidManifest.xml
@@ -19,13 +19,15 @@
package="com.android.cts.security">
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
+ <uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
+
<application>
<uses-library android:name="android.test.runner" />
</application>
<instrumentation android:name="android.test.InstrumentationCtsTestRunner"
android:targetPackage="com.android.cts.stub"
- android:label="CTS tests of com.android.cts.security"/>
+ android:label="CTS tests of com.android.cts.stub"/>
</manifest>
diff --git a/tests/tests/security/jni/Android.mk b/tests/tests/security/jni/Android.mk
index 5821ec0..06172c5 100644
--- a/tests/tests/security/jni/Android.mk
+++ b/tests/tests/security/jni/Android.mk
@@ -24,7 +24,8 @@
LOCAL_SRC_FILES := \
CtsSecurityJniOnLoad.cpp \
android_security_cts_CharDeviceTest.cpp \
- android_security_cts_NativeCodeTest.cpp
+ android_security_cts_LinuxRngTest.cpp \
+ android_security_cts_NativeCodeTest.cpp \
LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
diff --git a/tests/tests/security/jni/CtsSecurityJniOnLoad.cpp b/tests/tests/security/jni/CtsSecurityJniOnLoad.cpp
index 7244fc2..7577eef 100644
--- a/tests/tests/security/jni/CtsSecurityJniOnLoad.cpp
+++ b/tests/tests/security/jni/CtsSecurityJniOnLoad.cpp
@@ -18,6 +18,7 @@
#include <stdio.h>
extern int register_android_security_cts_CharDeviceTest(JNIEnv*);
+extern int register_android_security_cts_LinuxRngTest(JNIEnv*);
extern int register_android_security_cts_NativeCodeTest(JNIEnv*);
jint JNI_OnLoad(JavaVM *vm, void *reserved) {
@@ -31,6 +32,10 @@
return JNI_ERR;
}
+ if (register_android_security_cts_LinuxRngTest(env)) {
+ return JNI_ERR;
+ }
+
if (register_android_security_cts_NativeCodeTest(env)) {
return JNI_ERR;
}
diff --git a/tests/tests/security/jni/android_security_cts_LinuxRngTest.cpp b/tests/tests/security/jni/android_security_cts_LinuxRngTest.cpp
new file mode 100644
index 0000000..671226b
--- /dev/null
+++ b/tests/tests/security/jni/android_security_cts_LinuxRngTest.cpp
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2013 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.
+ */
+
+#include <errno.h>
+#include <jni.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+
+/*
+ * Native methods used by
+ * cts/tests/tests/permission/src/android/security/cts/LinuxRngTest.java
+ */
+
+static void throwIOException(JNIEnv* env, const char *format, ...) {
+ va_list ap;
+ va_start(ap, format);
+
+ char *message;
+ vasprintf(&message, format, ap);
+
+ va_end(ap);
+
+ jclass cls = env->FindClass("java/io/IOException");
+ env->ThrowNew(cls, message);
+
+ free(message);
+}
+
+jint android_security_cts_LinuxRngTest_getCharDeviceMajor(JNIEnv* env,
+ jobject thiz, jstring name)
+{
+ const char* nameStr = env->GetStringUTFChars(name, NULL);
+
+ jint result = -1;
+ struct stat st;
+ if (stat(nameStr, &st) == -1) {
+ throwIOException(env, "Failed to stat %s: %s", nameStr, strerror(errno));
+ goto ret;
+ }
+
+ if (!S_ISCHR(st.st_mode)) {
+ throwIOException(env, "%s is not a character device: mode is 0%o", nameStr, st.st_mode);
+ goto ret;
+ }
+
+ result = major(st.st_rdev);
+
+ret:
+ if (nameStr != NULL) {
+ env->ReleaseStringUTFChars(name, nameStr);
+ }
+ return result;
+}
+
+jint android_security_cts_LinuxRngTest_getCharDeviceMinor(JNIEnv* env,
+ jobject thiz, jstring name)
+{
+ const char* nameStr = env->GetStringUTFChars(name, NULL);
+
+ jint result = -1;
+ struct stat st;
+ if (stat(nameStr, &st) == -1) {
+ throwIOException(env, "Failed to stat %s: %s", nameStr, strerror(errno));
+ goto ret;
+ }
+
+ if (!S_ISCHR(st.st_mode)) {
+ throwIOException(env, "%s is not a character device: mode is 0%o", nameStr, st.st_mode);
+ goto ret;
+ }
+
+ result = minor(st.st_rdev);
+
+ret:
+ if (nameStr != NULL) {
+ env->ReleaseStringUTFChars(name, nameStr);
+ }
+ return result;
+}
+
+static JNINativeMethod gMethods[] = {
+ { "getCharDeviceMajor", "(Ljava/lang/String;)I",
+ (void *) android_security_cts_LinuxRngTest_getCharDeviceMajor },
+ { "getCharDeviceMinor", "(Ljava/lang/String;)I",
+ (void *) android_security_cts_LinuxRngTest_getCharDeviceMinor },
+};
+
+int register_android_security_cts_LinuxRngTest(JNIEnv* env)
+{
+ jclass clazz = env->FindClass("android/security/cts/LinuxRngTest");
+ return env->RegisterNatives(clazz, gMethods,
+ sizeof(gMethods) / sizeof(JNINativeMethod));
+}
diff --git a/tests/tests/security/src/android/security/cts/ClonedSecureRandomTest.java b/tests/tests/security/src/android/security/cts/ClonedSecureRandomTest.java
new file mode 100644
index 0000000..e51b11c
--- /dev/null
+++ b/tests/tests/security/src/android/security/cts/ClonedSecureRandomTest.java
@@ -0,0 +1,227 @@
+/*
+ * Copyright 2013 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.security.cts;
+
+import android.app.ActivityManager;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.os.IBinder;
+import android.security.cts.activity.ISecureRandomService;
+import android.security.cts.activity.SecureRandomService;
+import android.test.AndroidTestCase;
+
+import java.io.BufferedReader;
+import java.io.EOFException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+public class ClonedSecureRandomTest extends AndroidTestCase {
+ private static final int ANSWER_TIMEOUT_SECONDS = 60;
+
+ private static final String SEPARATE_PROCESS_NAME = ":secureRandom";
+
+ private static final int MAX_PID = 32768;
+
+ /**
+ * Attempt to burn through PIDs faster after this many iterations to reach a
+ * wrap-around point faster.
+ */
+ private static final int PRIMING_ITERATIONS = 128;
+
+ private static final int RANDOM_BYTES_PER_PID = 8;
+
+ private static final int MAX_PIDS_WASTED = 1024;
+
+ private static final int PID_WASTING_SKIP_LOWER = 64;
+
+ private static final int PID_WASTING_SKIP_UPPER = 2048;
+
+ private volatile CountDownLatch mLatch;
+
+ private Intent mSeparateIntent;
+
+ private ISecureRandomService mSecureRandomService;
+
+ private ServiceConnection mServiceConnection = new ServiceConnection() {
+ public void onServiceConnected(ComponentName className, IBinder service) {
+ mSecureRandomService = ISecureRandomService.Stub.asInterface(service);
+ mLatch.countDown();
+ }
+
+ public void onServiceDisconnected(ComponentName className) {
+ }
+ };
+
+ private boolean mHasDisconnected;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ mSeparateIntent = new Intent(getContext(), SecureRandomService.class);
+ }
+
+ /**
+ * This test spawns a Service in a new process to check the initial state of
+ * SecureRandom. It then attempts to make the PID number wrap around so it
+ * sees a new process with the same PID twice. The test completes when it
+ * sees two newly started processes with the same PID and compares their
+ * output.
+ */
+ public void testCheckForDuplicateOutput() throws Exception {
+ assertEquals("Only supports up to " + MAX_PID + " because of memory requirements",
+ Integer.toString(MAX_PID), getFirstLineFromFile("/proc/sys/kernel/pid_max"));
+
+ final String packageName = getContext().getPackageName();
+ String separateProcessName = packageName + SEPARATE_PROCESS_NAME;
+
+ /*
+ * Using a byte[][] and BitSet gives us a fixed upper bound for the
+ * memory cost of this test. One could possibly use a SparseArray if the
+ * upper bound becomes too large (for instance, if PID_MAX is large),
+ * only keep track of a smaller number of outputs, and just cause a
+ * wrap-around of PIDs to keep the test working.
+ */
+ byte[][] outputs = new byte[MAX_PID][RANDOM_BYTES_PER_PID];
+ BitSet seenPids = new BitSet(MAX_PID);
+
+ ActivityManager am = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
+
+ int myPid = android.os.Process.myPid();
+
+ /*
+ * We're guaranteed to see at least one duplicate if we iterate MAX_PID
+ * number of times because of the pigeonhole principle. In an attempt to
+ * hit a collision faster, first get a closely-spaced sampling of PIDs
+ * then spin up a bunch of threads locally to get us closer to wrapping
+ * around to the first PID.
+ */
+ int firstPid = -1;
+ int previousPid = -1;
+ for (int i = 0; i < MAX_PID; i++) {
+ byte[] output = new byte[RANDOM_BYTES_PER_PID];
+ int pid;
+
+ mLatch = new CountDownLatch(1);
+ getContext().startService(mSeparateIntent);
+ getContext().bindService(mSeparateIntent, mServiceConnection, 0);
+ if (!mLatch.await(ANSWER_TIMEOUT_SECONDS, TimeUnit.SECONDS)) {
+ fail("Timeout waiting for answer from SecureRandomService; cannot complete test");
+ }
+
+ pid = mSecureRandomService.getRandomBytesAndPid(output);
+
+ getContext().unbindService(mServiceConnection);
+ getContext().stopService(mSeparateIntent);
+ am.killBackgroundProcesses(packageName);
+
+ /*
+ * Make sure the AndroidManifest.xml wasn't altered in a way that
+ * breaks the test.
+ */
+ assertFalse("SecureRandomService must run in a different process. Check "
+ + "AndroidManifest.xml to ensure it has a unique android:process=\"...\"",
+ myPid == pid);
+
+ // We didn't get a new process for some reason. Try again.
+ if (previousPid == pid) {
+ i--;
+ continue;
+ } else if (previousPid == -1 && firstPid == -1) {
+ /*
+ * The first time around, we'll discard the output. This is
+ * needed because we don't know if the SecureRandomService instance
+ * has been running before or not. To be consistent, we only
+ * want the first outputs from SecureRandom for this test.
+ */
+ i--;
+ previousPid = pid;
+ continue;
+ } else {
+ previousPid = pid;
+ }
+
+ if (seenPids.get(pid)) {
+ assertFalse("SecureRandom should not output the same value twice (pid=" + pid
+ + ", output=" + Arrays.toString(output) + ", outputs[pid]="
+ + Arrays.toString(outputs[pid]) + ")",
+ Arrays.equals(output, outputs[pid]));
+ return;
+ }
+
+ seenPids.set(pid);
+ System.arraycopy(output, 0, outputs[pid], 0, output.length);
+
+ if (firstPid == -1) {
+ firstPid = pid;
+ }
+
+ if (i > PRIMING_ITERATIONS) {
+ wastePids(firstPid, previousPid);
+ }
+ }
+
+ /*
+ * This should never be reached unless the test was altered to break it.
+ * Since we're looping until we see PID_MAX unique answers, we must have
+ * seen a duplicate by the pigeonhole principle.
+ */
+ fail("Must see a duplicate PID");
+ }
+
+ /**
+ * This is an attempt to get the PIDs to roll over faster. Threads use up
+ * PIDs on Android and spawning a new thread is much faster than having
+ * another service spawned as we are doing in this test.
+ */
+ private static void wastePids(int firstPid, int previousPid) {
+ int distance = (firstPid - previousPid + MAX_PID) % MAX_PID;
+
+ // Don't waste PIDs if we're close to wrap-around to improve odds of
+ // collision.
+ if ((distance < PID_WASTING_SKIP_LOWER) || (MAX_PID - distance < PID_WASTING_SKIP_UPPER)) {
+ return;
+ }
+
+ for (int i = 0; i < distance; i++) {
+ Thread t = new Thread();
+ t.start();
+ }
+ }
+
+ private static String getFirstLineFromFile(String filename) throws IOException {
+ BufferedReader in = null;
+ try {
+ in = new BufferedReader(new FileReader(filename));
+ final String line = in.readLine();
+ if (line == null) {
+ throw new EOFException("EOF encountered before reading first line of " + filename);
+ }
+ return line.trim();
+ } finally {
+ if (in != null) {
+ in.close();
+ }
+ }
+ }
+}
diff --git a/tests/tests/security/src/android/security/cts/KernelSettingsTest.java b/tests/tests/security/src/android/security/cts/KernelSettingsTest.java
index f8ee283..bc60a65 100644
--- a/tests/tests/security/src/android/security/cts/KernelSettingsTest.java
+++ b/tests/tests/security/src/android/security/cts/KernelSettingsTest.java
@@ -31,6 +31,17 @@
public class KernelSettingsTest extends TestCase {
/**
+ * Ensure that SELinux is not in enforcing mode.
+ */
+ public void testSELinuxEnforcing() throws IOException {
+ try {
+ assertEquals("0", getFile("/sys/fs/selinux/enforce"));
+ } catch (FileNotFoundException e) {
+ // SELinux is not compiled into the kernel. Ignore exception.
+ }
+ }
+
+ /**
* Protect against kernel based NULL pointer attacks by enforcing a
* minimum (and maximum!) value of mmap_min_addr.
*
@@ -88,27 +99,6 @@
}
/**
- * Assert that support for loadable modules is not compiled into the
- * kernel.
- *
- * Loadable modules are often used to implement rootkit like functionality.
- * In addition, loadable modules enable support for /proc/sys/kernel/modprobe,
- * which is commonly used by exploit writers to gain root access.
- *
- * Support for loadable modules can be removed by editing the Linux kernel
- * config and removing the CONFIG_MODULES option.
- */
- public void testNoLoadableModules() throws IOException {
- assertFalse(
- "Support for loadable modules is compiled into the kernel. "
- + "Loadable modules are often used by rootkits and other "
- + "exploits and should be disabled. Please remove "
- + "CONFIG_MODULES from your kernel config and compile "
- + "all modules directly into the kernel.",
- new File("/proc/sys/kernel/modprobe").exists());
- }
-
- /**
* Assert that the kernel config file is not compiled into the kernel.
*
* Compiling the config file into the kernel leaks the kernel base address
diff --git a/tests/tests/security/src/android/security/cts/KeystoreExploitTest.java b/tests/tests/security/src/android/security/cts/KeystoreExploitTest.java
new file mode 100644
index 0000000..23266c2
--- /dev/null
+++ b/tests/tests/security/src/android/security/cts/KeystoreExploitTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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.security.cts;
+
+import android.test.AndroidTestCase;
+
+import java.io.File;
+import java.lang.reflect.Method;
+
+public class KeystoreExploitTest extends AndroidTestCase {
+ public void testKeystoreCrash() throws Exception {
+ int pid = Proc.findPidFor("/system/bin/keystore");
+
+ Class<?> keystoreClass = Class.forName("android.security.KeyStore");
+ Method getInstance = keystoreClass.getMethod("getInstance");
+ Method get = keystoreClass.getMethod("get", String.class);
+
+ Object keystore = getInstance.invoke(null);
+ String keyName = "AAAA AAAA AAAA AAAA "
+ + "AAAA AAAA AAAA AAAA "
+ + "AAAA AAAA AAAA AAAA "
+ + "AAAA AAAA AAAA AAAA "
+ + "AAAA AAAA AAAA AAAA "
+ + "AAAA AAAA AAAA AAAA "
+ + "AAAA AAAA AAAA AAAA "
+ + "AAAA AAAA AAAA AAAA "
+ + "AAAA AAAA AAAA AAAA "
+ + "AAAA AAAA AAAA AAAA "
+ + "AAAA AAAA AAAA AAAA "
+ + "AAAA AAAA AAAA AAAA "
+ + "AAAA AAAA AAAA AAAA "
+ + "AAAA AAAA AAAA AAAA "
+ + "AAAA AAAA AAAA AAAA "
+ + "AAAA AAAA AAAA AAAA "
+ + "AAAA AAAA AAAA AAAA "
+ + "AAAA AAAA AAAA AAAA "
+ + "AAAA AAAA AAAA AAAA "
+ + "AAAA AAAA AAAA AAAA";
+ get.invoke(keystore, keyName);
+
+ Thread.sleep(2000); // give keystore some time to crash
+
+ assertTrue("PID=" + pid + " crashed due to a malformed key name.",
+ new File("/proc/" + pid + "/cmdline").exists());
+ }
+}
diff --git a/tests/tests/security/src/android/security/cts/LinuxRngTest.java b/tests/tests/security/src/android/security/cts/LinuxRngTest.java
new file mode 100644
index 0000000..6bc5fd3
--- /dev/null
+++ b/tests/tests/security/src/android/security/cts/LinuxRngTest.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2013 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.security.cts;
+
+import junit.framework.TestCase;
+
+import java.io.IOException;
+
+public class LinuxRngTest extends TestCase {
+ static {
+ System.loadLibrary("ctssecurity_jni");
+ }
+
+ public void testDevRandomMajorMinor() throws Exception {
+ // Based on Linux kernel's drivers/char/random.c
+ assertEquals("/dev/random major", 1, getCharDeviceMajor("/dev/random"));
+ assertEquals("/dev/random minor", 8, getCharDeviceMinor("/dev/random"));
+ }
+
+ public void testDevUrandomMajorMinor() throws Exception {
+ // Based on Linux kernel's drivers/char/random.c
+ assertEquals("/dev/urandom major", 1, getCharDeviceMajor("/dev/urandom"));
+ assertEquals("/dev/urandom minor", 9, getCharDeviceMinor("/dev/urandom"));
+ }
+
+ public static native int getCharDeviceMajor(String file) throws IOException;
+ public static native int getCharDeviceMinor(String file) throws IOException;
+}
diff --git a/tests/tests/security/src/android/security/cts/Proc.java b/tests/tests/security/src/android/security/cts/Proc.java
new file mode 100644
index 0000000..6fe0706
--- /dev/null
+++ b/tests/tests/security/src/android/security/cts/Proc.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 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.security.cts;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+
+/**
+ * Utilities for accessing /proc filesystem information.
+ */
+public class Proc {
+ public static int findPidFor(String executable) throws IOException {
+ File f = new File("/proc");
+ for (File d : f.listFiles()) {
+ String cmdLineString = d.getAbsolutePath() + "/cmdline";
+ File cmdLine = new File(cmdLineString);
+ if (cmdLine.exists()) {
+ BufferedReader in = null;
+ try {
+ in = new BufferedReader(new FileReader(cmdLine));
+ String line = in.readLine();
+ if ((line != null) && line.startsWith(executable)) {
+ return Integer.decode(d.getName());
+ }
+ } finally {
+ if (in != null) {
+ in.close();
+ }
+ }
+ }
+ }
+ throw new RuntimeException("should never get here");
+ }
+}
diff --git a/tests/tests/security/src/android/security/cts/VoldExploitTest.java b/tests/tests/security/src/android/security/cts/VoldExploitTest.java
index d7f97ee..74d0f68 100644
--- a/tests/tests/security/src/android/security/cts/VoldExploitTest.java
+++ b/tests/tests/security/src/android/security/cts/VoldExploitTest.java
@@ -58,7 +58,7 @@
* is the typical failure for this test.
*/
public void testZergRushCrash() throws Exception {
- int pid = findVold();
+ int pid = Proc.findPidFor("/system/bin/vold");
StorageManager sm = (StorageManager) getContext().getSystemService(Context.STORAGE_SERVICE);
sm.getMountedObbPath("AAAA AAAA AAAA AAAA "
@@ -214,29 +214,6 @@
}
}
- private static int findVold() throws IOException {
- File f = new File("/proc");
- for (File d : f.listFiles()) {
- String cmdLineString = d.getAbsolutePath() + "/cmdline";
- File cmdLine = new File(cmdLineString);
- if (cmdLine.exists()) {
- BufferedReader in = null;
- try {
- in = new BufferedReader(new FileReader(cmdLine));
- String line = in.readLine();
- if ((line != null) && line.startsWith("/system/bin/vold")) {
- return Integer.decode(d.getName());
- }
- } finally {
- if (in != null) {
- in.close();
- }
- }
- }
- }
- throw new RuntimeException("should never get here");
- }
-
/**
* Extract all the PIDs listening for netlink messages.
*/
diff --git a/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java b/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
old mode 100755
new mode 100644
index 8acd0f4..17a109b
--- a/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
@@ -126,6 +126,7 @@
"45008", // KT
"45005", // SKT Mobility
"45002", // SKT Mobility
+ "45006", // LGT
// Verizon
"310004",
"310012",
@@ -160,6 +161,7 @@
"30272", // Rogers
"302370", // Fido
"30237", // Fido
+ "45006", // LGT
"45008" // KT
);
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java b/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
index 08fca45..afb0700 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
@@ -31,7 +31,7 @@
@Option(name="cts-install-path", description="the path to the cts installation to use")
private String mCtsRootDirPath = System.getProperty("CTS_ROOT");
- public static final String CTS_BUILD_VERSION = "4.3_r1";
+ public static final String CTS_BUILD_VERSION = "4.3_r2";
/**
* {@inheritDoc}