OSDN Git Service

Do not load xml metadata for unchanged packages in RegisteredServicesCache
authorNg Zhi An <zhin@google.com>
Thu, 24 Jan 2019 21:45:57 +0000 (13:45 -0800)
committerNg Zhi An <zhin@google.com>
Tue, 29 Jan 2019 20:36:09 +0000 (12:36 -0800)
commitdc66ef5ed383a889779adcd455826dcd1534ccf9
tree20ff51e522cd3c469eb9171c7f1b8101a204a6e0
parentf43f624efb18dd1d6c9100cf585437e7d6d9850c
Do not load xml metadata for unchanged packages in RegisteredServicesCache

RegisteredServicesCache caches services in an xml, so the system doesn't
have to scan all the apks. Whenever a package is changed
(add/remove/replaced), the broadcast receiver in RegisteredServicesCache
will refresh this cache by quering all matching services and reading
their
xml metadata. There is extra work done here, because only the changed
package
will have services added/removed.

The edge case is after a cache is invalidated, we want to query package
manager for everything, regardless of what changedUids is (we could
have arrived here if invalidateCache is called, and then a package
change event fires, before a getAllServices is called to rescan
everything).

Add a new test to verify that the optimization takes care of the case
when the cache is invalidated.

Bug: 117755076
Bug: 122912184
Test: atest RegisteredServicesCache
Test: dumpsys content # check sync adapters
Change-Id: I5c1f57108c4b67d24b198000d57216c63d35290a
core/java/android/content/pm/RegisteredServicesCache.java
core/tests/coretests/src/android/content/pm/RegisteredServicesCacheTest.java