1/*
2 *
3 * Copyright 2001-2011 Texas Instruments, Inc. - http://www.ti.com/
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 *    http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18
19package com.ti.server;
20
21import com.ti.fm.FmRadio;
22import com.ti.fm.IFmRadio;
23import com.ti.fm.FmRadioIntent;
24import com.ti.fm.IFmConstants;
25import android.content.BroadcastReceiver;
26import android.content.Context;
27import android.content.Intent;
28import android.content.IntentFilter;
29import android.os.RemoteException;
30import android.os.Handler;
31import android.media.AudioManager;
32import android.os.IBinder;
33import android.os.Message;
34import android.os.PowerManager;
35import android.provider.Settings;
36import android.util.Log;
37import android.os.Bundle;
38
39import java.util.concurrent.TimeUnit;
40import java.util.concurrent.BlockingQueue;
41import java.util.concurrent.LinkedBlockingQueue; /*  (additional packages required) */
42import java.util.HashMap;
43import java.util.LinkedList;
44import java.util.List;
45import java.util.ListIterator;
46import android.telephony.PhoneStateListener;
47import android.telephony.TelephonyManager;
48
49import android.os.ServiceManager;
50import android.os.SystemClock;
51import android.app.Notification;
52import android.app.NotificationManager;
53import android.app.PendingIntent; /*need wakelock for delayed poweroff */
54import android.os.PowerManager;
55import android.os.PowerManager.WakeLock;
56
57import android.media.MediaPlayer;
58import android.media.MediaPlayer.OnCompletionListener;
59import android.media.MediaPlayer.OnErrorListener;
60import android.view.KeyEvent;
61import java.io.IOException;
62import android.content.res.Resources;
63import android.content.ComponentName;
64import com.ti.jfm.core.*;
65import com.ti.server.R.*;
66
67
68/*************************************************************************************************
69 * Provides FM Radio functionality as a service in the Android Framework.
70 * There is a single instance of this class that is created during system
71 * startup as part of the system server. The class exposes its services via
72 * IFmRadio.aidl.
73 *
74 * @hide
75 *************************************************************************************************/
76
77public class StubFmService extends IFmRadio.Stub implements
78        JFmRx.ICallback,JFmTx.ICallback, IFmConstants {
79
80    private static final String TAG = "StubFmService";
81    private static final boolean DBG = false;
82    private static final String FMRX_ADMIN_PERM = "ti.permission.FMRX_ADMIN";
83    private static final String FMRX_PERM = "ti.permission.FMRX";
84    public static final String FM_SERVICE = "StubFmService";
85    private static final String AUDIO_RX_ENABLE = "audio_rx_enable";
86    private static final String AUDIO_TX_ENABLE = "audio_tx_enable";
87
88    /*FM specific commands*/
89    public static final String FM_PAUSE_CMD = "com.ti.server.fmpausecmd";
90    public static final String FM_RESUME_CMD = "com.ti.server.fmresumecmd";
91    private static final String FM_RESTORE_VALUES = "com.ti.server.fmrestorecmd";
92    public static final String FM_MUTE_CMD = "com.ti.server.fmmutecmd";
93    public static final String FM_UNMUTE_CMD = "com.ti.server.fmunmutecmd";
94
95
96    /*As the Alarm intents are not published in teh framework, using the string explicitly */
97    // TODO: Publish these intents
98    // This is a public action used in the manifest for receiving Alarm broadcasts
99    // from the alarm manager.
100    public static final String ALARM_ALERT_ACTION = "com.android.deskclock.ALARM_ALERT";
101
102    // A public action sent by AlarmKlaxon when the alarm has stopped sounding
103    // for any reason (e.g. because it has been dismissed from AlarmAlertFullScreen,
104    // or killed due to an incoming phone call, etc).
105    public static final String ALARM_DONE_ACTION = "com.android.deskclock.ALARM_DONE";
106
107       public static final String MUSIC_PAUSE_ACTION ="com.android.music.musicservicecommand";
108       public static final String CMDPAUSE = "pause";
109
110       private static final String ACTION_FMRx_PLUG = "ti.android.intent.action.FMRx_PLUG";
111       private static final String ACTION_FMTx_PLUG = "ti.android.intent.action.FMTx_PLUG";
112       private boolean mIsFmTxOn = false;
113
114    private AudioManager mAudioManager = null;
115    TelephonyManager tmgr;
116    private Context mContext = null;
117
118    private ComponentName mRemoteControlResponder;
119
120    /*FM TX and RX notification Ids*/
121    // TODO: When FM Service is made as an App Service, these will have to be moved there.
122    private int FM_RX_NOTIFICATION_ID;
123    private int FM_TX_NOTIFICATION_ID;
124
125    /*
126     * variable to make sure that the next volume change happens after the
127     * current volume request has been completed.
128     */
129    private boolean mVolState = VOL_REQ_STATE_IDLE;
130
131    /* Varibale to check whether to resume FM after call.*/
132
133    private boolean mResumeAfterCall = false;
134
135    private boolean mIsFmMuted = false;
136
137    private Object mVolumeSynchronizationLock = new Object();
138
139
140    /*  ***********Constants *********************** */
141    private Handler mDelayedDisableHandler;
142    private DelayedDisable mDelayedDisable;
143    private DelayedPauseDisable mDelayedPauseDisable;
144    private static final int FM_DISABLE_DELAY = 50;
145    private WakeLock mWakeLock = null;
146    private JFmRx mJFmRx;
147    private JFmTx mJFmTx;
148
149    private int mRxState = FmRadio.STATE_DEFAULT; // State of the FM Rx Service
150    private int mTxState = STATE_DEFAULT; // State of the FM Tx Service
151
152    private int mVolume = DEF_VOL; // to store the App Volume value
153    /*
154     * Variable to store the volume , so that when the value is changed intimate
155     * to the application
156     */
157    private int mLastVolume = DEF_VOL;
158
159    /* Variable to store the current Band */
160    private static int mCurrentBand = FM_BAND_EUROPE_US;
161
162    /* Variable to store the current tuned frequency */
163    private static int mCurrentFrequency = FM_FIRST_FREQ_US_EUROPE_KHZ;
164
165    /* Variable to store the current mute mode */
166    private static int mCurrentMuteMode = FM_NOT_MUTE;
167    /* Variable to store the current RDS state */
168    private static boolean mCurrentRdsState = false;
169    /*
170     * Variable to store the Mode , so that when the value is changed ,intimate
171     * to the application
172     */
173    private JFmRx.JFmRxMonoStereoMode mMode = JFmRx.JFmRxMonoStereoMode.FM_RX_STEREO;
174    /*
175     * Variable to store the PiCode , so that when the value is changed
176     * ,intimate to the application
177     */
178    static int last_msg_printed = 255;
179
180    /*
181     * To identify the pause/resume of the FM and reload the values
182     * accordingly(band,volume,freq)
183     */
184    private int mFmPauseResume =STATE_DISABLED;
185    private IntentFilter mIntentFilter;
186
187    /* Variables to store the return value of the FM APIs */
188    private static int getBandValue = FM_BAND_EUROPE_US;
189    private static int getMonoStereoModeValue = 0;
190    private static int getMuteModeValue = FM_NOT_MUTE;
191    private static int getRfDependentMuteModeValue = FM_RF_DEP_MUTE_OFF;
192    private static int getRssiThresholdValue = FM_RSSI_THRESHHOLD;
193    private static int getDeEmphasisFilterValue = 0;
194    private static int getVolumeValue = FM_MAX_VOLUME / 2;
195    private static int getChannelSpaceValue = FM_CHANNEL_SPACE;
196    private static int getTunedFrequencyValue = FM_UNDEFINED_FREQ;
197    private static int getRssiValue = 0;
198    private static int getRdsSystemValue = 0;
199    private static long getRdsGroupMaskValue = FM_UNDEFINED_FREQ;
200    private static int getRdsAfSwitchModeValue = 0;
201    private static double getFwVersion = 0.0;
202    private static int getScanProgress = 0;
203    private static boolean mIsValidChannel = false;
204    private static int mStopCompleteScanStatus = 0;
205
206    /*Variable to protect the FM APIS when Seek,Tune,CompleteScan is in progress*/
207    private static boolean mIsCompleteScanInProgress = false;
208    private static boolean mIsSeekInProgress = false;
209    private static boolean mIsTuneInProgress = false;
210
211
212    /* Varibale for fm TX zoom2 audio deafult */
213    private static final int fmTxDeafultCalResource=0; /*CAL_RESOURCE_I2SH*/
214    private static final int fmTxDeafultSampleFrequency=7; /*CAL_SAMPLE_FREQ_44100*/
215
216    /*
217     * Listener for Incoming call. Disable the FM and let the call proceed.
218     */
219
220    private PhoneStateListener mPhoneStateListener = new PhoneStateListener() {
221
222        public void onCallStateChanged(int state, String incomingNumber) {
223            if (state == TelephonyManager.CALL_STATE_RINGING) {
224                /* Don't handle pause/resume if FM radio is off */
225                if (!rxIsEnabled()) {
226                    return;
227                }
228                Log.d(TAG,"onCallStateChanged:CALL_STATE_RINGING.Pause FM Radio ");
229                pauseFm();
230                /* Turn off speakerphone before call and save state */
231                if (!mResumeAfterCall) {
232                    /* only turn off speaker if not already paused */
233                    mAudioManager.setSpeakerphoneOn(false);
234                }
235                mResumeAfterCall = true;
236
237            } else if (state == TelephonyManager.CALL_STATE_OFFHOOK) {
238                /* pause the music while a conversation is in progress.
239                 Don't handle pause/resume if FM radio is off */
240                if (!rxIsEnabled()) {
241                    return;
242                }
243                Log.d(TAG,"onCallStateChanged:CALL_STATE_OFFHOOK Pause FM Radio  ");
244                pauseFm();
245                /* Turn off speakerphone before call and save state */
246                if (!mResumeAfterCall) {
247                    /* only turn off speaker if not already paused */
248                    mAudioManager.setSpeakerphoneOn(false);
249                }
250                mResumeAfterCall = true;
251
252            } else if (state == TelephonyManager.CALL_STATE_IDLE) {
253                // start playing again
254                if (DBG)
255                    Log.d(TAG, "onCallStateChanged:CALL_STATE_IDLE) ");
256
257                if (mResumeAfterCall) {
258                    /* resume playback only if FM was playing
259                     when the call was answered */
260                    if (!rxIsFMPaused() ) {
261                        return;
262                    }
263                    resumeFm();
264                    mResumeAfterCall = false;
265                }
266
267            }
268        }
269    };
270
271    /*************************************************************************************************
272     *  Constructor
273     *************************************************************************************************/
274
275    public StubFmService() {
276
277        super();
278        //Log.d(TAG, "StubFmService: null constructor called");
279    }
280
281    private void initialise(Context context) {
282        //Log.d(TAG, "StubFmService:  initialise called");
283        // Save the context to be used later
284        mContext = context;
285        mRxState = STATE_DEFAULT;
286        mFmPauseResume =STATE_DEFAULT;
287
288        mDelayedDisable = new DelayedDisable();
289        mDelayedPauseDisable = new DelayedPauseDisable();
290        mDelayedDisableHandler = new Handler();
291        mAudioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
292        tmgr = (TelephonyManager) mContext
293                .getSystemService(Context.TELEPHONY_SERVICE);
294        tmgr.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
295
296        PowerManager powerManager = (PowerManager)context.
297                          getSystemService(Context.POWER_SERVICE);
298        if (powerManager != null) {
299                mWakeLock = powerManager.
300                    newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
301             }
302             else {
303            Log.e(TAG, "Failed to get Power Manager.");
304            mWakeLock = null;
305        }
306
307        if (mWakeLock != null) {
308            mWakeLock.setReferenceCounted(false);
309             }
310             else {
311            Log.e(TAG, "Failed to create WakeLock.");
312        }
313
314       mRemoteControlResponder = new ComponentName(mContext.getPackageName(),
315             MediaButtonBroadcastReceiver.class.getName());
316
317    }
318
319    /*************************************************************************************************
320     * Must be called after construction, and before any other method.
321     *************************************************************************************************/
322    public synchronized void init(Context context) {
323
324        initialise(context);
325        // create a single new JFmRx instance
326        mJFmRx = new JFmRx();
327        // create a single new JFmTx instance
328        mJFmTx = new JFmTx();
329
330    }
331
332    /*************************************************************************************************
333     * Must be called when the service is no longer needed.But is the service
334     * really going down?
335     *************************************************************************************************/
336    public synchronized void close() {
337        JFmRxStatus status;
338        //Log.d(TAG, "StubFmService:  close ");
339        try {
340            tmgr.listen(mPhoneStateListener, 0);
341            // destroy the underlying FMRX & FMTX
342            destroyJFmRx();
343            destroyJFmTx();
344        } catch (Exception e) {
345            Log.e(TAG, "close: Exception thrown during close (" + e.toString()
346                    + ")");
347            return;
348        }
349
350    }
351       /*
352        * L27 Specific
353        */
354
355       public void enableRx(int state) {
356         Intent fm_intent = new Intent(ACTION_FMRx_PLUG);
357        fm_intent.putExtra("state", state);
358          mContext.sendBroadcast(fm_intent);
359       }
360
361        public void enableTx(int state) {
362                Intent fm_intent = new Intent(ACTION_FMTx_PLUG);
363                fm_intent.putExtra("state", state);
364                mContext.sendBroadcast(fm_intent);
365           if (state == 1)
366             mIsFmTxOn = true;
367           else
368             mIsFmTxOn = false;
369    }
370
371       public boolean isTransmissionOn() {
372           return mIsFmTxOn;
373       }
374    /*************************************************************************************************
375     * Must be called after construction, and before any other method.
376     *************************************************************************************************/
377
378    public boolean rxIsEnabled() {
379        //Log.d(TAG, "StubFmService:  rxIsEnabled ");
380        mContext.enforceCallingOrSelfPermission(FMRX_PERM,
381                "Need FMRX_PERM permission");
382        return (mRxState == STATE_ENABLED);
383
384    }
385
386    /*************************************************************************************************
387     * Implementation of IFmRadio IPC interface
388     *************************************************************************************************/
389
390    public int rxGetFMState() {
391        mContext.enforceCallingOrSelfPermission(FMRX_PERM,
392                "Need FMRX_PERM permission");
393        Log.i(TAG, "rxGetFMState mRxState" +mRxState );
394        return mRxState;
395    }
396
397    /*************************************************************************************************
398     * Implementation of IFmRadio IPC interface
399     *************************************************************************************************/
400    public boolean rxIsFMPaused() {
401        mContext.enforceCallingOrSelfPermission(FMRX_PERM,
402                "Need FMRX_PERM permission");
403        Log.i(TAG, "rxIsFMPaused mFmPauseResume" + mFmPauseResume);
404        return (mFmPauseResume == STATE_PAUSE);
405    }
406
407    /*************************************************************************************************
408     * Implementation of conversion from Unsigned to nSigned Integer
409     *************************************************************************************************/
410    private int convertUnsignedToSignedInt(long a) {
411
412        int nReturnVal;
413
414        if ((a > 65535) || (a < 0)) {
415            Log.d(TAG,"convertUnsignedToSignedInt: Error in conversion from Unsigned to nSigned Integer");
416            nReturnVal = 0;
417            return nReturnVal;
418        }
419
420        if (a > 32767)
421            nReturnVal = (int) (a - 65536);
422        else
423            nReturnVal = (int) a;
424
425        return nReturnVal;
426    }
427
428    /*************************************************************************************************
429     * Implementation of IFmRadio IPC interface
430     *************************************************************************************************/
431
432    public synchronized boolean rxEnable() {
433        Log.i(TAG, "StubFmService:  rxEnable ");
434
435        if(IsFmTxEnabled()==true){
436            Log.e(TAG, "StubFmService rxEnable: FM TX is enabled could not Enable fm RX");
437                     return false;
438                        }
439
440        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
441                "Need FMRX_ADMIN_PERM permission");
442        mDelayedDisableHandler.removeCallbacks(mDelayedDisable);
443        mDelayedDisableHandler.removeCallbacks(mDelayedPauseDisable);
444        JFmRxStatus status;
445        try {
446        /* Tell the music playback service to pause*/
447            // TODO: these constants need to be published somewhere in the
448             //framework
449            Intent i = new Intent("com.android.music.musicservicecommand");
450            i.putExtra("command", "pause");
451            mContext.sendBroadcast(i);
452
453            /*
454             * register for the master Volume control Intent and music/video
455             * playback
456             */
457            mIntentFilter = new IntentFilter();
458            mIntentFilter.addAction(AudioManager.VOLUME_CHANGED_ACTION);
459            mIntentFilter.addAction(FM_PAUSE_CMD);
460            mIntentFilter.addAction(FM_RESUME_CMD);
461            /*This is for the  SMS and other notifications*/
462            mIntentFilter.addAction(FM_MUTE_CMD);
463            mIntentFilter.addAction(FM_UNMUTE_CMD);
464            mIntentFilter.addAction(FM_RESTORE_VALUES);
465            /*This is for the  Alarm notifications*/
466            mIntentFilter.addAction(ALARM_ALERT_ACTION);
467            mIntentFilter.addAction(ALARM_DONE_ACTION);
468                    mIntentFilter.addAction(MUSIC_PAUSE_ACTION);
469            mContext.registerReceiver(mFmRxIntentReceiver, mIntentFilter);
470
471            /*Seperate Receiver for Headset*/
472            IntentFilter inf = new IntentFilter();
473            inf.addAction(Intent.ACTION_HEADSET_PLUG);
474            mContext.registerReceiver(mHeadsetPlugReceiver, inf);
475
476            /*Seperate Receiver for MediaButton*/
477            mAudioManager.registerMediaButtonEventReceiver(
478            mRemoteControlResponder);
479
480        if((mRxState!= STATE_DEFAULT)&&(mRxState!= STATE_DISABLED))
481              switch (mRxState) {
482                   case STATE_ENABLED:
483                      return true;
484               default:
485                  return false;
486            }
487
488            // try communicating for 5 seconds (by trying to create a valid FmRX context)
489           boolean fmRxCreated = false;
490          for (int count = 0; count< 10; count++) {
491               //Log.i(TAG, "FmRxEnable: FmRx create try #" + count);
492          //Log.i(TAG, "FmRxEnable: mJFmRx is:"+ mJFmRx);
493             status = mJFmRx.create(this);
494             //Log.i(TAG, "FmRxEnable: FmRx create returned " + status.toString());
495             if (status == JFmRxStatus.SUCCESS) {
496                fmRxCreated = true;
497                break;
498             }
499             SystemClock.sleep(500);
500          }
501
502          if (fmRxCreated == false) {
503             Log.e(TAG, "FmRxEnable: FmRx create failed. Aborting");
504             return false;
505          }
506
507            status = mJFmRx.enable();
508            Log.i(TAG, "mJFmRx.enable returned status " + status.toString());
509
510            /* If the Operation Fail, Send false to the user and reset the MCP Monitor */
511            if (status != JFmRxStatus.PENDING && status != JFmRxStatus.SUCCESS){
512                Log.e(TAG, "mJFmRx.enable returned status "+ status.toString());
513                return false;
514            }
515
516        } catch (Exception e) {
517            Log.e(TAG, "enable: Exception thrown during enable ("
518                    + e.toString() + ")");
519            return false;
520        }
521        mRxState = STATE_ENABLING;
522        mFmPauseResume =STATE_DEFAULT;
523
524          // if its already on, call the event
525           if (status == JFmRxStatus.SUCCESS)
526               {
527               updateEnableConfiguration();
528               enableIntent(JFmRxStatus.SUCCESS);
529               }
530        else {
531            // set a delayed timeout message
532            }
533        return true;
534
535    }
536    private void  destroyJFmRx() {
537        //Log.i(TAG, "StubFmService:  destroyJFmRx ");
538        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
539                "Need FMRX_ADMIN_PERM permission");
540
541        try {
542            if(mContext!= null)
543            mContext.unregisterReceiver(mFmRxIntentReceiver);
544            mContext.unregisterReceiver(mHeadsetPlugReceiver);
545               mAudioManager.unregisterMediaButtonEventReceiver(
546                     mRemoteControlResponder);
547
548        if (mJFmRx != null) {
549                mJFmRx.destroy();
550            }
551
552        } catch (Exception e) {
553            Log.e(TAG, "destroyJFmRx: Exception thrown during destroy ("
554                    + e.toString() + ")");
555        }
556
557        mRxState = STATE_DEFAULT;
558
559    }
560
561    /*************************************************************************************************
562     * Implementation of IFmRadio IPC interface
563     *************************************************************************************************/
564    public synchronized boolean rxDisable() {
565        Log.i(TAG, "StubFmRxService:  rxDisable ");
566        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
567                "Need FMRX_ADMIN_PERM permission");
568        if (mRxState != STATE_ENABLED) {
569            Log.e(TAG, "disable error: fm not enabled " + mRxState);
570            return false;
571        }
572
573        mDelayedDisableHandler.postDelayed(mDelayedDisable, FM_DISABLE_DELAY);
574
575        return true;
576
577    }
578
579    /*************************************************************************************************
580     * Implementation DelayedDisable runnable class
581     *************************************************************************************************/
582    private class DelayedDisable implements Runnable {
583
584        public final void run() {
585            if ((mWakeLock != null) && (mWakeLock.isHeld())) {
586                mWakeLock.release();
587            }
588            if (mRxState == STATE_ENABLED) {
589                boolean success = true;
590                try {
591                    JFmRxStatus status = mJFmRx.disable();
592                    if (DBG)
593                        Log.d(TAG, "mJFmRx.disable returned status "
594                                + status.toString());
595                    if (JFmRxStatus.PENDING != status) {
596                        success = false;
597                        Log.e(TAG, "mJFmRx.disable returned status "
598                                + status.toString());
599                    }
600                } catch (Exception e) {
601                    success = false;
602                    Log.e(TAG, "disable: Exception thrown during disable ("
603                            + e.toString() + ")");
604                }
605                if (success) {
606                    mRxState = STATE_DISABLING;
607                    mFmPauseResume = STATE_DEFAULT;
608                }
609            } else {
610                Log.e(TAG, "disable error: fm not enabled " + mRxState);
611            }
612        }
613    }
614
615    private class DelayedPauseDisable implements Runnable {
616        public final void run() {
617            if ((mWakeLock != null) && (mWakeLock.isHeld())) {
618                mWakeLock.release();
619            }
620        // if its already off, call the completion function
621            if (mRxState == STATE_ENABLED) {
622                boolean success = true;
623                try {
624                    JFmRxStatus status = mJFmRx.disable();
625                    if (DBG)
626                        Log.d(TAG, "mJFmRx.disable returned status "
627                                + status.toString());
628                    if (JFmRxStatus.PENDING != status) {
629                        success = false;
630                        Log.e(TAG, "mJFmRx.disable returned status "
631                                + status.toString());
632                    }
633                } catch (Exception e) {
634                    success = false;
635                    Log.e(TAG, "disable: Exception thrown during disable ("
636                            + e.toString() + ")");
637            }
638                if (success) {
639                    mRxState = STATE_PAUSE;
640                    mFmPauseResume = STATE_PAUSE;
641                }
642            } else {
643                Log.e(TAG, "disable error: fm not enabled " + mRxState);
644        }
645        }
646
647    }
648
649    /*************************************************************************************************
650     * Implementation of IFmRadio IPC interface
651     *************************************************************************************************/
652    /* separate queue for each set call synchronization */
653    private BlockingQueue<String> mSetBandSyncQueue = new LinkedBlockingQueue<String>(
654            5);
655
656    public boolean rxSetBand(int band) {
657        Log.i(TAG, "StubFmService:rxSetBand   band " + band);
658        mCurrentBand = band;
659        if (mRxState != STATE_ENABLED) {
660            Log.e(TAG, "rxSetBand: failed, fm not enabled state " + mRxState);
661            return false;
662        }
663
664        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
665                "Need FMRX_ADMIN_PERM permission");
666        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
667                && (mIsCompleteScanInProgress == false)) {
668
669
670        JFmRx.JFmRxBand lBand = JFmUtils.getEnumConst(JFmRx.JFmRxBand.class,
671                band);
672        if (lBand == null) {
673            Log.e(TAG, "StubFmService:rxSetBand invalid  lBand " + lBand);
674            return false;
675        }
676
677        JFmRxStatus status = mJFmRx.setBand(lBand);
678        Log.i(TAG, "mJFmRx.setBand returned status " + status.toString());
679        if (JFmRxStatus.PENDING != status) {
680            Log.e(TAG, "mJFmRx.setBand returned status " + status.toString());
681            return false;
682        }
683
684        /*implementation to make the set API Synchronous */
685        try {
686            String syncString = mSetBandSyncQueue.take();
687            if (!syncString.equals("*")) {
688                Log.e(TAG, "wrong sync string reseived: " + syncString);
689            }
690        } catch (InterruptedException e) {
691            Log.e(TAG, "mJFmRx.setBand-- Wait() s Exception!!!");
692        }
693
694} else {
695            Log.e(TAG, "Seek is in progress.cannot call the API");
696            return false;
697        }
698        Log.i(TAG, "StubFmService:rxSetBand():--------- Exiting... ");
699
700        return true;
701
702    }
703
704    /*************************************************************************************************
705     * Implementation of IFmRadio IPC interface
706     *************************************************************************************************/
707    public boolean rxSetBand_nb(int band) {
708        Log.i(TAG, "StubFmService:rxSetBand_nb   band " + band);
709        mCurrentBand = band;
710        if (mRxState != STATE_ENABLED) {
711            Log.e(TAG, "rxSetBand_nb: failed, fm not enabled state " + mRxState);
712            return false;
713        }
714
715        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
716                "Need FMRX_ADMIN_PERM permission");
717
718        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
719        && (mIsCompleteScanInProgress == false)) {
720        JFmRx.JFmRxBand lBand = JFmUtils.getEnumConst(JFmRx.JFmRxBand.class,
721                band);
722        if (lBand == null) {
723            Log.e(TAG, "StubFmService:rxSetBand_nb invalid  lBand " + lBand);
724            return false;
725        }
726
727        JFmRxStatus status = mJFmRx.setBand(lBand);
728        Log.i(TAG, "mJFmRx.setBand returned status " + status.toString());
729        if (JFmRxStatus.PENDING != status) {
730            Log.e(TAG, "mJFmRx.setBand returned status " + status.toString());
731            return false;
732        }
733
734        } else {
735            Log.e(TAG, "Seek is in progress.cannot call the API");
736            return false;
737        }
738        return true;
739
740    }
741
742    /*************************************************************************************************
743     * Implementation of IFmRadio IPC interface
744     *************************************************************************************************/
745
746    /* (separate queue for each get call synchronization) */
747    private BlockingQueue<String> mBandSyncQueue = new LinkedBlockingQueue<String>(
748            5);
749    public synchronized int rxGetBand() {
750
751        Log.i(TAG, "StubFmService:rxGetBand  ");
752        if (mRxState != STATE_ENABLED) {
753            Log.e(TAG, "rxGetBand: failed, fm not enabled  state " + mRxState);
754            return 0;
755        }
756        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
757                "Need FMRX_ADMIN_PERM permission");
758
759    if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
760        && (mIsCompleteScanInProgress == false)) {
761            JFmRxStatus status = mJFmRx.getBand();
762            Log.i(TAG, "mJFmRx.getBand returned status " + status.toString());
763            if (JFmRxStatus.PENDING != status) {
764                Log.e(TAG, "mJFmRx.getBand returned status "
765                        + status.toString());
766                return 0;
767            }
768
769            /* implementation to make the FM API Synchronous */
770                try {
771                String syncString = mBandSyncQueue.take();
772                if (!syncString.equals("*")) {
773                    Log.e(TAG, "wrong sync string reseived: " + syncString);
774                }
775                } catch (InterruptedException e) {
776                    Log.e(TAG, "mJFmRx.getBand-- Wait() s Exception!!!");
777                }
778
779        } else {
780            Log.e(TAG, "Seek is in progress.cannot call the API");
781            return FM_SEEK_IN_PROGRESS;
782        }
783        Log.i(TAG, "StubFmService:rxGetBand():--------- Exiting... ");
784        return getBandValue;
785
786    }
787
788    /*************************************************************************************************
789     * Implementation of IFmRadio IPC interface
790     *************************************************************************************************/
791
792    public  boolean rxGetBand_nb() {
793
794        Log.i(TAG, "StubFmService:rxGetBand_nb  ");
795        if (mRxState != STATE_ENABLED) {
796            Log.e(TAG, "rxGetBand_nb: failed, fm not enabled  state " + mRxState);
797            return false;
798        }
799        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
800                "Need FMRX_ADMIN_PERM permission");
801        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
802                && (mIsCompleteScanInProgress == false)) {
803
804            JFmRxStatus status = mJFmRx.getBand();
805            Log.i(TAG, "mJFmRx.getBand returned status " + status.toString());
806            if (JFmRxStatus.PENDING != status) {
807                Log.e(TAG, "mJFmRx.getBand returned status "
808                        + status.toString());
809                return false;
810            }
811
812        } else {
813            Log.e(TAG, "Seek is in progress.cannot call the API");
814            return false;
815        }
816        return false;
817
818    }
819
820    /*************************************************************************************************
821     * Implementation of IFmRadio IPC interface
822     *************************************************************************************************/
823    /* (separate queue for each set call synchronization) */
824    private BlockingQueue<String> mSetMonoStereoModeSyncQueue = new LinkedBlockingQueue<String>(
825            5);
826
827    public boolean rxSetMonoStereoMode(int mode) {
828        Log.i(TAG, "StubFmService:rxSetMonoStereoMode mode  " + mode);
829        if (mRxState != STATE_ENABLED) {
830            Log.e(TAG, "rxSetMonoStereoMode: failed, fm not enabled  state "
831                    + mRxState);
832            return false;
833        }
834        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
835                "Need FMRX_ADMIN_PERM permission");
836        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
837                && (mIsCompleteScanInProgress == false)) {
838
839
840        JFmRx.JFmRxMonoStereoMode lMode = JFmUtils.getEnumConst(
841                JFmRx.JFmRxMonoStereoMode.class, mode);
842        if (lMode == null) {
843            Log.e(TAG, "StubFmService:rxSetMonoStereoMode invalid  lBand " + lMode);
844            return false;
845        }
846        JFmRxStatus status = mJFmRx.setMonoStereoMode(lMode);
847        Log.i(TAG, "mJFmRx.setMonoStereoMode returned status "
848                + status.toString());
849        if (JFmRxStatus.PENDING != status) {
850            Log.e(TAG, "mJFmRx.setMonoStereoMode returned status "
851                    + status.toString());
852            return false;
853        }
854
855        /*implementation to make the set API Synchronous */
856        try {
857            String syncString = mSetMonoStereoModeSyncQueue.take();
858            if (!syncString.equals("*")) {
859                Log.e(TAG, "wrong sync string reseived: " + syncString);
860            }
861        } catch (InterruptedException e) {
862            Log.e(TAG, "mJFmRx.setMonoStereoMode-- Wait() s Exception!!!");
863        }
864
865} else {
866            Log.e(TAG, "Seek is in progress.cannot call the API");
867            return false;
868        }
869        Log.i(TAG, "StubFmService:rxSetMonoStereoMode exiting");
870        return true;
871
872    }
873
874    /*************************************************************************************************
875     * Implementation of IFmRadio IPC interface
876     *************************************************************************************************/
877
878    public boolean rxSetMonoStereoMode_nb(int mode) {
879        Log.i(TAG, "StubFmService:rxSetMonoStereoMode_nb mode  " + mode);
880        if (mRxState != STATE_ENABLED) {
881            Log.e(TAG, "rxSetMonoStereoMode_nb: failed, fm not enabled  state "
882                    + mRxState);
883            return false;
884        }
885        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
886                "Need FMRX_ADMIN_PERM permission");
887
888        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
889        && (mIsCompleteScanInProgress == false)) {
890        JFmRx.JFmRxMonoStereoMode lMode = JFmUtils.getEnumConst(
891                JFmRx.JFmRxMonoStereoMode.class, mode);
892        if (lMode == null) {
893            Log.e(TAG, "StubFmService:rxSetMonoStereoMode_nb invalid  lBand "
894                    + lMode);
895            return false;
896        }
897        JFmRxStatus status = mJFmRx.setMonoStereoMode(lMode);
898        Log.i(TAG, "mJFmRx.setMonoStereoMode returned status "
899                + status.toString());
900        if (JFmRxStatus.PENDING != status) {
901            Log.e(TAG, "mJFmRx.setMonoStereoMode returned status "
902                    + status.toString());
903            return false;
904        }
905
906        } else {
907            Log.e(TAG, "Seek is in progress.cannot call the API");
908            return false;
909        }
910
911        return true;
912
913    }
914
915    /*************************************************************************************************
916     * Implementation of IFmRadio IPC interface
917     *************************************************************************************************/
918
919    /* (separate queue for each get call synchronization) */
920    private BlockingQueue<String> mMonoStereoModeSyncQueue = new LinkedBlockingQueue<String>(
921            5);
922
923    public synchronized int rxGetMonoStereoMode() {
924        Log.i(TAG, "StubFmService:rxGetMonoStereoMode  ");
925        if (mRxState != STATE_ENABLED) {
926            Log.e(TAG, "rxGetMonoStereoMode: failed, fm not enabled  state "
927                    + mRxState);
928            return 0;
929        }
930        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
931                "Need FMRX_ADMIN_PERM permission");
932
933        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
934        && (mIsCompleteScanInProgress == false)) {
935
936            JFmRxStatus status = mJFmRx.getMonoStereoMode();
937            Log.i(TAG, "mJFmRx.getMonoStereoMode returned status "
938                    + status.toString());
939            if (JFmRxStatus.PENDING != status) {
940                Log.e(TAG, "mJFmRx.getMonoStereoMode returned status "
941                        + status.toString());
942                return 0;
943            }
944
945            /*implementation to make the FM API Synchronous */
946
947                try {
948                String syncString = mMonoStereoModeSyncQueue.take();
949                if (!syncString.equals("*")) {
950                    Log.e(TAG, "wrong sync string reseived: " + syncString);
951                }
952            } catch (InterruptedException e) {
953                Log.e(TAG, "mJFmRx.getMonoStereoMode-- Wait() s Exception!!!");
954            }
955
956        } else {
957            Log.e(TAG, "Seek is in progress.cannot call the API");
958            return FM_SEEK_IN_PROGRESS;
959        }
960
961        Log.i(TAG, "StubFmService:rxGetMonoStereoMode(): -------- Exiting ");
962
963        return getMonoStereoModeValue;
964
965    }
966
967    /*************************************************************************************************
968     * Implementation of IFmRadio IPC interface
969     *************************************************************************************************/
970
971    public boolean rxGetMonoStereoMode_nb() {
972        Log.i(TAG, "StubFmService:rxGetMonoStereoMode_nb  ");
973        if (mRxState != STATE_ENABLED) {
974            Log.e(TAG, "rxGetMonoStereoMode_nb: failed, fm not enabled  state "
975                    + mRxState);
976            return false;
977        }
978        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
979                "Need FMRX_ADMIN_PERM permission");
980        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
981        && (mIsCompleteScanInProgress == false)) {
982
983            JFmRxStatus status = mJFmRx.getMonoStereoMode();
984            Log.i(TAG, "mJFmRx.getMonoStereoMode returned status "
985                    + status.toString());
986            if (JFmRxStatus.PENDING != status) {
987                Log.e(TAG, "mJFmRx.getMonoStereoMode returned status "
988                        + status.toString());
989                return false;
990            }
991
992
993        } else {
994            Log.e(TAG, "Seek is in progress.Cannot call the API");
995            return false;
996        }
997
998        return false;
999
1000    }
1001
1002    /*************************************************************************************************
1003     * Implementation of IFmRadio IPC interface
1004     *************************************************************************************************/
1005
1006    /* (separate queue for each set call synchronization) */
1007    private BlockingQueue<String> mSetMuteModeSyncQueue = new LinkedBlockingQueue<String>(
1008            5);
1009
1010
1011    public boolean rxSetMuteMode(int muteMode) {
1012        Log.i(TAG, "StubFmService:rxSetMuteMode  muteMode" + muteMode);
1013        if (mRxState != STATE_ENABLED) {
1014            Log.e(TAG, "rxSetMuteMode: failed, fm not enabled  state " + mRxState);
1015            return false;
1016        }
1017        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
1018                "Need FMRX_ADMIN_PERM permission");
1019        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
1020        && (mIsCompleteScanInProgress == false)) {
1021
1022            JFmRx.JFmRxMuteMode lMode = JFmUtils.getEnumConst(
1023                    JFmRx.JFmRxMuteMode.class, muteMode);
1024            if (lMode == null) {
1025                Log.e(TAG, "StubFmService:rxSetMuteMode invalid  lMode " + lMode);
1026                return false;
1027            }
1028            JFmRxStatus status = mJFmRx.setMuteMode(lMode);
1029                Log.i(TAG, "mJFmRx.SetMuteMode returned status "
1030                        + status.toString());
1031            if (JFmRxStatus.PENDING != status) {
1032                Log.e(TAG, "mJFmRx.SetMuteMode returned status "
1033                        + status.toString());
1034                return false;
1035            }
1036
1037            /*
1038             * (When muting turn off audio paths to lower power consumption and
1039             * reduce noise)
1040             */
1041            if (lMode == JFmRx.JFmRxMuteMode.FMC_MUTE) {
1042
1043                 /* L25 Specific */
1044            //mAudioManager.setParameters(AUDIO_RX_ENABLE + "=false");
1045            //Log.i(TAG, "MUTE- On");
1046                 /* L27 Specific */
1047                    enableRx(0);
1048
1049            } else {
1050                 /* L25 Specific */
1051            //mAudioManager.setParameters(AUDIO_RX_ENABLE + "=true");
1052            //Log.i(TAG, "MUTE- OFF");
1053                 /* L27 Specific */
1054            enableRx(1);
1055            }
1056
1057
1058            /* implementation to make the set API Synchronous */
1059
1060            try {
1061                String syncString = mSetMuteModeSyncQueue.take();
1062                if (!syncString.equals("*")) {
1063                    Log.e(TAG, "wrong sync string reseived: " + syncString);
1064                }
1065            } catch (InterruptedException e) {
1066                Log.e(TAG, "mJFmRx.setMuteMode-- Wait() s Exception!!!");
1067            }
1068
1069        } else {
1070            Log.e(TAG, "Seek is in progress.cannot call the API");
1071            return false;
1072        }
1073        mCurrentMuteMode = muteMode;
1074        return true;
1075
1076    }
1077
1078    /*************************************************************************************************
1079     * Implementation of IFmRadio IPC interface
1080     *************************************************************************************************/
1081
1082    public boolean rxSetMuteMode_nb(int muteMode) {
1083        JFmRx.JFmRxMuteMode lMode;
1084        Log.i(TAG, "StubFmService:rxSetMuteMode_nb  muteode" + muteMode);
1085        if (mRxState != STATE_ENABLED) {
1086            Log.e(TAG, "rxSetMuteMode_nb: failed, fm not enabled  state "
1087                    + mRxState);
1088            return false;
1089        }
1090        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
1091                "Need FMRX_ADMIN_PERM permission");
1092                if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
1093        && (mIsCompleteScanInProgress == false)) {
1094
1095        lMode = JFmUtils.getEnumConst(
1096                JFmRx.JFmRxMuteMode.class, muteMode);
1097        if (lMode == null) {
1098            Log.e(TAG, "StubFmService:rxSetMuteMode_nb invalid  lBand " + lMode);
1099            return false;
1100        }
1101        JFmRxStatus status = mJFmRx.setMuteMode(lMode);
1102        Log.i(TAG, "mJFmRx.SetMuteMode returned status " + status.toString());
1103        if (JFmRxStatus.PENDING != status) {
1104            Log.e(TAG, "mJFmRx.SetMuteMode returned status "
1105                    + status.toString());
1106            return false;
1107        }
1108
1109        } else {
1110            Log.e(TAG, "Seek is in progress.cannot call the API");
1111            return false;
1112        }
1113        /*
1114        * (When muting turn off audio paths to lower power consumption and
1115        * reduce noise)
1116          * L25 Specific
1117        */
1118        if (lMode == JFmRx.JFmRxMuteMode.FMC_MUTE) {
1119            //mAudioManager.setParameters(AUDIO_RX_ENABLE + "=false");
1120
1121        } else {
1122            //mAudioManager.setParameters(AUDIO_RX_ENABLE + "=true");
1123        }
1124
1125        return true;
1126
1127    }
1128
1129    /*************************************************************************************************
1130     * Implementation of IFmRadio IPC interface
1131     *************************************************************************************************/
1132
1133    /* (separate queue for each get call synchronization) */
1134    private BlockingQueue<String> mMuteModeSyncQueue = new LinkedBlockingQueue<String>(
1135            5);
1136
1137    public synchronized int rxGetMuteMode() {
1138        Log.i(TAG, "StubFmService:rxGetMuteMode  ");
1139        if (mRxState != STATE_ENABLED) {
1140            Log.e(TAG, "rxGetMuteMode: failed, fm not enabled  state " + mRxState);
1141            return 0;
1142        }
1143        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
1144                "Need FMRX_ADMIN_PERM permission");
1145
1146        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
1147                && (mIsCompleteScanInProgress == false)) {
1148
1149            JFmRxStatus status = mJFmRx.getMuteMode();
1150            Log.i(TAG, "mJFmRx.getMuteMode returned status "
1151                    + status.toString());
1152            if (JFmRxStatus.PENDING != status) {
1153                Log.e(TAG, "mJFmRx.getMuteMode returned status "
1154                        + status.toString());
1155                return 0;
1156            }
1157
1158            /* implementation to make the FM API Synchronous */
1159
1160                try {
1161                String syncString = mMuteModeSyncQueue.take();
1162                if (!syncString.equals("*")) {
1163                    Log.e(TAG, "wrong sync string reseived: " + syncString);
1164                }
1165                } catch (InterruptedException e) {
1166                    Log.e(TAG, "mJFmRx.getMuteMode-- Wait() s Exception!!!");
1167                }
1168
1169
1170        } else {
1171            Log.e(TAG, "Seek is in progress.cannot call the API");
1172            return FM_SEEK_IN_PROGRESS;
1173        }
1174        Log.i(TAG, "StubFmService:rxGetMuteMode(): -------- Exiting... ");
1175        return getMuteModeValue;
1176
1177    }
1178
1179    /*************************************************************************************************
1180     * Implementation of IFmRadio IPC interface
1181     *************************************************************************************************/
1182
1183    public boolean rxGetMuteMode_nb() {
1184        Log.i(TAG, "StubFmService:rxGetMuteMode_nb  ");
1185        if (mRxState != STATE_ENABLED) {
1186            Log.e(TAG, "rxGetMuteMode_nb: failed, fm not enabled  state "
1187                    + mRxState);
1188            return false;
1189        }
1190        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
1191                "Need FMRX_ADMIN_PERM permission");
1192        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
1193                && (mIsCompleteScanInProgress == false)) {
1194
1195            JFmRxStatus status = mJFmRx.getMuteMode();
1196            Log.i(TAG, "mJFmRx.getMuteMode returned status "
1197                    + status.toString());
1198            if (JFmRxStatus.PENDING != status) {
1199                Log.e(TAG, "mJFmRx.getMuteMode returned status "
1200                        + status.toString());
1201                return false;
1202            }
1203
1204        } else {
1205            Log.e(TAG, "Seek is in progress.Cannot call the API");
1206            return false;
1207        }
1208        return true;
1209
1210    }
1211
1212    /*************************************************************************************************
1213     * Implementation of IFmRadio IPC interface
1214     *************************************************************************************************/
1215    /* (separate queue for each set call synchronization) */
1216    private BlockingQueue<String> mSetRfDependentMuteModeSyncQueue = new LinkedBlockingQueue<String>(
1217            5);
1218
1219    public boolean rxSetRfDependentMuteMode(int rfMuteMode) {
1220        Log.i(TAG, "StubFmService:rxSetRfDependentMuteMode  " + rfMuteMode);
1221        if (mRxState != STATE_ENABLED) {
1222            Log.e(TAG, "rxSetRfDependentMuteMode: failed, fm not enabled  state "
1223                    + mRxState);
1224            return false;
1225        }
1226        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
1227                "Need FMRX_ADMIN_PERM permission");
1228        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
1229                && (mIsCompleteScanInProgress == false)) {
1230
1231
1232        JFmRx.JFmRxRfDependentMuteMode lrfMute = JFmUtils.getEnumConst(
1233                JFmRx.JFmRxRfDependentMuteMode.class, rfMuteMode);
1234        if (lrfMute == null) {
1235            Log.e(TAG, "StubFmService:rxSetRfDependentMuteMode invalid  lrfMute "
1236                    + lrfMute);
1237            return false;
1238        }
1239
1240        JFmRxStatus status = mJFmRx.setRfDependentMuteMode(lrfMute);
1241        Log.i(TAG, "mJFmRx.setRfDependentMuteMode returned status "
1242                + status.toString());
1243        if (status != JFmRxStatus.PENDING) {
1244            Log.e(TAG, "mJFmRx.setRfDependentMuteMode returned status "
1245                    + status.toString());
1246            return false;
1247        }
1248
1249        /* implementation to make the set API Synchronous */
1250
1251        try {
1252            String syncString = mSetRfDependentMuteModeSyncQueue.take();
1253            if (!syncString.equals("*")) {
1254                Log.e(TAG, "wrong sync string reseived: " + syncString);
1255            }
1256        } catch (InterruptedException e) {
1257            Log.e(TAG, "mJFmRx.setRfDependentMuteMode-- Wait() s Exception!!!");
1258        }
1259
1260} else {
1261            Log.e(TAG, "Seek is in progress.cannot call the API");
1262            return false;
1263        }
1264        Log.i(TAG, "StubFmService:rxSetRfDependentMuteMode exiting");
1265        return true;
1266
1267    }
1268
1269    /*************************************************************************************************
1270     * Implementation of IFmRadio IPC interface
1271     *************************************************************************************************/
1272
1273    public boolean rxSetRfDependentMuteMode_nb(int rfMuteMode) {
1274        Log.i(TAG, "StubFmService:rxSetRfDependentMuteMode_nb  " + rfMuteMode);
1275        if (mRxState != STATE_ENABLED) {
1276            Log.e(TAG,
1277                    "rxSetRfDependentMuteMode_nb: failed, fm not enabled  state "
1278                            + mRxState);
1279            return false;
1280        }
1281        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
1282                "Need FMRX_ADMIN_PERM permission");
1283        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
1284        && (mIsCompleteScanInProgress == false)) {
1285        JFmRx.JFmRxRfDependentMuteMode lrfMute = JFmUtils.getEnumConst(
1286                JFmRx.JFmRxRfDependentMuteMode.class, rfMuteMode);
1287        if (lrfMute == null) {
1288            Log.e(TAG,
1289                    "StubFmService:rxSetRfDependentMuteMode_nb invalid  lrfMute "
1290                            + lrfMute);
1291            return false;
1292        }
1293
1294        JFmRxStatus status = mJFmRx.setRfDependentMuteMode(lrfMute);
1295        Log.i(TAG, "mJFmRx.setRfDependentMuteMode returned status "
1296                + status.toString());
1297        if (status != JFmRxStatus.PENDING) {
1298            Log.e(TAG, "mJFmRx.setRfDependentMuteMode returned status "
1299                    + status.toString());
1300            return false;
1301        }
1302
1303
1304    } else {
1305            Log.e(TAG, "Seek is in progress.cannot call the API");
1306            return false;
1307        }
1308        return true;
1309
1310    }
1311
1312    /*************************************************************************************************
1313     * Implementation of IFmRadio IPC interface
1314     *************************************************************************************************/
1315
1316    /* (separate queue for each get call synchronization) */
1317    private BlockingQueue<String> mRfDependentMuteModeSyncQueue = new LinkedBlockingQueue<String>(
1318            5);
1319
1320    public synchronized int rxGetRfDependentMuteMode() {
1321        Log.i(TAG, "StubFmService:rxGetRfDependentMuteMode  ");
1322        if (mRxState != STATE_ENABLED) {
1323            Log.e(TAG, "rxGetRfDependentMuteMode: failed, fm not enabled  state "
1324                    + mRxState);
1325            return 0;
1326        }
1327        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
1328                "Need FMRX_ADMIN_PERM permission");
1329
1330        if ((mIsSeekInProgress == false) ||(mIsTuneInProgress == false)) {
1331            JFmRxStatus status = mJFmRx.getRfDependentMute();
1332                Log.i(TAG, "mJFmRx.getRfDependentMuteMode returned status "
1333                        + status.toString());
1334            if (JFmRxStatus.PENDING != status) {
1335                Log.e(TAG, "mJFmRx.getRfDependentMuteMode returned status "
1336                        + status.toString());
1337
1338                return 0;
1339            }
1340            /* implementation to make the FM API Synchronous */
1341
1342            try {
1343                String syncString = mRfDependentMuteModeSyncQueue.take();
1344                if (!syncString.equals("*")) {
1345                    Log.e(TAG, "wrong sync string reseived: " + syncString);
1346                }
1347            } catch (InterruptedException e) {
1348                Log
1349                        .e(TAG,
1350                                "mJFmRx.getRfDependentMuteMode-- Wait() s Exception!!!");
1351            }
1352
1353        } else {
1354            Log.e(TAG, "Seek is in progress.cannot call the API");
1355            return FM_SEEK_IN_PROGRESS;
1356        }
1357        Log.i(TAG,
1358                "StubFmService:rxGetRfDependentMuteMode(): --------- Exiting... ");
1359        return getRfDependentMuteModeValue;
1360
1361    }
1362
1363    /*************************************************************************************************
1364     * Implementation of IFmRadio IPC interface
1365     *************************************************************************************************/
1366
1367    public boolean rxGetRfDependentMuteMode_nb() {
1368        Log.i(TAG, "StubFmService:rxGetRfDependentMuteMode_nb  ");
1369        if (mRxState != STATE_ENABLED) {
1370            Log.e(TAG, "rxGetRfDependentMuteMode_nb: failed, fm not enabled  state "
1371                    + mRxState);
1372            return false;
1373        }
1374        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
1375                "Need FMRX_ADMIN_PERM permission");
1376        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
1377                && (mIsCompleteScanInProgress == false)) {
1378
1379            JFmRxStatus status = mJFmRx.getRfDependentMute();
1380            Log.i(TAG, "mJFmRx.getRfDependentMuteMode returned status "
1381                    + status.toString());
1382            if (JFmRxStatus.PENDING != status) {
1383                Log.e(TAG, "mJFmRx.getRfDependentMuteMode returned status "
1384                        + status.toString());
1385
1386                return false;
1387            }
1388
1389        } else {
1390            Log.e(TAG, "Seek is in progress.Cannot call the API");
1391            return false;
1392        }
1393        return false;
1394
1395    }
1396
1397    /*************************************************************************************************
1398     * Implementation of IFmRadio IPC interface
1399     *************************************************************************************************/
1400
1401    /* (separate queue for each set call synchronization) */
1402    private BlockingQueue<String> mSetRssiThresholdSyncQueue = new LinkedBlockingQueue<String>(
1403            5);
1404
1405
1406    public boolean rxSetRssiThreshold(int threshhold) {
1407        Log.i(TAG, "StubFmService:rxSetRssiThreshold  " + threshhold);
1408        if (mRxState != STATE_ENABLED) {
1409            Log.e(TAG, "rxSetRssiThreshold: failed, fm not enabled  state "
1410                    + mRxState);
1411            return false;
1412        }
1413        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
1414                "Need FMRX_ADMIN_PERM permission");
1415        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
1416                && (mIsCompleteScanInProgress == false)) {
1417
1418
1419            JFmRx.JFmRxRssi lrssiThreshhold = new JFmRx.JFmRxRssi(threshhold);
1420            if (lrssiThreshhold == null) {
1421            Log.e(TAG, "StubFmService:rxSetRssiThreshold invalid rssi "
1422                        + lrssiThreshhold);
1423                return false;
1424            }
1425        Log.d(TAG, "StubFmService:rxSetRssiThreshold  " + lrssiThreshhold);
1426        JFmRxStatus status = mJFmRx.setRssiThreshold(lrssiThreshhold);
1427        Log.i(TAG, "mJFmRx.setRssiThreshold returned status "
1428                + status.toString());
1429        if (status != JFmRxStatus.PENDING) {
1430            Log.e(TAG, "mJFmRx.setRssiThreshold returned status "
1431                    + status.toString());
1432            return false;
1433        }
1434
1435        /*implementation to make the set API Synchronous */
1436
1437        try {
1438            String syncString = mSetRssiThresholdSyncQueue.take();
1439            if (!syncString.equals("*")) {
1440                Log.e(TAG, "wrong sync string reseived: " + syncString);
1441            }
1442        } catch (InterruptedException e) {
1443            Log.e(TAG, "mJFmRx.setRssiThreshold-- Wait() s Exception!!!");
1444        }
1445
1446} else {
1447            Log.e(TAG, "Seek is in progress.cannot call the API");
1448            return false;
1449        }
1450        Log.i(TAG, "StubFmService:rxSetRssiThreshold exiting");
1451        return true;
1452
1453    }
1454
1455    /*************************************************************************************************
1456     * Implementation of IFmRadio IPC interface
1457     *************************************************************************************************/
1458
1459    public boolean rxSetRssiThreshold_nb(int threshhold) {
1460        Log.i(TAG, "StubFmService:rxSetRssiThreshold_nb  " + threshhold);
1461        if (mRxState != STATE_ENABLED) {
1462            Log.e(TAG, "rxSetRssiThreshold_nb: failed, fm not enabled  state "
1463                    + mRxState);
1464            return false;
1465        }
1466        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
1467                "Need FMRX_ADMIN_PERM permission");
1468        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
1469        && (mIsCompleteScanInProgress == false)) {
1470        JFmRx.JFmRxRssi lrssiThreshhold = new JFmRx.JFmRxRssi(threshhold);
1471        if (lrssiThreshhold == null) {
1472            Log.e(TAG, "StubFmService:setRssiThreshold_nb invalid rssi "
1473                        + lrssiThreshhold);
1474            return false;
1475        }
1476        Log.d(TAG, "StubFmService:setRssiThreshold_nb  " + lrssiThreshhold);
1477            JFmRxStatus status = mJFmRx.setRssiThreshold(lrssiThreshhold);
1478            if (DBG)
1479                Log.i(TAG, "mJFmRx.setRssiThreshold returned status "
1480                        + status.toString());
1481            if (status != JFmRxStatus.PENDING) {
1482                Log.e(TAG, "mJFmRx.setRssiThreshold returned status "
1483                        + status.toString());
1484                return false;
1485            }
1486        } else {
1487            Log.e(TAG, "Seek is in progress.cannot call the API");
1488            return false;
1489        }
1490        return true;
1491
1492    }
1493
1494    /*************************************************************************************************
1495     * Implementation of IFmRadio IPC interface
1496     *************************************************************************************************/
1497
1498    /* (separate queue for each get call synchronization) */
1499    private BlockingQueue<String> mRssiThresholdSyncQueue = new LinkedBlockingQueue<String>(
1500            5);
1501
1502
1503    public synchronized int rxGetRssiThreshold() {
1504
1505        Log.i(TAG, "StubFmService:rxGetRssiThreshold --Entry  ");
1506        if (mRxState != STATE_ENABLED) {
1507            Log.e(TAG, "rxGetRssiThreshold: failed, fm not enabled  state "
1508                    + mRxState);
1509            return 0;
1510        }
1511        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
1512                "Need FMRX_ADMIN_PERM permission");
1513
1514        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
1515                && (mIsCompleteScanInProgress == false)) {
1516
1517            JFmRxStatus status = mJFmRx.getRssiThreshold();
1518            Log.i(TAG, "mJFmRx.getRssiThreshold returned status "
1519                    + status.toString());
1520            if (JFmRxStatus.PENDING != status) {
1521                Log.e(TAG, "mJFmRx.getRssiThreshold returned status "
1522                        + status.toString());
1523                return 0;
1524            }
1525
1526            /*implementation to make the FM API Synchronous */
1527
1528                try {
1529                String syncString = mRssiThresholdSyncQueue.take();
1530                if (!syncString.equals("*")) {
1531                    Log.e(TAG, "wrong sync string reseived: " + syncString);
1532                }
1533            } catch (InterruptedException e) {
1534                Log.e(TAG, "mJFmRx.getRssiThreshold-- Wait() s Exception!!!");
1535            }
1536
1537        } else {
1538            Log.e(TAG, "Seek is in progress.cannot call the API");
1539            return FM_SEEK_IN_PROGRESS;
1540        }
1541        Log.i(TAG, "StubFmService:rxGetRssiThreshold(): ---------- Exiting ");
1542        return getRssiThresholdValue;
1543
1544    }
1545
1546    /*************************************************************************************************
1547     * Implementation of IFmRadio IPC interface
1548     *************************************************************************************************/
1549
1550    public boolean rxGetRssiThreshold_nb() {
1551
1552        Log.i(TAG, "StubFmService:rxGetRssiThreshold_nb --Entry  ");
1553        if (mRxState != STATE_ENABLED) {
1554            Log.e(TAG, "rxGetRssiThreshold_nb: failed, fm not enabled  state "
1555                    + mRxState);
1556            return false;
1557        }
1558        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
1559                "Need FMRX_ADMIN_PERM permission");
1560        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
1561                && (mIsCompleteScanInProgress == false)) {
1562
1563            JFmRxStatus status = mJFmRx.getRssiThreshold();
1564            Log.i(TAG, "mJFmRx.getRssiThreshold returned status "
1565                    + status.toString());
1566            if (JFmRxStatus.PENDING != status) {
1567                Log.e(TAG, "mJFmRx.getRssiThreshold returned status "
1568                        + status.toString());
1569                return false;
1570            }
1571
1572        } else {
1573            Log.e(TAG, "Seek is in progress.Cannot call the API");
1574            return false;
1575        }
1576
1577        return false;
1578
1579    }
1580
1581    /*************************************************************************************************
1582     * Implementation of IFmRadio IPC interface
1583     *************************************************************************************************/
1584
1585    /* (separate queue for each set call synchronization) */
1586    private BlockingQueue<String> mSetDeEmphasisFilterSyncQueue = new LinkedBlockingQueue<String>(
1587            5);
1588
1589
1590    public boolean rxSetDeEmphasisFilter(int filter) {
1591        Log.i(TAG, "StubFmService:rxSetDeEmphasisFilter filter " + filter);
1592        if (mRxState != STATE_ENABLED) {
1593            Log.e(TAG, "rxSetDeEmphasisFilter: failed, fm not enabled  state "
1594                    + mRxState);
1595            return false;
1596        }
1597        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
1598                "Need FMRX_ADMIN_PERM permission");
1599        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
1600                && (mIsCompleteScanInProgress == false)) {
1601
1602        JFmRx.JFmRxEmphasisFilter lFilter = JFmUtils.getEnumConst(
1603                JFmRx.JFmRxEmphasisFilter.class, filter);
1604        if (lFilter == null) {
1605            Log.e(TAG, "StubFmService:rxSetDeEmphasisFilter invalid  lBand "
1606                    + lFilter);
1607            return false;
1608        }
1609        JFmRxStatus status = mJFmRx.SetDeEmphasisFilter(lFilter);
1610        Log.i(TAG, "mJFmRx.setDeEmphasisFilter returned status "
1611                + status.toString());
1612        if (JFmRxStatus.PENDING != status) {
1613            Log.e(TAG, "mJFmRx.setDeEmphasisFilter returned status "
1614                    + status.toString());
1615            return false;
1616        }
1617
1618        /*implementation to make the set API Synchronous */
1619
1620        try {
1621            String syncString = mSetDeEmphasisFilterSyncQueue.take();
1622            if (!syncString.equals("*")) {
1623                Log.e(TAG, "wrong sync string reseived: " + syncString);
1624            }
1625        } catch (InterruptedException e) {
1626            Log.e(TAG, "mJFmRx.setDeEmphasisFilter-- Wait() s Exception!!!");
1627        }
1628
1629    } else {
1630            Log.e(TAG, "Seek is in progress.cannot call the API");
1631            return false;
1632        }
1633        Log.i(TAG, "StubFmService:rxSetDeEmphasisFilter exiting");
1634        return true;
1635
1636    }
1637
1638    /*************************************************************************************************
1639     * Implementation of IFmRadio IPC interface
1640     *************************************************************************************************/
1641
1642    public boolean rxSetDeEmphasisFilter_nb(int filter) {
1643        Log.i(TAG, "StubFmService:rxSetDeEmphasisFilter_nb filter " + filter);
1644        if (mRxState != STATE_ENABLED) {
1645            Log.e(TAG, "rxSetDeEmphasisFilter_nb: failed, fm not enabled  state "
1646                    + mRxState);
1647            return false;
1648        }
1649        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
1650                "Need FMRX_ADMIN_PERM permission");
1651
1652
1653        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
1654                && (mIsCompleteScanInProgress == false)) {
1655        JFmRx.JFmRxEmphasisFilter lFilter = JFmUtils.getEnumConst(
1656                JFmRx.JFmRxEmphasisFilter.class, filter);
1657        if (lFilter == null) {
1658            Log.e(TAG, "StubFmService:rxSetDeEmphasisFilter_nb invalid  lBand "
1659                    + lFilter);
1660            return false;
1661        }
1662        JFmRxStatus status = mJFmRx.SetDeEmphasisFilter(lFilter);
1663        Log.i(TAG, "mJFmRx.setDeEmphasisFilter returned status "
1664                + status.toString());
1665        if (JFmRxStatus.PENDING != status) {
1666            Log.e(TAG, "mJFmRx.setDeEmphasisFilter returned status "
1667                    + status.toString());
1668            return false;
1669        }
1670
1671        } else {
1672            Log.e(TAG, "Seek is in progress.cannot call the API");
1673            return false;
1674        }
1675        return true;
1676
1677    }
1678
1679    /*************************************************************************************************
1680     * Implementation of IFmRadio IPC interface
1681     *************************************************************************************************/
1682
1683    /* (separate queue for each get call synchronization) */
1684    private BlockingQueue<String> mDeEmphasisFilterSyncQueue = new LinkedBlockingQueue<String>(
1685            5);
1686
1687
1688    public synchronized int rxGetDeEmphasisFilter() {
1689        Log.i(TAG, "StubFmService:rxGetDeEmphasisFilter  ");
1690        if (mRxState != STATE_ENABLED) {
1691            Log.e(TAG, "rxGetDeEmphasisFilter: failed, fm not enabled  state "
1692                    + mRxState);
1693            return 0;
1694        }
1695        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
1696                "Need FMRX_ADMIN_PERM permission");
1697
1698        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
1699                && (mIsCompleteScanInProgress == false)) {
1700
1701            JFmRxStatus status = mJFmRx.GetDeEmphasisFilter();
1702            Log.i(TAG, "mJFmRx.getDeEmphasisFilter returned status "
1703                    + status.toString());
1704            if (JFmRxStatus.PENDING != status) {
1705                Log.e(TAG, "mJFmRx.getDeEmphasisFilter returned status "
1706                        + status.toString());
1707                return 0;
1708            }
1709            /* :implementation to make the FM API Synchronous */
1710
1711                try {
1712                String syncString = mDeEmphasisFilterSyncQueue.take();
1713                if (!syncString.equals("*")) {
1714                    Log.e(TAG, "wrong sync string reseived: " + syncString);
1715                }
1716                } catch (InterruptedException e) {
1717                    Log
1718                            .e(TAG,
1719                                    "mJFmRx.getDeEmphasisFilter-- Wait() s Exception!!!");
1720                }
1721
1722        } else {
1723            Log.e(TAG, "Seek is in progress.cannot call the API");
1724            return FM_SEEK_IN_PROGRESS;
1725        }
1726        Log.i(TAG, "StubFmService:rxGetDeEmphasisFilter(): -------- Exiting ");
1727        return getDeEmphasisFilterValue;
1728
1729    }
1730
1731    /*************************************************************************************************
1732     * Implementation of IFmRadio IPC interface
1733     *************************************************************************************************/
1734
1735    public boolean rxGetDeEmphasisFilter_nb() {
1736        Log.i(TAG, "StubFmService:rxGetDeEmphasisFilter_nb  ");
1737        if (mRxState != STATE_ENABLED) {
1738            Log.e(TAG, "rxGetDeEmphasisFilter_nb: failed, fm not enabled  state "
1739                    + mRxState);
1740            return false;
1741        }
1742        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
1743                "Need FMRX_ADMIN_PERM permission");
1744        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
1745                && (mIsCompleteScanInProgress == false)) {
1746
1747            JFmRxStatus status = mJFmRx.GetDeEmphasisFilter();
1748            Log.i(TAG, "mJFmRx.getDeEmphasisFilter returned status "
1749                    + status.toString());
1750            if (JFmRxStatus.PENDING != status) {
1751                Log.e(TAG, "mJFmRx.getDeEmphasisFilter returned status "
1752                        + status.toString());
1753                return false;
1754            }
1755
1756        } else {
1757            Log.e(TAG, "Seek is in progress.Cannot call the API");
1758            return false;
1759        }
1760
1761        return false;
1762
1763    }
1764
1765    /*************************************************************************************************
1766     * Implementation of IFmRadio IPC interface
1767     *************************************************************************************************/
1768
1769    public boolean rxSetVolume(int volume) {
1770        Log.i(TAG, "StubFmService:rxSetVolume  " + volume);
1771        if (mRxState != STATE_ENABLED) {
1772            Log.e(TAG, "rxSetVolume: failed, fm not enabled  state " + mRxState);
1773            return false;
1774        }
1775        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
1776                "Need FMRX_ADMIN_PERM permission");
1777
1778        mVolState = VOL_REQ_STATE_PENDING;
1779        JFmRx.JFmRxVolume lVolume = new JFmRx.JFmRxVolume(volume);
1780        if (lVolume == null) {
1781            Log.e(TAG, "StubFmService:rxSetVolume invalid  lVolume " + lVolume);
1782            return false;
1783        }
1784
1785        synchronized (mVolumeSynchronizationLock) {
1786
1787            JFmRxStatus status = mJFmRx.setVolume(lVolume);
1788            Log.i(TAG, "mJFmRx.setVolume returned status " + status.toString());
1789            if (JFmRxStatus.PENDING != status) {
1790                Log.e(TAG, "mJFmRx.setVolume returned status "
1791                        + status.toString());
1792                return false;
1793            }
1794
1795//            mVolState = VOL_REQ_STATE_PENDING;
1796        }
1797
1798        return true;
1799    }
1800
1801    /*************************************************************************************************
1802     * Implementation of IFmRadio IPC interface
1803     *************************************************************************************************/
1804
1805    public boolean rxSetChannelSpacing_nb(int channelSpace) {
1806
1807        Log.i(TAG, "StubFmService:rxSetChannelSpacing_nb  " + channelSpace);
1808        if (mRxState != STATE_ENABLED) {
1809            Log.e(TAG, "rxSetChannelSpacing_nb: failed, fm not enabled  state "
1810                    + mRxState);
1811            return false;
1812        }
1813        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
1814                "Need FMRX_ADMIN_PERM permission");
1815
1816        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
1817        && (mIsCompleteScanInProgress == false)) {
1818
1819        JFmRx.JFmRxChannelSpacing lChannelSpace = JFmUtils.getEnumConst(
1820                JFmRx.JFmRxChannelSpacing.class, channelSpace);
1821
1822        if (lChannelSpace == null) {
1823            Log.e(TAG, "StubFmService:rxSetChannelSpacing_nb invalid  lChannelSpace "
1824                    + lChannelSpace);
1825            return false;
1826        }
1827        JFmRxStatus status = mJFmRx.setChannelSpacing(lChannelSpace);
1828        Log.i(TAG, "mJFmRx.setChannelSpacing returned status "
1829                + status.toString());
1830        if (JFmRxStatus.PENDING != status) {
1831            Log.e(TAG, "mJFmRx.setChannelSpacing returned status "
1832                    + status.toString());
1833            return false;
1834        }
1835
1836        } else {
1837                    Log.e(TAG, "Seek is in progress.cannot call the API");
1838                    return false;
1839                }
1840
1841        return true;
1842
1843    }
1844
1845
1846    /*************************************************************************************************
1847         * Implementation of IFmRadio IPC interface
1848         *************************************************************************************************/
1849        /*  (separate queue for each set call synchronization) */
1850        private BlockingQueue<String> mSetChannelSpacingSyncQueue = new LinkedBlockingQueue<String>(
1851                5);
1852
1853
1854    public boolean rxSetChannelSpacing(int channelSpace) {
1855
1856            Log.i(TAG, "StubFmService:rxSetChannelSpacing  " + channelSpace);
1857        if (mRxState != STATE_ENABLED) {
1858            Log.e(TAG, "rxSetChannelSpacing: failed, fm not enabled  state "
1859                    + mRxState);
1860            return false;
1861        }
1862        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
1863                "Need FMRX_ADMIN_PERM permission");
1864            if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
1865                    && (mIsCompleteScanInProgress == false)) {
1866
1867        JFmRx.JFmRxChannelSpacing lChannelSpace = JFmUtils.getEnumConst(
1868                JFmRx.JFmRxChannelSpacing.class, channelSpace);
1869
1870                if (lChannelSpace == null) {
1871                    Log.e(TAG,
1872                            "StubFmService:rxSetChannelSpacing invalid    lChannelSpace "
1873                    + lChannelSpace);
1874            return false;
1875        }
1876        JFmRxStatus status = mJFmRx.setChannelSpacing(lChannelSpace);
1877        Log.i(TAG, "mJFmRx.setChannelSpacing returned status "
1878                + status.toString());
1879        if (JFmRxStatus.PENDING != status) {
1880            Log.e(TAG, "mJFmRx.setChannelSpacing returned status "
1881                    + status.toString());
1882            return false;
1883        }
1884
1885                    /* implementation to make the FM API Synchronous */
1886            try {
1887                Log
1888                        .i(TAG,
1889                                    "StubFmService:rxSetChannelSpacing(): -------- Waiting... ");
1890                    String syncString = mSetChannelSpacingSyncQueue.take();
1891                    if (!syncString.equals("*")) {
1892                        Log.e(TAG, "wrong sync string receieved: " + syncString);
1893                    }
1894                } catch (InterruptedException e) {
1895                    Log.e(TAG, "mJFmRx.setChannelSpacing-- Wait() s Exception!!!");
1896                }
1897
1898            } else {
1899                Log.e(TAG, "Seek is in progress.cannot call the API");
1900                return false;
1901            }
1902            Log.i(TAG, "StubFmService:rxSetChannelSpacing exiting");
1903        return true;
1904
1905    }
1906
1907    /*************************************************************************************************
1908     * Implementation of IFmRadio IPC interface
1909     *************************************************************************************************/
1910
1911    /* (separate queue for each get call synchronization) */
1912    private BlockingQueue<String> mVolumeSyncQueue = new LinkedBlockingQueue<String>(
1913            5);
1914
1915    public synchronized int rxGetVolume() {
1916        Log.i(TAG, "StubFmService:rxGetVolume  ");
1917        if (mRxState != STATE_ENABLED) {
1918            Log.e(TAG, "rxGetVolume: failed, fm not enabled  state " + mRxState);
1919            return 0;
1920        }
1921        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
1922                "Need FMRX_ADMIN_PERM permission");
1923
1924            if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
1925                    && (mIsCompleteScanInProgress == false)) {
1926
1927
1928            JFmRxStatus status = mJFmRx.getVolume();
1929            Log.i(TAG, "mJFmRx.getVolume returned status " + status.toString());
1930
1931            if (status != JFmRxStatus.PENDING) {
1932                Log.e(TAG, "mJFmRx.getVolume returned status "
1933                        + status.toString());
1934                return 0;
1935            }
1936
1937            /*implementation to make the FM API Synchronous */
1938
1939                try {
1940                String syncString = mVolumeSyncQueue.take();
1941                if (!syncString.equals("*")) {
1942                    Log.e(TAG, "wrong sync string reseived: " + syncString);
1943                }
1944            } catch (InterruptedException e) {
1945                Log.e(TAG, "mJFmRx.getVolume-- Wait() s Exception!!!");
1946            }
1947
1948        } else {
1949            Log.e(TAG, "Seek is in progress.cannot call the API");
1950            return FM_SEEK_IN_PROGRESS;
1951        }
1952        Log.i(TAG, "StubFmService:rxGetVolume(): -------- Exiting... ");
1953        return getVolumeValue;
1954
1955    }
1956
1957    /*************************************************************************************************
1958     * Implementation of IFmRadio IPC interface
1959     *************************************************************************************************/
1960
1961    public boolean rxGetVolume_nb() {
1962        Log.i(TAG, "StubFmService:rxGetVolume_nb  ");
1963        if (mRxState != STATE_ENABLED) {
1964            Log.e(TAG, "rxGetVolume_nb: failed, fm not enabled  state " + mRxState);
1965            return false;
1966        }
1967        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
1968                "Need FMRX_ADMIN_PERM permission");
1969        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
1970                && (mIsCompleteScanInProgress == false)) {
1971
1972            JFmRxStatus status = mJFmRx.getVolume();
1973            Log.i(TAG, "mJFmRx.rxGetVolume returned status " + status.toString());
1974
1975            if (status != JFmRxStatus.PENDING) {
1976                Log.e(TAG, "mJFmRx.rxGetVolume returned status "
1977                        + status.toString());
1978                return false;
1979            }
1980        } else {
1981            Log.e(TAG, "Seek is in progress.Cannot call the API");
1982            return false;
1983        }
1984
1985        return false;
1986
1987    }
1988
1989    /*************************************************************************************************
1990     * Implementation of IFmRadio IPC interface
1991     *************************************************************************************************/
1992    /* (separate queue for each get call synchronization) */
1993    private BlockingQueue<String> mChannelSpacingSyncQueue = new LinkedBlockingQueue<String>(
1994            5);
1995
1996    public synchronized int rxGetChannelSpacing() {
1997        Log.i(TAG, "StubFmService:rxGetChannelSpacing  ");
1998        if (mRxState != STATE_ENABLED) {
1999            Log.e(TAG, "rxGetChannelSpacing: failed, fm not enabled  state "
2000                    + mRxState);
2001            return 0;
2002        }
2003        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
2004                "Need FMRX_ADMIN_PERM permission");
2005
2006            if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
2007                    && (mIsCompleteScanInProgress == false)) {
2008
2009
2010            JFmRxStatus status = mJFmRx.getChannelSpacing();
2011            Log.i(TAG, "mJFmRx.rxGetChannelSpacing returned status "
2012                    + status.toString());
2013
2014            if (status != JFmRxStatus.PENDING) {
2015                Log.e(TAG, "mJFmRx.rxGetChannelSpacing returned status "
2016                        + status.toString());
2017                return 0;
2018            }
2019
2020            /* implementation to make the FM API Synchronous */
2021
2022                try {
2023                String syncString = mChannelSpacingSyncQueue.take();
2024                if (!syncString.equals("*")) {
2025                    Log.e(TAG, "wrong sync string reseived: " + syncString);
2026                }
2027            } catch (InterruptedException e) {
2028                Log.e(TAG, "mJFmRx.getChannelSpacing-- Wait() s Exception!!!");
2029            }
2030
2031        } else {
2032            Log.e(TAG, "Seek is in progress.cannot call the API");
2033            return FM_SEEK_IN_PROGRESS;
2034        }
2035        Log.i(TAG, "StubFmService:rxGetChannelSpacing() --Exiting ");
2036        return getChannelSpaceValue;
2037
2038    }
2039
2040    /*************************************************************************************************
2041     * Implementation of IFmRadio IPC interface
2042     *************************************************************************************************/
2043
2044    public  boolean rxGetChannelSpacing_nb() {
2045        Log.i(TAG, "StubFmService:rxGetChannelSpacing_nb  ");
2046        if (mRxState != STATE_ENABLED) {
2047            Log.e(TAG, "rxGetChannelSpacing_nb: failed, fm not enabled  state "
2048                    + mRxState);
2049            return false;
2050        }
2051        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
2052                "Need FMRX_ADMIN_PERM permission");
2053        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
2054                && (mIsCompleteScanInProgress == false)) {
2055
2056            JFmRxStatus status = mJFmRx.getChannelSpacing();
2057            Log.i(TAG, "mJFmRx.getChannelSpacing returned status "
2058                    + status.toString());
2059
2060            if (status != JFmRxStatus.PENDING) {
2061                Log.e(TAG, "mJFmRx.getChannelSpacing returned status "
2062                        + status.toString());
2063                return false;
2064            }
2065
2066        } else {
2067            Log.e(TAG, "Seek is in progress.Cannot call the API");
2068            return false;
2069        }
2070        return false;
2071
2072    }
2073
2074    static int BaseFreq() {
2075        return mCurrentBand == FM_BAND_JAPAN ? FM_FIRST_FREQ_JAPAN_KHZ
2076                : FM_FIRST_FREQ_US_EUROPE_KHZ;
2077    }
2078
2079    static int LastFreq() {
2080        return mCurrentBand == FM_BAND_JAPAN ? FM_LAST_FREQ_JAPAN_KHZ
2081                : FM_LAST_FREQ_US_EUROPE_KHZ;
2082    }
2083
2084    /*************************************************************************************************
2085     * Implementation of IFmRadio IPC interface
2086     *************************************************************************************************/
2087
2088    public boolean rxTune_nb(int freq) {
2089        Log.i(TAG, "StubFmService: rxTune_nb  " + freq);
2090
2091        mCurrentFrequency = freq;
2092        if (mRxState != STATE_ENABLED) {
2093            Log.e(TAG, " rxTune_nb: failed, fm not enabled  state " + mRxState);
2094            return false;
2095        }
2096        if (freq < BaseFreq() || freq > LastFreq()) {
2097            Log.e(TAG, "StubFmService: rxTune_nb invalid frequency not in range "
2098                    + freq);
2099            return false;
2100        }
2101        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
2102                "Need FMRX_ADMIN_PERM permission");
2103        JFmRx.JFmRxFreq lFreq = new JFmRx.JFmRxFreq(freq);
2104        if (lFreq == null) {
2105            Log.e(TAG, "StubFmService:tune invalid frequency " + lFreq);
2106            return false;
2107        }
2108        mIsTuneInProgress = true;
2109        Log.d(TAG, "StubFmService: rxTune_nb  " + lFreq);
2110        JFmRxStatus status = mJFmRx.tune(lFreq);
2111        Log.i(TAG, "mJFmRx.tune returned status " + status.toString());
2112        if (status != JFmRxStatus.PENDING) {
2113            Log.e(TAG, "mJFmRx.tune returned status " + status.toString());
2114            return false;
2115        }
2116//        mIsTuneInProgress = true;
2117        return true;
2118
2119    }
2120
2121    /*************************************************************************************************
2122     * Implementation of IFmRadio IPC interface
2123     *************************************************************************************************/
2124
2125    /* (separate queue for each get call synchronization) */
2126    private BlockingQueue<String> mTunedFrequencySyncQueue = new LinkedBlockingQueue<String>(
2127            5);
2128
2129    public synchronized int rxGetTunedFrequency() {
2130        Log.i(TAG, "StubFmService:rxGetTunedFrequency  ");
2131        if (mRxState != STATE_ENABLED) {
2132            Log.e(TAG, "rxGetTunedFrequency: failed, fm not enabled  state "
2133                    + mRxState);
2134            return 0;
2135        }
2136        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
2137                "Need FMRX_ADMIN_PERM permission");
2138
2139        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
2140                && (mIsCompleteScanInProgress == false)) {
2141
2142
2143            JFmRxStatus status = mJFmRx.getTunedFrequency();
2144            Log.i(TAG, "mJFmRx.getTunedFrequency returned status "
2145                    + status.toString());
2146
2147            if (status != JFmRxStatus.PENDING) {
2148                Log.e(TAG, "mJFmRx.getTunedFrequency returned status "
2149                        + status.toString());
2150                return 0;
2151            }
2152            /* implementation to make the FM API Synchronous */
2153                try {
2154                String syncString = mTunedFrequencySyncQueue.take();
2155                if (!syncString.equals("*")) {
2156                    Log.e(TAG, "wrong sync string reseived: " + syncString);
2157                }
2158            } catch (InterruptedException e) {
2159                Log.e(TAG, "mJFmRx.getTunedFrequency-- Wait() s Exception!!!");
2160            }
2161
2162        } else {
2163            Log.e(TAG, "Seek is in progress.cannot call the API");
2164            return FM_SEEK_IN_PROGRESS;
2165        }
2166        Log.i(TAG, "StubFmService:rxGetTunedFrequency(): ------- Exiting ");
2167        return getTunedFrequencyValue;
2168
2169    }
2170
2171    /*************************************************************************************************
2172     * Implementation of IFmRadio IPC interface
2173     *************************************************************************************************/
2174
2175    public boolean rxGetTunedFrequency_nb() {
2176        Log.i(TAG, "StubFmService:rxGetTunedFrequency_nb  ");
2177        if (mRxState != STATE_ENABLED) {
2178            Log.e(TAG, "rxGetTunedFrequency_nb: failed, fm not enabled  state "
2179                    + mRxState);
2180            return false;
2181        }
2182        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
2183                "Need FMRX_ADMIN_PERM permission");
2184        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
2185                && (mIsCompleteScanInProgress == false)) {
2186
2187
2188            JFmRxStatus status = mJFmRx.getTunedFrequency();
2189            Log.i(TAG, "mJFmRx.getTunedFrequency returned status "
2190                    + status.toString());
2191            if (status != JFmRxStatus.PENDING) {
2192                Log.e(TAG, "mJFmRx.getTunedFrequency returned status "
2193                        + status.toString());
2194                return false;
2195            }
2196
2197        } else {
2198            Log.e(TAG, "Seek is in progress.Cannot call the API");
2199            return false;
2200        }
2201
2202        return false;
2203
2204    }
2205
2206    /*************************************************************************************************
2207     * Implementation of IFmRadio IPC interface
2208     *************************************************************************************************/
2209
2210    public boolean rxSeek_nb(int direction) {
2211        Log.i(TAG, "StubFmService:rxSeek_nb  " + direction);
2212        if (mRxState != STATE_ENABLED) {
2213            Log.e(TAG, "rxSeek_nb: failed, fm not enabled  state " + mRxState);
2214            return false;
2215        }
2216        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
2217                "Need FMRX_ADMIN_PERM permission");
2218        JFmRx.JFmRxSeekDirection lDir = JFmUtils.getEnumConst(
2219                JFmRx.JFmRxSeekDirection.class, direction);
2220        if (lDir == null) {
2221            Log.e(TAG, "StubFmService:rxSeek_nb invalid  lDir " + lDir);
2222            return false;
2223        }
2224        mIsSeekInProgress = true;
2225        JFmRxStatus status = mJFmRx.seek(lDir);
2226        Log.i(TAG, "mJFmRx.seek returned status " + status.toString());
2227        if (status != JFmRxStatus.PENDING) {
2228            Log.e(TAG, "mJFmRx.seek returned status " + status.toString());
2229            return false;
2230        }
2231
2232//        mIsSeekInProgress = true;
2233        return true;
2234
2235    }
2236
2237    /*************************************************************************************************
2238     * Implementation of IFmRadio IPC interface
2239     *************************************************************************************************/
2240
2241    public boolean rxStopSeek_nb() {
2242        Log.i(TAG, "StubFmService:rxStopSeek_nb  ");
2243        if (mRxState != STATE_ENABLED) {
2244            Log.e(TAG, "rxStopSeek_nb: failed, fm not enabled  state " + mRxState);
2245            return false;
2246        }
2247        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
2248                "Need FMRX_ADMIN_PERM permission");
2249
2250        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
2251        && (mIsCompleteScanInProgress == false)) {
2252        JFmRxStatus status = mJFmRx.stopSeek();
2253        Log.i(TAG, "mJFmRx.stopSeek returned status " + status.toString());
2254        if (status != JFmRxStatus.PENDING) {
2255            Log.e(TAG, "mJFmRx.stopSeek returned status " + status.toString());
2256            return false;
2257        }
2258
2259
2260} else {
2261            Log.e(TAG, "Seek is in progress.cannot call the API");
2262            return false;
2263        }
2264        return true;
2265
2266    }
2267
2268
2269    /*************************************************************************************************
2270         * Implementation of IFmRadio IPC interface
2271         *************************************************************************************************/
2272        /*  (separate queue for each set call synchronization) */
2273        private BlockingQueue<String> mStopSeekSyncQueue = new LinkedBlockingQueue<String>(
2274                5);
2275    public boolean rxStopSeek() {
2276            Log.i(TAG, "StubFmService:rxStopSeek  ");
2277        if (mRxState != STATE_ENABLED) {
2278            Log.e(TAG, "rxStopSeek: failed, fm not enabled  state " + mRxState);
2279            return false;
2280        }
2281        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
2282                "Need FMRX_ADMIN_PERM permission");
2283            if ((mIsTuneInProgress == false)
2284                    && (mIsCompleteScanInProgress == false)) {
2285        JFmRxStatus status = mJFmRx.stopSeek();
2286        Log.i(TAG, "mJFmRx.stopSeek returned status " + status.toString());
2287        if (status != JFmRxStatus.PENDING) {
2288                    Log.e(TAG, "mJFmRx.stopSeek returned status "
2289                            + status.toString());
2290                    return false;
2291                }
2292
2293                try {
2294                    Log.i(TAG, "StubFmService:stopSeek(): -------- Waiting... ");
2295                    String syncString = mStopSeekSyncQueue.take();
2296                if (!syncString.equals("*")) {
2297                    Log.e(TAG, "wrong sync string receieved: " + syncString);
2298                }
2299            } catch (InterruptedException e) {
2300                    Log.e(TAG, "mJFmRx.stopSeek-- Wait() s Exception!!!");
2301                }
2302
2303            } else {
2304                Log.e(TAG, "tune is in progress.cannot call the API");
2305                return false;
2306            }
2307            return true;
2308
2309        }
2310
2311
2312    /*************************************************************************************************
2313     * Implementation of IFmRadio IPC interface
2314     *************************************************************************************************/
2315
2316    public boolean rxGetRssi_nb() {
2317        Log.i(TAG, "StubFmService:rxGetRssi_nb  ");
2318        if (mRxState != STATE_ENABLED) {
2319            Log.e(TAG, "rxGetRssi_nb: failed, fm not enabled  state " + mRxState);
2320            return false;
2321        }
2322        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
2323                "Need FMRX_ADMIN_PERM permission");
2324        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
2325        && (mIsCompleteScanInProgress == false)) {
2326        JFmRxStatus status = mJFmRx.getRssi();
2327        Log.i(TAG, "mJFmRx.getRssi returned status " + status.toString());
2328        if (status != JFmRxStatus.PENDING) {
2329            Log.e(TAG, "mJFmRx.getRssi returned status " + status.toString());
2330            return false;
2331        }
2332
2333        } else {
2334                    Log.e(TAG, "Seek is in progress.cannot call the API");
2335            return false;
2336        }
2337        return true;
2338
2339    }
2340
2341    /*************************************************************************************************
2342     * Implementation of IFmRadio IPC interface
2343     *************************************************************************************************/
2344
2345    /* (separate queue for each get call synchronization) */
2346    private BlockingQueue<String> mRssiSyncQueue = new LinkedBlockingQueue<String>(
2347            5);
2348    public synchronized int rxGetRssi() {
2349
2350        Log.i(TAG, "StubFmService:rxGetRssi  ");
2351        if (mRxState != STATE_ENABLED) {
2352            Log.e(TAG, "rxGetRssi: failed, fm not enabled  state " + mRxState);
2353            return 0;
2354        }
2355        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
2356                "Need FMRX_ADMIN_PERM permission");
2357
2358        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
2359        && (mIsCompleteScanInProgress == false)) {
2360
2361            JFmRxStatus status = mJFmRx.getRssi();
2362            Log.i(TAG, "mJFmRx.getRssi returned status " + status.toString());
2363            if (status != JFmRxStatus.PENDING) {
2364                Log.e(TAG, "mJFmRx.getRssi returned status "
2365                        + status.toString());
2366                return 0;
2367            }
2368            /* implementation to make the FM API Synchronous */
2369                try {
2370                String syncString = mRssiSyncQueue.take();
2371                if (!syncString.equals("*")) {
2372                    Log.e(TAG, "wrong sync string reseived: " + syncString);
2373                }
2374                } catch (InterruptedException e) {
2375                    Log.e(TAG, "mJFmRx.getRssi-- Wait() s Exception!!!");
2376                }
2377        } else {
2378            Log.e(TAG, "Seek is in progress.cannot call the API");
2379            return FM_SEEK_IN_PROGRESS;
2380        }
2381        Log.i(TAG, "StubFmService:rxGetRssi(): ---------- Exiting ");
2382        return getRssiValue;
2383    }
2384
2385    /*************************************************************************************************
2386     * Implementation of IFmRadio IPC interface
2387     *************************************************************************************************/
2388
2389    /* (separate queue for each get call synchronization) */
2390    private BlockingQueue<String> mRdsSystemSyncQueue = new LinkedBlockingQueue<String>(
2391            5);
2392
2393    public synchronized int rxGetRdsSystem() {
2394        Log.i(TAG, "StubFmService:rxGetRdsSystem  ");
2395        if (mRxState != STATE_ENABLED) {
2396            Log.e(TAG, "rxGetRdsSystem: failed, fm not enabled  state " + mRxState);
2397            return 0;
2398        }
2399        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
2400                "Need FMRX_ADMIN_PERM permission");
2401
2402        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
2403        && (mIsCompleteScanInProgress == false)) {
2404
2405            JFmRxStatus status = mJFmRx.getRdsSystem();
2406            Log.i(TAG, "mJFmRx.getRdsSystem returned status "
2407                    + status.toString());
2408            if (status != JFmRxStatus.PENDING) {
2409                Log.e(TAG, "mJFmRx.getRdsSystem returned status "
2410                        + status.toString());
2411                return 0;
2412            }
2413            /* implementation to make the FM API Synchronous */
2414
2415
2416                try {
2417                String syncString = mRdsSystemSyncQueue.take();
2418                if (!syncString.equals("*")) {
2419                    Log.e(TAG, "wrong sync string reseived: " + syncString);
2420                }
2421                } catch (InterruptedException e) {
2422                    Log.e(TAG, "mJFmRx.getRdsSystem-- Wait() s Exception!!!");
2423                }
2424        } else {
2425            Log.e(TAG, "Seek is in progress.cannot call the API");
2426            return FM_SEEK_IN_PROGRESS;
2427        }
2428        Log.i(TAG, "StubFmService:rxGetRdsSystem(): ----------- Exiting ");
2429        return getRdsSystemValue;
2430
2431    }
2432
2433        /*************************************************************************************************
2434     * Implementation of IFmRadio IPC interface
2435     *************************************************************************************************/
2436
2437    public boolean rxGetRdsSystem_nb() {
2438        Log.i(TAG, "StubFmService:rxGetRdsSystem_nb  ");
2439        if (mRxState != STATE_ENABLED) {
2440            Log.e(TAG, "rxGetRdsSystem_nb: failed, fm not enabled  state " + mRxState);
2441            return false;
2442        }
2443        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
2444                "Need FMRX_ADMIN_PERM permission");
2445        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
2446        && (mIsCompleteScanInProgress == false)) {
2447
2448            JFmRxStatus status = mJFmRx.getRdsSystem();
2449            Log.i(TAG, "mJFmRx.getRdsSystem returned status "
2450                    + status.toString());
2451            if (status != JFmRxStatus.PENDING) {
2452                Log.e(TAG, "mJFmRx.getRdsSystem returned status "
2453                        + status.toString());
2454                return false;
2455            }
2456
2457        } else {
2458            Log.e(TAG, "Seek is in progress.Cannot call the API");
2459            return false;
2460        }
2461        return false;
2462
2463    }
2464
2465    /*************************************************************************************************
2466     * Implementation of IFmRadio IPC interface
2467     *************************************************************************************************/
2468
2469    public boolean rxSetRdsSystem_nb(int system) {
2470
2471        Log.i(TAG, "StubFmService:rxSetRdsSystem_nb  " + system);
2472        if (mRxState != STATE_ENABLED) {
2473            Log.e(TAG, "rxSetRdsSystem_nb: failed, fm not enabled  state " + mRxState);
2474            return false;
2475        }
2476        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
2477                "Need FMRX_ADMIN_PERM permission");
2478                if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
2479        && (mIsCompleteScanInProgress == false)) {
2480        JFmRx.JFmRxRdsSystem lSystem = JFmUtils.getEnumConst(
2481                JFmRx.JFmRxRdsSystem.class, system);
2482        if (lSystem == null) {
2483            Log.e(TAG, "StubFmService:rxSetRdsSystem_nb invalid  lSystem " + lSystem);
2484            return false;
2485        }
2486        Log.d(TAG, "StubFmService:setRdsSystem   lSystem " + lSystem);
2487        JFmRxStatus status = mJFmRx.setRdsSystem(lSystem);
2488        Log.i(TAG, "mJFmRx.setRdsSystem returned status " + status.toString());
2489        if (status != JFmRxStatus.PENDING) {
2490            Log.e(TAG, "mJFmRx.setRdsSystem returned status "
2491                    + status.toString());
2492            return false;
2493        }
2494
2495
2496        } else {
2497                    Log.e(TAG, "Seek is in progress.cannot call the API");
2498                    return false;
2499                }
2500        return true;
2501
2502    }
2503
2504
2505        /*************************************************************************************************
2506     * Implementation of IFmRadio IPC interface
2507     *************************************************************************************************/
2508    /*  (separate queue for each set call synchronization) */
2509    private BlockingQueue<String> mSetRdsSystemSyncQueue = new LinkedBlockingQueue<String>(
2510            5);
2511
2512    public boolean rxSetRdsSystem(int system) {
2513
2514        Log.i(TAG, "StubFmService:rxSetRdsSystem  " + system);
2515        if (mRxState != STATE_ENABLED) {
2516            Log.e(TAG, "rxSetRdsSystem: failed, fm not enabled  state " + mRxState);
2517            return false;
2518        }
2519        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
2520                "Need FMRX_ADMIN_PERM permission");
2521        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
2522                && (mIsCompleteScanInProgress == false)) {
2523
2524        JFmRx.JFmRxRdsSystem lSystem = JFmUtils.getEnumConst(
2525                JFmRx.JFmRxRdsSystem.class, system);
2526        if (lSystem == null) {
2527                Log.e(TAG, "StubFmService:rxSetRdsSystem invalid  lSystem "
2528                        + lSystem);
2529            return false;
2530        }
2531            Log.d(TAG, "StubFmService:rxSetRdsSystem   lSystem " + lSystem);
2532        JFmRxStatus status = mJFmRx.setRdsSystem(lSystem);
2533            Log.i(TAG, "mJFmRx.setRdsSystem returned status "
2534                    + status.toString());
2535        if (status != JFmRxStatus.PENDING) {
2536                Log.e(TAG, "mJFmRx.rxSetRdsSystem returned status "
2537                    + status.toString());
2538            return false;
2539        }
2540            /* (separate queue for each get call synchronization) */
2541            try {
2542                Log.i(TAG, "StubFmService:rxSetRdsSystem(): -------- Waiting... ");
2543                String syncString = mSetRdsSystemSyncQueue.take();
2544                if (!syncString.equals("*")) {
2545                    Log.e(TAG, "wrong sync string received: " + syncString);
2546                }
2547            } catch (InterruptedException e) {
2548                Log.e(TAG, "mJFmRx.setRdsSystem-- Wait() s Exception!!!");
2549            }
2550
2551        } else {
2552            Log.e(TAG, "Seek is in progress.cannot call the API");
2553            return false;
2554        }
2555
2556        return true;
2557
2558    }
2559
2560    /*************************************************************************************************
2561     * Implementation of IFmRadio IPC interface
2562     *************************************************************************************************/
2563    /* (separate queue for each set call synchronization) */
2564    private BlockingQueue<String> mEnableRdsSyncQueue = new LinkedBlockingQueue<String>(
2565            5);
2566
2567    public boolean rxEnableRds() {
2568        Log.i(TAG, "StubFmService:rxEnableRds  ");
2569        if (mRxState != STATE_ENABLED) {
2570            Log.e(TAG, "rxEnableRds: failed, fm not enabled  state " + mRxState);
2571            return false;
2572        }
2573        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
2574                "Need FMRX_ADMIN_PERM permission");
2575        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
2576                && (mIsCompleteScanInProgress == false)) {
2577
2578
2579        JFmRxStatus status = mJFmRx.enableRDS();
2580        Log.i(TAG, "mJFmRx.enableRds returned status " + status.toString());
2581        if (status != JFmRxStatus.PENDING) {
2582            Log.e(TAG, "mJFmRx.enableRds returned status " + status.toString());
2583            return false;
2584        }
2585        mCurrentRdsState = true;
2586        Log.e(TAG, "rxEnableRds mCurrentRdsState"+mCurrentRdsState);
2587        /* implementation to make the set API Synchronous */
2588        try {
2589            String syncString = mEnableRdsSyncQueue.take();
2590            if (!syncString.equals("*")) {
2591                Log.e(TAG, "wrong sync string reseived: " + syncString);
2592            }
2593        } catch (InterruptedException e) {
2594            Log.e(TAG, "mJFmRx.enableRds-- Wait() s Exception!!!");
2595        }
2596} else {
2597            Log.e(TAG, "Seek is in progress.cannot call the API");
2598            return false;
2599        }
2600        Log.i(TAG, "StubFmService:rxEnableRds exiting");
2601        return true;
2602
2603    }
2604
2605    /*************************************************************************************************
2606     * Implementation of IFmRadio IPC interface
2607     *************************************************************************************************/
2608
2609    public boolean rxEnableRds_nb() {
2610        Log.i(TAG, "StubFmService:rxEnableRds_nb  ");
2611        if (mRxState != STATE_ENABLED) {
2612            Log.e(TAG, "rxEnableRds_nb: failed, fm not enabled  state " + mRxState);
2613            return false;
2614        }
2615        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
2616                "Need FMRX_ADMIN_PERM permission");
2617        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
2618        && (mIsCompleteScanInProgress == false)) {
2619        JFmRxStatus status = mJFmRx.enableRDS();
2620        Log.i(TAG, "mJFmRx.enableRds returned status " + status.toString());
2621        if (status != JFmRxStatus.PENDING) {
2622            Log.e(TAG, "mJFmRx.enableRds returned status " + status.toString());
2623            return false;
2624        }
2625        } else {
2626            Log.e(TAG, "Seek is in progress.cannot call the API");
2627            return false;
2628        }
2629        mCurrentRdsState = true;
2630        Log.e(TAG, "rxEnableRds_nb mCurrentRdsState"+mCurrentRdsState);
2631        return true;
2632
2633    }
2634
2635    /*************************************************************************************************
2636     * Implementation of IFmRadio IPC interface
2637     *************************************************************************************************/
2638    /* (separate queue for each set call synchronization) */
2639    private BlockingQueue<String> mDisableRdsSyncQueue = new LinkedBlockingQueue<String>(
2640            5);
2641
2642
2643    public boolean rxDisableRds() {
2644        Log.i(TAG, "StubFmService:rxDisableRds  ");
2645        if (mRxState != STATE_ENABLED) {
2646            Log.e(TAG, "rxDisableRds: failed, fm not enabled  state " + mRxState);
2647            return false;
2648        }
2649        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
2650                "Need FMRX_ADMIN_PERM permission");
2651        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
2652                && (mIsCompleteScanInProgress == false)) {
2653
2654
2655        JFmRxStatus status = mJFmRx.DisableRDS();
2656        Log.i(TAG, "mJFmRx.disableRds returned status " + status.toString());
2657        if (status != JFmRxStatus.PENDING) {
2658            Log
2659                    .e(TAG, "mJFmRx.disableRds returned status "
2660                            + status.toString());
2661            return false;
2662        }
2663        mCurrentRdsState = false;
2664        Log.e(TAG, "rxDisableRds mCurrentRdsState"+mCurrentRdsState);
2665        /* implementation to make the set API Synchronous */
2666
2667        try {
2668            String syncString = mDisableRdsSyncQueue.take();
2669            if (!syncString.equals("*")) {
2670                Log.e(TAG, "wrong sync string reseived: " + syncString);
2671            }
2672        } catch (InterruptedException e) {
2673            Log.e(TAG, "mJFmRx.disableRds-- Wait() s Exception!!!");
2674        }
2675} else {
2676            Log.e(TAG, "Seek is in progress.cannot call the API");
2677            return false;
2678        }
2679        Log.i(TAG, "StubFmService:rxDisableRds exiting");
2680        return true;
2681
2682    }
2683
2684    /*************************************************************************************************
2685     * Implementation of IFmRadio IPC interface
2686     *************************************************************************************************/
2687
2688    public boolean rxDisableRds_nb() {
2689        Log.i(TAG, "StubFmService:rxDisableRds_nb  ");
2690        if (mRxState != STATE_ENABLED) {
2691            Log
2692                    .e(TAG, "disableRds_nb: failed, fm not enabled  state "
2693                            + mRxState);
2694            return false;
2695        }
2696        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
2697                "Need FMRX_ADMIN_PERM permission");
2698        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
2699        && (mIsCompleteScanInProgress == false)) {
2700        JFmRxStatus status = mJFmRx.DisableRDS();
2701        Log.i(TAG, "mJFmRx.disableRds returned status " + status.toString());
2702        if (status != JFmRxStatus.PENDING) {
2703            Log
2704                    .e(TAG, "mJFmRx.disableRds returned status "
2705                            + status.toString());
2706            return false;
2707        }
2708        } else {
2709            Log.e(TAG, "Seek is in progress.cannot call the API");
2710            return false;
2711        }
2712        mCurrentRdsState = false;
2713        Log.e(TAG, "rxDisableRds_nb mCurrentRdsState"+mCurrentRdsState);
2714        return true;
2715
2716    }
2717
2718/*************************************************************************************************
2719     * Implementation of IFmRadio IPC interface
2720     *************************************************************************************************/
2721    /* separate queue for each set call synchronization */
2722    private BlockingQueue<String> mSetRdsGroupMaskSyncQueue = new LinkedBlockingQueue<String>(
2723            5);
2724    public boolean rxSetRdsGroupMask(int mask) {
2725        Log.i(TAG, "StubFmService:rxSetRdsGroupMask  " + mask);
2726        if (mRxState != STATE_ENABLED) {
2727            Log.e(TAG, "rxSetRdsGroupMask: failed, fm not enabled  state "
2728                    + mRxState);
2729            return false;
2730        }
2731        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
2732                "Need FMRX_ADMIN_PERM permission");
2733        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
2734                && (mIsCompleteScanInProgress == false)) {
2735
2736            JFmRx.JFmRxRdsGroupTypeMask lMask = JFmUtils.getEnumConst(
2737                    JFmRx.JFmRxRdsGroupTypeMask.class, (long) mask);
2738            JFmRxStatus status = mJFmRx.setRdsGroupMask(lMask);
2739            Log.i(TAG, "mJFmRx.setRdsGroupMask returned status "
2740                    + status.toString());
2741            if (status != JFmRxStatus.PENDING) {
2742                Log.e(TAG, "mJFmRx.setRdsGroupMask returned status "
2743                        + status.toString());
2744                return false;
2745            }
2746            /* implementation to make the set API Synchronous */
2747
2748            try {
2749                Log.i(TAG,
2750                        "StubFmService:rxSetRdsGroupMask(): -------- Waiting... ");
2751                String syncString = mSetRdsGroupMaskSyncQueue.take();
2752                if (!syncString.equals("*")) {
2753                    Log.e(TAG, "wrong sync string received: " + syncString);
2754                }
2755            } catch (InterruptedException e) {
2756                Log.e(TAG, "mJFmRx.setRdsGroupMask-- Wait() s Exception!!!");
2757            }
2758        } else {
2759            Log.e(TAG, "Seek is in progress.cannot call the API");
2760            return false;
2761        }
2762
2763        return true;
2764
2765    }
2766
2767    /*************************************************************************************************
2768     * Implementation of IFmRadio IPC interface
2769     *************************************************************************************************/
2770
2771    public boolean rxSetRdsGroupMask_nb(int mask) {
2772        Log.i(TAG, "StubFmService:rxSetRdsGroupMask_nb  " + mask);
2773        if (mRxState != STATE_ENABLED) {
2774            Log.e(TAG, " rxSetRdsGroupMask_nb: failed, fm not enabled  state "
2775                    + mRxState);
2776            return false;
2777        }
2778        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
2779                "Need FMRX_ADMIN_PERM permission");
2780
2781        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
2782        && (mIsCompleteScanInProgress == false)) {
2783        JFmRx.JFmRxRdsGroupTypeMask lMask = JFmUtils.getEnumConst(
2784                JFmRx.JFmRxRdsGroupTypeMask.class, (long) mask);
2785        JFmRxStatus status = mJFmRx.setRdsGroupMask(lMask);
2786        Log.i(TAG, "mJFmRx.setRdsSystem returned status " + status.toString());
2787        if (status != JFmRxStatus.PENDING) {
2788            Log.e(TAG, "mJFmRx.setRdsSystem returned status "
2789                    + status.toString());
2790            return false;
2791        }
2792        } else {
2793            Log.e(TAG, "Seek is in progress.cannot call the API");
2794            return false;
2795        }
2796        return true;
2797
2798    }
2799
2800    /*************************************************************************************************
2801     * Implementation of IFmRadio IPC interface
2802     *************************************************************************************************/
2803
2804    /* (separate queue for each get call synchronization) */
2805    private BlockingQueue<String> mRdsGroupMaskSyncQueue = new LinkedBlockingQueue<String>(
2806            5);
2807
2808    public synchronized long rxGetRdsGroupMask() {
2809        Log.i(TAG, "StubFmService:rxGetRdsGroupMask  ");
2810        if (mRxState != STATE_ENABLED) {
2811            Log.e(TAG, "rxGetRdsGroupMask: failed, fm not enabled  state "
2812                    + mRxState);
2813            return 0;
2814        }
2815        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
2816                "Need FMRX_ADMIN_PERM permission");
2817
2818        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
2819        && (mIsCompleteScanInProgress == false)) {
2820
2821            JFmRxStatus status = mJFmRx.getRdsGroupMask();
2822            Log.i(TAG, "mJFmRx.getRdsGroupMask returned status "
2823                    + status.toString());
2824            if (status != JFmRxStatus.PENDING) {
2825                Log.e(TAG, "mJFmRx.getRdsGroupMask returned status "
2826                        + status.toString());
2827                return 0;
2828            }
2829            /* implementation to make the set API Synchronous */
2830
2831                try {
2832                String syncString = mRdsGroupMaskSyncQueue.take();
2833                if (!syncString.equals("*")) {
2834                    Log.e(TAG, "wrong sync string reseived: " + syncString);
2835                }
2836            } catch (InterruptedException e) {
2837                Log.e(TAG, "mJFmRx.getRdsGroupMask-- Wait() s Exception!!!");
2838            }
2839        } else {
2840            Log.e(TAG, "Seek is in progress.cannot call the API");
2841            return FM_SEEK_IN_PROGRESS;
2842        }
2843        Log.i(TAG, "StubFmService:rxGetRdsGroupMask(): ---------- Exiting ");
2844        return getRdsGroupMaskValue;
2845
2846    }
2847
2848    /*************************************************************************************************
2849     * Implementation of IFmRadio IPC interface
2850     *************************************************************************************************/
2851
2852    public boolean rxGetRdsGroupMask_nb() {
2853        Log.i(TAG, "StubFmService:rxGetRdsGroupMask_nb  ");
2854        if (mRxState != STATE_ENABLED) {
2855            Log.e(TAG, "rxGetRdsGroupMask_nb: failed, fm not enabled  state "
2856                    + mRxState);
2857            return false;
2858        }
2859        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
2860                "Need FMRX_ADMIN_PERM permission");
2861        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
2862        && (mIsCompleteScanInProgress == false)) {
2863
2864            JFmRxStatus status = mJFmRx.getRdsGroupMask();
2865            Log.i(TAG, "mJFmRx.getRdsGroupMask returned status "
2866                    + status.toString());
2867            if (status != JFmRxStatus.PENDING) {
2868                Log.e(TAG, "mJFmRx.getRdsGroupMask returned status "
2869                        + status.toString());
2870                return false;
2871            }
2872
2873        } else {
2874            Log.e(TAG, "Seek is in progress.Cannot call the API");
2875            return false;
2876        }
2877
2878        return false;
2879
2880    }
2881
2882    /*************************************************************************************************
2883     * Implementation of IFmRadio IPC interface
2884     *************************************************************************************************/
2885
2886    public boolean rxSetRdsAfSwitchMode_nb(int mode) {
2887        Log.i(TAG, "StubFmService:rxSetRdsAfSwitchMode_nb  ");
2888        if (mRxState != STATE_ENABLED) {
2889            Log.e(TAG, "rxSetRdsAfSwitchMode_nb: failed, fm not enabled  state "
2890                    + mRxState);
2891            return false;
2892        }
2893        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
2894                "Need FMRX_ADMIN_PERM permission");
2895
2896                if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
2897        && (mIsCompleteScanInProgress == false)) {
2898        JFmRx.JFmRxRdsAfSwitchMode lMode = JFmUtils.getEnumConst(
2899                JFmRx.JFmRxRdsAfSwitchMode.class, mode);
2900        if (lMode == null) {
2901            Log
2902                    .e(TAG, "StubFmService:rxSetRdsAfSwitchMode_nb invalid  lMode "
2903                            + lMode);
2904            return false;
2905        }
2906        JFmRxStatus status = mJFmRx.setRdsAfSwitchMode(lMode);
2907        Log.i(TAG, "mJFmRx.setRdsAfSwitchMode returned status "
2908                + status.toString());
2909        if (status != JFmRxStatus.PENDING) {
2910            Log.e(TAG, "mJFmRx.setRdsAfSwitchMode returned status "
2911                    + status.toString());
2912
2913            return false;
2914        }
2915
2916        } else {
2917            Log.e(TAG, "Seek is in progress.cannot call the API");
2918            return false;
2919        }
2920        return true;
2921
2922    }
2923
2924
2925    /*************************************************************************************************
2926     * Implementation of IFmRadio IPC interface
2927     *************************************************************************************************/
2928    /* (separate queue for each set call synchronization) */
2929    private BlockingQueue<String> mSetRdsAfSwitchModeSyncQueue = new LinkedBlockingQueue<String>(
2930            5);
2931    public boolean rxSetRdsAfSwitchMode(int mode) {
2932        Log.i(TAG, "StubFmService:rxSetRdsAfSwitchMode  ");
2933        if (mRxState != STATE_ENABLED) {
2934            Log.e(TAG, "rxSetRdsAfSwitchMode: failed, fm not enabled  state "
2935                    + mRxState);
2936            return false;
2937        }
2938        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
2939                "Need FMRX_ADMIN_PERM permission");
2940        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
2941                && (mIsCompleteScanInProgress == false)) {
2942
2943        JFmRx.JFmRxRdsAfSwitchMode lMode = JFmUtils.getEnumConst(
2944                JFmRx.JFmRxRdsAfSwitchMode.class, mode);
2945        if (lMode == null) {
2946                Log.e(TAG, "StubFmService:rxSetRdsAfSwitchMode invalid  lMode "
2947                            + lMode);
2948            return false;
2949        }
2950        JFmRxStatus status = mJFmRx.setRdsAfSwitchMode(lMode);
2951        Log.i(TAG, "mJFmRx.setRdsAfSwitchMode returned status "
2952                + status.toString());
2953        if (status != JFmRxStatus.PENDING) {
2954            Log.e(TAG, "mJFmRx.setRdsAfSwitchMode returned status "
2955                    + status.toString());
2956
2957            return false;
2958        }
2959
2960            try {
2961                Log
2962                        .i(TAG,
2963                                "StubFmService:rxSetRdsAfSwitchMode(): -------- Waiting... ");
2964                String syncString = mSetRdsAfSwitchModeSyncQueue.take();
2965                if (!syncString.equals("*")) {
2966                    Log.e(TAG, "wrong sync string received: " + syncString);
2967                }
2968            } catch (InterruptedException e) {
2969                Log.e(TAG, "mJFmRx.setRdsAfSwitchMode-- Wait() s Exception!!!");
2970            }
2971
2972        } else {
2973            Log.e(TAG, "Seek is in progress.cannot call the API");
2974            return false;
2975        }
2976
2977        return true;
2978
2979    }
2980
2981    /*************************************************************************************************
2982     * Implementation of IFmRadio IPC interface
2983     *************************************************************************************************/
2984
2985    /* (separate queue for each get call synchronization) */
2986    private BlockingQueue<String> mRdsAfSwitchModeSyncQueue = new LinkedBlockingQueue<String>(
2987            5);
2988
2989    public synchronized int rxGetRdsAfSwitchMode() {
2990
2991        Log.i(TAG, "rxGetRdsAfSwitchMode  ");
2992        if (mRxState != STATE_ENABLED) {
2993            Log.e(TAG, "rxGetRdsAfSwitchMode: failed, fm not enabled  state "
2994                    + mRxState);
2995            return 0;
2996        }
2997        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
2998                "Need FMRX_ADMIN_PERM permission");
2999
3000        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
3001                && (mIsCompleteScanInProgress == false)) {
3002
3003            JFmRxStatus status = mJFmRx.getRdsAfSwitchMode();
3004            Log.i(TAG, "mJFmRx.getRdsAfSwitchMode returned status "
3005                    + status.toString());
3006            if (status != JFmRxStatus.PENDING) {
3007                Log.e(TAG, "mJFmRx.getRdsAfSwitchMode returned status "
3008                        + status.toString());
3009
3010                return 0;
3011            }
3012            /* implementation to make the set API Synchronous */
3013
3014                try {
3015                String syncString = mRdsAfSwitchModeSyncQueue.take();
3016                if (!syncString.equals("*")) {
3017                    Log.e(TAG, "wrong sync string reseived: " + syncString);
3018                }
3019            } catch (InterruptedException e) {
3020                Log.e(TAG, "mJFmRx.getRdsAfSwitchMode-- Wait() s Exception!!!");
3021            }
3022        } else {
3023            Log.e(TAG, "Seek is in progress.cannot call the API");
3024            return FM_SEEK_IN_PROGRESS;
3025        }
3026        Log.i(TAG, "StubFmService:rxGetRdsAfSwitchMode(): ---------- Exiting... ");
3027        return getRdsAfSwitchModeValue;
3028
3029    }
3030
3031    /*************************************************************************************************
3032         * Implementation of IFmRadio IPC interface
3033         *************************************************************************************************/
3034
3035        public boolean rxGetRdsAfSwitchMode_nb() {
3036
3037            Log.i(TAG, "rxGetRdsAfSwitchMode_nb    ");
3038            if (mRxState != STATE_ENABLED) {
3039                Log.e(TAG, "rxGetRdsAfSwitchMode_nb: failed, fm not enabled    state "
3040                        + mRxState);
3041                return false;
3042            }
3043            mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
3044                    "Need FMRX_ADMIN_PERM permission");
3045            if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
3046                    && (mIsCompleteScanInProgress == false)) {
3047
3048                JFmRxStatus status = mJFmRx.getRdsAfSwitchMode();
3049                Log.i(TAG, "mJFmRx.getRdsAfSwitchMode returned status "
3050                        + status.toString());
3051                if (status != JFmRxStatus.PENDING) {
3052                    Log.e(TAG, "mJFmRx.getRdsAfSwitchMode returned status "
3053                            + status.toString());
3054
3055                    return false;
3056                }
3057
3058            } else {
3059                Log.e(TAG, "Seek is in progress.Cannot call the API");
3060                return false;
3061            }
3062
3063            return false;
3064
3065        }
3066
3067    /*************************************************************************************************
3068     * Implementation of IFmRadio IPC interface
3069     *************************************************************************************************/
3070
3071    public boolean rxChangeAudioTarget(int mask, int digitalConfig) {
3072        Log.i(TAG, "StubFmService:rxChangeAudioTarget  ");
3073
3074        if (mRxState != STATE_ENABLED) {
3075            Log.e(TAG, "rxChangeAudioTarget: failed, already in state " + mRxState);
3076            return false;
3077        }
3078
3079        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
3080                "Need FMRX_ADMIN_PERM permission");
3081        JFmRx.JFmRxEcalSampleFrequency lconfig = JFmUtils.getEnumConst(
3082                JFmRx.JFmRxEcalSampleFrequency.class, digitalConfig);
3083        JFmRx.JFmRxAudioTargetMask lMask = JFmUtils.getEnumConst(
3084                JFmRx.JFmRxAudioTargetMask.class, mask);
3085        if (lMask == null || lconfig == null) {
3086            Log.e(TAG, "StubFmService:rxChangeAudioTarget invalid  lMask , lconfig"
3087                    + lMask + "" + lconfig);
3088            return false;
3089        }
3090
3091        JFmRxStatus status = mJFmRx.changeAudioTarget(lMask, lconfig);
3092        Log.i(TAG, "mJFmRx.changeAudioTarget returned status "
3093                + status.toString());
3094        if (status != JFmRxStatus.PENDING) {
3095            Log.e(TAG, "mJFmRx.changeAudioTarget returned status "
3096                    + status.toString());
3097            return false;
3098        }
3099
3100        return true;
3101
3102    }
3103
3104    /*************************************************************************************************
3105     * Implementation of IFmRadio IPC interface
3106     *************************************************************************************************/
3107
3108    public boolean rxChangeDigitalTargetConfiguration(int digitalConfig) {
3109        Log.i(TAG, "StubFmService:rxChangeDigitalTargetConfiguration  ");
3110
3111        if (mRxState != STATE_ENABLED) {
3112            Log.e(TAG,
3113                    "rxChangeDigitalTargetConfiguration: failed, already in state "
3114                            + mRxState);
3115            return false;
3116        }
3117
3118        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
3119                "Need FMRX_ADMIN_PERM permission");
3120        JFmRx.JFmRxEcalSampleFrequency lconfig = JFmUtils.getEnumConst(
3121                JFmRx.JFmRxEcalSampleFrequency.class, digitalConfig);
3122        if (lconfig == null) {
3123            Log.e(TAG,
3124                    "StubFmService:rxChangeDigitalTargetConfiguration invalid   lconfig"
3125                            + lconfig);
3126            return false;
3127        }
3128
3129        JFmRxStatus status = mJFmRx.changeDigitalTargetConfiguration(lconfig);
3130        Log.i(TAG, "mJFmRx.changeDigitalTargetConfiguration returned status "
3131                    + status.toString());
3132        if (status != JFmRxStatus.PENDING) {
3133            Log.e(TAG,
3134                    "mJFmRx.changeDigitalTargetConfiguration returned status "
3135                            + status.toString());
3136
3137            return false;
3138        }
3139
3140        return true;
3141
3142    }
3143
3144    /*************************************************************************************************
3145     * Implementation of IFmRadio IPC interface
3146     *************************************************************************************************/
3147
3148    public boolean rxEnableAudioRouting() {
3149        Log.i(TAG, "StubFmService:rxEnableAudioRouting  ");
3150        if (mRxState != STATE_ENABLED) {
3151            Log
3152                    .e(TAG, "rxEnableAudioRouting: failed, already in state "
3153                            + mRxState);
3154            return false;
3155        }
3156        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
3157                "Need FMRX_ADMIN_PERM permission");
3158        JFmRxStatus status = mJFmRx.enableAudioRouting();
3159        Log.i(TAG, "mJFmRx.enableAudioRouting returned status "
3160                + status.toString());
3161        if (status != JFmRxStatus.PENDING) {
3162            Log.e(TAG, "mJFmRx.enableAudioRouting returned status "
3163                    + status.toString());
3164
3165            return false;
3166        }
3167        return true;
3168
3169    }
3170
3171    /*************************************************************************************************
3172     * Implementation of IFmRadio IPC interface
3173     *************************************************************************************************/
3174
3175    public boolean rxDisableAudioRouting() {
3176        Log.i(TAG, "StubFmService:rxDisableAudioRouting  ");
3177        if (mRxState != STATE_ENABLED) {
3178            Log.e(TAG, "rxDisableAudioRouting: failed, already in state "
3179                    + mRxState);
3180            return false;
3181        }
3182        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
3183                "Need FMRX_ADMIN_PERM permission");
3184        JFmRxStatus status = mJFmRx.disableAudioRouting();
3185        if (DBG)
3186            Log.i(TAG, "mJFmRx.disableAudioRouting returned status "
3187                    + status.toString());
3188        if (status != JFmRxStatus.PENDING) {
3189            Log.e(TAG, "mJFmRx.disableAudioRouting returned status "
3190                    + status.toString());
3191            return false;
3192        }
3193        return true;
3194
3195    }
3196
3197    /*************************************************************************************************
3198     * Implementation of IFmRadio IPC interface
3199     *************************************************************************************************/
3200    /*When Asynchronous Events like Call, Music PLayback,VideoPlayback is happning, FM will be put into pause state
3201    by disabling the audio.*/
3202    public boolean pauseFm() {
3203        if (rxIsEnabled() == true) {
3204            Log.i(TAG, "StubFmService:pauseFm  ");
3205            if (mRxState != STATE_ENABLED) {
3206                Log.e(TAG, "pauseFm: failed, already in state " + mRxState);
3207                return false;
3208            }
3209            mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
3210                    "Need FMRX_ADMIN_PERM permission");
3211
3212               /* L25 Specific */
3213             //mAudioManager.setParameters(AUDIO_RX_ENABLE+"=false");
3214             int off = 0;
3215               /* L27 Specific */
3216            enableRx(off);
3217
3218            if (mWakeLock != null) {
3219                mWakeLock.acquire();
3220            }
3221
3222        try {
3223            JFmRxStatus status = mJFmRx.disableAudioRouting();
3224                Log.i(TAG, "mJFmRx.disableAudioRouting returned status "
3225                        + status.toString());
3226            if (JFmRxStatus.PENDING != status) {
3227                    Log.e(TAG, "mJFmRx.disableAudioRouting returned status "
3228                        + status.toString());
3229                return false;
3230            }
3231        } catch (Exception e) {
3232            Log.e(TAG, "disableAudioRouting: Exception thrown during disableAudioRouting ("
3233                    + e.toString() + ")");
3234            return false;
3235        }
3236
3237            mDelayedDisableHandler.postDelayed(mDelayedPauseDisable,
3238                    FM_DISABLE_DELAY);
3239            return true;
3240        } else
3241            return false;
3242
3243    }
3244
3245    /*************************************************************************************************
3246     * Implementation of IFmRadio IPC interface
3247     *************************************************************************************************/
3248    /*This API will be called when teh user wants to resume FM after it has been paused.
3249    With this API you resume the FM playback by restoring the values before pause.*/
3250    public boolean resumeFm() {
3251
3252        Log.i(TAG, "StubFmService:  resumeFm ");
3253        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
3254                "Need FMRX_ADMIN_PERM permission");
3255        mDelayedDisableHandler.removeCallbacks(mDelayedPauseDisable);
3256        mDelayedDisableHandler.removeCallbacks(mDelayedDisable);
3257
3258        // Tell the music playback service to pause
3259        // TODO: these constants need to be published somewhere in the
3260        // framework.
3261        Intent i = new Intent("com.android.music.musicservicecommand");
3262        i.putExtra("command", "pause");
3263        mContext.sendBroadcast(i);
3264
3265           if ((mWakeLock != null) && (mWakeLock.isHeld())) {
3266                mWakeLock.release();
3267             }
3268          /* L25 Specific */
3269        //mAudioManager.setParameters(AUDIO_RX_ENABLE+"=true");
3270        int On=1;
3271          /* L27 Specific */
3272        enableRx(On);
3273
3274        mRxState = STATE_RESUME;
3275        mFmPauseResume =STATE_RESUME;
3276
3277        Log.d(TAG, "Sending restore values intent");
3278        Intent restoreValuesIntent = new Intent(FM_RESTORE_VALUES);
3279        mContext.sendBroadcast(restoreValuesIntent);
3280
3281
3282        return true;
3283
3284    }
3285
3286
3287    /*************************************************************************************************
3288     * Implementation of IFmRadio IPC interface
3289     *************************************************************************************************/
3290    public boolean rxCompleteScan_nb() {
3291        Log.i(TAG, "StubFmService:rxCompleteScan_nb");
3292
3293        if (mRxState != STATE_ENABLED) {
3294            Log.e(TAG, "rxCompleteScan_nb: failed, fm not enabled state " + mRxState);
3295            return false;
3296        }
3297
3298        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
3299                "Need FMRX_ADMIN_PERM permission");
3300
3301        JFmRxStatus status = mJFmRx.completeScan();
3302        Log.i(TAG, "mJFmRx.completeScan returned status " + status.toString());
3303        if (JFmRxStatus.PENDING != status) {
3304            Log.e(TAG, "mJFmRx.completeScan returned status "
3305                    + status.toString());
3306            return false;
3307        }
3308
3309        mIsCompleteScanInProgress = true;
3310
3311        return true;
3312
3313    }
3314
3315    /*************************************************************************************************
3316     * Implementation of IFmRadio IPC interface
3317     *************************************************************************************************/
3318    public boolean rxStopCompleteScan_nb() {
3319        Log.i(TAG, "StubFmService:rxStopCompleteScan_nb");
3320
3321        if (mRxState != STATE_ENABLED) {
3322            Log.e(TAG, "rxStopCompleteScan_nb: failed, fm not enabled state "
3323                    + mRxState);
3324            return false;
3325        }
3326
3327        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
3328                "Need FMRX_ADMIN_PERM permission");
3329        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)) {
3330            JFmRxStatus status = mJFmRx.stopCompleteScan();
3331            Log.i(TAG, "mJFmRx.stopCompleteScan returned status "
3332                    + status.toString());
3333            if (JFmRxStatus.PENDING != status) {
3334                Log.e(TAG, "mJFmRx.stopCompleteScan returned status "
3335                        + status.toString());
3336                return false;
3337            }
3338
3339            return true;
3340        } else {
3341            Log.e(TAG, "Seek/tune is in progress.cannot call the API");
3342            return false;
3343        }
3344
3345    }
3346
3347
3348    /*************************************************************************************************
3349     * Implementation of IFmRadio IPC interface
3350     *************************************************************************************************/
3351    /* separate queue for each set call synchronization */
3352    private BlockingQueue<String> mStopCompleteScanSyncQueue = new LinkedBlockingQueue<String>(
3353            5);
3354    public int rxStopCompleteScan() {
3355        Log.i(TAG, "StubFmService:rxStopCompleteScan");
3356
3357        if (mRxState != STATE_ENABLED) {
3358            Log.e(TAG, "rxStopCompleteScan: failed, fm not enabled state "
3359                    + mRxState);
3360            return 0;
3361        }
3362
3363        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
3364                "Need FMRX_ADMIN_PERM permission");
3365        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)) {
3366            JFmRxStatus status = mJFmRx.stopCompleteScan();
3367            Log.i(TAG, "mJFmRx.stopCompleteScan returned status "
3368                    + status.toString());
3369            if (JFmRxStatus.PENDING != status) {
3370                Log.e(TAG, "mJFmRx.stopCompleteScan returned status "
3371                        + status.toString());
3372                if (JFmRxStatus.COMPLETE_SCAN_IS_NOT_IN_PROGRESS == status) {
3373                    return status.getValue();
3374                } else
3375                    return 0;
3376            }
3377
3378            /* implementation to make the set API Synchronous */
3379
3380            try {
3381                Log.i(TAG,
3382                        "StubFmService:rxStopCompleteScan(): -------- Waiting... ");
3383                String syncString = mStopCompleteScanSyncQueue.take();
3384                if (!syncString.equals("*")) {
3385                    Log.e(TAG, "wrong sync string received: " + syncString);
3386                }
3387            } catch (InterruptedException e) {
3388                Log.e(TAG, "mJFmRx.stopCompleteScan-- Wait() s Exception!!!");
3389            }
3390
3391        } else {
3392            Log.e(TAG, "Seek/tune is in progress.cannot call the API");
3393            return FM_SEEK_IN_PROGRESS;
3394        }
3395
3396        Log.i(TAG, "StubFmService:stopCompleteScan(): ---------- Exiting... ");
3397        return mStopCompleteScanStatus;
3398
3399    }
3400
3401    /*************************************************************************************************
3402     * Implementation of IFmRadio IPC interface
3403     *************************************************************************************************/
3404    /* (separate queue for each get call synchronization) */
3405    private BlockingQueue<String> mValidChannelSyncQueue = new LinkedBlockingQueue<String>(
3406            5);
3407    public synchronized boolean rxIsValidChannel() {
3408        Log.i(TAG, "StubFmService:rxIsValidChannel");
3409
3410        if (mRxState != STATE_ENABLED) {
3411            Log
3412                    .e(TAG, "rxIsValidChannel: failed, fm not enabled state "
3413                            + mRxState);
3414            return false;
3415        }
3416
3417        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
3418                "Need FMRX_ADMIN_PERM permission");
3419        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
3420                && (mIsCompleteScanInProgress == false)) {
3421
3422        JFmRxStatus status = mJFmRx.isValidChannel();
3423            Log.i(TAG, "mJFmRx.isValidChannel returned status "
3424                        + status.toString());
3425        if (JFmRxStatus.PENDING != status) {
3426            Log.e(TAG, "mJFmRx.isValidChannel returned status "
3427                    + status.toString());
3428            return false;
3429        }
3430
3431        /* implementation to make the FM API Synchronous */
3432
3433            try {
3434                String syncString = mValidChannelSyncQueue.take();
3435                if (!syncString.equals("*")) {
3436                    Log.e(TAG, "wrong sync string reseived: " + syncString);
3437                }
3438            } catch (InterruptedException e) {
3439                Log.e(TAG, "mJFmRx.isValidChannel-- Wait() s Exception!!!");
3440            }
3441        } else {
3442            Log.e(TAG, "Seek is in progress.cannot call the API");
3443            return false;
3444        }
3445        Log.i(TAG, "StubFmService:rxIsValidChannel(): ---------- Exiting... ");
3446        return mIsValidChannel;
3447
3448    }
3449
3450    /*************************************************************************************************
3451     * Implementation of IFmRadio IPC interface
3452     *************************************************************************************************/
3453    /* (separate queue for each get call synchronization) */
3454    private BlockingQueue<String> mFwVersionSyncQueue = new LinkedBlockingQueue<String>(
3455            5);
3456    public synchronized double rxGetFwVersion() {
3457        Log.i(TAG, "StubFmService:rxGetFwVersion");
3458
3459        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
3460                "Need FMRX_ADMIN_PERM permission");
3461        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)
3462                && (mIsCompleteScanInProgress == false)) {
3463
3464        JFmRxStatus status = mJFmRx.getFwVersion();
3465            Log.i(TAG, "mJFmRx.getFwVersion returned status "
3466                    + status.toString());
3467        if (JFmRxStatus.PENDING != status) {
3468            Log.e(TAG, "mJFmRx.getFwVersion returned status "
3469                    + status.toString());
3470            return 0;
3471        }
3472
3473                /* implementation to make the FM API Synchronous */
3474
3475            try {
3476                String syncString = mFwVersionSyncQueue.take();
3477                if (!syncString.equals("*")) {
3478                    Log.e(TAG, "wrong sync string reseived: " + syncString);
3479                }
3480            } catch (InterruptedException e) {
3481                Log.e(TAG, "mJFmRx.getFwVersion-- Wait() s Exception!!!");
3482            }
3483        } else {
3484            Log.e(TAG, "Seek is in progress.cannot call the API");
3485            return FM_SEEK_IN_PROGRESS;
3486        }
3487        Log.i(TAG, "StubFmService:rxGetFwVersion(): ---------- Exiting... ");
3488        return getFwVersion;
3489
3490    }
3491
3492    /*************************************************************************************************
3493     * Implementation of IFmRadio IPC interface
3494     *************************************************************************************************/
3495    /* (separate queue for each get call synchronization) */
3496    private BlockingQueue<String> mCompleteScanProgressSyncQueue = new LinkedBlockingQueue<String>(
3497            5);
3498
3499    public synchronized int rxGetCompleteScanProgress() {
3500        Log.i(TAG, "StubFmService:rxGetCompleteScanProgress");
3501
3502        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
3503                "Need FMRX_ADMIN_PERM permission");
3504
3505        if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)) {
3506            JFmRxStatus status = mJFmRx.getCompleteScanProgress();
3507            if (DBG)
3508                Log.i(TAG, "mJFmRx.getCompleteScanProgress returned status "
3509                        + status.toString());
3510            if (JFmRxStatus.PENDING != status) {
3511                Log.e(TAG, "mJFmRx.getCompleteScanProgress returned status "
3512                        + status.toString());
3513                if (JFmRxStatus.COMPLETE_SCAN_IS_NOT_IN_PROGRESS == status) {
3514                    return status.getValue();
3515                } else
3516                return 0;
3517            }
3518            /* implementation to make the FM API Synchronous */
3519
3520            try {
3521                String syncString = mCompleteScanProgressSyncQueue.take();
3522                if (!syncString.equals("*")) {
3523                    Log.e(TAG, "wrong sync string reseived: " + syncString);
3524                }
3525            } catch (InterruptedException e) {
3526                Log
3527                        .e(TAG,
3528                                "mJFmRx.getCompleteScanProgress-- Wait() s Exception!!!");
3529            }
3530        } else {
3531            Log.e(TAG, "Seek is in progress.cannot call the API");
3532            return FM_SEEK_IN_PROGRESS;
3533        }
3534        if (DBG)
3535            Log
3536                .i(TAG,
3537                        "StubFmService:rxGetCompleteScanProgress(): ---------- Exiting... ");
3538        return getScanProgress;
3539
3540    }
3541
3542
3543    /*************************************************************************************************
3544         * Implementation of IFmRadio IPC interface
3545         *************************************************************************************************/
3546
3547        public  boolean rxGetCompleteScanProgress_nb() {
3548            Log.i(TAG, "StubFmService:rxGetCompleteScanProgress_nb");
3549
3550            mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
3551                    "Need FMRX_ADMIN_PERM permission");
3552
3553            if ((mIsSeekInProgress == false) && (mIsTuneInProgress == false)) {
3554                JFmRxStatus status = mJFmRx.getCompleteScanProgress();
3555                Log.i(TAG, "mJFmRx.rxGetCompleteScanProgress_nb returned status "
3556                        + status.toString());
3557                if (JFmRxStatus.PENDING != status) {
3558                    Log.e(TAG, "mJFmRx.getCompleteScanProgress returned status "
3559                            + status.toString());
3560                        return false;
3561                }
3562
3563            } else {
3564                Log.e(TAG, "Seek is in progress.cannot call the API");
3565                return false;
3566            }
3567            Log
3568                    .i(TAG,
3569                            "StubFmService:rxGetCompleteScanProgress(): ---------- Exiting... ");
3570            return true;
3571
3572        }
3573
3574
3575    /*************************************************************************************************
3576     * Implementation of IFMReciever IPC interface
3577     *************************************************************************************************/
3578
3579    public boolean txEnable() {
3580        /* If Rx is NOT ENABLED then only Enable TX*/
3581                    if(rxIsEnabled()==true){
3582                 Log.e(TAG, "Fm TX Enable: FM RX is enabled could not Enable fm TX");
3583                     return false;
3584                        }
3585
3586        Log.i(TAG, "StubFmService:  txEnable ");
3587        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
3588                "Need FMRX_ADMIN_PERM permission");
3589        JFmTxStatus status;
3590
3591            /* Creating the Fm Tx Context*/
3592
3593            // try communicating for 5 seconds (by trying to create a valid FmRX context)
3594           boolean fmTxCreated = false;
3595          for (int count = 0; count< 10; count++) {
3596             Log.i(TAG, "FmTxEnable: FmRx create try #" + count);
3597          Log.i(TAG, "FmTxEnable: mJFmTx is:"+ mJFmTx);
3598             status = mJFmTx.txCreate(this);
3599             Log.i(TAG, "FmTxEnable: FmRx create returned " + status.toString());
3600             if (status == JFmTxStatus.SUCCESS) {
3601                fmTxCreated = true;
3602                break;
3603                 }
3604                     SystemClock.sleep(500);
3605                  }
3606
3607          if (fmTxCreated == false) {
3608             Log.e(TAG, "fmTxCreated: FmRx create failed. Aborting");
3609             return false;
3610                  }
3611
3612
3613/* Enabling  the Fm Tx module */
3614        try {
3615    // TODO: these constants need to be published somewhere in the framework.
3616            status = mJFmTx.txEnable();
3617            Log.i(TAG, "mJFmTx.txEnable returned status " + status.toString());
3618
3619            /* If the Operation Fail, Send false to the user and reset the MCP Monitor */
3620            if (status != JFmTxStatus.PENDING && status != JFmTxStatus.SUCCESS) {
3621            Log.e(TAG, "mJFmTx.txEnable returned status "    + status.toString());
3622            return false;
3623            }
3624        } catch (Exception e) {
3625        Log.e(TAG, "enable: Exception thrown during enable ("+ e.toString() + ")");
3626        return false;
3627        }
3628
3629        if (status == JFmTxStatus.SUCCESS)
3630        {
3631    Intent intentTxEnable = new Intent(FmRadioIntent.FM_TX_ENABLED_ACTION);
3632    intentTxEnable.putExtra(FmRadioIntent.STATUS, status);
3633    mContext.sendBroadcast(intentTxEnable, FMRX_PERM);
3634
3635        }else {
3636    // set a delayed timeout message
3637    }
3638
3639        return true;
3640    }
3641
3642
3643
3644   public boolean IsFmTxEnabled() {
3645        Log.i(TAG, "StubFmService:  IsFmTxEnabled ");
3646        mContext.enforceCallingOrSelfPermission(FMRX_PERM,
3647                "Need FMRX_PERM permission");
3648        return (mTxState == STATE_ENABLED);
3649
3650    }
3651
3652
3653    /*************************************************************************************************
3654     * Implementation of IFMReciever IPC interface
3655     *************************************************************************************************/
3656    public boolean txDisable() {
3657        JFmTxStatus status;
3658        Log.i(TAG, "StubFmService:  disableTx ");
3659        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
3660                "Need FMRX_ADMIN_PERM permission");
3661
3662        try {
3663            status = mJFmTx.txDisable();
3664        Log.i(TAG, "mJFmTx.txDisable returned status " + status.toString());
3665           if (status != JFmTxStatus.PENDING && status != JFmTxStatus.SUCCESS){
3666            destroyJFmTx(); /* destroy all connection with deamon on radioOff */
3667            return false;
3668        }
3669        } catch (Exception e) {
3670        Log.e(TAG, "txDisable: Exception thrown during disable ("+ e.toString() + ")");
3671        return false;
3672        }
3673
3674        mTxState = STATE_DEFAULT;
3675
3676        if (status == JFmTxStatus.SUCCESS)
3677            {
3678                //TODO - Need to see what to send here if the operation is synchronic
3679
3680            }
3681        else {
3682            // set a delayed timeout message
3683        }
3684
3685        return true;
3686    }
3687
3688
3689    /* Destroy Tx Context */
3690    private void destroyJFmTx() {
3691        JFmTxStatus status;
3692        Log.i(TAG, "StubFmService:  destroyJFmTx ");
3693        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,"Need FMRX_ADMIN_PERM permission");
3694
3695        try {
3696        if (mJFmTx != null) {
3697                 status = mJFmTx.txDestroy();
3698                 Log.i(TAG, "mJFmTx.destroyJFmTx returned status " + status.toString());
3699            }
3700        } catch (Exception e) {
3701        Log.e(TAG, "destroyJFmTx: Exception thrown during destroy ("+ e.toString() + ")");
3702        }
3703
3704        mTxState = STATE_DEFAULT;
3705
3706        }
3707
3708
3709
3710    /*************************************************************************************************
3711     * Implementation of IFMReciever IPC interface
3712     *************************************************************************************************/
3713    public boolean txStartTransmission() {
3714        Log.i(TAG, "StubFmService:  txStartTransmission ");
3715        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
3716                "Need FMRX_ADMIN_PERM permission");
3717
3718        try {
3719
3720            JFmTxStatus status = mJFmTx.txStartTransmission();
3721            Log.i(TAG, "mJFmTx.txStartTransmission returned status " + status.toString());
3722            if (JFmTxStatus.PENDING != status) {
3723                Log.e(TAG, "mJFmTx.txStartTransmission returned status "
3724                        + status.toString());
3725                return false;
3726            }
3727
3728        } catch (Exception e) {
3729            Log.e(TAG, "txStartTransmission: Exception thrown during disable ("
3730                    + e.toString() + ")");
3731            return false;
3732        }
3733        return true;
3734
3735    }
3736
3737
3738    /*************************************************************************************************
3739     * Implementation of IFMReciever IPC interface
3740     *************************************************************************************************/
3741    public boolean txStopTransmission() {
3742        Log.i(TAG, "StubFmService:  txStopTransmission ");
3743        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
3744                "Need FMRX_ADMIN_PERM permission");
3745
3746        try {
3747
3748            JFmTxStatus status = mJFmTx.txStopTransmission();
3749            Log.i(TAG, "mJFmTx.txStopTransmission returned status " + status.toString());
3750            if (JFmTxStatus.PENDING != status) {
3751                Log.e(TAG, "mJFmTx.txStopTransmission returned status "
3752                        + status.toString());
3753                return false;
3754            }
3755        } catch (Exception e) {
3756            Log.e(TAG, "txStopTransmission: Exception thrown during disable ("
3757                    + e.toString() + ")");
3758            return false;
3759        }
3760        return true;
3761
3762    }
3763
3764    /*************************************************************************************************
3765     * Implementation of IFMReciever IPC interface
3766     *************************************************************************************************/
3767
3768    public boolean txTune(long freq) {
3769        Log.i(TAG, "StubFmService:txTune  " + freq);
3770
3771        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
3772                "Need FMRX_ADMIN_PERM permission");
3773        JFmTx.JFmTxFreq lFreq = new JFmTx.JFmTxFreq(freq);
3774        if (lFreq == null) {
3775            Log.e(TAG, "StubFmService:txTune invalid frequency " + lFreq);
3776            return false;
3777        }
3778        Log.d(TAG, "StubFmService:txTune  " + lFreq);
3779        JFmTxStatus status = mJFmTx.txTune(lFreq);
3780        Log.i(TAG, "mJFmRx.tune returned status " + status.toString());
3781        if (status != JFmTxStatus.PENDING) {
3782            Log.e(TAG, "mJFmTx.txTune returned status " + status.toString());
3783            return false;
3784        }
3785        return true;
3786
3787    }
3788
3789
3790
3791    /*************************************************************************************************
3792     * Implementation of IFMReciever IPC interface
3793     *************************************************************************************************/
3794
3795    public boolean txGetTunedFrequency( ) {
3796        Log.i(TAG, "StubFmService:txGetTunedFrequency  ");
3797
3798        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
3799                "Need FMRX_ADMIN_PERM permission");
3800
3801        JFmTxStatus status = mJFmTx.txGetTunedFrequency();
3802
3803        Log.i(TAG, "mJFmTx.txGetTunedFrequency returned status " + status.toString());
3804        if (status != JFmTxStatus.PENDING) {
3805            Log.e(TAG, "mJFmTx.txGetTunedFrequency returned status " + status.toString());
3806            return false;
3807        }
3808        return true;
3809
3810    }
3811
3812
3813    /*************************************************************************************************
3814     * Implementation of IFMReciever IPC interface
3815     *************************************************************************************************/
3816
3817    public boolean txSetPowerLevel(int  powerLevel) {
3818        Log.i(TAG, "StubFmService:txSetPowerLevel  " + powerLevel);
3819
3820        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
3821                "Need FMRX_ADMIN_PERM permission");
3822        JFmTx.JFmTxPowerLevel lPowerLevel = new JFmTx.JFmTxPowerLevel(powerLevel);
3823        if (lPowerLevel == null) {
3824            Log.e(TAG, "StubFmService:txSetPowerLevel invalid PowerLevel " + lPowerLevel);
3825            return false;
3826        }
3827        Log.d(TAG, "StubFmService:txSetPowerLevel  " + lPowerLevel);
3828        JFmTxStatus status = mJFmTx.txSetPowerLevel(lPowerLevel);
3829        Log.i(TAG, "mJFmTx.txSetPowerLevel returned status " + status.toString());
3830        if (status != JFmTxStatus.PENDING) {
3831            Log.e(TAG, "mJFmTx.txSetPowerLevel returned status " + status.toString());
3832            return false;
3833        }
3834        return true;
3835
3836    }
3837
3838
3839
3840    /*************************************************************************************************
3841     * Implementation of IFMReciever IPC interface
3842     *************************************************************************************************/
3843
3844    public boolean txGetPowerLevel() {
3845        Log.i(TAG, "StubFmService:txGetPowerLevel  ");
3846
3847        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
3848                "Need FMRX_ADMIN_PERM permission");
3849
3850        JFmTxStatus status = mJFmTx.txGetPowerLevel();
3851        Log.i(TAG, "mJFmTx.txGetPowerLevel returned status " + status.toString());
3852        if (status != JFmTxStatus.PENDING) {
3853            Log.e(TAG, "mJFmTx.txGetPowerLevel returned status " + status.toString());
3854            return false;
3855        }
3856        return true;
3857
3858    }
3859
3860    /*************************************************************************************************
3861     * Implementation of IFMReciever IPC interface
3862     *************************************************************************************************/
3863
3864    public boolean txEnableRds() {
3865        Log.i(TAG, "StubFmService:txEnableRds  ");
3866
3867        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
3868                "Need FMRX_ADMIN_PERM permission");
3869
3870        JFmTxStatus status = mJFmTx.txEnableRds();
3871
3872        Log.i(TAG, "mJFmTx.txEnableRds returned status " + status.toString());
3873        if (status != JFmTxStatus.PENDING) {
3874            Log.e(TAG, "mJFmTx.txEnableRds returned status " + status.toString());
3875            return false;
3876        }
3877        return true;
3878
3879    }
3880
3881
3882    /*************************************************************************************************
3883     * Implementation of IFMReciever IPC interface
3884     *************************************************************************************************/
3885
3886    public boolean txDisableRds() {
3887        Log.i(TAG, "StubFmService:txDisableRds  ");
3888
3889        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
3890                "Need FMRX_ADMIN_PERM permission");
3891
3892        JFmTxStatus status = mJFmTx.txDisableRds();
3893
3894        Log.i(TAG, "mJFmTx.txDisableRds returned status " + status.toString());
3895        if (status != JFmTxStatus.PENDING) {
3896            Log.e(TAG, "mJFmTx.txDisableRds returned status " + status.toString());
3897            return false;
3898        }
3899        return true;
3900
3901    }
3902
3903
3904    /*************************************************************************************************
3905     * Implementation of IFMReciever IPC interface
3906     *************************************************************************************************/
3907
3908    public boolean txSetRdsTransmissionMode(int mode) {
3909        Log.i(TAG, "StubFmService:txSetRdsTransmissionMode  ");
3910
3911        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
3912                "Need FMRX_ADMIN_PERM permission");
3913
3914        JFmTx.JFmTxRdsTransmissionMode lMode = JFmUtils.getEnumConst(JFmTx.JFmTxRdsTransmissionMode.class,
3915                mode);
3916        if (lMode == null) {
3917            Log.e(TAG, "StubFmService:txSetRdsTransmissionMode invalid  lMode " + lMode);
3918            return false;
3919        }
3920
3921        JFmTxStatus status = mJFmTx.txSetRdsTransmissionMode(lMode);
3922
3923        Log.i(TAG, "mJFmTx.txSetRdsTransmissionMode returned status " + status.toString());
3924        if (status != JFmTxStatus.PENDING) {
3925            Log.e(TAG, "mJFmTx.txSetRdsTransmissionMode returned status " + status.toString());
3926            return false;
3927        }
3928        return true;
3929
3930    }
3931
3932
3933    /*************************************************************************************************
3934     * Implementation of IFMReciever IPC interface
3935     *************************************************************************************************/
3936
3937    public boolean txGetRdsTransmissionMode( ) {
3938        Log.i(TAG, "StubFmService:txGetRdsTransmissionMode  ");
3939
3940        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
3941                "Need FMRX_ADMIN_PERM permission");
3942
3943        JFmTxStatus status = mJFmTx.txGetRdsTransmissionMode();
3944
3945        Log.i(TAG, "mJFmTx.txGetRdsTransmissionMode returned status " + status.toString());
3946        if (status != JFmTxStatus.PENDING) {
3947            Log.e(TAG, "mJFmTx.txGetRdsTransmissionMode returned status " + status.toString());
3948            return false;
3949        }
3950        return true;
3951
3952    }
3953
3954
3955    /*************************************************************************************************
3956     * Implementation of IFMReciever IPC interface
3957     *************************************************************************************************/
3958
3959    public boolean txSetRdsTextPsMsg(String  psStr) {
3960        Log.i(TAG, "StubFmService:txSetRdsTextPsMsg --> psString = "+psStr);
3961
3962        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
3963                "Need FMRX_ADMIN_PERM permission");
3964
3965        int strLength = psStr.length();
3966        //byte[] psString = psStr.getBytes();// converting String to Byte Array
3967
3968        JFmTxStatus status = mJFmTx.txSetRdsTextPsMsg(psStr,strLength);
3969
3970        Log.i(TAG, "mJFmTx.txSetRdsTextPsMsg returned status " + status.toString());
3971        if (status != JFmTxStatus.PENDING) {
3972            Log.e(TAG, "mJFmTx.txSetRdsTextPsMsg returned status " + status.toString());
3973            return false;
3974        }
3975        return true;
3976
3977    }
3978
3979
3980    /*************************************************************************************************
3981     * Implementation of IFMReciever IPC interface
3982     *************************************************************************************************/
3983
3984    public boolean txGetRdsTextPsMsg( ) {
3985        Log.i(TAG, "StubFmService:txGetRdsTextPsMsg --> psString = ");
3986
3987        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
3988                "Need FMRX_ADMIN_PERM permission");
3989
3990        JFmTxStatus status = mJFmTx.txGetRdsTextPsMsg();
3991
3992        Log.i(TAG, "mJFmTx.txGetRdsTextPsMsg returned status " + status.toString());
3993        if (status != JFmTxStatus.PENDING) {
3994            Log.e(TAG, "mJFmTx.txGetRdsTextPsMsg returned status " + status.toString());
3995            return false;
3996        }
3997        return true;
3998
3999    }
4000
4001
4002
4003    /*************************************************************************************************
4004     * Implementation of IFMReciever IPC interface
4005     *************************************************************************************************/
4006
4007    public boolean txWriteRdsRawData(String msg) {
4008        Log.i(TAG, "StubFmService:txWriteRdsRawData  ");
4009
4010        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4011                "Need FMRX_ADMIN_PERM permission");
4012
4013        int strLength = msg.length();
4014        //byte[] rawData = msg.getBytes();// converting String to Byte Array
4015
4016        JFmTxStatus status = mJFmTx.txWriteRdsRawData(msg,strLength);
4017
4018        Log.i(TAG, "mJFmTx.txWriteRdsRawData returned status " + status.toString());
4019        if (status != JFmTxStatus.PENDING) {
4020            Log.e(TAG, "mJFmTx.txWriteRdsRawData returned status " + status.toString());
4021            return false;
4022        }
4023        return true;
4024
4025    }
4026
4027    public boolean  txChangeDigitalSourceConfiguration(int ecalSampleFreq){
4028        Log.i(TAG, "StubFmService:txChangeDigitalSourceConfiguration  ");
4029
4030        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4031                "Need FMRX_ADMIN_PERM permission");
4032
4033        JFmTxStatus status = mJFmTx.txChangeDigitalSourceConfiguration(ecalSampleFreq);
4034
4035        Log.i(TAG, "mJFmTx.txChangeDigitalSourceConfiguration returned status " + status.toString());
4036        if (status != JFmTxStatus.PENDING) {
4037            Log.e(TAG, "mJFmTx.txChangeDigitalSourceConfiguration returned status " + status.toString());
4038            return false;
4039        }
4040        return true;
4041
4042    }
4043
4044
4045    public boolean  txChangeAudioSource(int audioSrc,int ecalSampleFreq){
4046        Log.i(TAG, "StubFmService:txChangeAudioSource  ");
4047
4048        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4049                "Need FMRX_ADMIN_PERM permission");
4050
4051        JFmTx.JFmTxEcalResource lAudioSrc = JFmUtils.getEnumConst(
4052                JFmTx.JFmTxEcalResource.class, audioSrc);
4053        if (lAudioSrc == null) {
4054            Log.e(TAG, "StubFmService:txChangeAudioSource invalid  lAudioSrc " + lAudioSrc);
4055            return false;
4056        }
4057
4058        JFmTx.JFmTxEcalSampleFrequency lEcalSampleFreq = JFmUtils.getEnumConst(
4059                JFmTx.JFmTxEcalSampleFrequency.class, ecalSampleFreq);
4060        if (lAudioSrc == null) {
4061            Log.e(TAG, "StubFmService:txChangeAudioSource invalid  lEcalSampleFreq " + lEcalSampleFreq);
4062            return false;
4063        }
4064
4065
4066        JFmTxStatus status = mJFmTx.txChangeAudioSource(lAudioSrc,lEcalSampleFreq);
4067
4068        Log.i(TAG, "mJFmTx.txChangeAudioSource returned status " + status.toString());
4069        if (status != JFmTxStatus.PENDING) {
4070            Log.e(TAG, "mJFmTx.txChangeAudioSource returned status " + status.toString());
4071            return false;
4072        }
4073        return true;
4074
4075    }
4076
4077
4078    public boolean  txSetRdsECC(int ecc){
4079        Log.i(TAG, "StubFmService:txSetRdsECC  ");
4080
4081        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4082                "Need FMRX_ADMIN_PERM permission");
4083
4084
4085        JFmTxStatus status = mJFmTx.txSetRdsECC(ecc);
4086
4087        Log.i(TAG, "mJFmTx.txSetRdsECC returned status " + status.toString());
4088        if (status != JFmTxStatus.PENDING) {
4089            Log.e(TAG, "mJFmTx.txSetRdsECC returned status " + status.toString());
4090            return false;
4091        }
4092        return true;
4093
4094    }
4095
4096
4097    public boolean  txGetRdsECC( ){
4098        Log.i(TAG, "StubFmService:txGetRdsECC  ");
4099
4100        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4101                "Need FMRX_ADMIN_PERM permission");
4102
4103
4104        JFmTxStatus status = mJFmTx.txGetRdsECC();
4105
4106        Log.i(TAG, "mJFmTx.txGetRdsECC returned status " + status.toString());
4107        if (status != JFmTxStatus.PENDING) {
4108            Log.e(TAG, "mJFmTx.txGetRdsECC returned status " + status.toString());
4109            return false;
4110        }
4111        return true;
4112
4113    }
4114
4115
4116
4117    public boolean  txSetMonoStereoMode(int mode){
4118        Log.i(TAG, "StubFmService:txSetMonoStereoMode  ");
4119
4120        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4121                "Need FMRX_ADMIN_PERM permission");
4122
4123
4124        JFmTx.JFmTxMonoStereoMode lMode = JFmUtils.getEnumConst(
4125                JFmTx.JFmTxMonoStereoMode.class, mode);
4126        if (lMode == null) {
4127            Log.e(TAG, "StubFmService:txSetPreEmphasisFilter invalid  lMode " + lMode);
4128            return false;
4129        }
4130
4131        JFmTxStatus status = mJFmTx.txSetMonoStereoMode(lMode);
4132
4133        Log.i(TAG, "mJFmTx.txSetMonoStereoMode returned status " + status.toString());
4134        if (status != JFmTxStatus.PENDING) {
4135            Log.e(TAG, "mJFmTx.txSetMonoStereoMode returned status " + status.toString());
4136            return false;
4137        }
4138        return true;
4139
4140    }
4141
4142
4143       public boolean txGetMonoStereoMode(){
4144        Log.i(TAG, "StubFmService:txGetMonoStereoMode  ");
4145
4146        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4147                "Need FMRX_ADMIN_PERM permission");
4148
4149
4150        JFmTxStatus status = mJFmTx.txGetMonoStereoMode();
4151
4152        Log.i(TAG, "mJFmTx.txGetMonoStereoMode returned status " + status.toString());
4153        if (status != JFmTxStatus.PENDING) {
4154            Log.e(TAG, "mJFmTx.txGetMonoStereoMode returned status " + status.toString());
4155            return false;
4156        }
4157        return true;
4158
4159    }
4160
4161
4162       public boolean txSetPreEmphasisFilter(int preEmpFilter) {
4163        Log.i(TAG, "StubFmService:txSetPreEmphasisFilter  ");
4164
4165        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4166                "Need FMRX_ADMIN_PERM permission");
4167
4168
4169        JFmTx.JFmTxEmphasisFilter lPreEmpFilter = JFmUtils.getEnumConst(
4170                JFmTx.JFmTxEmphasisFilter.class, preEmpFilter);
4171        if (lPreEmpFilter == null) {
4172            Log.e(TAG, "StubFmService:txSetPreEmphasisFilter invalid  lPreEmpFilter " + lPreEmpFilter);
4173            return false;
4174        }
4175
4176        JFmTxStatus status = mJFmTx.txSetPreEmphasisFilter(lPreEmpFilter);
4177
4178        Log.i(TAG, "mJFmTx.txSetPreEmphasisFilter returned status " + status.toString());
4179        if (status != JFmTxStatus.PENDING) {
4180            Log.e(TAG, "mJFmTx.txSetPreEmphasisFilter returned status " + status.toString());
4181            return false;
4182        }
4183        return true;
4184
4185    }
4186
4187
4188       public boolean txGetPreEmphasisFilter( ) {
4189        Log.i(TAG, "StubFmService:txGetPreEmphasisFilter  ");
4190
4191        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4192                "Need FMRX_ADMIN_PERM permission");
4193
4194
4195        JFmTxStatus status = mJFmTx.txGetPreEmphasisFilter();
4196
4197        Log.i(TAG, "mJFmTx.txGetPreEmphasisFilter returned status " + status.toString());
4198        if (status != JFmTxStatus.PENDING) {
4199            Log.e(TAG, "mJFmTx.txGetPreEmphasisFilter returned status " + status.toString());
4200            return false;
4201        }
4202        return true;
4203
4204    }
4205
4206
4207
4208    public boolean  txSetMuteMode(int muteMode){
4209        Log.i(TAG, "StubFmService:txSetMuteMode  ");
4210
4211        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4212                "Need FMRX_ADMIN_PERM permission");
4213
4214
4215        JFmTx.JFmTxMuteMode lMuteMode = JFmUtils.getEnumConst(
4216                JFmTx.JFmTxMuteMode.class, muteMode);
4217        if (lMuteMode == null) {
4218            Log.e(TAG, "StubFmService:txSetMuteMode invalid  lMuteMode " + lMuteMode);
4219            return false;
4220        }
4221        JFmTxStatus status = mJFmTx.txSetMuteMode(lMuteMode);
4222
4223        Log.i(TAG, "mJFmTx.txSetMuteMode returned status " + status.toString());
4224        if (status != JFmTxStatus.PENDING) {
4225            Log.e(TAG, "mJFmTx.txSetMuteMode returned status " + status.toString());
4226            return false;
4227        }
4228        return true;
4229
4230    }
4231
4232
4233    public boolean  txGetMuteMode( ){
4234        Log.i(TAG, "StubFmService:txGetMuteMode  ");
4235
4236        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4237                "Need FMRX_ADMIN_PERM permission");
4238
4239        JFmTxStatus status = mJFmTx.txGetMuteMode();
4240
4241        Log.i(TAG, "mJFmTx.txGetMuteMode returned status " + status.toString());
4242        if (status != JFmTxStatus.PENDING) {
4243            Log.e(TAG, "mJFmTx.txGetMuteMode returned status " + status.toString());
4244            return false;
4245        }
4246        return true;
4247
4248    }
4249
4250
4251
4252    public boolean  txSetRdsAfCode(int afCode) {
4253        Log.i(TAG, "StubFmService:txSetRdsAfCode  ");
4254
4255        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4256                "Need FMRX_ADMIN_PERM permission");
4257
4258
4259        JFmTxStatus status = mJFmTx.txSetRdsAfCode(afCode);
4260
4261        Log.i(TAG, "mJFmTx.txSetRdsAfCode returned status " + status.toString());
4262        if (status != JFmTxStatus.PENDING) {
4263            Log.e(TAG, "mJFmTx.txSetRdsAfCode returned status " + status.toString());
4264            return false;
4265        }
4266        return true;
4267
4268    }
4269
4270
4271    public boolean  txGetRdsAfCode( ) {
4272        Log.i(TAG, "StubFmService:txGetRdsAfCode  ");
4273
4274        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4275                "Need FMRX_ADMIN_PERM permission");
4276
4277
4278        JFmTxStatus status = mJFmTx.txGetRdsAfCode();
4279
4280        Log.i(TAG, "mJFmTx.txGetRdsAfCode returned status " + status.toString());
4281        if (status != JFmTxStatus.PENDING) {
4282            Log.e(TAG, "mJFmTx.txGetRdsAfCode returned status " + status.toString());
4283            return false;
4284        }
4285        return true;
4286
4287    }
4288
4289
4290
4291    public boolean  txSetRdsPiCode(int piCode){
4292        Log.i(TAG, "StubFmService:txSetRdsPiCode  ");
4293
4294        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4295                "Need FMRX_ADMIN_PERM permission");
4296
4297        JFmTx.JFmTxRdsPiCode lPiCode = new JFmTx.JFmTxRdsPiCode(piCode);
4298        if (lPiCode == null) {
4299            Log.e(TAG, "StubFmService:txSetRdsPiCode invalid  lPiCode " + lPiCode);
4300            return false;
4301        }
4302
4303        JFmTxStatus status = mJFmTx.txSetRdsPiCode(lPiCode);
4304
4305        Log.i(TAG, "mJFmTx.txSetRdsPiCode returned status " + status.toString());
4306        if (status != JFmTxStatus.PENDING) {
4307            Log.e(TAG, "mJFmTx.txSetRdsPiCode returned status " + status.toString());
4308            return false;
4309        }
4310        return true;
4311
4312    }
4313
4314
4315    public boolean  txGetRdsPiCode( ){
4316        Log.i(TAG, "StubFmService:txGetRdsPiCode  ");
4317
4318        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4319                "Need FMRX_ADMIN_PERM permission");
4320
4321        JFmTxStatus status = mJFmTx.txGetRdsPiCode();
4322
4323        Log.i(TAG, "mJFmTx.txGetRdsPiCode returned status " + status.toString());
4324        if (status != JFmTxStatus.PENDING) {
4325            Log.e(TAG, "mJFmTx.txGetRdsPiCode returned status " + status.toString());
4326            return false;
4327        }
4328        return true;
4329
4330    }
4331
4332
4333
4334    public boolean  txSetRdsPtyCode(int ptyCode) {
4335        Log.i(TAG, "StubFmService:txSetRdsPtyCode  ");
4336
4337        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4338                "Need FMRX_ADMIN_PERM permission");
4339
4340
4341        JFmTx.JFmTxRdsPtyCode lPtyCode = new JFmTx.JFmTxRdsPtyCode(ptyCode);
4342        if (lPtyCode == null) {
4343            Log.e(TAG, "StubFmService:txSetRdsPtyCode invalid ptyCode " + lPtyCode);
4344            return false;
4345        }
4346
4347        JFmTxStatus status = mJFmTx.txSetRdsPtyCode(lPtyCode);
4348
4349        Log.i(TAG, "mJFmTx.txSetRdsPtyCode returned status " + status.toString());
4350        if (status != JFmTxStatus.PENDING) {
4351            Log.e(TAG, "mJFmTx.txSetRdsPtyCode returned status " + status.toString());
4352            return false;
4353        }
4354        return true;
4355
4356    }
4357
4358
4359    public boolean  txGetRdsPtyCode( ) {
4360        Log.i(TAG, "StubFmService:txGetRdsPtyCode  ");
4361
4362        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4363                "Need FMRX_ADMIN_PERM permission");
4364
4365        JFmTxStatus status = mJFmTx.txGetRdsPtyCode();
4366
4367        Log.i(TAG, "mJFmTx.txGetRdsPtyCode returned status " + status.toString());
4368        if (status != JFmTxStatus.PENDING) {
4369            Log.e(TAG, "mJFmTx.txGetRdsPtyCode returned status " + status.toString());
4370            return false;
4371        }
4372        return true;
4373
4374    }
4375
4376
4377
4378
4379    public boolean  txSetRdsTextRepertoire(int repertoire){
4380        Log.i(TAG, "StubFmService:txSetRdsTextRepertoire  ");
4381
4382        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4383                "Need FMRX_ADMIN_PERM permission");
4384
4385        JFmTx.JFmTxRepertoire lRepertoire = JFmUtils.getEnumConst(
4386                JFmTx.JFmTxRepertoire.class, repertoire);
4387        if (lRepertoire == null) {
4388            Log.e(TAG, "StubFmService:txSetRdsTextRepertoire invalid  lRepertoire " + lRepertoire);
4389            return false;
4390        }
4391
4392
4393        JFmTxStatus status = mJFmTx.txSetRdsTextRepertoire(lRepertoire);
4394
4395        Log.i(TAG, "mJFmTx.txSetRdsTextRepertoire returned status " + status.toString());
4396        if (status != JFmTxStatus.PENDING) {
4397            Log.e(TAG, "mJFmTx.txSetRdsTextRepertoire returned status " + status.toString());
4398            return false;
4399        }
4400        return true;
4401
4402    }
4403
4404
4405
4406    public boolean  txGetRdsTextRepertoire( ){
4407        Log.i(TAG, "StubFmService:txGetRdsTextRepertoire  ");
4408
4409        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4410                "Need FMRX_ADMIN_PERM permission");
4411
4412        JFmTxStatus status = mJFmTx.txGetRdsTextRepertoire();
4413
4414        Log.i(TAG, "mJFmTx.txGetRdsTextRepertoire returned status " + status.toString());
4415        if (status != JFmTxStatus.PENDING) {
4416            Log.e(TAG, "mJFmTx.txGetRdsTextRepertoire returned status " + status.toString());
4417            return false;
4418        }
4419        return true;
4420
4421    }
4422
4423
4424
4425
4426    public boolean  txSetRdsPsDisplayMode(int dispalyMode) {
4427        Log.i(TAG, "StubFmService:txSetRdsPsDisplayMode  ");
4428
4429        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4430                "Need FMRX_ADMIN_PERM permission");
4431
4432        JFmTx.JFmRdsPsDisplayMode lPsDisplayMode = JFmUtils.getEnumConst(
4433                JFmTx.JFmRdsPsDisplayMode.class, dispalyMode);
4434        if (lPsDisplayMode == null) {
4435            Log.e(TAG, "StubFmService:txSetRdsPsDisplayMode invalid  lPsDisplayMode " + lPsDisplayMode);
4436            return false;
4437        }
4438
4439        JFmTxStatus status = mJFmTx.txSetRdsPsDisplayMode(lPsDisplayMode);
4440
4441        Log.i(TAG, "mJFmTx.txSetRdsPsDisplayMode returned status " + status.toString());
4442        if (status != JFmTxStatus.PENDING) {
4443            Log.e(TAG, "mJFmTx.txSetRdsPsDisplayMode returned status " + status.toString());
4444            return false;
4445        }
4446        return true;
4447
4448    }
4449
4450
4451
4452    public boolean  txGetRdsPsDisplayMode( ) {
4453        Log.i(TAG, "StubFmService:txGetRdsPsDisplayMode  ");
4454
4455        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4456                "Need FMRX_ADMIN_PERM permission");
4457
4458        JFmTxStatus status = mJFmTx.txGetRdsPsDisplayMode();
4459
4460        Log.i(TAG, "mJFmTx.txGetRdsPsDisplayMode returned status " + status.toString());
4461        if (status != JFmTxStatus.PENDING) {
4462            Log.e(TAG, "mJFmTx.txGetRdsPsDisplayMode returned status " + status.toString());
4463            return false;
4464        }
4465        return true;
4466
4467    }
4468
4469
4470
4471    public boolean  txSetRdsPsScrollSpeed(int scrollSpeed) {
4472        Log.i(TAG, "StubFmService:txSetRdsPsScrollSpeed  ");
4473
4474        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4475                "Need FMRX_ADMIN_PERM permission");
4476
4477
4478        JFmTxStatus status = mJFmTx.txSetRdsPsScrollSpeed(scrollSpeed);
4479
4480        Log.i(TAG, "mJFmTx.txSetRdsPsScrollSpeed returned status " + status.toString());
4481        if (status != JFmTxStatus.PENDING) {
4482            Log.e(TAG, "mJFmTx.txSetRdsPsScrollSpeed returned status " + status.toString());
4483            return false;
4484        }
4485        return true;
4486
4487    }
4488
4489
4490
4491    public boolean  txGetRdsPsScrollSpeed( ) {
4492        Log.i(TAG, "StubFmService:txGetRdsPsScrollSpeed  ");
4493
4494        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4495                "Need FMRX_ADMIN_PERM permission");
4496
4497
4498        JFmTxStatus status = mJFmTx.txGetRdsPsScrollSpeed();
4499
4500        Log.i(TAG, "mJFmTx.txGetRdsPsScrollSpeed returned status " + status.toString());
4501        if (status != JFmTxStatus.PENDING) {
4502            Log.e(TAG, "mJFmTx.txGetRdsPsScrollSpeed returned status " + status.toString());
4503            return false;
4504        }
4505        return true;
4506
4507    }
4508
4509    public boolean  txSetRdsTextRtMsg(int msgType, String msg, int msgLength){
4510        Log.i(TAG, "StubFmService:txSetRdsTextRtMsg  ");
4511
4512        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4513                "Need FMRX_ADMIN_PERM permission");
4514
4515        JFmTx.JFmRdsRtMsgType lMsgType = JFmUtils.getEnumConst(
4516                JFmTx.JFmRdsRtMsgType.class, msgType);
4517        if (lMsgType == null) {
4518            Log.e(TAG, "StubFmService:txSetRdsTextRtMsg invalid  lMsgType " + lMsgType);
4519            return false;
4520        }
4521        JFmTxStatus status = mJFmTx.txSetRdsTextRtMsg(lMsgType,msg,msgLength);
4522
4523        Log.i(TAG, "mJFmTx.txSetRdsTextRtMsg returned status " + status.toString());
4524        if (status != JFmTxStatus.PENDING) {
4525            Log.e(TAG, "mJFmTx.txSetRdsTextRtMsg returned status " + status.toString());
4526            return false;
4527        }
4528        return true;
4529
4530    }
4531
4532
4533    public boolean  txGetRdsTextRtMsg(){
4534        Log.i(TAG, "StubFmService:txGetRdsTextRtMsg  ");
4535
4536        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4537                "Need FMRX_ADMIN_PERM permission");
4538
4539        JFmTxStatus status = mJFmTx.txGetRdsTextRtMsg();
4540
4541        Log.i(TAG, "mJFmTx.txGetRdsTextRtMsg returned status " + status.toString());
4542        if (status != JFmTxStatus.PENDING) {
4543            Log.e(TAG, "mJFmTx.txGetRdsTextRtMsg returned status " + status.toString());
4544            return false;
4545        }
4546        return true;
4547
4548    }
4549
4550
4551
4552
4553    public boolean  txSetRdsTransmittedGroupsMask(long rdsTrasmittedGrpMask){
4554        Log.i(TAG, "StubFmService:txSetRdsTransmittedGroupsMask  ");
4555
4556        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4557                "Need FMRX_ADMIN_PERM permission");
4558
4559
4560        JFmTxStatus status = mJFmTx.txSetRdsTransmittedGroupsMask(rdsTrasmittedGrpMask);
4561
4562        Log.i(TAG, "mJFmTx.txSetRdsTransmittedGroupsMask returned status " + status.toString());
4563        if (status != JFmTxStatus.PENDING) {
4564            Log.e(TAG, "mJFmTx.txSetRdsTransmittedGroupsMask returned status " + status.toString());
4565            return false;
4566        }
4567        return true;
4568
4569    }
4570
4571
4572
4573    public boolean  txGetRdsTransmittedGroupsMask(){
4574        Log.i(TAG, "StubFmService:txGetRdsTransmittedGroupsMask  ");
4575
4576        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4577                "Need FMRX_ADMIN_PERM permission");
4578
4579
4580        JFmTxStatus status = mJFmTx.txGetRdsTransmittedGroupsMask();
4581
4582        Log.i(TAG, "mJFmTx.txGetRdsTransmittedGroupsMask returned status " + status.toString());
4583        if (status != JFmTxStatus.PENDING) {
4584            Log.e(TAG, "mJFmTx.txGetRdsTransmittedGroupsMask returned status " + status.toString());
4585            return false;
4586        }
4587        return true;
4588
4589    }
4590
4591
4592
4593
4594    public boolean  txSetRdsTrafficCodes(int taCode, int tpCode){
4595        Log.i(TAG, "StubFmService:txSetRdsTrafficCodes  ");
4596
4597        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4598                "Need FMRX_ADMIN_PERM permission");
4599
4600
4601        JFmTx.JFmTaCode lTaCode = JFmUtils.getEnumConst(
4602                JFmTx.JFmTaCode.class, taCode);
4603        if (lTaCode == null) {
4604            Log.e(TAG, "StubFmService:txChangeAudioSource invalid  lTaCode " + lTaCode);
4605            return false;
4606        }
4607
4608        JFmTx.JFmTpCode lTpCode = JFmUtils.getEnumConst(
4609                JFmTx.JFmTpCode.class, tpCode);
4610        if (lTaCode == null) {
4611            Log.e(TAG, "StubFmService:txChangeAudioSource invalid  lTpCode " + lTpCode);
4612            return false;
4613        }
4614
4615        JFmTxStatus status = mJFmTx.txSetRdsTrafficCodes(lTaCode,lTpCode);
4616
4617        Log.i(TAG, "mJFmTx.txSetRdsTrafficCodes returned status " + status.toString());
4618        if (status != JFmTxStatus.PENDING) {
4619            Log.e(TAG, "mJFmTx.txSetRdsTrafficCodes returned status " + status.toString());
4620            return false;
4621        }
4622        return true;
4623
4624    }
4625
4626
4627
4628    public boolean  txGetRdsTrafficCodes(){
4629        Log.i(TAG, "StubFmService:txGetRdsTrafficCodes  ");
4630
4631        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4632                "Need FMRX_ADMIN_PERM permission");
4633
4634
4635        JFmTxStatus status = mJFmTx.txGetRdsTrafficCodes();
4636
4637        Log.i(TAG, "mJFmTx.txGetRdsTrafficCodes returned status " + status.toString());
4638        if (status != JFmTxStatus.PENDING) {
4639            Log.e(TAG, "mJFmTx.txGetRdsTrafficCodes returned status " + status.toString());
4640            return false;
4641        }
4642        return true;
4643
4644    }
4645
4646
4647
4648    public boolean  txSetRdsMusicSpeechFlag(int musicSpeechFlag)  {
4649        Log.i(TAG, "StubFmService:txSetRdsMusicSpeechFlag  ");
4650
4651        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4652                "Need FMRX_ADMIN_PERM permission");
4653
4654        JFmTx.JFmMusicSpeechFlag lMusicSpeechFlag = JFmUtils.getEnumConst(
4655                JFmTx.JFmMusicSpeechFlag.class, musicSpeechFlag);
4656        if (lMusicSpeechFlag == null) {
4657            Log.e(TAG, "StubFmService:txChangeAudioSource invalid  lMusicSpeechFlag " + lMusicSpeechFlag);
4658            return false;
4659        }
4660
4661        JFmTxStatus status = mJFmTx.txSetRdsMusicSpeechFlag(lMusicSpeechFlag);
4662
4663        Log.i(TAG, "mJFmTx.txSetRdsMusicSpeechFlag returned status " + status.toString());
4664        if (status != JFmTxStatus.PENDING) {
4665            Log.e(TAG, "mJFmTx.txSetRdsMusicSpeechFlag returned status " + status.toString());
4666            return false;
4667        }
4668        return true;
4669
4670    }
4671
4672
4673
4674    public boolean  txGetRdsMusicSpeechFlag( )  {
4675        Log.i(TAG, "StubFmService:txGetRdsMusicSpeechFlag  ");
4676
4677        mContext.enforceCallingOrSelfPermission(FMRX_ADMIN_PERM,
4678                "Need FMRX_ADMIN_PERM permission");
4679
4680        JFmTxStatus status = mJFmTx.txGetRdsMusicSpeechFlag();
4681
4682        Log.i(TAG, "mJFmTx.txGetRdsMusicSpeechFlag returned status " + status.toString());
4683        if (status != JFmTxStatus.PENDING) {
4684            Log.e(TAG, "mJFmTx.txGetRdsMusicSpeechFlag returned status " + status.toString());
4685            return false;
4686        }
4687        return true;
4688
4689    }
4690
4691
4692    /*************************************************************************************************
4693     * Implementation of IFmRadio IPC interface
4694     *************************************************************************************************/
4695
4696    public int txGetFMState() {
4697        mContext.enforceCallingOrSelfPermission(FMRX_PERM,
4698                "Need FMRX_PERM permission");
4699        return mTxState;
4700    }
4701
4702
4703
4704    /*************************************************************************************************
4705     * JFmRxlback interface for receiving its events and for broadcasting them
4706     * as intents
4707     *************************************************************************************************/
4708
4709    public void fmRxRawRDS(JFmRx context, JFmRxStatus status,
4710            JFmRx.JFmRxRdsGroupTypeMask bitInMaskValue, byte[] groupData)
4711
4712    {
4713        Log.i(TAG, "StubFmService:fmRxRawRDS ");
4714        Log.d(TAG, "StubFmService:fmRxRawRDS status = " + status.toString());
4715        Log.d(TAG, "StubFmService:fmRxRawRDS bitInMaskValue = "
4716                + bitInMaskValue.getValue());
4717
4718    }
4719
4720    public void fmRxRadioText(JFmRx context, JFmRxStatus status,
4721            boolean resetDisplay, byte[] msg1, int len, int startIndex,
4722            JFmRx.JFmRxRepertoire repertoire) {
4723        Log.i(TAG, "StubFmService:fmRxRadioText ");
4724        Log.d(TAG,
4725                "StubFmService:fmRxRadioText status = , msg1 =  ,len =  , startIndex  = "
4726                        + status.toString() + " " +" " + len
4727                        + " " + startIndex);
4728        Log.d(TAG, "StubFmService:sending intent RDS_TEXT_CHANGED_ACTION");
4729
4730        Intent intentRds = new Intent(FmRadioIntent.RDS_TEXT_CHANGED_ACTION);
4731        if (FM_SEND_RDS_IN_BYTEARRAY == true) {
4732            Bundle b = new Bundle();
4733            b.putByteArray(FmRadioIntent.RDS, msg1);// Send Byte Array to App
4734            intentRds.putExtras(b);
4735        } else {
4736            /*
4737             *Convert the received Byte Array to
4738             * appropriate String
4739             */
4740            String radioTextString = findFromLookupTable(msg1, repertoire);
4741            intentRds.putExtra(FmRadioIntent.RADIOTEXT_CONVERTED,
4742                    radioTextString);// converted String
4743        }
4744
4745        intentRds.putExtra(FmRadioIntent.STATUS, status.getValue());// Status
4746
4747        mContext.sendBroadcast(intentRds, FMRX_PERM);
4748    }
4749
4750    public void fmRxPiCodeChanged(JFmRx context, JFmRxStatus status,
4751            JFmRx.JFmRxRdsPiCode pi) {
4752
4753        Log.i(TAG, "StubFmService:fmRxPiCodeChanged ");
4754        Log.d(TAG, "StubFmService:fmRxPiCodeChanged status = "
4755                + status.toString());
4756        Log.d(TAG, "StubFmService:fmRxPiCodeChanged pi = " + pi.getValue());
4757
4758        if (status == JFmRxStatus.SUCCESS) {
4759            /* simple mechanism to prevent displaying repetitious messages */
4760            if (pi.getValue() != last_msg_printed) {
4761                last_msg_printed = pi.getValue();
4762                Log.d(TAG, "StubFmService:sending intent PI_CODE_CHANGED_ACTION");
4763                Intent intentPi = new Intent(
4764                        FmRadioIntent.PI_CODE_CHANGED_ACTION);
4765                intentPi.putExtra(FmRadioIntent.PI, pi.getValue());
4766                intentPi.putExtra(FmRadioIntent.STATUS, status.getValue());
4767                mContext.sendBroadcast(intentPi, FMRX_PERM);
4768            }
4769        }
4770    }
4771
4772    public void fmRxPtyCodeChanged(JFmRx context, JFmRxStatus status,
4773            JFmRx.JFmRxRdsPtyCode pty) {
4774
4775        Log.i(TAG, "StubFmService:fmRxPtyCodeChanged ");
4776        Log.d(TAG, "StubFmService:fmRxPtyCodeChanged status = "
4777                + status.toString());
4778        Log.d(TAG, "StubFmService:fmRxPtyCodeChanged pty = " + pty.getValue());
4779
4780    }
4781
4782    public void fmRxPsChanged(JFmRx context, JFmRxStatus status,
4783            JFmRx.JFmRxFreq frequency, byte[] name,
4784            JFmRx.JFmRxRepertoire repertoire) {
4785        Log.i(TAG, "StubFmService:fmRxPsChanged ");
4786        Log.d(TAG, "StubFmService:fmRxPsChanged status = " + status.toString());
4787        Log.d(TAG, "StubFmService:fmRxPsChanged frequency = "
4788                + frequency.getValue());
4789
4790        Log.d(TAG, "StubFmService:fmRxPsChanged repertoire = "
4791                + repertoire.getValue());
4792        Log.d(TAG, "StubFmService:sending intent PS_CHANGED_ACTION");
4793
4794
4795        Intent intentPs = new Intent(FmRadioIntent.PS_CHANGED_ACTION);
4796        if (FM_SEND_RDS_IN_BYTEARRAY == true) {
4797            Bundle b = new Bundle();
4798            b.putByteArray(FmRadioIntent.PS, name);// Send Byte Array to App
4799            intentPs.putExtras(b);
4800        } else {
4801            /*
4802             * Convert the received Byte Array to
4803             * appropriate String Broadcast the PS data Byte Array, Converted
4804             * string to App
4805             */
4806
4807            String psString = findFromLookupTable(name, repertoire);
4808            Log.i(TAG, "fmRxPsChanged--> psString = " + psString);
4809            intentPs.putExtra(FmRadioIntent.PS_CONVERTED, psString);// converted
4810            // PS
4811            // String
4812        }
4813
4814        intentPs.putExtra(FmRadioIntent.REPERTOIRE, repertoire.getValue());// repertoire
4815        intentPs.putExtra(FmRadioIntent.STATUS, status.getValue());// status
4816
4817        mContext.sendBroadcast(intentPs, FMRX_PERM);
4818
4819    }
4820
4821    public void fmRxMonoStereoModeChanged(JFmRx context, JFmRxStatus status,
4822            JFmRx.JFmRxMonoStereoMode mode) {
4823        Log.e(TAG, "StubFmService:fmRxMonoStereoModeChanged status = "
4824                + status.toString());
4825
4826        Log.i(TAG, "StubFmService:fmRxMonoStereoModeChanged ");
4827        Log.d(TAG, "StubFmService:fmRxMonoStereoModeChanged status = "
4828                + status.toString());
4829        Log.d(TAG, "StubFmService:fmRxMonoStereoModeChanged mode = "
4830                + mode.getValue());
4831
4832        /* simple mechanism to prevent displaying repetitious messages */
4833        if (mode == mMode)
4834            return;
4835
4836        mMode = mode;
4837        switch (mMode) {
4838        case FM_RX_MONO:
4839            Log.e(TAG, "Mono Mode");
4840            break;
4841        case FM_RX_STEREO:
4842            Log.e(TAG, "Stereo Mode");
4843            break;
4844        default:
4845            Log.e(TAG, "Illegal stereo mode received from stack: " + mode);
4846            break;
4847        }
4848        Log
4849                .d(TAG,
4850                        "StubFmService:sending intent DISPLAY_MODE_MONO_STEREO_ACTION");
4851        Intent intentMode = new Intent(
4852                FmRadioIntent.DISPLAY_MODE_MONO_STEREO_ACTION);
4853        intentMode.putExtra(FmRadioIntent.MODE_MONO_STEREO, mode.getValue());
4854        intentMode.putExtra(FmRadioIntent.STATUS, status.getValue());
4855        mContext.sendBroadcast(intentMode, FMRX_PERM);
4856    }
4857
4858    public void fmRxAudioPathChanged(JFmRx context, JFmRxStatus status) {
4859
4860        Log.i(TAG, "StubFmService:fmRxAudioPathChanged ");
4861        Log.d(TAG, "StubFmService:fmRxAudioPathChanged status = "
4862                + status.toString());
4863        Log.d(TAG, "StubFmService:sending intent AUDIO_PATH_CHANGED_ACTION");
4864
4865        Intent intentPath = new Intent(
4866                FmRadioIntent.AUDIO_PATH_CHANGED_ACTION);
4867        intentPath.putExtra(FmRadioIntent.STATUS, status.getValue());
4868        mContext.sendBroadcast(intentPath, FMRX_PERM);
4869    }
4870
4871    public void fmRxAfSwitchFreqFailed(JFmRx context, JFmRxStatus status,
4872            JFmRx.JFmRxRdsPiCode pi, JFmRx.JFmRxFreq tunedFreq,
4873            JFmRx.JFmRxAfFreq afFreq) {
4874
4875        Log.i(TAG, "StubFmService:fmRxAfSwitchFreqFailed ");
4876        Log.d(TAG, "StubFmService:fmRxAfSwitchFreqFailed status = "
4877                + status.toString());
4878        Log.d(TAG, "StubFmService:fmRxAfSwitchFreqFailed pi = " + pi.getValue());
4879        Log.d(TAG, "StubFmService:fmRxAfSwitchFreqFailed tunedFreq = "
4880                + tunedFreq.getValue());
4881        Log.d(TAG, "StubFmService:fmRxAfSwitchFreqFailed afFreq = "
4882                + afFreq.getAfFreq());
4883
4884    }
4885
4886    public void fmRxAfSwitchStart(JFmRx context, JFmRxStatus status,
4887            JFmRx.JFmRxRdsPiCode pi, JFmRx.JFmRxFreq tunedFreq,
4888            JFmRx.JFmRxAfFreq afFreq) {
4889
4890        Log.i(TAG, "StubFmService:fmRxAfSwitchStart ");
4891        Log.d(TAG, "StubFmService:fmRxAfSwitchStart status = "
4892                + status.toString());
4893        Log.d(TAG, "StubFmService:fmRxAfSwitchStart pi = " + pi.getValue());
4894        Log.d(TAG, "StubFmService:fmRxAfSwitchStart tunedFreq = "
4895                + tunedFreq.getValue());
4896        Log.d(TAG, "StubFmService:fmRxAfSwitchStart afFreq = "
4897                + afFreq.getAfFreq());
4898
4899    }
4900
4901    public void fmRxAfSwitchComplete(JFmRx context, JFmRxStatus status,
4902            JFmRx.JFmRxRdsPiCode pi, JFmRx.JFmRxFreq tunedFreq,
4903            JFmRx.JFmRxAfFreq afFreq) {
4904
4905        Log.i(TAG, "StubFmService:fmRxAfSwitchComplete ");
4906        Log.d(TAG, "StubFmService:fmRxAfSwitchComplete status = "
4907                + status.toString());
4908        Log.d(TAG, "StubFmService:fmRxAfSwitchComplete pi = " + pi.getValue());
4909        Log.d(TAG, "StubFmService:fmRxAfSwitchComplete tunedFreq = "
4910                + tunedFreq.getValue());
4911        Log.d(TAG, "StubFmService:fmRxAfSwitchComplete afFreq = "
4912                + afFreq.getAfFreq());
4913
4914    }
4915
4916    public void fmRxAfListChanged(JFmRx context, JFmRxStatus status,
4917            JFmRx.JFmRxRdsPiCode pi, int[] afList,
4918            JFmRx.JFmRxAfListSize afListSize) {
4919
4920        Log.i(TAG, "StubFmService:fmRxAfListChanged ");
4921        Log.d(TAG, "StubFmService:fmRxAfListChanged status = "
4922                + status.toString());
4923        Log.d(TAG, "StubFmService:fmRxAfListChanged pi = " + pi.getValue());
4924        Log.d(TAG, "StubFmService:fmRxAfListChanged afListSize = "
4925                + afListSize.getValue());
4926
4927    }
4928
4929    public void fmRxCompleteScanDone(JFmRx context, JFmRxStatus status,
4930            int numOfChannels, int[] channelsData) {
4931
4932        mIsCompleteScanInProgress = false;
4933
4934        Log.i(TAG, "StubFmService:fmRxCompleteScanDone ");
4935        Log.d(TAG, "StubFmService:fmRxCompleteScanDone status = "
4936                + status.toString());
4937        Log.d(TAG, "StubFmService:fmRxCompleteScanDone numOfChannels = "
4938                + numOfChannels);
4939        for (int i = 0; i < numOfChannels; i++)
4940            Log.d(TAG, "StubFmService:fmRxCompleteScanDone channelsData = " + i
4941                    + "  " + +channelsData[i]);
4942
4943        Log.i(TAG, "StubFmService:COMPLETE_SCAN_DONE_ACTION ");
4944        Intent intentscan = new Intent(
4945                FmRadioIntent.COMPLETE_SCAN_DONE_ACTION);
4946        Bundle b = new Bundle();
4947        b.putIntArray(FmRadioIntent.SCAN_LIST, channelsData);
4948        b.putInt(FmRadioIntent.STATUS, status.getValue());
4949        b.putInt(FmRadioIntent.SCAN_LIST_COUNT, numOfChannels);
4950        intentscan.putExtras(b);
4951        mContext.sendBroadcast(intentscan, FMRX_PERM);
4952        }
4953
4954    public  void fmRxCmdEnable(JFmRx context, JFmRxStatus status, int command,
4955            long value) {
4956
4957        Log.i(TAG, "StubFmService:fmRxCmdEnable ");
4958        Log.d(TAG, "  fmRxCmdEnable ( command: , status: , value: )" + command
4959                + "" + status + "" + value);
4960
4961        if (status == JFmRxStatus.SUCCESS) {
4962            updateEnableConfiguration();
4963        }
4964
4965        else {
4966
4967            Log.e(TAG, "  fmRxCmdEnable fail (status: " + status + ", value: "
4968                    + value);
4969            mRxState = STATE_DEFAULT;
4970        }
4971        int RXicon = R.drawable.rxradio;
4972        sendNotificationRX();
4973        Log.d(TAG, "Sending restore values intent");
4974            Intent restoreValuesIntent = new Intent(FM_RESTORE_VALUES);
4975            mContext.sendBroadcast(restoreValuesIntent);
4976        enableIntent(status);
4977    }
4978
4979    public synchronized void fmRxCmdDisable(JFmRx context, JFmRxStatus status, int command,
4980            long value) {
4981
4982        Log.i(TAG, "StubFmService:fmRxCmdDisable ");
4983        Log.d(TAG, "  fmRxCmdDisable ( command: , status: , value: )" + command
4984                + "" + status + "" + value);
4985
4986    if (status != JFmRxStatus.SUCCESS) {
4987            Log.e(TAG, "StubFmService:fmRxCmdDisable failed ");
4988            return ;
4989        }
4990        destroyJFmRx();
4991            mRxState = STATE_DISABLED;
4992             int off =0;
4993              /* L27 Specific */
4994             enableRx(off);
4995	     /* Release the wake lock
4996	      * so that device can go into
4997	      * OFF mode
4998	      */
4999	     if ((mWakeLock != null) && (mWakeLock.isHeld()))
5000		     mWakeLock.release();
5001	     Log.d(TAG, "FM RX powered on mRxState " + mRxState);
5002        Log.d(TAG, "StubFmService:sending intent FM_DISABLED_ACTION");
5003
5004        cancelNotification(FM_RX_NOTIFICATION_ID);
5005
5006            if (mFmPauseResume == STATE_PAUSE) {
5007                ;
5008            } else {
5009                if (DBG)
5010                    Log
5011                            .d(TAG,
5012                                    "StubFmRxService:sending intent FM_DISABLED_ACTION");
5013        Intent intentDisable = new Intent(FmRadioIntent.FM_DISABLED_ACTION);
5014            intentDisable.putExtra(FmRadioIntent.STATUS, status.getValue());
5015                mContext.sendBroadcast(intentDisable, FMRX_PERM);
5016            }
5017
5018    }
5019
5020    public void fmRxCmdDestroy(JFmRx context, JFmRxStatus status, int command,
5021            long value) {
5022
5023        Log.i(TAG, "StubFmService:fmRxCmdDestroy ");
5024        Log.d(TAG, "  fmRxCmdDestroy ( command: , status: , value: )" + command
5025                + "" + status + "" + value);
5026    }
5027
5028    public void fmRxCmdDisableAudio(JFmRx context, JFmRxStatus status,
5029            int command, long value) {
5030
5031        Log.i(TAG, "StubFmService:fmRxCmdDisableAudio ");
5032        Log.d(TAG, "  fmRxCmdDisableAudio ( command: , status: , value: )"
5033                + command + "" + status + "" + value);
5034    }
5035
5036    public  void fmRxCmdGetRdsAfSwitchMode(JFmRx context, JFmRxStatus status,
5037            int command, long value) {
5038
5039        Log.i(TAG, "StubFmService:fmRxCmdGetRdsAfSwitchMode ");
5040        Log.d(TAG,
5041                "  fmRxCmdGetRdsAfSwitchMode ( command: , status: , value: )"
5042                        + command + "" + status + "" + value);
5043
5044        if (MAKE_FM_APIS_BLOCKING == true) {
5045          // Code for blocking call
5046
5047              getRdsAfSwitchModeValue = (int) value;
5048
5049            /* implementation to make the FM API Synchronous */
5050            try {
5051                mRdsAfSwitchModeSyncQueue.put("*");
5052            } catch (InterruptedException e) {
5053                Log.e(TAG, "InterruptedException on queue wakeup!");
5054            }
5055            ;
5056
5057            Log.d(TAG,
5058                    "  fmRxCmdGetRdsAfSwitchMode ( getRdsAfSwitchModeValue: )"
5059                            + getRdsAfSwitchModeValue);
5060
5061        } else {
5062          // Code for non blocking call
5063            Log.d(TAG,
5064                    "StubFmService:sending intent GET_RDS_AF_SWITCH_MODE_ACTION");
5065
5066        Intent getRdsAf = new Intent(
5067        FmRadioIntent.GET_RDS_AF_SWITCH_MODE_ACTION);
5068        getRdsAf.putExtra(FmRadioIntent.GET_RDS_AF_SWITCHMODE, value);
5069        getRdsAf.putExtra(FmRadioIntent.STATUS, status);
5070        mContext.sendBroadcast(getRdsAf, FMRX_PERM);
5071
5072        }
5073
5074
5075
5076    }
5077
5078    public void fmRxCmdSetRdsAfSwitchMode(JFmRx context, JFmRxStatus status,
5079            int command, long value) {
5080
5081        Log.i(TAG, "StubFmService:fmRxCmdSetRdsAfSwitchMode ");
5082        Log.d(TAG,
5083                "  fmRxCmdSetRdsAfSwitchMode ( command: , status: , value: )"
5084                        + command + "" + status + "" + value);
5085
5086        if (MAKE_FM_APIS_BLOCKING == true) {
5087        // Code for blocking call
5088            /* implementation to make the FM API Synchronous */
5089            try {
5090                mSetRdsAfSwitchModeSyncQueue.put("*");
5091            } catch (InterruptedException e) {
5092                Log.e(TAG, "InterruptedException on queue wakeup!");
5093            }
5094            ;
5095
5096        }
5097        else
5098        {
5099
5100            Log.d(TAG, "StubFmService:sending intent SET_RDS_AF_ACTION");
5101        Intent intent = new Intent(FmRadioIntent.SET_RDS_AF_ACTION);
5102        intent.putExtra(FmRadioIntent.STATUS, status);
5103        mContext.sendBroadcast(intent, FMRX_PERM);
5104    }
5105    }
5106
5107    public void fmRxCmdSetRdsSystem(JFmRx context, JFmRxStatus status,
5108            int command, long value) {
5109
5110        Log.i(TAG, "StubFmService:fmRxCmdSetRdsSystem ");
5111        Log.d(TAG, "  fmRxCmdSetRdsSystem ( command: , status: , value: )"
5112                + command + "" + status + "" + value);
5113        if (MAKE_FM_APIS_BLOCKING == true) {
5114            // Code for blocking call
5115            getRdsSystemValue = (int) value;
5116                /* implementation to make the FM API Synchronous */
5117            try {
5118            mRdsSystemSyncQueue.put("*");
5119            } catch (InterruptedException e) {
5120            Log.e(TAG, "InterruptedException on queue wakeup!");
5121            }
5122            ;
5123
5124            Log.d(TAG, "  fmRxCmdGetRdsSystem ( getRdsSystemValue: )"
5125            + getRdsSystemValue);
5126        }
5127        else
5128        {
5129            Log.d(TAG, "StubFmService:sending intent SET_RDS_SYSTEM_ACTION");
5130        Intent intent = new Intent(FmRadioIntent.SET_RDS_SYSTEM_ACTION);
5131        intent.putExtra(FmRadioIntent.STATUS, status);
5132        mContext.sendBroadcast(intent, FMRX_PERM);
5133        }
5134
5135    }
5136
5137    public  void fmRxCmdGetRdsSystem(JFmRx context, JFmRxStatus status,
5138            int command, long value) {
5139
5140        Log.i(TAG, "StubFmService:fmRxCmdGetRdsSystem ");
5141        Log.d(TAG, "  fmRxCmdGetRdsSystem ( command: , status: , value: )"
5142                + command + "" + status + "" + value);
5143
5144        if (MAKE_FM_APIS_BLOCKING == true) {
5145          // Code for blocking call
5146                        getRdsSystemValue = (int) value;
5147
5148            /* implementation to make the FM API Synchronous */
5149            try {
5150                mRdsSystemSyncQueue.put("*");
5151            } catch (InterruptedException e) {
5152                Log.e(TAG, "InterruptedException on queue wakeup!");
5153            }
5154            ;
5155            Log.d(TAG, "  fmRxCmdGetRdsSystem ( getRdsSystemValue: )"
5156                    + getRdsSystemValue);
5157        } else {
5158          // Code for non blocking call
5159                    Log.d(TAG, "StubFmService:sending intent GET_RDS_SYSTEM_ACTION");
5160
5161            Intent getRdsSystem = new Intent(
5162                    FmRadioIntent.GET_RDS_SYSTEM_ACTION);
5163        getRdsSystem.putExtra(FmRadioIntent.GET_RDS_SYSTEM, value);
5164        getRdsSystem.putExtra(FmRadioIntent.STATUS, status);
5165        mContext.sendBroadcast(getRdsSystem, FMRX_PERM);
5166        }
5167
5168    }
5169
5170    public void fmRxCmdDisableRds(JFmRx context, JFmRxStatus status,
5171            int command, long value) {
5172
5173        Log.i(TAG, "StubFmService:fmRxCmdDisableRds ");
5174        Log.d(TAG, "  fmRxCmdDisableRds ( command: , status: , value: )"
5175                + command + "" + status + "" + value);
5176        if (MAKE_FM_APIS_BLOCKING == true) {
5177            // Code for blocking call
5178            /* implementation to make the FM API Synchronous */
5179
5180            try {
5181                mDisableRdsSyncQueue.put("*");
5182            } catch (InterruptedException e) {
5183                Log.e(TAG, "InterruptedException on queue wakeup!");
5184            }
5185            ;
5186
5187
5188        } else {
5189            // Code for non blocking call
5190
5191        Log.d(TAG, "StubFmService:sending intent DISABLE_RDS_ACTION");
5192        Intent intent = new Intent(FmRadioIntent.DISABLE_RDS_ACTION);
5193        intent.putExtra(FmRadioIntent.STATUS, status);
5194        mContext.sendBroadcast(intent, FMRX_PERM);
5195    }
5196
5197    }
5198
5199    public void fmRxCmdEnableRds(JFmRx context, JFmRxStatus status,
5200            int command, long value) {
5201
5202        Log.i(TAG, "StubFmService:fmRxCmdEnableRds ");
5203        Log.d(TAG, "  fmRxCmdEnableRds ( command: , status: , value: )"
5204                + command + "" + status + "" + value);
5205        if (MAKE_FM_APIS_BLOCKING == true) {
5206            // Code for blocking call
5207            /*implementation to make the set API Synchronous */
5208
5209            try {
5210                mEnableRdsSyncQueue.put("*");
5211            } catch (InterruptedException e) {
5212                Log.e(TAG, "InterruptedException on queue wakeup!");
5213            }
5214            ;
5215
5216
5217        } else {
5218            // Code for non blocking call
5219        Log.d(TAG, "StubFmService:sending intent ENABLE_RDS_ACTION");
5220        Intent intentRdsOn = new Intent(FmRadioIntent.ENABLE_RDS_ACTION);
5221        intentRdsOn.putExtra(FmRadioIntent.STATUS, status);
5222        mContext.sendBroadcast(intentRdsOn, FMRX_PERM);
5223        }
5224
5225    }
5226
5227    public   void fmRxCmdGetRdsGroupMask(JFmRx context, JFmRxStatus status,
5228            int command, long value) {
5229
5230        Log.i(TAG, "StubFmService:fmRxCmdGetRdsGroupMask ");
5231        Log.d(TAG, "  fmRxCmdGetRdsGroupMask ( command: , status: , value: )"
5232                + command + "" + status + "" + value);
5233
5234        if (MAKE_FM_APIS_BLOCKING == true) {
5235          getRdsGroupMaskValue = value;
5236
5237            /* implementation to make the FM API Synchronous */
5238            try {
5239                mRdsGroupMaskSyncQueue.put("*");
5240            } catch (InterruptedException e) {
5241                Log.e(TAG, "InterruptedException on queue wakeup!");
5242            }
5243            ;
5244          Log.d(TAG, "    fmRxCmdGetRdsGroupMask ( getRdsGroupMaskValue: )"
5245                  + getRdsGroupMaskValue);
5246        } else {
5247          // Code for non blocking call
5248                      Log.d(TAG, "StubFmService:sending intent GET_RDS_GROUPMASK_ACTION");
5249
5250                Intent getRdsGroup = new Intent(
5251                FmRadioIntent.GET_RDS_GROUPMASK_ACTION);
5252        getRdsGroup.putExtra(FmRadioIntent.GET_RDS_GROUPMASK, value);
5253        getRdsGroup.putExtra(FmRadioIntent.STATUS, status);
5254        mContext.sendBroadcast(getRdsGroup, FMRX_PERM);
5255        }
5256
5257    }
5258
5259    public void fmRxCmdSetRdsGroupMask(JFmRx context, JFmRxStatus status,
5260            int command, long value) {
5261
5262        Log.i(TAG, "StubFmService:fmRxCmdSetRdsGroupMask ");
5263        Log.d(TAG, "  fmRxCmdSetRdsGroupMask ( command: , status: , value: )"
5264                + command + "" + status + "" + value);
5265
5266        if (MAKE_FM_APIS_BLOCKING == true) {
5267                  // Code for blocking call
5268        /* implementation to make the FM API Synchronous */
5269            try {
5270                mSetRdsGroupMaskSyncQueue.put("*");
5271            } catch (InterruptedException e) {
5272                Log.e(TAG, "InterruptedException on queue wakeup!");
5273            }
5274            ;
5275        }
5276        else
5277        {
5278        Intent intent = new Intent(FmRadioIntent.SET_RDS_GROUP_MASK_ACTION);
5279        intent.putExtra(FmRadioIntent.STATUS, status);
5280        mContext.sendBroadcast(intent, FMRX_PERM);
5281        }
5282
5283    }
5284
5285    public void fmRxCmdGetRssi(JFmRx context, JFmRxStatus status, int command,
5286            long value) {
5287
5288        Log.i(TAG, "StubFmService:fmRxCmdGetRssi ");
5289        Log.d(TAG, "  fmRxCmdGetRssi ( command: , status: , value: )" + command
5290                + "" + status + "" + value);
5291        // The RSSI value is 8 bit signed number in 2's complement format
5292
5293        getRssiValue = convertUnsignedToSignedInt(value);
5294
5295        if (MAKE_FM_APIS_BLOCKING == true) {
5296                  // Code for blocking call
5297
5298        /*implementation to make the FM API Synchronous */
5299        try {
5300            mRssiSyncQueue.put("*");
5301        } catch (InterruptedException e) {
5302            Log.e(TAG, "InterruptedException on queue wakeup!");
5303        }
5304        ;
5305        Log.d(TAG, "  fmRxCmdGetRssi ( getRssiValue: )" + getRssiValue);
5306    }
5307        else
5308            {
5309                    Log.d(TAG, "StubFmService:sending intent GET_RSSI_ACTION");
5310        Intent intent = new Intent(FmRadioIntent.GET_RSSI_ACTION);
5311        intent.putExtra(FmRadioIntent.GET_RSSI, getRssiValue);
5312        intent.putExtra(FmRadioIntent.STATUS, status);
5313        mContext.sendBroadcast(intent, FMRX_PERM);
5314            }
5315    }
5316
5317    public void fmRxCmdStopSeek(JFmRx context, JFmRxStatus status, int command,
5318            long value) {
5319
5320        Log.i(TAG, "StubFmService:fmRxCmdStopSeek ");
5321        Log.d(TAG, "  fmRxCmdStopSeek ( command: , status: , value: )"
5322                + command + "" + status + "" + value);
5323
5324        if (MAKE_FM_APIS_BLOCKING == true) {
5325                  // Code for blocking call
5326            try {
5327                mStopSeekSyncQueue.put("*");
5328            } catch (InterruptedException e) {
5329                Log.e(TAG, "InterruptedException on queue wakeup!");
5330            }
5331            ;
5332            }else
5333                      {
5334        Log.d(TAG, "StubFmService:sending intent SEEK_STOP_ACTION");
5335        Intent intentstop = new Intent(FmRadioIntent.SEEK_STOP_ACTION);
5336        intentstop.putExtra(FmRadioIntent.SEEK_FREQUENCY, value);
5337        intentstop.putExtra(FmRadioIntent.STATUS, status);
5338        mContext.sendBroadcast(intentstop, FMRX_PERM);
5339    }
5340    }
5341
5342    public void fmRxCmdSeek(JFmRx context, JFmRxStatus status, int command,
5343            long value) {
5344
5345        Log.i(TAG, "StubFmService:fmRxCmdSeek ");
5346        Log.d(TAG, "  fmRxCmdSeek ( command: , status: , value: )" + command
5347                + "" + status + "" + value);
5348        Log.d(TAG, "StubFmService:sending intent SEEK_ACTION");
5349        mIsSeekInProgress = false;
5350        mCurrentFrequency = (int) value;
5351
5352        Log.d(TAG, "StubFmService:sending intent SEEK_ACTION");
5353        Intent intentstart = new Intent(FmRadioIntent.SEEK_ACTION);
5354        intentstart.putExtra(FmRadioIntent.SEEK_FREQUENCY, mCurrentFrequency);
5355        intentstart.putExtra(FmRadioIntent.STATUS, status);
5356        mContext.sendBroadcast(intentstart, FMRX_PERM);
5357    }
5358
5359    public void fmRxCmdGetTunedFrequency(JFmRx context, JFmRxStatus status,
5360            int command, long value) {
5361
5362        Log.i(TAG, "StubFmService:fmRxCmdGetTunedFrequency ");
5363        Log.d(TAG, "  fmRxCmdGetTunedFrequency ( command: , status: , value: )"
5364                + command + "" + status + "" + value);
5365        getTunedFrequencyValue = (int) value;
5366
5367        if (MAKE_FM_APIS_BLOCKING == true) {
5368          // Code for blocking call
5369              getTunedFrequencyValue = (int) value;
5370
5371                /* implementation to make the FM API Synchronous */
5372
5373            try {
5374                mTunedFrequencySyncQueue.put("*");
5375            } catch (InterruptedException e) {
5376                Log.e(TAG, "InterruptedException on queue wakeup!");
5377            }
5378            ;
5379            Log.d(TAG, "  fmRxCmdGetTunedFrequency ( getTunedFrequencyValue: )"
5380                    + getTunedFrequencyValue);
5381        } else {
5382          // Code for non blocking call
5383                  Log.d(TAG, "StubFmService:sending intent GET_FREQUENCY_ACTION");
5384            Intent freqIntent = new Intent(
5385                    FmRadioIntent.GET_FREQUENCY_ACTION);
5386        freqIntent.putExtra(FmRadioIntent.TUNED_FREQUENCY, getTunedFrequencyValue);
5387        freqIntent.putExtra(FmRadioIntent.STATUS, status);
5388        mContext.sendBroadcast(freqIntent, FMRX_PERM);
5389        }
5390    }
5391
5392    public void fmRxCmdTune(JFmRx context, JFmRxStatus status, int command,
5393            long value) {
5394
5395        Log.i(TAG, "StubFmService:fmRxCmdTune ");
5396        Log.d(TAG, "  fmRxCmdTune ( command: , status: , value: )" + command
5397                + "" + status + "" + value);
5398        mIsTuneInProgress = false;
5399        mCurrentFrequency = (int) value;
5400        Log.d(TAG, "StubFmService:sending intent TUNE_COMPLETE_ACTION");
5401        /* Now FM resume has been completed.Set it to default. */
5402            if (mFmPauseResume ==STATE_RESUME) {
5403
5404//                mFmPauseResume =STATE_DEFAULT;
5405            } else {
5406                Intent intentTune = new Intent(
5407                        FmRadioIntent.TUNE_COMPLETE_ACTION);
5408                intentTune.putExtra(FmRadioIntent.TUNED_FREQUENCY, mCurrentFrequency);
5409                intentTune.putExtra(FmRadioIntent.STATUS, status);
5410                mContext.sendBroadcast(intentTune, FMRX_PERM);
5411            }
5412
5413    }
5414
5415    public void fmRxCmdGetVolume(JFmRx context, JFmRxStatus status,
5416            int command, long value) {
5417        Log.i(TAG, "StubFmService:fmRxCmdGetVolume ");
5418        Log.d(TAG, "  fmRxCmdGetVolume ( command: , status: , value: )"
5419                + command + "" + status + "" + value);
5420            if (MAKE_FM_APIS_BLOCKING == true) {
5421          // Code for blocking call
5422                        getVolumeValue = (int) value;
5423
5424            /*implementation to make the FM API Synchronous */
5425            try {
5426                mVolumeSyncQueue.put("*");
5427            } catch (InterruptedException e) {
5428                Log.e(TAG, "InterruptedException on queue wakeup!");
5429            }
5430            ;
5431            Log.d(TAG, "  fmRxCmdGetVolume ( getVolumeValue: )"
5432                    + getVolumeValue);
5433        } else {
5434          // Code for non blocking call
5435              Log.d(TAG, "StubFmService:sending intent GET_VOLUME_ACTION");
5436                  Intent getVolume = new Intent(FmRadioIntent.GET_VOLUME_ACTION);
5437        getVolume.putExtra(FmRadioIntent.GET_VOLUME, value);
5438        getVolume.putExtra(FmRadioIntent.STATUS, status);
5439        mContext.sendBroadcast(getVolume, FMRX_PERM);
5440
5441        }
5442    }
5443
5444    public void fmRxCmdSetVolume(JFmRx context, JFmRxStatus status,
5445            int command, long value) {
5446
5447            /*
5448         * volume change will be completed here. So set the state to idle, so
5449         * that user can set other volume.
5450             */
5451            synchronized (mVolumeSynchronizationLock) {
5452                mVolState = VOL_REQ_STATE_IDLE;
5453            }
5454
5455        Log.d(TAG, "StubFmService:fmRxCmdDone  JFmRxCommand.CMD_SET_VOLUME");
5456        Log.d(TAG, "  fmRxCmdSetVolume ( command: , status: , value: )"
5457                    + command + "" + status + "" + value);
5458        Log.d(TAG, "StubFmService:sending intent VOLUME_CHANGED_ACTION");
5459            /* If the FM is resumed, then load the current band. */
5460            if (mFmPauseResume ==STATE_RESUME) {
5461            Log.d(TAG, "StubFmService:FM resuming . Dont do anything");
5462            }
5463            /*
5464         * If the FM is enabled, then send the intent to App to load the band..
5465             */
5466            else {
5467                Intent intentVolume = new Intent(
5468                        FmRadioIntent.VOLUME_CHANGED_ACTION);
5469                intentVolume.putExtra(FmRadioIntent.STATUS, status);
5470                mContext.sendBroadcast(intentVolume, FMRX_PERM);
5471            }
5472
5473    }
5474
5475    public void fmRxCmdGetDeemphasisFilter(JFmRx context, JFmRxStatus status,
5476            int command, long value) {
5477
5478        Log.i(TAG, "StubFmService:fmRxCmdGetDeemphasisFilter ");
5479        Log.d(TAG,
5480                "  fmRxCmdGetDeemphasisFilter ( command: , status: , value: )"
5481                        + command + "" + status + "" + value);
5482
5483            if (MAKE_FM_APIS_BLOCKING == true) {
5484          // Code for blocking call
5485
5486                getDeEmphasisFilterValue = (int) value;
5487
5488            /*implementation to make the FM API Synchronous */
5489
5490            try {
5491                mDeEmphasisFilterSyncQueue.put("*");
5492            } catch (InterruptedException e) {
5493                Log.e(TAG, "InterruptedException on queue wakeup!");
5494            }
5495            ;
5496
5497            Log.d(TAG,
5498                    "  fmRxCmdGetDeemphasisFilter ( getDeEmphasisFilterValue: )"
5499                            + getDeEmphasisFilterValue);
5500        } else {
5501          // Code for non blocking call
5502          Log.d(TAG, "StubFmService:sending intent GET_DEEMPHASIS_FILTER_ACTION");
5503          Intent getDeEmpFilter = new Intent(
5504                      FmRadioIntent.GET_DEEMPHASIS_FILTER_ACTION);
5505              getDeEmpFilter.putExtra(FmRadioIntent.GET_DEEMPHASIS_FILTER, value);
5506              getDeEmpFilter.putExtra(FmRadioIntent.STATUS, status);
5507              mContext.sendBroadcast(getDeEmpFilter, FMRX_PERM);
5508
5509        }
5510    }
5511
5512    public void fmRxCmdSetDeemphasisFilter(JFmRx context, JFmRxStatus status,
5513            int command, long value) {
5514
5515        Log.i(TAG, "StubFmService:fmRxCmdSetDeemphasisFilter ");
5516        Log.d(TAG,
5517                "  fmRxCmdSetDeemphasisFilter ( command: , status: , value: )"
5518                        + command + "" + status + "" + value);
5519        if (MAKE_FM_APIS_BLOCKING == true) {
5520            // Code for blocking call
5521            /*implementation to make the set API Synchronous */
5522            try {
5523                mSetDeEmphasisFilterSyncQueue.put("*");
5524            } catch (InterruptedException e) {
5525                Log.e(TAG, "InterruptedException on queue wakeup!");
5526            }
5527            ;
5528
5529        } else {
5530            // Code for non blocking call
5531        Log.d(TAG, "StubFmService:sending intent SET_DEEMP_FILTER_ACTION");
5532        Intent intent = new Intent(FmRadioIntent.SET_DEEMP_FILTER_ACTION);
5533        intent.putExtra(FmRadioIntent.STATUS, status);
5534        mContext.sendBroadcast(intent, FMRX_PERM);
5535    }
5536
5537    }
5538
5539    public void fmRxCmdGetRssiThreshhold(JFmRx context, JFmRxStatus status,
5540            int command, long value) {
5541
5542        Log.i(TAG, "StubFmService:fmRxCmdGetRssiThreshhold ");
5543        Log.d(TAG, "  fmRxCmdGetRssiThreshhold ( command: , status: , value: )"
5544                + command + "" + status + "" + value);
5545
5546            if (MAKE_FM_APIS_BLOCKING == true) {
5547          // Code for blocking call
5548
5549            getRssiThresholdValue = (int) value;
5550
5551            /*implementation to make the FM API Synchronous */
5552            try {
5553                mRssiThresholdSyncQueue.put("*");
5554            } catch (InterruptedException e) {
5555                Log.e(TAG, "InterruptedException on queue wakeup!");
5556            }
5557            ;
5558            Log.d(TAG, "  fmRxCmdGetRssiThreshhold ( getRssiThresholdValue: )"
5559                    + getRssiThresholdValue);
5560
5561        } else {
5562          // Code for non blocking call
5563           Log.d(TAG, "StubFmService:sending intent GET_RSSI_THRESHHOLD_ACTION");
5564                Intent getRssiThreshHold = new Intent(
5565                FmRadioIntent.GET_RSSI_THRESHHOLD_ACTION);
5566            getRssiThreshHold.putExtra(FmRadioIntent.GET_RSSI_THRESHHOLD,
5567                    value);
5568        getRssiThreshHold.putExtra(FmRadioIntent.STATUS, status);
5569        mContext.sendBroadcast(getRssiThreshHold, FMRX_PERM);
5570        }
5571    }
5572
5573    public void fmRxCmdSetRssiThreshhold(JFmRx context, JFmRxStatus status,
5574            int command, long value) {
5575
5576        Log.i(TAG, "StubFmService:fmRxCmdSetRssiThreshhold ");
5577        Log.d(TAG, "  fmRxCmdSetRssiThreshhold ( command: , status: , value: )"
5578                + command + "" + status + "" + value);
5579        if (MAKE_FM_APIS_BLOCKING == true) {
5580            // Code for blocking call
5581                /* implementation to make the FM API Synchronous */
5582
5583            try {
5584                mSetRssiThresholdSyncQueue.put("*");
5585            } catch (InterruptedException e) {
5586                Log.e(TAG, "InterruptedException on queue wakeup!");
5587            }
5588            ;
5589
5590
5591        } else {
5592            // Code for non blocking call
5593        Log.d(TAG, "StubFmService:sending intent SET_RSSI_THRESHHOLD_ACTION");
5594        Intent intentRssi = new Intent(
5595                FmRadioIntent.SET_RSSI_THRESHHOLD_ACTION);
5596        intentRssi.putExtra(FmRadioIntent.STATUS, status);
5597        mContext.sendBroadcast(intentRssi, FMRX_PERM);
5598        }
5599
5600    }
5601
5602    public void fmRxCmdGetRfDependentMuteMode(JFmRx context,
5603            JFmRxStatus status, int command, long value) {
5604
5605        Log.i(TAG, "StubFmService:fmRxCmdGetRfDependentMuteMode ");
5606        Log.d(TAG,
5607                "  fmRxCmdGetRfDependentMuteMode ( command: , status: , value: )"
5608                        + command + "" + status + "" + value);
5609
5610            if (MAKE_FM_APIS_BLOCKING == true) {
5611          // Code for blocking call
5612
5613          getRfDependentMuteModeValue = (int) value;
5614
5615          /*implementation to make the FM API Synchronous */
5616
5617            try {
5618                mRfDependentMuteModeSyncQueue.put("*");
5619            } catch (InterruptedException e) {
5620            Log.e(TAG, "InterruptedException on queue wakeup!");
5621            }
5622            ;
5623
5624          Log.d(TAG,
5625                  "  fmRxCmdGetRfDependentMuteMode ( getRfDependentMuteModeValue: )"
5626                          + getRfDependentMuteModeValue);
5627        } else {
5628          // Code for non blocking call
5629          Log.d(TAG, "StubFmService:sending intent GET_RF_MUTE_MODE_ACTION");
5630
5631                  Intent getRfMuteMode = new Intent(
5632                FmRadioIntent.GET_RF_MUTE_MODE_ACTION);
5633        getRfMuteMode.putExtra(FmRadioIntent.GET_RF_MUTE_MODE, value);
5634        getRfMuteMode.putExtra(FmRadioIntent.STATUS, status);
5635        mContext.sendBroadcast(getRfMuteMode, FMRX_PERM);
5636
5637        }
5638    }
5639
5640    public void fmRxCmdSetRfDependentMuteMode(JFmRx context,
5641            JFmRxStatus status, int command, long value) {
5642
5643        Log.i(TAG, "StubFmService:fmRxCmdSetRfDependentMuteMode ");
5644        Log.d(TAG,
5645                "  fmRxCmdSetRfDependentMuteMode ( command: , status: , value: )"
5646                + command + "" + status + "" + value);
5647        if (MAKE_FM_APIS_BLOCKING == true) {
5648            // Code for blocking call
5649            /*implementation to make the set API Synchronous */
5650
5651            try {
5652                mSetRfDependentMuteModeSyncQueue.put("*");
5653            } catch (InterruptedException e) {
5654                Log.e(TAG, "InterruptedException on queue wakeup!");
5655            }
5656            ;
5657
5658
5659        } else {
5660            // Code for non blocking call
5661            Log.d(TAG,
5662                    "StubFmService:sending intent SET_RF_DEPENDENT_MUTE_ACTION");
5663        Intent intentRfMute = new Intent(
5664                FmRadioIntent.SET_RF_DEPENDENT_MUTE_ACTION);
5665        intentRfMute.putExtra(FmRadioIntent.STATUS, status);
5666        mContext.sendBroadcast(intentRfMute, FMRX_PERM);
5667    }
5668
5669            }
5670
5671    public  void fmRxCmdSetMuteMode(JFmRx context, JFmRxStatus status,
5672            int command, long value) {
5673        Log.i(TAG, "StubFmService:fmRxCmdSetMuteMode ");
5674        Log.d(TAG, "  fmRxCmdSetMuteMode ( command: , status: , value: )"
5675                + command + "" + status + "" + value);
5676        if (MAKE_FM_APIS_BLOCKING == true) {
5677            // Code for blocking call
5678
5679            /* implementation to make the FM API Synchronous */
5680
5681            try {
5682                mSetMuteModeSyncQueue.put("*");
5683            } catch (InterruptedException e) {
5684                Log.e(TAG, "InterruptedException on queue wakeup!");
5685            }
5686            ;
5687
5688
5689        } else {
5690            // Code for non blocking call
5691
5692        if(mIsFmMuted == false)
5693        {
5694            Log.d(TAG, "StubFmService:sending intent MUTE_CHANGE_ACTION");
5695            Intent intentMute = new Intent(FmRadioIntent.MUTE_CHANGE_ACTION);
5696            intentMute.putExtra(FmRadioIntent.STATUS, status);
5697            mContext.sendBroadcast(intentMute, FMRX_PERM);
5698        }
5699    }
5700
5701    }
5702
5703    public void fmRxCmdGetMuteMode(JFmRx context, JFmRxStatus status,
5704            int command, long value) {
5705        Log.i(TAG, "StubFmService:fmRxCmdGetMuteMode ");
5706        Log.d(TAG, "  fmRxCmdGetMuteMode ( command: , status: , value: )"
5707                        + command + "" + status + "" + value);
5708
5709            if (MAKE_FM_APIS_BLOCKING == true) {
5710          // Code for blocking call
5711
5712                    getMuteModeValue = (int) value;
5713
5714            /* implementation to make the FM API Synchronous */
5715            try {
5716                mMuteModeSyncQueue.put("*");
5717            } catch (InterruptedException e) {
5718                Log.e(TAG, "InterruptedException on queue wakeup!");
5719            }
5720            ;
5721
5722            Log.d(TAG, "  fmRxCmdGetMuteMode ( getMuteModeValue: )"
5723                    + getMuteModeValue);
5724        } else {
5725          // Code for non blocking call
5726          Log.d(TAG, "StubFmService:sending intent GET_MUTE_MODE_ACTION");
5727
5728            Intent getMuteMode = new Intent(
5729                    FmRadioIntent.GET_MUTE_MODE_ACTION);
5730        getMuteMode.putExtra(FmRadioIntent.GET_MUTE_MODE, value);
5731        getMuteMode.putExtra(FmRadioIntent.STATUS, status);
5732        mContext.sendBroadcast(getMuteMode, FMRX_PERM);
5733
5734        }
5735    }
5736
5737    public void fmRxCmdGetMonoStereoMode(JFmRx context, JFmRxStatus status,
5738            int command, long value) {
5739        Log.i(TAG, "StubFmService:fmRxCmdGetMonoStereoMode ");
5740        Log.d(TAG, "  fmRxCmdGetMonoStereoMode ( command: , status: , value: )"
5741                                + command + "" + status + "" + value);
5742
5743            if (MAKE_FM_APIS_BLOCKING == true) {
5744          // Code for blocking call
5745            getMonoStereoModeValue = (int) value;
5746
5747                /* implementation to make the FM API Synchronous */
5748
5749            try {
5750                mMonoStereoModeSyncQueue.put("*");
5751            } catch (InterruptedException e) {
5752                Log.e(TAG, "InterruptedException on queue wakeup!");
5753            }
5754            ;
5755
5756            Log.d(TAG, "  fmRxCmdGetMonoStereoMode ( getMonoStereoModeValue: )"
5757                    + getMonoStereoModeValue);
5758
5759        } else {
5760          // Code for non blocking call
5761            Log.d(TAG, "StubFmService:sending intent GET_MONO_STEREO_MODE_ACTION");
5762                Intent getMode = new Intent(
5763                FmRadioIntent.GET_MONO_STEREO_MODE_ACTION);
5764        getMode.putExtra(FmRadioIntent.GET_MODE, value);
5765        getMode.putExtra(FmRadioIntent.STATUS, status);
5766        mContext.sendBroadcast(getMode, FMRX_PERM);
5767        }
5768    }
5769
5770    public void fmRxCmdSetMonoStereoMode(JFmRx context, JFmRxStatus status,
5771            int command, long value) {
5772
5773        Log.i(TAG, "StubFmService:fmRxCmdSetMonoStereoMode ");
5774        Log.d(TAG, "  fmRxCmdSetMonoStereoMode ( command: , status: , value: )"
5775                                + command + "" + status + "" + value);
5776        if (MAKE_FM_APIS_BLOCKING == true) {
5777            // Code for blocking call
5778            /* implementation to make the set API Synchronous */
5779
5780            try {
5781                mSetMonoStereoModeSyncQueue.put("*");
5782            } catch (InterruptedException e) {
5783                Log.e(TAG, "InterruptedException on queue wakeup!");
5784            }
5785            ;
5786
5787        } else {
5788            // Code for non blocking call
5789                Log
5790                        .d(TAG,
5791                            "StubFmService:sending intent SET_MODE_MONO_STEREO_ACTION");
5792        Intent intentMode = new Intent(
5793                FmRadioIntent.SET_MODE_MONO_STEREO_ACTION);
5794        intentMode.putExtra(FmRadioIntent.STATUS, status);
5795        mContext.sendBroadcast(intentMode, FMRX_PERM);
5796    }
5797
5798            }
5799
5800    public void fmRxCmdGetBand(JFmRx context, JFmRxStatus status, int command,
5801            long value) {
5802        Log.i(TAG, "StubFmService:fmRxCmdGetBand ");
5803        Log.d(TAG, "  fmRxCmdGetBand ( command: , status: , value: )" + command
5804                + "" + status + "" + value);
5805
5806        if (MAKE_FM_APIS_BLOCKING == true) {
5807          // Code for blocking call
5808
5809            getBandValue = (int) value;
5810
5811            /* implementation to make the FM API Synchronous */
5812
5813            try {
5814                mBandSyncQueue.put("*");
5815            } catch (InterruptedException e) {
5816                Log.e(TAG, "InterruptedException on queue wakeup!");
5817            }
5818            ;
5819
5820
5821            Log.d(TAG, "  fmRxCmdGetBand ( getBandValue: )" + getBandValue);
5822        } else {
5823          // Code for non blocking call
5824          Log.d(TAG, "StubFmService:sending intent GET_BAND_ACTION");
5825        Intent getBand = new Intent(FmRadioIntent.GET_BAND_ACTION);
5826        getBand.putExtra(FmRadioIntent.GET_BAND, value);
5827        getBand.putExtra(FmRadioIntent.STATUS, status);
5828        mContext.sendBroadcast(getBand, FMRX_PERM);
5829
5830        }
5831            }
5832
5833    public void fmRxCmdSetBand(JFmRx context, JFmRxStatus status, int command,
5834            long value) {
5835        Log.i(TAG, "StubFmService:fmRxCmdSetBand ");
5836        Log.d(TAG, "  fmRxCmdSetBand ( command: , status: , value: )" + command
5837                + "" + status + "" + value);
5838
5839        if (MAKE_FM_APIS_BLOCKING == true) {
5840            // Code for blocking call
5841            /*implementation to make the Set API Synchronous */
5842
5843            try {
5844                mSetBandSyncQueue.put("*");
5845            } catch (InterruptedException e) {
5846                Log.e(TAG, "InterruptedException on queue wakeup!");
5847            }
5848            ;
5849
5850
5851        } else {
5852            // Code for non blocking call
5853            Log.d(TAG, "StubFmService:FM resuming . mFmPauseResume"
5854                    + mFmPauseResume);
5855        /* If the FM is resumed, then load the previously tuned frequency. */
5856        if (mFmPauseResume ==STATE_RESUME) {
5857                Log.d(TAG, "StubFmService:FM resuming . Dont do anything");
5858        }
5859        /*
5860         * If the FM is enabled, then send the intent to App to load the
5861         * freq..
5862         */
5863        else {
5864                Log.d(TAG, "StubFmService:sending intent BAND_CHANGE_ACTION");
5865                Intent intentBand = new Intent(FmRadioIntent.BAND_CHANGE_ACTION);
5866            intentBand.putExtra(FmRadioIntent.STATUS, status);
5867            mContext.sendBroadcast(intentBand, FMRX_PERM);
5868        }
5869
5870        }
5871
5872    }
5873
5874    public void fmRxCmdChangeAudioTarget(JFmRx context, JFmRxStatus status,
5875            int command, long AudioCmd) {
5876        Log.i(TAG, "StubFmService:fmRxCmdChangeAudioTarget ");
5877        Log.d(TAG,
5878                "  fmRxCmdChangeAudioTarget ( command: , status: , AudioCmd: )"
5879                        + command + "" + status + "" + AudioCmd);
5880    }
5881
5882    public void fmRxCmdEnableAudio(JFmRx context, JFmRxStatus status,
5883            int command, long AudioCmd) {
5884        Log.i(TAG, "StubFmService:fmRxCmdEnableAudio ");
5885        Log.d(TAG,
5886                "  fmRxCmdEnableAudio ( command: , status: , AudioCmd: )"
5887                        + command + "" + status + "" + AudioCmd);
5888    }
5889
5890    public void fmRxCmdChangeDigitalAudioConfiguration(JFmRx context,
5891            JFmRxStatus status, int command, long value) {
5892
5893        Log.i(TAG, "StubFmService:fmRxCmdChangeDigitalAudioConfiguration ");
5894                Log.d(TAG,
5895                "  fmRxCmdChangeDigitalAudioConfiguration ( command: , status: , value: )"
5896                                + command + "" + status + "" + value);
5897            }
5898
5899    public void fmRxCmdGetChannelSpacing(JFmRx context, JFmRxStatus status,
5900            int command, long value) {
5901
5902        Log.i(TAG, "StubFmService:fmRxCmdGetChannelSpacing ");
5903        Log.d(TAG, "  fmRxCmdGetChannelSpacing ( command: , status: , value: )"
5904                        + command + "" + status + "" + value);
5905
5906            if (MAKE_FM_APIS_BLOCKING == true) {
5907          // Code for blocking call
5908                            getChannelSpaceValue = (int) value;
5909                /* implementation to make the FM API Synchronous */
5910
5911            try {
5912                mChannelSpacingSyncQueue.put("*");
5913            } catch (InterruptedException e) {
5914                Log.e(TAG, "InterruptedException on queue wakeup!");
5915            }
5916            ;
5917
5918            Log.d(TAG, "  fmRxCmdGetChannelSpacing ( getChannelSpaceValue: )"
5919                    + getChannelSpaceValue);
5920
5921        } else {
5922          // Code for non blocking call
5923
5924                    Log.d(TAG, "StubFmService:sending intent GET_CHANNEL_SPACE_ACTION");
5925            Intent getChSpace = new Intent(
5926                    FmRadioIntent.GET_CHANNEL_SPACE_ACTION);
5927        getChSpace.putExtra(FmRadioIntent.GET_CHANNEL_SPACE, value);
5928        getChSpace.putExtra(FmRadioIntent.STATUS, status);
5929        mContext.sendBroadcast(getChSpace, FMRX_PERM);
5930
5931        }
5932    }
5933
5934    public void fmRxCmdSetChannelSpacing(JFmRx context, JFmRxStatus status,
5935            int command, long value) {
5936
5937        Log.i(TAG, "StubFmService:fmRxCmdSetChannelSpacing ");
5938        Log.d(TAG, "  fmRxCmdSetChannelSpacing ( command: , status: , value: )"
5939                        + command + "" + status + "" + value);
5940
5941        if (MAKE_FM_APIS_BLOCKING == true) {
5942                /* implementation to make the FM API Synchronous */
5943            try {
5944                mSetChannelSpacingSyncQueue.put("*");
5945            } catch (InterruptedException e) {
5946                Log.e(TAG, "InterruptedException on queue wakeup!");
5947            }
5948            ;
5949            }
5950        else
5951            {
5952
5953        Log.d(TAG, "StubFmService:sending intent CHANNEL_SPACING_CHANGED_ACTION");
5954            Intent intentChannelSpace = new Intent(
5955                    FmRadioIntent.CHANNEL_SPACING_CHANGED_ACTION);
5956            intentChannelSpace.putExtra(FmRadioIntent.STATUS, status);
5957            mContext.sendBroadcast(intentChannelSpace, FMRX_PERM);
5958    }
5959    }
5960
5961    public void fmRxCmdIsValidChannel(JFmRx context, JFmRxStatus status,
5962            int command, long value) {
5963
5964        Log.i(TAG, "StubFmService:fmRxCmdIsValidChannel ");
5965        Log.d(TAG, "  fmRxCmdIsValidChannel ( command: , status: , value: )"
5966                                + command + "" + status + "" + value);
5967        if (value > 0)
5968            mIsValidChannel = true;
5969        else
5970            mIsValidChannel = false;
5971
5972        /*implementation to make the FM API Synchronous */
5973
5974        try {
5975            mValidChannelSyncQueue.put("*");
5976        } catch (InterruptedException e) {
5977            Log.e(TAG, "InterruptedException on queue wakeup!");
5978            }
5979        ;
5980
5981        Log.d(TAG, "  fmRxCmdIsValidChannel ( isValidChannel: )"
5982                + mIsValidChannel);
5983
5984            }
5985
5986    public void fmRxCmdGetFwVersion(JFmRx context, JFmRxStatus status,
5987            int command, long value) {
5988
5989        Log.i(TAG, "StubFmService:fmRxCmdGetFwVersion ");
5990        Log.d(TAG, "  fmRxCmdGetFwVersion ( command: , status: , value: )"
5991                                + command + "" + status + "" + value);
5992
5993            getFwVersion = ((double) value / 1000);
5994
5995            /* implementation to make the FM API Synchronous */
5996            try {
5997                mFwVersionSyncQueue.put("*");
5998            } catch (InterruptedException e) {
5999                Log.e(TAG, "InterruptedException on queue wakeup!");
6000            }
6001            ;
6002        Log.d(TAG, "  fmRxCmdGetFwVersion ( getFwVersion: )" + getFwVersion);
6003
6004    }
6005
6006    public void fmRxCmdGetCompleteScanProgress(JFmRx context,
6007            JFmRxStatus status, int command, long value) {
6008
6009        Log.i(TAG, "StubFmService:fmRxCmdGetCompleteScanProgress ");
6010                Log.d(TAG,
6011                        "  fmRxCmdGetCompleteScanProgress ( command: , status: , value: )"
6012                                + command + "" + status + "" + value);
6013
6014            getScanProgress = (int) value;
6015
6016            if (MAKE_FM_APIS_BLOCKING == true) {
6017
6018
6019                /* implementation to make the FM API Synchronous */
6020
6021            try {
6022                mCompleteScanProgressSyncQueue.put("*");
6023            } catch (InterruptedException e) {
6024                Log.e(TAG, "InterruptedException on queue wakeup!");
6025            }
6026
6027
6028        Log.d(TAG, "  fmRxCmdGetCompleteScanProgress ( getFwVersion: )"
6029                                + getScanProgress);
6030                }
6031            else
6032            {
6033
6034                    Log.d(TAG, "StubFmService:sending intent COMPLETE_SCAN_PROGRESS_ACTION");
6035            Intent intent = new Intent(
6036                    FmRadioIntent.COMPLETE_SCAN_PROGRESS_ACTION);
6037            intent.putExtra(FmRadioIntent.STATUS, status);
6038            intent.putExtra(FmRadioIntent.SCAN_PROGRESS, getScanProgress);
6039            mContext.sendBroadcast(intent, FMRX_PERM);
6040
6041        }
6042
6043            }
6044
6045    public void fmRxCmdStopCompleteScan(JFmRx context, JFmRxStatus status,
6046            int command, long value) {
6047
6048    Log.i(TAG, "StubFmService:fmRxCmdStopCompleteScan ");
6049        Log.d(TAG, "  fmRxCmdStopCompleteScan ( command: , status: , value: )"
6050    + command + "" + status + "" + value);
6051            mIsCompleteScanInProgress = false;
6052
6053    if (MAKE_FM_APIS_BLOCKING == true) {
6054
6055        mStopCompleteScanStatus = status.getValue();
6056
6057        /* implementation to make the FM API Synchronous */
6058
6059            try {
6060                mStopCompleteScanSyncQueue.put("*");
6061            } catch (InterruptedException e) {
6062                Log.e(TAG, "InterruptedException on queue wakeup!");
6063            }
6064            ;
6065        Log.d(TAG, "  fmRxCmdStopCompleteScan ( mStopCompleteScanStatus: )"
6066                                + mStopCompleteScanStatus);
6067    }
6068    else
6069    {
6070
6071        Log.d(TAG, "StubFmService:sending intent COMPLETE_SCAN_STOP_ACTION ");
6072
6073    Intent intentStopScan = new Intent(
6074            FmRadioIntent.COMPLETE_SCAN_STOP_ACTION);
6075
6076        Bundle b = new Bundle();
6077        b.putInt(FmRadioIntent.STATUS, status.getValue());
6078        b.putInt(FmRadioIntent.LAST_SCAN_CHANNEL, (int)value);
6079        intentStopScan.putExtras(b);
6080    mContext.sendBroadcast(intentStopScan, FMRX_PERM);
6081    }
6082
6083    }
6084
6085
6086
6087
6088
6089
6090/*****  FM TX ******/
6091
6092    public void fmTxCmdEnable(JFmTx context, JFmTxStatus status,
6093            long value) {
6094
6095        Log.i(TAG, "StubFmService:fmTxCmdEnable ");
6096        Log.d(TAG, "  fmTxCmdEnable ( status: " + status + " )");
6097
6098            Intent intentTxEnable = new Intent(FmRadioIntent.FM_TX_ENABLED_ACTION);
6099            intentTxEnable.putExtra(FmRadioIntent.STATUS, status);
6100            mContext.sendBroadcast(intentTxEnable, FMRX_PERM);
6101            mTxState = STATE_ENABLED;
6102
6103
6104	sendNotificationTX();
6105        /* Ne need to call again, let it take from default */
6106
6107        //if(status ==JFmTxStatus.SUCCESS )
6108        //    {
6109          //        /*Enable the Audio deafult platfrom values */
6110        //        JFmTx.JFmTxEcalResource fmTxDeafultSourceConfig =
6111        //        JFmUtils.getEnumConst(    JFmTx.JFmTxEcalResource.class,fmTxDeafultCalResource);
6112
6113        //        JFmTx.JFmTxEcalSampleFrequency fmTxDeafultFreqConfig = JFmUtils.getEnumConst(
6114        //        JFmTx.JFmTxEcalSampleFrequency.class,fmTxDeafultSampleFrequency);
6115
6116        //        mJFmTx.txChangeAudioSource(fmTxDeafultSourceConfig,fmTxDeafultFreqConfig);
6117                /* Notify to APM */
6118
6119        //    }
6120    }
6121
6122    public void fmTxCmdDisable(JFmTx context, JFmTxStatus status,
6123            long value) {
6124
6125        Log.i(TAG, "StubFmService:fmTxCmdDisable ");
6126        Log.d(TAG, "  fmTxCmdDisable ( status: " + status + " )");
6127        /* Notify to APM */
6128
6129             if (isTransmissionOn()) {
6130                   Log.i(TAG, "StubFmService:Sending ACTION_FMTx_PLUG ");
6131                   enableTx(0);
6132                   Log.i(TAG, "StubFmService:Sent! ACTION_FMTx_PLUG ");
6133             }
6134
6135             mIsFmTxOn = false;
6136
6137        cancelNotification(FM_TX_NOTIFICATION_ID);
6138
6139        destroyJFmTx();
6140
6141        Intent intentTxDisable = new Intent(FmRadioIntent.FM_TX_DISABLED_ACTION);
6142        intentTxDisable.putExtra(FmRadioIntent.STATUS, status);
6143        mContext.sendBroadcast(intentTxDisable, FMRX_PERM);
6144        mTxState = STATE_DISABLED;
6145
6146    }
6147
6148
6149    public void fmTxCmdDestroy(JFmTx context, JFmTxStatus status,
6150            long value) {
6151
6152        Log.i(TAG, "StubFmService:fmRxCmdDestroy ");
6153        Log.d(TAG, "  fmRxCmdDestroy (status: " + status + " )");
6154
6155        Intent intentTxDestroy = new Intent(FmRadioIntent.FM_TX_DESTROY_ACTION);
6156        intentTxDestroy.putExtra(FmRadioIntent.STATUS, status);
6157        mContext.sendBroadcast(intentTxDestroy, FMRX_PERM);
6158
6159    }
6160
6161    public void fmTxCmdStartTransmission(JFmTx context, JFmTxStatus status/*,
6162            JFmCcmVacUnavailResourceList ccmVacUnavailResourceList*/) {
6163
6164        Log.i(TAG, "StubFmService:fmTxCmdStartTransmission ");
6165        Log.d(TAG, "  fmTxCmdStartTransmission (status: " + status + " )");
6166        Intent intentStartTransmission = new Intent(FmRadioIntent.FM_TX_START_TRANSMISSION_ACTION);
6167        intentStartTransmission.putExtra(FmRadioIntent.STATUS, status);
6168        mContext.sendBroadcast(intentStartTransmission, FMRX_PERM);
6169
6170        if(status ==JFmTxStatus.SUCCESS ) {
6171            //mAudioManager.setParameters(AUDIO_TX_ENABLE+"=true");
6172                    Log.i(TAG, "StubFmService:Sending ACTION_FMTx_PLUG ");
6173                    enableTx(1);
6174                    Log.i(TAG, "StubFmService:Sent! ACTION_FMTx_PLUG ");
6175             }
6176
6177    }
6178
6179
6180    public void fmTxCmdStopTransmission(JFmTx context, JFmTxStatus status,
6181            long value) {
6182
6183        Log.i(TAG, "StubFmService:fmTxCmdStopTransmission ");
6184        Log.d(TAG, "  fmTxCmdStopTransmission ( status: " + status + " )");
6185
6186        Intent intentStopTransmission = new Intent(FmRadioIntent.FM_TX_STOP_TRANSMISSION_ACTION);
6187        intentStopTransmission.putExtra(FmRadioIntent.STATUS, status);
6188        mContext.sendBroadcast(intentStopTransmission, FMRX_PERM);
6189
6190        if(status ==JFmTxStatus.SUCCESS ) {
6191            //mAudioManager.setParameters(AUDIO_TX_ENABLE+"=false");
6192                    Log.i(TAG, "StubFmService:Sending ACTION_FMTx_PLUG ");
6193                    enableTx(0);
6194                    Log.i(TAG, "StubFmService:Sent! ACTION_FMTx_PLUG ");
6195             }
6196
6197    }
6198
6199    public void fmTxCmdSetPowerLevel(JFmTx context, JFmTxStatus status,
6200            long value) {
6201
6202        Log.i(TAG, "StubFmService:fmTxCmdSetPowerLevel ");
6203        Log.d(TAG, "  fmTxCmdSetPowerLevel ( status: " + status + " )");
6204    }
6205
6206
6207
6208        public void fmTxCmdEnableRds(JFmTx context, JFmTxStatus status,
6209            long value) {
6210
6211        Log.i(TAG, "StubFmService:fmTxCmdEnableRds ");
6212        Log.d(TAG, "  fmTxCmdEnableRds ( status: " + status + " )");
6213
6214
6215        Intent intentTxEnableRds = new Intent(FmRadioIntent.FM_TX_ENABLE_RSD_ACTION);
6216        intentTxEnableRds.putExtra(FmRadioIntent.STATUS, status);
6217        mContext.sendBroadcast(intentTxEnableRds, FMRX_PERM);
6218
6219    }
6220
6221
6222        public void fmTxCmdDisableRds(JFmTx context, JFmTxStatus status,
6223            long value) {
6224
6225        Log.i(TAG, "StubFmService:fmTxCmdDisableRds ");
6226        Log.d(TAG, "  fmTxCmdDisableRds (status: " + status + " )");
6227
6228        Intent intentTxDisableRds = new Intent(FmRadioIntent.FM_TX_DISABLE_RSD_ACTION);
6229        intentTxDisableRds.putExtra(FmRadioIntent.STATUS, status);
6230        mContext.sendBroadcast(intentTxDisableRds, FMRX_PERM);
6231
6232    }
6233
6234        public void fmTxCmdTune(JFmTx context, JFmTxStatus status,
6235            long value) {
6236
6237        Log.i(TAG, "StubFmService:fmRxCmdTune ");
6238        Log.d(TAG, "  fmRxCmdTune (status: " + status + " )");
6239
6240            Intent intentTxTune = new Intent(
6241                    FmRadioIntent.FM_TX_TUNE_ACTION);
6242            intentTxTune.putExtra(FmRadioIntent.TUNED_FREQUENCY, value);
6243            intentTxTune.putExtra(FmRadioIntent.STATUS, status);
6244            mContext.sendBroadcast(intentTxTune, FMRX_PERM);
6245
6246    }
6247
6248
6249        public void fmTxCmdGetTunedFrequency(JFmTx context, JFmTxStatus status,
6250            long value) {
6251
6252        Log.i(TAG, "StubFmService:fmTxCmdGetTunedFrequency ");
6253        Log.d(TAG, "  fmTxCmdGetTunedFrequency ( status: " + status + " )");
6254
6255    }
6256
6257
6258
6259        public void fmTxCmdSetRdsTransmissionMode(JFmTx context,JFmTxStatus status,
6260            long value) {
6261
6262        Log.i(TAG, "StubFmService:fmTxCmdSetRdsTransmissionMode ");
6263        Log.d(TAG, "  fmTxCmdSetRdsTransmissionMode ( status: " + status + " )");
6264
6265
6266            Intent txMode = new Intent(
6267                    FmRadioIntent.FM_TX_SET_TRANSMISSION_MODE_ACTION);
6268            txMode.putExtra(FmRadioIntent.TX_MODE, value);
6269            txMode.putExtra(FmRadioIntent.STATUS, status);
6270            mContext.sendBroadcast(txMode, FMRX_PERM);
6271
6272
6273    }
6274
6275
6276        public void fmTxCmdGetRdsTransmissionMode(JFmTx context,  JFmTxStatus status,
6277            long value) {
6278
6279        Log.i(TAG, "StubFmService:fmTxCmdGetRdsTransmissionMode ");
6280        Log.d(TAG, "  fmTxCmdGetRdsTransmissionMode ( status: " + status + " ) value: " + value + ")");
6281
6282    }
6283
6284
6285        public void fmTxCmdSetMonoStereoMode(JFmTx context,  JFmTxStatus status,
6286            long value) {
6287
6288        Log.i(TAG, "StubFmService:fmTxCmdSetMonoStereoMode ");
6289        Log.d(TAG, "  fmTxCmdSetMonoStereoMode ( status: " + status + " )");
6290
6291        Intent txModeMonoStereo = new Intent(
6292                FmRadioIntent.FM_TX_SET_MONO_STEREO_MODE_ACTION);
6293        txModeMonoStereo.putExtra(FmRadioIntent.MODE_MONO_STEREO, value);
6294        txModeMonoStereo.putExtra(FmRadioIntent.STATUS, status);
6295        mContext.sendBroadcast(txModeMonoStereo, FMRX_PERM);
6296
6297
6298    }
6299
6300        public void fmTxCmdGetMonoStereoMode(JFmTx context,  JFmTxStatus status,
6301            long value) {
6302
6303        Log.i(TAG, "StubFmService:fmTxCmdGetMonoStereoMode ");
6304        Log.d(TAG, "  fmTxCmdGetMonoStereoMode ( status: " + status + " ) value: " + value + ")");
6305    }
6306
6307        public void fmTxCmdSetPreEmphasisFilter(JFmTx context,  JFmTxStatus status,
6308            long value) {
6309
6310        Log.i(TAG, "StubFmService:fmTxCmdSetPreEmphasisFilter ");
6311        Log.d(TAG, "  fmTxCmdSetPreEmphasisFilter ( status: " + status + " )");
6312
6313        Log.i(TAG, "StubFmService:Calling txGetPreEmphasisFilter().. ");
6314
6315    }
6316
6317        public void fmTxCmdGetPreEmphasisFilter(JFmTx context,  JFmTxStatus status,
6318            long value) {
6319
6320        Log.i(TAG, "StubFmService:fmTxCmdGetPreEmphasisFilter ");
6321        Log.d(TAG, "  fmTxCmdGetPreEmphasisFilter ( status: " + status + " ) value: " + value + ")");
6322    }
6323
6324
6325        public void fmTxCmdSetMuteMode(JFmTx context,  JFmTxStatus status,
6326            long value) {
6327
6328        Log.i(TAG, "StubFmService:fmTxCmdSetMuteMode ");
6329        Log.d(TAG, "  fmTxCmdSetMuteMode ( status: " + status + " )");
6330        Intent intentMute = new Intent(FmRadioIntent.FM_TX_SET_MUTE_MODE_ACTION);
6331        intentMute.putExtra(FmRadioIntent.TX_REPERTOIRE, value);
6332        intentMute.putExtra(FmRadioIntent.STATUS, status);
6333        mContext.sendBroadcast(intentMute, FMRX_PERM);
6334
6335    }
6336
6337
6338        public void fmTxCmdGetMuteMode(JFmTx context,  JFmTxStatus status,
6339            long value) {
6340
6341        Log.i(TAG, "StubFmService:fmTxCmdGetMuteMode ");
6342        Log.d(TAG, "  fmTxCmdGetMuteMode ( status: " + status + " ) value: " + value + ")");
6343
6344    }
6345
6346
6347
6348        public void fmTxCmdSetRdsAfCode(JFmTx context,  JFmTxStatus status,
6349            long value) {
6350
6351        Log.i(TAG, "StubFmService:fmTxCmdSetRdsAfCode ");
6352        Log.d(TAG, "  fmTxCmdSetRdsAfCode ( status: " + status + " )");
6353    }
6354
6355
6356        public void fmTxCmdGetRdsAfCode(JFmTx context,  JFmTxStatus status,
6357            long value) {
6358
6359        Log.i(TAG, "StubFmService:fmTxCmdGetRdsAfCode ");
6360        Log.d(TAG, "  fmTxCmdGetRdsAfCode ( status: " + status + " ) value: " + value + ")");
6361
6362    }
6363
6364
6365
6366        public void fmTxCmdSetRdsPiCode(JFmTx context,  JFmTxStatus status,
6367            long value) {
6368
6369        Log.i(TAG, "StubFmService:fmTxCmdSetRdsPiCode ");
6370        Log.d(TAG, "  fmTxCmdSetRdsPiCode (status: " + status + " )");
6371
6372    }
6373
6374
6375
6376        public void fmTxCmdGetRdsPiCode(JFmTx context,  JFmTxStatus status,
6377            long value) {
6378
6379        Log.i(TAG, "StubFmService:fmTxCmdGetRdsPiCode ");
6380        Log.d(TAG, "  fmTxCmdGetRdsPiCode ( status: " + status + " ) value: " + value + ")");
6381
6382    }
6383
6384
6385
6386
6387        public void fmTxCmdSetRdsPtyCode(JFmTx context,  JFmTxStatus status,
6388            long value) {
6389
6390        Log.i(TAG, "StubFmService:fmTxCmdSetRdsPtyCode ");
6391        Log.d(TAG, "  fmTxCmdSetRdsPtyCode ( status: " + status + " )");
6392
6393    }
6394
6395
6396        public void fmTxCmdGetRdsPtyCode(JFmTx context,  JFmTxStatus status,
6397            long value) {
6398
6399        Log.i(TAG, "StubFmService:fmTxCmdGetRdsPtyCode ");
6400        Log.d(TAG, "  fmTxCmdGetRdsPtyCode ( status: " + status + " ) value: " + value + ")");
6401
6402    }
6403
6404
6405
6406        public void fmTxCmdSetRdsTextRepertoire(JFmTx context,  JFmTxStatus status,
6407            long value) {
6408
6409        Log.i(TAG, "StubFmService:fmTxCmdSetRdsTextRepertoire ");
6410        Log.d(TAG, "  fmTxCmdSetRdsTextRepertoire ( status: " + status + " )");
6411        Intent intentRepertoire = new Intent(FmRadioIntent. FM_TX_SET_RDS_TEXT_REPERTOIRE_ACTION);
6412        intentRepertoire.putExtra(FmRadioIntent.TX_REPERTOIRE, value);
6413        intentRepertoire.putExtra(FmRadioIntent.STATUS, status);
6414        mContext.sendBroadcast(intentRepertoire, FMRX_PERM);
6415
6416    }
6417
6418
6419        public void fmTxCmdGetRdsTextRepertoire(JFmTx context,  JFmTxStatus status,
6420            long value) {
6421
6422        Log.i(TAG, "StubFmService:fmTxCmdGetRdsTextRepertoire ");
6423        Log.d(TAG, "  fmTxCmdGetRdsTextRepertoire ( status: " + status + " ) value: " + value + ")");
6424
6425    }
6426
6427
6428        public void fmTxCmdSetRdsPsDisplayMode(JFmTx context,  JFmTxStatus status,
6429            long value) {
6430
6431        Log.i(TAG, "StubFmService:fmTxCmdSetRdsPsDisplayMode ");
6432        Log.d(TAG, "  fmTxCmdSetRdsPsDisplayMode ( status: " + status + " )");
6433        Intent intentRdsPsDisplayMode = new Intent(
6434                FmRadioIntent.FM_TX_PS_DISPLAY_MODE_ACTION);
6435        intentRdsPsDisplayMode.putExtra(FmRadioIntent.DISPLAY_MODE, value);
6436        intentRdsPsDisplayMode.putExtra(FmRadioIntent.STATUS, status);
6437        mContext.sendBroadcast(intentRdsPsDisplayMode, FMRX_PERM);
6438
6439    }
6440
6441
6442
6443        public void fmTxCmdGetRdsPsDisplayMode(JFmTx context,  JFmTxStatus status,
6444            long value) {
6445
6446        Log.i(TAG, "StubFmService:fmTxCmdGetRdsPsDisplayMode ");
6447        Log.d(TAG, "  fmTxCmdGetRdsPsDisplayMode ( status: " + status + " ) value: " + value + ")");
6448
6449    }
6450
6451
6452        public void fmTxCmdSetRdsPsScrollSpeed(JFmTx context,  JFmTxStatus status,
6453            long value) {
6454
6455        Log.i(TAG, "StubFmService:fmTxCmdSetRdsPsScrollSpeed ");
6456        Log.d(TAG, "  fmTxCmdSetRdsPsScrollSpeed ( status: " + status + " )");
6457
6458    }
6459
6460
6461        public void fmTxCmdGetRdsPsScrollSpeed(JFmTx context,  JFmTxStatus status,
6462            long value) {
6463
6464        Log.i(TAG, "StubFmService:fmTxCmdGetRdsPsScrollSpeed ");
6465        Log.d(TAG, "  fmTxCmdGetRdsPsScrollSpeed ( status: " + status + " ) value: " + value + ")");
6466
6467    }
6468
6469
6470
6471        public void fmTxCmdSetRdsTextRtMsg(JFmTx context,  JFmTxStatus status,
6472            int msgType,int msgLen,byte[]msg) {
6473
6474        Log.i(TAG, "StubFmService:fmTxCmdSetRdsTextRtMsg ");
6475        Log.d(TAG, "  fmTxCmdSetRdsTextRtMsg ( status: " + status + " )");
6476    }
6477
6478
6479
6480        public void fmTxCmdGetRdsTextRtMsg(JFmTx context,  JFmTxStatus status,
6481            int msgType,int msgLen,byte[]msg) {
6482
6483        Log.i(TAG, "StubFmService:fmTxCmdGetRdsTextRtMsg ");
6484        Log.d(TAG, "  fmTxCmdgetRdsTextRtMsg ( status: " + status + "msgType: " + msgType +
6485            "msgLen: " + msgLen + ")");
6486    }
6487
6488
6489
6490        public void fmTxCmdSetRdsTextPsMsg(JFmTx context,  JFmTxStatus status,
6491            int msgLen,byte[] msg) {
6492
6493        Log.i(TAG, "StubFmService:fmTxCmdSetRdsTextPsMsg ");
6494        Log.d(TAG, "  fmTxCmdSetRdsTextPsMsg ( status: " + status + " )");
6495        Intent intentPsMsg = new Intent(
6496                FmRadioIntent.FM_TX_SET_RDS_TEXT_PS_MSG_ACTION);
6497
6498        String psString = new String(msg);
6499        intentPsMsg.putExtra(FmRadioIntent.PS_MSG, psString);
6500        intentPsMsg.putExtra(FmRadioIntent.STATUS, status);
6501        mContext.sendBroadcast(intentPsMsg, FMRX_PERM);
6502
6503    }
6504
6505
6506
6507        public void fmTxCmdGetRdsTextPsMsg(JFmTx context,  JFmTxStatus status,
6508            int msgLen,byte[] msg) {
6509
6510        Log.i(TAG, "StubFmService:fmTxCmdGetRdsTextPsMsg ");
6511        Log.d(TAG, "  fmTxCmdGetRdsTextPsMsg ( status: " + status +
6512            "msgLen: " + msgLen + ")");
6513    }
6514
6515
6516
6517/*
6518        public void fmTxCmdGetRdsTransmittedGroupsMask(JFmTx context,  JFmTxStatus status,
6519            long value) {
6520
6521        Log.i(TAG, "StubFmService:fmTxCmdGetRdsTransmittedGroupsMask ");
6522        Log.d(TAG, "  fmTxCmdGetRdsTransmittedGroupsMask ( status: " + status + " ) value: " + value + ")");
6523
6524
6525    }
6526*/
6527
6528        public void fmTxCmdSetRdsTrafficCodes(JFmTx context,  JFmTxStatus status,
6529            int tacode,int tpCode) {
6530
6531        Log.i(TAG, "StubFmService:fmTxCmdSetRdsTrafficCodes ");
6532        Log.d(TAG, "  fmTxCmdSetRdsTrafficCodes ( status: " + status + " )");
6533
6534    }
6535
6536
6537        public void fmTxCmdGetRdsTrafficCodes(JFmTx context,  JFmTxStatus status,
6538            int tacode,int tpCode) {
6539
6540        Log.i(TAG, "StubFmService:fmTxCmdGetRdsTrafficCodes ");
6541        Log.d(TAG, "  fmTxCmdGetRdsTrafficCodes ( status: " + status + " ) tpCode: " +tpCode+ " tacode: " + tacode );
6542    }
6543
6544
6545        public void fmTxCmdSetRdsMusicSpeechFlag(JFmTx context,  JFmTxStatus status,
6546            long value) {
6547
6548        Log.i(TAG, "StubFmService:fmTxCmdSetRdsMusicSpeechFlag ");
6549        Log.d(TAG, "  fmTxCmdSetRdsMusicSpeechFlag ( status: " + status + " )");
6550
6551
6552        Intent intentMusicSpeechFlag = new Intent(
6553                FmRadioIntent.FM_TX_SET_RDS_MUSIC_SPEECH_FLAG_ACTION);
6554        intentMusicSpeechFlag.putExtra(FmRadioIntent.MUSIC_SPEECH_FLAG, value);
6555        intentMusicSpeechFlag.putExtra(FmRadioIntent.STATUS, status);
6556        mContext.sendBroadcast(intentMusicSpeechFlag, FMRX_PERM);
6557
6558    }
6559
6560
6561
6562        public void fmTxCmdGetRdsMusicSpeechFlag(JFmTx context,  JFmTxStatus status,
6563            long value) {
6564
6565        Log.i(TAG, "StubFmService:fmTxCmdGetRdsMusicSpeechFlag ");
6566        Log.d(TAG, "  fmTxCmdGetRdsMusicSpeechFlag ( status: " + status + " ) value: " + value + ")");
6567
6568    }
6569
6570
6571
6572
6573        public void fmTxCmdChangeAudioSource(JFmTx context,  JFmTxStatus status,
6574            JFmCcmVacUnavailResourceList ccmVacUnavailResourceList) {
6575
6576        Log.i(TAG, "StubFmService:fmTxCmdChangeAudioSource ");
6577        Log.d(TAG, "  fmTxCmdChangeAudioSource ( status: " + status + " )");
6578    }
6579   /*
6580        public void fmTxCmdChangeDigitalAudioConfiguration(JFmTx context,  JFmTxStatus status,
6581            JFmCcmVacUnavailResourceList ccmVacUnavailResourceList) {
6582
6583        Log.i(TAG, "StubFmService:fmTxCmdChangeDigitalAudioConfiguration ");
6584        Log.d(TAG, "  fmTxCmdChangeDigitalAudioConfiguration ( command: , status:  )" + command
6585                );
6586    }
6587*/
6588
6589
6590
6591        public void fmTxCmdSetInterruptMask(JFmTx context,  JFmTxStatus status,
6592            long value) {
6593
6594        Log.i(TAG, "StubFmService:fmTxCmdSetInterruptMask ");
6595        Log.d(TAG, "  fmTxCmdSetInterruptMask ( status: " + status + " )");
6596    }
6597
6598
6599        public void fmTxCmdGetInterruptMask(JFmTx context,  JFmTxStatus status,
6600            long value) {
6601
6602        Log.i(TAG, "StubFmService:fmTxCmdGetInterruptMask ");
6603        Log.d(TAG, "  fmTxCmdGetInterruptMask ( status: " + status + " ) value: " + value + ")");
6604    }
6605
6606
6607        public void fmTxCmdSetRdsPsDisplaySpeed(JFmTx context,  JFmTxStatus status,
6608            long value) {
6609
6610        Log.i(TAG, "StubFmService:fmTxCmdSetRdsPsDisplaySpeed ");
6611        Log.d(TAG, "  fmTxCmdSetRdsPsDisplaySpeed ( status: " + status + " )");
6612
6613    }
6614
6615
6616
6617        public void fmTxCmdGetRdsPsDisplaySpeed(JFmTx context,  JFmTxStatus status,
6618            long value) {
6619
6620        Log.i(TAG, "StubFmService:fmTxCmdGetRdsPsDisplaySpeed ");
6621        Log.d(TAG, "  fmTxCmdGetRdsPsDisplaySpeed ( status: " + status + " ) value: " + value + ")");
6622    }
6623
6624
6625        public void fmTxCmdReadRdsRawData(JFmTx context,  JFmTxStatus status,
6626            int len,byte[] msg) {
6627
6628        Log.i(TAG, "StubFmService:fmTxCmdReadRdsRawData ");
6629        Log.d(TAG, "  fmTxCmdReadRdsRawData ( status: " + status + " ) len: " + len + ")");
6630    }
6631
6632
6633
6634
6635        public void fmTxCmdSetRdsTransmittedMask(JFmTx context,  JFmTxStatus status,
6636            long value) {
6637
6638        Log.i(TAG, "StubFmService:fmTxCmdSetRdsTransmittedMask ");
6639        Log.d(TAG, "  fmTxCmdSetRdsTransmittedMask (  status: " + status + " ) value: " + value + ")");
6640
6641
6642        Intent intentRdsTxGrpMask = new Intent(
6643                FmRadioIntent.FM_TX_SET_RDS_TRANSMISSION_GROUPMASK_ACTION);
6644
6645        intentRdsTxGrpMask.putExtra(FmRadioIntent.RDS_GRP_MASK, value);
6646        intentRdsTxGrpMask.putExtra(FmRadioIntent.STATUS, status);
6647        mContext.sendBroadcast(intentRdsTxGrpMask, FMRX_PERM);
6648
6649
6650    }
6651
6652
6653
6654        public void fmTxCmdGetRdsTransmittedMask(JFmTx context,  JFmTxStatus status,
6655            long value) {
6656
6657        Log.i(TAG, "StubFmService:fmTxCmdGetRdsTransmittedMask ");
6658        Log.d(TAG, "  fmTxCmdGetRdsTransmittedMask ( status: " + status + " )");
6659    }
6660
6661
6662
6663        public void fmTxCmdChangeDigitalAudioConfiguration(JFmTx context,  JFmTxStatus status,
6664            long value) {
6665
6666        Log.i(TAG, "StubFmService:fmTxCmdChangeDigitalAudioConfiguration ");
6667        Log.d(TAG, "  fmTxCmdChangeDigitalAudioConfiguration ( status: " + status + " )");
6668    }
6669
6670
6671
6672        public void fmTxCmdSetRdsExtendedCountryCode(JFmTx context,  JFmTxStatus status,
6673            long value) {
6674
6675        Log.i(TAG, "StubFmService:fmTxCmdSetRdsExtendedCountryCode ");
6676        Log.d(TAG, "  fmTxCmdSetRdsExtendedCountryCode ( status: " + status + " )");
6677
6678    }
6679
6680
6681
6682        public void fmTxCmdGetRdsExtendedCountryCode(JFmTx context,  JFmTxStatus status,
6683            long value) {
6684
6685        Log.i(TAG, "StubFmService:fmTxCmdGetRdsExtendedCountryCode ");
6686        Log.d(TAG, "  fmTxCmdGetRdsExtendedCountryCode (  status: " + status + " ) value: " + value + ")");
6687    }
6688
6689
6690        public void fmTxCmdWriteRdsRawData(JFmTx context,  JFmTxStatus status,
6691            int len, byte[] msg) {
6692
6693        Log.i(TAG, "StubFmService:fmTxCmdWriteRdsRawData ");
6694        Log.d(TAG, "  fmTxCmdWriteRdsRawData ( status: " + status + " )");
6695    }
6696
6697
6698
6699        public void fmTxCmdSetRdsPsDispalyMode(JFmTx context,  JFmTxStatus status,
6700            long value) {
6701
6702        Log.i(TAG, "StubFmService:fmTxCmdSetRdsPsDispalyMode ");
6703        Log.d(TAG, "  fmTxCmdSetRdsPsDispalyMode ( status: " + status + " )");
6704    }
6705
6706
6707
6708        public void fmTxCmdGetRdsPsDispalyMode(JFmTx context,  JFmTxStatus status,
6709            long value) {
6710
6711        Log.i(TAG, "StubFmService:fmTxCmdGetRdsPsDispalyMode ");
6712        Log.d(TAG, "  fmTxCmdGetRdsPsDispalyMode (  status: " + status + " ) value: " + value + ")");
6713        }
6714
6715
6716        public void fmTxCmdGetPowerLevel(JFmTx context,  JFmTxStatus status,
6717            long value) {
6718
6719        Log.i(TAG, "StubFmService:fmTxCmdGetPowerLevel ");
6720        Log.d(TAG, "  fmTxCmdGetPowerLevel (  status: " + status + " ) value: " + value + ")");
6721    }
6722
6723    /*Play Mp3 file*/
6724    private void musicPlay(Context context)
6725    {
6726               MediaPlayer mp = MediaPlayer.create(context,
6727                    R.raw.ding);
6728            mp.start();
6729            // react on the end of the music-file:
6730            mp.setOnCompletionListener(new OnCompletionListener(){
6731
6732                public void onCompletion(MediaPlayer mp) {
6733                    // File has ended !!!
6734                    cleanupPlayer(mp);
6735                }
6736            });
6737    }
6738
6739
6740       private void cleanupPlayer(MediaPlayer mp) {
6741          if (mp != null) {
6742             try {
6743                mp.stop();
6744                mp.release();
6745             } catch (IllegalStateException ex) {
6746                Log.w(TAG, "MediaPlayer IllegalStateException: "+ex);
6747             }
6748          }
6749       }
6750
6751    /* Broadcast receiver for the HEDASET_PLUG broadcast intent.*/
6752    private final BroadcastReceiver mHeadsetPlugReceiver = new BroadcastReceiver() {
6753
6754    public void onReceive(Context context, Intent intent) {
6755
6756        Log.i(TAG, " mHeadsetPlugReceiver--->onReceive");
6757             int state = intent.getIntExtra("state", 0);
6758             if (mRxState == STATE_ENABLED ){
6759                int on =1;
6760                if (state == 1) {
6761                   Log.i(TAG, " mHeadsetPlugReceiver--->Headset plugged");
6762                   /* L25 Specific */
6763                   /* HEADSET IS OR HAS BEEN CONNECTED */
6764                 /*Play a ding mp3 file to force the new routing to take effect,
6765                   as FM analog playback is not associated with any PCM stream to trigger
6766                   the routing change based on headset detection*/
6767                 //musicPlay(context);
6768                } else {
6769                  Log.i(TAG, " mHeadsetPlugReceiver--->Headset unplugged");
6770                }
6771                /* L27 Specific */
6772
6773                enableRx(on-1);
6774                enableRx(on);
6775              }
6776
6777       }
6778    };
6779
6780
6781    /* Broadcast receiver for the ACTION_MEDIA_BUTTON broadcast intent.*/
6782
6783    private class MediaButtonBroadcastReceiver extends BroadcastReceiver {
6784       @Override
6785       public void onReceive(Context context, Intent intent) {
6786    Log.i(TAG, " MediaButtonBroadcastReceiver--->onReceive");
6787    String intentAction = intent.getAction();
6788    if (Intent.ACTION_MEDIA_BUTTON.equals(intentAction))
6789    {
6790        KeyEvent event = (KeyEvent)
6791        intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
6792
6793        if (event == null) {
6794            return;
6795        }
6796
6797        int keycode = event.getKeyCode();
6798        int action = event.getAction();
6799
6800        boolean volState;
6801
6802        synchronized (mVolumeSynchronizationLock) {
6803        volState = mVolState;
6804        }
6805
6806        int mVolume = mAudioManager
6807        .getStreamVolume(AudioManager.STREAM_MUSIC);
6808        // Convert the stream volume to the FM specific volume.
6809        mVolume = (mVolume * FM_MAX_VOLUME)/ (mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC));
6810        Log.i(TAG, "  Audio Manager mVolume  " + mVolume);
6811
6812        switch (keycode) {
6813            case KeyEvent.KEYCODE_VOLUME_UP:
6814            mVolume ++;
6815            break;
6816
6817            case KeyEvent.KEYCODE_VOLUME_DOWN:
6818            mVolume --;
6819            break;
6820        }
6821
6822        if (action == KeyEvent.ACTION_DOWN) {
6823            if (mVolState) {
6824
6825                    if (!rxSetVolume(mVolume)) {
6826                    Log.i(TAG, "Not able, to set volume ");
6827                    }
6828                    Log.i(TAG, "send intent for UI updation ");
6829                    /* Send Intent to App for UI updation */
6830                    Intent intentMasterVolume = new Intent(
6831                    FmRadioIntent.MASTER_VOLUME_CHANGED_ACTION);
6832                    intentMasterVolume.putExtra(FmRadioIntent.MASTER_VOLUME,mVolume);
6833                    mContext.sendBroadcast(intentMasterVolume, FMRX_PERM);
6834
6835                } // mVolState
6836                else {
6837                    Log.i(TAG, "previous volume set not complete ");
6838                }
6839        }
6840
6841        if (isOrderedBroadcast()) {
6842        abortBroadcast();
6843        }
6844
6845        }
6846
6847    }
6848
6849    }
6850
6851
6852    private class SmsBroadcastReceiver extends BroadcastReceiver {
6853       public void onReceive(Context context, Intent intent) {
6854        Log.i(TAG, " SmsBroadcastReceiver--->onReceive");
6855        rxSetMuteMode(FM_MUTE);
6856
6857          }
6858    }
6859
6860
6861    // Receiver of the Intent Broadcasted by AudioService
6862    private final BroadcastReceiver mFmRxIntentReceiver = new BroadcastReceiver() {
6863
6864        public void onReceive(Context context, Intent intent) {
6865
6866            String fmRxAction = intent.getAction();
6867            boolean setVolume = false;
6868            Log.d(TAG, " mFmRxIntentReceiver--->fmRxAction" + fmRxAction);
6869            int volType = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, AudioManager.STREAM_MUSIC);
6870
6871
6872
6873
6874            /*
6875             * Intent received when the volume has been changed from the master
6876             * volume control keys. Convert it to the FM specific volume and set
6877             * the volume.
6878             */
6879            if (fmRxAction.equals(AudioManager.VOLUME_CHANGED_ACTION)) {
6880                Log.i(TAG, " AUDIOMANGER_VOLUME_CHANGED_ACTION    ");
6881                if ((mRxState == STATE_ENABLED)&&
6882                    (volType == AudioManager.STREAM_MUSIC) ){
6883                    Log.i(TAG, " AUDIOMANGER_VOLUME_CHANGED_ACTION ");
6884                    setVolume = true;
6885                } // mRxState & volType
6886
6887                else {
6888                    Log.i(TAG,"VOLUME_CHANGED_ACTION Intent is Ignored, as FM is not yet Enabled");
6889
6890                }
6891            } // volume _change
6892
6893            /*
6894             * Intent recived if the video or Music playback has started.
6895             * Disable the FM and let the music/video playback proceed.
6896             */
6897            if (fmRxAction.equals(FM_PAUSE_CMD) ) {
6898                Log.i(TAG, FM_PAUSE_CMD);
6899                if (rxIsEnabled() == true) {
6900                    pauseFm();
6901                }
6902            }
6903
6904            /*
6905             * Intent recived if the video or Music playback has started.
6906             * Disable the FM and let the music/video playback proceed.
6907             */
6908            if (fmRxAction.equals(FM_RESUME_CMD)) {
6909                Log.i(TAG, FM_RESUME_CMD);
6910                // resume playback only if FM was playing
6911                // when the call was answered
6912                resumeFm();
6913
6914            }
6915            /*
6916             * Intent recived if the Notification sound playback has started.
6917             * Mute the FM and let the notification sound playback proceed.
6918             */
6919            if (fmRxAction.equals(FM_MUTE_CMD) ) {
6920                Log.i(TAG, FM_MUTE_CMD);
6921                if (rxIsEnabled() == true)
6922                {
6923                    mIsFmMuted = true;
6924                    if (MAKE_FM_APIS_BLOCKING == true) {
6925                    Log.i(TAG, " Blocking version");
6926                    rxSetMuteMode(FM_MUTE);
6927                    } else {
6928                    Log.i(TAG, " Non blocking version");
6929                    rxSetMuteMode_nb(FM_MUTE);
6930                    }
6931                }
6932
6933            }
6934
6935            /*
6936             * Intent recived if the Notification sound playback has stopped.
6937             * UnMute the FM and let the notification sound playback proceed.
6938             */
6939            if (fmRxAction.equals(FM_UNMUTE_CMD) ) {
6940                Log.i(TAG, FM_UNMUTE_CMD);
6941                if (rxIsEnabled() == true)
6942                {
6943                    mIsFmMuted = false ;
6944                    if (MAKE_FM_APIS_BLOCKING == true) {
6945                    Log.i(TAG, " Blocking version");
6946                    rxSetMuteMode(FM_NOT_MUTE);
6947                    } else {
6948                    Log.i(TAG, " Non blocking version");
6949                    rxSetMuteMode_nb(FM_NOT_MUTE);
6950                    }
6951                }
6952
6953            }
6954
6955            /*
6956             * Intent recived if the Alarm alert is recieved sound playback has stopped.
6957             * UnMute the FM and let the Alarm sound playback proceed.
6958             */
6959
6960            if (fmRxAction.equals(ALARM_ALERT_ACTION)) {
6961                Log.i(TAG, ALARM_ALERT_ACTION);
6962                if (rxIsEnabled() == true)
6963                {
6964                    mIsFmMuted = true;
6965                    if (MAKE_FM_APIS_BLOCKING == true) {
6966                    Log.i(TAG, " Blocking version");
6967                    rxSetMuteMode(FM_MUTE);
6968                    } else {
6969                    Log.i(TAG, " Non blocking version");
6970                    rxSetMuteMode_nb(FM_MUTE);
6971                                enableRx(0);
6972                    }
6973
6974                }
6975            }
6976
6977                   if (fmRxAction.equals(MUSIC_PAUSE_ACTION)) {
6978                         Log.i(TAG, MUSIC_PAUSE_ACTION);
6979                         String cmd = intent.getStringExtra("command");
6980                         if (CMDPAUSE.equals(cmd)) {
6981                              if (rxIsEnabled() == true) {
6982                                pauseFm();
6983                              Log.i(TAG, "FM app exit");
6984                             }
6985                         }
6986                   }
6987            /*
6988             * Intent recived if the Alarm alert has stopped sounding for any reason
6989             * UnMute the FM and let the Alarm sound playback proceed.
6990             */
6991
6992            if (fmRxAction.equals(ALARM_DONE_ACTION) ) {
6993                Log.i(TAG, ALARM_DONE_ACTION );
6994                if (rxIsEnabled() == true)
6995                {
6996                    mIsFmMuted = false ;
6997                    if (MAKE_FM_APIS_BLOCKING == true) {
6998                    Log.i(TAG, " Blocking version");
6999                    rxSetMuteMode(FM_NOT_MUTE);
7000                    } else {
7001                    Log.i(TAG, " Non blocking version");
7002                    rxSetMuteMode_nb(FM_NOT_MUTE);
7003                                enableRx(1);
7004                    }
7005
7006                }
7007            }
7008
7009
7010            if (fmRxAction.equals(FM_RESTORE_VALUES)) {
7011                Log.e(TAG, "FM_RESTORE_VALUES intent received");
7012
7013                setVolume = true;
7014
7015                if (mFmPauseResume == STATE_RESUME) {
7016
7017                    if (MAKE_FM_APIS_BLOCKING == true) {
7018                    Log.d(TAG, " Blocking version");
7019                    rxSetBand(mCurrentBand);
7020                    rxSetMuteMode(mCurrentMuteMode);
7021                    if(mCurrentRdsState)
7022                    {
7023                    Log.d(TAG, " restore mCurrentRdsState");
7024                    rxEnableRds();
7025                    }
7026
7027                } else {
7028
7029                    Log.d(TAG, " Non blocking version");
7030                    rxSetBand_nb(mCurrentBand);
7031                    rxSetMuteMode_nb(mCurrentMuteMode);
7032                    if(mCurrentRdsState)
7033                    {
7034                    Log.d(TAG, " restore mCurrentRdsState");
7035                    rxEnableRds_nb();
7036                    }
7037                    }
7038                    rxTune_nb(mCurrentFrequency);
7039                    //rxEnableAudioRouting();
7040                    mFmPauseResume = STATE_DEFAULT;
7041
7042                }
7043            }
7044
7045            if (setVolume) {
7046                boolean volState;
7047
7048                synchronized (mVolumeSynchronizationLock) {
7049                    volState = mVolState;
7050                }
7051                if (mVolState) {
7052                    int mVolume = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, 0);
7053                    if (mVolume == 0) {
7054                        Log.i(TAG, "no volume setting in intent");
7055                        // read the current volume
7056                        mVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
7057                    }
7058
7059                Log.i(TAG, "  Audio Manager mVolume  " + mVolume);
7060                    // Convert the stream volume to the FM specific volume.
7061                    mVolume = (mVolume * FM_MAX_VOLUME)/ (mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC));
7062
7063                    Log.i(TAG, " mVolume  " + mVolume);
7064                    if (!rxSetVolume(mVolume)) {
7065                    Log.i(TAG, "Not able, to set volume ");
7066                    }
7067                    Log.i(TAG, "send intent for UI updation ");
7068                    /* Send Intent to App for UI updation */
7069                    Intent intentMasterVolume = new Intent(
7070                            FmRadioIntent.MASTER_VOLUME_CHANGED_ACTION);
7071                intentMasterVolume.putExtra(FmRadioIntent.MASTER_VOLUME,mVolume);
7072                    mContext.sendBroadcast(intentMasterVolume, FMRX_PERM);
7073
7074                } // mVolState
7075                else {
7076                Log.i(TAG, "previous volume set not complete ");
7077                }
7078            }
7079
7080        }
7081    };
7082
7083    private  void updateEnableConfiguration() {
7084
7085            mRxState = STATE_ENABLED;
7086        Log.d(TAG, "FM RX powered on mRxState " + mRxState);
7087        Log.d(TAG, "StubFmService:sending intent FM_ENABLED_ACTION");
7088
7089        /*
7090         * Tell the Audio Hardware interface that FM is enabled, so that routing
7091         * happens appropriately
7092         */
7093         int on = 1;
7094         enableRx(on);
7095         /*
7096          * Previously when FM playback use to happen the wake lock was present in kernel
7097          * which used to prevent device into suspend. And FM playback used to work
7098          * Now, the wake lock has been removed and the FM service will not control
7099          * by acquiring wake lock and releasing once FM is off
7100          */
7101	 if (mWakeLock != null) {
7102		 if (!mWakeLock.isHeld()) {
7103			 mWakeLock.acquire();
7104		 } else
7105			 Log.e(TAG," Wake lock is already held");
7106	 }
7107    }
7108
7109        private  void enableIntent(JFmRxStatus status) {
7110            Intent intentEnable = new Intent(FmRadioIntent.FM_ENABLED_ACTION);
7111            intentEnable.putExtra(FmRadioIntent.STATUS, status);
7112            mContext.sendBroadcast(intentEnable, FMRX_PERM);
7113        }
7114
7115    /***************************************************************
7116     *  findAndPrintFromLookup():
7117     *
7118     ****************************************************************/
7119    public String findFromLookupTable(byte[] indexArray,
7120            JFmRx.JFmRxRepertoire repertoire) {
7121        StringBuilder sb = new StringBuilder("");
7122
7123        Log.i(TAG, "findFromLookupTable");
7124        Log.i(TAG, "Repertoire= " + repertoire);
7125
7126        switch (repertoire) {
7127        case FMC_RDS_REPERTOIRE_G0_CODE_TABLE:
7128            Log.i(TAG, "FMC_RDS_REPERTOIRE_G0_CODE_TABLE");
7129
7130            for (int i = 0; i < indexArray.length; i++) {
7131                int msb = (indexArray[i] & 0xF0) >> 4;
7132                int lsb = (indexArray[i] & 0x0F);
7133                sb.append(lookUpTable_G0[msb][lsb]);
7134            }
7135            break;
7136
7137        case FMC_RDS_REPERTOIRE_G1_CODE_TABLE:
7138            Log.i(TAG, "FMC_RDS_REPERTOIRE_G1_CODE_TABLE");
7139            for (int i = 0; i < indexArray.length; i++) {
7140                int msb = (indexArray[i] & 0xF0) >> 4;
7141                int lsb = (indexArray[i] & 0x0F);
7142                sb.append(lookUpTable_G1[msb][lsb]);
7143            }
7144            break;
7145
7146        case FMC_RDS_REPERTOIRE_G2_CODE_TABLE:
7147            Log.i(TAG, "FMC_RDS_REPERTOIRE_G2_CODE_TABLE");
7148
7149            for (int i = 0; i < indexArray.length; i++) {
7150                int msb = (indexArray[i] & 0xF0) >> 4;
7151                int lsb = (indexArray[i] & 0x0F);
7152                sb.append(lookUpTable_G2[msb][lsb]);
7153            }
7154            break;
7155
7156        default:
7157            Log.i(TAG, "Incorrect Repertoire received...");
7158            String convertedPsString = "???????????";
7159            break;
7160        }
7161
7162        String convertedString = sb.toString();
7163        return convertedString;
7164
7165    }
7166
7167
7168
7169
7170    private final void sendNotificationRX() {
7171        Log.i(TAG, "Sending FM running notification");
7172
7173        // Pack up the values and broadcast them to everyone
7174        Intent FMplaybackIntent = new Intent(
7175                "android.intent.action.FM_PLAYBACK");
7176        NotificationManager mNotificationMgr = (NotificationManager) mContext
7177                .getSystemService(Context.NOTIFICATION_SERVICE);
7178        CharSequence title = "FM Radio RX";
7179        Long lcurrentfreq;
7180        lcurrentfreq = new Long(mCurrentFrequency);
7181        CharSequence details = lcurrentfreq.toString();
7182
7183        PendingIntent intent = PendingIntent.getActivity(mContext, 0,
7184                FMplaybackIntent, 0);
7185        Notification notification = new Notification();
7186
7187        /* Currently making use of the icon in the service. when FM is made application Service
7188        we would use the APP icon  */
7189        notification.icon = R.drawable.rxradio;
7190
7191        notification.setLatestEventInfo(mContext, title, details, intent);
7192        mNotificationMgr.notify(FM_RX_NOTIFICATION_ID, notification);
7193
7194    }
7195
7196
7197    private final void sendNotificationTX() {
7198        Log.i(TAG, "Sending FM running notification");
7199
7200        // Pack up the values and broadcast them to everyone
7201        Intent FMplaybackIntent = new Intent(
7202                "android.intent.action.FMTXRELAUNCH");
7203        NotificationManager mNotificationMgr = (NotificationManager) mContext
7204                .getSystemService(Context.NOTIFICATION_SERVICE);
7205        CharSequence title = "FM Radio TX";
7206
7207        PendingIntent intent = PendingIntent.getActivity(mContext, 0,
7208                FMplaybackIntent, 0);
7209        Notification notification = new Notification();
7210        /* Currently making use of the icon in the service. when FM is made application Service
7211        we would use the APP icon  */
7212        notification.icon = R.drawable.txradio;
7213        CharSequence emptychr = "";
7214        notification.setLatestEventInfo(mContext, title, emptychr, intent);
7215        mNotificationMgr.notify(FM_TX_NOTIFICATION_ID, notification);
7216
7217    }
7218
7219    private final void cancelNotification(int id) {
7220        Log.i(TAG, "Canceling FM  notification");
7221        NotificationManager mNotificationMgr = (NotificationManager) mContext
7222                .getSystemService(Context.NOTIFICATION_SERVICE);
7223        // cancel notification since memory has been freed
7224        mNotificationMgr.cancel(id);
7225
7226    }
7227
7228}
7229