Android FM模块学习之四源码分析(八)

上一篇 ,今天将要来看看android\vendor\qcom\opensource\fm\fmapp2\src\com\caf\fmradio \PresetStation.java


调整频率位置状态构造方法

public PresetStation(String name, int frequency) {
           mName = name;
      /*
       *  setFrequency set the name to
       *  "Frequency" String if Name is empty
       */
      setFrequency(frequency);
   }

设置频率

 public void setFrequency(int freq){
      mFrequency = freq;
      /* If no name set it to the frequency */
      if (TextUtils.isEmpty(mName))
      {
         mName = ""+mFrequency/1000.0;
      }
      return;
   }

 

构造方法

public PresetStation(PresetStation station) {
      Copy(station);
      /*
       *  setFrequency set the name to
       *  "Frequency" String if Name is empty
       */
      setFrequency(station.getFrequency());
   }

 

复制频率位置

 

public void Copy(PresetStation station) {
      /* Let copy just do a copy
       * without any manipulation
       */
      mName = station.getName();
      mFrequency = station.getFrequency();
      mPI = station.getPI();
      mPty = station.getPty();
      mRDSSupported = station.getRDSSupported();

      mPtyStr = station.getPtyString();
      mPIStr = station.getPIString();
   }

获取 public static String getFrequencyString(int frequency)字符串

 

  public static String getFrequencyString(int frequency) {
          double frequencyDbl = frequency / 1000.0;
      String frequencyString =""+frequencyDbl;
      return frequencyString;
   }

常规解析PI代码从整数到呼号字符串

public static String parsePI(int piCode)
   {
      String callSign = "";
      if ( (piCode >> 8) == 0xAF)
      {//CALL LETTERS THAT MAP TO PI CODES = _ _ 0 0.
         piCode = ((piCode & 0xFF) << 8);
      }
      /* Run the second exception
         NOTE: For 9 special cases 1000,2000,..,9000 a double mapping
         occurs utilizing exceptions 1 and 2:
         1000->A100->AFA1;2000->A200->AFA2; ... ;
         8000->A800->AFA8;9000->A900->AFA9
      */
      if ( (piCode >> 12) == 0xA)
      {//CALL LETTERS THAT MAP TO PI CODES = _ 0 _ _.
         piCode = ((piCode & 0xF00) << 4) + (piCode & 0xFF);
      }
      if ( (piCode >= 0x1000) && (piCode <= 0x994E))
      { String ShartChar;
         /* KAAA - KZZZ */
         if ( (piCode >= 0x1000) && (piCode <= 0x54A7))
         {
            piCode -= 0x1000;
            ShartChar = "K";
         } else
         { /* WAAA - WZZZ*/
            piCode -= 0x54A8;
            ShartChar = "W";
         }
         int CharDiv = piCode / 26;
         int CharPos = piCode - (CharDiv * 26);
         char c3 = (char)('A'+CharPos);

         piCode = CharDiv;CharDiv = piCode / 26;
         CharPos = piCode - (CharDiv * 26);
         char c2 = (char)('A'+CharPos);

         piCode = CharDiv;
         CharDiv = piCode / 26;
         CharPos = piCode - (CharDiv * 26);
         char c1 = (char)('A'+CharPos);
         callSign = ShartChar + c1+ c2+ c3;
      } else if ( (piCode >= 0x9950) && (piCode <= 0x9EFF))
      {//3-LETTER-ONLY CALL LETTERS
         callSign = get3LetterCallSign(piCode);} else
      {//NATIONALLY-LINKED RADIO STATIONS CARRYING DIFFERENT CALL LETTERS
         callSign = getOtherCallSign(piCode);
      }
      return callSign;
   }

 

获得项目类型的文本字符串的代码

public static String getRDSPtyString(int pty)

public static String parsePTY(int pty)
   {
      String ptyStr="";
      int rdsStd = FmSharedPreferences.getFMConfiguration().getRdsStd();
      if(rdsStd ==  FmReceiver.FM_RDS_STD_RBDS)
      {
         ptyStr = getRBDSPtyString(pty);
      }
      else if(rdsStd ==  FmReceiver.FM_RDS_STD_RDS)
      {
         ptyStr = getRDSPtyString(pty);
      }
      return (ptyStr);
   }


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值