Fix bugs uncovered by HeadsetClientStateMachineTest
* State change broadcast should always happen after actual state transitions. Therefore, state change broadcast should only happen in enter() and exit() methods of states, except when no actual state transition is involved. Otherwise, there is a race condition between state change broadcast and actual state transition. If user of state machine sends message for new state indicated by the broadcast, the state machine may still be in previous state and hence result is undefined depending on timing condition. * This CL fixes this issue by moving all state change broadcasts to enter() and exit() methods of individual states and log previous state in exit() * Also, messages that are supposed to be executed in the next state should be sent using deferMessage() instead of sending message after transitionTo() is called * Remove some unused variables from HeadsetClientStateMachine * Unified HeadsetClientStateMachine.start()/stop() into setUp() and tearDown() methods in HeadsetClientStateMachineTest * Fixed testIncomingPriorityAccept to keep up with recent change: I6c5a7ee9eb4e10f5f649794546acde5ec4b297aa * Use explicit intent matcher instead of matching any intents for the above fixed test Bug: 68722902 Test: build, run unit tests Change-Id: Iccbaec9df0abfc9136e5b86b450151b13b45cfa7
Loading
Please register or sign in to comment