2011-11-8 9:51:28
修改摄像头的支持
public static Camera open() {
int numberOfCameras = getNumberOfCameras();
CameraInfo cameraInfo = new CameraInfo();
for (int i = 0; i < numberOfCameras; i++) {
getCameraInfo(i, cameraInfo);
if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) {
return new Camera(i);
}
}
return null;
}
默认打开的就是前置摄像头
Camera(int cameraId) {
mShutterCallback = null;
mRawImageCallback = null;
mJpegCallback = null;
mPreviewCallback = null;
mPostviewCallback = null;
mZoomListener = null;
Looper looper;
if ((looper = Looper.myLooper()) != null) {
mEventHandler = new EventHandler(this, looper);
} else if ((looper = Looper.getMainLooper()) != null) {
mEventHandler = new EventHandler(this, looper);
} else {
mEventHandler = null;
}
native_setup(new WeakReference<Camera>(this), cameraId);
}
为调用线程建立消息循环
int AndroidRuntime::startReg(JNIEnv* env)
注册、jni
struct fields_t {
jfieldID context;
jfieldID surface;
jfieldID facing;
jfieldID orientation;
jmethodID post_event;
};
static fields_t fields;
摄像头服务,直接调用的HAL层的接口
通过名字获取
static void GetCameraPropery(char * pFaceBackCameraName, char *pFaceFrontCameraName, int *pFaceBackOrient, int *pFaceFrontOrient)
{
char orientStr[10];
property_get (FACE_BACK_CAMERA_NAME,
pFaceBackCameraName,
DEFAULT_ERROR_NAME_str );
property_get (FACE_BACK_CAMERA_ORIENT,
orientStr,
DEFAULT_ERROR_NAME_str );
if (orientStr[0] == DEFAULT_ERROR_NAME )
*pFaceBackOrient = 0;
else
*pFaceBackOrient = atoi(orientStr);
LOGI("Face Back Camera is %s, orient is %d", pFaceBackCameraName, *pFaceBackOrient);
property_get (FACE_FRONT_CAMERA_NAME,
pFaceFrontCameraName,
DEFAULT_ERROR_NAME_str );
property_get (FACE_FRONT_CAMERA_ORIENT,
orientStr,
DEFAULT_ERROR_NAME_str );
if (orientStr[0] == DEFAULT_ERROR_NAME )
*pFaceFrontOrient = 0;
else
*pFaceFrontOrient = atoi(orientStr);
LOGI("Face Front Camera is %s, orient is %d", pFaceFrontCameraName, *pFaceFrontOrient);
}
property_get (FACE_BACK_CAMERA_NAME,
pFaceBackCameraName,
DEFAULT_ERROR_NAME_str );
property_get (FACE_BACK_CAMERA_ORIENT,
orientStr,
DEFAULT_ERROR_NAME_str );
获取后置摄像头的名字和旋转方向
if (orientStr[0] == DEFAULT_ERROR_NAME )
*pFaceBackOrient = 0;
else
*pFaceBackOrient = atoi(orientStr);
如果没有旋转方向,那么旋转方向为0
后前摄像头的数目好解决
那么摄像头的打开
#define PROP_SERVICE_NAME "property_service"
2 #define PROP_PATH_RAMDISK_DEFAULT "/default.prop"
3 #define PROP_PATH_SYSTEM_BUILD "/system/build.prop"
4 #define PROP_PATH_SYSTEM_DEFAULT "/system/default.prop"
5 #define PROP_PATH_LOCAL_OVERRIDE "/data/local.prop"
busybox的使用
service console /system/bin/sh //注释掉Android系统自带的shell
service console /data/busybox/bin/sh //使用busybox的shell
console
busybox的用法
由于freescale 已经在 /system/bin 下加入了busybox,所有只需要替换掉自带的sh
建立目录 /bin-amp ,在之下建立sh连接到 /system/bin/busybox
修改init.rc
1 将PATH 改为如下
export PATH /bin-amp:/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
替换自带的sh
2 service console /system/bin/busybox sh //使用busybox的shell
setprop back_camera_name ov
setprop back_camera_orient 0
只是设置了后置摄像头