summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/SettingsManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/camera/SettingsManager.java')
-rwxr-xr-xsrc/com/android/camera/SettingsManager.java188
1 files changed, 187 insertions, 1 deletions
diff --git a/src/com/android/camera/SettingsManager.java b/src/com/android/camera/SettingsManager.java
index 4fb29283b..1fc746740 100755
--- a/src/com/android/camera/SettingsManager.java
+++ b/src/com/android/camera/SettingsManager.java
@@ -69,6 +69,7 @@ import com.android.camera.ui.PanoCaptureProcessView;
import com.android.camera.ui.TrackingFocusRenderer;
import com.android.camera.util.SettingTranslation;
import com.android.camera.app.CameraApp;
+import com.android.camera.util.AutoTestUtil;
import org.codeaurora.snapcam.R;
import org.json.JSONException;
@@ -174,6 +175,8 @@ public class SettingsManager implements ListMenu.SettingsListener {
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 AUTO_TEST_WRITE_CONTENT = "auto_test_write_content";
+
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";
@@ -349,8 +352,9 @@ public class SettingsManager implements ListMenu.SettingsListener {
public void init() {
Log.d(TAG, "SettingsManager init");
- int cameraId = getInitialCameraId(mPreferences);
+ final int cameraId = getInitialCameraId(mPreferences);
setLocalIdAndInitialize(cameraId);
+ autoTestBroadcast(cameraId);
}
public void reinit(int cameraId) {
@@ -358,6 +362,92 @@ public class SettingsManager implements ListMenu.SettingsListener {
setLocalIdAndInitialize(cameraId);
}
+ private void autoTestBroadcast(int cameraId) {
+ final SharedPreferences pref = mContext.getSharedPreferences(
+ ComboPreferences.getLocalSharedPreferencesName(mContext, cameraId),
+ Context.MODE_PRIVATE);
+ final SharedPreferences.Editor editor = pref.edit();
+ boolean autoWrite = pref.getBoolean(AUTO_TEST_WRITE_CONTENT, true);
+ if (autoWrite) {
+ Thread autoTest = new Thread() {
+ public void run() {
+ writeAutoTextHelpTxt(editor);
+ }
+ };
+ autoTest.start();
+ }
+ }
+
+ private void writeAutoTextHelpTxt(SharedPreferences.Editor editor) {
+ List<String> supportLists = new ArrayList<String>();
+ /* Video Size */
+ String[] videoSizes = getEntryValues(R.array.pref_camera2_video_quality_entryvalues);
+ /* Picture Size */
+ String[] pictSizes = getEntryValues(R.array.pref_camera2_picturesize_entryvalues);
+ // back support pictureSizes
+ List<String> backPLists = getSupportList(getSupportedPictureSize(0), pictSizes);
+ supportLists.add("<Back camera support PictureSizes>");
+ supportLists.addAll(backPLists);
+ // front support pictureSizes
+ if (mCharacteristics.size() > 1) {
+ List<String> frontPLists = getSupportList(getSupportedPictureSize(1), pictSizes);
+ supportLists.add("<Front camera support PictureSizes>");
+ supportLists.addAll(frontPLists);
+ /* Video Size */
+ List<String> frontVideoLists = getSupportList(getSupportedVideoSize(1), videoSizes);
+ supportLists.add("<Front camera support VideoSizes and fps>");
+ for (int i=0; i < frontVideoLists.size(); i++) {
+ String videoSize = frontVideoLists.get(i);
+ List<String> fps = getSupportedHFRForAutoTest(videoSize);
+ supportLists.add(videoSize);
+ supportLists.addAll(fps);
+ List<String> videoEncoders = getSupportedVideoEncoderForAutoTest(videoSize);
+ supportLists.addAll(videoEncoders);
+ supportLists.add("");
+ }
+ }
+ List<String> backVideoLists = getSupportList(getSupportedVideoSize(0), videoSizes);
+ supportLists.add("<Back camera support VideoSizes and fps>");
+ for (int i=0; i < backVideoLists.size(); i++) {
+ String videoSize = backVideoLists.get(i);
+ List<String> fps = getSupportedHFRForAutoTest(videoSize);
+ supportLists.add(videoSize);
+ supportLists.addAll(fps);
+ List<String> videoEncoders = getSupportedVideoEncoderForAutoTest(videoSize);
+ supportLists.addAll(videoEncoders);
+ supportLists.add("");
+ }
+
+ String filePath = AutoTestUtil.createFile(mContext);
+ boolean result = AutoTestUtil.writeFileContent(filePath, supportLists);
+ editor.putBoolean(AUTO_TEST_WRITE_CONTENT, false);
+ editor.apply();
+ }
+
+ private List<String> setCharSequenceToListStr(String title, CharSequence[] charSequences) {
+ List<String> list = new ArrayList<String>();
+ list.add(title);
+ for (CharSequence support : charSequences) {
+ list.add(support.toString());
+ }
+ return list;
+ }
+
+ private String[] getEntryValues(int id) {
+ return mContext.getResources().getStringArray(id);
+
+ }
+
+ public List<String> getSupportList(List<String> supported, String[] supportList) {
+ List<String> resultList = new ArrayList<String>();
+ for (String item : supportList) {
+ if (supported.indexOf(item) >= 0) {
+ resultList.add(item);
+ }
+ }
+ return resultList;
+ }
+
private void setLocalIdAndInitialize(int cameraId) {
mPreferences.setLocalId(mContext, cameraId);
mCameraId = cameraId;
@@ -1164,6 +1254,102 @@ public class SettingsManager implements ListMenu.SettingsListener {
return res;
}
+ private List<String> getSupportedVideoEncoderForAutoTest(String videoSizeStr) {
+ ArrayList<String> supported = new ArrayList<String>();
+ ListPreference videoEncoder = mPreferenceGroup.findPreference(KEY_VIDEO_ENCODER);
+ if (videoEncoder == null) return supported;
+
+ if (videoEncoder != null) {
+ String str = null;
+ List<VideoEncoderCap> videoEncoders = EncoderCapabilities.getVideoEncoders();
+ for (VideoEncoderCap vEncoder: videoEncoders) {
+ str = SettingTranslation.getVideoEncoder(vEncoder.mCodec);
+ if (str != null) {
+ if (videoSizeStr != null) {
+ Size videoSize = parseSize(videoSizeStr);
+ if (videoSize.getWidth() > vEncoder.mMaxFrameWidth ||
+ videoSize.getWidth() < vEncoder.mMinFrameWidth ||
+ videoSize.getHeight() > vEncoder.mMaxFrameHeight ||
+ videoSize.getHeight() < vEncoder.mMinFrameHeight) {
+ Log.e(TAG, "Codec = " + vEncoder.mCodec + ", capabilities: " +
+ "mMinFrameWidth = " + vEncoder.mMinFrameWidth + " , " +
+ "mMinFrameHeight = " + vEncoder.mMinFrameHeight + " , " +
+ "mMaxFrameWidth = " + vEncoder.mMaxFrameWidth + " , " +
+ "mMaxFrameHeight = " + vEncoder.mMaxFrameHeight);
+ } else {
+ supported.add(str);
+ }
+ }
+ }
+ }
+ }
+ return supported;
+ }
+
+ private List<String> getSupportedHFRForAutoTest(String videoSizeStr) {
+ ArrayList<String> supported = new ArrayList<String>();
+ ListPreference videoEncoder = mPreferenceGroup.findPreference(KEY_VIDEO_ENCODER);
+ if (videoEncoder == null) return supported;
+ int videoEncoderNum = SettingTranslation.getVideoEncoder(videoEncoder.getValue());
+ VideoCapabilities videoCapabilities = null;
+ boolean findVideoEncoder = false;
+ if (videoSizeStr != null) {
+ Size videoSize = parseSize(videoSizeStr);
+ MediaCodecList allCodecs = new MediaCodecList(MediaCodecList.ALL_CODECS);
+ for (MediaCodecInfo info : allCodecs.getCodecInfos()) {
+ if (!info.isEncoder() || info.getName().contains("google")) continue;
+ for (String type : info.getSupportedTypes()) {
+ if ((videoEncoderNum == MediaRecorder.VideoEncoder.MPEG_4_SP && type.equalsIgnoreCase(MediaFormat.MIMETYPE_VIDEO_MPEG4))
+ || (videoEncoderNum == MediaRecorder.VideoEncoder.H263 && type.equalsIgnoreCase(MediaFormat.MIMETYPE_VIDEO_H263))
+ || (videoEncoderNum == MediaRecorder.VideoEncoder.H264 && type.equalsIgnoreCase(MediaFormat.MIMETYPE_VIDEO_AVC))
+ || (videoEncoderNum == MediaRecorder.VideoEncoder.HEVC && type.equalsIgnoreCase(MediaFormat.MIMETYPE_VIDEO_HEVC))) {
+ CodecCapabilities codecCapabilities = info.getCapabilitiesForType(type);
+ videoCapabilities = codecCapabilities.getVideoCapabilities();
+ findVideoEncoder = true;
+ break;
+ }
+ }
+ if (findVideoEncoder) break;
+ }
+
+ try {
+ Range[] range = getSupportedHighSpeedVideoFPSRange(mCameraId, videoSize);
+ for (Range r : range) {
+ // To support HFR for both preview and recording,
+ // minmal FPS needs to be equal to maximum FPS
+ if ((int) r.getUpper() == (int) r.getLower()) {
+ if (videoCapabilities != null) {
+ if (videoCapabilities.areSizeAndRateSupported(
+ videoSize.getWidth(), videoSize.getHeight(), (int) r.getUpper())) {
+ supported.add("hfr" + String.valueOf(r.getUpper()));
+ supported.add("hsr" + String.valueOf(r.getUpper()));
+ }
+ }
+ }
+ }
+ } catch (IllegalArgumentException ex) {
+ Log.w(TAG, "HFR is not supported for this resolution " + ex);
+ }
+ if (mExtendedHFRSize != null && mExtendedHFRSize.length >= 3) {
+ for (int i = 0; i < mExtendedHFRSize.length; i += 3) {
+ String item = "hfr" + mExtendedHFRSize[i + 2];
+ if (!supported.contains(item)
+ && videoSize.getWidth() <= mExtendedHFRSize[i]
+ && videoSize.getHeight() <= mExtendedHFRSize[i + 1]) {
+ if (videoCapabilities != null) {
+ if (videoCapabilities.areSizeAndRateSupported(
+ videoSize.getWidth(), videoSize.getHeight(), mExtendedHFRSize[i + 2])) {
+ supported.add(item);
+ supported.add("hsr" + mExtendedHFRSize[i + 2]);
+ }
+ }
+ }
+ }
+ }
+ }
+ return supported;
+ }
+
private List<String> getSupportedHighFrameRate() {
ArrayList<String> supported = new ArrayList<String>();
supported.add("off");