Merge "FM: Store duration of file recording in database"
diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java
index 82c029c..a095d11 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;
@@ -1277,7 +1277,7 @@
});
mSampleStart = SystemClock.elapsedRealtime();
- Log.d(LOGTAG, "mSampleStart: " +mSampleStart);
+ Log.d(LOGTAG, "Sample start time: " +mSampleStart);
return true;
}
@@ -1294,8 +1294,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);
@@ -1340,7 +1342,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));