fm/qcom/fmradio/FmReceiver.java
public boolean searchStations (int mode,
                                  int dwellPeriod,
                                  int direction,
                                  int pty,
                                  int pi) {
      boolean bStatus = true;
      int state = getFMState();
      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, "RDS search...");

      /* Validate the arguments */
      if ( (mode != FM_RX_SRCHRDS_MODE_SEEK_PTY)
           && (mode != FM_RX_SRCHRDS_MODE_SCAN_PTY)
           && (mode != FM_RX_SRCHRDS_MODE_SEEK_PI)
           && (mode != FM_RX_SRCHRDS_MODE_SEEK_AF)
         )
      {
         Log.d (TAG, "Invalid search mode: " + mode );
         bStatus = false;
      }
      if ( (dwellPeriod < FM_RX_DWELL_PERIOD_1S) ||
           (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);
         Log.d (TAG, "searchStations: dwellPeriod " + dwellPeriod);
         Log.d (TAG, "searchStations: direction " + direction);
         Log.d (TAG, "searchStations: pty " + pty);
         Log.d (TAG, "searchStations: pi " + pi);
         setSearchState(subSrchLevel_ScanInProg);
         re = mControl.searchStations(sFd, mode, dwellPeriod, direction, pty, pi);
         if (re != 0) {
             Log.e(TAG, "scan station failed");
             if (getFMState() == FMState_Srch_InProg)
                 setSearchState(subSrchLevel_SrchComplete);
             bStatus = false;
         }
      }
      return bStatus;
   }
/**
   *    Initiates RDS based seek and scan operations.
   *
   *    <p>
   *    This command allows the client to issue seeks and scans similar
   *    to commands found in basic searchStations(mode, scanTime,
   *    direction). However, each command has an additional RDS/RBDS
   *    component which must be satisfied before a station is
   *    successfully tuned. Please see searchStations(mode,
   *    scanTime, direction) for an understanding of how seeks and
   *    scans work.
   *
   *    <p>
   *    <ul>
   *    This API is used to search stations using RDS:
   *    <li> Invokes seek based on program type ({@link
   *    #FM_RX_SRCHRDS_MODE_SEEK_PTY})
   *    <li> Invokes scan based on program type with specified dwell period
   *    ({@link #FM_RX_SRCHRDS_MODE_SCAN_PTY})
   *    <li> Invokes seek based on program identification ({@link
   *    #FM_RX_SRCHRDS_MODE_SEEK_PI})
   *    <li> Invokes seek for alternate frequency ({@link
   *    #FM_RX_SRCHRDS_MODE_SEEK_AF})
   *    </ul>
   *
   *    <p>
   *    Much like {@link #FM_RX_SRCH_MODE_SEEK} in searchStations,
   *    {@link #FM_RX_SRCHRDS_MODE_SEEK_PTY} allows the client to
   *    seek to stations which are broadcasting RDS/RBDS groups
   *    with a particular Program Type that matches the supplied
   *    Program Type (PTY). The behavior and events generated for a
   *    {@link #FM_RX_SRCHRDS_MODE_SEEK_PTY} are very similar to
   *    that of {@link #FM_RX_SRCH_MODE_SEEK}, however only
   *    stations meeting the set search signal threshold and are
   *    also broadcasting the specified RDS Program Type (PTY) will
   *    be tuned. If no matching stations can be found, the
   *    original station will be re-tuned.
   *
   *    <p>
   *    Just as {@link #FM_RX_SRCHRDS_MODE_SEEK_PTY}'s
   *    functionality matches {@link #FM_RX_SRCH_MODE_SEEK}, so
   *    does {@link #FM_RX_SRCHRDS_MODE_SCAN_PTY} match {@link
   *    #FM_RX_SRCH_MODE_SCAN}. The one of the differences between
   *    the two is that only stations meeting the set search
   *    threshold and are also broadcasting a RDS Program Type
   *    (PTY) matching tucRdsSrchPty are found and tuned. If no
   *    station is found to have the PTY as specified by argument
   *    "pty", then the original station will be re-tuned.
   *
   *    <p> {@link #FM_RX_SRCHRDS_MODE_SEEK_PI} is used the same
   *    way as {@link #FM_RX_SRCHRDS_MODE_SEEK_PTY}, but only
   *    stations which meet the set search threshold and are also
   *    broadcasting the Program Identification matching the
   *    argument "pi" are tuned.
   *
   *    <p>
   *    Lastly, {@link #FM_RX_SRCHRDS_MODE_SEEK_AF} functionality
   *    differs slightly compared to the other commands in this
   *    function. This command only seeks to stations which are
   *    known ahead of time to be Alternative Frequencies for the
   *    currently tune station. If no alternate frequencies are
   *    known, or if the Alternative Frequencies have weaker signal
   *    strength than the original frequency, the original
   *    frequency will be re-tuned.
   *
   *    <p>
   *    Each time the driver initiates an RDS-based search, the client will be
   *    notified via a FmRxEvSearchInProgress event. Similarly, each
   *    time an RDS-based search completes, the client will be notified via a
   *    FmRxEvSearchComplete event.
   *
   *    <p>
   *    Once issuing a search command, several commands from the client may be
   *    disallowed until the search is completed or canceled.
   *
   *    <p>
   *    The search can be canceled at any time by using API
   *    cancelSearch (). Once canceled, 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_SRCHRDS_MODE_SEEK_PTY}
   *    <li>{@link #FM_RX_SRCHRDS_MODE_SCAN_PTY}
   *    <li>{@link #FM_RX_SRCHRDS_MODE_SEEK_PI}
   *    <li>{@link #FM_RX_SRCHRDS_MODE_SEEK_AF}
   *    </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>
   *    @param mode the FM search mode.
   *    @param dwellPeriod the FM scan dwell time. Used only when
   *    mode={@link #FM_RX_SRCHRDS_MODE_SCAN_PTY}
   *    @param direction the Search Direction.
   *    @param pty the FM RDS search Program Type
   *    @param pi the FM RDS search Program Identification Code
   *    <p>
   *    @return true if Search Initiate succeeded, false if
   *            Search Initiate  failed.
   *
   *   @see #searchStations(int, int, int)
   *   @see #searchStationList
   */
Initiates RDS based seek and scan operations.

This command allows the client to issue seeks and scans similar
to commands found in basic searchStations(mode, scanTime,
direction). However, each command has an additional RDS/RBDS
component which must be satisfied before a station is
successfully tuned. Please see searchStations(mode,
scanTime, direction) for an understanding of how seeks and
scans work.



This API is used to search stations using RDS:
 Invokes seek based on program type ({@link
#FM_RX_SRCHRDS_MODE_SEEK_PTY})
 Invokes scan based on program type with specified dwell period
( #FM_RX_SRCHRDS_MODE_SCAN_PTY)
 Invokes seek based on program identification ({@link
#FM_RX_SRCHRDS_MODE_SEEK_PI})
 Invokes seek for alternate frequency ({@link
#FM_RX_SRCHRDS_MODE_SEEK_AF})



Much like  #FM_RX_SRCH_MODE_SEEK in searchStations,
#FM_RX_SRCHRDS_MODE_SEEK_PTY allows the client to
seek to stations which are broadcasting RDS/RBDS groups
with a particular Program Type that matches the supplied
Program Type (PTY). The behavior and events generated for a
#FM_RX_SRCHRDS_MODE_SEEK_PTY are very similar to
that of  #FM_RX_SRCH_MODE_SEEK, however only
stations meeting the set search signal threshold and are
also broadcasting the specified RDS Program Type (PTY) will
be tuned. If no matching stations can be found, the
original station will be re-tuned.



  #FM_RX_SRCHRDS_MODE_SEEK_PI is used the same
way as  #FM_RX_SRCHRDS_MODE_SEEK_PTY, but only
stations which meet the set search threshold and are also
broadcasting the Program Identification matching the
argument "pi" are tuned.


Lastly,  #FM_RX_SRCHRDS_MODE_SEEK_AF functionality
differs slightly compared to the other commands in this
function. This command only seeks to stations which are
known ahead of time to be Alternative Frequencies for the
currently tune station. If no alternate frequencies are
known, or if the Alternative Frequencies have weaker signal
strength than the original frequency, the original
frequency will be re-tuned.


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


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


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




Initiates RDS based seek and scan operations . This command allows the client to issue seeks and scans similar to commands found in basic searchStations ( mode scanTime direction ) . However each command has an additional RDS / RBDS component which must be satisfied before a station is successfully tuned . Please see searchStations ( mode scanTime direction ) for an understanding of how seeks and scans work . This API is used to search stations using RDS : Invokes seek based on program type ( { @link #FM_RX_SRCHRDS_MODE_SEEK_PTY } ) Invokes scan based on program type with specified dwell period ( #FM_RX_SRCHRDS_MODE_SCAN_PTY ) Invokes seek based on program identification ( { @link #FM_RX_SRCHRDS_MODE_SEEK_PI } ) Invokes seek for alternate frequency ( { @link #FM_RX_SRCHRDS_MODE_SEEK_AF } ) Much like #FM_RX_SRCH_MODE_SEEK in searchStations #FM_RX_SRCHRDS_MODE_SEEK_PTY allows the client to seek to stations which are broadcasting RDS / RBDS groups with a particular Program Type that matches the supplied Program Type ( PTY ) . The behavior and events generated for a #FM_RX_SRCHRDS_MODE_SEEK_PTY are very similar to that of #FM_RX_SRCH_MODE_SEEK however only stations meeting the set search signal threshold and are also broadcasting the specified RDS Program Type ( PTY ) will be tuned . If no matching stations can be found the original station will be re - tuned . #FM_RX_SRCHRDS_MODE_SEEK_PI is used the same way as #FM_RX_SRCHRDS_MODE_SEEK_PTY but only stations which meet the set search threshold and are also broadcasting the Program Identification matching the argument " pi " are tuned . Lastly #FM_RX_SRCHRDS_MODE_SEEK_AF functionality differs slightly compared to the other commands in this function . This command only seeks to stations which are known ahead of time to be Alternative Frequencies for the currently tune station . If no alternate frequencies are known or if the Alternative Frequencies have weaker signal strength than the original frequency the original frequency will be re - tuned . Each time the driver initiates an RDS - based search the client will be notified via a FmRxEvSearchInProgress event . Similarly each time an RDS - based search completes the client will be notified via a FmRxEvSearchComplete event . Once issuing a search command several commands from the client may be disallowed until the search is completed or canceled . The search can be canceled at any time by using API cancelSearch () . Once canceled each search will tune to the last tuned station and generate both FmRxEvSearchComplete and FmRxEvRadioTuneStatus events .
public boolean searchStations (int mode,
                                  int dwellPeriod,
                                  int direction,
                                  int pty,
                                  int pi) {
      boolean bStatus = true;
      int state = getFMState();
      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, "RDS search...");
      /* Validate the arguments */
      if ( (mode != FM_RX_SRCHRDS_MODE_SEEK_PTY)
           && (mode != FM_RX_SRCHRDS_MODE_SCAN_PTY)
           && (mode != FM_RX_SRCHRDS_MODE_SEEK_PI)
           && (mode != FM_RX_SRCHRDS_MODE_SEEK_AF)
         )
      {
         Log.d (TAG, "Invalid search mode: " + mode );
         bStatus = false;
      }
      if ( (dwellPeriod < FM_RX_DWELL_PERIOD_1S) ||
           (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);
         Log.d (TAG, "searchStations: dwellPeriod " + dwellPeriod);
         Log.d (TAG, "searchStations: direction " + direction);
         Log.d (TAG, "searchStations: pty " + pty);
         Log.d (TAG, "searchStations: pi " + pi);
         setSearchState(subSrchLevel_ScanInProg);
         re = mControl.searchStations(sFd, mode, dwellPeriod, direction, pty, pi);
         if (re != 0) {
             Log.e(TAG, "scan station failed");
             if (getFMState() == FMState_Srch_InProg)
                 setSearchState(subSrchLevel_SrchComplete);
             bStatus = false;
         }
      }
      return bStatus;
   }
public boolean searchStations ( int mode , int dwellPeriod , int direction , int pty , int pi ) { boolean bStatus = true ; int state = getFMState ( ) ; 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 , "RDS search..." ) ; /* Validate the arguments */ if ( ( mode != FM_RX_SRCHRDS_MODE_SEEK_PTY ) && ( mode != FM_RX_SRCHRDS_MODE_SCAN_PTY ) && ( mode != FM_RX_SRCHRDS_MODE_SEEK_PI ) && ( mode != FM_RX_SRCHRDS_MODE_SEEK_AF ) ) { Log . d ( TAG , "Invalid search mode: " + mode ) ; bStatus = false ; } if ( ( dwellPeriod < FM_RX_DWELL_PERIOD_1S ) || ( 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 ) ; Log . d ( TAG , "searchStations: dwellPeriod " + dwellPeriod ) ; Log . d ( TAG , "searchStations: direction " + direction ) ; Log . d ( TAG , "searchStations: pty " + pty ) ; Log . d ( TAG , "searchStations: pi " + pi ) ; setSearchState ( subSrchLevel_ScanInProg ) ; re = mControl . searchStations ( sFd , mode , dwellPeriod , direction , pty , pi ) ; if ( re != 0 ) { Log . e ( TAG , "scan station failed" ) ; if ( getFMState ( ) == FMState_Srch_InProg ) setSearchState ( subSrchLevel_SrchComplete ) ; bStatus = false ; } } return bStatus ; }
Initiates RDS based seek and scan operations.
Initiates RDS based seek and scan operations .