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

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

Merge "Remove reference to getDefaultStreamVolume." into main

parents f7fb1da2 3de102c4
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -5787,11 +5787,19 @@ public class CallsManager extends Call.ListenerBase
                return;
            }
            if (am.getStreamVolume(AudioManager.STREAM_VOICE_CALL) == 0) {
                Log.i(this,
                        "ensureCallAudible: voice call stream has volume 0. Adjusting to default.");
                if (mFeatureFlags.resolveHiddenDependenciesTwo()) {
                    Log.i(this, "ensureCallAudible: voice call stream has volume 0. "
                            + "Adjusting to average.");
                    int averageStreamVolume = (am.getStreamMaxVolume(AudioManager.STREAM_VOICE_CALL)
                            + am.getStreamMinVolume(AudioManager.STREAM_VOICE_CALL)) / 2;
                    am.setStreamVolume(AudioManager.STREAM_VOICE_CALL, averageStreamVolume, 0);
                } else {
                    Log.i(this, "ensureCallAudible: voice call stream has volume 0. "
                            + "Adjusting to default.");
                    am.setStreamVolume(AudioManager.STREAM_VOICE_CALL,
                            AudioSystem.getDefaultStreamVolume(AudioManager.STREAM_VOICE_CALL), 0);
                }
            }
        });
    }

+21 −0
Original line number Diff line number Diff line
@@ -3427,6 +3427,7 @@ public class CallsManagerTest extends TelecomTestCase {
        verify(mComponentContextFixture.getAudioManager(), times(1)).setStreamVolume(
                eq(AudioManager.STREAM_VOICE_CALL), anyInt(), anyInt());
    }

    @MediumTest
    @Test
    public void testSetCallDialingAndIncreaseVolume() {
@@ -3442,6 +3443,26 @@ public class CallsManagerTest extends TelecomTestCase {
                eq(AudioManager.STREAM_VOICE_CALL), anyInt(), anyInt());
    }

    @MediumTest
    @Test
    public void testSetCallDialingAndCalculateAverageVolume() {
        // This test specificaslly tests the new behavior guarded by this flag:
        when(mFeatureFlags.resolveHiddenDependenciesTwo()).thenReturn(true);

        // Start with a zero volume stream.
        mComponentContextFixture.getAudioManager().setStreamVolume(AudioManager.STREAM_VOICE_CALL,
                0, 0 /* flags */);

        Call call = mock(Call.class);
        mCallsManager.markCallAsDialing(call);

        // Ensure we calculate the new volume using the average of AudioManager min and max volume:
        verify(mComponentContextFixture.getAudioManager(), times(1))
                .getStreamMaxVolume(eq(AudioManager.STREAM_VOICE_CALL));
        verify(mComponentContextFixture.getAudioManager(), times(1))
                .getStreamMinVolume(eq(AudioManager.STREAM_VOICE_CALL));
    }

    @MediumTest
    @Test
    public void testSetCallActiveAndDontIncreaseVolume() {