FileDocCategorySizeDatePackage
CameraTestHelper.javaAPI DocAndroid 5.1 API5668Thu Mar 12 22:22:30 GMT 2015com.android.mediaframeworktest

CameraTestHelper

public class CameraTestHelper extends Object

Fields Summary
public android.hardware.Camera
mCamera
private String
TAG
private static final int
CAMERA_ID
private static final long
WAIT_GENERIC
private static final long
WAIT_ZOOM_ANIMATION
protected static final String
CAMERA_STRESS_IMAGES_DIRECTORY
private static final String
CAMERA_STRESS_IMAGES_PREFIX
private final CameraErrorCallback
mCameraErrorCallback
private android.hardware.Camera.ShutterCallback
shutterCallback
private android.hardware.Camera.PictureCallback
rawCallback
private android.hardware.Camera.PictureCallback
jpegCallback
Constructors Summary
Methods Summary
public voidcapturePhoto()
Helper method for taking a photo

        mCamera.takePicture(shutterCallback, rawCallback, jpegCallback);
        Thread.sleep(WAIT_GENERIC);
        mCamera.stopPreview();
        mCamera.release();
    
public voidcleanupTestImages()
Helper method for cleaning up pics taken during tests

        try {
            File stressImagesDirectory = new File(String.format("%s/%s",
                    Environment.getExternalStorageDirectory(), CAMERA_STRESS_IMAGES_DIRECTORY));
            File[] stressImages = stressImagesDirectory.listFiles();
            for (File f : stressImages) {
                f.delete();
            }
        } catch (SecurityException e) {
            Log.e(TAG, "Security manager access violation: " + e.toString());
        }
    
public android.hardware.Camera.ParametersgetCameraParameters()
Helper method for getting the available parameters of the default camera

        mCamera = Camera.open(CAMERA_ID);
        Parameters params = mCamera.getParameters();
        mCamera.release();
        return params;
    
public voidsetParameters(android.hardware.Camera.Parameters params)
Helper method for setting the camera parameters

        try {
            mCamera.setParameters(params);
        } catch (Exception e) {
            Log.e(TAG, "Error setting camera parameters");
        }
    
public voidsetupCameraTest()
Helper method for prepping test


              
       
        // Create the test images directory if it doesn't exist
        File stressImagesDirectory = new File(String.format("%s/%s",
                Environment.getExternalStorageDirectory(), CAMERA_STRESS_IMAGES_DIRECTORY));
        if (!stressImagesDirectory.exists()) {
            stressImagesDirectory.mkdir();
        }

        mCamera = Camera.open(CAMERA_ID);
    
public voidstartCameraPreview(android.view.SurfaceHolder surfaceHolder)
Helper method for starting up the camera preview

        mCamera.setErrorCallback(mCameraErrorCallback);
        mCamera.setPreviewDisplay(surfaceHolder);
        mCamera.startPreview();
        Thread.sleep(WAIT_GENERIC);