[FM] FM recording can not be stopped in notification bar

Select "Start Recording" in options menu -> Press "Home"
key, drag-down notification bar -> Tap "stop recording"
button -> Check the screen, "Save recording?"dialog will
not pop up.

The fix is set different intent actions to distinguish
which intent is called at onNewIntent(). If clicking stop
button, need to stop recording.

Bug 18849361
from: https://partner-android-review.googlesource.com/#/c/192387/

Change-Id: I229c8cf7c44c7a9ba3b2ba752a47cbcda4690b37
Signed-off-by: Benson Huang <benson.huang@mediatek.com>
diff --git a/src/com/android/fmradio/FmRecordActivity.java b/src/com/android/fmradio/FmRecordActivity.java
index cfee6e2..b00d146 100644
--- a/src/com/android/fmradio/FmRecordActivity.java
+++ b/src/com/android/fmradio/FmRecordActivity.java
@@ -55,8 +55,10 @@
  */
 public class FmRecordActivity extends Activity implements
         FmSaveDialog.OnRecordingDialogClickListener {
-    private static final String TAG = "FmRecordActivity/Record";
+    private static final String TAG = "FmRecordActivity";
 
+    private static final String FM_STOP_RECORDING = "fmradio.stop.recording";
+    private static final String FM_ENTER_RECORD_SCREEN = "fmradio.enter.record.screen";
     private static final String TAG_SAVE_RECORDINGD = "SaveRecording";
     private static final int MSG_UPDATE_NOTIFICATION = 1000;
     private Context mContext;
@@ -161,9 +163,8 @@
 
     private void updateRecordingNotification(long recordTime) {
         if (mNotificationBuilder == null) {
-            Intent intent = new Intent();
+            Intent intent = new Intent(FM_STOP_RECORDING);
             intent.setClass(mContext, FmRecordActivity.class);
-            intent.putExtra("is_from_notification", true);
             intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
             PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, intent,
                     PendingIntent.FLAG_UPDATE_CURRENT);
@@ -179,7 +180,7 @@
                     .addAction(R.drawable.btn_fm_rec_stop_enabled, getText(R.string.stop_record),
                             pendingIntent);
 
-            Intent cIntent = new Intent();
+            Intent cIntent = new Intent(FM_ENTER_RECORD_SCREEN);
             cIntent.setClass(mContext, FmRecordActivity.class);
             cIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
             PendingIntent contentPendingIntent = PendingIntent.getActivity(mContext, 0, cIntent,
@@ -199,10 +200,16 @@
 
     @Override
     public void onNewIntent(Intent intent) {
-        // If start by notification, need stop recording
-        if (intent != null && intent.getBooleanExtra("is_from_notification", false)
-                && mService != null & !isStopRecording()) {
-            mService.stopRecordingAsync();
+        if (intent != null && intent.getAction() != null) {
+            String action = intent.getAction();
+            if (FM_STOP_RECORDING.equals(action)) {
+                // If click stop button in notification, need to stop recording
+                if (mService != null && !isStopRecording()) {
+                    mService.stopRecordingAsync();
+                }
+            } else if (FM_ENTER_RECORD_SCREEN.equals(action)) {
+                // Just enter record screen, do nothing
+            }
         }
     }