use of android.view.SurfaceHolder in project platform_frameworks_base by android.
the class RSSurfaceView method init.
private void init() {
// Install a SurfaceHolder.Callback so we get notified when the
// underlying surface is created and destroyed
SurfaceHolder holder = getHolder();
holder.addCallback(this);
}
use of android.view.SurfaceHolder in project platform_frameworks_base by android.
the class CameraFunctionalTest method testFunctionalCameraExposureCompensation.
/**
* Functional test iterating on the range of supported exposure compensation levels
*/
@LargeTest
public void testFunctionalCameraExposureCompensation() throws Exception {
try {
SurfaceHolder surfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
Parameters params = mCameraTestHelper.getCameraParameters();
int min = params.getMinExposureCompensation();
int max = params.getMaxExposureCompensation();
assertFalse("Adjusting exposure not supported", (max == 0 && min == 0));
float step = params.getExposureCompensationStep();
int stepsPerEV = (int) Math.round(Math.pow((double) step, -1));
// only get integer values for exposure compensation
for (int i = min; i <= max; i += stepsPerEV) {
runOnLooper(new Runnable() {
@Override
public void run() {
mCameraTestHelper.setupCameraTest();
}
});
Log.v(TAG, "Setting exposure compensation index to " + i);
params.setExposureCompensation(i);
mCameraTestHelper.setParameters(params);
mCameraTestHelper.startCameraPreview(surfaceHolder);
mCameraTestHelper.capturePhoto();
}
mCameraTestHelper.cleanupTestImages();
} catch (Exception e) {
Log.e(TAG, e.toString());
fail("Camera exposure compensation test Exception");
}
}
use of android.view.SurfaceHolder in project platform_frameworks_base by android.
the class CameraFunctionalTest method testFunctionalCameraWhiteBalance.
/**
* Functional test iterating on the various white balances (auto, daylight, cloudy, etc.)
*/
@LargeTest
public void testFunctionalCameraWhiteBalance() throws Exception {
try {
SurfaceHolder surfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
Parameters params = mCameraTestHelper.getCameraParameters();
List<String> supportedWhiteBalance = params.getSupportedWhiteBalance();
assertNotNull("No white balance modes supported", supportedWhiteBalance);
for (int i = 0; i < supportedWhiteBalance.size(); i++) {
runOnLooper(new Runnable() {
@Override
public void run() {
mCameraTestHelper.setupCameraTest();
}
});
Log.v(TAG, "Setting white balance to: " + supportedWhiteBalance.get(i));
params.setWhiteBalance(supportedWhiteBalance.get(i));
mCameraTestHelper.setParameters(params);
mCameraTestHelper.startCameraPreview(surfaceHolder);
mCameraTestHelper.capturePhoto();
}
mCameraTestHelper.cleanupTestImages();
} catch (Exception e) {
Log.e(TAG, e.toString());
fail("Camera focus modes test Exception");
}
}
use of android.view.SurfaceHolder in project platform_frameworks_base by android.
the class Camera2SurfaceViewTestCase method updatePreviewSurface.
/**
* Update the preview surface size.
*
* @param size The preview size to be updated.
*/
protected void updatePreviewSurface(Size size) {
if (size.equals(mPreviewSize) && mPreviewSurface != null) {
Log.w(TAG, "Skipping update preview surface size...");
return;
}
mPreviewSize = size;
Camera2SurfaceViewActivity ctsActivity = getActivity();
final SurfaceHolder holder = ctsActivity.getSurfaceView().getHolder();
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
@Override
public void run() {
holder.setFixedSize(mPreviewSize.getWidth(), mPreviewSize.getHeight());
}
});
boolean res = ctsActivity.waitForSurfaceSizeChanged(WAIT_FOR_SURFACE_CHANGE_TIMEOUT_MS, mPreviewSize.getWidth(), mPreviewSize.getHeight());
assertTrue("wait for surface change to " + mPreviewSize.toString() + " timed out", res);
mPreviewSurface = holder.getSurface();
assertNotNull("Preview surface is null", mPreviewSurface);
assertTrue("Preview surface is invalid", mPreviewSurface.isValid());
}
use of android.view.SurfaceHolder in project platform_frameworks_base by android.
the class CameraTest method checkTakePicture.
private void checkTakePicture() {
SurfaceHolder mSurfaceHolder;
try {
mSurfaceHolder = MediaFrameworkTest.mSurfaceView.getHolder();
mCamera.setPreviewDisplay(mSurfaceHolder);
Log.v(TAG, "Start preview");
mCamera.startPreview();
waitForPreviewDone();
mCamera.setPreviewCallback(null);
mCamera.takePicture(mShutterCallback, mRawPictureCallback, mJpegPictureCallback);
waitForSnapshotDone();
} catch (Exception e) {
Log.v(TAG, e.toString());
}
}
Aggregations