Add notification volume controller in settings

Separate notification and ring controllers based on the ring/volume
stream alias boolean in config.xml.

For both ring and volume controller: Not show vibrate icon when vibration is not supported on device. Show
silent icon instead.

Known issue: Add the notification volume slider only in Settings, and
not in VolumePanelDialog. When the alias is set to false and the streams
separated, the ring volume slider in VolumePanelDialog keeps its title
of "Ring & notification volume" instead of changing to "Ring volume".

Bug: b/38477228

Test: make DEBUG_ROBOLECTRIC=1 ROBOTEST_FILTER=NotificationVolumePreferenceControllerTest RunSettingsRoboTests -j40
      make DEBUG_ROBOLECTRIC=1 ROBOTEST_FILTER=RingVolumePreferenceControllerTest RunSettingsRoboTests -j40
      make DEBUG_ROBOLECTRIC=1 ROBOTEST_FILTER=SoundSettingsTest RunSettingsRoboTests

Change-Id: Id17523f49b291a5cf612b90f93c3b2ab6486c62f
This commit is contained in:
Behnam Heydarshahi
2022-09-06 22:12:37 +00:00
parent 6ecbe4c18e
commit 3ac6aaf796
11 changed files with 590 additions and 36 deletions

View File

@@ -35,6 +35,7 @@ import com.android.settings.testutils.shadow.ShadowBluetoothAdapter;
import com.android.settings.testutils.shadow.ShadowDeviceConfig;
import com.android.settings.testutils.shadow.ShadowUserManager;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
@@ -44,8 +45,6 @@ import org.robolectric.util.ReflectionHelpers;
import java.util.List;
import org.junit.Ignore;
@RunWith(RobolectricTestRunner.class)
public class SoundSettingsTest {
@@ -86,4 +85,19 @@ public class SoundSettingsTest {
assertThat(settings.mHandler.hasMessages(SoundSettings.STOP_SAMPLE)).isTrue();
}
@Test
public void notificationVolume_isBetweenRingAndAlarm() {
final Context context = spy(RuntimeEnvironment.application);
final SoundSettings settings = new SoundSettings();
final int xmlId = settings.getPreferenceScreenResId();
final List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(context, xmlId);
int ring = keys.indexOf("ring_volume");
int notification = keys.indexOf("notification_volume");
int alarm = keys.indexOf("alarm_volume");
assertThat(ring < notification).isTrue();
assertThat(notification < alarm).isTrue();
}
}