Ring & notif vol missing on a largescreen device
Before: "Ring & notification volume" showed up in volume panel and in volume settings. Now (what prompted this bugreport): A device config was changed to mark it not voice capable. "Ring & notification volume" disappeared from both places; "Notification volume" showed up only in volume settings, not panel. Fix: the voice capable should not be a factor when determining availability for ring/notification slices. After this fix is applied: "Ring & notification volume" to reappear at both settings and panel. Bug: 256548882 Test: make DEBUG_ROBOLECTRIC=1 ROBOTEST_FILTER="VolumePanelTest|RingVolumePreferenceControllerTest|NotificationVolumePreferenceControllerTest|SeparateRingVolumePreferenceController" RunSettingsRoboTests -j40 Change-Id: Ie2b1913bde6a64303c4d9fde3724889f949c363b
This commit is contained in:
@@ -35,7 +35,6 @@ import androidx.preference.PreferenceScreen;
|
|||||||
|
|
||||||
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
|
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.Utils;
|
|
||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -129,8 +128,7 @@ public class NotificationVolumePreferenceController extends
|
|||||||
boolean separateNotification = isSeparateNotificationConfigEnabled();
|
boolean separateNotification = isSeparateNotificationConfigEnabled();
|
||||||
|
|
||||||
return mContext.getResources().getBoolean(R.bool.config_show_notification_volume)
|
return mContext.getResources().getBoolean(R.bool.config_show_notification_volume)
|
||||||
&& !mHelper.isSingleVolume()
|
&& !mHelper.isSingleVolume() && separateNotification
|
||||||
&& (separateNotification || !Utils.isVoiceCapable(mContext))
|
|
||||||
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -34,7 +34,6 @@ import androidx.lifecycle.OnLifecycleEvent;
|
|||||||
|
|
||||||
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
|
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.Utils;
|
|
||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -114,8 +113,7 @@ public class RingVolumePreferenceController extends
|
|||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
boolean separateNotification = isSeparateNotificationConfigEnabled();
|
boolean separateNotification = isSeparateNotificationConfigEnabled();
|
||||||
|
return !separateNotification && !mHelper.isSingleVolume()
|
||||||
return !separateNotification && Utils.isVoiceCapable(mContext) && !mHelper.isSingleVolume()
|
|
||||||
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,7 +33,6 @@ import androidx.lifecycle.OnLifecycleEvent;
|
|||||||
|
|
||||||
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
|
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.Utils;
|
|
||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -111,8 +110,7 @@ public class SeparateRingVolumePreferenceController extends
|
|||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
boolean separateNotification = isSeparateNotificationConfigEnabled();
|
boolean separateNotification = isSeparateNotificationConfigEnabled();
|
||||||
|
return separateNotification && !mHelper.isSingleVolume()
|
||||||
return separateNotification && Utils.isVoiceCapable(mContext) && !mHelper.isSingleVolume()
|
|
||||||
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -96,12 +96,16 @@ public class RingVolumePreferenceControllerTest {
|
|||||||
assertThat(mController.isAvailable()).isFalse();
|
assertThat(mController.isAvailable()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Devices that are not voice capable should still show Ring volume, because it is used by apps
|
||||||
|
* that make calls outside the cell network.
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void isAvailable_notVoiceCapable_shouldReturnFalse() {
|
public void isAvailable_notSingleVolume_notVoiceCapable_shouldReturnTrue() {
|
||||||
when(mHelper.isSingleVolume()).thenReturn(false);
|
when(mHelper.isSingleVolume()).thenReturn(false);
|
||||||
when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
|
when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isFalse();
|
assertThat(mController.isAvailable()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -27,8 +27,10 @@ import android.content.Context;
|
|||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
|
import android.provider.DeviceConfig;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
|
|
||||||
|
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
|
||||||
import com.android.settings.testutils.shadow.ShadowDeviceConfig;
|
import com.android.settings.testutils.shadow.ShadowDeviceConfig;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@@ -87,6 +89,19 @@ public class SeparateRingVolumePreferenceControllerTest {
|
|||||||
assertThat(mController.isAvailable()).isFalse();
|
assertThat(mController.isAvailable()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maintain that the device does not need to be voice capable to display this slider
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void isAvailable_ringNotificationSeparated_isNotVoiceCapable_shouldReturnTrue() {
|
||||||
|
DeviceConfig.setProperty(DeviceConfig.NAMESPACE_SYSTEMUI,
|
||||||
|
SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, "true", false);
|
||||||
|
when(mHelper.isSingleVolume()).thenReturn(false);
|
||||||
|
when(mTelephonyManager.isVoiceCapable()).thenReturn(false);
|
||||||
|
|
||||||
|
assertThat(mController.isAvailable()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getAudioStream_shouldReturnRing() {
|
public void getAudioStream_shouldReturnRing() {
|
||||||
assertThat(mController.getAudioStream()).isEqualTo(AudioManager.STREAM_RING);
|
assertThat(mController.getAudioStream()).isEqualTo(AudioManager.STREAM_RING);
|
||||||
|
Reference in New Issue
Block a user