Merge "Modify user agent CTS test to (optionally) match new webview user agent." into lollipop-cts-dev
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index 57fcc85..35371ea 100644
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -1435,93 +1435,90 @@
<string name="js_any_connectivity_test">Device with no connectivity will not execute a job with an unmetered connectivity constraint.</string>
<string name="js_no_connectivity_test">Device with no connectivity will still execute a job with no connectivity constraints.</string>
- <!-- String for Live Channels app Tests -->
+ <!-- String for the bundled TV app Tests -->
- <string name="tv_input_discover_test">3rd-party TV input app discoverability test</string>
+ <string name="tv_input_discover_test">3rd-party TV input test</string>
<string name="tv_input_discover_test_info">
- This test verifies that the pre-loaded Live Channels app is invoked via intents and issues
- appropriate calls to framework APIs, so that TV input apps work properly with the pre-loaded
- Live Channels app.
+ Verify that the bundled TV app launches via Intent and calls the proper API to discover
+ 3rd-party TV inputs.
</string>
<string name="tv_input_discover_test_go_to_setup">
- Press the \"Launch Live Channels\" button, and set up the newly installed TV input:
+ Select the \"Launch TV app\" button and set up the newly installed TV input:
\"CTS Verifier\".
</string>
<string name="tv_input_discover_test_verify_setup">
Setup activity must have been started.
</string>
<string name="tv_input_discover_test_tune_to_channel">
- Press the \"Launch Live Channels\" button, and tune to the channel named \"Dummy\" from
- \"CTS Verifier\" input. If necessary, configure the channel to be visible.
+ Select the \"Launch TV app\" button and tune to the \"Dummy\" channel from \"CTS Verifier\"
+ input. If necessary, configure the channel to be visible.
</string>
<string name="tv_input_discover_test_verify_tune">
Tune command must be called.
</string>
<string name="tv_input_discover_test_verify_overlay_view">
- Overlay view must be shown. Verify that there is a text view displaying \"Overlay View Dummy Text\"
- when you tune to the \"Dummy\" channel.
+ Verify that the overlay appears and displays the text \"Overlay View Dummy Text\" when you tune
+ to the \"Dummy\" channel.
</string>
<string name="tv_input_discover_test_verify_global_search">
- Live Channels app should provide query results for 3rd-party input\'s channels and programs on
- global search requests.
+ Verify the TV app provides query results for 3rd-party input\'s channels and programs in
+ global search results.
</string>
<string name="tv_input_discover_test_go_to_epg">
- Press the \"Launch EPG\" button, and locate the channel named \"Dummy\".
+ Select the \"Launch EPG\" button and locate the \"Dummy\" channel.
</string>
<string name="tv_input_discover_test_verify_epg">
- Do you see the programs named \"Dummy Program\" and its description
+ Do you see the programs named \"Dummy Program\" and their descriptions
"Dummy Program Description" in the EPG?
</string>
<string name="tv_input_discover_test_yes">Yes</string>
- <string name="tv_parental_control_test">Live Channels app parental control test</string>
+ <string name="tv_parental_control_test">TV app parental controls test</string>
<string name="tv_parental_control_test_info">
- This test verifies that the default Live Channels app invokes proper parental control APIs in
- the framework.
+ Verify that the bundled TV app calls the parental controls API.
</string>
<string name="tv_parental_control_test_turn_on_parental_control">
- Press the \"Launch Live Channels\" button, and turn on the parental control. If it\'s on
- already, turn it off and on again.
+ Select the \"Launch TV app\" button and turn on the parental controls. If parental controls are
+ on already, turn it off and on again.
</string>
<string name="tv_parental_control_test_verify_receive_broadcast1">
TV input service must have received ACTION_PARENTAL_CONTROLS_ENABLED_CHANGED broadcast.
</string>
<string name="tv_parental_control_test_block_tv_ma">
- Press the \"Launch Live Channels\" button, and block \"Fake\" rating for \"CtsVerifier\" rating
- system in the parental control settings. You may have to enable the rating system if it is
- disabled by default. If it\'s already blocked, unblock, save, and then block again.
+ Select the \"Launch TV app\" button and block the \"Fake\" rating for \"CtsVerifier\" rating
+ system in the parental control settings. If the rating system is disabled by default, enable it.
+ If the \"Fake\" rating is already blocked, unblock it, save, and then block again.
</string>
<string name="tv_parental_control_test_verify_receive_broadcast2">
TV input service must have received ACTION_BLOCKED_RATINGS_CHANGED broadcast.
</string>
<string name="tv_parental_control_test_block_unblock">
- Press the \"Launch Live Channels\" button; verify that the channel is blocked visually.
- Try unblock the screen by entering PIN; verify that it\'s unblocked visually.
+ Select the \"Launch TV app\" button; verify that the channel is blocked.
+ Try to unblock the screen by entering PIN; verify that it\'s unblocked.
</string>
- <string name="tv_launch_tv_app">Launch Live Channels</string>
+ <string name="tv_launch_tv_app">Launch TV app</string>
<string name="tv_launch_epg">Launch EPG</string>
<string name="tv_channel_not_found">
CtsVerifier channel is not set up. Please set up before proceeding.
</string>
- <string name="tv_multiple_tracks_test">Live Channels app closed captions and multi-audio test</string>
+ <string name="tv_multiple_tracks_test">TV app closed captions and multi-audio test</string>
<string name="tv_multiple_tracks_test_info">
- This test verifies that the default Live Channels app invokes proper mulitple tracks APIs in the
- framework.
+ Verify that the bundled TV app calls the multi-track API.
</string>
<string name="tv_multiple_tracks_test_select_subtitle">
- Press the \"Launch Live Channels\" button. Verify that the closed caption is off by default.
- Set closed caption to English.
+ Select the \"Launch TV app\" button. Verify that closed captions are off by default. Set closed
+ caption language to English.
</string>
<string name="tv_multiple_tracks_test_verify_set_caption_enabled">
- Caption should be enabled.
+ Captions are enabled.
</string>
<string name="tv_multiple_tracks_test_verify_select_subtitle">
- The English subtitle track should be selected.
+ The English closed caption track should be selected.
</string>
<string name="tv_multiple_tracks_test_select_audio">
- Press the \"Launch Live Channels\" button. Verify that the audio track is English by default.
+ Select the \"Launch TV app\" button. Verify that the audio track is English by default.
Select Spanish audio track.
</string>
<string name="tv_multiple_tracks_test_verify_select_audio">
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/camera/formats/CameraFormatsActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/formats/CameraFormatsActivity.java
index d325b65..9c5b31d 100755
--- a/apps/CtsVerifier/src/com/android/cts/verifier/camera/formats/CameraFormatsActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/camera/formats/CameraFormatsActivity.java
@@ -236,8 +236,15 @@
public void onSurfaceTextureAvailable(SurfaceTexture surface,
int width, int height) {
mPreviewTexture = surface;
- mPreviewTexWidth = width;
- mPreviewTexHeight = height;
+ if (mFormatView.getMeasuredWidth() != width
+ || mFormatView.getMeasuredHeight() != height) {
+ mPreviewTexWidth = mFormatView.getMeasuredWidth();
+ mPreviewTexHeight = mFormatView.getMeasuredHeight();
+ } else {
+ mPreviewTexWidth = width;
+ mPreviewTexHeight = height;
+ }
+
if (mCamera != null) {
startPreview();
}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/camera/fov/DetermineFovActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/fov/DetermineFovActivity.java
index 8b989e1..959e98f 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/camera/fov/DetermineFovActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/camera/fov/DetermineFovActivity.java
@@ -145,7 +145,7 @@
mTargetDistanceCm = getTargetDistance();
mReportedFovDegrees = PhotoCaptureActivity.getReportedFovDegrees();
- mFovDegrees = mReportedFovDegrees > 80 ? 60 : mReportedFovDegrees;
+ mFovDegrees = mReportedFovDegrees > 120 ? 60 : mReportedFovDegrees;
mFovMaxDegrees = mFovDegrees + FOV_ADJUSTMENT_RANGE / 2;
mFovMinDegrees = mFovDegrees - FOV_ADJUSTMENT_RANGE / 2;
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/camera/orientation/CameraOrientationActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/orientation/CameraOrientationActivity.java
index 273d78a..49b34fd 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/camera/orientation/CameraOrientationActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/camera/orientation/CameraOrientationActivity.java
@@ -389,6 +389,7 @@
int targetWidth = w;
boolean aspectRatio = true;
+ boolean maintainCeiling = true;
while(true) {
for (Camera.Size size : sizes) {
if(aspectRatio) {
@@ -399,20 +400,27 @@
}
curDiff = Math.abs(size.height - targetHeight) +
Math.abs(size.width - targetWidth);
- if (curDiff < minDiff
+ if (maintainCeiling && curDiff < minDiff
&& size.height <= targetHeight
&& size.width <= targetWidth) {
optimalSize = size;
minDiff = curDiff;
+ } else if (maintainCeiling == false
+ && curDiff < minDiff) {
+ //try to get as close as possible
+ optimalSize = size;
+ minDiff = curDiff;
}
}
- if (optimalSize == null) {
+ if (optimalSize == null && aspectRatio == true) {
// Cannot find a match, so repeat search and
// ignore aspect ratio requirement
aspectRatio = false;
- continue;
- }
- else {
+ } else if (maintainCeiling == true) {
+ //Camera resolutions are greater than ceiling provided
+ //lets try to get as close as we can
+ maintainCeiling = false;
+ } else {
break;
}
}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/camera/video/CameraVideoActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/camera/video/CameraVideoActivity.java
index 48ce03c..0a397e8 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/camera/video/CameraVideoActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/camera/video/CameraVideoActivity.java
@@ -268,6 +268,7 @@
@Override
public void onCompletion(MediaPlayer mp) {
isPlayingBack = false;
+ mPlaybackView.stopPlayback();
captureButton.setEnabled(true);
mStatusLabel.setText(getResources().getString(R.string.status_ready));
}
@@ -562,7 +563,7 @@
if (matchedSize == null) {
for (int i = mPreviewSizes.size() - 1; i >= 0; i--) {
if (Math.abs((float)mPreviewSizes.get(i).width * recordSize.height /
- mPreviewSizes.get(i).height / recordSize.width - 1) < 0.1) {
+ mPreviewSizes.get(i).height / recordSize.width - 1) < 0.12) {
matchedSize = mCamera.new Size(mPreviewSizes.get(i).width,
mPreviewSizes.get(i).height);
break;
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/tv/TvAppVerifierActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/tv/TvAppVerifierActivity.java
index 3529237..12e9652 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/tv/TvAppVerifierActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/tv/TvAppVerifierActivity.java
@@ -63,6 +63,7 @@
protected void setButtonEnabled(View item, boolean enabled) {
View button = item.findViewById(R.id.user_action_button);
+ button.setFocusable(enabled);
button.setClickable(enabled);
button.setEnabled(enabled);
}
@@ -70,9 +71,7 @@
protected void setPassState(View item, boolean passed) {
ImageView status = (ImageView) item.findViewById(R.id.status);
status.setImageResource(passed ? R.drawable.fs_good : R.drawable.fs_error);
- View button = item.findViewById(R.id.user_action_button);
- button.setClickable(false);
- button.setEnabled(false);
+ setButtonEnabled(item, false);
status.invalidate();
}
diff --git a/hostsidetests/dumpsys/src/android/dumpsys/cts/DumpsysHostTest.java b/hostsidetests/dumpsys/src/android/dumpsys/cts/DumpsysHostTest.java
index 4668faf..0315c96 100644
--- a/hostsidetests/dumpsys/src/android/dumpsys/cts/DumpsysHostTest.java
+++ b/hostsidetests/dumpsys/src/android/dumpsys/cts/DumpsysHostTest.java
@@ -699,7 +699,7 @@
}
private void checkSignalStrength(String[] parts) {
- assertEquals(9, parts.length);
+ assertTrue(parts.length >= 9);
assertInteger(parts[4]); // none
assertInteger(parts[5]); // poor
assertInteger(parts[6]); // moderate
diff --git a/suite/cts/deviceTests/videoperf/src/com/android/cts/videoperf/CodecInfo.java b/suite/cts/deviceTests/videoperf/src/com/android/cts/videoperf/CodecInfo.java
index b7d1d27..5daf73d 100644
--- a/suite/cts/deviceTests/videoperf/src/com/android/cts/videoperf/CodecInfo.java
+++ b/suite/cts/deviceTests/videoperf/src/com/android/cts/videoperf/CodecInfo.java
@@ -86,6 +86,20 @@
if (mimeType.equals(VIDEO_AVC)) {
info.mFps = vidCap.getSupportedFrameRatesFor(w, h).getUpper().intValue();
info.mBitRate = vidCap.getBitrateRange().getUpper();
+
+ // we don't parse bitrate-range on L, so need to adjust bitrate to supported
+ // baseline or main profiles only.
+ int maxBitRate = 0;
+ for (CodecProfileLevel pl : cap.profileLevels) {
+ if (pl.profile == pl.AVCProfileBaseline || pl.profile == pl.AVCProfileMain) {
+ VideoCapabilities vidCapPL =
+ CodecCapabilities.createFromProfileLevel(mimeType, pl.profile, pl.level)
+ .getVideoCapabilities();
+ maxBitRate = Math.max(maxBitRate, vidCapPL.getBitrateRange().getUpper());
+ }
+ }
+ info.mBitRate = Math.min(info.mBitRate, maxBitRate);
+
Log.i(TAG, "AVC bit rate " + info.mBitRate + " fps " + info.mFps);
}
return info;
diff --git a/tests/JobScheduler/src/android/jobscheduler/cts/ConnectivityConstraintTest.java b/tests/JobScheduler/src/android/jobscheduler/cts/ConnectivityConstraintTest.java
index a83f7a9..547b205 100644
--- a/tests/JobScheduler/src/android/jobscheduler/cts/ConnectivityConstraintTest.java
+++ b/tests/JobScheduler/src/android/jobscheduler/cts/ConnectivityConstraintTest.java
@@ -51,6 +51,8 @@
private boolean mHasWifi;
/** Whether the device running these tests supports telephony. */
private boolean mHasTelephony;
+ /** Track whether WiFi was enabled in case we turn it off. */
+ private boolean mInitialWiFiState;
private JobInfo.Builder mBuilder;
@@ -67,6 +69,14 @@
mHasTelephony = packageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
mBuilder =
new JobInfo.Builder(CONNECTIVITY_JOB_ID, kJobServiceComponent);
+
+ mInitialWiFiState = mWifiManager.isWifiEnabled();
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ // Ensure that we leave WiFi in its previous state.
+ mWifiManager.setWifiEnabled(mInitialWiFiState);
}
// --------------------------------------------------------------------------------------------
@@ -202,6 +212,14 @@
}
}
+ /**
+ * Disconnect from WiFi in an attempt to connect to cellular data. Worth noting that this is
+ * best effort - there are no public APIs to force connecting to cell data. We disable WiFi
+ * and wait for a broadcast that we're connected to cell.
+ * We will not call into this function if the device doesn't support telephony.
+ * @see #mHasTelephony
+ * @see #checkDeviceSupportsMobileData()
+ */
private void disconnectWifiToConnectToMobile() throws InterruptedException {
if (mHasWifi && mWifiManager.isWifiEnabled()) {
ConnectivityActionReceiver connectMobileReceiver =
diff --git a/tests/expectations/knownfailures.txt b/tests/expectations/knownfailures.txt
index 804362a..0ed52cd 100644
--- a/tests/expectations/knownfailures.txt
+++ b/tests/expectations/knownfailures.txt
@@ -151,24 +151,6 @@
bug: 17508787
},
{
- description: "New tests recently added for Android Enterprise. To be moved out of CTS-staging as soon as they show that they are stable",
- names: [
- "com.android.cts.devicepolicy.LauncherAppsMultiUserTest#testGetActivitiesForNonProfileFails",
- "com.android.cts.devicepolicy.LauncherAppsMultiUserTest#testNoLauncherCallbackPackageAddedSecondaryUser",
- "com.android.cts.devicepolicy.LauncherAppsProfileTest#testGetActivitiesWithProfile",
- "com.android.cts.devicepolicy.LauncherAppsProfileTest#testLauncherCallbackPackageAddedProfile",
- "com.android.cts.devicepolicy.LauncherAppsProfileTest#testLauncherCallbackPackageRemovedProfile",
- "com.android.cts.devicepolicy.LauncherAppsProfileTest#testLauncherCallbackPackageChangedProfile",
- "com.android.cts.devicepolicy.LauncherAppsSingleUserTest#testInstallAppMainUser",
- "com.android.cts.devicepolicy.LauncherAppsSingleUserTest#testLauncherCallbackPackageAddedMainUser",
- "com.android.cts.devicepolicy.LauncherAppsSingleUserTest#testLauncherCallbackPackageRemovedMainUser",
- "com.android.cts.devicepolicy.LauncherAppsSingleUserTest#testLauncherCallbackPackageChangedMainUser",
- "com.android.cts.devicepolicy.LauncherAppsSingleUserTest#testLauncherNonExportedAppFails",
- "com.android.cts.devicepolicy.LauncherAppsSingleUserTest#testLaunchNonExportActivityFails",
- "com.android.cts.devicepolicy.LauncherAppsSingleUserTest#testLaunchMainActivity"
- ]
-},
-{
description: "These tests fail on some devices.",
names: [
"android.uirendering.cts.testclasses.ExactCanvasTests#testBlueRect",
@@ -379,5 +361,12 @@
"com.android.org.conscrypt.SignatureTest#test_getInstance_OpenSSL_ENGINE"
],
bug: 18030049
+},
+{
+ description: "URLConnection fails for unknown reasons",
+ names: [
+ "libcore.java.net.URLConnectionTest#testConnectViaHttpProxyToHttpsUsingBadProxyAndHttpResponseCache fails"
+ ],
+ bug: 22033061
}
]
diff --git a/tests/tests/app/src/android/app/cts/ActivityManagerTest.java b/tests/tests/app/src/android/app/cts/ActivityManagerTest.java
index e633f1f..998a005 100644
--- a/tests/tests/app/src/android/app/cts/ActivityManagerTest.java
+++ b/tests/tests/app/src/android/app/cts/ActivityManagerTest.java
@@ -219,7 +219,8 @@
hasTestProcess = true;
}
}
- assertTrue(hasSystemProcess && hasTestProcess);
+ // For security reasons the system process is not exposed.
+ assertTrue(!hasSystemProcess && hasTestProcess);
for (RunningAppProcessInfo ra : list) {
if (ra.processName.equals("com.android.cts.app.stub:remote")) {
diff --git a/tests/tests/content/src/android/content/cts/HighPriorityBroadcastReceiver.java b/tests/tests/content/src/android/content/cts/HighPriorityBroadcastReceiver.java
index f3a4ba1..187fe06 100644
--- a/tests/tests/content/src/android/content/cts/HighPriorityBroadcastReceiver.java
+++ b/tests/tests/content/src/android/content/cts/HighPriorityBroadcastReceiver.java
@@ -22,13 +22,11 @@
public class HighPriorityBroadcastReceiver extends ResultReceiver {
@Override
- public void onReceive(Context context, Intent intent) {
+ public synchronized void onReceive(Context context, Intent intent) {
super.onReceive(context, intent);
try {
- synchronized (this) {
- wait();
- }
+ wait();
} catch (InterruptedException e) {
throw new RuntimeException("Got interrupted during wait()", e);
}
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/Camera2SurfaceViewCtsActivity.java b/tests/tests/hardware/src/android/hardware/camera2/cts/Camera2SurfaceViewCtsActivity.java
index 936883e..1881774 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/Camera2SurfaceViewCtsActivity.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/Camera2SurfaceViewCtsActivity.java
@@ -19,6 +19,7 @@
import android.app.Activity;
import android.os.Bundle;
import android.os.ConditionVariable;
+import android.os.SystemClock;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
@@ -57,7 +58,7 @@
int waitTimeMs = timeOutMs;
boolean changeSucceeded = false;
while (!changeSucceeded && waitTimeMs > 0) {
- long startTimeMs = System.currentTimeMillis();
+ long startTimeMs = SystemClock.elapsedRealtime();
changeSucceeded = surfaceChangedDone.block(waitTimeMs);
if (!changeSucceeded) {
Log.e(TAG, "Wait for surface change timed out after " + timeOutMs + " ms");
@@ -72,7 +73,7 @@
// again.
changeSucceeded = false;
}
- waitTimeMs -= (System.currentTimeMillis() - startTimeMs);
+ waitTimeMs -= (SystemClock.elapsedRealtime() - startTimeMs);
}
// Couldn't get expected surface size change.
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/CameraDeviceTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/CameraDeviceTest.java
index 9f50b43..d7c3cea 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/CameraDeviceTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/CameraDeviceTest.java
@@ -1307,6 +1307,10 @@
!mStaticInfo.isCapabilitySupported(CameraCharacteristics.
REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR)) {
// OK
+ } else if (template == CameraDevice.TEMPLATE_ZERO_SHUTTER_LAG &&
+ !mStaticInfo.isCapabilitySupported(CameraCharacteristics.
+ REQUEST_AVAILABLE_CAPABILITIES_ZSL)) {
+ // OK.
} else if (sLegacySkipTemplates.contains(template) &&
mStaticInfo.isHardwareLevelLegacy()) {
// OK
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/CameraTestUtils.java b/tests/tests/hardware/src/android/hardware/camera2/cts/CameraTestUtils.java
index 18721b8..8beab50 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/CameraTestUtils.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/CameraTestUtils.java
@@ -40,7 +40,9 @@
import android.media.Image.Plane;
import android.os.Handler;
import android.util.Log;
+import android.view.Display;
import android.view.Surface;
+import android.view.WindowManager;
import com.android.ex.camera2.blocking.BlockingCameraManager;
import com.android.ex.camera2.blocking.BlockingCameraManager.BlockingOpenException;
@@ -1013,4 +1015,22 @@
}
return resultRegions;
}
+
+ public static Size getPreviewSizeBound(WindowManager windowManager, Size bound) {
+ Display display = windowManager.getDefaultDisplay();
+
+ int width = display.getWidth();
+ int height = display.getHeight();
+
+ if (height > width) {
+ height = width;
+ width = display.getHeight();
+ }
+
+ if (bound.getWidth() <= width &&
+ bound.getHeight() <= height)
+ return bound;
+ else
+ return new Size(width, height);
+ }
}
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/CaptureRequestTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/CaptureRequestTest.java
index bb5527f..6e46955 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/CaptureRequestTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/CaptureRequestTest.java
@@ -147,7 +147,8 @@
changeExposure(requestBuilder, DEFAULT_EXP_TIME_NS, DEFAULT_SENSITIVITY);
Size previewSz =
- getMaxPreviewSize(mCamera.getId(), mCameraManager, PREVIEW_SIZE_BOUND);
+ getMaxPreviewSize(mCamera.getId(), mCameraManager,
+ getPreviewSizeBound(mWindowManager, PREVIEW_SIZE_BOUND));
startPreview(requestBuilder, previewSz, listener);
waitForSettingsApplied(listener, NUM_FRAMES_WAITED_FOR_UNKNOWN_LATENCY);
@@ -202,7 +203,8 @@
STATISTICS_LENS_SHADING_MAP_MODE_ON);
Size previewSz =
- getMaxPreviewSize(mCamera.getId(), mCameraManager, PREVIEW_SIZE_BOUND);
+ getMaxPreviewSize(mCamera.getId(), mCameraManager,
+ getPreviewSizeBound(mWindowManager, PREVIEW_SIZE_BOUND));
listener = new SimpleCaptureCallback();
startPreview(requestBuilder, previewSz, listener);
@@ -256,7 +258,8 @@
int[] modes = mStaticInfo.getAeAvailableAntiBandingModesChecked();
Size previewSz =
- getMaxPreviewSize(mCamera.getId(), mCameraManager, PREVIEW_SIZE_BOUND);
+ getMaxPreviewSize(mCamera.getId(), mCameraManager,
+ getPreviewSizeBound(mWindowManager, PREVIEW_SIZE_BOUND));
for (int mode : modes) {
antiBandingTestByMode(previewSz, mode);
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/PerformanceTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/PerformanceTest.java
index 8e57c17..8615df2 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/PerformanceTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/PerformanceTest.java
@@ -335,7 +335,9 @@
*/
private void initializeImageReader(String cameraId, int format) throws Exception {
mOrderedPreviewSizes = CameraTestUtils.getSupportedPreviewSizes(
- cameraId, mCameraManager, CameraTestUtils.PREVIEW_SIZE_BOUND);
+ cameraId, mCameraManager,
+ CameraTestUtils.getPreviewSizeBound(mWindowManager,
+ CameraTestUtils.PREVIEW_SIZE_BOUND));
Size maxPreviewSize = mOrderedPreviewSizes.get(0);
createImageReader(maxPreviewSize, format, NUM_MAX_IMAGES, /*listener*/null);
updatePreviewSurface(maxPreviewSize);
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/RecordingTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/RecordingTest.java
index 3440ad6..d7ab0ed 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/RecordingTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/RecordingTest.java
@@ -559,6 +559,10 @@
throws Exception {
final int NUM_SINGLE_SHOT_TEST = 5;
final int FRAMEDROP_TOLERANCE = 8;
+ final int FRAME_SIZE_15M = 15000000;
+ final float FRAME_DROP_TOLERENCE_FACTOR = 1.5f;
+ int kFrameDrop_Tolerence = FRAMEDROP_TOLERANCE;
+
for (int profileId : mCamcorderProfileList) {
int cameraId = Integer.valueOf(mCamera.getId());
if (!CamcorderProfile.hasProfile(cameraId, profileId) ||
@@ -594,6 +598,8 @@
videoSnapshotSz = candidateSize;
}
}
+ if (videoSnapshotSz.getWidth() * videoSnapshotSz.getHeight() > FRAME_SIZE_15M)
+ kFrameDrop_Tolerence = (int)(FRAMEDROP_TOLERANCE * FRAME_DROP_TOLERENCE_FACTOR);
/**
* Only test full res snapshot when below conditions are all true.
@@ -701,8 +707,8 @@
"Camera %d Video size %s: Number of dropped frames %d must not"
+ " be larger than %d",
cameraId, videoSz.toString(), totalDroppedFrames,
- FRAMEDROP_TOLERANCE),
- FRAMEDROP_TOLERANCE, totalDroppedFrames);
+ kFrameDrop_Tolerence),
+ kFrameDrop_Tolerence, totalDroppedFrames);
}
closeImageReader();
}
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/RobustnessTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/RobustnessTest.java
index a6a7d10..c3144e6 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/RobustnessTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/RobustnessTest.java
@@ -19,11 +19,13 @@
import static android.hardware.camera2.cts.CameraTestUtils.*;
import static android.hardware.camera2.cts.RobustnessTest.MaxOutputSizes.*;
+import android.content.Context;
import android.graphics.ImageFormat;
import android.graphics.SurfaceTexture;
import android.hardware.camera2.CameraCaptureSession;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraDevice;
+import android.hardware.camera2.CameraManager;
import android.hardware.camera2.CaptureRequest;
import android.hardware.camera2.TotalCaptureResult;
import android.hardware.camera2.CaptureFailure;
@@ -36,7 +38,9 @@
import android.media.ImageReader;
import android.util.Log;
import android.util.Size;
+import android.view.Display;
import android.view.Surface;
+import android.view.WindowManager;
import java.util.Arrays;
import java.util.ArrayList;
@@ -179,7 +183,7 @@
CameraCharacteristics cc = mCameraManager.getCameraCharacteristics(id);
- MaxOutputSizes maxSizes = new MaxOutputSizes(cc, id);
+ MaxOutputSizes maxSizes = new MaxOutputSizes(cc, id, getContext());
final StaticMetadata staticInfo = new StaticMetadata(cc);
@@ -243,7 +247,7 @@
static final int VGA = 3;
static final int RESOLUTION_COUNT = 4;
- public MaxOutputSizes(CameraCharacteristics cc, String cameraId) {
+ public MaxOutputSizes(CameraCharacteristics cc, String cameraId, Context context) {
StreamConfigurationMap configs =
cc.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
Size[] privSizes = configs.getOutputSizes(SurfaceTexture.class);
@@ -251,11 +255,13 @@
Size[] jpegSizes = configs.getOutputSizes(ImageFormat.JPEG);
Size[] rawSizes = configs.getOutputSizes(ImageFormat.RAW_SENSOR);
+ Size maxPreviewSize = getMaxPreviewSize(context, cameraId);
+
maxRawSize = (rawSizes != null) ? CameraTestUtils.getMaxSize(rawSizes) : null;
- maxPrivSizes[PREVIEW] = getMaxSize(privSizes, PREVIEW_SIZE_BOUND);
- maxYuvSizes[PREVIEW] = getMaxSize(yuvSizes, PREVIEW_SIZE_BOUND);
- maxJpegSizes[PREVIEW] = getMaxSize(jpegSizes, PREVIEW_SIZE_BOUND);
+ maxPrivSizes[PREVIEW] = getMaxSize(privSizes, maxPreviewSize);
+ maxYuvSizes[PREVIEW] = getMaxSize(yuvSizes, maxPreviewSize);
+ maxJpegSizes[PREVIEW] = getMaxSize(jpegSizes, maxPreviewSize);
maxPrivSizes[RECORD] = getMaxRecordingSize(cameraId);
maxYuvSizes[RECORD] = getMaxRecordingSize(cameraId);
@@ -514,4 +520,35 @@
return sz;
}
+ private static Size getMaxPreviewSize(Context context, String cameraId) {
+ try {
+ WindowManager windowManager =
+ (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
+ Display display = windowManager.getDefaultDisplay();
+
+ int width = display.getWidth();
+ int height = display.getHeight();
+
+ if (height > width) {
+ height = width;
+ width = display.getHeight();
+ }
+
+ CameraManager camMgr =
+ (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
+ List<Size> orderedPreviewSizes = CameraTestUtils.getSupportedPreviewSizes(
+ cameraId, camMgr, PREVIEW_SIZE_BOUND);
+
+ if (orderedPreviewSizes != null) {
+ for (Size size : orderedPreviewSizes) {
+ if (width >= size.getWidth() &&
+ height >= size.getHeight())
+ return size;
+ }
+ }
+ } catch (Exception e) {
+ Log.e(TAG, "getMaxPreviewSize Failed. "+e.toString());
+ }
+ return PREVIEW_SIZE_BOUND;
+ }
}
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/testcases/Camera2AndroidTestCase.java b/tests/tests/hardware/src/android/hardware/camera2/cts/testcases/Camera2AndroidTestCase.java
index 5fc6321..ff69581 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/testcases/Camera2AndroidTestCase.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/testcases/Camera2AndroidTestCase.java
@@ -38,6 +38,7 @@
import android.test.AndroidTestCase;
import android.util.Log;
import android.view.Surface;
+import android.view.WindowManager;
import com.android.ex.camera2.blocking.BlockingSessionCallback;
import com.android.ex.camera2.blocking.BlockingStateCallback;
@@ -70,11 +71,14 @@
protected List<Size> mOrderedVideoSizes; // In descending order.
protected List<Size> mOrderedStillSizes; // In descending order.
+ protected WindowManager mWindowManager;
+
@Override
public void setContext(Context context) {
super.setContext(context);
mCameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
assertNotNull("Can't connect to camera manager!", mCameraManager);
+ mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
}
/**
@@ -184,7 +188,8 @@
mStaticInfo = new StaticMetadata(mCameraManager.getCameraCharacteristics(cameraId),
CheckLevel.ASSERT, /*collector*/null);
mOrderedPreviewSizes = getSupportedPreviewSizes(
- cameraId, mCameraManager, PREVIEW_SIZE_BOUND);
+ cameraId, mCameraManager,
+ getPreviewSizeBound(mWindowManager, PREVIEW_SIZE_BOUND));
mOrderedVideoSizes = getSupportedVideoSizes(cameraId, mCameraManager, PREVIEW_SIZE_BOUND);
mOrderedStillSizes = getSupportedStillSizes(cameraId, mCameraManager, null);
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/testcases/Camera2MultiViewTestCase.java b/tests/tests/hardware/src/android/hardware/camera2/cts/testcases/Camera2MultiViewTestCase.java
index 03e9647..5d832d6 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/testcases/Camera2MultiViewTestCase.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/testcases/Camera2MultiViewTestCase.java
@@ -43,6 +43,7 @@
import android.util.Size;
import android.view.Surface;
import android.view.TextureView;
+import android.view.WindowManager;
import com.android.ex.camera2.blocking.BlockingCameraManager;
import com.android.ex.camera2.blocking.BlockingSessionCallback;
@@ -76,6 +77,8 @@
private CameraHolder[] mCameraHolders;
private HashMap<String, Integer> mCameraIdMap;
+ protected WindowManager mWindowManager;
+
public Camera2MultiViewTestCase() {
super(Camera2MultiViewCtsActivity.class);
}
@@ -104,6 +107,7 @@
mCameraHolders[i] = new CameraHolder(mCameraIds[i]);
mCameraIdMap.put(mCameraIds[i], i);
}
+ mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
}
@Override
@@ -359,7 +363,8 @@
mStaticInfo = new StaticMetadata(mCameraManager.getCameraCharacteristics(mCameraId),
CheckLevel.ASSERT, /*collector*/null);
mOrderedPreviewSizes = getSupportedPreviewSizes(
- mCameraId, mCameraManager, PREVIEW_SIZE_BOUND);
+ mCameraId, mCameraManager,
+ getPreviewSizeBound(mWindowManager, PREVIEW_SIZE_BOUND));
assertNotNull(String.format("Failed to open camera device ID: %s", mCameraId), mCamera);
}
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/testcases/Camera2SurfaceViewTestCase.java b/tests/tests/hardware/src/android/hardware/camera2/cts/testcases/Camera2SurfaceViewTestCase.java
index 6c8557d..baf8ad0 100755
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/testcases/Camera2SurfaceViewTestCase.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/testcases/Camera2SurfaceViewTestCase.java
@@ -29,6 +29,7 @@
import android.util.Log;
import android.view.Surface;
import android.view.SurfaceHolder;
+import android.view.WindowManager;
import android.content.Context;
import android.graphics.ImageFormat;
import android.hardware.camera2.CameraAccessException;
@@ -103,6 +104,7 @@
protected List<Size> mOrderedStillSizes; // In descending order.
protected HashMap<Size, Long> mMinPreviewFrameDurationMap;
+ protected WindowManager mWindowManager;
public Camera2SurfaceViewTestCase() {
super(Camera2SurfaceViewCtsActivity.class);
@@ -132,6 +134,8 @@
mHandler = new Handler(mHandlerThread.getLooper());
mCameraListener = new BlockingStateCallback();
mCollector = new CameraErrorCollector();
+
+ mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
}
@Override
@@ -562,7 +566,8 @@
mCollector.setCameraId(cameraId);
mStaticInfo = new StaticMetadata(mCameraManager.getCameraCharacteristics(cameraId),
CheckLevel.ASSERT, /*collector*/null);
- mOrderedPreviewSizes = getSupportedPreviewSizes(cameraId, mCameraManager, PREVIEW_SIZE_BOUND);
+ mOrderedPreviewSizes = getSupportedPreviewSizes(cameraId, mCameraManager,
+ getPreviewSizeBound(mWindowManager, PREVIEW_SIZE_BOUND));
mOrderedVideoSizes = getSupportedVideoSizes(cameraId, mCameraManager, PREVIEW_SIZE_BOUND);
mOrderedStillSizes = getSupportedStillSizes(cameraId, mCameraManager, null);
// Use ImageFormat.YUV_420_888 for now. TODO: need figure out what's format for preview
diff --git a/tests/tests/hardware/src/android/hardware/cts/CameraTest.java b/tests/tests/hardware/src/android/hardware/cts/CameraTest.java
index 019bd21..ec9caaf 100644
--- a/tests/tests/hardware/src/android/hardware/cts/CameraTest.java
+++ b/tests/tests/hardware/src/android/hardware/cts/CameraTest.java
@@ -37,6 +37,7 @@
import android.os.ConditionVariable;
import android.os.Environment;
import android.os.Looper;
+import android.os.SystemClock;
import android.test.ActivityInstrumentationTestCase2;
import android.test.MoreAsserts;
import android.test.UiThreadTest;
@@ -1975,7 +1976,7 @@
// This method tests if the actual fps is between minimum and maximum.
// It also tests if the frame interval is too long.
public void onPreviewFrame(byte[] data, android.hardware.Camera camera) {
- long arrivalTime = System.currentTimeMillis();
+ long arrivalTime = SystemClock.elapsedRealtime();
camera.addCallbackBuffer(data);
if (firstFrameArrivalTime == 0) firstFrameArrivalTime = arrivalTime;
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/EventOrderingVerification.java b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/EventOrderingVerification.java
index 6598725..31974c6 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/EventOrderingVerification.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/sensorverification/EventOrderingVerification.java
@@ -117,9 +117,9 @@
if (mPreviousEvent == null) {
mMaxTimestamp = event.timestamp;
} else {
- if (event.timestamp < mMaxTimestamp) {
+ if (event.timestamp <= mMaxTimestamp) {
mOutOfOrderEvents.add(new IndexedEventPair(mIndex, event, mPreviousEvent));
- } else if (event.timestamp > mMaxTimestamp) {
+ } else {
mMaxTimestamp = event.timestamp;
}
}
diff --git a/tests/tests/jni/libjnitest/Android.mk b/tests/tests/jni/libjnitest/Android.mk
index d7d1bad..396e161 100644
--- a/tests/tests/jni/libjnitest/Android.mk
+++ b/tests/tests/jni/libjnitest/Android.mk
@@ -29,6 +29,7 @@
android_jni_cts_InstanceNonce.c \
android_jni_cts_JniCTest.c \
android_jni_cts_JniCppTest.cpp \
+ android_jni_cts_JniStaticTest.cpp \
android_jni_cts_StaticNonce.c \
helper.c \
register.c
diff --git a/tests/tests/jni/libjnitest/android_jni_cts_JniStaticTest.cpp b/tests/tests/jni/libjnitest/android_jni_cts_JniStaticTest.cpp
new file mode 100644
index 0000000..5e8bea0
--- /dev/null
+++ b/tests/tests/jni/libjnitest/android_jni_cts_JniStaticTest.cpp
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2015 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.
+ */
+
+/*
+ * Native implementation for the JniStaticTest parts.
+ */
+
+#include <jni.h>
+#include <JNIHelp.h>
+
+extern "C" JNIEXPORT jint JNICALL Java_android_jni_cts_ClassLoaderHelper_nativeGetHashCode(
+ JNIEnv* env,
+ jobject obj __attribute__((unused)),
+ jobject appLoader,
+ jclass appLoaderClass) {
+ jmethodID midFindClass = env->GetMethodID(appLoaderClass, "findClass",
+ "(Ljava/lang/String;)Ljava/lang/Class;");
+ jstring coreClsName = env->NewStringUTF("android.jni.cts.ClassLoaderStaticNonce");
+ jobject coreClass = env->CallObjectMethod(appLoader, midFindClass, coreClsName);
+ jmethodID midHashCode = env->GetMethodID((jclass)coreClass, "hashCode", "()I");
+ jint hash = env->CallIntMethod(coreClass, midHashCode);
+
+ return hash;
+}
diff --git a/tests/tests/jni/src/android/jni/cts/ClassLoaderHelper.java b/tests/tests/jni/src/android/jni/cts/ClassLoaderHelper.java
new file mode 100644
index 0000000..c4fe0f0
--- /dev/null
+++ b/tests/tests/jni/src/android/jni/cts/ClassLoaderHelper.java
@@ -0,0 +1,49 @@
+/*
+ * 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.jni.cts;
+
+class ClassLoaderHelper {
+
+ // Note: To not hava a dependency on other classes, assume that if we do initialize then
+ // it's OK to load the library.
+ static {
+ System.loadLibrary("jnitest");
+ }
+
+ public static boolean run() {
+ ClassLoaderHelper clh = new ClassLoaderHelper();
+
+ int firstHashCode = clh.getHashCodeDirect();
+
+ Runtime.getRuntime().gc();
+
+ int secondHashCode = clh.getHashCodeNative();
+
+ return (firstHashCode == secondHashCode);
+ }
+
+ // Simple helpers to avoid keeping references alive because of dex registers.
+ private int getHashCodeDirect() {
+ return ClassLoaderStaticNonce.class.hashCode();
+ }
+ private int getHashCodeNative() {
+ ClassLoader loader = getClass().getClassLoader();
+ return nativeGetHashCode(loader, loader.getClass());
+ }
+
+ private native int nativeGetHashCode(ClassLoader loader, Class<?> classLoaderClass);
+}
\ No newline at end of file
diff --git a/tests/tests/jni/src/android/jni/cts/ClassLoaderStaticNonce.java b/tests/tests/jni/src/android/jni/cts/ClassLoaderStaticNonce.java
new file mode 100644
index 0000000..d425c77
--- /dev/null
+++ b/tests/tests/jni/src/android/jni/cts/ClassLoaderStaticNonce.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2009 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.jni.cts;
+
+import android.util.Log;
+
+/**
+ * Class to help with class-loader check..
+ */
+public class ClassLoaderStaticNonce {
+
+ static Object ctx;
+
+ // Have a static initializer block.
+ static {
+ ctx = new Object();
+ log("Initializing ClassLoaderStaticNonce");
+ }
+
+ private final static A a = new A();
+
+ public static void log(String s) {
+ Log.i("ClassLoaderStaticNone", s);
+ }
+
+ public static class A {
+ // Have a finalizer. This will make the outer class not finalizable when we allocate for
+ // a static field.
+ public void finalize() throws Throwable {
+ super.finalize();
+
+ // Do something so that the finalizer can't be recognized as empty.
+ toNull = null;
+ }
+
+ private Object toNull = new Object();
+ }
+
+
+ public static void setCtx(Object in) {
+ ctx = in;
+ }
+
+ public static Object getCtx() {
+ return ctx;
+ }
+}
diff --git a/tests/tests/jni/src/android/jni/cts/JniStaticTest.java b/tests/tests/jni/src/android/jni/cts/JniStaticTest.java
index 3036c71..d4b51b9 100644
--- a/tests/tests/jni/src/android/jni/cts/JniStaticTest.java
+++ b/tests/tests/jni/src/android/jni/cts/JniStaticTest.java
@@ -24,6 +24,20 @@
*/
public class JniStaticTest extends JniTestCase {
+ static {
+ if (!JniTestCase.isCpuAbiNone()) {
+ System.loadLibrary("jnitest");
+ }
+ }
+
+ /**
+ * Test that accessing classes true JNI works as expected. b/19382130
+ */
+ public void test_classload() {
+ // Use an independent class to do this.
+ assertEquals(true, ClassLoaderHelper.run());
+ }
+
/**
* Test a simple no-op and void-returning method call.
*/
diff --git a/tests/tests/location/src/android/location/cts/LocationManagerTest.java b/tests/tests/location/src/android/location/cts/LocationManagerTest.java
index a985aee..118b8f9 100644
--- a/tests/tests/location/src/android/location/cts/LocationManagerTest.java
+++ b/tests/tests/location/src/android/location/cts/LocationManagerTest.java
@@ -49,7 +49,7 @@
* android.permission.ACCESS_LOCATION_EXTRA_COMMANDS to send extra commands to GPS provider
*/
public class LocationManagerTest extends InstrumentationTestCase {
- private static final long TEST_TIME_OUT = 5000;
+ private static final long TEST_TIME_OUT = 10000;
private static final String TEST_MOCK_PROVIDER_NAME = "test_provider";
diff --git a/tests/tests/media/src/android/media/cts/AdaptivePlaybackTest.java b/tests/tests/media/src/android/media/cts/AdaptivePlaybackTest.java
index 854c6f7..5afd131 100644
--- a/tests/tests/media/src/android/media/cts/AdaptivePlaybackTest.java
+++ b/tests/tests/media/src/android/media/cts/AdaptivePlaybackTest.java
@@ -447,7 +447,8 @@
this, c, mediaIx) {
public void run() {
try {
- mDecoder.configureAndStart(stepFormat(), stepSurface());
+ //mDecoder.configureAndStart(stepFormat(), stepSurface());
+ if(mDecoder.configureAndStart(stepFormat(), stepSurface())){
int decodedFrames = -mDecoder.queueInputBufferRange(
stepMedia(),
0 /* startFrame */,
@@ -461,6 +462,7 @@
warn(mDecoder.getWarnings());
mDecoder.clearWarnings();
mDecoder.flush();
+ }
} finally {
mDecoder.stop();
}
@@ -856,10 +858,16 @@
mWarnings.clear();
}
- public void configureAndStart(MediaFormat format, TestSurface surface) {
+ public boolean configureAndStart(MediaFormat format, TestSurface surface) {
mSurface = surface;
Log.i(TAG, "configure(" + format + ", " + mSurface.getSurface() + ")");
- mCodec.configure(format, mSurface.getSurface(), null /* crypto */, 0 /* flags */);
+ try{
+ mCodec.configure(format, mSurface.getSurface(), null /* crypto */, 0 /* flags */);
+ }
+ catch (Exception e){
+ Log.i(TAG, "Unsupported Codec");
+ return false;
+ }
Log.i(TAG, "start");
mCodec.start();
mInputBuffers = mCodec.getInputBuffers();
@@ -869,6 +877,7 @@
mOutputBuffers.length + "output[" +
(mOutputBuffers[0] == null ? null : mOutputBuffers[0].capacity()) + "]");
mQueuedEos = false;
+ return true;
}
public void stop() {
diff --git a/tests/tests/media/src/android/media/cts/EncodeVirtualDisplayTest.java b/tests/tests/media/src/android/media/cts/EncodeVirtualDisplayTest.java
index 08276fa..3346d40 100755
--- a/tests/tests/media/src/android/media/cts/EncodeVirtualDisplayTest.java
+++ b/tests/tests/media/src/android/media/cts/EncodeVirtualDisplayTest.java
@@ -507,7 +507,7 @@
* Determines if two color values are approximately equal.
*/
private static boolean approxEquals(int expected, int actual) {
- final int MAX_DELTA = 4;
+ final int MAX_DELTA = 7;
return Math.abs(expected - actual) <= MAX_DELTA;
}
diff --git a/tests/tests/media/src/android/media/cts/EncodeVirtualDisplayWithCompositionTest.java b/tests/tests/media/src/android/media/cts/EncodeVirtualDisplayWithCompositionTest.java
index 4a42791..dd5b238 100644
--- a/tests/tests/media/src/android/media/cts/EncodeVirtualDisplayWithCompositionTest.java
+++ b/tests/tests/media/src/android/media/cts/EncodeVirtualDisplayWithCompositionTest.java
@@ -658,6 +658,7 @@
} catch (InterruptedException e) {
// don't care
}
+ cleanupGl();
mCompositionThread = null;
mSurface = null;
mStartCompletionSemaphore = null;
@@ -967,6 +968,7 @@
public void cleanup() {
mNumTextureUpdated.set(0);
+ mVerticesData.clear();
if (mTextureId != 0) {
int[] textures = new int[] {
mTextureId
diff --git a/tests/tests/media/src/android/media/cts/MediaRecorderTest.java b/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
index 78b5cfd..216e21b 100644
--- a/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
@@ -159,13 +159,29 @@
}
public void testRecorderCamera() throws Exception {
+ int width;
+ int height;
+ Camera camera = null;
if (!hasCamera()) {
return;
}
+ // Try to get camera first supported resolution.
+ // If we fail for any reason, set the video size to default value.
+ try {
+ camera = Camera.open();
+ width = camera.getParameters().getSupportedPreviewSizes().get(0).width;
+ height = camera.getParameters().getSupportedPreviewSizes().get(0).height;
+ } catch (Exception e) {
+ width = VIDEO_WIDTH;
+ height = VIDEO_HEIGHT;
+ }
+ if (camera != null) {
+ camera.release();
+ }
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);
- mMediaRecorder.setVideoSize(VIDEO_WIDTH, VIDEO_HEIGHT);
+ mMediaRecorder.setVideoSize(width, height);
mMediaRecorder.setVideoEncodingBitRate(VIDEO_BIT_RATE_IN_BPS);
mMediaRecorder.setPreviewDisplay(mActivity.getSurfaceHolder().getSurface());
mMediaRecorder.prepare();
diff --git a/tests/tests/media/src/android/media/cts/MediaSessionTest.java b/tests/tests/media/src/android/media/cts/MediaSessionTest.java
index 2e77d50..f4a30e8 100644
--- a/tests/tests/media/src/android/media/cts/MediaSessionTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaSessionTest.java
@@ -26,22 +26,47 @@
import android.media.VolumeProvider;
import android.media.session.MediaController;
import android.media.session.MediaSession;
-import android.media.session.MediaSessionManager;
import android.media.session.PlaybackState;
import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
import android.os.Parcel;
import android.test.AndroidTestCase;
import java.util.ArrayList;
+import java.util.List;
import java.util.Set;
public class MediaSessionTest extends AndroidTestCase {
+ // The maximum time to wait for an operation.
+ private static final long TIME_OUT_MS = 3000L;
+ private static final int MAX_AUDIO_INFO_CHANGED_CALLBACK_COUNT = 10;
+ private static final String TEST_SESSION_TAG = "test-session-tag";
+ private static final String TEST_KEY = "test-key";
+ private static final String TEST_VALUE = "test-val";
+ private static final int TEST_CURRENT_VOLUME = 10;
+ private static final int TEST_MAX_VOLUME = 11;
+ private static final long TEST_QUEUE_ID = 12L;
+ private static final long TEST_ACTION = 55L;
+
private AudioManager mAudioManager;
+ private Handler mHandler = new Handler(Looper.getMainLooper());
+ private Object mWaitLock = new Object();
+ private MediaControllerCallback mCallback = new MediaControllerCallback();
+ private MediaSession mSession;
@Override
protected void setUp() throws Exception {
super.setUp();
mAudioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
+ mSession = new MediaSession(getContext(), TEST_SESSION_TAG);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ // It is OK to call release() twice.
+ mSession.release();
+ super.tearDown();
}
/**
@@ -49,24 +74,20 @@
* initialized correctly.
*/
public void testCreateSession() throws Exception {
- String tag = "test session";
- MediaSession session = new MediaSession(getContext(), tag);
- assertNotNull(session.getSessionToken());
- assertFalse("New session should not be active", session.isActive());
+ assertNotNull(mSession.getSessionToken());
+ assertFalse("New session should not be active", mSession.isActive());
// Verify by getting the controller and checking all its fields
- MediaController controller = session.getController();
+ MediaController controller = mSession.getController();
assertNotNull(controller);
- verifyNewSession(controller, tag);
+ verifyNewSession(controller, TEST_SESSION_TAG);
}
/**
* Tests MediaSession.Token created in the constructor of MediaSession.
*/
public void testSessionToken() throws Exception {
- String tag = "test session";
- MediaSession session = new MediaSession(getContext(), tag);
- MediaSession.Token sessionToken = session.getSessionToken();
+ MediaSession.Token sessionToken = mSession.getSessionToken();
assertNotNull(sessionToken);
assertEquals(0, sessionToken.describeContents());
@@ -85,96 +106,179 @@
* controller.
*/
public void testConfigureSession() throws Exception {
- String tag = "test session";
- String key = "test-key";
- String val = "test-val";
- MediaSession session = new MediaSession(getContext(), tag);
- MediaController controller = session.getController();
+ MediaController controller = mSession.getController();
+ controller.registerCallback(mCallback, mHandler);
- // test setExtras
- Bundle extras = new Bundle();
- extras.putString(key, val);
- session.setExtras(extras);
- Bundle extrasOut = controller.getExtras();
- assertNotNull(extrasOut);
- assertEquals(val, extrasOut.get(key));
+ synchronized (mWaitLock) {
+ // test setExtras
+ mCallback.resetLocked();
+ final Bundle extras = new Bundle();
+ extras.putString(TEST_KEY, TEST_VALUE);
+ mSession.setExtras(extras);
+ mWaitLock.wait(TIME_OUT_MS);
+ assertTrue(mCallback.mOnExtraChangedCalled);
- // test setFlags
- session.setFlags(5);
- assertEquals(5, controller.getFlags());
+ Bundle extrasOut = mCallback.mExtras;
+ assertNotNull(extrasOut);
+ assertEquals(TEST_VALUE, extrasOut.get(TEST_KEY));
- // test setMetadata
- MediaMetadata metadata = new MediaMetadata.Builder().putString(key, val).build();
- session.setMetadata(metadata);
- MediaMetadata metadataOut = controller.getMetadata();
- assertNotNull(metadataOut);
- assertEquals(val, metadataOut.getString(key));
+ extrasOut = controller.getExtras();
+ assertNotNull(extrasOut);
+ assertEquals(TEST_VALUE, extrasOut.get(TEST_KEY));
- // test setPlaybackState
- PlaybackState state = new PlaybackState.Builder().setActions(55).build();
- session.setPlaybackState(state);
- PlaybackState stateOut = controller.getPlaybackState();
- assertNotNull(stateOut);
- assertEquals(55L, stateOut.getActions());
+ // test setFlags
+ mSession.setFlags(5);
+ assertEquals(5, controller.getFlags());
- // test setPlaybackToRemote, do this before testing setPlaybackToLocal
- // to ensure it switches correctly.
- try {
- session.setPlaybackToRemote(null);
- fail("Expected IAE for setPlaybackToRemote(null)");
- } catch (IllegalArgumentException e) {
- // expected
+ // test setMetadata
+ mCallback.resetLocked();
+ MediaMetadata metadata =
+ new MediaMetadata.Builder().putString(TEST_KEY, TEST_VALUE).build();
+ mSession.setMetadata(metadata);
+ mWaitLock.wait(TIME_OUT_MS);
+ assertTrue(mCallback.mOnMetadataChangedCalled);
+
+ MediaMetadata metadataOut = mCallback.mMediaMetadata;
+ assertNotNull(metadataOut);
+ assertEquals(TEST_VALUE, metadataOut.getString(TEST_KEY));
+
+ metadataOut = controller.getMetadata();
+ assertNotNull(metadataOut);
+ assertEquals(TEST_VALUE, metadataOut.getString(TEST_KEY));
+
+ // test setPlaybackState
+ mCallback.resetLocked();
+ PlaybackState state = new PlaybackState.Builder().setActions(TEST_ACTION).build();
+ mSession.setPlaybackState(state);
+ mWaitLock.wait(TIME_OUT_MS);
+ assertTrue(mCallback.mOnPlaybackStateChangedCalled);
+
+ PlaybackState stateOut = mCallback.mPlaybackState;
+ assertNotNull(stateOut);
+ assertEquals(TEST_ACTION, stateOut.getActions());
+
+ stateOut = controller.getPlaybackState();
+ assertNotNull(stateOut);
+ assertEquals(TEST_ACTION, stateOut.getActions());
+
+ // test setQueue and setQueueTitle
+ mCallback.resetLocked();
+ List<MediaSession.QueueItem> queue = new ArrayList<MediaSession.QueueItem>();
+ MediaSession.QueueItem item = new MediaSession.QueueItem(new MediaDescription.Builder()
+ .setMediaId(TEST_VALUE).setTitle("title").build(), TEST_QUEUE_ID);
+ queue.add(item);
+ mSession.setQueue(queue);
+ mWaitLock.wait(TIME_OUT_MS);
+ assertTrue(mCallback.mOnQueueChangedCalled);
+
+ mSession.setQueueTitle(TEST_VALUE);
+ mWaitLock.wait(TIME_OUT_MS);
+ assertTrue(mCallback.mOnQueueTitleChangedCalled);
+
+ assertEquals(TEST_VALUE, mCallback.mTitle);
+ assertEquals(queue.size(), mCallback.mQueue.size());
+ assertEquals(TEST_QUEUE_ID, mCallback.mQueue.get(0).getQueueId());
+ assertEquals(TEST_VALUE, mCallback.mQueue.get(0).getDescription().getMediaId());
+
+ assertEquals(TEST_VALUE, controller.getQueueTitle());
+ assertEquals(queue.size(), controller.getQueue().size());
+ assertEquals(TEST_QUEUE_ID, controller.getQueue().get(0).getQueueId());
+ assertEquals(TEST_VALUE, controller.getQueue().get(0).getDescription().getMediaId());
+
+ mCallback.resetLocked();
+ mSession.setQueue(null);
+ mWaitLock.wait(TIME_OUT_MS);
+ assertTrue(mCallback.mOnQueueChangedCalled);
+
+ mSession.setQueueTitle(null);
+ mWaitLock.wait(TIME_OUT_MS);
+ assertTrue(mCallback.mOnQueueTitleChangedCalled);
+
+ assertNull(mCallback.mTitle);
+ assertNull(mCallback.mQueue);
+ assertNull(controller.getQueueTitle());
+ assertNull(controller.getQueue());
+
+ // test setSessionActivity
+ Intent intent = new Intent("cts.MEDIA_SESSION_ACTION");
+ PendingIntent pi = PendingIntent.getActivity(getContext(), 555, intent, 0);
+ mSession.setSessionActivity(pi);
+ assertEquals(pi, controller.getSessionActivity());
+
+ // test setActivity
+ mSession.setActive(true);
+ assertTrue(mSession.isActive());
+
+ // test release
+ mCallback.resetLocked();
+ mSession.release();
+ mWaitLock.wait(TIME_OUT_MS);
+ assertTrue(mCallback.mOnSessionDestroyedCalled);
}
- VolumeProvider vp = new VolumeProvider(VolumeProvider.VOLUME_CONTROL_FIXED, 11, 11) {};
- session.setPlaybackToRemote(vp);
- MediaController.PlaybackInfo info = controller.getPlaybackInfo();
- assertNotNull(info);
- assertEquals(MediaController.PlaybackInfo.PLAYBACK_TYPE_REMOTE, info.getPlaybackType());
- assertEquals(11, info.getMaxVolume());
- assertEquals(11, info.getCurrentVolume());
- assertEquals(VolumeProvider.VOLUME_CONTROL_FIXED, info.getVolumeControl());
-
- // test setPlaybackToLocal
- AudioAttributes attrs = new AudioAttributes.Builder().addTag(val).build();
- session.setPlaybackToLocal(attrs);
- info = controller.getPlaybackInfo();
- assertNotNull(info);
- assertEquals(MediaController.PlaybackInfo.PLAYBACK_TYPE_LOCAL, info.getPlaybackType());
- Set<String> tags = info.getAudioAttributes().getTags();
- assertNotNull(tags);
- assertTrue(tags.contains(val));
-
- // test setQueue and setQueueTitle
- ArrayList<MediaSession.QueueItem> queue = new ArrayList<MediaSession.QueueItem>();
- MediaSession.QueueItem item = new MediaSession.QueueItem(new MediaDescription.Builder()
- .setMediaId(val).setTitle("title").build(), 11);
- queue.add(item);
- session.setQueue(queue);
- session.setQueueTitle(val);
-
- assertEquals(val, controller.getQueueTitle());
- assertEquals(1, controller.getQueue().size());
- assertEquals(11, controller.getQueue().get(0).getQueueId());
- assertEquals(val, controller.getQueue().get(0).getDescription().getMediaId());
-
- session.setQueue(null);
- session.setQueueTitle(null);
-
- assertNull(controller.getQueueTitle());
- assertNull(controller.getQueue());
-
- // test setSessionActivity
- Intent intent = new Intent("cts.MEDIA_SESSION_ACTION");
- PendingIntent pi = PendingIntent.getActivity(getContext(), 555, intent, 0);
- session.setSessionActivity(pi);
- assertEquals(pi, controller.getSessionActivity());
-
- // test setActivity
- session.setActive(true);
- assertTrue(session.isActive());
}
/**
+ * Tests for setPlaybackToLocal and setPlaybackToRemote.
+ */
+ public void testPlaybackToLocalAndRemote() throws Exception {
+ MediaController controller = mSession.getController();
+ controller.registerCallback(mCallback, mHandler);
+
+ synchronized (mWaitLock) {
+ // test setPlaybackToRemote, do this before testing setPlaybackToLocal
+ // to ensure it switches correctly.
+ mCallback.resetLocked();
+ try {
+ mSession.setPlaybackToRemote(null);
+ fail("Expected IAE for setPlaybackToRemote(null)");
+ } catch (IllegalArgumentException e) {
+ // expected
+ }
+ VolumeProvider vp = new VolumeProvider(VolumeProvider.VOLUME_CONTROL_FIXED,
+ TEST_MAX_VOLUME, TEST_CURRENT_VOLUME) {};
+ mSession.setPlaybackToRemote(vp);
+
+ MediaController.PlaybackInfo info = null;
+ for (int i = 0; i < MAX_AUDIO_INFO_CHANGED_CALLBACK_COUNT; ++i) {
+ mCallback.mOnAudioInfoChangedCalled = false;
+ mWaitLock.wait(TIME_OUT_MS);
+ assertTrue(mCallback.mOnAudioInfoChangedCalled);
+ info = mCallback.mPlaybackInfo;
+ if (info != null && info.getCurrentVolume() == TEST_CURRENT_VOLUME
+ && info.getMaxVolume() == TEST_MAX_VOLUME
+ && info.getPlaybackType() == MediaController.PlaybackInfo.PLAYBACK_TYPE_REMOTE
+ && info.getVolumeControl() == VolumeProvider.VOLUME_CONTROL_FIXED) {
+ break;
+ }
+ }
+ assertNotNull(info);
+ assertEquals(MediaController.PlaybackInfo.PLAYBACK_TYPE_REMOTE, info.getPlaybackType());
+ assertEquals(TEST_MAX_VOLUME, info.getMaxVolume());
+ assertEquals(TEST_CURRENT_VOLUME, info.getCurrentVolume());
+ assertEquals(VolumeProvider.VOLUME_CONTROL_FIXED, info.getVolumeControl());
+
+ info = controller.getPlaybackInfo();
+ assertNotNull(info);
+ assertEquals(MediaController.PlaybackInfo.PLAYBACK_TYPE_REMOTE, info.getPlaybackType());
+ assertEquals(TEST_MAX_VOLUME, info.getMaxVolume());
+ assertEquals(TEST_CURRENT_VOLUME, info.getCurrentVolume());
+ assertEquals(VolumeProvider.VOLUME_CONTROL_FIXED, info.getVolumeControl());
+
+ // test setPlaybackToLocal
+ AudioAttributes attrs = new AudioAttributes.Builder().addTag(TEST_VALUE).build();
+ mSession.setPlaybackToLocal(attrs);
+
+ info = controller.getPlaybackInfo();
+ assertNotNull(info);
+ assertEquals(MediaController.PlaybackInfo.PLAYBACK_TYPE_LOCAL, info.getPlaybackType());
+ Set<String> tags = info.getAudioAttributes().getTags();
+ assertNotNull(tags);
+ assertTrue(tags.contains(TEST_VALUE));
+ }
+ }
+
+
+ /**
* Verifies that a new session hasn't had any configuration bits set yet.
*
* @param controller The controller for the session
@@ -205,4 +309,100 @@
assertEquals(mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC),
info.getCurrentVolume());
}
+
+ private class MediaControllerCallback extends MediaController.Callback {
+ private volatile boolean mOnPlaybackStateChangedCalled;
+ private volatile boolean mOnMetadataChangedCalled;
+ private volatile boolean mOnQueueChangedCalled;
+ private volatile boolean mOnQueueTitleChangedCalled;
+ private volatile boolean mOnExtraChangedCalled;
+ private volatile boolean mOnAudioInfoChangedCalled;
+ private volatile boolean mOnSessionDestroyedCalled;
+
+ private volatile PlaybackState mPlaybackState;
+ private volatile MediaMetadata mMediaMetadata;
+ private volatile List<MediaSession.QueueItem> mQueue;
+ private volatile CharSequence mTitle;
+ private volatile Bundle mExtras;
+ private volatile MediaController.PlaybackInfo mPlaybackInfo;
+
+ public void resetLocked() {
+ mOnPlaybackStateChangedCalled = false;
+ mOnMetadataChangedCalled = false;
+ mOnQueueChangedCalled = false;
+ mOnQueueTitleChangedCalled = false;
+ mOnExtraChangedCalled = false;
+ mOnAudioInfoChangedCalled = false;
+ mOnSessionDestroyedCalled = false;
+
+ mPlaybackState = null;
+ mMediaMetadata = null;
+ mQueue = null;
+ mTitle = null;
+ mExtras = null;
+ mPlaybackInfo = null;
+ }
+
+ @Override
+ public void onPlaybackStateChanged(PlaybackState state) {
+ synchronized (mWaitLock) {
+ mOnPlaybackStateChangedCalled = true;
+ mPlaybackState = state;
+ mWaitLock.notify();
+ }
+ }
+
+ @Override
+ public void onMetadataChanged(MediaMetadata metadata) {
+ synchronized (mWaitLock) {
+ mOnMetadataChangedCalled = true;
+ mMediaMetadata = metadata;
+ mWaitLock.notify();
+ }
+ }
+
+ @Override
+ public void onQueueChanged(List<MediaSession.QueueItem> queue) {
+ synchronized (mWaitLock) {
+ mOnQueueChangedCalled = true;
+ mQueue = queue;
+ mWaitLock.notify();
+ }
+ }
+
+ @Override
+ public void onQueueTitleChanged(CharSequence title) {
+ synchronized (mWaitLock) {
+ mOnQueueTitleChangedCalled = true;
+ mTitle = title;
+ mWaitLock.notify();
+ }
+ }
+
+ @Override
+ public void onExtrasChanged(Bundle extras) {
+ synchronized (mWaitLock) {
+ mOnExtraChangedCalled = true;
+ mExtras = extras;
+ mWaitLock.notify();
+ }
+ }
+
+ @Override
+ public void onAudioInfoChanged(MediaController.PlaybackInfo info) {
+ synchronized (mWaitLock) {
+ mOnAudioInfoChangedCalled = true;
+ mPlaybackInfo = info;
+ mWaitLock.notify();
+ }
+ }
+
+ @Override
+ public void onSessionDestroyed() {
+ synchronized (mWaitLock) {
+ mOnSessionDestroyedCalled = true;
+ mWaitLock.notify();
+ }
+ }
+ }
}
diff --git a/tests/tests/mediastress/src/android/mediastress/cts/MediaRecorderStressTest.java b/tests/tests/mediastress/src/android/mediastress/cts/MediaRecorderStressTest.java
index 0b76185..a6a06ea 100644
--- a/tests/tests/mediastress/src/android/mediastress/cts/MediaRecorderStressTest.java
+++ b/tests/tests/mediastress/src/android/mediastress/cts/MediaRecorderStressTest.java
@@ -32,6 +32,7 @@
import java.io.File;
import java.io.FileWriter;
import java.io.Writer;
+import java.util.List;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
@@ -50,6 +51,8 @@
private final CameraErrorCallback mCameraErrorCallback = new CameraErrorCallback();
private final RecorderErrorCallback mRecorderErrorCallback = new RecorderErrorCallback();
private final static int WAIT_TIMEOUT = 10000;
+ private static final int VIDEO_WIDTH = 176;
+ private static final int VIDEO_HEIGHT = 144;
private MediaRecorder mRecorder;
private Camera mCamera;
@@ -215,11 +218,35 @@
mSurfaceHolder = MediaFrameworkTest.getSurfaceView().getHolder();
File stressOutFile = new File(WorkDir.getTopDir(), MEDIA_STRESS_OUTPUT);
Writer output = new BufferedWriter(new FileWriter(stressOutFile, true));
+ int width;
+ int height;
+ Camera camera = null;
if (!mHasRearCamera && !mHasFrontCamera) {
output.write("No camera found. Skipping recorder stress test\n");
return;
}
+ // Try to get camera smallest supported resolution.
+ // If we fail for any reason, set the video size to default value.
+ try {
+ camera = Camera.open(0);
+ List<Camera.Size> previewSizes = camera.getParameters().getSupportedPreviewSizes();
+ width = previewSizes.get(0).width;
+ height = previewSizes.get(0).height;
+ for (Camera.Size size : previewSizes) {
+ if (size.width < width || size.height < height) {
+ width = size.width;
+ height = size.height;
+ }
+ }
+ } catch (Exception e) {
+ width = VIDEO_WIDTH;
+ height = VIDEO_HEIGHT;
+ }
+ if (camera != null) {
+ camera.release();
+ }
+ Log.v(TAG, String.format("Camera video size used for test %dx%d", width, height));
output.write("H263 video record- reset after prepare Stress test\n");
output.write("Total number of loops:" +
NUMBER_OF_RECORDER_STRESS_LOOPS + "\n");
@@ -241,7 +268,7 @@
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setOutputFile(filename);
mRecorder.setVideoFrameRate(mFrameRate);
- mRecorder.setVideoSize(176,144);
+ mRecorder.setVideoSize(width, height);
Log.v(TAG, "setEncoder");
mRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H263);
mSurfaceHolder = MediaFrameworkTest.getSurfaceView().getHolder();
@@ -268,6 +295,8 @@
}
String filename;
+ int width;
+ int height;
SurfaceHolder mSurfaceHolder;
mSurfaceHolder = MediaFrameworkTest.getSurfaceView().getHolder();
File stressOutFile = new File(WorkDir.getTopDir(), MEDIA_STRESS_OUTPUT);
@@ -294,6 +323,19 @@
if (mCamera == null) {
break;
}
+ // Try to get camera smallest supported resolution.
+ // If we fail for any reason, set the video size to default value.
+ List<Camera.Size> previewSizes = mCamera.getParameters().getSupportedPreviewSizes();
+ width = previewSizes.get(0).width;
+ height = previewSizes.get(0).height;
+ for (Camera.Size size : previewSizes) {
+ if (size.width < width || size.height < height) {
+ width = size.width;
+ height = size.height;
+ }
+ }
+ Log.v(TAG, String.format("Camera video size used for test %dx%d", width, height));
+
mCamera.setErrorCallback(mCameraErrorCallback);
mCamera.setPreviewDisplay(mSurfaceHolder);
mCamera.startPreview();
@@ -315,7 +357,7 @@
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setOutputFile(filename);
mRecorder.setVideoFrameRate(mFrameRate);
- mRecorder.setVideoSize(176,144);
+ mRecorder.setVideoSize(width, height);
Log.v(TAG, "Media recorder setEncoder");
mRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H263);
Log.v(TAG, "mediaRecorder setPreview");
diff --git a/tests/tests/os/src/android/os/cts/BuildVersionTest.java b/tests/tests/os/src/android/os/cts/BuildVersionTest.java
index 3002ca3..e335901 100644
--- a/tests/tests/os/src/android/os/cts/BuildVersionTest.java
+++ b/tests/tests/os/src/android/os/cts/BuildVersionTest.java
@@ -29,7 +29,7 @@
private static final String LOG_TAG = "BuildVersionTest";
private static final Set<String> EXPECTED_RELEASES =
- new HashSet<String>(Arrays.asList("5.0.1", "5.0.2"));
+ new HashSet<String>(Arrays.asList("5.0", "5.0.1", "5.0.2"));
private static final int EXPECTED_SDK = 21;
private static final String EXPECTED_BUILD_VARIANT = "user";
private static final String EXPECTED_TAG = "release-keys";
diff --git a/tests/tests/permission2/src/android/permission2/cts/NoCaptureAudioOutputPermissionTest.java b/tests/tests/permission2/src/android/permission2/cts/NoCaptureAudioOutputPermissionTest.java
index b4e2855..bb63792 100644
--- a/tests/tests/permission2/src/android/permission2/cts/NoCaptureAudioOutputPermissionTest.java
+++ b/tests/tests/permission2/src/android/permission2/cts/NoCaptureAudioOutputPermissionTest.java
@@ -16,6 +16,7 @@
package android.permission2.cts;
+import android.content.pm.PackageManager;
import android.media.AudioFormat;
import android.media.AudioRecord;
import android.media.MediaRecorder.AudioSource;
@@ -37,9 +38,20 @@
*/
@SmallTest
public void testCreateAudioRecord() {
- final int bufferSize = AudioRecord.getMinBufferSize(44100,
+ int bufferSize = AudioRecord.getMinBufferSize(44100,
AudioFormat.CHANNEL_IN_STEREO, AudioFormat.ENCODING_PCM_16BIT);
+ if (bufferSize <= 0)
+ {
+ // getMinBufferSize() returns an invalid buffer size.
+ // That could be because there is no microphone. In that case,
+ // use this buffer size to test AudioRecord creation.
+ PackageManager packageManager = mContext.getPackageManager();
+ if (!packageManager.hasSystemFeature(PackageManager.FEATURE_MICROPHONE)) {
+ bufferSize = 44100;
+ }
+ }
+
// The attempt to create the AudioRecord object succeeds even if the
// app does not have permission, but the object is not usable.
// The API should probably throw SecurityException but it was not originally
diff --git a/tests/tests/provider/src/android/provider/cts/BrowserTest.java b/tests/tests/provider/src/android/provider/cts/BrowserTest.java
index 2f0432a..9f96412 100644
--- a/tests/tests/provider/src/android/provider/cts/BrowserTest.java
+++ b/tests/tests/provider/src/android/provider/cts/BrowserTest.java
@@ -84,7 +84,9 @@
value.put(colNames[i], cursor.getFloat(i));
break;
case Cursor.FIELD_TYPE_INTEGER:
- value.put(colNames[i], cursor.getLong(i));
+ if (!"_ID".equalsIgnoreCase(colNames[i])) {
+ value.put(colNames[i], cursor.getLong(i));
+ }
break;
case Cursor.FIELD_TYPE_STRING:
value.put(colNames[i], cursor.getString(i));
diff --git a/tests/tests/security/jni/android_security_cts_NativeCodeTest.cpp b/tests/tests/security/jni/android_security_cts_NativeCodeTest.cpp
index faa6eea..51e6e46 100644
--- a/tests/tests/security/jni/android_security_cts_NativeCodeTest.cpp
+++ b/tests/tests/security/jni/android_security_cts_NativeCodeTest.cpp
@@ -37,6 +37,7 @@
#include <errno.h>
#include <inttypes.h>
#include <linux/sysctl.h>
+#include <arpa/inet.h>
#define PASSED 0
#define UNKNOWN_ERROR -1
@@ -282,6 +283,28 @@
return (ret == -1 && errno == EINVAL);
}
+static jboolean android_security_cts_NativeCodeTest_doPingPongRootTest(JNIEnv*, jobject)
+{
+ int icmp_sock;
+ struct sockaddr sock_addr;
+
+ memset(&sock_addr, 0, sizeof(sock_addr));
+ icmp_sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP);
+ sock_addr.sa_family = AF_INET;
+
+ /* first connect */
+ connect(icmp_sock, &sock_addr, sizeof(sock_addr));
+
+ /* disconnect */
+ sock_addr.sa_family = AF_UNSPEC;
+ connect(icmp_sock, &sock_addr, sizeof(sock_addr));
+
+ /* second disconnect -> crash */
+ sock_addr.sa_family = AF_UNSPEC;
+ connect(icmp_sock, &sock_addr, sizeof(sock_addr));
+
+ return true;
+}
static JNINativeMethod gMethods[] = {
{ "doPerfEventTest", "()Z",
@@ -296,6 +319,8 @@
(void *) android_security_cts_NativeCodeTest_doCVE20141710Test },
{ "doFutexTest", "()Z",
(void *) android_security_cts_NativeCodeTest_doFutexTest },
+ { "doPingPongRootTest", "()Z",
+ (void *) android_security_cts_NativeCodeTest_doPingPongRootTest },
};
int register_android_security_cts_NativeCodeTest(JNIEnv* env)
diff --git a/tests/tests/security/src/android/security/cts/NativeCodeTest.java b/tests/tests/security/src/android/security/cts/NativeCodeTest.java
index 4be00b6..9a4df91 100644
--- a/tests/tests/security/src/android/security/cts/NativeCodeTest.java
+++ b/tests/tests/security/src/android/security/cts/NativeCodeTest.java
@@ -56,6 +56,13 @@
doFutexTest());
}
+ public void testPingPongRoot() throws Exception {
+ assertTrue("Device is vulnerable to CVE-2015-3636, a vulnerability in the ping "
+ + "socket implementation. Please apply the security patch at "
+ + "https://github.com/torvalds/linux/commit/a134f083e79f",
+ doPingPongRootTest());
+ }
+
/**
* Returns true iff this device is vulnerable to CVE-2013-2094.
* A patch for CVE-2013-2094 can be found at
@@ -114,4 +121,17 @@
* false if the device is vulnerable.
*/
private static native boolean doCVE20141710Test();
+
+ /**
+ * CVE-2015-3636
+ *
+ * Returns true if the patch is applied, crashes the system otherwise.
+ *
+ * Detects if the following patch is present.
+ * https://github.com/torvalds/linux/commit/a134f083e79f
+ *
+ * Credit: Wen Xu and wushi of KeenTeam.
+ * http://seclists.org/oss-sec/2015/q2/333
+ */
+ private static native boolean doPingPongRootTest();
}
diff --git a/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java b/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
index 12a510a..92f352f 100755
--- a/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/SmsManagerTest.java
@@ -80,6 +80,8 @@
"51502", // Globe Telecoms
"51503", // Smart Communications
"51505", // Sun Cellular
+ "53001", // Vodafone New Zealand
+ "53024", // NZC
"311870", // Boost Mobile
"311220", // USCC
"311225", // USCC LTE
@@ -96,6 +98,7 @@
"310600", // Cellcom
"31000", // Republic Wireless US
"310026", // T-Mobile US
+ "330120", // OpenMobile communication
// Verizon
"310004",
"310012",
diff --git a/tests/tests/util/src/android/util/cts/EventLogTest.java b/tests/tests/util/src/android/util/cts/EventLogTest.java
index 12df64f..bbff3bc 100644
--- a/tests/tests/util/src/android/util/cts/EventLogTest.java
+++ b/tests/tests/util/src/android/util/cts/EventLogTest.java
@@ -69,8 +69,6 @@
EventLog.writeEvent(ANSWER_TAG, 12345L, longString.toString());
EventLog.writeEvent(ANSWER_TAG, longString.toString(), longString.toString());
EventLog.writeEvent(ANSWER_TAG, longArray);
- // Give the message some time to show up in the log
- Thread.sleep(10);
List<Event> events = getEventsAfterMarker(markerData, ANSWER_TAG);
assertEquals(6, events.size());
@@ -156,8 +154,11 @@
}
/** Return elements after and the event that has the marker data and matching tag. */
- private List<Event> getEventsAfterMarker(Object marker, int... tags) throws IOException {
+ private List<Event> getEventsAfterMarker(Object marker, int... tags)
+ throws IOException, InterruptedException {
List<Event> events = new ArrayList<Event>();
+ // Give the message some time to show up in the log
+ Thread.sleep(20);
EventLog.readEvents(tags, events);
for (Iterator<Event> itr = events.iterator(); itr.hasNext(); ) {
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
index b381d72..6572285 100755
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
@@ -1456,14 +1456,10 @@
"Find all instances of a word on the page and highlight them.</p>";
mOnUiThread.loadDataAndWaitForCompletion("<html><body>" + p + p + "</body></html>", "text/html", null);
- WaitForFindResultsListener l = new WaitForFindResultsListener();
- mOnUiThread.setFindListener(l);
// highlight all the strings found
mOnUiThread.findAll("all");
- // make sure the findAll action is completed before findNext
- l.get();
- mOnUiThread.setFindListener(null);
+ getInstrumentation().waitForIdleSync();
int previousScrollY = mOnUiThread.getScrollY();
diff --git a/tests/tests/widget/src/android/widget/cts/AdapterViewTest.java b/tests/tests/widget/src/android/widget/cts/AdapterViewTest.java
index 81a1a4b..6a2240e 100644
--- a/tests/tests/widget/src/android/widget/cts/AdapterViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/AdapterViewTest.java
@@ -37,6 +37,7 @@
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.AdapterView.OnItemSelectedListener;
+import android.provider.Settings;
import com.android.cts.widget.R;
@@ -211,8 +212,12 @@
setArrayAdapter(mAdapterView);
// LastVisiblePosition should be adapter's getCount - 1,by mocking method
+ float fontScale = Settings.System.getFloat(mActivity.getContentResolver(), Settings.System.FONT_SCALE, 1);
+ if (fontScale < 1) {
+ fontScale = 1;
+ }
float density = mActivity.getResources().getDisplayMetrics().density;
- int bottom = (int) (LAYOUT_HEIGHT * density);
+ int bottom = (int) (LAYOUT_HEIGHT * density * fontScale);
mAdapterView.layout(0, 0, LAYOUT_WIDTH, bottom);
assertEquals(FRUIT.length - 1, mAdapterView.getLastVisiblePosition());
}
diff --git a/tests/tests/widget/src/android/widget/cts/AutoCompleteTextViewTest.java b/tests/tests/widget/src/android/widget/cts/AutoCompleteTextViewTest.java
index da99fa3..c08abbc 100644
--- a/tests/tests/widget/src/android/widget/cts/AutoCompleteTextViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/AutoCompleteTextViewTest.java
@@ -502,6 +502,7 @@
}
}.run();
} else {
+ Thread.sleep(200);
mInstrumentation.sendStringSync(STRING_TEST);
new PollingCheck() {
@Override
diff --git a/tests/uiautomator/src/com/android/cts/uiautomatortest/CtsUiAutomatorTest.java b/tests/uiautomator/src/com/android/cts/uiautomatortest/CtsUiAutomatorTest.java
index 7e44e49..7e4c367 100644
--- a/tests/uiautomator/src/com/android/cts/uiautomatortest/CtsUiAutomatorTest.java
+++ b/tests/uiautomator/src/com/android/cts/uiautomatortest/CtsUiAutomatorTest.java
@@ -827,17 +827,17 @@
assertTrue("Pinch must be in center of target view", p2s.y == screenRect.centerY());
assertTrue("Touch-down X coordinate for pointer 1 is invalid",
- withinMarginOfError(0.1f, screenRect.centerX(), p1s.x));
+ withinMarginOfError(0.125f, screenRect.centerX(), p1s.x));
assertTrue("Touch-down X coordinate for pointer 2 is invalid",
- withinMarginOfError(0.1f, screenRect.centerX(), p2s.x));
+ withinMarginOfError(0.125f, screenRect.centerX(), p2s.x));
assertTrue("Touch-up X coordinate for pointer 1 is invalid",
- withinMarginOfError(0.1f, screenRect.centerX() - screenRect.left,
+ withinMarginOfError(0.125f, screenRect.centerX() - screenRect.left,
screenRect.centerX() - p1e.x));
assertTrue("Touch-up X coordinate for pointer 2 is invalid",
- withinMarginOfError(0.1f, screenRect.right, p2e.x));
+ withinMarginOfError(0.125f, screenRect.right, p2e.x));
}
/**
@@ -881,17 +881,17 @@
assertTrue("Pinch must be in center of target view", p2s.y == screenRect.centerY());
assertTrue("Touch-down X coordinate for pointer 1 is invalid",
- withinMarginOfError(0.1f, screenRect.centerX() - screenRect.left,
+ withinMarginOfError(0.125f, screenRect.centerX() - screenRect.left,
screenRect.centerX() - p1s.x));
assertTrue("Touch-down X coordinate for pointer 2 is invalid",
- withinMarginOfError(0.1f, screenRect.right, p2s.x));
+ withinMarginOfError(0.125f, screenRect.right, p2s.x));
assertTrue("Touch-up X coordinate for pointer 1 is invalid",
- withinMarginOfError(0.1f, screenRect.centerX() - FINGER_TOUCH_HALF_WIDTH, p1e.x));
+ withinMarginOfError(0.125f, screenRect.centerX() - FINGER_TOUCH_HALF_WIDTH, p1e.x));
assertTrue("Touch-up X coordinate for pointer 2 is invalid",
- withinMarginOfError(0.1f, screenRect.centerX() + FINGER_TOUCH_HALF_WIDTH, p2e.x));
+ withinMarginOfError(0.125f, screenRect.centerX() + FINGER_TOUCH_HALF_WIDTH, p2e.x));
}
/**
diff --git a/tools/utils/CollectAllTests.java b/tools/utils/CollectAllTests.java
index ed74824..95b77f2 100644
--- a/tools/utils/CollectAllTests.java
+++ b/tools/utils/CollectAllTests.java
@@ -78,16 +78,26 @@
final String outputPathPrefix = args[0];
File manifestFile = new File(args[1]);
String jarFileName = args[2];
- final String javaPackageFilter = args[3];
- // Validate the javaPackageFilter value if non null.
- if (javaPackageFilter.length() != 0) {
- if (!isValidJavaPackage(javaPackageFilter)) {
- System.err.println("Invalid " + ATTRIBUTE_JAVA_PACKAGE_FILTER + ": " +
- javaPackageFilter);
- System.exit(1);
- return;
+ final String javaPackageFilterArg = args[3] != null ? args[3].replaceAll("\\s+", "") : "";
+ final String[] javaPackagePrefixes;
+ // Validate the javaPackageFilter value if non-empty.
+ if (!javaPackageFilterArg.isEmpty()) {
+ javaPackagePrefixes = javaPackageFilterArg.split(":");
+ for (int i = 0; i < javaPackagePrefixes.length; ++i) {
+ final String javaPackageFilter = javaPackagePrefixes[i];
+ if (!isValidJavaPackage(javaPackageFilter)) {
+ System.err.println("Invalid " + ATTRIBUTE_JAVA_PACKAGE_FILTER + ": " +
+ javaPackageFilter);
+ System.exit(1);
+ return;
+ } else {
+ javaPackagePrefixes[i] = javaPackageFilter.trim() + ".";
+ }
}
+ } else {
+ javaPackagePrefixes = new String[0];
}
+
String architecture = args[4];
if (architecture == null || architecture.equals("")) {
System.err.println("Invalid architecture");
@@ -132,7 +142,7 @@
setAttribute(testPackageElem, ATTRIBUTE_RUNNER, runner);
setAttribute(testPackageElem, ATTRIBUTE_PACKAGE, packageName);
setAttribute(testPackageElem, ATTRIBUTE_NS, packageName);
- setAttribute(testPackageElem, ATTRIBUTE_JAVA_PACKAGE_FILTER, javaPackageFilter);
+ setAttribute(testPackageElem, ATTRIBUTE_JAVA_PACKAGE_FILTER, javaPackageFilterArg);
if (testType.type == TestType.HOST_SIDE_ONLY) {
setAttribute(testPackageElem, ATTRIBUTE_HOST_SIDE_ONLY, "true");
@@ -185,8 +195,6 @@
Map<String,TestClass> testCases = new LinkedHashMap<String, TestClass>();
- String javaPackagePrefix = javaPackageFilter.isEmpty() ? "" : (javaPackageFilter + ".");
-
Enumeration<JarEntry> jarEntries = jarFile.entries();
while (jarEntries.hasMoreElements()) {
JarEntry jarEntry = jarEntries.nextElement();
@@ -196,9 +204,22 @@
}
String className
= name.substring(0, name.length() - ".class".length()).replace('/', '.');
- if (!className.startsWith(javaPackagePrefix)) {
+
+ boolean matchesPrefix = false;
+ if (javaPackagePrefixes.length > 0) {
+ for (String javaPackagePrefix : javaPackagePrefixes) {
+ if (className.startsWith(javaPackagePrefix)) {
+ matchesPrefix = true;
+ }
+ }
+ } else {
+ matchesPrefix = true;
+ }
+
+ if (!matchesPrefix) {
continue;
}
+
try {
Class<?> klass = Class.forName(className,
false,