SnapdragonCamera: Add 48min 144min No Limit for 480fps

Add 48min 144min and No Limit for 480fps.

CRS-Fixed: 2361398
Change-Id: Ie89e00edcb5fe10a544d873e6800a9ae7a10c574
diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml
old mode 100644
new mode 100755
index 9b8290f..715029f
--- a/res/values-zh-rCN/strings.xml
+++ b/res/values-zh-rCN/strings.xml
@@ -415,6 +415,8 @@
     <string name="pref_camera_video_duration_entry_mms">"30 秒(MMS)"</string>
     <string name="pref_camera_video_duration_entry_10">"10 分钟"</string>
     <string name="pref_camera_video_duration_entry_30">"30 分钟"</string>
+  <string name="pref_camera_video_duration_entry_48">"48 分钟"</string>
+  <string name="pref_camera_video_duration_entry_144">"144 分钟"</string>
     <string name="pref_camera_video_duration_entry_nolimit">"无限制"</string>
 
    <!-- Settings screen, Select hfr title -->
diff --git a/res/values/camera2arrays.xml b/res/values/camera2arrays.xml
index f34d2f8..f51e2f8 100755
--- a/res/values/camera2arrays.xml
+++ b/res/values/camera2arrays.xml
@@ -748,6 +748,8 @@
         <item>@string/pref_camera_video_duration_entry_mms</item>
         <item>@string/pref_camera_video_duration_entry_10</item>
         <item>@string/pref_camera_video_duration_entry_30</item>
+        <item>@string/pref_camera_video_duration_entry_48</item>
+        <item>@string/pref_camera_video_duration_entry_144</item>
         <item>@string/pref_camera_video_duration_entry_nolimit</item>
     </string-array>
 
@@ -756,6 +758,8 @@
         <item>-1</item>
         <item>10</item>
         <item>30</item>
+        <item>48</item>
+        <item>144</item>
         <item>0</item>
     </string-array>
 
diff --git a/res/values/qcomstrings.xml b/res/values/qcomstrings.xml
index 50f70f0..877a9ac 100755
--- a/res/values/qcomstrings.xml
+++ b/res/values/qcomstrings.xml
@@ -91,6 +91,8 @@
     <string name="pref_camera_video_duration_entry_mms">30 seconds(MMS)</string>
     <string name="pref_camera_video_duration_entry_10">10 minutes</string>
     <string name="pref_camera_video_duration_entry_30">30 minutes</string>
+    <string name="pref_camera_video_duration_entry_48">48 minutes</string>
+    <string name="pref_camera_video_duration_entry_144">144 minutes</string>
     <string name="pref_camera_video_duration_entry_nolimit">no limit</string>
 
     <!-- Default Skin Tone Enhancement setting. Do not translate. -->
diff --git a/src/com/android/camera/SettingsActivity.java b/src/com/android/camera/SettingsActivity.java
index 8e80d56..2f3bfbf 100755
--- a/src/com/android/camera/SettingsActivity.java
+++ b/src/com/android/camera/SettingsActivity.java
@@ -99,6 +99,19 @@
                 updatePreference(SettingsManager.KEY_VIDEO_ENCODER);
             }else if ( key.equals(SettingsManager.KEY_VIDEO_ENCODER) ) {
                 updatePreference(SettingsManager.KEY_VIDEO_ENCODER_PROFILE);
+            } else if ( key.equals(SettingsManager.KEY_VIDEO_HIGH_FRAME_RATE) ) {
+                value = ((ListPreference) p).getValue();
+                if (!value.equals("off")) {
+                    int fpsRate = Integer.parseInt(value.substring(3));
+                    if (fpsRate == 480) {
+                        mSettingsManager.filterVideoDurationFor480fps();
+                    } else {
+                        mSettingsManager.filterVideoDuration();
+                    }
+                } else {
+                    mSettingsManager.filterVideoDuration();
+                }
+                updatePreference(SettingsManager.KEY_VIDEO_DURATION);
             }
             List<String> list = mSettingsManager.getDependentKeys(key);
             if (list != null) {
@@ -653,6 +666,7 @@
         updatePreference(SettingsManager.KEY_VIDEO_ENCODER);
         updatePreference(SettingsManager.KEY_ZOOM);
         updatePreference(SettingsManager.KEY_SWITCH_CAMERA);
+        updatePreference(SettingsManager.KEY_VIDEO_DURATION);
         updateMultiPreference(SettingsManager.KEY_STATS_VISUALIZER_VALUE);
         updatePictureSizePreferenceButton();
         updateVideoHDRPreference();
@@ -754,6 +768,7 @@
                     idx = 0;
                 }
                 pref.setValueIndex(idx);
+                mSettingsManager.setValueIndex(key, idx);
             }
         }
     }
diff --git a/src/com/android/camera/SettingsManager.java b/src/com/android/camera/SettingsManager.java
index 013fb67..b112291 100755
--- a/src/com/android/camera/SettingsManager.java
+++ b/src/com/android/camera/SettingsManager.java
@@ -829,6 +829,7 @@
         ListPreference mpo = mPreferenceGroup.findPreference(KEY_MPO);
         ListPreference redeyeReduction = mPreferenceGroup.findPreference(KEY_REDEYE_REDUCTION);
         ListPreference videoQuality = mPreferenceGroup.findPreference(KEY_VIDEO_QUALITY);
+        ListPreference videoDuration = mPreferenceGroup.findPreference(KEY_VIDEO_DURATION);
         ListPreference audioEncoder = mPreferenceGroup.findPreference(KEY_AUDIO_ENCODER);
         ListPreference noiseReduction = mPreferenceGroup.findPreference(KEY_NOISE_REDUCTION);
         ListPreference faceDetection = mPreferenceGroup.findPreference(KEY_FACE_DETECTION);
@@ -941,6 +942,29 @@
             }
         }
 
+        if (videoDuration != null) {
+            final SharedPreferences pref = mContext.getSharedPreferences(
+                    ComboPreferences.getLocalSharedPreferencesName(mContext, cameraId),
+                    Context.MODE_PRIVATE);
+            String fpsStr = pref.getString(SettingsManager.KEY_VIDEO_HIGH_FRAME_RATE, "off");
+            if (fpsStr != null && !fpsStr.equals("off")) {
+                int fpsRate = Integer.parseInt(fpsStr.substring(3));
+                if (fpsRate == 480) {
+                    if (filterUnsupportedOptions(videoDuration, getSupportedVideoDurationFor480())) {
+                        mFilteredKeys.add(videoDuration.getKey());
+                    }
+                } else {
+                    if (filterUnsupportedOptions(videoDuration, getSupportedVideoDuration())) {
+                        mFilteredKeys.add(videoDuration.getKey());
+                    }
+                }
+            } else {
+                if (filterUnsupportedOptions(videoDuration, getSupportedVideoDuration())) {
+                    mFilteredKeys.add(videoDuration.getKey());
+                }
+            }
+        }
+
         if (!mIsMonoCameraPresent) {
             if (clearsight != null) removePreference(mPreferenceGroup, KEY_CLEARSIGHT);
             if (monoPreview != null) removePreference(mPreferenceGroup, KEY_MONO_PREVIEW);
@@ -1617,6 +1641,24 @@
         return map.getOutputSizes(cl);
     }
 
+    private List<String> getSupportedVideoDuration() {
+        int[] videoDurations = {-1, 10, 30, 0};
+        List<String> modes = new ArrayList<>();
+        for (int i : videoDurations) {
+            modes.add(""+i);
+        }
+        return  modes;
+    }
+
+    private List<String> getSupportedVideoDurationFor480() {
+        int[] videoDurations = {48, 144, 0};
+        List<String> modes = new ArrayList<>();
+        for (int i : videoDurations) {
+            modes.add(""+i);
+        }
+        return  modes;
+    }
+
     private List<String> getSupportedVideoSize(int cameraId) {
         StreamConfigurationMap map = mCharacteristics.get(cameraId).get(
                 CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
@@ -2018,6 +2060,22 @@
         }
     }
 
+    public void filterVideoDuration() {
+        ListPreference videoDuration = mPreferenceGroup.findPreference(KEY_VIDEO_DURATION);
+        videoDuration.reloadInitialEntriesAndEntryValues();
+        if (filterUnsupportedOptions(videoDuration, getSupportedVideoDuration())) {
+            mFilteredKeys.add(videoDuration.getKey());
+        }
+    }
+
+    public void filterVideoDurationFor480fps() {
+        ListPreference videoDuration = mPreferenceGroup.findPreference(KEY_VIDEO_DURATION);
+        videoDuration.reloadInitialEntriesAndEntryValues();
+        if (filterUnsupportedOptions(videoDuration, getSupportedVideoDurationFor480())) {
+            mFilteredKeys.add(videoDuration.getKey());
+        }
+    }
+
     private boolean filterUnsupportedOptions(ListPreference pref, List<String> supported) {
         // Remove the preference if the parameter is not supported
         if (supported == null) {