接上一篇 ,今天将要来看看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);
}