summaryrefslogtreecommitdiffstats
path: root/services/java/com/android/server/PackageManagerService.java
diff options
context:
space:
mode:
authorMihai Preda <preda@google.com>2009-05-13 10:13:48 +0200
committerMihai Preda <preda@google.com>2009-05-15 12:32:07 +0200
commiteae850cefe7e149f396c9e8ca1f34ec02b20a3f0 (patch)
treea4e19d75aeef5529a0a8084d513638890afac2cd /services/java/com/android/server/PackageManagerService.java
parent75986cf9bc57ef11ad70f36fb77fbbf5d63af6ec (diff)
downloadframeworks_base-eae850cefe7e149f396c9e8ca1f34ec02b20a3f0.zip
frameworks_base-eae850cefe7e149f396c9e8ca1f34ec02b20a3f0.tar.gz
frameworks_base-eae850cefe7e149f396c9e8ca1f34ec02b20a3f0.tar.bz2
Allow intent resolution to be constrained by package name.
Diffstat (limited to 'services/java/com/android/server/PackageManagerService.java')
-rw-r--r--services/java/com/android/server/PackageManagerService.java49
1 files changed, 45 insertions, 4 deletions
diff --git a/services/java/com/android/server/PackageManagerService.java b/services/java/com/android/server/PackageManagerService.java
index 079f363..4ce40b6 100644
--- a/services/java/com/android/server/PackageManagerService.java
+++ b/services/java/com/android/server/PackageManagerService.java
@@ -1203,6 +1203,33 @@ class PackageManagerService extends IPackageManager.Stub {
public ResolveInfo resolveIntent(Intent intent, String resolvedType,
int flags) {
List<ResolveInfo> query = queryIntentActivities(intent, resolvedType, flags);
+ return chooseBestActivity(intent, resolvedType, flags, query);
+ }
+
+ public ResolveInfo resolveIntentForPackage(Intent intent, String resolvedType,
+ int flags, String packageName) {
+ ComponentName comp = intent.getComponent();
+ if (comp != null) {
+ // if this is an explicit intent, it must have the same the packageName
+ if (packageName.equals(comp.getPackageName())) {
+ return resolveIntent(intent, resolvedType, flags);
+ }
+ return null;
+ } else {
+ List<ResolveInfo> query = null;
+ synchronized (mPackages) {
+ PackageParser.Package pkg = mPackages.get(packageName);
+ if (pkg != null) {
+ query = (List<ResolveInfo>) mActivities.
+ queryIntentForPackage(intent, resolvedType, flags, pkg.activities);
+ }
+ }
+ return chooseBestActivity(intent, resolvedType, flags, query);
+ }
+ }
+
+ private ResolveInfo chooseBestActivity(Intent intent, String resolvedType,
+ int flags, List<ResolveInfo> query) {
if (query != null) {
final int N = query.size();
if (N == 1) {
@@ -2853,6 +2880,22 @@ class PackageManagerService extends IPackageManager.Stub {
(flags&PackageManager.MATCH_DEFAULT_ONLY) != 0);
}
+ public List queryIntentForPackage(Intent intent, String resolvedType, int flags,
+ ArrayList<PackageParser.Activity> packageActivities) {
+ if (packageActivities == null) {
+ return null;
+ }
+ mFlags = flags;
+ final boolean defaultOnly = (flags&PackageManager.MATCH_DEFAULT_ONLY) != 0;
+ int N = packageActivities.size();
+ ArrayList<ArrayList<PackageParser.ActivityIntentInfo>> listCut =
+ new ArrayList<ArrayList<PackageParser.ActivityIntentInfo>>(N);
+ for (int i = 0; i < N; ++i) {
+ listCut.add(packageActivities.get(i).intents);
+ }
+ return super.queryIntentFromList(intent, resolvedType, defaultOnly, listCut);
+ }
+
public final void addActivity(PackageParser.Activity a, String type) {
mActivities.put(a.component, a);
if (SHOW_INFO || Config.LOGV) Log.v(
@@ -2860,8 +2903,7 @@ class PackageManagerService extends IPackageManager.Stub {
(a.info.nonLocalizedLabel != null ? a.info.nonLocalizedLabel : a.info.name) + ":");
if (SHOW_INFO || Config.LOGV) Log.v(TAG, " Class=" + a.info.name);
int NI = a.intents.size();
- int j;
- for (j=0; j<NI; j++) {
+ for (int j=0; j<NI; j++) {
PackageParser.ActivityIntentInfo intent = a.intents.get(j);
if (SHOW_INFO || Config.LOGV) {
Log.v(TAG, " IntentFilter:");
@@ -2881,8 +2923,7 @@ class PackageManagerService extends IPackageManager.Stub {
(a.info.nonLocalizedLabel != null ? a.info.nonLocalizedLabel : a.info.name) + ":");
if (SHOW_INFO || Config.LOGV) Log.v(TAG, " Class=" + a.info.name);
int NI = a.intents.size();
- int j;
- for (j=0; j<NI; j++) {
+ for (int j=0; j<NI; j++) {
PackageParser.ActivityIntentInfo intent = a.intents.get(j);
if (SHOW_INFO || Config.LOGV) {
Log.v(TAG, " IntentFilter:");