Fix Robolectric failures for new registerReceiver security design

- Security team add new interface to Context.registerReceiver() with a
third parameter.

- The new interface might have some issues in the test environment.

- Spy the registerReceiver() and unregisterReceiver() to avoid
unexpected issues.

Bug: 214938188
Test: manual test
make RunSettingsRoboTests
ROBOTEST_FILTER=WifiPrimarySwitchPreferenceControllerTest

Change-Id: I5bf9fc860a3de99145bc7535ba57cb514b403966
1 file changed