O1--添加假对焦功能并支持对焦

修改内容:
vendor\mediatek\proprietary\packages\apps\Camera\src\com\android\camera\CameraActivity.java
只需要更改此文件下面代码部分

public void onSingleTapUp(View view, int x, int y) {
        //@tony add start:{
        FocusManager focusManager = mCameraDeviceCtrl.getFocusManager();
        if(focusManager != null){
            Log.i(TAG,"focusManager.onSingleTapUp...");
            focusManager.onSingleTapUp(x, y);  
              /* 去除下面一段,则只有假对焦效果,无变焦效果 */
            mCameraDeviceCtrl.getCameraDevice().setParametersAsync(getParameters(),1);  //control zoom
        }
        //@tony add end:}
        if (FeatureSwitcher.isApi2Enable(this)) {
            return;
        }
    ...
}

vendor\mediatek\proprietary\packages\apps\Camera\src\com\android\camera\FocusManager.java
需要更改此文件的4个代码部分
001

    private static final int STATE_FOCUSING_SNAP_ON_FINISH = 2;
    private static final int STATE_SUCCESS = 3; // Focus finishes and succeeds.
    private static final int STATE_FAIL = 4; // Focus finishes and fails.

    //@tony add start:{
    private static final int MSG_SHOW_FOCUS_END = 5;    
    private static final int MSG_SHOW_FOCUS_END_DELAY = 600;    
    private static final int RESET_TOUCH_FOCUS_DELAY = 3000;
    //@tony add end:}

    private boolean mInitialized;
    private boolean mFocusAreaSupported;
    private boolean mLockAeAwbNeeded;
    private boolean mLockAeNeeded = true;

002

public void handleMessage(Message msg) {
            Log.d(TAG, "[handleMessage] msg .what = " + msg.what);

            switch (msg.what) {
            case RESET_TOUCH_FOCUS:
                cancelAutoFocus();
                break;
            case RESET_FACE_BEAUTY_TOUCH_POSITION:
                resetFaceBeautyTouchPosition();
                break;
            case RESET_MULTIAF_FOCUS:
                if (mMultiZoneAfView != null) {
                    mMultiZoneAfView.clear();
                }
                break;
            //@tony add start:{
            case MSG_SHOW_FOCUS_END:
                mFocusIndicatorRotateLayout.showSuccess(true);
                mListener.playSound(MediaActionSound.FOCUS_COMPLETE);
                 /* 去除下面一段,则只有假对焦效果,无变焦效果 */
                mContext.getCameraDevice().setParametersAsync(mParameters, 0);  //control zoom
                break;
            //@tony add end:}
            default:
                break;
            }
        }  

003

 public void onSingleTapUp(int x, int y) {
        Log.d(TAG, "onSingleTapUp x = " + x + " y = " + y);

        // when devices support both continuous and infinity focus mode.
        String focusMode = getCurrentFocusMode(mContext);
        if (focusMode == null || Parameters.FOCUS_MODE_INFINITY.equals(focusMode)) {
            Log.w(TAG, "[onSingleTapUp]focusMode:" + focusMode);
            return;
        }
        // Check if metering area or focus area is supported.
        //@tony del start:{
        /* if (!mFocusAreaSupported) {
            Log.i(TAG, "[onSingleTapUp] mFocusAreaSupported is false");
            return;
        } */
        //@tony del end:}
        if (!mInitialized || mState == STATE_FOCUSING_SNAP_ON_FINISH || mState == STATE_UNKNOWN) {
            return;
        }
        ...
    }

004

  public void onSingleTapUp(int x, int y) {
    ...
    // Set the focus area and metering area.
        mListener.setFocusParameters();

        //@tony modify start:{
        //autoFocus();

        Log.d(TAG, "ydw, add if-else flow.");
        if (mFocusAreaSupported) {
            autoFocus();
        } else { // Just show the indicator in all other cases.
            updateFocusUI();
            // Reset the metering area in 3 seconds.
            mHandler.removeMessages(RESET_TOUCH_FOCUS);
            mHandler.sendEmptyMessageDelayed(RESET_TOUCH_FOCUS, RESET_TOUCH_FOCUS_DELAY);
            mHandler.removeMessages(MSG_SHOW_FOCUS_END);
            mHandler.sendEmptyMessageDelayed(MSG_SHOW_FOCUS_END, MSG_SHOW_FOCUS_END_DELAY); 
        }
        //@tony modify end:}
    }

你可能感兴趣的:(android)