Build AppsFilter cache without holding packages lock

This change attempts to update the apps filter cache without holding the
package manager lock. It makes a local copy of the package settings and
gets the hashcode of each setting's package object. After building the
cache, it checks that all of the packges are the same as before the
cache was built. If there was a change, the cache is discarded and
rebuilt while holding the package lock.

Before change:
MakePackageManagerServiceReady took to complete: ~30ms
MakeDisplayManagerServiceReady took to complete: ~180ms

After change:
MakePackageManagerServiceReady took to complete: ~110ms
MakeDisplayManagerServiceReady took to complete: ~1ms

Test: atest AppEnumerationTests
Fixes: 167169644
Fixes: 161214066
Bug: 161250592
Bug: 162347084
This change reverts commit 112a64a6dd94903f56272bc5c0d11d32f7b4e2ed.

Change-Id: I910d73f4d3b4cb1fe54d667752d40445b1c56906
2 files changed