Refactor scanPackagesDirtyLI()

Just a small drop in a larger sea of refactorings. This time we
break up scanPackagesDirtyLI(). It's now in three sections:
  1) data setup
  2) package scan
  3) data commit

The goal is to not dramatically change the behaviour of the platform,
but, to provide some structure for future changes.

Ideally, only data commit would modify the running system. But,
all three still modify some part of the system. The scan
is the closest to being fully hermetic as only the PackageSetting
object is modified. A future task is to remove the dependency
of a singular PackageSetting object [with integer equality!] which
will finally make the scan independent.

The data setup and commit both modify the running system. We need to
continue to push on making the data setup section hermetic. Or, at
least track the allocations and be able to rewind if something goes
wrong.

The next refactoring will be rectify the difference between the
new scan method and scanPackageInternalLI.

Bug: 63539144
Test: bit FrameworksServicesTests:com.android.server.pm.
Change-Id: I59d401a81de2aed3309b99d663afdfa91316bc0a
5 files changed