From 637aa08ffd14e60d01832af2aa0d2076864aa237 Mon Sep 17 00:00:00 2001
From: Kamal Negi <kamaln@codeaurora.org>
Date: Thu, 20 Oct 2016 11:44:15 +0530
Subject: [PATCH] Check for antenna connected on activity restart

On activity restart, check if antenna connected or not. On activity
restart we request for audio focus and update the UI with Radio text
etc. even if antenna not connected. This enables UI and disable it again
even if FM is turned off.

CRs-Fixed: 1081388
Change-Id: I0c27f4025322451447423e1f5c07da1f8db790e6
---
 fmapp2/src/com/caf/fmradio/FMRadio.java | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fmapp2/src/com/caf/fmradio/FMRadio.java b/fmapp2/src/com/caf/fmradio/FMRadio.java
index 43fd2ef..7d357f7 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadio.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadio.java
@@ -439,7 +439,7 @@ public class FMRadio extends Activity
    public void onRestart() {
       Log.d(LOGTAG, "FMRadio: onRestart");
       try {
-         if (null != mService) {
+         if (null != mService && isAntennaAvailable()) {
               mService.requestFocus();
          }
       } catch (Exception e) {
@@ -505,6 +505,9 @@ public class FMRadio extends Activity
 
       super.onResume();
 
+      if (!isAntennaAvailable()) {
+          return;
+      }
       // TODO: We should return on exception or continue?
       try {
           if (mService != null)
-- 
GitLab