Add ECM appOp after UidState is created
This fixes a bug introduced in ag/22299389.
ECM is enabled for a package by an AppOp being added to it at install
time from InstallPackageHelper#updateSettingsInternalLI. This is
/before/ an AppOp tracker(AppOpsService.UidState) has been created for
the package.
That is created in InstallPackageHelper#handlePackagePostInstall which
will call through to AppOpsService#onPackageAdded.
updateSettingsInternalLI is called before handlePackagePostInstall.
In T and U, this worked fine. If setMode was called before UidState had
been created, it would automatically create it first here.
However, this code has now changed to no longer create the UidState.
This results in setMode silently failing and not setting the appOp to
ERRORED for ECM.
We also fix a different bug where installing the app with a new user on
a multi-user device would result in ECM being set back to errored for
all users.
Bug: 307324622
Test: Manually tested on device
Test: atest android.packageinstaller.install.cts
Change-Id: I68450e0d7ae06039fc7e41f6e9b2332f1491fb02
1 file changed