QGP: Customize fmapp2 to seek next station by hook button of headset

The old way to customize seek-next-station FR through
registerMediaButtonEventReceiver() has been deprecated.

So we should move this FR to MediaSession and detect long press
to trigger the seek-next-station operation.

Change-Id: If0ea91a8681e6dd1c79c05a382f9de2230886a9a
CRs-Fixed: 853013
diff --git a/fmapp2/src/com/caf/fmradio/FMRadio.java b/fmapp2/src/com/caf/fmradio/FMRadio.java
index 6fa9298..5f89dc3 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadio.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadio.java
@@ -3131,6 +3131,10 @@
          Log.d(LOGTAG, "mServiceCallbacks.onRecordingStarted:");
          startRecordingTimer();
       }
+      public void onSeekNextStation() {
+          Log.d(LOGTAG, "mServiceCallbacks.onSeekNextStation:");
+          SeekNextStation();
+      }
    };
 
     private void registerFMSettingListner() {
diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java
index c7f1682..a0448c3 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadioService.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java
@@ -469,12 +469,6 @@
                          int keycode = event.getKeyCode();
                          switch (keycode) {
                              case KeyEvent.KEYCODE_HEADSETHOOK :
-                                 if (isFmOn() && getResources()
-                                        .getBoolean(R.bool.def_headset_next_enabled)) {
-                                     Log.d(LOGTAG, "enabled the headset button function to seek next station");
-                                     seek(true);
-                                     break;
-                                 }
                                  toggleFM();
                                  if (isOrderedBroadcast()) {
                                      abortBroadcast();
@@ -838,6 +832,13 @@
                     toggleFM();
                 } else if ((mKeyActionDownCount == 2) && (key_action == KeyEvent.ACTION_DOWN)) {
                     Log.d(LOGTAG, "SessionCallback: HEADSETHOOK/MEDIA_PLAY_PAUSE long press");
+                    if (isFmOn() && getResources()
+                            .getBoolean(R.bool.def_headset_next_enabled)) {
+                        try {
+                            mCallbacks.onSeekNextStation();
+                        }catch (RemoteException e) {
+                        }
+                    }
                     mKeyActionDownCount = 0;
                 }
                 return true;
diff --git a/fmapp2/src/com/caf/fmradio/FMStats.java b/fmapp2/src/com/caf/fmradio/FMStats.java
index a380781..ddefd89 100644
--- a/fmapp2/src/com/caf/fmradio/FMStats.java
+++ b/fmapp2/src/com/caf/fmradio/FMStats.java
@@ -2713,6 +2713,9 @@
              initiateRecordDurationTimer(durationInMins);
              invalidateOptionsMenu();
           }
+          public void onSeekNextStation() {
+             Log.d(LOGTAG, "mServiceCallbacks.onSeekNextStation:");
+          }
       };
       /* Radio Vars */
      private Handler mHandler = new Handler();
diff --git a/fmapp2/src/com/caf/fmradio/IFMRadioServiceCallbacks.aidl b/fmapp2/src/com/caf/fmradio/IFMRadioServiceCallbacks.aidl
index 4b9d2f0..6a8deb5 100644
--- a/fmapp2/src/com/caf/fmradio/IFMRadioServiceCallbacks.aidl
+++ b/fmapp2/src/com/caf/fmradio/IFMRadioServiceCallbacks.aidl
@@ -46,4 +46,5 @@
   void onRecordingStopped();
   void onExtenRadioTextChanged();
   void onRecordingStarted();
+  void onSeekNextStation();
 }