More multi-user methods in PM
pm can list installed packages by user now.
Bug: 6926465
Change-Id: I822311bfd6e7e2d6fb315fc484739fbf953c9bb6
diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java
index c4f1371..7870031 100644
--- a/core/java/android/app/ApplicationPackageManager.java
+++ b/core/java/android/app/ApplicationPackageManager.java
@@ -407,6 +407,12 @@
@SuppressWarnings("unchecked")
@Override
public List<PackageInfo> getInstalledPackages(int flags) {
+ return getInstalledPackages(flags, UserHandle.myUserId());
+ }
+
+ /** @hide */
+ @Override
+ public List<PackageInfo> getInstalledPackages(int flags, int userId) {
try {
final List<PackageInfo> packageInfos = new ArrayList<PackageInfo>();
PackageInfo lastItem = null;
@@ -414,7 +420,7 @@
do {
final String lastKey = lastItem != null ? lastItem.packageName : null;
- slice = mPM.getInstalledPackages(flags, lastKey);
+ slice = mPM.getInstalledPackages(flags, lastKey, userId);
lastItem = slice.populateList(packageInfos, PackageInfo.CREATOR);
} while (!slice.isLastSlice());
@@ -460,12 +466,19 @@
@Override
public List<ResolveInfo> queryIntentActivities(Intent intent,
int flags) {
+ return queryIntentActivitiesForUser(intent, flags, UserHandle.myUserId());
+ }
+
+ /** @hide Same as above but for a specific user */
+ @Override
+ public List<ResolveInfo> queryIntentActivitiesForUser(Intent intent,
+ int flags, int userId) {
try {
return mPM.queryIntentActivities(
intent,
intent.resolveTypeIfNeeded(mContext.getContentResolver()),
flags,
- UserHandle.myUserId());
+ userId);
} catch (RemoteException e) {
throw new RuntimeException("Package manager has died", e);
}
diff --git a/core/java/android/content/pm/IPackageManager.aidl b/core/java/android/content/pm/IPackageManager.aidl
index 0e1fe3e..b0ae5da 100644
--- a/core/java/android/content/pm/IPackageManager.aidl
+++ b/core/java/android/content/pm/IPackageManager.aidl
@@ -127,7 +127,7 @@
* limit that kicks in when flags are included that bloat up the data
* returned.
*/
- ParceledListSlice getInstalledPackages(int flags, in String lastRead);
+ ParceledListSlice getInstalledPackages(int flags, in String lastRead, in int userId);
/**
* This implements getInstalledApplications via a "last returned row"
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index e5ddfda..5399583 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -1469,6 +1469,45 @@
public abstract List<PackageInfo> getInstalledPackages(int flags);
/**
+ * Return a List of all packages that are installed on the device, for a specific user.
+ * Requesting a list of installed packages for another user
+ * will require the permission INTERACT_ACROSS_USERS_FULL.
+ * @param flags Additional option flags. Use any combination of
+ * {@link #GET_ACTIVITIES},
+ * {@link #GET_GIDS},
+ * {@link #GET_CONFIGURATIONS},
+ * {@link #GET_INSTRUMENTATION},
+ * {@link #GET_PERMISSIONS},
+ * {@link #GET_PROVIDERS},
+ * {@link #GET_RECEIVERS},
+ * {@link #GET_SERVICES},
+ * {@link #GET_SIGNATURES},
+ * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned.
+ * @param userId The user for whom the installed packages are to be listed
+ *
+ * @return A List of PackageInfo objects, one for each package that is
+ * installed on the device. In the unlikely case of there being no
+ * installed packages, an empty list is returned.
+ * If flag GET_UNINSTALLED_PACKAGES is set, a list of all
+ * applications including those deleted with DONT_DELETE_DATA
+ * (partially installed apps with data directory) will be returned.
+ *
+ * @see #GET_ACTIVITIES
+ * @see #GET_GIDS
+ * @see #GET_CONFIGURATIONS
+ * @see #GET_INSTRUMENTATION
+ * @see #GET_PERMISSIONS
+ * @see #GET_PROVIDERS
+ * @see #GET_RECEIVERS
+ * @see #GET_SERVICES
+ * @see #GET_SIGNATURES
+ * @see #GET_UNINSTALLED_PACKAGES
+ *
+ * @hide
+ */
+ public abstract List<PackageInfo> getInstalledPackages(int flags, int userId);
+
+ /**
* Check whether a particular package has been granted a particular
* permission.
*
@@ -1755,6 +1794,29 @@
int flags);
/**
+ * Retrieve all activities that can be performed for the given intent, for a specific user.
+ *
+ * @param intent The desired intent as per resolveActivity().
+ * @param flags Additional option flags. The most important is
+ * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only
+ * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}.
+ *
+ * @return A List<ResolveInfo> containing one entry for each matching
+ * Activity. These are ordered from best to worst match -- that
+ * is, the first item in the list is what is returned by
+ * {@link #resolveActivity}. If there are no matching activities, an empty
+ * list is returned.
+ *
+ * @see #MATCH_DEFAULT_ONLY
+ * @see #GET_INTENT_FILTERS
+ * @see #GET_RESOLVED_FILTER
+ * @hide
+ */
+ public abstract List<ResolveInfo> queryIntentActivitiesForUser(Intent intent,
+ int flags, int userId);
+
+
+ /**
* Retrieve a set of activities that should be presented to the user as
* similar options. This is like {@link #queryIntentActivities}, except it
* also allows you to supply a list of more explicit Intents that you would