Merge "Make BluetoothHeadset APIs used by Telecom into System APIs" am: c3c651dd07 am: 9a9f985fd2
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1932883 Change-Id: Ia2abdf8e49958e089c9ee15816512ae87940b2eb
This commit is contained in:
@@ -274,6 +274,7 @@ applications that come with the platform
|
|||||||
<privapp-permissions package="com.android.server.telecom">
|
<privapp-permissions package="com.android.server.telecom">
|
||||||
<permission name="android.permission.BIND_CONNECTION_SERVICE"/>
|
<permission name="android.permission.BIND_CONNECTION_SERVICE"/>
|
||||||
<permission name="android.permission.BIND_INCALL_SERVICE"/>
|
<permission name="android.permission.BIND_INCALL_SERVICE"/>
|
||||||
|
<permission name="android.permission.BLUETOOTH_PRIVILEGED"/>
|
||||||
<permission name="android.permission.CALL_PRIVILEGED"/>
|
<permission name="android.permission.CALL_PRIVILEGED"/>
|
||||||
<permission name="android.permission.HANDLE_CAR_MODE_CHANGES"/>
|
<permission name="android.permission.HANDLE_CAR_MODE_CHANGES"/>
|
||||||
<permission name="android.permission.INTERACT_ACROSS_USERS"/>
|
<permission name="android.permission.INTERACT_ACROSS_USERS"/>
|
||||||
|
|||||||
@@ -140,13 +140,6 @@ public class HeadsetProfile implements LocalBluetoothProfile {
|
|||||||
return (activeDevices.size() > 0) ? activeDevices.get(0) : null;
|
return (activeDevices.size() > 0) ? activeDevices.get(0) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAudioOn() {
|
|
||||||
if (mService == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return mService.isAudioOn();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getAudioState(BluetoothDevice device) {
|
public int getAudioState(BluetoothDevice device) {
|
||||||
if (mService == null) {
|
if (mService == null) {
|
||||||
return BluetoothHeadset.STATE_AUDIO_DISCONNECTED;
|
return BluetoothHeadset.STATE_AUDIO_DISCONNECTED;
|
||||||
|
|||||||
@@ -54,15 +54,6 @@ public class HeadsetProfileTest {
|
|||||||
mServiceListener.onServiceConnected(BluetoothProfile.HEADSET, mService);
|
mServiceListener.onServiceConnected(BluetoothProfile.HEADSET, mService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void bluetoothProfile_shouldReturnTheAudioStatusFromBlueToothHeadsetService() {
|
|
||||||
when(mService.isAudioOn()).thenReturn(true);
|
|
||||||
assertThat(mProfile.isAudioOn()).isTrue();
|
|
||||||
|
|
||||||
when(mService.isAudioOn()).thenReturn(false);
|
|
||||||
assertThat(mProfile.isAudioOn()).isFalse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testHeadsetProfile_shouldReturnAudioState() {
|
public void testHeadsetProfile_shouldReturnAudioState() {
|
||||||
when(mService.getAudioState(mBluetoothDevice)).
|
when(mService.getAudioState(mBluetoothDevice)).
|
||||||
|
|||||||
@@ -102,8 +102,6 @@ public class BtHelper {
|
|||||||
/*package*/ static final int SCO_MODE_UNDEFINED = -1;
|
/*package*/ static final int SCO_MODE_UNDEFINED = -1;
|
||||||
// SCO audio mode is virtual voice call (BluetoothHeadset.startScoUsingVirtualVoiceCall())
|
// SCO audio mode is virtual voice call (BluetoothHeadset.startScoUsingVirtualVoiceCall())
|
||||||
/*package*/ static final int SCO_MODE_VIRTUAL_CALL = 0;
|
/*package*/ static final int SCO_MODE_VIRTUAL_CALL = 0;
|
||||||
// SCO audio mode is raw audio (BluetoothHeadset.connectAudio())
|
|
||||||
private static final int SCO_MODE_RAW = 1;
|
|
||||||
// SCO audio mode is Voice Recognition (BluetoothHeadset.startVoiceRecognition())
|
// SCO audio mode is Voice Recognition (BluetoothHeadset.startVoiceRecognition())
|
||||||
private static final int SCO_MODE_VR = 2;
|
private static final int SCO_MODE_VR = 2;
|
||||||
// max valid SCO audio mode values
|
// max valid SCO audio mode values
|
||||||
@@ -122,8 +120,6 @@ public class BtHelper {
|
|||||||
return "SCO_MODE_UNDEFINED";
|
return "SCO_MODE_UNDEFINED";
|
||||||
case SCO_MODE_VIRTUAL_CALL:
|
case SCO_MODE_VIRTUAL_CALL:
|
||||||
return "SCO_MODE_VIRTUAL_CALL";
|
return "SCO_MODE_VIRTUAL_CALL";
|
||||||
case SCO_MODE_RAW:
|
|
||||||
return "SCO_MODE_RAW";
|
|
||||||
case SCO_MODE_VR:
|
case SCO_MODE_VR:
|
||||||
return "SCO_MODE_VR";
|
return "SCO_MODE_VR";
|
||||||
default:
|
default:
|
||||||
@@ -814,8 +810,6 @@ public class BtHelper {
|
|||||||
private static boolean disconnectBluetoothScoAudioHelper(BluetoothHeadset bluetoothHeadset,
|
private static boolean disconnectBluetoothScoAudioHelper(BluetoothHeadset bluetoothHeadset,
|
||||||
BluetoothDevice device, int scoAudioMode) {
|
BluetoothDevice device, int scoAudioMode) {
|
||||||
switch (scoAudioMode) {
|
switch (scoAudioMode) {
|
||||||
case SCO_MODE_RAW:
|
|
||||||
return bluetoothHeadset.disconnectAudio();
|
|
||||||
case SCO_MODE_VIRTUAL_CALL:
|
case SCO_MODE_VIRTUAL_CALL:
|
||||||
return bluetoothHeadset.stopScoUsingVirtualVoiceCall();
|
return bluetoothHeadset.stopScoUsingVirtualVoiceCall();
|
||||||
case SCO_MODE_VR:
|
case SCO_MODE_VR:
|
||||||
@@ -828,8 +822,6 @@ public class BtHelper {
|
|||||||
private static boolean connectBluetoothScoAudioHelper(BluetoothHeadset bluetoothHeadset,
|
private static boolean connectBluetoothScoAudioHelper(BluetoothHeadset bluetoothHeadset,
|
||||||
BluetoothDevice device, int scoAudioMode) {
|
BluetoothDevice device, int scoAudioMode) {
|
||||||
switch (scoAudioMode) {
|
switch (scoAudioMode) {
|
||||||
case SCO_MODE_RAW:
|
|
||||||
return bluetoothHeadset.connectAudio();
|
|
||||||
case SCO_MODE_VIRTUAL_CALL:
|
case SCO_MODE_VIRTUAL_CALL:
|
||||||
return bluetoothHeadset.startScoUsingVirtualVoiceCall();
|
return bluetoothHeadset.startScoUsingVirtualVoiceCall();
|
||||||
case SCO_MODE_VR:
|
case SCO_MODE_VR:
|
||||||
|
|||||||
Reference in New Issue
Block a user