I\'m trying to read the focus distance (distance of subject in a photo) from an Android camera. I keep getting 0 for all focus distances on my HTC Desire even when it correc
Probably its a bug in the camera driver you can only fix this if you set up you phone again, yes I know it really shitty, but I had exact the same problem too.
But i choosed to use a custom rom for my device. Atm im using Android Revolution HD 6.1.1 http://forum.xda-developers.com/showthread.php?t=840040
For your secound Question you can take out the source file for the camera app from the package you download with the rom. Probably if you change it, it will work.
Best Regards
I don't know where you can get the source for the native calls. But what about getting 0 for all the focus distances in getFocusDistances(float[]) method, you can read this issue. There you can read that this error is not the error of the device but of the Android SDK.
In Froyo, frameworks/base/core/jni/android_hardware_Camera.cpp implements native_autoFocus() by calling android_hardware_Camera_autoFocus(), which appears to bind at runtime to the device/vendor specific code.
Unfortunately, "If the camera does not support auto-focus and autoFocus is called, onAutoFocus will be called immediately with a fake value of success set to true." is a documented behavior.
I'm curious which of the functions you use requires 2.3.3, API level 10.
This is Bug 14341 - "Distances returned by Camera.Parameters.getFocusDistances() do not change on Nexus S regardless of actual focus distance".
First reported Jan 26, 2011 with the last report on Mar 18, 2014. Thus, the Bug was reported shortly before you ran into it and has not been fixed to this day. It is specifically reported against your Device.
Various comments in the report claim this Bug affects the "Nexus S", "HTC Sensation", "Galaxy S Plus", "Galaxy S II", "HTC Desire HD", "Galaxy Nexus", "Xperia Mini ST15i", "Nexus 5", "Galaxy R", and the "Galaxy Note II"; with one Comment claiming it works perfectly on the "Galaxy Nexus".
Reference: https://code.google.com/p/android/issues/detail?id=14341 .
Is this the Source Code you were looking for: https://android.googlesource.com/platform/frameworks/base/+/froyo-release/core/jni/android_hardware_Camera.cpp