summaryrefslogtreecommitdiffstats
path: root/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java
diff options
context:
space:
mode:
authorAyaz Ahmad <aahmad@codeaurora.org>2013-12-16 17:49:08 +0530
committerAyaz Ahmad <aahmad@codeaurora.org>2013-12-18 15:56:22 +0530
commit35122243d0a1c6209142ab76cb911f02fd4f2802 (patch)
tree28d955fa105ae7a6876f0d4b8e0f02e683ced507 /FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java
parent60ca65983863572f25e5da9dc64da457f1c6e424 (diff)
downloadandroid_hardware_qcom_fm-35122243d0a1c6209142ab76cb911f02fd4f2802.tar.gz
android_hardware_qcom_fm-35122243d0a1c6209142ab76cb911f02fd4f2802.tar.bz2
android_hardware_qcom_fm-35122243d0a1c6209142ab76cb911f02fd4f2802.zip
fmrecord: Stop recording when sd card is unmounted
FM recording does not stop when sd card is unmounted. Stop FM recording on receiving sd card unmounted intent. Change-Id: I79fe6ce0d0799b6be5716ed5f51b9ed87598c205 CRs-Fixed: 581710
Diffstat (limited to 'FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java')
-rw-r--r--FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java b/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java
index e542512..4ca4645 100644
--- a/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java
+++ b/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java
@@ -92,6 +92,7 @@ public class FMRecordingService extends Service {
private Thread mStatusCheckThread = null;
private int clientPid = -1;
private String clientProcessName = "";
+ private BroadcastReceiver mSdcardUnmountReceiver = null;
public void onCreate() {
@@ -99,6 +100,7 @@ public class FMRecordingService extends Service {
Log.d(TAG, "FMRecording Service onCreate");
registerRecordingListner();
registerShutdownListner();
+ registerStorageMediaListener();
}
public int onStartCommand(Intent intent, int flags, int startId) {
@@ -115,6 +117,7 @@ public class FMRecordingService extends Service {
}
unregisterBroadCastReceiver(mFmRecordingReceiver);
unregisterBroadCastReceiver(mFmShutdownReceiver);
+ unregisterBroadCastReceiver(mSdcardUnmountReceiver);
super.onDestroy();
}
@@ -196,6 +199,33 @@ public class FMRecordingService extends Service {
return true;
}
+ private void registerStorageMediaListener() {
+ if (mSdcardUnmountReceiver == null) {
+ mSdcardUnmountReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ if ((action.equals(Intent.ACTION_MEDIA_UNMOUNTED))
+ || action.equals(Intent.ACTION_MEDIA_EJECT)) {
+ Log.d(TAG, "ACTION_MEDIA_UNMOUNTED Intent received");
+ if (mFmRecordingOn == true) {
+ try {
+ stopRecord();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ };
+ IntentFilter iFilter = new IntentFilter();
+ iFilter.addAction(Intent.ACTION_MEDIA_UNMOUNTED);
+ iFilter.addAction(Intent.ACTION_MEDIA_EJECT);
+ iFilter.addDataScheme("file");
+ registerReceiver(mSdcardUnmountReceiver, iFilter);
+ }
+ }
+
private void sendRecordingStatusIntent(int status) {
Intent intent = new Intent(ACTION_FM_RECORDING_STATUS);
intent.putExtra("state", status);