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

Commit d7fb8c03 authored by Hall Liu's avatar Hall Liu Committed by android-build-merger
Browse files

Fix BT call state issue am: ee99e09f am: af71ec3a

am: 9aee7ea2

Change-Id: Iffee2ec541a992f28ffe2423920705217d1136da
parents 0da4d1a4 9aee7ea2
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -727,12 +727,14 @@ public class CallAudioManager extends CallsManagerListenerBase {
            Log.d(this, "Found a disconnected call with tone to play %d.", toneToPlay);

            if (toneToPlay != InCallTonePlayer.TONE_INVALID) {
                mPlayerFactory.createPlayer(toneToPlay).startTone();
                boolean didToneStart = mPlayerFactory.createPlayer(toneToPlay).startTone();
                if (didToneStart) {
                    mCallsManager.onDisconnectedTonePlaying(true);
                    mIsDisconnectedTonePlaying = true;
                }
            }
        }
    }

    private void playRingbackForCall(Call call) {
        if (call == mForegroundCall && call.isRingbackRequested()) {
+3 −2
Original line number Diff line number Diff line
@@ -427,11 +427,11 @@ public class InCallTonePlayer extends Thread {
    }

    @VisibleForTesting
    public void startTone() {
    public boolean startTone() {
        // Skip playing the end call tone if the volume is silenced.
        if (mToneId == TONE_CALL_ENDED && !mAudioManagerAdapter.isVolumeOverZero()) {
            Log.i(this, "startTone: skip end-call tone as device is silenced.");
            return;
            return false;
        }

        sTonesPlaying++;
@@ -447,6 +447,7 @@ public class InCallTonePlayer extends Thread {
        }

        super.start();
        return true;
    }

    @Override
+1 −1
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ public class CallAudioManagerTest extends TelecomTestCase {
            InCallTonePlayer mockInCallTonePlayer = mock(InCallTonePlayer.class);
            doAnswer((invocation2) -> {
                mCallAudioManager.setIsTonePlaying(true);
                return null;
                return true;
            }).when(mockInCallTonePlayer).startTone();
            return mockInCallTonePlayer;
        }).when(mPlayerFactory).createPlayer(anyInt());
+4 −2
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.server.telecom.tests;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
@@ -114,7 +116,7 @@ public class InCallTonePlayerTest extends TelecomTestCase {
    public void testNoEndCallToneInSilence() {
        when(mAudioManagerAdapter.isVolumeOverZero()).thenReturn(false);
        InCallTonePlayer player = mFactory.createPlayer(InCallTonePlayer.TONE_CALL_ENDED);
        player.startTone();
        assertFalse(player.startTone());

        // Verify we didn't play a tone.
        verify(mCallAudioManager, never()).setIsTonePlaying(eq(true));
@@ -126,7 +128,7 @@ public class InCallTonePlayerTest extends TelecomTestCase {
    public void testEndCallToneWhenNotSilenced() {
        when(mAudioManagerAdapter.isVolumeOverZero()).thenReturn(true);
        InCallTonePlayer player = mFactory.createPlayer(InCallTonePlayer.TONE_CALL_ENDED);
        player.startTone();
        assertTrue(player.startTone());

        // Verify we did play a tone.
        verify(mCallAudioManager).setIsTonePlaying(eq(true));
+1 −0
Original line number Diff line number Diff line
@@ -123,6 +123,7 @@ public class RingerTest extends TelecomTestCase {
        when(mockAudioManager.getRingerModeInternal()).thenReturn(AudioManager.RINGER_MODE_NORMAL);
        NotificationManager notificationManager =
                (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
        when(mockTonePlayer.startTone()).thenReturn(true);
        when(notificationManager.matchesCallFilter(any(Bundle.class))).thenReturn(true);
        mRingerUnderTest = new Ringer(mockPlayerFactory, mContext, mockSystemSettingsUtil,
                mockRingtonePlayer, mockRingtoneFactory, mockVibrator, spyVibrationEffectProxy,