Prune obsolete UsageStats data on upgrade.

When a database upgrade is performed for UsageStats, prune all
UsageStats data that belongs to packages that have been uninstalled.
This ensures that all data in UsageStats in R belongs to packages that
are currently installed or to those packages whose DONT_DELETE_DATA flag
was set when uninstalling.

Also remove the clean-up mapping step on boot. That was added as a
safety measure to ensure the mappings file is always updated. However,
with the addition of the prune job on package uninstalls and this CL,
that step is now unnecessary.

Bug: 143889121
Test: atest UsageStatsDatabase
Change-Id: Ib3d24dead4cd0e23145c15e7b1f88e2e20aadcaa
2 files changed