Filter preferred activities before committing to storage

When running CtsShortcutHostTestCases, package-restrictions.xml is
backed up and restored. When restoring the backup, preferred activities
are added to package-restrictions.xml without checking for duplicates.
This causes package-restrictions.xml to double in size each time
CtsShortcutHostTestCases is performing a backup and restore cycle.
Eventually the system will behave strangely, with lots of binder
allocation errors preventing apps from starting.

Bug: 144526220
Test: manual (monitor packages-restrictions.xml while running CtsShortcutHostTestCases)
Change-Id: Ie4367c749c5cc0e403c6d38f6b290064b1cff40e
1 file changed