summaryrefslogtreecommitdiffstats
path: root/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java
diff options
context:
space:
mode:
authorVenkateshwarlu Domakonda <Venkateshwarlu@codeaurora.org>2013-09-02 11:55:23 +0530
committerVenkateshwarlu Domakonda <Venkateshwarlu@codeaurora.org>2013-09-02 19:23:43 +0530
commit7ef0f1717ed62357807d7952eecb8aba54f1f7ea (patch)
treef7ac235a2cb88aa536c57cbc8c61eec35eabc92a /FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java
parent15ddfeb22142016dceee6c71386e261902b545b7 (diff)
downloadandroid_hardware_qcom_fm-7ef0f1717ed62357807d7952eecb8aba54f1f7ea.tar.gz
android_hardware_qcom_fm-7ef0f1717ed62357807d7952eecb8aba54f1f7ea.tar.bz2
android_hardware_qcom_fm-7ef0f1717ed62357807d7952eecb8aba54f1f7ea.zip
FMRecord: Handle shutdown intent
- Fm recording file is not getting saved, if device is shutting down during recording. - If shutdown happens during recording, save the file before closing the application. Change-Id: I652e0fdc548a9c848147568bfbd1d052112ab792 CRs-Fixed: 524782
Diffstat (limited to 'FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java')
-rw-r--r--FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java27
1 files changed, 25 insertions, 2 deletions
diff --git a/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java b/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java
index 3fb6446..2c615e8 100644
--- a/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java
+++ b/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java
@@ -61,6 +61,7 @@ import android.os.StatFs;
public class FMRecordingService extends Service {
private static final String TAG = "FMRecordingService";
private BroadcastReceiver mFmRecordingReceiver = null;
+ private BroadcastReceiver mFmShutdownReceiver = null;
public static final long UNAVAILABLE = -1L;
public static final long PREPARING = -2L;
public static final long UNKNOWN_SIZE = -3L;
@@ -83,6 +84,7 @@ public class FMRecordingService extends Service {
super.onCreate();
Log.d(TAG, "FMRecording Service onCreate");
registerRecordingListner();
+ registerShutdownListner();
}
public int onStartCommand(Intent intent, int flags, int startId) {
@@ -98,6 +100,7 @@ public class FMRecordingService extends Service {
stopRecord();
}
unregisterBroadCastReceiver(mFmRecordingReceiver);
+ unregisterBroadCastReceiver(mFmShutdownReceiver);
super.onDestroy();
}
@@ -106,13 +109,33 @@ public class FMRecordingService extends Service {
return null;
}
- private void unregisterBroadCastReceiver(BroadcastReceiver myreceiver) {
+ private void unregisterBroadCastReceiver(BroadcastReceiver myreceiver) {
if (myreceiver != null) {
unregisterReceiver(myreceiver);
myreceiver = null;
}
- }
+ }
+
+ private void registerShutdownListner() {
+ if (mFmShutdownReceiver == null) {
+ mFmShutdownReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Log.d(TAG, "Received intent " +intent);
+ String action = intent.getAction();
+ Log.d(TAG, " action = " +action);
+ if (action.equals("android.intent.action.ACTION_SHUTDOWN")) {
+ Log.d(TAG, "android.intent.action.ACTION_SHUTDOWN Intent received");
+ stopRecord();
+ }
+ }
+ };
+ IntentFilter iFilter = new IntentFilter();
+ iFilter.addAction("android.intent.action.ACTION_SHUTDOWN");
+ registerReceiver(mFmShutdownReceiver, iFilter);
+ }
+ }
private static long getAvailableSpace() {
String state = Environment.getExternalStorageState();