Show ambient volume contrl only for hearing devices
Flag: EXEMPT bugfix Bug: 388156028 Test: atest BluetoothDetailsAmbientVolumePreferenceControllerTest Change-Id: Ia38fd90f798dec9a46366ca15e358b42f7d7fe70
This commit is contained in:
@@ -129,7 +129,7 @@ public class BluetoothDetailsAmbientVolumePreferenceController extends Bluetooth
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAvailable() {
|
public boolean isAvailable() {
|
||||||
return mCachedDevice.getProfiles().stream().anyMatch(
|
return mCachedDevice.isHearingDevice() && mCachedDevice.getProfiles().stream().anyMatch(
|
||||||
profile -> profile instanceof VolumeControlProfile);
|
profile -> profile instanceof VolumeControlProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,15 +21,11 @@ import static com.android.settings.bluetooth.BluetoothDetailsHearingDeviceContro
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
|
||||||
import static org.mockito.ArgumentMatchers.anyLong;
|
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.os.Handler;
|
|
||||||
|
|
||||||
import androidx.preference.PreferenceCategory;
|
import androidx.preference.PreferenceCategory;
|
||||||
|
|
||||||
import com.android.settings.testutils.shadow.ShadowThreadUtils;
|
import com.android.settings.testutils.shadow.ShadowThreadUtils;
|
||||||
@@ -70,8 +66,6 @@ public class BluetoothDetailsAmbientVolumePreferenceControllerTest extends
|
|||||||
@Mock
|
@Mock
|
||||||
private VolumeControlProfile mVolumeControlProfile;
|
private VolumeControlProfile mVolumeControlProfile;
|
||||||
@Mock
|
@Mock
|
||||||
private Handler mTestHandler;
|
|
||||||
@Mock
|
|
||||||
private AmbientVolumeUiController mUiController;
|
private AmbientVolumeUiController mUiController;
|
||||||
|
|
||||||
private BluetoothDetailsAmbientVolumePreferenceController mController;
|
private BluetoothDetailsAmbientVolumePreferenceController mController;
|
||||||
@@ -91,13 +85,6 @@ public class BluetoothDetailsAmbientVolumePreferenceControllerTest extends
|
|||||||
PreferenceCategory deviceControls = new PreferenceCategory(mContext);
|
PreferenceCategory deviceControls = new PreferenceCategory(mContext);
|
||||||
deviceControls.setKey(KEY_HEARING_DEVICE_GROUP);
|
deviceControls.setKey(KEY_HEARING_DEVICE_GROUP);
|
||||||
mScreen.addPreference(deviceControls);
|
mScreen.addPreference(deviceControls);
|
||||||
|
|
||||||
when(mContext.getMainThreadHandler()).thenReturn(mTestHandler);
|
|
||||||
when(mTestHandler.postDelayed(any(Runnable.class), anyLong())).thenAnswer(
|
|
||||||
invocationOnMock -> {
|
|
||||||
invocationOnMock.getArgument(0, Runnable.class).run();
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -109,7 +96,31 @@ public class BluetoothDetailsAmbientVolumePreferenceControllerTest extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void refresh_deviceNotSupportVcp_verifyUiControllerNoRefresh() {
|
public void isAvailable_notHearingDevice_returnFalse() {
|
||||||
|
when(mCachedDevice.isHearingDevice()).thenReturn(false);
|
||||||
|
|
||||||
|
assertThat(mController.isAvailable()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isAvailable_isHearingDeviceAndNotSupportVcp_returnFalse() {
|
||||||
|
when(mCachedDevice.isHearingDevice()).thenReturn(true);
|
||||||
|
when(mCachedDevice.getProfiles()).thenReturn(List.of());
|
||||||
|
|
||||||
|
assertThat(mController.isAvailable()).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void isAvailable_isHearingDeviceAndSupportVcp_returnTrue() {
|
||||||
|
when(mCachedDevice.isHearingDevice()).thenReturn(true);
|
||||||
|
when(mCachedDevice.getProfiles()).thenReturn(List.of(mVolumeControlProfile));
|
||||||
|
|
||||||
|
assertThat(mController.isAvailable()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void refresh_isHearingDeviceAndNotSupportVcp_verifyUiControllerNoRefresh() {
|
||||||
|
when(mCachedDevice.isHearingDevice()).thenReturn(true);
|
||||||
when(mCachedDevice.getProfiles()).thenReturn(List.of());
|
when(mCachedDevice.getProfiles()).thenReturn(List.of());
|
||||||
|
|
||||||
mController.refresh();
|
mController.refresh();
|
||||||
@@ -118,7 +129,8 @@ public class BluetoothDetailsAmbientVolumePreferenceControllerTest extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void refresh_deviceSupportVcp_verifyUiControllerRefresh() {
|
public void refresh_isHearingDeviceAndSupportVcp_verifyUiControllerRefresh() {
|
||||||
|
when(mCachedDevice.isHearingDevice()).thenReturn(true);
|
||||||
when(mCachedDevice.getProfiles()).thenReturn(List.of(mVolumeControlProfile));
|
when(mCachedDevice.getProfiles()).thenReturn(List.of(mVolumeControlProfile));
|
||||||
|
|
||||||
mController.refresh();
|
mController.refresh();
|
||||||
|
Reference in New Issue
Block a user