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

Commit d27148d0 authored by Grace Jia's avatar Grace Jia
Browse files

Voip call streaming operations cleanup.

1. Log all call transaction operations in sessions.
2. Avoid multiple times invoke of Call#destroy
3. Fix incorrect MessageArgs for CallAudioModeStateMachine to not treat
   disconnected streaming call as ongoing streaming call.

Bug: 279937547
Test: atest CallStreamingTest
Change-Id: I830534adff6526535b39f89d01a845964005a349
parent 8a0898a7
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -534,6 +534,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
    private boolean mWasHighDefAudio = false;
    private boolean mWasWifi = false;
    private boolean mWasVolte = false;
    private boolean mDestroyed = false;

    // For conferences which support merge/swap at their level, we retain a notion of an active
    // call. This is used for BluetoothPhoneService.  In order to support hold/merge, it must have
@@ -929,6 +930,9 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
    }

    public void destroy() {
        if (mDestroyed) {
            return;
        }
        // We should not keep these bitmaps around because the Call objects may be held for logging
        // purposes.
        // TODO: Make a container object that only stores the information we care about for Logging.
@@ -939,6 +943,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        closeRttStreams();

        Log.addEvent(this, LogUtils.Events.DESTROYED);
        mDestroyed = true;
    }

    private void closeRttStreams() {
+1 −1
Original line number Diff line number Diff line
@@ -795,7 +795,7 @@ public class CallAudioManager extends CallsManagerListenerBase {
                .setHasHoldingCalls(mHoldingCalls.size() > 0)
                .setHasAudioProcessingCalls(mAudioProcessingCalls.size() > 0)
                .setIsTonePlaying(mIsTonePlaying)
                .setIsStreaming(mStreamingCall != null)
                .setIsStreaming((mStreamingCall != null) && (!mStreamingCall.isDisconnected()))
                .setForegroundCallIsVoip(
                        mForegroundCall != null && isCallVoip(mForegroundCall))
                .setSession(Log.createSubsession()).build();
+1 −0
Original line number Diff line number Diff line
@@ -224,6 +224,7 @@ public class LogUtils {
        public static final String FLASH_NOTIFICATION_START = "FLASH_NOTIFICATION_START";
        public static final String FLASH_NOTIFICATION_STOP = "FLASH_NOTIFICATION_STOP";
        public static final String GAINED_FGS_DELEGATION = "GAINED_FGS_DELEGATION";
        public static final String GAIN_FGS_DELEGATION_FAILED = "GAIN_FGS_DELEGATION_FAILED";
        public static final String LOST_FGS_DELEGATION = "LOST_FGS_DELEGATION";
        public static final String START_STREAMING = "START_STREAMING";
        public static final String STOP_STREAMING = "STOP_STREAMING";
+38 −22
Original line number Diff line number Diff line
@@ -16,9 +16,11 @@

package com.android.server.telecom.voip;

import com.android.server.telecom.LoggedHandlerExecutor;
import com.android.server.telecom.TelecomSystem;

import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicInteger;

/**
@@ -33,15 +35,19 @@ public class ParallelTransaction extends VoipCallTransaction {
    @Override
    public void start() {
        // post timeout work
        mHandler.postDelayed(() -> {
        CompletableFuture<Void> future = new CompletableFuture<>();
        mHandler.postDelayed(() -> future.complete(null), TIMEOUT_LIMIT);
        future.thenApplyAsync((x) -> {
            if (mCompleted.getAndSet(true)) {
                return;
                return null;
            }
            if (mCompleteListener != null) {
                mCompleteListener.onTransactionTimeout(mTransactionName);
            }
            finish();
        }, TIMEOUT_LIMIT);
            return null;
        }, new LoggedHandlerExecutor(mHandler, mTransactionName + "@" + hashCode()
                + ".s", mLock));

        if (mSubTransactions != null && mSubTransactions.size() > 0) {
            TransactionManager.TransactionCompleteListener subTransactionListener =
@@ -52,16 +58,21 @@ public class ParallelTransaction extends VoipCallTransaction {
                        public void onTransactionCompleted(VoipCallTransactionResult result,
                                String transactionName) {
                            if (result.getResult() != VoipCallTransactionResult.RESULT_SUCCEED) {
                                mHandler.post(() -> {
                                CompletableFuture.completedFuture(null).thenApplyAsync(
                                        (x) -> {
                                            VoipCallTransactionResult mainResult =
                                                    new VoipCallTransactionResult(
                                                            VoipCallTransactionResult.RESULT_FAILED,
                                                    String.format("sub transaction %s failed",
                                                            String.format(
                                                                    "sub transaction %s failed",
                                                                    transactionName));
                                            mCompleteListener.onTransactionCompleted(mainResult,
                                                    mTransactionName);
                                            finish();
                                });
                                            return null;
                                        }, new LoggedHandlerExecutor(mHandler,
                                                mTransactionName + "@" + hashCode()
                                                        + ".oTC", mLock));
                            } else {
                                if (mCount.decrementAndGet() == 0) {
                                    scheduleTransaction();
@@ -71,15 +82,20 @@ public class ParallelTransaction extends VoipCallTransaction {

                        @Override
                        public void onTransactionTimeout(String transactionName) {
                            mHandler.post(() -> {
                                VoipCallTransactionResult mainResult = new VoipCallTransactionResult(
                            CompletableFuture.completedFuture(null).thenApplyAsync(
                                    (x) -> {
                                        VoipCallTransactionResult mainResult =
                                                new VoipCallTransactionResult(
                                                VoipCallTransactionResult.RESULT_FAILED,
                                                String.format("sub transaction %s timed out",
                                                        transactionName));
                                        mCompleteListener.onTransactionCompleted(mainResult,
                                                mTransactionName);
                                        finish();
                            });
                                        return null;
                                    }, new LoggedHandlerExecutor(mHandler,
                                            mTransactionName + "@" + hashCode()
                                                    + ".oTT", mLock));
                        }
                    };
            for (VoipCallTransaction transaction : mSubTransactions) {
+38 −22
Original line number Diff line number Diff line
@@ -16,9 +16,11 @@

package com.android.server.telecom.voip;

import com.android.server.telecom.LoggedHandlerExecutor;
import com.android.server.telecom.TelecomSystem;

import java.util.List;
import java.util.concurrent.CompletableFuture;

/**
 * A VoipCallTransaction implementation that its sub transactions will be executed in serial
@@ -36,15 +38,19 @@ public class SerialTransaction extends VoipCallTransaction {
    @Override
    public void start() {
        // post timeout work
        mHandler.postDelayed(() -> {
        CompletableFuture<Void> future = new CompletableFuture<>();
        mHandler.postDelayed(() -> future.complete(null), TIMEOUT_LIMIT);
        future.thenApplyAsync((x) -> {
            if (mCompleted.getAndSet(true)) {
                return;
                return null;
            }
            if (mCompleteListener != null) {
                mCompleteListener.onTransactionTimeout(mTransactionName);
            }
            finish();
        }, TIMEOUT_LIMIT);
            return null;
        }, new LoggedHandlerExecutor(mHandler, mTransactionName + "@" + hashCode()
                + ".s", mLock));

        if (mSubTransactions != null && mSubTransactions.size() > 0) {
            TransactionManager.TransactionCompleteListener subTransactionListener =
@@ -54,16 +60,21 @@ public class SerialTransaction extends VoipCallTransaction {
                        public void onTransactionCompleted(VoipCallTransactionResult result,
                                String transactionName) {
                            if (result.getResult() != VoipCallTransactionResult.RESULT_SUCCEED) {
                                mHandler.post(() -> {
                                CompletableFuture.completedFuture(null).thenApplyAsync(
                                        (x) -> {
                                            VoipCallTransactionResult mainResult =
                                                    new VoipCallTransactionResult(
                                                            VoipCallTransactionResult.RESULT_FAILED,
                                                    String.format("sub transaction %s failed",
                                                            String.format(
                                                                    "sub transaction %s failed",
                                                                    transactionName));
                                            mCompleteListener.onTransactionCompleted(mainResult,
                                                    mTransactionName);
                                            finish();
                                });
                                            return null;
                                        }, new LoggedHandlerExecutor(mHandler,
                                                mTransactionName + "@" + hashCode()
                                                        + ".oTC", mLock));
                            } else {
                                if (mSubTransactions.size() > 0) {
                                    VoipCallTransaction transaction = mSubTransactions.remove(0);
@@ -77,15 +88,20 @@ public class SerialTransaction extends VoipCallTransaction {

                        @Override
                        public void onTransactionTimeout(String transactionName) {
                            mHandler.post(() -> {
                                VoipCallTransactionResult mainResult = new VoipCallTransactionResult(
                            CompletableFuture.completedFuture(null).thenApplyAsync(
                                    (x) -> {
                                        VoipCallTransactionResult mainResult =
                                                new VoipCallTransactionResult(
                                                VoipCallTransactionResult.RESULT_FAILED,
                                                String.format("sub transaction %s timed out",
                                                        transactionName));
                                        mCompleteListener.onTransactionCompleted(mainResult,
                                                mTransactionName);
                                        finish();
                            });
                                        return null;
                                    }, new LoggedHandlerExecutor(mHandler,
                                            mTransactionName + "@" + hashCode()
                                                    + ".oTT", mLock));
                        }
                    };
            VoipCallTransaction transaction = mSubTransactions.remove(0);
Loading