From 5b83d77f94f549f4d2803d68bd8b5e2df0e3a76e Mon Sep 17 00:00:00 2001
From: Mingbo Zhang <mingboz@codeaurora.org>
Date: Tue, 10 Jan 2017 14:02:28 +0800
Subject: [PATCH] pause cmd behaves like audiofocus loss

when fm audio is routed to a2dp, then video is started
to play. fm will receive pause cmd, and call fmOperationsOff,
then call resetAudioRoute(). audio output will be changed to
wired headset. We should keep audio route unchanged.

Change-Id: I42a15fea24ed26bfe7460a4611bca1a7620de4e1
CRs-Fixed: 1109351
---
 fmapp2/src/com/caf/fmradio/FMRadioService.java | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java
index ceaa022..a178548 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadioService.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java
@@ -742,8 +742,10 @@ public class FMRadioService extends Service
                         Log.d(LOGTAG, "Music Service command : "+cmd+ " received");
                         if (cmd != null && cmd.equals("pause")) {
                             if (isFmOn()) {
-                                fmOperationsOff();
-                                mStoppedOnFocusLoss = true;
+                                AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
+                                audioManager.abandonAudioFocus(mAudioFocusListener);
+                                mDelayedStopHandler.obtainMessage(FOCUSCHANGE, AudioManager.AUDIOFOCUS_LOSS, 0).sendToTarget();
+
                                 if (isOrderedBroadcast()) {
                                     abortBroadcast();
                                 }
-- 
GitLab