Merge "Import translations. DO NOT MERGE ANYWHERE" into main
diff --git a/src/com/android/server/telecom/CallAudioRouteController.java b/src/com/android/server/telecom/CallAudioRouteController.java
index 29e67bb..d8e4a5e 100644
--- a/src/com/android/server/telecom/CallAudioRouteController.java
+++ b/src/com/android/server/telecom/CallAudioRouteController.java
@@ -958,7 +958,8 @@
BluetoothDevice device = mBluetoothRoutes.get(route);
// Check if in-band ringtone is enabled for the device; if it isn't, move to
// inactive route.
- if (device != null && !mBluetoothRouteManager.isInbandRingEnabled(device)) {
+ if (device != null && !mBluetoothRouteManager
+ .isInbandRingEnabled(route.getType(), device)) {
routeTo(false, route);
} else {
routeTo(true, route);
@@ -966,7 +967,8 @@
} else {
// Route is already active.
BluetoothDevice device = mBluetoothRoutes.get(mCurrentRoute);
- if (device != null && !mBluetoothRouteManager.isInbandRingEnabled(device)) {
+ if (device != null && !mBluetoothRouteManager
+ .isInbandRingEnabled(mCurrentRoute.getType(), device)) {
routeTo(false, mCurrentRoute);
}
}
@@ -1002,8 +1004,9 @@
if (bluetoothRoute != null && bluetoothDevice != null) {
if (mFocusType == RINGING_FOCUS) {
- routeTo(mBluetoothRouteManager.isInbandRingEnabled(bluetoothDevice) && mIsActive,
- bluetoothRoute);
+ routeTo(mBluetoothRouteManager
+ .isInbandRingEnabled(bluetoothRoute.getType(), bluetoothDevice)
+ && mIsActive, bluetoothRoute);
mBluetoothAddressForRinging = bluetoothDevice.getAddress();
} else {
routeTo(mIsActive, bluetoothRoute);
diff --git a/src/com/android/server/telecom/CallsManager.java b/src/com/android/server/telecom/CallsManager.java
index abcdd18..3c10f4e 100644
--- a/src/com/android/server/telecom/CallsManager.java
+++ b/src/com/android/server/telecom/CallsManager.java
@@ -1828,6 +1828,24 @@
} else {
notifyCreateConnectionFailed(phoneAccountHandle, call);
}
+ } else if (mFeatureFlags.enableCallSequencing() && (hasMaximumManagedRingingCalls(call)
+ || hasMaximumManagedDialingCalls(call))) {
+ // Fail incoming call if there's already a ringing or dialing call present.
+ boolean maxRinging = hasMaximumManagedRingingCalls(call);
+ if (maxRinging) {
+ call.setMissedReason(AUTO_MISSED_MAXIMUM_RINGING);
+ call.setStartFailCause(CallFailureCause.MAX_RINGING_CALLS);
+ } else {
+ call.setMissedReason(AUTO_MISSED_MAXIMUM_DIALING);
+ }
+ call.getAnalytics().setMissedReason(call.getMissedReason());
+ mCallLogManager.logCall(call, Calls.MISSED_TYPE,
+ true /*showNotificationForMissedCall*/, null /*CallFilteringResult*/);
+ if (isConference) {
+ notifyCreateConferenceFailed(phoneAccountHandle, call);
+ } else {
+ notifyCreateConnectionFailed(phoneAccountHandle, call);
+ }
} else if (call.isTransactionalCall()) {
// transactional calls should skip Call#startCreateConnection below
// as that is meant for Call objects with a ConnectionServiceWrapper
@@ -3544,6 +3562,9 @@
*/
public void disconnectCallOld(Call call, int previousState) {
call.disconnect();
+ for (CallsManagerListener listener : mListeners) {
+ listener.onCallStateChanged(call, previousState, call.getState());
+ }
processDisconnectCallAndCleanup(call, previousState);
}
@@ -3554,9 +3575,6 @@
* @param previousState The previous call state before the call is disconnected.
*/
public void processDisconnectCallAndCleanup(Call call, int previousState) {
- for (CallsManagerListener listener : mListeners) {
- listener.onCallStateChanged(call, previousState, call.getState());
- }
// Cancel any of the outgoing call futures if they're still around.
if (mPendingCallConfirm != null && !mPendingCallConfirm.isDone()) {
mPendingCallConfirm.complete(null);
diff --git a/src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java b/src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java
index 64c7f33..eda8c64 100644
--- a/src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java
+++ b/src/com/android/server/telecom/bluetooth/BluetoothDeviceManager.java
@@ -992,6 +992,34 @@
return isInbandRingEnabled(activeDevice);
}
+ /**
+ * Check if inband ringing is enabled for the specified BT device.
+ * This is intended for use by {@link CallAudioRouteController}.
+ * @param audioRouteType The BT device type.
+ * @param bluetoothDevice The BT device.
+ * @return {@code true} if inband ringing is enabled, {@code false} otherwise.
+ */
+ public boolean isInbandRingEnabled(@AudioRoute.AudioRouteType int audioRouteType,
+ BluetoothDevice bluetoothDevice) {
+ if (audioRouteType == AudioRoute.TYPE_BLUETOOTH_LE) {
+ if (mBluetoothLeAudioService == null) {
+ Log.i(this, "isInbandRingingEnabled: no leaudio service available.");
+ return false;
+ }
+ int groupId = mBluetoothLeAudioService.getGroupId(bluetoothDevice);
+ return mBluetoothLeAudioService.isInbandRingtoneEnabled(groupId);
+ } else {
+ if (getBluetoothHeadset() == null) {
+ Log.i(this, "isInbandRingingEnabled: no headset service available.");
+ return false;
+ }
+ boolean isEnabled = mBluetoothHeadset.isInbandRingingEnabled();
+ Log.i(this, "isInbandRingEnabled: device: %s, isEnabled: %b", bluetoothDevice,
+ isEnabled);
+ return isEnabled;
+ }
+ }
+
public boolean isInbandRingEnabled(BluetoothDevice bluetoothDevice) {
if (mBluetoothRouteManager.isCachedLeAudioDevice(bluetoothDevice)) {
if (mBluetoothLeAudioService == null) {
diff --git a/src/com/android/server/telecom/bluetooth/BluetoothRouteManager.java b/src/com/android/server/telecom/bluetooth/BluetoothRouteManager.java
index 6e9af8a..93dbed6 100644
--- a/src/com/android/server/telecom/bluetooth/BluetoothRouteManager.java
+++ b/src/com/android/server/telecom/bluetooth/BluetoothRouteManager.java
@@ -37,6 +37,7 @@
import com.android.internal.util.IState;
import com.android.internal.util.State;
import com.android.internal.util.StateMachine;
+import com.android.server.telecom.AudioRoute;
import com.android.server.telecom.CallAudioCommunicationDeviceTracker;
import com.android.server.telecom.TelecomSystem;
import com.android.server.telecom.Timeouts;
@@ -1180,6 +1181,11 @@
return mDeviceManager.isInbandRingEnabled(bluetoothDevice);
}
+ public boolean isInbandRingEnabled(@AudioRoute.AudioRouteType int audioRouteType,
+ BluetoothDevice bluetoothDevice) {
+ return mDeviceManager.isInbandRingEnabled(audioRouteType, bluetoothDevice);
+ }
+
private boolean addDevice(String address) {
if (mAudioConnectingStates.containsKey(address)) {
Log.i(this, "Attempting to add device %s twice.", address);
diff --git a/tests/src/com/android/server/telecom/tests/CallAudioRouteControllerTest.java b/tests/src/com/android/server/telecom/tests/CallAudioRouteControllerTest.java
index 19b08c6..b0b1d4e 100644
--- a/tests/src/com/android/server/telecom/tests/CallAudioRouteControllerTest.java
+++ b/tests/src/com/android/server/telecom/tests/CallAudioRouteControllerTest.java
@@ -409,7 +409,8 @@
@SmallTest
@Test
public void testSwitchFocusForBluetoothDeviceSupportInbandRinging() {
- when(mBluetoothRouteManager.isInbandRingEnabled(eq(BLUETOOTH_DEVICE_1))).thenReturn(true);
+ when(mBluetoothRouteManager.isInbandRingEnabled(eq(AudioRoute.TYPE_BLUETOOTH_SCO),
+ eq(BLUETOOTH_DEVICE_1))).thenReturn(true);
mController.initialize();
mController.sendMessageWithSessionInfo(BT_DEVICE_ADDED, AudioRoute.TYPE_BLUETOOTH_SCO,
@@ -932,7 +933,8 @@
public void testRouteFromBtSwitchInRingingSelected() {
when(mFeatureFlags.ignoreAutoRouteToWatchDevice()).thenReturn(true);
when(mBluetoothRouteManager.isWatch(any(BluetoothDevice.class))).thenReturn(true);
- when(mBluetoothRouteManager.isInbandRingEnabled(eq(BLUETOOTH_DEVICE_1))).thenReturn(false);
+ when(mBluetoothRouteManager.isInbandRingEnabled(eq(AudioRoute.TYPE_BLUETOOTH_SCO),
+ eq(BLUETOOTH_DEVICE_1))).thenReturn(false);
mController.initialize();
mController.sendMessageWithSessionInfo(BT_DEVICE_ADDED, AudioRoute.TYPE_BLUETOOTH_SCO,
@@ -1261,7 +1263,8 @@
@SmallTest
public void testAbandonCallAudioFocusAfterCallEnd() {
// Make sure in-band ringing is disabled so that route never becomes active
- when(mBluetoothRouteManager.isInbandRingEnabled(eq(BLUETOOTH_DEVICE_1))).thenReturn(false);
+ when(mBluetoothRouteManager.isInbandRingEnabled(eq(AudioRoute.TYPE_BLUETOOTH_SCO),
+ eq(BLUETOOTH_DEVICE_1))).thenReturn(false);
mController.initialize();
mController.sendMessageWithSessionInfo(BT_DEVICE_ADDED, AudioRoute.TYPE_BLUETOOTH_SCO,