Merge "FM: add permission to receive android.intent.action.USER_SWITCHED Intent" into fm.lnx.6.0
diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java
index bcbc2ce..3d48f4f 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadioService.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java
@@ -1157,6 +1157,13 @@
stopRecording();
+ if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
+ Log.e(LOGTAG, "startRecording, no external storage available");
+ return false;
+ }
+
+ if (!updateAndShowStorageHint())
+ return false;
long maxFileSize = mStorageSpace - LOW_STORAGE_THRESHOLD;
if(FmSharedPreferences.getRecordDuration() !=
FmSharedPreferences.RECORD_DUR_INDEX_3_VAL) {
@@ -1172,7 +1179,7 @@
}
- mStoragePath = getApplicationContext().getFilesDir();;
+ mStoragePath = Environment.getExternalStorageDirectory();
Log.d(LOGTAG, "mStoragePath " + mStoragePath);
if (null == mStoragePath) {
Log.e(LOGTAG, "External Storage Directory is null");
@@ -1183,10 +1190,10 @@
File sampleDir = null;
if (!"".equals(getResources().getString(R.string.def_fmRecord_savePath))) {
String fmRecordSavePath = getResources().getString(R.string.def_fmRecord_savePath);
- sampleDir = new File(getApplicationContext().getFilesDir().getPath().toString()
+ sampleDir = new File(Environment.getExternalStorageDirectory().toString()
+ fmRecordSavePath);
} else {
- sampleDir = new File(getApplicationContext().getFilesDir().getAbsolutePath()
+ sampleDir = new File(Environment.getExternalStorageDirectory().getAbsolutePath()
+ "/FMRecording");
}
@@ -1264,6 +1271,7 @@
if (mFmRecordingOn) {
stopRecording();
}
+ updateAndShowStorageHint();
}
}
});
@@ -1296,6 +1304,7 @@
String state = Environment.getExternalStorageState(mStoragePath);
Log.d(LOGTAG, "storage state is " + state);
+ if (Environment.MEDIA_MOUNTED.equals(state)) {
try {
this.addToMediaDB(mSampleFile);
Toast.makeText(this,getString(R.string.save_record_file,
@@ -1304,6 +1313,10 @@
} catch(Exception e) {
e.printStackTrace();
}
+ } else {
+ Log.e(LOGTAG, "SD card must have removed during recording. ");
+ Toast.makeText(this, "Recording aborted", Toast.LENGTH_SHORT).show();
+ }
try {
if((mServiceInUse) && (mCallbacks != null) ) {
mCallbacks.onRecordingStopped();