summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Himanshu Rawat <rwt@google.com> 2022-08-17 05:56:22 +0000
committer William Escande <wescande@google.com> 2022-08-25 01:24:23 +0000
commitc36de01a103fbc44b5552c10c03282aa76935fa6 (patch)
tree7eac465be072e58a6bdc125396a05c6f16b9e9e3
parentcb8ddeb8116fd866b934f17759f6cf81d09db56b (diff)
Attempt outgoing HID host reconnection
When phone initiates the reconnection, it does not attempt to reconnect HID profile. Bug: 242641683 Tag: #stability Test: Initiate reconnection from phone Merged-In: Icf3c869a6ab335cdee3b44592fcadfb444628d17 Change-Id: Icf3c869a6ab335cdee3b44592fcadfb444628d17
-rw-r--r--android/app/src/com/android/bluetooth/btservice/PhonePolicy.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/android/app/src/com/android/bluetooth/btservice/PhonePolicy.java b/android/app/src/com/android/bluetooth/btservice/PhonePolicy.java
index c81a5fbd69..163a3cdf7d 100644
--- a/android/app/src/com/android/bluetooth/btservice/PhonePolicy.java
+++ b/android/app/src/com/android/bluetooth/btservice/PhonePolicy.java
@@ -576,6 +576,7 @@ class PhonePolicy {
+ " attempting auto connection");
autoConnectHeadset(mostRecentlyActiveA2dpDevice);
autoConnectA2dp(mostRecentlyActiveA2dpDevice);
+ autoConnectHidHost(mostRecentlyActiveA2dpDevice);
} else {
debugLog("autoConnect() - BT is in quiet mode. Not initiating auto connections");
}
@@ -614,6 +615,23 @@ class PhonePolicy {
}
}
+ @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
+ private void autoConnectHidHost(BluetoothDevice device) {
+ final HidHostService hidHostService = mFactory.getHidHostService();
+ if (hidHostService == null) {
+ warnLog("autoConnectHidHost: service is null, failed to connect to " + device);
+ return;
+ }
+ int hidHostConnectionPolicy = hidHostService.getConnectionPolicy(device);
+ if (hidHostConnectionPolicy == BluetoothProfile.CONNECTION_POLICY_ALLOWED) {
+ debugLog("autoConnectHidHost: Connecting HID with " + device);
+ hidHostService.connect(device);
+ } else {
+ debugLog("autoConnectHidHost: skipped auto-connect HID with device " + device
+ + " connectionPolicy " + hidHostConnectionPolicy);
+ }
+ }
+
private void connectOtherProfile(BluetoothDevice device) {
if (mAdapterService.isQuietModeEnabled()) {
debugLog("connectOtherProfile: in quiet mode, skip connect other profile " + device);
@@ -657,6 +675,7 @@ class PhonePolicy {
VolumeControlService volumeControlService =
mFactory.getVolumeControlService();
BatteryService batteryService = mFactory.getBatteryService();
+ HidHostService hidHostService = mFactory.getHidHostService();
if (hsService != null) {
if (!mHeadsetRetrySet.contains(device) && (hsService.getConnectionPolicy(device)
@@ -730,6 +749,15 @@ class PhonePolicy {
batteryService.connect(device);
}
}
+ if (hidHostService != null) {
+ if ((hidHostService.getConnectionPolicy(device)
+ == BluetoothProfile.CONNECTION_POLICY_ALLOWED)
+ && (hidHostService.getConnectionState(device)
+ == BluetoothProfile.STATE_DISCONNECTED)) {
+ debugLog("Retrying connection to HID with device " + device);
+ hidHostService.connect(device);
+ }
+ }
}
private static void debugLog(String msg) {