Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 36de60dc authored by Ng Zhi An's avatar Ng Zhi An
Browse files

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.

This change changes RegisteredServicesCache to only get the service info of changed packages.

Bug: 117755076
Test: atest RegisteredServicesCache
Change-Id: I2d9e7980fcd651617e450ff12e1588601de4ef6c
parent 21ffe60b
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -475,6 +475,14 @@ public abstract class RegisteredServicesCache<V> {
        final List<ResolveInfo> resolveInfos = queryIntentServices(userId);
        for (ResolveInfo resolveInfo : resolveInfos) {
            try {
                // if this package is not one of those changedUids, we don't need to scan it,
                // since nothing in it changed, so save a call to parseServiceInfo, which
                // can cause a large amount of the package apk to be loaded into memory.
                // if this is the initial scan, changedUids will be null, and containsUid will
                // trivially return true, and will call parseServiceInfo
                if (!containsUid(changedUids, resolveInfo.serviceInfo.applicationInfo.uid)) {
                    continue;
                }
                ServiceInfo<V> info = parseServiceInfo(resolveInfo);
                if (info == null) {
                    Log.w(TAG, "Unable to load service info " + resolveInfo.toString());