diff options
author | phaneendra Reddy <quic_phaneend@quicinc.com> | 2021-12-26 07:02:28 +0530 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2022-02-08 23:20:22 -0800 |
commit | 473b15dd1514ed52966ba2f66ceda1c8f594d6ef (patch) | |
tree | 982eea623d79968ffa5933cb053ac1ac06f91985 | |
parent | fb1dcce4fb47faaf1ea5777d215b6fa1d87d1b8e (diff) |
DSDA related changes
Intent changes in IncallService for DSDA
and profile informatoin for remote events
is updated to incallservice to process
event path based on profile
Change-Id: Ib212098f4a9947186545dc1966a9fc2454605c62
3 files changed, 166 insertions, 19 deletions
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(); |