Use post-execution state for lifecycle callback sequences

onActivityResult callback should always be executed before onResume.
If an activity is in the process of starting or creation, it can be
executed after onStart. If an activity was already resumed, then we
should pause it first, execute onActivityResult, then resume again.
So there are two valid pre-execute states - onStart and onPause.

For cases like the one described above this CL uses post-execution
state to identify valid pre-execute states and will try to use the
one that is closer to the current activity state during execution.

It also moves activity result and new intent callbacks into the same
transaction as the resumed state request, so that all changes can be
handled appropriately on the client side.

Bug: 72547861
Bug: 73348613
Test: TransactionExecutorTests
Test: ActivityLifecycleTests
Change-Id: I0af457d305c73a640040b8b7aee46dbbdfa6038f
9 files changed