[Audiosharing] Block pairing during audio sharing
When a) there are two sinks in sharing b) there is at least one temp bond device connected Test: atest Flag: com.android.settingslib.flags.enable_temporary_bond_devices_ui Bug: 392004799 Change-Id: Id093b4c0b67bdc1db621e0241e79900abbd26c0f
This commit is contained in:
@@ -48,6 +48,7 @@ import com.android.settings.widget.GearPreference;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
import com.android.settingslib.flags.Flags;
|
||||
import com.android.settingslib.utils.ThreadUtils;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -93,6 +94,7 @@ public final class BluetoothDevicePreference extends GearPreference {
|
||||
private final int mType;
|
||||
|
||||
private AlertDialog mDisconnectDialog;
|
||||
@Nullable private AlertDialog mBlockPairingDialog;
|
||||
private String contentDescription = null;
|
||||
private boolean mHideSecondTarget = false;
|
||||
private boolean mIsCallbackRemoved = true;
|
||||
@@ -409,13 +411,24 @@ public final class BluetoothDevicePreference extends GearPreference {
|
||||
SettingsEnums.ACTION_SETTINGS_BLUETOOTH_CONNECT);
|
||||
mCachedDevice.connect();
|
||||
} else if (bondState == BluetoothDevice.BOND_NONE) {
|
||||
metricsFeatureProvider.action(context,
|
||||
SettingsEnums.ACTION_SETTINGS_BLUETOOTH_PAIR);
|
||||
if (!mCachedDevice.hasHumanReadableName()) {
|
||||
var unused = ThreadUtils.postOnBackgroundThread(() -> {
|
||||
if (Flags.enableTemporaryBondDevicesUi() && Utils.shouldBlockPairingInAudioSharing(
|
||||
mLocalBtManager)) {
|
||||
// TODO: collect metric
|
||||
context.getMainExecutor().execute(() ->
|
||||
mBlockPairingDialog =
|
||||
Utils.showBlockPairingDialog(context, mBlockPairingDialog,
|
||||
mLocalBtManager));
|
||||
return;
|
||||
}
|
||||
metricsFeatureProvider.action(context,
|
||||
SettingsEnums.ACTION_SETTINGS_BLUETOOTH_PAIR_DEVICES_WITHOUT_NAMES);
|
||||
}
|
||||
pair();
|
||||
SettingsEnums.ACTION_SETTINGS_BLUETOOTH_PAIR);
|
||||
if (!mCachedDevice.hasHumanReadableName()) {
|
||||
metricsFeatureProvider.action(context,
|
||||
SettingsEnums.ACTION_SETTINGS_BLUETOOTH_PAIR_DEVICES_WITHOUT_NAMES);
|
||||
}
|
||||
context.getMainExecutor().execute(() -> pair());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user