fm/fmapp2/src/com/caf/fmradio/FMTransmitterService.java
private boolean fmOn() {
      boolean bStatus=false;

      Log.d(LOGTAG, "fmOn");
      mWakeLock.acquire(10*1000);
      if (mTransmitter == null) {
          try {
               mTransmitter = new FmTransmitter(FMRADIO_DEVICE_FD_STRING, transmitCallbacks);
               Log.d(LOGTAG, "new transmitter created");
          } catch (InstantiationException e) {
               throw new RuntimeException("FmTx service not available!");
          }
      }
      if (mTransmitter != null)
      {
         if (isFmOn())
         {
            /* FM Is already on,*/
            bStatus = true;
            try {
                 if(mCallbacks != null) {
                    mCallbacks.onEnabled(true);
                 }
            } catch(RemoteException e) {
                 e.printStackTrace();
            }
            Log.d(LOGTAG, "mTransmitter is enabled");
         }
         else
         {
         // This sets up the FM radio device
             FmConfig config = FmSharedPreferences.getFMConfiguration();
             Log.d(LOGTAG, "fmOn: RadioBand   :"+ config.getRadioBand());
             Log.d(LOGTAG, "fmOn: Emphasis    :"+ config.getEmphasis());
             Log.d(LOGTAG, "fmOn: ChSpacing   :"+ config.getChSpacing());
             Log.d(LOGTAG, "fmOn: RdsStd      :"+ config.getRdsStd());
             Log.d(LOGTAG, "fmOn: LowerLimit  :"+ config.getLowerLimit());
             Log.d(LOGTAG, "fmOn: UpperLimit  :"+ config.getUpperLimit());

             boolean bFmRxEnabled = false;

             if (!mA2dpDeviceState.isDeviceAvailable()) {
                 bStatus = mTransmitter.enable(config);
             }
             if( false == bStatus ) {
                Log.e(LOGTAG,"FM Enable failed");
                return bStatus;
             }
             bStatus = mTransmitter.setTxPowerLevel(FmTransmitter.FM_TX_PWR_LEVEL_7);

             if( false == bStatus ) {
                Log.e(LOGTAG,"FM setPowerLevel failed");
                return bStatus;
             }

             Log.e(LOGTAG, "FMTx is on: Requesting to start FM TX");
             AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_FM_TX,
                                  AudioSystem.DEVICE_STATE_AVAILABLE, "");
         }

         if(true == bStatus )
         {
                bStatus = mTransmitter.setRdsOn();
                if( true != bStatus ) {
                    Log.d(LOGTAG, "FMTx setRdsOn failed");
                } else {
                    if(false == mTransmitter.getInternalAntenna()) {
                        Log.d(LOGTAG, "Setting internal antenna explicitly");
                        mTransmitter.setInternalAntenna(true);
                    }
                    startNotification();
                }
         }
         else
         {
             stop();
         }
      }
      return(bStatus);
   }
/*
    * Turn ON FM: Powers up FM hardware, and initializes the FM module
    *                                                                                 .
    * @return true if fm Enable api was invoked successfully, false if the api failed.
    */
Turn ON FM: Powers up FM hardware, and initializes the FM module
.
@return true if fm Enable api was invoked successfully, false if the api failed.
Turn ON FM : Powers up FM hardware and initializes the FM module . @return true if fm Enable api was invoked successfully false if the api failed .
private boolean fmOn() {
      boolean bStatus=false;
      Log.d(LOGTAG, "fmOn");
      mWakeLock.acquire(10*1000);
      if (mTransmitter == null) {
          try {
               mTransmitter = new FmTransmitter(FMRADIO_DEVICE_FD_STRING, transmitCallbacks);
               Log.d(LOGTAG, "new transmitter created");
          } catch (InstantiationException e) {
               throw new RuntimeException("FmTx service not available!");
          }
      }
      if (mTransmitter != null)
      {
         if (isFmOn())
         {
            /* FM Is already on,*/
            bStatus = true;
            try {
                 if(mCallbacks != null) {
                    mCallbacks.onEnabled(true);
                 }
            } catch(RemoteException e) {
                 e.printStackTrace();
            }
            Log.d(LOGTAG, "mTransmitter is enabled");
         }
         else
         {
             FmConfig config = FmSharedPreferences.getFMConfiguration();
             Log.d(LOGTAG, "fmOn: RadioBand   :"+ config.getRadioBand());
             Log.d(LOGTAG, "fmOn: Emphasis    :"+ config.getEmphasis());
             Log.d(LOGTAG, "fmOn: ChSpacing   :"+ config.getChSpacing());
             Log.d(LOGTAG, "fmOn: RdsStd      :"+ config.getRdsStd());
             Log.d(LOGTAG, "fmOn: LowerLimit  :"+ config.getLowerLimit());
             Log.d(LOGTAG, "fmOn: UpperLimit  :"+ config.getUpperLimit());
             boolean bFmRxEnabled = false;
             if (!mA2dpDeviceState.isDeviceAvailable()) {
                 bStatus = mTransmitter.enable(config);
             }
             if( false == bStatus ) {
                Log.e(LOGTAG,"FM Enable failed");
                return bStatus;
             }
             bStatus = mTransmitter.setTxPowerLevel(FmTransmitter.FM_TX_PWR_LEVEL_7);
             if( false == bStatus ) {
                Log.e(LOGTAG,"FM setPowerLevel failed");
                return bStatus;
             }
             Log.e(LOGTAG, "FMTx is on: Requesting to start FM TX");
             AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_FM_TX,
                                  AudioSystem.DEVICE_STATE_AVAILABLE, "");
         }
         if(true == bStatus )
         {
                bStatus = mTransmitter.setRdsOn();
                if( true != bStatus ) {
                    Log.d(LOGTAG, "FMTx setRdsOn failed");
                } else {
                    if(false == mTransmitter.getInternalAntenna()) {
                        Log.d(LOGTAG, "Setting internal antenna explicitly");
                        mTransmitter.setInternalAntenna(true);
                    }
                    startNotification();
                }
         }
         else
         {
             stop();
         }
      }
      return(bStatus);
   }
private boolean fmOn ( ) { boolean bStatus = false ; Log . d ( LOGTAG , "fmOn" ) ; mWakeLock . acquire ( 10 * 1000 ) ; if ( mTransmitter == null ) { try { mTransmitter = new FmTransmitter ( FMRADIO_DEVICE_FD_STRING , transmitCallbacks ) ; Log . d ( LOGTAG , "new transmitter created" ) ; } catch ( InstantiationException e ) { throw new RuntimeException ( "FmTx service not available!" ) ; } } if ( mTransmitter != null ) { if ( isFmOn ( ) ) { /* FM Is already on,*/ bStatus = true ; try { if ( mCallbacks != null ) { mCallbacks . onEnabled ( true ) ; } } catch ( RemoteException e ) { e . printStackTrace ( ) ; } Log . d ( LOGTAG , "mTransmitter is enabled" ) ; } else { FmConfig config = FmSharedPreferences . getFMConfiguration ( ) ; Log . d ( LOGTAG , "fmOn: RadioBand   :" + config . getRadioBand ( ) ) ; Log . d ( LOGTAG , "fmOn: Emphasis    :" + config . getEmphasis ( ) ) ; Log . d ( LOGTAG , "fmOn: ChSpacing   :" + config . getChSpacing ( ) ) ; Log . d ( LOGTAG , "fmOn: RdsStd      :" + config . getRdsStd ( ) ) ; Log . d ( LOGTAG , "fmOn: LowerLimit  :" + config . getLowerLimit ( ) ) ; Log . d ( LOGTAG , "fmOn: UpperLimit  :" + config . getUpperLimit ( ) ) ; boolean bFmRxEnabled = false ; if ( ! mA2dpDeviceState . isDeviceAvailable ( ) ) { bStatus = mTransmitter . enable ( config ) ; } if ( false == bStatus ) { Log . e ( LOGTAG , "FM Enable failed" ) ; return bStatus ; } bStatus = mTransmitter . setTxPowerLevel ( FmTransmitter . FM_TX_PWR_LEVEL_7 ) ; if ( false == bStatus ) { Log . e ( LOGTAG , "FM setPowerLevel failed" ) ; return bStatus ; } Log . e ( LOGTAG , "FMTx is on: Requesting to start FM TX" ) ; AudioSystem . setDeviceConnectionState ( AudioSystem . DEVICE_OUT_FM_TX , AudioSystem . DEVICE_STATE_AVAILABLE , "" ) ; } if ( true == bStatus ) { bStatus = mTransmitter . setRdsOn ( ) ; if ( true != bStatus ) { Log . d ( LOGTAG , "FMTx setRdsOn failed" ) ; } else { if ( false == mTransmitter . getInternalAntenna ( ) ) { Log . d ( LOGTAG , "Setting internal antenna explicitly" ) ; mTransmitter . setInternalAntenna ( true ) ; } startNotification ( ) ; } } else { stop ( ) ; } } return ( bStatus ) ; }
Turn ON FM: Powers up FM hardware, and initializes the FM module
                                                                                 .
Turn ON FM : Powers up FM hardware and initializes the FM module .
// This sets up the FM radio device