Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 33c61ef8 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Skip set the volume when slider is not initialized" into main

parents a9cc446d 2250d7bd
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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);
                    }
                }
@@ -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);
                    }
                }
+5 −0
Original line number Diff line number Diff line
@@ -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) {
@@ -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);
                }
            }
        });
+7 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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());

@@ -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();