Fix a leak in HasSystemFeatureCache.

Bug: 150037560

Make HasSystemFeatureQuery static so that it does not retain a handle
to ApplicationPackageManager.

Test: Boot with an instrumented image to verify that caching still works
as expected.  Took a heap profile to verify that there were no leaks in
the cache.

Change-Id: I2cd39a6dfab9cc1bf04bb7f55638a572213f04ce
This commit is contained in:
Lee Shombert
2020-02-22 13:24:02 -08:00
parent 81958ce9b4
commit 1f771846c5

View File

@@ -99,6 +99,7 @@ import android.util.Log;
import android.view.Display;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.Immutable;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.os.SomeArgs;
import com.android.internal.util.UserIcons;
@@ -612,7 +613,11 @@ public class ApplicationPackageManager extends PackageManager {
return hasSystemFeature(name, 0);
}
private class HasSystemFeatureQuery {
/**
* Identifies a single hasSystemFeature query.
*/
@Immutable
private static final class HasSystemFeatureQuery {
public final String name;
public final int version;
public HasSystemFeatureQuery(String n, int v) {