summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanesh M <daneshm90@gmail.com>2014-11-25 12:38:19 -0800
committerEthan Chen <intervigil@gmail.com>2015-01-08 12:38:30 -0800
commit793e029317a1839388a8a38da10085744aab7156 (patch)
treeef3883f41dd52e44fe8cd6cac52e778f1013d96e
parentc5f6f90e1ffbdbc0dd9796f81c7ecb7076900d31 (diff)
downloadandroid_hardware_qcom_fm-793e029317a1839388a8a38da10085744aab7156.tar.gz
android_hardware_qcom_fm-793e029317a1839388a8a38da10085744aab7156.tar.bz2
android_hardware_qcom_fm-793e029317a1839388a8a38da10085744aab7156.zip
FMRecorder : Save to a private temporary file while recording
While recording save to a temporary private file and once finished, move to external storage Change-Id: If82a84beeffe2ea8e5ba4bf7e93e4f3d6203e10f
-rw-r--r--FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java20
1 files changed, 15 insertions, 5 deletions
diff --git a/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java b/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java
index 251ba23..e95a148 100644
--- a/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java
+++ b/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java
@@ -236,13 +236,11 @@ public class FMRecordingService extends Service {
}
mSampleFile = null;
- File sampleDir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() +"/FMRecording");
-
- if(!(sampleDir.mkdirs() || sampleDir.isDirectory()))
- return false;
+ File sampleDir = getExternalCacheDir();
try {
- mSampleFile = File.createTempFile("FMRecording", ".3gpp", sampleDir);
+ mSampleFile = new File(sampleDir, "FMRecording.3gpp");
+ mSampleFile.createNewFile();
} catch (IOException e) {
Log.e(TAG, "Not able to access SD Card");
Toast.makeText(this, "Not able to access SD Card", Toast.LENGTH_SHORT).show();
@@ -359,6 +357,18 @@ public class FMRecordingService extends Service {
Log.d(TAG, "storage state is " + state);
if (Environment.MEDIA_MOUNTED.equals(state)) {
+ File finalFile;
+ try {
+ finalFile = File.createTempFile("FMRecording", ".3gpp",
+ Environment.getExternalStorageDirectory());
+ mSampleFile.renameTo(finalFile);
+ mSampleFile = finalFile;
+ } catch (IOException e) {
+ Log.e(TAG, "Not able to access SD Card");
+ Toast.makeText(this, "Not able to access SD Card", Toast.LENGTH_SHORT).show();
+ e.printStackTrace();
+ }
+
try {
this.addToMediaDB(mSampleFile);
Toast.makeText(this,getString(R.string.save_record_file,