Loading packages/SettingsLib/src/com/android/settingslib/bluetooth/AmbientVolumeController.java +2 −2 Original line number Diff line number Diff line Loading @@ -368,7 +368,7 @@ public class AmbientVolumeController implements LocalBluetoothProfileManager.Ser if (mCallback != null) { synchronized (mDeviceAmbientStateMap) { RemoteAmbientState previousState = mDeviceAmbientStateMap.get(mDevice); if (previousState.gainSetting != gainSetting) { if (previousState == null || previousState.gainSetting != gainSetting) { mCallback.onAmbientChanged(mDevice, gainSetting); } } Loading @@ -388,7 +388,7 @@ public class AmbientVolumeController implements LocalBluetoothProfileManager.Ser if (mCallback != null) { synchronized (mDeviceAmbientStateMap) { RemoteAmbientState previousState = mDeviceAmbientStateMap.get(mDevice); if (previousState.mute != mute) { if (previousState == null || previousState.mute != mute) { mCallback.onMuteChanged(mDevice, mute); } } Loading packages/SettingsLib/src/com/android/settingslib/bluetooth/AmbientVolumeUiController.java +5 −0 Original line number Diff line number Diff line Loading @@ -371,6 +371,10 @@ public class AmbientVolumeUiController implements if (volume == INVALID_VOLUME) { return; } if (!mRangeInitializedSliderSides.contains(side)) { Log.w(TAG, "the slider is not initialized yet, skip set volume on side=" + side); return; } mAmbientLayout.setSliderValue(side, volume); // Update new value to local data if (side == SIDE_UNIFIED) { Loading Loading @@ -418,6 +422,7 @@ public class AmbientVolumeUiController implements mAmbientLayout.setSliderRange(side, ambientMin, ambientMax); mAmbientLayout.setSliderRange(SIDE_UNIFIED, ambientMin, ambientMax); mRangeInitializedSliderSides.add(side); mRangeInitializedSliderSides.add(SIDE_UNIFIED); } } }); Loading packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/AmbientVolumeUiControllerTest.java +7 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,8 @@ public class AmbientVolumeUiControllerTest { private static final String TEST_ADDRESS = "00:00:00:00:11"; private static final String TEST_MEMBER_ADDRESS = "00:00:00:00:22"; private static final int TEST_AMBIENT_MAX = 60; private static final int TEST_AMBIENT_MIN = -30; @Mock LocalBluetoothManager mBluetoothManager; Loading Loading @@ -111,7 +113,11 @@ public class AmbientVolumeUiControllerTest { when(mVolumeControlProfile.getConnectionStatus(mMemberDevice)).thenReturn( BluetoothProfile.STATE_CONNECTED); when(mVolumeController.isAmbientControlAvailable(mDevice)).thenReturn(true); when(mVolumeController.getAmbientMax(mDevice)).thenReturn(TEST_AMBIENT_MAX); when(mVolumeController.getAmbientMin(mDevice)).thenReturn(TEST_AMBIENT_MIN); when(mVolumeController.isAmbientControlAvailable(mMemberDevice)).thenReturn(true); when(mVolumeController.getAmbientMax(mMemberDevice)).thenReturn(TEST_AMBIENT_MAX); when(mVolumeController.getAmbientMin(mMemberDevice)).thenReturn(TEST_AMBIENT_MIN); when(mLocalDataManager.get(any(BluetoothDevice.class))).thenReturn( new HearingDeviceLocalDataManager.Data.Builder().build()); Loading Loading @@ -213,6 +219,7 @@ public class AmbientVolumeUiControllerTest { .ambient(0).groupAmbient(0).ambientControlExpanded(testExpanded).build(); when(mLocalDataManager.get(mDevice)).thenReturn(data); mController.refresh(); mController.onDeviceLocalDataChange(TEST_ADDRESS, data); shadowOf(Looper.getMainLooper()).idle(); Loading Loading
packages/SettingsLib/src/com/android/settingslib/bluetooth/AmbientVolumeController.java +2 −2 Original line number Diff line number Diff line Loading @@ -368,7 +368,7 @@ public class AmbientVolumeController implements LocalBluetoothProfileManager.Ser if (mCallback != null) { synchronized (mDeviceAmbientStateMap) { RemoteAmbientState previousState = mDeviceAmbientStateMap.get(mDevice); if (previousState.gainSetting != gainSetting) { if (previousState == null || previousState.gainSetting != gainSetting) { mCallback.onAmbientChanged(mDevice, gainSetting); } } Loading @@ -388,7 +388,7 @@ public class AmbientVolumeController implements LocalBluetoothProfileManager.Ser if (mCallback != null) { synchronized (mDeviceAmbientStateMap) { RemoteAmbientState previousState = mDeviceAmbientStateMap.get(mDevice); if (previousState.mute != mute) { if (previousState == null || previousState.mute != mute) { mCallback.onMuteChanged(mDevice, mute); } } Loading
packages/SettingsLib/src/com/android/settingslib/bluetooth/AmbientVolumeUiController.java +5 −0 Original line number Diff line number Diff line Loading @@ -371,6 +371,10 @@ public class AmbientVolumeUiController implements if (volume == INVALID_VOLUME) { return; } if (!mRangeInitializedSliderSides.contains(side)) { Log.w(TAG, "the slider is not initialized yet, skip set volume on side=" + side); return; } mAmbientLayout.setSliderValue(side, volume); // Update new value to local data if (side == SIDE_UNIFIED) { Loading Loading @@ -418,6 +422,7 @@ public class AmbientVolumeUiController implements mAmbientLayout.setSliderRange(side, ambientMin, ambientMax); mAmbientLayout.setSliderRange(SIDE_UNIFIED, ambientMin, ambientMax); mRangeInitializedSliderSides.add(side); mRangeInitializedSliderSides.add(SIDE_UNIFIED); } } }); Loading
packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/AmbientVolumeUiControllerTest.java +7 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,8 @@ public class AmbientVolumeUiControllerTest { private static final String TEST_ADDRESS = "00:00:00:00:11"; private static final String TEST_MEMBER_ADDRESS = "00:00:00:00:22"; private static final int TEST_AMBIENT_MAX = 60; private static final int TEST_AMBIENT_MIN = -30; @Mock LocalBluetoothManager mBluetoothManager; Loading Loading @@ -111,7 +113,11 @@ public class AmbientVolumeUiControllerTest { when(mVolumeControlProfile.getConnectionStatus(mMemberDevice)).thenReturn( BluetoothProfile.STATE_CONNECTED); when(mVolumeController.isAmbientControlAvailable(mDevice)).thenReturn(true); when(mVolumeController.getAmbientMax(mDevice)).thenReturn(TEST_AMBIENT_MAX); when(mVolumeController.getAmbientMin(mDevice)).thenReturn(TEST_AMBIENT_MIN); when(mVolumeController.isAmbientControlAvailable(mMemberDevice)).thenReturn(true); when(mVolumeController.getAmbientMax(mMemberDevice)).thenReturn(TEST_AMBIENT_MAX); when(mVolumeController.getAmbientMin(mMemberDevice)).thenReturn(TEST_AMBIENT_MIN); when(mLocalDataManager.get(any(BluetoothDevice.class))).thenReturn( new HearingDeviceLocalDataManager.Data.Builder().build()); Loading Loading @@ -213,6 +219,7 @@ public class AmbientVolumeUiControllerTest { .ambient(0).groupAmbient(0).ambientControlExpanded(testExpanded).build(); when(mLocalDataManager.get(mDevice)).thenReturn(data); mController.refresh(); mController.onDeviceLocalDataChange(TEST_ADDRESS, data); shadowOf(Looper.getMainLooper()).idle(); Loading