summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShashank Dash <quic_vendetta@quicinc.com>2022-05-31 14:45:30 +0530
committerShashank Dash <quic_vendetta@quicinc.com>2022-06-01 14:28:33 +0530
commit23bde9f0d28724807efd4534d13d9a23f5c47854 (patch)
tree7124090fed79c9958077527002c17698b1b99a2e
parent14267667ad4ddb5cda810d2f623b9d74ead25fd8 (diff)
Btservice/PhonePolicy: AutoConnect enablement in HeadsetService.
Apm/CallAudioIntf: AutoConnect Reflection Function. - PhonePolicy: Autoconnecting the HeadsetService by calling the autoConnect function in the CallAudioIntf. - CallAudioIntf: Autoconnect reflection function to handle autoconnect usecase. Change-Id: I4c8605db1e3bba879aad4c85b8dabd5e95877694
-rw-r--r--src/com/android/bluetooth/apm/CallAudioIntf.java22
-rw-r--r--src/com/android/bluetooth/btservice/PhonePolicy.java7
2 files changed, 28 insertions, 1 deletions
diff --git a/src/com/android/bluetooth/apm/CallAudioIntf.java b/src/com/android/bluetooth/apm/CallAudioIntf.java
index caa6c9660..6904e2c28 100644
--- a/src/com/android/bluetooth/apm/CallAudioIntf.java
+++ b/src/com/android/bluetooth/apm/CallAudioIntf.java
@@ -118,6 +118,28 @@ public class CallAudioIntf {
return false;
}
+ public boolean autoConnect(BluetoothDevice device) {
+ if(CallAudio == null)
+ return false;
+
+ Class[] arg = new Class[1];
+ arg[0] = BluetoothDevice.class;
+
+ try {
+ Method autoConnect = CallAudio.getDeclaredMethod("autoConnect", arg);
+ Boolean ret = (Boolean)autoConnect.invoke(mCallAudio, device);
+ return ret;
+ } catch(IllegalAccessException e) {
+ Log.i(TAG, "Exception" + e);
+ } catch(NoSuchMethodException e) {
+ Log.i(TAG, "Exception" + e);
+ } catch(InvocationTargetException e) {
+ Log.i(TAG, "Exception" + e);
+ }
+
+ return false;
+ }
+
public boolean disconnect(BluetoothDevice device) {
if(CallAudio == null)
return false;
diff --git a/src/com/android/bluetooth/btservice/PhonePolicy.java b/src/com/android/bluetooth/btservice/PhonePolicy.java
index 73d40ed4a..c3ee05e1e 100644
--- a/src/com/android/bluetooth/btservice/PhonePolicy.java
+++ b/src/com/android/bluetooth/btservice/PhonePolicy.java
@@ -733,7 +733,12 @@ class PhonePolicy {
int headsetConnectionPolicy = hsService.getConnectionPolicy(device);
if (headsetConnectionPolicy == BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
debugLog("autoConnectHeadset: Connecting HFP with " + device);
- hsService.connect(device);
+ if(ApmConstIntf.getLeAudioEnabled()) {
+ CallAudioIntf mCallAudio = CallAudioIntf.get();
+ mCallAudio.autoConnect(device);
+ } else {
+ hsService.connect(device);
+ }
} else {
debugLog("autoConnectHeadset: skipped auto-connect HFP with device " + device
+ " headsetConnectionPolicy " + headsetConnectionPolicy);