Migrate permissions when leaving sharedUserId

- Retrieve the previous uid permission state and create a copy of it as
  the new app's uid state.
- Remove the app from the original shared user group. Other apps in the
  shared user group will perceive as if the original app is uninstalled.
- The new permission state is updated in updatePermissions() just like
  a normal package upgrade.

Test: atest CtsSharedUserMigrationTestCases
Bug: 179284822
Change-Id: I9d7c3b16959dd4b2c2684ddaf8bd223fb32c3c41
9 files changed