Fix pairing dialog doesn't show the correct pairing key.

When the pairing dialog doesn't show in the foreground at the first time, the pairing key will display incorrectly.
This is caused by the intent doesn't contain the parameter BluetoothDevice.EXTRA_PAIRING_KEY.

Correct the pairing key by passing the pairing key to intent pairingDialogIntent.

Tag: #stability
Bug: 188614067
Test: make RunSettingsRoboTests ROBOTEST_FILTER=BluetoothPairingServiceTest
Change-Id: I3c91bf6ea51fa3fb77b4c4a5c17555606160603e
This commit is contained in:
Patty
2021-05-26 15:46:00 +08:00
parent f6d0845783
commit c491216243

View File

@@ -177,6 +177,15 @@ public final class BluetoothPairingService extends Service {
pairingDialogIntent.setClass(this, BluetoothPairingService.class);
pairingDialogIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, mDevice);
pairingDialogIntent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, type);
if (type == BluetoothDevice.PAIRING_VARIANT_PASSKEY_CONFIRMATION
|| type == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PASSKEY
|| type == BluetoothDevice.PAIRING_VARIANT_DISPLAY_PIN) {
int pairingKey = intent.getIntExtra(BluetoothDevice.EXTRA_PAIRING_KEY,
BluetoothDevice.ERROR);
pairingDialogIntent.putExtra(BluetoothDevice.EXTRA_PAIRING_KEY, pairingKey);
}
PendingIntent pairIntent = PendingIntent.getService(this, 0, pairingDialogIntent,
PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE);