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

Commit 3164476a authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 13503953 from ed51163a to 25Q3-release

Change-Id: Id955fa3084ff1b555c657aef0ff2708de9215e46
parents 81088e9e ed51163a
Loading
Loading
Loading
Loading
+25 −4
Original line number Diff line number Diff line
@@ -3655,6 +3655,19 @@ public class CallsManager extends Call.ListenerBase
        }
        mPendingAccountSelection.remove(callId);
    }

    /**
     * Derived from the disconnectCallOld logic to ensure that the registered listeners are notified
     * of the disconnecting state once the call is disconnected. This is used for call sequencing.
     * @param call The call to notify the state change for.
     * @param previousState The previous call state before the disconnect.
     */
    public void notifyCallStateChangeForDisconnect(Call call, int previousState) {
        for (CallsManagerListener listener : mListeners) {
            listener.onCallStateChanged(call, previousState, call.getState());
        }
    }

    /**
     * Disconnects calls for any other {@link PhoneAccountHandle} but the one specified.
     * Note: As a protective measure, will NEVER disconnect an emergency call.  Although that
@@ -5774,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);
                }
            }
        });
    }

+7 −0
Original line number Diff line number Diff line
@@ -863,12 +863,19 @@ public class CallSequencingController {
     */
    public void disconnectCall(Call call, int previousState) {
        CompletableFuture<Boolean> disconnectFuture = call.disconnect();
        int newState = call.getState();
        mCallsManager.notifyCallStateChangeForDisconnect(call, previousState);
        disconnectFuture.thenComposeAsync((result) -> {
            if (result) {
                Log.i(this, "disconnectCall: Disconnect call transaction succeeded. "
                        + "Processing associated cleanup.");
                mCallsManager.processDisconnectCallAndCleanup(call, previousState);
            } else {
                // Revert the disconnecting state that was set as a result of invoking
                // Call#disconnect and make sure the reverted state is notified to the registered
                // listeners.
                call.setLocallyDisconnecting(false);
                mCallsManager.notifyCallStateChangeForDisconnect(call, newState);
                Log.i(this, "disconnectCall: Disconnect call transaction failed. "
                        + "Aborting associated cleanup.");
            }
+4 −6
Original line number Diff line number Diff line
@@ -136,12 +136,10 @@ public class CallSequencingStats extends TelecomPulledAtom {

    @VisibleForTesting(otherwise = VisibleForTesting.PROTECTED)
    public void log(CallSequencingStatsKey key, int duration) {
        post(() -> {
        CallSequencingStatsData data = mCallSequencingStatsMap
                .computeIfAbsent(key, k -> new CallSequencingStatsData(0, 0));
        data.add(duration);
        onAggregate();
        });
    }

    public void onCallEnd(Call call) {
+5 −0
Original line number Diff line number Diff line
@@ -620,6 +620,7 @@ public class CallSequencingTests extends TelecomTestCase {
        when(mActiveCall.disconnect()).thenReturn(CompletableFuture.completedFuture(true));
        int previousState = CallState.ACTIVE;
        mController.disconnectCall(mActiveCall, previousState);
        verify(mCallsManager).notifyCallStateChangeForDisconnect(any(Call.class), anyInt());
        verify(mCallsManager, timeout(SEQUENCING_TIMEOUT_MS))
                .processDisconnectCallAndCleanup(eq(mActiveCall), eq(previousState));
    }
@@ -630,8 +631,12 @@ public class CallSequencingTests extends TelecomTestCase {
        when(mActiveCall.disconnect()).thenReturn(CompletableFuture.completedFuture(false));
        int previousState = CallState.ACTIVE;
        mController.disconnectCall(mActiveCall, previousState);
        verify(mCallsManager).notifyCallStateChangeForDisconnect(any(Call.class), anyInt());
        verify(mCallsManager, timeout(SEQUENCING_TIMEOUT_MS).times(0))
                .processDisconnectCallAndCleanup(eq(mActiveCall), eq(previousState));
        verify(mCallsManager, timeout(SEQUENCING_TIMEOUT_MS).times(2))
                .notifyCallStateChangeForDisconnect(any(Call.class), anyInt());
        verify(mActiveCall, timeout(SEQUENCING_TIMEOUT_MS)).setLocallyDisconnecting(eq(false));
    }

    @Test
+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() {
Loading