diff options
author | Rupesh Tatiya <rtatiya@codeaurora.org> | 2016-01-19 21:54:49 +0530 |
---|---|---|
committer | Arne Coucheron <arco68@gmail.com> | 2016-03-22 00:14:24 +0100 |
commit | e48b2e68c31fc90c4ea5725e261f9b5756707249 (patch) | |
tree | 7b5f40b3e17bdfeb21c0924eb869a3a4e632a111 | |
parent | daaa11b54fce58bc63977f686b96a9c212577cde (diff) | |
download | android_hardware_qcom_fm-e48b2e68c31fc90c4ea5725e261f9b5756707249.tar.gz android_hardware_qcom_fm-e48b2e68c31fc90c4ea5725e261f9b5756707249.tar.bz2 android_hardware_qcom_fm-e48b2e68c31fc90c4ea5725e261f9b5756707249.zip |
Stop recording only if its storage is unmounted
Stop FM recording only if the storage where it was saving file is
unmounted and not on unmounting of any other storage as done before.
CRs-Fixed: 964047
Change-Id: Ic9dc2ca3ef2c9c91400156be47da4a6c8620ce8c
Signed-off-by: Rupesh Tatiya <rtatiya@codeaurora.org>
-rw-r--r-- | fmapp2/src/com/caf/fmradio/FMRadioService.java | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java index 855afe2..4fa919d 100644 --- a/fmapp2/src/com/caf/fmradio/FMRadioService.java +++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java @@ -215,6 +215,7 @@ public class FMRadioService extends Service private static final int AUDIO_FRAMES_COUNT_TO_IGNORE = 3; private Object mRecordSinkLock = new Object(); private boolean mIsFMDeviceLoopbackActive = false; + private File mStoragePath = null; private Notification.Builder mRadioNotification; private Notification mNotificationInstance; @@ -547,8 +548,16 @@ public class FMRadioService extends Service || (action.equals(Intent.ACTION_MEDIA_EJECT))) { Log.d(LOGTAG, "ACTION_MEDIA_UNMOUNTED Intent received"); if (mFmRecordingOn == true) { + if (mStoragePath == null) { + Log.d(LOGTAG, "Storage path is null, doing nothing"); + return; + } try { - stopRecording(); + String state = Environment.getExternalStorageState(mStoragePath); + if (!Environment.MEDIA_MOUNTED.equals(state)) { + Log.d(LOGTAG, "Recording storage is not mounted, stop recording"); + stopRecording(); + } } catch (Exception e) { e.printStackTrace(); } @@ -1158,6 +1167,13 @@ public class FMRadioService extends Service } + mStoragePath = Environment.getExternalStorageDirectory(); + Log.d(LOGTAG, "mStoragePath " + mStoragePath); + if (null == mStoragePath) { + Log.e(LOGTAG, "External Storage Directory is null"); + return false; + } + mSampleFile = null; File sampleDir = null; if (!"".equals(getResources().getString(R.string.def_fmRecord_savePath))) { @@ -1269,7 +1285,7 @@ public class FMRadioService extends Service int sampleLength = (int)((System.currentTimeMillis() - mSampleStart)/1000 ); if (sampleLength == 0) return; - String state = Environment.getExternalStorageState(); + String state = Environment.getExternalStorageState(mStoragePath); Log.d(LOGTAG, "storage state is " + state); if (Environment.MEDIA_MOUNTED.equals(state)) { @@ -2328,16 +2344,6 @@ public class FMRadioService extends Service public boolean isSpeakerEnabled() { return mSpeakerPhoneOn; } - public boolean isExternalStorageAvailable() { - boolean mStorageAvail = false; - String state = Environment.getExternalStorageState(); - - if(Environment.MEDIA_MOUNTED.equals(state)){ - Log.d(LOGTAG, "device available"); - mStorageAvail = true; - } - return mStorageAvail; - } public void enableSpeaker(boolean speakerOn) { Log.d(LOGTAG, "speakerOn: " + speakerOn); |