Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6526eb1a authored by George Lu's avatar George Lu
Browse files

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
parent 80161fc4
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -250,6 +250,29 @@ public class StartProgramListUpdatesFanoutTest {
        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];
+7 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.util.MutableBoolean;
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 @@ class TunerSession extends ITuner.Stub {

    @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);