Loading core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/AidlTestUtils.java +1 −1 Original line number Diff line number Diff line Loading @@ -80,7 +80,7 @@ final class AidlTestUtils { /* vendorIds= */ null); } static android.hardware.broadcastradio.ProgramSelector makeHalFmSelector(int freq) { static android.hardware.broadcastradio.ProgramSelector makeHalFmSelector(long freq) { ProgramIdentifier halId = makeHalIdentifier(IdentifierType.AMFM_FREQUENCY_KHZ, freq); return makeHalSelector(halId, /* secondaryIds= */ new ProgramIdentifier[0]); } Loading core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/ConversionUtilsResultTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ public final class ConversionUtilsResultTest { {Result.INVALID_STATE, RadioTuner.TUNER_RESULT_INVALID_STATE}, {Result.NOT_SUPPORTED, RadioTuner.TUNER_RESULT_NOT_SUPPORTED}, {Result.TIMEOUT, RadioTuner.TUNER_RESULT_TIMEOUT}, {Result.CANCELED, RadioTuner.TUNER_RESULT_CANCELED}, {Result.UNKNOWN_ERROR, RadioTuner.TUNER_RESULT_UNKNOWN_ERROR} }); } Loading core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/ConversionUtilsTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -27,11 +27,13 @@ import android.hardware.broadcastradio.ProgramIdentifier; import android.hardware.broadcastradio.ProgramInfo; import android.hardware.broadcastradio.ProgramListChunk; import android.hardware.broadcastradio.Properties; import android.hardware.broadcastradio.Result; import android.hardware.broadcastradio.VendorKeyValue; import android.hardware.radio.Announcement; import android.hardware.radio.ProgramList; import android.hardware.radio.ProgramSelector; import android.hardware.radio.RadioManager; import android.os.ServiceSpecificException; import com.android.dx.mockito.inline.extended.StaticMockitoSessionBuilder; import com.android.server.broadcastradio.ExtendedRadioMockitoTestCase; Loading Loading @@ -152,6 +154,16 @@ public final class ConversionUtilsTest extends ExtendedRadioMockitoTestCase { .that(ConversionUtils.isAtLeastU(U_APP_UID)).isTrue(); } @Test public void throwOnError_withCancelException() { ServiceSpecificException halException = new ServiceSpecificException(Result.CANCELED); RuntimeException thrown = ConversionUtils.throwOnError(halException, "tune"); expect.withMessage("Exception thrown for canceling error").that(thrown) .hasMessageThat().contains("tune: CANCELED"); } @Test public void propertiesFromHalProperties_idsMatch() { expect.withMessage("Properties id") Loading core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/TunerSessionTest.java +17 −1 Original line number Diff line number Diff line Loading @@ -1168,12 +1168,28 @@ public final class TunerSessionTest extends ExtendedRadioMockitoTestCase { doReturn(USER_ID_2).when(() -> RadioServiceUserController.getCurrentUser()); mHalTunerCallback.onCurrentProgramInfoChanged(AidlTestUtils.makeHalProgramInfo( AidlTestUtils.makeHalFmSelector(/* freq= */ 97300), SIGNAL_QUALITY)); AidlTestUtils.makeHalFmSelector(AM_FM_FREQUENCY_LIST[1]), SIGNAL_QUALITY)); verify(mAidlTunerCallbackMocks[0], CALLBACK_TIMEOUT.times(0)) .onCurrentProgramInfoChanged(any()); } @Test public void onTuneFailed_forTunerCallback() throws Exception { int numSessions = 3; openAidlClients(numSessions); android.hardware.broadcastradio.ProgramSelector halSel = AidlTestUtils.makeHalFmSelector( AM_FM_FREQUENCY_LIST[1]); ProgramSelector sel = AidlTestUtils.makeFmSelector(AM_FM_FREQUENCY_LIST[1]); mHalTunerCallback.onTuneFailed(Result.CANCELED, halSel); for (int index = 0; index < numSessions; index++) { verify(mAidlTunerCallbackMocks[index], CALLBACK_TIMEOUT) .onTuneFailed(RadioTuner.TUNER_RESULT_CANCELED, sel); } } @Test public void onAntennaStateChange_forTunerCallback() throws Exception { int numSessions = 3; Loading services/core/java/com/android/server/broadcastradio/aidl/ConversionUtils.java +4 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,8 @@ final class ConversionUtils { return new UnsupportedOperationException(action + ": NOT_SUPPORTED"); case Result.TIMEOUT: return new ParcelableException(new RuntimeException(action + ": TIMEOUT")); case Result.CANCELED: return new IllegalStateException(action + ": CANCELED"); default: return new ParcelableException(new RuntimeException( action + ": unknown error (" + result + ")")); Loading @@ -123,6 +125,8 @@ final class ConversionUtils { return RadioTuner.TUNER_RESULT_NOT_SUPPORTED; case Result.TIMEOUT: return RadioTuner.TUNER_RESULT_TIMEOUT; case Result.CANCELED: return RadioTuner.TUNER_RESULT_CANCELED; case Result.UNKNOWN_ERROR: default: return RadioTuner.TUNER_RESULT_UNKNOWN_ERROR; Loading Loading
core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/AidlTestUtils.java +1 −1 Original line number Diff line number Diff line Loading @@ -80,7 +80,7 @@ final class AidlTestUtils { /* vendorIds= */ null); } static android.hardware.broadcastradio.ProgramSelector makeHalFmSelector(int freq) { static android.hardware.broadcastradio.ProgramSelector makeHalFmSelector(long freq) { ProgramIdentifier halId = makeHalIdentifier(IdentifierType.AMFM_FREQUENCY_KHZ, freq); return makeHalSelector(halId, /* secondaryIds= */ new ProgramIdentifier[0]); } Loading
core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/ConversionUtilsResultTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ public final class ConversionUtilsResultTest { {Result.INVALID_STATE, RadioTuner.TUNER_RESULT_INVALID_STATE}, {Result.NOT_SUPPORTED, RadioTuner.TUNER_RESULT_NOT_SUPPORTED}, {Result.TIMEOUT, RadioTuner.TUNER_RESULT_TIMEOUT}, {Result.CANCELED, RadioTuner.TUNER_RESULT_CANCELED}, {Result.UNKNOWN_ERROR, RadioTuner.TUNER_RESULT_UNKNOWN_ERROR} }); } Loading
core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/ConversionUtilsTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -27,11 +27,13 @@ import android.hardware.broadcastradio.ProgramIdentifier; import android.hardware.broadcastradio.ProgramInfo; import android.hardware.broadcastradio.ProgramListChunk; import android.hardware.broadcastradio.Properties; import android.hardware.broadcastradio.Result; import android.hardware.broadcastradio.VendorKeyValue; import android.hardware.radio.Announcement; import android.hardware.radio.ProgramList; import android.hardware.radio.ProgramSelector; import android.hardware.radio.RadioManager; import android.os.ServiceSpecificException; import com.android.dx.mockito.inline.extended.StaticMockitoSessionBuilder; import com.android.server.broadcastradio.ExtendedRadioMockitoTestCase; Loading Loading @@ -152,6 +154,16 @@ public final class ConversionUtilsTest extends ExtendedRadioMockitoTestCase { .that(ConversionUtils.isAtLeastU(U_APP_UID)).isTrue(); } @Test public void throwOnError_withCancelException() { ServiceSpecificException halException = new ServiceSpecificException(Result.CANCELED); RuntimeException thrown = ConversionUtils.throwOnError(halException, "tune"); expect.withMessage("Exception thrown for canceling error").that(thrown) .hasMessageThat().contains("tune: CANCELED"); } @Test public void propertiesFromHalProperties_idsMatch() { expect.withMessage("Properties id") Loading
core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/TunerSessionTest.java +17 −1 Original line number Diff line number Diff line Loading @@ -1168,12 +1168,28 @@ public final class TunerSessionTest extends ExtendedRadioMockitoTestCase { doReturn(USER_ID_2).when(() -> RadioServiceUserController.getCurrentUser()); mHalTunerCallback.onCurrentProgramInfoChanged(AidlTestUtils.makeHalProgramInfo( AidlTestUtils.makeHalFmSelector(/* freq= */ 97300), SIGNAL_QUALITY)); AidlTestUtils.makeHalFmSelector(AM_FM_FREQUENCY_LIST[1]), SIGNAL_QUALITY)); verify(mAidlTunerCallbackMocks[0], CALLBACK_TIMEOUT.times(0)) .onCurrentProgramInfoChanged(any()); } @Test public void onTuneFailed_forTunerCallback() throws Exception { int numSessions = 3; openAidlClients(numSessions); android.hardware.broadcastradio.ProgramSelector halSel = AidlTestUtils.makeHalFmSelector( AM_FM_FREQUENCY_LIST[1]); ProgramSelector sel = AidlTestUtils.makeFmSelector(AM_FM_FREQUENCY_LIST[1]); mHalTunerCallback.onTuneFailed(Result.CANCELED, halSel); for (int index = 0; index < numSessions; index++) { verify(mAidlTunerCallbackMocks[index], CALLBACK_TIMEOUT) .onTuneFailed(RadioTuner.TUNER_RESULT_CANCELED, sel); } } @Test public void onAntennaStateChange_forTunerCallback() throws Exception { int numSessions = 3; Loading
services/core/java/com/android/server/broadcastradio/aidl/ConversionUtils.java +4 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,8 @@ final class ConversionUtils { return new UnsupportedOperationException(action + ": NOT_SUPPORTED"); case Result.TIMEOUT: return new ParcelableException(new RuntimeException(action + ": TIMEOUT")); case Result.CANCELED: return new IllegalStateException(action + ": CANCELED"); default: return new ParcelableException(new RuntimeException( action + ": unknown error (" + result + ")")); Loading @@ -123,6 +125,8 @@ final class ConversionUtils { return RadioTuner.TUNER_RESULT_NOT_SUPPORTED; case Result.TIMEOUT: return RadioTuner.TUNER_RESULT_TIMEOUT; case Result.CANCELED: return RadioTuner.TUNER_RESULT_CANCELED; case Result.UNKNOWN_ERROR: default: return RadioTuner.TUNER_RESULT_UNKNOWN_ERROR; Loading