Check bluetooth key missing count in BluetoothKeyMissingReceiver

Bug: 388018781
Test: local build and tested. I didn't find a good way to add unit test for reflection
Flag: EXEMPT minor fix
Change-Id: I9cf6e0b3121114c6eca571dff5df3ea4115fbbf1
This commit is contained in:
Haijie Hong
2025-02-28 13:30:43 +08:00
parent 878fdc6fcd
commit ca69e6fddc
2 changed files with 9 additions and 0 deletions

View File

@@ -33,6 +33,7 @@ import androidx.core.app.NotificationCompat;
import com.android.settings.R;
import com.android.settings.flags.Flags;
import com.android.settingslib.bluetooth.BluetoothUtils;
/**
* BluetoothKeyMissingReceiver is a receiver for Bluetooth key missing error when reconnecting to a
@@ -57,6 +58,11 @@ public final class BluetoothKeyMissingReceiver extends BroadcastReceiver {
PowerManager powerManager = context.getSystemService(PowerManager.class);
if (TextUtils.equals(action, BluetoothDevice.ACTION_KEY_MISSING)) {
Log.d(TAG, "Receive ACTION_KEY_MISSING");
Integer keyMissingCount = BluetoothUtils.getKeyMissingCount(device);
if (keyMissingCount != null && keyMissingCount != 1) {
Log.d(TAG, "Key missing count is " + keyMissingCount + ", skip.");
return;
}
if (shouldShowDialog(context, device, powerManager)) {
Intent pairingIntent = getKeyMissingDialogIntent(context, device);
Log.d(TAG, "Show key missing dialog:" + device);