Fix permission state missing when backup is restored.

The BackupAgent of an application may run before package post
installation, so the permission state must be ready by then. So
instead of calling onPackageInstalled() in post install, we can revert
to calling it in updateSettingsInternalLI() as in R (before
ag/13144022 which introduced the regression).

This changes the grant permissions etc to be done before package
post-installation, but this might be actually a correct change as
application code may expect permissions, and we are already doing it
like this in installExistingPackageAsUser() so this change is making
it consistent.

Fixes: 175932103
Test: manual
Test: Wipe and restore a backup and ensure Keep is no longer crashing.
Test: presubmit
Change-Id: Ie2e0dbd7a1a8454f9935527b9c303c26010ff592
1 file changed