Fix issue #11217255: Setup Wizard ANR when adding new user profile from settings.

Two problems addressed here:

- If a call to startActivity() comes in on an activity that is finishing, we can
  end up putting the new activity in a stack that isn't actually in use any more
  (if the finishing activity is the last one on that stack).  This is a bad case,
  anyway, so if this happen the treat it as not being called on an existing
  activity and switch to NEW_TASK to find a task for it.

- There was a bug in handling PACKAGE_CHANGE broadcasts that would result in the
  app's processes being killed, even though the cleanup through the activities
  was done.  This could leave the activity stack in a bad state.  Fix this to
  correctly provide an app id for the changing package so that its processes are
  killed.

Change-Id: Iece04e0cf95025c3d30353d68bf3d14fd39d44c3
3 files changed