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

Commit 39461545 authored by George Lu's avatar George Lu Committed by Android (Google) Code Review
Browse files

Merge "Fix support for AIDL client calling startProgramListUpdates(null)."

parents b2e7b3a2 6526eb1a
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);