summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2018-09-05 15:37:51 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2018-09-05 15:37:51 -0700
commitab80290f403947f03f891ac5353390ed80565de6 (patch)
treec941bb7a38a237651f516216ef143634f4031821
parent9e99d4612bb94a13ad4e21783cb94aa038883276 (diff)
parentf60de0b67cd8699dcf15b73ca44ae20d77d599df (diff)
downloadandroid_packages_apps_Snap-ab80290f403947f03f891ac5353390ed80565de6.tar.gz
android_packages_apps_Snap-ab80290f403947f03f891ac5353390ed80565de6.tar.bz2
android_packages_apps_Snap-ab80290f403947f03f891ac5353390ed80565de6.zip
Merge "SnapdragonCamera: Completed the function of Manual WB"
-rwxr-xr-xres/xml/capture_preferences.xml7
-rwxr-xr-xres/xml/setting_menu_preferences.xml9
-rwxr-xr-xsrc/com/android/camera/CaptureModule.java39
-rwxr-xr-xsrc/com/android/camera/SettingsActivity.java185
-rwxr-xr-xsrc/com/android/camera/SettingsManager.java42
-rwxr-xr-xsrc/com/android/camera/util/VendorTagUtil.java49
6 files changed, 330 insertions, 1 deletions
diff --git a/res/xml/capture_preferences.xml b/res/xml/capture_preferences.xml
index bc74e280b..9050f6319 100755
--- a/res/xml/capture_preferences.xml
+++ b/res/xml/capture_preferences.xml
@@ -367,6 +367,13 @@
camera:entryValues="@array/pref_camera_manual_exp_entry_values" />
<ListPreference
+ camera:defaultValue="@string/pref_camera_manual_wb_default"
+ camera:entries="@array/pref_camera_manual_wb_entries"
+ camera:entryValues="@array/pref_camera_manual_wb_entry_values"
+ camera:key="pref_camera2_manual_wb_key"
+ camera:title="@string/pref_camera_manual_wb_title" />
+
+ <ListPreference
camera:defaultValue="@string/pref_camera2_qcfa_default"
camera:entries="@array/pref_camera2_qcfa_entries"
camera:entryValues="@array/pref_camera2_qcfa_entryvalues"
diff --git a/res/xml/setting_menu_preferences.xml b/res/xml/setting_menu_preferences.xml
index da47590be..0036c11b2 100755
--- a/res/xml/setting_menu_preferences.xml
+++ b/res/xml/setting_menu_preferences.xml
@@ -368,6 +368,15 @@
android:entryValues="@array/pref_camera_manual_exp_entry_values" />
<ListPreference
+ android:defaultValue="@string/pref_camera_manual_wb_default"
+ android:entries="@array/pref_camera_manual_wb_entries"
+ android:entryValues="@array/pref_camera_manual_wb_entry_values"
+ android:key="pref_camera2_manual_wb_key"
+ android:layout="@layout/preference"
+ android:summary="%s"
+ android:title="@string/pref_camera_manual_wb_title" />
+
+ <ListPreference
android:key="pref_camera2_qcfa_key"
android:defaultValue="@string/pref_camera2_qcfa_default"
android:title="@string/pref_camera2_qcfa_title"
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java
index 1605c77fc..7b5403f8b 100755
--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -269,6 +269,12 @@ public class CaptureModule implements CameraModule, PhotoController,
public static CameraCharacteristics.Key<long[]> EXPOSURE_RANGE =
new CameraCharacteristics.Key<>("org.codeaurora.qcamera3.iso_exp_priority.exposure_time_range", long[].class);
+ // manual WB color temperature and gains
+ public static CameraCharacteristics.Key<int[]> WB_COLOR_TEMPERATURE_RANGE =
+ new CameraCharacteristics.Key<>("org.codeaurora.qcamera3.manualWB.color_temperature_range", int[].class);
+ public static CameraCharacteristics.Key<float[]> WB_RGB_GAINS_RANGE =
+ new CameraCharacteristics.Key<>("org.codeaurora.qcamera3.manualWB.gains_range", float[].class);
+
public static CameraCharacteristics.Key<Integer> buckets =
new CameraCharacteristics.Key<>("org.codeaurora.qcamera3.histogram.buckets", Integer.class);
public static CameraCharacteristics.Key<Integer> maxCount =
@@ -2799,6 +2805,7 @@ public class CaptureModule implements CameraModule, PhotoController,
applyAWBCCTAndAgain(builder);
applyBGStats(builder);
applyBEStats(builder);
+ applyWbColorTemperature(builder);
}
/**
@@ -5367,6 +5374,38 @@ public class CaptureModule implements CameraModule, PhotoController,
updateBEStatsVisibility(View.GONE);
}
+ private void applyWbColorTemperature(CaptureRequest.Builder request) {
+ final SharedPreferences pref = mActivity.getSharedPreferences(
+ ComboPreferences.getLocalSharedPreferencesName(mActivity, getMainCameraId()),
+ Context.MODE_PRIVATE);
+ String manualWBMode = mSettingsManager.getValue(SettingsManager.KEY_MANUAL_WB);
+ String cctMode = mActivity.getString(
+ R.string.pref_camera_manual_wb_value_color_temperature);
+ String gainMode = mActivity.getString(
+ R.string.pref_camera_manual_wb_value_rbgb_gains);
+ Log.v("daming", " >>> 5362 >>> cctMode :" + cctMode);
+ if (manualWBMode.equals(cctMode)) {
+ int colorTempValue = Integer.parseInt(pref.getString(
+ SettingsManager.KEY_MANUAL_WB_TEMPERATURE_VALUE, "-1"));
+ Log.v("daming", " >>> 5366 >>> colorTempValue :" + colorTempValue);
+ if (colorTempValue != -1) {
+ VendorTagUtil.setWbColorTemperatureValue(request, colorTempValue);
+ }
+ } else if (manualWBMode.equals(gainMode)) {
+ float rGain = pref.getFloat(SettingsManager.KEY_MANUAL_WB_R_GAIN, -1.0f);
+ float gGain = pref.getFloat(SettingsManager.KEY_MANUAL_WB_G_GAIN, -1.0f);
+ float bGain = pref.getFloat(SettingsManager.KEY_MANUAL_WB_B_GAIN, -1.0f);
+ if (rGain != -1.0 && gGain != -1.0 && bGain != -1.0f) {
+ request.set(CaptureRequest.CONTROL_AWB_MODE, CaptureRequest.CONTROL_AWB_MODE_OFF);
+ float[] gains = {rGain, gGain, bGain};
+ Log.v("daming", " >>> 5375 >>> rGain :" + rGain + ", gGain :" + gGain + ", bGain :" + bGain);
+ VendorTagUtil.setMWBGainsValue(request, gains);
+ }
+ } else {
+ VendorTagUtil.setMWBDisableMode(request);
+ }
+ }
+
private void updateGraghViewVisibility(final int visibility) {
mActivity.runOnUiThread(new Runnable() {
public void run() {
diff --git a/src/com/android/camera/SettingsActivity.java b/src/com/android/camera/SettingsActivity.java
index 8a7d1f9cd..360037aad 100755
--- a/src/com/android/camera/SettingsActivity.java
+++ b/src/com/android/camera/SettingsActivity.java
@@ -66,6 +66,7 @@ public class SettingsActivity extends PreferenceActivity {
private static final String TAG = "SettingsActivity";
private SettingsManager mSettingsManager;
private SharedPreferences mSharedPreferences;
+ private SharedPreferences mLocalSharedPref;
private boolean mDeveloperMenuEnabled;
private int privateCounter = 0;
private final int DEVELOPER_MENU_TOUCH_COUNT = 10;
@@ -134,6 +135,10 @@ public class SettingsActivity extends PreferenceActivity {
autoHdrPref.setEnabled(true);
}
}
+
+ if ( (pref.getKey().equals(SettingsManager.KEY_MANUAL_WB)) ) {
+ updateManualWBSettings();
+ }
}
}
};
@@ -328,6 +333,181 @@ public class SettingsActivity extends PreferenceActivity {
alert.show();
}
+ private void showManualWBGainDialog(final LinearLayout linear,
+ final AlertDialog.Builder alert) {
+ SharedPreferences.Editor editor = mLocalSharedPref.edit();
+ final TextView rGainTtext = new TextView(SettingsActivity.this);
+ final TextView rGainValue = new TextView(SettingsActivity.this);
+ final EditText rGainInput = new EditText(SettingsActivity.this);
+ final TextView gGainTtext = new TextView(SettingsActivity.this);
+ final TextView gGainValue = new TextView(SettingsActivity.this);
+ final EditText gGainInput = new EditText(SettingsActivity.this);
+ final TextView bGainTtext = new TextView(SettingsActivity.this);
+ final TextView bGainValue = new TextView(SettingsActivity.this);
+ final EditText bGainInput = new EditText(SettingsActivity.this);
+ int floatType = InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_CLASS_NUMBER;
+ rGainInput.setInputType(floatType);
+ gGainInput.setInputType(floatType);
+ bGainInput.setInputType(floatType);
+
+ float rGain = mLocalSharedPref.getFloat(SettingsManager.KEY_MANUAL_WB_R_GAIN, -1.0f);
+ float gGain = mLocalSharedPref.getFloat(SettingsManager.KEY_MANUAL_WB_G_GAIN, -1.0f);
+ float bGain = mLocalSharedPref.getFloat(SettingsManager.KEY_MANUAL_WB_B_GAIN, -1.0f);
+
+ if (rGain == -1.0) {
+ rGainValue.setText(" Current rGain is " );
+ } else {
+ rGainValue.setText(" Current rGain is " + rGain);
+ }
+ if (rGain == -1.0) {
+ gGainValue.setText(" Current gGain is " );
+ } else {
+ gGainValue.setText(" Current gGain is " + gGain);
+ }
+ if (rGain == -1.0) {
+ bGainValue.setText(" Current bGain is ");
+ } else {
+ bGainValue.setText(" Current bGain is " + bGain);
+ }
+ int cameraId = mSettingsManager.getCurrentCameraId();
+ final float[] gainsRange = mSettingsManager.getWBGainsRangeValues(cameraId);
+ //refresh camera parameters to get latest CCT value
+ if (gainsRange == null) {
+ alert.setMessage("Enter gains value in the range get is NULL ");
+ } else {
+ alert.setMessage("Enter gains value in the range of " + gainsRange[0]+ " to " + gainsRange[1]);
+ }
+ linear.addView(rGainTtext);
+ linear.addView(rGainInput);
+ linear.addView(rGainValue);
+ linear.addView(gGainTtext);
+ linear.addView(gGainInput);
+ linear.addView(gGainValue);
+ linear.addView(bGainTtext);
+ linear.addView(bGainInput);
+ linear.addView(bGainValue);
+ alert.setView(linear);
+ alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ float rGain = -1.0f;
+ float gGain = -1.0f;
+ float bGain = -1.0f;
+ String rgainStr = rGainInput.getText().toString();
+ String ggainStr = gGainInput.getText().toString();
+ String bgainStr = bGainInput.getText().toString();
+ if (rgainStr.length() > 0) {
+ rGain = Float.parseFloat(rgainStr);
+ }
+ if (ggainStr.length() > 0) {
+ gGain = Float.parseFloat(ggainStr);
+ }
+ if (bgainStr.length() > 0) {
+ bGain = Float.parseFloat(bgainStr);
+ }
+ if (gainsRange == null) {
+ RotateTextToast.makeText(SettingsActivity.this, "Gains Range is NULL, " +
+ "Invalid gains", Toast.LENGTH_SHORT).show();
+ return;
+ }
+ if (rGain <= gainsRange[1] && rGain >= gainsRange[0]) {
+ Log.v(TAG, "Setting rGain value : " + rGain);
+ editor.putFloat(SettingsManager.KEY_MANUAL_WB_R_GAIN, rGain);
+ } else {
+ RotateTextToast.makeText(SettingsActivity.this, "Invalid rGain value:",
+ Toast.LENGTH_SHORT).show();
+ }
+ if (gGain <= gainsRange[1] && gGain >= gainsRange[0]) {
+ Log.v(TAG, "Setting gGain value : " + gGain);
+ editor.putFloat(SettingsManager.KEY_MANUAL_WB_G_GAIN, gGain);
+ } else {
+ RotateTextToast.makeText(SettingsActivity.this, "Invalid gGain value:",
+ Toast.LENGTH_SHORT).show();
+ }
+ if (bGain <= gainsRange[1] && bGain >= gainsRange[0]) {
+ Log.v(TAG, "Setting bGain value : " + bGain);
+ editor.putFloat(SettingsManager.KEY_MANUAL_WB_B_GAIN, bGain);
+ } else {
+ RotateTextToast.makeText(SettingsActivity.this, "Invalid bGain value:",
+ Toast.LENGTH_SHORT).show();
+ }
+ editor.apply();
+ }
+ });
+ alert.show();
+ }
+
+ private void updateManualWBSettings() {
+ int cameraId = mSettingsManager.getCurrentCameraId();
+ SharedPreferences.Editor editor = mLocalSharedPref.edit();
+ final AlertDialog.Builder alert = new AlertDialog.Builder(SettingsActivity.this);
+ LinearLayout linear = new LinearLayout(SettingsActivity.this);
+ linear.setOrientation(1);
+ alert.setTitle("Manual White Balance Settings");
+ alert.setNegativeButton("Cancel",new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog,int id) {
+ dialog.cancel();
+ }
+ });
+
+ String cctMode = this.getString(
+ R.string.pref_camera_manual_wb_value_color_temperature);
+ String rgbGainMode = this.getString(
+ R.string.pref_camera_manual_wb_value_rbgb_gains);
+ String currentWBTemp = mLocalSharedPref.getString(
+ SettingsManager.KEY_MANUAL_WB_TEMPERATURE_VALUE, "-1");
+ final String manualWBMode = mSettingsManager.getValue(SettingsManager.KEY_MANUAL_WB);
+ Log.v(TAG, "manualWBMode selected = " + manualWBMode);
+ final int[] wbRange = mSettingsManager.getWBColorTemperatureRangeValues(cameraId);
+ if (manualWBMode.equals(cctMode)) {
+ final TextView CCTtext = new TextView(SettingsActivity.this);
+ final EditText CCTinput = new EditText(SettingsActivity.this);
+ CCTinput.setInputType(InputType.TYPE_CLASS_NUMBER);
+
+ //refresh camera parameters to get latest CCT value
+ if (currentWBTemp.equals("-1")) {
+ CCTtext.setText(" Current CCT is ");
+ } else {
+ CCTtext.setText(" Current CCT is " + currentWBTemp);
+ }
+ if (wbRange == null) {
+ alert.setMessage("Enter CCT value is get NULL ");
+ } else {
+ alert.setMessage("Enter CCT value in the range of " + wbRange[0]+ " to " + wbRange[1]);
+ }
+ linear.addView(CCTinput);
+ linear.addView(CCTtext);
+ alert.setView(linear);
+ alert.setPositiveButton("Ok",new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog,int id) {
+ int newCCT = -1;
+ String cct = CCTinput.getText().toString();
+ if (cct.length() > 0) {
+ newCCT = Integer.parseInt(cct);
+ }
+ if (wbRange == null) {
+ RotateTextToast.makeText(SettingsActivity.this, "CCT Range is NULL, " +
+ "Invalid CCT", Toast.LENGTH_SHORT).show();
+ return;
+ }
+ if (newCCT <= wbRange[1] && newCCT >= wbRange[0]) {
+ Log.v(TAG, "Setting CCT value : " + newCCT);
+ //0 corresponds to manual CCT mode
+ editor.putString(SettingsManager.KEY_MANUAL_WB_TEMPERATURE_VALUE, cct);
+ editor.apply();
+ } else {
+ RotateTextToast.makeText(SettingsActivity.this, "Invalid CCT",
+ Toast.LENGTH_SHORT).show();
+ }
+ }
+ });
+ alert.show();
+ } else if (manualWBMode.equals(rgbGainMode)) {
+ showManualWBGainDialog(linear, alert);
+ } else {
+ // user select off, nothing to do.
+ }
+ }
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -349,6 +529,11 @@ public class SettingsActivity extends PreferenceActivity {
finish();
return;
}
+
+ int cameraId = mSettingsManager.getCurrentCameraId();
+ mLocalSharedPref = this.getSharedPreferences(
+ ComboPreferences.getLocalSharedPreferencesName(this, cameraId),
+ Context.MODE_PRIVATE);
mSettingsManager.registerListener(mListener);
addPreferencesFromResource(R.xml.setting_menu_preferences);
mSharedPreferences = getPreferenceManager().getSharedPreferences();
diff --git a/src/com/android/camera/SettingsManager.java b/src/com/android/camera/SettingsManager.java
index af1a4f620..08488c9ee 100755
--- a/src/com/android/camera/SettingsManager.java
+++ b/src/com/android/camera/SettingsManager.java
@@ -159,10 +159,20 @@ public class SettingsManager implements ListMenu.SettingsListener {
public static final String KEY_SHARPNESS_CONTROL_MODE = "pref_camera2_sharpness_control_key";
public static final String KEY_AF_MODE = "pref_camera2_afmode_key";
public static final String KEY_EXPOSURE_METERING_MODE = "pref_camera2_exposure_metering_key";
+
+ //manual 3A keys and parameter strings
public static final String KEY_MANUAL_EXPOSURE = "pref_camera2_manual_exp_key";
public static final String KEY_MANUAL_ISO_VALUE = "pref_camera2_manual_iso_key";
public static final String KEY_MANUAL_GAINS_VALUE = "pref_camera2_manual_gains_key";
public static final String KEY_MANUAL_EXPOSURE_VALUE = "pref_camera2_manual_exposure_key";
+
+ public static final String KEY_MANUAL_WB = "pref_camera2_manual_wb_key";
+ public static final String KEY_MANUAL_WB_TEMPERATURE_VALUE =
+ "pref_camera2_manual_temperature_key";
+ public static final String KEY_MANUAL_WB_R_GAIN = "pref_camera2_manual_wb_r_gain";
+ public static final String KEY_MANUAL_WB_G_GAIN = "pref_camera2_manual_wb_g_gain";
+ public static final String KEY_MANUAL_WB_B_GAIN = "pref_camera2_manual_wb_b_gain";
+
public static final String KEY_QCFA = "pref_camera2_qcfa_key";
public static final String KEY_EIS_VALUE = "pref_camera2_eis_key";
public static final String KEY_FOVC_VALUE = "pref_camera2_fovc_key";
@@ -939,6 +949,38 @@ public class SettingsManager implements ListMenu.SettingsListener {
return pref.getEntryValues();
}
+ public int[] getWBColorTemperatureRangeValues(int cameraId) {
+ int[] wbRange = null;
+ try {
+ wbRange = mCharacteristics.get(cameraId).get(CaptureModule.WB_COLOR_TEMPERATURE_RANGE);
+ if (wbRange == null) {
+ Log.w(TAG, "Supported exposure range get null.");
+ return null;
+ }
+ } catch(NullPointerException e) {
+ Log.w(TAG, "Supported exposure range modes is null.");
+ } catch(IllegalArgumentException e) {
+ Log.w(TAG, "Supported exposure range modes occur IllegalArgumentException.");
+ }
+ return wbRange;
+ }
+
+ public float[] getWBGainsRangeValues(int cameraId) {
+ float[] rgbRange = null;
+ try {
+ rgbRange = mCharacteristics.get(cameraId).get(CaptureModule.WB_RGB_GAINS_RANGE);
+ if (rgbRange == null) {
+ Log.w(TAG, "Supported gains range get null.");
+ return null;
+ }
+ } catch(NullPointerException e) {
+ Log.w(TAG, "Supported gains range modes is null.");
+ } catch(IllegalArgumentException e) {
+ Log.w(TAG, "Supported gains range modes occur IllegalArgumentException.");
+ }
+ return rgbRange;
+ }
+
public long[] getExposureRangeValues(int cameraId) {
long[] exposureRange = null;
try {
diff --git a/src/com/android/camera/util/VendorTagUtil.java b/src/com/android/camera/util/VendorTagUtil.java
index 2842b62cf..b2efbfa54 100755
--- a/src/com/android/camera/util/VendorTagUtil.java
+++ b/src/com/android/camera/util/VendorTagUtil.java
@@ -57,9 +57,20 @@ public class VendorTagUtil {
private static CaptureRequest.Key<Integer> USE_ISO_VALUE =
new CaptureRequest.Key<>("org.codeaurora.qcamera3.iso_exp_priority.use_iso_value",
Integer.class);
- private static final CaptureRequest.Key<Byte> HDRVideoMode =
+ private static CaptureRequest.Key<Integer> WB_COLOR_TEMPERATURE =
+ new CaptureRequest.Key<>("org.codeaurora.qcamera3.manualWB.color_temperature",
+ Integer.class);
+ private static CaptureRequest.Key<float[]> MANUAL_WB_GAINS =
+ new CaptureRequest.Key<>("org.codeaurora.qcamera3.manualWB.gains", float[].class);
+ private static CaptureRequest.Key<Integer> PARTIAL_MANUAL_WB_MODE =
+ new CaptureRequest.Key<>("org.codeaurora.qcamera3.manualWB.partial_mwb_mode", Integer.class);
+ private static CaptureRequest.Key<Byte> HDRVideoMode =
new CaptureRequest.Key<>("org.quic.camera2.streamconfigs.HDRVideoMode", Byte.class);
+ private static final int MANUAL_WB_DISABLE_MODE = 0;
+ private static final int MANUAL_WB_CCT_MODE = 1;
+ private static final int MANUAL_WB_GAINS_MODE = 2;
+
private static boolean isSupported(CaptureRequest.Builder builder,
CaptureRequest.Key<?> key) {
boolean supported = true;
@@ -147,6 +158,42 @@ public class VendorTagUtil {
return isSupported(builder, USE_ISO_VALUE);
}
+ private static boolean isPartialWBModeSupported(CaptureRequest.Builder builder) {
+ return isSupported(builder, PARTIAL_MANUAL_WB_MODE);
+ }
+
+ private static boolean isWBTemperatureSupported(CaptureRequest.Builder builder) {
+ return isSupported(builder, WB_COLOR_TEMPERATURE);
+ }
+
+ private static boolean isMWBGainsSupported(CaptureRequest.Builder builder) {
+ return isSupported(builder, MANUAL_WB_GAINS);
+ }
+
+ public static void setWbColorTemperatureValue(CaptureRequest.Builder builder, Integer value) {
+ if (isPartialWBModeSupported(builder)) {
+ builder.set(PARTIAL_MANUAL_WB_MODE, MANUAL_WB_CCT_MODE);
+ if (isWBTemperatureSupported(builder)) {
+ builder.set(WB_COLOR_TEMPERATURE, value);
+ }
+ }
+ }
+
+ public static void setMWBGainsValue(CaptureRequest.Builder builder, float[] gains) {
+ if (isPartialWBModeSupported(builder)) {
+ builder.set(PARTIAL_MANUAL_WB_MODE, MANUAL_WB_GAINS_MODE);
+ if (isMWBGainsSupported(builder)) {
+ builder.set(MANUAL_WB_GAINS, gains);
+ }
+ }
+ }
+
+ public static void setMWBDisableMode(CaptureRequest.Builder builder) {
+ if (isPartialWBModeSupported(builder)) {
+ builder.set(PARTIAL_MANUAL_WB_MODE, MANUAL_WB_DISABLE_MODE);
+ }
+ }
+
public static void setHDRVideoMode(CaptureRequest.Builder builder, byte mode) {
if ( isHDRVideoModeSupported(builder) ) {
builder.set(HDRVideoMode, mode);