Loading android/app/src/com/android/bluetooth/vc/VolumeControlService.java +13 −22 Original line number Diff line number Diff line Loading @@ -48,8 +48,7 @@ import com.android.bluetooth.btservice.ProfileService; import com.android.bluetooth.btservice.ServiceFactory; import com.android.bluetooth.btservice.storage.DatabaseManager; import com.android.bluetooth.csip.CsipSetCoordinatorService; import com.android.bluetooth.flags.FeatureFlags; import com.android.bluetooth.flags.FeatureFlagsImpl; import com.android.bluetooth.flags.Flags; import com.android.bluetooth.le_audio.LeAudioService; import com.android.internal.annotations.VisibleForTesting; import com.android.modules.utils.SynchronousResultReceiver; Loading Loading @@ -79,7 +78,6 @@ public class VolumeControlService extends ProfileService { private DatabaseManager mDatabaseManager; private HandlerThread mStateMachinesThread; private Handler mHandler = null; private FeatureFlags mFeatureFlags; @VisibleForTesting RemoteCallbackList<IBluetoothVolumeControlCallback> mCallbacks; Loading Loading @@ -200,13 +198,6 @@ public class VolumeControlService extends ProfileService { public VolumeControlService(Context ctx) { super(ctx); mFeatureFlags = new FeatureFlagsImpl(); } @VisibleForTesting VolumeControlService(Context ctx, FeatureFlags featureFlags) { super(ctx); mFeatureFlags = featureFlags; } public static boolean isEnabled() { Loading Loading @@ -599,7 +590,7 @@ public class VolumeControlService extends ProfileService { } void setDeviceVolume(BluetoothDevice device, int volume, boolean isGroupOp) { if (!mFeatureFlags.leaudioBroadcastVolumeControlForConnectedDevices()) { if (!Flags.leaudioBroadcastVolumeControlForConnectedDevices()) { return; } if (DBG) { Loading Loading @@ -790,7 +781,7 @@ public class VolumeControlService extends ProfileService { } catch (RemoteException e) { // Not every callback had to be defined; just continue } if (mFeatureFlags.leaudioMultipleVocsInstancesApi()) { if (Flags.leaudioMultipleVocsInstancesApi()) { try { tempCallbackList .getBroadcastItem(i) Loading @@ -812,7 +803,7 @@ public class VolumeControlService extends ProfileService { tempCallbackList.finishBroadcast(); if (mFeatureFlags.leaudioBroadcastVolumeControlForConnectedDevices()) { if (Flags.leaudioBroadcastVolumeControlForConnectedDevices()) { notifyDevicesVolumeChanged(tempCallbackList, getDevices(), Optional.empty()); } Loading Loading @@ -893,7 +884,7 @@ public class VolumeControlService extends ProfileService { mGroupVolumeCache.put(groupId, volume); mGroupMuteCache.put(groupId, mute); if (mFeatureFlags.leaudioBroadcastVolumeControlForConnectedDevices()) { if (Flags.leaudioBroadcastVolumeControlForConnectedDevices()) { LeAudioService leAudioService = mFactory.getLeAudioService(); if (leAudioService != null) { int currentlyActiveGroupId = leAudioService.getActiveGroupId(); Loading Loading @@ -949,7 +940,7 @@ public class VolumeControlService extends ProfileService { int groupVolume = getGroupVolume(groupId); Boolean groupMute = getGroupMute(groupId); if (mFeatureFlags.leaudioBroadcastVolumeControlForConnectedDevices()) { if (Flags.leaudioBroadcastVolumeControlForConnectedDevices()) { Log.i(TAG, "handleVolumeControlChanged: " + device + "; volume: " + volume); if (device == null) { // notify group devices volume changed Loading Loading @@ -1056,7 +1047,7 @@ public class VolumeControlService extends ProfileService { case AudioManager.MODE_IN_CALL: return AudioManager.STREAM_VOICE_CALL; case AudioManager.MODE_RINGTONE: if (mFeatureFlags.leaudioVolumeChangeOnRingtoneFix()) { if (Flags.leaudioVolumeChangeOnRingtoneFix()) { if (DBG) { Log.d(TAG, " Update during ringtone applied to voice call"); } Loading Loading @@ -1135,7 +1126,7 @@ public class VolumeControlService extends ProfileService { } offsets.setLocation(id, location); if (mFeatureFlags.leaudioMultipleVocsInstancesApi()) { if (Flags.leaudioMultipleVocsInstancesApi()) { if (mCallbacks == null) { return; } Loading Loading @@ -1168,7 +1159,7 @@ public class VolumeControlService extends ProfileService { } offsets.setDescription(id, description); if (mFeatureFlags.leaudioMultipleVocsInstancesApi()) { if (Flags.leaudioMultipleVocsInstancesApi()) { if (mCallbacks == null) { return; } Loading android/app/tests/unit/src/com/android/bluetooth/vc/VolumeControlServiceTest.java +24 −17 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import android.media.AudioManager; import android.os.Binder; import android.os.Looper; import android.os.ParcelUuid; import android.platform.test.flag.junit.SetFlagsRule; import androidx.test.InstrumentationRegistry; import androidx.test.filters.MediumTest; Loading @@ -45,7 +46,6 @@ import com.android.bluetooth.btservice.AdapterService; import com.android.bluetooth.btservice.ServiceFactory; import com.android.bluetooth.btservice.storage.DatabaseManager; import com.android.bluetooth.csip.CsipSetCoordinatorService; import com.android.bluetooth.flags.FakeFeatureFlagsImpl; import com.android.bluetooth.flags.Flags; import com.android.bluetooth.le_audio.LeAudioService; import com.android.bluetooth.x.com.android.modules.utils.SynchronousResultReceiver; Loading Loading @@ -87,7 +87,6 @@ public class VolumeControlServiceTest { private static final int CALL_MAX_VOL = 8; private BroadcastReceiver mVolumeControlIntentReceiver; private FakeFeatureFlagsImpl mFakeFlagsImpl; @Rule public MockitoRule mockitoRule = MockitoJUnit.rule(); Loading @@ -100,6 +99,7 @@ public class VolumeControlServiceTest { @Mock private CsipSetCoordinatorService mCsipService; @Rule public final ServiceTestRule mServiceRule = new ServiceTestRule(); @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); @Before public void setUp() throws Exception { Loading @@ -124,13 +124,8 @@ public class VolumeControlServiceTest { doReturn(CALL_MAX_VOL).when(mAudioManager) .getStreamMaxVolume(eq(AudioManager.STREAM_VOICE_CALL)); mFakeFlagsImpl = new FakeFeatureFlagsImpl(); mFakeFlagsImpl.setFlag( Flags.FLAG_LEAUDIO_BROADCAST_VOLUME_CONTROL_FOR_CONNECTED_DEVICES, false); mFakeFlagsImpl.setFlag(Flags.FLAG_LEAUDIO_MULTIPLE_VOCS_INSTANCES_API, false); VolumeControlNativeInterface.setInstance(mNativeInterface); mService = new VolumeControlService(mTargetContext, mFakeFlagsImpl); mService = new VolumeControlService(mTargetContext); mService.start(); mService.setAvailable(true); Loading Loading @@ -592,6 +587,10 @@ public class VolumeControlServiceTest { @Test public void testAutonomousVolumeStateChange() { // TODO: b/329163385 - This test should be modified to run without having to set the flag to // a specific value mSetFlagsRule.disableFlags( Flags.FLAG_LEAUDIO_BROADCAST_VOLUME_CONTROL_FOR_CONNECTED_DEVICES); doReturn(AudioManager.MODE_IN_CALL).when(mAudioManager).getMode(); testVolumeCalculations(AudioManager.STREAM_VOICE_CALL, CALL_MIN_VOL, CALL_MAX_VOL); Loading @@ -604,6 +603,10 @@ public class VolumeControlServiceTest { */ @Test public void testAutonomousMuteUnmute() { // TODO: b/329163385 - This test should be modified to run without having to set the flag to // a specific value mSetFlagsRule.disableFlags( Flags.FLAG_LEAUDIO_BROADCAST_VOLUME_CONTROL_FOR_CONNECTED_DEVICES); int streamType = AudioManager.STREAM_MUSIC; int streamVol = getLeAudioVolume(19, MEDIA_MIN_VOL, MEDIA_MAX_VOL, streamType); Loading Loading @@ -672,6 +675,10 @@ public class VolumeControlServiceTest { /** Test Active Group change */ @Test public void testActiveGroupChange() throws Exception { // TODO: b/329163385 - This test should be modified to run without having to set the flag to // a specific value mSetFlagsRule.disableFlags( Flags.FLAG_LEAUDIO_BROADCAST_VOLUME_CONTROL_FOR_CONNECTED_DEVICES); int groupId_1 = 1; int volume_groupId_1 = 6; Loading Loading @@ -1040,8 +1047,8 @@ public class VolumeControlServiceTest { @Test public void testServiceBinderSetDeviceVolumeMethods() throws Exception { mFakeFlagsImpl.setFlag( Flags.FLAG_LEAUDIO_BROADCAST_VOLUME_CONTROL_FOR_CONNECTED_DEVICES, true); mSetFlagsRule.enableFlags( Flags.FLAG_LEAUDIO_BROADCAST_VOLUME_CONTROL_FOR_CONNECTED_DEVICES); int groupId = 1; int groupVolume = 56; Loading Loading @@ -1110,7 +1117,7 @@ public class VolumeControlServiceTest { @Test public void testServiceBinderRegisterCallbackWhenDeviceAlreadyConnected() throws Exception { mFakeFlagsImpl.setFlag(Flags.FLAG_LEAUDIO_MULTIPLE_VOCS_INSTANCES_API, true); mSetFlagsRule.enableFlags(Flags.FLAG_LEAUDIO_MULTIPLE_VOCS_INSTANCES_API); int groupId = 1; int groupVolume = 56; Loading Loading @@ -1203,8 +1210,8 @@ public class VolumeControlServiceTest { @Test public void testServiceBinderRegisterVolumeChangedCallbackWhenDeviceAlreadyConnected() throws Exception { mFakeFlagsImpl.setFlag( Flags.FLAG_LEAUDIO_BROADCAST_VOLUME_CONTROL_FOR_CONNECTED_DEVICES, true); mSetFlagsRule.enableFlags( Flags.FLAG_LEAUDIO_BROADCAST_VOLUME_CONTROL_FOR_CONNECTED_DEVICES); int groupId = 1; int deviceOneVolume = 46; int deviceTwoVolume = 36; Loading Loading @@ -1257,8 +1264,8 @@ public class VolumeControlServiceTest { @Test public void testServiceBinderTestNotifyNewRegisteredCallback() throws Exception { mFakeFlagsImpl.setFlag( Flags.FLAG_LEAUDIO_BROADCAST_VOLUME_CONTROL_FOR_CONNECTED_DEVICES, true); mSetFlagsRule.enableFlags( Flags.FLAG_LEAUDIO_BROADCAST_VOLUME_CONTROL_FOR_CONNECTED_DEVICES); int groupId = 1; int deviceOneVolume = 46; int deviceTwoVolume = 36; Loading Loading @@ -1402,8 +1409,8 @@ public class VolumeControlServiceTest { /** Test Volume Control changed callback. */ @Test public void testVolumeControlChangedCallback() throws Exception { mFakeFlagsImpl.setFlag( Flags.FLAG_LEAUDIO_BROADCAST_VOLUME_CONTROL_FOR_CONNECTED_DEVICES, true); mSetFlagsRule.enableFlags( Flags.FLAG_LEAUDIO_BROADCAST_VOLUME_CONTROL_FOR_CONNECTED_DEVICES); int groupId = 1; int groupVolume = 56; Loading Loading
android/app/src/com/android/bluetooth/vc/VolumeControlService.java +13 −22 Original line number Diff line number Diff line Loading @@ -48,8 +48,7 @@ import com.android.bluetooth.btservice.ProfileService; import com.android.bluetooth.btservice.ServiceFactory; import com.android.bluetooth.btservice.storage.DatabaseManager; import com.android.bluetooth.csip.CsipSetCoordinatorService; import com.android.bluetooth.flags.FeatureFlags; import com.android.bluetooth.flags.FeatureFlagsImpl; import com.android.bluetooth.flags.Flags; import com.android.bluetooth.le_audio.LeAudioService; import com.android.internal.annotations.VisibleForTesting; import com.android.modules.utils.SynchronousResultReceiver; Loading Loading @@ -79,7 +78,6 @@ public class VolumeControlService extends ProfileService { private DatabaseManager mDatabaseManager; private HandlerThread mStateMachinesThread; private Handler mHandler = null; private FeatureFlags mFeatureFlags; @VisibleForTesting RemoteCallbackList<IBluetoothVolumeControlCallback> mCallbacks; Loading Loading @@ -200,13 +198,6 @@ public class VolumeControlService extends ProfileService { public VolumeControlService(Context ctx) { super(ctx); mFeatureFlags = new FeatureFlagsImpl(); } @VisibleForTesting VolumeControlService(Context ctx, FeatureFlags featureFlags) { super(ctx); mFeatureFlags = featureFlags; } public static boolean isEnabled() { Loading Loading @@ -599,7 +590,7 @@ public class VolumeControlService extends ProfileService { } void setDeviceVolume(BluetoothDevice device, int volume, boolean isGroupOp) { if (!mFeatureFlags.leaudioBroadcastVolumeControlForConnectedDevices()) { if (!Flags.leaudioBroadcastVolumeControlForConnectedDevices()) { return; } if (DBG) { Loading Loading @@ -790,7 +781,7 @@ public class VolumeControlService extends ProfileService { } catch (RemoteException e) { // Not every callback had to be defined; just continue } if (mFeatureFlags.leaudioMultipleVocsInstancesApi()) { if (Flags.leaudioMultipleVocsInstancesApi()) { try { tempCallbackList .getBroadcastItem(i) Loading @@ -812,7 +803,7 @@ public class VolumeControlService extends ProfileService { tempCallbackList.finishBroadcast(); if (mFeatureFlags.leaudioBroadcastVolumeControlForConnectedDevices()) { if (Flags.leaudioBroadcastVolumeControlForConnectedDevices()) { notifyDevicesVolumeChanged(tempCallbackList, getDevices(), Optional.empty()); } Loading Loading @@ -893,7 +884,7 @@ public class VolumeControlService extends ProfileService { mGroupVolumeCache.put(groupId, volume); mGroupMuteCache.put(groupId, mute); if (mFeatureFlags.leaudioBroadcastVolumeControlForConnectedDevices()) { if (Flags.leaudioBroadcastVolumeControlForConnectedDevices()) { LeAudioService leAudioService = mFactory.getLeAudioService(); if (leAudioService != null) { int currentlyActiveGroupId = leAudioService.getActiveGroupId(); Loading Loading @@ -949,7 +940,7 @@ public class VolumeControlService extends ProfileService { int groupVolume = getGroupVolume(groupId); Boolean groupMute = getGroupMute(groupId); if (mFeatureFlags.leaudioBroadcastVolumeControlForConnectedDevices()) { if (Flags.leaudioBroadcastVolumeControlForConnectedDevices()) { Log.i(TAG, "handleVolumeControlChanged: " + device + "; volume: " + volume); if (device == null) { // notify group devices volume changed Loading Loading @@ -1056,7 +1047,7 @@ public class VolumeControlService extends ProfileService { case AudioManager.MODE_IN_CALL: return AudioManager.STREAM_VOICE_CALL; case AudioManager.MODE_RINGTONE: if (mFeatureFlags.leaudioVolumeChangeOnRingtoneFix()) { if (Flags.leaudioVolumeChangeOnRingtoneFix()) { if (DBG) { Log.d(TAG, " Update during ringtone applied to voice call"); } Loading Loading @@ -1135,7 +1126,7 @@ public class VolumeControlService extends ProfileService { } offsets.setLocation(id, location); if (mFeatureFlags.leaudioMultipleVocsInstancesApi()) { if (Flags.leaudioMultipleVocsInstancesApi()) { if (mCallbacks == null) { return; } Loading Loading @@ -1168,7 +1159,7 @@ public class VolumeControlService extends ProfileService { } offsets.setDescription(id, description); if (mFeatureFlags.leaudioMultipleVocsInstancesApi()) { if (Flags.leaudioMultipleVocsInstancesApi()) { if (mCallbacks == null) { return; } Loading
android/app/tests/unit/src/com/android/bluetooth/vc/VolumeControlServiceTest.java +24 −17 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ import android.media.AudioManager; import android.os.Binder; import android.os.Looper; import android.os.ParcelUuid; import android.platform.test.flag.junit.SetFlagsRule; import androidx.test.InstrumentationRegistry; import androidx.test.filters.MediumTest; Loading @@ -45,7 +46,6 @@ import com.android.bluetooth.btservice.AdapterService; import com.android.bluetooth.btservice.ServiceFactory; import com.android.bluetooth.btservice.storage.DatabaseManager; import com.android.bluetooth.csip.CsipSetCoordinatorService; import com.android.bluetooth.flags.FakeFeatureFlagsImpl; import com.android.bluetooth.flags.Flags; import com.android.bluetooth.le_audio.LeAudioService; import com.android.bluetooth.x.com.android.modules.utils.SynchronousResultReceiver; Loading Loading @@ -87,7 +87,6 @@ public class VolumeControlServiceTest { private static final int CALL_MAX_VOL = 8; private BroadcastReceiver mVolumeControlIntentReceiver; private FakeFeatureFlagsImpl mFakeFlagsImpl; @Rule public MockitoRule mockitoRule = MockitoJUnit.rule(); Loading @@ -100,6 +99,7 @@ public class VolumeControlServiceTest { @Mock private CsipSetCoordinatorService mCsipService; @Rule public final ServiceTestRule mServiceRule = new ServiceTestRule(); @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); @Before public void setUp() throws Exception { Loading @@ -124,13 +124,8 @@ public class VolumeControlServiceTest { doReturn(CALL_MAX_VOL).when(mAudioManager) .getStreamMaxVolume(eq(AudioManager.STREAM_VOICE_CALL)); mFakeFlagsImpl = new FakeFeatureFlagsImpl(); mFakeFlagsImpl.setFlag( Flags.FLAG_LEAUDIO_BROADCAST_VOLUME_CONTROL_FOR_CONNECTED_DEVICES, false); mFakeFlagsImpl.setFlag(Flags.FLAG_LEAUDIO_MULTIPLE_VOCS_INSTANCES_API, false); VolumeControlNativeInterface.setInstance(mNativeInterface); mService = new VolumeControlService(mTargetContext, mFakeFlagsImpl); mService = new VolumeControlService(mTargetContext); mService.start(); mService.setAvailable(true); Loading Loading @@ -592,6 +587,10 @@ public class VolumeControlServiceTest { @Test public void testAutonomousVolumeStateChange() { // TODO: b/329163385 - This test should be modified to run without having to set the flag to // a specific value mSetFlagsRule.disableFlags( Flags.FLAG_LEAUDIO_BROADCAST_VOLUME_CONTROL_FOR_CONNECTED_DEVICES); doReturn(AudioManager.MODE_IN_CALL).when(mAudioManager).getMode(); testVolumeCalculations(AudioManager.STREAM_VOICE_CALL, CALL_MIN_VOL, CALL_MAX_VOL); Loading @@ -604,6 +603,10 @@ public class VolumeControlServiceTest { */ @Test public void testAutonomousMuteUnmute() { // TODO: b/329163385 - This test should be modified to run without having to set the flag to // a specific value mSetFlagsRule.disableFlags( Flags.FLAG_LEAUDIO_BROADCAST_VOLUME_CONTROL_FOR_CONNECTED_DEVICES); int streamType = AudioManager.STREAM_MUSIC; int streamVol = getLeAudioVolume(19, MEDIA_MIN_VOL, MEDIA_MAX_VOL, streamType); Loading Loading @@ -672,6 +675,10 @@ public class VolumeControlServiceTest { /** Test Active Group change */ @Test public void testActiveGroupChange() throws Exception { // TODO: b/329163385 - This test should be modified to run without having to set the flag to // a specific value mSetFlagsRule.disableFlags( Flags.FLAG_LEAUDIO_BROADCAST_VOLUME_CONTROL_FOR_CONNECTED_DEVICES); int groupId_1 = 1; int volume_groupId_1 = 6; Loading Loading @@ -1040,8 +1047,8 @@ public class VolumeControlServiceTest { @Test public void testServiceBinderSetDeviceVolumeMethods() throws Exception { mFakeFlagsImpl.setFlag( Flags.FLAG_LEAUDIO_BROADCAST_VOLUME_CONTROL_FOR_CONNECTED_DEVICES, true); mSetFlagsRule.enableFlags( Flags.FLAG_LEAUDIO_BROADCAST_VOLUME_CONTROL_FOR_CONNECTED_DEVICES); int groupId = 1; int groupVolume = 56; Loading Loading @@ -1110,7 +1117,7 @@ public class VolumeControlServiceTest { @Test public void testServiceBinderRegisterCallbackWhenDeviceAlreadyConnected() throws Exception { mFakeFlagsImpl.setFlag(Flags.FLAG_LEAUDIO_MULTIPLE_VOCS_INSTANCES_API, true); mSetFlagsRule.enableFlags(Flags.FLAG_LEAUDIO_MULTIPLE_VOCS_INSTANCES_API); int groupId = 1; int groupVolume = 56; Loading Loading @@ -1203,8 +1210,8 @@ public class VolumeControlServiceTest { @Test public void testServiceBinderRegisterVolumeChangedCallbackWhenDeviceAlreadyConnected() throws Exception { mFakeFlagsImpl.setFlag( Flags.FLAG_LEAUDIO_BROADCAST_VOLUME_CONTROL_FOR_CONNECTED_DEVICES, true); mSetFlagsRule.enableFlags( Flags.FLAG_LEAUDIO_BROADCAST_VOLUME_CONTROL_FOR_CONNECTED_DEVICES); int groupId = 1; int deviceOneVolume = 46; int deviceTwoVolume = 36; Loading Loading @@ -1257,8 +1264,8 @@ public class VolumeControlServiceTest { @Test public void testServiceBinderTestNotifyNewRegisteredCallback() throws Exception { mFakeFlagsImpl.setFlag( Flags.FLAG_LEAUDIO_BROADCAST_VOLUME_CONTROL_FOR_CONNECTED_DEVICES, true); mSetFlagsRule.enableFlags( Flags.FLAG_LEAUDIO_BROADCAST_VOLUME_CONTROL_FOR_CONNECTED_DEVICES); int groupId = 1; int deviceOneVolume = 46; int deviceTwoVolume = 36; Loading Loading @@ -1402,8 +1409,8 @@ public class VolumeControlServiceTest { /** Test Volume Control changed callback. */ @Test public void testVolumeControlChangedCallback() throws Exception { mFakeFlagsImpl.setFlag( Flags.FLAG_LEAUDIO_BROADCAST_VOLUME_CONTROL_FOR_CONNECTED_DEVICES, true); mSetFlagsRule.enableFlags( Flags.FLAG_LEAUDIO_BROADCAST_VOLUME_CONTROL_FOR_CONNECTED_DEVICES); int groupId = 1; int groupVolume = 56; Loading