diff options
32 files changed, 703 insertions, 144 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index e44f9cc94..06ad579ae 100755 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -67,6 +67,7 @@ <activity android:name="com.android.camera.PermissionsActivity" android:label="@string/app_name" + android:launchMode="singleTop" android:configChanges="orientation|screenSize|keyboardHidden" android:parentActivityName="com.android.camera.CameraActivity" > <meta-data diff --git a/res/layout/photo_module.xml b/res/layout/photo_module.xml index 2e3fb8aa0..c55433b3f 100644..100755 --- a/res/layout/photo_module.xml +++ b/res/layout/photo_module.xml @@ -108,4 +108,20 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:visibility="gone" /> + <FrameLayout + android:layout_height="match_parent" + android:layout_width="match_parent" + android:layout_gravity="bottom"> + <SeekBar + style="?android:attr/seekBarStyle" + android:id="@+id/blur_degree_bar" + android:orientation="horizontal" + android:layout_gravity="bottom" + android:paddingBottom="80dp" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginBottom="30dip" + android:layout_marginLeft="30dip" + android:layout_marginRight="30dip" /> + </FrameLayout> </merge> diff --git a/res/values/qcomarrays.xml b/res/values/qcomarrays.xml index 5a7f7a309..c11056d9f 100644..100755 --- a/res/values/qcomarrays.xml +++ b/res/values/qcomarrays.xml @@ -862,5 +862,82 @@ <item>@string/pref_camera_instant_capture_value_fast_aec</item> <item>@string/pref_camera_instant_capture_value_disable</item> </string-array> + + <string-array name="pref_camera_bokeh_mode_entries" translatable="true"> + <item>@string/pref_camera_bokeh_mode_entry_enable</item> + <item>@string/pref_camera_bokeh_mode_entry_disable</item> + </string-array> + + <string-array name="pref_camera_bokeh_mode_entry_values" translatable="false"> + <item>@string/pref_camera_bokeh_mode_entry_value_enable</item> + <item>@string/pref_camera_bokeh_mode_entry_value_disable</item> + </string-array> + + <string-array name="pref_camera_bokeh_mpo_entries" translatable="true"> + <item>@string/pref_camera_bokeh_mpo_entry_enable</item> + <item>@string/pref_camera_bokeh_mpo_entry_disable</item> + </string-array> + + <string-array name="pref_camera_bokeh_mpo_entry_values" translatable="false"> + <item>@string/pref_camera_bokeh_mpo_entry_value_enable</item> + <item>@string/pref_camera_bokeh_mpo_entry_value_disable</item> + </string-array> + + <string-array name="pref_camera_bokeh_blur_degree_entries" translatable="true"> + <item>0</item> + <item>10</item> + <item>20</item> + <item>30</item> + <item>40</item> + <item>50</item> + <item>60</item> + <item>70</item> + <item>80</item> + <item>90</item> + <item>100</item> + </string-array> + + <string-array name="pref_camera_bokeh_blur_degree_entry_values" translatable="false"> + <item>0</item> + <item>10</item> + <item>20</item> + <item>30</item> + <item>40</item> + <item>50</item> + <item>60</item> + <item>70</item> + <item>80</item> + <item>90</item> + <item>100</item> + </string-array> + <!-- Camera Preferences zoom dialog box entries --> + <string-array name="pref_camera_zoom_entries" translatable="false"> + <item>@string/pref_camera_zoom_entry_off</item> + <item>@string/pref_camera_zoom_entry_1x</item> + <item>@string/pref_camera_zoom_entry_2x</item> + <item>@string/pref_camera_zoom_entry_3x</item> + <item>@string/pref_camera_zoom_entry_4x</item> + <item>@string/pref_camera_zoom_entry_5x</item> + <item>@string/pref_camera_zoom_entry_6x</item> + <item>@string/pref_camera_zoom_entry_7x</item> + <item>@string/pref_camera_zoom_entry_8x</item> + <item>@string/pref_camera_zoom_entry_9x</item> + <item>@string/pref_camera_zoom_entry_10x</item> + </string-array> + + <string-array name="pref_camera_zoom_entryvalues" translatable="false"> + <item>@string/pref_camera_zoom_default</item> + <item>1</item> + <item>2</item> + <item>3</item> + <item>4</item> + <item>5</item> + <item>6</item> + <item>7</item> + <item>8</item> + <item>9</item> + <item>10</item> + </string-array> + </resources> diff --git a/res/values/qcomstrings.xml b/res/values/qcomstrings.xml index 3ceaf93f1..5dcd4b5cb 100644..100755 --- a/res/values/qcomstrings.xml +++ b/res/values/qcomstrings.xml @@ -1130,5 +1130,37 @@ <string name="pref_camera2_auto_hdr_default" translatable="false">disable</string> <string name="pref_camera2_auto_hdr_entry_enable" translatable="true">Enable</string> <string name="pref_camera2_auto_hdr_entry_disable" translatable="true">Disable</string> + + <string name="pref_camera_bokeh_mode_default" translatable="false">0</string> + <string name="pref_camera_bokeh_mode_title" translatable="true">Bokeh Mode</string> + <string name="pref_camera_bokeh_mode_entry_enable" translatable="true">Enable</string> + <string name="pref_camera_bokeh_mode_entry_disable" translatable="true">Disable</string> + <string name="pref_camera_bokeh_mode_entry_value_enable" translatable="false">1</string> + <string name="pref_camera_bokeh_mode_entry_value_disable" translatable="false">0</string> + + <string name="pref_camera_bokeh_mpo_default" translatable="false">0</string> + <string name="pref_camera_bokeh_mpo_title" translatable="true">Bokeh Mode MPO</string> + <string name="pref_camera_bokeh_mpo_entry_enable" translatable="true">Enable</string> + <string name="pref_camera_bokeh_mpo_entry_disable" translatable="true">Disable</string> + <string name="pref_camera_bokeh_mpo_entry_value_enable" translatable="false">1</string> + <string name="pref_camera_bokeh_mpo_entry_value_disable" translatable="false">0</string> + + <string name="pref_camera_bokeh_blur_degree_default" translatable="false">50</string> + <string name="pref_camera_bokeh_blur_degree_title" translatable="true">Bokeh Blur Value</string> + <!-- Default Zoom setting. --> + <string name="pref_camera_zoom_default" translatable="false">0</string> + <string name="pref_camera_zoom_title">Zoom</string> + <!-- Settings menu, Zoom choices --> + <string name="pref_camera_zoom_entry_off">Off</string> + <string name="pref_camera_zoom_entry_1x">1x</string> + <string name="pref_camera_zoom_entry_2x">2x</string> + <string name="pref_camera_zoom_entry_3x">3x</string> + <string name="pref_camera_zoom_entry_4x">4x</string> + <string name="pref_camera_zoom_entry_5x">5x</string> + <string name="pref_camera_zoom_entry_6x">6x</string> + <string name="pref_camera_zoom_entry_7x">7x</string> + <string name="pref_camera_zoom_entry_8x">8x</string> + <string name="pref_camera_zoom_entry_9x">9x</string> + <string name="pref_camera_zoom_entry_10x">10x</string> </resources> diff --git a/res/xml/camera_preferences.xml b/res/xml/camera_preferences.xml index a9540550b..dc73d10da 100644..100755 --- a/res/xml/camera_preferences.xml +++ b/res/xml/camera_preferences.xml @@ -381,9 +381,39 @@ camera:entryValues="@array/pref_camera_instant_capture_entry_values" /> <ListPreference + camera:key="pref_camera_bokeh_mode_key" + camera:defaultValue="@string/pref_camera_bokeh_mode_default" + camera:title="@string/pref_camera_bokeh_mode_title" + camera:entries="@array/pref_camera_bokeh_mode_entries" + camera:entryValues="@array/pref_camera_bokeh_mode_entry_values" /> + + <ListPreference + camera:key="pref_camera_bokeh_mpo_key" + camera:defaultValue="@string/pref_camera_bokeh_mpo_default" + camera:title="@string/pref_camera_bokeh_mpo_title" + camera:entries="@array/pref_camera_bokeh_mpo_entries" + camera:entryValues="@array/pref_camera_bokeh_mpo_entry_values" /> + + <ListPreference + camera:key="pref_camera_bokeh_blur_degree_key" + camera:defaultValue="@string/pref_camera_bokeh_blur_degree_default" + camera:title="@string/pref_camera_bokeh_blur_degree_title" + camera:entries="@array/pref_camera_bokeh_blur_degree_entries" + camera:entryValues="@array/pref_camera_bokeh_blur_degree_entry_values" /> + + + <ListPreference camera:key="pref_camera2_camera2_key" camera:defaultValue="@string/setting_off_value" camera:title="@string/pref_camera2_camera2_title" camera:entries="@array/pref_camera2_camera2_entries" camera:entryValues="@array/pref_camera2_camera2_entryvalues" /> + + <ListPreference + camera:key="pref_camera_zoom_key" + camera:defaultValue="@string/pref_camera_zoom_default" + camera:title="@string/pref_camera_zoom_title" + camera:entries="@array/pref_camera_zoom_entries" + camera:entryValues="@array/pref_camera_zoom_entryvalues" /> + </PreferenceGroup> diff --git a/res/xml/video_preferences.xml b/res/xml/video_preferences.xml index 2d9e2fbc8..3fafddda7 100644 --- a/res/xml/video_preferences.xml +++ b/res/xml/video_preferences.xml @@ -186,4 +186,10 @@ camera:title="@string/pref_camera_video_rotation_title" camera:entries="@array/pref_camera_video_rotation_entries" camera:entryValues="@array/pref_camera_video_rotation_entryvalues" /> + <ListPreference + camera:key="pref_camera_zoom_key" + camera:defaultValue="@string/pref_camera_zoom_default" + camera:title="@string/pref_camera_zoom_title" + camera:entries="@array/pref_camera_zoom_entries" + camera:entryValues="@array/pref_camera_zoom_entryvalues" /> </PreferenceGroup> diff --git a/src/com/android/camera/BestpictureActivity.java b/src/com/android/camera/BestpictureActivity.java index cf285c2eb..6eaa2a3d0 100644 --- a/src/com/android/camera/BestpictureActivity.java +++ b/src/com/android/camera/BestpictureActivity.java @@ -257,7 +257,7 @@ public class BestpictureActivity extends FragmentActivity { private void initOverFlow(View v) { View popView = getLayoutInflater().inflate(R.layout.overflow, null); - PopupWindow pop = new PopupWindow(popView, CameraUtil.dip2px(BestpictureActivity.this, 150), + final PopupWindow pop = new PopupWindow(popView, CameraUtil.dip2px(BestpictureActivity.this, 150), CameraUtil.dip2px(BestpictureActivity.this, 100), true); pop.setOutsideTouchable(true); pop.showAtLocation(v, Gravity.RIGHT | Gravity.TOP, @@ -398,7 +398,7 @@ public class BestpictureActivity extends FragmentActivity { }); } - private void initSaveDialog(int mode, int choosenCount) { + private void initSaveDialog(int mode, final int choosenCount) { BestPictureActionDialogLayout layout = getDialogLayout(mode); layout.setDialogDataControler(mDialogRoot, new BestPictureActionDialogLayout diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java index 32d499a38..046265131 100755 --- a/src/com/android/camera/CameraActivity.java +++ b/src/com/android/camera/CameraActivity.java @@ -1774,6 +1774,7 @@ public class CameraActivity extends Activity if(!mSecureCamera && (!isRequestShown || !hasCriticalPermissions())) { Log.v(TAG, "Start Request Permission"); Intent intent = new Intent(this, PermissionsActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean(CameraSettings.KEY_REQUEST_PERMISSION, true); diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java index 069fb8701..2a8122872 100644 --- a/src/com/android/camera/CameraSettings.java +++ b/src/com/android/camera/CameraSettings.java @@ -23,6 +23,7 @@ import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.content.res.Resources; import android.content.res.TypedArray; +import android.graphics.BitmapFactory; import android.hardware.Camera; import android.hardware.Camera.CameraInfo; import android.hardware.Camera.Parameters; @@ -126,6 +127,11 @@ public class CameraSettings { public static final String KEY_LONGSHOT = "pref_camera_longshot_key"; public static final String KEY_INSTANT_CAPTURE = "pref_camera_instant_capture_key"; + public static final String KEY_ZOOM = "pref_camera_zoom_key"; + + public static final String KEY_BOKEH_MODE = "pref_camera_bokeh_mode_key"; + public static final String KEY_BOKEH_MPO = "pref_camera_bokeh_mpo_key"; + public static final String KEY_BOKEH_BLUR_VALUE = "pref_camera_bokeh_blur_degree_key"; private static final String KEY_QC_SUPPORTED_AE_BRACKETING_MODES = "ae-bracket-hdr-values"; private static final String KEY_QC_SUPPORTED_AF_BRACKETING_MODES = "af-bracket-values"; @@ -241,6 +247,14 @@ public class CameraSettings { public static final String KEY_QC_SUPPORTED_MANUAL_EXPOSURE_MODES = "manual-exposure-modes"; public static final String KEY_QC_SUPPORTED_MANUAL_WB_MODES = "manual-wb-modes"; + //Bokeh + public static final String KEY_QC_IS_BOKEH_MODE_SUPPORTED = "is-bokeh-supported"; + public static final String KEY_QC_IS_BOKEH_MPO_SUPPORTED = "is-bokeh-mpo-supported"; + public static final String KEY_QC_BOKEH_MODE = "bokeh-mode"; + public static final String KEY_QC_BOKEH_MPO_MODE = "bokeh-mpo-mode"; + public static final String KEY_QC_SUPPORTED_DEGREES_OF_BLUR = "supported-blur-degrees"; + public static final String KEY_QC_BOKEH_BLUR_VALUE = "bokeh-blur-value"; + public static final String KEY_TS_MAKEUP_UILABLE = "pref_camera_tsmakeup_key"; public static final String KEY_TS_MAKEUP_PARAM = "tsmakeup"; // on/of public static final String KEY_TS_MAKEUP_PARAM_WHITEN = "tsmakeup_whiten"; // 0~100 @@ -649,6 +663,18 @@ public class CameraSettings { } + private static List<String> getSupportedZoomLevel(Parameters params) { + ArrayList<String> supported = new ArrayList<String>(); + int zoomMaxIdx = params.getMaxZoom(); + List <Integer> zoomRatios = params.getZoomRatios(); + int zoomMax = zoomRatios.get(zoomMaxIdx)/100; + + for (int zoomLevel = 0; zoomLevel <= zoomMax; zoomLevel++) { + supported.add(String.valueOf(zoomLevel)); + } + return supported; + } + private void qcomInitPreferences(PreferenceGroup group){ //Qcom Preference add here ListPreference powerMode = group.findPreference(KEY_POWER_MODE); @@ -686,6 +712,11 @@ public class CameraSettings { ListPreference manualExposure = group.findPreference(KEY_MANUAL_EXPOSURE); ListPreference manualWB = group.findPreference(KEY_MANUAL_WB); ListPreference instantCapture = group.findPreference(KEY_INSTANT_CAPTURE); + ListPreference bokehMode = group.findPreference(KEY_BOKEH_MODE); + ListPreference bokehMpo = group.findPreference(KEY_BOKEH_MPO); + ListPreference bokehBlurDegree = group.findPreference(KEY_BOKEH_BLUR_VALUE); + ListPreference zoomLevel = group.findPreference(KEY_ZOOM); + if (instantCapture != null) { if (!isInstantCaptureSupported(mParameters)) { @@ -693,6 +724,19 @@ public class CameraSettings { } } + if (bokehMode != null) { + if (!isBokehModeSupported(mParameters)) { + removePreference(group, bokehMode.getKey()); + removePreference(group, bokehBlurDegree.getKey()); + } + } + + if (bokehMpo != null) { + if (!isBokehMPOSupported(mParameters)) { + removePreference(group, bokehMpo.getKey()); + } + } + if (hdr_need_1x != null) { filterUnsupportedOptions(group, hdr_need_1x, getSupportedHDRNeed1x(mParameters)); @@ -826,6 +870,11 @@ public class CameraSettings { filterUnsupportedOptions(group, manualExposure, getSupportedManualExposureModes(mParameters)); } + + if (zoomLevel != null) { + filterUnsupportedOptions(group, + zoomLevel, getSupportedZoomLevel(mParameters)); + } } private void initPreference(PreferenceGroup group) { @@ -1027,6 +1076,10 @@ public class CameraSettings { return; } +// if (numOfCameras > 2 ) { +// numOfCameras = 2; +// } + CharSequence[] entryValues = new CharSequence[numOfCameras]; for (int i = 0; i < numOfCameras; ++i) { entryValues[i] = "" + i; @@ -1427,4 +1480,35 @@ public class CameraSettings { } return ret; } + + public static boolean isBokehModeSupported(Parameters params) { + boolean ret = false; + if (null != params) { + String val = params.get(KEY_QC_IS_BOKEH_MODE_SUPPORTED); + if ("1".equals(val)) { + ret = true; + } + } + return ret; + } + + public static boolean isBokehMPOSupported(Parameters params) { + boolean ret = false; + if (null != params) { + String val = params.get(KEY_QC_IS_BOKEH_MPO_SUPPORTED); + if ("1".equals(val)) { + ret = true; + } + } + return ret; + } + + public static List<String> getSupportedDegreesOfBlur(Parameters params) { + String str = params.get(KEY_QC_SUPPORTED_DEGREES_OF_BLUR); + if (str == null) { + return null; + } + Log.d(TAG,"getSupportedDegreesOfBlur str =" +str); + return split(str); + } } diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java index b06bd2d12..e4c162a5b 100755 --- a/src/com/android/camera/CaptureModule.java +++ b/src/com/android/camera/CaptureModule.java @@ -147,7 +147,7 @@ public class CaptureModule implements CameraModule, PhotoController, public static final int INTENT_MODE_CAPTURE_SECURE = 3; private static final int BACK_MODE = 0; private static final int FRONT_MODE = 1; - private static final int CANCEL_TOUCH_FOCUS_DELAY = 3000; + private static final int CANCEL_TOUCH_FOCUS_DELAY = 5000; private static final int OPEN_CAMERA = 0; private static final int CANCEL_TOUCH_FOCUS = 1; private static final int MAX_NUM_CAM = 3; @@ -556,17 +556,16 @@ public class CaptureModule implements CameraModule, PhotoController, updateFocusStateChange(result); Face[] faces = result.get(CaptureResult.STATISTICS_FACES); updateFaceView(faces); - - if (SettingsManager.getInstance().isHistogramSupport()) { - int[] histogramStats = result.get(CaptureModule.histogramStats); - if (histogramStats != null && mHiston) { + } + if (SettingsManager.getInstance().isHistogramSupport()) { + int[] histogramStats = result.get(CaptureModule.histogramStats); + if (histogramStats != null && mHiston) { /*The first element in the array stores max hist value . Stats data begin from second value*/ - synchronized (statsdata) { - System.arraycopy(histogramStats, 0, statsdata, 0, 1024); - } - updateGraghView(); + synchronized (statsdata) { + System.arraycopy(histogramStats, 0, statsdata, 0, 1024); } + updateGraghView(); } } processCaptureResult(result); @@ -1233,7 +1232,8 @@ public class CaptureModule implements CameraModule, PhotoController, mJpegImageData = data; } - public void showCapturedReview(final byte[] jpegData, int orientation, boolean mirror) { + public void showCapturedReview(final byte[] jpegData, final int orientation, + final boolean mirror) { mActivity.runOnUiThread(new Runnable() { @Override public void run() { @@ -1724,7 +1724,7 @@ public class CaptureModule implements CameraModule, PhotoController, ExifInterface exif = Exif.getExif(bytes); int orientation = Exif.getOrientation(exif); - if (getCameraMode() != CaptureModule.INTENT_MODE_NORMAL) { + if (mIntentMode != CaptureModule.INTENT_MODE_NORMAL) { mJpegImageData = bytes; if (!mQuickCapture) { showCapturedReview(bytes, orientation, @@ -2121,6 +2121,7 @@ public class CaptureModule implements CameraModule, PhotoController, @Override public void onPauseBeforeSuper() { + cancelTouchFocus(); mPaused = true; mToast = null; mUI.onPause(); @@ -2171,6 +2172,20 @@ public class CaptureModule implements CameraModule, PhotoController, updatePreviewSurfaceReadyState(false); } + private void cancelTouchFocus() { + if (getCameraMode() == DUAL_MODE) { + if(mState[BAYER_ID] == STATE_WAITING_TOUCH_FOCUS) { + cancelTouchFocus(BAYER_ID); + } else if (mState[MONO_ID] == STATE_WAITING_TOUCH_FOCUS) { + cancelTouchFocus(MONO_ID); + } + } else { + if (mState[getMainCameraId()] == STATE_WAITING_TOUCH_FOCUS) { + cancelTouchFocus(getMainCameraId()); + } + } + } + private ArrayList<Integer> getFrameProcFilterId() { ArrayList<Integer> filters = new ArrayList<Integer>(); @@ -3868,7 +3883,7 @@ public class CaptureModule implements CameraModule, PhotoController, private void applyHistogram(CaptureRequest.Builder request) { String value = mSettingsManager.getValue(SettingsManager.KEY_HISTOGRAM); - if (value != null && isBackCamera()) { + if (value != null ) { if (value.equals("enable")){ final byte enable = 1; request.set(CaptureModule.histMode, enable); @@ -4026,10 +4041,10 @@ public class CaptureModule implements CameraModule, PhotoController, String value = mSettingsManager.getValue(SettingsManager.KEY_ISO); if (value == null) return; if (value.equals("auto")) { - request.set(SELECT_PRIORITY, null); - request.set(ISO_EXP, null); + request.set(SELECT_PRIORITY, 0); + request.set(ISO_EXP, 0L); } else { - long intValue = Integer.parseInt(value); + long intValue = SettingsManager.KEY_ISO_INDEX.get(value); request.set(SELECT_PRIORITY, 0); request.set(ISO_EXP, intValue); } @@ -4275,6 +4290,7 @@ public class CaptureModule implements CameraModule, PhotoController, return; case SettingsManager.KEY_FLASH_MODE: case SettingsManager.KEY_SAVERAW: + case SettingsManager.KEY_HDR: if (count == 0) restartSession(false); return; case SettingsManager.KEY_SCENE_MODE: diff --git a/src/com/android/camera/CaptureUI.java b/src/com/android/camera/CaptureUI.java index 2ef89abdf..c0be9b77f 100755 --- a/src/com/android/camera/CaptureUI.java +++ b/src/com/android/camera/CaptureUI.java @@ -391,7 +391,7 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, mFaceView = (Camera2FaceView) mRootView.findViewById(R.id.face_view); mCancelButton = (ImageView) mRootView.findViewById(R.id.cancel_button); - int intentMode = mModule.getCurrentIntentMode(); + final int intentMode = mModule.getCurrentIntentMode(); if (intentMode != CaptureModule.INTENT_MODE_NORMAL) { mCameraControls.setIntentMode(intentMode); mCameraControls.setVideoMode(false); @@ -487,17 +487,31 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, protected void showCapturedImageForReview(byte[] jpegData, int orientation, boolean mirror) { mDecodeTaskForReview = new CaptureUI.DecodeImageForReview(jpegData, orientation, mirror); mDecodeTaskForReview.execute(); - mPreviewLayout.setVisibility(View.VISIBLE); - CameraUtil.fadeIn(mReviewDoneButton); - CameraUtil.fadeIn(mReviewRetakeButton); + if (getCurrentIntentMode() != CaptureModule.INTENT_MODE_NORMAL) { + if (mFilterMenuStatus == FILTER_MENU_ON) { + removeFilterMenu(false); + } + mPreviewLayout.setVisibility(View.VISIBLE); + CameraUtil.fadeIn(mReviewDoneButton); + CameraUtil.fadeIn(mReviewRetakeButton); + } } protected void showRecordVideoForReview(Bitmap preview) { - mReviewImage.setImageBitmap(preview); - mPreviewLayout.setVisibility(View.VISIBLE); - mReviewPlayButton.setVisibility(View.VISIBLE); - CameraUtil.fadeIn(mReviewDoneButton); - CameraUtil.fadeIn(mReviewRetakeButton); + if (getCurrentIntentMode() != CaptureModule.INTENT_MODE_NORMAL) { + if (mFilterMenuStatus == FILTER_MENU_ON) { + removeFilterMenu(false); + } + mReviewImage.setImageBitmap(preview); + mPreviewLayout.setVisibility(View.VISIBLE); + mReviewPlayButton.setVisibility(View.VISIBLE); + CameraUtil.fadeIn(mReviewDoneButton); + CameraUtil.fadeIn(mReviewRetakeButton); + } + } + + private int getCurrentIntentMode() { + return mModule.getCurrentIntentMode(); } private void toggleMakeup() { @@ -868,6 +882,7 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, public void hideUIwhileRecording() { mCameraControls.setVideoMode(true); + mSceneModeLabelRect.setVisibility(View.INVISIBLE); mFrontBackSwitcher.setVisibility(View.INVISIBLE); mFilterModeSwitcher.setVisibility(View.INVISIBLE); mSceneModeSwitcher.setVisibility(View.INVISIBLE); @@ -881,6 +896,7 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, public void showUIafterRecording() { mCameraControls.setVideoMode(false); + mSceneModeLabelRect.setVisibility(View.VISIBLE); mFrontBackSwitcher.setVisibility(View.VISIBLE); mFilterModeSwitcher.setVisibility(View.VISIBLE); mSceneModeSwitcher.setVisibility(View.VISIBLE); diff --git a/src/com/android/camera/PermissionsActivity.java b/src/com/android/camera/PermissionsActivity.java index e8df5c571..91699c34f 100644..100755 --- a/src/com/android/camera/PermissionsActivity.java +++ b/src/com/android/camera/PermissionsActivity.java @@ -44,11 +44,6 @@ public class PermissionsActivity extends Activity { super.onCreate(savedInstanceState); mIntent = getIntent(); mIsReturnResult = false; - } - - @Override - protected void onResume() { - super.onResume(); if (!mCriticalPermissionDenied && !mIsReturnResult) { mNumPermissionsToRequest = 0; checkPermissions(); @@ -56,7 +51,7 @@ public class PermissionsActivity extends Activity { mCriticalPermissionDenied = false; } } - + private void checkPermissions() { if (checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { diff --git a/src/com/android/camera/PhotoMenu.java b/src/com/android/camera/PhotoMenu.java index 991b4a367..eb3f4135a 100644..100755 --- a/src/com/android/camera/PhotoMenu.java +++ b/src/com/android/camera/PhotoMenu.java @@ -233,11 +233,14 @@ public class PhotoMenu extends MenuController CameraSettings.KEY_ADVANCED_FEATURES, CameraSettings.KEY_AE_BRACKET_HDR, CameraSettings.KEY_INSTANT_CAPTURE, + CameraSettings.KEY_BOKEH_MODE, + CameraSettings.KEY_BOKEH_MPO, CameraSettings.KEY_MANUAL_EXPOSURE, CameraSettings.KEY_MANUAL_WB, CameraSettings.KEY_MANUAL_FOCUS, CameraSettings.KEY_SELFIE_MIRROR, - CameraSettings.KEY_SHUTTER_SOUND + CameraSettings.KEY_SHUTTER_SOUND, + CameraSettings.KEY_ZOOM }; initSwitchItem(CameraSettings.KEY_CAMERA_ID, mFrontBackSwitcher); diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java index 3b7456f2e..afde62a7d 100644..100755 --- a/src/com/android/camera/PhotoModule.java +++ b/src/com/android/camera/PhotoModule.java @@ -231,6 +231,7 @@ public class PhotoModule private ProgressBar brightnessProgressBar; // Constant from android.hardware.Camera.Parameters private static final String KEY_PICTURE_FORMAT = "picture-format"; + private SeekBar mBlurDegreeProgressBar; private static final String KEY_QC_RAW_PICUTRE_SIZE = "raw-size"; public static final String PIXEL_FORMAT_JPEG = "jpeg"; @@ -359,6 +360,8 @@ public class PhotoModule private float[] mR = new float[16]; private int mHeading = -1; + private static final int MAX_ZOOM = 10; + private int[] mZoomIdxTbl = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; // True if all the parameters needed to start preview is ready. private boolean mCameraPreviewParamsReady = false; @@ -594,6 +597,9 @@ public class PhotoModule mSensorManager = (SensorManager)(mActivity.getSystemService(Context.SENSOR_SERVICE)); brightnessProgressBar = (ProgressBar)mRootView.findViewById(R.id.progress); + mBlurDegreeProgressBar = (SeekBar)mRootView.findViewById(R.id.blur_degree_bar); + mBlurDegreeProgressBar.setOnSeekBarChangeListener(mBlurDegreeListener); + mBlurDegreeProgressBar.setMax(100); if (brightnessProgressBar instanceof SeekBar) { SeekBar seeker = (SeekBar) brightnessProgressBar; seeker.setOnSeekBarChangeListener(mSeekListener); @@ -629,9 +635,15 @@ public class PhotoModule // Prompt the user to pick to record location for the very first run of // camera only private void locationFirstRun() { + boolean enableRecordingLocation = false; + if (mActivity.checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) + == PackageManager.PERMISSION_GRANTED) { + enableRecordingLocation = true; + } /* Do not prompt if the preference is already set, this is a secure * camera session, or the prompt has already been triggered. */ - if (RecordLocationPreference.isSet(mPreferences, CameraSettings.KEY_RECORD_LOCATION) || + if ((RecordLocationPreference.isSet( + mPreferences, CameraSettings.KEY_RECORD_LOCATION) && enableRecordingLocation) || mActivity.isSecureCamera() || mLocationPromptTriggered) { return; } @@ -647,11 +659,6 @@ public class PhotoModule /* Enable the location at the begining, always. If the user denies the permission, it will be disabled right away due to exception */ - boolean enableRecordingLocation = false; - if (mActivity.checkSelfPermission(Manifest.permission.ACCESS_COARSE_LOCATION) - == PackageManager.PERMISSION_GRANTED) { - enableRecordingLocation = true; - } enableRecordingLocation(enableRecordingLocation); } @@ -1279,13 +1286,18 @@ public class PhotoModule } } - private byte[] flipJpeg(byte[] jpegData, int orientation) { + private byte[] flipJpeg(byte[] jpegData, int orientation, int jpegOrientation) { Bitmap srcBitmap = BitmapFactory.decodeByteArray(jpegData, 0, jpegData.length); Matrix m = new Matrix(); if(orientation == 270) { m.preScale(-1, 1); } else { //if it's 90 - m.preScale(1, -1); + // Judge whether the picture or phone is horizontal screen + if (jpegOrientation == 0 || jpegOrientation == 180) { + m.preScale(-1, 1); + } else { // the picture or phone is Vertical screen + m.preScale(1, -1); + } } Bitmap dstBitmap = Bitmap.createBitmap(srcBitmap, 0, 0, srcBitmap.getWidth(), srcBitmap.getHeight(), m, false); dstBitmap.setDensity(DisplayMetrics.DENSITY_DEFAULT); @@ -1415,7 +1427,7 @@ public class PhotoModule if (selfieMirrorPref != null && selfieMirrorPref.getValue() != null && selfieMirrorPref.getValue().equalsIgnoreCase("enable")) { CameraInfo info = CameraHolder.instance().getCameraInfo()[mCameraId]; - jpegData = flipJpeg(jpegData, info.orientation); + jpegData = flipJpeg(jpegData, info.orientation, orientation); jpegData = addExifTags(jpegData, orientation); } } @@ -1554,9 +1566,27 @@ public class PhotoModule private OnSeekBarChangeListener mSeekListener = new OnSeekBarChangeListener() { public void onStartTrackingTouch(SeekBar bar) { - // no support + // no support + } + public void onProgressChanged(SeekBar bar, int progress, boolean fromtouch) { + } + public void onStopTrackingTouch(SeekBar bar) { + } + }; + + private OnSeekBarChangeListener mBlurDegreeListener = new OnSeekBarChangeListener() { + public void onStartTrackingTouch(SeekBar bar) { } public void onProgressChanged(SeekBar bar, int progress, boolean fromtouch) { + if (mPreferenceGroup != null) { + ListPreference blurValue = mPreferenceGroup.findPreference( + CameraSettings.KEY_BOKEH_BLUR_VALUE); + if (blurValue != null) { + blurValue.setValue(""+progress); + } + } + mParameters.set(CameraSettings.KEY_QC_BOKEH_BLUR_VALUE, progress); + Log.d(TAG,"seekbar bokeh degree = "+ progress); } public void onStopTrackingTouch(SeekBar bar) { } @@ -3625,7 +3655,6 @@ public class PhotoModule + mInstantCaptureSnapShot); mParameters.set(CameraSettings.KEY_QC_INSTANT_CAPTURE, instantCapture); - //Set Histogram String histogram = mPreferences.getString( CameraSettings.KEY_HISTOGRAM, @@ -3669,6 +3698,67 @@ public class PhotoModule !mFocusManager.isFocusCompleted()) { mUI.clearFocus(); } + + String bokehMode = mPreferences.getString( + CameraSettings.KEY_BOKEH_MODE, + mActivity.getString(R.string.pref_camera_bokeh_mode_default)); + String bokehMpo = mPreferences.getString( + CameraSettings.KEY_BOKEH_MPO, + mActivity.getString(R.string.pref_camera_bokeh_mpo_default)); + String bokehBlurDegree = mPreferences.getString( + CameraSettings.KEY_BOKEH_BLUR_VALUE, + mActivity.getString(R.string.pref_camera_bokeh_blur_degree_default)); + CameraSettings.getSupportedDegreesOfBlur(mParameters); + + if (!bokehMode.equals(mActivity.getString( + R.string.pref_camera_bokeh_mode_entry_value_disable))) { + if(!zsl.equals("on")) { + mParameters.setZSLMode("on"); + } + if(mParameters.getSceneMode() != Parameters.SCENE_MODE_AUTO) { + mParameters.setSceneMode(Parameters.SCENE_MODE_AUTO); + } + if(mParameters.getFlashMode() != Parameters.FLASH_MODE_OFF) { + mParameters.setFlashMode(Parameters.FLASH_MODE_OFF); + } + if(mParameters.get("long-shot").equals(mActivity.getString(R.string.setting_on_value))) { + mParameters.set("long-shot",mActivity.getString(R.string.setting_off_value)); + } + if(mManual3AEnabled != 0) { + mManual3AEnabled = 0; + } + mActivity.runOnUiThread(new Runnable() { + @Override + public void run() { + mUI.overrideSettings(CameraSettings.KEY_SCENE_MODE, + mActivity.getString(R.string.pref_camera_scenemode_default)); + mUI.overrideSettings(CameraSettings.KEY_ZSL, + mActivity.getString(R.string.pref_camera_zsl_value_on)); + mUI.overrideSettings(CameraSettings.KEY_FLASH_MODE, "off"); + mUI.overrideSettings(CameraSettings.KEY_LONGSHOT, + mActivity.getString(R.string.pref_camera_longshot_default)); + mBlurDegreeProgressBar.setVisibility(View.VISIBLE); + mBlurDegreeProgressBar.setProgress(50); + } + }); + mParameters.set(CameraSettings.KEY_QC_BOKEH_MODE, bokehMode); + mParameters.set(CameraSettings.KEY_QC_BOKEH_MPO_MODE, bokehMpo); + mParameters.set(CameraSettings.KEY_QC_BOKEH_BLUR_VALUE, bokehBlurDegree); + + } else { + mActivity.runOnUiThread(new Runnable() { + @Override + public void run() { + mUI.overrideSettings(CameraSettings.KEY_BOKEH_MPO, + mActivity.getString(R.string.pref_camera_bokeh_mpo_default)); + mUI.overrideSettings(CameraSettings.KEY_BOKEH_BLUR_VALUE, + mActivity.getString(R.string.pref_camera_bokeh_blur_degree_default)); + mBlurDegreeProgressBar.setVisibility(View.GONE); + } + }); + } + Log.v(TAG, "Bokeh Mode = " + bokehMode + " bokehMpo = " + bokehMpo + + " bokehBlurDegree = " + bokehBlurDegree); } private int estimateJpegFileSize(final Size size, final String quality) { @@ -3758,6 +3848,61 @@ public class PhotoModule mParameters.setMeteringAreas(mFocusManager.getMeteringAreas()); } } + private void setZoomMenuValue() { + String zoomMenuValue = mPreferences.getString(CameraSettings.KEY_ZOOM, + mActivity.getString(R.string.pref_camera_zoom_default)); + if (!zoomMenuValue.equals("0")) { + int zoomValue = Integer.parseInt(zoomMenuValue); + if (mZoomIdxTbl[0] == -1) { + /* update the index table once */ + Log.d(TAG, "Update the zoom index table."); + List<Integer> zoomRatios = mParameters.getZoomRatios(); + int lastZoomIdx = 0; + for (int zoom = 1; zoom <= MAX_ZOOM; zoom++) { + int zoomIdx = zoomRatios.indexOf(zoom*100); + if (zoomIdx == -1) { + Log.d(TAG, "Can't find matching zoom value "+zoom); + int nextZoom = 0; + while ((++lastZoomIdx < zoomRatios.size()) && + (nextZoom < (zoom*100))){ + nextZoom = zoomRatios.get(lastZoomIdx); + zoomIdx = lastZoomIdx; + } + if (lastZoomIdx < zoomRatios.size()) { + zoomIdx = lastZoomIdx - 1; + } else { + break; + } + } + mZoomIdxTbl[zoom-1] = zoomIdx; + lastZoomIdx = zoomIdx; + } + } + + if ((zoomValue <= mZoomIdxTbl.length) && + (mZoomIdxTbl[zoomValue-1] != -1)) { + int step = 1; + int cur_zoom = mParameters.getZoom(); + Log.d(TAG, "zoom index = "+mZoomIdxTbl[zoomValue-1]+", cur index = "+cur_zoom); + if (cur_zoom > mZoomIdxTbl[zoomValue-1]) { + step = -1; + } + + /* move zoom slowly */ + while (cur_zoom != mZoomIdxTbl[zoomValue-1]) { + cur_zoom += step; + mParameters.setZoom(cur_zoom); + try { + Thread.sleep(25); + } catch(InterruptedException e) { + } + } + mParameters.setZoom(mZoomIdxTbl[zoomValue-1]); + } else { + Log.e(TAG, "Zoom value "+zoomValue+" is not supported!"); + } + } + } /** This can run on a background thread, so don't do UI updates here.*/ private boolean updateCameraParametersPreference() { @@ -4044,6 +4189,8 @@ public class PhotoModule mParameters.set(CameraSettings.KEY_TS_MAKEUP_PARAM_CLEAN, makeupCleanValue); } + setZoomMenuValue(); + //QCom related parameters updated here. qcomUpdateCameraParametersPreference(); return doGcamModeSwitch; diff --git a/src/com/android/camera/SettingsActivity.java b/src/com/android/camera/SettingsActivity.java index 0444fc80d..00f42daa4 100644 --- a/src/com/android/camera/SettingsActivity.java +++ b/src/com/android/camera/SettingsActivity.java @@ -171,9 +171,14 @@ public class SettingsActivity extends PreferenceActivity { set.add(SettingsManager.KEY_MONO_ONLY); set.add(SettingsManager.KEY_CLEARSIGHT); - PreferenceScreen parent = getPreferenceScreen(); - PreferenceGroup developer = (PreferenceGroup)findPreference("developer"); - parent.removePreference(developer); + PreferenceGroup developer = (PreferenceGroup) findPreference("developer"); + //Before restore settings,if current is not developer mode,the developer + // preferenceGroup has been removed when enter camera by default .So duplicate remove + // it will cause crash. + if (developer != null) { + PreferenceScreen parent = getPreferenceScreen(); + parent.removePreference(developer); + } } CharSequence[] entries = mSettingsManager.getEntries(SettingsManager.KEY_SCENE_MODE); diff --git a/src/com/android/camera/SettingsManager.java b/src/com/android/camera/SettingsManager.java index 638b89fb9..d8c36b16b 100644 --- a/src/com/android/camera/SettingsManager.java +++ b/src/com/android/camera/SettingsManager.java @@ -144,6 +144,7 @@ public class SettingsManager implements ListMenu.SettingsListener { public static final String KEY_HISTOGRAM = "pref_camera2_histogram_key"; public static final String KEY_HDR = "pref_camera2_hdr_key"; public static final String KEY_SAVERAW = "pref_camera2_saveraw_key"; + public static final HashMap<String, Integer> KEY_ISO_INDEX = new HashMap<String, Integer>(); private static final String TAG = "SnapCam_SettingsManager"; @@ -169,6 +170,18 @@ public class SettingsManager implements ListMenu.SettingsListener { return mFilteredKeys; } + static { + //ISO values vendor tag + KEY_ISO_INDEX.put("auto", 0); + KEY_ISO_INDEX.put("deblur", 1); + KEY_ISO_INDEX.put("100", 2); + KEY_ISO_INDEX.put("100", 2); + KEY_ISO_INDEX.put("200", 3); + KEY_ISO_INDEX.put("400", 4); + KEY_ISO_INDEX.put("800", 5); + KEY_ISO_INDEX.put("1600", 6); + } + private SettingsManager(Context context) { mListeners = new ArrayList<>(); mCharacteristics = new ArrayList<>(); diff --git a/src/com/android/camera/VideoMenu.java b/src/com/android/camera/VideoMenu.java index f5c432a19..472630b3c 100755 --- a/src/com/android/camera/VideoMenu.java +++ b/src/com/android/camera/VideoMenu.java @@ -140,7 +140,8 @@ public class VideoMenu extends MenuController CameraSettings.KEY_VIDEO_ROTATION, CameraSettings.KEY_VIDEO_CDS_MODE, CameraSettings.KEY_VIDEO_TNR_MODE, - CameraSettings.KEY_VIDEO_SNAPSHOT_SIZE + CameraSettings.KEY_VIDEO_SNAPSHOT_SIZE, + CameraSettings.KEY_ZOOM }; initSwitchItem(CameraSettings.KEY_CAMERA_ID, mFrontBackSwitcher); } @@ -776,7 +777,13 @@ public class VideoMenu extends MenuController .getInt("persist.camcorder.eis.maxfps", 30); ListPreference hfrPref = mPreferenceGroup .findPreference(CameraSettings.KEY_VIDEO_HIGH_FRAME_RATE); - String highFrameRate = hfrPref.getValue(); + String highFrameRate; + if (hfrPref == null) { + //If hfrPref is null, use whitespace instead. + highFrameRate = " "; + } else { + highFrameRate = hfrPref.getValue(); + } boolean isHFR = "hfr".equals(highFrameRate.substring(0,3)); boolean isHSR = "hsr".equals(highFrameRate.substring(0,3)); int rate = 0; diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java index e651843be..0f5fe324a 100644 --- a/src/com/android/camera/VideoModule.java +++ b/src/com/android/camera/VideoModule.java @@ -216,6 +216,9 @@ public class VideoModule implements CameraModule, private boolean mFaceDetectionEnabled = false; private boolean mFaceDetectionStarted = false; + private static final int MAX_ZOOM = 10; + private int[] mZoomIdxTbl = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; + private static final boolean PERSIST_4K_NO_LIMIT = android.os.SystemProperties.getBoolean("persist.camcorder.4k.nolimit", false); @@ -1728,6 +1731,12 @@ public class VideoModule implements CameraModule, private void saveVideo() { if (mVideoFileDescriptor == null) { + //use the recording stop timestamp to generate the video's file name. + String videoSourcePath = mVideoFilename; + generateVideoFilename(mProfile.fileFormat); + mCurrentVideoFilename = mVideoFilename; + File sourceFile = new File(videoSourcePath); + sourceFile.renameTo(new File(mCurrentVideoFilename)); File origFile = new File(mCurrentVideoFilename); if (!origFile.exists() || origFile.length() <= 0) { Log.e(TAG, "Invalid file"); @@ -2263,11 +2272,69 @@ public class VideoModule implements CameraModule, mIsFlipEnabled = false; } } + private void setZoomMenuValue() { + String zoomMenuValue = mPreferences.getString(CameraSettings.KEY_ZOOM, + mActivity.getString(R.string.pref_camera_zoom_default)); + if (!zoomMenuValue.equals("0")) { + int zoomValue = Integer.parseInt(zoomMenuValue); + if (mZoomIdxTbl[0] == -1) { + /* update the index table once */ + Log.d(TAG, "Update the zoom index table."); + List<Integer> zoomRatios = mParameters.getZoomRatios(); + int lastZoomIdx = 0; + for (int zoom = 1; zoom <= MAX_ZOOM; zoom++) { + int zoomIdx = zoomRatios.indexOf(zoom*100); + if (zoomIdx == -1) { + Log.d(TAG, "Can't find matching zoom value "+zoom); + int nextZoom = 0; + while ((++lastZoomIdx < zoomRatios.size()) && + (nextZoom < (zoom*100))){ + nextZoom = zoomRatios.get(lastZoomIdx); + zoomIdx = lastZoomIdx; + } + if (lastZoomIdx < zoomRatios.size()) { + zoomIdx = lastZoomIdx - 1; + } else { + break; + } + } + mZoomIdxTbl[zoom-1] = zoomIdx; + lastZoomIdx = zoomIdx; + } + } + + if ((zoomValue <= mZoomIdxTbl.length) && + (mZoomIdxTbl[zoomValue-1] != -1)) { + int step = 1; + int cur_zoom = mParameters.getZoom(); + Log.d(TAG, "zoom index = "+mZoomIdxTbl[zoomValue-1]+", cur index = "+cur_zoom); + if (cur_zoom > mZoomIdxTbl[zoomValue-1]) { + step = -1; + } + + /* move zoom slowly */ + while (cur_zoom != mZoomIdxTbl[zoomValue-1]) { + cur_zoom += step; + mParameters.setZoom(cur_zoom); + try { + Thread.sleep(25); + } catch(InterruptedException e) { + } + } + + mParameters.setZoom(mZoomIdxTbl[zoomValue-1]); + } else { + Log.e(TAG, "Zoom value "+zoomValue+" is not supported!"); + } + } + } private void qcomSetCameraParameters(){ // add QCOM Parameters here // Set color effect parameter. Log.i(TAG,"NOTE: qcomSetCameraParameters " + videoWidth + " x " + videoHeight); + + setZoomMenuValue(); String colorEffect = mPreferences.getString( CameraSettings.KEY_COLOR_EFFECT, mActivity.getString(R.string.pref_camera_coloreffect_default)); diff --git a/src/com/android/camera/imageprocessor/PostProcessor.java b/src/com/android/camera/imageprocessor/PostProcessor.java index c64684f30..da8554cf8 100755..100644 --- a/src/com/android/camera/imageprocessor/PostProcessor.java +++ b/src/com/android/camera/imageprocessor/PostProcessor.java @@ -120,9 +120,12 @@ public class PostProcessor{ private int mOrientation = 0; private ImageWriter mImageWriter; - private static boolean DEBUG_FILTER = false; - private static boolean DEBUG_ZSL = false; - private ImageFilter.ResultImage mDebugResultImage; + private static boolean DEBUG_DUMP_FILTER_IMG = + (PersistUtil.getCamera2Debug() == PersistUtil.CAMERA2_DEBUG_DUMP_IMAGE) || + (PersistUtil.getCamera2Debug() == PersistUtil.CAMERA2_DEBUG_DUMP_ALL); + private static boolean DEBUG_ZSL = + (PersistUtil.getCamera2Debug() == PersistUtil.CAMERA2_DEBUG_DUMP_LOG) || + (PersistUtil.getCamera2Debug() == PersistUtil.CAMERA2_DEBUG_DUMP_ALL); private ZSLQueue mZSLQueue; private CameraDevice mCameraDevice; @@ -671,6 +674,8 @@ public class PostProcessor{ if(setFilter(postFilterId) || isFlashModeOn || isTrackingFocusOn || isMakeupOn || isSelfieMirrorOn || PersistUtil.getCameraZSLDisabled() || SettingsManager.getInstance().isCamera2HDRSupport() + || "18".equals(SettingsManager.getInstance().getValue( + SettingsManager.KEY_SCENE_MODE)) || mController.getCameraMode() == CaptureModule.DUAL_MODE) { mUseZSL = false; } else { @@ -943,14 +948,7 @@ public class PostProcessor{ } ByteBuffer yBuf = image.getPlanes()[0].getBuffer(); ByteBuffer vuBuf = image.getPlanes()[2].getBuffer(); - if(mFilter != null && DEBUG_FILTER && numImage == 0) { - mDebugResultImage = new ImageFilter.ResultImage(ByteBuffer.allocateDirect(mStride * mHeight*3/2), - new Rect(0, 0, mWidth, mHeight), mWidth, mHeight, mStride); - yBuf.get(mDebugResultImage.outBuffer.array(), 0, yBuf.remaining()); - vuBuf.get(mDebugResultImage.outBuffer.array(), mStride * mHeight, vuBuf.remaining()); - yBuf.rewind(); - vuBuf.rewind(); - } + if(mFilter == null) { mDefaultResultImage = new ImageFilter.ResultImage(ByteBuffer.allocateDirect(mStride * mHeight*3/2), new Rect(0, 0, mWidth, mHeight), mWidth, mHeight, mStride); @@ -958,8 +956,26 @@ public class PostProcessor{ vuBuf.get(mDefaultResultImage.outBuffer.array(), mStride*mHeight, vuBuf.remaining()); image.close(); } else { - mFilter.addImage(image.getPlanes()[0].getBuffer(), - image.getPlanes()[2].getBuffer(), numImage, null); + if (DEBUG_DUMP_FILTER_IMG) { + ImageFilter.ResultImage debugResultImage = new + ImageFilter.ResultImage(ByteBuffer.allocateDirect( + mStride * mHeight * 3 / 2), new Rect(0, 0, mWidth, + mHeight), mWidth, mHeight, mStride); + yBuf.get(debugResultImage.outBuffer.array(), 0, yBuf.remaining()); + vuBuf.get(debugResultImage.outBuffer.array(), mStride * mHeight, + vuBuf.remaining()); + yBuf.rewind(); + vuBuf.rewind(); + + byte[] bytes = nv21ToJpeg(debugResultImage, mOrientation, null); + mActivity.getMediaSaveService().addImage( + bytes, "Debug_beforeApplyingFilter" + numImage, 0L, null, + debugResultImage.outRoi.width(), + debugResultImage.outRoi.height(), + mOrientation, null, mController.getMediaSavedListener(), + mActivity.getContentResolver(), "jpeg"); + } + mFilter.addImage(yBuf, vuBuf, numImage, null); mImages[numImage] = image; } } @@ -1063,12 +1079,6 @@ public class PostProcessor{ ) { Log.d(TAG, "Result image is not valid."); } else { - if(mFilter != null && DEBUG_FILTER) { - bytes = nv21ToJpeg(mDebugResultImage, mOrientation, null); - mActivity.getMediaSaveService().addImage( - bytes, title + "_beforeApplyingFilter", date, null, mDebugResultImage.outRoi.width(), mDebugResultImage.outRoi.height(), - mOrientation, null, mediaSavedListener, contentResolver, "jpeg"); - } bytes = nv21ToJpeg(resultImage, mOrientation, waitForMetaData(0)); if (mController.getCurrentIntentMode() == CaptureModule.INTENT_MODE_CAPTURE) { diff --git a/src/com/android/camera/imageprocessor/ZSLQueue.java b/src/com/android/camera/imageprocessor/ZSLQueue.java index b9dea4e51..c9ecb79a2 100755..100644 --- a/src/com/android/camera/imageprocessor/ZSLQueue.java +++ b/src/com/android/camera/imageprocessor/ZSLQueue.java @@ -34,6 +34,7 @@ import android.media.Image; import android.util.Log; import com.android.camera.CaptureModule; +import com.android.camera.util.PersistUtil; import android.os.SystemProperties; import java.util.Iterator; @@ -49,8 +50,9 @@ public class ZSLQueue { private int mMetaHead; private Object mLock = new Object(); private CaptureModule mModule; - private static final boolean DEBUG = false; - private static final boolean DEBUG_QUEUE = false; + private static final boolean DEBUG_QUEUE = + (PersistUtil.getCamera2Debug() == PersistUtil.CAMERA2_DEBUG_DUMP_LOG) || + (PersistUtil.getCamera2Debug() == PersistUtil.CAMERA2_DEBUG_DUMP_ALL); private static final String TAG = "ZSLQueue"; public ZSLQueue(CaptureModule module) { diff --git a/src/com/android/camera/imageprocessor/filter/BeautificationFilter.java b/src/com/android/camera/imageprocessor/filter/BeautificationFilter.java index ec60db749..e6c597b77 100644 --- a/src/com/android/camera/imageprocessor/filter/BeautificationFilter.java +++ b/src/com/android/camera/imageprocessor/filter/BeautificationFilter.java @@ -53,7 +53,6 @@ public class BeautificationFilter implements ImageFilter { int mStrideY; int mStrideVU; private CaptureModule mModule; - private static boolean DEBUG = false; private static String TAG = "BeautificationFilter"; private static boolean mIsSupported = false; private static int FACE_TIMEOUT_VALUE = 60; //in frame count diff --git a/src/com/android/camera/imageprocessor/filter/BestpictureFilter.java b/src/com/android/camera/imageprocessor/filter/BestpictureFilter.java index e2c784f97..418bd0391 100755..100644 --- a/src/com/android/camera/imageprocessor/filter/BestpictureFilter.java +++ b/src/com/android/camera/imageprocessor/filter/BestpictureFilter.java @@ -38,8 +38,8 @@ import android.hardware.camera2.CameraCaptureSession; import android.hardware.camera2.CameraCharacteristics; import android.hardware.camera2.CaptureRequest; import android.hardware.camera2.CaptureResult; +import android.hardware.camera2.TotalCaptureResult; import android.net.Uri; -import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.util.Log; @@ -66,8 +66,7 @@ public class BestpictureFilter implements ImageFilter { private int mStrideY; private int mStrideVU; private static String TAG = "BestpictureFilter"; - private static final boolean DEBUG = false; - private static boolean mIsSupported = true; + private static boolean mIsSupported = false; private CaptureModule mModule; private CameraActivity mActivity; private int mOrientation = 0; @@ -85,6 +84,7 @@ public class BestpictureFilter implements ImageFilter { private boolean mIsOn = false; private PostProcessor mProcessor; private ProgressDialog mProgressDialog; + private ImageFilter.ResultImage mBestpictureResultImage; private static void Log(String msg) { if (DEBUG) { @@ -148,13 +148,14 @@ public class BestpictureFilter implements ImageFilter { mBY = bY; mBVU = bVU; + byte[] bytes = getYUVBytes(bY, bVU, imageNum); long captureStartTime = System.currentTimeMillis(); mNamedImages.nameNewImage(captureStartTime); PhotoModule.NamedImages.NamedEntity name = mNamedImages.getNextNameEntity(); String title = (name == null) ? null : name.title; long date = (name == null) ? -1 : name.date; mActivity.getMediaSaveService().addImage( - nv21ToJpeg(mBY, mBVU, new Rect(0, 0, mWidth, mHeight), mOrientation, 0), title, date, null, mWidth, mHeight, + bytes, title, date, null, mWidth, mHeight, mOrientation, null, new MediaSaveService.OnMediaSavedListener() { @Override public void onMediaSaved(final Uri uri) { @@ -182,8 +183,8 @@ public class BestpictureFilter implements ImageFilter { } , mActivity.getContentResolver(), "jpeg"); } - ImageSaveTask t = new ImageSaveTask(bY, bVU, new Rect(0, 0, mWidth, mHeight), mOrientation, imageNum); - t.execute(); + byte[] bytes = getYUVBytes(bY, bVU, imageNum); + saveBestPicture(bytes, imageNum); } @Override @@ -200,6 +201,26 @@ public class BestpictureFilter implements ImageFilter { }); } + private byte[] getYUVBytes(final ByteBuffer yBuf, final ByteBuffer vuBuf, + final int imageNum) { + synchronized (mClosingLock) { + if (!mIsOn) { + return null; + } + mBestpictureResultImage = new ImageFilter.ResultImage(ByteBuffer.allocateDirect( + mStrideY * mHeight * 3 / 2), + new Rect(0, 0, mWidth, mHeight), mWidth, mHeight, mStrideY); + yBuf.get(mBestpictureResultImage.outBuffer.array(), 0, yBuf.remaining()); + vuBuf.get(mBestpictureResultImage.outBuffer.array(), mStrideY * mHeight, + vuBuf.remaining()); + yBuf.rewind(); + vuBuf.rewind(); + + return nv21ToJpeg(mBestpictureResultImage, mOrientation, + mProcessor.waitForMetaData(imageNum)); + } + } + private void dismissProgressDialog() { mActivity.runOnUiThread(new Runnable() { public void run() { @@ -256,20 +277,15 @@ public class BestpictureFilter implements ImageFilter { return mIsSupported; } - private byte[] nv21ToJpeg(ByteBuffer bY, ByteBuffer bVU, Rect roi, int orientation, int imageIndex) { - ByteBuffer buf = ByteBuffer.allocate(mStrideY*mHeight*3/2); - buf.put(bY); - bY.rewind(); - if(bVU != null) { - buf.put(bVU); - bVU.rewind(); - } + private byte[] nv21ToJpeg(ImageFilter.ResultImage resultImage, int orientation, + TotalCaptureResult result) { BitmapOutputStream bos = new BitmapOutputStream(1024); - YuvImage im = new YuvImage(buf.array(), ImageFormat.NV21, - mWidth, mHeight, new int[]{mStrideY, mStrideVU}); - im.compressToJpeg(roi, mProcessor.getJpegQualityValue(), bos); + YuvImage im = new YuvImage(resultImage.outBuffer.array(), ImageFormat.NV21, + resultImage.width, resultImage.height, new int[]{resultImage.stride, + resultImage.stride}); + im.compressToJpeg(resultImage.outRoi, mProcessor.getJpegQualityValue(), bos); byte[] bytes = bos.getArray(); - bytes = PostProcessor.addExifTags(bytes, orientation, mProcessor.waitForMetaData(imageIndex)); + bytes = PostProcessor.addExifTags(bytes, orientation, result); return bytes; } @@ -283,53 +299,22 @@ public class BestpictureFilter implements ImageFilter { } } - private class ImageSaveTask extends AsyncTask<Void, Void, byte[]> { - ByteBuffer bY; - ByteBuffer bVU; - Rect roi; - int orientation; - int imageNum; - - public ImageSaveTask(ByteBuffer bY, ByteBuffer bVU, Rect roi, int orientation, int imageNum) { - this.bY = bY; - this.bVU = bVU; - this.roi = roi; - this.orientation = orientation; - this.imageNum = imageNum; - } - - @Override - protected void onPreExecute() { + private void saveBestPicture(byte[] bytes, int imageNum) { + if(bytes == null) + return; + String filesPath = mActivity.getFilesDir()+"/Bestpicture"; + File file = new File(filesPath); + if(!file.exists()) { + file.mkdir(); } - - @Override - protected byte[] doInBackground(Void... v) { - synchronized (mClosingLock) { - if (!mIsOn) { - return null; - } - return nv21ToJpeg(bY, bVU, roi, orientation, imageNum); - } - } - - @Override - protected void onPostExecute(byte[] bytes) { - if(bytes == null) - return; - String filesPath = mActivity.getFilesDir()+"/Bestpicture"; - File file = new File(filesPath); - if(!file.exists()) { - file.mkdir(); - } - file = new File(filesPath+"/"+NAMES[imageNum]); - try { - FileOutputStream out = new FileOutputStream(file); - out.write(bytes, 0, bytes.length); - out.close(); - } catch (Exception e) { - } - mSavedCount++; - Log(imageNum+" image is saved"); + file = new File(filesPath+"/"+NAMES[imageNum]); + try { + FileOutputStream out = new FileOutputStream(file); + out.write(bytes, 0, bytes.length); + out.close(); + } catch (Exception e) { } + mSavedCount++; + Log(imageNum+" image is saved"); } } diff --git a/src/com/android/camera/imageprocessor/filter/BlurbusterFilter.java b/src/com/android/camera/imageprocessor/filter/BlurbusterFilter.java index 2ac8fdc0e..4ec2fe378 100644 --- a/src/com/android/camera/imageprocessor/filter/BlurbusterFilter.java +++ b/src/com/android/camera/imageprocessor/filter/BlurbusterFilter.java @@ -47,7 +47,6 @@ public class BlurbusterFilter implements ImageFilter{ private int mStrideY; private int mStrideVU; private static String TAG = "BlurbusterFilter"; - private static final boolean DEBUG = false; private static boolean mIsSupported = false; private ByteBuffer mOutBuf; private CaptureModule mModule; diff --git a/src/com/android/camera/imageprocessor/filter/ChromaflashFilter.java b/src/com/android/camera/imageprocessor/filter/ChromaflashFilter.java index e244c1040..607908ebf 100644 --- a/src/com/android/camera/imageprocessor/filter/ChromaflashFilter.java +++ b/src/com/android/camera/imageprocessor/filter/ChromaflashFilter.java @@ -50,7 +50,7 @@ public class ChromaflashFilter implements ImageFilter{ private int mStrideY; private int mStrideVU; private static String TAG = "ChromaflashFilter"; - private static final boolean DEBUG = false; + private static boolean mIsSupported = false; private ByteBuffer mOutBuf; private CaptureModule mModule; diff --git a/src/com/android/camera/imageprocessor/filter/ImageFilter.java b/src/com/android/camera/imageprocessor/filter/ImageFilter.java index bb581c965..ccdac0ea4 100644 --- a/src/com/android/camera/imageprocessor/filter/ImageFilter.java +++ b/src/com/android/camera/imageprocessor/filter/ImageFilter.java @@ -33,12 +33,17 @@ import android.hardware.camera2.CameraAccessException; import android.hardware.camera2.CameraCaptureSession; import android.hardware.camera2.CaptureRequest; import android.os.Handler; +import com.android.camera.util.PersistUtil; import java.nio.ByteBuffer; import java.util.List; public interface ImageFilter { + public static final boolean DEBUG = + (PersistUtil.getCamera2Debug() == PersistUtil.CAMERA2_DEBUG_DUMP_LOG) || + (PersistUtil.getCamera2Debug() == PersistUtil.CAMERA2_DEBUG_DUMP_ALL); + /* Return the number of required images to process*/ List<CaptureRequest> setRequiredImages(CaptureRequest.Builder builder); diff --git a/src/com/android/camera/imageprocessor/filter/OptizoomFilter.java b/src/com/android/camera/imageprocessor/filter/OptizoomFilter.java index 486ea7a0c..8136ea0a3 100644 --- a/src/com/android/camera/imageprocessor/filter/OptizoomFilter.java +++ b/src/com/android/camera/imageprocessor/filter/OptizoomFilter.java @@ -47,7 +47,6 @@ public class OptizoomFilter implements ImageFilter{ private int mStrideY; private int mStrideVU; private static String TAG = "OptizoomFilter"; - private static final boolean DEBUG = false; private int temp; private static boolean mIsSupported = true; private ByteBuffer mOutBuf; diff --git a/src/com/android/camera/imageprocessor/filter/SharpshooterFilter.java b/src/com/android/camera/imageprocessor/filter/SharpshooterFilter.java index c51e13c59..611949f64 100644 --- a/src/com/android/camera/imageprocessor/filter/SharpshooterFilter.java +++ b/src/com/android/camera/imageprocessor/filter/SharpshooterFilter.java @@ -51,7 +51,6 @@ public class SharpshooterFilter implements ImageFilter{ private int mStrideY; private int mStrideVU; private static String TAG = "SharpshooterFilter"; - private static final boolean DEBUG = false; private int temp; private static boolean mIsSupported = true; private ByteBuffer mOutBuf; diff --git a/src/com/android/camera/imageprocessor/filter/StillmoreFilter.java b/src/com/android/camera/imageprocessor/filter/StillmoreFilter.java index e5c2c03d9..2f483bfdc 100644 --- a/src/com/android/camera/imageprocessor/filter/StillmoreFilter.java +++ b/src/com/android/camera/imageprocessor/filter/StillmoreFilter.java @@ -50,7 +50,6 @@ public class StillmoreFilter implements ImageFilter{ private int mStrideY; private int mStrideVU; private static String TAG = "StillmoreFilter"; - private static final boolean DEBUG = false; private static boolean mIsSupported = false; private ByteBuffer mOutBuf; private CaptureModule mModule; diff --git a/src/com/android/camera/imageprocessor/filter/TrackingFocusFrameListener.java b/src/com/android/camera/imageprocessor/filter/TrackingFocusFrameListener.java index de7fdfff7..964b221cb 100644 --- a/src/com/android/camera/imageprocessor/filter/TrackingFocusFrameListener.java +++ b/src/com/android/camera/imageprocessor/filter/TrackingFocusFrameListener.java @@ -54,7 +54,6 @@ public class TrackingFocusFrameListener implements ImageFilter { int mStrideY; int mStrideVU; private CaptureModule mModule; - private static boolean DEBUG = false; private static String TAG = "TrackingFocusFrameListener"; private static boolean mIsSupported = false; private Rect imageRect; diff --git a/src/com/android/camera/imageprocessor/filter/UbifocusFilter.java b/src/com/android/camera/imageprocessor/filter/UbifocusFilter.java index f32832dd8..d29f29f80 100644 --- a/src/com/android/camera/imageprocessor/filter/UbifocusFilter.java +++ b/src/com/android/camera/imageprocessor/filter/UbifocusFilter.java @@ -39,6 +39,7 @@ import android.hardware.camera2.CameraCaptureSession; import android.hardware.camera2.CameraCharacteristics; import android.hardware.camera2.CaptureRequest; import android.hardware.camera2.CaptureResult; +import android.hardware.camera2.TotalCaptureResult; import android.os.Handler; import android.util.Log; import android.util.Range; @@ -63,7 +64,6 @@ public class UbifocusFilter implements ImageFilter { private int mStrideY; private int mStrideVU; private static String TAG = "UbifocusFilter"; - private static final boolean DEBUG = false; private static final int FOCUS_ADJUST_TIME_OUT = 400; private static final int META_BYTES_SIZE = 25; private int temp; @@ -75,6 +75,7 @@ public class UbifocusFilter implements ImageFilter { private float mMinFocusDistance = -1f; private Object mClosingLock = new Object(); private PostProcessor mPostProcessor; + private ImageFilter.ResultImage mUbifocusResultImage; final String[] NAMES = {"00.jpg", "01.jpg", "02.jpg", "03.jpg", "04.jpg", "DepthMapImage.y", "AllFocusImage.jpg"}; @@ -147,7 +148,8 @@ public class UbifocusFilter implements ImageFilter { if(mOutBuf == null) { return; } - saveToPrivateFile(imageNum, nv21ToJpeg(bY, bVU, new Rect(0, 0, mWidth, mHeight), mOrientation, imageNum)); + byte[] bytes = getYUVBytes(bY, bVU, imageNum); + saveToPrivateFile(imageNum, bytes); mSavedCount++; } } @@ -274,6 +276,38 @@ public class UbifocusFilter implements ImageFilter { } } + private byte[] getYUVBytes(final ByteBuffer yBuf, final ByteBuffer vuBuf, + final int imageNum) { + synchronized (mClosingLock) { + if (mOutBuf == null) { + return null; + } + mUbifocusResultImage = new ImageFilter.ResultImage(ByteBuffer.allocateDirect( + mStrideY * mHeight * 3 / 2), + new Rect(0, 0, mWidth, mHeight), mWidth, mHeight, mStrideY); + yBuf.get(mUbifocusResultImage.outBuffer.array(), 0, yBuf.remaining()); + vuBuf.get(mUbifocusResultImage.outBuffer.array(), mStrideY * mHeight, + vuBuf.remaining()); + yBuf.rewind(); + vuBuf.rewind(); + + return nv21ToJpeg(mUbifocusResultImage, mOrientation, + mPostProcessor.waitForMetaData(imageNum)); + } + } + + private byte[] nv21ToJpeg(ImageFilter.ResultImage resultImage, int orientation, + TotalCaptureResult result) { + BitmapOutputStream bos = new BitmapOutputStream(1024); + YuvImage im = new YuvImage(resultImage.outBuffer.array(), ImageFormat.NV21, + resultImage.width, resultImage.height, new int[]{resultImage.stride, + resultImage.stride}); + im.compressToJpeg(resultImage.outRoi, mPostProcessor.getJpegQualityValue(), bos); + byte[] bytes = bos.getArray(); + bytes = PostProcessor.addExifTags(bytes, orientation, result); + return bytes; + } + private native int nativeInit(int width, int height, int yStride, int vuStride, int numImages); private native int nativeDeinit(); private native int nativeAddImage(ByteBuffer yB, ByteBuffer vuB, int ySize, int vuSize, int imageNum); diff --git a/src/com/android/camera/mpo/MpoOutputStream.java b/src/com/android/camera/mpo/MpoOutputStream.java index 5d01d269f..df45c48ab 100644 --- a/src/com/android/camera/mpo/MpoOutputStream.java +++ b/src/com/android/camera/mpo/MpoOutputStream.java @@ -32,10 +32,13 @@ import android.util.Log; import com.android.camera.exif.JpegHeader; import com.android.camera.exif.OrderedDataOutputStream; import com.android.camera.mpo.MpoTag.MpEntry; +import com.android.camera.util.PersistUtil; class MpoOutputStream extends FilterOutputStream { private static final String TAG = "MpoOutputStream"; - private static final boolean DEBUG = true; + private static final boolean DEBUG = + (PersistUtil.getCamera2Debug() == PersistUtil.CAMERA2_DEBUG_DUMP_LOG) || + (PersistUtil.getCamera2Debug() == PersistUtil.CAMERA2_DEBUG_DUMP_ALL); private static final int STREAMBUFFER_SIZE = 0x00010000; // 64Kb private static final int STATE_SOI = 0; diff --git a/src/com/android/camera/util/PersistUtil.java b/src/com/android/camera/util/PersistUtil.java index cce0e20d3..37bf6ce11 100644 --- a/src/com/android/camera/util/PersistUtil.java +++ b/src/com/android/camera/util/PersistUtil.java @@ -44,6 +44,12 @@ public class PersistUtil { SystemProperties.getBoolean("persist.camera.camera2", false); private static final boolean PERSIST_CAMERA_ZSL = SystemProperties.getBoolean("persist.camera.zsl.disabled", false); + private static final int PERSIST_CAMERA2_DEBUG = + SystemProperties.getInt("persist.camera2.debug", 0); + + public static final int CAMERA2_DEBUG_DUMP_IMAGE = 1; + public static final int CAMERA2_DEBUG_DUMP_LOG = 2; + public static final int CAMERA2_DEBUG_DUMP_ALL = 100; public static int getMemoryLimit() { return PERSIST_MEMORY_LIMIT; @@ -68,4 +74,8 @@ public class PersistUtil { public static boolean getCameraZSLDisabled() { return PERSIST_CAMERA_ZSL; } + + public static int getCamera2Debug() { + return PERSIST_CAMERA2_DEBUG; + } } |