[Audiosharing] Enable audio sharing UI when preview option on.

Test: atest
Bug: 368401233
Flag: com.android.settingslib.flags.audio_sharing_developer_option
Change-Id: Idbc84e2c43f7361c58c440d1a7d7c78edd3c0521
This commit is contained in:
Yiyi Shen
2024-11-01 18:48:18 +08:00
parent 55cd3c67cb
commit 2fc788c35a
29 changed files with 445 additions and 379 deletions

View File

@@ -228,19 +228,19 @@ public abstract class BluetoothDevicePairingDetailBase extends DeviceListPrefere
final BluetoothDevice device = cachedDevice.getDevice();
if (device != null
&& mSelectedList.contains(device)) {
if (!BluetoothUtils.isAudioSharingEnabled()) {
if (BluetoothUtils.isAudioSharingUIAvailable(getContext())) {
if (bluetoothProfile == BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT
&& state == BluetoothAdapter.STATE_CONNECTED
&& device.equals(mJustBonded)
&& mShouldTriggerAudioSharingShareThenPairFlow) {
Log.d(getLogTag(),
"onProfileConnectionStateChanged, assistant profile connected");
dismissConnectingDialog();
mHandler.removeMessages(AUTO_DISMISS_MESSAGE_ID);
finishFragmentWithResultForAudioSharing(device);
}
} else {
finish();
return;
}
if (bluetoothProfile == BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT
&& state == BluetoothAdapter.STATE_CONNECTED
&& device.equals(mJustBonded)
&& mShouldTriggerAudioSharingShareThenPairFlow) {
Log.d(getLogTag(),
"onProfileConnectionStateChanged, assistant profile connected");
dismissConnectingDialog();
mHandler.removeMessages(AUTO_DISMISS_MESSAGE_ID);
finishFragmentWithResultForAudioSharing(device);
}
} else {
onDeviceDeleted(cachedDevice);
@@ -309,15 +309,17 @@ public abstract class BluetoothDevicePairingDetailBase extends DeviceListPrefere
@VisibleForTesting
boolean shouldTriggerAudioSharingShareThenPairFlow() {
if (!BluetoothUtils.isAudioSharingEnabled()) return false;
Activity activity = getActivity();
Intent intent = activity == null ? null : activity.getIntent();
Bundle args =
intent == null ? null :
intent.getBundleExtra(
SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS);
return args != null
&& args.getBoolean(EXTRA_PAIR_AND_JOIN_SHARING, false);
if (BluetoothUtils.isAudioSharingUIAvailable(getContext())) {
Activity activity = getActivity();
Intent intent = activity == null ? null : activity.getIntent();
Bundle args =
intent == null ? null :
intent.getBundleExtra(
SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS);
return args != null
&& args.getBoolean(EXTRA_PAIR_AND_JOIN_SHARING, false);
}
return false;
}
private void addOnMetadataChangedListener(@Nullable BluetoothDevice device) {