Skip to content
Snippets Groups Projects
Commit 8cddbc9a authored by Linux Build Service Account's avatar Linux Build Service Account
Browse files

Promotion of fm.lnx.1.0-00009.

CRs      Change ID                                   Subject
--------------------------------------------------------------------------------------------------------------
964047   Ic9dc2ca3ef2c9c91400156be47da4a6c8620ce8c   Stop recording only if its storage is unmounted

Change-Id: Icf5fabeb909e933e09830152bed7be42eb855438
CRs-Fixed: 964047
parents c3bc670c 9a50d9a3
No related branches found
No related tags found
No related merge requests found
...@@ -212,6 +212,7 @@ public class FMRadioService extends Service ...@@ -212,6 +212,7 @@ public class FMRadioService extends Service
private static final int AUDIO_FRAMES_COUNT_TO_IGNORE = 3; private static final int AUDIO_FRAMES_COUNT_TO_IGNORE = 3;
private Object mRecordSinkLock = new Object(); private Object mRecordSinkLock = new Object();
private boolean mIsFMDeviceLoopbackActive = false; private boolean mIsFMDeviceLoopbackActive = false;
private File mStoragePath = null;
private static final int FM_OFF_FROM_APPLICATION = 1; private static final int FM_OFF_FROM_APPLICATION = 1;
private static final int FM_OFF_FROM_ANTENNA = 2; private static final int FM_OFF_FROM_ANTENNA = 2;
...@@ -540,8 +541,16 @@ public class FMRadioService extends Service ...@@ -540,8 +541,16 @@ public class FMRadioService extends Service
|| (action.equals(Intent.ACTION_MEDIA_EJECT))) { || (action.equals(Intent.ACTION_MEDIA_EJECT))) {
Log.d(LOGTAG, "ACTION_MEDIA_UNMOUNTED Intent received"); Log.d(LOGTAG, "ACTION_MEDIA_UNMOUNTED Intent received");
if (mFmRecordingOn == true) { if (mFmRecordingOn == true) {
if (mStoragePath == null) {
Log.d(LOGTAG, "Storage path is null, doing nothing");
return;
}
try { try {
String state = Environment.getExternalStorageState(mStoragePath);
if (!Environment.MEDIA_MOUNTED.equals(state)) {
Log.d(LOGTAG, "Recording storage is not mounted, stop recording");
stopRecording(); stopRecording();
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -1125,6 +1134,13 @@ public class FMRadioService extends Service ...@@ -1125,6 +1134,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; mSampleFile = null;
File sampleDir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() +"/FMRecording"); File sampleDir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() +"/FMRecording");
if(!(sampleDir.mkdirs() || sampleDir.isDirectory())) if(!(sampleDir.mkdirs() || sampleDir.isDirectory()))
...@@ -1221,7 +1237,7 @@ public class FMRadioService extends Service ...@@ -1221,7 +1237,7 @@ public class FMRadioService extends Service
int sampleLength = (int)((System.currentTimeMillis() - mSampleStart)/1000 ); int sampleLength = (int)((System.currentTimeMillis() - mSampleStart)/1000 );
if (sampleLength == 0) if (sampleLength == 0)
return; return;
String state = Environment.getExternalStorageState(); String state = Environment.getExternalStorageState(mStoragePath);
Log.d(LOGTAG, "storage state is " + state); Log.d(LOGTAG, "storage state is " + state);
if (Environment.MEDIA_MOUNTED.equals(state)) { if (Environment.MEDIA_MOUNTED.equals(state)) {
...@@ -2264,16 +2280,6 @@ public class FMRadioService extends Service ...@@ -2264,16 +2280,6 @@ public class FMRadioService extends Service
public boolean isSpeakerEnabled() { public boolean isSpeakerEnabled() {
return mSpeakerPhoneOn; 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) { public void enableSpeaker(boolean speakerOn) {
Log.d(LOGTAG, "speakerOn: " + speakerOn); Log.d(LOGTAG, "speakerOn: " + speakerOn);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment