Loading android/app/src/com/android/bluetooth/btservice/PhonePolicy.java +28 −0 Original line number Diff line number Diff line Loading @@ -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"); } Loading Loading @@ -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); Loading Loading @@ -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) Loading Loading @@ -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) { Loading Loading
android/app/src/com/android/bluetooth/btservice/PhonePolicy.java +28 −0 Original line number Diff line number Diff line Loading @@ -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"); } Loading Loading @@ -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); Loading Loading @@ -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) Loading Loading @@ -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) { Loading