summaryrefslogtreecommitdiffstats
path: root/fmapp2
diff options
context:
space:
mode:
authorXuebo Li <xuebol@codeaurora.org>2015-11-03 16:37:16 +0800
committerArne Coucheron <arco68@gmail.com>2016-03-22 00:14:08 +0100
commit40a5d4be4ec96d589f419f48349677dc7c0d89ea (patch)
tree2164c58f604402cf8bdf4c4adabf56a4c588452a /fmapp2
parentbd28479d329965aefbf5c7a2472ace6c9c578d74 (diff)
downloadandroid_hardware_qcom_fm-40a5d4be4ec96d589f419f48349677dc7c0d89ea.tar.gz
android_hardware_qcom_fm-40a5d4be4ec96d589f419f48349677dc7c0d89ea.tar.bz2
android_hardware_qcom_fm-40a5d4be4ec96d589f419f48349677dc7c0d89ea.zip
FM: Regional requirement for FM
- Add resource to customize FM-recorder files name format. - Add resource to customize the save path of FM-recorder files. - Add resource to customize media type. Change-Id: I5d547ec691d44621b19b2c8435c290b8eafeabc5 CRs-Fixed: 933506
Diffstat (limited to 'fmapp2')
-rw-r--r--fmapp2/res/values/customize.xml15
-rw-r--r--fmapp2/src/com/caf/fmradio/FMRadioService.java47
2 files changed, 59 insertions, 3 deletions
diff --git a/fmapp2/res/values/customize.xml b/fmapp2/res/values/customize.xml
index 43f4018..3216d42 100644
--- a/fmapp2/res/values/customize.xml
+++ b/fmapp2/res/values/customize.xml
@@ -44,4 +44,19 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<bool name="def_only_stereo_enabled">false</bool>
+ <!-- enabled the name format of recordings files or not, default value is false -->
+ <bool name="def_save_name_format_enabled">false</bool>
+
+ <!-- the prefix of recordings files name, file name like this "FM-yyyy-MM-dd-HH-mm-ss.3gpp" -->
+ <string name="def_save_name_prefix" translatable="false">FM</string>
+
+ <!-- the suffix of recordings files, default value is ".3gpp" -->
+ <string name="def_save_name_suffix" translatable="false">.3gpp</string>
+
+ <!-- the name format of recordings files -->
+ <string name="def_save_name_format" translatable="false">yyyy-MM-dd-HH-mm-ss</string>
+
+ <!-- the save path of recordings files -->
+ <string name="def_fmRecord_savePath" translatable="false"></string>
+
</resources>
diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java
index 61aabd7..478fedf 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadioService.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java
@@ -1145,6 +1145,32 @@ public class FMRadioService extends Service
return status;
}
+ private File createTempFile(String prefix, String suffix, File directory)
+ throws IOException {
+ // Force a prefix null check first
+ if (prefix.length() < 3) {
+ throw new IllegalArgumentException("prefix must be at least 3 characters");
+ }
+ if (suffix == null) {
+ suffix = ".tmp";
+ }
+ File tmpDirFile = directory;
+ if (tmpDirFile == null) {
+ String tmpDir = System.getProperty("java.io.tmpdir", ".");
+ tmpDirFile = new File(tmpDir);
+ }
+
+ String nameFormat = getResources().getString(R.string.def_save_name_format);
+ SimpleDateFormat df = new SimpleDateFormat(nameFormat);
+ String currentTime = df.format(System.currentTimeMillis());
+
+ File result;
+ do {
+ result = new File(tmpDirFile, prefix + currentTime + suffix);
+ } while (!result.createNewFile());
+ return result;
+ }
+
public boolean startRecording() {
int mRecordDuration = -1;
@@ -1181,12 +1207,27 @@ public class FMRadioService extends Service
}
mSampleFile = null;
- File sampleDir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() +"/FMRecording");
+ File sampleDir = null;
+ if (!"".equals(getResources().getString(R.string.def_fmRecord_savePath))) {
+ String fmRecordSavePath = getResources().getString(R.string.def_fmRecord_savePath);
+ sampleDir = new File(Environment.getExternalStorageDirectory().toString()
+ + fmRecordSavePath);
+ } else {
+ sampleDir = new File(Environment.getExternalStorageDirectory().getAbsolutePath()
+ + "/FMRecording");
+ }
+
if(!(sampleDir.mkdirs() || sampleDir.isDirectory()))
return false;
try {
- mSampleFile = File
- .createTempFile("FMRecording", ".aac", sampleDir);
+ if (getResources().getBoolean(R.bool.def_save_name_format_enabled)) {
+ String suffix = getResources().getString(R.string.def_save_name_suffix);
+ suffix = "".equals(suffix) ? ".3gpp" : suffix;
+ String prefix = getResources().getString(R.string.def_save_name_prefix) + '-';
+ mSampleFile = createTempFile(prefix, suffix, sampleDir);
+ } else {
+ mSampleFile = File.createTempFile("FMRecording", ".3gpp", sampleDir);
+ }
} catch (IOException e) {
Log.e(LOGTAG, "Not able to access SD Card");
Toast.makeText(this, "Not able to access SD Card", Toast.LENGTH_SHORT).show();