summaryrefslogtreecommitdiffstats
path: root/camera
diff options
context:
space:
mode:
authorIgor Murashkin <iam@google.com>2013-03-20 15:56:31 -0700
committerIgor Murashkin <iam@google.com>2013-03-26 17:16:11 -0700
commita36381479c5c546a01188390f1e0d2e280a3dbd8 (patch)
tree84123991a8c16817eb7f0094f90b75e0187da15a /camera
parent2247dd0dc60096d1b5a91ccadb5539f0b100c88f (diff)
downloadframeworks_av-a36381479c5c546a01188390f1e0d2e280a3dbd8.zip
frameworks_av-a36381479c5c546a01188390f1e0d2e280a3dbd8.tar.gz
frameworks_av-a36381479c5c546a01188390f1e0d2e280a3dbd8.tar.bz2
Camera: Add hotplug support (for fixed # of cameras)
* Minor: also change addListener to fire the current status upon subscription * Minor: STATUS_AVAILABLE is now an alias for STATUS_PRESENT and deprecated Change-Id: I254608a7332095e3ef201ffea64cff156cfc1b3e
Diffstat (limited to 'camera')
-rw-r--r--camera/tests/ProCameraTests.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/camera/tests/ProCameraTests.cpp b/camera/tests/ProCameraTests.cpp
index ecc0854..5f8f772 100644
--- a/camera/tests/ProCameraTests.cpp
+++ b/camera/tests/ProCameraTests.cpp
@@ -587,14 +587,19 @@ TEST_F(ProCameraTest, DISABLED_StreamingImageSingle) {
sp<ServiceListener> listener = new ServiceListener();
EXPECT_OK(ProCamera::addServiceListener(listener));
- ServiceListener::Status currentStatus = ServiceListener::STATUS_AVAILABLE;
+ ServiceListener::Status currentStatus;
+
+ // when subscribing a new listener,
+ // we immediately get a callback to the current status
+ while (listener->waitForStatusChange(/*out*/currentStatus) != OK);
+ EXPECT_EQ(ServiceListener::STATUS_PRESENT, currentStatus);
dout << "Will now stream and resume infinitely..." << std::endl;
while (true) {
- if (currentStatus == ServiceListener::STATUS_AVAILABLE) {
+ if (currentStatus == ServiceListener::STATUS_PRESENT) {
- EXPECT_OK(mCamera->createStream(mDisplayW, mDisplayH, mDisplayFmt,
+ ASSERT_OK(mCamera->createStream(mDisplayW, mDisplayH, mDisplayFmt,
surface,
&depthStreamId));
EXPECT_NE(-1, depthStreamId);
@@ -613,12 +618,15 @@ TEST_F(ProCameraTest, DISABLED_StreamingImageSingle) {
while (listener->waitForStatusChange(/*out*/stat) != OK);
if (currentStatus != stat) {
- if (stat == ServiceListener::STATUS_AVAILABLE) {
+ if (stat == ServiceListener::STATUS_PRESENT) {
dout << "Reconnecting to camera" << std::endl;
mCamera = ProCamera::connect(CAMERA_ID);
} else if (stat == ServiceListener::STATUS_NOT_AVAILABLE) {
dout << "Disconnecting from camera" << std::endl;
mCamera->disconnect();
+ } else if (stat == ServiceListener::STATUS_NOT_PRESENT) {
+ dout << "Camera unplugged" << std::endl;
+ mCamera = NULL;
} else {
dout << "Unknown status change "
<< std::hex << stat << std::endl;
@@ -1216,7 +1224,7 @@ TEST_F(ProCameraTest, ServiceListenersFunctional) {
}
EXPECT_OK(listener->waitForStatusChange(/*out*/stat));
- EXPECT_EQ(ServiceListener::STATUS_AVAILABLE, stat);
+ EXPECT_EQ(ServiceListener::STATUS_PRESENT, stat);
EXPECT_OK(ProCamera::removeServiceListener(listener));
}