From 0dc64ffddb06d0b41e65f10c742caec52e8b0436 Mon Sep 17 00:00:00 2001 From: Alok Kediya Date: Fri, 27 Sep 2013 20:22:45 +0530 Subject: Camera : Enable camera and camcorder UI features.. Added keys and APIs for enabling QC features from UI. (cherry picked from commit a0fdd6924374635711ea6a554f3a59a087cf4b21) Change-Id: Id50b7cebe2d33eaf7bb6a8e51fecded50ac6dcf8 Conflicts: src/com/android/camera/CameraSettings.java src/com/android/camera/PhotoMenu.java src/com/android/camera/PhotoModule.java src/com/android/camera/VideoModule.java Conflicts: src/com/android/camera/CameraSettings.java src/com/android/camera/VideoModule.java (cherry picked from commit 93cd1cdb59449ccb2b9594c9d8e3978a25d7f376) (cherry picked from commit af04f9d621183addee0f7cdd7c1a41c8d0e65cfe) --- src/com/android/camera/.PhotoModule.java.swp | Bin 0 -> 28672 bytes .../android/camera/AndroidCameraManagerImpl.java | 20 + src/com/android/camera/CameraManager.java | 12 + src/com/android/camera/CameraSettings.java | 121 ++++ src/com/android/camera/FocusOverlayManager.java | 22 +- src/com/android/camera/PhotoMenu.java | 268 ++++--- src/com/android/camera/PhotoModule.java | 799 +++++++++++++++++++-- src/com/android/camera/VideoMenu.java | 84 ++- src/com/android/camera/VideoModule.java | 65 +- 9 files changed, 1227 insertions(+), 164 deletions(-) create mode 100644 src/com/android/camera/.PhotoModule.java.swp (limited to 'src/com/android/camera') diff --git a/src/com/android/camera/.PhotoModule.java.swp b/src/com/android/camera/.PhotoModule.java.swp new file mode 100644 index 000000000..0cc18b352 Binary files /dev/null and b/src/com/android/camera/.PhotoModule.java.swp differ diff --git a/src/com/android/camera/AndroidCameraManagerImpl.java b/src/com/android/camera/AndroidCameraManagerImpl.java index d9e21fdd0..84dc0a8de 100644 --- a/src/com/android/camera/AndroidCameraManagerImpl.java +++ b/src/com/android/camera/AndroidCameraManagerImpl.java @@ -39,6 +39,8 @@ import android.os.Looper; import android.os.Message; import android.util.Log; import android.view.SurfaceHolder; +import android.hardware.Camera.CameraDataCallback; +import com.android.camera.util.ApiHelper; /** * A class to implement {@link CameraManager} of the Android camera framework. @@ -83,6 +85,9 @@ class AndroidCameraManagerImpl implements CameraManager { // Presentation private static final int ENABLE_SHUTTER_SOUND = 501; private static final int SET_DISPLAY_ORIENTATION = 502; + // Histogram + private static final int SET_HISTOGRAM_MODE = 601; + private static final int SEND_HISTOGRAM_DATA = 602; private CameraHandler mCameraHandler; private android.hardware.Camera mCamera; @@ -317,6 +322,13 @@ class AndroidCameraManagerImpl implements CameraManager { mParametersIsDirty = true; return; + case SET_HISTOGRAM_MODE: + mCamera.setHistogramMode((CameraDataCallback) msg.obj); + break; + + case SEND_HISTOGRAM_DATA: + mCamera.sendHistogramData(); + break; default: throw new RuntimeException("Invalid CameraProxy message=" + msg.what); } @@ -540,6 +552,14 @@ class AndroidCameraManagerImpl implements CameraManager { mCameraHandler.obtainMessage( ENABLE_SHUTTER_SOUND, (enable ? 1 : 0), 0).sendToTarget(); } + @Override + public void setHistogramMode(CameraDataCallback cb) { + mCameraHandler.obtainMessage(SET_HISTOGRAM_MODE, cb).sendToTarget(); + } + @Override + public void sendHistogramData() { + mCameraHandler.sendEmptyMessage(SEND_HISTOGRAM_DATA); + } } /** diff --git a/src/com/android/camera/CameraManager.java b/src/com/android/camera/CameraManager.java index 909e1ca75..4c43c27b8 100644 --- a/src/com/android/camera/CameraManager.java +++ b/src/com/android/camera/CameraManager.java @@ -25,6 +25,7 @@ import android.hardware.Camera.Parameters; import android.os.Build; import android.os.Handler; import android.view.SurfaceHolder; +import android.hardware.Camera.CameraDataCallback; /** * An interface which provides possible camera device operations. @@ -349,5 +350,16 @@ public interface CameraManager { * {@code false} to disable it. */ public void enableShutterSound(boolean enable); + /** + * Set histogram Mode + * + * @param cb cameraDataCallback to use + */ + public void setHistogramMode(CameraDataCallback cb); + /** + * Send the Histogram Data. + * + */ + public void sendHistogramData(); } } diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java index f9fccc898..9cfb7750d 100644 --- a/src/com/android/camera/CameraSettings.java +++ b/src/com/android/camera/CameraSettings.java @@ -73,11 +73,46 @@ public class CameraSettings { public static final String KEY_VIDEO_ENCODER = "pref_camera_videoencoder_key"; public static final String KEY_AUDIO_ENCODER = "pref_camera_audioencoder_key"; public static final String KEY_VIDEO_DURATION = "pref_camera_video_duration_key"; + public static final String KEY_POWER_MODE = "pref_camera_powermode_key"; + public static final String KEY_PICTURE_FORMAT = "pref_camera_pictureformat_key"; + public static final String KEY_ZSL = "pref_camera_zsl_key"; + public static final String KEY_COLOR_EFFECT = "pref_camera_coloreffect_key"; + public static final String KEY_FACE_DETECTION = "pref_camera_facedetection_key"; + public static final String KEY_TOUCH_AF_AEC = "pref_camera_touchafaec_key"; + public static final String KEY_SELECTABLE_ZONE_AF = "pref_camera_selectablezoneaf_key"; + public static final String KEY_SATURATION = "pref_camera_saturation_key"; + public static final String KEY_CONTRAST = "pref_camera_contrast_key"; + public static final String KEY_SHARPNESS = "pref_camera_sharpness_key"; + public static final String KEY_AUTOEXPOSURE = "pref_camera_autoexposure_key"; + public static final String KEY_ANTIBANDING = "pref_camera_antibanding_key"; + public static final String KEY_ISO = "pref_camera_iso_key"; + public static final String KEY_LENSSHADING = "pref_camera_lensshading_key"; + public static final String KEY_HISTOGRAM = "pref_camera_histogram_key"; + public static final String KEY_DENOISE = "pref_camera_denoise_key"; + public static final String KEY_REDEYE_REDUCTION = "pref_camera_redeyereduction_key"; + public static final String KEY_AE_BRACKET_HDR = "pref_camera_ae_bracket_hdr_key"; + + public static final String KEY_VIDEO_SNAPSHOT_SIZE = "pref_camera_videosnapsize_key"; + public static final String KEY_VIDEO_HIGH_FRAME_RATE = "pref_camera_hfr_key"; + public static final String DEFAULT_VIDEO_QUALITY_VALUE = "custom"; + public static final String KEY_SKIN_TONE_ENHANCEMENT = "pref_camera_skinToneEnhancement_key"; + public static final String KEY_SKIN_TONE_ENHANCEMENT_FACTOR = "pref_camera_skinToneEnhancement_factor_key"; + + private static final String VIDEO_QUALITY_HIGH = "high"; + private static final String VIDEO_QUALITY_MMS = "mms"; + private static final String VIDEO_QUALITY_YOUTUBE = "youtube"; + + public static final String EXPOSURE_DEFAULT_VALUE = "0"; public static final int CURRENT_VERSION = 5; public static final int CURRENT_LOCAL_VERSION = 2; + public static final int DEFAULT_VIDEO_DURATION = 0; // no limit + private static final int MMS_VIDEO_DURATION = (CamcorderProfile.get(CamcorderProfile.QUALITY_LOW) != null) ? + CamcorderProfile.get(CamcorderProfile.QUALITY_LOW).duration :30; + private static final int YOUTUBE_VIDEO_DURATION = 15 * 60; // 15 mins + private static final String TAG = "CameraSettings"; private final Context mContext; @@ -162,6 +197,83 @@ public class CameraSettings { return duration; } + private void qcomInitPreferences(PreferenceGroup group){ + //Qcom Preference add here + ListPreference powerMode = group.findPreference(KEY_POWER_MODE); + ListPreference zsl = group.findPreference(KEY_ZSL); + ListPreference colorEffect = group.findPreference(KEY_COLOR_EFFECT); + ListPreference faceDetection = group.findPreference(KEY_FACE_DETECTION); + ListPreference touchAfAec = group.findPreference(KEY_TOUCH_AF_AEC); + ListPreference selectableZoneAf = group.findPreference(KEY_SELECTABLE_ZONE_AF); + ListPreference saturation = group.findPreference(KEY_SATURATION); + ListPreference contrast = group.findPreference(KEY_CONTRAST); + ListPreference sharpness = group.findPreference(KEY_SHARPNESS); + ListPreference autoExposure = group.findPreference(KEY_AUTOEXPOSURE); + ListPreference antiBanding = group.findPreference(KEY_ANTIBANDING); + ListPreference mIso = group.findPreference(KEY_ISO); + ListPreference lensShade = group.findPreference(KEY_LENSSHADING); + ListPreference histogram = group.findPreference(KEY_HISTOGRAM); + ListPreference denoise = group.findPreference(KEY_DENOISE); + ListPreference redeyeReduction = group.findPreference(KEY_REDEYE_REDUCTION); + ListPreference hdr = group.findPreference(KEY_AE_BRACKET_HDR); + ListPreference jpegQuality = group.findPreference(KEY_JPEG_QUALITY); + ListPreference videoSnapSize = group.findPreference(KEY_VIDEO_SNAPSHOT_SIZE); + + + if (touchAfAec != null) { + filterUnsupportedOptions(group, + touchAfAec, mParameters.getSupportedTouchAfAec()); + } + + if (selectableZoneAf != null) { + filterUnsupportedOptions(group, + selectableZoneAf, mParameters.getSupportedSelectableZoneAf()); + } + + if (mIso != null) { + filterUnsupportedOptions(group, + mIso, mParameters.getSupportedIsoValues()); + } + + if (redeyeReduction != null) { + filterUnsupportedOptions(group, + redeyeReduction, mParameters.getSupportedRedeyeReductionModes()); + } + + if (denoise != null) { + filterUnsupportedOptions(group, + denoise, mParameters.getSupportedDenoiseModes()); + } + + if (colorEffect != null) { + filterUnsupportedOptions(group, + colorEffect, mParameters.getSupportedColorEffects()); + } + + if (antiBanding != null) { + filterUnsupportedOptions(group, + antiBanding, mParameters.getSupportedAntibanding()); + } + + if (autoExposure != null) { + filterUnsupportedOptions(group, + autoExposure, mParameters.getSupportedAutoexposure()); + } + + if (!mParameters.isPowerModeSupported()){ + filterUnsupportedOptions(group, + videoSnapSize, null); + } else { + filterUnsupportedOptions(group, videoSnapSize, sizeListToStringList( + mParameters.getSupportedPictureSizes())); + } + + if (histogram!= null) { + filterUnsupportedOptions(group, + histogram, mParameters.getSupportedHistogramModes()); + } + + } private void initPreference(PreferenceGroup group) { ListPreference videoQuality = group.findPreference(KEY_VIDEO_QUALITY); ListPreference timeLapseInterval = group.findPreference(KEY_VIDEO_TIME_LAPSE_FRAME_INTERVAL); @@ -234,6 +346,7 @@ public class CameraSettings { !GcamHelper.hasGcamCapture() || isFrontCamera)) { removePreference(group, cameraHdrPlus.getKey()); } + qcomInitPreferences(group); } private void buildExposureCompensation( @@ -580,4 +693,12 @@ public class CameraSettings { } } + public static int getVideoDurationInMillis(String quality) { + if (VIDEO_QUALITY_MMS.equals(quality)) { + return MMS_VIDEO_DURATION * 1000; + } else if (VIDEO_QUALITY_YOUTUBE.equals(quality)) { + return YOUTUBE_VIDEO_DURATION * 1000; + } + return DEFAULT_VIDEO_DURATION * 1000; + } } diff --git a/src/com/android/camera/FocusOverlayManager.java b/src/com/android/camera/FocusOverlayManager.java index c223aea6b..adfd9652d 100644 --- a/src/com/android/camera/FocusOverlayManager.java +++ b/src/com/android/camera/FocusOverlayManager.java @@ -62,12 +62,12 @@ public class FocusOverlayManager { private static final int RESET_TOUCH_FOCUS_DELAY = 3000; private int mState = STATE_IDLE; - private static final int STATE_IDLE = 0; // Focus is not active. - private static final int STATE_FOCUSING = 1; // Focus is in progress. + public static final int STATE_IDLE = 0; // Focus is not active. + public static final int STATE_FOCUSING = 1; // Focus is in progress. // Focus is in progress and the camera should take a picture after focus finishes. - 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. + public static final int STATE_FOCUSING_SNAP_ON_FINISH = 2; + public static final int STATE_SUCCESS = 3; // Focus finishes and succeeds. + public static final int STATE_FAIL = 4; // Focus finishes and fails. private boolean mInitialized; private boolean mFocusAreaSupported; @@ -91,6 +91,7 @@ public class FocusOverlayManager { Listener mListener; private boolean mPreviousMoving; private boolean mFocusDefault; + private boolean mZslEnabled = false; //QCom Parameter to disable focus for ZSL private FocusUI mUI; @@ -190,7 +191,7 @@ public class FocusOverlayManager { } private void lockAeAwbIfNeeded() { - if (mLockAeAwbNeeded && !mAeAwbLock) { + if (mLockAeAwbNeeded && !mAeAwbLock && !mZslEnabled) { mAeAwbLock = true; mListener.setFocusParameters(); } @@ -540,6 +541,10 @@ public class FocusOverlayManager { return mState == STATE_SUCCESS || mState == STATE_FAIL; } + public int getCurrentFocusState() { + return mState; + } + public boolean isFocusingSnapOnFinish() { return mState == STATE_FOCUSING_SNAP_ON_FINISH; } @@ -561,9 +566,14 @@ public class FocusOverlayManager { } private boolean needAutoFocusCall() { + if(mZslEnabled) return false; String focusMode = getFocusMode(); return !(focusMode.equals(Parameters.FOCUS_MODE_INFINITY) || focusMode.equals(Parameters.FOCUS_MODE_FIXED) || focusMode.equals(Parameters.FOCUS_MODE_EDOF)); } + + public void setZslEnable(boolean value) { + mZslEnabled = value; + } } diff --git a/src/com/android/camera/PhotoMenu.java b/src/com/android/camera/PhotoMenu.java index ae33059fa..2e521d715 100644 --- a/src/com/android/camera/PhotoMenu.java +++ b/src/com/android/camera/PhotoMenu.java @@ -24,19 +24,36 @@ import android.hardware.Camera.Parameters; import com.android.camera.ui.AbstractSettingPopup; import com.android.camera.ui.CountdownTimerPopup; import com.android.camera.ui.ListPrefSettingPopup; +import com.android.camera.ui.MoreSettingPopup; import com.android.camera.ui.PieItem; import com.android.camera.ui.PieItem.OnClickListener; import com.android.camera.ui.PieRenderer; import com.android.camera2.R; +import android.content.Context; +import android.view.LayoutInflater; +import android.util.Log; + +import java.util.Locale; public class PhotoMenu extends PieController - implements CountdownTimerPopup.Listener, + implements MoreSettingPopup.Listener, + CountdownTimerPopup.Listener, ListPrefSettingPopup.Listener { private static String TAG = "PhotoMenu"; private final String mSettingOff; + private String[] mOtherKeys1; + private String[] mOtherKeys2; + private String[] mOtherKeys3; + private MoreSettingPopup mPopup1; + private MoreSettingPopup mPopup2; + private MoreSettingPopup mPopup3; + private static final int POPUP_NONE = 0; + private static final int POPUP_FIRST_LEVEL = 1; + private static final int POPUP_SECOND_LEVEL = 2; private PhotoUI mUI; + private int mPopupStatus; private AbstractSettingPopup mPopup; private CameraActivity mActivity; @@ -50,6 +67,10 @@ public class PhotoMenu extends PieController public void initialize(PreferenceGroup group) { super.initialize(group); mPopup = null; + mPopup1 = null; + mPopup2 = null; + mPopup3 = null; + mPopupStatus = POPUP_NONE; PieItem item = null; final Resources res = mActivity.getResources(); Locale locale = res.getConfiguration().locale; @@ -66,24 +87,102 @@ public class PhotoMenu extends PieController item = makeSwitchItem(CameraSettings.KEY_CAMERA_HDR, true); mRenderer.addItem(item); } - // Exposure compensation. - if (group.findPreference(CameraSettings.KEY_EXPOSURE) != null) { - item = makeItem(CameraSettings.KEY_EXPOSURE); - item.setLabel(res.getString(R.string.pref_exposure_label)); - mRenderer.addItem(item); - } - // More settings. - PieItem more = makeItem(R.drawable.ic_settings_holo_light); - more.setLabel(res.getString(R.string.camera_menu_more_label)); - mRenderer.addItem(more); - - // Flash. - if (group.findPreference(CameraSettings.KEY_FLASH_MODE) != null) { - item = makeItem(CameraSettings.KEY_FLASH_MODE); - item.setLabel(res.getString(R.string.pref_camera_flashmode_label)); - mRenderer.addItem(item); - } - // Camera switcher. + + // countdown timer + final ListPreference ctpref = group.findPreference(CameraSettings.KEY_TIMER); + final ListPreference beeppref = group.findPreference(CameraSettings.KEY_TIMER_SOUND_EFFECTS); + item = makeItem(R.drawable.ic_timer); + item.setLabel(res.getString(R.string.pref_camera_timer_title).toUpperCase(locale)); + item.setOnClickListener(new OnClickListener() { + @Override + public void onClick(PieItem item) { + CountdownTimerPopup timerPopup = (CountdownTimerPopup) mActivity.getLayoutInflater().inflate( + R.layout.countdown_setting_popup, null, false); + timerPopup.initialize(ctpref, beeppref); + timerPopup.setSettingChangedListener(PhotoMenu.this); + mUI.dismissPopup(); + mPopup = timerPopup; + mUI.showPopup(mPopup); + } + }); + mRenderer.addItem(item); + + mOtherKeys1 = new String[] { + CameraSettings.KEY_SCENE_MODE, + CameraSettings.KEY_RECORD_LOCATION, + CameraSettings.KEY_PICTURE_SIZE, + CameraSettings.KEY_HISTOGRAM, + CameraSettings.KEY_FOCUS_MODE, + CameraSettings.KEY_PICTURE_FORMAT, + CameraSettings.KEY_JPEG_QUALITY, + CameraSettings.KEY_ZSL + }; + + mOtherKeys2 = new String[] { + CameraSettings.KEY_COLOR_EFFECT, + CameraSettings.KEY_FACE_DETECTION, + CameraSettings.KEY_TOUCH_AF_AEC, + CameraSettings.KEY_SELECTABLE_ZONE_AF, + CameraSettings.KEY_SATURATION, + CameraSettings.KEY_CONTRAST, + CameraSettings.KEY_SHARPNESS, + CameraSettings.KEY_AUTOEXPOSURE + }; + + mOtherKeys3 = new String[] { + CameraSettings.KEY_ANTIBANDING, + CameraSettings.KEY_ISO, + CameraSettings.KEY_DENOISE, + CameraSettings.KEY_EXPOSURE, + CameraSettings.KEY_WHITE_BALANCE, + CameraSettings.KEY_FLASH_MODE, + CameraSettings.KEY_REDEYE_REDUCTION + }; + + PieItem item1 = makeItem(R.drawable.ic_settings_holo_light); + item1.setLabel(mActivity.getResources().getString(R.string.camera_menu_more_label)); + item1.setOnClickListener(new OnClickListener() { + @Override + public void onClick(PieItem item) { + if (mPopup1 == null || mPopupStatus != POPUP_FIRST_LEVEL){ + initializePopup(); + mPopupStatus = POPUP_FIRST_LEVEL; + } + mUI.showPopup(mPopup1); + } + }); + mRenderer.addItem(item1); + + PieItem item2 = makeItem(R.drawable.ic_settings_holo_light); + item2.setLabel(mActivity.getResources().getString(R.string.camera_menu_more_label)); + item2.setOnClickListener(new OnClickListener() { + @Override + public void onClick(PieItem item) { + if (mPopup2 == null || mPopupStatus != POPUP_FIRST_LEVEL) { + initializePopup(); + mPopupStatus = POPUP_FIRST_LEVEL; + } + mUI.showPopup(mPopup2); + } + }); + mRenderer.addItem(item2); + + PieItem item3= makeItem(R.drawable.ic_settings_holo_light); + item3.setLabel(mActivity.getResources().getString(R.string.camera_menu_more_label)); + item3.setOnClickListener(new OnClickListener() { + @Override + public void onClick(PieItem item) { + if (mPopup3 == null || mPopupStatus != POPUP_FIRST_LEVEL) { + initializePopup(); + mPopupStatus = POPUP_FIRST_LEVEL; + } + mUI.showPopup(mPopup3); + mPopupStatus = POPUP_FIRST_LEVEL; + } + }); + mRenderer.addItem(item3); + + // camera switcher if (group.findPreference(CameraSettings.KEY_CAMERA_ID) != null) { item = makeSwitchItem(CameraSettings.KEY_CAMERA_ID, false); final PieItem fitem = item; @@ -105,79 +204,82 @@ public class PhotoMenu extends PieController }); mRenderer.addItem(item); } - // Location. - if (group.findPreference(CameraSettings.KEY_RECORD_LOCATION) != null) { - item = makeSwitchItem(CameraSettings.KEY_RECORD_LOCATION, true); - more.addItem(item); - if (mActivity.isSecureCamera()) { - // Prevent location preference from getting changed in secure camera mode - item.setEnabled(false); - } - } - // Countdown timer. - final ListPreference ctpref = group.findPreference(CameraSettings.KEY_TIMER); - final ListPreference beeppref = group.findPreference(CameraSettings.KEY_TIMER_SOUND_EFFECTS); - item = makeItem(R.drawable.ic_timer); - item.setLabel(res.getString(R.string.pref_camera_timer_title).toUpperCase(locale)); - item.setOnClickListener(new OnClickListener() { - @Override - public void onClick(PieItem item) { - CountdownTimerPopup timerPopup = (CountdownTimerPopup) mActivity.getLayoutInflater().inflate( - R.layout.countdown_setting_popup, null, false); - timerPopup.initialize(ctpref, beeppref); - timerPopup.setSettingChangedListener(PhotoMenu.this); - mUI.dismissPopup(); - mPopup = timerPopup; - mUI.showPopup(mPopup); - } - }); - more.addItem(item); - // Image size. - item = makeItem(R.drawable.ic_imagesize); - final ListPreference sizePref = group.findPreference(CameraSettings.KEY_PICTURE_SIZE); - item.setLabel(res.getString(R.string.pref_camera_picturesize_title).toUpperCase(locale)); - item.setOnClickListener(new OnClickListener() { - @Override - public void onClick(PieItem item) { - ListPrefSettingPopup popup = (ListPrefSettingPopup) mActivity.getLayoutInflater().inflate( - R.layout.list_pref_setting_popup, null, false); - popup.initialize(sizePref); - popup.setSettingChangedListener(PhotoMenu.this); - mUI.dismissPopup(); - mPopup = popup; - mUI.showPopup(mPopup); - } - }); - more.addItem(item); - // White balance. - if (group.findPreference(CameraSettings.KEY_WHITE_BALANCE) != null) { - item = makeItem(CameraSettings.KEY_WHITE_BALANCE); - item.setLabel(res.getString(R.string.pref_camera_whitebalance_label)); - more.addItem(item); - } - // Scene mode. - if (group.findPreference(CameraSettings.KEY_SCENE_MODE) != null) { - IconListPreference pref = (IconListPreference) group.findPreference( - CameraSettings.KEY_SCENE_MODE); - pref.setUseSingleIcon(true); - item = makeItem(CameraSettings.KEY_SCENE_MODE); - more.addItem(item); - } - } - + } @Override // Hit when an item in a popup gets selected public void onListPrefChanged(ListPreference pref) { - if (mPopup != null) { - mUI.dismissPopup(); + if (mPopup1 != null && mPopup2 != null && mPopup3 != null) { + if (mPopupStatus == POPUP_SECOND_LEVEL) { + mUI.dismissPopup(); + } } onSettingChanged(pref); } + @Override + public void overrideSettings(final String ... keyvalues) { + super.overrideSettings(keyvalues); + if ((mPopup1 == null) && (mPopup2 == null) && (mPopup3 == null)) initializePopup(); + mPopup1.overrideSettings(keyvalues); + mPopup2.overrideSettings(keyvalues); + mPopup3.overrideSettings(keyvalues); + } + + protected void initializePopup() { + LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService( + Context.LAYOUT_INFLATER_SERVICE); + MoreSettingPopup popup1 = (MoreSettingPopup) inflater.inflate( + R.layout.more_setting_popup, null, false); + popup1.setSettingChangedListener(this); + popup1.initialize(mPreferenceGroup, mOtherKeys1); + if (mActivity.isSecureCamera()) { + // Prevent location preference from getting changed in secure camera mode + popup1.setPreferenceEnabled(CameraSettings.KEY_RECORD_LOCATION,false); + } + mPopup1 = popup1; + + MoreSettingPopup popup2 = (MoreSettingPopup) inflater.inflate( + R.layout.more_setting_popup, null, false); + popup2.setSettingChangedListener(this); + popup2.initialize(mPreferenceGroup, mOtherKeys2); + mPopup2 = popup2; + + MoreSettingPopup popup3 = (MoreSettingPopup) inflater.inflate( + R.layout.more_setting_popup, null, false); + popup3.setSettingChangedListener(this); + popup3.initialize(mPreferenceGroup, mOtherKeys3); + mPopup3 = popup3; + } + public void popupDismissed() { - if (mPopup != null) { - mPopup = null; + // the popup gets dismissed + if (mPopup1 != null) { + mPopup1 = null; } + if (mPopup2 != null) { + mPopup2 = null; + } + if (mPopup3 != null) { + mPopup3 = null; + } + } + + @Override + // Hit when an item in the first-level popup gets selected, then bring up + // the second-level popup + public void onPreferenceClicked(ListPreference pref) { + if (mPopupStatus != POPUP_FIRST_LEVEL) return; + + LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService( + Context.LAYOUT_INFLATER_SERVICE); + ListPrefSettingPopup basic = (ListPrefSettingPopup) inflater.inflate( + R.layout.list_pref_setting_popup, null, false); + basic.initialize(pref); + basic.setSettingChangedListener(this); + mUI.dismissPopup(); + mPopup = basic; + mUI.showPopup(mPopup); + mPopupStatus = POPUP_SECOND_LEVEL; } // Return true if the preference has the specified key but not the value. diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java index 58e8f4bb4..ac29d54e9 100644 --- a/src/com/android/camera/PhotoModule.java +++ b/src/com/android/camera/PhotoModule.java @@ -49,6 +49,12 @@ import android.view.KeyEvent; import android.view.OrientationEventListener; import android.view.View; import android.view.WindowManager; +import android.widget.Toast; +import android.widget.ProgressBar; +import android.widget.SeekBar; +import android.widget.SeekBar.OnSeekBarChangeListener; +import android.widget.LinearLayout; +import android.widget.TextView; import com.android.camera.CameraManager.CameraAFCallback; import com.android.camera.CameraManager.CameraAFMoveCallback; @@ -75,6 +81,14 @@ import java.io.IOException; import java.io.OutputStream; import java.util.List; import java.util.Vector; +import java.util.HashMap; +import android.util.AttributeSet; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.os.SystemProperties; +import java.util.Collections; +import java.util.Formatter; public class PhotoModule implements CameraModule, @@ -88,6 +102,18 @@ public class PhotoModule private static final String TAG = "CAM_PhotoModule"; + //QCom data members + public static boolean mBrightnessVisible = true; + private static final int MAX_SHARPNESS_LEVEL = 6; + private boolean mRestartPreview = false; + private int mSnapshotMode; + public boolean mFaceDetectionEnabled = false; + + /*Histogram variables*/ + private GraphView mGraphView; + private static final int STATS_DATA = 257; + public static int statsdata[] = new int[STATS_DATA]; + public boolean mHiston = false; // We number the request code from 1000 to avoid collision with Gallery. private static final int REQUEST_CROP = 1000; @@ -101,8 +127,7 @@ public class PhotoModule private static final int CAMERA_OPEN_DONE = 8; private static final int OPEN_CAMERA_FAIL = 9; private static final int CAMERA_DISABLED = 10; - private static final int SWITCH_TO_GCAM_MODULE = 11; - + private static final int SET_SKIN_TONE_FACTOR = 11; // The subset of parameters we need to update in setCameraParameters(). private static final int UPDATE_PARAM_INITIALIZE = 1; private static final int UPDATE_PARAM_ZOOM = 2; @@ -121,6 +146,7 @@ public class PhotoModule private int mCameraId; private Parameters mParameters; private boolean mPaused; + private View mRootView; private PhotoUI mUI; @@ -145,6 +171,7 @@ public class PhotoModule private boolean mAeLockSupported; private boolean mAwbLockSupported; private boolean mContinuousFocusSupported; + private boolean mTouchAfAecFlag; // The degrees of the device rotated clockwise from its natural orientation. private int mOrientation = OrientationEventListener.ORIENTATION_UNKNOWN; @@ -155,6 +182,27 @@ public class PhotoModule private ContentProviderClient mMediaProviderClient; private boolean mFaceDetectionStarted = false; + private static final int MINIMUM_BRIGHTNESS = 0; + private static final int MAXIMUM_BRIGHTNESS = 6; + private int mbrightness = 3; + private int mbrightness_step = 1; + private ProgressBar brightnessProgressBar; + // Constant from android.hardware.Camera.Parameters + private static final String KEY_PICTURE_FORMAT = "picture-format"; + private static final String KEY_QC_RAW_PICUTRE_SIZE = "raw-size"; + private static final String PIXEL_FORMAT_JPEG = "jpeg"; + + private static final int MIN_SCE_FACTOR = -10; + private static final int MAX_SCE_FACTOR = +10; + private int SCE_FACTOR_STEP = 10; + private int mskinToneValue = 0; + private boolean mSkinToneSeekBar= false; + private boolean mSeekBarInitialized = false; + private SeekBar skinToneSeekBar; + private TextView LeftValue; + private TextView RightValue; + private TextView Title; + // mCropValue and mSaveUri are used only if isImageCaptureIntent() is true. private String mCropValue; private Uri mSaveUri; @@ -214,6 +262,7 @@ public class PhotoModule : null; private final CameraErrorCallback mErrorCallback = new CameraErrorCallback(); + private final StatsCallback mStatsCallback = new StatsCallback(); private long mFocusStartTime; private long mShutterCallbackTime; @@ -341,18 +390,44 @@ public class PhotoModule R.string.camera_disabled); break; } - - case SWITCH_TO_GCAM_MODULE: { - mActivity.onModuleSelected(ModuleSwitcher.GCAM_MODULE_INDEX); - } + case SET_SKIN_TONE_FACTOR: { + Log.v(TAG, "set tone bar: mSceneMode = " + mSceneMode); + setSkinToneFactor(); + mSeekBarInitialized = true; + // skin tone ie enabled only for party and portrait BSM + // when color effects are not enabled + String colorEffect = mPreferences.getString( + CameraSettings.KEY_COLOR_EFFECT, + mActivity.getString(R.string.pref_camera_coloreffect_default)); + if((Parameters.SCENE_MODE_PARTY.equals(mSceneMode) || + Parameters.SCENE_MODE_PORTRAIT.equals(mSceneMode))&& + (Parameters.EFFECT_NONE.equals(colorEffect))) { + ; + } + else{ + Log.v(TAG, "Skin tone bar: disable"); + disableSkinToneSeekBar(); + } + break; + } } } } - - + private BroadcastReceiver mReceiver = null; + private class ShutterBroadcastReceiver extends BroadcastReceiver { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action.equals(CameraUtil.ACTION_CAMERA_SHUTTER_CLICK)) { + onShutterButtonFocus(true); + onShutterButtonClick(); + } + } + } @Override public void init(CameraActivity activity, View parent) { mActivity = activity; + mRootView = parent; mUI = new PhotoUI(activity, this, parent); mPreferences = new ComboPreferences(mActivity); CameraSettings.upgradeGlobalPreferences(mPreferences.getGlobal()); @@ -373,6 +448,21 @@ public class PhotoModule mQuickCapture = mActivity.getIntent().getBooleanExtra(EXTRA_QUICK_CAPTURE, false); mLocationManager = new LocationManager(mActivity, mUI); mSensorManager = (SensorManager)(mActivity.getSystemService(Context.SENSOR_SERVICE)); + + brightnessProgressBar = (ProgressBar)mRootView.findViewById(R.id.progress); + if (brightnessProgressBar instanceof SeekBar) { + SeekBar seeker = (SeekBar) brightnessProgressBar; + seeker.setOnSeekBarChangeListener(mSeekListener); + } + brightnessProgressBar.setMax(MAXIMUM_BRIGHTNESS); + brightnessProgressBar.setProgress(mbrightness); + skinToneSeekBar = (SeekBar) mRootView.findViewById(R.id.skintoneseek); + skinToneSeekBar.setOnSeekBarChangeListener(mskinToneSeekListener); + skinToneSeekBar.setVisibility(View.INVISIBLE); + Title = (TextView)mRootView.findViewById(R.id.skintonetitle); + RightValue = (TextView)mRootView.findViewById(R.id.skintoneright); + LeftValue = (TextView)mRootView.findViewById(R.id.skintoneleft); + } private void initializeControlByIntent() { @@ -554,6 +644,12 @@ public class PhotoModule } mNamedImages = new NamedImages(); + mGraphView = (GraphView)mRootView.findViewById(R.id.graph_view); + if(mGraphView == null){ + Log.e(TAG, "mGraphView is null"); + } else{ + mGraphView.setPhotoModuleObject(this); + } mFirstTimeInitialized = true; addIdleHandler(); @@ -599,7 +695,8 @@ public class PhotoModule @Override public void startFaceDetection() { - if (mFaceDetectionStarted) return; + if (mFaceDetectionEnabled == false + || mFaceDetectionStarted || mCameraState != IDLE) return; if (mParameters.getMaxNumDetectedFaces() > 0) { mFaceDetectionStarted = true; CameraInfo info = CameraHolder.instance().getCameraInfo()[mCameraId]; @@ -612,7 +709,7 @@ public class PhotoModule @Override public void stopFaceDetection() { - if (!mFaceDetectionStarted) return; + if (mFaceDetectionEnabled == false || !mFaceDetectionStarted) return; if (mParameters.getMaxNumDetectedFaces() > 0) { mFaceDetectionStarted = false; mCameraDevice.setFaceDetectionCallback(null, null); @@ -645,7 +742,26 @@ public class PhotoModule } } } - + private final class StatsCallback + implements android.hardware.Camera.CameraDataCallback { + @Override + public void onCameraData(int [] data, android.hardware.Camera camera) { + //if(!mPreviewing || !mHiston || !mFirstTimeInitialized){ + if(!mHiston || !mFirstTimeInitialized){ + return; + } + /*The first element in the array stores max hist value . Stats data begin from second value*/ + synchronized(statsdata) { + System.arraycopy(data,0,statsdata,0,STATS_DATA); + } + mActivity.runOnUiThread(new Runnable() { + public void run() { + if(mGraphView != null) + mGraphView.PreviewChanged(); + } + }); + } + } private final class PostViewPictureCallback implements CameraPictureCallback { @Override @@ -794,7 +910,49 @@ public class PhotoModule } } } + private OnSeekBarChangeListener mSeekListener = new OnSeekBarChangeListener() { + public void onStartTrackingTouch(SeekBar bar) { + // no support + } + public void onProgressChanged(SeekBar bar, int progress, boolean fromtouch) { + } + public void onStopTrackingTouch(SeekBar bar) { + } + }; + + private OnSeekBarChangeListener mskinToneSeekListener = new OnSeekBarChangeListener() { + public void onStartTrackingTouch(SeekBar bar) { + // no support + } + + public void onProgressChanged(SeekBar bar, int progress, boolean fromtouch) { + int value = (progress + MIN_SCE_FACTOR) * SCE_FACTOR_STEP; + if(progress > (MAX_SCE_FACTOR - MIN_SCE_FACTOR)/2){ + RightValue.setText(String.valueOf(value)); + LeftValue.setText(""); + } else if (progress < (MAX_SCE_FACTOR - MIN_SCE_FACTOR)/2){ + LeftValue.setText(String.valueOf(value)); + RightValue.setText(""); + } else { + LeftValue.setText(""); + RightValue.setText(""); + } + if(value != mskinToneValue && mCameraDevice != null) { + mskinToneValue = value; + mParameters = mCameraDevice.getParameters(); + mParameters.set("skinToneEnhancement", String.valueOf(mskinToneValue)); + mCameraDevice.setParameters(mParameters); + } + } + public void onStopTrackingTouch(SeekBar bar) { + Log.v(TAG, "Set onStopTrackingTouch mskinToneValue = " + mskinToneValue); + Editor editor = mPreferences.edit(); + editor.putString(CameraSettings.KEY_SKIN_TONE_ENHANCEMENT_FACTOR, + Integer.toString(mskinToneValue)); + editor.apply(); + } + }; private final class AutoFocusCallback implements CameraAFCallback { @Override public void onAutoFocus( @@ -887,6 +1045,18 @@ public class PhotoModule mJpegImageData = null; final boolean animateBefore = (mSceneMode == CameraUtil.SCENE_MODE_HDR); + if(mHiston) { + if (mSnapshotMode != CameraInfo.CAMERA_SUPPORT_MODE_ZSL) { + mHiston = false; + mCameraDevice.setHistogramMode(null); + } + mActivity.runOnUiThread(new Runnable() { + public void run() { + if(mGraphView != null) + mGraphView.setVisibility(View.INVISIBLE); + } + }); + } if (animateBefore) { animateAfterShutter(); @@ -903,7 +1073,12 @@ public class PhotoModule } mJpegRotation = CameraUtil.getJpegRotation(mCameraId, orientation); mParameters.setRotation(mJpegRotation); - Location loc = mLocationManager.getCurrentLocation(); + String pictureFormat = mParameters.get(KEY_PICTURE_FORMAT); + Location loc = null; + if (pictureFormat != null && + PIXEL_FORMAT_JPEG.equalsIgnoreCase(pictureFormat)) { + loc = mLocationManager.getCurrentLocation(); + } CameraUtil.setGpsParameters(mParameters, loc); mCameraDevice.setParameters(mParameters); @@ -956,18 +1131,25 @@ public class PhotoModule // focus mode, instead, we read it from driver if (!Parameters.SCENE_MODE_AUTO.equals(mSceneMode)) { overrideCameraSettings(mParameters.getFlashMode(), - mParameters.getWhiteBalance(), mParameters.getFocusMode()); + mParameters.getWhiteBalance(), mParameters.getFocusMode(), + Integer.toString(mParameters.getExposureCompensation()), + mParameters.getTouchAfAec(), mParameters.getAutoExposure()); } else { - overrideCameraSettings(null, null, null); + overrideCameraSettings(null, null, null, null, null, null); } } private void overrideCameraSettings(final String flashMode, - final String whiteBalance, final String focusMode) { + final String whiteBalance, final String focusMode, + final String exposureMode, final String touchMode, + final String autoExposure) { mUI.overrideSettings( CameraSettings.KEY_FLASH_MODE, flashMode, CameraSettings.KEY_WHITE_BALANCE, whiteBalance, - CameraSettings.KEY_FOCUS_MODE, focusMode); + CameraSettings.KEY_FOCUS_MODE, focusMode, + CameraSettings.KEY_EXPOSURE, exposureMode, + CameraSettings.KEY_TOUCH_AF_AEC, touchMode, + CameraSettings.KEY_AUTOEXPOSURE, autoExposure); } private void loadCameraPreferences() { @@ -989,6 +1171,13 @@ public class PhotoModule mHandler.removeMessages(SHOW_TAP_TO_FOCUS_TOAST); showTapToFocusToast(); } + + // need to re-initialize mGraphView to show histogram on rotate + mGraphView = (GraphView)mRootView.findViewById(R.id.graph_view); + if(mGraphView != null){ + mGraphView.setPhotoModuleObject(this); + mGraphView.PreviewChanged(); + } } @Override @@ -1134,6 +1323,14 @@ public class PhotoModule mUI.hideSwitcher(); mUI.setSwipingEnabled(false); } + + //Need to disable focus for ZSL mode + if(mSnapshotMode == CameraInfo.CAMERA_SUPPORT_MODE_ZSL) { + mFocusManager.setZslEnable(true); + } else { + mFocusManager.setZslEnable(false); + } + // If the user wants to do a snapshot while the previous one is still // in progress, remember the fact and do it after we finish the previous // one and re-start the preview. Snapshot in progress also includes the @@ -1222,6 +1419,11 @@ public class PhotoModule return; } + if (mSkinToneSeekBar != true) + { + Log.v(TAG, "Send tone bar: mSkinToneSeekBar = " + mSkinToneSeekBar); + mHandler.sendEmptyMessage(SET_SKIN_TONE_FACTOR); + } // If first time initialization is not finished, put it in the // message queue. if (!mFirstTimeInitialized) { @@ -1360,6 +1562,10 @@ public class PhotoModule } } + protected CameraManager.CameraProxy getCamera() { + return mCameraDevice; + } + private boolean canTakePicture() { return isCameraIdle() && (mActivity.getStorageSpaceBytes() > Storage.LOW_STORAGE_THRESHOLD_BYTES); } @@ -1387,7 +1593,10 @@ public class PhotoModule || mCameraState == PREVIEW_STOPPED) { return; } - + //If Touch AF/AEC is disabled in UI, return + if(this.mTouchAfAecFlag == false) { + return; + } // Check if metering area or focus area is supported. if (!mFocusAreaSupported && !mMeteringAreaSupported) return; mFocusManager.onSingleTapUp(x, y); @@ -1416,6 +1625,36 @@ public class PhotoModule onShutterButtonClick(); } return true; + case KeyEvent.KEYCODE_DPAD_LEFT: + if ( (mCameraState != PREVIEW_STOPPED) && + (mFocusManager.getCurrentFocusState() != mFocusManager.STATE_FOCUSING) && + (mFocusManager.getCurrentFocusState() != mFocusManager.STATE_FOCUSING_SNAP_ON_FINISH) ) { + if (mbrightness > MINIMUM_BRIGHTNESS) { + mbrightness-=mbrightness_step; + /* Set the "luma-adaptation" parameter */ + mParameters = mCameraDevice.getParameters(); + mParameters.set("luma-adaptation", String.valueOf(mbrightness)); + mCameraDevice.setParameters(mParameters); + } + brightnessProgressBar.setProgress(mbrightness); + brightnessProgressBar.setVisibility(View.VISIBLE); + } + break; + case KeyEvent.KEYCODE_DPAD_RIGHT: + if ( (mCameraState != PREVIEW_STOPPED) && + (mFocusManager.getCurrentFocusState() != mFocusManager.STATE_FOCUSING) && + (mFocusManager.getCurrentFocusState() != mFocusManager.STATE_FOCUSING_SNAP_ON_FINISH) ) { + if (mbrightness < MAXIMUM_BRIGHTNESS) { + mbrightness+=mbrightness_step; + /* Set the "luma-adaptation" parameter */ + mParameters = mCameraDevice.getParameters(); + mParameters.set("luma-adaptation", String.valueOf(mbrightness)); + mCameraDevice.setParameters(mParameters); + } + brightnessProgressBar.setProgress(mbrightness); + brightnessProgressBar.setVisibility(View.VISIBLE); + } + break; case KeyEvent.KEYCODE_DPAD_CENTER: // If we get a dpad center event without any focused view, move // the focus to the shutter button and press it. @@ -1567,6 +1806,255 @@ public class PhotoModule mParameters.setZoom(mZoomValue); } } + private boolean needRestart() { + mRestartPreview = false; + String zsl = mPreferences.getString(CameraSettings.KEY_ZSL, + mActivity.getString(R.string.pref_camera_zsl_default)); + if(zsl.equals("on") && mSnapshotMode != CameraInfo.CAMERA_SUPPORT_MODE_ZSL + && mCameraState != PREVIEW_STOPPED) { + //Switch on ZSL Camera mode + Log.v(TAG, "Switching to ZSL Camera Mode. Restart Preview"); + mRestartPreview = true; + return mRestartPreview; + } + if(zsl.equals("off") && mSnapshotMode != CameraInfo.CAMERA_SUPPORT_MODE_NONZSL + && mCameraState != PREVIEW_STOPPED) { + //Switch on Normal Camera mode + Log.v(TAG, "Switching to Normal Camera Mode. Restart Preview"); + mRestartPreview = true; + return mRestartPreview; + } + return mRestartPreview; + } + + private void qcomUpdateCameraParametersPreference() { + //qcom Related Parameter update + //Set Brightness. + mParameters.set("luma-adaptation", String.valueOf(mbrightness)); + + if (Parameters.SCENE_MODE_AUTO.equals(mSceneMode)) { + // Set Touch AF/AEC parameter. + String touchAfAec = mPreferences.getString( + CameraSettings.KEY_TOUCH_AF_AEC, + mActivity.getString(R.string.pref_camera_touchafaec_default)); + if (CameraUtil.isSupported(touchAfAec, mParameters.getSupportedTouchAfAec())) { + mParameters.setTouchAfAec(touchAfAec); + } + } else { + mParameters.setTouchAfAec(mParameters.TOUCH_AF_AEC_OFF); + mFocusManager.resetTouchFocus(); + } + try { + if(mParameters.getTouchAfAec().equals(mParameters.TOUCH_AF_AEC_ON)) + this.mTouchAfAecFlag = true; + else + this.mTouchAfAecFlag = false; + } catch(Exception e){ + Log.e(TAG, "Handled NULL pointer Exception"); + } + + // Set Picture Format + // Picture Formats specified in UI should be consistent with + // PIXEL_FORMAT_JPEG and PIXEL_FORMAT_RAW constants + String pictureFormat = mPreferences.getString( + CameraSettings.KEY_PICTURE_FORMAT, + mActivity.getString(R.string.pref_camera_picture_format_default)); + mParameters.set(KEY_PICTURE_FORMAT, pictureFormat); + + // Set JPEG quality. + String jpegQuality = mPreferences.getString( + CameraSettings.KEY_JPEG_QUALITY, + mActivity.getString(R.string.pref_camera_jpegquality_default)); + //mUnsupportedJpegQuality = false; + Size pic_size = mParameters.getPictureSize(); + if (pic_size == null) { + Log.e(TAG, "error getPictureSize: size is null"); + } + else{ + if("100".equals(jpegQuality) && (pic_size.width >= 3200)){ + //mUnsupportedJpegQuality = true; + }else { + mParameters.setJpegQuality(JpegEncodingQualityMappings.getQualityNumber(jpegQuality)); + } + } + + // Set Selectable Zone Af parameter. + String selectableZoneAf = mPreferences.getString( + CameraSettings.KEY_SELECTABLE_ZONE_AF, + mActivity.getString(R.string.pref_camera_selectablezoneaf_default)); + List str = mParameters.getSupportedSelectableZoneAf(); + if (CameraUtil.isSupported(selectableZoneAf, mParameters.getSupportedSelectableZoneAf())) { + mParameters.setSelectableZoneAf(selectableZoneAf); + } + + // Set wavelet denoise mode + if (mParameters.getSupportedDenoiseModes() != null) { + String Denoise = mPreferences.getString( CameraSettings.KEY_DENOISE, + mActivity.getString(R.string.pref_camera_denoise_default)); + mParameters.setDenoise(Denoise); + } + // Set Redeye Reduction + String redeyeReduction = mPreferences.getString( + CameraSettings.KEY_REDEYE_REDUCTION, + mActivity.getString(R.string.pref_camera_redeyereduction_default)); + if (CameraUtil.isSupported(redeyeReduction, + mParameters.getSupportedRedeyeReductionModes())) { + mParameters.setRedeyeReductionMode(redeyeReduction); + } + // Set ISO parameter + String iso = mPreferences.getString( + CameraSettings.KEY_ISO, + mActivity.getString(R.string.pref_camera_iso_default)); + if (CameraUtil.isSupported(iso, + mParameters.getSupportedIsoValues())) { + mParameters.setISOValue(iso); + } + // Set color effect parameter. + String colorEffect = mPreferences.getString( + CameraSettings.KEY_COLOR_EFFECT, + mActivity.getString(R.string.pref_camera_coloreffect_default)); + Log.v(TAG, "Color effect value =" + colorEffect); + if (CameraUtil.isSupported(colorEffect, mParameters.getSupportedColorEffects())) { + mParameters.setColorEffect(colorEffect); + } + //Set Saturation + String saturationStr = mPreferences.getString( + CameraSettings.KEY_SATURATION, + mActivity.getString(R.string.pref_camera_saturation_default)); + int saturation = Integer.parseInt(saturationStr); + Log.v(TAG, "Saturation value =" + saturation); + if((0 <= saturation) && (saturation <= mParameters.getMaxSaturation())){ + mParameters.setSaturation(saturation); + } + // Set contrast parameter. + String contrastStr = mPreferences.getString( + CameraSettings.KEY_CONTRAST, + mActivity.getString(R.string.pref_camera_contrast_default)); + int contrast = Integer.parseInt(contrastStr); + Log.v(TAG, "Contrast value =" +contrast); + if((0 <= contrast) && (contrast <= mParameters.getMaxContrast())){ + mParameters.setContrast(contrast); + } + // Set sharpness parameter + String sharpnessStr = mPreferences.getString( + CameraSettings.KEY_SHARPNESS, + mActivity.getString(R.string.pref_camera_sharpness_default)); + int sharpness = Integer.parseInt(sharpnessStr) * + (mParameters.getMaxSharpness()/MAX_SHARPNESS_LEVEL); + Log.v(TAG, "Sharpness value =" + sharpness); + if((0 <= sharpness) && (sharpness <= mParameters.getMaxSharpness())){ + mParameters.setSharpness(sharpness); + } + // Set auto exposure parameter. + String autoExposure = mPreferences.getString( + CameraSettings.KEY_AUTOEXPOSURE, + mActivity.getString(R.string.pref_camera_autoexposure_default)); + Log.v(TAG, "autoExposure value =" + autoExposure); + if (CameraUtil.isSupported(autoExposure, mParameters.getSupportedAutoexposure())) { + mParameters.setAutoExposure(autoExposure); + } + + // Set anti banding parameter. + String antiBanding = mPreferences.getString( + CameraSettings.KEY_ANTIBANDING, + mActivity.getString(R.string.pref_camera_antibanding_default)); + Log.v(TAG, "antiBanding value =" + antiBanding); + if (CameraUtil.isSupported(antiBanding, mParameters.getSupportedAntibanding())) { + mParameters.setAntibanding(antiBanding); + } + + String zsl = mPreferences.getString(CameraSettings.KEY_ZSL, + mActivity.getString(R.string.pref_camera_zsl_default)); + String hdr = mPreferences.getString(CameraSettings.KEY_CAMERA_HDR, + mActivity.getString(R.string.pref_camera_hdr_default)); + mParameters.setZSLMode(zsl); + if(zsl.equals("on")) { + //Switch on ZSL Camera mode + mSnapshotMode = CameraInfo.CAMERA_SUPPORT_MODE_ZSL; + mParameters.setCameraMode(1); + mFocusManager.setZslEnable(true); + + // Currently HDR is not supported under ZSL mode + Editor editor = mPreferences.edit(); + editor.putString(CameraSettings.KEY_AE_BRACKET_HDR, mActivity.getString(R.string.setting_off_value)); + + //Raw picture format is not supported under ZSL mode + editor.putString(CameraSettings.KEY_PICTURE_FORMAT, mActivity.getString(R.string.pref_camera_picture_format_value_jpeg)); + editor.apply(); + + if(!pictureFormat.equals(PIXEL_FORMAT_JPEG)) { + mActivity.runOnUiThread(new Runnable() { + public void run() { + Toast.makeText(mActivity, R.string.error_app_unsupported_raw, + Toast.LENGTH_SHORT).show(); + } + }); + } + + if(hdr.equals(mActivity.getString(R.string.setting_on_value))) { + mActivity.runOnUiThread(new Runnable() { + public void run() { + Toast.makeText(mActivity, R.string.error_app_unsupported_hdr_zsl, + Toast.LENGTH_SHORT).show(); + } + }); + } + } else if(zsl.equals("off")) { + mSnapshotMode = CameraInfo.CAMERA_SUPPORT_MODE_NONZSL; + mParameters.setCameraMode(0); + mFocusManager.setZslEnable(false); + } + // Set face detetction parameter. + String faceDetection = mPreferences.getString( + CameraSettings.KEY_FACE_DETECTION, + mActivity.getString(R.string.pref_camera_facedetection_default)); + + if (CameraUtil.isSupported(faceDetection, mParameters.getSupportedFaceDetectionModes())) { + mParameters.setFaceDetectionMode(faceDetection); + if(faceDetection.equals("on") && mFaceDetectionEnabled == false) { + mFaceDetectionEnabled = true; + startFaceDetection(); + } + if(faceDetection.equals("off") && mFaceDetectionEnabled == true) { + stopFaceDetection(); + mFaceDetectionEnabled = false; + } + } + //Set Skin Tone Correction factor + Log.v(TAG, "set tone bar: mSceneMode = " + mSceneMode); + if(mSeekBarInitialized == true) + mHandler.sendEmptyMessage(SET_SKIN_TONE_FACTOR); + + //Set Histogram + String histogram = mPreferences.getString( + CameraSettings.KEY_HISTOGRAM, + mActivity.getString(R.string.pref_camera_histogram_default)); + if (CameraUtil.isSupported(histogram, + mParameters.getSupportedHistogramModes()) && mCameraDevice != null) { + // Call for histogram + if(histogram.equals("enable")) { + mActivity.runOnUiThread(new Runnable() { + public void run() { + if(mGraphView != null) { + mGraphView.setVisibility(View.VISIBLE); + mGraphView.PreviewChanged(); + } + } + }); + mCameraDevice.setHistogramMode(mStatsCallback); + mHiston = true; + } else { + mHiston = false; + mActivity.runOnUiThread(new Runnable() { + public void run() { + if (mGraphView != null) + mGraphView.setVisibility(View.INVISIBLE); + } + }); + mCameraDevice.setHistogramMode(null); + } + } + } @TargetApi(Build.VERSION_CODES.JELLY_BEAN) private void setAutoExposureLockIfSupported() { @@ -1606,9 +2094,19 @@ public class PhotoModule if (pictureSize == null) { CameraSettings.initialCameraPictureSize(mActivity, mParameters); } else { + Size old_size = mParameters.getPictureSize(); + Log.v(TAG, "old picture_size = " + old_size.width + " x " + old_size.height); List supported = mParameters.getSupportedPictureSizes(); CameraSettings.setCameraPictureSize( pictureSize, supported, mParameters); + Size size = mParameters.getPictureSize(); + Log.v(TAG, "new picture_size = " + size.width + " x " + size.height); + if (old_size != null && size != null) { + if(!size.equals(old_size) && mCameraState != PREVIEW_STOPPED) { + Log.v(TAG, "Picture Size changed. Restart Preview"); + mRestartPreview = true; + } + } } Size size = mParameters.getPictureSize(); @@ -1630,6 +2128,8 @@ public class PhotoModule mCameraDevice.setParameters(mParameters); } mParameters = mCameraDevice.getParameters(); + Log.v(TAG, "Preview Size changed. Restart Preview"); + mRestartPreview = true; } Log.v(TAG, "Preview size is " + optimalSize.width + "x" + optimalSize.height); @@ -1732,7 +2232,8 @@ public class PhotoModule if (mContinuousFocusSupported && ApiHelper.HAS_AUTO_FOCUS_MOVE_CALLBACK) { updateAutoFocusMoveCallback(); } - + //QCom related parameters updated here. + qcomUpdateCameraParametersPreference(); return doGcamModeSwitch; } @@ -1783,6 +2284,13 @@ public class PhotoModule return; } else if (isCameraIdle()) { setCameraParameters(mUpdateSet); + if(mRestartPreview && mCameraState != PREVIEW_STOPPED) { + Log.v(TAG, "Restarting Preview..."); + stopPreview(); + startPreview(); + setCameraState(IDLE); + } + mRestartPreview = false; updateSceneMode(); updateHdrMode(); mUpdateSet = 0; @@ -1825,9 +2333,30 @@ public class PhotoModule boolean recordLocation = RecordLocationPreference.get( mPreferences, mContentResolver); mLocationManager.recordLocation(recordLocation); - + if(needRestart()){ + Log.v(TAG, "Restarting Preview... Camera Mode Changhed"); + stopPreview(); + startPreview(); + setCameraState(IDLE); + mRestartPreview = false; + } setCameraParametersWhenIdle(UPDATE_PARAM_PREFERENCE); - mUI.updateOnScreenIndicators(mParameters, mPreferenceGroup, mPreferences); + mUI.updateOnScreenIndicators(mParameters, mPreferenceGroup,mPreferences); + if (mSeekBarInitialized == true){ + Log.v(TAG, "onSharedPreferenceChanged Skin tone bar: change"); + // skin tone is enabled only for party and portrait BSM + // when color effects are not enabled + String colorEffect = mPreferences.getString( + CameraSettings.KEY_COLOR_EFFECT, + mActivity.getString(R.string.pref_camera_coloreffect_default)); + if((Parameters.SCENE_MODE_PARTY.equals(mSceneMode) || + Parameters.SCENE_MODE_PORTRAIT.equals(mSceneMode)) && + (Parameters.EFFECT_NONE.equals(colorEffect))) { + Log.v(TAG, "Party/Portrait + No effect, SkinToneBar enabled"); + } else { + disableSkinToneSeekBar(); + } + } } @Override @@ -1967,44 +2496,222 @@ public class PhotoModule mHeading += 360; } } - @Override public void onPreviewFocusChanged(boolean previewFocused) { mUI.onPreviewFocusChanged(previewFocused); } - + // TODO: Delete this function after old camera code is removed @Override - public boolean arePreviewControlsVisible() { - return mUI.arePreviewControlsVisible(); - } + public void onRestorePreferencesClicked() {} + private void setSkinToneFactor() { + if(mCameraDevice == null || mParameters == null || skinToneSeekBar == null) + return; - // For debugging only. - public void setDebugUri(Uri uri) { - mDebugUri = uri; - } + String skinToneEnhancementPref = "enable"; + if(CameraUtil.isSupported(skinToneEnhancementPref, + mParameters.getSupportedSkinToneEnhancementModes())) { + if(skinToneEnhancementPref.equals("enable")) { + int skinToneValue =0; + int progress; + //get the value for the first time! + if (mskinToneValue ==0) { + String factor = mPreferences.getString( + CameraSettings.KEY_SKIN_TONE_ENHANCEMENT_FACTOR, "0"); + skinToneValue = Integer.parseInt(factor); + } - // For debugging only. - private void saveToDebugUri(byte[] data) { - if (mDebugUri != null) { - OutputStream outputStream = null; - try { - outputStream = mContentResolver.openOutputStream(mDebugUri); - outputStream.write(data); - outputStream.close(); - } catch (IOException e) { - Log.e(TAG, "Exception while writing debug jpeg file", e); - } finally { - CameraUtil.closeSilently(outputStream); + Log.v(TAG, "Skin tone bar: enable = " + mskinToneValue); + enableSkinToneSeekBar(); + //As a wrokaround set progress again to show the actually progress on screen. + if (skinToneValue != 0) { + progress = (skinToneValue/SCE_FACTOR_STEP)-MIN_SCE_FACTOR; + skinToneSeekBar.setProgress(progress); + } + } else { + Log.v(TAG, "Skin tone bar: disable"); + disableSkinToneSeekBar(); } + } else { + Log.v(TAG, "Skin tone bar: Not supported"); + skinToneSeekBar.setVisibility(View.INVISIBLE); } } -/* Below is no longer needed, except to get rid of compile error - * TODO: Remove these - */ + private void enableSkinToneSeekBar() { + int progress; + if(brightnessProgressBar != null) + brightnessProgressBar.setVisibility(View.INVISIBLE); + skinToneSeekBar.setMax(MAX_SCE_FACTOR-MIN_SCE_FACTOR); + skinToneSeekBar.setVisibility(View.VISIBLE); + skinToneSeekBar.requestFocus(); + if (mskinToneValue != 0) { + progress = (mskinToneValue/SCE_FACTOR_STEP)-MIN_SCE_FACTOR; + mskinToneSeekListener.onProgressChanged(skinToneSeekBar, progress, false); + } else { + progress = (MAX_SCE_FACTOR-MIN_SCE_FACTOR)/2; + RightValue.setText(""); + LeftValue.setText(""); + } + skinToneSeekBar.setProgress(progress); + Title.setText("Skin Tone Enhancement"); + Title.setVisibility(View.VISIBLE); + RightValue.setVisibility(View.VISIBLE); + LeftValue.setVisibility(View.VISIBLE); + mSkinToneSeekBar = true; + } + + private void disableSkinToneSeekBar() { + skinToneSeekBar.setVisibility(View.INVISIBLE); + Title.setVisibility(View.INVISIBLE); + RightValue.setVisibility(View.INVISIBLE); + LeftValue.setVisibility(View.INVISIBLE); + mskinToneValue = 0; + mSkinToneSeekBar = false; + Editor editor = mPreferences.edit(); + editor.putString(CameraSettings.KEY_SKIN_TONE_ENHANCEMENT_FACTOR, + Integer.toString(mskinToneValue - MIN_SCE_FACTOR)); + editor.apply(); + if(brightnessProgressBar != null) + brightnessProgressBar.setVisibility(View.VISIBLE); + } +} +class JpegEncodingQualityMappings { + private static final String TAG = "JpegEncodingQualityMappings"; + private static final int DEFAULT_QUALITY = 85; + private static HashMap mHashMap = + new HashMap(); + + static { + mHashMap.put("normal", CameraProfile.QUALITY_LOW); + mHashMap.put("fine", CameraProfile.QUALITY_MEDIUM); + mHashMap.put("superfine", CameraProfile.QUALITY_HIGH); + } + + // Retrieve and return the Jpeg encoding quality number + // for the given quality level. + public static int getQualityNumber(String jpegQuality) { + try{ + int qualityPercentile = Integer.parseInt(jpegQuality); + if(qualityPercentile >= 0 && qualityPercentile <=100) + return qualityPercentile; + else + return DEFAULT_QUALITY; + } catch(NumberFormatException nfe){ + //chosen quality is not a number, continue + } + Integer quality = mHashMap.get(jpegQuality); + if (quality == null) { + Log.w(TAG, "Unknown Jpeg quality: " + jpegQuality); + return DEFAULT_QUALITY; + } + return CameraProfile.getJpegEncodingQualityParameter(quality.intValue()); + } +} - // TODO: Delete this function after old camera code is removed +class GraphView extends View { + private Bitmap mBitmap; + private Paint mPaint = new Paint(); + private Paint mPaintRect = new Paint(); + private Canvas mCanvas = new Canvas(); + private float mScale = (float)3; + private float mWidth; + private float mHeight; + private PhotoModule mPhotoModule; + private CameraManager.CameraProxy mGraphCameraDevice; + private float scaled; + private static final int STATS_SIZE = 256; + private static final String TAG = "GraphView"; + + + public GraphView(Context context, AttributeSet attrs) { + super(context,attrs); + + mPaint.setFlags(Paint.ANTI_ALIAS_FLAG); + mPaintRect.setColor(0xFFFFFFFF); + mPaintRect.setStyle(Paint.Style.FILL); + } @Override - public void onRestorePreferencesClicked() {} + protected void onSizeChanged(int w, int h, int oldw, int oldh) { + mBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.RGB_565); + mCanvas.setBitmap(mBitmap); + mWidth = w; + mHeight = h; + super.onSizeChanged(w, h, oldw, oldh); + } + @Override + protected void onDraw(Canvas canvas) { + Log.v(TAG, "in Camera.java ondraw"); + //don't display histogram if user swipes to gallery during preview + //boolean inCamPreview = ActivityBase.getCameraAppViewStatus(); + if(mPhotoModule != null){ + PreviewChanged(); + return; + } + + if(mPhotoModule == null || !mPhotoModule.mHiston ) { + Log.e(TAG, "returning as histogram is off "); + return; + } + if (mBitmap != null) { + final Paint paint = mPaint; + final Canvas cavas = mCanvas; + final float border = 5; + float graphheight = mHeight - (2 * border); + float graphwidth = mWidth - (2 * border); + float left,top,right,bottom; + float bargap = 0.0f; + float barwidth = graphwidth/STATS_SIZE; + + cavas.drawColor(0xFFAAAAAA); + paint.setColor(Color.BLACK); + + for (int k = 0; k <= (graphheight /32) ; k++) { + float y = (float)(32 * k)+ border; + cavas.drawLine(border, y, graphwidth + border , y, paint); + } + for (int j = 0; j <= (graphwidth /32); j++) { + float x = (float)(32 * j)+ border; + cavas.drawLine(x, border, x, graphheight + border, paint); + } + synchronized(PhotoModule.statsdata) { + //Assumption: The first element contains + // the maximum value. + int maxValue = Integer.MIN_VALUE; + if ( 0 == PhotoModule.statsdata[0] ) { + for ( int i = 1 ; i <= STATS_SIZE ; i++ ) { + if ( maxValue < PhotoModule.statsdata[i] ) { + maxValue = PhotoModule.statsdata[i]; + } + } + } else { + maxValue = PhotoModule.statsdata[0]; + } + mScale = ( float ) maxValue; + for(int i=1 ; i<=STATS_SIZE ; i++) { + scaled = (PhotoModule.statsdata[i]/mScale)*STATS_SIZE; + if(scaled >= (float)STATS_SIZE) + scaled = (float)STATS_SIZE; + left = (bargap * (i+1)) + (barwidth * i) + border; + top = graphheight + border; + right = left + barwidth; + bottom = top - scaled; + cavas.drawRect(left, top, right, bottom, mPaintRect); + } + } + canvas.drawBitmap(mBitmap, 0, 0, null); + } + if (mPhotoModule.mHiston && mPhotoModule!= null) { + mGraphCameraDevice = mPhotoModule.getCamera(); + if (mGraphCameraDevice != null){ + mGraphCameraDevice.sendHistogramData(); + } + } + } + public void PreviewChanged() { + invalidate(); + } + public void setPhotoModuleObject(PhotoModule photoModule) { + mPhotoModule = photoModule; + } } diff --git a/src/com/android/camera/VideoMenu.java b/src/com/android/camera/VideoMenu.java index 8db219924..afe8d312e 100644 --- a/src/com/android/camera/VideoMenu.java +++ b/src/com/android/camera/VideoMenu.java @@ -36,7 +36,11 @@ public class VideoMenu extends PieController private static String TAG = "CAM_VideoMenu"; private VideoUI mUI; - private String[] mOtherKeys; + private String[] mOtherKeys1; + private String[] mOtherKeys2; + private MoreSettingPopup mPopup1; + private MoreSettingPopup mPopup2; + private AbstractSettingPopup mPopup; private static final int POPUP_NONE = 0; @@ -51,19 +55,15 @@ public class VideoMenu extends PieController mActivity = activity; } - public void initialize(PreferenceGroup group) { super.initialize(group); mPopup = null; + mPopup1 = null; + mPopup2 = null; mPopupStatus = POPUP_NONE; PieItem item = null; - // white balance - if (group.findPreference(CameraSettings.KEY_WHITE_BALANCE) != null) { - item = makeItem(CameraSettings.KEY_WHITE_BALANCE); - mRenderer.addItem(item); - } // settings popup - mOtherKeys = new String[] { + mOtherKeys1 = new String[] { CameraSettings.KEY_VIDEO_EFFECT, CameraSettings.KEY_VIDEO_TIME_LAPSE_FRAME_INTERVAL, CameraSettings.KEY_VIDEO_QUALITY, @@ -72,19 +72,44 @@ public class VideoMenu extends PieController CameraSettings.KEY_VIDEO_DURATION, CameraSettings.KEY_RECORD_LOCATION }; - item = makeItem(R.drawable.ic_settings_holo_light); - item.setLabel(mActivity.getResources().getString(R.string.camera_menu_settings_label)); - item.setOnClickListener(new OnClickListener() { + + //settings popup + mOtherKeys2 = new String[] { + CameraSettings.KEY_COLOR_EFFECT, + CameraSettings.KEY_POWER_MODE, + CameraSettings.KEY_WHITE_BALANCE, + CameraSettings.KEY_VIDEO_HIGH_FRAME_RATE, + CameraSettings.KEY_VIDEOCAMERA_FLASH_MODE, + }; + + PieItem item1 = makeItem(R.drawable.ic_settings_holo_light); + item1.setLabel(mActivity.getResources().getString(R.string.camera_menu_more_label)); + item1.setOnClickListener(new OnClickListener() { + @Override + public void onClick(PieItem item) { + if (mPopup1 == null || mPopupStatus != POPUP_FIRST_LEVEL) { + initializePopup(); + mPopupStatus = POPUP_FIRST_LEVEL; + } + mUI.showPopup(mPopup1); + } + }); + mRenderer.addItem(item1); + + PieItem item2 = makeItem(R.drawable.ic_settings_holo_light); + item2.setLabel(mActivity.getResources().getString(R.string.camera_menu_more_label)); + item2.setOnClickListener(new OnClickListener() { @Override public void onClick(PieItem item) { - if (mPopup == null || mPopupStatus != POPUP_FIRST_LEVEL) { + if (mPopup2 == null || mPopupStatus != POPUP_FIRST_LEVEL) { initializePopup(); mPopupStatus = POPUP_FIRST_LEVEL; } - mUI.showPopup(mPopup); + mUI.showPopup(mPopup2); } }); - mRenderer.addItem(item); + mRenderer.addItem(item2); + // camera switcher if (group.findPreference(CameraSettings.KEY_CAMERA_ID) != null) { item = makeItem(R.drawable.ic_switch_back); @@ -117,18 +142,16 @@ public class VideoMenu extends PieController }); mRenderer.addItem(item); } - // flash - if (group.findPreference(CameraSettings.KEY_VIDEOCAMERA_FLASH_MODE) != null) { - item = makeItem(CameraSettings.KEY_VIDEOCAMERA_FLASH_MODE); - mRenderer.addItem(item); - } } @Override public void reloadPreferences() { super.reloadPreferences(); - if (mPopup != null) { - mPopup.reloadPreference(); + if (mPopup1 != null) { + mPopup1.reloadPreference(); + } + if (mPopup2 != null) { + mPopup2.reloadPreference(); } } @@ -145,7 +168,7 @@ public class VideoMenu extends PieController @Override // Hit when an item in the second-level popup gets selected public void onListPrefChanged(ListPreference pref) { - if (mPopup != null) { + if (mPopup1 != null && mPopup2 != null) { if (mPopupStatus == POPUP_SECOND_LEVEL) { mUI.dismissPopup(true); } @@ -157,15 +180,21 @@ public class VideoMenu extends PieController LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService( Context.LAYOUT_INFLATER_SERVICE); - MoreSettingPopup popup = (MoreSettingPopup) inflater.inflate( + MoreSettingPopup popup1 = (MoreSettingPopup) inflater.inflate( R.layout.more_setting_popup, null, false); - popup.setSettingChangedListener(this); - popup.initialize(mPreferenceGroup, mOtherKeys); + popup1.setSettingChangedListener(this); + popup1.initialize(mPreferenceGroup, mOtherKeys1); if (mActivity.isSecureCamera()) { // Prevent location preference from getting changed in secure camera mode - popup.setPreferenceEnabled(CameraSettings.KEY_RECORD_LOCATION, false); + popup1.setPreferenceEnabled(CameraSettings.KEY_RECORD_LOCATION, false); } - mPopup = popup; + mPopup1 = popup1; + + MoreSettingPopup popup2 = (MoreSettingPopup) inflater.inflate( + R.layout.more_setting_popup, null, false); + popup2.setSettingChangedListener(this); + popup2.initialize(mPreferenceGroup, mOtherKeys2); + mPopup2 = popup2; } public void popupDismissed(boolean topPopupOnly) { @@ -204,4 +233,5 @@ public class VideoMenu extends PieController mUI.showPopup(mPopup); mPopupStatus = POPUP_SECOND_LEVEL; } + } diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java index 0ad5901ba..c40e98760 100644 --- a/src/com/android/camera/VideoModule.java +++ b/src/com/android/camera/VideoModule.java @@ -29,6 +29,7 @@ import android.content.SharedPreferences.Editor; import android.content.res.Configuration; import android.graphics.Bitmap; import android.graphics.SurfaceTexture; +import android.graphics.ImageFormat; import android.hardware.Camera.CameraInfo; import android.hardware.Camera.Parameters; import android.hardware.Camera.Size; @@ -41,6 +42,7 @@ import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.Message; +import android.os.SystemProperties; import android.os.ParcelFileDescriptor; import android.os.SystemClock; import android.provider.MediaStore; @@ -281,7 +283,8 @@ public class VideoModule implements CameraModule, private int videoWidth; private int videoHeight; boolean mUnsupportedResolution = false; - + private boolean mUnsupportedHFRVideoSize = false; + private boolean mUnsupportedHFRVideoCodec = false; // This Handler is used to post message back onto the main thread of the // application @@ -1614,6 +1617,63 @@ public class VideoModule implements CameraModule, return supported == null ? false : supported.indexOf(value) >= 0; } + private void qcomSetCameraParameters(){ + // add QCOM Parameters here + // Set color effect parameter. + String colorEffect = mPreferences.getString( + CameraSettings.KEY_COLOR_EFFECT, + mActivity.getString(R.string.pref_camera_coloreffect_default)); + Log.v(TAG, "Color effect value =" + colorEffect); + if (isSupported(colorEffect, mParameters.getSupportedColorEffects())) { + mParameters.setColorEffect(colorEffect); + } + + mUnsupportedHFRVideoSize = false; + mUnsupportedHFRVideoCodec = false; + // To set preview format as YV12 , run command + // "adb shell setprop "debug.camera.yv12" true" + String yv12formatset = SystemProperties.get("debug.camera.yv12"); + if(yv12formatset.equals("true")) { + Log.v(TAG, "preview format set to YV12"); + mParameters.setPreviewFormat (ImageFormat.YV12); + } + + // Set High Frame Rate. + String HighFrameRate = mPreferences.getString( + CameraSettings.KEY_VIDEO_HIGH_FRAME_RATE, + mActivity. getString(R.string.pref_camera_hfr_default)); + if(!("off".equals(HighFrameRate))){ + mUnsupportedHFRVideoSize = true; + String hfrsize = videoWidth+"x"+videoHeight; + Log.v(TAG, "current set resolution is : "+hfrsize); + try { + for(Size size : mParameters.getSupportedHfrSizes()){ + if(size != null) { + Log.v(TAG, "supported hfr size : "+ size.width+ " "+size.height); + if(videoWidth <= size.width && videoHeight <= size.height) { + mUnsupportedHFRVideoSize = false; + Log.v(TAG,"Current hfr resolution is supported"); + break; + } + } + } + } catch (NullPointerException e){ + Log.e(TAG, "supported hfr sizes is null"); + } + + if(mUnsupportedHFRVideoSize) + Log.v(TAG,"Unsupported hfr resolution"); + + if(mVideoEncoder != MediaRecorder.VideoEncoder.H264) + mUnsupportedHFRVideoCodec = true; + } + if (isSupported(HighFrameRate, + mParameters.getSupportedVideoHighFrameRateModes()) && + !mUnsupportedHFRVideoSize) { + mParameters.setVideoHighFrameRate(HighFrameRate); + } else + mParameters.setVideoHighFrameRate("off"); + } @SuppressWarnings("deprecation") private void setCameraParameters() { mParameters.setPreviewSize(mDesiredPreviewWidth, mDesiredPreviewHeight); @@ -1686,7 +1746,8 @@ public class VideoModule implements CameraModule, int jpegQuality = CameraProfile.getJpegEncodingQualityParameter(mCameraId, CameraProfile.QUALITY_HIGH); mParameters.setJpegQuality(jpegQuality); - + //Call Qcom related Camera Parameters + qcomSetCameraParameters(); mCameraDevice.setParameters(mParameters); // Keep preview size up to date. mParameters = mCameraDevice.getParameters(); -- cgit v1.2.3