diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2022-03-14 08:05:35 -0700 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2022-03-14 08:05:35 -0700 |
commit | 9a7b5a5c31a5c47b51bd6e45dea11ddc6c282bd0 (patch) | |
tree | 927ca5ed11217d94b9252fed5863b5e7d6cc6b9c | |
parent | eca69592755cd9d5714fa77ffca25e2a37a7334f (diff) | |
parent | b942c1fda135b29dc8673c08024307eb8558684c (diff) |
Merge b942c1fda135b29dc8673c08024307eb8558684c on remote branch
Change-Id: If73c1c0315dc24fd3a4ef7e5dd9a4643d1e413da
6 files changed, 186 insertions, 47 deletions
diff --git a/src/com/android/bluetooth/btservice/AdapterService.java b/src/com/android/bluetooth/btservice/AdapterService.java index 24c672eec..8a0cdc9f6 100644 --- a/src/com/android/bluetooth/btservice/AdapterService.java +++ b/src/com/android/bluetooth/btservice/AdapterService.java @@ -1159,7 +1159,7 @@ public class AdapterService extends Service { ParcelUuid.fromString("00006AD5-0000-1000-8000-00805F9B34FB"); ParcelUuid ADV_AUDIO_G_MEDIA = - ParcelUuid.fromString("00006AD3-0000-1000-8000-00805F9B34FB"); + ParcelUuid.fromString("12994B7E-6d47-4215-8C9E-AAE9A1095BA3"); ParcelUuid ADV_AUDIO_W_MEDIA = ParcelUuid.fromString("2587db3c-ce70-4fc9-935f-777ab4188fd7"); diff --git a/src/com/android/bluetooth/btservice/PhonePolicy.java b/src/com/android/bluetooth/btservice/PhonePolicy.java index d9b2a6eff..73d40ed4a 100644 --- a/src/com/android/bluetooth/btservice/PhonePolicy.java +++ b/src/com/android/bluetooth/btservice/PhonePolicy.java @@ -339,7 +339,7 @@ class PhonePolicy { ParcelUuid.fromString("00006AD5-0000-1000-8000-00805F9B34FB"); ParcelUuid ADV_AUDIO_G_MEDIA = - ParcelUuid.fromString("00006AD3-0000-1000-8000-00805F9B34FB"); + ParcelUuid.fromString("12994B7E-6d47-4215-8C9E-AAE9A1095BA3"); ParcelUuid ADV_AUDIO_W_MEDIA = ParcelUuid.fromString("2587db3c-ce70-4fc9-935f-777ab4188fd7"); diff --git a/src/com/android/bluetooth/hfp/HeadsetService.java b/src/com/android/bluetooth/hfp/HeadsetService.java index 177a0c955..9f71b9069 100644 --- a/src/com/android/bluetooth/hfp/HeadsetService.java +++ b/src/com/android/bluetooth/hfp/HeadsetService.java @@ -998,11 +998,6 @@ public class HeadsetService extends ProfileService { @Override public void phoneStateChanged(int numActive, int numHeld, int callState, String number, int type, String name, AttributionSource source) { - HeadsetService service = getService(source); - if (service == null) { - return; - } - service.phoneStateChanged(numActive, numHeld, callState, number, type, name, false); if (ApmConstIntf.getLeAudioEnabled()) { Log.d(TAG, "Adv Audio enabled: phoneStateChanged"); CallControlIntf mCallControl = CallControlIntf.get(); @@ -1019,11 +1014,6 @@ public class HeadsetService extends ProfileService { CallControlIntf mCallControl = CallControlIntf.get(); mCallControl.clccResponse(index, direction, status, mode, mpty, number, type); } - HeadsetService service = getService(source); - if (service == null) { - return; - } - service.clccResponse(index, direction, status, mode, mpty, number, type); } @Override @@ -1071,24 +1061,25 @@ public class HeadsetService extends ProfileService { return service.isInbandRingingEnabled(); } + @Override public void phoneStateChangedDsDa(int numActive, int numHeld, int callState, String number, int type, String name, AttributionSource source) { - HeadsetService service = getService(source); - if (service == null) { - return; - } - service.phoneStateChanged(numActive, numHeld, callState, number, type, name, false); - } - - public void clccResponseDsDa(int index, int direction, int status, int mode, boolean mpty, - String number, int type, AttributionSource source) { + HeadsetService service = getService(source); + if (service == null) { + return; + } + service.phoneStateChanged(numActive, numHeld, callState, number, type, name, false); + } - HeadsetService service = getService(source); - if (service == null) { - return; - } - service.clccResponse(index, direction, status, mode, mpty, number, type); - } + @Override + public void clccResponseDsDa(int index, int direction, int status, int mode, boolean mpty, + String number, int type, AttributionSource source) { + HeadsetService service = getService(source); + if (service == null) { + return; + } + service.clccResponse(index, direction, status, mode, mpty, number, type); + } } // API methods @@ -1824,8 +1815,9 @@ public class HeadsetService extends ProfileService { ActiveDeviceManagerServiceIntf.get(); /*Precautionary Change: Force Active Device Manager * to always return false as same as Media Audio*/ - return mActiveDeviceManager.setActiveDevice(device, + mActiveDeviceManager.setActiveDevice(device, ApmConstIntf.AudioFeatures.CALL_AUDIO, false); + return true; } else { int ret = setActiveDeviceHF(device); if (ret == ActiveDeviceManagerServiceIntf.SHO_FAILED) { diff --git a/src/com/android/bluetooth/hfp/HeadsetStateMachine.java b/src/com/android/bluetooth/hfp/HeadsetStateMachine.java index 2b016a458..c3fc03c12 100644 --- a/src/com/android/bluetooth/hfp/HeadsetStateMachine.java +++ b/src/com/android/bluetooth/hfp/HeadsetStateMachine.java @@ -13,6 +13,40 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* Changes from Qualcomm Innovation Center are provided under the following license: + * + * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted (subject to the limitations in the + * disclaimer below) provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE + * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT + * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE + */ package com.android.bluetooth.hfp; @@ -912,11 +946,11 @@ public class HeadsetStateMachine extends StateMachine { break; case HeadsetStackEvent.EVENT_TYPE_ANSWER_CALL: stateLogW("Unexpected answer event for " + event.device); - mSystemInterface.answerCall(event.device); + mSystemInterface.answerCall(event.device, ApmConstIntf.AudioProfiles.HFP); break; case HeadsetStackEvent.EVENT_TYPE_HANGUP_CALL: stateLogW("Unexpected hangup event for " + event.device); - mSystemInterface.hangupCall(event.device); + mSystemInterface.hangupCall(event.device, ApmConstIntf.AudioProfiles.HFP); break; case HeadsetStackEvent.EVENT_TYPE_SWB: processSWBEvent(event.valueInt); @@ -1288,10 +1322,10 @@ public class HeadsetStateMachine extends StateMachine { processVrEvent(event.valueInt); break; case HeadsetStackEvent.EVENT_TYPE_ANSWER_CALL: - mSystemInterface.answerCall(event.device); + mSystemInterface.answerCall(event.device, ApmConstIntf.AudioProfiles.HFP); break; case HeadsetStackEvent.EVENT_TYPE_HANGUP_CALL: - mSystemInterface.hangupCall(event.device); + mSystemInterface.hangupCall(event.device, ApmConstIntf.AudioProfiles.HFP); break; case HeadsetStackEvent.EVENT_TYPE_VOLUME_CHANGED: processVolumeEvent(event.valueInt, event.valueInt2); @@ -2533,7 +2567,7 @@ public class HeadsetStateMachine extends StateMachine { @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) private void processAtChld(int chld, BluetoothDevice device) { - if (mSystemInterface.processChld(chld)) { + if (mSystemInterface.processChld(chld, ApmConstIntf.AudioProfiles.HFP)) { mNativeInterface.atResponseCode(device, HeadsetHalConstants.AT_RESPONSE_OK, 0); } else { mNativeInterface.atResponseCode(device, HeadsetHalConstants.AT_RESPONSE_ERROR, 0); @@ -2632,7 +2666,7 @@ public class HeadsetStateMachine extends StateMachine { mNativeInterface.clccResponse(device, 0, 0, 0, 0, false, "", 0); } else { // In Telecom call, ask Telecom to send send remote phone number - if (!mSystemInterface.listCurrentCalls()) { + if (!mSystemInterface.listCurrentCalls(ApmConstIntf.AudioProfiles.HFP)) { Log.e(TAG, "processAtClcc: failed to list current calls for " + device); mNativeInterface.clccResponse(device, 0, 0, 0, 0, false, "", 0); } else { @@ -2817,7 +2851,7 @@ public class HeadsetStateMachine extends StateMachine { @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) private void processKeyPressed(BluetoothDevice device) { if (mSystemInterface.isRinging()) { - mSystemInterface.answerCall(device); + mSystemInterface.answerCall(device, ApmConstIntf.AudioProfiles.HFP); } else if (getAudioState() != BluetoothHeadset.STATE_AUDIO_DISCONNECTED) { if (!mNativeInterface.disconnectAudio(mDevice)) { Log.w(TAG, "processKeyPressed, failed to disconnect audio from " + mDevice); diff --git a/src/com/android/bluetooth/hfp/HeadsetSystemInterface.java b/src/com/android/bluetooth/hfp/HeadsetSystemInterface.java index 548bed038..d84418dcb 100644 --- a/src/com/android/bluetooth/hfp/HeadsetSystemInterface.java +++ b/src/com/android/bluetooth/hfp/HeadsetSystemInterface.java @@ -13,6 +13,40 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* Changes from Qualcomm Innovation Center are provided under the following license: + * + * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted (subject to the limitations in the + * disclaimer below) provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE + * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT + * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE + */ package com.android.bluetooth.hfp; @@ -165,7 +199,7 @@ public class HeadsetSystemInterface { */ @VisibleForTesting @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) - public void answerCall(BluetoothDevice device) { + public void answerCall(BluetoothDevice device, int profile) { if (device == null) { Log.w(TAG, "answerCall device is null"); return; @@ -181,7 +215,7 @@ public class HeadsetSystemInterface { Log.e(TAG, "Thread sleep ", e); } } - bluetoothInCallService.answerCall(); + bluetoothInCallService.answerCall(profile); } else { Log.e(TAG, "Handsfree phone proxy null for answering call"); } @@ -194,7 +228,7 @@ public class HeadsetSystemInterface { */ @VisibleForTesting @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) - public void hangupCall(BluetoothDevice device) { + public void hangupCall(BluetoothDevice device, int profile) { if (device == null) { Log.w(TAG, "hangupCall device is null"); return; @@ -214,7 +248,7 @@ public class HeadsetSystemInterface { } else { BluetoothInCallService bluetoothInCallService = getBluetoothInCallServiceInstance(); if (bluetoothInCallService != null) { - bluetoothInCallService.hangupCall(); + bluetoothInCallService.hangupCall(profile); } else { Log.e(TAG, "Handsfree phone proxy null for hanging up call"); } @@ -283,10 +317,10 @@ public class HeadsetSystemInterface { */ @VisibleForTesting @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) - public boolean processChld(int chld) { + public boolean processChld(int chld, int profile) { BluetoothInCallService bluetoothInCallService = getBluetoothInCallServiceInstance(); if (bluetoothInCallService != null) { - return bluetoothInCallService.processChld(chld); + return bluetoothInCallService.processChld(chld, profile); } else { Log.e(TAG, "processChld: bluetoothInCallService proxy null"); } @@ -386,13 +420,13 @@ public class HeadsetSystemInterface { */ @VisibleForTesting @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) - public boolean listCurrentCalls() { + public boolean listCurrentCalls(int profile) { BluetoothInCallService bluetoothInCallService = getBluetoothInCallServiceInstance(); if (bluetoothInCallService == null) { Log.e(TAG, "listCurrentCalls() failed: mBluetoothInCallService is null"); return false; } - return bluetoothInCallService.listCurrentCalls(); + return bluetoothInCallService.listCurrentCalls(profile); } /** diff --git a/src/com/android/bluetooth/telephony/BluetoothInCallService.java b/src/com/android/bluetooth/telephony/BluetoothInCallService.java index 9ed9f6879..1dff2104a 100644 --- a/src/com/android/bluetooth/telephony/BluetoothInCallService.java +++ b/src/com/android/bluetooth/telephony/BluetoothInCallService.java @@ -13,9 +13,45 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/* Changes from Qualcomm Innovation Center are provided under the following license: + * + * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted (subject to the limitations in the + * disclaimer below) provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE + * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT + * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE + */ package com.android.bluetooth.telephony; +import static android.Manifest.permission.BLUETOOTH_CONNECT; + import android.annotation.RequiresPermission; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothHeadset; @@ -31,6 +67,7 @@ import android.net.Uri; import android.os.Binder; import android.os.IBinder; import android.os.Bundle; +import android.os.UserHandle; import android.telecom.Call; import android.telecom.CallAudioState; import android.telecom.Connection; @@ -46,6 +83,8 @@ import android.util.Log; import com.android.bluetooth.hfp.BluetoothHeadsetProxy; import com.android.bluetooth.hfp.HeadsetService; +import com.android.bluetooth.apm.ApmConstIntf; + import androidx.annotation.VisibleForTesting; import com.android.internal.telephony.PhoneConstants; @@ -112,6 +151,15 @@ public class BluetoothInCallService extends InCallService { private int mAudioMode = AudioManager.MODE_INVALID; private final Object mAudioModeLock = new Object(); + public static final String ACTION_DSDA_CALL_STATE_CHANGE = + "android.bluetooth.dsda.action.DSDA_CALL_STATE_CHANGED"; + + public static final int ANSWER_CALL = 1; + public static final int HANGUP_CALL = 2; + public static final int PROCESS_CHLD= 3; + public static final int HELD_CALL = 4; + public static final int LIST_CLCC = 5; + @VisibleForTesting public AudioManager mAudioManager; @@ -369,7 +417,15 @@ public class BluetoothInCallService extends InCallService { } @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) - public boolean answerCall() { + public boolean answerCall(int profile) { + Log.d(TAG, "answer received"); + if (ApmConstIntf.AudioProfiles.HFP == profile) { + Log.d(TAG, "answercall: hfp"); + Intent DsdaIntent = new Intent(ACTION_DSDA_CALL_STATE_CHANGE); + DsdaIntent.putExtra("state", ANSWER_CALL); + sendBroadcastAsUser(DsdaIntent, UserHandle.ALL, BLUETOOTH_CONNECT); + return true; + } synchronized (LOCK) { enforceModifyPermission(); Log.i(TAG, "BT - answering call"); @@ -383,7 +439,14 @@ public class BluetoothInCallService extends InCallService { } @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) - public boolean hangupCall() { + public boolean hangupCall(int profile) { + if (ApmConstIntf.AudioProfiles.HFP == profile) { + Log.d(TAG, "hangup call: hfp"); + Intent DsdaIntent = new Intent(ACTION_DSDA_CALL_STATE_CHANGE); + DsdaIntent.putExtra("state", HANGUP_CALL); + sendBroadcastAsUser(DsdaIntent, UserHandle.ALL, BLUETOOTH_CONNECT); + return true; + } synchronized (LOCK) { enforceModifyPermission(); Log.i(TAG, "BT - hanging up call"); @@ -507,7 +570,15 @@ public class BluetoothInCallService extends InCallService { } @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) - public boolean listCurrentCalls() { + public boolean listCurrentCalls(int profile) { + if (ApmConstIntf.AudioProfiles.HFP == profile) { + Log.d(TAG, "listCurrentCalls: hfp"); + Intent DsdaIntent = new Intent(ACTION_DSDA_CALL_STATE_CHANGE); + DsdaIntent.putExtra("state", LIST_CLCC); + sendBroadcastAsUser(DsdaIntent, UserHandle.ALL, BLUETOOTH_CONNECT); + return true; + } + synchronized (LOCK) { enforceModifyPermission(); // only log if it is after we recently updated the headset state or else it can @@ -582,7 +653,15 @@ public class BluetoothInCallService extends InCallService { } @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) - public boolean processChld(int chld) { + public boolean processChld(int chld, int profile) { + if (ApmConstIntf.AudioProfiles.HFP == profile) { + Log.d(TAG, "processChld: hfp"); + Intent DsdaIntent = new Intent(ACTION_DSDA_CALL_STATE_CHANGE); + DsdaIntent.putExtra("state", PROCESS_CHLD); + DsdaIntent.putExtra("chld", chld); + sendBroadcastAsUser(DsdaIntent, UserHandle.ALL, BLUETOOTH_CONNECT); + return true; + } synchronized (LOCK) { enforceModifyPermission(); long token = Binder.clearCallingIdentity(); |