summaryrefslogtreecommitdiffstats
path: root/fmapp2/src
diff options
context:
space:
mode:
authorDanesh M <daneshm90@gmail.com>2014-11-25 12:38:19 -0800
committerMatt Wagantall <mwagantall@cyngn.com>2016-02-19 14:07:47 -0800
commit92871d4e2a9fb803a046d5fc3109ca5b5e8aeddb (patch)
tree1343fb7f1e50dd390541e6c299e048d76cb36188 /fmapp2/src
parent10f12bc879ea4f053611bbe0eb0eb3ecc8ee630b (diff)
downloadandroid_hardware_qcom_fm-92871d4e2a9fb803a046d5fc3109ca5b5e8aeddb.tar.gz
android_hardware_qcom_fm-92871d4e2a9fb803a046d5fc3109ca5b5e8aeddb.tar.bz2
android_hardware_qcom_fm-92871d4e2a9fb803a046d5fc3109ca5b5e8aeddb.zip
FMRecorder : Save to a private temporary file while recordingstaging/for-cm13.0
While recording save to a temporary private file and once finished, move to external storage Change-Id: If82a84beeffe2ea8e5ba4bf7e93e4f3d6203e10f
Diffstat (limited to 'fmapp2/src')
-rw-r--r--fmapp2/src/com/caf/fmradio/FMRadioService.java20
1 files changed, 15 insertions, 5 deletions
diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java
index d19af3a..2235e2c 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadioService.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java
@@ -1126,12 +1126,11 @@ public class FMRadioService 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", ".aac", sampleDir);
+ mSampleFile = new File(sampleDir, "FMRecording.aac");
+ mSampleFile.createNewFile();
} 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();
@@ -1225,6 +1224,17 @@ public class FMRadioService extends Service
Log.d(LOGTAG, "storage state is " + state);
if (Environment.MEDIA_MOUNTED.equals(state)) {
+ File finalFile;
+ try {
+ finalFile = File.createTempFile("FMRecording", ".aac",
+ Environment.getExternalStorageDirectory());
+ mSampleFile.renameTo(finalFile);
+ mSampleFile = finalFile;
+ } 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();
+ e.printStackTrace();
+ }
try {
this.addToMediaDB(mSampleFile);
Toast.makeText(this,getString(R.string.save_record_file,