Fix support for AIDL client calling startProgramListUpdates(null).
ag/7063548 inadvertently changed the behavior of calling
startProgramListUpdates(null) to be equivalent to
stopProgramListUpdates(). This change restores the original behavior
of the AIDL client receiving all program list updates.
Bug: 121305828
Test: atest com.android.server.broadcastradio.hal2.StartProgramListUpdatesFanoutTest
Change-Id: I60d21816d314b682585d6bcff6732675eef55a9b
diff --git a/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/StartProgramListUpdatesFanoutTest.java b/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/StartProgramListUpdatesFanoutTest.java
index 6e65df1..3d9a1d9 100644
--- a/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/StartProgramListUpdatesFanoutTest.java
+++ b/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/StartProgramListUpdatesFanoutTest.java
@@ -250,6 +250,29 @@
verify(mHalTunerSessionMock).stopProgramListUpdates();
}
+ @Test
+ public void testNullAidlFilter() throws RemoteException {
+ openAidlClients(1);
+ mTunerSessions[0].startProgramListUpdates(null);
+ verify(mHalTunerSessionMock, times(1)).startProgramListUpdates(any());
+
+ // Verify the AIDL client receives all types of updates (e.g. a new program, an update to
+ // that program, and a category).
+ updateHalProgramInfo(true, Arrays.asList(mAmFmInfo, mRdsInfo), null);
+ verifyAidlClientReceivedChunk(mAidlTunerCallbackMocks[0], true, Arrays.asList(
+ mAmFmInfo, mRdsInfo), null);
+ updateHalProgramInfo(false, Arrays.asList(mModifiedAmFmInfo), null);
+ verifyAidlClientReceivedChunk(mAidlTunerCallbackMocks[0], false,
+ Arrays.asList(mModifiedAmFmInfo), null);
+ updateHalProgramInfo(false, Arrays.asList(mDabEnsembleInfo), null);
+ verifyAidlClientReceivedChunk(mAidlTunerCallbackMocks[0], false,
+ Arrays.asList(mDabEnsembleInfo), null);
+
+ // Verify closing the AIDL session also stops HAL updates.
+ mTunerSessions[0].close();
+ verify(mHalTunerSessionMock).stopProgramListUpdates();
+ }
+
private void openAidlClients(int numClients) throws RemoteException {
mAidlTunerCallbackMocks = new android.hardware.radio.ITunerCallback[numClients];
mTunerSessions = new TunerSession[numClients];
diff --git a/services/core/java/com/android/server/broadcastradio/hal2/TunerSession.java b/services/core/java/com/android/server/broadcastradio/hal2/TunerSession.java
index 764fca9..7ab3bdd 100644
--- a/services/core/java/com/android/server/broadcastradio/hal2/TunerSession.java
+++ b/services/core/java/com/android/server/broadcastradio/hal2/TunerSession.java
@@ -31,6 +31,7 @@
import android.util.MutableInt;
import android.util.Slog;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -186,6 +187,12 @@
@Override
public void startProgramListUpdates(ProgramList.Filter filter) throws RemoteException {
+ // If the AIDL client provides a null filter, it wants all updates, so use the most broad
+ // filter.
+ if (filter == null) {
+ filter = new ProgramList.Filter(new HashSet<Integer>(),
+ new HashSet<android.hardware.radio.ProgramSelector.Identifier>(), true, false);
+ }
synchronized (mLock) {
checkNotClosedLocked();
mProgramInfoCache = new ProgramInfoCache(filter);