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

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

Snap for 11012804 from d8ccf402 to 24Q1-release

Change-Id: I0a3677762d52af5487e6cd856db276d9d94b6135
parents f3fc7487 d8ccf402
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -13,3 +13,10 @@ flag {
  description: "When set, call details/extras id updates to Telecom APIs for Android V are active."
  bug: "301713560"
}

flag {
  name: "unbind_timeout_connections"
  namespace: "telecom"
  description: "When set, Telecom will auto-unbind if a ConnectionService returns no connections after some time."
  bug: "293458004"
}
+8 −1
Original line number Diff line number Diff line
@@ -14,6 +14,13 @@ flag {
  bug: "289861657"
}

flag {
  name: "ignore_auto_route_to_watch_device"
  namespace: "telecom"
  description: "Ignore auto routing to wearable devices."
  bug: "294378768"
}

flag {
  name: "transit_route_before_audio_disconnect_bt"
  namespace: "telecom"
+25 −1
Original line number Diff line number Diff line
@@ -2022,6 +2022,30 @@ public class CallAudioRouteStateMachine extends StateMachine {
        return false;
    }

    private boolean isWatchActiveOrOnlyWatchesAvailable() {
        if (!mFeatureFlags.ignoreAutoRouteToWatchDevice()) {
            return false;
        }

        boolean containsWatchDevice = false;
        boolean containsNonWatchDevice = false;
        Collection<BluetoothDevice> connectedBtDevices =
                mBluetoothRouteManager.getConnectedDevices();

        for (BluetoothDevice connectedDevice: connectedBtDevices) {
            if (mBluetoothRouteManager.isWatch(connectedDevice)) {
                containsWatchDevice = true;
            } else {
                containsNonWatchDevice = true;
            }
        }

        // Don't ignore switch if watch is already the active device.
        return containsWatchDevice && !containsNonWatchDevice
                && !mBluetoothRouteManager.isWatch(
                        mBluetoothRouteManager.getBluetoothAudioConnectedDevice());
    }

    private int calculateBaselineRouteMessage(boolean isExplicitUserRequest,
            boolean includeBluetooth) {
        boolean isSkipEarpiece = false;
@@ -2034,7 +2058,7 @@ public class CallAudioRouteStateMachine extends StateMachine {
        }
        if ((mAvailableRoutes & ROUTE_BLUETOOTH) != 0
                && !mHasUserExplicitlyLeftBluetooth
                && includeBluetooth) {
                && includeBluetooth && !isWatchActiveOrOnlyWatchesAvailable()) {
            return isExplicitUserRequest ? USER_SWITCH_BLUETOOTH : SWITCH_BLUETOOTH;
        } else if ((mAvailableRoutes & ROUTE_EARPIECE) != 0 && !isSkipEarpiece) {
            return isExplicitUserRequest ? USER_SWITCH_EARPIECE : SWITCH_EARPIECE;
+47 −6
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.IBinder;
import android.os.ParcelFileDescriptor;
import android.os.Process;
import android.os.RemoteException;
import android.os.ResultReceiver;
import android.os.UserHandle;
@@ -65,6 +64,7 @@ import com.android.internal.telecom.IConnectionServiceAdapter;
import com.android.internal.telecom.IVideoProvider;
import com.android.internal.telecom.RemoteServiceCallback;
import com.android.internal.util.Preconditions;
import com.android.server.telecom.flags.Flags;

import java.util.ArrayList;
import java.util.Collection;
@@ -72,13 +72,14 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.Objects;

/**
 * Wrapper for {@link IConnectionService}s, handles binding to {@link IConnectionService} and keeps
@@ -91,9 +92,12 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        ConnectionServiceFocusManager.ConnectionServiceFocus {

    private static final String TELECOM_ABBREVIATION = "cast";
    private static final long SERVICE_BINDING_TIMEOUT = 15000L;
    private CompletableFuture<Pair<Integer, Location>> mQueryLocationFuture = null;
    private @Nullable CancellationSignal mOngoingQueryLocationRequest = null;
    private final ExecutorService mQueryLocationExecutor = Executors.newSingleThreadExecutor();
    private ScheduledExecutorService mScheduledExecutor =
            Executors.newSingleThreadScheduledExecutor();

    private final class Adapter extends IConnectionServiceAdapter.Stub {

@@ -1600,7 +1604,22 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
                        .setParticipants(call.getParticipants())
                        .setIsAdhocConferenceCall(call.isAdhocConferenceCall())
                        .build();

                if (Flags.unbindTimeoutConnections()) {
                    android.telecom.Logging.Runnable r =
                            new android.telecom.Logging.Runnable("CSW.cC", mLock) {
                        @Override
                        public void loggedRun() {
                            if (!call.isCreateConnectionComplete()) {
                                Log.e(this, new Exception(), "Conference %s creation timeout",
                                        getComponentName());
                                response.handleCreateConferenceFailure(
                                        new DisconnectCause(DisconnectCause.ERROR));
                            }
                        }
                    };
                    mScheduledExecutor.schedule(r.getRunnableToCancel(), SERVICE_BINDING_TIMEOUT,
                            TimeUnit.MILLISECONDS);
                }
                try {
                    mServiceInterface.createConference(
                            call.getConnectionManagerPhoneAccount(),
@@ -1609,7 +1628,6 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
                            call.shouldAttachToExistingConnection(),
                            call.isUnknown(),
                            Log.getExternalSession(TELECOM_ABBREVIATION));

                } catch (RemoteException e) {
                    Log.e(this, e, "Failure to createConference -- %s", getComponentName());
                    mPendingResponses.remove(callId).handleCreateConferenceFailure(
@@ -1642,6 +1660,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
                    Log.i(ConnectionServiceWrapper.this, "Call not present"
                            + " in call id mapper, maybe it was aborted before the bind"
                            + " completed successfully?");

                    response.handleCreateConnectionFailure(
                            new DisconnectCause(DisconnectCause.CANCELED));
                    return;
@@ -1703,6 +1722,23 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
                        .setRttPipeToInCall(call.getCsToInCallRttPipeForCs())
                        .build();

                if (Flags.unbindTimeoutConnections()) {
                    android.telecom.Logging.Runnable r =
                            new android.telecom.Logging.Runnable("CSW.cC", mLock) {
                                @Override
                                public void loggedRun() {
                                    if (!call.isCreateConnectionComplete()) {
                                        Log.e(this, new Exception(),
                                                "Connection %s creation timeout",
                                                getComponentName());
                                        response.handleCreateConnectionFailure(
                                                new DisconnectCause(DisconnectCause.ERROR));
                                    }
                                }
                            };
                    mScheduledExecutor.schedule(r.getRunnableToCancel(), SERVICE_BINDING_TIMEOUT,
                            TimeUnit.MILLISECONDS);
                }
                try {
                    mServiceInterface.createConnection(
                            call.getConnectionManagerPhoneAccount(),
@@ -1711,7 +1747,6 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
                            call.shouldAttachToExistingConnection(),
                            call.isUnknown(),
                            Log.getExternalSession(TELECOM_ABBREVIATION));

                } catch (RemoteException e) {
                    Log.e(this, e, "Failure to createConnection -- %s", getComponentName());
                    mPendingResponses.remove(callId).handleCreateConnectionFailure(
@@ -2160,7 +2195,8 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        }
    }

    void addCall(Call call) {
    @VisibleForTesting
    public void addCall(Call call) {
        if (mCallIdMapper.getCallId(call) == null) {
            mCallIdMapper.addCall(call);
        }
@@ -2629,4 +2665,9 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        sb.append("]");
        return sb.toString();
    }

    @VisibleForTesting
    public void setScheduledExecutorService(ScheduledExecutorService service) {
        mScheduledExecutor = service;
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -261,7 +261,8 @@ public class TelecomSystem {
                    mContext.getSystemService(BluetoothManager.class).getAdapter(),
                    communicationDeviceTracker);
            BluetoothRouteManager bluetoothRouteManager = new BluetoothRouteManager(mContext, mLock,
                    bluetoothDeviceManager, new Timeouts.Adapter(), communicationDeviceTracker);
                    bluetoothDeviceManager, new Timeouts.Adapter(),
                    communicationDeviceTracker, featureFlags);
            BluetoothStateReceiver bluetoothStateReceiver = new BluetoothStateReceiver(
                    bluetoothDeviceManager, bluetoothRouteManager, communicationDeviceTracker);
            mContext.registerReceiver(bluetoothStateReceiver, BluetoothStateReceiver.INTENT_FILTER);
Loading