Read flag to show/hide notification slider

Replace the build-time boolean resource with a run time device config flag that
signals whether the ring notification slider should be displayed or not

Bug: b/38477228
Test: make DEBUG_ROBOLECTRIC=1 ROBOTEST_FILTER=NotificationVolumePreferenceControllerTest RunSettingsRoboTests -j40
      make DEBUG_ROBOLECTRIC=1 ROBOTEST_FILTER=RingVolumePreferenceControllerTest RunSettingsRoboTests -j40
Change-Id: I8b9a2cbd5af7fa1bba56ff9ba62771d677d4a932
This commit is contained in:
Behnam Heydarshahi
2022-10-12 15:08:22 +00:00
parent 1fa98709be
commit 2ac6fc5709
5 changed files with 240 additions and 69 deletions

View File

@@ -27,10 +27,13 @@ import android.content.Context;
import android.content.res.Resources;
import android.media.AudioManager;
import android.os.Vibrator;
import android.provider.DeviceConfig;
import android.service.notification.NotificationListenerService;
import android.telephony.TelephonyManager;
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
import com.android.settings.R;
import com.android.settings.testutils.shadow.ShadowDeviceConfig;
import org.junit.Before;
import org.junit.Test;
@@ -39,9 +42,11 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowApplication;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {ShadowDeviceConfig.class})
public class RingVolumePreferenceControllerTest {
@Mock
@@ -124,9 +129,10 @@ public class RingVolumePreferenceControllerTest {
// todo: verify that the title change is displayed, by examining the underlying preference
@Test
public void ringNotificationStreamsNotAliased_sliderTitleSetToRingOnly() {
when(mResources.getBoolean(
com.android.internal.R.bool.config_alias_ring_notif_stream_types))
.thenReturn(false);
DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, "true", false);
final RingVolumePreferenceController controller =
new RingVolumePreferenceController(mContext);
@@ -138,8 +144,9 @@ public class RingVolumePreferenceControllerTest {
@Test
public void ringNotificationStreamsAliased_sliderTitleIncludesBothRingNotification() {
when(mResources.getBoolean(
com.android.internal.R.bool.config_alias_ring_notif_stream_types)).thenReturn(true);
DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SYSTEMUI,
SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, "false", false);
final RingVolumePreferenceController control = new RingVolumePreferenceController(mContext);
int expectedTitleId = R.string.ring_volume_option_title;
@@ -150,39 +157,39 @@ public class RingVolumePreferenceControllerTest {
@Test
public void setHintsRing_aliased_Matches() {
assertThat(mController.hintsMatch(
NotificationListenerService.HINT_HOST_DISABLE_CALL_EFFECTS, true)).isTrue();
NotificationListenerService.HINT_HOST_DISABLE_CALL_EFFECTS, false)).isTrue();
}
@Test
public void setHintsRingNotification_aliased_Matches() {
assertThat(mController.hintsMatch(NotificationListenerService.HINT_HOST_DISABLE_EFFECTS,
true)).isTrue();
false)).isTrue();
}
@Test
public void setHintNotification_aliased_Matches() {
assertThat(mController
.hintsMatch(NotificationListenerService.HINT_HOST_DISABLE_NOTIFICATION_EFFECTS,
true)).isTrue();
false)).isTrue();
}
@Test
public void setHintsRing_unaliased_Matches() {
assertThat(mController.hintsMatch(
NotificationListenerService.HINT_HOST_DISABLE_CALL_EFFECTS, false)).isTrue();
NotificationListenerService.HINT_HOST_DISABLE_CALL_EFFECTS, true)).isTrue();
}
@Test
public void setHintsRingNotification_unaliased_Matches() {
assertThat(mController.hintsMatch(NotificationListenerService.HINT_HOST_DISABLE_EFFECTS,
false)).isTrue();
true)).isTrue();
}
@Test
public void setHintNotification_unaliased_doesNotMatch() {
assertThat(mController
.hintsMatch(NotificationListenerService.HINT_HOST_DISABLE_NOTIFICATION_EFFECTS,
false)).isFalse();
true)).isFalse();
}
@Test