From c491216243de8af8d2f313c404a3e543fb249888 Mon Sep 17 00:00:00 2001 From: Patty Date: Wed, 26 May 2021 15:46:00 +0800 Subject: [PATCH] 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 --- .../settings/bluetooth/BluetoothPairingService.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/com/android/settings/bluetooth/BluetoothPairingService.java b/src/com/android/settings/bluetooth/BluetoothPairingService.java index 0bff721b8a9..47565d3f09a 100644 --- a/src/com/android/settings/bluetooth/BluetoothPairingService.java +++ b/src/com/android/settings/bluetooth/BluetoothPairingService.java @@ -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);