Hi,
I have a problem with a simple application that captures images from
the camera. It works on the emulator, but throws an exception when I
run it on the HTC Desire.
Here are the relevant log messages:
W/CameraSwitch( 3801): open main camera
W/CameraSwitch( 3801): no file - can't switch camera
E/CameraSwitch( 3801): setSwitchFile failed: /sys/android_camera2/
htcwc
E/CameraSwitch( 3801): java.io.FileNotFoundException: /sys/
android_camera2/htcwc
E/CameraSwitch( 3801): at
org.apache.harmony.luni.platform.OSFileSystem.open(OS
FileSystem.java:244)
E/CameraSwitch( 3801): at
java.io.FileOutputStream.<init>(FileOutputStream.java
:97)
E/CameraSwitch( 3801): at java.io.FileWriter.<init>(FileWriter.java:
58)
E/CameraSwitch( 3801): at
android.hardware.CameraSwitch.setSwitchFile(CameraSwi
tch.java:44)
E/CameraSwitch( 3801): at
android.hardware.CameraSwitch.openMainCamera(CameraSw
itch.java:22)
E/CameraSwitch( 3801): at android.hardware.Camera.open(Camera.java:
90)
E/CameraSwitch( 3801): at
be.uhasselt.edm.research.sherlock.CameraPreview.surfa
ceCreated(SherlockActivity.java:51)
E/CameraSwitch( 3801): at
android.view.SurfaceView.updateWindow(SurfaceView.jav
a:454)
E/CameraSwitch( 3801): at
android.view.SurfaceView.dispatchDraw(SurfaceView.jav
a:287)
E/CameraSwitch( 3801): at
android.view.ViewGroup.drawChild(ViewGroup.java:1583)
E/CameraSwitch( 3801): at
android.view.ViewGroup.dispatchDraw(ViewGroup.java:13
12)
E/CameraSwitch( 3801): at android.view.View.draw(View.java:6538)
E/CameraSwitch( 3801): at
android.widget.FrameLayout.draw(FrameLayout.java:352)
E/CameraSwitch( 3801): at
android.view.ViewGroup.drawChild(ViewGroup.java:1585)
E/CameraSwitch( 3801): at
android.view.ViewGroup.dispatchDraw(ViewGroup.java:13
12)
E/CameraSwitch( 3801): at android.view.View.draw(View.java:6538)
E/CameraSwitch( 3801): at
android.widget.FrameLayout.draw(FrameLayout.java:352)
E/CameraSwitch( 3801): at com.android.internal.policy.impl.PhoneWindow
$DecorVie
w.draw(PhoneWindow.java:1866)
E/CameraSwitch( 3801): at android.view.ViewRoot.draw(ViewRoot.java:
1364)
E/CameraSwitch( 3801): at
android.view.ViewRoot.performTraversals(ViewRoot.java
:1118)
E/CameraSwitch( 3801): at
android.view.ViewRoot.handleMessage(ViewRoot.java:165
0)
E/CameraSwitch( 3801): at
android.os.Handler.dispatchMessage(Handler.java:99)
E/CameraSwitch( 3801): at android.os.Looper.loop(Looper.java:123)
E/CameraSwitch( 3801): at
android.app.ActivityThread.main(ActivityThread.java:4
595)
E/CameraSwitch( 3801): at
java.lang.reflect.Method.invokeNative(Native Method)
E/CameraSwitch( 3801): at java.lang.reflect.Method.invoke(Method.java:
521)
E/CameraSwitch( 3801): at com.android.internal.os.ZygoteInit
$MethodAndArgsCalle
r.run(ZygoteInit.java:860)
E/CameraSwitch( 3801): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.ja
va:618)
E/CameraSwitch( 3801): at dalvik.system.NativeStart.main(Native
Method)
D/CameraService( 57): CameraService::connect E (pid 3801, client
0x267f0)
D/CameraService( 57): Client::Client E (pid 3801)
V/QualcommCameraHardware( 57): openCameraHardware: call
createInstance
D/QualcommCameraHardware( 57): createInstance: E
V/QualcommCameraHardware( 57): constructor EX
V/QualcommCameraHardware( 57): startCamera E
V/QualcommCameraHardware( 57): loading liboemcamera at 0xb00140d0
I/QualcommCameraHardware( 57): Set main cam and main cam only
I/mm-camera-mmap( 57): set sensor selection :0
I/QualcommCameraHardware( 57): Open Device node : /dev/msm_camera/
control0
I/mm-camera-config( 57): cam_conf fd cfgctrl.camfd:0
I/mm-camera-config( 57): Open config device node : /dev/msm_camera/
config0
I/ ( 57): [AWB Calibration]:ctrlfd:26
I/ ( 57): [AWB Calibration] cfg.fuse_id_word1:0x0
I/ ( 57): [AWB Calibration] cfg.fuse_id_word2:0x0
I/ ( 57): [AWB Calibration] cfg.fuse_id_word3:0x45002
I/ ( 57): [AWB Calibration] cfg.fuse_id_word4:0x22e645
I/ ( 57): [AWB Calibration] rg_ratio_GS_table[0]:0.733340
I/ ( 57): [AWB Calibration] rg_ratio_GS_table[1]:0.733340
I/ ( 57): [AWB Calibration] rg_ratio_GS_table[2]:0.754883
I/ ( 57): [AWB Calibration] bg_ratio_GS_table[0]:0.601600
I/ ( 57): [AWB Calibration] bg_ratio_GS_table[1]:0.601600
I/ ( 57): [AWB Calibration] bg_ratio_GS_table[2]:0.598633
I/ ( 57): [AWB Calibration] sfuse.fuse_id_word1:0x0
I/ ( 57): [AWB Calibration] sfuse.fuse_id_word2:0x0
I/ ( 57): [AWB Calibration] sfuse.fuse_id_word3:0x45002
I/ ( 57): [AWB Calibration] sfuse.fuse_id_word4:0x22e645
I/ ( 57): [AWB Calibration] fuse_id : 0x0, 0x0, 0x45002,
0x22e645
I/ ( 57): [AWB Calibration] fail to read /data/awb_cal
I/ ( 57): [AWB Calibration] read from file OK: /sys/
android_camera_awb_
cal/awb_ca
I/ ( 57): [AWB Calibration] read all c1b ,ok=1
I/ ( 57): [AWB Calibration] read all 323 ,ok=1
I/ ( 57): [AWB Calibration] read all 230 ,ok=1
I/ ( 57): [AWB Calibration] read all 0 ,ok=1
I/ ( 57): [AWB Calibration] read all 0 ,ok=1
I/ ( 57): [AWB Calibration] read all 45002 ,ok=1
I/ ( 57): [AWB Calibration] read all 22e645 ,ok=1
I/ ( 57): [AWB Calibration] read all b538fe81 ,ok=1
I/ ( 57): [AWB Calibration] check sum=b538fe81, OK
I/ ( 57): [AWB Calibration] caBuff[0]:0x00000c1b
I/ ( 57): [AWB Calibration] caBuff[1]:0x00000323
I/ ( 57): [AWB Calibration] caBuff[2]:0x00000230
I/ ( 57): [AWB Calibration] caBuff[3]:0x00000000
I/ ( 57): [AWB Calibration] caBuff[4]:0x00000000
I/ ( 57): [AWB Calibration] caBuff[5]:0x00045002
I/ ( 57): [AWB Calibration] caBuff[6]:0x0022e645
I/ ( 57): [AWB Calibration] caBuff[7]:0xb538fe81
I/ ( 57): [AWB Calibration] fuse_id_word1:0x00000000
I/ ( 57): [AWB Calibration] fuse_id_word2:0x00000000
I/ ( 57): [AWB Calibration] fuse_id_word3:0x00045002
I/ ( 57): [AWB Calibration] fuse_id_word4:0x0022e645
I/ ( 57): [AWB Calibration] caBuff[0]:3099
I/ ( 57): [AWB Calibration] valid bit and fuseID pass, use
new white po
ints
I/ ( 57): [AWB Calibration] use light version: v3
I/mm-camera-aec( 57): Touch AEC == numRegions:256
I/mm-camera-aec( 57): Touch AEC aecCtrl->aec_state.aec_algo:1
I/QualcommCameraHardware( 57): startCamera: camsensor name s5k3e2fx,
flash 1
V/QualcommCameraHardware( 57): startCamera X
V/QualcommCameraHardware( 57): initDefaultParameters E
V/QualcommCameraHardware( 57): setParameters: E params = 0x4af24
V/QualcommCameraHardware( 57): requested preview size 720 x 480
V/QualcommCameraHardware( 57): requested picture size 1024 x 768
V/QualcommCameraHardware( 57): native_set_parm: fd 12, type 21,
length 4
V/QualcommCameraHardware( 57): native_set_parm: fd 12, type 15,
length 4
V/QualcommCameraHardware( 57): native_set_parm: fd 12, type 14,
length 4
V/QualcommCameraHardware( 57): native_set_parm: fd 12, type 49,
length 4
I/QualcommCameraHardware( 57): Setting Zoom is 0
V/QualcommCameraHardware( 57): native_set_parm: fd 12, type 2,
length 4
I/QualcommCameraHardware( 57): Setting Contrast is 5
V/QualcommCameraHardware( 57): native_set_parm: fd 12, type 6,
length 4
I/QualcommCameraHardware( 57): Setting Brightness is 3
V/QualcommCameraHardware( 57): native_set_parm: fd 12, type 7,
length 4
I/QualcommCameraHardware( 57): Setting Saturation is 5
V/QualcommCameraHardware( 57): native_set_parm: fd 12, type 11,
length 4
I/QualcommCameraHardware( 57): Setting Sharpness is 10
V/QualcommCameraHardware( 57): native_set_parm: fd 12, type 9,
length 4
V/QualcommCameraHardware( 57): native_set_parm: fd 12, type 12,
length 4
I/mm-camera-ctrlcmd( 57): md.d.aec_mode.aec_mode:1
I/mm-camera-aec( 57): Touch AEC == numRegions:256
I/mm-camera-aec( 57): Touch AEC aecCtrl->aec_state.aec_algo:1
D/QualcommCameraHardware( 57): not defined touch-focus yet, or AP
without touc
h-focus function
I/QualcommCameraHardware( 57): Before Setting coordinate x:360 y:240
I/QualcommCameraHardware( 57): Setting coordinate x:2 y:2
V/QualcommCameraHardware( 57): native_set_parm: fd 12, type 55,
length 28
I/mm-camera 8x vfe( 57): vfe_set_coordinate x:2 y:2
V/QualcommCameraHardware( 57): native_set_parm: fd 12, type 26,
length 4
D/mm-camera-ctrlcmd( 57): md.d.aec_iso_mode = 0
V/QualcommCameraHardware( 57): native_set_parm: fd 12, type 57,
length 4
D/QualcommCameraHardware( 57): virtual android::status_t
android::QualcommCame
raHardware::setParameters(const android::CameraParameters&),
final_rc=0
V/QualcommCameraHardware( 57): setParameters: X
V/QualcommCameraHardware( 57): initDefaultParameters X
D/QualcommCameraHardware( 57): createInstance: X created
hardware=0x4af20
D/CameraService( 57): Client::Client X (pid 3801)
D/CameraService( 57): CameraService::connect X
D/CameraService( 57): setPreviewDisplay(0x58418) (pid 3801)
I/CameraService( 57): OLAWORK
getParameters(antibanding=auto;antibanding-value
s=off,50hz,60hz,auto;brightness=3;brightness-def=3;brightness-
max=6;brightness-m
in=0;contrast=5;contrast-def=5;contrast-max=10;contrast-
min=0;effect=none;effect
-values=none,mono,negative,solarize,sepia,posterize,aqua;flash-
mode=off;flash-mo
de-values=off,auto,on;focus-mode=auto;focus-mode-
values=auto,infinity;iso=auto;i
so-values=auto,deblur,100,200,400,800,1250;jpeg-quality=100;jpeg-
thumbnail-heigh
t=384;jpeg-thumbnail-quality=90;jpeg-thumbnail-width=512;max-
zoom=5;meter-mode=m
eter-center;meter-mode-values=meter-average,meter-center,meter-
spot;picture-form
at=jpeg;picture-format-values=jpeg;picture-size=1024x768;picture-size-
values=259
2x1952,2592x1728,2592x1552,2560x1920,2560x1712,2048x1536,2048x1360,2048x1216,201
6x1344,1600x1200,1584x1056,1280x960,1280x848,1280x768,1248x832,1024x768,640x480,
640x416,640x384,624x416,512x384,400x400,272x272;preview-
format=yuv420sp;preview-
format-values=yuv420sp;preview-frame-rate=15;preview-
size=720x480;preview-size-v
alues=1
D/CameraService( 57): setParameters(sharpness-max=30;zoom=0;taking-
picture-zoo
m=0;zoom-supported=true;sharpness-
min=0;sharpness=10;contrast=5;whitebalance=aut
o;jpeg-quality=100;preview-format-values=yuv420sp;jpeg-thumbnail-
quality=90;prev
iew-format=yuv420sp;preview-size=320x508;iso=auto;meter-mode=meter-
center;flash-
mode-values=off,auto,on;preview-frame-rate=15;focus-mode-
values=auto,infinity;jp
eg-thumbnail-width=512;saturation-def=5;preview-size-
values=1280x720,800x480,720
x480,640x480,576x432,480x320,400x240,384x288,352x288,320x240,272x272,240x240,240
x160,176x144;smart-contrast=off;picture-size-
values=2592x1952,2592x1728,2592x155
2,2560x1920,2560x1712,2048x1536,2048x1360,2048x1216,2016x1344,1600x1200,1584x105
6,1280x960,1280x848,1280x768,1248x832,1024x768,640x480,640x416,640x384,624x416,5
12x384,400x400,272x272;contrast-min=0;brightness-
min=0;antibanding=auto;taking-p
icture-zoom-min=0;saturation-min=1;contrast-max=10;taking-picture-zoom-
max=20;co
ntrast-def=5;brightness-max=6;brightness=3;jpeg-thumbnail-
height=384;focus-mode=
auto;sh
V/QualcommCameraHardware( 57): setParameters: E params = 0x40a60d08
V/QualcommCameraHardware( 57): requested preview size 320 x 508
E/QualcommCameraHardware( 57): Invalid preview size requested:
320x508
E/QualcommCameraHardware( 57): virtual android::status_t
android::QualcommCame
raHardware::setParameters(const android::CameraParameters&): 2109, rc
= -22
V/QualcommCameraHardware( 57): requested picture size 1024 x 768
V/QualcommCameraHardware( 57): native_set_parm: fd 12, type 21,
length 4
V/QualcommCameraHardware( 57): native_set_parm: fd 12, type 15,
length 4
V/QualcommCameraHardware( 57): native_set_parm: fd 12, type 14,
length 4
V/QualcommCameraHardware( 57): native_set_parm: fd 12, type 49,
length 4
I/QualcommCameraHardware( 57): Setting Zoom is 0
V/QualcommCameraHardware( 57): native_set_parm: fd 12, type 2,
length 4
I/QualcommCameraHardware( 57): Setting Contrast is 5
V/QualcommCameraHardware( 57): native_set_parm: fd 12, type 6,
length 4
I/QualcommCameraHardware( 57): Setting Brightness is 3
V/QualcommCameraHardware( 57): native_set_parm: fd 12, type 7,
length 4
I/QualcommCameraHardware( 57): Setting Saturation is 5
V/QualcommCameraHardware( 57): native_set_parm: fd 12, type 11,
length 4
I/QualcommCameraHardware( 57): Setting Sharpness is 10
V/QualcommCameraHardware( 57): native_set_parm: fd 12, type 9,
length 4
V/QualcommCameraHardware( 57): native_set_parm: fd 12, type 12,
length 4
I/mm-camera-ctrlcmd( 57): md.d.aec_mode.aec_mode:1
I/mm-camera-aec( 57): Touch AEC == numRegions:256
I/mm-camera-aec( 57): Touch AEC aecCtrl->aec_state.aec_algo:1
D/QualcommCameraHardware( 57): not defined touch-focus yet, or AP
without touc
h-focus function
I/QualcommCameraHardware( 57): Before Setting coordinate x:360 y:240
I/QualcommCameraHardware( 57): Setting coordinate x:2 y:2
V/QualcommCameraHardware( 57): native_set_parm: fd 12, type 55,
length 28
I/mm-camera 8x vfe( 57): vfe_set_coordinate x:2 y:2
V/QualcommCameraHardware( 57): native_set_parm: fd 12, type 26,
length 4
D/mm-camera-ctrlcmd( 57): md.d.aec_iso_mode = 0
V/QualcommCameraHardware( 57): native_set_parm: fd 12, type 57,
length 4
D/QualcommCameraHardware( 57): virtual android::status_t
android::QualcommCame
raHardware::setParameters(const android::CameraParameters&),
final_rc=-22
V/QualcommCameraHardware( 57): setParameters: X
D/dalvikvm( 377): GC freed 189 objects / 9440 bytes in 87ms
I/WindowManager( 75): Setting rotation to 1, animFlags=0
I/ActivityManager( 75): Config changed: { scale=1.0 imsi=0/0
loc=en_NL touch=3
keys=1/1/2 nav=3/1 orien=2 layout=34}
D/PhoneApp( 153): updateProximitySensorMode: state = IDLE
D/PhoneApp( 153): updateProximitySensorMode: lock already released.
D/BackupManagerService( 75): Now awaiting backup for 1 participants:
D/BackupManagerService( 75): +
BackupRequest{app=ApplicationInfo{46678b88
com.android.providers.settings} full=false}
agent=com.android.providers.settings
.SettingsBackupAgent
I/CalendarProvider( 258): updateCalendarNameByLocale
I/CalendarProvider( 258): updateCalendarNameByLocale
I/CalendarProvider( 258): update locale:NLD
I/CalendarProvider( 258): Locale doesn't change, so return it
And this is my code:
public class SherlockActivity extends Activity {
private CameraPreview _preview;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Hide the window title.
requestWindowFeature(Window.FEATURE_NO_TITLE);
// create our preview view and set it as the content of the
activity.
_preview = new CameraPreview(this);
setContentView(_preview);
}
}
class CameraPreview extends SurfaceView implements
SurfaceHolder.Callback {
SurfaceHolder _holder;
Camera _camera;
CameraPreview(Context context) {
super(context);
// Install a SurfaceHolder.Callback so we get notified when
// the underlying surface is created and destroyed.
_holder = getHolder();
_holder.addCallback(this);
_holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
public void surfaceCreated(SurfaceHolder holder) {
// The Surface has been created, acquire the camera and
// tell it where to draw.
_camera = Camera.open();
try {
_camera.setPreviewDisplay(holder);
} catch (IOException exception) {
_camera.release();
_camera = null;
// TODO: more exception handling logic
}
}
public void surfaceDestroyed(SurfaceHolder holder) {
// Surface will be destroyed when we return, so stop the
preview.
// Because the CameraDevice object is not a shared resource,
it's
very
// important to release it when the activity is paused.
_camera.stopPreview();
_camera.release();
_camera = null;
}
public void surfaceChanged(SurfaceHolder holder, int format, int w,
int h) {
// Now that the size is known, set up the camera parameters and
begin
// the preview.
Camera.Parameters parameters = _camera.getParameters();
parameters.setPreviewSize(w, h);
_camera.setParameters(parameters);
_camera.startPreview();
}
}
I have used the correct <uses-permission> and <uses-feature> tags in
my manifest file:
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
Thanks in advance!
Cheers,
-- Jo
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en