summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorweijiew <weijiew@codeaurora.org>2016-12-23 16:19:43 +0800
committerweijiew <weijiew@codeaurora.org>2016-12-23 17:01:48 +0800
commit8815dd2a2fdf3a778099a5f5c14d334cc72b6ff8 (patch)
tree84a47db915de53ed40e39c1a22b8d86abe256c23
parentd92a952b0cfe8e570f85112bc9a4c65729e7ffed (diff)
downloadandroid_packages_apps_Snap-8815dd2a2fdf3a778099a5f5c14d334cc72b6ff8.tar.gz
android_packages_apps_Snap-8815dd2a2fdf3a778099a5f5c14d334cc72b6ff8.tar.bz2
android_packages_apps_Snap-8815dd2a2fdf3a778099a5f5c14d334cc72b6ff8.zip
SnapdragonCamera: Add features to developer option
Description: 1、Add Histogram support to developer option 2、Add HDR & Non-HDR support to developer option 3、Add Saturation Level support to developer option 4、Add Anti Banding support to developer option Change-Id: I2db7e1be65a6b3ee04ebc46cb214dc1cc9667fc6 CRs-Fixed: 1103649
-rw-r--r--[-rwxr-xr-x]res/layout/capture_module.xml28
-rw-r--r--[-rwxr-xr-x]res/values/camera2arrays.xml72
-rw-r--r--[-rwxr-xr-x]res/values/qcomstrings.xml36
-rw-r--r--[-rwxr-xr-x]res/xml/capture_preferences.xml28
-rw-r--r--[-rwxr-xr-x]res/xml/setting_menu_preferences.xml40
-rw-r--r--[-rwxr-xr-x]src/com/android/camera/CaptureModule.java280
-rw-r--r--[-rwxr-xr-x]src/com/android/camera/SettingsActivity.java11
-rw-r--r--[-rwxr-xr-x]src/com/android/camera/SettingsManager.java78
-rw-r--r--src/com/android/camera/imageprocessor/PostProcessor.java3
9 files changed, 574 insertions, 2 deletions
diff --git a/res/layout/capture_module.xml b/res/layout/capture_module.xml
index 44d5c59c6..82249f42d 100755..100644
--- a/res/layout/capture_module.xml
+++ b/res/layout/capture_module.xml
@@ -60,6 +60,34 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"/>
+ <com.android.camera.Camera2GraphView
+ android:id="@+id/graph_view_r"
+ android:visibility="gone"
+ android:layout_width="100dip"
+ android:layout_height="100dip"
+ android:layout_marginTop="70dip"
+ android:layout_marginLeft="10dip" />
+ <com.android.camera.Camera2GraphView
+ android:id="@+id/graph_view_gr"
+ android:visibility="gone"
+ android:layout_width="100dip"
+ android:layout_height="100dip"
+ android:layout_marginTop="70dip"
+ android:layout_marginLeft="120dip" />
+ <com.android.camera.Camera2GraphView
+ android:id="@+id/graph_view_gb"
+ android:visibility="gone"
+ android:layout_width="100dip"
+ android:layout_height="100dip"
+ android:layout_marginTop="70dip"
+ android:layout_marginLeft="230dip" />
+ <com.android.camera.Camera2GraphView
+ android:id="@+id/graph_view_b"
+ android:visibility="gone"
+ android:layout_width="100dip"
+ android:layout_height="100dip"
+ android:layout_marginTop="180dip"
+ android:layout_marginLeft="10dip" />
</FrameLayout>
<com.android.camera.ui.RenderOverlay
diff --git a/res/values/camera2arrays.xml b/res/values/camera2arrays.xml
index ca6234944..204638ccc 100755..100644
--- a/res/values/camera2arrays.xml
+++ b/res/values/camera2arrays.xml
@@ -958,4 +958,76 @@ for time lapse recording -->
<item>@string/pref_camera2_instant_aec_entry_aggressive</item>
<item>@string/pref_camera2_instant_aec_entry_fast</item>
</string-array>
+
+ <string-array name="pref_camera2_anti_banding_level_entryvalues" translatable="false">
+ <item>0</item>
+ <item>1</item>
+ <item>2</item>
+ <item>3</item>
+ </string-array>
+
+ <string-array name="pref_camera2_anti_banding_level_entries" translatable="true">
+ <item>@string/pref_camera2_anti_banding_level_entry_off</item>
+ <item>@string/pref_camera2_anti_banding_level_entry_50hz</item>
+ <item>@string/pref_camera2_anti_banding_level_entry_60hz</item>
+ <item>@string/pref_camera2_anti_banding_level_entry_auto</item>
+ </string-array>
+
+ <string-array name="pref_camera2_saturation_level_entryvalues" translatable="false">
+ <item>0</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>
+
+ <string-array name="pref_camera2_saturation_level_entries" translatable="true">
+ <item>@string/pref_camera2_saturation_level_entry_0</item>
+ <item>@string/pref_camera2_saturation_level_entry_1</item>
+ <item>@string/pref_camera2_saturation_level_entry_2</item>
+ <item>@string/pref_camera2_saturation_level_entry_3</item>
+ <item>@string/pref_camera2_saturation_level_entry_4</item>
+ <item>@string/pref_camera2_saturation_level_entry_5</item>
+ <item>@string/pref_camera2_saturation_level_entry_6</item>
+ <item>@string/pref_camera2_saturation_level_entry_7</item>
+ <item>@string/pref_camera2_saturation_level_entry_8</item>
+ <item>@string/pref_camera2_saturation_level_entry_9</item>
+ <item>@string/pref_camera2_saturation_level_entry_10</item>
+ </string-array>
+
+ <string-array name="pref_camera2_histogram_entryvalues" translatable="false">
+ <item>enable</item>
+ <item>disable</item>
+ </string-array>
+
+ <string-array name="pref_camera2_histogram_entries" translatable="true">
+ <item>@string/pref_camera2_histogram_entry_enable</item>
+ <item>@string/pref_camera2_histogram_entry_disable</item>
+ </string-array>
+
+ <string-array name="pref_camera2_hdr_entryvalues" translatable="false">
+ <item>enable</item>
+ <item>disable</item>
+ </string-array>
+
+ <string-array name="pref_camera2_hdr_entries" translatable="true">
+ <item>@string/pref_camera2_hdr_entry_enable</item>
+ <item>@string/pref_camera2_hdr_entry_disable</item>
+ </string-array>
+
+ <string-array name="pref_camera2_auto_hdr_entryvalues" translatable="false">
+ <item>enable</item>
+ <item>disable</item>
+ </string-array>
+
+ <string-array name="pref_camera2_auto_hdr_entries" translatable="true">
+ <item>@string/pref_camera2_auto_hdr_entry_enable</item>
+ <item>@string/pref_camera2_auto_hdr_entry_disable</item>
+ </string-array>
</resources>
diff --git a/res/values/qcomstrings.xml b/res/values/qcomstrings.xml
index 526e72021..70b211d0a 100755..100644
--- a/res/values/qcomstrings.xml
+++ b/res/values/qcomstrings.xml
@@ -1086,5 +1086,41 @@
<string name="pref_camera2_instant_aec_entry_disable" translatable="true">Disable</string>
<string name="pref_camera2_instant_aec_entry_aggressive" translatable="true">Aggressive AEC</string>
<string name="pref_camera2_instant_aec_entry_fast" translatable="true">Fast AEC</string>
+
+ <string name="pref_camera2_saturation_level_title" translatable="true">Saturation Level</string>
+ <string name="pref_camera2_saturation_level_default" translatable="false">5</string>
+ <string name="pref_camera2_saturation_level_entry_0" translatable="true">Level 0</string>
+ <string name="pref_camera2_saturation_level_entry_1" translatable="true">Level 1</string>
+ <string name="pref_camera2_saturation_level_entry_2" translatable="true">Level 2</string>
+ <string name="pref_camera2_saturation_level_entry_3" translatable="true">Level 3</string>
+ <string name="pref_camera2_saturation_level_entry_4" translatable="true">Level 4</string>
+ <string name="pref_camera2_saturation_level_entry_5" translatable="true">Level 5(Default)</string>
+ <string name="pref_camera2_saturation_level_entry_6" translatable="true">Level 6</string>
+ <string name="pref_camera2_saturation_level_entry_7" translatable="true">Level 7</string>
+ <string name="pref_camera2_saturation_level_entry_8" translatable="true">Level 8</string>
+ <string name="pref_camera2_saturation_level_entry_9" translatable="true">Level 9</string>
+ <string name="pref_camera2_saturation_level_entry_10" translatable="true">Level 10</string>
+
+ <string name="pref_camera2_anti_banding_level_title" translatable="true">Anti Banding Level</string>
+ <string name="pref_camera2_anti_banding_level_default" translatable="false">0</string>
+ <string name="pref_camera2_anti_banding_level_entry_off" translatable="true">Off</string>
+ <string name="pref_camera2_anti_banding_level_entry_50hz" translatable="true">50HZ</string>
+ <string name="pref_camera2_anti_banding_level_entry_60hz" translatable="true">60HZ</string>
+ <string name="pref_camera2_anti_banding_level_entry_auto" translatable="true">Auto</string>
+
+ <string name="pref_camera2_histogram_title" translatable="true">Histogram</string>
+ <string name="pref_camera2_histogram_default" translatable="false">disable</string>
+ <string name="pref_camera2_histogram_entry_enable" translatable="true">Enable</string>
+ <string name="pref_camera2_histogram_entry_disable" translatable="true">Disable</string>
+
+ <string name="pref_camera2_hdr_title" translatable="true">HDR &amp; Non-HDR</string>
+ <string name="pref_camera2_hdr_default" translatable="false">disable</string>
+ <string name="pref_camera2_hdr_entry_enable" translatable="true">Enable</string>
+ <string name="pref_camera2_hdr_entry_disable" translatable="true">Disable</string>
+
+ <string name="pref_camera2_auto_hdr_title" translatable="true">AUTO HDR</string>
+ <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>
</resources>
diff --git a/res/xml/capture_preferences.xml b/res/xml/capture_preferences.xml
index cab23a027..67893979e 100755..100644
--- a/res/xml/capture_preferences.xml
+++ b/res/xml/capture_preferences.xml
@@ -307,4 +307,32 @@
camera:entryValues="@array/pref_camera2_instant_aec_entryvalues"
camera:key="pref_camera2_instant_aec_key"
camera:title="@string/pref_camera2_instant_aec_title" />
+
+ <ListPreference
+ camera:defaultValue="@string/pref_camera2_saturation_level_default"
+ camera:entries="@array/pref_camera2_saturation_level_entries"
+ camera:entryValues="@array/pref_camera2_saturation_level_entryvalues"
+ camera:key="pref_camera2_saturation_level_key"
+ camera:title="@string/pref_camera2_saturation_level_title" />
+
+ <ListPreference
+ camera:defaultValue="@string/pref_camera2_anti_banding_level_default"
+ camera:entries="@array/pref_camera2_anti_banding_level_entries"
+ camera:entryValues="@array/pref_camera2_anti_banding_level_entryvalues"
+ camera:key="pref_camera2_anti_banding_level_key"
+ camera:title="@string/pref_camera2_anti_banding_level_title" />
+
+ <ListPreference
+ camera:defaultValue="@string/pref_camera2_histogram_default"
+ camera:entries="@array/pref_camera2_histogram_entries"
+ camera:entryValues="@array/pref_camera2_histogram_entryvalues"
+ camera:key="pref_camera2_histogram_key"
+ camera:title="@string/pref_camera2_histogram_title" />
+
+ <ListPreference
+ camera:defaultValue="@string/pref_camera2_hdr_default"
+ camera:entries="@array/pref_camera2_hdr_entries"
+ camera:entryValues="@array/pref_camera2_hdr_entryvalues"
+ camera:key="pref_camera2_hdr_key"
+ camera:title="@string/pref_camera2_hdr_title" />
</PreferenceGroup>
diff --git a/res/xml/setting_menu_preferences.xml b/res/xml/setting_menu_preferences.xml
index 31e5475c0..94f6fd9f7 100755..100644
--- a/res/xml/setting_menu_preferences.xml
+++ b/res/xml/setting_menu_preferences.xml
@@ -289,5 +289,45 @@
android:layout="@layout/preference"
android:summary="%s"
android:title="@string/pref_camera2_instant_aec_title" />
+ <ListPreference
+ android:defaultValue="@string/pref_camera2_saturation_level_default"
+ android:entries="@array/pref_camera2_saturation_level_entries"
+ android:entryValues="@array/pref_camera2_saturation_level_entryvalues"
+ android:key="pref_camera2_saturation_level_key"
+ android:layout="@layout/preference"
+ android:summary="%s"
+ android:title="@string/pref_camera2_saturation_level_title" />
+ <ListPreference
+ android:defaultValue="@string/pref_camera2_anti_banding_level_default"
+ android:entries="@array/pref_camera2_anti_banding_level_entries"
+ android:entryValues="@array/pref_camera2_anti_banding_level_entryvalues"
+ android:key="pref_camera2_anti_banding_level_key"
+ android:layout="@layout/preference"
+ android:summary="%s"
+ android:title="@string/pref_camera2_anti_banding_level_title" />
+ <ListPreference
+ android:defaultValue="@string/pref_camera2_histogram_default"
+ android:entries="@array/pref_camera2_histogram_entries"
+ android:entryValues="@array/pref_camera2_histogram_entryvalues"
+ android:key="pref_camera2_histogram_key"
+ android:layout="@layout/preference"
+ android:summary="%s"
+ android:title="@string/pref_camera2_histogram_title" />
+ <ListPreference
+ android:defaultValue="@string/pref_camera2_hdr_default"
+ android:entries="@array/pref_camera2_hdr_entries"
+ android:entryValues="@array/pref_camera2_hdr_entryvalues"
+ android:key="pref_camera2_hdr_key"
+ android:layout="@layout/preference"
+ android:summary="%s"
+ android:title="@string/pref_camera2_hdr_title" />
+ <ListPreference
+ android:defaultValue="@string/pref_camera2_auto_hdr_default"
+ android:entries="@array/pref_camera2_auto_hdr_entries"
+ android:entryValues="@array/pref_camera2_auto_hdr_entryvalues"
+ android:key="pref_camera2_auto_hdr_key"
+ android:layout="@layout/preference"
+ android:summary="%s"
+ android:title="@string/pref_camera2_auto_hdr_title" />
</PreferenceCategory>
</PreferenceScreen>
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java
index 64b97e6ed..670047af1 100755..100644
--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -77,6 +77,11 @@ import android.view.SurfaceHolder;
import android.view.View;
import android.view.WindowManager;
import android.widget.Toast;
+import android.graphics.Paint;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.util.AttributeSet;
+import android.graphics.Bitmap;
import com.android.camera.exif.ExifInterface;
import com.android.camera.imageprocessor.filter.BlurbusterFilter;
@@ -208,6 +213,16 @@ public class CaptureModule implements CameraModule, PhotoController,
new CameraCharacteristics.Key<>("org.codeaurora.qcamera3.instant_aec.instant_aec_available_modes", int[].class);
public static final CaptureRequest.Key<Integer> INSTANT_AEC_MODE =
new CaptureRequest.Key<>("org.codeaurora.qcamera3.instant_aec.instant_aec_mode", Integer.class);
+ public static final CaptureRequest.Key<Integer> SATURATION=
+ new CaptureRequest.Key<>("org.codeaurora.qcamera3.saturation.use_saturation", Integer.class);
+ public static final CaptureRequest.Key<Byte> histMode =
+ new CaptureRequest.Key<>("org.codeaurora.qcamera3.histogram.enable", byte.class);
+ public static CameraCharacteristics.Key<Integer> buckets =
+ new CameraCharacteristics.Key<>("org.codeaurora.qcamera3.histogram.buckets", Integer.class);
+ public static CameraCharacteristics.Key<Integer> maxCount =
+ new CameraCharacteristics.Key<>("org.codeaurora.qcamera3.histogram.max_count", Integer.class);
+ public static CaptureResult.Key<int[]> histogramStats =
+ new CaptureResult.Key<>("org.codeaurora.qcamera3.histogram.stats", int[].class);
private boolean[] mTakingPicture = new boolean[MAX_NUM_CAM];
private int mControlAFMode = CameraMetadata.CONTROL_AF_MODE_CONTINUOUS_PICTURE;
private int mLastResultAFState = -1;
@@ -216,6 +231,11 @@ public class CaptureModule implements CameraModule, PhotoController,
private boolean mAutoExposureRegionSupported;
// The degrees of the device rotated clockwise from its natural orientation.
private int mOrientation = OrientationEventListener.ORIENTATION_UNKNOWN;
+ /*Histogram variables*/
+ private Camera2GraphView mGraphViewR,mGraphViewGR,mGraphViewGB,mGraphViewB;
+ /*HDR Test*/
+ private boolean mCaptureHDRTestEnable = false;
+ boolean mHiston = false;
private boolean mFirstTimeInitialized;
private boolean mCamerasOpened = false;
private boolean mIsLinked = false;
@@ -226,6 +246,7 @@ public class CaptureModule implements CameraModule, PhotoController,
private boolean[] mCameraOpened = new boolean[MAX_NUM_CAM];
private CameraDevice[] mCameraDevice = new CameraDevice[MAX_NUM_CAM];
private String[] mCameraId = new String[MAX_NUM_CAM];
+ private View mRootView;
private CaptureUI mUI;
private CameraActivity mActivity;
private List<Integer> mCameraIdList;
@@ -320,6 +341,8 @@ public class CaptureModule implements CameraModule, PhotoController,
private int mHighSpeedCaptureRate;
private CaptureRequest.Builder mVideoRequestBuilder;
+ public static int statsdata[] = new int[1024];
+
private static final int SELFIE_FLASH_DURATION = 680;
private MediaActionSound mSound;
@@ -504,6 +527,16 @@ public class CaptureModule implements CameraModule, PhotoController,
updateFocusStateChange(result);
Face[] faces = result.get(CaptureResult.STATISTICS_FACES);
updateFaceView(faces);
+
+
+ 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();
+ }
}
processCaptureResult(result);
mPostProcessor.onMetaAvailable(result);
@@ -679,7 +712,18 @@ public class CaptureModule implements CameraModule, PhotoController,
} else {
mState[id] = STATE_PICTURE_TAKEN;
captureStillPicture(id);
+ captureStillPictureForHDRTest(id);
+ }
+ }
+
+ private void captureStillPictureForHDRTest(int id) {
+ String scene = mSettingsManager.getValue(SettingsManager.KEY_SCENE_MODE);
+ if (SettingsManager.getInstance().isCamera2HDRSupport()
+ && scene != null && scene.equals("18")){
+ mCaptureHDRTestEnable = true;
+ captureStillPicture(id);
}
+ mCaptureHDRTestEnable = false;
}
public void startFaceDetection() {
@@ -780,6 +824,26 @@ public class CaptureModule implements CameraModule, PhotoController,
}
mNamedImages = new NamedImages();
+ mGraphViewR = (Camera2GraphView) mRootView.findViewById(R.id.graph_view_r);
+ mGraphViewGR = (Camera2GraphView) mRootView.findViewById(R.id.graph_view_gr);
+ mGraphViewGB = (Camera2GraphView) mRootView.findViewById(R.id.graph_view_gb);
+ mGraphViewB = (Camera2GraphView) mRootView.findViewById(R.id.graph_view_b);
+ mGraphViewR.setDataSection(0,256);
+ mGraphViewGR.setDataSection(256,512);
+ mGraphViewGB.setDataSection(512,768);
+ mGraphViewB.setDataSection(768,1024);
+ if (mGraphViewR != null){
+ mGraphViewR.setCaptureModuleObject(this);
+ }
+ if (mGraphViewGR != null){
+ mGraphViewGR.setCaptureModuleObject(this);
+ }
+ if (mGraphViewGB != null){
+ mGraphViewGB.setCaptureModuleObject(this);
+ }
+ if (mGraphViewB != null){
+ mGraphViewB.setCaptureModuleObject(this);
+ }
mFirstTimeInitialized = true;
}
@@ -1075,6 +1139,7 @@ public class CaptureModule implements CameraModule, PhotoController,
@Override
public void init(CameraActivity activity, View parent) {
mActivity = activity;
+ mRootView = parent;
mSettingsManager = SettingsManager.getInstance();
mSettingsManager.registerListener(this);
mSettingsManager.init();
@@ -1191,6 +1256,9 @@ public class CaptureModule implements CameraModule, PhotoController,
mLockRequestHashCode[id] = request.hashCode();
mState[id] = STATE_WAITING_AF_LOCK;
mCaptureSession[id].capture(request, mCaptureCallback, mCameraHandler);
+ if(mHiston) {
+ updateGraghViewVisibility(View.INVISIBLE);
+ }
} catch (CameraAccessException | IllegalStateException e) {
e.printStackTrace();
}
@@ -1841,6 +1909,9 @@ public class CaptureModule implements CameraModule, PhotoController,
applySceneMode(builder);
applyZoom(builder, id);
applyInstantAEC(builder);
+ applySaturationLevel(builder);
+ applyAntiBandingLevel(builder);
+ applyHistogram(builder);
}
/**
@@ -2524,6 +2595,48 @@ public class CaptureModule implements CameraModule, PhotoController,
if (oldOrientation != mOrientation) {
mUI.onOrientationChanged();
mUI.setOrientation(mOrientation, true);
+ if (mGraphViewR != null) {
+ mGraphViewR.setRotation(-mOrientation);
+ }
+ if (mGraphViewGR != null) {
+ mGraphViewGR.setRotation(-mOrientation);
+ }
+ if (mGraphViewGB != null) {
+ mGraphViewGB.setRotation(-mOrientation);
+ }
+ if (mGraphViewB != null) {
+ mGraphViewB.setRotation(-mOrientation);
+ }
+ }
+
+ // need to re-initialize mGraphView to show histogram on rotate
+ mGraphViewR = (Camera2GraphView) mRootView.findViewById(R.id.graph_view_r);
+ mGraphViewGR = (Camera2GraphView) mRootView.findViewById(R.id.graph_view_gr);
+ mGraphViewGB = (Camera2GraphView) mRootView.findViewById(R.id.graph_view_gb);
+ mGraphViewB = (Camera2GraphView) mRootView.findViewById(R.id.graph_view_b);
+ mGraphViewR.setDataSection(0,256);
+ mGraphViewGR.setDataSection(256,512);
+ mGraphViewGB.setDataSection(512,768);
+ mGraphViewB.setDataSection(768,1024);
+ if(mGraphViewR != null){
+ mGraphViewR.setAlpha(0.75f);
+ mGraphViewR.setCaptureModuleObject(this);
+ mGraphViewR.PreviewChanged();
+ }
+ if(mGraphViewGR != null){
+ mGraphViewGR.setAlpha(0.75f);
+ mGraphViewGR.setCaptureModuleObject(this);
+ mGraphViewGR.PreviewChanged();
+ }
+ if(mGraphViewGB != null){
+ mGraphViewGB.setAlpha(0.75f);
+ mGraphViewGB.setCaptureModuleObject(this);
+ mGraphViewGB.PreviewChanged();
+ }
+ if(mGraphViewB != null){
+ mGraphViewB.setAlpha(0.75f);
+ mGraphViewB.setCaptureModuleObject(this);
+ mGraphViewB.PreviewChanged();
}
}
@@ -3463,6 +3576,76 @@ public class CaptureModule implements CameraModule, PhotoController,
request.set(CaptureModule.INSTANT_AEC_MODE, intValue);
}
+ private void applySaturationLevel(CaptureRequest.Builder request) {
+ String value = mSettingsManager.getValue(SettingsManager.KEY_SATURATION_LEVEL);
+ if (value != null) {
+ int intValue = Integer.parseInt(value);
+ request.set(CaptureModule.SATURATION, intValue);
+ }
+ }
+
+ private void applyAntiBandingLevel(CaptureRequest.Builder request) {
+ String value = mSettingsManager.getValue(SettingsManager.KEY_ANTI_BANDING_LEVEL);
+ if (value != null) {
+ int intValue = Integer.parseInt(value);
+ request.set(CaptureRequest.CONTROL_AE_ANTIBANDING_MODE, intValue);
+ }
+ }
+
+ private void applyHistogram(CaptureRequest.Builder request) {
+ String value = mSettingsManager.getValue(SettingsManager.KEY_HISTOGRAM);
+ if (value != null && isBackCamera()) {
+ if (value.equals("enable")){
+ final byte enable = 1;
+ request.set(CaptureModule.histMode, enable);
+ mHiston = true;
+ updateGraghViewVisibility(View.VISIBLE);
+ updateGraghView();
+ return;
+ }
+ }
+ mHiston = false;
+ updateGraghViewVisibility(View.GONE);
+ }
+
+ private void updateGraghViewVisibility(final int visibility) {
+ mActivity.runOnUiThread(new Runnable() {
+ public void run() {
+ if(mGraphViewR != null) {
+ mGraphViewR.setVisibility(visibility);
+ }
+ if(mGraphViewGR != null) {
+ mGraphViewGR.setVisibility(visibility);
+ }
+ if(mGraphViewGB != null) {
+ mGraphViewGB.setVisibility(visibility);
+ }
+ if(mGraphViewB != null) {
+ mGraphViewB.setVisibility(visibility);
+ }
+ }
+ });
+ }
+
+ private void updateGraghView(){
+ mActivity.runOnUiThread(new Runnable() {
+ public void run() {
+ if(mGraphViewR != null) {
+ mGraphViewR.PreviewChanged();
+ }
+ if(mGraphViewGR != null) {
+ mGraphViewGR.PreviewChanged();
+ }
+ if(mGraphViewGB != null) {
+ mGraphViewGB.PreviewChanged();
+ }
+ if(mGraphViewB != null) {
+ mGraphViewB.PreviewChanged();
+ }
+ }
+ });
+ }
+
private boolean applyPreferenceToPreview(int cameraId, String key, String value) {
if (!checkSessionAndBuilder(mCaptureSession[cameraId], mPreviewRequestBuilder[cameraId])) {
return false;
@@ -3544,7 +3727,7 @@ public class CaptureModule implements CameraModule, PhotoController,
String value = mSettingsManager.getValue(SettingsManager.KEY_SCENE_MODE);
if (value == null) return;
int mode = Integer.parseInt(value);
- if(getPostProcFilterId(mode) != PostProcessor.FILTER_NONE) {
+ if(getPostProcFilterId(mode) != PostProcessor.FILTER_NONE || mCaptureHDRTestEnable) {
request.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_AUTO);
return;
}
@@ -4286,3 +4469,98 @@ public class CaptureModule implements CameraModule, PhotoController,
return session != null && builder != null;
}
}
+
+class Camera2GraphView 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 int mStart, mEnd;
+ private CaptureModule mCaptureModule;
+ private float scaled;
+ private static final int STATS_SIZE = 256;
+ private static final String TAG = "GraphView";
+
+
+ public Camera2GraphView(Context context, AttributeSet attrs) {
+ super(context,attrs);
+
+ mPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
+ mPaintRect.setColor(0xFFFFFFFF);
+ mPaintRect.setStyle(Paint.Style.FILL);
+ }
+
+ void setDataSection(int start, int end){
+ mStart = start;
+ mEnd = end;
+ }
+
+ @Override
+ 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) {
+ if(mCaptureModule == null && !mCaptureModule.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(CaptureModule.statsdata) {
+ int maxValue = Integer.MIN_VALUE;
+ for ( int i = mStart ; i < mEnd ; i++ ) {
+ if ( maxValue < CaptureModule.statsdata[i] ) {
+ maxValue = CaptureModule.statsdata[i];
+ }
+ }
+ mScale = ( float ) maxValue;
+ for(int i=mStart ; i < mEnd ; i++) {
+ scaled = (CaptureModule.statsdata[i]/mScale)*STATS_SIZE;
+ if(scaled >= (float)STATS_SIZE)
+ scaled = (float)STATS_SIZE;
+ left = (bargap * (i - mStart + 1)) + (barwidth * (i - mStart)) + border;
+ top = graphheight + border;
+ right = left + barwidth;
+ bottom = top - scaled;
+ cavas.drawRect(left, top, right, bottom, mPaintRect);
+ }
+ }
+ canvas.drawBitmap(mBitmap, 0, 0, null);
+ }
+ }
+ public void PreviewChanged() {
+ invalidate();
+ }
+
+ public void setCaptureModuleObject(CaptureModule captureModule) {
+ mCaptureModule = captureModule;
+ }
+}
diff --git a/src/com/android/camera/SettingsActivity.java b/src/com/android/camera/SettingsActivity.java
index 61c8c46f1..0444fc80d 100755..100644
--- a/src/com/android/camera/SettingsActivity.java
+++ b/src/com/android/camera/SettingsActivity.java
@@ -53,6 +53,7 @@ import com.android.camera.util.CameraUtil;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.Arrays;
public class SettingsActivity extends PreferenceActivity {
private SettingsManager mSettingsManager;
@@ -175,6 +176,16 @@ public class SettingsActivity extends PreferenceActivity {
parent.removePreference(developer);
}
+ CharSequence[] entries = mSettingsManager.getEntries(SettingsManager.KEY_SCENE_MODE);
+ List<CharSequence> list = Arrays.asList(entries);
+ if (mDeveloperMenuEnabled && !list.contains("HDR")){
+ Preference p = findPreference("pref_camera2_hdr_key");
+ if (p != null){
+ PreferenceGroup developer = (PreferenceGroup)findPreference("developer");
+ developer.removePreference(p);
+ }
+ }
+
for (String key : set) {
Preference p = findPreference(key);
if (p == null) continue;
diff --git a/src/com/android/camera/SettingsManager.java b/src/com/android/camera/SettingsManager.java
index ae4f8bdfb..c51c7c555 100755..100644
--- a/src/com/android/camera/SettingsManager.java
+++ b/src/com/android/camera/SettingsManager.java
@@ -139,6 +139,10 @@ public class SettingsManager implements ListMenu.SettingsListener {
public static final String KEY_RESTORE_DEFAULT = "pref_camera2_restore_default_key";
public static final String KEY_FOCUS_DISTANCE = "pref_camera2_focus_distance_key";
public static final String KEY_INSTANT_AEC = "pref_camera2_instant_aec_key";
+ public static final String KEY_SATURATION_LEVEL = "pref_camera2_saturation_level_key";
+ public static final String KEY_ANTI_BANDING_LEVEL = "pref_camera2_anti_banding_level_key";
+ public static final String KEY_HISTOGRAM = "pref_camera2_histogram_key";
+ public static final String KEY_HDR = "pref_camera2_hdr_key";
private static final String TAG = "SnapCam_SettingsManager";
private static SettingsManager sInstance;
@@ -584,6 +588,10 @@ public class SettingsManager implements ListMenu.SettingsListener {
ListPreference noiseReduction = mPreferenceGroup.findPreference(KEY_NOISE_REDUCTION);
ListPreference faceDetection = mPreferenceGroup.findPreference(KEY_FACE_DETECTION);
ListPreference instantAec = mPreferenceGroup.findPreference(KEY_INSTANT_AEC);
+ ListPreference saturationLevel = mPreferenceGroup.findPreference(KEY_SATURATION_LEVEL);
+ ListPreference antiBandingLevel = mPreferenceGroup.findPreference(KEY_ANTI_BANDING_LEVEL);
+ ListPreference histogram = mPreferenceGroup.findPreference(KEY_HISTOGRAM);
+ ListPreference hdr = mPreferenceGroup.findPreference(KEY_HDR);
if (whiteBalance != null) {
if (filterUnsupportedOptions(whiteBalance, getSupportedWhiteBalanceModes(cameraId))) {
@@ -611,6 +619,34 @@ public class SettingsManager implements ListMenu.SettingsListener {
}
}
+ if (saturationLevel != null) {
+ if (filterUnsupportedOptions(saturationLevel,
+ getSupportedSaturationLevelAvailableModes(cameraId))) {
+ mFilteredKeys.add(saturationLevel.getKey());
+ }
+ }
+
+ if (antiBandingLevel != null) {
+ if (filterUnsupportedOptions(antiBandingLevel,
+ getSupportedAntiBandingLevelAvailableModes(cameraId))) {
+ mFilteredKeys.add(antiBandingLevel.getKey());
+ }
+ }
+
+ if (histogram != null) {
+ if (filterUnsupportedOptions(histogram,
+ getSupportedHistogramAvailableModes(cameraId))) {
+ mFilteredKeys.add(histogram.getKey());
+ }
+ }
+
+ if (hdr != null){
+ if (filterUnsupportedOptions(hdr,
+ getSupportedHdrAvailableModes(cameraId))) {
+ mFilteredKeys.add(hdr.getKey());
+ }
+ }
+
if (sceneMode != null) {
if (filterUnsupportedOptions(sceneMode, getSupportedSceneModes(cameraId))) {
mFilteredKeys.add(sceneMode.getKey());
@@ -1228,6 +1264,48 @@ public class SettingsManager implements ListMenu.SettingsListener {
return modes;
}
+ public List<String> getSupportedSaturationLevelAvailableModes(int cameraId) {
+ int[] saturationLevelAvailableModes = {0,1,2,3,4,5,6,7,8,9,10};
+ List<String> modes = new ArrayList<>();
+ for (int i : saturationLevelAvailableModes) {
+ modes.add(""+i);
+ }
+ return modes;
+ }
+
+ public List<String> getSupportedAntiBandingLevelAvailableModes(int cameraId) {
+ int[] antiBandingLevelAvailableModes = mCharacteristics.get(cameraId).get(
+ CameraCharacteristics.CONTROL_AE_AVAILABLE_ANTIBANDING_MODES);
+ List<String> modes = new ArrayList<>();
+ for (int i : antiBandingLevelAvailableModes) {
+ modes.add(""+i);
+ }
+ return modes;
+ }
+
+ public List<String> getSupportedHistogramAvailableModes(int cameraId) {
+ String[] data = {"enable","disable"};
+ List<String> modes = new ArrayList<>();
+ for (String i : data) {
+ modes.add(i);
+ }
+ return modes;
+ }
+
+ public List<String> getSupportedHdrAvailableModes(int cameraId) {
+ String[] data = {"enable","disable"};
+ List<String> modes = new ArrayList<>();
+ for (String i : data) {
+ modes.add(i);
+ }
+ return modes;
+ }
+
+ public boolean isCamera2HDRSupport(){
+ String value = getValue(KEY_HDR);
+ return value != null && value.equals("enable");
+ }
+
private boolean filterUnsupportedOptions(ListPreference pref, List<String> supported) {
// Remove the preference if the parameter is not supported
if (supported == null) {
diff --git a/src/com/android/camera/imageprocessor/PostProcessor.java b/src/com/android/camera/imageprocessor/PostProcessor.java
index 8e6caa953..8db3fb39e 100644
--- a/src/com/android/camera/imageprocessor/PostProcessor.java
+++ b/src/com/android/camera/imageprocessor/PostProcessor.java
@@ -577,7 +577,8 @@ public class PostProcessor{
mImageHandlerTask = new ImageHandlerTask();
if(setFilter(postFilterId) || isFlashModeOn || isTrackingFocusOn || isMakeupOn || isSelfieMirrorOn
- || PersistUtil.getCameraZSLDisabled()) {
+ || PersistUtil.getCameraZSLDisabled()
+ || SettingsManager.getInstance().isCamera2HDRSupport()) {
mUseZSL = false;
} else {
mUseZSL = true;