Loading android/app/src/com/android/bluetooth/btservice/PhonePolicy.java +24 −7 Original line number Diff line number Diff line Loading @@ -175,10 +175,7 @@ public class PhonePolicy implements AdapterService.BluetoothStateCallback { PhonePolicy(AdapterService service, ServiceFactory factory) { mAdapterService = service; mDatabaseManager = Objects.requireNonNull( mAdapterService.getDatabase(), "DatabaseManager cannot be null when PhonePolicy starts"); mDatabaseManager = Objects.requireNonNull(service.getDatabase()); mFactory = factory; mHandler = new PhonePolicyHandler(service.getMainLooper()); mAutoConnectProfilesSupported = Loading Loading @@ -285,6 +282,23 @@ public class PhonePolicy implements AdapterService.BluetoothStateCallback { return isLeAudioOnlyGroup(device); } // return true if device support Hearing Access Service and it has not been manually disabled private boolean shouldEnableHapByDefault(BluetoothDevice device, ParcelUuid[] uuids) { if (!Flags.enableHapByDefault()) { Log.i(TAG, "shouldDefaultToHap: Flag enableHapByDefault is disabled"); return false; } HapClientService hap = mFactory.getHapClientService(); if (hap == null) { Log.e(TAG, "shouldDefaultToHap: HapClient is null"); return false; } return Utils.arrayContains(uuids, BluetoothUuid.HAS) && hap.getConnectionPolicy(device) != BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; } // Policy implementation, all functions MUST be private @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) private void processInitProfilePriorities(BluetoothDevice device, ParcelUuid[] uuids) { Loading @@ -306,6 +320,7 @@ public class PhonePolicy implements AdapterService.BluetoothStateCallback { SystemProperties.getBoolean(BYPASS_LE_AUDIO_ALLOWLIST_PROPERTY, false); boolean isLeAudioOnly = isLeAudioOnlyDevice(device, uuids); boolean shouldEnableHapByDefault = shouldEnableHapByDefault(device, uuids); boolean isLeAudioProfileAllowed = (leAudioService != null) && Utils.arrayContains(uuids, BluetoothUuid.LE_AUDIO) Loading @@ -313,9 +328,9 @@ public class PhonePolicy implements AdapterService.BluetoothStateCallback { != BluetoothProfile.CONNECTION_POLICY_FORBIDDEN) && (mLeAudioEnabledByDefault || isDualModeAudioEnabled()) && (isBypassLeAudioAllowlist || shouldEnableHapByDefault || mAdapterService.isLeAudioAllowed(device) || isLeAudioOnly); debugLog( "mLeAudioEnabledByDefault: " + mLeAudioEnabledByDefault Loading @@ -328,7 +343,9 @@ public class PhonePolicy implements AdapterService.BluetoothStateCallback { + ", isLeAudioProfileAllowed: " + isLeAudioProfileAllowed + ", isLeAudioOnly: " + isLeAudioOnly); + isLeAudioOnly + ", shouldEnableHapByDefault: " + shouldEnableHapByDefault); // Set profile priorities only for the profiles discovered on the remote device. // This avoids needless auto-connect attempts to profiles non-existent on the remote device Loading Loading @@ -516,7 +533,7 @@ public class PhonePolicy implements AdapterService.BluetoothStateCallback { && (hearingAidService.getConnectionPolicy(device) == BluetoothProfile.CONNECTION_POLICY_UNKNOWN)) { if (isLeAudioProfileAllowed) { debugLog("LE Audio preferred over ASHA for device " + device); Log.i(TAG, "LE Audio preferred over ASHA for device " + device); mAdapterService .getDatabase() .setProfileConnectionPolicy( Loading flags/hap.aconfig +7 −1 Original line number Diff line number Diff line package: "com.android.bluetooth.flags" container: "com.android.btservices" flag { name: "enable_hap_by_default" namespace: "bluetooth" description: "On device that support HAP, enable it by default and disable ASHA" bug: "345826775" } flag { name: "settings_can_control_hap_preset" is_exported: true Loading @@ -8,4 +15,3 @@ flag { description: "Allow user to control the preset of hearing aid devices" bug: "306236481" } Loading
android/app/src/com/android/bluetooth/btservice/PhonePolicy.java +24 −7 Original line number Diff line number Diff line Loading @@ -175,10 +175,7 @@ public class PhonePolicy implements AdapterService.BluetoothStateCallback { PhonePolicy(AdapterService service, ServiceFactory factory) { mAdapterService = service; mDatabaseManager = Objects.requireNonNull( mAdapterService.getDatabase(), "DatabaseManager cannot be null when PhonePolicy starts"); mDatabaseManager = Objects.requireNonNull(service.getDatabase()); mFactory = factory; mHandler = new PhonePolicyHandler(service.getMainLooper()); mAutoConnectProfilesSupported = Loading Loading @@ -285,6 +282,23 @@ public class PhonePolicy implements AdapterService.BluetoothStateCallback { return isLeAudioOnlyGroup(device); } // return true if device support Hearing Access Service and it has not been manually disabled private boolean shouldEnableHapByDefault(BluetoothDevice device, ParcelUuid[] uuids) { if (!Flags.enableHapByDefault()) { Log.i(TAG, "shouldDefaultToHap: Flag enableHapByDefault is disabled"); return false; } HapClientService hap = mFactory.getHapClientService(); if (hap == null) { Log.e(TAG, "shouldDefaultToHap: HapClient is null"); return false; } return Utils.arrayContains(uuids, BluetoothUuid.HAS) && hap.getConnectionPolicy(device) != BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; } // Policy implementation, all functions MUST be private @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED) private void processInitProfilePriorities(BluetoothDevice device, ParcelUuid[] uuids) { Loading @@ -306,6 +320,7 @@ public class PhonePolicy implements AdapterService.BluetoothStateCallback { SystemProperties.getBoolean(BYPASS_LE_AUDIO_ALLOWLIST_PROPERTY, false); boolean isLeAudioOnly = isLeAudioOnlyDevice(device, uuids); boolean shouldEnableHapByDefault = shouldEnableHapByDefault(device, uuids); boolean isLeAudioProfileAllowed = (leAudioService != null) && Utils.arrayContains(uuids, BluetoothUuid.LE_AUDIO) Loading @@ -313,9 +328,9 @@ public class PhonePolicy implements AdapterService.BluetoothStateCallback { != BluetoothProfile.CONNECTION_POLICY_FORBIDDEN) && (mLeAudioEnabledByDefault || isDualModeAudioEnabled()) && (isBypassLeAudioAllowlist || shouldEnableHapByDefault || mAdapterService.isLeAudioAllowed(device) || isLeAudioOnly); debugLog( "mLeAudioEnabledByDefault: " + mLeAudioEnabledByDefault Loading @@ -328,7 +343,9 @@ public class PhonePolicy implements AdapterService.BluetoothStateCallback { + ", isLeAudioProfileAllowed: " + isLeAudioProfileAllowed + ", isLeAudioOnly: " + isLeAudioOnly); + isLeAudioOnly + ", shouldEnableHapByDefault: " + shouldEnableHapByDefault); // Set profile priorities only for the profiles discovered on the remote device. // This avoids needless auto-connect attempts to profiles non-existent on the remote device Loading Loading @@ -516,7 +533,7 @@ public class PhonePolicy implements AdapterService.BluetoothStateCallback { && (hearingAidService.getConnectionPolicy(device) == BluetoothProfile.CONNECTION_POLICY_UNKNOWN)) { if (isLeAudioProfileAllowed) { debugLog("LE Audio preferred over ASHA for device " + device); Log.i(TAG, "LE Audio preferred over ASHA for device " + device); mAdapterService .getDatabase() .setProfileConnectionPolicy( Loading
flags/hap.aconfig +7 −1 Original line number Diff line number Diff line package: "com.android.bluetooth.flags" container: "com.android.btservices" flag { name: "enable_hap_by_default" namespace: "bluetooth" description: "On device that support HAP, enable it by default and disable ASHA" bug: "345826775" } flag { name: "settings_can_control_hap_preset" is_exported: true Loading @@ -8,4 +15,3 @@ flag { description: "Allow user to control the preset of hearing aid devices" bug: "306236481" }