Allow secondary ids missing for DAB selector
Sometimes DAB program selector used in tuning does not have secondary
identifiers such as ensemble and frequency, and HAL will automatically
selector a DAB station with specified ensemble and frequency. Thus,
secondary ids in DAB program selector are not mandatory in HAL. Also
updated broadcast radio AIDL HAL documentation.
Bug: 273804622
Test: atest VtsHalBroadcastradioAidlTargetTest
Change-Id: If05b7eeb79e299667c3a64bf8b931bb6396f9045
diff --git a/broadcastradio/aidl/default/BroadcastRadio.cpp b/broadcastradio/aidl/default/BroadcastRadio.cpp
index 36520fb..c0c475a 100644
--- a/broadcastradio/aidl/default/BroadcastRadio.cpp
+++ b/broadcastradio/aidl/default/BroadcastRadio.cpp
@@ -589,10 +589,11 @@
}
ProgramSelector sel = {};
if (isDab) {
- if (numArgs != 5) {
+ if (numArgs != 5 && numArgs != 3) {
dprintf(fd,
"Invalid number of arguments: please provide "
- "--tune dab <SID> <ENSEMBLE> <FREQUENCY>\n");
+ "--tune dab <SID> <ENSEMBLE> <FREQUENCY> or "
+ "--tune dab <SID>\n");
return STATUS_BAD_VALUE;
}
int sid;
@@ -600,17 +601,21 @@
dprintf(fd, "Non-integer sid provided with tune: %s\n", args[2]);
return STATUS_BAD_VALUE;
}
- int ensemble;
- if (!utils::parseArgInt(string(args[3]), &ensemble)) {
- dprintf(fd, "Non-integer ensemble provided with tune: %s\n", args[3]);
- return STATUS_BAD_VALUE;
+ if (numArgs == 3) {
+ sel = utils::makeSelectorDab(sid);
+ } else {
+ int ensemble;
+ if (!utils::parseArgInt(string(args[3]), &ensemble)) {
+ dprintf(fd, "Non-integer ensemble provided with tune: %s\n", args[3]);
+ return STATUS_BAD_VALUE;
+ }
+ int freq;
+ if (!utils::parseArgInt(string(args[4]), &freq)) {
+ dprintf(fd, "Non-integer frequency provided with tune: %s\n", args[4]);
+ return STATUS_BAD_VALUE;
+ }
+ sel = utils::makeSelectorDab(sid, ensemble, freq);
}
- int freq;
- if (!utils::parseArgInt(string(args[4]), &freq)) {
- dprintf(fd, "Non-integer frequency provided with tune: %s\n", args[4]);
- return STATUS_BAD_VALUE;
- }
- sel = utils::makeSelectorDab(sid, ensemble, freq);
} else {
if (numArgs != 3) {
dprintf(fd, "Invalid number of arguments: please provide --tune amfm <FREQUENCY>\n");