BroadcastInterceptingContext: use passed-in broadcast Handler.
Currently, BroadcastInterceptingContext always runs broadcast receivers on the thread that called sendBroadcast. This means: 1. Receivers might run on the wrong thread, making the test less realistic. 2. If any receiver checks what thread it's running on, then either the check needs to be modified or deleted, or the test must call sendBroadcast on the thread that the receiver expects to run on. The latter is impossible when there is more than one receiver that needs to run on more than one thread. This CL adds a setUseRegisteredHandlers method that allows tests to say that they want each receiver to run on the Handler specified at registration time. This CL also enables the new mode for ConnectivityServiceTest, and resolves a TODO to re-enable a disabled thread check. The new mode cannot be enabled by default because it would break most of the tests. All the below tests pass except for the car bluetooth test testAutoConnectAdapterOff_returnsImmediately which was already failing. Bug: 173331190 Test: atest CarInputServiceTest BluetoothProfileDeviceManagerTest Test: atest NetworkPolicyManagerServiceTest Test: atest ConnectivityServiceTest Test: atest TetheringTest TetheringNotificationUpdaterTest Test: atest VersionedBroadcastListenerTest EntitlementManagerTest Test: atest TetheringConfigurationTest Test: atest CachedDeviceStateServiceTest Test: atest EmergencyAffordanceServiceTest Change-Id: I3303bb14516f07a55d82a16b59c111ab3f8b0389
Loading
Please register or sign in to comment