summaryrefslogtreecommitdiffstats
path: root/fmapp2
diff options
context:
space:
mode:
Diffstat (limited to 'fmapp2')
-rw-r--r--fmapp2/src/com/caf/fmradio/FMRadioService.java30
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);