Merge "Move android.content out of CtsTestStubs" into lmp-dev
diff --git a/tests/res/layout/autocompletetextview_layout.xml b/tests/res/layout/autocompletetextview_layout.xml
index be1d284..c2404d5 100644
--- a/tests/res/layout/autocompletetextview_layout.xml
+++ b/tests/res/layout/autocompletetextview_layout.xml
@@ -28,5 +28,6 @@
android:completionThreshold="1"
android:completionHint="@string/tabs_1"
android:layout_width="match_parent"
- android:layout_height="wrap_content" />
+ android:layout_height="wrap_content"
+ android:inputType="none"/>
</LinearLayout>
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/CaptureResultTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/CaptureResultTest.java
index f81e2be..744f4ca 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/CaptureResultTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/CaptureResultTest.java
@@ -504,6 +504,10 @@
waiverKeys.add(CaptureResult.NOISE_REDUCTION_MODE);
}
+ if (!mStaticInfo.isManualLensShadingMapSupported()) {
+ waiverKeys.add(CaptureResult.SHADING_MODE);
+ }
+
//Keys not required if manual sensor control is not supported
if (!mStaticInfo.isCapabilitySupported(
CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR)) {
@@ -531,7 +535,6 @@
waiverKeys.add(CaptureResult.LENS_APERTURE);
waiverKeys.add(CaptureResult.LENS_FILTER_DENSITY);
waiverKeys.add(CaptureResult.SENSOR_ROLLING_SHUTTER_SKEW);
- waiverKeys.add(CaptureResult.SHADING_MODE);
waiverKeys.add(CaptureResult.STATISTICS_LENS_SHADING_MAP_MODE);
waiverKeys.add(CaptureResult.STATISTICS_SCENE_FLICKER);
waiverKeys.add(CaptureResult.STATISTICS_HOT_PIXEL_MAP_MODE);
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/StaticMetadataTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/StaticMetadataTest.java
index f0d8293..1d28e6d 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/StaticMetadataTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/StaticMetadataTest.java
@@ -31,14 +31,16 @@
import junit.framework.Assert;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
/**
* <p>
* This class covers the {@link CameraCharacteristics} tests that are not
- * covered by {@link CaptureRequestTest} and {@link CameraCharacteristicsTest}
- * (auto-generated tests that only do the non-null checks).
+ * covered by {@link CaptureRequestTest} and {@link ExtendedCameraCharacteristicsTest}
* </p>
* <p>
* Note that most of the tests in this class don't require camera open.
@@ -137,14 +139,79 @@
* @return {@code true} if request keys' presence match expectation. Otherwise {@code false}
*/
private boolean validateRequestKeysPresence(String capabilityName,
- List<CaptureRequest.Key<?>> requestKeys, boolean expectedPresence) {
+ Collection<CaptureRequest.Key<?>> requestKeys, boolean expectedPresence) {
boolean actualPresence = mStaticInfo.areRequestKeysAvailable(requestKeys);
if (expectedPresence != actualPresence) {
if (expectedPresence) {
for (CaptureRequest.Key<?> key : requestKeys) {
if (!mStaticInfo.areKeysAvailable(key)) {
mCollector.addMessage(String.format(
- "Camera %s list capability %s but doesn't contain key %s",
+ "Camera %s list capability %s but doesn't contain request key %s",
+ mCameraId, capabilityName, key.getName()));
+ }
+ }
+ } else {
+ Log.w(TAG, String.format(
+ "Camera %s doesn't list capability %s but contain all required keys",
+ mCameraId, capabilityName));
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Check if result keys' presence match expectation.
+ *
+ * @param capabilityName The name string of capability being tested. Used for output messages.
+ * @param resultKeys The capture result keys to be checked
+ * @param expectedPresence Expected presence of {@code resultKeys}. {@code true} for expecting
+ * all keys are available. Otherwise {@code false}
+ * @return {@code true} if result keys' presence match expectation. Otherwise {@code false}
+ */
+ private boolean validateResultKeysPresence(String capabilityName,
+ Collection<CaptureResult.Key<?>> resultKeys, boolean expectedPresence) {
+ boolean actualPresence = mStaticInfo.areResultKeysAvailable(resultKeys);
+ if (expectedPresence != actualPresence) {
+ if (expectedPresence) {
+ for (CaptureResult.Key<?> key : resultKeys) {
+ if (!mStaticInfo.areKeysAvailable(key)) {
+ mCollector.addMessage(String.format(
+ "Camera %s list capability %s but doesn't contain result key %s",
+ mCameraId, capabilityName, key.getName()));
+ }
+ }
+ } else {
+ Log.w(TAG, String.format(
+ "Camera %s doesn't list capability %s but contain all required keys",
+ mCameraId, capabilityName));
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Check if characteristics keys' presence match expectation.
+ *
+ * @param capabilityName The name string of capability being tested. Used for output messages.
+ * @param characteristicsKeys The characteristics keys to be checked
+ * @param expectedPresence Expected presence of {@code characteristicsKeys}. {@code true} for
+ * expecting all keys are available. Otherwise {@code false}
+ * @return {@code true} if characteristics keys' presence match expectation.
+ * Otherwise {@code false}
+ */
+ private boolean validateCharacteristicsKeysPresence(String capabilityName,
+ Collection<CameraCharacteristics.Key<?>> characteristicsKeys,
+ boolean expectedPresence) {
+ boolean actualPresence = mStaticInfo.areCharacteristicsKeysAvailable(characteristicsKeys);
+ if (expectedPresence != actualPresence) {
+ if (expectedPresence) {
+ for (CameraCharacteristics.Key<?> key : characteristicsKeys) {
+ if (!mStaticInfo.areKeysAvailable(key)) {
+ mCollector.addMessage(String.format(
+ "Camera %s list capability %s but doesn't contain" +
+ "characteristics key %s",
mCameraId, capabilityName, key.getName()));
}
}
@@ -160,8 +227,8 @@
private void validateCapability(Integer capability, boolean isCapabilityAvailable) {
List<CaptureRequest.Key<?>> requestKeys = new ArrayList<>();
- /* Only test request keys in this test
- Characteristics keys are tested in CameraCharacteristicsTest
+ /* For available capabilities, only check request keys in this test
+ Characteristics keys are tested in ExtendedCameraCharacteristicsTest
Result keys are tested in CaptureResultTest */
String capabilityName;
switch (capability) {
@@ -239,38 +306,74 @@
requestKeys.add(CaptureRequest.BLACK_LEVEL_LOCK);
break;
case REQUEST_AVAILABLE_CAPABILITIES_RAW:
- capabilityName = "REQUEST_AVAILABLE_CAPABILITIES_RAW";
- boolean rawOutputSupported = mStaticInfo.getRawOutputSizesChecked().length > 0;
- if (isCapabilityAvailable) {
- mCollector.expectTrue(
- "REQUEST_AVAILABLE_CAPABILITIES_RAW should support RAW_SENSOR output",
- rawOutputSupported);
- }
- requestKeys.add(CaptureRequest.HOT_PIXEL_MODE);
- requestKeys.add(CaptureRequest.STATISTICS_HOT_PIXEL_MAP_MODE);
- break;
+ // RAW_CAPABILITY needs to check for not just capture request keys
+ validateRawCapability(isCapabilityAvailable);
+ return;
default:
capabilityName = "Unknown";
Assert.fail(String.format("Unknown capability: %d", capability));
}
+
boolean matchExpectation =
validateRequestKeysPresence(capabilityName, requestKeys, isCapabilityAvailable);
-
// In case of isCapabilityAvailable == true, error has been filed in
// validateRequestKeysPresence
if (!matchExpectation && !isCapabilityAvailable) {
- if (capability == REQUEST_AVAILABLE_CAPABILITIES_RAW) {
- // RAW capability needs to also check raw output capability
- boolean rawOutputSupported = mStaticInfo.getRawOutputSizesChecked().length > 0;
- if (rawOutputSupported) {
- mCollector.addMessage(String.format(
- "Camera %s doesn't list capability %s but contain all required keys" +
- " and RAW format output",
- mCameraId, capabilityName));
- }
+ mCollector.addMessage(String.format(
+ "Camera %s doesn't list capability %s but contain all required keys",
+ mCameraId, capabilityName));
+ }
+ }
+
+ private void validateRawCapability(boolean isCapabilityAvailable) {
+ String capabilityName = "REQUEST_AVAILABLE_CAPABILITIES_RAW";
+
+ Set<CaptureRequest.Key<?>> requestKeys = new HashSet<>();
+ requestKeys.add(CaptureRequest.HOT_PIXEL_MODE);
+ requestKeys.add(CaptureRequest.STATISTICS_HOT_PIXEL_MAP_MODE);
+
+ Set<CameraCharacteristics.Key<?>> characteristicsKeys = new HashSet<>();
+ characteristicsKeys.add(HOT_PIXEL_AVAILABLE_HOT_PIXEL_MODES);
+ characteristicsKeys.add(SENSOR_BLACK_LEVEL_PATTERN);
+ characteristicsKeys.add(SENSOR_CALIBRATION_TRANSFORM1);
+ characteristicsKeys.add(SENSOR_CALIBRATION_TRANSFORM2);
+ characteristicsKeys.add(SENSOR_COLOR_TRANSFORM1);
+ characteristicsKeys.add(SENSOR_COLOR_TRANSFORM2);
+ characteristicsKeys.add(SENSOR_FORWARD_MATRIX1);
+ characteristicsKeys.add(SENSOR_FORWARD_MATRIX2);
+ characteristicsKeys.add(SENSOR_INFO_ACTIVE_ARRAY_SIZE);
+ characteristicsKeys.add(SENSOR_INFO_COLOR_FILTER_ARRANGEMENT);
+ characteristicsKeys.add(SENSOR_INFO_WHITE_LEVEL);
+ characteristicsKeys.add(SENSOR_REFERENCE_ILLUMINANT1);
+ characteristicsKeys.add(SENSOR_REFERENCE_ILLUMINANT2);
+ characteristicsKeys.add(STATISTICS_INFO_AVAILABLE_HOT_PIXEL_MAP_MODES);
+
+ Set<CaptureResult.Key<?>> resultKeys = new HashSet<>();
+ resultKeys.add(CaptureResult.SENSOR_NEUTRAL_COLOR_POINT);
+ resultKeys.add(CaptureResult.SENSOR_GREEN_SPLIT);
+ resultKeys.add(CaptureResult.SENSOR_NOISE_PROFILE);
+
+ boolean rawOutputSupported = mStaticInfo.getRawOutputSizesChecked().length > 0;
+ boolean requestKeysPresent = mStaticInfo.areRequestKeysAvailable(requestKeys);
+ boolean characteristicsKeysPresent =
+ mStaticInfo.areCharacteristicsKeysAvailable(characteristicsKeys);
+ boolean resultKeysPresent = mStaticInfo.areResultKeysAvailable(resultKeys);
+ boolean expectCapabilityPresent = rawOutputSupported && requestKeysPresent &&
+ characteristicsKeysPresent && resultKeysPresent;
+
+ if (isCapabilityAvailable != expectCapabilityPresent) {
+ if (isCapabilityAvailable) {
+ mCollector.expectTrue(
+ "REQUEST_AVAILABLE_CAPABILITIES_RAW should support RAW_SENSOR output",
+ rawOutputSupported);
+ validateRequestKeysPresence(capabilityName, requestKeys, isCapabilityAvailable);
+ validateResultKeysPresence(capabilityName, resultKeys, isCapabilityAvailable);
+ validateCharacteristicsKeysPresence(capabilityName, characteristicsKeys,
+ isCapabilityAvailable);
} else {
mCollector.addMessage(String.format(
- "Camera %s doesn't list capability %s but contain all required keys",
+ "Camera %s doesn't list capability %s but contain all required keys" +
+ " and RAW format output",
mCameraId, capabilityName));
}
}
diff --git a/tests/tests/media/src/android/media/cts/Vp8CodecTestBase.java b/tests/tests/media/src/android/media/cts/Vp8CodecTestBase.java
index a4051c9..40d09a5 100644
--- a/tests/tests/media/src/android/media/cts/Vp8CodecTestBase.java
+++ b/tests/tests/media/src/android/media/cts/Vp8CodecTestBase.java
@@ -629,9 +629,10 @@
}
if (result >= 0) {
int outputBufIndex = result;
+ int bufferSize = Math.min(frameWidth * frameHeight * 3 / 2, bufferInfo.size);
outPresentationTimeUs = bufferInfo.presentationTimeUs;
Log.v(TAG, "Writing buffer # " + outputFrameIndex +
- ". Size: " + bufferInfo.size +
+ ". Size: " + bufferSize +
". InTime: " + (inPresentationTimeUs + 500)/1000 +
". OutTime: " + (outPresentationTimeUs + 500)/1000);
if ((bufferInfo.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0) {
@@ -639,12 +640,12 @@
Log.d(TAG, " Output EOS for frame # " + outputFrameIndex);
}
- if (bufferInfo.size > 0) {
+ if (bufferSize > 0) {
// Save decoder output to yuv file.
if (yuv != null) {
- byte[] frame = new byte[bufferInfo.size];
+ byte[] frame = new byte[bufferSize];
outputBuffers[outputBufIndex].position(bufferInfo.offset);
- outputBuffers[outputBufIndex].get(frame, 0, bufferInfo.size);
+ outputBuffers[outputBufIndex].get(frame, 0, bufferSize);
// Convert NV12 to YUV420 if necessary
if (frameColorFormat != CodecCapabilities.COLOR_FormatYUV420Planar) {
frame = NV12ToYUV420(frameWidth, frameHeight,
@@ -657,7 +658,7 @@
// Update statistics - store presentation time delay in offset
long presentationTimeUsDelta = inPresentationTimeUs - outPresentationTimeUs;
MediaCodec.BufferInfo bufferInfoCopy = new MediaCodec.BufferInfo();
- bufferInfoCopy.set((int)presentationTimeUsDelta, bufferInfo.size,
+ bufferInfoCopy.set((int)presentationTimeUsDelta, bufferSize,
outPresentationTimeUs, bufferInfo.flags);
bufferInfos.add(bufferInfoCopy);
}
diff --git a/tests/tests/security/jni/android_security_cts_NativeCodeTest.cpp b/tests/tests/security/jni/android_security_cts_NativeCodeTest.cpp
index dde06a2..faa6eea 100644
--- a/tests/tests/security/jni/android_security_cts_NativeCodeTest.cpp
+++ b/tests/tests/security/jni/android_security_cts_NativeCodeTest.cpp
@@ -30,6 +30,7 @@
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/stat.h>
+#include <sys/utsname.h>
#include <fcntl.h>
#include <cutils/log.h>
#include <linux/perf_event.h>
@@ -102,6 +103,17 @@
struct iovec iov;
struct sock_diag_req* sock_diag_data;
+ int major, minor;
+ struct utsname uts;
+ if (uname(&uts) != -1 &&
+ sscanf(uts.release, "%d.%d", &major, &minor) == 2 &&
+ ((major > 3) || ((major == 3) && (minor > 8)))) {
+ // Kernels above 3.8 are patched against CVE-2013-1763
+ // This test generates false positives if run on > 3.8.
+ // b/17253473
+ return PASSED;
+ }
+
fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_SOCK_DIAG);
if (fd == -1) {
switch (errno) {
diff --git a/tests/tests/security/src/android/security/cts/SqliteJournalLeakTest.java b/tests/tests/security/src/android/security/cts/SqliteJournalLeakTest.java
deleted file mode 100644
index 109aa21..0000000
--- a/tests/tests/security/src/android/security/cts/SqliteJournalLeakTest.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * 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.
- */
-
-package android.security.cts;
-
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Environment;
-import android.test.AndroidTestCase;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.InputStreamReader;
-import java.io.IOException;
-
-
-public class SqliteJournalLeakTest extends AndroidTestCase {
-
- private static final int REPEAT = 5;
-
- private static final String[] DATABASES = {
- "/com.android.bluetooth/databases/btopp.db",
- "/com.android.browser/app_appcache/ApplicationCache.db",
- "/com.android.browser/app_databases/Databases.db",
- "/com.android.browser/app_geolocation/CachedGeoposition.db",
- "/com.android.browser/app_geolocation/GeolocationPermissions.db",
- "/com.android.browser/app_icons/WebpageIcons.db",
- "/com.android.browser/databases/browser.db",
- "/com.android.browser/databases/launcher.db",
- "/com.android.browser/databases/webview.db",
- "/com.android.browser/databases/webviewCache.db",
- "/com.android.email/databases/EmailProvider.db",
- "/com.android.email/databases/EmailProviderBody.db",
- "/com.android.email/databases/webview.db",
- "/com.android.email/databases/webviewCache.db",
- "/com.android.providers.calendar/databases/calendar.db",
- "/com.android.providers.contacts/databases/contacts2.db",
- "/com.android.providers.downloads/databases/downloads.db",
- "/com.android.providers.drm/databases/drm.db",
- "/com.android.providers.media/databases/internal.db",
- "/com.android.providers.settings/databases/settings.db",
- "/com.android.providers.tasks/databases/tasks.db",
- "/com.android.providers.telephony/optable.db",
- "/com.android.providers.telephony/databases/mmssms.db",
- "/com.android.providers.telephony/databases/nwk_info.db",
- "/com.android.providers.telephony/databases/telephony.db",
- "/com.android.providers.telephony/databases/tether_dun.db",
- "/com.android.providers.userdictionary/databases/user_dict.db",
- "/com.android.settings/databases/webview.db",
- "/com.android.settings/databases/webviewCache.db",
- "/com.android.vending/databases/billing4.db",
- "/com.android.vending/databases/market_assets.db",
- "/com.android.vending/databases/suggestions.db",
- "/com.android.vending/databases/webview.db",
- "/com.android.vending/databases/webviewCache.db"
- };
-
- /**
- * This method triggers activities that should cause database writes.
- * The goal of this is to try to make potentially short-lived journal
- * files show up.
- */
- private void doActivity() {
- Intent webIntent = new Intent(Intent.ACTION_VIEW);
- webIntent.setData(Uri.parse("http:///localhost"));
- webIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- getContext().startActivity(webIntent);
- Intent dictIntent = new Intent("android.settings.USER_DICTIONARY_SETTINGS");
- dictIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- getContext().startActivity(dictIntent);
- }
-
- private void checkDatabases(String suffix) {
- String msg = " is world readable. Please set its permissions to 600"
- + " by setting -DSQLITE_DEFAULT_FILE_PERMISSIONS=0600 in external/sqlite/dist/"
- + "Android.mk; see CVE-2011-3901.";
- String base = Environment.getDataDirectory().getAbsolutePath();
- for(int i=REPEAT; i > 0; i--) {
- doActivity();
- for (String name : DATABASES) {
- name = base + "/data" + name + suffix;
- File f = new File(name);
- assertFalse(name + msg, f.canRead());
- }
- }
- }
-
- public void testJournal() {
- checkDatabases("-journal");
- }
-
- public void testWal() {
- checkDatabases("-wal");
- }
-
- public void testShm() {
- checkDatabases("-shm");
- }
-}