snapcam对焦失败导致无法拍照
程序员文章站
2022-05-08 22:35:21
...
问题:相机中,连续4、5次点屏手动对焦,会出现对焦框不消失,此时无法拍照
分析:
底层对焦没有返回,导致上层卡死
方案:
添加对焦超时机制,超时后直接判定为对焦失败
Index: packages/apps/SnapdragonCamera/src/com/android/camera/PhotoModule.java
===================================================================
--- packages/apps/SnapdragonCamera/src/com/android/camera/PhotoModule.java (版本 1795)
+++ packages/apps/SnapdragonCamera/src/com/android/camera/PhotoModule.java (版本 1798)
@@ -1430,6 +1430,8 @@
public void onAutoFocus(
boolean focused, CameraProxy camera) {
if (mPaused) return;
+ Log.d(TAG, "onAutoFocus focused = " + focused + ", and remove timeout runnable!");
+ mHandler.removeCallbacks(focusTimeoutResetStateRunnable); // @ + for BUG #
mAutoFocusTime = System.currentTimeMillis() - mFocusStartTime;
Log.v(TAG, "mAutoFocusTime = " + mAutoFocusTime + "ms");
@@ -2497,6 +2499,12 @@
mFocusStartTime = System.currentTimeMillis();
mCameraDevice.autoFocus(mHandler, mAutoFocusCallback);
setCameraState(FOCUSING);
+ // @ + for BUG # {
+ if (mHandler.hasCallbacks(focusTimeoutResetStateRunnable)) {
+ mHandler.removeCallbacks(focusTimeoutResetStateRunnable);
+ }
+ mHandler.postDelayed(focusTimeoutResetStateRunnable, DELAY_TIME);
+ // @ + for BUG # }
}
@Override
@@ -2508,6 +2516,18 @@
}
}
+ // @ + for BUG # {
+ private final int DELAY_TIME = 5 * 1000; // 5s
+ Runnable focusTimeoutResetStateRunnable = new Runnable() {
+ @Override
+ public void run() {
+ Log.d(TAG, "focus timeout and reset camera state");
+ setCameraState(IDLE);
+ mFocusManager.onAutoFocus(false, false);
+ }
+ };
+ // @ + for BUG # }
+
// Preview area is touched. Handle touch focus.
@Override
public void onSingleTapUp(View view, int x, int y) {
推荐阅读
-
foxmail无法发送附件内容太大导致发送失败该怎么办?
-
Ubuntu14.04中stopping log initial device creation错误或自动挂载错误失败(导致系统无法自动启动)
-
Win10预览版14946升级失败怎么办?部分杀毒软件导致win10无法升级的解决方法
-
Win10系统更新升级安装补丁kb4019472失败导致无法安装的解决方法
-
win8系统通信端口初始化失败导致网络无法连接的解决方法图文教程
-
discuz清空session,导致session保存机制失败,session无法更新与解决
-
Ubuntu14.04中stopping log initial device creation错误或自动挂载错误失败(导致系统无法自动启动)
-
discuz清空session,导致session保存机制失败,session无法更新与解决
-
Win10预览版14946升级失败怎么办?部分杀毒软件导致win10无法升级的解决方法
-
Win10系统更新升级安装补丁kb4019472失败导致无法安装的解决方法