FM: Store duration of file recording in database
Store duration of the audio file recorded in the FM APP
in the database on stopRecording().
CRs-Fixed: 1049601
Change-Id: Ie775be8bfe88f3a0381569f56782096fa61db3fb
diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java
index a5e1d13..c62267e 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadioService.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java
@@ -160,6 +160,7 @@
private boolean mStoppedOnFactoryReset = false;
private File mSampleFile = null;
long mSampleStart = 0;
+ int mSampleLength = 0;
// Messages handled in FM Service
private static final int FM_STOP =1;
private static final int RESET_NOTCH_FILTER =2;
@@ -215,7 +216,6 @@
private Object mEventWaitLock = new Object();
private boolean mIsFMDeviceLoopbackActive = false;
private File mStoragePath = null;
-
private static final int FM_OFF_FROM_APPLICATION = 1;
private static final int FM_OFF_FROM_ANTENNA = 2;
private static final int RADIO_TIMEOUT = 1500;
@@ -1262,7 +1262,7 @@
});
mSampleStart = SystemClock.elapsedRealtime();
- Log.d(LOGTAG, "mSampleStart: " +mSampleStart);
+ Log.d(LOGTAG, "Sample start time: " +mSampleStart);
return true;
}
@@ -1279,8 +1279,10 @@
} catch(Exception e) {
e.printStackTrace();
}
- int sampleLength = (int)((System.currentTimeMillis() - mSampleStart)/1000 );
- if (sampleLength == 0)
+ mSampleLength = (int)(SystemClock.elapsedRealtime() - mSampleStart);
+ Log.d(LOGTAG, "Sample length is " + mSampleLength);
+
+ if (mSampleLength == 0)
return;
String state = Environment.getExternalStorageState(mStoragePath);
Log.d(LOGTAG, "storage state is " + state);
@@ -1325,7 +1327,7 @@
// Lets label the recorded audio file as NON-MUSIC so that the file
// won't be displayed automatically, except for in the playlist.
cv.put(MediaStore.Audio.Media.IS_MUSIC, "1");
-
+ cv.put(MediaStore.Audio.Media.DURATION, mSampleLength);
cv.put(MediaStore.Audio.Media.TITLE, title);
cv.put(MediaStore.Audio.Media.DATA, file.getAbsolutePath());
cv.put(MediaStore.Audio.Media.DATE_ADDED, (int) (current / 1000));