In the previous article, both hal1 and hal2 will call the tuneInternalLocked() method when switching channels. And the switching method is to call the virtualRadio().getProgram() method, but the following notification methods are different.
1. Switch channel HAL
tuneInternalLocked
Source location:
hal1.1:/hardware/interfaces/broadcastradio/1.1/default/Tuner.cpp
hal2.0:/hardware/interfaces/broadcastradio/2.0/default/TunerSession.cpp
void TunerSession::tuneInternalLocked(const ProgramSelector& sel) {
VirtualProgram virtualProgram;
ProgramInfo programInfo;
if (virtualRadio().getProgram(sel, virtualProgram)) {
mCurrentProgram = virtualProgram.selector;
programInfo = virtualProgram;
} else {
mCurrentProgram = sel;
// 电台切换失败
programInfo = makeDummyProgramInfo(sel);
}
mIsTuneCompleted = true;
......
}
// 电台切换失败,生成不指向任何程序的ProgramInfo
static ProgramInfo makeDummyProgramInfo(const Pr