Merge "Migrate Telecom tests to JUnit4"
diff --git a/src/com/android/server/telecom/BluetoothHeadsetProxy.java b/src/com/android/server/telecom/BluetoothHeadsetProxy.java
index 7edcdad..c5afafe 100644
--- a/src/com/android/server/telecom/BluetoothHeadsetProxy.java
+++ b/src/com/android/server/telecom/BluetoothHeadsetProxy.java
@@ -68,4 +68,8 @@
public boolean disconnectAudio() {
return mBluetoothHeadset.disconnectAudio();
}
+
+ public boolean isInbandRingingEnabled() {
+ return mBluetoothHeadset.isInbandRingingEnabled();
+ }
}
\ No newline at end of file
diff --git a/src/com/android/server/telecom/CallAudioRouteStateMachine.java b/src/com/android/server/telecom/CallAudioRouteStateMachine.java
index 23e5e69..ef65d8b 100644
--- a/src/com/android/server/telecom/CallAudioRouteStateMachine.java
+++ b/src/com/android/server/telecom/CallAudioRouteStateMachine.java
@@ -19,7 +19,6 @@
import android.app.ActivityManager;
import android.bluetooth.BluetoothDevice;
-import android.bluetooth.BluetoothHeadset;
import android.content.Context;
import android.content.pm.UserInfo;
import android.media.AudioDeviceInfo;
@@ -371,7 +370,8 @@
case SWITCH_BLUETOOTH:
case USER_SWITCH_BLUETOOTH:
if ((mAvailableRoutes & ROUTE_BLUETOOTH) != 0) {
- if (mAudioFocusType == ACTIVE_FOCUS || mIsInbandRingSupported) {
+ if (mAudioFocusType == ACTIVE_FOCUS
+ || mBluetoothRouteManager.isInbandRingingEnabled()) {
String address = (msg.obj instanceof SomeArgs) ?
(String) ((SomeArgs) msg.obj).arg2 : null;
// Omit transition to ActiveBluetoothRoute
@@ -568,7 +568,8 @@
case SWITCH_BLUETOOTH:
case USER_SWITCH_BLUETOOTH:
if ((mAvailableRoutes & ROUTE_BLUETOOTH) != 0) {
- if (mAudioFocusType == ACTIVE_FOCUS || mIsInbandRingSupported) {
+ if (mAudioFocusType == ACTIVE_FOCUS
+ || mBluetoothRouteManager.isInbandRingingEnabled()) {
String address = (msg.obj instanceof SomeArgs) ?
(String) ((SomeArgs) msg.obj).arg2 : null;
// Omit transition to ActiveBluetoothRoute until actual connection.
@@ -793,7 +794,8 @@
if (msg.arg1 == NO_FOCUS) {
setBluetoothOff();
reinitialize();
- } else if (msg.arg1 == RINGING_FOCUS && !mIsInbandRingSupported) {
+ } else if (msg.arg1 == RINGING_FOCUS
+ && !mBluetoothRouteManager.isInbandRingingEnabled()) {
setBluetoothOff();
transitionTo(mRingingBluetoothRoute);
}
@@ -954,7 +956,7 @@
if (msg.arg1 == ACTIVE_FOCUS) {
setBluetoothOn(null);
} else if (msg.arg1 == RINGING_FOCUS) {
- if (mIsInbandRingSupported) {
+ if (mBluetoothRouteManager.isInbandRingingEnabled()) {
setBluetoothOn(null);
} else {
transitionTo(mRingingBluetoothRoute);
@@ -1065,7 +1067,8 @@
String address = (msg.obj instanceof SomeArgs) ?
(String) ((SomeArgs) msg.obj).arg2 : null;
if ((mAvailableRoutes & ROUTE_BLUETOOTH) != 0) {
- if (mAudioFocusType == ACTIVE_FOCUS || mIsInbandRingSupported) {
+ if (mAudioFocusType == ACTIVE_FOCUS
+ || mBluetoothRouteManager.isInbandRingingEnabled()) {
// Omit transition to ActiveBluetoothRoute
setBluetoothOn(address);
} else {
@@ -1257,8 +1260,6 @@
private CallAudioState mCurrentCallAudioState;
private CallAudioState mLastKnownCallAudioState;
- private final boolean mIsInbandRingSupported;
-
public CallAudioRouteStateMachine(
Context context,
CallsManager callsManager,
@@ -1295,7 +1296,6 @@
default:
mDoesDeviceSupportEarpieceRoute = checkForEarpieceSupport();
}
- mIsInbandRingSupported = BluetoothHeadset.isInbandRingingSupported(mContext);
mLock = callsManager.getLock();
mStateNameToRouteCode = new HashMap<>(8);
diff --git a/src/com/android/server/telecom/LogUtils.java b/src/com/android/server/telecom/LogUtils.java
index 0411355..13ffacd 100644
--- a/src/com/android/server/telecom/LogUtils.java
+++ b/src/com/android/server/telecom/LogUtils.java
@@ -190,7 +190,6 @@
public static void initLogging(Context context) {
android.telecom.Log.setTag(TAG);
android.telecom.Log.setSessionContext(context);
- android.telecom.Log.initMd5Sum();
for (EventManager.TimedEventPair p : Events.Timings.sTimedEvents) {
android.telecom.Log.addRequestResponsePair(p);
}
diff --git a/src/com/android/server/telecom/bluetooth/BluetoothRouteManager.java b/src/com/android/server/telecom/bluetooth/BluetoothRouteManager.java
index f6dfc8a..2a4d6af 100644
--- a/src/com/android/server/telecom/bluetooth/BluetoothRouteManager.java
+++ b/src/com/android/server/telecom/bluetooth/BluetoothRouteManager.java
@@ -734,6 +734,22 @@
return null;
}
+ /**
+ * Check if in-band ringing is currently enabled. In-band ringing could be disabled during an
+ * active connection.
+ *
+ * @return true if in-band ringing is enabled, false if in-band ringing is disabled
+ */
+ @VisibleForTesting
+ public boolean isInbandRingingEnabled() {
+ BluetoothHeadsetProxy bluetoothHeadset = mDeviceManager.getHeadsetService();
+ if (bluetoothHeadset == null) {
+ Log.i(this, "isInbandRingingEnabled: no headset service available.");
+ return false;
+ }
+ return bluetoothHeadset.isInbandRingingEnabled();
+ }
+
private boolean connectAudio(String address) {
BluetoothHeadsetProxy bluetoothHeadset = mDeviceManager.getHeadsetService();
if (bluetoothHeadset == null) {
diff --git a/tests/src/com/android/server/telecom/tests/CallAudioRouteStateMachineTest.java b/tests/src/com/android/server/telecom/tests/CallAudioRouteStateMachineTest.java
index 9f8fa7c..4f91df0 100644
--- a/tests/src/com/android/server/telecom/tests/CallAudioRouteStateMachineTest.java
+++ b/tests/src/com/android/server/telecom/tests/CallAudioRouteStateMachineTest.java
@@ -1190,9 +1190,7 @@
}
private void setInBandRing(boolean enabled) {
- mComponentContextFixture.putBooleanResource(
- com.android.internal.R.bool.config_bluetooth_hfp_inband_ringing_support,
- enabled);
+ when(mockBluetoothRouteManager.isInbandRingingEnabled()).thenReturn(enabled);
}
private void resetMocks() {