summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKhalid Zubair <kzubair@cyngn.com>2016-06-28 12:14:22 -0700
committerKhalid Zubair <kzubair@cyngn.com>2016-06-28 15:14:08 -0700
commit480142b3781b394a9f088cba0bc51d8ecbbc4faa (patch)
treecfe647ff9857835459fdcd724ec7b24235c1830f
parent3c0c276699c9ba975e370c3c7711677b71772854 (diff)
downloadandroid_packages_apps_FMRadio-480142b3781b394a9f088cba0bc51d8ecbbc4faa.tar.gz
android_packages_apps_FMRadio-480142b3781b394a9f088cba0bc51d8ecbbc4faa.tar.bz2
android_packages_apps_FMRadio-480142b3781b394a9f088cba0bc51d8ecbbc4faa.zip
Keep main activity when recording is cancelled
When a recording (running in background) is stopped and the user returns to the FM app, the recording activity is seen with a 'Save Recording?' popup. After responding keep/discard the app exits itself instead of returning to the main activity. This happens because the service calls exitFm() and activity finish() when the service receives the musicservice 'pause' command (e.g. when the camera starts). Instead of a complete shutdown, stop recording and pause (powerDown) the FM playback. This leaves the service in a funtional state and the recording activity can save/discard the recording and return to the main screen. FEIJ-1373 Change-Id: Ia3209b32cea193e76fb7b0b26b1ba05b88bd9d2c
-rw-r--r--src/com/android/fmradio/FmService.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/com/android/fmradio/FmService.java b/src/com/android/fmradio/FmService.java
index d197be4..f6e98c3 100644
--- a/src/com/android/fmradio/FmService.java
+++ b/src/com/android/fmradio/FmService.java
@@ -248,7 +248,14 @@ public class FmService extends Service implements FmRecorder.OnRecorderStateChan
String command = intent.getStringExtra("command");
Log.d(TAG, "onReceive, action = " + action + " / command = " + command);
// other app want FM stop, stop FM
- if ((SOUND_POWER_DOWN_MSG.equals(action) && CMDPAUSE.equals(command))) {
+
+ if (CMDPAUSE.equals(command)) {
+ // need remove all messages, make power down will be execute
+ mFmServiceHandler.removeCallbacksAndMessages(null);
+ Log.d(TAG, "Stopping FM playback");
+ powerDownAsync();
+ } else if (SOUND_POWER_DOWN_MSG.equals(action)) {
+ // phone shut down, so exit FM
// need remove all messages, make power down will be execute
mFmServiceHandler.removeCallbacksAndMessages(null);
exitFm();
@@ -692,6 +699,10 @@ public class FmService extends Service implements FmRecorder.OnRecorderStateChan
return true;
}
+ if (mFmRecorder != null) {
+ stopRecording();
+ }
+
setMute(true);
setRds(false);
enableFmAudio(false);