From da03ddb58d04899f3b20e33190de89a8147b15ef Mon Sep 17 00:00:00 2001 From: Smriti Gupta <smritig@codeaurora.org> Date: Wed, 3 Aug 2016 16:11:05 +0530 Subject: [PATCH] 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 --- fmapp2/src/com/caf/fmradio/FMRadioService.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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 @@ public class FMRadioService extends Service 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 @@ public class FMRadioService extends Service 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 @@ public class FMRadioService extends Service }); mSampleStart = SystemClock.elapsedRealtime(); - Log.d(LOGTAG, "mSampleStart: " +mSampleStart); + Log.d(LOGTAG, "Sample start time: " +mSampleStart); return true; } @@ -1279,8 +1279,10 @@ public class FMRadioService extends Service } 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 @@ public class FMRadioService extends Service // 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)); -- GitLab