diff options
author | Kenny Root <kroot@google.com> | 2011-04-15 17:50:10 -0700 |
---|---|---|
committer | Kenny Root <kroot@google.com> | 2011-04-19 09:57:54 -0700 |
commit | 0e2c0f37d98bb5539b0fe41865aaf1add0ff1bb3 (patch) | |
tree | f39c38afc819ce0d75513880cca7fefcdab6925c /cmds/pm | |
parent | 71a556f24e2b8d489bf81b22fab6fe5e99a9eae0 (diff) | |
download | frameworks_base-0e2c0f37d98bb5539b0fe41865aaf1add0ff1bb3.zip frameworks_base-0e2c0f37d98bb5539b0fe41865aaf1add0ff1bb3.tar.gz frameworks_base-0e2c0f37d98bb5539b0fe41865aaf1add0ff1bb3.tar.bz2 |
Break apart queries to getInstalled* API
To avoid blowing past the Binder IPC limit, change the
PackageManagerService to have a DB-like interaction where the client
tells the service the last "row" that it read.
The fact that we use a HashMap instead of a TreeMap makes this
problematic. For now we're just making a new ArrayList for the keys and
then sorting them for each call. This can make the API slower for callers
of this, but it's probably greatly overshadowed by the cost of the data
transfer itself.
Bug: 4064282
Change-Id: Ic370fd148d4c3813ae4f2daffa1a7c28d63d5a09
Diffstat (limited to 'cmds/pm')
-rw-r--r-- | cmds/pm/src/com/android/commands/pm/Pm.java | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java index 326e2c8..2ee512f 100644 --- a/cmds/pm/src/com/android/commands/pm/Pm.java +++ b/cmds/pm/src/com/android/commands/pm/Pm.java @@ -30,14 +30,15 @@ import android.content.pm.InstrumentationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageItemInfo; import android.content.pm.PackageManager; +import android.content.pm.ParceledListSlice; import android.content.pm.PermissionGroupInfo; import android.content.pm.PermissionInfo; import android.content.res.AssetManager; import android.content.res.Resources; import android.net.Uri; +import android.os.Parcel; import android.os.RemoteException; import android.os.ServiceManager; -import android.provider.Settings; import java.io.File; import java.lang.reflect.Field; @@ -223,7 +224,7 @@ public final class Pm { String filter = nextArg(); try { - List<PackageInfo> packages = mPm.getInstalledPackages(getFlags); + final List<PackageInfo> packages = getInstalledPackages(mPm, getFlags); int count = packages.size(); for (int p = 0 ; p < count ; p++) { @@ -247,6 +248,22 @@ public final class Pm { } } + @SuppressWarnings("unchecked") + private List<PackageInfo> getInstalledPackages(IPackageManager pm, int flags) + throws RemoteException { + final List<PackageInfo> packageInfos = new ArrayList<PackageInfo>(); + PackageInfo lastItem = null; + ParceledListSlice<PackageInfo> slice; + + do { + final String lastKey = lastItem != null ? lastItem.packageName : null; + slice = pm.getInstalledPackages(flags, lastKey); + lastItem = slice.populateList(packageInfos, PackageInfo.CREATOR); + } while (!slice.isLastSlice()); + + return packageInfos; + } + /** * Lists all of the features supported by the current device. * |