diff options
author | Ayaz Ahmad <aahmad@codeaurora.org> | 2013-09-04 17:17:49 +0530 |
---|---|---|
committer | Ayaz Ahmad <aahmad@codeaurora.org> | 2013-09-06 11:51:02 +0530 |
commit | 93e785596c81dc2414f5121a3919bc608852dc35 (patch) | |
tree | e2aa05c116648a62e30cc9e713735487e1bc8b11 /FMRecord | |
parent | b0880e7472611a74c9f5df1a9e8176d2b76f984c (diff) | |
download | android_hardware_qcom_fm-93e785596c81dc2414f5121a3919bc608852dc35.tar.gz android_hardware_qcom_fm-93e785596c81dc2414f5121a3919bc608852dc35.tar.bz2 android_hardware_qcom_fm-93e785596c81dc2414f5121a3919bc608852dc35.zip |
fmapp2: Fix the issue FM recording timer does not stop
FM recording service gets killed by activity manager
as no package component is bound to it, and it runs in seperate
process so fm activity does not get notified of this killing.
Run recording service in foreground.
CRs-Fixed: 536649
Change-Id: I5dce8ff877aebb5038f3eabe60128500301afecd
Diffstat (limited to 'FMRecord')
-rwxr-xr-x | FMRecord/res/drawable/ic_menu_record.png | bin | 0 -> 798 bytes | |||
-rw-r--r-- | FMRecord/res/layout/record_status_bar.xml | 42 | ||||
-rw-r--r-- | FMRecord/res/values/strings.xml | 1 | ||||
-rw-r--r-- | FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java | 18 |
4 files changed, 61 insertions, 0 deletions
diff --git a/FMRecord/res/drawable/ic_menu_record.png b/FMRecord/res/drawable/ic_menu_record.png Binary files differnew file mode 100755 index 0000000..60f7a01 --- /dev/null +++ b/FMRecord/res/drawable/ic_menu_record.png diff --git a/FMRecord/res/layout/record_status_bar.xml b/FMRecord/res/layout/record_status_bar.xml new file mode 100644 index 0000000..d2e1151 --- /dev/null +++ b/FMRecord/res/layout/record_status_bar.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + * Copyright (c) 2013, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of The Linux Foundation nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +--> +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/fmradio" + android:layout_width="fill_parent" + android:layout_height="fill_parent" + android:orientation="vertical"> + + <TextView + android:id="@+id/record_label" + android:layout_width="fill_parent" + android:layout_height="wrap_content" + android:textSize="15sp" + android:text="@string/fm_record_progress"/> + +</RelativeLayout> diff --git a/FMRecord/res/values/strings.xml b/FMRecord/res/values/strings.xml index 59f14ad..ff11d19 100644 --- a/FMRecord/res/values/strings.xml +++ b/FMRecord/res/values/strings.xml @@ -46,4 +46,5 @@ <!-- all recordings will show up in the media database in a playlist with this name --> <string name="audio_db_playlist_name">FM recordings</string> <string name="save_record_file">FM Recorded file saved to "<xliff:g id="record_file">%1$s</xliff:g>"</string> + <string name="fm_record_progress">FM Recording in progress</string> </resources> diff --git a/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java b/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java index 2c615e8..39db48a 100644 --- a/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java +++ b/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java @@ -57,6 +57,13 @@ import android.os.UserHandle; import android.net.Uri; import android.content.res.Resources; import android.os.StatFs; +import android.app.Notification; +import android.app.NotificationManager; +import android.widget.RemoteViews; +import android.R.layout; +import android.R.drawable; +import android.content.ComponentName; +import android.content.res.Resources; public class FMRecordingService extends Service { private static final String TAG = "FMRecordingService"; @@ -282,9 +289,19 @@ public class FMRecordingService extends Service { }); mSampleStart = System.currentTimeMillis(); sendRecordingStatusIntent(START); + startNotification(); return true; } + private void startNotification() { + RemoteViews views = new RemoteViews(getPackageName(), R.layout.record_status_bar); + Notification status = new Notification(); + status.contentView = views; + status.flags |= Notification.FLAG_ONGOING_EVENT; + status.icon = R.drawable.ic_menu_record; + startForeground(102, status); + } + private void stopRecord() { Log.d(TAG, "Enter stopRecord"); mFmRecordingOn = false; @@ -301,6 +318,7 @@ public class FMRecordingService extends Service { sendRecordingStatusIntent(STOP); saveFile(); + stopForeground(true); } private void saveFile() { |