summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorKenny Guy <kennyguy@google.com>2014-07-17 15:15:52 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-07-17 00:09:54 +0000
commit78fd9d6b36b78abb57bf2a29e314202bdf26f480 (patch)
tree865a2f8acd3cf43a375349da515e1ebcea2d4b9f /services
parente702404c5a9d46765acb76f63ea6338d0a42b030 (diff)
parent2df1892f411de6fa93ba487e3c4d23a079b74fcb (diff)
downloadframeworks_base-78fd9d6b36b78abb57bf2a29e314202bdf26f480.zip
frameworks_base-78fd9d6b36b78abb57bf2a29e314202bdf26f480.tar.gz
frameworks_base-78fd9d6b36b78abb57bf2a29e314202bdf26f480.tar.bz2
Merge "Check for exported and category before starting activity." into lmp-dev
Diffstat (limited to 'services')
-rw-r--r--services/core/java/com/android/server/pm/LauncherAppsService.java30
1 files changed, 28 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/pm/LauncherAppsService.java b/services/core/java/com/android/server/pm/LauncherAppsService.java
index 65cb6c9..09cf392 100644
--- a/services/core/java/com/android/server/pm/LauncherAppsService.java
+++ b/services/core/java/com/android/server/pm/LauncherAppsService.java
@@ -269,13 +269,39 @@ public class LauncherAppsService extends SystemService {
Intent launchIntent = new Intent(Intent.ACTION_MAIN);
launchIntent.addCategory(Intent.CATEGORY_LAUNCHER);
- launchIntent.setComponent(component);
launchIntent.setSourceBounds(sourceBounds);
launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ launchIntent.setPackage(component.getPackageName());
long ident = Binder.clearCallingIdentity();
try {
- mContext.startActivityAsUser(launchIntent, opts, user);
+ IPackageManager pm = AppGlobals.getPackageManager();
+ ActivityInfo info = pm.getActivityInfo(component, 0, user.getIdentifier());
+ if (!info.exported) {
+ throw new SecurityException("Cannot launch non-exported components "
+ + component);
+ }
+
+ // Check that the component actually has Intent.CATEGORY_LAUCNCHER
+ // as calling startActivityAsUser ignores the category and just
+ // resolves based on the component if present.
+ List<ResolveInfo> apps = mPm.queryIntentActivitiesAsUser(launchIntent,
+ PackageManager.NO_CROSS_PROFILE, // We only want the apps for this user
+ user.getIdentifier());
+ final int size = apps.size();
+ for (int i = 0; i < size; ++i) {
+ ActivityInfo activityInfo = apps.get(i).activityInfo;
+ if (activityInfo.packageName.equals(component.getPackageName()) &&
+ activityInfo.name.equals(component.getClassName())) {
+ // Found an activity with category launcher that matches
+ // this component so ok to launch.
+ launchIntent.setComponent(component);
+ mContext.startActivityAsUser(launchIntent, opts, user);
+ return;
+ }
+ }
+ throw new SecurityException("Attempt to launch activity without "
+ + " category Intent.CATEGORY_LAUNCHER " + component);
} finally {
Binder.restoreCallingIdentity(ident);
}