Loading android/app/src/com/android/bluetooth/a2dp/A2dpService.java +0 −34 Original line number Original line Diff line number Diff line Loading @@ -433,19 +433,9 @@ public class A2dpService extends ProfileService { } } } } private void storeActiveDeviceVolume() { // Make sure volume has been stored before been removed from active. if (mFactory.getAvrcpTargetService() != null && mActiveDevice != null) { mFactory.getAvrcpTargetService().storeVolumeForDevice(mActiveDevice); } } private void removeActiveDevice(boolean forceStopPlayingAudio) { private void removeActiveDevice(boolean forceStopPlayingAudio) { BluetoothDevice previousActiveDevice = mActiveDevice; BluetoothDevice previousActiveDevice = mActiveDevice; synchronized (mStateMachines) { synchronized (mStateMachines) { // Make sure volume has been store before device been remove from active. storeActiveDeviceVolume(); // This needs to happen before we inform the audio manager that the device // This needs to happen before we inform the audio manager that the device // disconnected. Please see comment in updateAndBroadcastActiveDevice() for why. // disconnected. Please see comment in updateAndBroadcastActiveDevice() for why. updateAndBroadcastActiveDevice(null); updateAndBroadcastActiveDevice(null); Loading Loading @@ -499,22 +489,6 @@ public class A2dpService extends ProfileService { return true; return true; } } /** * Early notification that Hearing Aids will be the active device. This allows the A2DP to save * its volume before the Audio Service starts changing its media stream. */ public void earlyNotifyHearingAidActive() { enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH ADMIN permission"); synchronized (mStateMachines) { // Switch active device from A2DP to Hearing Aids. if (DBG) { Log.d(TAG, "earlyNotifyHearingAidActive: Save volume for " + mActiveDevice); } storeActiveDeviceVolume(); } } /** /** * Set the active device. * Set the active device. * * Loading Loading @@ -554,14 +528,6 @@ public class A2dpService extends ProfileService { codecStatus = sm.getCodecStatus(); codecStatus = sm.getCodecStatus(); boolean deviceChanged = !Objects.equals(device, mActiveDevice); boolean deviceChanged = !Objects.equals(device, mActiveDevice); if (deviceChanged) { // Switch from one A2DP to another A2DP device if (DBG) { Log.d(TAG, "Switch A2DP devices to " + device + " from " + mActiveDevice); } storeActiveDeviceVolume(); } // This needs to happen before we inform the audio manager that the device // This needs to happen before we inform the audio manager that the device // disconnected. Please see comment in updateAndBroadcastActiveDevice() for why. // disconnected. Please see comment in updateAndBroadcastActiveDevice() for why. updateAndBroadcastActiveDevice(device); updateAndBroadcastActiveDevice(device); Loading android/app/src/com/android/bluetooth/avrcp/AvrcpTargetService.java +0 −18 Original line number Original line Diff line number Diff line Loading @@ -242,24 +242,6 @@ public class AvrcpTargetService extends ProfileService { mVolumeManager.volumeDeviceSwitched(device); mVolumeManager.volumeDeviceSwitched(device); } } /** * Store the current system volume for a device in order to be retrieved later. */ public void storeVolumeForDevice(BluetoothDevice device) { if (device == null) return; List<BluetoothDevice> HAActiveDevices = null; if (mFactory.getHearingAidService() != null) { HAActiveDevices = mFactory.getHearingAidService().getActiveDevices(); } if (HAActiveDevices != null && (HAActiveDevices.get(0) != null || HAActiveDevices.get(1) != null)) { Log.d(TAG, "Do not store volume when Hearing Aid devices is active"); return; } mVolumeManager.storeVolumeForDevice(device); } /** /** * Remove the stored volume for a device. * Remove the stored volume for a device. */ */ Loading android/app/src/com/android/bluetooth/hearingaid/HearingAidService.java +0 −10 Original line number Original line Diff line number Diff line Loading @@ -33,7 +33,6 @@ import android.util.StatsLog; import com.android.bluetooth.BluetoothMetricsProto; import com.android.bluetooth.BluetoothMetricsProto; import com.android.bluetooth.Utils; import com.android.bluetooth.Utils; import com.android.bluetooth.a2dp.A2dpService; import com.android.bluetooth.btservice.AdapterService; import com.android.bluetooth.btservice.AdapterService; import com.android.bluetooth.btservice.MetricsLogger; import com.android.bluetooth.btservice.MetricsLogger; import com.android.bluetooth.btservice.ProfileService; import com.android.bluetooth.btservice.ProfileService; Loading Loading @@ -517,15 +516,6 @@ public class HearingAidService extends ProfileService { Long deviceHiSyncId = mDeviceHiSyncIdMap.getOrDefault(device, Long deviceHiSyncId = mDeviceHiSyncIdMap.getOrDefault(device, BluetoothHearingAid.HI_SYNC_ID_INVALID); BluetoothHearingAid.HI_SYNC_ID_INVALID); if (deviceHiSyncId != mActiveDeviceHiSyncId) { if (deviceHiSyncId != mActiveDeviceHiSyncId) { // Give an early notification to A2DP that active device is being switched // to Hearing Aids before the Audio Service. final A2dpService a2dpService = mFactory.getA2dpService(); if (a2dpService != null) { if (DBG) { Log.d(TAG, "earlyNotifyHearingAidActive for " + device); } a2dpService.earlyNotifyHearingAidActive(); } mActiveDeviceHiSyncId = deviceHiSyncId; mActiveDeviceHiSyncId = deviceHiSyncId; reportActiveDevice(device); reportActiveDevice(device); } } Loading android/app/tests/unit/src/com/android/bluetooth/a2dp/A2dpServiceTest.java +0 −34 Original line number Original line Diff line number Diff line Loading @@ -39,9 +39,7 @@ import androidx.test.runner.AndroidJUnit4; import com.android.bluetooth.R; import com.android.bluetooth.R; import com.android.bluetooth.TestUtils; import com.android.bluetooth.TestUtils; import com.android.bluetooth.avrcp.AvrcpTargetService; import com.android.bluetooth.btservice.AdapterService; import com.android.bluetooth.btservice.AdapterService; import com.android.bluetooth.btservice.ServiceFactory; import com.android.bluetooth.btservice.storage.DatabaseManager; import com.android.bluetooth.btservice.storage.DatabaseManager; import org.junit.After; import org.junit.After; Loading Loading @@ -78,8 +76,6 @@ public class A2dpServiceTest { @Mock private AdapterService mAdapterService; @Mock private AdapterService mAdapterService; @Mock private A2dpNativeInterface mA2dpNativeInterface; @Mock private A2dpNativeInterface mA2dpNativeInterface; @Mock private DatabaseManager mDatabaseManager; @Mock private DatabaseManager mDatabaseManager; @Mock private AvrcpTargetService mAvrcpTargetService; @Mock private ServiceFactory mFactory; @Rule public final ServiceTestRule mServiceRule = new ServiceTestRule(); @Rule public final ServiceTestRule mServiceRule = new ServiceTestRule(); Loading @@ -98,13 +94,11 @@ public class A2dpServiceTest { TestUtils.setAdapterService(mAdapterService); TestUtils.setAdapterService(mAdapterService); doReturn(MAX_CONNECTED_AUDIO_DEVICES).when(mAdapterService).getMaxConnectedAudioDevices(); doReturn(MAX_CONNECTED_AUDIO_DEVICES).when(mAdapterService).getMaxConnectedAudioDevices(); doReturn(false).when(mAdapterService).isQuietModeEnabled(); doReturn(false).when(mAdapterService).isQuietModeEnabled(); doReturn(mAvrcpTargetService).when(mFactory).getAvrcpTargetService(); mAdapter = BluetoothAdapter.getDefaultAdapter(); mAdapter = BluetoothAdapter.getDefaultAdapter(); startService(); startService(); mA2dpService.mA2dpNativeInterface = mA2dpNativeInterface; mA2dpService.mA2dpNativeInterface = mA2dpNativeInterface; mA2dpService.mFactory = mFactory; // Override the timeout value to speed up the test // Override the timeout value to speed up the test A2dpStateMachine.sConnectTimeoutMs = TIMEOUT_MS; // 1s A2dpStateMachine.sConnectTimeoutMs = TIMEOUT_MS; // 1s Loading Loading @@ -252,8 +246,6 @@ public class A2dpServiceTest { }); }); // Verify that setActiveDevice(null) was called during shutdown // Verify that setActiveDevice(null) was called during shutdown verify(mA2dpNativeInterface).setActiveDevice(null); verify(mA2dpNativeInterface).setActiveDevice(null); // Verify that storeVolumeForDevice(mTestDevice) was called during shutdown verify(mAvrcpTargetService).storeVolumeForDevice(mTestDevice); // Try to restart the service. Note: must be done on the main thread. // Try to restart the service. Note: must be done on the main thread. InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() { InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() { public void run() { public void run() { Loading Loading @@ -796,13 +788,11 @@ public class A2dpServiceTest { Assert.assertEquals(mTestDevice, mA2dpService.getActiveDevice()); Assert.assertEquals(mTestDevice, mA2dpService.getActiveDevice()); Assert.assertTrue(mA2dpService.setSilenceMode(mTestDevice, true)); Assert.assertTrue(mA2dpService.setSilenceMode(mTestDevice, true)); verify(mA2dpNativeInterface).setSilenceDevice(mTestDevice, true); verify(mA2dpNativeInterface).setSilenceDevice(mTestDevice, true); verify(mAvrcpTargetService).storeVolumeForDevice(mTestDevice); Assert.assertNull(mA2dpService.getActiveDevice()); Assert.assertNull(mA2dpService.getActiveDevice()); // Test whether active device been resumeed after disable silence mode. // Test whether active device been resumeed after disable silence mode. Assert.assertTrue(mA2dpService.setSilenceMode(mTestDevice, false)); Assert.assertTrue(mA2dpService.setSilenceMode(mTestDevice, false)); verify(mA2dpNativeInterface).setSilenceDevice(mTestDevice, false); verify(mA2dpNativeInterface).setSilenceDevice(mTestDevice, false); verify(mAvrcpTargetService).storeVolumeForDevice(mTestDevice); Assert.assertEquals(mTestDevice, mA2dpService.getActiveDevice()); Assert.assertEquals(mTestDevice, mA2dpService.getActiveDevice()); // Test that active device should not be changed when silence a non-active device // Test that active device should not be changed when silence a non-active device Loading @@ -810,13 +800,11 @@ public class A2dpServiceTest { Assert.assertEquals(mTestDevice, mA2dpService.getActiveDevice()); Assert.assertEquals(mTestDevice, mA2dpService.getActiveDevice()); Assert.assertTrue(mA2dpService.setSilenceMode(otherDevice, true)); Assert.assertTrue(mA2dpService.setSilenceMode(otherDevice, true)); verify(mA2dpNativeInterface).setSilenceDevice(otherDevice, true); verify(mA2dpNativeInterface).setSilenceDevice(otherDevice, true); verify(mAvrcpTargetService).storeVolumeForDevice(mTestDevice); Assert.assertEquals(mTestDevice, mA2dpService.getActiveDevice()); Assert.assertEquals(mTestDevice, mA2dpService.getActiveDevice()); // Test that active device should not be changed when another device exits silence mode // Test that active device should not be changed when another device exits silence mode Assert.assertTrue(mA2dpService.setSilenceMode(otherDevice, false)); Assert.assertTrue(mA2dpService.setSilenceMode(otherDevice, false)); verify(mA2dpNativeInterface).setSilenceDevice(otherDevice, false); verify(mA2dpNativeInterface).setSilenceDevice(otherDevice, false); verify(mAvrcpTargetService).storeVolumeForDevice(mTestDevice); Assert.assertEquals(mTestDevice, mA2dpService.getActiveDevice()); Assert.assertEquals(mTestDevice, mA2dpService.getActiveDevice()); } } Loading Loading @@ -906,28 +894,6 @@ public class A2dpServiceTest { verifySupportTime, verifyNotSupportTime, verifyEnabledTime); verifySupportTime, verifyNotSupportTime, verifyEnabledTime); } } /** * Test that volume level of previous active device will be stored after set active device. */ @Test public void testStoreVolumeAfterSetActiveDevice() { BluetoothDevice otherDevice = mAdapter.getRemoteDevice("05:04:03:02:01:00"); connectDevice(otherDevice); connectDevice(mTestDevice); doReturn(true).when(mA2dpNativeInterface).setActiveDevice(any(BluetoothDevice.class)); doReturn(true).when(mA2dpNativeInterface).setActiveDevice(null); Assert.assertTrue(mA2dpService.setActiveDevice(mTestDevice)); // Test volume stored for previous active device an adjust for current active device Assert.assertTrue(mA2dpService.setActiveDevice(otherDevice)); verify(mAvrcpTargetService).storeVolumeForDevice(mTestDevice); verify(mAvrcpTargetService).getRememberedVolumeForDevice(otherDevice); // Test volume store for previous active device when set active device to null Assert.assertTrue(mA2dpService.setActiveDevice(null)); verify(mAvrcpTargetService).storeVolumeForDevice(otherDevice); } private void connectDevice(BluetoothDevice device) { private void connectDevice(BluetoothDevice device) { connectDeviceWithCodecStatus(device, null); connectDeviceWithCodecStatus(device, null); } } Loading Loading
android/app/src/com/android/bluetooth/a2dp/A2dpService.java +0 −34 Original line number Original line Diff line number Diff line Loading @@ -433,19 +433,9 @@ public class A2dpService extends ProfileService { } } } } private void storeActiveDeviceVolume() { // Make sure volume has been stored before been removed from active. if (mFactory.getAvrcpTargetService() != null && mActiveDevice != null) { mFactory.getAvrcpTargetService().storeVolumeForDevice(mActiveDevice); } } private void removeActiveDevice(boolean forceStopPlayingAudio) { private void removeActiveDevice(boolean forceStopPlayingAudio) { BluetoothDevice previousActiveDevice = mActiveDevice; BluetoothDevice previousActiveDevice = mActiveDevice; synchronized (mStateMachines) { synchronized (mStateMachines) { // Make sure volume has been store before device been remove from active. storeActiveDeviceVolume(); // This needs to happen before we inform the audio manager that the device // This needs to happen before we inform the audio manager that the device // disconnected. Please see comment in updateAndBroadcastActiveDevice() for why. // disconnected. Please see comment in updateAndBroadcastActiveDevice() for why. updateAndBroadcastActiveDevice(null); updateAndBroadcastActiveDevice(null); Loading Loading @@ -499,22 +489,6 @@ public class A2dpService extends ProfileService { return true; return true; } } /** * Early notification that Hearing Aids will be the active device. This allows the A2DP to save * its volume before the Audio Service starts changing its media stream. */ public void earlyNotifyHearingAidActive() { enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH ADMIN permission"); synchronized (mStateMachines) { // Switch active device from A2DP to Hearing Aids. if (DBG) { Log.d(TAG, "earlyNotifyHearingAidActive: Save volume for " + mActiveDevice); } storeActiveDeviceVolume(); } } /** /** * Set the active device. * Set the active device. * * Loading Loading @@ -554,14 +528,6 @@ public class A2dpService extends ProfileService { codecStatus = sm.getCodecStatus(); codecStatus = sm.getCodecStatus(); boolean deviceChanged = !Objects.equals(device, mActiveDevice); boolean deviceChanged = !Objects.equals(device, mActiveDevice); if (deviceChanged) { // Switch from one A2DP to another A2DP device if (DBG) { Log.d(TAG, "Switch A2DP devices to " + device + " from " + mActiveDevice); } storeActiveDeviceVolume(); } // This needs to happen before we inform the audio manager that the device // This needs to happen before we inform the audio manager that the device // disconnected. Please see comment in updateAndBroadcastActiveDevice() for why. // disconnected. Please see comment in updateAndBroadcastActiveDevice() for why. updateAndBroadcastActiveDevice(device); updateAndBroadcastActiveDevice(device); Loading
android/app/src/com/android/bluetooth/avrcp/AvrcpTargetService.java +0 −18 Original line number Original line Diff line number Diff line Loading @@ -242,24 +242,6 @@ public class AvrcpTargetService extends ProfileService { mVolumeManager.volumeDeviceSwitched(device); mVolumeManager.volumeDeviceSwitched(device); } } /** * Store the current system volume for a device in order to be retrieved later. */ public void storeVolumeForDevice(BluetoothDevice device) { if (device == null) return; List<BluetoothDevice> HAActiveDevices = null; if (mFactory.getHearingAidService() != null) { HAActiveDevices = mFactory.getHearingAidService().getActiveDevices(); } if (HAActiveDevices != null && (HAActiveDevices.get(0) != null || HAActiveDevices.get(1) != null)) { Log.d(TAG, "Do not store volume when Hearing Aid devices is active"); return; } mVolumeManager.storeVolumeForDevice(device); } /** /** * Remove the stored volume for a device. * Remove the stored volume for a device. */ */ Loading
android/app/src/com/android/bluetooth/hearingaid/HearingAidService.java +0 −10 Original line number Original line Diff line number Diff line Loading @@ -33,7 +33,6 @@ import android.util.StatsLog; import com.android.bluetooth.BluetoothMetricsProto; import com.android.bluetooth.BluetoothMetricsProto; import com.android.bluetooth.Utils; import com.android.bluetooth.Utils; import com.android.bluetooth.a2dp.A2dpService; import com.android.bluetooth.btservice.AdapterService; import com.android.bluetooth.btservice.AdapterService; import com.android.bluetooth.btservice.MetricsLogger; import com.android.bluetooth.btservice.MetricsLogger; import com.android.bluetooth.btservice.ProfileService; import com.android.bluetooth.btservice.ProfileService; Loading Loading @@ -517,15 +516,6 @@ public class HearingAidService extends ProfileService { Long deviceHiSyncId = mDeviceHiSyncIdMap.getOrDefault(device, Long deviceHiSyncId = mDeviceHiSyncIdMap.getOrDefault(device, BluetoothHearingAid.HI_SYNC_ID_INVALID); BluetoothHearingAid.HI_SYNC_ID_INVALID); if (deviceHiSyncId != mActiveDeviceHiSyncId) { if (deviceHiSyncId != mActiveDeviceHiSyncId) { // Give an early notification to A2DP that active device is being switched // to Hearing Aids before the Audio Service. final A2dpService a2dpService = mFactory.getA2dpService(); if (a2dpService != null) { if (DBG) { Log.d(TAG, "earlyNotifyHearingAidActive for " + device); } a2dpService.earlyNotifyHearingAidActive(); } mActiveDeviceHiSyncId = deviceHiSyncId; mActiveDeviceHiSyncId = deviceHiSyncId; reportActiveDevice(device); reportActiveDevice(device); } } Loading
android/app/tests/unit/src/com/android/bluetooth/a2dp/A2dpServiceTest.java +0 −34 Original line number Original line Diff line number Diff line Loading @@ -39,9 +39,7 @@ import androidx.test.runner.AndroidJUnit4; import com.android.bluetooth.R; import com.android.bluetooth.R; import com.android.bluetooth.TestUtils; import com.android.bluetooth.TestUtils; import com.android.bluetooth.avrcp.AvrcpTargetService; import com.android.bluetooth.btservice.AdapterService; import com.android.bluetooth.btservice.AdapterService; import com.android.bluetooth.btservice.ServiceFactory; import com.android.bluetooth.btservice.storage.DatabaseManager; import com.android.bluetooth.btservice.storage.DatabaseManager; import org.junit.After; import org.junit.After; Loading Loading @@ -78,8 +76,6 @@ public class A2dpServiceTest { @Mock private AdapterService mAdapterService; @Mock private AdapterService mAdapterService; @Mock private A2dpNativeInterface mA2dpNativeInterface; @Mock private A2dpNativeInterface mA2dpNativeInterface; @Mock private DatabaseManager mDatabaseManager; @Mock private DatabaseManager mDatabaseManager; @Mock private AvrcpTargetService mAvrcpTargetService; @Mock private ServiceFactory mFactory; @Rule public final ServiceTestRule mServiceRule = new ServiceTestRule(); @Rule public final ServiceTestRule mServiceRule = new ServiceTestRule(); Loading @@ -98,13 +94,11 @@ public class A2dpServiceTest { TestUtils.setAdapterService(mAdapterService); TestUtils.setAdapterService(mAdapterService); doReturn(MAX_CONNECTED_AUDIO_DEVICES).when(mAdapterService).getMaxConnectedAudioDevices(); doReturn(MAX_CONNECTED_AUDIO_DEVICES).when(mAdapterService).getMaxConnectedAudioDevices(); doReturn(false).when(mAdapterService).isQuietModeEnabled(); doReturn(false).when(mAdapterService).isQuietModeEnabled(); doReturn(mAvrcpTargetService).when(mFactory).getAvrcpTargetService(); mAdapter = BluetoothAdapter.getDefaultAdapter(); mAdapter = BluetoothAdapter.getDefaultAdapter(); startService(); startService(); mA2dpService.mA2dpNativeInterface = mA2dpNativeInterface; mA2dpService.mA2dpNativeInterface = mA2dpNativeInterface; mA2dpService.mFactory = mFactory; // Override the timeout value to speed up the test // Override the timeout value to speed up the test A2dpStateMachine.sConnectTimeoutMs = TIMEOUT_MS; // 1s A2dpStateMachine.sConnectTimeoutMs = TIMEOUT_MS; // 1s Loading Loading @@ -252,8 +246,6 @@ public class A2dpServiceTest { }); }); // Verify that setActiveDevice(null) was called during shutdown // Verify that setActiveDevice(null) was called during shutdown verify(mA2dpNativeInterface).setActiveDevice(null); verify(mA2dpNativeInterface).setActiveDevice(null); // Verify that storeVolumeForDevice(mTestDevice) was called during shutdown verify(mAvrcpTargetService).storeVolumeForDevice(mTestDevice); // Try to restart the service. Note: must be done on the main thread. // Try to restart the service. Note: must be done on the main thread. InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() { InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() { public void run() { public void run() { Loading Loading @@ -796,13 +788,11 @@ public class A2dpServiceTest { Assert.assertEquals(mTestDevice, mA2dpService.getActiveDevice()); Assert.assertEquals(mTestDevice, mA2dpService.getActiveDevice()); Assert.assertTrue(mA2dpService.setSilenceMode(mTestDevice, true)); Assert.assertTrue(mA2dpService.setSilenceMode(mTestDevice, true)); verify(mA2dpNativeInterface).setSilenceDevice(mTestDevice, true); verify(mA2dpNativeInterface).setSilenceDevice(mTestDevice, true); verify(mAvrcpTargetService).storeVolumeForDevice(mTestDevice); Assert.assertNull(mA2dpService.getActiveDevice()); Assert.assertNull(mA2dpService.getActiveDevice()); // Test whether active device been resumeed after disable silence mode. // Test whether active device been resumeed after disable silence mode. Assert.assertTrue(mA2dpService.setSilenceMode(mTestDevice, false)); Assert.assertTrue(mA2dpService.setSilenceMode(mTestDevice, false)); verify(mA2dpNativeInterface).setSilenceDevice(mTestDevice, false); verify(mA2dpNativeInterface).setSilenceDevice(mTestDevice, false); verify(mAvrcpTargetService).storeVolumeForDevice(mTestDevice); Assert.assertEquals(mTestDevice, mA2dpService.getActiveDevice()); Assert.assertEquals(mTestDevice, mA2dpService.getActiveDevice()); // Test that active device should not be changed when silence a non-active device // Test that active device should not be changed when silence a non-active device Loading @@ -810,13 +800,11 @@ public class A2dpServiceTest { Assert.assertEquals(mTestDevice, mA2dpService.getActiveDevice()); Assert.assertEquals(mTestDevice, mA2dpService.getActiveDevice()); Assert.assertTrue(mA2dpService.setSilenceMode(otherDevice, true)); Assert.assertTrue(mA2dpService.setSilenceMode(otherDevice, true)); verify(mA2dpNativeInterface).setSilenceDevice(otherDevice, true); verify(mA2dpNativeInterface).setSilenceDevice(otherDevice, true); verify(mAvrcpTargetService).storeVolumeForDevice(mTestDevice); Assert.assertEquals(mTestDevice, mA2dpService.getActiveDevice()); Assert.assertEquals(mTestDevice, mA2dpService.getActiveDevice()); // Test that active device should not be changed when another device exits silence mode // Test that active device should not be changed when another device exits silence mode Assert.assertTrue(mA2dpService.setSilenceMode(otherDevice, false)); Assert.assertTrue(mA2dpService.setSilenceMode(otherDevice, false)); verify(mA2dpNativeInterface).setSilenceDevice(otherDevice, false); verify(mA2dpNativeInterface).setSilenceDevice(otherDevice, false); verify(mAvrcpTargetService).storeVolumeForDevice(mTestDevice); Assert.assertEquals(mTestDevice, mA2dpService.getActiveDevice()); Assert.assertEquals(mTestDevice, mA2dpService.getActiveDevice()); } } Loading Loading @@ -906,28 +894,6 @@ public class A2dpServiceTest { verifySupportTime, verifyNotSupportTime, verifyEnabledTime); verifySupportTime, verifyNotSupportTime, verifyEnabledTime); } } /** * Test that volume level of previous active device will be stored after set active device. */ @Test public void testStoreVolumeAfterSetActiveDevice() { BluetoothDevice otherDevice = mAdapter.getRemoteDevice("05:04:03:02:01:00"); connectDevice(otherDevice); connectDevice(mTestDevice); doReturn(true).when(mA2dpNativeInterface).setActiveDevice(any(BluetoothDevice.class)); doReturn(true).when(mA2dpNativeInterface).setActiveDevice(null); Assert.assertTrue(mA2dpService.setActiveDevice(mTestDevice)); // Test volume stored for previous active device an adjust for current active device Assert.assertTrue(mA2dpService.setActiveDevice(otherDevice)); verify(mAvrcpTargetService).storeVolumeForDevice(mTestDevice); verify(mAvrcpTargetService).getRememberedVolumeForDevice(otherDevice); // Test volume store for previous active device when set active device to null Assert.assertTrue(mA2dpService.setActiveDevice(null)); verify(mAvrcpTargetService).storeVolumeForDevice(otherDevice); } private void connectDevice(BluetoothDevice device) { private void connectDevice(BluetoothDevice device) { connectDeviceWithCodecStatus(device, null); connectDeviceWithCodecStatus(device, null); } } Loading