Fix Bluetooth pairing dialogue crash

When pairing passkey is invalid, onCreate() should return early to
prevent any dialog from displaying, which will then call onDestroy()
to destroy the activity. However mReceiver should be registered before
onDestroy() is called as onDestroy() will call unregisterReceiver(mReceiver)
that will throw an IllegalArgumentException when mReceiver was not registered.

This fix adds a flag that tracks whether mReceiver has been registered.
In addition, this fix fails the passkey confirmation request upon invalid
passkey.

Bug: 32577328
Test: Test with PTS TC_SERVER_SA_BI_01_C
Change-Id: Ifc047bad6bd99abca04404af9cd54d2034cd35aa
(cherry picked from commit 6f8e9eda2d9ed830d47971d93327792906db2dc1)
1 file changed