Register PackageChangedReceiver to AppSearchManagerService.

The Receiver could receive ACTION_PACKAGE_FULLY_REMOVED and
ACTION_PACKAGE_DATA_CLEARED broadcast and clean the package data.

The CL has been reverted back since the receiver tries to write
to /data/system_ce/appSearch before user storage has been unlocked.
And this prevents encryption policy from being setup correctly.

Added check and only handle those actions if used is unlocked.

PatchSet 1 is the old version that has been reverted.

Bug: 145759910
Test: atest --rebuild-module-info CtsAppSearchHostTestCases
Test: atest StagedRollbackTest:com.android.tests.rollback.host.StagedRollbackTest#testRollbackDataPolicy -- --abi x86_64
Change-Id: I41dc0501ac227551ae9bf2c59f57accc66adc85f
2 files changed