summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorxianming wang <mingwax@codeaurora.org>2018-11-30 10:26:27 +0800
committerjinwu <jinwu@codeaurora.org>2018-12-27 20:54:17 +0800
commit36e8c1e6cceff44dd722efe72388742afd5d1854 (patch)
tree48714d041b449f51306058413a5b654c44b5c061 /src
parentc48104739d7221ff3c617f34f2d6c63be5888288 (diff)
downloadandroid_packages_apps_Snap-36e8c1e6cceff44dd722efe72388742afd5d1854.tar.gz
android_packages_apps_Snap-36e8c1e6cceff44dd722efe72388742afd5d1854.tar.bz2
android_packages_apps_Snap-36e8c1e6cceff44dd722efe72388742afd5d1854.zip
SnapdragonCamera: Complete Auto test requirements
Completed the Auto test requirements which can get the available options of videoSize fps videoEncoder and pictureSize. CRs-Fixed: 2353929 Change-Id: If244e90d7c585aae9ae7d52b7db1a9f489a95059
Diffstat (limited to 'src')
-rwxr-xr-xsrc/com/android/camera/SettingsManager.java188
-rwxr-xr-xsrc/com/android/camera/util/AutoTestUtil.java120
2 files changed, 307 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");
diff --git a/src/com/android/camera/util/AutoTestUtil.java b/src/com/android/camera/util/AutoTestUtil.java
new file mode 100755
index 000000000..4d8cc107e
--- /dev/null
+++ b/src/com/android/camera/util/AutoTestUtil.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.android.camera.util;
+
+import android.content.Context;
+import android.util.Log;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.io.BufferedReader;
+import java.io.FileOutputStream;
+import java.io.PrintWriter;
+import java.io.IOException;
+import java.util.List;
+
+
+public class AutoTestUtil {
+
+ private static final String TAG = "AutoTestUtil";
+
+ public static String createFile (Context context) {
+ String path = context.getApplicationContext().getFilesDir().getAbsolutePath();
+ Log.v(TAG, "getFilePath path :" + path);
+ String filePathName = path + "/AutoTestHelp" + ".txt";
+ File file = new File(filePathName);
+ try {
+ if (!file.exists()) {
+ file.createNewFile();
+ }
+ } catch(IOException exception) {
+ exception.printStackTrace();
+ }
+ return filePathName;
+ }
+
+ public static boolean writeFileContent(String filePath, List<String> list) {
+ boolean result = false;
+ String temp = "";
+
+ FileInputStream fis = null;
+ InputStreamReader isr = null;
+ BufferedReader br = null;
+ FileOutputStream fos = null;
+ PrintWriter pw = null;
+ try {
+ File file = new File(filePath);
+ fis = new FileInputStream(file);
+ isr = new InputStreamReader(fis);
+ br = new BufferedReader(isr);
+ StringBuffer strBuffer = new StringBuffer();
+
+ for(int i=0; (temp=br.readLine())!=null; i++) {
+ strBuffer.append(temp);
+ strBuffer.append("\n");
+ }
+
+ for (String newStr : list) {
+ strBuffer.append(newStr);
+ strBuffer.append("\r\n");
+ }
+
+ fos = new FileOutputStream(file);
+ pw = new PrintWriter(fos);
+ pw.write(strBuffer.toString().toCharArray());
+ pw.flush();
+ result = true;
+ } catch(IOException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ if (pw != null) {
+ pw.close();
+ }
+ if (fos != null) {
+ fos.close();
+ }
+ if (br != null) {
+ br.close();
+ }
+ if (isr != null) {
+ isr.close();
+ }
+ if (fis != null) {
+ fis.close();
+ }
+ } catch(IOException e) {
+ e.printStackTrace();
+ }
+ }
+ return result;
+ }
+
+}