Check activity state before showing phone disambig dialog

- This is a monkey bug on Crespo that happens often. The
monkey is likely tapping on a favorite contact in the Phone
app, which is trying to either dial the contact or
show a disambiguation dialog if the contact has multiple
phone numbers. There's an IllegalStateException with trying
to commit the dialog fragment transaction because the
saved state has already been called.

- After a PhoneNumberInteraction is started, a CursorLoader
is started, and when that returns, potentially we try to
commit a FragmentTransaction (showing the DialogFragment).

At this point, the activity may be long gone, so we need to
know if the activity has saved state or not. Hence,
we add a new base activity class (TransactionSafeActivity)
that keeps track of this information for us.

- The PhoneNumberInteractionTests still rely on passing in
a context to PhoneNumberInteraction (in order to check
that the queries and subsequent activities are correct),
but we typecast the static methods the app uses to
create these PhoneNumberInteraction objects.

Bug: 5132436
Change-Id: Id9d887bd55235b07133568a38d4922dc7fce24a7
4 files changed