Merge "Use correct context when querying package manager" into mnc-dr-dev
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index e1d4eb0..ea16821 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -1708,8 +1708,8 @@
<meta-data android:name="test_required_features" android:value="android.hardware.microphone" />
</activity>
- <activity android:name=".audio.AudioDeviceNotificationsActivity"
- android:label="@string/audio_devices_notifications_test">
+ <activity android:name=".audio.AudioOutputDeviceNotificationsActivity"
+ android:label="@string/audio_in_devices_notifications_test">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.cts.intent.category.MANUAL_TEST" />
@@ -1718,18 +1718,37 @@
<!--
<meta-data android:name="test_required_features" android:value="android.hardware.microphone" />
-->
+ <meta-data android:name="test_required_features" android:value="android.hardware.audio.output" />
</activity>
- <activity android:name=".audio.AudioRoutingNotificationsActivity"
- android:label="@string/audio_routingnotifications_test">
+ <activity android:name=".audio.AudioInputDeviceNotificationsActivity"
+ android:label="@string/audio_in_devices_notifications_test">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.cts.intent.category.MANUAL_TEST" />
</intent-filter>
<meta-data android:name="test_category" android:value="@string/test_category_audio" />
- <!--
<meta-data android:name="test_required_features" android:value="android.hardware.microphone" />
- -->
+ </activity>
+
+ <activity android:name=".audio.AudioOutputRoutingNotificationsActivity"
+ android:label="@string/audio_output_routingnotifications_test">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.cts.intent.category.MANUAL_TEST" />
+ </intent-filter>
+ <meta-data android:name="test_category" android:value="@string/test_category_audio" />
+ <meta-data android:name="test_required_features" android:value="android.hardware.audio.output" />
+ </activity>
+
+ <activity android:name=".audio.AudioInputRoutingNotificationsActivity"
+ android:label="@string/audio_input_routingnotifications_test">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.cts.intent.category.MANUAL_TEST" />
+ </intent-filter>
+ <meta-data android:name="test_category" android:value="@string/test_category_audio" />
+ <meta-data android:name="test_required_features" android:value="android.hardware.microphone" />
</activity>
<activity android:name=".audio.AudioLoopbackActivity"
diff --git a/apps/CtsVerifier/res/layout/audio_dev_notify.xml b/apps/CtsVerifier/res/layout/audio_dev_notify.xml
index 98dbd8b..0975ab9 100644
--- a/apps/CtsVerifier/res/layout/audio_dev_notify.xml
+++ b/apps/CtsVerifier/res/layout/audio_dev_notify.xml
@@ -24,8 +24,7 @@
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:gravity="bottom"
- android:id="@+id/info_text"
- android:text="@string/audio_devices_notification_instructions" />
+ android:id="@+id/info_text"/>
<LinearLayout
android:layout_width="match_parent"
diff --git a/apps/CtsVerifier/res/layout/audio_routingnotifications_test.xml b/apps/CtsVerifier/res/layout/audio_input_routingnotifications_test.xml
similarity index 64%
copy from apps/CtsVerifier/res/layout/audio_routingnotifications_test.xml
copy to apps/CtsVerifier/res/layout/audio_input_routingnotifications_test.xml
index cef30d6..ca7dd19 100644
--- a/apps/CtsVerifier/res/layout/audio_routingnotifications_test.xml
+++ b/apps/CtsVerifier/res/layout/audio_input_routingnotifications_test.xml
@@ -26,40 +26,7 @@
android:scrollbars="vertical"
android:gravity="bottom"
android:id="@+id/info_text"
- android:text="@string/audio_dev_routingnotification_instructions" />
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:id="@+id/audioTrackRoutingLayout">
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/audio_routingnotification_playHeader"/>
-
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:id="@+id/audio_routingnotification_audioTrack_change"/>
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal">
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:id="@+id/audio_routingnotification_playBtn"
- android:text="@string/audio_routingnotification_playBtn"/>
-
- <Button
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:id="@+id/audio_routingnotification_playStopBtn"
- android:text="@string/audio_routingnotification_playStopBtn"/>
- </LinearLayout>
- </LinearLayout>
+ android:text="@string/audio_input_routingnotification_instructions" />
<LinearLayout
android:layout_width="match_parent"
diff --git a/apps/CtsVerifier/res/layout/audio_routingnotifications_test.xml b/apps/CtsVerifier/res/layout/audio_output_routingnotifications_test.xml
similarity index 64%
rename from apps/CtsVerifier/res/layout/audio_routingnotifications_test.xml
rename to apps/CtsVerifier/res/layout/audio_output_routingnotifications_test.xml
index cef30d6..b321000 100644
--- a/apps/CtsVerifier/res/layout/audio_routingnotifications_test.xml
+++ b/apps/CtsVerifier/res/layout/audio_output_routingnotifications_test.xml
@@ -26,7 +26,7 @@
android:scrollbars="vertical"
android:gravity="bottom"
android:id="@+id/info_text"
- android:text="@string/audio_dev_routingnotification_instructions" />
+ android:text="@string/audio_output_routingnotification_instructions" />
<LinearLayout
android:layout_width="match_parent"
@@ -61,39 +61,6 @@
</LinearLayout>
</LinearLayout>
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical"
- android:id="@+id/audioRecordRoutingLayout">
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/audio_routingnotification_recHeader"/>
-
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:id="@+id/audio_routingnotification_audioRecord_change"/>
-
- <LinearLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="horizontal">
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:id="@+id/audio_routingnotification_recordBtn"
- android:text="@string/audio_routingnotification_recBtn"/>
-
- <Button
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:id="@+id/audio_routingnotification_recordStopBtn"
- android:text="@string/audio_routingnotification_recStopBtn"/>
- </LinearLayout>
- </LinearLayout>
-
<include layout="@layout/pass_fail_buttons" />
</LinearLayout>
\ No newline at end of file
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index 1c4ec06..d8a96eb 100644
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -2040,25 +2040,34 @@
<string name="error_screen_pinning_did_not_exit">Screen was not unpinned.</string>
<string name="error_screen_pinning_couldnt_exit">Could not exit screen pinning through API.</string>
- <!-- Audio Devices Notifcations Test -->
- <string name="audio_devices_notifications_test">Audio Devices Notifications Test</string>
- <string name="audio_devices_notification_instructions">
+ <!-- Audio Devices Notifcations Tests -->
+ <string name="audio_out_devices_notifications_test">Audio Output Devices Notifications Test</string>
+ <string name="audio_out_devices_notification_instructions">
Click the "Clear Messages" button then connect and disconnect a wired headset.
Note if the appropriate notification messages appear below.
</string>
+ <string name="audio_in_devices_notifications_test">Audio Input Devices Notifications Test</string>
+ <string name="audio_in_devices_notification_instructions">
+ Click the "Clear Messages" button then connect and disconnect a microphone or wired headset.
+ Note if the appropriate notification messages appear below.
+ </string>
<string name="audio_dev_notification_clearmsgs">Clear Messages</string>
<string name="audio_dev_notification_connectMsg">CONNECT DETECTED</string>
<string name="audio_dev_notification_disconnectMsg">DISCONNECT DETECTED</string>
- <!-- Audio Routing Notifcations Test -->
- <string name="audio_routingnotifications_test">Audio Routing Notifications Test</string>
- <string name="audio_dev_routingnotification_instructions">
- Click on the "Play" button in the AudioTrack Routing Notifictions section below to
+ <string name="audio_input_routingnotifications_test">Audio Input Routing Notifications Test</string>
+ <string name="audio_input_routingnotification_instructions">
+ Click on the "Record" button in the AudioRecord Routing Notifications section below to
+ start recording. Insert a wired headset or microphone. Observe a message acknowledging the
+ rerouting event below. Remove the wired headset and observe the new routing message.
+ Click on the "Stop" button to stop recording.\n
+ </string>
+ <string name="audio_output_routingnotifications_test">Audio Output Routing Notifications Test</string>
+ <string name="audio_output_routingnotification_instructions">
+ Click on the "Play" button in the AudioTrack Routing Notifications section below to
start (silent) playback. Insert a wired headset. Observe a message acknowledging the
rerouting event below. Remove the wired headset and observe the new routing message.
Click on the "Stop" button to stop playback.\n
- Repeat the process with "Record" and "Stop" button in the AudioRecord Routing
- Notifications section below.
</string>
<string name="audio_routingnotification_playBtn">Play</string>
<string name="audio_routingnotification_playStopBtn">Stop</string>
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioDeviceNotificationsActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioInputDeviceNotificationsActivity.java
similarity index 86%
copy from apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioDeviceNotificationsActivity.java
copy to apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioInputDeviceNotificationsActivity.java
index 93e0507..3513774 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioDeviceNotificationsActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioInputDeviceNotificationsActivity.java
@@ -34,10 +34,10 @@
import android.widget.TextView;
/**
- * Tests Audio Device Connection events by prompting the user to insert/remove a wired headset
- * and noting the presence (or absence) of notifictions.
+ * Tests Audio Device Connection events for output by prompting the user to insert/remove a
+ * wired headset (or microphone) and noting the presence (or absence) of notifications.
*/
-public class AudioDeviceNotificationsActivity extends PassFailButtons.Activity {
+public class AudioInputDeviceNotificationsActivity extends PassFailButtons.Activity {
Context mContext;
TextView mConnectView;
@@ -71,6 +71,9 @@
mConnectView = (TextView)findViewById(R.id.audio_dev_notification_connect_msg);
mDisconnectView = (TextView)findViewById(R.id.audio_dev_notification_disconnect_msg);
+ ((TextView)findViewById(R.id.info_text)).setText(mContext.getResources().getString(
+ R.string.audio_in_devices_notification_instructions));
+
mClearMsgsBtn = (Button)findViewById(R.id.audio_dev_notification_connect_clearmsgs_btn);
mClearMsgsBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioRoutingNotificationsActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioInputRoutingNotificationsActivity.java
similarity index 63%
rename from apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioRoutingNotificationsActivity.java
rename to apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioInputRoutingNotificationsActivity.java
index 47bc48a..cdc8199 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioRoutingNotificationsActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioInputRoutingNotificationsActivity.java
@@ -25,7 +25,6 @@
import android.media.AudioDeviceInfo;
import android.media.AudioManager;
import android.media.AudioRecord;
-import android.media.AudioTrack;
import android.os.Bundle;
import android.os.Handler;
@@ -39,33 +38,23 @@
import android.widget.TextView;
/**
- * Tests AudioTrack and AudioRecord (re)Routing messages.
+ * Tests AudioRecord (re)Routing messages.
*/
-public class AudioRoutingNotificationsActivity extends PassFailButtons.Activity {
- private static final String TAG = "AudioRoutingNotificationsActivity";
+public class AudioInputRoutingNotificationsActivity extends PassFailButtons.Activity {
+ private static final String TAG = "AudioInputRoutingNotificationsActivity";
Context mContext;
- OnBtnClickListener mBtnClickListener = new OnBtnClickListener();
-
- int mNumTrackNotifications = 0;
int mNumRecordNotifications = 0;
- TrivialPlayer mAudioPlayer = new TrivialPlayer();
+ OnBtnClickListener mBtnClickListener = new OnBtnClickListener();
+
TrivialRecorder mAudioRecorder = new TrivialRecorder();
private class OnBtnClickListener implements OnClickListener {
@Override
public void onClick(View v) {
switch (v.getId()) {
- case R.id.audio_routingnotification_playBtn:
- mAudioPlayer.start();
- break;
-
- case R.id.audio_routingnotification_playStopBtn:
- mAudioPlayer.stop();
- break;
-
case R.id.audio_routingnotification_recordBtn:
mAudioRecorder.start();
break;
@@ -77,22 +66,6 @@
}
}
- private class AudioTrackRoutingChangeListener implements AudioTrack.OnRoutingChangedListener {
- public void onRoutingChanged(AudioTrack audioTrack) {
- mNumTrackNotifications++;
- TextView textView =
- (TextView)findViewById(R.id.audio_routingnotification_audioTrack_change);
- String msg = mContext.getResources().getString(
- R.string.audio_routingnotification_trackRoutingMsg);
- AudioDeviceInfo routedDevice = audioTrack.getRoutedDevice();
- CharSequence deviceName = routedDevice != null ? routedDevice.getProductName() : "none";
- int deviceType = routedDevice != null ? routedDevice.getType() : -1;
- textView.setText(msg + " - " +
- deviceName + " [0x" + Integer.toHexString(deviceType) + "]" +
- " - " + mNumTrackNotifications);
- }
- }
-
private class AudioRecordRoutingChangeListener implements AudioRecord.OnRoutingChangedListener {
public void onRoutingChanged(AudioRecord audioRecord) {
mNumRecordNotifications++;
@@ -112,13 +85,9 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.audio_routingnotifications_test);
+ setContentView(R.layout.audio_input_routingnotifications_test);
Button btn;
- btn = (Button)findViewById(R.id.audio_routingnotification_playBtn);
- btn.setOnClickListener(mBtnClickListener);
- btn = (Button)findViewById(R.id.audio_routingnotification_playStopBtn);
- btn.setOnClickListener(mBtnClickListener);
btn = (Button)findViewById(R.id.audio_routingnotification_recordBtn);
btn.setOnClickListener(mBtnClickListener);
btn = (Button)findViewById(R.id.audio_routingnotification_recordStopBtn);
@@ -126,10 +95,6 @@
mContext = this;
- AudioTrack audioTrack = mAudioPlayer.getAudioTrack();
- audioTrack.addOnRoutingChangedListener(
- new AudioTrackRoutingChangeListener(), new Handler());
-
AudioRecord audioRecord = mAudioRecorder.getAudioRecord();
audioRecord.addOnRoutingChangedListener(
new AudioRecordRoutingChangeListener(), new Handler());
@@ -139,7 +104,6 @@
@Override
public void onBackPressed () {
- mAudioPlayer.shutDown();
mAudioRecorder.shutDown();
super.onBackPressed();
}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioDeviceNotificationsActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioOutputDeviceNotificationsActivity.java
similarity index 86%
rename from apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioDeviceNotificationsActivity.java
rename to apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioOutputDeviceNotificationsActivity.java
index 93e0507..a64ddc4 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioDeviceNotificationsActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioOutputDeviceNotificationsActivity.java
@@ -34,10 +34,10 @@
import android.widget.TextView;
/**
- * Tests Audio Device Connection events by prompting the user to insert/remove a wired headset
- * and noting the presence (or absence) of notifictions.
+ * Tests Audio Device Connection events for output devices by prompting the user to
+ * insert/remove a wired headset and noting the presence (or absence) of notifications.
*/
-public class AudioDeviceNotificationsActivity extends PassFailButtons.Activity {
+public class AudioOutputDeviceNotificationsActivity extends PassFailButtons.Activity {
Context mContext;
TextView mConnectView;
@@ -71,6 +71,9 @@
mConnectView = (TextView)findViewById(R.id.audio_dev_notification_connect_msg);
mDisconnectView = (TextView)findViewById(R.id.audio_dev_notification_disconnect_msg);
+ ((TextView)findViewById(R.id.info_text)).setText(mContext.getResources().getString(
+ R.string.audio_out_devices_notification_instructions));
+
mClearMsgsBtn = (Button)findViewById(R.id.audio_dev_notification_connect_clearmsgs_btn);
mClearMsgsBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioRoutingNotificationsActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioOutputRoutingNotificationsActivity.java
similarity index 63%
copy from apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioRoutingNotificationsActivity.java
copy to apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioOutputRoutingNotificationsActivity.java
index 47bc48a..bfc3d45 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioRoutingNotificationsActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/AudioOutputRoutingNotificationsActivity.java
@@ -24,7 +24,6 @@
import android.media.AudioDeviceCallback;
import android.media.AudioDeviceInfo;
import android.media.AudioManager;
-import android.media.AudioRecord;
import android.media.AudioTrack;
import android.os.Bundle;
@@ -41,18 +40,16 @@
/**
* Tests AudioTrack and AudioRecord (re)Routing messages.
*/
-public class AudioRoutingNotificationsActivity extends PassFailButtons.Activity {
- private static final String TAG = "AudioRoutingNotificationsActivity";
+public class AudioOutputRoutingNotificationsActivity extends PassFailButtons.Activity {
+ private static final String TAG = "AudioOutputRoutingNotificationsActivity";
Context mContext;
OnBtnClickListener mBtnClickListener = new OnBtnClickListener();
int mNumTrackNotifications = 0;
- int mNumRecordNotifications = 0;
TrivialPlayer mAudioPlayer = new TrivialPlayer();
- TrivialRecorder mAudioRecorder = new TrivialRecorder();
private class OnBtnClickListener implements OnClickListener {
@Override
@@ -65,14 +62,6 @@
case R.id.audio_routingnotification_playStopBtn:
mAudioPlayer.stop();
break;
-
- case R.id.audio_routingnotification_recordBtn:
- mAudioRecorder.start();
- break;
-
- case R.id.audio_routingnotification_recordStopBtn:
- mAudioRecorder.stop();
- break;
}
}
}
@@ -93,36 +82,16 @@
}
}
- private class AudioRecordRoutingChangeListener implements AudioRecord.OnRoutingChangedListener {
- public void onRoutingChanged(AudioRecord audioRecord) {
- mNumRecordNotifications++;
- TextView textView =
- (TextView)findViewById(R.id.audio_routingnotification_audioRecord_change);
- String msg = mContext.getResources().getString(
- R.string.audio_routingnotification_recordRoutingMsg);
- AudioDeviceInfo routedDevice = audioRecord.getRoutedDevice();
- CharSequence deviceName = routedDevice != null ? routedDevice.getProductName() : "none";
- int deviceType = routedDevice != null ? routedDevice.getType() : -1;
- textView.setText(msg + " - " +
- deviceName + " [0x" + Integer.toHexString(deviceType) + "]" +
- " - " + mNumRecordNotifications);
- }
- }
-
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.audio_routingnotifications_test);
+ setContentView(R.layout.audio_output_routingnotifications_test);
Button btn;
btn = (Button)findViewById(R.id.audio_routingnotification_playBtn);
btn.setOnClickListener(mBtnClickListener);
btn = (Button)findViewById(R.id.audio_routingnotification_playStopBtn);
btn.setOnClickListener(mBtnClickListener);
- btn = (Button)findViewById(R.id.audio_routingnotification_recordBtn);
- btn.setOnClickListener(mBtnClickListener);
- btn = (Button)findViewById(R.id.audio_routingnotification_recordStopBtn);
- btn.setOnClickListener(mBtnClickListener);
mContext = this;
@@ -130,17 +99,12 @@
audioTrack.addOnRoutingChangedListener(
new AudioTrackRoutingChangeListener(), new Handler());
- AudioRecord audioRecord = mAudioRecorder.getAudioRecord();
- audioRecord.addOnRoutingChangedListener(
- new AudioRecordRoutingChangeListener(), new Handler());
-
setPassFailButtonClickListeners();
}
@Override
public void onBackPressed () {
mAudioPlayer.shutDown();
- mAudioRecorder.shutDown();
super.onBackPressed();
}
}
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/BurstCaptureRawTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/BurstCaptureRawTest.java
index 75de9c0..41e2045 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/BurstCaptureRawTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/BurstCaptureRawTest.java
@@ -714,6 +714,7 @@
// clear out the surface and camera session
stopPreviewAndClearSurface(previewBuilder, rawBurstBuilder);
+ rawReaderListener.drain();
closeImageReader();
}
} finally {
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 c5eb27b..d78b3b5 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/CameraTestUtils.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/CameraTestUtils.java
@@ -337,7 +337,7 @@
*
*/
public void drain() {
- for (int i = 0; i < mQueue.size(); i++) {
+ while (!mQueue.isEmpty()) {
Image image = mQueue.poll();
assertNotNull("Unable to get an image", image);
image.close();
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 dc499ba..2ae29c3 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/CaptureResultTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/CaptureResultTest.java
@@ -316,18 +316,24 @@
session, previewBuilder.build(), mHandler);
// Check if all timestamps are the same
+ Image prevImage = prevListener.getImage(CAPTURE_IMAGE_TIMEOUT_MS);
validateTimestamps("Result 1", result.first,
- prevListener.getImage(CAPTURE_IMAGE_TIMEOUT_MS), result.second);
+ prevImage, result.second);
+ prevImage.close();
// Capture targeting both jpeg and preview
Pair<TotalCaptureResult, Long> result2 = captureAndVerifyResult(mockCaptureCallback,
session, multiBuilder.build(), mHandler);
// Check if all timestamps are the same
+ prevImage = prevListener.getImage(CAPTURE_IMAGE_TIMEOUT_MS);
+ Image jpegImage = jpegListener.getImage(CAPTURE_IMAGE_TIMEOUT_MS);
validateTimestamps("Result 2 Preview", result2.first,
- prevListener.getImage(CAPTURE_IMAGE_TIMEOUT_MS), result2.second);
+ prevImage, result2.second);
validateTimestamps("Result 2 Jpeg", result2.first,
- jpegListener.getImage(CAPTURE_IMAGE_TIMEOUT_MS), result2.second);
+ jpegImage, result2.second);
+ prevImage.close();
+ jpegImage.close();
// Check if timestamps are increasing
mCollector.expectGreater("Timestamps must be increasing.", result.second,
@@ -343,10 +349,14 @@
long resultDiff = result4.second - result3.second;
// Check if all timestamps are the same
+ prevImage = prevListener.getImage(CAPTURE_IMAGE_TIMEOUT_MS);
validateTimestamps("Result 3", result3.first,
- prevListener.getImage(CAPTURE_IMAGE_TIMEOUT_MS), result3.second);
+ prevImage, result3.second);
+ prevImage.close();
+ prevImage = prevListener.getImage(CAPTURE_IMAGE_TIMEOUT_MS);
validateTimestamps("Result 4", result4.first,
- prevListener.getImage(CAPTURE_IMAGE_TIMEOUT_MS), result4.second);
+ prevImage, result4.second);
+ prevImage.close();
// Check that the timestamps monotonically increase at a reasonable rate
mCollector.expectGreaterOrEqual("Timestamps increase faster than system clock.",
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/ImageReaderTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/ImageReaderTest.java
index 7c80c7d..155f9dd 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/ImageReaderTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/ImageReaderTest.java
@@ -460,6 +460,10 @@
// Stop capture, delete the streams.
stopCapture(/*fast*/false);
+ yuvImage.close();
+ jpegImage.close();
+ yuvListener.drain();
+ jpegListener.drain();
} finally {
closeImageReader(jpegReader);
jpegReader = null;
@@ -645,6 +649,8 @@
maxYuvSz.getHeight(), ImageFormat.YUV_420_888, /*filePath*/null);
CameraTestUtils.validateImage(captureImage, captureSz.getWidth(),
captureSz.getHeight(), format, /*filePath*/null);
+ yuvImage.close();
+ captureImage.close();
}
// Stop capture, delete the streams.
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/MultiViewTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/MultiViewTest.java
index dfba587..2795bde 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/MultiViewTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/MultiViewTest.java
@@ -78,7 +78,7 @@
Exception prior = null;
ImageVerifierListener yuvListener;
- ImageReader yuvReader;
+ ImageReader yuvReader = null;
try {
openCamera(cameraId);
@@ -102,6 +102,9 @@
prior = e;
} finally {
try {
+ if (yuvReader != null) {
+ yuvReader.close();
+ }
closeCamera(cameraId);
} catch (Exception e) {
if (prior != null) {
@@ -151,7 +154,7 @@
Exception prior = null;
ImageVerifierListener yuvListener;
- ImageReader yuvReader;
+ ImageReader yuvReader = null;
try {
openCamera(cameraId);
@@ -175,6 +178,9 @@
prior = e;
} finally {
try {
+ if (yuvReader != null) {
+ yuvReader.close();
+ }
closeCamera(cameraId);
} catch (Exception e) {
if (prior != null) {
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 2e001c7..39eb1dc 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/PerformanceTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/PerformanceTest.java
@@ -71,8 +71,7 @@
private final int MAX_INPUT_IMAGES = MAX_REPROCESS_IMAGES;
// ZSL queue depth should be bigger than the max simultaneous reprocessing capture request
// count to maintain reasonable number of candidate image for the worse-case.
- // Here we want to make sure we at most dequeue half of the queue max images for the worst-case.
- private final int MAX_ZSL_IMAGES = MAX_REPROCESS_IMAGES * 2;
+ private final int MAX_ZSL_IMAGES = MAX_REPROCESS_IMAGES * 3 / 2;
private final double REPROCESS_STALL_MARGIN = 0.1;
private DeviceReportLog mReportLog;
@@ -434,7 +433,7 @@
// Wait for reprocess output jpeg and result come back.
reprocessResultListener.getCaptureResultForRequest(reprocessRequest,
CameraTestUtils.CAPTURE_RESULT_TIMEOUT_MS);
- mJpegListener.getImage(CameraTestUtils.CAPTURE_IMAGE_TIMEOUT_MS);
+ mJpegListener.getImage(CameraTestUtils.CAPTURE_IMAGE_TIMEOUT_MS).close();
long numFramesMaybeStalled = mZslResultListener.getTotalNumFrames();
assertTrue("Reprocess capture result should be returned in "
+ MAX_REPROCESS_RETURN_FRAME_COUNT + " frames",
@@ -475,6 +474,8 @@
maxCaptureGapsMs[i] = maxTimestampGapMs;
}
+ stopZslStreaming();
+
String reprocessType = " YUV reprocessing ";
if (reprocessInputFormat == ImageFormat.PRIVATE) {
reprocessType = " opaque reprocessing ";
@@ -539,24 +540,34 @@
// Get images
startTimeMs = SystemClock.elapsedRealtime();
+ Image jpegImages[] = new Image[MAX_REPROCESS_IMAGES];
for (int i = 0; i < MAX_REPROCESS_IMAGES; i++) {
- mJpegListener.getImage(CameraTestUtils.CAPTURE_IMAGE_TIMEOUT_MS);
+ jpegImages[i] = mJpegListener.getImage(CameraTestUtils.CAPTURE_IMAGE_TIMEOUT_MS);
getImageLatenciesMs[i] = SystemClock.elapsedRealtime() - startTimeMs;
startTimeMs = SystemClock.elapsedRealtime();
}
+ for (Image i : jpegImages) {
+ i.close();
+ }
} else {
// sync capture: issue reprocess request one by one, only submit next one when
// the previous capture image is returned. This is to test the back to back capture
// performance.
+ Image jpegImages[] = new Image[MAX_REPROCESS_IMAGES];
for (int i = 0; i < MAX_REPROCESS_IMAGES; i++) {
startTimeMs = SystemClock.elapsedRealtime();
mWriter.queueInputImage(inputImages[i]);
mSession.capture(reprocessReqs[i].build(), null, null);
- mJpegListener.getImage(CameraTestUtils.CAPTURE_IMAGE_TIMEOUT_MS);
+ jpegImages[i] = mJpegListener.getImage(CameraTestUtils.CAPTURE_IMAGE_TIMEOUT_MS);
getImageLatenciesMs[i] = SystemClock.elapsedRealtime() - startTimeMs;
}
+ for (Image i : jpegImages) {
+ i.close();
+ }
}
+ stopZslStreaming();
+
String reprocessType = " YUV reprocessing ";
if (reprocessInputFormat == ImageFormat.PRIVATE) {
reprocessType = " opaque reprocessing ";
@@ -591,6 +602,12 @@
mSession.setRepeatingRequest(zslBuilder.build(), mZslResultListener, mHandler);
}
+ private void stopZslStreaming() throws Exception {
+ mSession.stopRepeating();
+ mSessionListener.getStateWaiter().waitForState(
+ BlockingSessionCallback.SESSION_READY, CameraTestUtils.CAMERA_IDLE_TIMEOUT_MS);
+ }
+
/**
* Wait for a certain number of frames, the images and results will be drained from the
* listeners to make sure that next reprocessing can get matched results and images.
@@ -598,24 +615,22 @@
* @param numFrameWait The number of frames to wait before return, 0 means that
* this call returns immediately after streaming on.
*/
- private void waitForFrames(int numFrameWait) {
+ private void waitForFrames(int numFrameWait) throws Exception {
if (numFrameWait < 0) {
throw new IllegalArgumentException("numFrameWait " + numFrameWait +
" should be non-negative");
}
- if (numFrameWait == 0) {
- // Let is stream out for a while
- waitForNumResults(mZslResultListener, numFrameWait);
- // Drain the pending images, to ensure that all future images have an associated
- // capture result available.
- mCameraZslImageListener.drain();
+ for (int i = 0; i < numFrameWait; i++) {
+ mCameraZslImageListener.getImage(CameraTestUtils.CAPTURE_IMAGE_TIMEOUT_MS).close();
}
}
private void closeReaderWriters() {
+ mCameraZslImageListener.drain();
CameraTestUtils.closeImageReader(mCameraZslReader);
mCameraZslReader = null;
+ mJpegListener.drain();
CameraTestUtils.closeImageReader(mJpegReader);
mJpegReader = null;
CameraTestUtils.closeImageWriter(mWriter);