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

Commit 26c5ca22 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Handle remote exception for bcradio openSession" into main

parents 6b409d93 284f7be4
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.verification.VerificationWithTimeout;

import java.util.ArrayList;
@@ -212,6 +213,18 @@ public final class TunerSessionTest extends ExtendedRadioMockitoTestCase {
        }
    }

    @Test
    public void openSession_whenHalThrowsRemoteException() throws Exception {
        android.hardware.radio.ITunerCallback tunerCallbackMock =
                mock(android.hardware.radio.ITunerCallback.class);
        Mockito.doThrow(new RemoteException("HAL service died")).when(mBroadcastRadioMock)
                .setTunerCallback(any());

        expect.withMessage("Null tuner session with HAL throwing remote exception")
                .that(mRadioModule.openSession(tunerCallbackMock)).isNull();

    }

    @Test
    public void setConfiguration() throws Exception {
        openAidlClients(/* numClients= */ 1);
+1 −1
Original line number Diff line number Diff line
@@ -222,7 +222,7 @@ public final class BroadcastRadioServiceImpl {
        }

        TunerSession tunerSession = radioModule.openSession(callback);
        if (legacyConfig != null) {
        if (tunerSession != null && legacyConfig != null) {
            tunerSession.setConfiguration(legacyConfig);
        }
        return tunerSession;
+8 −1
Original line number Diff line number Diff line
@@ -247,6 +247,7 @@ final class RadioModule {
        return mProperties;
    }

    @Nullable
    TunerSession openSession(android.hardware.radio.ITunerCallback userCb)
            throws RemoteException {
        mLogger.logRadioEvent("Open TunerSession");
@@ -260,7 +261,13 @@ final class RadioModule {
            antennaConnected = mAntennaConnected;
            currentProgramInfo = mCurrentProgramInfo;
            if (isFirstTunerSession) {
                try {
                    mService.setTunerCallback(mHalTunerCallback);
                } catch (RemoteException ex) {
                    Slogf.wtf(TAG, ex, "Failed to register HAL callback for module %d",
                            mProperties.getId());
                    return null;
                }
            }
        }
        // Propagate state to new client.