diff options
17 files changed, 278 insertions, 162 deletions
diff --git a/core/tests/BroadcastRadioTests/src/android/hardware/radio/RadioManagerTest.java b/core/tests/BroadcastRadioTests/src/android/hardware/radio/RadioManagerTest.java index 4f9b2697ee89..4c3d4e3af99f 100644 --- a/core/tests/BroadcastRadioTests/src/android/hardware/radio/RadioManagerTest.java +++ b/core/tests/BroadcastRadioTests/src/android/hardware/radio/RadioManagerTest.java @@ -16,8 +16,6 @@ package android.hardware.radio; -import static com.google.common.truth.Truth.assertWithMessage; - import static org.junit.Assert.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; @@ -36,6 +34,8 @@ import android.os.RemoteException; import android.platform.test.flag.junit.SetFlagsRule; import android.util.ArrayMap; +import com.google.common.truth.Expect; + import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -155,6 +155,9 @@ public final class RadioManagerTest { private RadioManager mRadioManager; private final ApplicationInfo mApplicationInfo = new ApplicationInfo(); + @Rule + public final Expect mExpect = Expect.create(); + @Mock private IRadioService mRadioServiceMock; @Mock @@ -175,7 +178,7 @@ public final class RadioManagerTest { () -> new RadioManager.AmBandDescriptor(REGION, /* type= */ 100, AM_LOWER_LIMIT, AM_UPPER_LIMIT, AM_SPACING, STEREO_SUPPORTED)); - assertWithMessage("Unsupported band type exception") + mExpect.withMessage("Unsupported band type exception") .that(thrown).hasMessageThat().contains("Unsupported band"); } @@ -183,7 +186,7 @@ public final class RadioManagerTest { public void getType_forBandDescriptor() { RadioManager.BandDescriptor bandDescriptor = createAmBandDescriptor(); - assertWithMessage("AM Band Descriptor type") + mExpect.withMessage("AM Band Descriptor type") .that(bandDescriptor.getType()).isEqualTo(RadioManager.BAND_AM); } @@ -191,7 +194,7 @@ public final class RadioManagerTest { public void getRegion_forBandDescriptor() { RadioManager.BandDescriptor bandDescriptor = createFmBandDescriptor(); - assertWithMessage("FM Band Descriptor region") + mExpect.withMessage("FM Band Descriptor region") .that(bandDescriptor.getRegion()).isEqualTo(REGION); } @@ -199,7 +202,7 @@ public final class RadioManagerTest { public void getLowerLimit_forBandDescriptor() { RadioManager.BandDescriptor bandDescriptor = createFmBandDescriptor(); - assertWithMessage("FM Band Descriptor lower limit") + mExpect.withMessage("FM Band Descriptor lower limit") .that(bandDescriptor.getLowerLimit()).isEqualTo(FM_LOWER_LIMIT); } @@ -207,7 +210,7 @@ public final class RadioManagerTest { public void getUpperLimit_forBandDescriptor() { RadioManager.BandDescriptor bandDescriptor = createAmBandDescriptor(); - assertWithMessage("AM Band Descriptor upper limit") + mExpect.withMessage("AM Band Descriptor upper limit") .that(bandDescriptor.getUpperLimit()).isEqualTo(AM_UPPER_LIMIT); } @@ -215,7 +218,7 @@ public final class RadioManagerTest { public void getSpacing_forBandDescriptor() { RadioManager.BandDescriptor bandDescriptor = createAmBandDescriptor(); - assertWithMessage("AM Band Descriptor spacing") + mExpect.withMessage("AM Band Descriptor spacing") .that(bandDescriptor.getSpacing()).isEqualTo(AM_SPACING); } @@ -223,7 +226,7 @@ public final class RadioManagerTest { public void describeContents_forBandDescriptor() { RadioManager.BandDescriptor bandDescriptor = createFmBandDescriptor(); - assertWithMessage("Band Descriptor contents") + mExpect.withMessage("Band Descriptor contents") .that(bandDescriptor.describeContents()).isEqualTo(0); } @@ -237,7 +240,7 @@ public final class RadioManagerTest { RadioManager.BandDescriptor bandDescriptorFromParcel = RadioManager.BandDescriptor.CREATOR.createFromParcel(parcel); - assertWithMessage("Band Descriptor created from parcel") + mExpect.withMessage("Band Descriptor created from parcel") .that(bandDescriptorFromParcel).isEqualTo(bandDescriptor); } @@ -246,14 +249,14 @@ public final class RadioManagerTest { RadioManager.BandDescriptor[] bandDescriptors = RadioManager.BandDescriptor.CREATOR.newArray(CREATOR_ARRAY_SIZE); - assertWithMessage("Band Descriptors").that(bandDescriptors).hasLength(CREATOR_ARRAY_SIZE); + mExpect.withMessage("Band Descriptors").that(bandDescriptors).hasLength(CREATOR_ARRAY_SIZE); } @Test public void isAmBand_forAmBandDescriptor_returnsTrue() { RadioManager.BandDescriptor bandDescriptor = createAmBandDescriptor(); - assertWithMessage("Is AM Band Descriptor an AM band") + mExpect.withMessage("Is AM Band Descriptor an AM band") .that(bandDescriptor.isAmBand()).isTrue(); } @@ -261,43 +264,43 @@ public final class RadioManagerTest { public void isFmBand_forAmBandDescriptor_returnsFalse() { RadioManager.BandDescriptor bandDescriptor = createAmBandDescriptor(); - assertWithMessage("Is AM Band Descriptor an FM band") + mExpect.withMessage("Is AM Band Descriptor an FM band") .that(bandDescriptor.isFmBand()).isFalse(); } @Test public void isStereoSupported_forFmBandDescriptor() { - assertWithMessage("FM Band Descriptor stereo") + mExpect.withMessage("FM Band Descriptor stereo") .that(FM_BAND_DESCRIPTOR.isStereoSupported()).isEqualTo(STEREO_SUPPORTED); } @Test public void isRdsSupported_forFmBandDescriptor() { - assertWithMessage("FM Band Descriptor RDS or RBDS") + mExpect.withMessage("FM Band Descriptor RDS or RBDS") .that(FM_BAND_DESCRIPTOR.isRdsSupported()).isEqualTo(RDS_SUPPORTED); } @Test public void isTaSupported_forFmBandDescriptor() { - assertWithMessage("FM Band Descriptor traffic announcement") + mExpect.withMessage("FM Band Descriptor traffic announcement") .that(FM_BAND_DESCRIPTOR.isTaSupported()).isEqualTo(TA_SUPPORTED); } @Test public void isAfSupported_forFmBandDescriptor() { - assertWithMessage("FM Band Descriptor alternate frequency") + mExpect.withMessage("FM Band Descriptor alternate frequency") .that(FM_BAND_DESCRIPTOR.isAfSupported()).isEqualTo(AF_SUPPORTED); } @Test public void isEaSupported_forFmBandDescriptor() { - assertWithMessage("FM Band Descriptor emergency announcement") + mExpect.withMessage("FM Band Descriptor emergency announcement") .that(FM_BAND_DESCRIPTOR.isEaSupported()).isEqualTo(EA_SUPPORTED); } @Test public void describeContents_forFmBandDescriptor() { - assertWithMessage("FM Band Descriptor contents") + mExpect.withMessage("FM Band Descriptor contents") .that(FM_BAND_DESCRIPTOR.describeContents()).isEqualTo(0); } @@ -310,7 +313,7 @@ public final class RadioManagerTest { RadioManager.FmBandDescriptor fmBandDescriptorFromParcel = RadioManager.FmBandDescriptor.CREATOR.createFromParcel(parcel); - assertWithMessage("FM Band Descriptor created from parcel") + mExpect.withMessage("FM Band Descriptor created from parcel") .that(fmBandDescriptorFromParcel).isEqualTo(FM_BAND_DESCRIPTOR); } @@ -319,19 +322,19 @@ public final class RadioManagerTest { RadioManager.FmBandDescriptor[] fmBandDescriptors = RadioManager.FmBandDescriptor.CREATOR.newArray(CREATOR_ARRAY_SIZE); - assertWithMessage("FM Band Descriptors") + mExpect.withMessage("FM Band Descriptors") .that(fmBandDescriptors).hasLength(CREATOR_ARRAY_SIZE); } @Test public void isStereoSupported_forAmBandDescriptor() { - assertWithMessage("AM Band Descriptor stereo") + mExpect.withMessage("AM Band Descriptor stereo") .that(AM_BAND_DESCRIPTOR.isStereoSupported()).isEqualTo(STEREO_SUPPORTED); } @Test public void describeContents_forAmBandDescriptor() { - assertWithMessage("AM Band Descriptor contents") + mExpect.withMessage("AM Band Descriptor contents") .that(AM_BAND_DESCRIPTOR.describeContents()).isEqualTo(0); } @@ -344,7 +347,7 @@ public final class RadioManagerTest { RadioManager.AmBandDescriptor amBandDescriptorFromParcel = RadioManager.AmBandDescriptor.CREATOR.createFromParcel(parcel); - assertWithMessage("FM Band Descriptor created from parcel") + mExpect.withMessage("FM Band Descriptor created from parcel") .that(amBandDescriptorFromParcel).isEqualTo(AM_BAND_DESCRIPTOR); } @@ -353,7 +356,7 @@ public final class RadioManagerTest { RadioManager.AmBandDescriptor[] amBandDescriptors = RadioManager.AmBandDescriptor.CREATOR.newArray(CREATOR_ARRAY_SIZE); - assertWithMessage("AM Band Descriptors") + mExpect.withMessage("AM Band Descriptors") .that(amBandDescriptors).hasLength(CREATOR_ARRAY_SIZE); } @@ -361,7 +364,7 @@ public final class RadioManagerTest { public void equals_withSameFmBandDescriptors_returnsTrue() { RadioManager.FmBandDescriptor fmBandDescriptorCompared = createFmBandDescriptor(); - assertWithMessage("The same FM Band Descriptor") + mExpect.withMessage("The same FM Band Descriptor") .that(FM_BAND_DESCRIPTOR).isEqualTo(fmBandDescriptorCompared); } @@ -369,19 +372,19 @@ public final class RadioManagerTest { public void equals_withSameAmBandDescriptors_returnsTrue() { RadioManager.AmBandDescriptor amBandDescriptorCompared = createAmBandDescriptor(); - assertWithMessage("The same AM Band Descriptor") + mExpect.withMessage("The same AM Band Descriptor") .that(AM_BAND_DESCRIPTOR).isEqualTo(amBandDescriptorCompared); } @Test public void equals_withAmBandDescriptorsAndOtherTypeObject() { - assertWithMessage("AM Band Descriptor") + mExpect.withMessage("AM Band Descriptor") .that(AM_BAND_DESCRIPTOR).isNotEqualTo(FM_BAND_DESCRIPTOR); } @Test public void equals_withFmBandDescriptorsAndOtherTypeObject() { - assertWithMessage("FM Band Descriptor") + mExpect.withMessage("FM Band Descriptor") .that(FM_BAND_DESCRIPTOR).isNotEqualTo(AM_BAND_DESCRIPTOR); } @@ -391,7 +394,7 @@ public final class RadioManagerTest { new RadioManager.AmBandDescriptor(REGION, RadioManager.BAND_AM, AM_LOWER_LIMIT, AM_UPPER_LIMIT + AM_SPACING, AM_SPACING, STEREO_SUPPORTED); - assertWithMessage("AM Band Descriptor of different upper limit") + mExpect.withMessage("AM Band Descriptor of different upper limit") .that(AM_BAND_DESCRIPTOR).isNotEqualTo(amBandDescriptorCompared); } @@ -401,7 +404,7 @@ public final class RadioManagerTest { new RadioManager.AmBandDescriptor(REGION, RadioManager.BAND_AM, AM_LOWER_LIMIT, AM_UPPER_LIMIT, AM_SPACING, !STEREO_SUPPORTED); - assertWithMessage("AM Band Descriptor of different stereo support values") + mExpect.withMessage("AM Band Descriptor of different stereo support values") .that(AM_BAND_DESCRIPTOR).isNotEqualTo(amBandDescriptorCompared); } @@ -411,7 +414,7 @@ public final class RadioManagerTest { REGION, RadioManager.BAND_FM, FM_LOWER_LIMIT, FM_UPPER_LIMIT, FM_SPACING * 2, STEREO_SUPPORTED, RDS_SUPPORTED, TA_SUPPORTED, AF_SUPPORTED, EA_SUPPORTED); - assertWithMessage("FM Band Descriptors of different support limit values") + mExpect.withMessage("FM Band Descriptors of different support limit values") .that(FM_BAND_DESCRIPTOR).isNotEqualTo(fmBandDescriptorCompared); } @@ -421,7 +424,7 @@ public final class RadioManagerTest { REGION + 1, RadioManager.BAND_AM_HD, AM_LOWER_LIMIT, AM_UPPER_LIMIT, AM_SPACING, STEREO_SUPPORTED, RDS_SUPPORTED, TA_SUPPORTED, AF_SUPPORTED, EA_SUPPORTED); - assertWithMessage("FM Band Descriptors of different region values") + mExpect.withMessage("FM Band Descriptors of different region values") .that(FM_BAND_DESCRIPTOR).isNotEqualTo(fmBandDescriptorCompared); } @@ -431,7 +434,7 @@ public final class RadioManagerTest { REGION, RadioManager.BAND_FM, FM_LOWER_LIMIT, FM_UPPER_LIMIT, FM_SPACING, !STEREO_SUPPORTED, RDS_SUPPORTED, TA_SUPPORTED, AF_SUPPORTED, EA_SUPPORTED); - assertWithMessage("FM Band Descriptors of different stereo support values") + mExpect.withMessage("FM Band Descriptors of different stereo support values") .that(fmBandDescriptorCompared).isNotEqualTo(FM_BAND_DESCRIPTOR); } @@ -441,7 +444,7 @@ public final class RadioManagerTest { REGION, RadioManager.BAND_FM, FM_LOWER_LIMIT, FM_UPPER_LIMIT, FM_SPACING, STEREO_SUPPORTED, !RDS_SUPPORTED, TA_SUPPORTED, AF_SUPPORTED, EA_SUPPORTED); - assertWithMessage("FM Band Descriptors of different rds support values") + mExpect.withMessage("FM Band Descriptors of different rds support values") .that(fmBandDescriptorCompared).isNotEqualTo(FM_BAND_DESCRIPTOR); } @@ -451,7 +454,7 @@ public final class RadioManagerTest { REGION, RadioManager.BAND_FM, FM_LOWER_LIMIT, FM_UPPER_LIMIT, FM_SPACING, STEREO_SUPPORTED, RDS_SUPPORTED, !TA_SUPPORTED, AF_SUPPORTED, EA_SUPPORTED); - assertWithMessage("FM Band Descriptors of different ta support values") + mExpect.withMessage("FM Band Descriptors of different ta support values") .that(fmBandDescriptorCompared).isNotEqualTo(FM_BAND_DESCRIPTOR); } @@ -461,7 +464,7 @@ public final class RadioManagerTest { REGION, RadioManager.BAND_FM, FM_LOWER_LIMIT, FM_UPPER_LIMIT, FM_SPACING, STEREO_SUPPORTED, RDS_SUPPORTED, TA_SUPPORTED, !AF_SUPPORTED, EA_SUPPORTED); - assertWithMessage("FM Band Descriptors of different af support values") + mExpect.withMessage("FM Band Descriptors of different af support values") .that(fmBandDescriptorCompared).isNotEqualTo(FM_BAND_DESCRIPTOR); } @@ -471,7 +474,7 @@ public final class RadioManagerTest { REGION, RadioManager.BAND_FM, FM_LOWER_LIMIT, FM_UPPER_LIMIT, FM_SPACING, STEREO_SUPPORTED, RDS_SUPPORTED, TA_SUPPORTED, AF_SUPPORTED, !EA_SUPPORTED); - assertWithMessage("FM Band Descriptors of different ea support values") + mExpect.withMessage("FM Band Descriptors of different ea support values") .that(fmBandDescriptorCompared).isNotEqualTo(FM_BAND_DESCRIPTOR); } @@ -479,7 +482,7 @@ public final class RadioManagerTest { public void hashCode_withSameFmBandDescriptors_equals() { RadioManager.FmBandDescriptor fmBandDescriptorCompared = createFmBandDescriptor(); - assertWithMessage("Hash code of the same FM Band Descriptor") + mExpect.withMessage("Hash code of the same FM Band Descriptor") .that(fmBandDescriptorCompared.hashCode()).isEqualTo(FM_BAND_DESCRIPTOR.hashCode()); } @@ -487,7 +490,7 @@ public final class RadioManagerTest { public void hashCode_withSameAmBandDescriptors_equals() { RadioManager.AmBandDescriptor amBandDescriptorCompared = createAmBandDescriptor(); - assertWithMessage("Hash code of the same AM Band Descriptor") + mExpect.withMessage("Hash code of the same AM Band Descriptor") .that(amBandDescriptorCompared.hashCode()).isEqualTo(AM_BAND_DESCRIPTOR.hashCode()); } @@ -497,7 +500,7 @@ public final class RadioManagerTest { REGION, RadioManager.BAND_FM, FM_LOWER_LIMIT, FM_UPPER_LIMIT, FM_SPACING, STEREO_SUPPORTED, RDS_SUPPORTED, TA_SUPPORTED, !AF_SUPPORTED, EA_SUPPORTED); - assertWithMessage("Hash code of FM Band Descriptor of different spacing") + mExpect.withMessage("Hash code of FM Band Descriptor of different spacing") .that(fmBandDescriptorCompared.hashCode()) .isNotEqualTo(FM_BAND_DESCRIPTOR.hashCode()); } @@ -508,7 +511,7 @@ public final class RadioManagerTest { new RadioManager.AmBandDescriptor(REGION, RadioManager.BAND_AM, AM_LOWER_LIMIT, AM_UPPER_LIMIT, AM_SPACING * 2, STEREO_SUPPORTED); - assertWithMessage("Hash code of AM Band Descriptor of different spacing") + mExpect.withMessage("Hash code of AM Band Descriptor of different spacing") .that(amBandDescriptorCompared.hashCode()) .isNotEqualTo(AM_BAND_DESCRIPTOR.hashCode()); } @@ -517,7 +520,7 @@ public final class RadioManagerTest { public void getType_forBandConfig() { RadioManager.BandConfig fmBandConfig = createFmBandConfig(); - assertWithMessage("FM Band Config type") + mExpect.withMessage("FM Band Config type") .that(fmBandConfig.getType()).isEqualTo(RadioManager.BAND_FM); } @@ -525,7 +528,7 @@ public final class RadioManagerTest { public void getRegion_forBandConfig() { RadioManager.BandConfig amBandConfig = createAmBandConfig(); - assertWithMessage("AM Band Config region") + mExpect.withMessage("AM Band Config region") .that(amBandConfig.getRegion()).isEqualTo(REGION); } @@ -533,7 +536,7 @@ public final class RadioManagerTest { public void getLowerLimit_forBandConfig() { RadioManager.BandConfig amBandConfig = createAmBandConfig(); - assertWithMessage("AM Band Config lower limit") + mExpect.withMessage("AM Band Config lower limit") .that(amBandConfig.getLowerLimit()).isEqualTo(AM_LOWER_LIMIT); } @@ -541,7 +544,7 @@ public final class RadioManagerTest { public void getUpperLimit_forBandConfig() { RadioManager.BandConfig fmBandConfig = createFmBandConfig(); - assertWithMessage("FM Band Config upper limit") + mExpect.withMessage("FM Band Config upper limit") .that(fmBandConfig.getUpperLimit()).isEqualTo(FM_UPPER_LIMIT); } @@ -549,7 +552,7 @@ public final class RadioManagerTest { public void getSpacing_forBandConfig() { RadioManager.BandConfig fmBandConfig = createFmBandConfig(); - assertWithMessage("FM Band Config spacing") + mExpect.withMessage("FM Band Config spacing") .that(fmBandConfig.getSpacing()).isEqualTo(FM_SPACING); } @@ -557,7 +560,7 @@ public final class RadioManagerTest { public void describeContents_forBandConfig() { RadioManager.BandConfig bandConfig = createFmBandConfig(); - assertWithMessage("FM Band Config contents") + mExpect.withMessage("FM Band Config contents") .that(bandConfig.describeContents()).isEqualTo(0); } @@ -571,7 +574,7 @@ public final class RadioManagerTest { RadioManager.BandConfig bandConfigFromParcel = RadioManager.BandConfig.CREATOR.createFromParcel(parcel); - assertWithMessage("Band Config created from parcel") + mExpect.withMessage("Band Config created from parcel") .that(bandConfigFromParcel).isEqualTo(bandConfig); } @@ -580,42 +583,42 @@ public final class RadioManagerTest { RadioManager.BandConfig[] bandConfigs = RadioManager.BandConfig.CREATOR.newArray(CREATOR_ARRAY_SIZE); - assertWithMessage("Band Configs").that(bandConfigs).hasLength(CREATOR_ARRAY_SIZE); + mExpect.withMessage("Band Configs").that(bandConfigs).hasLength(CREATOR_ARRAY_SIZE); } @Test public void getStereo_forFmBandConfig() { - assertWithMessage("FM Band Config stereo") + mExpect.withMessage("FM Band Config stereo") .that(FM_BAND_CONFIG.getStereo()).isEqualTo(STEREO_SUPPORTED); } @Test public void getRds_forFmBandConfig() { - assertWithMessage("FM Band Config RDS or RBDS") + mExpect.withMessage("FM Band Config RDS or RBDS") .that(FM_BAND_CONFIG.getRds()).isEqualTo(RDS_SUPPORTED); } @Test public void getTa_forFmBandConfig() { - assertWithMessage("FM Band Config traffic announcement") + mExpect.withMessage("FM Band Config traffic announcement") .that(FM_BAND_CONFIG.getTa()).isEqualTo(TA_SUPPORTED); } @Test public void getAf_forFmBandConfig() { - assertWithMessage("FM Band Config alternate frequency") + mExpect.withMessage("FM Band Config alternate frequency") .that(FM_BAND_CONFIG.getAf()).isEqualTo(AF_SUPPORTED); } @Test public void getEa_forFmBandConfig() { - assertWithMessage("FM Band Config emergency Announcement") + mExpect.withMessage("FM Band Config emergency Announcement") .that(FM_BAND_CONFIG.getEa()).isEqualTo(EA_SUPPORTED); } @Test public void describeContents_forFmBandConfig() { - assertWithMessage("FM Band Config contents") + mExpect.withMessage("FM Band Config contents") .that(FM_BAND_CONFIG.describeContents()).isEqualTo(0); } @@ -628,7 +631,7 @@ public final class RadioManagerTest { RadioManager.FmBandConfig fmBandConfigFromParcel = RadioManager.FmBandConfig.CREATOR.createFromParcel(parcel); - assertWithMessage("FM Band Config created from parcel") + mExpect.withMessage("FM Band Config created from parcel") .that(fmBandConfigFromParcel).isEqualTo(FM_BAND_CONFIG); } @@ -637,18 +640,18 @@ public final class RadioManagerTest { RadioManager.FmBandConfig[] fmBandConfigs = RadioManager.FmBandConfig.CREATOR.newArray(CREATOR_ARRAY_SIZE); - assertWithMessage("FM Band Configs").that(fmBandConfigs).hasLength(CREATOR_ARRAY_SIZE); + mExpect.withMessage("FM Band Configs").that(fmBandConfigs).hasLength(CREATOR_ARRAY_SIZE); } @Test public void getStereo_forAmBandConfig() { - assertWithMessage("AM Band Config stereo") + mExpect.withMessage("AM Band Config stereo") .that(AM_BAND_CONFIG.getStereo()).isEqualTo(STEREO_SUPPORTED); } @Test public void describeContents_forAmBandConfig() { - assertWithMessage("AM Band Config contents") + mExpect.withMessage("AM Band Config contents") .that(AM_BAND_CONFIG.describeContents()).isEqualTo(0); } @@ -661,7 +664,7 @@ public final class RadioManagerTest { RadioManager.AmBandConfig amBandConfigFromParcel = RadioManager.AmBandConfig.CREATOR.createFromParcel(parcel); - assertWithMessage("AM Band Config created from parcel") + mExpect.withMessage("AM Band Config created from parcel") .that(amBandConfigFromParcel).isEqualTo(AM_BAND_CONFIG); } @@ -670,7 +673,7 @@ public final class RadioManagerTest { RadioManager.AmBandConfig[] amBandConfigs = RadioManager.AmBandConfig.CREATOR.newArray(CREATOR_ARRAY_SIZE); - assertWithMessage("AM Band Configs").that(amBandConfigs).hasLength(CREATOR_ARRAY_SIZE); + mExpect.withMessage("AM Band Configs").that(amBandConfigs).hasLength(CREATOR_ARRAY_SIZE); } @Test @@ -679,7 +682,7 @@ public final class RadioManagerTest { new RadioManager.FmBandConfig.Builder(FM_BAND_CONFIG); RadioManager.FmBandConfig fmBandConfigCompared = builder.build(); - assertWithMessage("The same FM Band Config") + mExpect.withMessage("The same FM Band Config") .that(FM_BAND_CONFIG).isEqualTo(fmBandConfigCompared); } @@ -690,7 +693,7 @@ public final class RadioManagerTest { AM_LOWER_LIMIT, AM_UPPER_LIMIT, AM_SPACING, STEREO_SUPPORTED, RDS_SUPPORTED, TA_SUPPORTED, AF_SUPPORTED, EA_SUPPORTED)); - assertWithMessage("FM Band Config of different regions") + mExpect.withMessage("FM Band Config of different regions") .that(FM_BAND_CONFIG).isNotEqualTo(fmBandConfigCompared); } @@ -701,7 +704,7 @@ public final class RadioManagerTest { FM_UPPER_LIMIT, FM_SPACING, !STEREO_SUPPORTED, RDS_SUPPORTED, TA_SUPPORTED, AF_SUPPORTED, EA_SUPPORTED)); - assertWithMessage("FM Band Config with different stereo support values") + mExpect.withMessage("FM Band Config with different stereo support values") .that(fmBandConfigCompared).isNotEqualTo(FM_BAND_CONFIG); } @@ -712,7 +715,7 @@ public final class RadioManagerTest { FM_UPPER_LIMIT, FM_SPACING, STEREO_SUPPORTED, !RDS_SUPPORTED, TA_SUPPORTED, AF_SUPPORTED, EA_SUPPORTED)); - assertWithMessage("FM Band Config with different RDS support values") + mExpect.withMessage("FM Band Config with different RDS support values") .that(fmBandConfigCompared).isNotEqualTo(FM_BAND_CONFIG); } @@ -723,7 +726,7 @@ public final class RadioManagerTest { FM_UPPER_LIMIT, FM_SPACING, STEREO_SUPPORTED, RDS_SUPPORTED, !TA_SUPPORTED, AF_SUPPORTED, EA_SUPPORTED)); - assertWithMessage("FM Band Configs with different ta values") + mExpect.withMessage("FM Band Configs with different ta values") .that(fmBandConfigCompared).isNotEqualTo(FM_BAND_CONFIG); } @@ -734,7 +737,7 @@ public final class RadioManagerTest { .setTa(TA_SUPPORTED).setAf(!AF_SUPPORTED).setEa(EA_SUPPORTED); RadioManager.FmBandConfig fmBandConfigCompared = builder.build(); - assertWithMessage("FM Band Config of different af support value") + mExpect.withMessage("FM Band Config of different af support value") .that(FM_BAND_CONFIG).isNotEqualTo(fmBandConfigCompared); } @@ -745,19 +748,19 @@ public final class RadioManagerTest { FM_UPPER_LIMIT, FM_SPACING, STEREO_SUPPORTED, RDS_SUPPORTED, TA_SUPPORTED, AF_SUPPORTED, !EA_SUPPORTED)); - assertWithMessage("FM Band Configs with different ea support values") + mExpect.withMessage("FM Band Configs with different ea support values") .that(fmBandConfigCompared).isNotEqualTo(FM_BAND_CONFIG); } @Test public void equals_withAmBandConfigsAndOtherTypeObject() { - assertWithMessage("AM Band Config") + mExpect.withMessage("AM Band Config") .that(AM_BAND_CONFIG).isNotEqualTo(FM_BAND_CONFIG); } @Test public void equals_withFmBandConfigsAndOtherTypeObject() { - assertWithMessage("FM Band Config") + mExpect.withMessage("FM Band Config") .that(FM_BAND_CONFIG).isNotEqualTo(AM_BAND_CONFIG); } @@ -767,7 +770,7 @@ public final class RadioManagerTest { new RadioManager.AmBandConfig.Builder(AM_BAND_CONFIG); RadioManager.AmBandConfig amBandConfigCompared = builder.build(); - assertWithMessage("The same AM Band Config") + mExpect.withMessage("The same AM Band Config") .that(AM_BAND_CONFIG).isEqualTo(amBandConfigCompared); } @@ -777,7 +780,7 @@ public final class RadioManagerTest { new RadioManager.AmBandDescriptor(REGION, RadioManager.BAND_AM_HD, AM_LOWER_LIMIT, AM_UPPER_LIMIT, AM_SPACING, STEREO_SUPPORTED)); - assertWithMessage("AM Band Config of different type") + mExpect.withMessage("AM Band Config of different type") .that(AM_BAND_CONFIG).isNotEqualTo(amBandConfigCompared); } @@ -787,7 +790,7 @@ public final class RadioManagerTest { createAmBandDescriptor()).setStereo(!STEREO_SUPPORTED); RadioManager.AmBandConfig amBandConfigFromBuilder = builder.build(); - assertWithMessage("AM Band Config of different stereo value") + mExpect.withMessage("AM Band Config of different stereo value") .that(AM_BAND_CONFIG).isNotEqualTo(amBandConfigFromBuilder); } @@ -795,7 +798,7 @@ public final class RadioManagerTest { public void hashCode_withSameFmBandConfigs_equals() { RadioManager.FmBandConfig fmBandConfigCompared = createFmBandConfig(); - assertWithMessage("Hash code of the same FM Band Config") + mExpect.withMessage("Hash code of the same FM Band Config") .that(FM_BAND_CONFIG.hashCode()).isEqualTo(fmBandConfigCompared.hashCode()); } @@ -803,7 +806,7 @@ public final class RadioManagerTest { public void hashCode_withSameAmBandConfigs_equals() { RadioManager.AmBandConfig amBandConfigCompared = createAmBandConfig(); - assertWithMessage("Hash code of the same AM Band Config") + mExpect.withMessage("Hash code of the same AM Band Config") .that(amBandConfigCompared.hashCode()).isEqualTo(AM_BAND_CONFIG.hashCode()); } @@ -814,7 +817,7 @@ public final class RadioManagerTest { FM_UPPER_LIMIT, FM_SPACING, STEREO_SUPPORTED, RDS_SUPPORTED, TA_SUPPORTED, AF_SUPPORTED, EA_SUPPORTED)); - assertWithMessage("Hash code of FM Band Config with different type") + mExpect.withMessage("Hash code of FM Band Config with different type") .that(fmBandConfigCompared.hashCode()).isNotEqualTo(FM_BAND_CONFIG.hashCode()); } @@ -824,87 +827,87 @@ public final class RadioManagerTest { new RadioManager.AmBandDescriptor(REGION, RadioManager.BAND_AM, AM_LOWER_LIMIT, AM_UPPER_LIMIT, AM_SPACING, !STEREO_SUPPORTED)); - assertWithMessage("Hash code of AM Band Config with different stereo support") + mExpect.withMessage("Hash code of AM Band Config with different stereo support") .that(amBandConfigCompared.hashCode()).isNotEqualTo(AM_BAND_CONFIG.hashCode()); } @Test public void getId_forModuleProperties() { - assertWithMessage("Properties id") + mExpect.withMessage("Properties id") .that(AMFM_PROPERTIES.getId()).isEqualTo(PROPERTIES_ID); } @Test public void getServiceName_forModuleProperties() { - assertWithMessage("Properties service name") + mExpect.withMessage("Properties service name") .that(AMFM_PROPERTIES.getServiceName()).isEqualTo(SERVICE_NAME); } @Test public void getClassId_forModuleProperties() { - assertWithMessage("Properties class ID") + mExpect.withMessage("Properties class ID") .that(AMFM_PROPERTIES.getClassId()).isEqualTo(CLASS_ID); } @Test public void getImplementor_forModuleProperties() { - assertWithMessage("Properties implementor") + mExpect.withMessage("Properties implementor") .that(AMFM_PROPERTIES.getImplementor()).isEqualTo(IMPLEMENTOR); } @Test public void getProduct_forModuleProperties() { - assertWithMessage("Properties product") + mExpect.withMessage("Properties product") .that(AMFM_PROPERTIES.getProduct()).isEqualTo(PRODUCT); } @Test public void getVersion_forModuleProperties() { - assertWithMessage("Properties version") + mExpect.withMessage("Properties version") .that(AMFM_PROPERTIES.getVersion()).isEqualTo(VERSION); } @Test public void getSerial_forModuleProperties() { - assertWithMessage("Serial properties") + mExpect.withMessage("Serial properties") .that(AMFM_PROPERTIES.getSerial()).isEqualTo(SERIAL); } @Test public void getNumTuners_forModuleProperties() { - assertWithMessage("Number of tuners in properties") + mExpect.withMessage("Number of tuners in properties") .that(AMFM_PROPERTIES.getNumTuners()).isEqualTo(NUM_TUNERS); } @Test public void getNumAudioSources_forModuleProperties() { - assertWithMessage("Number of audio sources in properties") + mExpect.withMessage("Number of audio sources in properties") .that(AMFM_PROPERTIES.getNumAudioSources()).isEqualTo(NUM_AUDIO_SOURCES); } @Test public void isInitializationRequired_forModuleProperties() { - assertWithMessage("Initialization required in properties") + mExpect.withMessage("Initialization required in properties") .that(AMFM_PROPERTIES.isInitializationRequired()) .isEqualTo(IS_INITIALIZATION_REQUIRED); } @Test public void isCaptureSupported_forModuleProperties() { - assertWithMessage("Capture support in properties") + mExpect.withMessage("Capture support in properties") .that(AMFM_PROPERTIES.isCaptureSupported()).isEqualTo(IS_CAPTURE_SUPPORTED); } @Test public void isBackgroundScanningSupported_forModuleProperties() { - assertWithMessage("Background scan support in properties") + mExpect.withMessage("Background scan support in properties") .that(AMFM_PROPERTIES.isBackgroundScanningSupported()) .isEqualTo(IS_BG_SCAN_SUPPORTED); } @Test public void isProgramTypeSupported_withSupportedType_forModuleProperties() { - assertWithMessage("AM/FM frequency type radio support in properties") + mExpect.withMessage("AM/FM frequency type radio support in properties") .that(AMFM_PROPERTIES.isProgramTypeSupported( ProgramSelector.IDENTIFIER_TYPE_AMFM_FREQUENCY)) .isTrue(); @@ -912,28 +915,28 @@ public final class RadioManagerTest { @Test public void isProgramTypeSupported_withNonSupportedType_forModuleProperties() { - assertWithMessage("DAB frequency type radio support in properties") + mExpect.withMessage("DAB frequency type radio support in properties") .that(AMFM_PROPERTIES.isProgramTypeSupported( ProgramSelector.IDENTIFIER_TYPE_DAB_FREQUENCY)).isFalse(); } @Test public void isProgramIdentifierSupported_withSupportedIdentifier_forModuleProperties() { - assertWithMessage("AM/FM frequency identifier radio support in properties") + mExpect.withMessage("AM/FM frequency identifier radio support in properties") .that(AMFM_PROPERTIES.isProgramIdentifierSupported( ProgramSelector.IDENTIFIER_TYPE_AMFM_FREQUENCY)).isTrue(); } @Test public void isProgramIdentifierSupported_withNonSupportedIdentifier_forModuleProperties() { - assertWithMessage("DAB frequency identifier radio support in properties") + mExpect.withMessage("DAB frequency identifier radio support in properties") .that(AMFM_PROPERTIES.isProgramIdentifierSupported( ProgramSelector.IDENTIFIER_TYPE_DAB_FREQUENCY)).isFalse(); } @Test public void getDabFrequencyTable_forModulePropertiesInitializedWithNullTable() { - assertWithMessage("Properties DAB frequency table") + mExpect.withMessage("Properties DAB frequency table") .that(AMFM_PROPERTIES.getDabFrequencyTable()).isNull(); } @@ -941,32 +944,32 @@ public final class RadioManagerTest { public void getDabFrequencyTable_forModulePropertiesInitializedWithEmptyTable() { RadioManager.ModuleProperties properties = createAmFmProperties(new ArrayMap<>()); - assertWithMessage("Properties DAB frequency table") + mExpect.withMessage("Properties DAB frequency table") .that(properties.getDabFrequencyTable()).isNull(); } @Test public void getVendorInfo_forModuleProperties() { - assertWithMessage("Properties vendor info") + mExpect.withMessage("Properties vendor info") .that(AMFM_PROPERTIES.getVendorInfo()).isEmpty(); } @Test public void getBands_forModuleProperties() { - assertWithMessage("Properties bands") + mExpect.withMessage("Properties bands") .that(AMFM_PROPERTIES.getBands()).asList() .containsExactly(AM_BAND_DESCRIPTOR, FM_BAND_DESCRIPTOR); } @Test public void describeContents_forModuleProperties() { - assertWithMessage("Module properties contents") + mExpect.withMessage("Module properties contents") .that(AMFM_PROPERTIES.describeContents()).isEqualTo(0); } @Test public void toString_forModuleProperties() { - assertWithMessage("Module properties string").that(AMFM_PROPERTIES.toString()) + mExpect.withMessage("Module properties string").that(AMFM_PROPERTIES.toString()) .contains(AM_BAND_DESCRIPTOR.toString() + ", " + FM_BAND_DESCRIPTOR.toString()); } @@ -979,7 +982,7 @@ public final class RadioManagerTest { RadioManager.ModuleProperties modulePropertiesFromParcel = RadioManager.ModuleProperties.CREATOR.createFromParcel(parcel); - assertWithMessage("Module properties created from parcel") + mExpect.withMessage("Module properties created from parcel") .that(modulePropertiesFromParcel).isEqualTo(AMFM_PROPERTIES); } @@ -994,7 +997,7 @@ public final class RadioManagerTest { RadioManager.ModuleProperties modulePropertiesFromParcel = RadioManager.ModuleProperties.CREATOR.createFromParcel(parcel); - assertWithMessage("Module properties created from parcel") + mExpect.withMessage("Module properties created from parcel") .that(modulePropertiesFromParcel).isEqualTo(propertiesToParcel); } @@ -1003,7 +1006,7 @@ public final class RadioManagerTest { RadioManager.ModuleProperties propertiesCompared = createAmFmProperties(/* dabFrequencyTable= */ null); - assertWithMessage("The same module properties") + mExpect.withMessage("The same module properties") .that(AMFM_PROPERTIES).isEqualTo(propertiesCompared); } @@ -1016,7 +1019,7 @@ public final class RadioManagerTest { SUPPORTED_PROGRAM_TYPES, SUPPORTED_IDENTIFIERS_TYPES, Map.of("5A", 174928), /* vendorInfo= */ null); - assertWithMessage("Module properties of different id") + mExpect.withMessage("Module properties of different id") .that(AMFM_PROPERTIES).isNotEqualTo(propertiesDab); } @@ -1025,7 +1028,7 @@ public final class RadioManagerTest { RadioManager.ModuleProperties propertiesCompared = createAmFmProperties(/* dabFrequencyTable= */ null); - assertWithMessage("Hash code of the same module properties") + mExpect.withMessage("Hash code of the same module properties") .that(propertiesCompared.hashCode()).isEqualTo(AMFM_PROPERTIES.hashCode()); } @@ -1034,86 +1037,86 @@ public final class RadioManagerTest { RadioManager.ModuleProperties[] modulePropertiesArray = RadioManager.ModuleProperties.CREATOR.newArray(CREATOR_ARRAY_SIZE); - assertWithMessage("Module properties array") + mExpect.withMessage("Module properties array") .that(modulePropertiesArray).hasLength(CREATOR_ARRAY_SIZE); } @Test public void getSelector_forProgramInfo() { - assertWithMessage("Selector of DAB program info") + mExpect.withMessage("Selector of DAB program info") .that(DAB_PROGRAM_INFO.getSelector()).isEqualTo(DAB_SELECTOR); } @Test public void getLogicallyTunedTo_forProgramInfo() { - assertWithMessage("Identifier logically tuned to in DAB program info") + mExpect.withMessage("Identifier logically tuned to in DAB program info") .that(DAB_PROGRAM_INFO.getLogicallyTunedTo()).isEqualTo(DAB_SID_EXT_IDENTIFIER); } @Test public void getPhysicallyTunedTo_forProgramInfo() { - assertWithMessage("Identifier physically tuned to DAB program info") + mExpect.withMessage("Identifier physically tuned to DAB program info") .that(DAB_PROGRAM_INFO.getPhysicallyTunedTo()).isEqualTo(DAB_FREQUENCY_IDENTIFIER); } @Test public void getRelatedContent_forProgramInfo() { - assertWithMessage("DAB program info contents") + mExpect.withMessage("DAB program info contents") .that(DAB_PROGRAM_INFO.getRelatedContent()) .containsExactly(DAB_SID_EXT_IDENTIFIER_RELATED); } @Test public void getChannel_forProgramInfo() { - assertWithMessage("Main channel of DAB program info") + mExpect.withMessage("Main channel of DAB program info") .that(DAB_PROGRAM_INFO.getChannel()).isEqualTo(0); } @Test public void getSubChannel_forProgramInfo() { - assertWithMessage("Sub channel of DAB program info") + mExpect.withMessage("Sub channel of DAB program info") .that(DAB_PROGRAM_INFO.getSubChannel()).isEqualTo(0); } @Test public void isTuned_forProgramInfo() { - assertWithMessage("Tuned status of DAB program info") + mExpect.withMessage("Tuned status of DAB program info") .that(DAB_PROGRAM_INFO.isTuned()).isTrue(); } @Test public void isStereo_forProgramInfo() { - assertWithMessage("Stereo support in DAB program info") + mExpect.withMessage("Stereo support in DAB program info") .that(DAB_PROGRAM_INFO.isStereo()).isTrue(); } @Test public void isDigital_forProgramInfo() { - assertWithMessage("Digital DAB program info") + mExpect.withMessage("Digital DAB program info") .that(DAB_PROGRAM_INFO.isDigital()).isTrue(); } @Test public void isLive_forProgramInfo() { - assertWithMessage("Live status of DAB program info") + mExpect.withMessage("Live status of DAB program info") .that(DAB_PROGRAM_INFO.isLive()).isTrue(); } @Test public void isMuted_forProgramInfo() { - assertWithMessage("Muted status of DAB program info") + mExpect.withMessage("Muted status of DAB program info") .that(DAB_PROGRAM_INFO.isMuted()).isFalse(); } @Test public void isTrafficProgram_forProgramInfo() { - assertWithMessage("Traffic program support in DAB program info") + mExpect.withMessage("Traffic program support in DAB program info") .that(DAB_PROGRAM_INFO.isTrafficProgram()).isFalse(); } @Test public void isTrafficAnnouncementActive_forProgramInfo() { - assertWithMessage("Active traffic announcement for DAB program info") + mExpect.withMessage("Active traffic announcement for DAB program info") .that(DAB_PROGRAM_INFO.isTrafficAnnouncementActive()).isFalse(); } @@ -1121,7 +1124,7 @@ public final class RadioManagerTest { public void isSignalAcquired_forProgramInfo() { mSetFlagsRule.enableFlags(Flags.FLAG_HD_RADIO_IMPROVED); - assertWithMessage("Signal acquisition status for HD program info") + mExpect.withMessage("Signal acquisition status for HD program info") .that(HD_PROGRAM_INFO.isSignalAcquired()).isTrue(); } @@ -1129,7 +1132,7 @@ public final class RadioManagerTest { public void isHdSisAvailable_forProgramInfo() { mSetFlagsRule.enableFlags(Flags.FLAG_HD_RADIO_IMPROVED); - assertWithMessage("SIS information acquisition status for HD program") + mExpect.withMessage("SIS information acquisition status for HD program") .that(HD_PROGRAM_INFO.isHdSisAvailable()).isTrue(); } @@ -1137,31 +1140,31 @@ public final class RadioManagerTest { public void isHdAudioAvailable_forProgramInfo() { mSetFlagsRule.enableFlags(Flags.FLAG_HD_RADIO_IMPROVED); - assertWithMessage("Audio acquisition status for HD program") + mExpect.withMessage("Audio acquisition status for HD program") .that(HD_PROGRAM_INFO.isHdAudioAvailable()).isFalse(); } @Test public void getSignalStrength_forProgramInfo() { - assertWithMessage("Signal strength of DAB program info") + mExpect.withMessage("Signal strength of DAB program info") .that(DAB_PROGRAM_INFO.getSignalStrength()).isEqualTo(SIGNAL_QUALITY); } @Test public void getMetadata_forProgramInfo() { - assertWithMessage("Metadata of DAB program info") + mExpect.withMessage("Metadata of DAB program info") .that(DAB_PROGRAM_INFO.getMetadata()).isEqualTo(METADATA); } @Test public void getVendorInfo_forProgramInfo() { - assertWithMessage("Vendor info of DAB program info") + mExpect.withMessage("Vendor info of DAB program info") .that(DAB_PROGRAM_INFO.getVendorInfo()).isEmpty(); } @Test public void describeContents_forProgramInfo() { - assertWithMessage("Program info contents") + mExpect.withMessage("Program info contents") .that(DAB_PROGRAM_INFO.describeContents()).isEqualTo(0); } @@ -1170,7 +1173,7 @@ public final class RadioManagerTest { RadioManager.ProgramInfo[] programInfoArray = RadioManager.ProgramInfo.CREATOR.newArray(CREATOR_ARRAY_SIZE); - assertWithMessage("Program infos").that(programInfoArray).hasLength(CREATOR_ARRAY_SIZE); + mExpect.withMessage("Program infos").that(programInfoArray).hasLength(CREATOR_ARRAY_SIZE); } @Test @@ -1182,7 +1185,7 @@ public final class RadioManagerTest { RadioManager.ProgramInfo programInfoFromParcel = RadioManager.ProgramInfo.CREATOR.createFromParcel(parcel); - assertWithMessage("Program info created from parcel") + mExpect.withMessage("Program info created from parcel") .that(programInfoFromParcel).isEqualTo(DAB_PROGRAM_INFO); } @@ -1190,7 +1193,7 @@ public final class RadioManagerTest { public void equals_withSameProgramInfo_returnsTrue() { RadioManager.ProgramInfo dabProgramInfoCompared = createDabProgramInfo(DAB_SELECTOR); - assertWithMessage("The same program info") + mExpect.withMessage("The same program info") .that(dabProgramInfoCompared).isEqualTo(DAB_PROGRAM_INFO); } @@ -1202,7 +1205,7 @@ public final class RadioManagerTest { /* vendorIds= */ null); RadioManager.ProgramInfo dabProgramInfoCompared = createDabProgramInfo(dabSelectorCompared); - assertWithMessage("Program info with different secondary id selectors") + mExpect.withMessage("Program info with different secondary id selectors") .that(DAB_PROGRAM_INFO).isNotEqualTo(dabProgramInfoCompared); } @@ -1213,7 +1216,7 @@ public final class RadioManagerTest { mRadioManager.listModules(modules); - assertWithMessage("Modules in radio manager") + mExpect.withMessage("Modules in radio manager") .that(modules).containsExactly(AMFM_PROPERTIES); } @@ -1221,7 +1224,7 @@ public final class RadioManagerTest { public void listModules_forRadioManagerWithNullListAsInput_fails() throws Exception { createRadioManager(); - assertWithMessage("Status when listing module with empty list input") + mExpect.withMessage("Status when listing module with empty list input") .that(mRadioManager.listModules(null)).isEqualTo(RadioManager.STATUS_BAD_VALUE); } @@ -1231,7 +1234,7 @@ public final class RadioManagerTest { when(mRadioServiceMock.listModules()).thenReturn(null); List<RadioManager.ModuleProperties> modules = new ArrayList<>(); - assertWithMessage("Status for listing module when getting null list from HAL client") + mExpect.withMessage("Status for listing module when getting null list from HAL client") .that(mRadioManager.listModules(modules)).isEqualTo(RadioManager.STATUS_ERROR); } @@ -1241,7 +1244,7 @@ public final class RadioManagerTest { when(mRadioServiceMock.listModules()).thenThrow(new RemoteException()); List<RadioManager.ModuleProperties> modules = new ArrayList<>(); - assertWithMessage("Status for listing module when HAL client service is dead") + mExpect.withMessage("Status for listing module when HAL client service is dead") .that(mRadioManager.listModules(modules)) .isEqualTo(RadioManager.STATUS_DEAD_OBJECT); } @@ -1267,7 +1270,21 @@ public final class RadioManagerTest { RadioTuner nullTuner = mRadioManager.openTuner(/* moduleId= */ 0, FM_BAND_CONFIG, /* withAudio= */ true, mCallbackMock, /* handler= */ null); - assertWithMessage("Radio tuner when service is dead").that(nullTuner).isNull(); + mExpect.withMessage("Radio tuner when service is dead").that(nullTuner).isNull(); + } + + @Test + public void openTuner_withNullCallback() throws Exception { + createRadioManager(); + int moduleId = 0; + boolean withAudio = true; + + IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, + () -> mRadioManager.openTuner(moduleId, FM_BAND_CONFIG, withAudio, + /* callback= */ null, /* handler= */ null)); + + mExpect.withMessage("Null tuner callback exception").that(thrown) + .hasMessageThat().contains("callback must not be empty"); } @Test @@ -1323,7 +1340,7 @@ public final class RadioManagerTest { RuntimeException thrown = assertThrows(RuntimeException.class, () -> mRadioManager.addAnnouncementListener(enableTypeSet, mEventListener)); - assertWithMessage("Exception for adding announcement listener with dead service") + mExpect.withMessage("Exception for adding announcement listener with dead service") .that(thrown).hasMessageThat().contains(exceptionMessage); } diff --git a/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/AnnouncementAggregatorTest.java b/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/AnnouncementAggregatorTest.java index 0e0dbecb7df3..2bf0aa3bfaa4 100644 --- a/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/AnnouncementAggregatorTest.java +++ b/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/AnnouncementAggregatorTest.java @@ -16,11 +16,11 @@ package com.android.server.broadcastradio.aidl; -import static com.google.common.truth.Truth.assertWithMessage; - import static org.junit.Assert.assertThrows; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; @@ -33,7 +33,10 @@ import android.hardware.radio.ICloseHandle; import android.os.IBinder; import android.os.RemoteException; +import com.google.common.truth.Expect; + import org.junit.Before; +import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; @@ -54,6 +57,9 @@ public final class AnnouncementAggregatorTest { private AnnouncementAggregator mAnnouncementAggregator; private IBinder.DeathRecipient mDeathRecipient; + @Rule + public final Expect mExpect = Expect.create(); + @Mock private IAnnouncementListener mListenerMock; @Mock @@ -75,6 +81,18 @@ public final class AnnouncementAggregatorTest { } @Test + public void constructor_withBinderDied() throws Exception { + RemoteException remoteException = new RemoteException("Binder is died"); + doThrow(remoteException).when(mBinderMock).linkToDeath(any(), anyInt()); + + RuntimeException thrown = assertThrows(RuntimeException.class, () -> + new AnnouncementAggregator(mListenerMock, mLock)); + + mExpect.withMessage("Exception for dead binder").that(thrown).hasMessageThat() + .contains(remoteException.getMessage()); + } + + @Test public void onListUpdated_withOneModuleWatcher() throws Exception { ArgumentCaptor<IAnnouncementListener> moduleWatcherCaptor = ArgumentCaptor.forClass(IAnnouncementListener.class); @@ -103,7 +121,7 @@ public final class AnnouncementAggregatorTest { moduleWatcherCaptor.getValue().onListUpdated(Arrays.asList(mAnnouncementMocks[index])); verify(mListenerMock, times(index + 1)).onListUpdated(announcementsCaptor.capture()); - assertWithMessage("Number of announcements %s after %s announcements were updated", + mExpect.withMessage("Number of announcements %s after %s announcements were updated", announcementsCaptor.getValue(), index + 1) .that(announcementsCaptor.getValue().size()).isEqualTo(index + 1); } @@ -131,7 +149,7 @@ public final class AnnouncementAggregatorTest { () -> mAnnouncementAggregator.watchModule(mRadioModuleMocks[0], TEST_ENABLED_TYPES)); - assertWithMessage("Exception for watching module after aggregator has been closed") + mExpect.withMessage("Exception for watching module after aggregator has been closed") .that(thrown).hasMessageThat() .contains("announcement aggregator has already been closed"); } diff --git a/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/ConversionUtilsTest.java b/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/ConversionUtilsTest.java index 8d9fad999624..5f78b2a8a5f0 100644 --- a/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/ConversionUtilsTest.java +++ b/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/ConversionUtilsTest.java @@ -622,6 +622,12 @@ public final class ConversionUtilsTest extends ExtendedRadioMockitoTestCase { .isEqualTo(TEST_ALBUM_ART); } + @Test + public void getBands_withInvalidFrequency() { + expect.withMessage("Band for invalid frequency") + .that(Utils.getBand(/* freq= */ 110000)).isEqualTo(Utils.FrequencyBand.UNKNOWN); + } + private static RadioManager.ModuleProperties convertToModuleProperties() { AmFmRegionConfig amFmConfig = createAmFmRegionConfig(); DabTableEntry[] dabTableEntries = new DabTableEntry[]{ diff --git a/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/ProgramInfoCacheTest.java b/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/ProgramInfoCacheTest.java index ce27bc177769..d64fcaf865f2 100644 --- a/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/ProgramInfoCacheTest.java +++ b/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/ProgramInfoCacheTest.java @@ -440,6 +440,29 @@ public class ProgramInfoCacheTest { TEST_DAB_UNIQUE_ID_ALTERNATIVE); } + @Test + public void filterAndApplyChunkInternal_withInvalidProgramInfoAndIdentifiers() + throws RemoteException { + ProgramInfoCache cache = new ProgramInfoCache(/* filter= */ null, + /* complete= */ false, TEST_FM_INFO, TEST_RDS_INFO, TEST_DAB_INFO); + ProgramInfo[] halModified = new android.hardware.broadcastradio.ProgramInfo[1]; + halModified[0] = AidlTestUtils.makeHalProgramInfo( + ConversionUtils.programSelectorToHalProgramSelector(TEST_DAB_SELECTOR_ALTERNATIVE), + ConversionUtils.identifierToHalProgramIdentifier(TEST_DAB_FREQUENCY_ID_ALTERNATIVE), + ConversionUtils.identifierToHalProgramIdentifier(TEST_DAB_FREQUENCY_ID_ALTERNATIVE), + TEST_SIGNAL_QUALITY); + ProgramIdentifier[] halRemoved = new android.hardware.broadcastradio.ProgramIdentifier[1]; + halRemoved[0] = new android.hardware.broadcastradio.ProgramIdentifier(); + ProgramListChunk halChunk = AidlTestUtils.makeHalChunk(/* purge= */ false, + /* complete= */ true, halModified, halRemoved); + + List<ProgramList.Chunk> programListChunks = cache.filterAndApplyChunkInternal(halChunk, + TEST_MAX_NUM_MODIFIED_PER_CHUNK, TEST_MAX_NUM_REMOVED_PER_CHUNK); + + expect.withMessage("Program list chunk applied with invalid program and identifiers") + .that(programListChunks).isEmpty(); + } + private void verifyChunkListPurge(List<ProgramList.Chunk> chunks, boolean purge) { if (chunks.isEmpty()) { return; diff --git a/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/AnnouncementAggregatorHidlTest.java b/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/AnnouncementAggregatorHidlTest.java index 5e99b28b62b1..8e0abff07944 100644 --- a/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/AnnouncementAggregatorHidlTest.java +++ b/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/AnnouncementAggregatorHidlTest.java @@ -16,11 +16,11 @@ package com.android.server.broadcastradio.hal2; -import static com.google.common.truth.Truth.assertWithMessage; - import static org.junit.Assert.assertThrows; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; @@ -33,7 +33,10 @@ import android.hardware.radio.ICloseHandle; import android.os.IBinder; import android.os.RemoteException; +import com.google.common.truth.Expect; + import org.junit.Before; +import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; @@ -55,6 +58,9 @@ public final class AnnouncementAggregatorHidlTest { private AnnouncementAggregator mAnnouncementAggregator; private IBinder.DeathRecipient mDeathRecipient; + @Rule + public final Expect mExpect = Expect.create(); + @Mock private IAnnouncementListener mListenerMock; @Mock @@ -76,6 +82,19 @@ public final class AnnouncementAggregatorHidlTest { } @Test + public void constructor_withBinderDied() throws Exception { + RemoteException remoteException = new RemoteException("Binder is died"); + doThrow(remoteException).when(mBinderMock).linkToDeath(any(), anyInt()); + + RuntimeException thrown = assertThrows(RuntimeException.class, + () -> new com.android.server.broadcastradio.aidl.AnnouncementAggregator( + mListenerMock, mLock)); + + mExpect.withMessage("Exception for dead binder").that(thrown).hasMessageThat() + .contains(remoteException.getMessage()); + } + + @Test public void onListUpdated_withOneModuleWatcher() throws Exception { ArgumentCaptor<IAnnouncementListener> moduleWatcherCaptor = ArgumentCaptor.forClass(IAnnouncementListener.class); @@ -104,7 +123,7 @@ public final class AnnouncementAggregatorHidlTest { moduleWatcherCaptor.getValue().onListUpdated(Arrays.asList(mAnnouncementMocks[index])); verify(mListenerMock, times(index + 1)).onListUpdated(announcementsCaptor.capture()); - assertWithMessage("Number of announcements %s after %s announcements were updated", + mExpect.withMessage("Number of announcements %s after %s announcements were updated", announcementsCaptor.getValue(), index + 1) .that(announcementsCaptor.getValue().size()).isEqualTo(index + 1); } @@ -132,7 +151,7 @@ public final class AnnouncementAggregatorHidlTest { () -> mAnnouncementAggregator.watchModule(mRadioModuleMocks[0], TEST_ENABLED_TYPES)); - assertWithMessage("Exception for watching module after aggregator has been closed") + mExpect.withMessage("Exception for watching module after aggregator has been closed") .that(thrown).hasMessageThat() .contains("announcement aggregator has already been closed"); } diff --git a/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/ConvertTest.java b/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/ConvertTest.java index 3de4f5d7dcd9..123e02c0a054 100644 --- a/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/ConvertTest.java +++ b/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/ConvertTest.java @@ -173,6 +173,12 @@ public final class ConvertTest { .that(ANNOUNCEMENT.getVendorInfo()).isEmpty(); } + @Test + public void getBands_withInvalidFrequency() { + expect.withMessage("Band for invalid frequency") + .that(Utils.getBand(/* freq= */ 110000)).isEqualTo(FrequencyBand.UNKNOWN); + } + private static RadioManager.ModuleProperties convertToModuleProperties() { AmFmRegionConfig amFmConfig = createAmFmRegionConfig(); List<DabTableEntry> dabTableEntries = Arrays.asList( diff --git a/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/ProgramInfoCacheTest.java b/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/ProgramInfoCacheTest.java index 36a64303cddd..015e9c032fd0 100644 --- a/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/ProgramInfoCacheTest.java +++ b/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/ProgramInfoCacheTest.java @@ -17,6 +17,7 @@ package com.android.server.broadcastradio.hal2; import static org.junit.Assert.*; +import android.hardware.broadcastradio.V2_0.ProgramIdentifier; import android.hardware.broadcastradio.V2_0.ProgramListChunk; import android.hardware.radio.ProgramList; import android.hardware.radio.ProgramSelector; @@ -34,6 +35,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; +import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -261,6 +263,25 @@ public class ProgramInfoCacheTest extends ExtendedRadioMockitoTestCase { verifyChunkListRemoved(chunks, 1, TEST_DAB_UNIQUE_ID, TEST_VENDOR_UNIQUE_ID); } + @Test + public void filterAndApplyChunkInternal_withInvalidIdentifier() { + ProgramInfoCache cache = new ProgramInfoCache(/* filter= */ null, /* complete= */ false, + TEST_AM_FM_INFO, TEST_RDS_INFO, TEST_DAB_INFO, TEST_VENDOR_INFO); + ArrayList<ProgramIdentifier> halRemoved = new ArrayList<>(); + halRemoved.add(new ProgramIdentifier()); + ProgramListChunk halChunk = new ProgramListChunk(); + halChunk.complete = true; + halChunk.purge = false; + halChunk.modified = new ArrayList<>(); + halChunk.removed = halRemoved; + + List<ProgramList.Chunk> programListChunks = cache.filterAndApplyChunkInternal(halChunk, + /* maxNumModifiedPerChunk= */ 1, /* maxNumRemovedPerChunk= */ 1); + + expect.withMessage("Program list chunk applied with invalid identifier") + .that(programListChunks).isEmpty(); + } + // Verifies that: // - The first chunk's purge flag matches expectPurge. // - The last chunk's complete flag matches expectComplete. diff --git a/services/core/java/com/android/server/broadcastradio/IRadioServiceAidlImpl.java b/services/core/java/com/android/server/broadcastradio/IRadioServiceAidlImpl.java index e6de14bcf9aa..16514fa813dc 100644 --- a/services/core/java/com/android/server/broadcastradio/IRadioServiceAidlImpl.java +++ b/services/core/java/com/android/server/broadcastradio/IRadioServiceAidlImpl.java @@ -29,6 +29,7 @@ import android.os.Binder; import android.os.IBinder; import android.os.RemoteException; import android.os.ServiceManager; +import android.util.IndentingPrintWriter; import android.util.Log; import com.android.internal.annotations.VisibleForTesting; @@ -121,8 +122,7 @@ final class IRadioServiceAidlImpl extends IRadioService.Stub { + " without permission " + Manifest.permission.DUMP); return; } - android.util.IndentingPrintWriter radioPrintWriter = - new android.util.IndentingPrintWriter(printWriter); + IndentingPrintWriter radioPrintWriter = new IndentingPrintWriter(printWriter); radioPrintWriter.printf("BroadcastRadioService\n"); radioPrintWriter.increaseIndent(); diff --git a/services/core/java/com/android/server/broadcastradio/IRadioServiceHidlImpl.java b/services/core/java/com/android/server/broadcastradio/IRadioServiceHidlImpl.java index 93fb7b2525fb..ab083429a200 100644 --- a/services/core/java/com/android/server/broadcastradio/IRadioServiceHidlImpl.java +++ b/services/core/java/com/android/server/broadcastradio/IRadioServiceHidlImpl.java @@ -26,6 +26,7 @@ import android.hardware.radio.ITunerCallback; import android.hardware.radio.RadioManager; import android.os.Binder; import android.os.RemoteException; +import android.util.IndentingPrintWriter; import android.util.Log; import android.util.Slog; @@ -138,7 +139,7 @@ final class IRadioServiceHidlImpl extends IRadioService.Stub { + " without permission " + Manifest.permission.DUMP); return; } - android.util.IndentingPrintWriter radioPw = new android.util.IndentingPrintWriter(pw); + IndentingPrintWriter radioPw = new IndentingPrintWriter(pw); radioPw.printf("BroadcastRadioService\n"); radioPw.increaseIndent(); diff --git a/services/core/java/com/android/server/broadcastradio/RadioEventLogger.java b/services/core/java/com/android/server/broadcastradio/RadioEventLogger.java index 2c8f499c619b..b71589c2196c 100644 --- a/services/core/java/com/android/server/broadcastradio/RadioEventLogger.java +++ b/services/core/java/com/android/server/broadcastradio/RadioEventLogger.java @@ -17,6 +17,7 @@ package com.android.server.broadcastradio; import android.text.TextUtils; +import android.util.IndentingPrintWriter; import android.util.LocalLog; import android.util.Log; @@ -54,7 +55,7 @@ public final class RadioEventLogger { * Dump broadcast radio service event * @param pw Indenting print writer for dump */ - public void dump(android.util.IndentingPrintWriter pw) { + public void dump(IndentingPrintWriter pw) { mEventLogger.dump(pw); } } diff --git a/services/core/java/com/android/server/broadcastradio/aidl/AnnouncementAggregator.java b/services/core/java/com/android/server/broadcastradio/aidl/AnnouncementAggregator.java index 9654a93d2036..b618aa3d65dc 100644 --- a/services/core/java/com/android/server/broadcastradio/aidl/AnnouncementAggregator.java +++ b/services/core/java/com/android/server/broadcastradio/aidl/AnnouncementAggregator.java @@ -22,6 +22,7 @@ import android.hardware.radio.IAnnouncementListener; import android.hardware.radio.ICloseHandle; import android.os.IBinder; import android.os.RemoteException; +import android.util.IndentingPrintWriter; import android.util.Log; import com.android.internal.annotations.GuardedBy; @@ -93,7 +94,7 @@ public final class AnnouncementAggregator extends ICloseHandle.Stub { if (mCloseHandle != null) mCloseHandle.close(); } - public void dumpInfo(android.util.IndentingPrintWriter pw) { + public void dumpInfo(IndentingPrintWriter pw) { pw.printf("ModuleWatcher:\n"); pw.increaseIndent(); @@ -191,8 +192,7 @@ public final class AnnouncementAggregator extends ICloseHandle.Stub { @Override protected void dump(FileDescriptor fd, PrintWriter printWriter, String[] args) { - android.util.IndentingPrintWriter announcementPrintWriter = - new android.util.IndentingPrintWriter(printWriter); + IndentingPrintWriter announcementPrintWriter = new IndentingPrintWriter(printWriter); announcementPrintWriter.printf("AnnouncementAggregator\n"); announcementPrintWriter.increaseIndent(); diff --git a/services/core/java/com/android/server/broadcastradio/aidl/BroadcastRadioServiceImpl.java b/services/core/java/com/android/server/broadcastradio/aidl/BroadcastRadioServiceImpl.java index 1c421614599d..d9f8588039da 100644 --- a/services/core/java/com/android/server/broadcastradio/aidl/BroadcastRadioServiceImpl.java +++ b/services/core/java/com/android/server/broadcastradio/aidl/BroadcastRadioServiceImpl.java @@ -29,6 +29,7 @@ import android.os.IServiceCallback; import android.os.RemoteException; import android.os.ServiceManager; import android.util.ArrayMap; +import android.util.IndentingPrintWriter; import android.util.Log; import android.util.SparseArray; @@ -128,7 +129,7 @@ public final class BroadcastRadioServiceImpl { if (entry.getValue() == mModuleId) { Slogf.w(TAG, "Service %s died, removed RadioModule with ID %d", entry.getKey(), mModuleId); - return; + break; } } } @@ -260,7 +261,7 @@ public final class BroadcastRadioServiceImpl { * * @param pw The file to which {@link BroadcastRadioServiceImpl} state is dumped. */ - public void dumpInfo(android.util.IndentingPrintWriter pw) { + public void dumpInfo(IndentingPrintWriter pw) { synchronized (mLock) { pw.printf("Next module id available: %d\n", mNextModuleId); pw.printf("ServiceName to module id map:\n"); diff --git a/services/core/java/com/android/server/broadcastradio/aidl/RadioModule.java b/services/core/java/com/android/server/broadcastradio/aidl/RadioModule.java index 0cac35641ed0..03e347a903b5 100644 --- a/services/core/java/com/android/server/broadcastradio/aidl/RadioModule.java +++ b/services/core/java/com/android/server/broadcastradio/aidl/RadioModule.java @@ -38,6 +38,7 @@ import android.os.Looper; import android.os.RemoteException; import android.os.UserHandle; import android.util.ArraySet; +import android.util.IndentingPrintWriter; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; @@ -524,7 +525,7 @@ final class RadioModule { return BitmapFactory.decodeByteArray(rawImage, 0, rawImage.length); } - void dumpInfo(android.util.IndentingPrintWriter pw) { + void dumpInfo(IndentingPrintWriter pw) { pw.printf("RadioModule\n"); pw.increaseIndent(); diff --git a/services/core/java/com/android/server/broadcastradio/aidl/TunerSession.java b/services/core/java/com/android/server/broadcastradio/aidl/TunerSession.java index 925f149b12cf..e90a1dda6cf5 100644 --- a/services/core/java/com/android/server/broadcastradio/aidl/TunerSession.java +++ b/services/core/java/com/android/server/broadcastradio/aidl/TunerSession.java @@ -29,6 +29,7 @@ import android.os.Binder; import android.os.RemoteException; import android.util.ArrayMap; import android.util.ArraySet; +import android.util.IndentingPrintWriter; import com.android.internal.annotations.GuardedBy; import com.android.server.broadcastradio.RadioEventLogger; @@ -434,7 +435,7 @@ final class TunerSession extends ITuner.Stub { } } - void dumpInfo(android.util.IndentingPrintWriter pw) { + void dumpInfo(IndentingPrintWriter pw) { pw.printf("TunerSession\n"); pw.increaseIndent(); diff --git a/services/core/java/com/android/server/broadcastradio/hal2/BroadcastRadioService.java b/services/core/java/com/android/server/broadcastradio/hal2/BroadcastRadioService.java index e1650c227266..a4efa2e330f8 100644 --- a/services/core/java/com/android/server/broadcastradio/hal2/BroadcastRadioService.java +++ b/services/core/java/com/android/server/broadcastradio/hal2/BroadcastRadioService.java @@ -30,6 +30,7 @@ import android.hidl.manager.V1_0.IServiceNotification; import android.os.IHwBinder.DeathRecipient; import android.os.RemoteException; import android.util.ArrayMap; +import android.util.IndentingPrintWriter; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; @@ -115,7 +116,7 @@ public final class BroadcastRadioService { if (entry.getValue() == moduleId) { Slogf.i(TAG, "service " + entry.getKey() + " died; removed RadioModule with ID " + moduleId); - return; + break; } } } @@ -221,7 +222,7 @@ public final class BroadcastRadioService { * * @param pw The file to which BroadcastRadioService state is dumped. */ - public void dumpInfo(android.util.IndentingPrintWriter pw) { + public void dumpInfo(IndentingPrintWriter pw) { synchronized (mLock) { pw.printf("Next module id available: %d\n", mNextModuleId); pw.printf("ServiceName to module id map:\n"); diff --git a/services/core/java/com/android/server/broadcastradio/hal2/RadioModule.java b/services/core/java/com/android/server/broadcastradio/hal2/RadioModule.java index 7269f24fc4b1..d3b244886a64 100644 --- a/services/core/java/com/android/server/broadcastradio/hal2/RadioModule.java +++ b/services/core/java/com/android/server/broadcastradio/hal2/RadioModule.java @@ -40,6 +40,7 @@ import android.os.Looper; import android.os.RemoteException; import android.os.UserHandle; import android.util.ArraySet; +import android.util.IndentingPrintWriter; import android.util.MutableInt; import com.android.internal.annotations.GuardedBy; @@ -453,7 +454,7 @@ final class RadioModule { return BitmapFactory.decodeByteArray(rawImage, 0, rawImage.length); } - void dumpInfo(android.util.IndentingPrintWriter pw) { + void dumpInfo(IndentingPrintWriter pw) { pw.printf("RadioModule\n"); pw.increaseIndent(); pw.printf("BroadcastRadioService: %s\n", mService); 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 b1b5d3488a5b..80efacdb12ee 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.os.Binder; import android.os.RemoteException; import android.util.ArrayMap; import android.util.ArraySet; +import android.util.IndentingPrintWriter; import android.util.MutableBoolean; import android.util.MutableInt; @@ -324,9 +325,7 @@ final class TunerSession extends ITuner.Stub { try { isConfigFlagSet(flag); return true; - } catch (IllegalStateException ex) { - return true; - } catch (UnsupportedOperationException ex) { + } catch (IllegalStateException | UnsupportedOperationException ex) { return false; } } @@ -389,7 +388,7 @@ final class TunerSession extends ITuner.Stub { } } - void dumpInfo(android.util.IndentingPrintWriter pw) { + void dumpInfo(IndentingPrintWriter pw) { pw.printf("TunerSession\n"); pw.increaseIndent(); pw.printf("HIDL HAL Session: %s\n", mHwSession); |