FileDocCategorySizeDatePackage
CameraBinderTestUtils.javaAPI DocAndroid 5.1 API3221Thu Mar 12 22:22:30 GMT 2015com.android.mediaframeworktest.integration

CameraBinderTestUtils

public class CameraBinderTestUtils extends Object

Fields Summary
private final android.hardware.ICameraService
mCameraService
private int
mGuessedNumCameras
static final String
CAMERA_SERVICE_BINDER_NAME
protected static final int
USE_CALLING_UID
protected static final int
BAD_VALUE
protected static final int
INVALID_OPERATION
protected static final int
ALREADY_EXISTS
public static final int
NO_ERROR
public static final int
EOPNOTSUPP
private final android.content.Context
mContext
Constructors Summary
public CameraBinderTestUtils(android.content.Context context)


       

        mContext = context;

        guessNumCameras();

        IBinder cameraServiceBinder = ServiceManager
                .getService(CameraBinderTestUtils.CAMERA_SERVICE_BINDER_NAME);
        assertNotNull("Camera service IBinder should not be null", cameraServiceBinder);

        this.mCameraService = ICameraService.Stub.asInterface(cameraServiceBinder);
        assertNotNull("Camera service should not be null", getCameraService());
    
Methods Summary
android.hardware.ICameraServicegetCameraService()

        return mCameraService;
    
intgetGuessedNumCameras()

        return mGuessedNumCameras;
    
private voidguessNumCameras()


        /**
         * Why do we need this? This way we have no dependency on getNumCameras
         * actually working. On most systems there are only 0, 1, or 2 cameras,
         * and this covers that 'usual case'. On other systems there might be 3+
         * cameras, but this will at least check the first 2.
         */
        this.mGuessedNumCameras = 0;

        // Front facing camera
        if (CameraBinderTestUtils.isFeatureAvailable(mContext,
                PackageManager.FEATURE_CAMERA_FRONT)) {
            this.mGuessedNumCameras = getGuessedNumCameras() + 1;
        }

        // Back facing camera
        if (CameraBinderTestUtils.isFeatureAvailable(mContext,
                PackageManager.FEATURE_CAMERA)) {
            this.mGuessedNumCameras = getGuessedNumCameras() + 1;
        }

        // Any facing camera
        if (getGuessedNumCameras() == 0
                && CameraBinderTestUtils.isFeatureAvailable(mContext,
                        PackageManager.FEATURE_CAMERA_ANY)) {
            this.mGuessedNumCameras = getGuessedNumCameras() + 1;
        }

        Log.v(CameraBinderTest.TAG, "Guessing there are at least " + getGuessedNumCameras()
                + " cameras");
    
public static final booleanisFeatureAvailable(android.content.Context context, java.lang.String feature)

        final PackageManager packageManager = context.getPackageManager();
        final FeatureInfo[] featuresList = packageManager.getSystemAvailableFeatures();
        for (FeatureInfo f : featuresList) {
            if (f.name != null && f.name.equals(feature)) {
                return true;
            }
        }

        return false;