Firefly AIO-3399J Android7.1 打开camera失败的问题

测试中发现不停的打开关闭camera,出现camera黑屏,没有图像

然后写一个测试脚本,不停的打开关闭。

#!/system/bin/sh

i=0;

while [ i -le 10000000000000 ];

do echo $i;

i=$(($i+1));

    am start -n com.android.camera2/com.android.camera.CameraLauncher;

    sleep 5;

    input keyevent KEYCODE_BACK;

    sleep 1;

    input keyevent KEYCODE_BACK;

    sleep 1;

done

出现问题之后,内核消息出现cameraserver被killed

[ 4382.347906] init: Service 'cameraserver' (pid 280) killed by signal 11

[ 4382.348106] init: Service 'cameraserver' (pid 280) killing any children in process group

在Root权限查看lsof查看系统打开的文件,发现cameraserver一直打开/data/camera/media_profiles.xml

cameraser 31505 cameraserv  122r      REG             179,13     25574      17590 /data/camera/media_profiles.xml

cameraser 31505 cameraserv  123r      REG             179,13     25574      17590 /data/camera/media_profiles.xml

cameraser 31505 cameraserv  124r      REG             179,13     25574      17590 /data/camera/media_profiles.xml

cameraser 31505 cameraserv  125r      REG             179,13     25574      17590 /data/camera/media_profiles.xml

cameraser 31505 cameraserv  126r      REG             179,13     25574      17590 /data/camera/media_profiles.xml

初步判断应该是节点没有关闭导致camera出现问题,排查代码,确实没有关闭打开的文件


int camera_board_profiles::LoadSensor(camera_board_profiles* profiles)
{    
    char dst_file[50];
    int err = RK_RET_SUCCESS;
    int count = 0;
	int result= 0;

    LOG_FUNCTION_NAME
        
    strlcpy(dst_file, RK_DST_MEDIA_PROFILES_XML_PATH, sizeof(dst_file));
    ALOGD("read cam name from xml(%s)\n",dst_file );

    FILE* fp = fopen(dst_file, "r");//此处打开了文件,但是一直没有调用fclose关闭
    if(!fp){
        ALOGE(" is not exist, register all\n");
        goto err_end;
    }

    //read sensor name
    count = ReadDevNameFromXML(fp, profiles->mXmlDevInfo);
	profiles->xml_device_count = count;
    if(count<1){
        ALOGD("media_profiles.xml not have any camera device\n");
        goto err_end;
    }

    ALOGD("find camera count(%d) cam1(%s) cam2(%s)\n", count, profiles->mXmlDevInfo[0].camera_name,  profiles->mXmlDevInfo[1].camera_name);
    //verrify media_xml_device is supported by board xml 
    for(int i=0; (imXmlDevInfo[i].camera_name, UVC_CAM_NAME)!= 0){
        	err |= BoardFileHaveDev(profiles, (profiles->mXmlDevInfo+i));
		}
    }

    if(err != RK_RET_SUCCESS){
        goto err_end;
    }

    //register exist sensor
    for(int i=0; (imXmlDevInfo[i].camera_name, UVC_CAM_NAME)== 0){
			continue;
		}
				
        result = OpenAndRegistOneSensor(profiles->mDevieVector[profiles->mXmlDevInfo[i].index]);
		if(result != 0){
			goto err_end;
		}
       
    }

	if(profiles->mDevieVector.size()>0){
		
		return RK_RET_SUCCESS;
	}else
		return RK_RET_NOSETUP;

err_end:
    OpenAndRegistALLSensor(profiles);
    LOG_FUNCTION_NAME_EXIT
    return err;
    
}

解决方法就是调用fclose(fp)关闭已经打开的节点。

你可能感兴趣的:(RK3399)