diff options
4 files changed, 45 insertions, 183 deletions
diff --git a/src/com/android/bluetooth/hfp/HeadsetService.java b/src/com/android/bluetooth/hfp/HeadsetService.java index 07cc888a8..b7852cd85 100644 --- a/src/com/android/bluetooth/hfp/HeadsetService.java +++ b/src/com/android/bluetooth/hfp/HeadsetService.java @@ -998,6 +998,11 @@ 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(); @@ -1014,6 +1019,11 @@ 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 @@ -1061,25 +1071,24 @@ 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); - } - - @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); - } + 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.clccResponse(index, direction, status, mode, mpty, number, type); + } } // API methods diff --git a/src/com/android/bluetooth/hfp/HeadsetStateMachine.java b/src/com/android/bluetooth/hfp/HeadsetStateMachine.java index 0b7feb53a..45da973a8 100644 --- a/src/com/android/bluetooth/hfp/HeadsetStateMachine.java +++ b/src/com/android/bluetooth/hfp/HeadsetStateMachine.java @@ -13,40 +13,6 @@ * 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; @@ -946,11 +912,11 @@ public class HeadsetStateMachine extends StateMachine { break; case HeadsetStackEvent.EVENT_TYPE_ANSWER_CALL: stateLogW("Unexpected answer event for " + event.device); - mSystemInterface.answerCall(event.device, ApmConstIntf.AudioProfiles.HFP); + mSystemInterface.answerCall(event.device); break; case HeadsetStackEvent.EVENT_TYPE_HANGUP_CALL: stateLogW("Unexpected hangup event for " + event.device); - mSystemInterface.hangupCall(event.device, ApmConstIntf.AudioProfiles.HFP); + mSystemInterface.hangupCall(event.device); break; case HeadsetStackEvent.EVENT_TYPE_SWB: processSWBEvent(event.valueInt); @@ -1322,10 +1288,10 @@ public class HeadsetStateMachine extends StateMachine { processVrEvent(event.valueInt); break; case HeadsetStackEvent.EVENT_TYPE_ANSWER_CALL: - mSystemInterface.answerCall(event.device, ApmConstIntf.AudioProfiles.HFP); + mSystemInterface.answerCall(event.device); break; case HeadsetStackEvent.EVENT_TYPE_HANGUP_CALL: - mSystemInterface.hangupCall(event.device, ApmConstIntf.AudioProfiles.HFP); + mSystemInterface.hangupCall(event.device); break; case HeadsetStackEvent.EVENT_TYPE_VOLUME_CHANGED: processVolumeEvent(event.valueInt, event.valueInt2); @@ -2568,7 +2534,7 @@ public class HeadsetStateMachine extends StateMachine { @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) private void processAtChld(int chld, BluetoothDevice device) { - if (mSystemInterface.processChld(chld, ApmConstIntf.AudioProfiles.HFP)) { + if (mSystemInterface.processChld(chld)) { mNativeInterface.atResponseCode(device, HeadsetHalConstants.AT_RESPONSE_OK, 0); } else { mNativeInterface.atResponseCode(device, HeadsetHalConstants.AT_RESPONSE_ERROR, 0); @@ -2667,7 +2633,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(ApmConstIntf.AudioProfiles.HFP)) { + if (!mSystemInterface.listCurrentCalls()) { Log.e(TAG, "processAtClcc: failed to list current calls for " + device); mNativeInterface.clccResponse(device, 0, 0, 0, 0, false, "", 0); } else { @@ -2852,7 +2818,7 @@ public class HeadsetStateMachine extends StateMachine { @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) private void processKeyPressed(BluetoothDevice device) { if (mSystemInterface.isRinging()) { - mSystemInterface.answerCall(device, ApmConstIntf.AudioProfiles.HFP); + mSystemInterface.answerCall(device); } 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 d84418dcb..548bed038 100644 --- a/src/com/android/bluetooth/hfp/HeadsetSystemInterface.java +++ b/src/com/android/bluetooth/hfp/HeadsetSystemInterface.java @@ -13,40 +13,6 @@ * 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; @@ -199,7 +165,7 @@ public class HeadsetSystemInterface { */ @VisibleForTesting @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) - public void answerCall(BluetoothDevice device, int profile) { + public void answerCall(BluetoothDevice device) { if (device == null) { Log.w(TAG, "answerCall device is null"); return; @@ -215,7 +181,7 @@ public class HeadsetSystemInterface { Log.e(TAG, "Thread sleep ", e); } } - bluetoothInCallService.answerCall(profile); + bluetoothInCallService.answerCall(); } else { Log.e(TAG, "Handsfree phone proxy null for answering call"); } @@ -228,7 +194,7 @@ public class HeadsetSystemInterface { */ @VisibleForTesting @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) - public void hangupCall(BluetoothDevice device, int profile) { + public void hangupCall(BluetoothDevice device) { if (device == null) { Log.w(TAG, "hangupCall device is null"); return; @@ -248,7 +214,7 @@ public class HeadsetSystemInterface { } else { BluetoothInCallService bluetoothInCallService = getBluetoothInCallServiceInstance(); if (bluetoothInCallService != null) { - bluetoothInCallService.hangupCall(profile); + bluetoothInCallService.hangupCall(); } else { Log.e(TAG, "Handsfree phone proxy null for hanging up call"); } @@ -317,10 +283,10 @@ public class HeadsetSystemInterface { */ @VisibleForTesting @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) - public boolean processChld(int chld, int profile) { + public boolean processChld(int chld) { BluetoothInCallService bluetoothInCallService = getBluetoothInCallServiceInstance(); if (bluetoothInCallService != null) { - return bluetoothInCallService.processChld(chld, profile); + return bluetoothInCallService.processChld(chld); } else { Log.e(TAG, "processChld: bluetoothInCallService proxy null"); } @@ -420,13 +386,13 @@ public class HeadsetSystemInterface { */ @VisibleForTesting @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) - public boolean listCurrentCalls(int profile) { + public boolean listCurrentCalls() { BluetoothInCallService bluetoothInCallService = getBluetoothInCallServiceInstance(); if (bluetoothInCallService == null) { Log.e(TAG, "listCurrentCalls() failed: mBluetoothInCallService is null"); return false; } - return bluetoothInCallService.listCurrentCalls(profile); + return bluetoothInCallService.listCurrentCalls(); } /** diff --git a/src/com/android/bluetooth/telephony/BluetoothInCallService.java b/src/com/android/bluetooth/telephony/BluetoothInCallService.java index 31fca6d5f..13c7ad357 100644 --- a/src/com/android/bluetooth/telephony/BluetoothInCallService.java +++ b/src/com/android/bluetooth/telephony/BluetoothInCallService.java @@ -13,45 +13,9 @@ * 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; @@ -67,7 +31,6 @@ 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; @@ -83,8 +46,6 @@ 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; @@ -151,15 +112,6 @@ 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; @@ -420,15 +372,7 @@ public class BluetoothInCallService extends InCallService { } @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) - 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; - } + public boolean answerCall() { synchronized (LOCK) { enforceModifyPermission(); Log.i(TAG, "BT - answering call"); @@ -442,14 +386,7 @@ public class BluetoothInCallService extends InCallService { } @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) - 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; - } + public boolean hangupCall() { synchronized (LOCK) { enforceModifyPermission(); Log.i(TAG, "BT - hanging up call"); @@ -573,15 +510,7 @@ public class BluetoothInCallService extends InCallService { } @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) - 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; - } - + public boolean listCurrentCalls() { synchronized (LOCK) { enforceModifyPermission(); // only log if it is after we recently updated the headset state or else it can @@ -656,15 +585,7 @@ public class BluetoothInCallService extends InCallService { } @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) - 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; - } + public boolean processChld(int chld) { synchronized (LOCK) { enforceModifyPermission(); long token = Binder.clearCallingIdentity(); |