fm/qcom/fmradio/FmReceiver.java
public boolean searchStations (int mode,
                                  int dwellPeriod,
                                  int direction){

      int state = getFMState();
      boolean bStatus = true;
      int re;

      /* Check current state of FM device */
      if (state == FMState_Turned_Off || state == FMState_Srch_InProg) {
          Log.d(TAG, "searchStations: Device currently busy in executing another command.");
          return false;
      }

      Log.d (TAG, "Basic search...");

      /* Validate the arguments */
      if ( (mode != FM_RX_SRCH_MODE_SEEK) &&
           (mode != FM_RX_SRCH_MODE_SCAN))
      {
         Log.d (TAG, "Invalid search mode: " + mode );
         bStatus = false;
      }
      if ( (dwellPeriod < FM_RX_DWELL_PERIOD_0S ) ||
           (dwellPeriod > FM_RX_DWELL_PERIOD_7S))
      {
         Log.d (TAG, "Invalid dwelling time: " + dwellPeriod);
         bStatus = false;
      }
      if ( (direction != FM_RX_SEARCHDIR_DOWN) &&
           (direction != FM_RX_SEARCHDIR_UP))
      {
         Log.d (TAG, "Invalid search direction: " + direction);
         bStatus = false;
      }

      if (bStatus)
      {
         Log.d (TAG, "searchStations: mode " + mode + "direction:  " + direction);

         if (mode == FM_RX_SRCH_MODE_SEEK)
             setSearchState(subSrchLevel_SeekInPrg);
         else if (mode == FM_RX_SRCH_MODE_SCAN)
             setSearchState(subSrchLevel_ScanInProg);
         Log.v(TAG, "searchStations: CURRENT-STATE : FMRxOn ---> NEW-STATE : SearchInProg");

         re = mControl.searchStations(sFd, mode, dwellPeriod, direction, 0, 0);
         if (re != 0) {
             Log.e(TAG, "search station failed");
             if (getFMState() == FMState_Srch_InProg)
                 setSearchState(subSrchLevel_SrchComplete);
             return false;
         }
         state = getFMState();
         if (state == FMState_Turned_Off) {
             Log.d(TAG, "searchStations: CURRENT-STATE : FMState_Off (unexpected)");
             return false;
         }
      }
      return bStatus;
   }
/**
   *   Initiates basic seek and scan operations.
   *    <p>
   *    This command is used to invoke a basic seek/scan of the FM
   *    radio band.
   *    <p>
   *    <ul>
   *    This API is used to:
   *    <li> Invoke basic seek operations ({@link
   *    #FM_RX_SRCH_MODE_SEEK})
   *    <li> Invoke basic scan operations ({@link
   *    #FM_RX_SRCH_MODE_SCAN})
   *    </ul>
   *    <p>
   *    The most basic operation performed by this function
   *    is a {@link #FM_RX_SRCH_MODE_SEEK} command. The seek
   *    process is handled incrementing or decrementing the
   *    frequency in pre-defined channel steps (defined by the
   *    channel spacing) and measuring the resulting signal level.
   *    Once a station is successfully tuned and found to meet or
   *    exceed this signal level, the seek operation will be
   *    completed and a FmRxEvSearchComplete event will be returned
   *    to the client. If no stations are found to match the search
   *    criteria, the frequency will be returned to the originally
   *    tuned station.
   *    <p>
   *    Since seek always results in a frequency being tuned, each
   *    seek operation will also return a single
   *    FmRxEvRadioTuneStatus event to the client/application
   *    layer.
   *    <p>
   *    Much like {@link #FM_RX_SRCH_MODE_SEEK}, a {@link
   *    #FM_RX_SRCH_MODE_SCAN} command can be likened to many back
   *    to back seeks with a dwell period after each successful
   *    seek. Once issued, a scan will either increment or
   *    decrement frequencies by the defined channel spacing until
   *    a station is found to meet or exceed the set search
   *    threshold. Once this station is found, and is successfully
   *    tuned, an FmRxEvRadioTuneStatus event will be returned to
   *    the client and the station will remain tuned for the
   *    specific period of time indicated by argument dwellPeriod.
   *    After that time expires, an FmRxEvSearchInProgress event
   *    will be sent to the client and a new search will begin for
   *    the next station that meets the search threshold. After
   *    scanning the entire band, or after a cancel search has been
   *    initiated by the client, an FmRxEvRadioTuneStatus event
   *    will be sent to the client. Similar to a seek command, each
   *    scan will result in at least one station being tuned, even
   *    if this is the starting frequency.
   *    <p>
   *    Each time the driver initiates a search (seek or scan) the client
   *    will be notified via an FmRxEvSearchInProgress event.
   *    Similarly, each time a search completes, the client will be notified via an
   *    FmRxEvRadioTuneStatus event.
   *    <p>
   *    Once issuing a search command, several commands from the client
   *    may be disallowed until the search is completed or cancelled.
   *    <p>
   *    The search can be canceled at any time by using API
   *    cancelSearch (). Once cancelled, each search will tune to the
   *    last tuned station and generate both FmRxEvSearchComplete and
   *    FmRxEvRadioTuneStatus events.
   *    Valid Values for argument 'mode':
   *    <ul>
   *    <li>{@link #FM_RX_SRCH_MODE_SEEK}
   *    <li>{@link #FM_RX_SRCH_MODE_SCAN}
   *    </ul>
   *    <p>
   *    Valid Values for argument 'dwellPeriod' :
   *    <ul>
   *    <li>{@link #FM_RX_DWELL_PERIOD_1S}
   *    <li>{@link #FM_RX_DWELL_PERIOD_2S}
   *    <li>{@link #FM_RX_DWELL_PERIOD_3S}
   *    <li>{@link #FM_RX_DWELL_PERIOD_4S}
   *    <li>{@link #FM_RX_DWELL_PERIOD_5S}
   *    <li>{@link #FM_RX_DWELL_PERIOD_6S}
   *    <li>{@link #FM_RX_DWELL_PERIOD_7S}
   *    </ul>
   *    <p>
   *    Valid Values for argument 'direction' :
   *    <ul>
   *    <li>{@link #FM_RX_SEARCHDIR_DOWN}
   *    <li>{@link #FM_RX_SEARCHDIR_UP}
   *    </ul>
   *    <p>
   *
   *    <p>
   *    @param mode the FM search mode.
   *    @param dwellPeriod the FM scan dwell time. Used only when
   *    mode={@link #FM_RX_SRCH_MODE_SCAN}
   *    @param direction the Search Direction.
   *   <p>
   *    @return true if Search Initiate succeeded, false if
   *            Search Initiate  failed.
   *
   *   @see #searchStations(int, int, int, int, int)
   *   @see #searchStationList
   */
Initiates basic seek and scan operations.

This command is used to invoke a basic seek/scan of the FM
radio band.


This API is used to:
 Invoke basic seek operations ({@link
#FM_RX_SRCH_MODE_SEEK})
 Invoke basic scan operations ({@link
#FM_RX_SRCH_MODE_SCAN})


The most basic operation performed by this function
is a  #FM_RX_SRCH_MODE_SEEK command. The seek
process is handled incrementing or decrementing the
frequency in pre-defined channel steps (defined by the
channel spacing) and measuring the resulting signal level.
Once a station is successfully tuned and found to meet or
exceed this signal level, the seek operation will be
completed and a FmRxEvSearchComplete event will be returned
to the client. If no stations are found to match the search
criteria, the frequency will be returned to the originally
tuned station.

Since seek always results in a frequency being tuned, each
seek operation will also return a single
FmRxEvRadioTuneStatus event to the client/application
layer.

Much like  #FM_RX_SRCH_MODE_SEEK, a {@link
#FM_RX_SRCH_MODE_SCAN} command can be likened to many back
to back seeks with a dwell period after each successful
seek. Once issued, a scan will either increment or
decrement frequencies by the defined channel spacing until
a station is found to meet or exceed the set search
threshold. Once this station is found, and is successfully
tuned, an FmRxEvRadioTuneStatus event will be returned to
the client and the station will remain tuned for the
specific period of time indicated by argument dwellPeriod.
After that time expires, an FmRxEvSearchInProgress event
will be sent to the client and a new search will begin for
the next station that meets the search threshold. After
scanning the entire band, or after a cancel search has been
initiated by the client, an FmRxEvRadioTuneStatus event
will be sent to the client. Similar to a seek command, each
scan will result in at least one station being tuned, even
if this is the starting frequency.

Each time the driver initiates a search  the client
will be notified via an FmRxEvSearchInProgress event.
Similarly, each time a search completes, the client will be notified via an
FmRxEvRadioTuneStatus event.

Once issuing a search command, several commands from the client
may be disallowed until the search is completed or cancelled.

The search can be canceled at any time by using API
cancelSearch (). Once cancelled, each search will tune to the
last tuned station and generate both FmRxEvSearchComplete and
FmRxEvRadioTuneStatus events.


@param mode the FM search mode.
@param dwellPeriod the FM scan dwell time. Used only when
mode= #FM_RX_SRCH_MODE_SCAN
@param direction the Search Direction.

@return true if Search Initiate succeeded, false if
Search Initiate  failed.


Initiates basic seek and scan operations . This command is used to invoke a basic seek / scan of the FM radio band . This API is used to : Invoke basic seek operations ( { @link #FM_RX_SRCH_MODE_SEEK } ) Invoke basic scan operations ( { @link #FM_RX_SRCH_MODE_SCAN } ) The most basic operation performed by this function is a #FM_RX_SRCH_MODE_SEEK command . The seek process is handled incrementing or decrementing the frequency in pre - defined channel steps ( defined by the channel spacing ) and measuring the resulting signal level . Once a station is successfully tuned and found to meet or exceed this signal level the seek operation will be completed and a FmRxEvSearchComplete event will be returned to the client . If no stations are found to match the search criteria the frequency will be returned to the originally tuned station . Since seek always results in a frequency being tuned each seek operation will also return a single FmRxEvRadioTuneStatus event to the client / application layer . Much like #FM_RX_SRCH_MODE_SEEK a { @link #FM_RX_SRCH_MODE_SCAN } command can be likened to many back to back seeks with a dwell period after each successful seek . Once issued a scan will either increment or decrement frequencies by the defined channel spacing until a station is found to meet or exceed the set search threshold . Once this station is found and is successfully tuned an FmRxEvRadioTuneStatus event will be returned to the client and the station will remain tuned for the specific period of time indicated by argument dwellPeriod . After that time expires an FmRxEvSearchInProgress event will be sent to the client and a new search will begin for the next station that meets the search threshold . After scanning the entire band or after a cancel search has been initiated by the client an FmRxEvRadioTuneStatus event will be sent to the client . Similar to a seek command each scan will result in at least one station being tuned even if this is the starting frequency . Each time the driver initiates a search the client will be notified via an FmRxEvSearchInProgress event . Similarly each time a search completes the client will be notified via an FmRxEvRadioTuneStatus event . Once issuing a search command several commands from the client may be disallowed until the search is completed or cancelled . The search can be canceled at any time by using API cancelSearch () . Once cancelled each search will tune to the last tuned station and generate both FmRxEvSearchComplete and FmRxEvRadioTuneStatus events . @param mode the FM search mode . @param dwellPeriod the FM scan dwell time . Used only when mode = #FM_RX_SRCH_MODE_SCAN @param direction the Search Direction . @return true if Search Initiate succeeded false if Search Initiate failed .
public boolean searchStations (int mode,
                                  int dwellPeriod,
                                  int direction){
      int state = getFMState();
      boolean bStatus = true;
      int re;
      /* Check current state of FM device */
      if (state == FMState_Turned_Off || state == FMState_Srch_InProg) {
          Log.d(TAG, "searchStations: Device currently busy in executing another command.");
          return false;
      }
      Log.d (TAG, "Basic search...");
      /* Validate the arguments */
      if ( (mode != FM_RX_SRCH_MODE_SEEK) &&
           (mode != FM_RX_SRCH_MODE_SCAN))
      {
         Log.d (TAG, "Invalid search mode: " + mode );
         bStatus = false;
      }
      if ( (dwellPeriod < FM_RX_DWELL_PERIOD_0S ) ||
           (dwellPeriod > FM_RX_DWELL_PERIOD_7S))
      {
         Log.d (TAG, "Invalid dwelling time: " + dwellPeriod);
         bStatus = false;
      }
      if ( (direction != FM_RX_SEARCHDIR_DOWN) &&
           (direction != FM_RX_SEARCHDIR_UP))
      {
         Log.d (TAG, "Invalid search direction: " + direction);
         bStatus = false;
      }
      if (bStatus)
      {
         Log.d (TAG, "searchStations: mode " + mode + "direction:  " + direction);
         if (mode == FM_RX_SRCH_MODE_SEEK)
             setSearchState(subSrchLevel_SeekInPrg);
         else if (mode == FM_RX_SRCH_MODE_SCAN)
             setSearchState(subSrchLevel_ScanInProg);
         Log.v(TAG, "searchStations: CURRENT-STATE : FMRxOn ---> NEW-STATE : SearchInProg");
         re = mControl.searchStations(sFd, mode, dwellPeriod, direction, 0, 0);
         if (re != 0) {
             Log.e(TAG, "search station failed");
             if (getFMState() == FMState_Srch_InProg)
                 setSearchState(subSrchLevel_SrchComplete);
             return false;
         }
         state = getFMState();
         if (state == FMState_Turned_Off) {
             Log.d(TAG, "searchStations: CURRENT-STATE : FMState_Off (unexpected)");
             return false;
         }
      }
      return bStatus;
   }
public boolean searchStations ( int mode , int dwellPeriod , int direction ) { int state = getFMState ( ) ; boolean bStatus = true ; int re ; /* Check current state of FM device */ if ( state == FMState_Turned_Off || state == FMState_Srch_InProg ) { Log . d ( TAG , "searchStations: Device currently busy in executing another command." ) ; return false ; } Log . d ( TAG , "Basic search..." ) ; /* Validate the arguments */ if ( ( mode != FM_RX_SRCH_MODE_SEEK ) && ( mode != FM_RX_SRCH_MODE_SCAN ) ) { Log . d ( TAG , "Invalid search mode: " + mode ) ; bStatus = false ; } if ( ( dwellPeriod < FM_RX_DWELL_PERIOD_0S ) || ( dwellPeriod > FM_RX_DWELL_PERIOD_7S ) ) { Log . d ( TAG , "Invalid dwelling time: " + dwellPeriod ) ; bStatus = false ; } if ( ( direction != FM_RX_SEARCHDIR_DOWN ) && ( direction != FM_RX_SEARCHDIR_UP ) ) { Log . d ( TAG , "Invalid search direction: " + direction ) ; bStatus = false ; } if ( bStatus ) { Log . d ( TAG , "searchStations: mode " + mode + "direction:  " + direction ) ; if ( mode == FM_RX_SRCH_MODE_SEEK ) setSearchState ( subSrchLevel_SeekInPrg ) ; else if ( mode == FM_RX_SRCH_MODE_SCAN ) setSearchState ( subSrchLevel_ScanInProg ) ; Log . v ( TAG , "searchStations: CURRENT-STATE : FMRxOn ---> NEW-STATE : SearchInProg" ) ; re = mControl . searchStations ( sFd , mode , dwellPeriod , direction , 0 , 0 ) ; if ( re != 0 ) { Log . e ( TAG , "search station failed" ) ; if ( getFMState ( ) == FMState_Srch_InProg ) setSearchState ( subSrchLevel_SrchComplete ) ; return false ; } state = getFMState ( ) ; if ( state == FMState_Turned_Off ) { Log . d ( TAG , "searchStations: CURRENT-STATE : FMState_Off (unexpected)" ) ; return false ; } } return bStatus ; }
Initiates basic seek and scan operations.
Initiates basic seek and scan operations .