Add getPackageStates to replace forAllPackageStates
Rather than pre-optimize the filtering path, the FilteredSnapshot
now just returns a Map<String, PackageState>.
Any optimization can come in the form of a custom Map implementation
which caches on iteration, but that can be saved for when there's a
use case for that.
This leaves the old API intact for now due to a bulid system quirk
where the dependent CL can't be merged if the API in the prebuilt
doesn't exist.
Test: atest PackageManagerLocalSnapshotTest
For now a simple Map makes the API easier to use.
Bug: 246609797
Change-Id: Ifc68d4753290e2922672859b1a8a15b1ec0795cf
diff --git a/services/api/current.txt b/services/api/current.txt
index 834ed2f..d05431d 100644
--- a/services/api/current.txt
+++ b/services/api/current.txt
@@ -59,6 +59,7 @@
method public void close();
method public void forAllPackageStates(@NonNull java.util.function.Consumer<com.android.server.pm.pkg.PackageState>);
method @Nullable public com.android.server.pm.pkg.PackageState getPackageState(@NonNull String);
+ method @NonNull public java.util.Map<java.lang.String,com.android.server.pm.pkg.PackageState> getPackageStates();
}
public static interface PackageManagerLocal.UnfilteredSnapshot extends java.lang.AutoCloseable {